import{o as e}from"./rolldown-runtime.DAXXjFlN.js";import{r as t}from"./emotion-is-prop-valid.esm.CygBv61C.js";import{c as n,t as r}from"./emotion-styled.browser.esm.DmHEQgFq.js";import{v as i}from"./StreamlitMarkdown.CwaSe4JX.js";import{g as a}from"./getColors.DvVOOCnR.js";import{n as o,t as s}from"./styled-components.BnwjjA8j.js";import{nn as c,rn as l,tn as u}from"./index.BfkDCGNp.js";import{t as d}from"./iconPosition.DWeCxQ7w.js";var f=e(t(),1);function p(e,t){switch(e){case o.XSMALL:return{padding:`${t.spacing.twoXS} ${t.spacing.sm}`,fontSize:t.fontSizes.sm};case o.SMALL:return{padding:`${t.spacing.twoXS} ${t.spacing.md}`};case o.LARGE:return{padding:`${t.spacing.md} ${t.spacing.md}`};default:return{padding:`${t.spacing.xs} ${t.spacing.md}`}}}var m=r(`a`,{target:`evo6qzw0`})(({containerWidth:e,size:t,theme:n})=>({display:`inline-flex`,alignItems:`center`,justifyContent:`center`,fontWeight:n.fontWeights.normal,padding:`${n.spacing.xs} ${n.spacing.md}`,borderRadius:n.radii.button,minHeight:n.sizes.minElementHeight,margin:0,lineHeight:n.lineHeights.base,color:n.colors.primary,textDecoration:`none`,width:e?`100%`:`auto`,userSelect:`none`,"&:visited":{color:n.colors.primary},"&:focus":{outline:`none`},"&:focus-visible":{boxShadow:n.shadows.focusRing},"&:hover":{textDecoration:`none`},"&:active":{textDecoration:`none`},...p(t,n)})),h=r(m,{target:`evo6qzw1`})(({theme:e})=>({backgroundColor:e.colors.primary,color:e.colors.white,border:`${e.sizes.borderWidth} solid ${e.colors.primary}`,"&:hover, &:focus-visible":{backgroundColor:a(e.colors.primary,.15),borderColor:a(e.colors.primary,.15)},"&:active":{backgroundColor:e.colors.primary,borderColor:a(e.colors.primary,.15)},"&:visited:not(:active)":{color:e.colors.white},"&[disabled], &[disabled]:hover, &[disabled]:active, &[disabled]:visited":{borderColor:e.colors.borderColor,backgroundColor:e.colors.transparent,color:e.colors.fadedText40,cursor:`not-allowed`}})),g=r(m,{target:`evo6qzw2`})(({theme:e})=>({backgroundColor:e.colors.lightenedBg05,color:e.colors.bodyText,border:`${e.sizes.borderWidth} solid ${e.colors.borderColor}`,"&:visited":{color:e.colors.bodyText},"&:hover, &:focus-visible":{backgroundColor:e.colors.darkenedBgMix15},"&:active":{backgroundColor:e.colors.darkenedBgMix25},"&[disabled], &[disabled]:hover, &[disabled]:active":{borderColor:e.colors.borderColor,backgroundColor:e.colors.transparent,color:e.colors.fadedText40,cursor:`not-allowed`}})),_=r(m,{target:`evo6qzw3`})(({theme:e})=>({padding:e.spacing.none,backgroundColor:e.colors.transparent,color:e.colors.bodyText,border:`none`,"&:visited":{color:e.colors.bodyText},"&:hover, &:focus-visible":{color:e.colors.primary},"&:hover:not([disabled]), &:focus-visible:not([disabled])":{"span.stMarkdownColoredText":{color:`inherit !important`}},"&:active":{color:a(e.colors.primary,.25)},"&[disabled], &[disabled]:hover, &[disabled]:active":{backgroundColor:e.colors.transparent,color:e.colors.fadedText40,cursor:`not-allowed`}})),v=(0,f.forwardRef)(function({kind:e,size:t,disabled:r,children:i,autoFocus:a,href:c,rel:l,target:u,onClick:d},f){let p=h;return e===s.SECONDARY?p=g:e===s.TERTIARY&&(p=_),n(p,{ref:f,kind:e,size:t||o.MEDIUM,containerWidth:!0,disabled:r||!1,autoFocus:a||!1,href:c,target:u,rel:l,onClick:d,tabIndex:r?-1:0,"data-testid":`stBaseLinkButton-${e}`,children:i})});v.displayName=`BaseLinkButton`;var y=(0,f.memo)(v);function b(e){let{element:t,widgetMgr:r,fragmentId:a}=e,p=t.shortcut||void 0,m=s.SECONDARY;t.type===`primary`?m=s.PRIMARY:t.type===`tertiary`&&(m=s.TERTIARY);let h=(0,f.useRef)(null),g=(0,f.useCallback)(()=>{t.disabled||h.current?.click()},[t.disabled]),_=(0,f.useCallback)(e=>{if(t.disabled){e.preventDefault();return}!t.ignoreRerun&&t.id&&r.setTriggerValue(t,{fromUi:!0},a)},[t,a,r]);return c({shortcut:p,disabled:t.disabled,onActivate:g}),n(i,{className:`stLinkButton`,"data-testid":`stLinkButton`,children:n(l,{help:t.help,containerWidth:!0,children:n(y,{ref:h,kind:m,size:o.SMALL,disabled:t.disabled,onClick:_,href:t.url,target:`_blank`,rel:`noreferrer`,"aria-disabled":t.disabled,children:n(u,{icon:t.icon,iconPosition:d(t.iconPosition),label:t.label,shortcut:p})})})})}var x=(0,f.memo)(b);export{x as default};