import{o as e}from"./rolldown-runtime.C0FnF6B9.js";import{r as t}from"./emotion-is-prop-valid.esm.CuYlOKOk.js";import{a as n,i as r,t as i}from"./emotion-styled.browser.esm.BYv_Qzcq.js";import{r as a}from"./StreamlitMarkdown.BYA62LKI.js";import{t as o}from"./DynamicIcon.qdIiJ9dI.js";import{t as s}from"./useEmotionTheme.Dmt_qJ4x.js";import{t as c}from"./Tooltip.CcubhKj6.js";import{t as l}from"./BaseButtonTooltip.B83DZSNb.js";import{t as u}from"./NavigationContext.4T7w2rIe.js";import{t as d}from"./iconPosition.DwITqWdC.js";var f=e(t(),1),p=i(`div`,{target:`evng2kd0`})({display:`flex`,flexDirection:`column`,width:`100%`}),m=i(`a`,{target:`evng2kd1`})(({disabled:e,isCurrentPage:t,theme:n})=>({textDecoration:`none`,width:`100%`,display:`flex`,flexDirection:`row`,alignItems:`center`,justifyContent:`flex-start`,gap:n.spacing.sm,borderRadius:n.radii.default,paddingLeft:n.spacing.sm,paddingRight:n.spacing.sm,marginTop:n.spacing.threeXS,marginBottom:n.spacing.threeXS,lineHeight:n.lineHeights.menuItem,backgroundColor:t?n.colors.darkenedBgMix15:`transparent`,"&:hover":{backgroundColor:t?n.colors.darkenedBgMix25:n.colors.darkenedBgMix15},"&:active,&:visited,&:hover":{textDecoration:`none`},"&:focus":{outline:`none`},"&:focus-visible":{backgroundColor:n.colors.darkenedBgMix15},"@media print":{paddingLeft:n.spacing.none},...e?{borderColor:n.colors.borderColor,backgroundColor:n.colors.transparent,color:n.colors.fadedText40,cursor:`not-allowed`,"&:hover":{color:n.colors.fadedText40,backgroundColor:n.colors.transparent}}:{}})),h=i(`span`,{target:`evng2kd2`})(({disabled:e,theme:t})=>({color:t.colors.bodyText,overflow:`hidden`,whiteSpace:`nowrap`,textOverflow:`ellipsis`,display:`table-cell`,...e?{borderColor:t.colors.borderColor,backgroundColor:t.colors.transparent,color:t.colors.fadedText40,cursor:`not-allowed`}:{}}));function g(e){let t=e.page;if(e.queryString){if(e.external)try{let n=new URL(e.page);new URLSearchParams(e.queryString).forEach((e,t)=>n.searchParams.append(t,e)),t=n.toString()}catch{let[n,r]=t.split(`#`);t=n+(n.includes(`?`)?`&`:`?`)+e.queryString+(r?`#`+r:``)}else t+=(t.includes(`?`)?`&`:`?`)+e.queryString}return t}function _(e){let{onPageChange:t,currentPageScriptHash:i}=(0,f.useContext)(u),{colors:_}=s(),{disabled:v,element:y}=e,b=i===y.pageScriptHash,x=e=>{y.external?v&&e.preventDefault():(e.preventDefault(),v||t(y.pageScriptHash,y.queryString))},S=d(y.iconPosition),C=g(y);return r(`div`,{className:`stPageLink`,"data-testid":`stPageLink`,children:r(l,{help:y.help,placement:c.TOP_RIGHT,containerWidth:!0,children:r(p,{children:n(m,{"data-testid":`stPageLink-NavLink`,disabled:v,isCurrentPage:b,href:C,target:y.external?`_blank`:``,rel:`noreferrer`,onClick:x,children:[y.icon&&S===`left`&&r(o,{size:`base`,color:v?_.fadedText40:_.bodyText,iconValue:y.icon}),r(h,{disabled:v,children:r(a,{source:y.label,allowHTML:!1,isLabel:!0,boldLabel:b,disableLinks:!0})}),y.icon&&S===`right`&&r(o,{size:`base`,color:v?_.fadedText40:_.bodyText,iconValue:y.icon})]})})})})}var v=(0,f.memo)(_);export{g as buildHref,v as default};