import{A as b,aw as u,ax as e,b as a,ay as l,c as t,az as C,aA as x,aB as L,aC as S}from"./index.BdH_oWMm.js";import{m as w}from"./iconPosition.BmsruyBM.js";function R(o,r){switch(o){case e.XSMALL:return{padding:`${r.spacing.twoXS} ${r.spacing.sm}`,fontSize:r.fontSizes.sm};case e.SMALL:return{padding:`${r.spacing.twoXS} ${r.spacing.md}`};case e.LARGE:return{padding:`${r.spacing.md} ${r.spacing.md}`};default:return{padding:`${r.spacing.xs} ${r.spacing.md}`}}}const y=b("a",{target:"evo6qzw0"})(({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=b(y,{target:"evo6qzw1"})(({theme:o})=>({backgroundColor:o.colors.primary,color:o.colors.white,border:`${o.sizes.borderWidth} solid ${o.colors.primary}`,"&:hover, &:focus-visible":{backgroundColor:u(o.colors.primary,.15),borderColor:u(o.colors.primary,.15)},"&:active":{backgroundColor:o.colors.primary,borderColor:u(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"}})),$=b(y,{target:"evo6qzw2"})(({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=b(y,{target:"evo6qzw3"})(({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:u(o.colors.primary,.25)},"&[disabled], &[disabled]:hover, &[disabled]:active":{backgroundColor:o.colors.transparent,color:o.colors.fadedText40,cursor:"not-allowed"}})),k=a.forwardRef(function({kind:r,size:i,disabled:n,children:d,autoFocus:s,href:c,rel:g,target:p,onClick:f},B){let v=T;return r===l.SECONDARY?v=$:r===l.TERTIARY&&(v=z),t(v,{ref:B,kind:r,size:i||e.MEDIUM,containerWidth:!0,disabled:n||!1,autoFocus:s||!1,href:c,target:p,rel:g,onClick:f,tabIndex:n?-1:0,"data-testid":`stBaseLinkButton-${r}`,children:d})});k.displayName="BaseLinkButton";const A=a.memo(k);function M(o){const{element:r,widgetMgr:i,fragmentId:n}=o,d=r.shortcut||void 0;let s=l.SECONDARY;r.type==="primary"?s=l.PRIMARY:r.type==="tertiary"&&(s=l.TERTIARY);const c=a.useRef(null),g=a.useCallback(()=>{r.disabled||c.current?.click()},[r.disabled]),p=a.useCallback(f=>{if(r.disabled){f.preventDefault();return}!r.ignoreRerun&&r.id&&i.setTriggerValue(r,{fromUi:!0},n)},[r,n,i]);return C({shortcut:d,disabled:r.disabled,onActivate:g}),t(S,{className:"stLinkButton","data-testid":"stLinkButton",children:t(x,{help:r.help,containerWidth:!0,children:t(A,{ref:c,kind:s,size:e.SMALL,disabled:r.disabled,onClick:p,href:r.url,target:"_blank",rel:"noreferrer","aria-disabled":r.disabled,children:t(L,{icon:r.icon,iconPosition:w(r.iconPosition),label:r.label,shortcut:d})})})})}const I=a.memo(M);export{I as default};
