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