teodor-new-chat-ui 4.3.498 → 4.3.499

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -15289,7 +15289,7 @@ const Ml = $g(function({
15289
15289
  S == null || S(n);
15290
15290
  }, [S, n]), mt = !_ && $, At = ie(() => {
15291
15291
  mt && X((je) => je === "expanded" ? "preview" : "expanded");
15292
- }, [mt]), Et = _ || $ ? "expanded" : V, en = ie(() => {
15292
+ }, [mt]), Et = _ ? "expanded" : V, en = ie(() => {
15293
15293
  const Xe = te(q ? "h-3 w-3" : "h-4 w-4", "opacity-60 flex-shrink-0", xe);
15294
15294
  switch (Y) {
15295
15295
  case "user":
package/dist/index.umd.js CHANGED
@@ -127,5 +127,5 @@ ${t}</tr>
127
127
  `+(p.tokens?this.parseInline(p.tokens):p.text);r+=n?this.renderer.paragraph(m):m;continue}default:{const A='Token with "'+p.type+'" type was not found.';if(this.options.silent){console.error(A);return}else throw new Error(A)}}}return r}parseInline(t,n){n=n||this.renderer;let r="",o,s,i;const a=t.length;for(o=0;o<a;o++){if(s=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[s.type]&&(i=this.options.extensions.renderers[s.type].call({parser:this},s),i!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type))){r+=i||"";continue}switch(s.type){case"escape":{r+=n.text(s.text);break}case"html":{r+=n.html(s.text);break}case"link":{r+=n.link(s.href,s.title,this.parseInline(s.tokens,n));break}case"image":{r+=n.image(s.href,s.title,s.text);break}case"strong":{r+=n.strong(this.parseInline(s.tokens,n));break}case"em":{r+=n.em(this.parseInline(s.tokens,n));break}case"codespan":{r+=n.codespan(s.text);break}case"br":{r+=n.br();break}case"del":{r+=n.del(this.parseInline(s.tokens,n));break}case"text":{r+=n.text(s.text);break}default:{const l='Token with "'+s.type+'" type was not found.';if(this.options.silent){console.error(l);return}else throw new Error(l)}}}return r}}class Js{constructor(t){this.options=t||lr}preprocess(t){return t}postprocess(t){return t}}ix(Js,"passThroughHooks",new Set(["preprocess","postprocess"]));function zT(e,t,n){return r=>{if(r.message+=`
128
128
  Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An error occurred:</p><pre>"+Ot(r.message+"",!0)+"</pre>";if(t)return Promise.resolve(o);if(n){n(null,o);return}return o}if(t)return Promise.reject(r);if(n){n(r);return}throw r}}function Eh(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...me.defaults,...s};const i=zT(r.silent,r.async,o);if(typeof n>"u"||n===null)return i(new Error("marked(): input parameter is undefined or null"));if(typeof n!="string")return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));if($T(r),r.hooks&&(r.hooks.options=r),o){const a=r.highlight;let l;try{r.hooks&&(n=r.hooks.preprocess(n)),l=e(n,r)}catch(f){return i(f)}const c=function(f){let m;if(!f)try{r.walkTokens&&me.walkTokens(l,r.walkTokens),m=t(l,r),r.hooks&&(m=r.hooks.postprocess(m))}catch(p){f=p}return r.highlight=a,f?i(f):o(null,m)};if(!a||a.length<3||(delete r.highlight,!l.length))return c();let d=0;me.walkTokens(l,function(f){f.type==="code"&&(d++,setTimeout(()=>{a(f.text,f.lang,function(m,p){if(m)return c(m);p!=null&&p!==f.text&&(f.text=p,f.escaped=!0),d--,d===0&&c()})},0))}),d===0&&c();return}if(r.async)return Promise.resolve(r.hooks?r.hooks.preprocess(n):n).then(a=>e(a,r)).then(a=>r.walkTokens?Promise.all(me.walkTokens(a,r.walkTokens)).then(()=>a):a).then(a=>t(a,r)).then(a=>r.hooks?r.hooks.postprocess(a):a).catch(i);try{r.hooks&&(n=r.hooks.preprocess(n));const a=e(n,r);r.walkTokens&&me.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function me(e,t,n){return Eh(Wn.lex,Vn.parse)(e,t,n)}me.options=me.setOptions=function(e){return me.defaults={...me.defaults,...e},kT(me.defaults),me},me.getDefaults=hh,me.defaults=lr,me.use=function(...e){const t=me.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=me.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(o=>{if(!o.name)throw new Error("extension name required");if(o.renderer){const s=t.renderers[o.name];s?t.renderers[o.name]=function(...i){let a=o.renderer.apply(this,i);return a===!1&&(a=s.apply(this,i)),a}:t.renderers[o.name]=o.renderer}if(o.tokenizer){if(!o.level||o.level!=="block"&&o.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");t[o.level]?t[o.level].unshift(o.tokenizer):t[o.level]=[o.tokenizer],o.start&&(o.level==="block"?t.startBlock?t.startBlock.push(o.start):t.startBlock=[o.start]:o.level==="inline"&&(t.startInline?t.startInline.push(o.start):t.startInline=[o.start]))}o.childTokens&&(t.childTokens[o.name]=o.childTokens)}),r.extensions=t),n.renderer){const o=me.defaults.renderer||new cl;for(const s in n.renderer){const i=o[s];o[s]=(...a)=>{let l=n.renderer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.renderer=o}if(n.tokenizer){const o=me.defaults.tokenizer||new ll;for(const s in n.tokenizer){const i=o[s];o[s]=(...a)=>{let l=n.tokenizer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.tokenizer=o}if(n.hooks){const o=me.defaults.hooks||new Js;for(const s in n.hooks){const i=o[s];Js.passThroughHooks.has(s)?o[s]=a=>{if(me.defaults.async)return Promise.resolve(n.hooks[s].call(o,a)).then(c=>i.call(o,c));const l=n.hooks[s].call(o,a);return i.call(o,l)}:o[s]=(...a)=>{let l=n.hooks[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.hooks=o}if(n.walkTokens){const o=me.defaults.walkTokens;r.walkTokens=function(s){let i=[];return i.push(n.walkTokens.call(this,s)),o&&(i=i.concat(o.call(this,s))),i}}me.setOptions(r)})},me.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(me,r)),r.type){case"table":{for(const o of r.header)n=n.concat(me.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(me.walkTokens(s.tokens,t));break}case"list":{n=n.concat(me.walkTokens(r.items,t));break}default:me.defaults.extensions&&me.defaults.extensions.childTokens&&me.defaults.extensions.childTokens[r.type]?me.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(me.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(me.walkTokens(r.tokens,t)))}return n},me.parseInline=Eh(Wn.lexInline,Vn.parseInline),me.Parser=Vn,me.parser=Vn.parse,me.Renderer=cl,me.TextRenderer=Th,me.Lexer=Wn,me.lexer=Wn.lex,me.Tokenizer=ll,me.Slugger=kh,me.Hooks=Js,me.parse=me,me.options,me.setOptions,me.use,me.walkTokens,me.parseInline,Vn.parse,Wn.lex;function cr({content:e,className:t="",allowHtml:n=!1,style:r}){const o=w.useMemo(()=>{if(!e||typeof e!="string"||e.trim().length===0)return"";try{if(!n){const i=e.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,"").replace(/javascript:/gi,"").replace(/on\w+\s*=/gi,"");return typeof me.parse=="function"?me.parse(i):me(i)}return typeof me.parse=="function"?me.parse(e):me(e)}catch(i){return console.error("[MarkdownContent] parse error",i),`<pre class="font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words">Error rendering markdown: ${String(i)}</pre>`}},[e,n]),s=w.useMemo(()=>{const i={color:"currentColor",...r};if(r&&r.color){const a=r.color;return{...i,"--tw-prose-body":a,"--tw-prose-headings":a,"--tw-prose-links":a,"--tw-prose-bold":a,"--tw-prose-counters":a,"--tw-prose-bullets":a,"--tw-prose-hr":a,"--tw-prose-quotes":a,"--tw-prose-quote-borders":a,"--tw-prose-captions":a,"--tw-prose-code":a,"--tw-prose-pre-code":a,"--tw-prose-pre-bg":"inherit","--tw-prose-th-borders":a,"--tw-prose-td-borders":a}}return i},[r]);return u.jsx("div",{className:ne("markdown prose prose-sm max-w-none break-words","dark:prose-invert","text-current","prose-headings:text-current prose-p:text-current prose-li:text-current prose-a:text-current prose-strong:text-current","prose-em:text-current prose-blockquote:text-current prose-table:text-current prose-td:text-current prose-th:text-current","prose-pre:font-mono prose-pre:text-xs prose-pre:bg-background/50 prose-pre:border prose-pre:rounded prose-pre:p-3 prose-pre:whitespace-pre prose-pre:overflow-x-auto","prose-code:font-mono prose-code:text-sm prose-code:bg-background/50 prose-code:px-1.5 prose-code:py-0.5 prose-code:rounded prose-code:text-current",t),style:s,dangerouslySetInnerHTML:{__html:o}})}function Ih({preview:e,idx:t}){return u.jsxs("div",{className:"space-y-2",children:[e.label&&u.jsxs("p",{className:"text-[0.65rem] uppercase tracking-wide text-muted-foreground",children:["Artifact: ",e.label]}),u.jsx("div",{className:"overflow-hidden rounded border border-border/60 bg-background/60 p-1 shadow-sm",children:u.jsx("img",{src:e.src,alt:e.alt,title:e.label,loading:"lazy",className:"h-auto max-h-[420px] w-full rounded object-contain",onLoad:()=>{},onError:n=>{console.error(`[MessageComponent] ❌ Image failed to load for artifact ${t}:`,{alt:e.alt,label:e.label,message:n.target.alt})}})})]})}function Nh({artifact:e,idx:t=0}){const n=w.useMemo(()=>e?(Array.isArray(e.plots)?e.plots:[]).map(o=>dw(o)).filter(o=>o!==null):[],[e]);return n.length>0?u.jsx("div",{className:"space-y-2",children:n.map((r,o)=>u.jsx(Ih,{preview:r,idx:o},`${t}-plot-${o}`))}):e&&typeof e=="object"?u.jsx("div",{className:"rounded-lg border border-gray-200 dark:border-gray-800 bg-gray-50 dark:bg-gray-900/20 p-4",children:u.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:["Unknown artifact type: ",u.jsx("code",{className:"font-mono",children:e.type||"unknown"})]})}):null}const HT="prose prose-sm max-w-none break-words dark:prose-invert prose-headings:break-words prose-p:break-words prose-li:break-words prose-td:break-words prose-th:break-words prose-a:break-all prose-code:break-words prose-blockquote:break-words";function Zs({data:e}){return Array.isArray(e)?e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?u.jsx("div",{className:HT,children:u.jsx("ul",{className:"list-disc pl-5",children:e.map((n,r)=>u.jsx("li",{children:String(n)},r))})}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:wr(e)}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:wr(e)})}function Ah({message:e,isStreaming:t=!1}){const n=e.name??"tool",r=w.useMemo(()=>{const a=e.additionalKwargs??{};return Array.isArray(a.toolProgress)?[...a.toolProgress]:[]},[e]),s=r.some(a=>a.type==="tool.start"||a.type==="tool.call"||a.type==="message.start")?`Running ${n}…`:void 0;return t||r.length>0?u.jsxs("div",{className:"space-y-2",children:[u.jsxs("div",{className:"flex items-center gap-2 text-xs uppercase tracking-wide text-muted-foreground",children:[t&&u.jsx(le.Loader,{className:"h-3 w-3 animate-spin"}),u.jsx("span",{children:s??`Running ${n}…`})]}),r.length>0&&u.jsx("div",{className:"space-y-2 text-xs text-muted-foreground",children:r.map((a,l)=>{var c;return u.jsxs("div",{className:"rounded border border-current/10 bg-muted/60 p-2 text-[11px] leading-snug",children:[u.jsxs("div",{className:"mb-1 flex items-center justify-between text-[8px] uppercase tracking-wide text-muted-foreground",children:[u.jsx("span",{children:((c=a.type)==null?void 0:c.replace(/\./g," "))??"progress"}),u.jsx("span",{children:a.idx??l+1})]}),a.content&&u.jsx("p",{className:"mt-1 text-[12px] text-foreground/90",children:a.content}),u.jsxs("div",{className:"mt-1 flex flex-wrap gap-2 text-[10px] opacity-70",children:[typeof a.factsFound=="number"&&u.jsxs("span",{children:["Facts found: ",a.factsFound]}),typeof a.isSufficient=="boolean"&&u.jsxs("span",{children:["Research ",a.isSufficient?"sufficient":"needs more data"]})]})]},`tool-progress-${n}-${l}`)})})]}):null}const ul=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:ne("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));ul.displayName="Card";const dl=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:ne("flex flex-col space-y-1.5 p-6",e),...t}));dl.displayName="CardHeader";const fl=h.forwardRef(({className:e,...t},n)=>u.jsx("h3",{ref:n,className:ne("text-2xl font-semibold leading-none tracking-tight",e),...t}));fl.displayName="CardTitle";const pl=h.forwardRef(({className:e,...t},n)=>u.jsx("p",{ref:n,className:ne("text-sm text-muted-foreground",e),...t}));pl.displayName="CardDescription";const Qs=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:ne("p-6 pt-0",e),...t}));Qs.displayName="CardContent";const jh=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:ne("flex items-center p-6 pt-0",e),...t}));jh.displayName="CardFooter";const UT=e=>!!e&&typeof e=="object"&&e.type==="user_choice"&&typeof e.question=="string"&&Array.isArray(e.alternatives);function hl({interruptPart:e,onApprove:t,onReject:n,onSelectAlternative:r,disabled:o,isActive:s,payload:i}){const a=UT(i)?i:null,l=(a==null?void 0:a.question)??e.title??"Approve the result?",c=a?s?"Select one of the alternatives to continue.":"Waiting for approval from another participant.":s?"Please approve or reject this action to resume the workflow.":"Waiting for approval from another participant.";let d=null;if(!a&&i!==void 0&&i!==null)if(typeof i=="string")d=u.jsx("p",{className:"text-sm leading-relaxed text-blue-800/90 dark:text-blue-200/90 whitespace-pre-wrap",children:i});else{const f=wr(i);d=u.jsx("pre",{className:"max-h-48 overflow-auto rounded bg-blue-100/60 p-2 text-xs text-blue-900/90 dark:bg-blue-900/40 dark:text-blue-100/80",children:f})}return u.jsxs(ul,{className:ne("border-blue-200 dark:border-blue-800 bg-blue-50/50 dark:bg-blue-950/10 transition-shadow",s?"shadow-md ring-1 ring-blue-300 dark:ring-blue-500/70":"opacity-80"),children:[u.jsxs(dl,{className:"pb-3",children:[u.jsx(fl,{className:"text-blue-900 dark:text-blue-100 text-base",children:l}),u.jsx(pl,{className:"text-blue-700 dark:text-blue-300 text-sm",children:c})]}),a?u.jsx(Qs,{className:"pt-0 pb-3",children:u.jsx("div",{className:"space-y-2",children:a.alternatives.map(f=>u.jsx(Je,{size:"sm",variant:"outline",onClick:()=>r==null?void 0:r(e,f),className:"w-full justify-start text-left",disabled:o||!s,children:u.jsxs("div",{className:"flex flex-col items-start gap-1",children:[u.jsx("span",{className:"font-semibold",children:f.label}),f.description?u.jsx("span",{className:"text-xs text-muted-foreground leading-snug",children:f.description}):null]})},f.id))})}):d&&u.jsx(Qs,{className:"pt-0 pb-3",children:d}),!a&&u.jsx(jh,{className:"pt-0",children:u.jsxs("div",{className:"flex gap-2 ml-auto",children:[u.jsx(Je,{size:"sm",variant:"outline",onClick:()=>n(e),className:"border-red-300 text-red-700 hover:bg-red-50 dark:border-red-700 dark:text-red-300 dark:hover:bg-red-950/50",disabled:o||!s,children:"Reject"}),u.jsx(Je,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:o||!s,children:"Approve"})]})})]})}function Ph({className:e}){const t=w.useRef(null);return w.useEffect(()=>{let n=0;const r=()=>{if(n=(n+1)%4,t.current){const s=".".repeat(n);t.current.textContent=`Is thinking${s}`}};r();const o=setInterval(r,500);return()=>clearInterval(o)},[]),u.jsx("span",{ref:t,"aria-live":"polite",className:ne("inline-block text-xs opacity-70 ml-1",e),children:"Is thinking"})}function _h({text:e,expanded:t,onExpandedChange:n,previewLength:r,isCompact:o}){const s=Math.max(e.length-r,0),i=e.substring(0,r);return u.jsxs("div",{className:"flex flex-col gap-1",children:[u.jsx("div",{className:ne("text-sm text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:t?u.jsx(cr,{content:e,allowHtml:!1}):u.jsxs("pre",{className:ne("font-sans whitespace-pre-wrap break-words bg-transparent p-0 m-0 text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:[i,"..."]})}),u.jsx(Je,{type:"button",variant:"ghost",size:"sm",className:"h-6 text-xs !text-[hsl(var(--chat-bubble-user-text))]",onClick:()=>n(!t),children:t?u.jsxs(u.Fragment,{children:[u.jsx(le.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):u.jsxs(u.Fragment,{children:[u.jsx(le.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",s," chars)"]})})]})}function Rh(e){const{allowFileOpen:t,currentThreadId:n}=e,{toast:r}=al(),[o,s]=w.useState({}),[i,a]=w.useState(null),[l,c]=w.useState(!1),d=w.useCallback(()=>{c(!1),a(null)},[]),f=w.useCallback(p=>{a(p),c(!0)},[]),m=w.useCallback(async(p,v,g)=>{var x,y;if(!t){p.preventDefault();return}if(o[g]){p.preventDefault();return}try{const b=String(v.url??""),C=b.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(C){p.preventDefault();const k=C[1],S=v.name||`file_${k}`,T=v.mimeType||"application/octet-stream";f({id:k,name:S,mimeType:T});return}if(b.startsWith("data:")){p.preventDefault(),s(S=>({...S,[g]:!0}));const k=r({title:"Fetching file...",description:"",open:!0});try{const S=await ou(n??void 0);if(!S||!Array.isArray(S))throw new Error("Invalid file list response");const T=S.find(E=>!E||typeof E!="object"||!((E.filename??"")===(v.name??""))?!1:typeof v.size=="number"&&typeof E.size=="number"?E.size===v.size:!0);if(!(T!=null&&T.id))throw new Error(`File "${v.name}" is not yet available on the server`);if(!T.id||!T.filename)throw new Error("Invalid file data received from server");f({id:T.id,name:v.name||T.filename||`file_${T.id}`,mimeType:v.mimeType||T.mime_type||"application/octet-stream"}),(x=k.update)==null||x.call(k,{id:k.id,title:"Success",description:`Opened ${v.name}`,open:!0})}catch(S){console.error("Failed to fetch server file:",S);const T=S instanceof Error?S.message:"Unknown error occurred";(y=k.update)==null||y.call(k,{id:k.id,title:"Failed",description:T}),r({title:"Failed to fetch file",description:T,open:!0})}finally{s(S=>({...S,[g]:!1}))}}}catch(b){console.error("File click error:",b),s(C=>({...C,[g]:!1}))}},[t,o,r,n,f]);return{uploadingFiles:o,handleFileClick:m,fileViewerOpen:l,currentFileInfo:i,closeFileViewer:d}}function Mh(e,t){return w.useMemo(()=>{if(t)return{contentParts:[],textContent:"",toolMeta:{},imageParts:[],fileParts:[],interruptParts:[],toolRaw:"",isToolStreaming:!1};const n=e,r=Array.isArray(n.content)?n.content:[],o=n.additionalKwargs??{};return{contentParts:r,textContent:sw(r),toolMeta:Fi(n),imageParts:r.filter(s=>s.type==="image_url"),fileParts:r.filter(s=>s.type==="file"),interruptParts:r.filter(s=>s.type==="interrupt"),toolRaw:iw(r),isToolStreaming:!!o.toolStreaming}},[e,t])}const Oh="data:";function WT(e){if(!e)return[];const t=[],n=e.split(/\r?\n/);for(const r of n){const o=r.trim();if(!o||!o.startsWith(Oh))continue;const s=o.slice(Oh.length).trim();if(!s||s.toLowerCase()==="[done]")continue;const i=to(s);i&&typeof i=="object"&&t.push(i)}return t}function VT(e){if(!e)return null;if(Array.isArray(e))return e;if(typeof e!="object")return null;const t=e.issues;if(Array.isArray(t))return t;if(t&&typeof t=="object"){const n=t.issues;if(Array.isArray(n))return n}return null}function KT(e){for(let t=e.length-1;t>=0;t-=1){const n=e[t];if(n&&typeof n=="object"&&n.type==="tool.end")return n}return null}function qT(e){return w.useMemo(()=>{const t=e.content.filter(c=>c.type==="text");if(!t.length)return null;let r=t.flatMap(c=>WT(c.text??""));if(!r.length){const c=t.map(f=>f.text??"").join(`
129
129
  `),d=to(c);d&&typeof d=="object"&&(r=[d])}if(!r.length)return null;const s=KT(r)??r[r.length-1];if(!s)return null;const i=s.output??s.payload??s,a=br(i),l=VT(a);return l&&l.length?{kind:"issues",value:a,issues:l,event:s}:a&&typeof a=="object"&&!Array.isArray(a)?{kind:"dict",value:a,data:a,event:s}:{kind:"generic",value:a,event:s}},[e])}function Dh({message:e,viewMode:t,isStreaming:n=!1,toolRenderers:r,toolArtifactRenderers:o}){var C;const s=Fi(e),i=e.artifact??null,a=qT(e),l=e.content.find(k=>k.type!=="tool_call"),c=k=>{if(k==null)return null;const S=typeof k=="string"?to(k)??k:k;if(S&&typeof S=="object")return u.jsx(Zs,{data:S});const T=typeof S=="string"?S:(()=>{try{return wr(S)}catch{return String(S??"")}})();return u.jsx("pre",{className:"whitespace-pre-wrap break-words font-sans text-sm text-foreground/90",children:T})},d=k=>{if(k==null)return null;const{content:S,isMarkdown:T}=ow(k);return T?u.jsx(cr,{content:S,className:"text-current"}):c(k)},f=k=>u.jsxs("div",{className:"space-y-2 rounded-2xl border border-muted-foreground/30 bg-white/80 p-4 shadow-sm shadow-slate-900/10",children:[u.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-[0.4em] text-muted-foreground",children:"Structured dictionary"}),u.jsx(Zs,{data:k})]}),m=()=>{if((a==null?void 0:a.kind)==="generic")return d(a.value);if(!l)return null;if(l.type==="text"){const E=(l.text??"").trim();if(!E)return null;const A=br(E);return d(A)}const k=no(l),S=br(k);return d(S)},p=()=>(a==null?void 0:a.kind)==="dict"?f(a.data):m(),g=(()=>{if(r){if(s.name){const k=r[s.name];if(k)return k}if(a!=null&&a.kind){const k=r[a.kind];if(k)return k}return r.default}})(),x=(g==null?void 0:g({message:e,toolMeta:s,toolPayload:a,viewMode:t,isStreaming:n}))??null,b=((C=(()=>{if(!o)return;const k=i==null?void 0:i.type;if(typeof k=="string"){const S=o[k];if(S)return S}return o.default})())==null?void 0:C({artifact:i,message:e,toolPayload:a,isStreaming:n}))??null;return u.jsxs("div",{className:"space-y-2",children:[i&&(b??u.jsx(Nh,{artifact:i,idx:0})),u.jsx(Ah,{message:e,isStreaming:n}),t==="expanded"&&u.jsx(u.Fragment,{children:x??p()})]})}const GT={checkpoints:[],checkpointMetaByCheckpointId:new Map,timeline:[],messagePreviews:new Map,getLatest:()=>{},getCheckpoint:()=>{},getMessageAttempts:()=>[]},ml=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,gl=w.memo(function({message:t,index:n,isStreaming:r,streamingAssistantId:o,streamingDebounceMs:s,layoutSize:i,enableMessageEditing:a,editingMessageId:l,onEdit:c,onRegenerate:d,onCancelEdit:f,showToolMessages:m,checkpointIndex:p,onSelectCheckpoint:v,getMessageCustomStyles:g,getInterruptOptions:x,toolRenderers:y,toolArtifactRenderers:b}){const C=ml(t,n),k=t.role==="default_message",T=!!t.__syntheticStreaming,E=p??GT,A=!k&&"checkpointId"in t?t.checkpointId??null:null,{attemptCount:R,attemptIndex:L,attempts:F}=w.useMemo(()=>oc(t.id,A,E),[t.id,A,E]),K=g==null?void 0:g(t);return u.jsx("div",{className:"relative mb-4 last:mb-0","data-message-id":C,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:u.jsx(ei,{message:t,messageIndex:n,isStreamingMessage:T||r&&o===t.id&&t.role==="assistant",streamingDebounceMs:s,isEditing:l===t.id,showActions:a,showTimestamp:!1,showAgentName:!0,layoutSize:i,onEdit:c,onRegenerate:()=>d(n),onCancelEdit:f,getInterruptOptions:x,showToolMessages:m,attemptCount:R,attemptIndex:L,attemptMetas:F,onSelectCheckpoint:v,customStyles:K,toolRenderers:y,toolArtifactRenderers:b})})});gl.displayName="MessageRow";function YT(e,t,n){const[r,o]=w.useState(e),s=w.useRef([]);return w.useEffect(()=>{if(!t){o(e),s.current=e.map(a=>a.type==="text"?a.text??"":void 0);return}const i=e.map((a,l)=>{if(a.type!=="text")return s.current[l]=void 0,a;const c=a.text??"",d=s.current[l];return n(c)?(s.current[l]=c,a):{...a,text:d??""}});o(i)},[e,t,n]),r}function XT({message:e,isToolMessage:t,showToolMessages:n,toolViewMode:r,isToolStreaming:o,contentParts:s,textContent:i,imageParts:a,fileParts:l,interruptPart:c,isStreamingMessage:d,enableStreamingMarkdownBuffer:f,renderStreamingMarkdown:m,defaultMessage:p,handleFileClick:v,uploadingFiles:g,messageRole:x,truncateUserMessages:y,userMessagePreviewLength:b,isUserExpanded:C,setIsUserExpanded:k,isCompactLayout:S,iconForeground:T,toolRenderers:E,toolArtifactRenderers:A,handleInterruptApprove:R,handleInterruptReject:L,handleInterruptAlternative:F,disableInterruptActions:K,isInterruptMessage:J}){const P=w.useCallback(()=>u.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[u.jsx(le.Loader,{className:"h-4 w-4 text-muted-foreground"}),u.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),q=YT(s,(f??!0)&&d,Lh),W=w.useMemo(()=>q.filter(z=>z.type==="text"),[q]),D=w.useMemo(()=>W.map(z=>z.text??"").join(""),[W]),I=w.useMemo(()=>{if(!m)return null;const z=JT(D);return{stablePart:D.slice(0,z),tailPart:D.slice(z)}},[D,m]),G=w.useMemo(()=>{if(!I)return null;const{stablePart:z,tailPart:O}=I;return!z&&!O?null:u.jsxs("div",{className:"space-y-2",children:[z?u.jsx(cr,{content:z,allowHtml:!1}):null,O?u.jsx(cr,{content:O,allowHtml:!1}):null]})},[I]),X=w.useMemo(()=>{if(!m)return q;const z=[];let O=!1;for(const j of q){if(j.type==="text"){O||(z.push({type:"text",text:"",__streamingMarkdownAggregate:!0}),O=!0);continue}z.push(j)}return z},[q,m]),B=(m?X:q).filter(z=>z.type!=="interrupt"),_=w.useCallback(({part:z,i:O})=>{if(z.type==="text"){if(m)return null;const j=z.text??"",U=j.trim(),Q=to(U);return Q&&x!=="tool"?u.jsx(Zs,{data:Q},O):x==="user"&&y&&U.length>b?u.jsx(_h,{text:U,expanded:C,onExpandedChange:k,previewLength:b,isCompact:S},O):u.jsx(cr,{content:j,allowHtml:!1},O)}if(z.type==="image_url"){const j=z;return u.jsx("div",{className:"my-2",children:u.jsx("img",{src:j.url,alt:j.alt??"",loading:"lazy",className:"border rounded max-h-[420px] w-auto object-contain"})},O)}if(z.type==="file"){const j=z,U=j.name||"file";return u.jsxs("a",{href:j.url,onClick:Q=>v(Q,j,O),className:`inline-flex items-center gap-2 rounded px-2 py-1 text-xs bg-gray-100 border hover:bg-gray-200
130
- dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20`,children:[g[O]?u.jsx(le.Loader,{className:"h-4 w-4 animate-spin"}):null,u.jsxs("span",{className:"truncate max-w-[180px]",children:[U,g[O]?" (processing)":""]})]},O)}return null},[v,S,C,x,y,g,b,m,k]),$=i.trim().length>0||a.length>0||l.length>0||B.length>0;if(!t&&l.length>0&&!d)return P();if(!t&&!$&&!d)return null;if(t){if(!n)return null;if(J&&c){const z=c.value,O=!K,j=R??(()=>{}),U=L??(()=>{});return u.jsx(hl,{interruptPart:c,payload:z,onApprove:j,onReject:U,onSelectAlternative:F,disabled:K,isActive:O})}return u.jsx(Dh,{message:e,viewMode:r,isStreaming:o,toolRenderers:E,toolArtifactRenderers:A},e.id)}if(!p){const z=u.jsx("div",{className:"space-y-2",children:B.map((O,j)=>m&&ZT(O)?G?u.jsx("div",{className:"space-y-2",children:G},`streaming-md-${j}`):null:u.jsx(_,{part:O,i:j},j))});return d?u.jsxs("div",{"aria-busy":"true",role:"status",children:[z,u.jsx(Ph,{className:T})]}):z}return null}function Lh(e){return e?!(jo(e,/```/g)||jo(e,/`/g)||jo(e,/\*\*/g)||jo(e,/__/g)||jo(e,/~~/g)||/[^\\]\[[^\]]*$/.test(e)||/\[[^\]]*\]\([^)]*$/.test(e)):!0}function jo(e,t){const n=e.match(t);return((n==null?void 0:n.length)??0)%2!==0}function JT(e){if(!e)return 0;for(let t=e.length;t>=0;t-=1)if(Lh(e.slice(0,t)))return t;return 0}function ZT(e){return e.type==="text"&&!!e.__streamingMarkdownAggregate}const QT=Ur.cva("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function $h({className:e,variant:t,...n}){return u.jsx("div",{className:ne(QT({variant:t}),e),...n})}function ek({showTimestamp:e,showAgentName:t,isToolMessage:n,isInterruptMessage:r=!1,iconForeground:o,agentName:s,messageIcon:i,customHeaderClass:a,customActionsClass:l,isCompactLayout:c,showActions:d,isEditing:f,messageRole:m,toolViewMode:p,toolMeta:v,onToggleToolView:g,onCopy:x,onEdit:y,onRegenerate:b,showCheckpointControls:C,attemptCount:k,attemptIndex:S,handleOlderAttemptSelect:T,handleNewerAttemptSelect:E,messageCreatedAt:A,copied:R}){return!e&&!t&&!n&&!r?null:u.jsxs("div",{className:ne("flex items-center justify-between mb-2 pb-2 border-b border-current/10",c&&"mb-1 pb-1",o,a),children:[u.jsxs("div",{className:"flex items-center gap-2",children:[i,t&&s&&u.jsx("span",{className:ne("font-medium",c?"text-xs":"text-sm"),children:s}),n&&!r&&u.jsxs($h,{variant:"outline",className:ne("text-xs flex items-center gap-1 cursor-pointer select-none",o,"border border-current/40",c&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":p==="expanded",onClick:g,onKeyDown:L=>{(L.key==="Enter"||L.key===" ")&&(L.preventDefault(),g())},children:[u.jsx("span",{children:v.name??"Tool Output"}),v.toolCallId&&u.jsx("span",{className:"opacity-70",children:v.toolCallId.slice(0,8)}),p==="expanded"?u.jsx(le.ChevronUp,{className:"h-3 w-3"}):u.jsx(le.ChevronDown,{className:"h-3 w-3"})]}),r&&u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:v.name??"Interrupt"})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[C&&k>1&&u.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[u.jsx("button",{type:"button",className:ne("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",S<k-1?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{S>=k-1||T()},"aria-label":"Older attempt (back in time)",disabled:S>=k-1,children:u.jsx(le.ChevronLeft,{className:"h-3 w-3"})}),u.jsx("div",{className:"flex items-center gap-2",children:u.jsxs("span",{className:"whitespace-nowrap",children:[k-S," / ",k]})}),u.jsx("button",{type:"button",className:ne("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",S>0?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{S<=0||E()},"aria-label":"Newer attempt (forward in time)",disabled:S<=0,children:u.jsx(le.ChevronRight,{className:"h-3 w-3"})})]}),e&&A&&u.jsx("time",{className:ne("text-xs opacity-60",o,c&&"text-xs"),dateTime:new Date(A).toISOString(),title:new Date(A).toLocaleString(),children:new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(new Date(A))}),d&&!f&&u.jsxs("div",{className:ne("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",l),children:[u.jsx("div",{className:"relative",children:u.jsx(Je,{variant:"ghost",size:"sm",onClick:x,className:ne("h-6 w-6 p-0 hover:bg-foreground/10",o,c&&"h-5 w-5"),"aria-label":"Copy message",title:"Copy message",children:u.jsx(le.Copy,{className:ne(R?"text-success":o,c?"h-3 w-3":"h-4 w-4")})})}),m==="user"&&y&&u.jsx(Je,{variant:"ghost",size:"sm",onClick:y,className:ne("h-6 w-6 p-0 hover:bg-foreground/10",o,c&&"h-5 w-5"),"aria-label":"Edit message",children:u.jsx(le.Edit,{className:ne(o,c?"h-3 w-3":"h-4 w-4")})}),m==="assistant"&&b&&u.jsx(Je,{variant:"ghost",size:"sm",onClick:b,className:ne("h-6 w-6 p-0 hover:bg-foreground/10",o,c&&"h-5 w-5"),"aria-label":"Regenerate response",children:u.jsx(le.RotateCcw,{className:ne(o,c?"h-3 w-3":"h-4 w-4")})})]})]})]})}const ei=w.memo(function({message:t,messageIndex:n,isStreamingMessage:r=!1,isEditing:o=!1,showActions:s=!0,showTimestamp:i=!0,showAgentName:a=!0,layoutSize:l="desktop",truncateUserMessages:c=!0,userMessagePreviewLength:d=500,showToolMessages:f=!0,toolRenderers:m,toolArtifactRenderers:p,customStyles:v={},streamingDebounceMs:g=300,renderStreamingMarkdown:x=!1,enableStreamingMarkdownBuffer:y,onEdit:b,onRegenerate:C,onCopy:k,getInterruptOptions:S,attemptCount:T=1,attemptIndex:E=0,onSelectCheckpoint:A,attemptMetas:R=[]}){const[L,F]=w.useState(!1),[K,J]=w.useState("preview"),[P,Y]=w.useState(!1),{currentThreadId:q}=vr(),{respondToInterrupt:W}=ro(),[D,I]=w.useState(!1),G=l==="phone"||l==="half-screen",X=t.role,M=X==="interrupt",B=X==="tool"||M,$=!(t.role==="default_message")&&t.expandable!==void 0?t.expandable!==!1:!0,z=w.useMemo(()=>t.role==="default_message"?t:null,[t]),O=!!z,j=!(r&&X!=="user"),{uploadingFiles:U,handleFileClick:Q,fileViewerOpen:se,currentFileInfo:ie,closeFileViewer:Se}=Rh({allowFileOpen:j,currentThreadId:q}),xe=w.useMemo(()=>{switch(X){case"user":return"text-[hsl(var(--chat-bubble-user-text))]";case"assistant":return"text-[hsl(var(--chat-bubble-ai-text))]";case"interrupt":return"text-[hsl(var(--chat-bubble-ai-text))]";case"tool":return"text-secondary-foreground";case"system":return"text-muted-foreground";default:return"text-[hsl(var(--chat-bubble-ai-text))]"}},[X]),Re=Mh(t,z),{contentParts:Ve,imageParts:De,fileParts:Ge,textContent:He,toolMeta:ot,toolRaw:ut,isToolStreaming:nt,interruptParts:Le}=Re,Ke=y??g!==0,$e=w.useMemo(()=>Le.length?Le[0]:null,[Le]),Te=w.useCallback(async()=>{const je=B?ut:He;async function Ye(we){if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function"){await navigator.clipboard.writeText(we);return}if(navigator.clipboard&&typeof navigator.clipboard.write=="function"&&typeof ClipboardItem<"u"){const Qe=new Blob([we],{type:"text/plain"});await navigator.clipboard.write([new ClipboardItem({"text/plain":Qe})]);return}throw new Error("Clipboard API not supported in this context.")}try{await Ye(je),F(!0),setTimeout(()=>F(!1),2e3),k==null||k(je)}catch(we){console.error("Failed to copy:",we)}},[B,ut,He,k]),Ae=w.useCallback(async(je,Ye)=>{if(!$e)return;if(!wu($e.id)){console.warn("Interrupt part missing id",$e);return}I(!0);try{const Qe=S==null?void 0:S(t);await W(je,Ye,Qe)}catch(Qe){console.error("Failed to respond to interrupt:",Qe)}finally{I(!1)}},[$e,W]),dt=w.useCallback(()=>Ae(!0),[Ae]),Et=w.useCallback(()=>Ae(!1),[Ae]),at=w.useCallback((je,Ye)=>{if(!Ye)return;const we={alternativeId:Ye.id??Ye.label??void 0,alternativeLabel:Ye.label};Ae(!0,we)},[Ae]),It=w.useCallback(()=>{if(!b||!t.id)return;const je=(B?ut:He)??"",Ye="type"in t&&t.type==="default_message"?void 0:{checkpointId:t.checkpointId??null,checkpointNs:t.checkpointNs??null};b(t.id,je,Ye)},[b,B,ut,He,t]),bt=w.useCallback(()=>{C==null||C(n)},[C,n]),ft=!M&&$,Nt=w.useCallback(()=>{ft&&J(je=>je==="expanded"?"preview":"expanded")},[ft]),Ct=M||$?"expanded":K,on=w.useCallback(()=>{const Ye=ne(G?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",xe);switch(X){case"user":return u.jsx(le.User,{className:Ye});case"assistant":return u.jsx(le.Bot,{className:Ye});case"tool":return u.jsx(le.Wrench,{className:Ye});case"interrupt":return u.jsx(le.Bot,{className:Ye});default:return u.jsx(le.Bot,{className:Ye})}},[G,xe,X]),Tt=w.useCallback(()=>{const je="group relative mb-4 flex w-full";switch(X){case"user":return ne(je,"justify-end");case"assistant":case"tool":case"system":case"interrupt":return ne(je,"justify-start");default:return je}},[X]),Ie=w.useCallback(()=>{const je=ne("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",G&&"px-3 py-2 text-sm");if(O)return ne(je,"w-full","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40 shadow-sm");switch(X){case"user":return ne(je,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-user))] text-[hsl(var(--chat-bubble-user-text))]","border border-transparent");case"assistant":return ne(je,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40");case"tool":case"interrupt":return ne(je,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return ne(je,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return ne(je,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40")}},[G,O,X]),Ue=(f||M)&&$,jt=u.jsx(XT,{message:t,isToolMessage:B,showToolMessages:Ue,toolViewMode:Ct,isToolStreaming:nt,contentParts:Ve,textContent:He,imageParts:De,fileParts:Ge,isStreamingMessage:r,defaultMessage:z,enableStreamingMarkdownBuffer:Ke,renderStreamingMarkdown:x,handleFileClick:Q,uploadingFiles:U,messageRole:X,truncateUserMessages:c,userMessagePreviewLength:d,isUserExpanded:P,setIsUserExpanded:Y,isCompactLayout:G,iconForeground:xe,toolRenderers:m,toolArtifactRenderers:p,interruptPart:$e,handleInterruptApprove:dt,handleInterruptReject:Et,handleInterruptAlternative:at,disableInterruptActions:D,isInterruptMessage:M}),te=w.useMemo(()=>z?"Assistant":aw(t),[z,t]),ge=on(),rt=X==="user"&&(T??1)>1&&typeof A=="function",fe=(R==null?void 0:R.length)??0,ke=fe>0&&E<fe-1?R[E+1]:void 0,Fe=fe>0&&E>0?R[E-1]:void 0,ht=w.useCallback(()=>{!ke||!A||A(ke.id,void 0,!!ke.isLatestAttempt)},[ke,A]),pt=w.useCallback(()=>{!Fe||!A||A(Fe.id,void 0,!!Fe.isLatestAttempt)},[Fe,A]);return B&&!f?null:O&&z?u.jsx("div",{className:ne(Tt(),v.container),children:u.jsxs("div",{className:ne(Ie(),v.content),children:[u.jsxs("div",{className:"flex items-center gap-2 mb-2 pb-2 border-b border-current/10",children:[u.jsx(le.Bot,{className:ne("h-4 w-4",xe)}),a&&u.jsx("span",{className:"font-medium text-sm",children:"Assistant"})]}),u.jsx(cr,{content:z.content,className:"text-current"})]})}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:ne(Tt(),v.container),children:u.jsxs("div",{className:ne(Ie(),v.content),children:[u.jsx(ek,{showTimestamp:i,showAgentName:a,isToolMessage:B,iconForeground:xe,agentName:te,messageIcon:ge,customHeaderClass:v.header,customActionsClass:v.actions,isCompactLayout:G,showActions:s,isEditing:o,messageRole:X,toolViewMode:Ct,isInterruptMessage:M,toolMeta:ot,onToggleToolView:Nt,onCopy:Te,onEdit:It,onRegenerate:bt,showCheckpointControls:rt,attemptCount:T,attemptIndex:E,handleOlderAttemptSelect:ht,handleNewerAttemptSelect:pt,messageCreatedAt:t.createdAt,copied:L}),u.jsx("div",{className:"relative",children:jt}),B&&Ct==="expanded"&&(ot.toolCallId||ot.name)&&u.jsxs("div",{className:ne("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",G&&"text-xs"),children:[ot.name&&u.jsxs("div",{children:["Function: ",ot.name]}),ot.toolCallId&&u.jsxs("div",{children:["Call ID: ",ot.toolCallId]})]}),!(i||a||B)&&s&&!o&&u.jsxs("div",{className:ne("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",v.actions),children:[u.jsx(Je,{variant:"ghost",size:"sm",onClick:()=>Te(),className:ne("h-6 w-6 p-0 hover:bg-background/50 text-current",G&&"h-5 w-5"),children:u.jsx(le.Copy,{className:ne(L?"text-success":"text-current",G?"h-3 w-3":"h-4 w-4")})}),X==="user"&&b&&u.jsx(Je,{variant:"ghost",size:"sm",onClick:It,className:ne("h-6 w-6 p-0 hover:bg-background/50 text-current",G&&"h-5 w-5"),children:u.jsx(le.Edit,{className:ne("text-current",G?"h-3 w-3":"h-4 w-4")})}),X==="assistant"&&C&&u.jsx(Je,{variant:"ghost",size:"sm",onClick:bt,className:ne("h-6 w-6 p-0 hover:bg-background/50 text-current",G&&"h-5 w-5"),children:u.jsx(le.RotateCcw,{className:ne("text-current",G?"h-3 w-3":"h-4 w-4")})})]})]})}),ie&&u.jsx(ph,{isOpen:se,onClose:Se,fileId:ie.id,fileName:ie.name,mimeType:ie.mimeType})]})},(e,t)=>{var l,c,d,f,m,p,v,g;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&bu(e.message)===bu(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateUserMessages","userMessagePreviewLength","showToolMessages","toolRenderers","toolArtifactRenderers"].every(x=>e[x]===t[x]),s=((l=e.customStyles)==null?void 0:l.container)===((c=t.customStyles)==null?void 0:c.container)&&((d=e.customStyles)==null?void 0:d.content)===((f=t.customStyles)==null?void 0:f.content)&&((m=e.customStyles)==null?void 0:m.actions)===((p=t.customStyles)==null?void 0:p.actions)&&((v=e.customStyles)==null?void 0:v.header)===((g=t.customStyles)==null?void 0:g.header);if(!o||!s)return!1;const i=yu(e.message),a=yu(t.message);return i.length===a.length});ei.displayName="MessageComponent";const xl=w.forwardRef(({messages:e,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onStartReached:a,onEdit:l,onRegenerate:c,onCancelEdit:d,className:f,style:m,emptyMessage:p,followNewMessages:v=!0,isNavigatingCheckpoint:g=!1,onScrollAway:x,onAtBottom:y,showToolMessages:b=!0,toolRenderers:C,toolArtifactRenderers:k,checkpointIndex:S,activeCheckpointId:T,onSelectCheckpoint:E,createSyntheticThinkingMessage:A=!0,forceSyntheticThinking:R=!1,getMessageCustomStyles:L,getInterruptOptions:F},K)=>{const J=w.useRef(null),P=w.useRef(null),Y=w.useRef(!1),q=w.useRef(!1),W=e,D=w.useMemo(()=>{const j=n&&W.some(Q=>Q.id===n);return A&&(t||R)&&!j&&W.length>0?[...W,{id:"thinking-assistant",role:"assistant",content:[{type:"text",text:""}],createdAt:new Date().toISOString(),__syntheticStreaming:!0}]:W},[W,t,n,A,R]),I=w.useMemo(()=>b?D:D.filter(j=>(j==null?void 0:j.role)!=="tool"),[D,b]),G=w.useCallback(j=>{x&&x(!j),y&&y(j)},[x,y]),X=w.useMemo(()=>{if(a)return async()=>{if(!Y.current){Y.current=!0;try{await a()}finally{Y.current=!1}}}},[a]),M=w.useMemo(()=>!v||g?!1:"auto",[v,g]),B=w.useMemo(()=>{if(typeof p!="string")return null;const j=p.trim();return!j||I&&I.length>0?null:{id:"default-message",role:"default_message",content:j,createdAt:new Date().toISOString()}},[p,I]),_=["flex h-full flex-col md:flex-row",f].filter(Boolean).join(" "),$=()=>{if(B){const j=L==null?void 0:L(B);return u.jsx("div",{className:"p-6 h-full overflow-y-auto",children:u.jsx("div",{className:"w-full max-w-full",children:u.jsx(ei,{message:B,messageIndex:0,isStreamingMessage:!1,showActions:!1,showTimestamp:!1,showAgentName:!0,layoutSize:o,onEdit:()=>{},onRegenerate:()=>{},onCancelEdit:()=>{},customStyles:j,getInterruptOptions:F})})})}return u.jsx("div",{className:"flex h-full items-center justify-center py-8 text-center text-muted-foreground",children:p??"No messages yet. Start a conversation!"})},z=I.length,O=z>0;return w.useEffect(()=>{var j,U;if(z===0){q.current=!1;return}if(!q.current)if(q.current=!0,J.current&&I.length>0){const Q=I.length-1;(U=(j=J.current).scrollToIndex)==null||U.call(j,{index:Q,align:"end",behavior:"auto"})}else P.current&&(P.current.scrollTop=P.current.scrollHeight)},[z,I.length]),w.useImperativeHandle(K,()=>({scrollToLatest:()=>{var j,U;if(J.current&&I.length>0){const Q=I.length-1;(U=(j=J.current).scrollToIndex)==null||U.call(j,{index:Q,align:"end",behavior:"auto"})}else P.current&&(P.current.scrollTop=P.current.scrollHeight)},scrollToTop:()=>{var j,U;J.current&&I.length>0?(U=(j=J.current).scrollToIndex)==null||U.call(j,{index:0,align:"start",behavior:"auto"}):P.current&&(P.current.scrollTop=0)}}),[I]),u.jsx("div",{className:_,style:m,children:u.jsx("div",{className:"relative flex-1 min-h-0",children:O?u.jsx(qC,{ref:j=>{J.current=j},scrollerRef:j=>{P.current=j instanceof HTMLDivElement?j:null},data:I,followOutput:M,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,startReached:()=>{X&&X()},atBottomStateChange:G,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(j,U)=>ml(U,j),itemContent:(j,U)=>u.jsx(gl,{message:U,index:j,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onEdit:l,onRegenerate:c,onCancelEdit:d,showToolMessages:b,toolRenderers:C,toolArtifactRenderers:k,checkpointIndex:S,activeCheckpointId:T,onSelectCheckpoint:E,getMessageCustomStyles:L,getInterruptOptions:F})}):$()})})});xl.displayName="MessageList";const Fh={value:""};function Dr({className:e="",placeholder:t="Type your message...",autoFocus:n=!0,maxHeight:r=void 0,streamingDebounceMs:o=500,streamingThrottleMs:s,followNewMessages:i=!0,enableFileUpload:a=!0,enableExcelUpload:l=!1,enableMessageEditing:c=!0,showToolMessages:d=!0,toolRenderers:f,toolArtifactRenderers:m,payloadExtras:p={},customStyles:v={},messageCustomStyles:g,onMessageSent:x,onExcelUploadSuccess:y,onError:b,defaultMessage:C}){const{api:k}=Qr(),S=k.baseUrl,{currentThreadId:T}=vr(),{threadId:E,messages:A,isLoading:R,navigateToCheckpoint:L,returnToLatest:F,checkpoint:K,checkpoints:J,interrupt:P,metadata:Y,checkpointIndex:q,respondToInterrupt:W}=ro(),{isStreaming:D,error:I,connectionState:G,submit:X,stop:M}=Hi(),B=E??T??null,_=(K==null?void 0:K.id)??null,$=(K==null?void 0:K.namespace)??null,z=(Y==null?void 0:Y.assemblingMessageId)??null,O=P,j=O?wu(O.id):null,U=j!==null?{type:"interrupt",id:j}:null,[Q,se]=w.useState(!1),[ie,Se]=w.useState(!1);w.useEffect(()=>{O||se(!1)},[O]);const xe=w.useCallback(()=>{se(!0)},[]),Re=w.useCallback(()=>{se(!1)},[]),Ve=w.useCallback(N=>{},[]),De=w.useCallback(async(N,Z,re)=>{try{xe(),await W(N,Z,re)}catch(de){console.error("Failed to respond to interrupt:",de)}finally{Re()}},[Re,xe,W]),Ge=w.useCallback(()=>De(!0),[De]),He=w.useCallback(()=>De(!1),[De]),ot=w.useCallback((N,Z)=>De(!0,Z),[De]),ut=!!O||Q,[nt,Le]=w.useState(null),[Ke,$e]=w.useState(""),[Te,Ae]=w.useState(null),[dt,Et]=w.useState(null),[at,It]=w.useState(!1),[bt,ft]=w.useState(null),Nt=w.useRef(!1),[At,Ct]=w.useState(()=>Fh.value),on=w.useRef(At),Tt=w.useRef(null),Ie=w.useCallback(N=>{Fh.value=N,Ct(N)},[]),[Ue,jt]=w.useState(!1),te=w.useRef(null),ge=w.useCallback(N=>{Ie(N)},[Ie]);w.useEffect(()=>{D||Se(!1)},[D]),w.useEffect(()=>{Y!=null&&Y.assemblingMessageId&&Se(!1)},[Y==null?void 0:Y.assemblingMessageId]);const[rt,fe]=w.useState("desktop");w.useEffect(()=>{const N=()=>{const Z=window.innerWidth;fe(Z<640?"phone":Z<1024?"tablet":"desktop")};return N(),window.addEventListener("resize",N),()=>window.removeEventListener("resize",N)},[]),w.useEffect(()=>{Nt.current=!1},[B]),w.useEffect(()=>{on.current=At},[At]),w.useEffect(()=>{if(!nt){Tt.current=null;return}Tt.current===null&&(Tt.current=on.current),Ie(Ke??"")},[Ke,nt,Ie]),w.useEffect(()=>{if(C!==void 0){ft(C);return}(async()=>{if(!S){ft(null);return}try{const re=(await k.getAgent("default")).uiDefaultMessage||"";ft(re||null)}catch(Z){console.warn("Failed to fetch default message:",Z),ft(null)}})()},[k,S,C]),w.useEffect(()=>{I&&!at&&(b==null||b(I))},[I,at,b]);const ke=async(N,Z)=>{const re=N.trim();if(!(!re&&Z.length===0))try{const de=nt?(Te==null?void 0:Te.checkpointId)??_??void 0:_??void 0,Me=nt?(Te==null?void 0:Te.checkpointNs)??$??void 0:$??void 0;await X({text:re||"",attachments:Z,payload:p},{checkpointId:de,checkpointNs:Me,edit:!!nt,originalMessageId:nt??void 0}),x==null||x(re),Se(!0),Ie(""),Et(null),Le(null),$e(""),Ae(null)}catch(de){const Me=(de==null?void 0:de.message)||"Failed to send message";Et(Me),b==null||b(Me),Se(!1)}},Fe=w.useCallback(async N=>{await X({attachments:[N],payload:p},{checkpointId:_??void 0,checkpointNs:$??void 0}),y==null||y({file:N})},[_,$,p,y,X]),ht=w.useCallback((N,Z,re)=>{c&&(Tt.current=At,Le(N),$e(Z),Ie(Z),Et(null),Ae({checkpointId:(re==null?void 0:re.checkpointId)??null,checkpointNs:(re==null?void 0:re.checkpointNs)??null}))},[At,c,Ie]),pt=w.useCallback(()=>{Le(null),$e(""),Ae(null),Et(null),Ie(Tt.current??At),Tt.current=null},[At,Ie]),je=w.useCallback((N,Z,re)=>{ht(N,Z,re)},[ht]),Ye=w.useCallback(N=>{let Z=null;for(let Oe=N-1;Oe>=0;Oe--)if(A[Oe].role==="user"){Z=A[Oe];break}if(!Z)return;const re=Array.isArray(Z.content)?Z.content:[],Me=re.filter(Oe=>(Oe==null?void 0:Oe.type)==="text").map(Oe=>Oe.text).join("")||(()=>{try{return JSON.stringify(re,null,2)}catch{return String(re)}})();Me&&X({text:Me,payload:p},{checkpointId:_??void 0,checkpointNs:$??void 0,edit:!0,originalMessageId:Z.id})},[A,X,_,$,p]),we=w.useCallback(async N=>{if(T){jt(!0);try{if(!N){await F(),requestAnimationFrame(()=>{var de;(de=te.current)==null||de.scrollToLatest()});return}const Z=J.find(de=>de.checkpointId===N),re=(Z==null?void 0:Z.checkpointNs)??null;await L(N,re),requestAnimationFrame(()=>{var de;(de=te.current)==null||de.scrollToTop()})}finally{jt(!1)}}},[J,T,te,L,F]),Qe=w.useCallback(async(N,Z,re)=>{await we(re?null:N)},[we]),Xe=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${v.container||""}`,ct=`flex-1 min-h-0 min-w-0 max-h-full w-full overflow-hidden overscroll-contain break-words break-anywhere p-4 ${O?"pb-32":""} bg-transparent ${v.messagesArea||""}`,sn=`relative flex-shrink-0 w-full border-t p-4 bg-transparent ${v.inputArea||""}`;return u.jsxs("div",{className:Xe,children:[!!I&&!at&&u.jsxs("div",{className:"flex-shrink-0 bg-red-50 border border-red-200 text-red-800 px-4 py-2 text-sm flex items-center justify-between",children:[u.jsx("span",{children:I}),u.jsx(Je,{variant:"ghost",size:"sm",onClick:()=>It(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:u.jsx(le.X,{size:16})})]}),u.jsxs("div",{className:`relative ${ct}`,style:r?{maxHeight:r}:void 0,children:[u.jsx(xl,{ref:te,className:"h-full",style:{height:"100%"},messages:A,isStreaming:D,streamingAssistantId:z,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:rt,enableMessageEditing:c,editingMessageId:nt,onEdit:je,onRegenerate:Ye,onCancelEdit:pt,emptyMessage:bt??void 0,isNavigatingCheckpoint:Ue,showToolMessages:d,toolRenderers:f,toolArtifactRenderers:m,checkpointIndex:q,activeCheckpointId:_,onSelectCheckpoint:Qe,createSyntheticThinkingMessage:!0,forceSyntheticThinking:ie,getMessageCustomStyles:g,getInterruptOptions:Ve}),(G==="reconnecting"||G==="connecting")&&u.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-muted/80 px-3 py-1 text-xs font-medium text-foreground shadow-sm backdrop-blur-sm dark:bg-muted/60",children:u.jsxs("span",{className:"flex items-center gap-2",children:[u.jsx(le.Loader2,{className:"h-3 w-3 animate-spin"}),G==="reconnecting"?"Reconnecting…":"Connecting…"]})}),G==="error"&&u.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-destructive/10 px-3 py-1 text-xs font-semibold text-destructive shadow-sm",children:"Connection lost"}),R&&u.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[u.jsx(le.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]}),Ue&&u.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[u.jsx(le.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading checkpoint…"})]}),O&&U&&u.jsx("div",{className:"pointer-events-auto absolute inset-x-0 bottom-6 z-30 flex justify-center px-4",children:u.jsx("div",{className:"w-full max-w-3xl",children:u.jsx(hl,{interruptPart:U,onApprove:Ge,onReject:He,onSelectAlternative:ot,disabled:Q,isActive:!0,payload:O.value})})})]}),u.jsxs("div",{className:sn,children:[nt&&u.jsx("div",{className:"mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(le.Edit3,{size:16,className:"text-blue-600"}),u.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),u.jsx(Je,{variant:"ghost",size:"sm",onClick:pt,className:"text-blue-600 hover:bg-blue-100",children:u.jsx(le.X,{size:16})})]})}),dt&&u.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:dt}),u.jsx(LS,{composerValue:At,onComposerChange:ge,onSend:ke,onCancelEdit:pt,onStop:M,editingMessageId:nt,editingInitialValue:Ke,placeholder:nt?"Edit your message...":t,isStreaming:D,disabled:ut,enableFileUpload:a,enableExcelUpload:l,onExcelUpload:Fe,onError:b,customStyles:v,textareaClassName:v.textarea||"",allowEmptySend:!1,inputError:dt})]})]})}var Bh=1,tk=.9,nk=.8,rk=.17,vl=.1,wl=.999,ok=.9999,sk=.99,ik=/[\\\/_+.#"@\[\(\{&]/,ak=/[\\\/_+.#"@\[\(\{&]/g,lk=/[\s-]/,zh=/[\s-]/g;function bl(e,t,n,r,o,s,i){if(s===t.length)return o===e.length?Bh:sk;var a=`${o},${s}`;if(i[a]!==void 0)return i[a];for(var l=r.charAt(s),c=n.indexOf(l,o),d=0,f,m,p,v;c>=0;)f=bl(e,t,n,r,c+1,s+1,i),f>d&&(c===o?f*=Bh:ik.test(e.charAt(c-1))?(f*=nk,p=e.slice(o,c-1).match(ak),p&&o>0&&(f*=Math.pow(wl,p.length))):lk.test(e.charAt(c-1))?(f*=tk,v=e.slice(o,c-1).match(zh),v&&o>0&&(f*=Math.pow(wl,v.length))):(f*=rk,o>0&&(f*=Math.pow(wl,c-o))),e.charAt(c)!==t.charAt(s)&&(f*=ok)),(f<vl&&n.charAt(c-1)===r.charAt(s+1)||r.charAt(s+1)===r.charAt(s)&&n.charAt(c-1)!==r.charAt(s))&&(m=bl(e,t,n,r,c+1,s+2,i),m*vl>f&&(f=m*vl)),f>d&&(d=f),c=n.indexOf(l,c+1);return i[a]=d,d}function Hh(e){return e.toLowerCase().replace(zh," ")}function ck(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,bl(e,t,Hh(e),Hh(t),0,0,{})}var Po='[cmdk-group=""]',yl='[cmdk-group-items=""]',uk='[cmdk-group-heading=""]',Uh='[cmdk-item=""]',Wh=`${Uh}:not([aria-disabled="true"])`,Sl="cmdk-item-select",Lr="data-value",dk=(e,t,n)=>ck(e,t,n),Vh=h.createContext(void 0),_o=()=>h.useContext(Vh),Kh=h.createContext(void 0),Cl=()=>h.useContext(Kh),qh=h.createContext(void 0),Gh=h.forwardRef((e,t)=>{let n=$r(()=>{var M,B;return{search:"",value:(B=(M=e.value)!=null?M:e.defaultValue)!=null?B:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=$r(()=>new Set),o=$r(()=>new Map),s=$r(()=>new Map),i=$r(()=>new Set),a=Yh(e),{label:l,children:c,value:d,onValueChange:f,filter:m,shouldFilter:p,loop:v,disablePointerSelection:g=!1,vimBindings:x=!0,...y}=e,b=_t(),C=_t(),k=_t(),S=h.useRef(null),T=Sk();ur(()=>{if(d!==void 0){let M=d.trim();n.current.value=M,E.emit()}},[d]),ur(()=>{T(6,J)},[]);let E=h.useMemo(()=>({subscribe:M=>(i.current.add(M),()=>i.current.delete(M)),snapshot:()=>n.current,setState:(M,B,_)=>{var $,z,O,j;if(!Object.is(n.current[M],B)){if(n.current[M]=B,M==="search")K(),L(),T(1,F);else if(M==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let U=document.getElementById(k);U?U.focus():($=document.getElementById(b))==null||$.focus()}if(T(7,()=>{var U;n.current.selectedItemId=(U=P())==null?void 0:U.id,E.emit()}),_||T(5,J),((z=a.current)==null?void 0:z.value)!==void 0){let U=B??"";(j=(O=a.current).onValueChange)==null||j.call(O,U);return}}E.emit()}},emit:()=>{i.current.forEach(M=>M())}}),[]),A=h.useMemo(()=>({value:(M,B,_)=>{var $;B!==(($=s.current.get(M))==null?void 0:$.value)&&(s.current.set(M,{value:B,keywords:_}),n.current.filtered.items.set(M,R(B,_)),T(2,()=>{L(),E.emit()}))},item:(M,B)=>(r.current.add(M),B&&(o.current.has(B)?o.current.get(B).add(M):o.current.set(B,new Set([M]))),T(3,()=>{K(),L(),n.current.value||F(),E.emit()}),()=>{s.current.delete(M),r.current.delete(M),n.current.filtered.items.delete(M);let _=P();T(4,()=>{K(),(_==null?void 0:_.getAttribute("id"))===M&&F(),E.emit()})}),group:M=>(o.current.has(M)||o.current.set(M,new Set),()=>{s.current.delete(M),o.current.delete(M)}),filter:()=>a.current.shouldFilter,label:l||e["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:b,inputId:k,labelId:C,listInnerRef:S}),[]);function R(M,B){var _,$;let z=($=(_=a.current)==null?void 0:_.filter)!=null?$:dk;return M?z(M,n.current.search,B):0}function L(){if(!n.current.search||a.current.shouldFilter===!1)return;let M=n.current.filtered.items,B=[];n.current.filtered.groups.forEach($=>{let z=o.current.get($),O=0;z.forEach(j=>{let U=M.get(j);O=Math.max(U,O)}),B.push([$,O])});let _=S.current;Y().sort(($,z)=>{var O,j;let U=$.getAttribute("id"),Q=z.getAttribute("id");return((O=M.get(Q))!=null?O:0)-((j=M.get(U))!=null?j:0)}).forEach($=>{let z=$.closest(yl);z?z.appendChild($.parentElement===z?$:$.closest(`${yl} > *`)):_.appendChild($.parentElement===_?$:$.closest(`${yl} > *`))}),B.sort(($,z)=>z[1]-$[1]).forEach($=>{var z;let O=(z=S.current)==null?void 0:z.querySelector(`${Po}[${Lr}="${encodeURIComponent($[0])}"]`);O==null||O.parentElement.appendChild(O)})}function F(){let M=Y().find(_=>_.getAttribute("aria-disabled")!=="true"),B=M==null?void 0:M.getAttribute(Lr);E.setState("value",B||void 0)}function K(){var M,B,_,$;if(!n.current.search||a.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let z=0;for(let O of r.current){let j=(B=(M=s.current.get(O))==null?void 0:M.value)!=null?B:"",U=($=(_=s.current.get(O))==null?void 0:_.keywords)!=null?$:[],Q=R(j,U);n.current.filtered.items.set(O,Q),Q>0&&z++}for(let[O,j]of o.current)for(let U of j)if(n.current.filtered.items.get(U)>0){n.current.filtered.groups.add(O);break}n.current.filtered.count=z}function J(){var M,B,_;let $=P();$&&(((M=$.parentElement)==null?void 0:M.firstChild)===$&&((_=(B=$.closest(Po))==null?void 0:B.querySelector(uk))==null||_.scrollIntoView({block:"nearest"})),$.scrollIntoView({block:"nearest"}))}function P(){var M;return(M=S.current)==null?void 0:M.querySelector(`${Uh}[aria-selected="true"]`)}function Y(){var M;return Array.from(((M=S.current)==null?void 0:M.querySelectorAll(Wh))||[])}function q(M){let B=Y()[M];B&&E.setState("value",B.getAttribute(Lr))}function W(M){var B;let _=P(),$=Y(),z=$.findIndex(j=>j===_),O=$[z+M];(B=a.current)!=null&&B.loop&&(O=z+M<0?$[$.length-1]:z+M===$.length?$[0]:$[z+M]),O&&E.setState("value",O.getAttribute(Lr))}function D(M){let B=P(),_=B==null?void 0:B.closest(Po),$;for(;_&&!$;)_=M>0?bk(_,Po):yk(_,Po),$=_==null?void 0:_.querySelector(Wh);$?E.setState("value",$.getAttribute(Lr)):W(M)}let I=()=>q(Y().length-1),G=M=>{M.preventDefault(),M.metaKey?I():M.altKey?D(1):W(1)},X=M=>{M.preventDefault(),M.metaKey?q(0):M.altKey?D(-1):W(-1)};return h.createElement(pe.div,{ref:t,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:M=>{var B;(B=y.onKeyDown)==null||B.call(y,M);let _=M.nativeEvent.isComposing||M.keyCode===229;if(!(M.defaultPrevented||_))switch(M.key){case"n":case"j":{x&&M.ctrlKey&&G(M);break}case"ArrowDown":{G(M);break}case"p":case"k":{x&&M.ctrlKey&&X(M);break}case"ArrowUp":{X(M);break}case"Home":{M.preventDefault(),q(0);break}case"End":{M.preventDefault(),I();break}case"Enter":{M.preventDefault();let $=P();if($){let z=new Event(Sl);$.dispatchEvent(z)}}}}},h.createElement("label",{"cmdk-label":"",htmlFor:A.inputId,id:A.labelId,style:Tk},l),ti(e,M=>h.createElement(Kh.Provider,{value:E},h.createElement(Vh.Provider,{value:A},M))))}),fk=h.forwardRef((e,t)=>{var n,r;let o=_t(),s=h.useRef(null),i=h.useContext(qh),a=_o(),l=Yh(e),c=(r=(n=l.current)==null?void 0:n.forceMount)!=null?r:i==null?void 0:i.forceMount;ur(()=>{if(!c)return a.item(o,i==null?void 0:i.id)},[c]);let d=Xh(o,s,[e.value,e.children,s],e.keywords),f=Cl(),m=Kn(T=>T.value&&T.value===d.current),p=Kn(T=>c||a.filter()===!1?!0:T.search?T.filtered.items.get(o)>0:!0);h.useEffect(()=>{let T=s.current;if(!(!T||e.disabled))return T.addEventListener(Sl,v),()=>T.removeEventListener(Sl,v)},[p,e.onSelect,e.disabled]);function v(){var T,E;g(),(E=(T=l.current).onSelect)==null||E.call(T,d.current)}function g(){f.setState("value",d.current,!0)}if(!p)return null;let{disabled:x,value:y,onSelect:b,forceMount:C,keywords:k,...S}=e;return h.createElement(pe.div,{ref:Mn(s,t),...S,id:o,"cmdk-item":"",role:"option","aria-disabled":!!x,"aria-selected":!!m,"data-disabled":!!x,"data-selected":!!m,onPointerMove:x||a.getDisablePointerSelection()?void 0:g,onClick:x?void 0:v},e.children)}),pk=h.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:o,...s}=e,i=_t(),a=h.useRef(null),l=h.useRef(null),c=_t(),d=_o(),f=Kn(p=>o||d.filter()===!1?!0:p.search?p.filtered.groups.has(i):!0);ur(()=>d.group(i),[]),Xh(i,a,[e.value,e.heading,l]);let m=h.useMemo(()=>({id:i,forceMount:o}),[o]);return h.createElement(pe.div,{ref:Mn(a,t),...s,"cmdk-group":"",role:"presentation",hidden:f?void 0:!0},n&&h.createElement("div",{ref:l,"cmdk-group-heading":"","aria-hidden":!0,id:c},n),ti(e,p=>h.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?c:void 0},h.createElement(qh.Provider,{value:m},p))))}),hk=h.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=h.useRef(null),s=Kn(i=>!i.search);return!n&&!s?null:h.createElement(pe.div,{ref:Mn(o,t),...r,"cmdk-separator":"",role:"separator"})}),mk=h.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,o=e.value!=null,s=Cl(),i=Kn(c=>c.search),a=Kn(c=>c.selectedItemId),l=_o();return h.useEffect(()=>{e.value!=null&&s.setState("search",e.value)},[e.value]),h.createElement(pe.input,{ref:t,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":l.listId,"aria-labelledby":l.labelId,"aria-activedescendant":a,id:l.inputId,type:"text",value:o?e.value:i,onChange:c=>{o||s.setState("search",c.target.value),n==null||n(c.target.value)}})}),gk=h.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...o}=e,s=h.useRef(null),i=h.useRef(null),a=Kn(c=>c.selectedItemId),l=_o();return h.useEffect(()=>{if(i.current&&s.current){let c=i.current,d=s.current,f,m=new ResizeObserver(()=>{f=requestAnimationFrame(()=>{let p=c.offsetHeight;d.style.setProperty("--cmdk-list-height",p.toFixed(1)+"px")})});return m.observe(c),()=>{cancelAnimationFrame(f),m.unobserve(c)}}},[]),h.createElement(pe.div,{ref:Mn(s,t),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":r,id:l.listId},ti(e,c=>h.createElement("div",{ref:Mn(i,l.listInnerRef),"cmdk-list-sizer":""},c)))}),xk=h.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:o,contentClassName:s,container:i,...a}=e;return h.createElement(nl,{open:n,onOpenChange:r},h.createElement(rl,{container:i},h.createElement(Io,{"cmdk-overlay":"",className:o}),h.createElement(No,{"aria-label":e.label,"cmdk-dialog":"",className:s},h.createElement(Gh,{ref:t,...a}))))}),vk=h.forwardRef((e,t)=>Kn(n=>n.filtered.count===0)?h.createElement(pe.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),wk=h.forwardRef((e,t)=>{let{progress:n,children:r,label:o="Loading...",...s}=e;return h.createElement(pe.div,{ref:t,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},ti(e,i=>h.createElement("div",{"aria-hidden":!0},i)))}),Wt=Object.assign(Gh,{List:gk,Item:fk,Input:mk,Group:pk,Separator:hk,Dialog:xk,Empty:vk,Loading:wk});function bk(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function yk(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function Yh(e){let t=h.useRef(e);return ur(()=>{t.current=e}),t}var ur=typeof window>"u"?h.useEffect:h.useLayoutEffect;function $r(e){let t=h.useRef();return t.current===void 0&&(t.current=e()),t}function Kn(e){let t=Cl(),n=()=>e(t.snapshot());return h.useSyncExternalStore(t.subscribe,n,n)}function Xh(e,t,n,r=[]){let o=h.useRef(),s=_o();return ur(()=>{var i;let a=(()=>{var c;for(let d of n){if(typeof d=="string")return d.trim();if(typeof d=="object"&&"current"in d)return d.current?(c=d.current.textContent)==null?void 0:c.trim():o.current}})(),l=r.map(c=>c.trim());s.value(e,a,l),(i=t.current)==null||i.setAttribute(Lr,a),o.current=a}),o}var Sk=()=>{let[e,t]=h.useState(),n=$r(()=>new Map);return ur(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,o)=>{n.current.set(r,o),t({})}};function Ck(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function ti({asChild:e,children:t},n){return e&&h.isValidElement(t)?h.cloneElement(Ck(t),{ref:t.ref},n(t.props.children)):n(t)}var Tk={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const Tl=h.forwardRef(({className:e,...t},n)=>u.jsx(Wt,{ref:n,className:ne("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));Tl.displayName=Wt.displayName;const kl=h.forwardRef(({className:e,...t},n)=>u.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[u.jsx(le.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),u.jsx(Wt.Input,{ref:n,className:ne("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...t})]}));kl.displayName=Wt.Input.displayName;const El=h.forwardRef(({className:e,...t},n)=>u.jsx(Wt.List,{ref:n,className:ne("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));El.displayName=Wt.List.displayName;const Il=h.forwardRef((e,t)=>u.jsx(Wt.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));Il.displayName=Wt.Empty.displayName;const Nl=h.forwardRef(({className:e,...t},n)=>u.jsx(Wt.Group,{ref:n,className:ne("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",e),...t}));Nl.displayName=Wt.Group.displayName;const kk=h.forwardRef(({className:e,...t},n)=>u.jsx(Wt.Separator,{ref:n,className:ne("-mx-1 h-px bg-border",e),...t}));kk.displayName=Wt.Separator.displayName;const Al=h.forwardRef(({className:e,...t},n)=>u.jsx(Wt.Item,{ref:n,className:ne("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",e),...t}));Al.displayName=Wt.Item.displayName;function jl(e,[t,n]){return Math.min(n,Math.max(t,e))}function Ek(e,t){return h.useReducer((n,r)=>t[n][r]??n,e)}var Pl="ScrollArea",[Jh,UN]=cn(Pl),[Ik,rn]=Jh(Pl),Zh=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=h.useState(null),[c,d]=h.useState(null),[f,m]=h.useState(null),[p,v]=h.useState(null),[g,x]=h.useState(null),[y,b]=h.useState(0),[C,k]=h.useState(0),[S,T]=h.useState(!1),[E,A]=h.useState(!1),R=Pe(t,F=>l(F)),L=Qo(o);return u.jsx(Ik,{scope:n,type:r,dir:L,scrollHideDelay:s,scrollArea:a,viewport:c,onViewportChange:d,content:f,onContentChange:m,scrollbarX:p,onScrollbarXChange:v,scrollbarXEnabled:S,onScrollbarXEnabledChange:T,scrollbarY:g,onScrollbarYChange:x,scrollbarYEnabled:E,onScrollbarYEnabledChange:A,onCornerWidthChange:b,onCornerHeightChange:k,children:u.jsx(pe.div,{dir:L,...i,ref:R,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":C+"px",...e.style}})})});Zh.displayName=Pl;var Qh="ScrollAreaViewport",em=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=rn(Qh,n),a=h.useRef(null),l=Pe(t,a,i.onViewportChange);return u.jsxs(u.Fragment,{children:[u.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),u.jsx(pe.div,{"data-radix-scroll-area-viewport":"",...s,ref:l,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:u.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});em.displayName=Qh;var In="ScrollAreaScrollbar",_l=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=rn(In,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return h.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?u.jsx(Nk,{...r,ref:t,forceMount:n}):o.type==="scroll"?u.jsx(Ak,{...r,ref:t,forceMount:n}):o.type==="auto"?u.jsx(tm,{...r,ref:t,forceMount:n}):o.type==="always"?u.jsx(Rl,{...r,ref:t}):null});_l.displayName=In;var Nk=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=rn(In,e.__scopeScrollArea),[s,i]=h.useState(!1);return h.useEffect(()=>{const a=o.scrollArea;let l=0;if(a){const c=()=>{window.clearTimeout(l),i(!0)},d=()=>{l=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",c),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(l),a.removeEventListener("pointerenter",c),a.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),u.jsx(Ht,{present:n||s,children:u.jsx(tm,{"data-state":s?"visible":"hidden",...r,ref:t})})}),Ak=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=rn(In,e.__scopeScrollArea),s=e.orientation==="horizontal",i=si(()=>l("SCROLL_END"),100),[a,l]=Ek("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return h.useEffect(()=>{if(a==="idle"){const c=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(c)}},[a,o.scrollHideDelay,l]),h.useEffect(()=>{const c=o.viewport,d=s?"scrollLeft":"scrollTop";if(c){let f=c[d];const m=()=>{const p=c[d];f!==p&&(l("SCROLL"),i()),f=p};return c.addEventListener("scroll",m),()=>c.removeEventListener("scroll",m)}},[o.viewport,s,l,i]),u.jsx(Ht,{present:n||a!=="hidden",children:u.jsx(Rl,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:ae(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:ae(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),tm=h.forwardRef((e,t)=>{const n=rn(In,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=h.useState(!1),a=e.orientation==="horizontal",l=si(()=>{if(n.viewport){const c=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?c:d)}},10);return Fr(n.viewport,l),Fr(n.content,l),u.jsx(Ht,{present:r||s,children:u.jsx(Rl,{"data-state":s?"visible":"hidden",...o,ref:t})})}),Rl=h.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=rn(In,e.__scopeScrollArea),s=h.useRef(null),i=h.useRef(0),[a,l]=h.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),c=im(a.viewport,a.content),d={...r,sizes:a,onSizesChange:l,hasThumb:c>0&&c<1,onThumbChange:m=>s.current=m,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:m=>i.current=m};function f(m,p){return Ok(m,i.current,a,p)}return n==="horizontal"?u.jsx(jk,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollLeft,p=am(m,a,o.dir);s.current.style.transform=`translate3d(${p}px, 0, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollLeft=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollLeft=f(m,o.dir))}}):n==="vertical"?u.jsx(Pk,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollTop,p=am(m,a);s.current.style.transform=`translate3d(0, ${p}px, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollTop=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollTop=f(m))}}):null}),jk=h.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=rn(In,e.__scopeScrollArea),[i,a]=h.useState(),l=h.useRef(null),c=Pe(t,l,s.onScrollbarXChange);return h.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(rm,{"data-orientation":"horizontal",...o,ref:c,sizes:n,style:{bottom:0,left:s.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:s.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":oi(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.x),onDragScroll:d=>e.onDragScroll(d.x),onWheelScroll:(d,f)=>{if(s.viewport){const m=s.viewport.scrollLeft+d.deltaX;e.onWheelScroll(m),cm(m,f)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:l.current.clientWidth,paddingStart:ri(i.paddingLeft),paddingEnd:ri(i.paddingRight)}})}})}),Pk=h.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=rn(In,e.__scopeScrollArea),[i,a]=h.useState(),l=h.useRef(null),c=Pe(t,l,s.onScrollbarYChange);return h.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(rm,{"data-orientation":"vertical",...o,ref:c,sizes:n,style:{top:0,right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":oi(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.y),onDragScroll:d=>e.onDragScroll(d.y),onWheelScroll:(d,f)=>{if(s.viewport){const m=s.viewport.scrollTop+d.deltaY;e.onWheelScroll(m),cm(m,f)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:l.current.clientHeight,paddingStart:ri(i.paddingTop),paddingEnd:ri(i.paddingBottom)}})}})}),[_k,nm]=Jh(In),rm=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:l,onDragScroll:c,onWheelScroll:d,onResize:f,...m}=e,p=rn(In,n),[v,g]=h.useState(null),x=Pe(t,R=>g(R)),y=h.useRef(null),b=h.useRef(""),C=p.viewport,k=r.content-r.viewport,S=gt(d),T=gt(l),E=si(f,10);function A(R){if(y.current){const L=R.clientX-y.current.left,F=R.clientY-y.current.top;c({x:L,y:F})}}return h.useEffect(()=>{const R=L=>{const F=L.target;(v==null?void 0:v.contains(F))&&S(L,k)};return document.addEventListener("wheel",R,{passive:!1}),()=>document.removeEventListener("wheel",R,{passive:!1})},[C,v,k,S]),h.useEffect(T,[r,T]),Fr(v,E),Fr(p.content,E),u.jsx(_k,{scope:n,scrollbar:v,hasThumb:o,onThumbChange:gt(s),onThumbPointerUp:gt(i),onThumbPositionChange:T,onThumbPointerDown:gt(a),children:u.jsx(pe.div,{...m,ref:x,style:{position:"absolute",...m.style},onPointerDown:ae(e.onPointerDown,R=>{R.button===0&&(R.target.setPointerCapture(R.pointerId),y.current=v.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",p.viewport&&(p.viewport.style.scrollBehavior="auto"),A(R))}),onPointerMove:ae(e.onPointerMove,A),onPointerUp:ae(e.onPointerUp,R=>{const L=R.target;L.hasPointerCapture(R.pointerId)&&L.releasePointerCapture(R.pointerId),document.body.style.webkitUserSelect=b.current,p.viewport&&(p.viewport.style.scrollBehavior=""),y.current=null})})})}),ni="ScrollAreaThumb",om=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=nm(ni,e.__scopeScrollArea);return u.jsx(Ht,{present:n||o.hasThumb,children:u.jsx(Rk,{ref:t,...r})})}),Rk=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=rn(ni,n),i=nm(ni,n),{onThumbPositionChange:a}=i,l=Pe(t,f=>i.onThumbChange(f)),c=h.useRef(void 0),d=si(()=>{c.current&&(c.current(),c.current=void 0)},100);return h.useEffect(()=>{const f=s.viewport;if(f){const m=()=>{if(d(),!c.current){const p=Dk(f,a);c.current=p,a()}};return a(),f.addEventListener("scroll",m),()=>f.removeEventListener("scroll",m)}},[s.viewport,d,a]),u.jsx(pe.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:l,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:ae(e.onPointerDownCapture,f=>{const p=f.target.getBoundingClientRect(),v=f.clientX-p.left,g=f.clientY-p.top;i.onThumbPointerDown({x:v,y:g})}),onPointerUp:ae(e.onPointerUp,i.onThumbPointerUp)})});om.displayName=ni;var Ml="ScrollAreaCorner",sm=h.forwardRef((e,t)=>{const n=rn(Ml,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?u.jsx(Mk,{...e,ref:t}):null});sm.displayName=Ml;var Mk=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=rn(Ml,n),[s,i]=h.useState(0),[a,l]=h.useState(0),c=!!(s&&a);return Fr(o.scrollbarX,()=>{var f;const d=((f=o.scrollbarX)==null?void 0:f.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),Fr(o.scrollbarY,()=>{var f;const d=((f=o.scrollbarY)==null?void 0:f.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),c?u.jsx(pe.div,{...r,ref:t,style:{width:s,height:a,position:"absolute",right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function ri(e){return e?parseInt(e,10):0}function im(e,t){const n=e/t;return isNaN(n)?0:n}function oi(e){const t=im(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function Ok(e,t,n,r="ltr"){const o=oi(n),s=o/2,i=t||s,a=o-i,l=n.scrollbar.paddingStart+i,c=n.scrollbar.size-n.scrollbar.paddingEnd-a,d=n.content-n.viewport,f=r==="ltr"?[0,d]:[d*-1,0];return lm([l,c],f)(e)}function am(e,t,n="ltr"){const r=oi(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,i=t.content-t.viewport,a=s-r,l=n==="ltr"?[0,i]:[i*-1,0],c=jl(e,l);return lm([0,i],[0,a])(c)}function lm(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function cm(e,t){return e>0&&e<t}var Dk=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return function o(){const s={left:e.scrollLeft,top:e.scrollTop},i=n.left!==s.left,a=n.top!==s.top;(i||a)&&t(),n=s,r=window.requestAnimationFrame(o)}(),()=>window.cancelAnimationFrame(r)};function si(e,t){const n=gt(e),r=h.useRef(0);return h.useEffect(()=>()=>window.clearTimeout(r.current),[]),h.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function Fr(e,t){const n=gt(t);kt(()=>{let r=0;if(e){const o=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(n)});return o.observe(e),()=>{window.cancelAnimationFrame(r),o.unobserve(e)}}},[e,n])}var um=Zh,Lk=em,$k=sm;const Ol=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(um,{ref:r,className:ne("relative overflow-hidden",e),...n,children:[u.jsx(Lk,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),u.jsx(dm,{}),u.jsx($k,{})]}));Ol.displayName=um.displayName;const dm=h.forwardRef(({className:e,orientation:t="vertical",...n},r)=>u.jsx(_l,{ref:r,orientation:t,className:ne("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:u.jsx(om,{className:"relative flex-1 rounded-full bg-border"})}));dm.displayName=_l.displayName;const Dl=h.forwardRef(({className:e,type:t,...n},r)=>u.jsx("input",{type:t,className:ne("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:r,...n}));Dl.displayName="Input";const Fk="group relative p-3 rounded-lg cursor-pointer transition-colors border text-gray-900 dark:text-slate-100",Bk="bg-slate-700 border-slate-600 hover:bg-slate-600",zk="bg-slate-600 border-slate-500";function fm({thread:e,isActive:t,editingThreadId:n,editingTitle:r,onSelect:o,onStartEditing:s,onEditingTitleChange:i,onSaveEditing:a,onCancelEditing:l,onShare:c,onDelete:d,showEditTitle:f,showDeleteButton:m,formatDate:p,getDisplayThreadTitle:v,secondaryLine:g,itemClassName:x,activeItemClassName:y}){const b=n===e.threadId,C=t?`${y??zk}`:`${x??Bk}`,k=S=>{S.stopPropagation(),o(e.threadId)};return u.jsxs("div",{onClick:k,className:`${Fk} ${C}`,children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("div",{className:"flex-1 min-w-0",children:b?u.jsxs("div",{className:"flex items-center gap-2",onClick:S=>S.stopPropagation(),children:[u.jsx(Dl,{value:r,onChange:S=>i(S.target.value),onKeyDown:S=>{S.key==="Enter"?a(e.threadId):S.key==="Escape"&&l()},className:"h-6 text-sm",autoFocus:!0}),u.jsx(Je,{variant:"ghost",size:"sm",onClick:()=>a(e.threadId),className:"h-6 w-6 p-0",children:u.jsx(le.Check,{size:12})}),u.jsx(Je,{variant:"ghost",size:"sm",onClick:l,className:"h-6 w-6 p-0",children:u.jsx(le.X,{size:12})})]}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"font-medium text-sm truncate text-gray-900 dark:text-slate-100",children:v(e)}),u.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[u.jsx(le.Calendar,{size:10}),u.jsx("span",{children:p(e.updatedAt||e.createdAt)})]}),g&&u.jsx("div",{className:"text-[11px] text-muted-foreground mt-1",children:g})]})}),u.jsx("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:u.jsxs(ks,{children:[u.jsx(Es,{asChild:!0,children:u.jsx(Je,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",children:u.jsx(le.MoreHorizontal,{size:12})})}),u.jsxs(go,{align:"end",sideOffset:6,className:"w-44",children:[u.jsxs(Fn,{onClick:S=>{S.preventDefault(),c(e.threadId)},children:[u.jsx(le.Share2,{className:"mr-2 h-4 w-4"}),"Share thread"]}),f&&n!==e.threadId&&u.jsxs(Fn,{onClick:S=>{S.preventDefault(),s(e,S)},children:[u.jsx(le.Edit3,{className:"mr-2 h-4 w-4"}),"Rename"]}),m&&d&&u.jsxs(Fn,{className:"text-red-400 hover:text-red-300",onClick:S=>{S.preventDefault(),d(e.threadId,S)},children:[u.jsx(le.Trash2,{className:"mr-2 h-4 w-4"}),"Delete"]})]})]})})]}),t&&u.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]})}const pm=25,hm="thread-manager-view",Hk=e=>e==="default"||e==="shared",Uk=()=>{if(typeof window>"u")return null;try{const e=window.localStorage.getItem(hm);if(Hk(e))return e}catch{}return null};function mm({defaultView:e}={}){const[t,n]=w.useState(()=>Uk()??e??"default");w.useEffect(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem(hm,t)}catch{}},[t]);const r=w.useCallback(o=>{n(o)},[]);return{view:t,setView:r}}const Wk=[{key:"default",label:"My chats"},{key:"shared",label:"Shared with you"}];function ii({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:i=null,navigateToThread:a,onThreadSelect:l,onThreadCreate:c,onThreadDelete:d,view:f,defaultView:m,onViewChange:p,viewOptions:v,viewState:g,showHeader:x=!0,shareTargets:y,isLoadingShareTargets:b,shareTargetFilter:C}){const{threads:k,sharedThreads:S,currentThreadId:T,setCurrentThreadId:E,isLoading:A,isLoadingSharedThreads:R,actions:L,shareInFlight:F,shareStatus:K,clearShareStatus:J}=vr(),{createThread:P,deleteThread:Y,renameThread:q,shareThread:W}=L,{loadThread:D}=ro(),I=i??T,[G,X]=w.useState(Array.isArray(k)?k:[]),M=w.useRef(G.length>0),B=w.useRef(null),_=w.useRef(0),[$,z]=w.useState(null),[O,j]=w.useState(""),[U,Q]=w.useState(!1),[se,ie]=w.useState(!1),[Se,xe]=w.useState(null),[Re,Ve]=w.useState(""),De=v&&v.length>0?v:Wk,Ge=mm({defaultView:m}),He=g??Ge,ot=f??He.view,ut=w.useCallback(te=>{f||He.setView(te),p==null||p(te)},[f,p,He]),nt=De.find(te=>te.key===ot)??De[0],Le=te=>{xe(te),Ve(""),ie(!0)},Ke=()=>{ie(!1),xe(null),Ve(""),J()},$e=w.useCallback(async te=>{if(!(!Se||F)&&te.id)try{await W(Se,te.id),setTimeout(()=>Ke(),600)}catch(ge){console.error("Failed to share thread:",ge)}},[Ke,F,Se,W]),Te=w.useMemo(()=>{const te=y??[],ge=Re.trim().toLowerCase();return ge?C?te.filter(rt=>C(rt,ge)):te.filter(rt=>`${rt.label} ${rt.secondaryLabel??""}`.toLowerCase().includes(ge)):te},[y,Re,C]),Ae=ot==="shared",dt=Ae?S:G,Et=Ae?R:A,at=Ae?"No shared conversations yet":"No conversations yet",It=te=>{const ge=te.sharedAt?` • ${Ie(te.sharedAt)}`:"";return`Shared by ${te.sharedByUserId}${ge}`},bt=te=>"sharedByUserId"in te;w.useEffect(()=>{const te=Array.isArray(k)?k:[];if(te.length>0){M.current=!0,X(te);return}A||(M.current=!1,X(te))},[k,A]),w.useEffect(()=>{if(!B.current)return;const te=B.current.querySelector("[data-radix-scroll-area-viewport]");if(!te)return;let ge=null,rt=null;return ge=requestAnimationFrame(()=>{rt=requestAnimationFrame(()=>{te.scrollTop=_.current})}),()=>{ge!==null&&cancelAnimationFrame(ge),rt!==null&&cancelAnimationFrame(rt)}},[G]);const ft=async te=>{try{E(te),await D(te),a==null||a(te),l==null||l(te)}catch(ge){console.error("Failed to select thread:",ge)}},Nt=async()=>{try{Q(!0);const te=await P();te&&(c==null||c(te),a==null||a(te))}catch(te){console.error("Failed to create thread:",te)}finally{Q(!1)}},At=async(te,ge)=>{if(ge.stopPropagation(),!!confirm("Delete this thread?")){if(B.current){const rt=B.current.querySelector("[data-radix-scroll-area-viewport]");rt&&(_.current=rt.scrollTop)}try{await Y(te),d==null||d(te)}catch(rt){console.error("Failed to delete thread:",rt)}}},Ct=(te,ge)=>{ge.stopPropagation(),z(te.threadId),j(te.title||`Thread ${te.threadId.slice(0,8)}`)},on=async te=>{if(O.trim())try{await q(te,O.trim()),z(null),j("")}catch(ge){console.error("Failed to update title:",ge)}},Tt=()=>{z(null),j("")},Ie=te=>{if(!te)return"";try{const ge=new Date(te),fe=new Date().getTime()-ge.getTime(),ke=Math.floor(fe/(1e3*60*60*24));return ke===0?ge.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):ke===1?"Yesterday":ke<7?`${ke} days ago`:ge.toLocaleDateString()}catch{return""}},Ue=te=>te.title||`Thread ${te.threadId.slice(0,8)}`,jt=te=>{const ge=Ue(te);return ge.length<=pm?ge:`${ge.slice(0,pm)}...`};return u.jsxs("div",{className:`flex flex-col h-full ${e} ${s.container||""}`,children:[x&&u.jsxs("div",{className:s.header||"flex flex-col gap-2 px-1 py-0 border border-slate-200 bg-white dark:border-slate-700 dark:bg-slate-900 shadow-sm",children:[t&&u.jsx("div",{className:"flex justify-end",children:u.jsxs(Je,{onClick:Nt,disabled:U||A,className:s.createButton||"px-3 py-2 gap-1",size:"sm",variant:"ghost",title:U?"Creating...":"New Chat",children:[u.jsx(le.Edit3,{size:16}),u.jsx("span",{children:"New chat"})]})}),u.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-slate-700 dark:text-slate-200 uppercase tracking-wide leading-tight",children:[u.jsx("span",{children:"Current View"}),u.jsxs(ks,{children:[u.jsx(Es,{asChild:!0,children:u.jsx(Je,{variant:"outline",size:"sm",className:"text-[11px] text-slate-700 dark:text-slate-200 border border-slate-300 dark:border-slate-600 bg-white dark:bg-slate-900 hover:bg-slate-50 dark:hover:bg-slate-800 px-2 py-0",children:nt.label})}),u.jsx(go,{align:"start",sideOffset:6,className:"w-40",children:De.map(te=>u.jsxs(Fn,{className:"justify-between text-[12px]",onClick:ge=>{ge.preventDefault(),ut(te.key)},children:[u.jsx("span",{children:te.label}),ot===te.key&&u.jsx(le.Check,{className:"h-3 w-3"})]},te.key))})]})]})]}),u.jsx(Ol,{ref:B,className:`flex-1 min-h-0 ${s.threadList||""}`,style:o?{maxHeight:o}:void 0,children:u.jsx("div",{className:"p-2 space-y-1 pb-4",children:Et?u.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[u.jsx(le.Loader2,{className:"h-5 w-5 animate-spin"}),u.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):dt.length===0?u.jsxs("div",{className:"text-center py-8 text-slate-400",children:[u.jsx(le.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),u.jsx("p",{className:"text-sm text-slate-500",children:at})]}):dt.slice().sort((te,ge)=>new Date(ge.updatedAt||ge.createdAt||"").getTime()-new Date(te.updatedAt||te.createdAt||"").getTime()).map(te=>u.jsx(fm,{thread:te,isActive:I===te.threadId,editingThreadId:$,editingTitle:O,onSelect:ft,onStartEditing:Ct,onEditingTitleChange:ge=>j(ge),onSaveEditing:on,onCancelEditing:Tt,onShare:()=>Le(te.threadId),onDelete:At,showEditTitle:r,showDeleteButton:n,formatDate:Ie,getDisplayThreadTitle:jt,secondaryLine:Ae&&bt(te)?It(te):void 0,itemClassName:s.threadItem,activeItemClassName:s.activeThread},te.threadId))})}),u.jsx(ol,{open:se,onOpenChange:te=>!te&&Ke(),children:u.jsxs(Us,{className:"max-w-md p-0",children:[u.jsx(Ws,{children:u.jsx(Vs,{children:"Share thread"})}),u.jsxs(Tl,{children:[u.jsx(kl,{autoFocus:!0,value:Re,onValueChange:te=>Ve(te),placeholder:"Search for recipients..."}),u.jsxs(El,{children:[K&&u.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[F&&u.jsx(le.Loader2,{className:"h-3 w-3 animate-spin"}),u.jsx("span",{className:K.startsWith("Failed")?"text-red-500":K.startsWith("Shared")?"text-emerald-500":"text-slate-600 dark:text-slate-400",children:K})]}),u.jsx(Il,{children:b?u.jsxs("span",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(le.Loader2,{className:"h-4 w-4 animate-spin"}),"Loading recipients…"]}):"No matching recipients found"}),Te.length>0&&u.jsx(Nl,{heading:"Recipients",children:Te.map(te=>u.jsx(Al,{onSelect:()=>$e(te),children:u.jsxs("div",{className:"flex flex-col items-start text-sm",children:[u.jsx("span",{className:"font-medium",children:te.label}),te.secondaryLabel&&u.jsx("span",{className:"text-xs text-muted-foreground",children:te.secondaryLabel})]})},te.id))})]})]})]})})]})}function Vk({layout:e="sidebar",layoutSize:t="desktop",showThreads:n=!0,className:r="",customStyles:o={},...s}){const i=c=>{const d="h-full";switch(c){case"phone":return`${d} max-w-none`;case"tablet":return`${d} max-w-4xl mx-auto`;case"half-screen":return`${d} max-w-2xl`;case"desktop":default:return`${d} max-w-7xl mx-auto`}},a=c=>({"--chat-sidebar-width":c==="phone"?"100%":c==="tablet"?"280px":c==="half-screen"?"240px":"320px","--chat-message-max-width":c==="phone"?"95%":c==="tablet"?"90%":c==="half-screen"?"85%":"80%","--chat-input-height":c==="phone"?"120px":"100px"}),l=w.useCallback(c=>{var d;(d=s.onThreadChange)==null||d.call(s,c)},[s]);return e==="fullscreen"?u.jsx(yr,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsx(Dr,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?u.jsx(yr,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[n&&u.jsx("div",{className:`w-80 border-r flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:u.jsx(ii,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),u.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:u.jsx(Dr,{onError:s.onError,enableFileUpload:!0})})]})})}):u.jsx(yr,{...s,onThreadChange:l,children:u.jsxs("div",{className:`${i(t)} flex overflow-hidden ${r} ${o.container||""}`,style:a(t),children:[n&&u.jsx("div",{className:`w-80 border-r bg-gray-50 flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:u.jsx(ii,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),u.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:u.jsx(Dr,{onError:s.onError,enableFileUpload:!0})})]})})}function Kk({apiConfig:e,className:t="",onError:n}){return u.jsx(yr,{apiConfig:e,onError:n,children:u.jsx("div",{className:`h-full ${t}`,children:u.jsx(Dr,{})})})}function qk({placeholder:e,onMessageSent:t}){const[n,r]=w.useState("chat");return u.jsxs("div",{className:"flex flex-col h-full",children:[u.jsxs("div",{className:"flex border-b border-gray-200 bg-gray-50",children:[u.jsx("button",{onClick:()=>r("chat"),className:`flex-1 px-3 py-2 text-sm font-medium transition-colors ${n==="chat"?"border-b-2 border-slate-800 text-slate-800 bg-white":"text-gray-600 hover:text-gray-800"}`,children:u.jsxs("div",{className:"flex items-center justify-center gap-2",children:[u.jsx(le.MessageSquare,{size:14}),"Chat"]})}),u.jsx("button",{onClick:()=>r("threads"),className:`flex-1 px-3 py-2 text-sm font-medium transition-colors ${n==="threads"?"border-b-2 border-slate-800 text-slate-800 bg-white":"text-gray-600 hover:text-gray-800"}`,children:u.jsxs("div",{className:"flex items-center justify-center gap-2",children:[u.jsx(le.History,{size:14}),"History"]})})]}),u.jsx("div",{className:"flex-1 min-h-0",children:n==="chat"?u.jsx(Dr,{placeholder:e??"Ask Serti AI anything...",autoFocus:!0,className:"h-full",onMessageSent:t}):u.jsx(ii,{showCreateButton:!0,className:"h-full",onThreadSelect:()=>r("chat")})})]})}function Gk({className:e="",placeholder:t,isAuthenticated:n=!0,onMessageSent:r,widgetTitle:o="Serti AI Navigator",widgetSubtitle:s="AI-Powered Assistant",...i}){const[a,l]=w.useState(!1);return n?u.jsx(yr,{...i,children:u.jsx("div",{className:`fixed bottom-6 right-6 z-[9999] transition-all duration-300 ${e}`,children:u.jsxs("div",{className:`w-96 bg-white rounded-xl shadow-2xl border border-gray-200 overflow-hidden relative ${a?"scale-75":"scale-100"}`,children:[u.jsx("div",{className:"bg-slate-800 text-white p-4 flex-shrink-0",children:u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsxs("div",{className:"relative h-10 w-10 rounded-full bg-gradient-to-br from-slate-500 to-slate-700 border border-white/30 flex items-center justify-center text-white text-sm font-bold",children:["S",u.jsx("span",{className:"absolute -bottom-0.5 -right-0.5 h-3 w-3 rounded-full border-2 border-slate-800 bg-emerald-400"})]}),u.jsxs("div",{className:"flex flex-col",children:[u.jsx("h3",{className:"text-lg font-semibold leading-tight",children:o}),u.jsx("p",{className:"text-xs text-white/70",children:s})]}),u.jsx("span",{className:"ml-2 inline-flex items-center justify-center rounded-full bg-red-500 px-2 py-0.5 text-[11px] font-semibold leading-none text-white",children:"1"})]}),u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsx(Je,{variant:"ghost",size:"sm",className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:"Options",children:u.jsx(le.MoreHorizontal,{size:16})}),u.jsx(Je,{variant:"ghost",size:"sm",className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:"Compose",children:u.jsx(le.Edit3,{size:16})}),u.jsx(Je,{variant:"ghost",size:"sm",onClick:c=>{c.stopPropagation(),l(d=>!d)},className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:a?"Maximize":"Minimize",children:a?u.jsx(le.Maximize2,{size:14}):u.jsx(le.Minimize2,{size:14})})]})]})}),!a&&u.jsx("div",{className:"h-96 flex flex-col",children:u.jsx(qk,{placeholder:t,onMessageSent:r})})]})})}):null}function Yk({label:e="New chat",children:t,className:n,variant:r="ghost",size:o="sm",...s}){return u.jsxs(Je,{variant:r,size:o,className:ne("gap-2 rounded-full px-3 font-semibold transition-all hover:scale-[1.01]",n),...s,children:[u.jsx(le.Edit3,{size:16}),t??e]})}var Xk="Label",gm=h.forwardRef((e,t)=>u.jsx(pe.label,{...e,ref:t,onMouseDown:n=>{var o;n.target.closest("button, input, select, textarea")||((o=e.onMouseDown)==null||o.call(e,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));gm.displayName=Xk;var xm=gm;const Jk=Ur.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),vm=h.forwardRef(({className:e,...t},n)=>u.jsx(xm,{ref:n,className:ne(Jk(),e),...t}));vm.displayName=xm.displayName;function wm(e){const t=h.useRef({value:e,previous:e});return h.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var bm=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),Zk="VisuallyHidden",ai=h.forwardRef((e,t)=>u.jsx(pe.span,{...e,ref:t,style:{...bm,...e.style}}));ai.displayName=Zk;var Qk=ai,eE=[" ","Enter","ArrowUp","ArrowDown"],tE=[" ","Enter"],dr="Select",[li,ci,nE]=Zo(dr),[Br,WN]=cn(dr,[nE,Nr]),ui=Nr(),[rE,qn]=Br(dr),[oE,sE]=Br(dr),ym=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:l,dir:c,name:d,autoComplete:f,disabled:m,required:p,form:v}=e,g=ui(t),[x,y]=h.useState(null),[b,C]=h.useState(null),[k,S]=h.useState(!1),T=Qo(c),[E,A]=On({prop:r,defaultProp:o??!1,onChange:s,caller:dr}),[R,L]=On({prop:i,defaultProp:a,onChange:l,caller:dr}),F=h.useRef(null),K=x?v||!!x.closest("form"):!0,[J,P]=h.useState(new Set),Y=Array.from(J).map(q=>q.props.value).join(";");return u.jsx(ca,{...g,children:u.jsxs(rE,{required:p,scope:t,trigger:x,onTriggerChange:y,valueNode:b,onValueNodeChange:C,valueNodeHasChildren:k,onValueNodeHasChildrenChange:S,contentId:_t(),value:R,onValueChange:L,open:E,onOpenChange:A,dir:T,triggerPointerDownPosRef:F,disabled:m,children:[u.jsx(li.Provider,{scope:t,children:u.jsx(oE,{scope:e.__scopeSelect,onNativeOptionAdd:h.useCallback(q=>{P(W=>new Set(W).add(q))},[]),onNativeOptionRemove:h.useCallback(q=>{P(W=>{const D=new Set(W);return D.delete(q),D})},[]),children:n})}),K?u.jsxs(Vm,{"aria-hidden":!0,required:p,tabIndex:-1,name:d,autoComplete:f,value:R,onChange:q=>L(q.target.value),disabled:m,form:v,children:[R===void 0?u.jsx("option",{value:""}):null,Array.from(J)]},Y):null]})})};ym.displayName=dr;var Sm="SelectTrigger",Cm=h.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=ui(n),i=qn(Sm,n),a=i.disabled||r,l=Pe(t,i.onTriggerChange),c=ci(n),d=h.useRef("touch"),[f,m,p]=qm(g=>{const x=c().filter(C=>!C.disabled),y=x.find(C=>C.value===i.value),b=Gm(x,g,y);b!==void 0&&i.onValueChange(b.value)}),v=g=>{a||(i.onOpenChange(!0),p()),g&&(i.triggerPointerDownPosRef.current={x:Math.round(g.pageX),y:Math.round(g.pageY)})};return u.jsx(ua,{asChild:!0,...s,children:u.jsx(pe.button,{type:"button",role:"combobox","aria-controls":i.contentId,"aria-expanded":i.open,"aria-required":i.required,"aria-autocomplete":"none",dir:i.dir,"data-state":i.open?"open":"closed",disabled:a,"data-disabled":a?"":void 0,"data-placeholder":Km(i.value)?"":void 0,...o,ref:l,onClick:ae(o.onClick,g=>{g.currentTarget.focus(),d.current!=="mouse"&&v(g)}),onPointerDown:ae(o.onPointerDown,g=>{d.current=g.pointerType;const x=g.target;x.hasPointerCapture(g.pointerId)&&x.releasePointerCapture(g.pointerId),g.button===0&&g.ctrlKey===!1&&g.pointerType==="mouse"&&(v(g),g.preventDefault())}),onKeyDown:ae(o.onKeyDown,g=>{const x=f.current!=="";!(g.ctrlKey||g.altKey||g.metaKey)&&g.key.length===1&&m(g.key),!(x&&g.key===" ")&&eE.includes(g.key)&&(v(),g.preventDefault())})})})});Cm.displayName=Sm;var Tm="SelectValue",km=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=qn(Tm,n),{onValueNodeHasChildrenChange:c}=l,d=s!==void 0,f=Pe(t,l.onValueNodeChange);return kt(()=>{c(d)},[c,d]),u.jsx(pe.span,{...a,ref:f,style:{pointerEvents:"none"},children:Km(l.value)?u.jsx(u.Fragment,{children:i}):s})});km.displayName=Tm;var iE="SelectIcon",Em=h.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return u.jsx(pe.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});Em.displayName=iE;var aE="SelectPortal",Im=e=>u.jsx(lo,{asChild:!0,...e});Im.displayName=aE;var fr="SelectContent",Nm=h.forwardRef((e,t)=>{const n=qn(fr,e.__scopeSelect),[r,o]=h.useState();if(kt(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?Wr.createPortal(u.jsx(Am,{scope:e.__scopeSelect,children:u.jsx(li.Slot,{scope:e.__scopeSelect,children:u.jsx("div",{children:e.children})})}),s):null}return u.jsx(jm,{...e,ref:t})});Nm.displayName=fr;var mn=10,[Am,Gn]=Br(fr),lE="SelectContentImpl",cE=qt.createSlot("SelectContent.RemoveScroll"),jm=h.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:f,collisionBoundary:m,collisionPadding:p,sticky:v,hideWhenDetached:g,avoidCollisions:x,...y}=e,b=qn(fr,n),[C,k]=h.useState(null),[S,T]=h.useState(null),E=Pe(t,O=>k(O)),[A,R]=h.useState(null),[L,F]=h.useState(null),K=ci(n),[J,P]=h.useState(!1),Y=h.useRef(!1);h.useEffect(()=>{if(C)return ga(C)},[C]),qi();const q=h.useCallback(O=>{const[j,...U]=K().map(ie=>ie.ref.current),[Q]=U.slice(-1),se=document.activeElement;for(const ie of O)if(ie===se||(ie==null||ie.scrollIntoView({block:"nearest"}),ie===j&&S&&(S.scrollTop=0),ie===Q&&S&&(S.scrollTop=S.scrollHeight),ie==null||ie.focus(),document.activeElement!==se))return},[K,S]),W=h.useCallback(()=>q([A,C]),[q,A,C]);h.useEffect(()=>{J&&W()},[J,W]);const{onOpenChange:D,triggerPointerDownPosRef:I}=b;h.useEffect(()=>{if(C){let O={x:0,y:0};const j=Q=>{var se,ie;O={x:Math.abs(Math.round(Q.pageX)-(((se=I.current)==null?void 0:se.x)??0)),y:Math.abs(Math.round(Q.pageY)-(((ie=I.current)==null?void 0:ie.y)??0))}},U=Q=>{O.x<=10&&O.y<=10?Q.preventDefault():C.contains(Q.target)||D(!1),document.removeEventListener("pointermove",j),I.current=null};return I.current!==null&&(document.addEventListener("pointermove",j),document.addEventListener("pointerup",U,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",j),document.removeEventListener("pointerup",U,{capture:!0})}}},[C,D,I]),h.useEffect(()=>{const O=()=>D(!1);return window.addEventListener("blur",O),window.addEventListener("resize",O),()=>{window.removeEventListener("blur",O),window.removeEventListener("resize",O)}},[D]);const[G,X]=qm(O=>{const j=K().filter(se=>!se.disabled),U=j.find(se=>se.ref.current===document.activeElement),Q=Gm(j,O,U);Q&&setTimeout(()=>Q.ref.current.focus())}),M=h.useCallback((O,j,U)=>{const Q=!Y.current&&!U;(b.value!==void 0&&b.value===j||Q)&&(R(O),Q&&(Y.current=!0))},[b.value]),B=h.useCallback(()=>C==null?void 0:C.focus(),[C]),_=h.useCallback((O,j,U)=>{const Q=!Y.current&&!U;(b.value!==void 0&&b.value===j||Q)&&F(O)},[b.value]),$=r==="popper"?Ll:Pm,z=$===Ll?{side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:f,collisionBoundary:m,collisionPadding:p,sticky:v,hideWhenDetached:g,avoidCollisions:x}:{};return u.jsx(Am,{scope:n,content:C,viewport:S,onViewportChange:T,itemRefCallback:M,selectedItem:A,onItemLeave:B,itemTextRefCallback:_,focusSelectedItem:W,selectedItemText:L,position:r,isPositioned:J,searchRef:G,children:u.jsx(ws,{as:cE,allowPinchZoom:!0,children:u.jsx(es,{asChild:!0,trapped:b.open,onMountAutoFocus:O=>{O.preventDefault()},onUnmountAutoFocus:ae(o,O=>{var j;(j=b.trigger)==null||j.focus({preventScroll:!0}),O.preventDefault()}),children:u.jsx(Cr,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:O=>O.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:u.jsx($,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:O=>O.preventDefault(),...y,...z,onPlaced:()=>P(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:ae(y.onKeyDown,O=>{const j=O.ctrlKey||O.altKey||O.metaKey;if(O.key==="Tab"&&O.preventDefault(),!j&&O.key.length===1&&X(O.key),["ArrowUp","ArrowDown","Home","End"].includes(O.key)){let Q=K().filter(se=>!se.disabled).map(se=>se.ref.current);if(["ArrowUp","End"].includes(O.key)&&(Q=Q.slice().reverse()),["ArrowUp","ArrowDown"].includes(O.key)){const se=O.target,ie=Q.indexOf(se);Q=Q.slice(ie+1)}setTimeout(()=>q(Q)),O.preventDefault()}})})})})})})});jm.displayName=lE;var uE="SelectItemAlignedPosition",Pm=h.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=qn(fr,n),i=Gn(fr,n),[a,l]=h.useState(null),[c,d]=h.useState(null),f=Pe(t,E=>d(E)),m=ci(n),p=h.useRef(!1),v=h.useRef(!0),{viewport:g,selectedItem:x,selectedItemText:y,focusSelectedItem:b}=i,C=h.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&c&&g&&x&&y){const E=s.trigger.getBoundingClientRect(),A=c.getBoundingClientRect(),R=s.valueNode.getBoundingClientRect(),L=y.getBoundingClientRect();if(s.dir!=="rtl"){const se=L.left-A.left,ie=R.left-se,Se=E.left-ie,xe=E.width+Se,Re=Math.max(xe,A.width),Ve=window.innerWidth-mn,De=jl(ie,[mn,Math.max(mn,Ve-Re)]);a.style.minWidth=xe+"px",a.style.left=De+"px"}else{const se=A.right-L.right,ie=window.innerWidth-R.right-se,Se=window.innerWidth-E.right-ie,xe=E.width+Se,Re=Math.max(xe,A.width),Ve=window.innerWidth-mn,De=jl(ie,[mn,Math.max(mn,Ve-Re)]);a.style.minWidth=xe+"px",a.style.right=De+"px"}const F=m(),K=window.innerHeight-mn*2,J=g.scrollHeight,P=window.getComputedStyle(c),Y=parseInt(P.borderTopWidth,10),q=parseInt(P.paddingTop,10),W=parseInt(P.borderBottomWidth,10),D=parseInt(P.paddingBottom,10),I=Y+q+J+D+W,G=Math.min(x.offsetHeight*5,I),X=window.getComputedStyle(g),M=parseInt(X.paddingTop,10),B=parseInt(X.paddingBottom,10),_=E.top+E.height/2-mn,$=K-_,z=x.offsetHeight/2,O=x.offsetTop+z,j=Y+q+O,U=I-j;if(j<=_){const se=F.length>0&&x===F[F.length-1].ref.current;a.style.bottom="0px";const ie=c.clientHeight-g.offsetTop-g.offsetHeight,Se=Math.max($,z+(se?B:0)+ie+W),xe=j+Se;a.style.height=xe+"px"}else{const se=F.length>0&&x===F[0].ref.current;a.style.top="0px";const Se=Math.max(_,Y+g.offsetTop+(se?M:0)+z)+U;a.style.height=Se+"px",g.scrollTop=j-_+g.offsetTop}a.style.margin=`${mn}px 0`,a.style.minHeight=G+"px",a.style.maxHeight=K+"px",r==null||r(),requestAnimationFrame(()=>p.current=!0)}},[m,s.trigger,s.valueNode,a,c,g,x,y,s.dir,r]);kt(()=>C(),[C]);const[k,S]=h.useState();kt(()=>{c&&S(window.getComputedStyle(c).zIndex)},[c]);const T=h.useCallback(E=>{E&&v.current===!0&&(C(),b==null||b(),v.current=!1)},[C,b]);return u.jsx(fE,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:p,onScrollButtonChange:T,children:u.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:k},children:u.jsx(pe.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Pm.displayName=uE;var dE="SelectPopperPosition",Ll=h.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=mn,...s}=e,i=ui(n);return u.jsx(da,{...i,...s,ref:t,align:r,collisionPadding:o,style:{boxSizing:"border-box",...s.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});Ll.displayName=dE;var[fE,$l]=Br(fr,{}),Fl="SelectViewport",_m=h.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Gn(Fl,n),i=$l(Fl,n),a=Pe(t,s.onViewportChange),l=h.useRef(0);return u.jsxs(u.Fragment,{children:[u.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),u.jsx(li.Slot,{scope:n,children:u.jsx(pe.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:ae(o.onScroll,c=>{const d=c.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:m}=i;if(m!=null&&m.current&&f){const p=Math.abs(l.current-d.scrollTop);if(p>0){const v=window.innerHeight-mn*2,g=parseFloat(f.style.minHeight),x=parseFloat(f.style.height),y=Math.max(g,x);if(y<v){const b=y+p,C=Math.min(v,b),k=b-C;f.style.height=C+"px",f.style.bottom==="0px"&&(d.scrollTop=k>0?k:0,f.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});_m.displayName=Fl;var Rm="SelectGroup",[pE,hE]=Br(Rm),mE=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=_t();return u.jsx(pE,{scope:n,id:o,children:u.jsx(pe.div,{role:"group","aria-labelledby":o,...r,ref:t})})});mE.displayName=Rm;var Mm="SelectLabel",Om=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=hE(Mm,n);return u.jsx(pe.div,{id:o.id,...r,ref:t})});Om.displayName=Mm;var di="SelectItem",[gE,Dm]=Br(di),Lm=h.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=qn(di,n),l=Gn(di,n),c=a.value===r,[d,f]=h.useState(s??""),[m,p]=h.useState(!1),v=Pe(t,b=>{var C;return(C=l.itemRefCallback)==null?void 0:C.call(l,b,r,o)}),g=_t(),x=h.useRef("touch"),y=()=>{o||(a.onValueChange(r),a.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return u.jsx(gE,{scope:n,value:r,disabled:o,textId:g,isSelected:c,onItemTextChange:h.useCallback(b=>{f(C=>C||((b==null?void 0:b.textContent)??"").trim())},[]),children:u.jsx(li.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:u.jsx(pe.div,{role:"option","aria-labelledby":g,"data-highlighted":m?"":void 0,"aria-selected":c&&m,"data-state":c?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:v,onFocus:ae(i.onFocus,()=>p(!0)),onBlur:ae(i.onBlur,()=>p(!1)),onClick:ae(i.onClick,()=>{x.current!=="mouse"&&y()}),onPointerUp:ae(i.onPointerUp,()=>{x.current==="mouse"&&y()}),onPointerDown:ae(i.onPointerDown,b=>{x.current=b.pointerType}),onPointerMove:ae(i.onPointerMove,b=>{var C;x.current=b.pointerType,o?(C=l.onItemLeave)==null||C.call(l):x.current==="mouse"&&b.currentTarget.focus({preventScroll:!0})}),onPointerLeave:ae(i.onPointerLeave,b=>{var C;b.currentTarget===document.activeElement&&((C=l.onItemLeave)==null||C.call(l))}),onKeyDown:ae(i.onKeyDown,b=>{var k;((k=l.searchRef)==null?void 0:k.current)!==""&&b.key===" "||(tE.includes(b.key)&&y(),b.key===" "&&b.preventDefault())})})})})});Lm.displayName=di;var Ro="SelectItemText",$m=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=qn(Ro,n),a=Gn(Ro,n),l=Dm(Ro,n),c=sE(Ro,n),[d,f]=h.useState(null),m=Pe(t,y=>f(y),l.onItemTextChange,y=>{var b;return(b=a.itemTextRefCallback)==null?void 0:b.call(a,y,l.value,l.disabled)}),p=d==null?void 0:d.textContent,v=h.useMemo(()=>u.jsx("option",{value:l.value,disabled:l.disabled,children:p},l.value),[l.disabled,l.value,p]),{onNativeOptionAdd:g,onNativeOptionRemove:x}=c;return kt(()=>(g(v),()=>x(v)),[g,x,v]),u.jsxs(u.Fragment,{children:[u.jsx(pe.span,{id:l.textId,...s,ref:m}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?Wr.createPortal(s.children,i.valueNode):null]})});$m.displayName=Ro;var Fm="SelectItemIndicator",Bm=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Dm(Fm,n).isSelected?u.jsx(pe.span,{"aria-hidden":!0,...r,ref:t}):null});Bm.displayName=Fm;var Bl="SelectScrollUpButton",zm=h.forwardRef((e,t)=>{const n=Gn(Bl,e.__scopeSelect),r=$l(Bl,e.__scopeSelect),[o,s]=h.useState(!1),i=Pe(t,r.onScrollButtonChange);return kt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollTop>0;s(c)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?u.jsx(Um,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});zm.displayName=Bl;var zl="SelectScrollDownButton",Hm=h.forwardRef((e,t)=>{const n=Gn(zl,e.__scopeSelect),r=$l(zl,e.__scopeSelect),[o,s]=h.useState(!1),i=Pe(t,r.onScrollButtonChange);return kt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollHeight-l.clientHeight,d=Math.ceil(l.scrollTop)<c;s(d)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?u.jsx(Um,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});Hm.displayName=zl;var Um=h.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=Gn("SelectScrollButton",n),i=h.useRef(null),a=ci(n),l=h.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return h.useEffect(()=>()=>l(),[l]),kt(()=>{var d;const c=a().find(f=>f.ref.current===document.activeElement);(d=c==null?void 0:c.ref.current)==null||d.scrollIntoView({block:"nearest"})},[a]),u.jsx(pe.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:ae(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:ae(o.onPointerMove,()=>{var c;(c=s.onItemLeave)==null||c.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:ae(o.onPointerLeave,()=>{l()})})}),xE="SelectSeparator",Wm=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return u.jsx(pe.div,{"aria-hidden":!0,...r,ref:t})});Wm.displayName=xE;var Hl="SelectArrow",vE=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=ui(n),s=qn(Hl,n),i=Gn(Hl,n);return s.open&&i.position==="popper"?u.jsx(fa,{...o,...r,ref:t}):null});vE.displayName=Hl;var wE="SelectBubbleInput",Vm=h.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=h.useRef(null),s=Pe(r,o),i=wm(t);return h.useEffect(()=>{const a=o.current;if(!a)return;const l=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(l,"value").set;if(i!==t&&d){const f=new Event("change",{bubbles:!0});d.call(a,t),a.dispatchEvent(f)}},[i,t]),u.jsx(pe.select,{...n,style:{...bm,...n.style},ref:s,defaultValue:t})});Vm.displayName=wE;function Km(e){return e===""||e===void 0}function qm(e){const t=gt(e),n=h.useRef(""),r=h.useRef(0),o=h.useCallback(i=>{const a=n.current+i;t(a),function l(c){n.current=c,window.clearTimeout(r.current),c!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),s=h.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return h.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function Gm(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=bE(e,Math.max(s,0));o.length===1&&(i=i.filter(c=>c!==n));const l=i.find(c=>c.textValue.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function bE(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var yE=ym,Ym=Cm,SE=km,CE=Em,TE=Im,Xm=Nm,kE=_m,Jm=Om,Zm=Lm,EE=$m,IE=Bm,Qm=zm,eg=Hm,tg=Wm;const NE=yE,AE=SE,ng=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Ym,{ref:r,className:ne("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,u.jsx(CE,{asChild:!0,children:u.jsx(le.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));ng.displayName=Ym.displayName;const rg=h.forwardRef(({className:e,...t},n)=>u.jsx(Qm,{ref:n,className:ne("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(le.ChevronUp,{className:"h-4 w-4"})}));rg.displayName=Qm.displayName;const og=h.forwardRef(({className:e,...t},n)=>u.jsx(eg,{ref:n,className:ne("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(le.ChevronDown,{className:"h-4 w-4"})}));og.displayName=eg.displayName;const sg=h.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>u.jsx(TE,{children:u.jsxs(Xm,{ref:o,className:ne("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[u.jsx(rg,{}),u.jsx(kE,{className:ne("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),u.jsx(og,{})]})}));sg.displayName=Xm.displayName;const jE=h.forwardRef(({className:e,...t},n)=>u.jsx(Jm,{ref:n,className:ne("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));jE.displayName=Jm.displayName;const ig=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Zm,{ref:r,className:ne("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(IE,{children:u.jsx(le.Check,{className:"h-4 w-4"})})}),u.jsx(EE,{children:t})]}));ig.displayName=Zm.displayName;const PE=h.forwardRef(({className:e,...t},n)=>u.jsx(tg,{ref:n,className:ne("-mx-1 my-1 h-px bg-muted",e),...t}));PE.displayName=tg.displayName;var _E="Separator",ag="horizontal",RE=["horizontal","vertical"],lg=h.forwardRef((e,t)=>{const{decorative:n,orientation:r=ag,...o}=e,s=ME(r)?r:ag,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return u.jsx(pe.div,{"data-orientation":s,...a,...o,ref:t})});lg.displayName=_E;function ME(e){return RE.includes(e)}var cg=lg;const ug=h.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>u.jsx(cg,{ref:o,decorative:n,orientation:t,className:ne("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));ug.displayName=cg.displayName;var fi="Switch",[OE,VN]=cn(fi),[DE,LE]=OE(fi),dg=h.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:l="on",onCheckedChange:c,form:d,...f}=e,[m,p]=h.useState(null),v=Pe(t,C=>p(C)),g=h.useRef(!1),x=m?d||!!m.closest("form"):!0,[y,b]=On({prop:o,defaultProp:s??!1,onChange:c,caller:fi});return u.jsxs(DE,{scope:n,checked:y,disabled:a,children:[u.jsx(pe.button,{type:"button",role:"switch","aria-checked":y,"aria-required":i,"data-state":mg(y),"data-disabled":a?"":void 0,disabled:a,value:l,...f,ref:v,onClick:ae(e.onClick,C=>{b(k=>!k),x&&(g.current=C.isPropagationStopped(),g.current||C.stopPropagation())})}),x&&u.jsx(hg,{control:m,bubbles:!g.current,name:r,value:l,checked:y,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});dg.displayName=fi;var fg="SwitchThumb",pg=h.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=LE(fg,n);return u.jsx(pe.span,{"data-state":mg(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});pg.displayName=fg;var $E="SwitchBubbleInput",hg=h.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=h.useRef(null),a=Pe(i,s),l=wm(n),c=Td(t);return h.useEffect(()=>{const d=i.current;if(!d)return;const f=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(f,"checked").set;if(l!==n&&p){const v=new Event("click",{bubbles:r});p.call(d,n),d.dispatchEvent(v)}},[l,n,r]),u.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:a,style:{...o.style,...c,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});hg.displayName=$E;function mg(e){return e?"checked":"unchecked"}var gg=dg,FE=pg;const xg=h.forwardRef(({className:e,...t},n)=>u.jsx(gg,{className:ne("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:u.jsx(FE,{className:ne("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));xg.displayName=gg.displayName;const BE=nl,zE=xT,HE=rl,vg=h.forwardRef(({className:e,...t},n)=>u.jsx(Io,{className:ne("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:n}));vg.displayName=Io.displayName;const UE=Ur.cva("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),wg=h.forwardRef(({side:e="right",className:t,children:n,...r},o)=>u.jsxs(HE,{children:[u.jsx(vg,{}),u.jsxs(No,{ref:o,className:ne(UE({side:e}),t),...r,children:[n,u.jsxs(uh,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[u.jsx(le.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));wg.displayName=No.displayName;const bg=({className:e,...t})=>u.jsx("div",{className:ne("flex flex-col space-y-2 text-center sm:text-left",e),...t});bg.displayName="SheetHeader";const yg=h.forwardRef(({className:e,...t},n)=>u.jsx(ar,{ref:n,className:ne("text-lg font-semibold text-foreground",e),...t}));yg.displayName=ar.displayName;const Sg=h.forwardRef(({className:e,...t},n)=>u.jsx(Hs,{ref:n,className:ne("text-sm text-muted-foreground",e),...t}));Sg.displayName=Hs.displayName;var[pi,KN]=cn("Tooltip",[Nr]),hi=Nr(),Cg="TooltipProvider",WE=700,Ul="tooltip.open",[VE,Wl]=pi(Cg),Tg=e=>{const{__scopeTooltip:t,delayDuration:n=WE,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:s}=e,i=h.useRef(!0),a=h.useRef(!1),l=h.useRef(0);return h.useEffect(()=>{const c=l.current;return()=>window.clearTimeout(c)},[]),u.jsx(VE,{scope:t,isOpenDelayedRef:i,delayDuration:n,onOpen:h.useCallback(()=>{window.clearTimeout(l.current),i.current=!1},[]),onClose:h.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>i.current=!0,r)},[r]),isPointerInTransitRef:a,onPointerInTransitChange:h.useCallback(c=>{a.current=c},[]),disableHoverableContent:o,children:s})};Tg.displayName=Cg;var Mo="Tooltip",[KE,mi]=pi(Mo),kg=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:s,disableHoverableContent:i,delayDuration:a}=e,l=Wl(Mo,e.__scopeTooltip),c=hi(t),[d,f]=h.useState(null),m=_t(),p=h.useRef(0),v=i??l.disableHoverableContent,g=a??l.delayDuration,x=h.useRef(!1),[y,b]=On({prop:r,defaultProp:o??!1,onChange:E=>{E?(l.onOpen(),document.dispatchEvent(new CustomEvent(Ul))):l.onClose(),s==null||s(E)},caller:Mo}),C=h.useMemo(()=>y?x.current?"delayed-open":"instant-open":"closed",[y]),k=h.useCallback(()=>{window.clearTimeout(p.current),p.current=0,x.current=!1,b(!0)},[b]),S=h.useCallback(()=>{window.clearTimeout(p.current),p.current=0,b(!1)},[b]),T=h.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{x.current=!0,b(!0),p.current=0},g)},[g,b]);return h.useEffect(()=>()=>{p.current&&(window.clearTimeout(p.current),p.current=0)},[]),u.jsx(ca,{...c,children:u.jsx(KE,{scope:t,contentId:m,open:y,stateAttribute:C,trigger:d,onTriggerChange:f,onTriggerEnter:h.useCallback(()=>{l.isOpenDelayedRef.current?T():k()},[l.isOpenDelayedRef,T,k]),onTriggerLeave:h.useCallback(()=>{v?S():(window.clearTimeout(p.current),p.current=0)},[S,v]),onOpen:k,onClose:S,disableHoverableContent:v,children:n})})};kg.displayName=Mo;var Vl="TooltipTrigger",Eg=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=mi(Vl,n),s=Wl(Vl,n),i=hi(n),a=h.useRef(null),l=Pe(t,a,o.onTriggerChange),c=h.useRef(!1),d=h.useRef(!1),f=h.useCallback(()=>c.current=!1,[]);return h.useEffect(()=>()=>document.removeEventListener("pointerup",f),[f]),u.jsx(ua,{asChild:!0,...i,children:u.jsx(pe.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:l,onPointerMove:ae(e.onPointerMove,m=>{m.pointerType!=="touch"&&!d.current&&!s.isPointerInTransitRef.current&&(o.onTriggerEnter(),d.current=!0)}),onPointerLeave:ae(e.onPointerLeave,()=>{o.onTriggerLeave(),d.current=!1}),onPointerDown:ae(e.onPointerDown,()=>{o.open&&o.onClose(),c.current=!0,document.addEventListener("pointerup",f,{once:!0})}),onFocus:ae(e.onFocus,()=>{c.current||o.onOpen()}),onBlur:ae(e.onBlur,o.onClose),onClick:ae(e.onClick,o.onClose)})})});Eg.displayName=Vl;var qE="TooltipPortal",[qN,GE]=pi(qE,{forceMount:void 0}),zr="TooltipContent",Ig=h.forwardRef((e,t)=>{const n=GE(zr,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,i=mi(zr,e.__scopeTooltip);return u.jsx(Ht,{present:r||i.open,children:i.disableHoverableContent?u.jsx(Ng,{side:o,...s,ref:t}):u.jsx(YE,{side:o,...s,ref:t})})}),YE=h.forwardRef((e,t)=>{const n=mi(zr,e.__scopeTooltip),r=Wl(zr,e.__scopeTooltip),o=h.useRef(null),s=Pe(t,o),[i,a]=h.useState(null),{trigger:l,onClose:c}=n,d=o.current,{onPointerInTransitChange:f}=r,m=h.useCallback(()=>{a(null),f(!1)},[f]),p=h.useCallback((v,g)=>{const x=v.currentTarget,y={x:v.clientX,y:v.clientY},b=eI(y,x.getBoundingClientRect()),C=tI(y,b),k=nI(g.getBoundingClientRect()),S=oI([...C,...k]);a(S),f(!0)},[f]);return h.useEffect(()=>()=>m(),[m]),h.useEffect(()=>{if(l&&d){const v=x=>p(x,d),g=x=>p(x,l);return l.addEventListener("pointerleave",v),d.addEventListener("pointerleave",g),()=>{l.removeEventListener("pointerleave",v),d.removeEventListener("pointerleave",g)}}},[l,d,p,m]),h.useEffect(()=>{if(i){const v=g=>{const x=g.target,y={x:g.clientX,y:g.clientY},b=(l==null?void 0:l.contains(x))||(d==null?void 0:d.contains(x)),C=!rI(y,i);b?m():C&&(m(),c())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[l,d,i,c,m]),u.jsx(Ng,{...e,ref:s})}),[XE,JE]=pi(Mo,{isInside:!1}),ZE=qt.createSlottable("TooltipContent"),Ng=h.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:i,...a}=e,l=mi(zr,n),c=hi(n),{onClose:d}=l;return h.useEffect(()=>(document.addEventListener(Ul,d),()=>document.removeEventListener(Ul,d)),[d]),h.useEffect(()=>{if(l.trigger){const f=m=>{const p=m.target;p!=null&&p.contains(l.trigger)&&d()};return window.addEventListener("scroll",f,{capture:!0}),()=>window.removeEventListener("scroll",f,{capture:!0})}},[l.trigger,d]),u.jsx(Cr,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:f=>f.preventDefault(),onDismiss:d,children:u.jsxs(da,{"data-state":l.stateAttribute,...c,...a,ref:t,style:{...a.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[u.jsx(ZE,{children:r}),u.jsx(XE,{scope:n,isInside:!0,children:u.jsx(Qk,{id:l.contentId,role:"tooltip",children:o||r})})]})})});Ig.displayName=zr;var Ag="TooltipArrow",QE=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=hi(n);return JE(Ag,n).isInside?null:u.jsx(fa,{...o,...r,ref:t})});QE.displayName=Ag;function eI(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(n,r,o,s)){case s:return"left";case o:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function tI(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function nI(e){const{top:t,right:n,bottom:r,left:o}=e;return[{x:o,y:t},{x:n,y:t},{x:n,y:r},{x:o,y:r}]}function rI(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],l=t[i],c=a.x,d=a.y,f=l.x,m=l.y;d>r!=m>r&&n<(f-c)*(r-d)/(m-d)+c&&(o=!o)}return o}function oI(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),sI(t)}function sI(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const o=e[r];for(;t.length>=2;){const s=t[t.length-1],i=t[t.length-2];if((s.x-i.x)*(o.y-i.y)>=(s.y-i.y)*(o.x-i.x))t.pop();else break}t.push(o)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const o=e[r];for(;n.length>=2;){const s=n[n.length-1],i=n[n.length-2];if((s.x-i.x)*(o.y-i.y)>=(s.y-i.y)*(o.x-i.x))n.pop();else break}n.push(o)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var iI=Tg,aI=kg,lI=Eg,jg=Ig;const cI=iI,uI=aI,dI=lI,Pg=h.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(jg,{ref:r,sideOffset:t,className:ne("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n}));Pg.displayName=jg.displayName;var Kl="ToastProvider",[ql,fI,pI]=Zo("Toast"),[_g,GN]=cn("Toast",[pI]),[hI,gi]=_g(Kl),Rg=e=>{const{__scopeToast:t,label:n="Notification",duration:r=5e3,swipeDirection:o="right",swipeThreshold:s=50,children:i}=e,[a,l]=h.useState(null),[c,d]=h.useState(0),f=h.useRef(!1),m=h.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${Kl}\`. Expected non-empty \`string\`.`),u.jsx(ql.Provider,{scope:t,children:u.jsx(hI,{scope:t,label:n,duration:r,swipeDirection:o,swipeThreshold:s,toastCount:c,viewport:a,onViewportChange:l,onToastAdd:h.useCallback(()=>d(p=>p+1),[]),onToastRemove:h.useCallback(()=>d(p=>p-1),[]),isFocusedToastEscapeKeyDownRef:f,isClosePausedRef:m,children:i})})};Rg.displayName=Kl;var Mg="ToastViewport",mI=["F8"],Gl="toast.viewportPause",Yl="toast.viewportResume",Og=h.forwardRef((e,t)=>{const{__scopeToast:n,hotkey:r=mI,label:o="Notifications ({hotkey})",...s}=e,i=gi(Mg,n),a=fI(n),l=h.useRef(null),c=h.useRef(null),d=h.useRef(null),f=h.useRef(null),m=Pe(t,f,i.onViewportChange),p=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),v=i.toastCount>0;h.useEffect(()=>{const x=y=>{var C;r.length!==0&&r.every(k=>y[k]||y.code===k)&&((C=f.current)==null||C.focus())};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[r]),h.useEffect(()=>{const x=l.current,y=f.current;if(v&&x&&y){const b=()=>{if(!i.isClosePausedRef.current){const T=new CustomEvent(Gl);y.dispatchEvent(T),i.isClosePausedRef.current=!0}},C=()=>{if(i.isClosePausedRef.current){const T=new CustomEvent(Yl);y.dispatchEvent(T),i.isClosePausedRef.current=!1}},k=T=>{!x.contains(T.relatedTarget)&&C()},S=()=>{x.contains(document.activeElement)||C()};return x.addEventListener("focusin",b),x.addEventListener("focusout",k),x.addEventListener("pointermove",b),x.addEventListener("pointerleave",S),window.addEventListener("blur",b),window.addEventListener("focus",C),()=>{x.removeEventListener("focusin",b),x.removeEventListener("focusout",k),x.removeEventListener("pointermove",b),x.removeEventListener("pointerleave",S),window.removeEventListener("blur",b),window.removeEventListener("focus",C)}}},[v,i.isClosePausedRef]);const g=h.useCallback(({tabbingDirection:x})=>{const b=a().map(C=>{const k=C.ref.current,S=[k,...NI(k)];return x==="forwards"?S:S.reverse()});return(x==="forwards"?b.reverse():b).flat()},[a]);return h.useEffect(()=>{const x=f.current;if(x){const y=b=>{var S,T,E;const C=b.altKey||b.ctrlKey||b.metaKey;if(b.key==="Tab"&&!C){const A=document.activeElement,R=b.shiftKey;if(b.target===x&&R){(S=c.current)==null||S.focus();return}const K=g({tabbingDirection:R?"backwards":"forwards"}),J=K.findIndex(P=>P===A);Zl(K.slice(J+1))?b.preventDefault():R?(T=c.current)==null||T.focus():(E=d.current)==null||E.focus()}};return x.addEventListener("keydown",y),()=>x.removeEventListener("keydown",y)}},[a,g]),u.jsxs(Vw,{ref:l,role:"region","aria-label":o.replace("{hotkey}",p),tabIndex:-1,style:{pointerEvents:v?void 0:"none"},children:[v&&u.jsx(Xl,{ref:c,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"forwards"});Zl(x)}}),u.jsx(ql.Slot,{scope:n,children:u.jsx(pe.ol,{tabIndex:-1,...s,ref:m})}),v&&u.jsx(Xl,{ref:d,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"backwards"});Zl(x)}})]})});Og.displayName=Mg;var Dg="ToastFocusProxy",Xl=h.forwardRef((e,t)=>{const{__scopeToast:n,onFocusFromOutsideViewport:r,...o}=e,s=gi(Dg,n);return u.jsx(ai,{tabIndex:0,...o,ref:t,style:{position:"fixed"},onFocus:i=>{var c;const a=i.relatedTarget;!((c=s.viewport)!=null&&c.contains(a))&&r()}})});Xl.displayName=Dg;var Oo="Toast",gI="toast.swipeStart",xI="toast.swipeMove",vI="toast.swipeCancel",wI="toast.swipeEnd",Lg=h.forwardRef((e,t)=>{const{forceMount:n,open:r,defaultOpen:o,onOpenChange:s,...i}=e,[a,l]=On({prop:r,defaultProp:o??!0,onChange:s,caller:Oo});return u.jsx(Ht,{present:n||a,children:u.jsx(SI,{open:a,...i,ref:t,onClose:()=>l(!1),onPause:gt(e.onPause),onResume:gt(e.onResume),onSwipeStart:ae(e.onSwipeStart,c=>{c.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:ae(e.onSwipeMove,c=>{const{x:d,y:f}=c.detail.delta;c.currentTarget.setAttribute("data-swipe","move"),c.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${d}px`),c.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${f}px`)}),onSwipeCancel:ae(e.onSwipeCancel,c=>{c.currentTarget.setAttribute("data-swipe","cancel"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),c.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:ae(e.onSwipeEnd,c=>{const{x:d,y:f}=c.detail.delta;c.currentTarget.setAttribute("data-swipe","end"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),c.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${d}px`),c.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${f}px`),l(!1)})})})});Lg.displayName=Oo;var[bI,yI]=_g(Oo,{onClose(){}}),SI=h.forwardRef((e,t)=>{const{__scopeToast:n,type:r="foreground",duration:o,open:s,onClose:i,onEscapeKeyDown:a,onPause:l,onResume:c,onSwipeStart:d,onSwipeMove:f,onSwipeCancel:m,onSwipeEnd:p,...v}=e,g=gi(Oo,n),[x,y]=h.useState(null),b=Pe(t,P=>y(P)),C=h.useRef(null),k=h.useRef(null),S=o||g.duration,T=h.useRef(0),E=h.useRef(S),A=h.useRef(0),{onToastAdd:R,onToastRemove:L}=g,F=gt(()=>{var Y;(x==null?void 0:x.contains(document.activeElement))&&((Y=g.viewport)==null||Y.focus()),i()}),K=h.useCallback(P=>{!P||P===1/0||(window.clearTimeout(A.current),T.current=new Date().getTime(),A.current=window.setTimeout(F,P))},[F]);h.useEffect(()=>{const P=g.viewport;if(P){const Y=()=>{K(E.current),c==null||c()},q=()=>{const W=new Date().getTime()-T.current;E.current=E.current-W,window.clearTimeout(A.current),l==null||l()};return P.addEventListener(Gl,q),P.addEventListener(Yl,Y),()=>{P.removeEventListener(Gl,q),P.removeEventListener(Yl,Y)}}},[g.viewport,S,l,c,K]),h.useEffect(()=>{s&&!g.isClosePausedRef.current&&K(S)},[s,S,g.isClosePausedRef,K]),h.useEffect(()=>(R(),()=>L()),[R,L]);const J=h.useMemo(()=>x?Wg(x):null,[x]);return g.viewport?u.jsxs(u.Fragment,{children:[J&&u.jsx(CI,{__scopeToast:n,role:"status","aria-live":r==="foreground"?"assertive":"polite",children:J}),u.jsx(bI,{scope:n,onClose:F,children:Wr.createPortal(u.jsx(ql.ItemSlot,{scope:n,children:u.jsx(Ww,{asChild:!0,onEscapeKeyDown:ae(a,()=>{g.isFocusedToastEscapeKeyDownRef.current||F(),g.isFocusedToastEscapeKeyDownRef.current=!1}),children:u.jsx(pe.li,{tabIndex:0,"data-state":s?"open":"closed","data-swipe-direction":g.swipeDirection,...v,ref:b,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:ae(e.onKeyDown,P=>{P.key==="Escape"&&(a==null||a(P.nativeEvent),P.nativeEvent.defaultPrevented||(g.isFocusedToastEscapeKeyDownRef.current=!0,F()))}),onPointerDown:ae(e.onPointerDown,P=>{P.button===0&&(C.current={x:P.clientX,y:P.clientY})}),onPointerMove:ae(e.onPointerMove,P=>{if(!C.current)return;const Y=P.clientX-C.current.x,q=P.clientY-C.current.y,W=!!k.current,D=["left","right"].includes(g.swipeDirection),I=["left","up"].includes(g.swipeDirection)?Math.min:Math.max,G=D?I(0,Y):0,X=D?0:I(0,q),M=P.pointerType==="touch"?10:2,B={x:G,y:X},_={originalEvent:P,delta:B};W?(k.current=B,xi(xI,f,_,{discrete:!1})):Vg(B,g.swipeDirection,M)?(k.current=B,xi(gI,d,_,{discrete:!1}),P.target.setPointerCapture(P.pointerId)):(Math.abs(Y)>M||Math.abs(q)>M)&&(C.current=null)}),onPointerUp:ae(e.onPointerUp,P=>{const Y=k.current,q=P.target;if(q.hasPointerCapture(P.pointerId)&&q.releasePointerCapture(P.pointerId),k.current=null,C.current=null,Y){const W=P.currentTarget,D={originalEvent:P,delta:Y};Vg(Y,g.swipeDirection,g.swipeThreshold)?xi(wI,p,D,{discrete:!0}):xi(vI,m,D,{discrete:!0}),W.addEventListener("click",I=>I.preventDefault(),{once:!0})}})})})}),g.viewport)})]}):null}),CI=e=>{const{__scopeToast:t,children:n,...r}=e,o=gi(Oo,t),[s,i]=h.useState(!1),[a,l]=h.useState(!1);return EI(()=>i(!0)),h.useEffect(()=>{const c=window.setTimeout(()=>l(!0),1e3);return()=>window.clearTimeout(c)},[]),a?null:u.jsx(lo,{asChild:!0,children:u.jsx(ai,{...r,children:s&&u.jsxs(u.Fragment,{children:[o.label," ",n]})})})},TI="ToastTitle",$g=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(pe.div,{...r,ref:t})});$g.displayName=TI;var kI="ToastDescription",Fg=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(pe.div,{...r,ref:t})});Fg.displayName=kI;var Bg="ToastAction",zg=h.forwardRef((e,t)=>{const{altText:n,...r}=e;return n.trim()?u.jsx(Ug,{altText:n,asChild:!0,children:u.jsx(Jl,{...r,ref:t})}):(console.error(`Invalid prop \`altText\` supplied to \`${Bg}\`. Expected non-empty \`string\`.`),null)});zg.displayName=Bg;var Hg="ToastClose",Jl=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e,o=yI(Hg,n);return u.jsx(Ug,{asChild:!0,children:u.jsx(pe.button,{type:"button",...r,ref:t,onClick:ae(e.onClick,o.onClose)})})});Jl.displayName=Hg;var Ug=h.forwardRef((e,t)=>{const{__scopeToast:n,altText:r,...o}=e;return u.jsx(pe.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":r||void 0,...o,ref:t})});function Wg(e){const t=[];return Array.from(e.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&t.push(r.textContent),II(r)){const o=r.ariaHidden||r.hidden||r.style.display==="none",s=r.dataset.radixToastAnnounceExclude==="";if(!o)if(s){const i=r.dataset.radixToastAnnounceAlt;i&&t.push(i)}else t.push(...Wg(r))}}),t}function xi(e,t,n,{discrete:r}){const o=n.originalEvent.currentTarget,s=new CustomEvent(e,{bubbles:!0,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?Wi(o,s):o.dispatchEvent(s)}var Vg=(e,t,n=0)=>{const r=Math.abs(e.x),o=Math.abs(e.y),s=r>o;return t==="left"||t==="right"?s&&r>n:!s&&o>n};function EI(e=()=>{}){const t=gt(e);kt(()=>{let n=0,r=0;return n=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(r)}},[t])}function II(e){return e.nodeType===e.ELEMENT_NODE}function NI(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function Zl(e){const t=document.activeElement;return e.some(n=>n===t?!0:(n.focus(),document.activeElement!==t))}var AI=Rg,Kg=Og,qg=Lg,Gg=$g,Yg=Fg,Xg=zg,Jg=Jl;const jI=AI,Zg=h.forwardRef(({className:e,...t},n)=>u.jsx(Kg,{ref:n,className:ne("fixed bottom-0 right-0 z-[100] flex max-h-screen w-full flex-col p-4 md:max-w-[420px]",e),...t}));Zg.displayName=Kg.displayName;const PI=Ur.cva("group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",{variants:{variant:{default:"border bg-background text-foreground",destructive:"destructive group border-destructive bg-destructive text-destructive-foreground"}},defaultVariants:{variant:"default"}}),Qg=h.forwardRef(({className:e,variant:t,...n},r)=>u.jsx(qg,{ref:r,className:ne(PI({variant:t}),e),...n}));Qg.displayName=qg.displayName;const _I=h.forwardRef(({className:e,...t},n)=>u.jsx(Xg,{ref:n,className:ne("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",e),...t}));_I.displayName=Xg.displayName;const ex=h.forwardRef(({className:e,...t},n)=>u.jsx(Jg,{ref:n,className:ne("absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",e),"toast-close":"",...t,children:u.jsx(le.X,{className:"h-4 w-4"})}));ex.displayName=Jg.displayName;const tx=h.forwardRef(({className:e,...t},n)=>u.jsx(Gg,{ref:n,className:ne("text-sm font-semibold",e),...t}));tx.displayName=Gg.displayName;const nx=h.forwardRef(({className:e,...t},n)=>u.jsx(Yg,{ref:n,className:ne("text-sm opacity-90",e),...t}));nx.displayName=Yg.displayName;function RI(){const{toasts:e}=al();return u.jsxs(jI,{children:[e.map(function({id:t,title:n,description:r,action:o,...s}){return u.jsxs(Qg,{...s,children:[u.jsxs("div",{className:"grid gap-1",children:[n&&u.jsx(tx,{children:n}),r&&u.jsx(nx,{children:r})]}),o,u.jsx(ex,{})]},t)}),u.jsx(Zg,{})]})}var MI=(e,t,n,r,o,s,i,a)=>{let l=document.documentElement,c=["light","dark"];function d(p){(Array.isArray(e)?e:[e]).forEach(v=>{let g=v==="class",x=g&&s?o.map(y=>s[y]||y):o;g?(l.classList.remove(...x),l.classList.add(s&&s[p]?s[p]:p)):l.setAttribute(v,p)}),f(p)}function f(p){a&&c.includes(p)&&(l.style.colorScheme=p)}function m(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(r)d(r);else try{let p=localStorage.getItem(t)||n,v=i&&p==="system"?m():p;d(v)}catch{}},OI=h.createContext(void 0),DI={setTheme:e=>{},themes:[]},LI=()=>{var e;return(e=h.useContext(OI))!=null?e:DI};h.memo(({forcedTheme:e,storageKey:t,attribute:n,enableSystem:r,enableColorScheme:o,defaultTheme:s,value:i,themes:a,nonce:l,scriptProps:c})=>{let d=JSON.stringify([n,t,s,e,a,i,r,o]).slice(1,-1);return h.createElement("script",{...c,suppressHydrationWarning:!0,nonce:typeof window>"u"?l:"",dangerouslySetInnerHTML:{__html:`(${MI.toString()})(${d})`}})});var $I=e=>{switch(e){case"success":return zI;case"info":return UI;case"warning":return HI;case"error":return WI;default:return null}},FI=Array(12).fill(0),BI=({visible:e,className:t})=>w.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},w.createElement("div",{className:"sonner-spinner"},FI.map((n,r)=>w.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),zI=w.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},w.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),HI=w.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},w.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),UI=w.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},w.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),WI=w.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},w.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),VI=w.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},w.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),w.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),KI=()=>{let[e,t]=w.useState(document.hidden);return w.useEffect(()=>{let n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e},Ql=1,qI=class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{let t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{var t;let{message:n,...r}=e,o=typeof(e==null?void 0:e.id)=="number"||((t=e.id)==null?void 0:t.length)>0?e.id:Ql++,s=this.toasts.find(a=>a.id===o),i=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(o)&&this.dismissedToasts.delete(o),s?this.toasts=this.toasts.map(a=>a.id===o?(this.publish({...a,...e,id:o,title:n}),{...a,...e,id:o,dismissible:i,title:n}):a):this.addToast({title:n,...r,dismissible:i,id:o}),o},this.dismiss=e=>(this.dismissedToasts.add(e),e||this.toasts.forEach(t=>{this.subscribers.forEach(n=>n({id:t.id,dismiss:!0}))}),this.subscribers.forEach(t=>t({id:e,dismiss:!0})),e),this.message=(e,t)=>this.create({...t,message:e}),this.error=(e,t)=>this.create({...t,message:e,type:"error"}),this.success=(e,t)=>this.create({...t,type:"success",message:e}),this.info=(e,t)=>this.create({...t,type:"info",message:e}),this.warning=(e,t)=>this.create({...t,type:"warning",message:e}),this.loading=(e,t)=>this.create({...t,type:"loading",message:e}),this.promise=(e,t)=>{if(!t)return;let n;t.loading!==void 0&&(n=this.create({...t,promise:e,type:"loading",message:t.loading,description:typeof t.description!="function"?t.description:void 0}));let r=e instanceof Promise?e:e(),o=n!==void 0,s,i=r.then(async l=>{if(s=["resolve",l],w.isValidElement(l))o=!1,this.create({id:n,type:"default",message:l});else if(YI(l)&&!l.ok){o=!1;let c=typeof t.error=="function"?await t.error(`HTTP error! status: ${l.status}`):t.error,d=typeof t.description=="function"?await t.description(`HTTP error! status: ${l.status}`):t.description;this.create({id:n,type:"error",message:c,description:d})}else if(t.success!==void 0){o=!1;let c=typeof t.success=="function"?await t.success(l):t.success,d=typeof t.description=="function"?await t.description(l):t.description;this.create({id:n,type:"success",message:c,description:d})}}).catch(async l=>{if(s=["reject",l],t.error!==void 0){o=!1;let c=typeof t.error=="function"?await t.error(l):t.error,d=typeof t.description=="function"?await t.description(l):t.description;this.create({id:n,type:"error",message:c,description:d})}}).finally(()=>{var l;o&&(this.dismiss(n),n=void 0),(l=t.finally)==null||l.call(t)}),a=()=>new Promise((l,c)=>i.then(()=>s[0]==="reject"?c(s[1]):l(s[1])).catch(c));return typeof n!="string"&&typeof n!="number"?{unwrap:a}:Object.assign(n,{unwrap:a})},this.custom=(e,t)=>{let n=(t==null?void 0:t.id)||Ql++;return this.create({jsx:e(n),id:n,...t}),n},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},Vt=new qI,GI=(e,t)=>{let n=(t==null?void 0:t.id)||Ql++;return Vt.addToast({title:e,...t,id:n}),n},YI=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",XI=GI,JI=()=>Vt.toasts,ZI=()=>Vt.getActiveToasts();Object.assign(XI,{success:Vt.success,info:Vt.info,warning:Vt.warning,error:Vt.error,custom:Vt.custom,message:Vt.message,promise:Vt.promise,dismiss:Vt.dismiss,loading:Vt.loading},{getHistory:JI,getToasts:ZI});function QI(e,{insertAt:t}={}){if(typeof document>"u")return;let n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t==="top"&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}QI(`:where(html[dir="ltr"]),:where([data-sonner-toaster][dir="ltr"]){--toast-icon-margin-start: -3px;--toast-icon-margin-end: 4px;--toast-svg-margin-start: -1px;--toast-svg-margin-end: 0px;--toast-button-margin-start: auto;--toast-button-margin-end: 0;--toast-close-button-start: 0;--toast-close-button-end: unset;--toast-close-button-transform: translate(-35%, -35%)}:where(html[dir="rtl"]),:where([data-sonner-toaster][dir="rtl"]){--toast-icon-margin-start: 4px;--toast-icon-margin-end: -3px;--toast-svg-margin-start: 0px;--toast-svg-margin-end: -1px;--toast-button-margin-start: 0;--toast-button-margin-end: auto;--toast-close-button-start: unset;--toast-close-button-end: 0;--toast-close-button-transform: translate(35%, -35%)}:where([data-sonner-toaster]){position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1: hsl(0, 0%, 99%);--gray2: hsl(0, 0%, 97.3%);--gray3: hsl(0, 0%, 95.1%);--gray4: hsl(0, 0%, 93%);--gray5: hsl(0, 0%, 90.9%);--gray6: hsl(0, 0%, 88.7%);--gray7: hsl(0, 0%, 85.8%);--gray8: hsl(0, 0%, 78%);--gray9: hsl(0, 0%, 56.1%);--gray10: hsl(0, 0%, 52.3%);--gray11: hsl(0, 0%, 43.5%);--gray12: hsl(0, 0%, 9%);--border-radius: 8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:none;z-index:999999999;transition:transform .4s ease}:where([data-sonner-toaster][data-lifted="true"]){transform:translateY(-10px)}@media (hover: none) and (pointer: coarse){:where([data-sonner-toaster][data-lifted="true"]){transform:none}}:where([data-sonner-toaster][data-x-position="right"]){right:var(--offset-right)}:where([data-sonner-toaster][data-x-position="left"]){left:var(--offset-left)}:where([data-sonner-toaster][data-x-position="center"]){left:50%;transform:translate(-50%)}:where([data-sonner-toaster][data-y-position="top"]){top:var(--offset-top)}:where([data-sonner-toaster][data-y-position="bottom"]){bottom:var(--offset-bottom)}:where([data-sonner-toast]){--y: translateY(100%);--lift-amount: calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);filter:blur(0);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none;overflow-wrap:anywhere}:where([data-sonner-toast][data-styled="true"]){padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}:where([data-sonner-toast]:focus-visible){box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast][data-y-position="top"]){top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}:where([data-sonner-toast][data-y-position="bottom"]){bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}:where([data-sonner-toast]) :where([data-description]){font-weight:400;line-height:1.4;color:inherit}:where([data-sonner-toast]) :where([data-title]){font-weight:500;line-height:1.5;color:inherit}:where([data-sonner-toast]) :where([data-icon]){display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}:where([data-sonner-toast][data-promise="true"]) :where([data-icon])>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}:where([data-sonner-toast]) :where([data-icon])>*{flex-shrink:0}:where([data-sonner-toast]) :where([data-icon]) svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}:where([data-sonner-toast]) :where([data-content]){display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;cursor:pointer;outline:none;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}:where([data-sonner-toast]) :where([data-button]):focus-visible{box-shadow:0 0 0 2px #0006}:where([data-sonner-toast]) :where([data-button]):first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}:where([data-sonner-toast]) :where([data-cancel]){color:var(--normal-text);background:rgba(0,0,0,.08)}:where([data-sonner-toast][data-theme="dark"]) :where([data-cancel]){background:rgba(255,255,255,.3)}:where([data-sonner-toast]) :where([data-close-button]){position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast] [data-close-button]{background:var(--gray1)}:where([data-sonner-toast]) :where([data-close-button]):focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast]) :where([data-disabled="true"]){cursor:not-allowed}:where([data-sonner-toast]):hover :where([data-close-button]):hover{background:var(--gray2);border-color:var(--gray5)}:where([data-sonner-toast][data-swiping="true"]):before{content:"";position:absolute;left:-50%;right:-50%;height:100%;z-index:-1}:where([data-sonner-toast][data-y-position="top"][data-swiping="true"]):before{bottom:50%;transform:scaleY(3) translateY(50%)}:where([data-sonner-toast][data-y-position="bottom"][data-swiping="true"]):before{top:50%;transform:scaleY(3) translateY(-50%)}:where([data-sonner-toast][data-swiping="false"][data-removed="true"]):before{content:"";position:absolute;inset:0;transform:scaleY(2)}:where([data-sonner-toast]):after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}:where([data-sonner-toast][data-mounted="true"]){--y: translateY(0);opacity:1}:where([data-sonner-toast][data-expanded="false"][data-front="false"]){--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}:where([data-sonner-toast])>*{transition:opacity .4s}:where([data-sonner-toast][data-expanded="false"][data-front="false"][data-styled="true"])>*{opacity:0}:where([data-sonner-toast][data-visible="false"]){opacity:0;pointer-events:none}:where([data-sonner-toast][data-mounted="true"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}:where([data-sonner-toast][data-removed="true"][data-front="true"][data-swipe-out="false"]){--y: translateY(calc(var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="false"]){--y: translateY(40%);opacity:0;transition:transform .5s,opacity .2s}:where([data-sonner-toast][data-removed="true"][data-front="false"]):before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y, 0px)) translate(var(--swipe-amount-x, 0px));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width: 600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-theme=light]{--normal-bg: #fff;--normal-border: var(--gray4);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--info-bg: hsl(208, 100%, 97%);--info-border: hsl(221, 91%, 91%);--info-text: hsl(210, 92%, 45%);--warning-bg: hsl(49, 100%, 97%);--warning-border: hsl(49, 91%, 91%);--warning-text: hsl(31, 92%, 45%);--error-bg: hsl(359, 100%, 97%);--error-border: hsl(359, 100%, 94%);--error-text: hsl(360, 100%, 45%)}[data-sonner-toaster][data-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-theme=dark]{--normal-bg: #000;--normal-bg-hover: hsl(0, 0%, 12%);--normal-border: hsl(0, 0%, 20%);--normal-border-hover: hsl(0, 0%, 25%);--normal-text: var(--gray1);--success-bg: hsl(150, 100%, 6%);--success-border: hsl(147, 100%, 12%);--success-text: hsl(150, 86%, 65%);--info-bg: hsl(215, 100%, 6%);--info-border: hsl(223, 100%, 12%);--info-text: hsl(216, 87%, 65%);--warning-bg: hsl(64, 100%, 6%);--warning-border: hsl(60, 100%, 12%);--warning-text: hsl(46, 87%, 65%);--error-bg: hsl(358, 76%, 10%);--error-border: hsl(357, 89%, 16%);--error-text: hsl(358, 100%, 81%)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success],[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info],[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning],[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error],[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size: 16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:nth-child(1){animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}
130
+ dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20`,children:[g[O]?u.jsx(le.Loader,{className:"h-4 w-4 animate-spin"}):null,u.jsxs("span",{className:"truncate max-w-[180px]",children:[U,g[O]?" (processing)":""]})]},O)}return null},[v,S,C,x,y,g,b,m,k]),$=i.trim().length>0||a.length>0||l.length>0||B.length>0;if(!t&&l.length>0&&!d)return P();if(!t&&!$&&!d)return null;if(t){if(!n)return null;if(J&&c){const z=c.value,O=!K,j=R??(()=>{}),U=L??(()=>{});return u.jsx(hl,{interruptPart:c,payload:z,onApprove:j,onReject:U,onSelectAlternative:F,disabled:K,isActive:O})}return u.jsx(Dh,{message:e,viewMode:r,isStreaming:o,toolRenderers:E,toolArtifactRenderers:A},e.id)}if(!p){const z=u.jsx("div",{className:"space-y-2",children:B.map((O,j)=>m&&ZT(O)?G?u.jsx("div",{className:"space-y-2",children:G},`streaming-md-${j}`):null:u.jsx(_,{part:O,i:j},j))});return d?u.jsxs("div",{"aria-busy":"true",role:"status",children:[z,u.jsx(Ph,{className:T})]}):z}return null}function Lh(e){return e?!(jo(e,/```/g)||jo(e,/`/g)||jo(e,/\*\*/g)||jo(e,/__/g)||jo(e,/~~/g)||/[^\\]\[[^\]]*$/.test(e)||/\[[^\]]*\]\([^)]*$/.test(e)):!0}function jo(e,t){const n=e.match(t);return((n==null?void 0:n.length)??0)%2!==0}function JT(e){if(!e)return 0;for(let t=e.length;t>=0;t-=1)if(Lh(e.slice(0,t)))return t;return 0}function ZT(e){return e.type==="text"&&!!e.__streamingMarkdownAggregate}const QT=Ur.cva("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function $h({className:e,variant:t,...n}){return u.jsx("div",{className:ne(QT({variant:t}),e),...n})}function ek({showTimestamp:e,showAgentName:t,isToolMessage:n,isInterruptMessage:r=!1,iconForeground:o,agentName:s,messageIcon:i,customHeaderClass:a,customActionsClass:l,isCompactLayout:c,showActions:d,isEditing:f,messageRole:m,toolViewMode:p,toolMeta:v,onToggleToolView:g,onCopy:x,onEdit:y,onRegenerate:b,showCheckpointControls:C,attemptCount:k,attemptIndex:S,handleOlderAttemptSelect:T,handleNewerAttemptSelect:E,messageCreatedAt:A,copied:R}){return!e&&!t&&!n&&!r?null:u.jsxs("div",{className:ne("flex items-center justify-between mb-2 pb-2 border-b border-current/10",c&&"mb-1 pb-1",o,a),children:[u.jsxs("div",{className:"flex items-center gap-2",children:[i,t&&s&&u.jsx("span",{className:ne("font-medium",c?"text-xs":"text-sm"),children:s}),n&&!r&&u.jsxs($h,{variant:"outline",className:ne("text-xs flex items-center gap-1 cursor-pointer select-none",o,"border border-current/40",c&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":p==="expanded",onClick:g,onKeyDown:L=>{(L.key==="Enter"||L.key===" ")&&(L.preventDefault(),g())},children:[u.jsx("span",{children:v.name??"Tool Output"}),v.toolCallId&&u.jsx("span",{className:"opacity-70",children:v.toolCallId.slice(0,8)}),p==="expanded"?u.jsx(le.ChevronUp,{className:"h-3 w-3"}):u.jsx(le.ChevronDown,{className:"h-3 w-3"})]}),r&&u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:v.name??"Interrupt"})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[C&&k>1&&u.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[u.jsx("button",{type:"button",className:ne("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",S<k-1?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{S>=k-1||T()},"aria-label":"Older attempt (back in time)",disabled:S>=k-1,children:u.jsx(le.ChevronLeft,{className:"h-3 w-3"})}),u.jsx("div",{className:"flex items-center gap-2",children:u.jsxs("span",{className:"whitespace-nowrap",children:[k-S," / ",k]})}),u.jsx("button",{type:"button",className:ne("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",S>0?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{S<=0||E()},"aria-label":"Newer attempt (forward in time)",disabled:S<=0,children:u.jsx(le.ChevronRight,{className:"h-3 w-3"})})]}),e&&A&&u.jsx("time",{className:ne("text-xs opacity-60",o,c&&"text-xs"),dateTime:new Date(A).toISOString(),title:new Date(A).toLocaleString(),children:new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(new Date(A))}),d&&!f&&u.jsxs("div",{className:ne("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",l),children:[u.jsx("div",{className:"relative",children:u.jsx(Je,{variant:"ghost",size:"sm",onClick:x,className:ne("h-6 w-6 p-0 hover:bg-foreground/10",o,c&&"h-5 w-5"),"aria-label":"Copy message",title:"Copy message",children:u.jsx(le.Copy,{className:ne(R?"text-success":o,c?"h-3 w-3":"h-4 w-4")})})}),m==="user"&&y&&u.jsx(Je,{variant:"ghost",size:"sm",onClick:y,className:ne("h-6 w-6 p-0 hover:bg-foreground/10",o,c&&"h-5 w-5"),"aria-label":"Edit message",children:u.jsx(le.Edit,{className:ne(o,c?"h-3 w-3":"h-4 w-4")})}),m==="assistant"&&b&&u.jsx(Je,{variant:"ghost",size:"sm",onClick:b,className:ne("h-6 w-6 p-0 hover:bg-foreground/10",o,c&&"h-5 w-5"),"aria-label":"Regenerate response",children:u.jsx(le.RotateCcw,{className:ne(o,c?"h-3 w-3":"h-4 w-4")})})]})]})]})}const ei=w.memo(function({message:t,messageIndex:n,isStreamingMessage:r=!1,isEditing:o=!1,showActions:s=!0,showTimestamp:i=!0,showAgentName:a=!0,layoutSize:l="desktop",truncateUserMessages:c=!0,userMessagePreviewLength:d=500,showToolMessages:f=!0,toolRenderers:m,toolArtifactRenderers:p,customStyles:v={},streamingDebounceMs:g=300,renderStreamingMarkdown:x=!1,enableStreamingMarkdownBuffer:y,onEdit:b,onRegenerate:C,onCopy:k,getInterruptOptions:S,attemptCount:T=1,attemptIndex:E=0,onSelectCheckpoint:A,attemptMetas:R=[]}){const[L,F]=w.useState(!1),[K,J]=w.useState("preview"),[P,Y]=w.useState(!1),{currentThreadId:q}=vr(),{respondToInterrupt:W}=ro(),[D,I]=w.useState(!1),G=l==="phone"||l==="half-screen",X=t.role,M=X==="interrupt",B=X==="tool"||M,$=!(t.role==="default_message")&&t.expandable!==void 0?t.expandable!==!1:!0,z=w.useMemo(()=>t.role==="default_message"?t:null,[t]),O=!!z,j=!(r&&X!=="user"),{uploadingFiles:U,handleFileClick:Q,fileViewerOpen:se,currentFileInfo:ie,closeFileViewer:Se}=Rh({allowFileOpen:j,currentThreadId:q}),xe=w.useMemo(()=>{switch(X){case"user":return"text-[hsl(var(--chat-bubble-user-text))]";case"assistant":return"text-[hsl(var(--chat-bubble-ai-text))]";case"interrupt":return"text-[hsl(var(--chat-bubble-ai-text))]";case"tool":return"text-secondary-foreground";case"system":return"text-muted-foreground";default:return"text-[hsl(var(--chat-bubble-ai-text))]"}},[X]),Re=Mh(t,z),{contentParts:Ve,imageParts:De,fileParts:Ge,textContent:He,toolMeta:ot,toolRaw:ut,isToolStreaming:nt,interruptParts:Le}=Re,Ke=y??g!==0,$e=w.useMemo(()=>Le.length?Le[0]:null,[Le]),Te=w.useCallback(async()=>{const je=B?ut:He;async function Ye(we){if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function"){await navigator.clipboard.writeText(we);return}if(navigator.clipboard&&typeof navigator.clipboard.write=="function"&&typeof ClipboardItem<"u"){const Qe=new Blob([we],{type:"text/plain"});await navigator.clipboard.write([new ClipboardItem({"text/plain":Qe})]);return}throw new Error("Clipboard API not supported in this context.")}try{await Ye(je),F(!0),setTimeout(()=>F(!1),2e3),k==null||k(je)}catch(we){console.error("Failed to copy:",we)}},[B,ut,He,k]),Ae=w.useCallback(async(je,Ye)=>{if(!$e)return;if(!wu($e.id)){console.warn("Interrupt part missing id",$e);return}I(!0);try{const Qe=S==null?void 0:S(t);await W(je,Ye,Qe)}catch(Qe){console.error("Failed to respond to interrupt:",Qe)}finally{I(!1)}},[$e,W]),dt=w.useCallback(()=>Ae(!0),[Ae]),Et=w.useCallback(()=>Ae(!1),[Ae]),at=w.useCallback((je,Ye)=>{if(!Ye)return;const we={alternativeId:Ye.id??Ye.label??void 0,alternativeLabel:Ye.label};Ae(!0,we)},[Ae]),It=w.useCallback(()=>{if(!b||!t.id)return;const je=(B?ut:He)??"",Ye="type"in t&&t.type==="default_message"?void 0:{checkpointId:t.checkpointId??null,checkpointNs:t.checkpointNs??null};b(t.id,je,Ye)},[b,B,ut,He,t]),bt=w.useCallback(()=>{C==null||C(n)},[C,n]),ft=!M&&$,Nt=w.useCallback(()=>{ft&&J(je=>je==="expanded"?"preview":"expanded")},[ft]),Ct=M?"expanded":K,on=w.useCallback(()=>{const Ye=ne(G?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",xe);switch(X){case"user":return u.jsx(le.User,{className:Ye});case"assistant":return u.jsx(le.Bot,{className:Ye});case"tool":return u.jsx(le.Wrench,{className:Ye});case"interrupt":return u.jsx(le.Bot,{className:Ye});default:return u.jsx(le.Bot,{className:Ye})}},[G,xe,X]),Tt=w.useCallback(()=>{const je="group relative mb-4 flex w-full";switch(X){case"user":return ne(je,"justify-end");case"assistant":case"tool":case"system":case"interrupt":return ne(je,"justify-start");default:return je}},[X]),Ie=w.useCallback(()=>{const je=ne("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",G&&"px-3 py-2 text-sm");if(O)return ne(je,"w-full","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40 shadow-sm");switch(X){case"user":return ne(je,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-user))] text-[hsl(var(--chat-bubble-user-text))]","border border-transparent");case"assistant":return ne(je,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40");case"tool":case"interrupt":return ne(je,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return ne(je,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return ne(je,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40")}},[G,O,X]),Ue=(f||M)&&$,jt=u.jsx(XT,{message:t,isToolMessage:B,showToolMessages:Ue,toolViewMode:Ct,isToolStreaming:nt,contentParts:Ve,textContent:He,imageParts:De,fileParts:Ge,isStreamingMessage:r,defaultMessage:z,enableStreamingMarkdownBuffer:Ke,renderStreamingMarkdown:x,handleFileClick:Q,uploadingFiles:U,messageRole:X,truncateUserMessages:c,userMessagePreviewLength:d,isUserExpanded:P,setIsUserExpanded:Y,isCompactLayout:G,iconForeground:xe,toolRenderers:m,toolArtifactRenderers:p,interruptPart:$e,handleInterruptApprove:dt,handleInterruptReject:Et,handleInterruptAlternative:at,disableInterruptActions:D,isInterruptMessage:M}),te=w.useMemo(()=>z?"Assistant":aw(t),[z,t]),ge=on(),rt=X==="user"&&(T??1)>1&&typeof A=="function",fe=(R==null?void 0:R.length)??0,ke=fe>0&&E<fe-1?R[E+1]:void 0,Fe=fe>0&&E>0?R[E-1]:void 0,ht=w.useCallback(()=>{!ke||!A||A(ke.id,void 0,!!ke.isLatestAttempt)},[ke,A]),pt=w.useCallback(()=>{!Fe||!A||A(Fe.id,void 0,!!Fe.isLatestAttempt)},[Fe,A]);return B&&!f?null:O&&z?u.jsx("div",{className:ne(Tt(),v.container),children:u.jsxs("div",{className:ne(Ie(),v.content),children:[u.jsxs("div",{className:"flex items-center gap-2 mb-2 pb-2 border-b border-current/10",children:[u.jsx(le.Bot,{className:ne("h-4 w-4",xe)}),a&&u.jsx("span",{className:"font-medium text-sm",children:"Assistant"})]}),u.jsx(cr,{content:z.content,className:"text-current"})]})}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:ne(Tt(),v.container),children:u.jsxs("div",{className:ne(Ie(),v.content),children:[u.jsx(ek,{showTimestamp:i,showAgentName:a,isToolMessage:B,iconForeground:xe,agentName:te,messageIcon:ge,customHeaderClass:v.header,customActionsClass:v.actions,isCompactLayout:G,showActions:s,isEditing:o,messageRole:X,toolViewMode:Ct,isInterruptMessage:M,toolMeta:ot,onToggleToolView:Nt,onCopy:Te,onEdit:It,onRegenerate:bt,showCheckpointControls:rt,attemptCount:T,attemptIndex:E,handleOlderAttemptSelect:ht,handleNewerAttemptSelect:pt,messageCreatedAt:t.createdAt,copied:L}),u.jsx("div",{className:"relative",children:jt}),B&&Ct==="expanded"&&(ot.toolCallId||ot.name)&&u.jsxs("div",{className:ne("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",G&&"text-xs"),children:[ot.name&&u.jsxs("div",{children:["Function: ",ot.name]}),ot.toolCallId&&u.jsxs("div",{children:["Call ID: ",ot.toolCallId]})]}),!(i||a||B)&&s&&!o&&u.jsxs("div",{className:ne("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",v.actions),children:[u.jsx(Je,{variant:"ghost",size:"sm",onClick:()=>Te(),className:ne("h-6 w-6 p-0 hover:bg-background/50 text-current",G&&"h-5 w-5"),children:u.jsx(le.Copy,{className:ne(L?"text-success":"text-current",G?"h-3 w-3":"h-4 w-4")})}),X==="user"&&b&&u.jsx(Je,{variant:"ghost",size:"sm",onClick:It,className:ne("h-6 w-6 p-0 hover:bg-background/50 text-current",G&&"h-5 w-5"),children:u.jsx(le.Edit,{className:ne("text-current",G?"h-3 w-3":"h-4 w-4")})}),X==="assistant"&&C&&u.jsx(Je,{variant:"ghost",size:"sm",onClick:bt,className:ne("h-6 w-6 p-0 hover:bg-background/50 text-current",G&&"h-5 w-5"),children:u.jsx(le.RotateCcw,{className:ne("text-current",G?"h-3 w-3":"h-4 w-4")})})]})]})}),ie&&u.jsx(ph,{isOpen:se,onClose:Se,fileId:ie.id,fileName:ie.name,mimeType:ie.mimeType})]})},(e,t)=>{var l,c,d,f,m,p,v,g;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&bu(e.message)===bu(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateUserMessages","userMessagePreviewLength","showToolMessages","toolRenderers","toolArtifactRenderers"].every(x=>e[x]===t[x]),s=((l=e.customStyles)==null?void 0:l.container)===((c=t.customStyles)==null?void 0:c.container)&&((d=e.customStyles)==null?void 0:d.content)===((f=t.customStyles)==null?void 0:f.content)&&((m=e.customStyles)==null?void 0:m.actions)===((p=t.customStyles)==null?void 0:p.actions)&&((v=e.customStyles)==null?void 0:v.header)===((g=t.customStyles)==null?void 0:g.header);if(!o||!s)return!1;const i=yu(e.message),a=yu(t.message);return i.length===a.length});ei.displayName="MessageComponent";const xl=w.forwardRef(({messages:e,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onStartReached:a,onEdit:l,onRegenerate:c,onCancelEdit:d,className:f,style:m,emptyMessage:p,followNewMessages:v=!0,isNavigatingCheckpoint:g=!1,onScrollAway:x,onAtBottom:y,showToolMessages:b=!0,toolRenderers:C,toolArtifactRenderers:k,checkpointIndex:S,activeCheckpointId:T,onSelectCheckpoint:E,createSyntheticThinkingMessage:A=!0,forceSyntheticThinking:R=!1,getMessageCustomStyles:L,getInterruptOptions:F},K)=>{const J=w.useRef(null),P=w.useRef(null),Y=w.useRef(!1),q=w.useRef(!1),W=e,D=w.useMemo(()=>{const j=n&&W.some(Q=>Q.id===n);return A&&(t||R)&&!j&&W.length>0?[...W,{id:"thinking-assistant",role:"assistant",content:[{type:"text",text:""}],createdAt:new Date().toISOString(),__syntheticStreaming:!0}]:W},[W,t,n,A,R]),I=w.useMemo(()=>b?D:D.filter(j=>(j==null?void 0:j.role)!=="tool"),[D,b]),G=w.useCallback(j=>{x&&x(!j),y&&y(j)},[x,y]),X=w.useMemo(()=>{if(a)return async()=>{if(!Y.current){Y.current=!0;try{await a()}finally{Y.current=!1}}}},[a]),M=w.useMemo(()=>!v||g?!1:"auto",[v,g]),B=w.useMemo(()=>{if(typeof p!="string")return null;const j=p.trim();return!j||I&&I.length>0?null:{id:"default-message",role:"default_message",content:j,createdAt:new Date().toISOString()}},[p,I]),_=["flex h-full flex-col md:flex-row",f].filter(Boolean).join(" "),$=()=>{if(B){const j=L==null?void 0:L(B);return u.jsx("div",{className:"p-6 h-full overflow-y-auto",children:u.jsx("div",{className:"w-full max-w-full",children:u.jsx(ei,{message:B,messageIndex:0,isStreamingMessage:!1,showActions:!1,showTimestamp:!1,showAgentName:!0,layoutSize:o,onEdit:()=>{},onRegenerate:()=>{},onCancelEdit:()=>{},customStyles:j,getInterruptOptions:F})})})}return u.jsx("div",{className:"flex h-full items-center justify-center py-8 text-center text-muted-foreground",children:p??"No messages yet. Start a conversation!"})},z=I.length,O=z>0;return w.useEffect(()=>{var j,U;if(z===0){q.current=!1;return}if(!q.current)if(q.current=!0,J.current&&I.length>0){const Q=I.length-1;(U=(j=J.current).scrollToIndex)==null||U.call(j,{index:Q,align:"end",behavior:"auto"})}else P.current&&(P.current.scrollTop=P.current.scrollHeight)},[z,I.length]),w.useImperativeHandle(K,()=>({scrollToLatest:()=>{var j,U;if(J.current&&I.length>0){const Q=I.length-1;(U=(j=J.current).scrollToIndex)==null||U.call(j,{index:Q,align:"end",behavior:"auto"})}else P.current&&(P.current.scrollTop=P.current.scrollHeight)},scrollToTop:()=>{var j,U;J.current&&I.length>0?(U=(j=J.current).scrollToIndex)==null||U.call(j,{index:0,align:"start",behavior:"auto"}):P.current&&(P.current.scrollTop=0)}}),[I]),u.jsx("div",{className:_,style:m,children:u.jsx("div",{className:"relative flex-1 min-h-0",children:O?u.jsx(qC,{ref:j=>{J.current=j},scrollerRef:j=>{P.current=j instanceof HTMLDivElement?j:null},data:I,followOutput:M,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,startReached:()=>{X&&X()},atBottomStateChange:G,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(j,U)=>ml(U,j),itemContent:(j,U)=>u.jsx(gl,{message:U,index:j,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onEdit:l,onRegenerate:c,onCancelEdit:d,showToolMessages:b,toolRenderers:C,toolArtifactRenderers:k,checkpointIndex:S,activeCheckpointId:T,onSelectCheckpoint:E,getMessageCustomStyles:L,getInterruptOptions:F})}):$()})})});xl.displayName="MessageList";const Fh={value:""};function Dr({className:e="",placeholder:t="Type your message...",autoFocus:n=!0,maxHeight:r=void 0,streamingDebounceMs:o=500,streamingThrottleMs:s,followNewMessages:i=!0,enableFileUpload:a=!0,enableExcelUpload:l=!1,enableMessageEditing:c=!0,showToolMessages:d=!0,toolRenderers:f,toolArtifactRenderers:m,payloadExtras:p={},customStyles:v={},messageCustomStyles:g,onMessageSent:x,onExcelUploadSuccess:y,onError:b,defaultMessage:C}){const{api:k}=Qr(),S=k.baseUrl,{currentThreadId:T}=vr(),{threadId:E,messages:A,isLoading:R,navigateToCheckpoint:L,returnToLatest:F,checkpoint:K,checkpoints:J,interrupt:P,metadata:Y,checkpointIndex:q,respondToInterrupt:W}=ro(),{isStreaming:D,error:I,connectionState:G,submit:X,stop:M}=Hi(),B=E??T??null,_=(K==null?void 0:K.id)??null,$=(K==null?void 0:K.namespace)??null,z=(Y==null?void 0:Y.assemblingMessageId)??null,O=P,j=O?wu(O.id):null,U=j!==null?{type:"interrupt",id:j}:null,[Q,se]=w.useState(!1),[ie,Se]=w.useState(!1);w.useEffect(()=>{O||se(!1)},[O]);const xe=w.useCallback(()=>{se(!0)},[]),Re=w.useCallback(()=>{se(!1)},[]),Ve=w.useCallback(N=>{},[]),De=w.useCallback(async(N,Z,re)=>{try{xe(),await W(N,Z,re)}catch(de){console.error("Failed to respond to interrupt:",de)}finally{Re()}},[Re,xe,W]),Ge=w.useCallback(()=>De(!0),[De]),He=w.useCallback(()=>De(!1),[De]),ot=w.useCallback((N,Z)=>De(!0,Z),[De]),ut=!!O||Q,[nt,Le]=w.useState(null),[Ke,$e]=w.useState(""),[Te,Ae]=w.useState(null),[dt,Et]=w.useState(null),[at,It]=w.useState(!1),[bt,ft]=w.useState(null),Nt=w.useRef(!1),[At,Ct]=w.useState(()=>Fh.value),on=w.useRef(At),Tt=w.useRef(null),Ie=w.useCallback(N=>{Fh.value=N,Ct(N)},[]),[Ue,jt]=w.useState(!1),te=w.useRef(null),ge=w.useCallback(N=>{Ie(N)},[Ie]);w.useEffect(()=>{D||Se(!1)},[D]),w.useEffect(()=>{Y!=null&&Y.assemblingMessageId&&Se(!1)},[Y==null?void 0:Y.assemblingMessageId]);const[rt,fe]=w.useState("desktop");w.useEffect(()=>{const N=()=>{const Z=window.innerWidth;fe(Z<640?"phone":Z<1024?"tablet":"desktop")};return N(),window.addEventListener("resize",N),()=>window.removeEventListener("resize",N)},[]),w.useEffect(()=>{Nt.current=!1},[B]),w.useEffect(()=>{on.current=At},[At]),w.useEffect(()=>{if(!nt){Tt.current=null;return}Tt.current===null&&(Tt.current=on.current),Ie(Ke??"")},[Ke,nt,Ie]),w.useEffect(()=>{if(C!==void 0){ft(C);return}(async()=>{if(!S){ft(null);return}try{const re=(await k.getAgent("default")).uiDefaultMessage||"";ft(re||null)}catch(Z){console.warn("Failed to fetch default message:",Z),ft(null)}})()},[k,S,C]),w.useEffect(()=>{I&&!at&&(b==null||b(I))},[I,at,b]);const ke=async(N,Z)=>{const re=N.trim();if(!(!re&&Z.length===0))try{const de=nt?(Te==null?void 0:Te.checkpointId)??_??void 0:_??void 0,Me=nt?(Te==null?void 0:Te.checkpointNs)??$??void 0:$??void 0;await X({text:re||"",attachments:Z,payload:p},{checkpointId:de,checkpointNs:Me,edit:!!nt,originalMessageId:nt??void 0}),x==null||x(re),Se(!0),Ie(""),Et(null),Le(null),$e(""),Ae(null)}catch(de){const Me=(de==null?void 0:de.message)||"Failed to send message";Et(Me),b==null||b(Me),Se(!1)}},Fe=w.useCallback(async N=>{await X({attachments:[N],payload:p},{checkpointId:_??void 0,checkpointNs:$??void 0}),y==null||y({file:N})},[_,$,p,y,X]),ht=w.useCallback((N,Z,re)=>{c&&(Tt.current=At,Le(N),$e(Z),Ie(Z),Et(null),Ae({checkpointId:(re==null?void 0:re.checkpointId)??null,checkpointNs:(re==null?void 0:re.checkpointNs)??null}))},[At,c,Ie]),pt=w.useCallback(()=>{Le(null),$e(""),Ae(null),Et(null),Ie(Tt.current??At),Tt.current=null},[At,Ie]),je=w.useCallback((N,Z,re)=>{ht(N,Z,re)},[ht]),Ye=w.useCallback(N=>{let Z=null;for(let Oe=N-1;Oe>=0;Oe--)if(A[Oe].role==="user"){Z=A[Oe];break}if(!Z)return;const re=Array.isArray(Z.content)?Z.content:[],Me=re.filter(Oe=>(Oe==null?void 0:Oe.type)==="text").map(Oe=>Oe.text).join("")||(()=>{try{return JSON.stringify(re,null,2)}catch{return String(re)}})();Me&&X({text:Me,payload:p},{checkpointId:_??void 0,checkpointNs:$??void 0,edit:!0,originalMessageId:Z.id})},[A,X,_,$,p]),we=w.useCallback(async N=>{if(T){jt(!0);try{if(!N){await F(),requestAnimationFrame(()=>{var de;(de=te.current)==null||de.scrollToLatest()});return}const Z=J.find(de=>de.checkpointId===N),re=(Z==null?void 0:Z.checkpointNs)??null;await L(N,re),requestAnimationFrame(()=>{var de;(de=te.current)==null||de.scrollToTop()})}finally{jt(!1)}}},[J,T,te,L,F]),Qe=w.useCallback(async(N,Z,re)=>{await we(re?null:N)},[we]),Xe=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${v.container||""}`,ct=`flex-1 min-h-0 min-w-0 max-h-full w-full overflow-hidden overscroll-contain break-words break-anywhere p-4 ${O?"pb-32":""} bg-transparent ${v.messagesArea||""}`,sn=`relative flex-shrink-0 w-full border-t p-4 bg-transparent ${v.inputArea||""}`;return u.jsxs("div",{className:Xe,children:[!!I&&!at&&u.jsxs("div",{className:"flex-shrink-0 bg-red-50 border border-red-200 text-red-800 px-4 py-2 text-sm flex items-center justify-between",children:[u.jsx("span",{children:I}),u.jsx(Je,{variant:"ghost",size:"sm",onClick:()=>It(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:u.jsx(le.X,{size:16})})]}),u.jsxs("div",{className:`relative ${ct}`,style:r?{maxHeight:r}:void 0,children:[u.jsx(xl,{ref:te,className:"h-full",style:{height:"100%"},messages:A,isStreaming:D,streamingAssistantId:z,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:rt,enableMessageEditing:c,editingMessageId:nt,onEdit:je,onRegenerate:Ye,onCancelEdit:pt,emptyMessage:bt??void 0,isNavigatingCheckpoint:Ue,showToolMessages:d,toolRenderers:f,toolArtifactRenderers:m,checkpointIndex:q,activeCheckpointId:_,onSelectCheckpoint:Qe,createSyntheticThinkingMessage:!0,forceSyntheticThinking:ie,getMessageCustomStyles:g,getInterruptOptions:Ve}),(G==="reconnecting"||G==="connecting")&&u.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-muted/80 px-3 py-1 text-xs font-medium text-foreground shadow-sm backdrop-blur-sm dark:bg-muted/60",children:u.jsxs("span",{className:"flex items-center gap-2",children:[u.jsx(le.Loader2,{className:"h-3 w-3 animate-spin"}),G==="reconnecting"?"Reconnecting…":"Connecting…"]})}),G==="error"&&u.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-destructive/10 px-3 py-1 text-xs font-semibold text-destructive shadow-sm",children:"Connection lost"}),R&&u.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[u.jsx(le.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]}),Ue&&u.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[u.jsx(le.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading checkpoint…"})]}),O&&U&&u.jsx("div",{className:"pointer-events-auto absolute inset-x-0 bottom-6 z-30 flex justify-center px-4",children:u.jsx("div",{className:"w-full max-w-3xl",children:u.jsx(hl,{interruptPart:U,onApprove:Ge,onReject:He,onSelectAlternative:ot,disabled:Q,isActive:!0,payload:O.value})})})]}),u.jsxs("div",{className:sn,children:[nt&&u.jsx("div",{className:"mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(le.Edit3,{size:16,className:"text-blue-600"}),u.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),u.jsx(Je,{variant:"ghost",size:"sm",onClick:pt,className:"text-blue-600 hover:bg-blue-100",children:u.jsx(le.X,{size:16})})]})}),dt&&u.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:dt}),u.jsx(LS,{composerValue:At,onComposerChange:ge,onSend:ke,onCancelEdit:pt,onStop:M,editingMessageId:nt,editingInitialValue:Ke,placeholder:nt?"Edit your message...":t,isStreaming:D,disabled:ut,enableFileUpload:a,enableExcelUpload:l,onExcelUpload:Fe,onError:b,customStyles:v,textareaClassName:v.textarea||"",allowEmptySend:!1,inputError:dt})]})]})}var Bh=1,tk=.9,nk=.8,rk=.17,vl=.1,wl=.999,ok=.9999,sk=.99,ik=/[\\\/_+.#"@\[\(\{&]/,ak=/[\\\/_+.#"@\[\(\{&]/g,lk=/[\s-]/,zh=/[\s-]/g;function bl(e,t,n,r,o,s,i){if(s===t.length)return o===e.length?Bh:sk;var a=`${o},${s}`;if(i[a]!==void 0)return i[a];for(var l=r.charAt(s),c=n.indexOf(l,o),d=0,f,m,p,v;c>=0;)f=bl(e,t,n,r,c+1,s+1,i),f>d&&(c===o?f*=Bh:ik.test(e.charAt(c-1))?(f*=nk,p=e.slice(o,c-1).match(ak),p&&o>0&&(f*=Math.pow(wl,p.length))):lk.test(e.charAt(c-1))?(f*=tk,v=e.slice(o,c-1).match(zh),v&&o>0&&(f*=Math.pow(wl,v.length))):(f*=rk,o>0&&(f*=Math.pow(wl,c-o))),e.charAt(c)!==t.charAt(s)&&(f*=ok)),(f<vl&&n.charAt(c-1)===r.charAt(s+1)||r.charAt(s+1)===r.charAt(s)&&n.charAt(c-1)!==r.charAt(s))&&(m=bl(e,t,n,r,c+1,s+2,i),m*vl>f&&(f=m*vl)),f>d&&(d=f),c=n.indexOf(l,c+1);return i[a]=d,d}function Hh(e){return e.toLowerCase().replace(zh," ")}function ck(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,bl(e,t,Hh(e),Hh(t),0,0,{})}var Po='[cmdk-group=""]',yl='[cmdk-group-items=""]',uk='[cmdk-group-heading=""]',Uh='[cmdk-item=""]',Wh=`${Uh}:not([aria-disabled="true"])`,Sl="cmdk-item-select",Lr="data-value",dk=(e,t,n)=>ck(e,t,n),Vh=h.createContext(void 0),_o=()=>h.useContext(Vh),Kh=h.createContext(void 0),Cl=()=>h.useContext(Kh),qh=h.createContext(void 0),Gh=h.forwardRef((e,t)=>{let n=$r(()=>{var M,B;return{search:"",value:(B=(M=e.value)!=null?M:e.defaultValue)!=null?B:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=$r(()=>new Set),o=$r(()=>new Map),s=$r(()=>new Map),i=$r(()=>new Set),a=Yh(e),{label:l,children:c,value:d,onValueChange:f,filter:m,shouldFilter:p,loop:v,disablePointerSelection:g=!1,vimBindings:x=!0,...y}=e,b=_t(),C=_t(),k=_t(),S=h.useRef(null),T=Sk();ur(()=>{if(d!==void 0){let M=d.trim();n.current.value=M,E.emit()}},[d]),ur(()=>{T(6,J)},[]);let E=h.useMemo(()=>({subscribe:M=>(i.current.add(M),()=>i.current.delete(M)),snapshot:()=>n.current,setState:(M,B,_)=>{var $,z,O,j;if(!Object.is(n.current[M],B)){if(n.current[M]=B,M==="search")K(),L(),T(1,F);else if(M==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let U=document.getElementById(k);U?U.focus():($=document.getElementById(b))==null||$.focus()}if(T(7,()=>{var U;n.current.selectedItemId=(U=P())==null?void 0:U.id,E.emit()}),_||T(5,J),((z=a.current)==null?void 0:z.value)!==void 0){let U=B??"";(j=(O=a.current).onValueChange)==null||j.call(O,U);return}}E.emit()}},emit:()=>{i.current.forEach(M=>M())}}),[]),A=h.useMemo(()=>({value:(M,B,_)=>{var $;B!==(($=s.current.get(M))==null?void 0:$.value)&&(s.current.set(M,{value:B,keywords:_}),n.current.filtered.items.set(M,R(B,_)),T(2,()=>{L(),E.emit()}))},item:(M,B)=>(r.current.add(M),B&&(o.current.has(B)?o.current.get(B).add(M):o.current.set(B,new Set([M]))),T(3,()=>{K(),L(),n.current.value||F(),E.emit()}),()=>{s.current.delete(M),r.current.delete(M),n.current.filtered.items.delete(M);let _=P();T(4,()=>{K(),(_==null?void 0:_.getAttribute("id"))===M&&F(),E.emit()})}),group:M=>(o.current.has(M)||o.current.set(M,new Set),()=>{s.current.delete(M),o.current.delete(M)}),filter:()=>a.current.shouldFilter,label:l||e["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:b,inputId:k,labelId:C,listInnerRef:S}),[]);function R(M,B){var _,$;let z=($=(_=a.current)==null?void 0:_.filter)!=null?$:dk;return M?z(M,n.current.search,B):0}function L(){if(!n.current.search||a.current.shouldFilter===!1)return;let M=n.current.filtered.items,B=[];n.current.filtered.groups.forEach($=>{let z=o.current.get($),O=0;z.forEach(j=>{let U=M.get(j);O=Math.max(U,O)}),B.push([$,O])});let _=S.current;Y().sort(($,z)=>{var O,j;let U=$.getAttribute("id"),Q=z.getAttribute("id");return((O=M.get(Q))!=null?O:0)-((j=M.get(U))!=null?j:0)}).forEach($=>{let z=$.closest(yl);z?z.appendChild($.parentElement===z?$:$.closest(`${yl} > *`)):_.appendChild($.parentElement===_?$:$.closest(`${yl} > *`))}),B.sort(($,z)=>z[1]-$[1]).forEach($=>{var z;let O=(z=S.current)==null?void 0:z.querySelector(`${Po}[${Lr}="${encodeURIComponent($[0])}"]`);O==null||O.parentElement.appendChild(O)})}function F(){let M=Y().find(_=>_.getAttribute("aria-disabled")!=="true"),B=M==null?void 0:M.getAttribute(Lr);E.setState("value",B||void 0)}function K(){var M,B,_,$;if(!n.current.search||a.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let z=0;for(let O of r.current){let j=(B=(M=s.current.get(O))==null?void 0:M.value)!=null?B:"",U=($=(_=s.current.get(O))==null?void 0:_.keywords)!=null?$:[],Q=R(j,U);n.current.filtered.items.set(O,Q),Q>0&&z++}for(let[O,j]of o.current)for(let U of j)if(n.current.filtered.items.get(U)>0){n.current.filtered.groups.add(O);break}n.current.filtered.count=z}function J(){var M,B,_;let $=P();$&&(((M=$.parentElement)==null?void 0:M.firstChild)===$&&((_=(B=$.closest(Po))==null?void 0:B.querySelector(uk))==null||_.scrollIntoView({block:"nearest"})),$.scrollIntoView({block:"nearest"}))}function P(){var M;return(M=S.current)==null?void 0:M.querySelector(`${Uh}[aria-selected="true"]`)}function Y(){var M;return Array.from(((M=S.current)==null?void 0:M.querySelectorAll(Wh))||[])}function q(M){let B=Y()[M];B&&E.setState("value",B.getAttribute(Lr))}function W(M){var B;let _=P(),$=Y(),z=$.findIndex(j=>j===_),O=$[z+M];(B=a.current)!=null&&B.loop&&(O=z+M<0?$[$.length-1]:z+M===$.length?$[0]:$[z+M]),O&&E.setState("value",O.getAttribute(Lr))}function D(M){let B=P(),_=B==null?void 0:B.closest(Po),$;for(;_&&!$;)_=M>0?bk(_,Po):yk(_,Po),$=_==null?void 0:_.querySelector(Wh);$?E.setState("value",$.getAttribute(Lr)):W(M)}let I=()=>q(Y().length-1),G=M=>{M.preventDefault(),M.metaKey?I():M.altKey?D(1):W(1)},X=M=>{M.preventDefault(),M.metaKey?q(0):M.altKey?D(-1):W(-1)};return h.createElement(pe.div,{ref:t,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:M=>{var B;(B=y.onKeyDown)==null||B.call(y,M);let _=M.nativeEvent.isComposing||M.keyCode===229;if(!(M.defaultPrevented||_))switch(M.key){case"n":case"j":{x&&M.ctrlKey&&G(M);break}case"ArrowDown":{G(M);break}case"p":case"k":{x&&M.ctrlKey&&X(M);break}case"ArrowUp":{X(M);break}case"Home":{M.preventDefault(),q(0);break}case"End":{M.preventDefault(),I();break}case"Enter":{M.preventDefault();let $=P();if($){let z=new Event(Sl);$.dispatchEvent(z)}}}}},h.createElement("label",{"cmdk-label":"",htmlFor:A.inputId,id:A.labelId,style:Tk},l),ti(e,M=>h.createElement(Kh.Provider,{value:E},h.createElement(Vh.Provider,{value:A},M))))}),fk=h.forwardRef((e,t)=>{var n,r;let o=_t(),s=h.useRef(null),i=h.useContext(qh),a=_o(),l=Yh(e),c=(r=(n=l.current)==null?void 0:n.forceMount)!=null?r:i==null?void 0:i.forceMount;ur(()=>{if(!c)return a.item(o,i==null?void 0:i.id)},[c]);let d=Xh(o,s,[e.value,e.children,s],e.keywords),f=Cl(),m=Kn(T=>T.value&&T.value===d.current),p=Kn(T=>c||a.filter()===!1?!0:T.search?T.filtered.items.get(o)>0:!0);h.useEffect(()=>{let T=s.current;if(!(!T||e.disabled))return T.addEventListener(Sl,v),()=>T.removeEventListener(Sl,v)},[p,e.onSelect,e.disabled]);function v(){var T,E;g(),(E=(T=l.current).onSelect)==null||E.call(T,d.current)}function g(){f.setState("value",d.current,!0)}if(!p)return null;let{disabled:x,value:y,onSelect:b,forceMount:C,keywords:k,...S}=e;return h.createElement(pe.div,{ref:Mn(s,t),...S,id:o,"cmdk-item":"",role:"option","aria-disabled":!!x,"aria-selected":!!m,"data-disabled":!!x,"data-selected":!!m,onPointerMove:x||a.getDisablePointerSelection()?void 0:g,onClick:x?void 0:v},e.children)}),pk=h.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:o,...s}=e,i=_t(),a=h.useRef(null),l=h.useRef(null),c=_t(),d=_o(),f=Kn(p=>o||d.filter()===!1?!0:p.search?p.filtered.groups.has(i):!0);ur(()=>d.group(i),[]),Xh(i,a,[e.value,e.heading,l]);let m=h.useMemo(()=>({id:i,forceMount:o}),[o]);return h.createElement(pe.div,{ref:Mn(a,t),...s,"cmdk-group":"",role:"presentation",hidden:f?void 0:!0},n&&h.createElement("div",{ref:l,"cmdk-group-heading":"","aria-hidden":!0,id:c},n),ti(e,p=>h.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?c:void 0},h.createElement(qh.Provider,{value:m},p))))}),hk=h.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=h.useRef(null),s=Kn(i=>!i.search);return!n&&!s?null:h.createElement(pe.div,{ref:Mn(o,t),...r,"cmdk-separator":"",role:"separator"})}),mk=h.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,o=e.value!=null,s=Cl(),i=Kn(c=>c.search),a=Kn(c=>c.selectedItemId),l=_o();return h.useEffect(()=>{e.value!=null&&s.setState("search",e.value)},[e.value]),h.createElement(pe.input,{ref:t,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":l.listId,"aria-labelledby":l.labelId,"aria-activedescendant":a,id:l.inputId,type:"text",value:o?e.value:i,onChange:c=>{o||s.setState("search",c.target.value),n==null||n(c.target.value)}})}),gk=h.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...o}=e,s=h.useRef(null),i=h.useRef(null),a=Kn(c=>c.selectedItemId),l=_o();return h.useEffect(()=>{if(i.current&&s.current){let c=i.current,d=s.current,f,m=new ResizeObserver(()=>{f=requestAnimationFrame(()=>{let p=c.offsetHeight;d.style.setProperty("--cmdk-list-height",p.toFixed(1)+"px")})});return m.observe(c),()=>{cancelAnimationFrame(f),m.unobserve(c)}}},[]),h.createElement(pe.div,{ref:Mn(s,t),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":r,id:l.listId},ti(e,c=>h.createElement("div",{ref:Mn(i,l.listInnerRef),"cmdk-list-sizer":""},c)))}),xk=h.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:o,contentClassName:s,container:i,...a}=e;return h.createElement(nl,{open:n,onOpenChange:r},h.createElement(rl,{container:i},h.createElement(Io,{"cmdk-overlay":"",className:o}),h.createElement(No,{"aria-label":e.label,"cmdk-dialog":"",className:s},h.createElement(Gh,{ref:t,...a}))))}),vk=h.forwardRef((e,t)=>Kn(n=>n.filtered.count===0)?h.createElement(pe.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),wk=h.forwardRef((e,t)=>{let{progress:n,children:r,label:o="Loading...",...s}=e;return h.createElement(pe.div,{ref:t,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},ti(e,i=>h.createElement("div",{"aria-hidden":!0},i)))}),Wt=Object.assign(Gh,{List:gk,Item:fk,Input:mk,Group:pk,Separator:hk,Dialog:xk,Empty:vk,Loading:wk});function bk(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function yk(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function Yh(e){let t=h.useRef(e);return ur(()=>{t.current=e}),t}var ur=typeof window>"u"?h.useEffect:h.useLayoutEffect;function $r(e){let t=h.useRef();return t.current===void 0&&(t.current=e()),t}function Kn(e){let t=Cl(),n=()=>e(t.snapshot());return h.useSyncExternalStore(t.subscribe,n,n)}function Xh(e,t,n,r=[]){let o=h.useRef(),s=_o();return ur(()=>{var i;let a=(()=>{var c;for(let d of n){if(typeof d=="string")return d.trim();if(typeof d=="object"&&"current"in d)return d.current?(c=d.current.textContent)==null?void 0:c.trim():o.current}})(),l=r.map(c=>c.trim());s.value(e,a,l),(i=t.current)==null||i.setAttribute(Lr,a),o.current=a}),o}var Sk=()=>{let[e,t]=h.useState(),n=$r(()=>new Map);return ur(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,o)=>{n.current.set(r,o),t({})}};function Ck(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function ti({asChild:e,children:t},n){return e&&h.isValidElement(t)?h.cloneElement(Ck(t),{ref:t.ref},n(t.props.children)):n(t)}var Tk={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const Tl=h.forwardRef(({className:e,...t},n)=>u.jsx(Wt,{ref:n,className:ne("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));Tl.displayName=Wt.displayName;const kl=h.forwardRef(({className:e,...t},n)=>u.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[u.jsx(le.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),u.jsx(Wt.Input,{ref:n,className:ne("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...t})]}));kl.displayName=Wt.Input.displayName;const El=h.forwardRef(({className:e,...t},n)=>u.jsx(Wt.List,{ref:n,className:ne("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));El.displayName=Wt.List.displayName;const Il=h.forwardRef((e,t)=>u.jsx(Wt.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));Il.displayName=Wt.Empty.displayName;const Nl=h.forwardRef(({className:e,...t},n)=>u.jsx(Wt.Group,{ref:n,className:ne("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",e),...t}));Nl.displayName=Wt.Group.displayName;const kk=h.forwardRef(({className:e,...t},n)=>u.jsx(Wt.Separator,{ref:n,className:ne("-mx-1 h-px bg-border",e),...t}));kk.displayName=Wt.Separator.displayName;const Al=h.forwardRef(({className:e,...t},n)=>u.jsx(Wt.Item,{ref:n,className:ne("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",e),...t}));Al.displayName=Wt.Item.displayName;function jl(e,[t,n]){return Math.min(n,Math.max(t,e))}function Ek(e,t){return h.useReducer((n,r)=>t[n][r]??n,e)}var Pl="ScrollArea",[Jh,UN]=cn(Pl),[Ik,rn]=Jh(Pl),Zh=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=h.useState(null),[c,d]=h.useState(null),[f,m]=h.useState(null),[p,v]=h.useState(null),[g,x]=h.useState(null),[y,b]=h.useState(0),[C,k]=h.useState(0),[S,T]=h.useState(!1),[E,A]=h.useState(!1),R=Pe(t,F=>l(F)),L=Qo(o);return u.jsx(Ik,{scope:n,type:r,dir:L,scrollHideDelay:s,scrollArea:a,viewport:c,onViewportChange:d,content:f,onContentChange:m,scrollbarX:p,onScrollbarXChange:v,scrollbarXEnabled:S,onScrollbarXEnabledChange:T,scrollbarY:g,onScrollbarYChange:x,scrollbarYEnabled:E,onScrollbarYEnabledChange:A,onCornerWidthChange:b,onCornerHeightChange:k,children:u.jsx(pe.div,{dir:L,...i,ref:R,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":C+"px",...e.style}})})});Zh.displayName=Pl;var Qh="ScrollAreaViewport",em=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=rn(Qh,n),a=h.useRef(null),l=Pe(t,a,i.onViewportChange);return u.jsxs(u.Fragment,{children:[u.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),u.jsx(pe.div,{"data-radix-scroll-area-viewport":"",...s,ref:l,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:u.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});em.displayName=Qh;var In="ScrollAreaScrollbar",_l=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=rn(In,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return h.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?u.jsx(Nk,{...r,ref:t,forceMount:n}):o.type==="scroll"?u.jsx(Ak,{...r,ref:t,forceMount:n}):o.type==="auto"?u.jsx(tm,{...r,ref:t,forceMount:n}):o.type==="always"?u.jsx(Rl,{...r,ref:t}):null});_l.displayName=In;var Nk=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=rn(In,e.__scopeScrollArea),[s,i]=h.useState(!1);return h.useEffect(()=>{const a=o.scrollArea;let l=0;if(a){const c=()=>{window.clearTimeout(l),i(!0)},d=()=>{l=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",c),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(l),a.removeEventListener("pointerenter",c),a.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),u.jsx(Ht,{present:n||s,children:u.jsx(tm,{"data-state":s?"visible":"hidden",...r,ref:t})})}),Ak=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=rn(In,e.__scopeScrollArea),s=e.orientation==="horizontal",i=si(()=>l("SCROLL_END"),100),[a,l]=Ek("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return h.useEffect(()=>{if(a==="idle"){const c=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(c)}},[a,o.scrollHideDelay,l]),h.useEffect(()=>{const c=o.viewport,d=s?"scrollLeft":"scrollTop";if(c){let f=c[d];const m=()=>{const p=c[d];f!==p&&(l("SCROLL"),i()),f=p};return c.addEventListener("scroll",m),()=>c.removeEventListener("scroll",m)}},[o.viewport,s,l,i]),u.jsx(Ht,{present:n||a!=="hidden",children:u.jsx(Rl,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:ae(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:ae(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),tm=h.forwardRef((e,t)=>{const n=rn(In,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=h.useState(!1),a=e.orientation==="horizontal",l=si(()=>{if(n.viewport){const c=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?c:d)}},10);return Fr(n.viewport,l),Fr(n.content,l),u.jsx(Ht,{present:r||s,children:u.jsx(Rl,{"data-state":s?"visible":"hidden",...o,ref:t})})}),Rl=h.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=rn(In,e.__scopeScrollArea),s=h.useRef(null),i=h.useRef(0),[a,l]=h.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),c=im(a.viewport,a.content),d={...r,sizes:a,onSizesChange:l,hasThumb:c>0&&c<1,onThumbChange:m=>s.current=m,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:m=>i.current=m};function f(m,p){return Ok(m,i.current,a,p)}return n==="horizontal"?u.jsx(jk,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollLeft,p=am(m,a,o.dir);s.current.style.transform=`translate3d(${p}px, 0, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollLeft=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollLeft=f(m,o.dir))}}):n==="vertical"?u.jsx(Pk,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollTop,p=am(m,a);s.current.style.transform=`translate3d(0, ${p}px, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollTop=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollTop=f(m))}}):null}),jk=h.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=rn(In,e.__scopeScrollArea),[i,a]=h.useState(),l=h.useRef(null),c=Pe(t,l,s.onScrollbarXChange);return h.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(rm,{"data-orientation":"horizontal",...o,ref:c,sizes:n,style:{bottom:0,left:s.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:s.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":oi(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.x),onDragScroll:d=>e.onDragScroll(d.x),onWheelScroll:(d,f)=>{if(s.viewport){const m=s.viewport.scrollLeft+d.deltaX;e.onWheelScroll(m),cm(m,f)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:l.current.clientWidth,paddingStart:ri(i.paddingLeft),paddingEnd:ri(i.paddingRight)}})}})}),Pk=h.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=rn(In,e.__scopeScrollArea),[i,a]=h.useState(),l=h.useRef(null),c=Pe(t,l,s.onScrollbarYChange);return h.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(rm,{"data-orientation":"vertical",...o,ref:c,sizes:n,style:{top:0,right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":oi(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.y),onDragScroll:d=>e.onDragScroll(d.y),onWheelScroll:(d,f)=>{if(s.viewport){const m=s.viewport.scrollTop+d.deltaY;e.onWheelScroll(m),cm(m,f)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:l.current.clientHeight,paddingStart:ri(i.paddingTop),paddingEnd:ri(i.paddingBottom)}})}})}),[_k,nm]=Jh(In),rm=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:l,onDragScroll:c,onWheelScroll:d,onResize:f,...m}=e,p=rn(In,n),[v,g]=h.useState(null),x=Pe(t,R=>g(R)),y=h.useRef(null),b=h.useRef(""),C=p.viewport,k=r.content-r.viewport,S=gt(d),T=gt(l),E=si(f,10);function A(R){if(y.current){const L=R.clientX-y.current.left,F=R.clientY-y.current.top;c({x:L,y:F})}}return h.useEffect(()=>{const R=L=>{const F=L.target;(v==null?void 0:v.contains(F))&&S(L,k)};return document.addEventListener("wheel",R,{passive:!1}),()=>document.removeEventListener("wheel",R,{passive:!1})},[C,v,k,S]),h.useEffect(T,[r,T]),Fr(v,E),Fr(p.content,E),u.jsx(_k,{scope:n,scrollbar:v,hasThumb:o,onThumbChange:gt(s),onThumbPointerUp:gt(i),onThumbPositionChange:T,onThumbPointerDown:gt(a),children:u.jsx(pe.div,{...m,ref:x,style:{position:"absolute",...m.style},onPointerDown:ae(e.onPointerDown,R=>{R.button===0&&(R.target.setPointerCapture(R.pointerId),y.current=v.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",p.viewport&&(p.viewport.style.scrollBehavior="auto"),A(R))}),onPointerMove:ae(e.onPointerMove,A),onPointerUp:ae(e.onPointerUp,R=>{const L=R.target;L.hasPointerCapture(R.pointerId)&&L.releasePointerCapture(R.pointerId),document.body.style.webkitUserSelect=b.current,p.viewport&&(p.viewport.style.scrollBehavior=""),y.current=null})})})}),ni="ScrollAreaThumb",om=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=nm(ni,e.__scopeScrollArea);return u.jsx(Ht,{present:n||o.hasThumb,children:u.jsx(Rk,{ref:t,...r})})}),Rk=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=rn(ni,n),i=nm(ni,n),{onThumbPositionChange:a}=i,l=Pe(t,f=>i.onThumbChange(f)),c=h.useRef(void 0),d=si(()=>{c.current&&(c.current(),c.current=void 0)},100);return h.useEffect(()=>{const f=s.viewport;if(f){const m=()=>{if(d(),!c.current){const p=Dk(f,a);c.current=p,a()}};return a(),f.addEventListener("scroll",m),()=>f.removeEventListener("scroll",m)}},[s.viewport,d,a]),u.jsx(pe.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:l,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:ae(e.onPointerDownCapture,f=>{const p=f.target.getBoundingClientRect(),v=f.clientX-p.left,g=f.clientY-p.top;i.onThumbPointerDown({x:v,y:g})}),onPointerUp:ae(e.onPointerUp,i.onThumbPointerUp)})});om.displayName=ni;var Ml="ScrollAreaCorner",sm=h.forwardRef((e,t)=>{const n=rn(Ml,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?u.jsx(Mk,{...e,ref:t}):null});sm.displayName=Ml;var Mk=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=rn(Ml,n),[s,i]=h.useState(0),[a,l]=h.useState(0),c=!!(s&&a);return Fr(o.scrollbarX,()=>{var f;const d=((f=o.scrollbarX)==null?void 0:f.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),Fr(o.scrollbarY,()=>{var f;const d=((f=o.scrollbarY)==null?void 0:f.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),c?u.jsx(pe.div,{...r,ref:t,style:{width:s,height:a,position:"absolute",right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function ri(e){return e?parseInt(e,10):0}function im(e,t){const n=e/t;return isNaN(n)?0:n}function oi(e){const t=im(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function Ok(e,t,n,r="ltr"){const o=oi(n),s=o/2,i=t||s,a=o-i,l=n.scrollbar.paddingStart+i,c=n.scrollbar.size-n.scrollbar.paddingEnd-a,d=n.content-n.viewport,f=r==="ltr"?[0,d]:[d*-1,0];return lm([l,c],f)(e)}function am(e,t,n="ltr"){const r=oi(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,i=t.content-t.viewport,a=s-r,l=n==="ltr"?[0,i]:[i*-1,0],c=jl(e,l);return lm([0,i],[0,a])(c)}function lm(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function cm(e,t){return e>0&&e<t}var Dk=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return function o(){const s={left:e.scrollLeft,top:e.scrollTop},i=n.left!==s.left,a=n.top!==s.top;(i||a)&&t(),n=s,r=window.requestAnimationFrame(o)}(),()=>window.cancelAnimationFrame(r)};function si(e,t){const n=gt(e),r=h.useRef(0);return h.useEffect(()=>()=>window.clearTimeout(r.current),[]),h.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function Fr(e,t){const n=gt(t);kt(()=>{let r=0;if(e){const o=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(n)});return o.observe(e),()=>{window.cancelAnimationFrame(r),o.unobserve(e)}}},[e,n])}var um=Zh,Lk=em,$k=sm;const Ol=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(um,{ref:r,className:ne("relative overflow-hidden",e),...n,children:[u.jsx(Lk,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),u.jsx(dm,{}),u.jsx($k,{})]}));Ol.displayName=um.displayName;const dm=h.forwardRef(({className:e,orientation:t="vertical",...n},r)=>u.jsx(_l,{ref:r,orientation:t,className:ne("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:u.jsx(om,{className:"relative flex-1 rounded-full bg-border"})}));dm.displayName=_l.displayName;const Dl=h.forwardRef(({className:e,type:t,...n},r)=>u.jsx("input",{type:t,className:ne("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:r,...n}));Dl.displayName="Input";const Fk="group relative p-3 rounded-lg cursor-pointer transition-colors border text-gray-900 dark:text-slate-100",Bk="bg-slate-700 border-slate-600 hover:bg-slate-600",zk="bg-slate-600 border-slate-500";function fm({thread:e,isActive:t,editingThreadId:n,editingTitle:r,onSelect:o,onStartEditing:s,onEditingTitleChange:i,onSaveEditing:a,onCancelEditing:l,onShare:c,onDelete:d,showEditTitle:f,showDeleteButton:m,formatDate:p,getDisplayThreadTitle:v,secondaryLine:g,itemClassName:x,activeItemClassName:y}){const b=n===e.threadId,C=t?`${y??zk}`:`${x??Bk}`,k=S=>{S.stopPropagation(),o(e.threadId)};return u.jsxs("div",{onClick:k,className:`${Fk} ${C}`,children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("div",{className:"flex-1 min-w-0",children:b?u.jsxs("div",{className:"flex items-center gap-2",onClick:S=>S.stopPropagation(),children:[u.jsx(Dl,{value:r,onChange:S=>i(S.target.value),onKeyDown:S=>{S.key==="Enter"?a(e.threadId):S.key==="Escape"&&l()},className:"h-6 text-sm",autoFocus:!0}),u.jsx(Je,{variant:"ghost",size:"sm",onClick:()=>a(e.threadId),className:"h-6 w-6 p-0",children:u.jsx(le.Check,{size:12})}),u.jsx(Je,{variant:"ghost",size:"sm",onClick:l,className:"h-6 w-6 p-0",children:u.jsx(le.X,{size:12})})]}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"font-medium text-sm truncate text-gray-900 dark:text-slate-100",children:v(e)}),u.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[u.jsx(le.Calendar,{size:10}),u.jsx("span",{children:p(e.updatedAt||e.createdAt)})]}),g&&u.jsx("div",{className:"text-[11px] text-muted-foreground mt-1",children:g})]})}),u.jsx("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:u.jsxs(ks,{children:[u.jsx(Es,{asChild:!0,children:u.jsx(Je,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",children:u.jsx(le.MoreHorizontal,{size:12})})}),u.jsxs(go,{align:"end",sideOffset:6,className:"w-44",children:[u.jsxs(Fn,{onClick:S=>{S.preventDefault(),c(e.threadId)},children:[u.jsx(le.Share2,{className:"mr-2 h-4 w-4"}),"Share thread"]}),f&&n!==e.threadId&&u.jsxs(Fn,{onClick:S=>{S.preventDefault(),s(e,S)},children:[u.jsx(le.Edit3,{className:"mr-2 h-4 w-4"}),"Rename"]}),m&&d&&u.jsxs(Fn,{className:"text-red-400 hover:text-red-300",onClick:S=>{S.preventDefault(),d(e.threadId,S)},children:[u.jsx(le.Trash2,{className:"mr-2 h-4 w-4"}),"Delete"]})]})]})})]}),t&&u.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]})}const pm=25,hm="thread-manager-view",Hk=e=>e==="default"||e==="shared",Uk=()=>{if(typeof window>"u")return null;try{const e=window.localStorage.getItem(hm);if(Hk(e))return e}catch{}return null};function mm({defaultView:e}={}){const[t,n]=w.useState(()=>Uk()??e??"default");w.useEffect(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem(hm,t)}catch{}},[t]);const r=w.useCallback(o=>{n(o)},[]);return{view:t,setView:r}}const Wk=[{key:"default",label:"My chats"},{key:"shared",label:"Shared with you"}];function ii({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:i=null,navigateToThread:a,onThreadSelect:l,onThreadCreate:c,onThreadDelete:d,view:f,defaultView:m,onViewChange:p,viewOptions:v,viewState:g,showHeader:x=!0,shareTargets:y,isLoadingShareTargets:b,shareTargetFilter:C}){const{threads:k,sharedThreads:S,currentThreadId:T,setCurrentThreadId:E,isLoading:A,isLoadingSharedThreads:R,actions:L,shareInFlight:F,shareStatus:K,clearShareStatus:J}=vr(),{createThread:P,deleteThread:Y,renameThread:q,shareThread:W}=L,{loadThread:D}=ro(),I=i??T,[G,X]=w.useState(Array.isArray(k)?k:[]),M=w.useRef(G.length>0),B=w.useRef(null),_=w.useRef(0),[$,z]=w.useState(null),[O,j]=w.useState(""),[U,Q]=w.useState(!1),[se,ie]=w.useState(!1),[Se,xe]=w.useState(null),[Re,Ve]=w.useState(""),De=v&&v.length>0?v:Wk,Ge=mm({defaultView:m}),He=g??Ge,ot=f??He.view,ut=w.useCallback(te=>{f||He.setView(te),p==null||p(te)},[f,p,He]),nt=De.find(te=>te.key===ot)??De[0],Le=te=>{xe(te),Ve(""),ie(!0)},Ke=()=>{ie(!1),xe(null),Ve(""),J()},$e=w.useCallback(async te=>{if(!(!Se||F)&&te.id)try{await W(Se,te.id),setTimeout(()=>Ke(),600)}catch(ge){console.error("Failed to share thread:",ge)}},[Ke,F,Se,W]),Te=w.useMemo(()=>{const te=y??[],ge=Re.trim().toLowerCase();return ge?C?te.filter(rt=>C(rt,ge)):te.filter(rt=>`${rt.label} ${rt.secondaryLabel??""}`.toLowerCase().includes(ge)):te},[y,Re,C]),Ae=ot==="shared",dt=Ae?S:G,Et=Ae?R:A,at=Ae?"No shared conversations yet":"No conversations yet",It=te=>{const ge=te.sharedAt?` • ${Ie(te.sharedAt)}`:"";return`Shared by ${te.sharedByUserId}${ge}`},bt=te=>"sharedByUserId"in te;w.useEffect(()=>{const te=Array.isArray(k)?k:[];if(te.length>0){M.current=!0,X(te);return}A||(M.current=!1,X(te))},[k,A]),w.useEffect(()=>{if(!B.current)return;const te=B.current.querySelector("[data-radix-scroll-area-viewport]");if(!te)return;let ge=null,rt=null;return ge=requestAnimationFrame(()=>{rt=requestAnimationFrame(()=>{te.scrollTop=_.current})}),()=>{ge!==null&&cancelAnimationFrame(ge),rt!==null&&cancelAnimationFrame(rt)}},[G]);const ft=async te=>{try{E(te),await D(te),a==null||a(te),l==null||l(te)}catch(ge){console.error("Failed to select thread:",ge)}},Nt=async()=>{try{Q(!0);const te=await P();te&&(c==null||c(te),a==null||a(te))}catch(te){console.error("Failed to create thread:",te)}finally{Q(!1)}},At=async(te,ge)=>{if(ge.stopPropagation(),!!confirm("Delete this thread?")){if(B.current){const rt=B.current.querySelector("[data-radix-scroll-area-viewport]");rt&&(_.current=rt.scrollTop)}try{await Y(te),d==null||d(te)}catch(rt){console.error("Failed to delete thread:",rt)}}},Ct=(te,ge)=>{ge.stopPropagation(),z(te.threadId),j(te.title||`Thread ${te.threadId.slice(0,8)}`)},on=async te=>{if(O.trim())try{await q(te,O.trim()),z(null),j("")}catch(ge){console.error("Failed to update title:",ge)}},Tt=()=>{z(null),j("")},Ie=te=>{if(!te)return"";try{const ge=new Date(te),fe=new Date().getTime()-ge.getTime(),ke=Math.floor(fe/(1e3*60*60*24));return ke===0?ge.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):ke===1?"Yesterday":ke<7?`${ke} days ago`:ge.toLocaleDateString()}catch{return""}},Ue=te=>te.title||`Thread ${te.threadId.slice(0,8)}`,jt=te=>{const ge=Ue(te);return ge.length<=pm?ge:`${ge.slice(0,pm)}...`};return u.jsxs("div",{className:`flex flex-col h-full ${e} ${s.container||""}`,children:[x&&u.jsxs("div",{className:s.header||"flex flex-col gap-2 px-1 py-0 border border-slate-200 bg-white dark:border-slate-700 dark:bg-slate-900 shadow-sm",children:[t&&u.jsx("div",{className:"flex justify-end",children:u.jsxs(Je,{onClick:Nt,disabled:U||A,className:s.createButton||"px-3 py-2 gap-1",size:"sm",variant:"ghost",title:U?"Creating...":"New Chat",children:[u.jsx(le.Edit3,{size:16}),u.jsx("span",{children:"New chat"})]})}),u.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-slate-700 dark:text-slate-200 uppercase tracking-wide leading-tight",children:[u.jsx("span",{children:"Current View"}),u.jsxs(ks,{children:[u.jsx(Es,{asChild:!0,children:u.jsx(Je,{variant:"outline",size:"sm",className:"text-[11px] text-slate-700 dark:text-slate-200 border border-slate-300 dark:border-slate-600 bg-white dark:bg-slate-900 hover:bg-slate-50 dark:hover:bg-slate-800 px-2 py-0",children:nt.label})}),u.jsx(go,{align:"start",sideOffset:6,className:"w-40",children:De.map(te=>u.jsxs(Fn,{className:"justify-between text-[12px]",onClick:ge=>{ge.preventDefault(),ut(te.key)},children:[u.jsx("span",{children:te.label}),ot===te.key&&u.jsx(le.Check,{className:"h-3 w-3"})]},te.key))})]})]})]}),u.jsx(Ol,{ref:B,className:`flex-1 min-h-0 ${s.threadList||""}`,style:o?{maxHeight:o}:void 0,children:u.jsx("div",{className:"p-2 space-y-1 pb-4",children:Et?u.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[u.jsx(le.Loader2,{className:"h-5 w-5 animate-spin"}),u.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):dt.length===0?u.jsxs("div",{className:"text-center py-8 text-slate-400",children:[u.jsx(le.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),u.jsx("p",{className:"text-sm text-slate-500",children:at})]}):dt.slice().sort((te,ge)=>new Date(ge.updatedAt||ge.createdAt||"").getTime()-new Date(te.updatedAt||te.createdAt||"").getTime()).map(te=>u.jsx(fm,{thread:te,isActive:I===te.threadId,editingThreadId:$,editingTitle:O,onSelect:ft,onStartEditing:Ct,onEditingTitleChange:ge=>j(ge),onSaveEditing:on,onCancelEditing:Tt,onShare:()=>Le(te.threadId),onDelete:At,showEditTitle:r,showDeleteButton:n,formatDate:Ie,getDisplayThreadTitle:jt,secondaryLine:Ae&&bt(te)?It(te):void 0,itemClassName:s.threadItem,activeItemClassName:s.activeThread},te.threadId))})}),u.jsx(ol,{open:se,onOpenChange:te=>!te&&Ke(),children:u.jsxs(Us,{className:"max-w-md p-0",children:[u.jsx(Ws,{children:u.jsx(Vs,{children:"Share thread"})}),u.jsxs(Tl,{children:[u.jsx(kl,{autoFocus:!0,value:Re,onValueChange:te=>Ve(te),placeholder:"Search for recipients..."}),u.jsxs(El,{children:[K&&u.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[F&&u.jsx(le.Loader2,{className:"h-3 w-3 animate-spin"}),u.jsx("span",{className:K.startsWith("Failed")?"text-red-500":K.startsWith("Shared")?"text-emerald-500":"text-slate-600 dark:text-slate-400",children:K})]}),u.jsx(Il,{children:b?u.jsxs("span",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(le.Loader2,{className:"h-4 w-4 animate-spin"}),"Loading recipients…"]}):"No matching recipients found"}),Te.length>0&&u.jsx(Nl,{heading:"Recipients",children:Te.map(te=>u.jsx(Al,{onSelect:()=>$e(te),children:u.jsxs("div",{className:"flex flex-col items-start text-sm",children:[u.jsx("span",{className:"font-medium",children:te.label}),te.secondaryLabel&&u.jsx("span",{className:"text-xs text-muted-foreground",children:te.secondaryLabel})]})},te.id))})]})]})]})})]})}function Vk({layout:e="sidebar",layoutSize:t="desktop",showThreads:n=!0,className:r="",customStyles:o={},...s}){const i=c=>{const d="h-full";switch(c){case"phone":return`${d} max-w-none`;case"tablet":return`${d} max-w-4xl mx-auto`;case"half-screen":return`${d} max-w-2xl`;case"desktop":default:return`${d} max-w-7xl mx-auto`}},a=c=>({"--chat-sidebar-width":c==="phone"?"100%":c==="tablet"?"280px":c==="half-screen"?"240px":"320px","--chat-message-max-width":c==="phone"?"95%":c==="tablet"?"90%":c==="half-screen"?"85%":"80%","--chat-input-height":c==="phone"?"120px":"100px"}),l=w.useCallback(c=>{var d;(d=s.onThreadChange)==null||d.call(s,c)},[s]);return e==="fullscreen"?u.jsx(yr,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsx(Dr,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?u.jsx(yr,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[n&&u.jsx("div",{className:`w-80 border-r flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:u.jsx(ii,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),u.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:u.jsx(Dr,{onError:s.onError,enableFileUpload:!0})})]})})}):u.jsx(yr,{...s,onThreadChange:l,children:u.jsxs("div",{className:`${i(t)} flex overflow-hidden ${r} ${o.container||""}`,style:a(t),children:[n&&u.jsx("div",{className:`w-80 border-r bg-gray-50 flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:u.jsx(ii,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),u.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:u.jsx(Dr,{onError:s.onError,enableFileUpload:!0})})]})})}function Kk({apiConfig:e,className:t="",onError:n}){return u.jsx(yr,{apiConfig:e,onError:n,children:u.jsx("div",{className:`h-full ${t}`,children:u.jsx(Dr,{})})})}function qk({placeholder:e,onMessageSent:t}){const[n,r]=w.useState("chat");return u.jsxs("div",{className:"flex flex-col h-full",children:[u.jsxs("div",{className:"flex border-b border-gray-200 bg-gray-50",children:[u.jsx("button",{onClick:()=>r("chat"),className:`flex-1 px-3 py-2 text-sm font-medium transition-colors ${n==="chat"?"border-b-2 border-slate-800 text-slate-800 bg-white":"text-gray-600 hover:text-gray-800"}`,children:u.jsxs("div",{className:"flex items-center justify-center gap-2",children:[u.jsx(le.MessageSquare,{size:14}),"Chat"]})}),u.jsx("button",{onClick:()=>r("threads"),className:`flex-1 px-3 py-2 text-sm font-medium transition-colors ${n==="threads"?"border-b-2 border-slate-800 text-slate-800 bg-white":"text-gray-600 hover:text-gray-800"}`,children:u.jsxs("div",{className:"flex items-center justify-center gap-2",children:[u.jsx(le.History,{size:14}),"History"]})})]}),u.jsx("div",{className:"flex-1 min-h-0",children:n==="chat"?u.jsx(Dr,{placeholder:e??"Ask Serti AI anything...",autoFocus:!0,className:"h-full",onMessageSent:t}):u.jsx(ii,{showCreateButton:!0,className:"h-full",onThreadSelect:()=>r("chat")})})]})}function Gk({className:e="",placeholder:t,isAuthenticated:n=!0,onMessageSent:r,widgetTitle:o="Serti AI Navigator",widgetSubtitle:s="AI-Powered Assistant",...i}){const[a,l]=w.useState(!1);return n?u.jsx(yr,{...i,children:u.jsx("div",{className:`fixed bottom-6 right-6 z-[9999] transition-all duration-300 ${e}`,children:u.jsxs("div",{className:`w-96 bg-white rounded-xl shadow-2xl border border-gray-200 overflow-hidden relative ${a?"scale-75":"scale-100"}`,children:[u.jsx("div",{className:"bg-slate-800 text-white p-4 flex-shrink-0",children:u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsxs("div",{className:"relative h-10 w-10 rounded-full bg-gradient-to-br from-slate-500 to-slate-700 border border-white/30 flex items-center justify-center text-white text-sm font-bold",children:["S",u.jsx("span",{className:"absolute -bottom-0.5 -right-0.5 h-3 w-3 rounded-full border-2 border-slate-800 bg-emerald-400"})]}),u.jsxs("div",{className:"flex flex-col",children:[u.jsx("h3",{className:"text-lg font-semibold leading-tight",children:o}),u.jsx("p",{className:"text-xs text-white/70",children:s})]}),u.jsx("span",{className:"ml-2 inline-flex items-center justify-center rounded-full bg-red-500 px-2 py-0.5 text-[11px] font-semibold leading-none text-white",children:"1"})]}),u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsx(Je,{variant:"ghost",size:"sm",className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:"Options",children:u.jsx(le.MoreHorizontal,{size:16})}),u.jsx(Je,{variant:"ghost",size:"sm",className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:"Compose",children:u.jsx(le.Edit3,{size:16})}),u.jsx(Je,{variant:"ghost",size:"sm",onClick:c=>{c.stopPropagation(),l(d=>!d)},className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:a?"Maximize":"Minimize",children:a?u.jsx(le.Maximize2,{size:14}):u.jsx(le.Minimize2,{size:14})})]})]})}),!a&&u.jsx("div",{className:"h-96 flex flex-col",children:u.jsx(qk,{placeholder:t,onMessageSent:r})})]})})}):null}function Yk({label:e="New chat",children:t,className:n,variant:r="ghost",size:o="sm",...s}){return u.jsxs(Je,{variant:r,size:o,className:ne("gap-2 rounded-full px-3 font-semibold transition-all hover:scale-[1.01]",n),...s,children:[u.jsx(le.Edit3,{size:16}),t??e]})}var Xk="Label",gm=h.forwardRef((e,t)=>u.jsx(pe.label,{...e,ref:t,onMouseDown:n=>{var o;n.target.closest("button, input, select, textarea")||((o=e.onMouseDown)==null||o.call(e,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));gm.displayName=Xk;var xm=gm;const Jk=Ur.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),vm=h.forwardRef(({className:e,...t},n)=>u.jsx(xm,{ref:n,className:ne(Jk(),e),...t}));vm.displayName=xm.displayName;function wm(e){const t=h.useRef({value:e,previous:e});return h.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var bm=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),Zk="VisuallyHidden",ai=h.forwardRef((e,t)=>u.jsx(pe.span,{...e,ref:t,style:{...bm,...e.style}}));ai.displayName=Zk;var Qk=ai,eE=[" ","Enter","ArrowUp","ArrowDown"],tE=[" ","Enter"],dr="Select",[li,ci,nE]=Zo(dr),[Br,WN]=cn(dr,[nE,Nr]),ui=Nr(),[rE,qn]=Br(dr),[oE,sE]=Br(dr),ym=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:l,dir:c,name:d,autoComplete:f,disabled:m,required:p,form:v}=e,g=ui(t),[x,y]=h.useState(null),[b,C]=h.useState(null),[k,S]=h.useState(!1),T=Qo(c),[E,A]=On({prop:r,defaultProp:o??!1,onChange:s,caller:dr}),[R,L]=On({prop:i,defaultProp:a,onChange:l,caller:dr}),F=h.useRef(null),K=x?v||!!x.closest("form"):!0,[J,P]=h.useState(new Set),Y=Array.from(J).map(q=>q.props.value).join(";");return u.jsx(ca,{...g,children:u.jsxs(rE,{required:p,scope:t,trigger:x,onTriggerChange:y,valueNode:b,onValueNodeChange:C,valueNodeHasChildren:k,onValueNodeHasChildrenChange:S,contentId:_t(),value:R,onValueChange:L,open:E,onOpenChange:A,dir:T,triggerPointerDownPosRef:F,disabled:m,children:[u.jsx(li.Provider,{scope:t,children:u.jsx(oE,{scope:e.__scopeSelect,onNativeOptionAdd:h.useCallback(q=>{P(W=>new Set(W).add(q))},[]),onNativeOptionRemove:h.useCallback(q=>{P(W=>{const D=new Set(W);return D.delete(q),D})},[]),children:n})}),K?u.jsxs(Vm,{"aria-hidden":!0,required:p,tabIndex:-1,name:d,autoComplete:f,value:R,onChange:q=>L(q.target.value),disabled:m,form:v,children:[R===void 0?u.jsx("option",{value:""}):null,Array.from(J)]},Y):null]})})};ym.displayName=dr;var Sm="SelectTrigger",Cm=h.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=ui(n),i=qn(Sm,n),a=i.disabled||r,l=Pe(t,i.onTriggerChange),c=ci(n),d=h.useRef("touch"),[f,m,p]=qm(g=>{const x=c().filter(C=>!C.disabled),y=x.find(C=>C.value===i.value),b=Gm(x,g,y);b!==void 0&&i.onValueChange(b.value)}),v=g=>{a||(i.onOpenChange(!0),p()),g&&(i.triggerPointerDownPosRef.current={x:Math.round(g.pageX),y:Math.round(g.pageY)})};return u.jsx(ua,{asChild:!0,...s,children:u.jsx(pe.button,{type:"button",role:"combobox","aria-controls":i.contentId,"aria-expanded":i.open,"aria-required":i.required,"aria-autocomplete":"none",dir:i.dir,"data-state":i.open?"open":"closed",disabled:a,"data-disabled":a?"":void 0,"data-placeholder":Km(i.value)?"":void 0,...o,ref:l,onClick:ae(o.onClick,g=>{g.currentTarget.focus(),d.current!=="mouse"&&v(g)}),onPointerDown:ae(o.onPointerDown,g=>{d.current=g.pointerType;const x=g.target;x.hasPointerCapture(g.pointerId)&&x.releasePointerCapture(g.pointerId),g.button===0&&g.ctrlKey===!1&&g.pointerType==="mouse"&&(v(g),g.preventDefault())}),onKeyDown:ae(o.onKeyDown,g=>{const x=f.current!=="";!(g.ctrlKey||g.altKey||g.metaKey)&&g.key.length===1&&m(g.key),!(x&&g.key===" ")&&eE.includes(g.key)&&(v(),g.preventDefault())})})})});Cm.displayName=Sm;var Tm="SelectValue",km=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=qn(Tm,n),{onValueNodeHasChildrenChange:c}=l,d=s!==void 0,f=Pe(t,l.onValueNodeChange);return kt(()=>{c(d)},[c,d]),u.jsx(pe.span,{...a,ref:f,style:{pointerEvents:"none"},children:Km(l.value)?u.jsx(u.Fragment,{children:i}):s})});km.displayName=Tm;var iE="SelectIcon",Em=h.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return u.jsx(pe.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});Em.displayName=iE;var aE="SelectPortal",Im=e=>u.jsx(lo,{asChild:!0,...e});Im.displayName=aE;var fr="SelectContent",Nm=h.forwardRef((e,t)=>{const n=qn(fr,e.__scopeSelect),[r,o]=h.useState();if(kt(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?Wr.createPortal(u.jsx(Am,{scope:e.__scopeSelect,children:u.jsx(li.Slot,{scope:e.__scopeSelect,children:u.jsx("div",{children:e.children})})}),s):null}return u.jsx(jm,{...e,ref:t})});Nm.displayName=fr;var mn=10,[Am,Gn]=Br(fr),lE="SelectContentImpl",cE=qt.createSlot("SelectContent.RemoveScroll"),jm=h.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:f,collisionBoundary:m,collisionPadding:p,sticky:v,hideWhenDetached:g,avoidCollisions:x,...y}=e,b=qn(fr,n),[C,k]=h.useState(null),[S,T]=h.useState(null),E=Pe(t,O=>k(O)),[A,R]=h.useState(null),[L,F]=h.useState(null),K=ci(n),[J,P]=h.useState(!1),Y=h.useRef(!1);h.useEffect(()=>{if(C)return ga(C)},[C]),qi();const q=h.useCallback(O=>{const[j,...U]=K().map(ie=>ie.ref.current),[Q]=U.slice(-1),se=document.activeElement;for(const ie of O)if(ie===se||(ie==null||ie.scrollIntoView({block:"nearest"}),ie===j&&S&&(S.scrollTop=0),ie===Q&&S&&(S.scrollTop=S.scrollHeight),ie==null||ie.focus(),document.activeElement!==se))return},[K,S]),W=h.useCallback(()=>q([A,C]),[q,A,C]);h.useEffect(()=>{J&&W()},[J,W]);const{onOpenChange:D,triggerPointerDownPosRef:I}=b;h.useEffect(()=>{if(C){let O={x:0,y:0};const j=Q=>{var se,ie;O={x:Math.abs(Math.round(Q.pageX)-(((se=I.current)==null?void 0:se.x)??0)),y:Math.abs(Math.round(Q.pageY)-(((ie=I.current)==null?void 0:ie.y)??0))}},U=Q=>{O.x<=10&&O.y<=10?Q.preventDefault():C.contains(Q.target)||D(!1),document.removeEventListener("pointermove",j),I.current=null};return I.current!==null&&(document.addEventListener("pointermove",j),document.addEventListener("pointerup",U,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",j),document.removeEventListener("pointerup",U,{capture:!0})}}},[C,D,I]),h.useEffect(()=>{const O=()=>D(!1);return window.addEventListener("blur",O),window.addEventListener("resize",O),()=>{window.removeEventListener("blur",O),window.removeEventListener("resize",O)}},[D]);const[G,X]=qm(O=>{const j=K().filter(se=>!se.disabled),U=j.find(se=>se.ref.current===document.activeElement),Q=Gm(j,O,U);Q&&setTimeout(()=>Q.ref.current.focus())}),M=h.useCallback((O,j,U)=>{const Q=!Y.current&&!U;(b.value!==void 0&&b.value===j||Q)&&(R(O),Q&&(Y.current=!0))},[b.value]),B=h.useCallback(()=>C==null?void 0:C.focus(),[C]),_=h.useCallback((O,j,U)=>{const Q=!Y.current&&!U;(b.value!==void 0&&b.value===j||Q)&&F(O)},[b.value]),$=r==="popper"?Ll:Pm,z=$===Ll?{side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:f,collisionBoundary:m,collisionPadding:p,sticky:v,hideWhenDetached:g,avoidCollisions:x}:{};return u.jsx(Am,{scope:n,content:C,viewport:S,onViewportChange:T,itemRefCallback:M,selectedItem:A,onItemLeave:B,itemTextRefCallback:_,focusSelectedItem:W,selectedItemText:L,position:r,isPositioned:J,searchRef:G,children:u.jsx(ws,{as:cE,allowPinchZoom:!0,children:u.jsx(es,{asChild:!0,trapped:b.open,onMountAutoFocus:O=>{O.preventDefault()},onUnmountAutoFocus:ae(o,O=>{var j;(j=b.trigger)==null||j.focus({preventScroll:!0}),O.preventDefault()}),children:u.jsx(Cr,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:O=>O.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:u.jsx($,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:O=>O.preventDefault(),...y,...z,onPlaced:()=>P(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:ae(y.onKeyDown,O=>{const j=O.ctrlKey||O.altKey||O.metaKey;if(O.key==="Tab"&&O.preventDefault(),!j&&O.key.length===1&&X(O.key),["ArrowUp","ArrowDown","Home","End"].includes(O.key)){let Q=K().filter(se=>!se.disabled).map(se=>se.ref.current);if(["ArrowUp","End"].includes(O.key)&&(Q=Q.slice().reverse()),["ArrowUp","ArrowDown"].includes(O.key)){const se=O.target,ie=Q.indexOf(se);Q=Q.slice(ie+1)}setTimeout(()=>q(Q)),O.preventDefault()}})})})})})})});jm.displayName=lE;var uE="SelectItemAlignedPosition",Pm=h.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=qn(fr,n),i=Gn(fr,n),[a,l]=h.useState(null),[c,d]=h.useState(null),f=Pe(t,E=>d(E)),m=ci(n),p=h.useRef(!1),v=h.useRef(!0),{viewport:g,selectedItem:x,selectedItemText:y,focusSelectedItem:b}=i,C=h.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&c&&g&&x&&y){const E=s.trigger.getBoundingClientRect(),A=c.getBoundingClientRect(),R=s.valueNode.getBoundingClientRect(),L=y.getBoundingClientRect();if(s.dir!=="rtl"){const se=L.left-A.left,ie=R.left-se,Se=E.left-ie,xe=E.width+Se,Re=Math.max(xe,A.width),Ve=window.innerWidth-mn,De=jl(ie,[mn,Math.max(mn,Ve-Re)]);a.style.minWidth=xe+"px",a.style.left=De+"px"}else{const se=A.right-L.right,ie=window.innerWidth-R.right-se,Se=window.innerWidth-E.right-ie,xe=E.width+Se,Re=Math.max(xe,A.width),Ve=window.innerWidth-mn,De=jl(ie,[mn,Math.max(mn,Ve-Re)]);a.style.minWidth=xe+"px",a.style.right=De+"px"}const F=m(),K=window.innerHeight-mn*2,J=g.scrollHeight,P=window.getComputedStyle(c),Y=parseInt(P.borderTopWidth,10),q=parseInt(P.paddingTop,10),W=parseInt(P.borderBottomWidth,10),D=parseInt(P.paddingBottom,10),I=Y+q+J+D+W,G=Math.min(x.offsetHeight*5,I),X=window.getComputedStyle(g),M=parseInt(X.paddingTop,10),B=parseInt(X.paddingBottom,10),_=E.top+E.height/2-mn,$=K-_,z=x.offsetHeight/2,O=x.offsetTop+z,j=Y+q+O,U=I-j;if(j<=_){const se=F.length>0&&x===F[F.length-1].ref.current;a.style.bottom="0px";const ie=c.clientHeight-g.offsetTop-g.offsetHeight,Se=Math.max($,z+(se?B:0)+ie+W),xe=j+Se;a.style.height=xe+"px"}else{const se=F.length>0&&x===F[0].ref.current;a.style.top="0px";const Se=Math.max(_,Y+g.offsetTop+(se?M:0)+z)+U;a.style.height=Se+"px",g.scrollTop=j-_+g.offsetTop}a.style.margin=`${mn}px 0`,a.style.minHeight=G+"px",a.style.maxHeight=K+"px",r==null||r(),requestAnimationFrame(()=>p.current=!0)}},[m,s.trigger,s.valueNode,a,c,g,x,y,s.dir,r]);kt(()=>C(),[C]);const[k,S]=h.useState();kt(()=>{c&&S(window.getComputedStyle(c).zIndex)},[c]);const T=h.useCallback(E=>{E&&v.current===!0&&(C(),b==null||b(),v.current=!1)},[C,b]);return u.jsx(fE,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:p,onScrollButtonChange:T,children:u.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:k},children:u.jsx(pe.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Pm.displayName=uE;var dE="SelectPopperPosition",Ll=h.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=mn,...s}=e,i=ui(n);return u.jsx(da,{...i,...s,ref:t,align:r,collisionPadding:o,style:{boxSizing:"border-box",...s.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});Ll.displayName=dE;var[fE,$l]=Br(fr,{}),Fl="SelectViewport",_m=h.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Gn(Fl,n),i=$l(Fl,n),a=Pe(t,s.onViewportChange),l=h.useRef(0);return u.jsxs(u.Fragment,{children:[u.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),u.jsx(li.Slot,{scope:n,children:u.jsx(pe.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:ae(o.onScroll,c=>{const d=c.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:m}=i;if(m!=null&&m.current&&f){const p=Math.abs(l.current-d.scrollTop);if(p>0){const v=window.innerHeight-mn*2,g=parseFloat(f.style.minHeight),x=parseFloat(f.style.height),y=Math.max(g,x);if(y<v){const b=y+p,C=Math.min(v,b),k=b-C;f.style.height=C+"px",f.style.bottom==="0px"&&(d.scrollTop=k>0?k:0,f.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});_m.displayName=Fl;var Rm="SelectGroup",[pE,hE]=Br(Rm),mE=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=_t();return u.jsx(pE,{scope:n,id:o,children:u.jsx(pe.div,{role:"group","aria-labelledby":o,...r,ref:t})})});mE.displayName=Rm;var Mm="SelectLabel",Om=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=hE(Mm,n);return u.jsx(pe.div,{id:o.id,...r,ref:t})});Om.displayName=Mm;var di="SelectItem",[gE,Dm]=Br(di),Lm=h.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=qn(di,n),l=Gn(di,n),c=a.value===r,[d,f]=h.useState(s??""),[m,p]=h.useState(!1),v=Pe(t,b=>{var C;return(C=l.itemRefCallback)==null?void 0:C.call(l,b,r,o)}),g=_t(),x=h.useRef("touch"),y=()=>{o||(a.onValueChange(r),a.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return u.jsx(gE,{scope:n,value:r,disabled:o,textId:g,isSelected:c,onItemTextChange:h.useCallback(b=>{f(C=>C||((b==null?void 0:b.textContent)??"").trim())},[]),children:u.jsx(li.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:u.jsx(pe.div,{role:"option","aria-labelledby":g,"data-highlighted":m?"":void 0,"aria-selected":c&&m,"data-state":c?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:v,onFocus:ae(i.onFocus,()=>p(!0)),onBlur:ae(i.onBlur,()=>p(!1)),onClick:ae(i.onClick,()=>{x.current!=="mouse"&&y()}),onPointerUp:ae(i.onPointerUp,()=>{x.current==="mouse"&&y()}),onPointerDown:ae(i.onPointerDown,b=>{x.current=b.pointerType}),onPointerMove:ae(i.onPointerMove,b=>{var C;x.current=b.pointerType,o?(C=l.onItemLeave)==null||C.call(l):x.current==="mouse"&&b.currentTarget.focus({preventScroll:!0})}),onPointerLeave:ae(i.onPointerLeave,b=>{var C;b.currentTarget===document.activeElement&&((C=l.onItemLeave)==null||C.call(l))}),onKeyDown:ae(i.onKeyDown,b=>{var k;((k=l.searchRef)==null?void 0:k.current)!==""&&b.key===" "||(tE.includes(b.key)&&y(),b.key===" "&&b.preventDefault())})})})})});Lm.displayName=di;var Ro="SelectItemText",$m=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=qn(Ro,n),a=Gn(Ro,n),l=Dm(Ro,n),c=sE(Ro,n),[d,f]=h.useState(null),m=Pe(t,y=>f(y),l.onItemTextChange,y=>{var b;return(b=a.itemTextRefCallback)==null?void 0:b.call(a,y,l.value,l.disabled)}),p=d==null?void 0:d.textContent,v=h.useMemo(()=>u.jsx("option",{value:l.value,disabled:l.disabled,children:p},l.value),[l.disabled,l.value,p]),{onNativeOptionAdd:g,onNativeOptionRemove:x}=c;return kt(()=>(g(v),()=>x(v)),[g,x,v]),u.jsxs(u.Fragment,{children:[u.jsx(pe.span,{id:l.textId,...s,ref:m}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?Wr.createPortal(s.children,i.valueNode):null]})});$m.displayName=Ro;var Fm="SelectItemIndicator",Bm=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Dm(Fm,n).isSelected?u.jsx(pe.span,{"aria-hidden":!0,...r,ref:t}):null});Bm.displayName=Fm;var Bl="SelectScrollUpButton",zm=h.forwardRef((e,t)=>{const n=Gn(Bl,e.__scopeSelect),r=$l(Bl,e.__scopeSelect),[o,s]=h.useState(!1),i=Pe(t,r.onScrollButtonChange);return kt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollTop>0;s(c)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?u.jsx(Um,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});zm.displayName=Bl;var zl="SelectScrollDownButton",Hm=h.forwardRef((e,t)=>{const n=Gn(zl,e.__scopeSelect),r=$l(zl,e.__scopeSelect),[o,s]=h.useState(!1),i=Pe(t,r.onScrollButtonChange);return kt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollHeight-l.clientHeight,d=Math.ceil(l.scrollTop)<c;s(d)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?u.jsx(Um,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});Hm.displayName=zl;var Um=h.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=Gn("SelectScrollButton",n),i=h.useRef(null),a=ci(n),l=h.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return h.useEffect(()=>()=>l(),[l]),kt(()=>{var d;const c=a().find(f=>f.ref.current===document.activeElement);(d=c==null?void 0:c.ref.current)==null||d.scrollIntoView({block:"nearest"})},[a]),u.jsx(pe.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:ae(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:ae(o.onPointerMove,()=>{var c;(c=s.onItemLeave)==null||c.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:ae(o.onPointerLeave,()=>{l()})})}),xE="SelectSeparator",Wm=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return u.jsx(pe.div,{"aria-hidden":!0,...r,ref:t})});Wm.displayName=xE;var Hl="SelectArrow",vE=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=ui(n),s=qn(Hl,n),i=Gn(Hl,n);return s.open&&i.position==="popper"?u.jsx(fa,{...o,...r,ref:t}):null});vE.displayName=Hl;var wE="SelectBubbleInput",Vm=h.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=h.useRef(null),s=Pe(r,o),i=wm(t);return h.useEffect(()=>{const a=o.current;if(!a)return;const l=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(l,"value").set;if(i!==t&&d){const f=new Event("change",{bubbles:!0});d.call(a,t),a.dispatchEvent(f)}},[i,t]),u.jsx(pe.select,{...n,style:{...bm,...n.style},ref:s,defaultValue:t})});Vm.displayName=wE;function Km(e){return e===""||e===void 0}function qm(e){const t=gt(e),n=h.useRef(""),r=h.useRef(0),o=h.useCallback(i=>{const a=n.current+i;t(a),function l(c){n.current=c,window.clearTimeout(r.current),c!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),s=h.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return h.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function Gm(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=bE(e,Math.max(s,0));o.length===1&&(i=i.filter(c=>c!==n));const l=i.find(c=>c.textValue.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function bE(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var yE=ym,Ym=Cm,SE=km,CE=Em,TE=Im,Xm=Nm,kE=_m,Jm=Om,Zm=Lm,EE=$m,IE=Bm,Qm=zm,eg=Hm,tg=Wm;const NE=yE,AE=SE,ng=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Ym,{ref:r,className:ne("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,u.jsx(CE,{asChild:!0,children:u.jsx(le.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));ng.displayName=Ym.displayName;const rg=h.forwardRef(({className:e,...t},n)=>u.jsx(Qm,{ref:n,className:ne("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(le.ChevronUp,{className:"h-4 w-4"})}));rg.displayName=Qm.displayName;const og=h.forwardRef(({className:e,...t},n)=>u.jsx(eg,{ref:n,className:ne("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(le.ChevronDown,{className:"h-4 w-4"})}));og.displayName=eg.displayName;const sg=h.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>u.jsx(TE,{children:u.jsxs(Xm,{ref:o,className:ne("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[u.jsx(rg,{}),u.jsx(kE,{className:ne("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),u.jsx(og,{})]})}));sg.displayName=Xm.displayName;const jE=h.forwardRef(({className:e,...t},n)=>u.jsx(Jm,{ref:n,className:ne("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));jE.displayName=Jm.displayName;const ig=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Zm,{ref:r,className:ne("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(IE,{children:u.jsx(le.Check,{className:"h-4 w-4"})})}),u.jsx(EE,{children:t})]}));ig.displayName=Zm.displayName;const PE=h.forwardRef(({className:e,...t},n)=>u.jsx(tg,{ref:n,className:ne("-mx-1 my-1 h-px bg-muted",e),...t}));PE.displayName=tg.displayName;var _E="Separator",ag="horizontal",RE=["horizontal","vertical"],lg=h.forwardRef((e,t)=>{const{decorative:n,orientation:r=ag,...o}=e,s=ME(r)?r:ag,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return u.jsx(pe.div,{"data-orientation":s,...a,...o,ref:t})});lg.displayName=_E;function ME(e){return RE.includes(e)}var cg=lg;const ug=h.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>u.jsx(cg,{ref:o,decorative:n,orientation:t,className:ne("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));ug.displayName=cg.displayName;var fi="Switch",[OE,VN]=cn(fi),[DE,LE]=OE(fi),dg=h.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:l="on",onCheckedChange:c,form:d,...f}=e,[m,p]=h.useState(null),v=Pe(t,C=>p(C)),g=h.useRef(!1),x=m?d||!!m.closest("form"):!0,[y,b]=On({prop:o,defaultProp:s??!1,onChange:c,caller:fi});return u.jsxs(DE,{scope:n,checked:y,disabled:a,children:[u.jsx(pe.button,{type:"button",role:"switch","aria-checked":y,"aria-required":i,"data-state":mg(y),"data-disabled":a?"":void 0,disabled:a,value:l,...f,ref:v,onClick:ae(e.onClick,C=>{b(k=>!k),x&&(g.current=C.isPropagationStopped(),g.current||C.stopPropagation())})}),x&&u.jsx(hg,{control:m,bubbles:!g.current,name:r,value:l,checked:y,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});dg.displayName=fi;var fg="SwitchThumb",pg=h.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=LE(fg,n);return u.jsx(pe.span,{"data-state":mg(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});pg.displayName=fg;var $E="SwitchBubbleInput",hg=h.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=h.useRef(null),a=Pe(i,s),l=wm(n),c=Td(t);return h.useEffect(()=>{const d=i.current;if(!d)return;const f=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(f,"checked").set;if(l!==n&&p){const v=new Event("click",{bubbles:r});p.call(d,n),d.dispatchEvent(v)}},[l,n,r]),u.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:a,style:{...o.style,...c,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});hg.displayName=$E;function mg(e){return e?"checked":"unchecked"}var gg=dg,FE=pg;const xg=h.forwardRef(({className:e,...t},n)=>u.jsx(gg,{className:ne("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:u.jsx(FE,{className:ne("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));xg.displayName=gg.displayName;const BE=nl,zE=xT,HE=rl,vg=h.forwardRef(({className:e,...t},n)=>u.jsx(Io,{className:ne("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:n}));vg.displayName=Io.displayName;const UE=Ur.cva("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),wg=h.forwardRef(({side:e="right",className:t,children:n,...r},o)=>u.jsxs(HE,{children:[u.jsx(vg,{}),u.jsxs(No,{ref:o,className:ne(UE({side:e}),t),...r,children:[n,u.jsxs(uh,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[u.jsx(le.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));wg.displayName=No.displayName;const bg=({className:e,...t})=>u.jsx("div",{className:ne("flex flex-col space-y-2 text-center sm:text-left",e),...t});bg.displayName="SheetHeader";const yg=h.forwardRef(({className:e,...t},n)=>u.jsx(ar,{ref:n,className:ne("text-lg font-semibold text-foreground",e),...t}));yg.displayName=ar.displayName;const Sg=h.forwardRef(({className:e,...t},n)=>u.jsx(Hs,{ref:n,className:ne("text-sm text-muted-foreground",e),...t}));Sg.displayName=Hs.displayName;var[pi,KN]=cn("Tooltip",[Nr]),hi=Nr(),Cg="TooltipProvider",WE=700,Ul="tooltip.open",[VE,Wl]=pi(Cg),Tg=e=>{const{__scopeTooltip:t,delayDuration:n=WE,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:s}=e,i=h.useRef(!0),a=h.useRef(!1),l=h.useRef(0);return h.useEffect(()=>{const c=l.current;return()=>window.clearTimeout(c)},[]),u.jsx(VE,{scope:t,isOpenDelayedRef:i,delayDuration:n,onOpen:h.useCallback(()=>{window.clearTimeout(l.current),i.current=!1},[]),onClose:h.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>i.current=!0,r)},[r]),isPointerInTransitRef:a,onPointerInTransitChange:h.useCallback(c=>{a.current=c},[]),disableHoverableContent:o,children:s})};Tg.displayName=Cg;var Mo="Tooltip",[KE,mi]=pi(Mo),kg=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:s,disableHoverableContent:i,delayDuration:a}=e,l=Wl(Mo,e.__scopeTooltip),c=hi(t),[d,f]=h.useState(null),m=_t(),p=h.useRef(0),v=i??l.disableHoverableContent,g=a??l.delayDuration,x=h.useRef(!1),[y,b]=On({prop:r,defaultProp:o??!1,onChange:E=>{E?(l.onOpen(),document.dispatchEvent(new CustomEvent(Ul))):l.onClose(),s==null||s(E)},caller:Mo}),C=h.useMemo(()=>y?x.current?"delayed-open":"instant-open":"closed",[y]),k=h.useCallback(()=>{window.clearTimeout(p.current),p.current=0,x.current=!1,b(!0)},[b]),S=h.useCallback(()=>{window.clearTimeout(p.current),p.current=0,b(!1)},[b]),T=h.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{x.current=!0,b(!0),p.current=0},g)},[g,b]);return h.useEffect(()=>()=>{p.current&&(window.clearTimeout(p.current),p.current=0)},[]),u.jsx(ca,{...c,children:u.jsx(KE,{scope:t,contentId:m,open:y,stateAttribute:C,trigger:d,onTriggerChange:f,onTriggerEnter:h.useCallback(()=>{l.isOpenDelayedRef.current?T():k()},[l.isOpenDelayedRef,T,k]),onTriggerLeave:h.useCallback(()=>{v?S():(window.clearTimeout(p.current),p.current=0)},[S,v]),onOpen:k,onClose:S,disableHoverableContent:v,children:n})})};kg.displayName=Mo;var Vl="TooltipTrigger",Eg=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=mi(Vl,n),s=Wl(Vl,n),i=hi(n),a=h.useRef(null),l=Pe(t,a,o.onTriggerChange),c=h.useRef(!1),d=h.useRef(!1),f=h.useCallback(()=>c.current=!1,[]);return h.useEffect(()=>()=>document.removeEventListener("pointerup",f),[f]),u.jsx(ua,{asChild:!0,...i,children:u.jsx(pe.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:l,onPointerMove:ae(e.onPointerMove,m=>{m.pointerType!=="touch"&&!d.current&&!s.isPointerInTransitRef.current&&(o.onTriggerEnter(),d.current=!0)}),onPointerLeave:ae(e.onPointerLeave,()=>{o.onTriggerLeave(),d.current=!1}),onPointerDown:ae(e.onPointerDown,()=>{o.open&&o.onClose(),c.current=!0,document.addEventListener("pointerup",f,{once:!0})}),onFocus:ae(e.onFocus,()=>{c.current||o.onOpen()}),onBlur:ae(e.onBlur,o.onClose),onClick:ae(e.onClick,o.onClose)})})});Eg.displayName=Vl;var qE="TooltipPortal",[qN,GE]=pi(qE,{forceMount:void 0}),zr="TooltipContent",Ig=h.forwardRef((e,t)=>{const n=GE(zr,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,i=mi(zr,e.__scopeTooltip);return u.jsx(Ht,{present:r||i.open,children:i.disableHoverableContent?u.jsx(Ng,{side:o,...s,ref:t}):u.jsx(YE,{side:o,...s,ref:t})})}),YE=h.forwardRef((e,t)=>{const n=mi(zr,e.__scopeTooltip),r=Wl(zr,e.__scopeTooltip),o=h.useRef(null),s=Pe(t,o),[i,a]=h.useState(null),{trigger:l,onClose:c}=n,d=o.current,{onPointerInTransitChange:f}=r,m=h.useCallback(()=>{a(null),f(!1)},[f]),p=h.useCallback((v,g)=>{const x=v.currentTarget,y={x:v.clientX,y:v.clientY},b=eI(y,x.getBoundingClientRect()),C=tI(y,b),k=nI(g.getBoundingClientRect()),S=oI([...C,...k]);a(S),f(!0)},[f]);return h.useEffect(()=>()=>m(),[m]),h.useEffect(()=>{if(l&&d){const v=x=>p(x,d),g=x=>p(x,l);return l.addEventListener("pointerleave",v),d.addEventListener("pointerleave",g),()=>{l.removeEventListener("pointerleave",v),d.removeEventListener("pointerleave",g)}}},[l,d,p,m]),h.useEffect(()=>{if(i){const v=g=>{const x=g.target,y={x:g.clientX,y:g.clientY},b=(l==null?void 0:l.contains(x))||(d==null?void 0:d.contains(x)),C=!rI(y,i);b?m():C&&(m(),c())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[l,d,i,c,m]),u.jsx(Ng,{...e,ref:s})}),[XE,JE]=pi(Mo,{isInside:!1}),ZE=qt.createSlottable("TooltipContent"),Ng=h.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:i,...a}=e,l=mi(zr,n),c=hi(n),{onClose:d}=l;return h.useEffect(()=>(document.addEventListener(Ul,d),()=>document.removeEventListener(Ul,d)),[d]),h.useEffect(()=>{if(l.trigger){const f=m=>{const p=m.target;p!=null&&p.contains(l.trigger)&&d()};return window.addEventListener("scroll",f,{capture:!0}),()=>window.removeEventListener("scroll",f,{capture:!0})}},[l.trigger,d]),u.jsx(Cr,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:f=>f.preventDefault(),onDismiss:d,children:u.jsxs(da,{"data-state":l.stateAttribute,...c,...a,ref:t,style:{...a.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[u.jsx(ZE,{children:r}),u.jsx(XE,{scope:n,isInside:!0,children:u.jsx(Qk,{id:l.contentId,role:"tooltip",children:o||r})})]})})});Ig.displayName=zr;var Ag="TooltipArrow",QE=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=hi(n);return JE(Ag,n).isInside?null:u.jsx(fa,{...o,...r,ref:t})});QE.displayName=Ag;function eI(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(n,r,o,s)){case s:return"left";case o:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function tI(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function nI(e){const{top:t,right:n,bottom:r,left:o}=e;return[{x:o,y:t},{x:n,y:t},{x:n,y:r},{x:o,y:r}]}function rI(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],l=t[i],c=a.x,d=a.y,f=l.x,m=l.y;d>r!=m>r&&n<(f-c)*(r-d)/(m-d)+c&&(o=!o)}return o}function oI(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),sI(t)}function sI(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const o=e[r];for(;t.length>=2;){const s=t[t.length-1],i=t[t.length-2];if((s.x-i.x)*(o.y-i.y)>=(s.y-i.y)*(o.x-i.x))t.pop();else break}t.push(o)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const o=e[r];for(;n.length>=2;){const s=n[n.length-1],i=n[n.length-2];if((s.x-i.x)*(o.y-i.y)>=(s.y-i.y)*(o.x-i.x))n.pop();else break}n.push(o)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var iI=Tg,aI=kg,lI=Eg,jg=Ig;const cI=iI,uI=aI,dI=lI,Pg=h.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(jg,{ref:r,sideOffset:t,className:ne("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n}));Pg.displayName=jg.displayName;var Kl="ToastProvider",[ql,fI,pI]=Zo("Toast"),[_g,GN]=cn("Toast",[pI]),[hI,gi]=_g(Kl),Rg=e=>{const{__scopeToast:t,label:n="Notification",duration:r=5e3,swipeDirection:o="right",swipeThreshold:s=50,children:i}=e,[a,l]=h.useState(null),[c,d]=h.useState(0),f=h.useRef(!1),m=h.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${Kl}\`. Expected non-empty \`string\`.`),u.jsx(ql.Provider,{scope:t,children:u.jsx(hI,{scope:t,label:n,duration:r,swipeDirection:o,swipeThreshold:s,toastCount:c,viewport:a,onViewportChange:l,onToastAdd:h.useCallback(()=>d(p=>p+1),[]),onToastRemove:h.useCallback(()=>d(p=>p-1),[]),isFocusedToastEscapeKeyDownRef:f,isClosePausedRef:m,children:i})})};Rg.displayName=Kl;var Mg="ToastViewport",mI=["F8"],Gl="toast.viewportPause",Yl="toast.viewportResume",Og=h.forwardRef((e,t)=>{const{__scopeToast:n,hotkey:r=mI,label:o="Notifications ({hotkey})",...s}=e,i=gi(Mg,n),a=fI(n),l=h.useRef(null),c=h.useRef(null),d=h.useRef(null),f=h.useRef(null),m=Pe(t,f,i.onViewportChange),p=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),v=i.toastCount>0;h.useEffect(()=>{const x=y=>{var C;r.length!==0&&r.every(k=>y[k]||y.code===k)&&((C=f.current)==null||C.focus())};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[r]),h.useEffect(()=>{const x=l.current,y=f.current;if(v&&x&&y){const b=()=>{if(!i.isClosePausedRef.current){const T=new CustomEvent(Gl);y.dispatchEvent(T),i.isClosePausedRef.current=!0}},C=()=>{if(i.isClosePausedRef.current){const T=new CustomEvent(Yl);y.dispatchEvent(T),i.isClosePausedRef.current=!1}},k=T=>{!x.contains(T.relatedTarget)&&C()},S=()=>{x.contains(document.activeElement)||C()};return x.addEventListener("focusin",b),x.addEventListener("focusout",k),x.addEventListener("pointermove",b),x.addEventListener("pointerleave",S),window.addEventListener("blur",b),window.addEventListener("focus",C),()=>{x.removeEventListener("focusin",b),x.removeEventListener("focusout",k),x.removeEventListener("pointermove",b),x.removeEventListener("pointerleave",S),window.removeEventListener("blur",b),window.removeEventListener("focus",C)}}},[v,i.isClosePausedRef]);const g=h.useCallback(({tabbingDirection:x})=>{const b=a().map(C=>{const k=C.ref.current,S=[k,...NI(k)];return x==="forwards"?S:S.reverse()});return(x==="forwards"?b.reverse():b).flat()},[a]);return h.useEffect(()=>{const x=f.current;if(x){const y=b=>{var S,T,E;const C=b.altKey||b.ctrlKey||b.metaKey;if(b.key==="Tab"&&!C){const A=document.activeElement,R=b.shiftKey;if(b.target===x&&R){(S=c.current)==null||S.focus();return}const K=g({tabbingDirection:R?"backwards":"forwards"}),J=K.findIndex(P=>P===A);Zl(K.slice(J+1))?b.preventDefault():R?(T=c.current)==null||T.focus():(E=d.current)==null||E.focus()}};return x.addEventListener("keydown",y),()=>x.removeEventListener("keydown",y)}},[a,g]),u.jsxs(Vw,{ref:l,role:"region","aria-label":o.replace("{hotkey}",p),tabIndex:-1,style:{pointerEvents:v?void 0:"none"},children:[v&&u.jsx(Xl,{ref:c,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"forwards"});Zl(x)}}),u.jsx(ql.Slot,{scope:n,children:u.jsx(pe.ol,{tabIndex:-1,...s,ref:m})}),v&&u.jsx(Xl,{ref:d,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"backwards"});Zl(x)}})]})});Og.displayName=Mg;var Dg="ToastFocusProxy",Xl=h.forwardRef((e,t)=>{const{__scopeToast:n,onFocusFromOutsideViewport:r,...o}=e,s=gi(Dg,n);return u.jsx(ai,{tabIndex:0,...o,ref:t,style:{position:"fixed"},onFocus:i=>{var c;const a=i.relatedTarget;!((c=s.viewport)!=null&&c.contains(a))&&r()}})});Xl.displayName=Dg;var Oo="Toast",gI="toast.swipeStart",xI="toast.swipeMove",vI="toast.swipeCancel",wI="toast.swipeEnd",Lg=h.forwardRef((e,t)=>{const{forceMount:n,open:r,defaultOpen:o,onOpenChange:s,...i}=e,[a,l]=On({prop:r,defaultProp:o??!0,onChange:s,caller:Oo});return u.jsx(Ht,{present:n||a,children:u.jsx(SI,{open:a,...i,ref:t,onClose:()=>l(!1),onPause:gt(e.onPause),onResume:gt(e.onResume),onSwipeStart:ae(e.onSwipeStart,c=>{c.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:ae(e.onSwipeMove,c=>{const{x:d,y:f}=c.detail.delta;c.currentTarget.setAttribute("data-swipe","move"),c.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${d}px`),c.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${f}px`)}),onSwipeCancel:ae(e.onSwipeCancel,c=>{c.currentTarget.setAttribute("data-swipe","cancel"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),c.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:ae(e.onSwipeEnd,c=>{const{x:d,y:f}=c.detail.delta;c.currentTarget.setAttribute("data-swipe","end"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),c.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${d}px`),c.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${f}px`),l(!1)})})})});Lg.displayName=Oo;var[bI,yI]=_g(Oo,{onClose(){}}),SI=h.forwardRef((e,t)=>{const{__scopeToast:n,type:r="foreground",duration:o,open:s,onClose:i,onEscapeKeyDown:a,onPause:l,onResume:c,onSwipeStart:d,onSwipeMove:f,onSwipeCancel:m,onSwipeEnd:p,...v}=e,g=gi(Oo,n),[x,y]=h.useState(null),b=Pe(t,P=>y(P)),C=h.useRef(null),k=h.useRef(null),S=o||g.duration,T=h.useRef(0),E=h.useRef(S),A=h.useRef(0),{onToastAdd:R,onToastRemove:L}=g,F=gt(()=>{var Y;(x==null?void 0:x.contains(document.activeElement))&&((Y=g.viewport)==null||Y.focus()),i()}),K=h.useCallback(P=>{!P||P===1/0||(window.clearTimeout(A.current),T.current=new Date().getTime(),A.current=window.setTimeout(F,P))},[F]);h.useEffect(()=>{const P=g.viewport;if(P){const Y=()=>{K(E.current),c==null||c()},q=()=>{const W=new Date().getTime()-T.current;E.current=E.current-W,window.clearTimeout(A.current),l==null||l()};return P.addEventListener(Gl,q),P.addEventListener(Yl,Y),()=>{P.removeEventListener(Gl,q),P.removeEventListener(Yl,Y)}}},[g.viewport,S,l,c,K]),h.useEffect(()=>{s&&!g.isClosePausedRef.current&&K(S)},[s,S,g.isClosePausedRef,K]),h.useEffect(()=>(R(),()=>L()),[R,L]);const J=h.useMemo(()=>x?Wg(x):null,[x]);return g.viewport?u.jsxs(u.Fragment,{children:[J&&u.jsx(CI,{__scopeToast:n,role:"status","aria-live":r==="foreground"?"assertive":"polite",children:J}),u.jsx(bI,{scope:n,onClose:F,children:Wr.createPortal(u.jsx(ql.ItemSlot,{scope:n,children:u.jsx(Ww,{asChild:!0,onEscapeKeyDown:ae(a,()=>{g.isFocusedToastEscapeKeyDownRef.current||F(),g.isFocusedToastEscapeKeyDownRef.current=!1}),children:u.jsx(pe.li,{tabIndex:0,"data-state":s?"open":"closed","data-swipe-direction":g.swipeDirection,...v,ref:b,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:ae(e.onKeyDown,P=>{P.key==="Escape"&&(a==null||a(P.nativeEvent),P.nativeEvent.defaultPrevented||(g.isFocusedToastEscapeKeyDownRef.current=!0,F()))}),onPointerDown:ae(e.onPointerDown,P=>{P.button===0&&(C.current={x:P.clientX,y:P.clientY})}),onPointerMove:ae(e.onPointerMove,P=>{if(!C.current)return;const Y=P.clientX-C.current.x,q=P.clientY-C.current.y,W=!!k.current,D=["left","right"].includes(g.swipeDirection),I=["left","up"].includes(g.swipeDirection)?Math.min:Math.max,G=D?I(0,Y):0,X=D?0:I(0,q),M=P.pointerType==="touch"?10:2,B={x:G,y:X},_={originalEvent:P,delta:B};W?(k.current=B,xi(xI,f,_,{discrete:!1})):Vg(B,g.swipeDirection,M)?(k.current=B,xi(gI,d,_,{discrete:!1}),P.target.setPointerCapture(P.pointerId)):(Math.abs(Y)>M||Math.abs(q)>M)&&(C.current=null)}),onPointerUp:ae(e.onPointerUp,P=>{const Y=k.current,q=P.target;if(q.hasPointerCapture(P.pointerId)&&q.releasePointerCapture(P.pointerId),k.current=null,C.current=null,Y){const W=P.currentTarget,D={originalEvent:P,delta:Y};Vg(Y,g.swipeDirection,g.swipeThreshold)?xi(wI,p,D,{discrete:!0}):xi(vI,m,D,{discrete:!0}),W.addEventListener("click",I=>I.preventDefault(),{once:!0})}})})})}),g.viewport)})]}):null}),CI=e=>{const{__scopeToast:t,children:n,...r}=e,o=gi(Oo,t),[s,i]=h.useState(!1),[a,l]=h.useState(!1);return EI(()=>i(!0)),h.useEffect(()=>{const c=window.setTimeout(()=>l(!0),1e3);return()=>window.clearTimeout(c)},[]),a?null:u.jsx(lo,{asChild:!0,children:u.jsx(ai,{...r,children:s&&u.jsxs(u.Fragment,{children:[o.label," ",n]})})})},TI="ToastTitle",$g=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(pe.div,{...r,ref:t})});$g.displayName=TI;var kI="ToastDescription",Fg=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(pe.div,{...r,ref:t})});Fg.displayName=kI;var Bg="ToastAction",zg=h.forwardRef((e,t)=>{const{altText:n,...r}=e;return n.trim()?u.jsx(Ug,{altText:n,asChild:!0,children:u.jsx(Jl,{...r,ref:t})}):(console.error(`Invalid prop \`altText\` supplied to \`${Bg}\`. Expected non-empty \`string\`.`),null)});zg.displayName=Bg;var Hg="ToastClose",Jl=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e,o=yI(Hg,n);return u.jsx(Ug,{asChild:!0,children:u.jsx(pe.button,{type:"button",...r,ref:t,onClick:ae(e.onClick,o.onClose)})})});Jl.displayName=Hg;var Ug=h.forwardRef((e,t)=>{const{__scopeToast:n,altText:r,...o}=e;return u.jsx(pe.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":r||void 0,...o,ref:t})});function Wg(e){const t=[];return Array.from(e.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&t.push(r.textContent),II(r)){const o=r.ariaHidden||r.hidden||r.style.display==="none",s=r.dataset.radixToastAnnounceExclude==="";if(!o)if(s){const i=r.dataset.radixToastAnnounceAlt;i&&t.push(i)}else t.push(...Wg(r))}}),t}function xi(e,t,n,{discrete:r}){const o=n.originalEvent.currentTarget,s=new CustomEvent(e,{bubbles:!0,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?Wi(o,s):o.dispatchEvent(s)}var Vg=(e,t,n=0)=>{const r=Math.abs(e.x),o=Math.abs(e.y),s=r>o;return t==="left"||t==="right"?s&&r>n:!s&&o>n};function EI(e=()=>{}){const t=gt(e);kt(()=>{let n=0,r=0;return n=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(r)}},[t])}function II(e){return e.nodeType===e.ELEMENT_NODE}function NI(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function Zl(e){const t=document.activeElement;return e.some(n=>n===t?!0:(n.focus(),document.activeElement!==t))}var AI=Rg,Kg=Og,qg=Lg,Gg=$g,Yg=Fg,Xg=zg,Jg=Jl;const jI=AI,Zg=h.forwardRef(({className:e,...t},n)=>u.jsx(Kg,{ref:n,className:ne("fixed bottom-0 right-0 z-[100] flex max-h-screen w-full flex-col p-4 md:max-w-[420px]",e),...t}));Zg.displayName=Kg.displayName;const PI=Ur.cva("group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",{variants:{variant:{default:"border bg-background text-foreground",destructive:"destructive group border-destructive bg-destructive text-destructive-foreground"}},defaultVariants:{variant:"default"}}),Qg=h.forwardRef(({className:e,variant:t,...n},r)=>u.jsx(qg,{ref:r,className:ne(PI({variant:t}),e),...n}));Qg.displayName=qg.displayName;const _I=h.forwardRef(({className:e,...t},n)=>u.jsx(Xg,{ref:n,className:ne("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",e),...t}));_I.displayName=Xg.displayName;const ex=h.forwardRef(({className:e,...t},n)=>u.jsx(Jg,{ref:n,className:ne("absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",e),"toast-close":"",...t,children:u.jsx(le.X,{className:"h-4 w-4"})}));ex.displayName=Jg.displayName;const tx=h.forwardRef(({className:e,...t},n)=>u.jsx(Gg,{ref:n,className:ne("text-sm font-semibold",e),...t}));tx.displayName=Gg.displayName;const nx=h.forwardRef(({className:e,...t},n)=>u.jsx(Yg,{ref:n,className:ne("text-sm opacity-90",e),...t}));nx.displayName=Yg.displayName;function RI(){const{toasts:e}=al();return u.jsxs(jI,{children:[e.map(function({id:t,title:n,description:r,action:o,...s}){return u.jsxs(Qg,{...s,children:[u.jsxs("div",{className:"grid gap-1",children:[n&&u.jsx(tx,{children:n}),r&&u.jsx(nx,{children:r})]}),o,u.jsx(ex,{})]},t)}),u.jsx(Zg,{})]})}var MI=(e,t,n,r,o,s,i,a)=>{let l=document.documentElement,c=["light","dark"];function d(p){(Array.isArray(e)?e:[e]).forEach(v=>{let g=v==="class",x=g&&s?o.map(y=>s[y]||y):o;g?(l.classList.remove(...x),l.classList.add(s&&s[p]?s[p]:p)):l.setAttribute(v,p)}),f(p)}function f(p){a&&c.includes(p)&&(l.style.colorScheme=p)}function m(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(r)d(r);else try{let p=localStorage.getItem(t)||n,v=i&&p==="system"?m():p;d(v)}catch{}},OI=h.createContext(void 0),DI={setTheme:e=>{},themes:[]},LI=()=>{var e;return(e=h.useContext(OI))!=null?e:DI};h.memo(({forcedTheme:e,storageKey:t,attribute:n,enableSystem:r,enableColorScheme:o,defaultTheme:s,value:i,themes:a,nonce:l,scriptProps:c})=>{let d=JSON.stringify([n,t,s,e,a,i,r,o]).slice(1,-1);return h.createElement("script",{...c,suppressHydrationWarning:!0,nonce:typeof window>"u"?l:"",dangerouslySetInnerHTML:{__html:`(${MI.toString()})(${d})`}})});var $I=e=>{switch(e){case"success":return zI;case"info":return UI;case"warning":return HI;case"error":return WI;default:return null}},FI=Array(12).fill(0),BI=({visible:e,className:t})=>w.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},w.createElement("div",{className:"sonner-spinner"},FI.map((n,r)=>w.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),zI=w.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},w.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),HI=w.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},w.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),UI=w.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},w.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),WI=w.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},w.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),VI=w.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},w.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),w.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),KI=()=>{let[e,t]=w.useState(document.hidden);return w.useEffect(()=>{let n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e},Ql=1,qI=class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{let t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{var t;let{message:n,...r}=e,o=typeof(e==null?void 0:e.id)=="number"||((t=e.id)==null?void 0:t.length)>0?e.id:Ql++,s=this.toasts.find(a=>a.id===o),i=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(o)&&this.dismissedToasts.delete(o),s?this.toasts=this.toasts.map(a=>a.id===o?(this.publish({...a,...e,id:o,title:n}),{...a,...e,id:o,dismissible:i,title:n}):a):this.addToast({title:n,...r,dismissible:i,id:o}),o},this.dismiss=e=>(this.dismissedToasts.add(e),e||this.toasts.forEach(t=>{this.subscribers.forEach(n=>n({id:t.id,dismiss:!0}))}),this.subscribers.forEach(t=>t({id:e,dismiss:!0})),e),this.message=(e,t)=>this.create({...t,message:e}),this.error=(e,t)=>this.create({...t,message:e,type:"error"}),this.success=(e,t)=>this.create({...t,type:"success",message:e}),this.info=(e,t)=>this.create({...t,type:"info",message:e}),this.warning=(e,t)=>this.create({...t,type:"warning",message:e}),this.loading=(e,t)=>this.create({...t,type:"loading",message:e}),this.promise=(e,t)=>{if(!t)return;let n;t.loading!==void 0&&(n=this.create({...t,promise:e,type:"loading",message:t.loading,description:typeof t.description!="function"?t.description:void 0}));let r=e instanceof Promise?e:e(),o=n!==void 0,s,i=r.then(async l=>{if(s=["resolve",l],w.isValidElement(l))o=!1,this.create({id:n,type:"default",message:l});else if(YI(l)&&!l.ok){o=!1;let c=typeof t.error=="function"?await t.error(`HTTP error! status: ${l.status}`):t.error,d=typeof t.description=="function"?await t.description(`HTTP error! status: ${l.status}`):t.description;this.create({id:n,type:"error",message:c,description:d})}else if(t.success!==void 0){o=!1;let c=typeof t.success=="function"?await t.success(l):t.success,d=typeof t.description=="function"?await t.description(l):t.description;this.create({id:n,type:"success",message:c,description:d})}}).catch(async l=>{if(s=["reject",l],t.error!==void 0){o=!1;let c=typeof t.error=="function"?await t.error(l):t.error,d=typeof t.description=="function"?await t.description(l):t.description;this.create({id:n,type:"error",message:c,description:d})}}).finally(()=>{var l;o&&(this.dismiss(n),n=void 0),(l=t.finally)==null||l.call(t)}),a=()=>new Promise((l,c)=>i.then(()=>s[0]==="reject"?c(s[1]):l(s[1])).catch(c));return typeof n!="string"&&typeof n!="number"?{unwrap:a}:Object.assign(n,{unwrap:a})},this.custom=(e,t)=>{let n=(t==null?void 0:t.id)||Ql++;return this.create({jsx:e(n),id:n,...t}),n},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},Vt=new qI,GI=(e,t)=>{let n=(t==null?void 0:t.id)||Ql++;return Vt.addToast({title:e,...t,id:n}),n},YI=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",XI=GI,JI=()=>Vt.toasts,ZI=()=>Vt.getActiveToasts();Object.assign(XI,{success:Vt.success,info:Vt.info,warning:Vt.warning,error:Vt.error,custom:Vt.custom,message:Vt.message,promise:Vt.promise,dismiss:Vt.dismiss,loading:Vt.loading},{getHistory:JI,getToasts:ZI});function QI(e,{insertAt:t}={}){if(typeof document>"u")return;let n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t==="top"&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}QI(`:where(html[dir="ltr"]),:where([data-sonner-toaster][dir="ltr"]){--toast-icon-margin-start: -3px;--toast-icon-margin-end: 4px;--toast-svg-margin-start: -1px;--toast-svg-margin-end: 0px;--toast-button-margin-start: auto;--toast-button-margin-end: 0;--toast-close-button-start: 0;--toast-close-button-end: unset;--toast-close-button-transform: translate(-35%, -35%)}:where(html[dir="rtl"]),:where([data-sonner-toaster][dir="rtl"]){--toast-icon-margin-start: 4px;--toast-icon-margin-end: -3px;--toast-svg-margin-start: 0px;--toast-svg-margin-end: -1px;--toast-button-margin-start: 0;--toast-button-margin-end: auto;--toast-close-button-start: unset;--toast-close-button-end: 0;--toast-close-button-transform: translate(35%, -35%)}:where([data-sonner-toaster]){position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1: hsl(0, 0%, 99%);--gray2: hsl(0, 0%, 97.3%);--gray3: hsl(0, 0%, 95.1%);--gray4: hsl(0, 0%, 93%);--gray5: hsl(0, 0%, 90.9%);--gray6: hsl(0, 0%, 88.7%);--gray7: hsl(0, 0%, 85.8%);--gray8: hsl(0, 0%, 78%);--gray9: hsl(0, 0%, 56.1%);--gray10: hsl(0, 0%, 52.3%);--gray11: hsl(0, 0%, 43.5%);--gray12: hsl(0, 0%, 9%);--border-radius: 8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:none;z-index:999999999;transition:transform .4s ease}:where([data-sonner-toaster][data-lifted="true"]){transform:translateY(-10px)}@media (hover: none) and (pointer: coarse){:where([data-sonner-toaster][data-lifted="true"]){transform:none}}:where([data-sonner-toaster][data-x-position="right"]){right:var(--offset-right)}:where([data-sonner-toaster][data-x-position="left"]){left:var(--offset-left)}:where([data-sonner-toaster][data-x-position="center"]){left:50%;transform:translate(-50%)}:where([data-sonner-toaster][data-y-position="top"]){top:var(--offset-top)}:where([data-sonner-toaster][data-y-position="bottom"]){bottom:var(--offset-bottom)}:where([data-sonner-toast]){--y: translateY(100%);--lift-amount: calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);filter:blur(0);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none;overflow-wrap:anywhere}:where([data-sonner-toast][data-styled="true"]){padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}:where([data-sonner-toast]:focus-visible){box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast][data-y-position="top"]){top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}:where([data-sonner-toast][data-y-position="bottom"]){bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}:where([data-sonner-toast]) :where([data-description]){font-weight:400;line-height:1.4;color:inherit}:where([data-sonner-toast]) :where([data-title]){font-weight:500;line-height:1.5;color:inherit}:where([data-sonner-toast]) :where([data-icon]){display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}:where([data-sonner-toast][data-promise="true"]) :where([data-icon])>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}:where([data-sonner-toast]) :where([data-icon])>*{flex-shrink:0}:where([data-sonner-toast]) :where([data-icon]) svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}:where([data-sonner-toast]) :where([data-content]){display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;cursor:pointer;outline:none;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}:where([data-sonner-toast]) :where([data-button]):focus-visible{box-shadow:0 0 0 2px #0006}:where([data-sonner-toast]) :where([data-button]):first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}:where([data-sonner-toast]) :where([data-cancel]){color:var(--normal-text);background:rgba(0,0,0,.08)}:where([data-sonner-toast][data-theme="dark"]) :where([data-cancel]){background:rgba(255,255,255,.3)}:where([data-sonner-toast]) :where([data-close-button]){position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast] [data-close-button]{background:var(--gray1)}:where([data-sonner-toast]) :where([data-close-button]):focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast]) :where([data-disabled="true"]){cursor:not-allowed}:where([data-sonner-toast]):hover :where([data-close-button]):hover{background:var(--gray2);border-color:var(--gray5)}:where([data-sonner-toast][data-swiping="true"]):before{content:"";position:absolute;left:-50%;right:-50%;height:100%;z-index:-1}:where([data-sonner-toast][data-y-position="top"][data-swiping="true"]):before{bottom:50%;transform:scaleY(3) translateY(50%)}:where([data-sonner-toast][data-y-position="bottom"][data-swiping="true"]):before{top:50%;transform:scaleY(3) translateY(-50%)}:where([data-sonner-toast][data-swiping="false"][data-removed="true"]):before{content:"";position:absolute;inset:0;transform:scaleY(2)}:where([data-sonner-toast]):after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}:where([data-sonner-toast][data-mounted="true"]){--y: translateY(0);opacity:1}:where([data-sonner-toast][data-expanded="false"][data-front="false"]){--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}:where([data-sonner-toast])>*{transition:opacity .4s}:where([data-sonner-toast][data-expanded="false"][data-front="false"][data-styled="true"])>*{opacity:0}:where([data-sonner-toast][data-visible="false"]){opacity:0;pointer-events:none}:where([data-sonner-toast][data-mounted="true"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}:where([data-sonner-toast][data-removed="true"][data-front="true"][data-swipe-out="false"]){--y: translateY(calc(var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="false"]){--y: translateY(40%);opacity:0;transition:transform .5s,opacity .2s}:where([data-sonner-toast][data-removed="true"][data-front="false"]):before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y, 0px)) translate(var(--swipe-amount-x, 0px));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width: 600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-theme=light]{--normal-bg: #fff;--normal-border: var(--gray4);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--info-bg: hsl(208, 100%, 97%);--info-border: hsl(221, 91%, 91%);--info-text: hsl(210, 92%, 45%);--warning-bg: hsl(49, 100%, 97%);--warning-border: hsl(49, 91%, 91%);--warning-text: hsl(31, 92%, 45%);--error-bg: hsl(359, 100%, 97%);--error-border: hsl(359, 100%, 94%);--error-text: hsl(360, 100%, 45%)}[data-sonner-toaster][data-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-theme=dark]{--normal-bg: #000;--normal-bg-hover: hsl(0, 0%, 12%);--normal-border: hsl(0, 0%, 20%);--normal-border-hover: hsl(0, 0%, 25%);--normal-text: var(--gray1);--success-bg: hsl(150, 100%, 6%);--success-border: hsl(147, 100%, 12%);--success-text: hsl(150, 86%, 65%);--info-bg: hsl(215, 100%, 6%);--info-border: hsl(223, 100%, 12%);--info-text: hsl(216, 87%, 65%);--warning-bg: hsl(64, 100%, 6%);--warning-border: hsl(60, 100%, 12%);--warning-text: hsl(46, 87%, 65%);--error-bg: hsl(358, 76%, 10%);--error-border: hsl(357, 89%, 16%);--error-text: hsl(358, 100%, 81%)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success],[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info],[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning],[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error],[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size: 16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:nth-child(1){animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}
131
131
  `);function vi(e){return e.label!==void 0}var eN=3,tN="32px",nN="16px",rx=4e3,rN=356,oN=14,sN=20,iN=200;function gn(...e){return e.filter(Boolean).join(" ")}function aN(e){let[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}var lN=e=>{var t,n,r,o,s,i,a,l,c,d,f;let{invert:m,toast:p,unstyled:v,interacting:g,setHeights:x,visibleToasts:y,heights:b,index:C,toasts:k,expanded:S,removeToast:T,defaultRichColors:E,closeButton:A,style:R,cancelButtonStyle:L,actionButtonStyle:F,className:K="",descriptionClassName:J="",duration:P,position:Y,gap:q,loadingIcon:W,expandByDefault:D,classNames:I,icons:G,closeButtonAriaLabel:X="Close toast",pauseWhenPageIsHidden:M}=e,[B,_]=w.useState(null),[$,z]=w.useState(null),[O,j]=w.useState(!1),[U,Q]=w.useState(!1),[se,ie]=w.useState(!1),[Se,xe]=w.useState(!1),[Re,Ve]=w.useState(!1),[De,Ge]=w.useState(0),[He,ot]=w.useState(0),ut=w.useRef(p.duration||P||rx),nt=w.useRef(null),Le=w.useRef(null),Ke=C===0,$e=C+1<=y,Te=p.type,Ae=p.dismissible!==!1,dt=p.className||"",Et=p.descriptionClassName||"",at=w.useMemo(()=>b.findIndex(fe=>fe.toastId===p.id)||0,[b,p.id]),It=w.useMemo(()=>{var fe;return(fe=p.closeButton)!=null?fe:A},[p.closeButton,A]),bt=w.useMemo(()=>p.duration||P||rx,[p.duration,P]),ft=w.useRef(0),Nt=w.useRef(0),At=w.useRef(0),Ct=w.useRef(null),[on,Tt]=Y.split("-"),Ie=w.useMemo(()=>b.reduce((fe,ke,Fe)=>Fe>=at?fe:fe+ke.height,0),[b,at]),Ue=KI(),jt=p.invert||m,te=Te==="loading";Nt.current=w.useMemo(()=>at*q+Ie,[at,Ie]),w.useEffect(()=>{ut.current=bt},[bt]),w.useEffect(()=>{j(!0)},[]),w.useEffect(()=>{let fe=Le.current;if(fe){let ke=fe.getBoundingClientRect().height;return ot(ke),x(Fe=>[{toastId:p.id,height:ke,position:p.position},...Fe]),()=>x(Fe=>Fe.filter(ht=>ht.toastId!==p.id))}},[x,p.id]),w.useLayoutEffect(()=>{if(!O)return;let fe=Le.current,ke=fe.style.height;fe.style.height="auto";let Fe=fe.getBoundingClientRect().height;fe.style.height=ke,ot(Fe),x(ht=>ht.find(pt=>pt.toastId===p.id)?ht.map(pt=>pt.toastId===p.id?{...pt,height:Fe}:pt):[{toastId:p.id,height:Fe,position:p.position},...ht])},[O,p.title,p.description,x,p.id]);let ge=w.useCallback(()=>{Q(!0),Ge(Nt.current),x(fe=>fe.filter(ke=>ke.toastId!==p.id)),setTimeout(()=>{T(p)},iN)},[p,T,x,Nt]);w.useEffect(()=>{if(p.promise&&Te==="loading"||p.duration===1/0||p.type==="loading")return;let fe;return S||g||M&&Ue?(()=>{if(At.current<ft.current){let ke=new Date().getTime()-ft.current;ut.current=ut.current-ke}At.current=new Date().getTime()})():ut.current!==1/0&&(ft.current=new Date().getTime(),fe=setTimeout(()=>{var ke;(ke=p.onAutoClose)==null||ke.call(p,p),ge()},ut.current)),()=>clearTimeout(fe)},[S,g,p,Te,M,Ue,ge]),w.useEffect(()=>{p.delete&&ge()},[ge,p.delete]);function rt(){var fe,ke,Fe;return G!=null&&G.loading?w.createElement("div",{className:gn(I==null?void 0:I.loader,(fe=p==null?void 0:p.classNames)==null?void 0:fe.loader,"sonner-loader"),"data-visible":Te==="loading"},G.loading):W?w.createElement("div",{className:gn(I==null?void 0:I.loader,(ke=p==null?void 0:p.classNames)==null?void 0:ke.loader,"sonner-loader"),"data-visible":Te==="loading"},W):w.createElement(BI,{className:gn(I==null?void 0:I.loader,(Fe=p==null?void 0:p.classNames)==null?void 0:Fe.loader),visible:Te==="loading"})}return w.createElement("li",{tabIndex:0,ref:Le,className:gn(K,dt,I==null?void 0:I.toast,(t=p==null?void 0:p.classNames)==null?void 0:t.toast,I==null?void 0:I.default,I==null?void 0:I[Te],(n=p==null?void 0:p.classNames)==null?void 0:n[Te]),"data-sonner-toast":"","data-rich-colors":(r=p.richColors)!=null?r:E,"data-styled":!(p.jsx||p.unstyled||v),"data-mounted":O,"data-promise":!!p.promise,"data-swiped":Re,"data-removed":U,"data-visible":$e,"data-y-position":on,"data-x-position":Tt,"data-index":C,"data-front":Ke,"data-swiping":se,"data-dismissible":Ae,"data-type":Te,"data-invert":jt,"data-swipe-out":Se,"data-swipe-direction":$,"data-expanded":!!(S||D&&O),style:{"--index":C,"--toasts-before":C,"--z-index":k.length-C,"--offset":`${U?De:Nt.current}px`,"--initial-height":D?"auto":`${He}px`,...R,...p.style},onDragEnd:()=>{ie(!1),_(null),Ct.current=null},onPointerDown:fe=>{te||!Ae||(nt.current=new Date,Ge(Nt.current),fe.target.setPointerCapture(fe.pointerId),fe.target.tagName!=="BUTTON"&&(ie(!0),Ct.current={x:fe.clientX,y:fe.clientY}))},onPointerUp:()=>{var fe,ke,Fe,ht;if(Se||!Ae)return;Ct.current=null;let pt=Number(((fe=Le.current)==null?void 0:fe.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),je=Number(((ke=Le.current)==null?void 0:ke.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Ye=new Date().getTime()-((Fe=nt.current)==null?void 0:Fe.getTime()),we=B==="x"?pt:je,Qe=Math.abs(we)/Ye;if(Math.abs(we)>=sN||Qe>.11){Ge(Nt.current),(ht=p.onDismiss)==null||ht.call(p,p),z(B==="x"?pt>0?"right":"left":je>0?"down":"up"),ge(),xe(!0),Ve(!1);return}ie(!1),_(null)},onPointerMove:fe=>{var ke,Fe,ht,pt;if(!Ct.current||!Ae||((ke=window.getSelection())==null?void 0:ke.toString().length)>0)return;let je=fe.clientY-Ct.current.y,Ye=fe.clientX-Ct.current.x,we=(Fe=e.swipeDirections)!=null?Fe:aN(Y);!B&&(Math.abs(Ye)>1||Math.abs(je)>1)&&_(Math.abs(Ye)>Math.abs(je)?"x":"y");let Qe={x:0,y:0};B==="y"?(we.includes("top")||we.includes("bottom"))&&(we.includes("top")&&je<0||we.includes("bottom")&&je>0)&&(Qe.y=je):B==="x"&&(we.includes("left")||we.includes("right"))&&(we.includes("left")&&Ye<0||we.includes("right")&&Ye>0)&&(Qe.x=Ye),(Math.abs(Qe.x)>0||Math.abs(Qe.y)>0)&&Ve(!0),(ht=Le.current)==null||ht.style.setProperty("--swipe-amount-x",`${Qe.x}px`),(pt=Le.current)==null||pt.style.setProperty("--swipe-amount-y",`${Qe.y}px`)}},It&&!p.jsx?w.createElement("button",{"aria-label":X,"data-disabled":te,"data-close-button":!0,onClick:te||!Ae?()=>{}:()=>{var fe;ge(),(fe=p.onDismiss)==null||fe.call(p,p)},className:gn(I==null?void 0:I.closeButton,(o=p==null?void 0:p.classNames)==null?void 0:o.closeButton)},(s=G==null?void 0:G.close)!=null?s:VI):null,p.jsx||w.isValidElement(p.title)?p.jsx?p.jsx:typeof p.title=="function"?p.title():p.title:w.createElement(w.Fragment,null,Te||p.icon||p.promise?w.createElement("div",{"data-icon":"",className:gn(I==null?void 0:I.icon,(i=p==null?void 0:p.classNames)==null?void 0:i.icon)},p.promise||p.type==="loading"&&!p.icon?p.icon||rt():null,p.type!=="loading"?p.icon||(G==null?void 0:G[Te])||$I(Te):null):null,w.createElement("div",{"data-content":"",className:gn(I==null?void 0:I.content,(a=p==null?void 0:p.classNames)==null?void 0:a.content)},w.createElement("div",{"data-title":"",className:gn(I==null?void 0:I.title,(l=p==null?void 0:p.classNames)==null?void 0:l.title)},typeof p.title=="function"?p.title():p.title),p.description?w.createElement("div",{"data-description":"",className:gn(J,Et,I==null?void 0:I.description,(c=p==null?void 0:p.classNames)==null?void 0:c.description)},typeof p.description=="function"?p.description():p.description):null),w.isValidElement(p.cancel)?p.cancel:p.cancel&&vi(p.cancel)?w.createElement("button",{"data-button":!0,"data-cancel":!0,style:p.cancelButtonStyle||L,onClick:fe=>{var ke,Fe;vi(p.cancel)&&Ae&&((Fe=(ke=p.cancel).onClick)==null||Fe.call(ke,fe),ge())},className:gn(I==null?void 0:I.cancelButton,(d=p==null?void 0:p.classNames)==null?void 0:d.cancelButton)},p.cancel.label):null,w.isValidElement(p.action)?p.action:p.action&&vi(p.action)?w.createElement("button",{"data-button":!0,"data-action":!0,style:p.actionButtonStyle||F,onClick:fe=>{var ke,Fe;vi(p.action)&&((Fe=(ke=p.action).onClick)==null||Fe.call(ke,fe),!fe.defaultPrevented&&ge())},className:gn(I==null?void 0:I.actionButton,(f=p==null?void 0:p.classNames)==null?void 0:f.actionButton)},p.action.label):null))};function ox(){if(typeof window>"u"||typeof document>"u")return"ltr";let e=document.documentElement.getAttribute("dir");return e==="auto"||!e?window.getComputedStyle(document.documentElement).direction:e}function cN(e,t){let n={};return[e,t].forEach((r,o)=>{let s=o===1,i=s?"--mobile-offset":"--offset",a=s?nN:tN;function l(c){["top","right","bottom","left"].forEach(d=>{n[`${i}-${d}`]=typeof c=="number"?`${c}px`:c})}typeof r=="number"||typeof r=="string"?l(r):typeof r=="object"?["top","right","bottom","left"].forEach(c=>{r[c]===void 0?n[`${i}-${c}`]=a:n[`${i}-${c}`]=typeof r[c]=="number"?`${r[c]}px`:r[c]}):l(a)}),n}var uN=w.forwardRef(function(e,t){let{invert:n,position:r="bottom-right",hotkey:o=["altKey","KeyT"],expand:s,closeButton:i,className:a,offset:l,mobileOffset:c,theme:d="light",richColors:f,duration:m,style:p,visibleToasts:v=eN,toastOptions:g,dir:x=ox(),gap:y=oN,loadingIcon:b,icons:C,containerAriaLabel:k="Notifications",pauseWhenPageIsHidden:S}=e,[T,E]=w.useState([]),A=w.useMemo(()=>Array.from(new Set([r].concat(T.filter(M=>M.position).map(M=>M.position)))),[T,r]),[R,L]=w.useState([]),[F,K]=w.useState(!1),[J,P]=w.useState(!1),[Y,q]=w.useState(d!=="system"?d:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),W=w.useRef(null),D=o.join("+").replace(/Key/g,"").replace(/Digit/g,""),I=w.useRef(null),G=w.useRef(!1),X=w.useCallback(M=>{E(B=>{var _;return(_=B.find($=>$.id===M.id))!=null&&_.delete||Vt.dismiss(M.id),B.filter(({id:$})=>$!==M.id)})},[]);return w.useEffect(()=>Vt.subscribe(M=>{if(M.dismiss){E(B=>B.map(_=>_.id===M.id?{..._,delete:!0}:_));return}setTimeout(()=>{Do.flushSync(()=>{E(B=>{let _=B.findIndex($=>$.id===M.id);return _!==-1?[...B.slice(0,_),{...B[_],...M},...B.slice(_+1)]:[M,...B]})})})}),[]),w.useEffect(()=>{if(d!=="system"){q(d);return}if(d==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?q("dark"):q("light")),typeof window>"u")return;let M=window.matchMedia("(prefers-color-scheme: dark)");try{M.addEventListener("change",({matches:B})=>{q(B?"dark":"light")})}catch{M.addListener(({matches:_})=>{try{q(_?"dark":"light")}catch($){console.error($)}})}},[d]),w.useEffect(()=>{T.length<=1&&K(!1)},[T]),w.useEffect(()=>{let M=B=>{var _,$;o.every(z=>B[z]||B.code===z)&&(K(!0),(_=W.current)==null||_.focus()),B.code==="Escape"&&(document.activeElement===W.current||($=W.current)!=null&&$.contains(document.activeElement))&&K(!1)};return document.addEventListener("keydown",M),()=>document.removeEventListener("keydown",M)},[o]),w.useEffect(()=>{if(W.current)return()=>{I.current&&(I.current.focus({preventScroll:!0}),I.current=null,G.current=!1)}},[W.current]),w.createElement("section",{ref:t,"aria-label":`${k} ${D}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},A.map((M,B)=>{var _;let[$,z]=M.split("-");return T.length?w.createElement("ol",{key:M,dir:x==="auto"?ox():x,tabIndex:-1,ref:W,className:a,"data-sonner-toaster":!0,"data-theme":Y,"data-y-position":$,"data-lifted":F&&T.length>1&&!s,"data-x-position":z,style:{"--front-toast-height":`${((_=R[0])==null?void 0:_.height)||0}px`,"--width":`${rN}px`,"--gap":`${y}px`,...p,...cN(l,c)},onBlur:O=>{G.current&&!O.currentTarget.contains(O.relatedTarget)&&(G.current=!1,I.current&&(I.current.focus({preventScroll:!0}),I.current=null))},onFocus:O=>{O.target instanceof HTMLElement&&O.target.dataset.dismissible==="false"||G.current||(G.current=!0,I.current=O.relatedTarget)},onMouseEnter:()=>K(!0),onMouseMove:()=>K(!0),onMouseLeave:()=>{J||K(!1)},onDragEnd:()=>K(!1),onPointerDown:O=>{O.target instanceof HTMLElement&&O.target.dataset.dismissible==="false"||P(!0)},onPointerUp:()=>P(!1)},T.filter(O=>!O.position&&B===0||O.position===M).map((O,j)=>{var U,Q;return w.createElement(lN,{key:O.id,icons:C,index:j,toast:O,defaultRichColors:f,duration:(U=g==null?void 0:g.duration)!=null?U:m,className:g==null?void 0:g.className,descriptionClassName:g==null?void 0:g.descriptionClassName,invert:n,visibleToasts:v,closeButton:(Q=g==null?void 0:g.closeButton)!=null?Q:i,interacting:J,position:M,style:g==null?void 0:g.style,unstyled:g==null?void 0:g.unstyled,classNames:g==null?void 0:g.classNames,cancelButtonStyle:g==null?void 0:g.cancelButtonStyle,actionButtonStyle:g==null?void 0:g.actionButtonStyle,removeToast:X,toasts:T.filter(se=>se.position==O.position),heights:R.filter(se=>se.position==O.position),setHeights:L,expandByDefault:s,gap:y,loadingIcon:b,expanded:F,pauseWhenPageIsHidden:S,swipeDirections:e.swipeDirections})})):null}))});const dN=({...e})=>{const{theme:t="system"}=LI();return u.jsx(uN,{theme:t,className:"toaster group",toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground"}},...e})};H.Api=qv,H.ApiClient=Kv,H.ApiProvider=iu,H.ArtifactRenderer=Nh,H.Badge=$h,H.Button=Je,H.Card=ul,H.CardContent=Qs,H.CardDescription=pl,H.CardHeader=dl,H.CardTitle=fl,H.ChatApi=Xo,H.ChatApp=Vk,H.ChatInput=Gf,H.ChatInputRow=Yf,H.ChatInterface=Dr,H.ChatProviders=yr,H.ChatWidget=Gk,H.Command=Tl,H.CommandEmpty=Il,H.CommandGroup=Nl,H.CommandInput=kl,H.CommandItem=Al,H.CommandList=El,H.DEFAULT_TIMEOUT_MS=eu,H.Dialog=ol,H.DialogContent=Us,H.DialogHeader=Ws,H.DialogTitle=Vs,H.DropdownMenu=ks,H.DropdownMenuContent=go,H.DropdownMenuItem=Fn,H.DropdownMenuTrigger=Es,H.FileViewerModal=ph,H.HISTORY_TIMEOUT_MS=tu,H.Input=Dl,H.InterruptPartRenderer=hl,H.Label=vm,H.MarkdownContent=cr,H.MessageComponent=ei,H.MessageList=xl,H.MessageRow=gl,H.NewChatButton=Yk,H.PlotArtifact=Ih,H.SETTINGS_STORAGE_KEY=Ui,H.ScrollArea=Ol,H.Select=NE,H.SelectContent=sg,H.SelectItem=ig,H.SelectTrigger=ng,H.SelectValue=AE,H.Separator=ug,H.Sheet=BE,H.SheetContent=wg,H.SheetDescription=Sg,H.SheetHeader=bg,H.SheetTitle=yg,H.SheetTrigger=zE,H.SimpleChat=Kk,H.SimpleJsonView=Zs,H.Sonner=dN,H.StreamProgress=Ah,H.Switch=xg,H.Textarea=Aa,H.ThinkingIndicator=Ph,H.ThreadListItem=fm,H.ThreadManager=ii,H.ThreadStateProvider=ju,H.ThreadsProvider=xu,H.TimelineColumn=Cx,H.Toaster=RI,H.ToolComponent=Dh,H.Tooltip=uI,H.TooltipContent=Pg,H.TooltipProvider=cI,H.TooltipTrigger=dI,H.UserTextContent=_h,H.applySettings=Nw,H.buildCheckpointIndex=rc,H.buildCheckpointPreviewMap=dx,H.chatApiClient=Nn,H.del=Oi,H.downloadFileById=ru,H.extractConfigFields=yi,H.fileToBase64=au,H.get=Yt,H.getChatToken=Zc,H.getCheckpointForMessage=fx,H.getCurrentSettings=Iw,H.getDefaultApiConfig=Fu,H.getDefaultChatSettings=Bu,H.getFileContent=Li,H.getFileInfo=Yv,H.getMessageAttemptInfo=oc,H.getMessageDomKey=ml,H.getPreviewForMessage=bi,H.httpClient=Gt,H.hydrateHistorySnapshots=Yn,H.isEnvelope=cu,H.listFiles=ou,H.loadStoredSettings=zu,H.onChatTokenChanged=Qc,H.post=Yo,H.processAttachments=lu,H.put=nu,H.readNumber=ic,H.readString=Rn,H.resolveChatBaseUrl=vn,H.saveSettings=Hu,H.setChatToken=Go,H.toPlainObject=_n,H.unwrap=Dt,H.useApi=Qr,H.useCheckpointIndex=sc,H.useFilePreview=Rh,H.useHasChatSession=Tw,H.useParsedMessageContent=Mh,H.useShallowStableValue=Ou,H.useStream=Hi,H.useStreamingHook=Hi,H.useThreadHistoryState=Eu,H.useThreadManagerViewState=mm,H.useThreadState=ro,H.useThreadStateUpdater=Au,H.useThreads=vr,H.useThreadsState=mu,H.viewFileById=Gv,Object.defineProperty(H,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "teodor-new-chat-ui",
3
- "version": "4.3.498",
3
+ "version": "4.3.499",
4
4
  "description": "React chat UI components with streaming support, tool calls, and modern design",
5
5
  "main": "dist/index.umd.js",
6
6
  "module": "dist/index.esm.js",