import{n as u,r as o,y as w,z as y,j as i,D as h,aE as v,aR as n,aS as m,aT as k,F as z,G as R}from"./index.qnLB2_zl.js";const L=u("button",{target:"e1rpgzpk0"})(({theme:t})=>({fontSize:t.fontSizes.sm,lineHeight:t.lineHeights.base,color:t.colors.fadedText60,backgroundColor:t.colors.transparent,fontFamily:"inherit",margin:t.spacing.none,border:"none",boxShadow:"none",padding:t.spacing.none,"&:hover, &:active, &:focus":{border:"none",outline:"none",boxShadow:"none"},"&:hover":{color:t.colors.primary}})),B=u("div",{target:"e1rpgzpk1"})(({theme:t})=>({display:"flex",flexDirection:"row",gap:t.spacing.lg,"> span":{marginTop:t.spacing.twoXS}})),C=u("div",{target:"e1rpgzpk3"})(({theme:t})=>({display:"flex",flexDirection:"column",gap:t.spacing.sm,alignItems:"start",justifyContent:"center",overflow:"hidden",minHeight:"100%",fontSize:t.fontSizes.sm,lineHeight:t.lineHeights.base,div:{display:"inline-flex"}}));function E(t){const s=R(t);return{Body:{props:{"data-testid":"stToast",className:"stToast"},style:{display:"flex",flexDirection:"row",gap:t.spacing.md,width:t.sizes.toastWidth,marginTop:t.spacing.sm,borderTopLeftRadius:t.radii.default,borderTopRightRadius:t.radii.default,borderBottomLeftRadius:t.radii.default,borderBottomRightRadius:t.radii.default,paddingTop:t.spacing.lg,paddingBottom:t.spacing.lg,paddingLeft:t.spacing.twoXL,paddingRight:t.spacing.twoXL,backgroundColor:s?t.colors.gray10:t.colors.gray90,color:t.colors.bodyText,boxShadow:s?"0px 4px 16px rgba(0, 0, 0, 0.16)":"0px 4px 16px rgba(0, 0, 0, 0.7)"}},CloseIcon:{style:{color:t.colors.fadedText40,width:t.fontSizes.lg,height:t.fontSizes.lg,marginRight:`calc(-1 * ${t.spacing.lg} / 2)`,":hover":{color:t.colors.bodyText}}}}}function D(t){if(t.length>104){let a=t.replace(/^(.{104}[^\s]*).*/,"$1");return a.length>104&&(a=a.substring(0,104).split(" ").slice(0,-1).join(" ")),a.trim()}return t}function H({body:t,icon:s,width:a}){const r=w(),d=D(t),c=t!==d,[e,b]=o.useState(!c),[f,S]=o.useState(0),x=o.useCallback(()=>{b(!e)},[e]),l=o.useMemo(()=>E(r),[r]),g=o.useMemo(()=>y(B,{expanded:e,children:[s&&i(h,{iconValue:s,size:"xl",testid:"stToastDynamicIcon"}),y(C,{children:[i(v,{source:e?t:d,allowHTML:!1,isToast:!0}),c&&i(L,{"data-testid":"stToastViewButton",onClick:x,children:e?"view less":"view more"})]})]}),[c,e,t,s,d,x]);o.useEffect(()=>{if(r.inSidebar)return;const p=n.info(g,{overrides:{...l}});return S(p),()=>{n.update(p,{overrides:{Body:{style:{transitionDuration:0}}}}),n.clear(p)}},[]),o.useEffect(()=>{n.update(f,{children:g,overrides:{...l}})},[f,g,l]);const T=i(k,{kind:m.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.",width:a});return i(z,{children:r.inSidebar&&T})}const M=o.memo(H);export{M as default};
