import{Ja as e,Nr as t,Qa as n,Tn as r,Ya as i,Zt as a,cr as o,fr as s,io as c,mn as l,p as u,qa as d,vr as f,za as p}from"./index.dkY5s53S.js";var m=c(n(),1),h=f(`button`,{target:`e1a81sb30`})(({theme:e})=>({fontSize:e.fontSizes.sm,lineHeight:e.lineHeights.base,color:e.colors.fadedText60,backgroundColor:e.colors.transparent,fontFamily:`inherit`,margin:e.spacing.none,border:`none`,boxShadow:`none`,padding:e.spacing.none,"&:hover, &:active, &:focus":{border:`none`,outline:`none`,boxShadow:`none`},"&:hover":{color:e.colors.primary}})),g=f(`div`,{target:`e1a81sb31`})(({theme:e})=>({display:`flex`,flexDirection:`row`,gap:e.spacing.lg,"> span":{marginTop:e.spacing.twoXS}})),_=f(`div`,{target:`e1a81sb32`})(({theme:e})=>({display:`flex`,flexDirection:`column`,gap:e.spacing.sm,alignItems:`start`,justifyContent:`center`,overflow:`hidden`,minHeight:`100%`,fontSize:e.fontSizes.sm,lineHeight:e.lineHeights.base,div:{display:`inline-flex`}}));function v(e){let n=t(e);return{Body:{props:{"data-testid":`stToast`,className:`stToast`},style:{display:`flex`,flexDirection:`row`,gap:e.spacing.md,width:e.sizes.toastWidth,marginTop:e.spacing.sm,borderTopLeftRadius:e.radii.default,borderTopRightRadius:e.radii.default,borderBottomLeftRadius:e.radii.default,borderBottomRightRadius:e.radii.default,paddingTop:e.spacing.lg,paddingBottom:e.spacing.lg,paddingLeft:e.spacing.twoXL,paddingRight:e.spacing.twoXL,backgroundColor:e.colors.bgColor,filter:n?`brightness(0.98)`:`brightness(1.2)`,color:e.colors.bodyText,boxShadow:e.shadows.popover}},CloseIcon:{style:{color:e.colors.fadedText40,width:e.fontSizes.lg,height:e.fontSizes.lg,marginRight:`calc(-1 * ${e.spacing.lg} / 2)`,":hover":{color:e.colors.bodyText}}}}}function y(e){if(e.length>104){let t=e.replace(/^(.{104}[^\s]*).*/,`$1`);return t.length>104&&(t=t.substring(0,104).split(` `).slice(0,-1).join(` `)),t.trim()}return e}function b({element:t}){let{body:n,icon:c,duration:f}=t,b=o(),x=y(n),S=n!==x,[C,w]=(0,m.useState)(!S),T=(0,m.useRef)(null),E=(0,m.useCallback)(()=>{w(e=>!e)},[]),D=(0,m.useMemo)(()=>v(b),[b]),O=(0,m.useMemo)(()=>i(g,{expanded:C,children:[c&&e(s,{iconValue:c,size:`xl`,testid:`stToastDynamicIcon`}),i(_,{children:[e(l,{source:C?n:x,allowHTML:!1,isToast:!0}),S&&e(h,{"data-testid":`stToastViewButton`,onClick:E,children:C?`view less`:`view more`})]})]}),[S,C,n,c,x,E]);(0,m.useEffect)(()=>{if(b.inSidebar)return;let e=p(f)?f===0?0:f*1e3:4e3,t=u.info(O,{overrides:{...D},autoHideDuration:e});return T.current=t,()=>{u.update(t,{overrides:{Body:{style:{display:`none`}}}}),u.clear(t),T.current=null}},[]),(0,m.useEffect)(()=>{T.current!==null&&u.update(T.current,{children:O,overrides:{...D}})},[O,D]);let k=e(a,{kind:r.ERROR,body:"Streamlit API Error: `st.toast` cannot be called directly on the sidebar with `st.sidebar.toast`. See our `st.toast` API [docs](https://docs.streamlit.io/develop/api-reference/status/st.toast) for more information."});return e(d,{children:b.inSidebar&&k})}var x=(0,m.memo)(b);export{x as default,y as shortenMessage};