import{z as c,ah as e,c as t,r as n,B as l,j as a,u as C,a as x,D as L,d as S}from"./index.Drusyo5m.js";import{m as $}from"./iconPosition.B4EEXI3E.js";function R(o,r){switch(o){case t.XSMALL:return{padding:`${r.spacing.twoXS} ${r.spacing.sm}`,fontSize:r.fontSizes.sm};case t.SMALL:return{padding:`${r.spacing.twoXS} ${r.spacing.md}`};case t.LARGE:return{padding:`${r.spacing.md} ${r.spacing.md}`};default:return{padding:`${r.spacing.xs} ${r.spacing.md}`}}}const f=c("a",{target:"e1hofpsd0"})(({containerWidth:o,size:r,theme:i})=>({display:"inline-flex",alignItems:"center",justifyContent:"center",fontWeight:i.fontWeights.normal,padding:`${i.spacing.xs} ${i.spacing.md}`,borderRadius:i.radii.button,minHeight:i.sizes.minElementHeight,margin:0,lineHeight:i.lineHeights.base,color:i.colors.primary,textDecoration:"none",width:o?"100%":"auto",userSelect:"none","&:visited":{color:i.colors.primary},"&:focus":{outline:"none"},"&:focus-visible":{boxShadow:i.shadows.focusRing},"&:hover":{textDecoration:"none"},"&:active":{textDecoration:"none"},...R(r,i)})),T=c(f,{target:"e1hofpsd1"})(({theme:o})=>({backgroundColor:o.colors.primary,color:o.colors.white,border:`${o.sizes.borderWidth} solid ${o.colors.primary}`,"&:hover, &:focus-visible":{backgroundColor:e(o.colors.primary,.15),borderColor:e(o.colors.primary,.15)},"&:active":{backgroundColor:o.colors.primary,borderColor:e(o.colors.primary,.15)},"&:visited:not(:active)":{color:o.colors.white},"&[disabled], &[disabled]:hover, &[disabled]:active, &[disabled]:visited":{borderColor:o.colors.borderColor,backgroundColor:o.colors.transparent,color:o.colors.fadedText40,cursor:"not-allowed"}})),w=c(f,{target:"e1hofpsd2"})(({theme:o})=>({backgroundColor:o.colors.lightenedBg05,color:o.colors.bodyText,border:`${o.sizes.borderWidth} solid ${o.colors.borderColor}`,"&:visited":{color:o.colors.bodyText},"&:hover, &:focus-visible":{backgroundColor:o.colors.darkenedBgMix15},"&:active":{backgroundColor:o.colors.darkenedBgMix25},"&[disabled], &[disabled]:hover, &[disabled]:active":{borderColor:o.colors.borderColor,backgroundColor:o.colors.transparent,color:o.colors.fadedText40,cursor:"not-allowed"}})),z=c(f,{target:"e1hofpsd3"})(({theme:o})=>({padding:o.spacing.none,backgroundColor:o.colors.transparent,color:o.colors.bodyText,border:"none","&:visited":{color:o.colors.bodyText},"&:hover, &:focus-visible":{color:o.colors.primary},"&:hover:not([disabled]), &:focus-visible:not([disabled])":{"span.stMarkdownColoredText":{color:"inherit !important"}},"&:active":{color:e(o.colors.primary,.25)},"&[disabled], &[disabled]:hover, &[disabled]:active":{backgroundColor:o.colors.transparent,color:o.colors.fadedText40,cursor:"not-allowed"}})),y=n.forwardRef(function({kind:r,size:i,disabled:s,children:d,autoFocus:u,href:b,rel:p,target:k,onClick:B},v){let g=T;return r===l.SECONDARY?g=w:r===l.TERTIARY&&(g=z),a(g,{ref:v,kind:r,size:i||t.MEDIUM,containerWidth:!0,disabled:s||!1,autoFocus:u||!1,href:b,target:k,rel:p,onClick:B,tabIndex:s?-1:0,"data-testid":`stBaseLinkButton-${r}`,children:d})});y.displayName="BaseLinkButton";const A=n.memo(y);function D(o){const{element:r}=o,i=r.shortcut?r.shortcut:void 0;let s=l.SECONDARY;r.type==="primary"?s=l.PRIMARY:r.type==="tertiary"&&(s=l.TERTIARY);const d=n.useRef(null),u=n.useCallback(()=>{r.disabled||d.current?.click()},[r.disabled]),b=n.useCallback(p=>{r.disabled&&p.preventDefault()},[r.disabled]);return C({shortcut:i,disabled:r.disabled,onActivate:u}),a(S,{className:"stLinkButton","data-testid":"stLinkButton",children:a(x,{help:r.help,containerWidth:!0,children:a(A,{ref:d,kind:s,size:t.SMALL,disabled:r.disabled,onClick:b,href:r.url,target:"_blank",rel:"noreferrer","aria-disabled":r.disabled,children:a(L,{icon:r.icon,iconPosition:$(r.iconPosition),label:r.label,shortcut:i})})})})}const I=n.memo(D);export{I as default};
