teodor-new-chat-ui 4.3.477 → 4.3.478

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.umd.js CHANGED
@@ -126,6 +126,6 @@ ${t}</tr>
126
126
  `}strong(t){return`<strong>${t}</strong>`}em(t){return`<em>${t}</em>`}codespan(t){return`<code>${t}</code>`}br(){return this.options.xhtml?"<br/>":"<br>"}del(t){return`<del>${t}</del>`}link(t,n,r){if(t=gh(this.options.sanitize,this.options.baseUrl,t),t===null)return r;let o='<a href="'+t+'"';return n&&(o+=' title="'+n+'"'),o+=">"+r+"</a>",o}image(t,n,r){if(t=gh(this.options.sanitize,this.options.baseUrl,t),t===null)return r;let o=`<img src="${t}" alt="${r}"`;return n&&(o+=` title="${n}"`),o+=this.options.xhtml?"/>":">",o}text(t){return t}}class yh{strong(t){return t}em(t){return t}codespan(t){return t}del(t){return t}html(t){return t}text(t){return t}link(t,n,r){return""+r}image(t,n,r){return""+r}br(){return""}}class Sh{constructor(){this.seen={}}serialize(t){return t.toLowerCase().trim().replace(/<[!\/a-z].*?>/ig,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-")}getNextSafeSlug(t,n){let r=t,o=0;if(this.seen.hasOwnProperty(r)){o=this.seen[t];do o++,r=t+"-"+o;while(this.seen.hasOwnProperty(r))}return n||(this.seen[t]=o,this.seen[r]=0),r}slug(t,n={}){const r=this.serialize(t);return this.getNextSafeSlug(r,n.dryrun)}}class Vn{constructor(t){this.options=t||cr,this.options.renderer=this.options.renderer||new il,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new yh,this.slugger=new Sh}static parse(t,n){return new Vn(n).parse(t)}static parseInline(t,n){return new Vn(n).parseInline(t)}parse(t,n=!0){let r="",o,s,i,a,l,c,d,f,m,p,v,g,x,y,w,S,k,C,T;const E=t.length;for(o=0;o<E;o++){if(p=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[p.type]&&(T=this.options.extensions.renderers[p.type].call({parser:this},p),T!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(p.type))){r+=T||"";continue}switch(p.type){case"space":continue;case"hr":{r+=this.renderer.hr();continue}case"heading":{r+=this.renderer.heading(this.parseInline(p.tokens),p.depth,mh(this.parseInline(p.tokens,this.textRenderer)),this.slugger);continue}case"code":{r+=this.renderer.code(p.text,p.lang,p.escaped);continue}case"table":{for(f="",d="",a=p.header.length,s=0;s<a;s++)d+=this.renderer.tablecell(this.parseInline(p.header[s].tokens),{header:!0,align:p.align[s]});for(f+=this.renderer.tablerow(d),m="",a=p.rows.length,s=0;s<a;s++){for(c=p.rows[s],d="",l=c.length,i=0;i<l;i++)d+=this.renderer.tablecell(this.parseInline(c[i].tokens),{header:!1,align:p.align[i]});m+=this.renderer.tablerow(d)}r+=this.renderer.table(f,m);continue}case"blockquote":{m=this.parse(p.tokens),r+=this.renderer.blockquote(m);continue}case"list":{for(v=p.ordered,g=p.start,x=p.loose,a=p.items.length,m="",s=0;s<a;s++)w=p.items[s],S=w.checked,k=w.task,y="",w.task&&(C=this.renderer.checkbox(S),x?w.tokens.length>0&&w.tokens[0].type==="paragraph"?(w.tokens[0].text=C+" "+w.tokens[0].text,w.tokens[0].tokens&&w.tokens[0].tokens.length>0&&w.tokens[0].tokens[0].type==="text"&&(w.tokens[0].tokens[0].text=C+" "+w.tokens[0].tokens[0].text)):w.tokens.unshift({type:"text",text:C}):y+=C),y+=this.parse(w.tokens,x),m+=this.renderer.listitem(y,k,S);r+=this.renderer.list(m,v,g);continue}case"html":{r+=this.renderer.html(p.text);continue}case"paragraph":{r+=this.renderer.paragraph(this.parseInline(p.tokens));continue}case"text":{for(m=p.tokens?this.parseInline(p.tokens):p.text;o+1<E&&t[o+1].type==="text";)p=t[++o],m+=`
127
127
  `+(p.tokens?this.parseInline(p.tokens):p.text);r+=n?this.renderer.paragraph(m):m;continue}default:{const j='Token with "'+p.type+'" type was not found.';if(this.options.silent){console.error(j);return}else throw new Error(j)}}}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 Xs{constructor(t){this.options=t||cr}preprocess(t){return t}postprocess(t){return t}}ix(Xs,"passThroughHooks",new Set(["preprocess","postprocess"]));function FT(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>"+Mt(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 Ch(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...xe.defaults,...s};const i=FT(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(DT(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&&xe.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;xe.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(xe.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&&xe.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function xe(e,t,n){return Ch(Wn.lex,Vn.parse)(e,t,n)}xe.options=xe.setOptions=function(e){return xe.defaults={...xe.defaults,...e},CT(xe.defaults),xe},xe.getDefaults=dh,xe.defaults=cr,xe.use=function(...e){const t=xe.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=xe.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=xe.defaults.renderer||new il;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=xe.defaults.tokenizer||new sl;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=xe.defaults.hooks||new Xs;for(const s in n.hooks){const i=o[s];Xs.passThroughHooks.has(s)?o[s]=a=>{if(xe.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=xe.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}}xe.setOptions(r)})},xe.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(xe,r)),r.type){case"table":{for(const o of r.header)n=n.concat(xe.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(xe.walkTokens(s.tokens,t));break}case"list":{n=n.concat(xe.walkTokens(r.items,t));break}default:xe.defaults.extensions&&xe.defaults.extensions.childTokens&&xe.defaults.extensions.childTokens[r.type]?xe.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(xe.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(xe.walkTokens(r.tokens,t)))}return n},xe.parseInline=Ch(Wn.lexInline,Vn.parseInline),xe.Parser=Vn,xe.parser=Vn.parse,xe.Renderer=il,xe.TextRenderer=yh,xe.Lexer=Wn,xe.lexer=Wn.lex,xe.Tokenizer=sl,xe.Slugger=Sh,xe.Hooks=Xs,xe.parse=xe,xe.options,xe.setOptions,xe.use,xe.walkTokens,xe.parseInline,Vn.parse,Wn.lex;function Kn({content:e,className:t="",allowHtml:n=!1,style:r}){const o=b.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 xe.parse=="function"?xe.parse(i):xe(i)}return typeof xe.parse=="function"?xe.parse(e):xe(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=b.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:oe("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 Th({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})}})})]})}const kh={completed:{label:"Completed",badgeClass:"border border-green-200 bg-green-50 text-green-700"},success:{label:"Completed",badgeClass:"border border-green-200 bg-green-50 text-green-700"},failed:{label:"Failed",badgeClass:"border border-red-200 bg-red-50 text-red-700"},error:{label:"Failed",badgeClass:"border border-red-200 bg-red-50 text-red-700"},cancelled:{label:"Cancelled",badgeClass:"border border-orange-200 bg-orange-50 text-orange-700"},cancel:{label:"Cancelled",badgeClass:"border border-orange-200 bg-orange-50 text-orange-700"},pending:{label:"Pending",badgeClass:"border border-blue-200 bg-blue-50 text-blue-700"},processing:{label:"Processing",badgeClass:"border border-yellow-200 bg-yellow-50 text-yellow-700"}},BT=e=>{if(!e)return kh.processing;const t=e.toLowerCase().trim();return kh[t]??{label:t.replace(/(^\w|\s\w)/g,n=>n.toUpperCase()),badgeClass:"border border-slate-200 bg-slate-50 text-slate-800"}},zT=e=>e?e.length>10?`${e.slice(0,8)}…`:e:"";function Eh({artifact:e}){const t=BT(e.status),n=e.task_url??e.taskUrl??"";return u.jsxs("div",{className:"rounded-lg border border-blue-200/70 bg-blue-50/40 p-4 space-y-3",children:[u.jsxs("div",{className:"flex items-start justify-between gap-3",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-full bg-blue-600/10 text-blue-600",children:u.jsx(ae.Search,{className:"h-4 w-4"})}),u.jsxs("div",{className:"space-y-1",children:[u.jsx("p",{className:"text-xs font-semibold uppercase tracking-wide text-blue-700",children:"Research Task"}),u.jsxs("p",{className:"text-[11px] text-blue-900/80",children:["Task ID: ",u.jsx("span",{className:"font-mono",children:zT(e.task_id)})]})]})]}),t&&u.jsx("span",{className:`inline-flex items-center rounded-full px-3 py-1 text-[11px] font-semibold ${t.badgeClass}`,children:t.label})]}),e.query&&u.jsxs("div",{className:"rounded border border-blue-100 bg-white/80 px-3 py-2 text-xs text-blue-900/90",children:[u.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wide text-blue-500",children:"Query"}),u.jsx("p",{className:"line-clamp-2 text-[11px] text-blue-900",children:e.query})]}),typeof e.results=="string"&&e.results.trim()&&u.jsxs("div",{className:"rounded border border-blue-100 bg-white/80 px-3 py-2 text-sm text-blue-900/90 space-y-1",children:[u.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wide text-blue-500",children:"Results"}),u.jsx(Kn,{content:e.results,allowHtml:!1,className:"prose text-xs !prose-sm prose-blue dark:prose-invert"})]}),u.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[n?u.jsxs("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 rounded-full border border-blue-600/80 bg-blue-600/10 px-3 py-1 text-xs font-semibold text-blue-700 transition hover:bg-blue-600/20",children:[u.jsx("span",{children:"Go to task"}),u.jsx(ae.ExternalLink,{className:"h-3 w-3"})]}):u.jsx("span",{className:"text-xs text-muted-foreground",children:"Task link unavailable"}),e.createdAt&&u.jsxs("p",{className:"text-[10px] text-blue-700/70",children:["Started: ",new Date(e.createdAt).toLocaleTimeString()]})]})]})}function Ih({artifact:e,idx:t=0}){const n=b.useMemo(()=>e?(Array.isArray(e.plots)?e.plots:[]).map(o=>cb(o)).filter(o=>o!==null):[],[e]);return(e==null?void 0:e.type)==="research_task_info"?u.jsx(Eh,{artifact:{type:"research_task_info",task_id:e.task_id,task_url:e.task_url,query:e.query,status:e.status,createdAt:e.createdAt}}):n.length>0?u.jsx("div",{className:"space-y-2",children:n.map((r,o)=>u.jsx(Th,{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 al=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:oe("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));al.displayName="Card";const ll=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:oe("flex flex-col space-y-1.5 p-6",e),...t}));ll.displayName="CardHeader";const cl=h.forwardRef(({className:e,...t},n)=>u.jsx("h3",{ref:n,className:oe("text-2xl font-semibold leading-none tracking-tight",e),...t}));cl.displayName="CardTitle";const ul=h.forwardRef(({className:e,...t},n)=>u.jsx("p",{ref:n,className:oe("text-sm text-muted-foreground",e),...t}));ul.displayName="CardDescription";const dl=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:oe("p-6 pt-0",e),...t}));dl.displayName="CardContent";const Nh=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:oe("flex items-center p-6 pt-0",e),...t}));Nh.displayName="CardFooter";function Ah({interruptPart:e,onApprove:t,onReject:n,disabled:r,isActive:o,payload:s}){const i=e.title??"Approve the result?";let a=null;if(s!=null)if(typeof s=="string")a=u.jsx("p",{className:"text-sm leading-relaxed text-blue-800/90 dark:text-blue-200/90 whitespace-pre-wrap",children:s});else{const c=vr(s);a=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:c})}const l=o?"Please approve or reject this action to resume the workflow.":"Waiting for approval from another participant.";return u.jsxs(al,{className:oe("border-blue-200 dark:border-blue-800 bg-blue-50/50 dark:bg-blue-950/10 transition-shadow",o?"shadow-md ring-1 ring-blue-300 dark:ring-blue-500/70":"opacity-80"),children:[u.jsxs(ll,{className:"pb-3",children:[u.jsx(cl,{className:"text-blue-900 dark:text-blue-100 text-base",children:i}),u.jsx(ul,{className:"text-blue-700 dark:text-blue-300 text-sm",children:l})]}),a&&u.jsx(dl,{className:"pt-0 pb-3",children:a}),u.jsx(Nh,{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:r||!o,children:"Reject"}),u.jsx(Je,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:r||!o,children:"Approve"})]})})]})}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 Js({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:vr(e)}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:vr(e)})}function jh({message:e,isStreaming:t=!1}){const n=e.name??"tool",r=b.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(ae.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}function _h({className:e}){const[t,n]=b.useState(0);return b.useEffect(()=>{const r=setInterval(()=>n(o=>(o+1)%4),500);return()=>clearInterval(r)},[]),u.jsxs("span",{"aria-live":"polite",className:oe("inline-block text-xs opacity-70 ml-1",e),children:["Is thinking",".".repeat(t)]})}function Ph({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:oe("text-sm text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:t?u.jsx(Kn,{content:e,allowHtml:!1}):u.jsxs("pre",{className:oe("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(ae.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):u.jsxs(u.Fragment,{children:[u.jsx(ae.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",s," chars)"]})})]})}const Rh={desirability:"from-[#ffd6e6] to-[#ffb7cf]",feasibility:"from-[#fff6ca] to-[#ffe58f]",viability:"from-[#d5f2cf] to-[#b3e7b4]",other:"from-[#dfe7ff] to-[#c4d6ff]"};function fl(e){return(e.type??"other").toLowerCase()}function UT({issues:e}){if(!e.length)return null;const t=b.useMemo(()=>{const n={};return e.forEach(r=>{const o=fl(r).toUpperCase();n[o]||(n[o]=[]),n[o].push(r)}),n},[e]);return u.jsxs("div",{className:"rounded-3xl border border-muted-foreground/30 bg-background/80 p-4 shadow-lg shadow-slate-900/5",children:[u.jsxs("div",{className:"flex items-center justify-between border-b border-muted-foreground/20 pb-2",children:[u.jsx("div",{className:"text-xs font-semibold uppercase tracking-[0.4em] text-muted-foreground",children:"Issue Sticky Notes"}),u.jsxs("div",{className:"text-xs font-semibold text-muted-foreground",children:[e.length," total"]})]}),u.jsx("div",{className:"mt-4 flex w-full flex-col gap-6",children:Object.entries(t).map(([n,r])=>u.jsxs("details",{className:"w-full rounded-2xl border border-muted-foreground/30 bg-white/80 p-4 shadow-sm shadow-slate-900/10",children:[u.jsxs("summary",{className:"cursor-pointer text-[11px] font-semibold uppercase tracking-[0.4em] text-muted-foreground",children:[n," (",r.length,")"]}),u.jsx("div",{className:"mt-3 space-y-3",children:r.map((o,s)=>{const i=o.title||o.name||`Issue ${s+1}`,a=Rh[fl(o)]?fl(o):"other";return u.jsxs("div",{className:`relative overflow-hidden rounded-2xl border border-muted-foreground/30 bg-gradient-to-br p-4 text-sm font-medium text-foreground/90 shadow-[0_20px_30px_rgba(15,23,42,0.15)] ${Rh[a]}`,children:[u.jsx("div",{className:"text-base font-semibold text-foreground",children:i}),o.description?u.jsxs("details",{className:"mt-2 rounded-xl border border-border/40 bg-background/60 p-2 text-[12px] text-foreground/80",children:[u.jsx("summary",{className:"cursor-pointer font-semibold uppercase tracking-[0.3em] text-foreground/80",children:"View description"}),u.jsx("p",{className:"mt-2 text-xs leading-5 text-foreground/80",children:o.description})]}):null]},o.id??`${n}-${s}`)})})]},n))})]})}function Mh(e){const{allowFileOpen:t,currentThreadId:n}=e,{toast:r}=ol(),[o,s]=b.useState({}),[i,a]=b.useState(null),[l,c]=b.useState(!1),d=b.useCallback(()=>{c(!1),a(null)},[]),f=b.useCallback(p=>{a(p),c(!0)},[]),m=b.useCallback(async(p,v,g)=>{var x,y;if(!t){p.preventDefault();return}if(o[g]){p.preventDefault();return}try{const w=String(v.url??""),S=w.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(S){p.preventDefault();const k=S[1],C=v.name||`file_${k}`,T=v.mimeType||"application/octet-stream";f({id:k,name:C,mimeType:T});return}if(w.startsWith("data:")){p.preventDefault(),s(C=>({...C,[g]:!0}));const k=r({title:"Fetching file...",description:"",open:!0});try{const C=await nu(n??void 0);if(!C||!Array.isArray(C))throw new Error("Invalid file list response");const T=C.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(C){console.error("Failed to fetch server file:",C);const T=C instanceof Error?C.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(C=>({...C,[g]:!1}))}}}catch(w){console.error("File click error:",w),s(S=>({...S,[g]:!1}))}},[t,o,r,n,f]);return{uploadingFiles:o,handleFileClick:m,fileViewerOpen:l,currentFileInfo:i,closeFileViewer:d}}function Oh(e,t){return b.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:rb(r),toolMeta:Di(n),imageParts:r.filter(s=>s.type==="image_url"),fileParts:r.filter(s=>s.type==="file"),interruptParts:r.filter(s=>s.type==="interrupt"),toolRaw:ob(r),isToolStreaming:!!o.toolStreaming}},[e,t])}const Dh="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(Dh))continue;const s=o.slice(Dh.length).trim();if(!s||s.toLowerCase()==="[done]")continue;const i=Qr(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 b.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
- `),d=Qr(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 Lh({message:e,viewMode:t,isStreaming:n=!1}){Di(e).name;const o=e.artifact??null,s=qT(e),i=e.content.find(f=>f.type!=="tool_call"),a=f=>{if(f==null)return null;const m=typeof f=="string"?Qr(f)??f:f;if(m&&typeof m=="object")return u.jsx(Js,{data:m});const p=typeof m=="string"?m:(()=>{try{return vr(m)}catch{return String(m??"")}})();return u.jsx("pre",{className:"whitespace-pre-wrap break-words font-sans text-sm text-foreground/90",children:p})},l=f=>{if(f==null)return null;const{content:m,isMarkdown:p}=nb(f);return p?u.jsx(Kn,{content:m,className:"text-current"}):a(f)},c=f=>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(Js,{data:f})]}),d=()=>{if((s==null?void 0:s.kind)==="generic")return l(s.value);if(!i)return null;if(i.type==="text"){const v=(i.text??"").trim();if(!v)return null;const g=br(v);return l(g)}const f=eo(i),m=br(f);return l(m)};return u.jsxs("div",{className:"space-y-2",children:[o&&u.jsx(Ih,{artifact:o,idx:0}),u.jsx(jh,{message:e,isStreaming:n}),t==="expanded"&&u.jsx(u.Fragment,{children:(s==null?void 0:s.kind)==="issues"?u.jsx(UT,{issues:s.issues}):(s==null?void 0:s.kind)==="dict"?c(s.data):d()})]})}const GT={checkpoints:[],checkpointMetaByCheckpointId:new Map,timeline:[],messagePreviews:new Map,getLatest:()=>{},getCheckpoint:()=>{},getMessageAttempts:()=>[]},pl=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,hl=b.memo(function({message:t,index:n,isStreaming:r,streamingAssistantId:o,streamingDebounceMs:s,layoutSize:i,enableMessageEditing:a,editingMessageId:l,onEdit:c,onRegenerate:d,onCancelEdit:f,activeInterrupt:m,disableInterruptActions:p,onInterruptActionStart:v,onInterruptActionEnd:g,showToolMessages:x,checkpointIndex:y,onSelectCheckpoint:w,getMessageCustomStyles:S}){const k=pl(t,n),C=t.role==="default_message",E=!!t.__syntheticStreaming,j=y??GT,_=!C&&"checkpointId"in t?t.checkpointId??null:null,{attemptCount:D,attemptIndex:B,attempts:z}=b.useMemo(()=>nc(t.id,_,j),[t.id,_,j]),Q=S==null?void 0:S(t);return u.jsx("div",{className:"relative mb-4 last:mb-0","data-message-id":k,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:u.jsx(Zs,{message:t,messageIndex:n,isStreamingMessage:E||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,activeInterrupt:m,disableInterruptActions:p,onInterruptActionStart:v,onInterruptActionEnd:g,showToolMessages:x,attemptCount:D,attemptIndex:B,attemptMetas:z,onSelectCheckpoint:w,customStyles:Q})})});hl.displayName="MessageRow";function YT(e,t,n){const[r,o]=b.useState(e),s=b.useRef([]);return b.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,interruptParts:c,isStreamingMessage:d,enableStreamingMarkdownBuffer:f,renderStreamingMarkdown:m,defaultMessage:p,handleFileClick:v,uploadingFiles:g,handleInterruptApprove:x,handleInterruptReject:y,disableInterruptActions:w,messageRole:S,truncateUserMessages:k,userMessagePreviewLength:C,isUserExpanded:T,setIsUserExpanded:E,isCompactLayout:j,activeInterruptId:_,activeInterruptValue:D,iconForeground:B}){const z=b.useCallback(()=>u.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[u.jsx(ae.Loader,{className:"h-4 w-4 text-muted-foreground"}),u.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),P=YT(s,(f??!0)&&d,$h),q=b.useMemo(()=>P.filter($=>$.type==="text"),[P]),K=b.useMemo(()=>q.map($=>$.text??"").join(""),[q]),W=b.useMemo(()=>{if(!m)return null;const $=JT(K);return{stablePart:K.slice(0,$),tailPart:K.slice($)}},[K,m]),O=b.useMemo(()=>{if(!W)return null;const{stablePart:$,tailPart:A}=W;return!$&&!A?null:u.jsxs("div",{className:"space-y-2",children:[$?u.jsx(Kn,{content:$,allowHtml:!1}):null,A?u.jsx(Kn,{content:A,allowHtml:!1}):null]})},[W]),I=b.useMemo(()=>{if(!m)return P;const $=[];let A=!1;for(const M of P){if(M.type==="text"){A||($.push({type:"text",text:"",__streamingMarkdownAggregate:!0}),A=!0);continue}$.push(M)}return $},[P,m]),U=m?I:P,Z=b.useCallback(({part:$,i:A})=>{if($.type==="text"){if(m)return null;const M=$.text??"",X=M.trim(),F=Qr(X);return F&&S!=="tool"?u.jsx(Js,{data:F},A):S==="user"&&k&&X.length>C?u.jsx(Ph,{text:X,expanded:T,onExpandedChange:E,previewLength:C,isCompact:j},A):u.jsx(Kn,{content:M,allowHtml:!1},A)}if($.type==="image_url"){const M=$;return u.jsx("div",{className:"my-2",children:u.jsx("img",{src:M.url,alt:M.alt??"",loading:"lazy",className:"border rounded max-h-[420px] w-auto object-contain"})},A)}if($.type==="file"){const M=$,X=M.name||"file";return u.jsxs("a",{href:M.url,onClick:F=>v(F,M,A),className:`inline-flex items-center gap-2 rounded px-2 py-1 text-xs bg-gray-100 border hover:bg-gray-200
129
+ `),d=Qr(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 Lh({message:e,viewMode:t,isStreaming:n=!1}){Di(e).name;const o=e.artifact??null,s=qT(e),i=e.content.find(f=>f.type!=="tool_call"),a=f=>{if(f==null)return null;const m=typeof f=="string"?Qr(f)??f:f;if(m&&typeof m=="object")return u.jsx(Js,{data:m});const p=typeof m=="string"?m:(()=>{try{return vr(m)}catch{return String(m??"")}})();return u.jsx("pre",{className:"whitespace-pre-wrap break-words font-sans text-sm text-foreground/90",children:p})},l=f=>{if(f==null)return null;const{content:m,isMarkdown:p}=nb(f);return p?u.jsx(Kn,{content:m,className:"text-current"}):a(f)},c=f=>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(Js,{data:f})]}),d=()=>{if((s==null?void 0:s.kind)==="generic")return l(s.value);if(!i)return null;if(i.type==="text"){const v=(i.text??"").trim();if(!v)return null;const g=br(v);return l(g)}const f=eo(i),m=br(f);return l(m)};return u.jsxs("div",{className:"space-y-2",children:[o&&u.jsx(Ih,{artifact:o,idx:0}),u.jsx(jh,{message:e,isStreaming:n}),t==="expanded"&&u.jsx(u.Fragment,{children:(()=>{const f=(s==null?void 0:s.kind)==="issues"?s.issues:void 0,m=(s==null?void 0:s.kind)==="dict"?s.data:void 0,p=m&&Array.isArray(m.issues)?m.issues:void 0,v=f??p;return v&&v.length>0?u.jsx(UT,{issues:v}):(s==null?void 0:s.kind)==="dict"?c(s.data):d()})()})]})}const GT={checkpoints:[],checkpointMetaByCheckpointId:new Map,timeline:[],messagePreviews:new Map,getLatest:()=>{},getCheckpoint:()=>{},getMessageAttempts:()=>[]},pl=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,hl=b.memo(function({message:t,index:n,isStreaming:r,streamingAssistantId:o,streamingDebounceMs:s,layoutSize:i,enableMessageEditing:a,editingMessageId:l,onEdit:c,onRegenerate:d,onCancelEdit:f,activeInterrupt:m,disableInterruptActions:p,onInterruptActionStart:v,onInterruptActionEnd:g,showToolMessages:x,checkpointIndex:y,onSelectCheckpoint:w,getMessageCustomStyles:S}){const k=pl(t,n),C=t.role==="default_message",E=!!t.__syntheticStreaming,j=y??GT,_=!C&&"checkpointId"in t?t.checkpointId??null:null,{attemptCount:D,attemptIndex:B,attempts:z}=b.useMemo(()=>nc(t.id,_,j),[t.id,_,j]),Q=S==null?void 0:S(t);return u.jsx("div",{className:"relative mb-4 last:mb-0","data-message-id":k,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:u.jsx(Zs,{message:t,messageIndex:n,isStreamingMessage:E||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,activeInterrupt:m,disableInterruptActions:p,onInterruptActionStart:v,onInterruptActionEnd:g,showToolMessages:x,attemptCount:D,attemptIndex:B,attemptMetas:z,onSelectCheckpoint:w,customStyles:Q})})});hl.displayName="MessageRow";function YT(e,t,n){const[r,o]=b.useState(e),s=b.useRef([]);return b.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,interruptParts:c,isStreamingMessage:d,enableStreamingMarkdownBuffer:f,renderStreamingMarkdown:m,defaultMessage:p,handleFileClick:v,uploadingFiles:g,handleInterruptApprove:x,handleInterruptReject:y,disableInterruptActions:w,messageRole:S,truncateUserMessages:k,userMessagePreviewLength:C,isUserExpanded:T,setIsUserExpanded:E,isCompactLayout:j,activeInterruptId:_,activeInterruptValue:D,iconForeground:B}){const z=b.useCallback(()=>u.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[u.jsx(ae.Loader,{className:"h-4 w-4 text-muted-foreground"}),u.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),P=YT(s,(f??!0)&&d,$h),q=b.useMemo(()=>P.filter($=>$.type==="text"),[P]),K=b.useMemo(()=>q.map($=>$.text??"").join(""),[q]),W=b.useMemo(()=>{if(!m)return null;const $=JT(K);return{stablePart:K.slice(0,$),tailPart:K.slice($)}},[K,m]),O=b.useMemo(()=>{if(!W)return null;const{stablePart:$,tailPart:A}=W;return!$&&!A?null:u.jsxs("div",{className:"space-y-2",children:[$?u.jsx(Kn,{content:$,allowHtml:!1}):null,A?u.jsx(Kn,{content:A,allowHtml:!1}):null]})},[W]),I=b.useMemo(()=>{if(!m)return P;const $=[];let A=!1;for(const M of P){if(M.type==="text"){A||($.push({type:"text",text:"",__streamingMarkdownAggregate:!0}),A=!0);continue}$.push(M)}return $},[P,m]),U=m?I:P,Z=b.useCallback(({part:$,i:A})=>{if($.type==="text"){if(m)return null;const M=$.text??"",X=M.trim(),F=Qr(X);return F&&S!=="tool"?u.jsx(Js,{data:F},A):S==="user"&&k&&X.length>C?u.jsx(Ph,{text:X,expanded:T,onExpandedChange:E,previewLength:C,isCompact:j},A):u.jsx(Kn,{content:M,allowHtml:!1},A)}if($.type==="image_url"){const M=$;return u.jsx("div",{className:"my-2",children:u.jsx("img",{src:M.url,alt:M.alt??"",loading:"lazy",className:"border rounded max-h-[420px] w-auto object-contain"})},A)}if($.type==="file"){const M=$,X=M.name||"file";return u.jsxs("a",{href:M.url,onClick:F=>v(F,M,A),className:`inline-flex items-center gap-2 rounded px-2 py-1 text-xs bg-gray-100 border hover:bg-gray-200
130
130
  dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20`,children:[g[A]?u.jsx(ae.Loader,{className:"h-4 w-4 animate-spin"}):null,u.jsxs("span",{className:"truncate max-w-[180px]",children:[X,g[A]?" (processing)":""]})]},A)}if($.type==="interrupt"){const M=$,X=Xo((M==null?void 0:M.id)??(M==null?void 0:M.interrupt_id)),F=!!(_&&X&&X===_),L=F?D??(M==null?void 0:M.value):M==null?void 0:M.value,J=X?{...M,id:X,interrupt_id:X}:M;return u.jsx(Ah,{interruptPart:J,onApprove:x,onReject:y,disabled:w,isActive:F,payload:L},A)}return null},[_,D,w,v,x,y,j,T,S,k,g,C,m,E]),R=i.trim().length>0||a.length>0||l.length>0||c.length>0;if(!t&&l.length>0&&!d)return z();if(!t&&!R&&!d)return null;if(t)return n?u.jsx(Lh,{message:e,viewMode:r,isStreaming:o},e.id):null;if(!p){const $=u.jsx("div",{className:"space-y-2",children:U.map((A,M)=>m&&ZT(A)?O?u.jsx("div",{className:"space-y-2",children:O},`streaming-md-${M}`):null:u.jsx(Z,{part:A,i:M},M))});return d?u.jsxs("div",{"aria-busy":"true",role:"status",children:[$,u.jsx(_h,{className:B})]}):$}return null}function $h(e){return e?!(No(e,/```/g)||No(e,/`/g)||No(e,/\*\*/g)||No(e,/__/g)||No(e,/~~/g)||/[^\\]\[[^\]]*$/.test(e)||/\[[^\]]*\]\([^)]*$/.test(e)):!0}function No(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($h(e.slice(0,t)))return t;return 0}function ZT(e){return e.type==="text"&&!!e.__streamingMarkdownAggregate}const QT=Hr.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 Fh({className:e,variant:t,...n}){return u.jsx("div",{className:oe(QT({variant:t}),e),...n})}function ek({showTimestamp:e,showAgentName:t,isToolMessage:n,iconForeground:r,agentName:o,messageIcon:s,customHeaderClass:i,customActionsClass:a,isCompactLayout:l,showActions:c,isEditing:d,messageRole:f,toolViewMode:m,toolMeta:p,onToggleToolView:v,onCopy:g,onEdit:x,onRegenerate:y,showCheckpointControls:w,attemptCount:S,attemptIndex:k,handleOlderAttemptSelect:C,handleNewerAttemptSelect:T,messageCreatedAt:E,copied:j}){return!e&&!t&&!n?null:u.jsxs("div",{className:oe("flex items-center justify-between mb-2 pb-2 border-b border-current/10",l&&"mb-1 pb-1",r,i),children:[u.jsxs("div",{className:"flex items-center gap-2",children:[s,t&&o&&u.jsx("span",{className:oe("font-medium",l?"text-xs":"text-sm"),children:o}),n&&u.jsxs(Fh,{variant:"outline",className:oe("text-xs flex items-center gap-1 cursor-pointer select-none",r,"border border-current/40",l&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":m==="expanded",onClick:v,onKeyDown:_=>{(_.key==="Enter"||_.key===" ")&&(_.preventDefault(),v())},children:[u.jsx("span",{children:p.name??"Tool Output"}),p.toolCallId&&u.jsx("span",{className:"opacity-70",children:p.toolCallId.slice(0,8)}),m==="expanded"?u.jsx(ae.ChevronUp,{className:"h-3 w-3"}):u.jsx(ae.ChevronDown,{className:"h-3 w-3"})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[w&&S>1&&u.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[u.jsx("button",{type:"button",className:oe("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",k<S-1?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{k>=S-1||C()},"aria-label":"Older attempt (back in time)",disabled:k>=S-1,children:u.jsx(ae.ChevronLeft,{className:"h-3 w-3"})}),u.jsx("div",{className:"flex items-center gap-2",children:u.jsxs("span",{className:"whitespace-nowrap",children:[S-k," / ",S]})}),u.jsx("button",{type:"button",className:oe("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",k>0?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{k<=0||T()},"aria-label":"Newer attempt (forward in time)",disabled:k<=0,children:u.jsx(ae.ChevronRight,{className:"h-3 w-3"})})]}),e&&E&&u.jsx("time",{className:oe("text-xs opacity-60",r,l&&"text-xs"),dateTime:new Date(E).toISOString(),title:new Date(E).toLocaleString(),children:new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(new Date(E))}),c&&!d&&u.jsxs("div",{className:oe("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",a),children:[u.jsx("div",{className:"relative",children:u.jsx(Je,{variant:"ghost",size:"sm",onClick:g,className:oe("h-6 w-6 p-0 hover:bg-foreground/10",r,l&&"h-5 w-5"),"aria-label":"Copy message",title:"Copy message",children:u.jsx(ae.Copy,{className:oe(j?"text-success":r,l?"h-3 w-3":"h-4 w-4")})})}),f==="user"&&x&&u.jsx(Je,{variant:"ghost",size:"sm",onClick:x,className:oe("h-6 w-6 p-0 hover:bg-foreground/10",r,l&&"h-5 w-5"),"aria-label":"Edit message",children:u.jsx(ae.Edit,{className:oe(r,l?"h-3 w-3":"h-4 w-4")})}),f==="assistant"&&y&&u.jsx(Je,{variant:"ghost",size:"sm",onClick:y,className:oe("h-6 w-6 p-0 hover:bg-foreground/10",r,l&&"h-5 w-5"),"aria-label":"Regenerate response",children:u.jsx(ae.RotateCcw,{className:oe(r,l?"h-3 w-3":"h-4 w-4")})})]})]})]})}const Zs=b.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,customStyles:m={},streamingDebounceMs:p=300,renderStreamingMarkdown:v=!1,enableStreamingMarkdownBuffer:g,onEdit:x,onRegenerate:y,onCopy:w,activeInterrupt:S,disableInterruptActions:k=!1,onInterruptActionStart:C,onInterruptActionEnd:T,attemptCount:E=1,attemptIndex:j=0,onSelectCheckpoint:_,attemptMetas:D=[]}){const[B,z]=b.useState(!1),[Q,P]=b.useState("preview"),[q,K]=b.useState(!1),{currentThreadId:W}=xr(),{respondToInterrupt:O}=to(),I=l==="phone"||l==="half-screen",U=t.role,Z=U==="tool",R=b.useMemo(()=>t.role==="default_message"?t:null,[t]),$=!!R,A=!(r&&U!=="user"),{uploadingFiles:M,handleFileClick:X,fileViewerOpen:F,currentFileInfo:L,closeFileViewer:J}=Mh({allowFileOpen:A,currentThreadId:W}),ee=b.useMemo(()=>{switch(U){case"user":return"text-[hsl(var(--chat-bubble-user-text))]";case"assistant":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))]"}},[U]),G=Oh(t,R),{contentParts:te,imageParts:he,fileParts:we,interruptParts:ke,textContent:Me,toolMeta:Ae,toolRaw:Le,isToolStreaming:qe}=G,xt=g??p!==0,vt=(S==null?void 0:S.id)??(S==null?void 0:S.interrupt_id),pt=Xo(vt),Ue=S==null?void 0:S.value,Oe=b.useCallback(async()=>{const Y=Z?Le:Me;async function ce(ze){if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function"){await navigator.clipboard.writeText(ze);return}if(navigator.clipboard&&typeof navigator.clipboard.write=="function"&&typeof ClipboardItem<"u"){const ge=new Blob([ze],{type:"text/plain"});await navigator.clipboard.write([new ClipboardItem({"text/plain":ge})]);return}throw new Error("Clipboard API not supported in this context.")}try{await ce(Y),z(!0),setTimeout(()=>z(!1),2e3),w==null||w(Y)}catch(ze){console.error("Failed to copy:",ze)}},[Z,Le,Me,w]),Ge=b.useCallback(()=>{if(!x||!t.id)return;const Y=(Z?Le:Me)??"",ce="type"in t&&t.type==="default_message"?void 0:{checkpointId:t.checkpointId??null,checkpointNs:t.checkpointNs??null};x(t.id,Y,ce)},[x,t.id,Z,Le,Me,t]),je=b.useCallback(()=>{y==null||y(n)},[y,n]),De=b.useCallback(()=>{P(Y=>Y==="expanded"?"preview":"expanded")},[]),Ze=b.useCallback(()=>{const ce=oe(I?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",ee);switch(U){case"user":return u.jsx(ae.User,{className:ce});case"assistant":return u.jsx(ae.Bot,{className:ce});case"tool":return u.jsx(ae.Wrench,{className:ce});default:return u.jsx(ae.Bot,{className:ce})}},[I,ee,U]),It=b.useCallback(()=>{const Y="group relative mb-4 flex w-full";switch(U){case"user":return oe(Y,"justify-end");case"assistant":case"tool":case"system":return oe(Y,"justify-start");default:return Y}},[U]),st=b.useCallback(()=>{const Y=oe("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",I&&"px-3 py-2 text-sm");if($)return oe(Y,"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(U){case"user":return oe(Y,"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 oe(Y,"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":return oe(Y,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return oe(Y,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return oe(Y,"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")}},[I,$,U]),yt=b.useCallback(async Y=>{if(k)return;const ce=Xo((Y==null?void 0:Y.id)??(Y==null?void 0:Y.interrupt_id));if(!ce){console.warn("Interrupt part missing id",Y);return}try{C==null||C(),await O(ce,!0)}catch(ze){console.error("Failed to approve interrupt:",ze)}finally{T==null||T()}},[k,T,C,O]),St=b.useCallback(async Y=>{if(k)return;const ce=Xo((Y==null?void 0:Y.id)??(Y==null?void 0:Y.interrupt_id));if(!ce){console.warn("Interrupt part missing id",Y);return}try{C==null||C(),await O(ce,!1)}catch(ze){console.error("Failed to reject interrupt:",ze)}finally{T==null||T()}},[k,T,C,O]),Ct=u.jsx(XT,{message:t,isToolMessage:Z,showToolMessages:f,toolViewMode:Q,isToolStreaming:qe,contentParts:te,textContent:Me,imageParts:he,fileParts:we,interruptParts:ke,isStreamingMessage:r,defaultMessage:R,enableStreamingMarkdownBuffer:xt,renderStreamingMarkdown:v,handleFileClick:X,uploadingFiles:M,handleInterruptApprove:yt,handleInterruptReject:St,disableInterruptActions:k,messageRole:U,truncateUserMessages:c,userMessagePreviewLength:d,isUserExpanded:q,setIsUserExpanded:K,isCompactLayout:I,activeInterruptId:pt,activeInterruptValue:Ue,iconForeground:ee}),kt=b.useMemo(()=>R?"Assistant":sb(t),[R,t]),on=Ze(),Nt=U==="user"&&(E??1)>1&&typeof _=="function",Vt=(D==null?void 0:D.length)??0,Et=Vt>0&&j<Vt-1?D[j+1]:void 0,$e=Vt>0&&j>0?D[j-1]:void 0,We=b.useCallback(()=>{!Et||!_||_(Et.id,void 0,!!Et.isLatestAttempt)},[Et,_]),At=b.useCallback(()=>{!$e||!_||_($e.id,void 0,!!$e.isLatestAttempt)},[$e,_]);return Z&&!f?null:$&&R?u.jsx("div",{className:oe(It(),m.container),children:u.jsxs("div",{className:oe(st(),m.content),children:[u.jsxs("div",{className:"flex items-center gap-2 mb-2 pb-2 border-b border-current/10",children:[u.jsx(ae.Bot,{className:oe("h-4 w-4",ee)}),a&&u.jsx("span",{className:"font-medium text-sm",children:"Assistant"})]}),u.jsx(Kn,{content:R.content,className:"text-current"})]})}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:oe(It(),m.container),children:u.jsxs("div",{className:oe(st(),m.content),children:[u.jsx(ek,{showTimestamp:i,showAgentName:a,isToolMessage:Z,iconForeground:ee,agentName:kt,messageIcon:on,customHeaderClass:m.header,customActionsClass:m.actions,isCompactLayout:I,showActions:s,isEditing:o,messageRole:U,toolViewMode:Q,toolMeta:Ae,onToggleToolView:De,onCopy:Oe,onEdit:Ge,onRegenerate:je,showCheckpointControls:Nt,attemptCount:E,attemptIndex:j,handleOlderAttemptSelect:We,handleNewerAttemptSelect:At,messageCreatedAt:t.createdAt,copied:B}),u.jsx("div",{className:"relative",children:Ct}),Z&&Q==="expanded"&&(Ae.toolCallId||Ae.name)&&u.jsxs("div",{className:oe("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",I&&"text-xs"),children:[Ae.name&&u.jsxs("div",{children:["Function: ",Ae.name]}),Ae.toolCallId&&u.jsxs("div",{children:["Call ID: ",Ae.toolCallId]})]}),!(i||a||Z)&&s&&!o&&u.jsxs("div",{className:oe("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",m.actions),children:[u.jsx(Je,{variant:"ghost",size:"sm",onClick:()=>Oe(),className:oe("h-6 w-6 p-0 hover:bg-background/50 text-current",I&&"h-5 w-5"),children:u.jsx(ae.Copy,{className:oe(B?"text-success":"text-current",I?"h-3 w-3":"h-4 w-4")})}),U==="user"&&x&&u.jsx(Je,{variant:"ghost",size:"sm",onClick:Ge,className:oe("h-6 w-6 p-0 hover:bg-background/50 text-current",I&&"h-5 w-5"),children:u.jsx(ae.Edit,{className:oe("text-current",I?"h-3 w-3":"h-4 w-4")})}),U==="assistant"&&y&&u.jsx(Je,{variant:"ghost",size:"sm",onClick:je,className:oe("h-6 w-6 p-0 hover:bg-background/50 text-current",I&&"h-5 w-5"),children:u.jsx(ae.RotateCcw,{className:oe("text-current",I?"h-3 w-3":"h-4 w-4")})})]})]})}),L&&u.jsx(uh,{isOpen:F,onClose:J,fileId:L.id,fileName:L.name,mimeType:L.mimeType})]})},(e,t)=>{var l,c,d,f,m,p,v,g;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&xu(e.message)===xu(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateUserMessages","userMessagePreviewLength","showToolMessages"].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=vu(e.message),a=vu(t.message);return i.length===a.length});Zs.displayName="MessageComponent";const ml=b.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,activeInterrupt:w,disableInterruptActions:S=!1,onInterruptActionStart:k,onInterruptActionEnd:C,showToolMessages:T=!0,checkpointIndex:E,activeCheckpointId:j,onSelectCheckpoint:_,createSyntheticThinkingMessage:D=!0,forceSyntheticThinking:B=!1,getMessageCustomStyles:z},Q)=>{const P=b.useRef(null),q=b.useRef(null),K=b.useRef(!1),W=b.useRef(!1),O=b.useMemo(()=>w?e.some(G=>G.role==="default_message"?!1:Array.isArray(G==null?void 0:G.content)&&G.content.some(te=>te&&te.type==="interrupt"&&(te.id??te.interrupt_id)===w.id)):!1,[w,e]),I=b.useMemo(()=>{if(!w||O)return null;const G=w.id&&String(w.id).trim()?String(w.id).trim():"pending-interrupt";let te;const he=w.value;if(he&&typeof he=="object"&&!Array.isArray(he)){const we=he.title;typeof we=="string"&&we.trim()&&(te=we.trim())}return{id:`interrupt-${G}`,role:"system",createdAt:new Date().toISOString(),content:[{type:"interrupt",id:G,value:he,title:te}]}},[w,O]),U=b.useMemo(()=>I?[...e,I]:e,[e,I]),Z=b.useMemo(()=>{const G=n&&U.some(he=>he.id===n);return D&&(t||B)&&!G&&U.length>0?[...U,{id:"thinking-assistant",role:"assistant",content:[{type:"text",text:""}],createdAt:new Date().toISOString(),__syntheticStreaming:!0}]:U},[U,t,n,D,B]),R=b.useMemo(()=>T?Z:Z.filter(G=>(G==null?void 0:G.role)!=="tool"),[Z,T]),$=b.useCallback(G=>{x&&x(!G),y&&y(G)},[x,y]),A=b.useMemo(()=>{if(a)return async()=>{if(!K.current){K.current=!0;try{await a()}finally{K.current=!1}}}},[a]),M=b.useMemo(()=>!v||g?!1:"auto",[v,g]),X=b.useMemo(()=>{if(typeof p!="string")return null;const G=p.trim();return!G||R&&R.length>0?null:{id:"default-message",role:"default_message",content:G,createdAt:new Date().toISOString()}},[p,R]),F=["flex h-full flex-col md:flex-row",f].filter(Boolean).join(" "),L=()=>{if(X){const G=z==null?void 0:z(X);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(Zs,{message:X,messageIndex:0,isStreamingMessage:!1,showActions:!1,showTimestamp:!1,showAgentName:!0,layoutSize:o,onEdit:()=>{},onRegenerate:()=>{},onCancelEdit:()=>{},customStyles:G})})})}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!"})},J=R.length,ee=J>0;return b.useEffect(()=>{var G,te;if(J===0){W.current=!1;return}if(!W.current)if(W.current=!0,P.current&&R.length>0){const he=R.length-1;(te=(G=P.current).scrollToIndex)==null||te.call(G,{index:he,align:"end",behavior:"auto"})}else q.current&&(q.current.scrollTop=q.current.scrollHeight)},[J,R.length]),b.useImperativeHandle(Q,()=>({scrollToLatest:()=>{var G,te;if(P.current&&R.length>0){const he=R.length-1;(te=(G=P.current).scrollToIndex)==null||te.call(G,{index:he,align:"end",behavior:"auto"})}else q.current&&(q.current.scrollTop=q.current.scrollHeight)},scrollToTop:()=>{var G,te;P.current&&R.length>0?(te=(G=P.current).scrollToIndex)==null||te.call(G,{index:0,align:"start",behavior:"auto"}):q.current&&(q.current.scrollTop=0)}}),[R]),u.jsx("div",{className:F,style:m,children:u.jsx("div",{className:"relative flex-1 min-h-0",children:ee?u.jsx(VC,{ref:G=>{P.current=G},scrollerRef:G=>{q.current=G instanceof HTMLDivElement?G:null},data:R,followOutput:M,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,startReached:()=>{A&&A()},atBottomStateChange:$,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(G,te)=>pl(te,G),itemContent:(G,te)=>u.jsx(hl,{message:te,index:G,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onEdit:l,onRegenerate:c,onCancelEdit:d,activeInterrupt:w,disableInterruptActions:S,onInterruptActionStart:k,onInterruptActionEnd:C,showToolMessages:T,checkpointIndex:E,activeCheckpointId:j,onSelectCheckpoint:_,getMessageCustomStyles:z})}):L()})})});ml.displayName="MessageList";const Bh={value:""};function Or({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,payloadExtras:f={},customStyles:m={},messageCustomStyles:p,onMessageSent:v,onExcelUploadSuccess:g,onError:x,defaultMessage:y}){const{api:w}=Jr(),{currentThreadId:S}=xr(),{threadId:k,messages:C,isLoading:T,navigateToCheckpoint:E,returnToLatest:j,checkpoint:_,checkpoints:D,interrupt:B,metadata:z,checkpointIndex:Q}=to(),{isStreaming:P,error:q,connectionState:K,submit:W,stop:O}=Fi(),I=k??S??null,U=(_==null?void 0:_.id)??null,Z=(_==null?void 0:_.namespace)??null,R=(z==null?void 0:z.assemblingMessageId)??null,$=B,[A,M]=b.useState(!1),[X,F]=b.useState(!1);b.useEffect(()=>{$||M(!1)},[$]);const L=b.useCallback(()=>{M(!0)},[]),J=b.useCallback(()=>{M(!1)},[]),ee=!!$||A,[G,te]=b.useState(null),[he,we]=b.useState(""),[ke,Me]=b.useState(null),[Ae,Le]=b.useState(null),[qe,xt]=b.useState(!1),[vt,pt]=b.useState(null),Ue=b.useRef(!1),[Oe,Ge]=b.useState(()=>Bh.value),je=b.useRef(Oe),De=b.useRef(null),Ze=b.useCallback(fe=>{Bh.value=fe,Ge(fe)},[]),[It,st]=b.useState(!1),yt=b.useRef(null),St=b.useCallback(fe=>{Ze(fe)},[Ze]);b.useEffect(()=>{P||F(!1)},[P]),b.useEffect(()=>{z!=null&&z.assemblingMessageId&&F(!1)},[z==null?void 0:z.assemblingMessageId]);const[Ct,kt]=b.useState("desktop");b.useEffect(()=>{const fe=()=>{const ve=window.innerWidth;kt(ve<640?"phone":ve<1024?"tablet":"desktop")};return fe(),window.addEventListener("resize",fe),()=>window.removeEventListener("resize",fe)},[]),b.useEffect(()=>{Ue.current=!1},[I]),b.useEffect(()=>{je.current=Oe},[Oe]),b.useEffect(()=>{if(!G){De.current=null;return}De.current===null&&(De.current=je.current),Ze(he??"")},[he,G,Ze]),b.useEffect(()=>{if(y!==void 0){pt(y);return}(async()=>{if(!w.baseUrl){pt(null);return}try{const _e=(await w.getAgent("default")).uiDefaultMessage||"";pt(_e||null)}catch(ve){console.warn("Failed to fetch default message:",ve),pt(null)}})()},[w.baseUrl,y]),b.useEffect(()=>{q&&!qe&&(x==null||x(q))},[q,qe,x]);const on=async(fe,ve)=>{const _e=fe.trim();if(!(!_e&&ve.length===0))try{const Ve=G?(ke==null?void 0:ke.checkpointId)??U??void 0:U??void 0,at=G?(ke==null?void 0:ke.checkpointNs)??Z??void 0:Z??void 0;await W({text:_e||"",attachments:ve,payload:f},{checkpointId:Ve,checkpointNs:at,edit:!!G,originalMessageId:G??void 0}),v==null||v(_e),F(!0),Ze(""),Le(null),te(null),we(""),Me(null)}catch(Ve){const at=(Ve==null?void 0:Ve.message)||"Failed to send message";Le(at),x==null||x(at),F(!1)}},Nt=b.useCallback(async fe=>{await W({attachments:[fe],payload:f},{checkpointId:U??void 0,checkpointNs:Z??void 0}),g==null||g({file:fe})},[U,Z,f,g,W]),Vt=b.useCallback((fe,ve,_e)=>{c&&(De.current=Oe,te(fe),we(ve),Ze(ve),Le(null),Me({checkpointId:(_e==null?void 0:_e.checkpointId)??null,checkpointNs:(_e==null?void 0:_e.checkpointNs)??null}))},[Oe,c,Ze]),Et=b.useCallback(()=>{te(null),we(""),Me(null),Le(null),Ze(De.current??Oe),De.current=null},[Oe,Ze]),$e=b.useCallback((fe,ve,_e)=>{Vt(fe,ve,_e)},[Vt]),We=b.useCallback(fe=>{let ve=null;for(let lt=fe-1;lt>=0;lt--)if(C[lt].role==="user"){ve=C[lt];break}if(!ve)return;const _e=Array.isArray(ve.content)?ve.content:[],at=_e.filter(lt=>(lt==null?void 0:lt.type)==="text").map(lt=>lt.text).join("")||(()=>{try{return JSON.stringify(_e,null,2)}catch{return String(_e)}})();at&&W({text:at,payload:f},{checkpointId:U??void 0,checkpointNs:Z??void 0,edit:!0,originalMessageId:ve.id})},[C,W,U,Z,f]),At=async fe=>{if(S){st(!0);try{if(!fe){await j(),requestAnimationFrame(()=>{var Ve;(Ve=yt.current)==null||Ve.scrollToLatest()});return}const ve=D.find(Ve=>Ve.checkpointId===fe),_e=(ve==null?void 0:ve.checkpointNs)??null;await E(fe,_e),requestAnimationFrame(()=>{var Ve;(Ve=yt.current)==null||Ve.scrollToTop()})}finally{st(!1)}}},Y=b.useCallback(async(fe,ve,_e)=>{await At(_e?null:fe)},[At]),ce=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${m.container||""}`,ze=`flex-1 min-h-0 min-w-0 max-h-full w-full overflow-hidden overscroll-contain break-words break-anywhere p-4 bg-transparent ${m.messagesArea||""}`,ge=`relative flex-shrink-0 w-full border-t p-4 bg-transparent ${m.inputArea||""}`;return u.jsxs("div",{className:ce,children:[!!q&&!qe&&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:q}),u.jsx(Je,{variant:"ghost",size:"sm",onClick:()=>xt(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:u.jsx(ae.X,{size:16})})]}),u.jsxs("div",{className:`relative ${ze}`,style:r?{maxHeight:r}:void 0,children:[u.jsx(ml,{ref:yt,className:"h-full",style:{height:"100%"},messages:C,isStreaming:P,streamingAssistantId:R,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:Ct,enableMessageEditing:c,editingMessageId:G,onEdit:$e,onRegenerate:We,onCancelEdit:Et,emptyMessage:vt??void 0,isNavigatingCheckpoint:It,activeInterrupt:$,disableInterruptActions:A,onInterruptActionStart:L,onInterruptActionEnd:J,showToolMessages:d,checkpointIndex:Q,activeCheckpointId:U,onSelectCheckpoint:Y,createSyntheticThinkingMessage:!0,forceSyntheticThinking:X,getMessageCustomStyles:p}),(K==="reconnecting"||K==="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(ae.Loader2,{className:"h-3 w-3 animate-spin"}),K==="reconnecting"?"Reconnecting…":"Connecting…"]})}),K==="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"}),T&&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(ae.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]}),It&&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(ae.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading checkpoint…"})]})]}),u.jsxs("div",{className:ge,children:[G&&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(ae.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:Et,className:"text-blue-600 hover:bg-blue-100",children:u.jsx(ae.X,{size:16})})]})}),Ae&&u.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:Ae}),u.jsx(OS,{composerValue:Oe,onComposerChange:St,onSend:on,onCancelEdit:Et,onStop:O,editingMessageId:G,editingInitialValue:he,placeholder:G?"Edit your message...":t,isStreaming:P,disabled:ee,enableFileUpload:a,enableExcelUpload:l,onExcelUpload:Nt,onError:x,customStyles:m,textareaClassName:m.textarea||"",allowEmptySend:!1,inputError:Ae})]})]})}var zh=1,tk=.9,nk=.8,rk=.17,gl=.1,xl=.999,ok=.9999,sk=.99,ik=/[\\\/_+.#"@\[\(\{&]/,ak=/[\\\/_+.#"@\[\(\{&]/g,lk=/[\s-]/,Hh=/[\s-]/g;function vl(e,t,n,r,o,s,i){if(s===t.length)return o===e.length?zh: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=vl(e,t,n,r,c+1,s+1,i),f>d&&(c===o?f*=zh:ik.test(e.charAt(c-1))?(f*=nk,p=e.slice(o,c-1).match(ak),p&&o>0&&(f*=Math.pow(xl,p.length))):lk.test(e.charAt(c-1))?(f*=tk,v=e.slice(o,c-1).match(Hh),v&&o>0&&(f*=Math.pow(xl,v.length))):(f*=rk,o>0&&(f*=Math.pow(xl,c-o))),e.charAt(c)!==t.charAt(s)&&(f*=ok)),(f<gl&&n.charAt(c-1)===r.charAt(s+1)||r.charAt(s+1)===r.charAt(s)&&n.charAt(c-1)!==r.charAt(s))&&(m=vl(e,t,n,r,c+1,s+2,i),m*gl>f&&(f=m*gl)),f>d&&(d=f),c=n.indexOf(l,c+1);return i[a]=d,d}function Uh(e){return e.toLowerCase().replace(Hh," ")}function ck(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,vl(e,t,Uh(e),Uh(t),0,0,{})}var Ao='[cmdk-group=""]',bl='[cmdk-group-items=""]',uk='[cmdk-group-heading=""]',Wh='[cmdk-item=""]',Vh=`${Wh}:not([aria-disabled="true"])`,wl="cmdk-item-select",Dr="data-value",dk=(e,t,n)=>ck(e,t,n),Kh=h.createContext(void 0),jo=()=>h.useContext(Kh),qh=h.createContext(void 0),yl=()=>h.useContext(qh),Gh=h.createContext(void 0),Yh=h.forwardRef((e,t)=>{let n=Lr(()=>{var R,$;return{search:"",value:($=(R=e.value)!=null?R:e.defaultValue)!=null?$:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=Lr(()=>new Set),o=Lr(()=>new Map),s=Lr(()=>new Map),i=Lr(()=>new Set),a=Xh(e),{label:l,children:c,value:d,onValueChange:f,filter:m,shouldFilter:p,loop:v,disablePointerSelection:g=!1,vimBindings:x=!0,...y}=e,w=_t(),S=_t(),k=_t(),C=h.useRef(null),T=Sk();ur(()=>{if(d!==void 0){let R=d.trim();n.current.value=R,E.emit()}},[d]),ur(()=>{T(6,Q)},[]);let E=h.useMemo(()=>({subscribe:R=>(i.current.add(R),()=>i.current.delete(R)),snapshot:()=>n.current,setState:(R,$,A)=>{var M,X,F,L;if(!Object.is(n.current[R],$)){if(n.current[R]=$,R==="search")z(),D(),T(1,B);else if(R==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let J=document.getElementById(k);J?J.focus():(M=document.getElementById(w))==null||M.focus()}if(T(7,()=>{var J;n.current.selectedItemId=(J=P())==null?void 0:J.id,E.emit()}),A||T(5,Q),((X=a.current)==null?void 0:X.value)!==void 0){let J=$??"";(L=(F=a.current).onValueChange)==null||L.call(F,J);return}}E.emit()}},emit:()=>{i.current.forEach(R=>R())}}),[]),j=h.useMemo(()=>({value:(R,$,A)=>{var M;$!==((M=s.current.get(R))==null?void 0:M.value)&&(s.current.set(R,{value:$,keywords:A}),n.current.filtered.items.set(R,_($,A)),T(2,()=>{D(),E.emit()}))},item:(R,$)=>(r.current.add(R),$&&(o.current.has($)?o.current.get($).add(R):o.current.set($,new Set([R]))),T(3,()=>{z(),D(),n.current.value||B(),E.emit()}),()=>{s.current.delete(R),r.current.delete(R),n.current.filtered.items.delete(R);let A=P();T(4,()=>{z(),(A==null?void 0:A.getAttribute("id"))===R&&B(),E.emit()})}),group:R=>(o.current.has(R)||o.current.set(R,new Set),()=>{s.current.delete(R),o.current.delete(R)}),filter:()=>a.current.shouldFilter,label:l||e["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:w,inputId:k,labelId:S,listInnerRef:C}),[]);function _(R,$){var A,M;let X=(M=(A=a.current)==null?void 0:A.filter)!=null?M:dk;return R?X(R,n.current.search,$):0}function D(){if(!n.current.search||a.current.shouldFilter===!1)return;let R=n.current.filtered.items,$=[];n.current.filtered.groups.forEach(M=>{let X=o.current.get(M),F=0;X.forEach(L=>{let J=R.get(L);F=Math.max(J,F)}),$.push([M,F])});let A=C.current;q().sort((M,X)=>{var F,L;let J=M.getAttribute("id"),ee=X.getAttribute("id");return((F=R.get(ee))!=null?F:0)-((L=R.get(J))!=null?L:0)}).forEach(M=>{let X=M.closest(bl);X?X.appendChild(M.parentElement===X?M:M.closest(`${bl} > *`)):A.appendChild(M.parentElement===A?M:M.closest(`${bl} > *`))}),$.sort((M,X)=>X[1]-M[1]).forEach(M=>{var X;let F=(X=C.current)==null?void 0:X.querySelector(`${Ao}[${Dr}="${encodeURIComponent(M[0])}"]`);F==null||F.parentElement.appendChild(F)})}function B(){let R=q().find(A=>A.getAttribute("aria-disabled")!=="true"),$=R==null?void 0:R.getAttribute(Dr);E.setState("value",$||void 0)}function z(){var R,$,A,M;if(!n.current.search||a.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let X=0;for(let F of r.current){let L=($=(R=s.current.get(F))==null?void 0:R.value)!=null?$:"",J=(M=(A=s.current.get(F))==null?void 0:A.keywords)!=null?M:[],ee=_(L,J);n.current.filtered.items.set(F,ee),ee>0&&X++}for(let[F,L]of o.current)for(let J of L)if(n.current.filtered.items.get(J)>0){n.current.filtered.groups.add(F);break}n.current.filtered.count=X}function Q(){var R,$,A;let M=P();M&&(((R=M.parentElement)==null?void 0:R.firstChild)===M&&((A=($=M.closest(Ao))==null?void 0:$.querySelector(uk))==null||A.scrollIntoView({block:"nearest"})),M.scrollIntoView({block:"nearest"}))}function P(){var R;return(R=C.current)==null?void 0:R.querySelector(`${Wh}[aria-selected="true"]`)}function q(){var R;return Array.from(((R=C.current)==null?void 0:R.querySelectorAll(Vh))||[])}function K(R){let $=q()[R];$&&E.setState("value",$.getAttribute(Dr))}function W(R){var $;let A=P(),M=q(),X=M.findIndex(L=>L===A),F=M[X+R];($=a.current)!=null&&$.loop&&(F=X+R<0?M[M.length-1]:X+R===M.length?M[0]:M[X+R]),F&&E.setState("value",F.getAttribute(Dr))}function O(R){let $=P(),A=$==null?void 0:$.closest(Ao),M;for(;A&&!M;)A=R>0?wk(A,Ao):yk(A,Ao),M=A==null?void 0:A.querySelector(Vh);M?E.setState("value",M.getAttribute(Dr)):W(R)}let I=()=>K(q().length-1),U=R=>{R.preventDefault(),R.metaKey?I():R.altKey?O(1):W(1)},Z=R=>{R.preventDefault(),R.metaKey?K(0):R.altKey?O(-1):W(-1)};return h.createElement(pe.div,{ref:t,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:R=>{var $;($=y.onKeyDown)==null||$.call(y,R);let A=R.nativeEvent.isComposing||R.keyCode===229;if(!(R.defaultPrevented||A))switch(R.key){case"n":case"j":{x&&R.ctrlKey&&U(R);break}case"ArrowDown":{U(R);break}case"p":case"k":{x&&R.ctrlKey&&Z(R);break}case"ArrowUp":{Z(R);break}case"Home":{R.preventDefault(),K(0);break}case"End":{R.preventDefault(),I();break}case"Enter":{R.preventDefault();let M=P();if(M){let X=new Event(wl);M.dispatchEvent(X)}}}}},h.createElement("label",{"cmdk-label":"",htmlFor:j.inputId,id:j.labelId,style:Tk},l),Qs(e,R=>h.createElement(qh.Provider,{value:E},h.createElement(Kh.Provider,{value:j},R))))}),fk=h.forwardRef((e,t)=>{var n,r;let o=_t(),s=h.useRef(null),i=h.useContext(Gh),a=jo(),l=Xh(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=Jh(o,s,[e.value,e.children,s],e.keywords),f=yl(),m=qn(T=>T.value&&T.value===d.current),p=qn(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(wl,v),()=>T.removeEventListener(wl,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:w,forceMount:S,keywords:k,...C}=e;return h.createElement(pe.div,{ref:Mn(s,t),...C,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=jo(),f=qn(p=>o||d.filter()===!1?!0:p.search?p.filtered.groups.has(i):!0);ur(()=>d.group(i),[]),Jh(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),Qs(e,p=>h.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?c:void 0},h.createElement(Gh.Provider,{value:m},p))))}),hk=h.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=h.useRef(null),s=qn(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=yl(),i=qn(c=>c.search),a=qn(c=>c.selectedItemId),l=jo();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=qn(c=>c.selectedItemId),l=jo();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},Qs(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(Qa,{open:n,onOpenChange:r},h.createElement(el,{container:i},h.createElement(ko,{"cmdk-overlay":"",className:o}),h.createElement(Eo,{"aria-label":e.label,"cmdk-dialog":"",className:s},h.createElement(Yh,{ref:t,...a}))))}),vk=h.forwardRef((e,t)=>qn(n=>n.filtered.count===0)?h.createElement(pe.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),bk=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},Qs(e,i=>h.createElement("div",{"aria-hidden":!0},i)))}),Ut=Object.assign(Yh,{List:gk,Item:fk,Input:mk,Group:pk,Separator:hk,Dialog:xk,Empty:vk,Loading:bk});function wk(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 Xh(e){let t=h.useRef(e);return ur(()=>{t.current=e}),t}var ur=typeof window>"u"?h.useEffect:h.useLayoutEffect;function Lr(e){let t=h.useRef();return t.current===void 0&&(t.current=e()),t}function qn(e){let t=yl(),n=()=>e(t.snapshot());return h.useSyncExternalStore(t.subscribe,n,n)}function Jh(e,t,n,r=[]){let o=h.useRef(),s=jo();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(Dr,a),o.current=a}),o}var Sk=()=>{let[e,t]=h.useState(),n=Lr(()=>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 Qs({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 Sl=h.forwardRef(({className:e,...t},n)=>u.jsx(Ut,{ref:n,className:oe("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));Sl.displayName=Ut.displayName;const Cl=h.forwardRef(({className:e,...t},n)=>u.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[u.jsx(ae.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),u.jsx(Ut.Input,{ref:n,className:oe("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})]}));Cl.displayName=Ut.Input.displayName;const Tl=h.forwardRef(({className:e,...t},n)=>u.jsx(Ut.List,{ref:n,className:oe("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));Tl.displayName=Ut.List.displayName;const kl=h.forwardRef((e,t)=>u.jsx(Ut.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));kl.displayName=Ut.Empty.displayName;const El=h.forwardRef(({className:e,...t},n)=>u.jsx(Ut.Group,{ref:n,className:oe("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}));El.displayName=Ut.Group.displayName;const kk=h.forwardRef(({className:e,...t},n)=>u.jsx(Ut.Separator,{ref:n,className:oe("-mx-1 h-px bg-border",e),...t}));kk.displayName=Ut.Separator.displayName;const Il=h.forwardRef(({className:e,...t},n)=>u.jsx(Ut.Item,{ref:n,className:oe("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}));Il.displayName=Ut.Item.displayName;function Nl(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 Al="ScrollArea",[Zh,HN]=ln(Al),[Ik,rn]=Zh(Al),Qh=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,w]=h.useState(0),[S,k]=h.useState(0),[C,T]=h.useState(!1),[E,j]=h.useState(!1),_=Pe(t,B=>l(B)),D=Zo(o);return u.jsx(Ik,{scope:n,type:r,dir:D,scrollHideDelay:s,scrollArea:a,viewport:c,onViewportChange:d,content:f,onContentChange:m,scrollbarX:p,onScrollbarXChange:v,scrollbarXEnabled:C,onScrollbarXEnabledChange:T,scrollbarY:g,onScrollbarYChange:x,scrollbarYEnabled:E,onScrollbarYEnabledChange:j,onCornerWidthChange:w,onCornerHeightChange:k,children:u.jsx(pe.div,{dir:D,...i,ref:_,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})});Qh.displayName=Al;var em="ScrollAreaViewport",tm=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=rn(em,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})})]})});tm.displayName=em;var En="ScrollAreaScrollbar",jl=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=rn(En,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(nm,{...r,ref:t,forceMount:n}):o.type==="always"?u.jsx(_l,{...r,ref:t}):null});jl.displayName=En;var Nk=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=rn(En,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(zt,{present:n||s,children:u.jsx(nm,{"data-state":s?"visible":"hidden",...r,ref:t})})}),Ak=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=rn(En,e.__scopeScrollArea),s=e.orientation==="horizontal",i=ri(()=>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(zt,{present:n||a!=="hidden",children:u.jsx(_l,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:ie(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:ie(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),nm=h.forwardRef((e,t)=>{const n=rn(En,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=h.useState(!1),a=e.orientation==="horizontal",l=ri(()=>{if(n.viewport){const c=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?c:d)}},10);return $r(n.viewport,l),$r(n.content,l),u.jsx(zt,{present:r||s,children:u.jsx(_l,{"data-state":s?"visible":"hidden",...o,ref:t})})}),_l=h.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=rn(En,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=am(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=lm(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(_k,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollTop,p=lm(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(En,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(om,{"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":ni(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),um(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:ti(i.paddingLeft),paddingEnd:ti(i.paddingRight)}})}})}),_k=h.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=rn(En,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(om,{"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":ni(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),um(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:ti(i.paddingTop),paddingEnd:ti(i.paddingBottom)}})}})}),[Pk,rm]=Zh(En),om=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(En,n),[v,g]=h.useState(null),x=Pe(t,_=>g(_)),y=h.useRef(null),w=h.useRef(""),S=p.viewport,k=r.content-r.viewport,C=dt(d),T=dt(l),E=ri(f,10);function j(_){if(y.current){const D=_.clientX-y.current.left,B=_.clientY-y.current.top;c({x:D,y:B})}}return h.useEffect(()=>{const _=D=>{const B=D.target;(v==null?void 0:v.contains(B))&&C(D,k)};return document.addEventListener("wheel",_,{passive:!1}),()=>document.removeEventListener("wheel",_,{passive:!1})},[S,v,k,C]),h.useEffect(T,[r,T]),$r(v,E),$r(p.content,E),u.jsx(Pk,{scope:n,scrollbar:v,hasThumb:o,onThumbChange:dt(s),onThumbPointerUp:dt(i),onThumbPositionChange:T,onThumbPointerDown:dt(a),children:u.jsx(pe.div,{...m,ref:x,style:{position:"absolute",...m.style},onPointerDown:ie(e.onPointerDown,_=>{_.button===0&&(_.target.setPointerCapture(_.pointerId),y.current=v.getBoundingClientRect(),w.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",p.viewport&&(p.viewport.style.scrollBehavior="auto"),j(_))}),onPointerMove:ie(e.onPointerMove,j),onPointerUp:ie(e.onPointerUp,_=>{const D=_.target;D.hasPointerCapture(_.pointerId)&&D.releasePointerCapture(_.pointerId),document.body.style.webkitUserSelect=w.current,p.viewport&&(p.viewport.style.scrollBehavior=""),y.current=null})})})}),ei="ScrollAreaThumb",sm=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=rm(ei,e.__scopeScrollArea);return u.jsx(zt,{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(ei,n),i=rm(ei,n),{onThumbPositionChange:a}=i,l=Pe(t,f=>i.onThumbChange(f)),c=h.useRef(void 0),d=ri(()=>{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:ie(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:ie(e.onPointerUp,i.onThumbPointerUp)})});sm.displayName=ei;var Pl="ScrollAreaCorner",im=h.forwardRef((e,t)=>{const n=rn(Pl,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?u.jsx(Mk,{...e,ref:t}):null});im.displayName=Pl;var Mk=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=rn(Pl,n),[s,i]=h.useState(0),[a,l]=h.useState(0),c=!!(s&&a);return $r(o.scrollbarX,()=>{var f;const d=((f=o.scrollbarX)==null?void 0:f.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),$r(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 ti(e){return e?parseInt(e,10):0}function am(e,t){const n=e/t;return isNaN(n)?0:n}function ni(e){const t=am(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=ni(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 cm([l,c],f)(e)}function lm(e,t,n="ltr"){const r=ni(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=Nl(e,l);return cm([0,i],[0,a])(c)}function cm(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 um(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 ri(e,t){const n=dt(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 $r(e,t){const n=dt(t);Tt(()=>{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 dm=Qh,Lk=tm,$k=im;const Rl=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(dm,{ref:r,className:oe("relative overflow-hidden",e),...n,children:[u.jsx(Lk,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),u.jsx(fm,{}),u.jsx($k,{})]}));Rl.displayName=dm.displayName;const fm=h.forwardRef(({className:e,orientation:t="vertical",...n},r)=>u.jsx(jl,{ref:r,orientation:t,className:oe("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(sm,{className:"relative flex-1 rounded-full bg-border"})}));fm.displayName=jl.displayName;const Ml=h.forwardRef(({className:e,type:t,...n},r)=>u.jsx("input",{type:t,className:oe("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}));Ml.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 pm({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 w=n===e.threadId,S=t?`${y??zk}`:`${x??Bk}`,k=C=>{C.stopPropagation(),o(e.threadId)};return u.jsxs("div",{onClick:k,className:`${Fk} ${S}`,children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("div",{className:"flex-1 min-w-0",children:w?u.jsxs("div",{className:"flex items-center gap-2",onClick:C=>C.stopPropagation(),children:[u.jsx(Ml,{value:r,onChange:C=>i(C.target.value),onKeyDown:C=>{C.key==="Enter"?a(e.threadId):C.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(ae.Check,{size:12})}),u.jsx(Je,{variant:"ghost",size:"sm",onClick:l,className:"h-6 w-6 p-0",children:u.jsx(ae.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(ae.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(Ts,{children:[u.jsx(ks,{asChild:!0,children:u.jsx(Je,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",children:u.jsx(ae.MoreHorizontal,{size:12})})}),u.jsxs(ho,{align:"end",sideOffset:6,className:"w-44",children:[u.jsxs(Fn,{onClick:C=>{C.preventDefault(),c(e.threadId)},children:[u.jsx(ae.Share2,{className:"mr-2 h-4 w-4"}),"Share thread"]}),f&&n!==e.threadId&&u.jsxs(Fn,{onClick:C=>{C.preventDefault(),s(e,C)},children:[u.jsx(ae.Edit3,{className:"mr-2 h-4 w-4"}),"Rename"]}),m&&d&&u.jsxs(Fn,{className:"text-red-400 hover:text-red-300",onClick:C=>{C.preventDefault(),d(e.threadId,C)},children:[u.jsx(ae.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 hm=25,mm="thread-manager-view",Hk=e=>e==="default"||e==="shared",Uk=()=>{if(typeof window>"u")return null;try{const e=window.localStorage.getItem(mm);if(Hk(e))return e}catch{}return null};function gm({defaultView:e}={}){const[t,n]=b.useState(()=>Uk()??e??"default");b.useEffect(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem(mm,t)}catch{}},[t]);const r=b.useCallback(o=>{n(o)},[]);return{view:t,setView:r}}const Wk=[{key:"default",label:"My chats"},{key:"shared",label:"Shared with you"}];function oi({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:w,shareTargetFilter:S}){const{threads:k,sharedThreads:C,currentThreadId:T,setCurrentThreadId:E,isLoading:j,isLoadingSharedThreads:_,actions:D,shareInFlight:B,shareStatus:z,clearShareStatus:Q}=xr(),{createThread:P,deleteThread:q,renameThread:K,shareThread:W}=D,{loadThread:O}=to(),I=i??T,[U,Z]=b.useState(Array.isArray(k)?k:[]),R=b.useRef(U.length>0),$=b.useRef(null),A=b.useRef(0),[M,X]=b.useState(null),[F,L]=b.useState(""),[J,ee]=b.useState(!1),[G,te]=b.useState(!1),[he,we]=b.useState(null),[ke,Me]=b.useState(""),Ae=v&&v.length>0?v:Wk,Le=gm({defaultView:m}),qe=g??Le,xt=f??qe.view,vt=b.useCallback(Y=>{f||qe.setView(Y),p==null||p(Y)},[f,p,qe]),pt=Ae.find(Y=>Y.key===xt)??Ae[0],Ue=Y=>{we(Y),Me(""),te(!0)},Oe=()=>{te(!1),we(null),Me(""),Q()},Ge=b.useCallback(async Y=>{if(!(!he||B)&&Y.id)try{await W(he,Y.id),setTimeout(()=>Oe(),600)}catch(ce){console.error("Failed to share thread:",ce)}},[Oe,B,he,W]),je=b.useMemo(()=>{const Y=y??[],ce=ke.trim().toLowerCase();return ce?S?Y.filter(ze=>S(ze,ce)):Y.filter(ze=>`${ze.label} ${ze.secondaryLabel??""}`.toLowerCase().includes(ce)):Y},[y,ke,S]),De=xt==="shared",Ze=De?C:U,It=De?_:j,st=De?"No shared conversations yet":"No conversations yet",yt=Y=>{const ce=Y.sharedAt?` • ${$e(Y.sharedAt)}`:"";return`Shared by ${Y.sharedByUserId}${ce}`},St=Y=>"sharedByUserId"in Y;b.useEffect(()=>{const Y=Array.isArray(k)?k:[];if(Y.length>0){R.current=!0,Z(Y);return}j||(R.current=!1,Z(Y))},[k,j]),b.useEffect(()=>{if(!$.current)return;const Y=$.current.querySelector("[data-radix-scroll-area-viewport]");if(!Y)return;let ce=null,ze=null;return ce=requestAnimationFrame(()=>{ze=requestAnimationFrame(()=>{Y.scrollTop=A.current})}),()=>{ce!==null&&cancelAnimationFrame(ce),ze!==null&&cancelAnimationFrame(ze)}},[U]);const Ct=async Y=>{try{E(Y),await O(Y),a==null||a(Y),l==null||l(Y)}catch(ce){console.error("Failed to select thread:",ce)}},kt=async()=>{try{ee(!0);const Y=await P();Y&&(c==null||c(Y),a==null||a(Y))}catch(Y){console.error("Failed to create thread:",Y)}finally{ee(!1)}},on=async(Y,ce)=>{if(ce.stopPropagation(),!!confirm("Delete this thread?")){if($.current){const ze=$.current.querySelector("[data-radix-scroll-area-viewport]");ze&&(A.current=ze.scrollTop)}try{await q(Y),d==null||d(Y)}catch(ze){console.error("Failed to delete thread:",ze)}}},Nt=(Y,ce)=>{ce.stopPropagation(),X(Y.threadId),L(Y.title||`Thread ${Y.threadId.slice(0,8)}`)},Vt=async Y=>{if(F.trim())try{await K(Y,F.trim()),X(null),L("")}catch(ce){console.error("Failed to update title:",ce)}},Et=()=>{X(null),L("")},$e=Y=>{if(!Y)return"";try{const ce=new Date(Y),ge=new Date().getTime()-ce.getTime(),fe=Math.floor(ge/(1e3*60*60*24));return fe===0?ce.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):fe===1?"Yesterday":fe<7?`${fe} days ago`:ce.toLocaleDateString()}catch{return""}},We=Y=>Y.title||`Thread ${Y.threadId.slice(0,8)}`,At=Y=>{const ce=We(Y);return ce.length<=hm?ce:`${ce.slice(0,hm)}...`};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:kt,disabled:J||j,className:s.createButton||"px-3 py-2 gap-1",size:"sm",variant:"ghost",title:J?"Creating...":"New Chat",children:[u.jsx(ae.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(Ts,{children:[u.jsx(ks,{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:pt.label})}),u.jsx(ho,{align:"start",sideOffset:6,className:"w-40",children:Ae.map(Y=>u.jsxs(Fn,{className:"justify-between text-[12px]",onClick:ce=>{ce.preventDefault(),vt(Y.key)},children:[u.jsx("span",{children:Y.label}),xt===Y.key&&u.jsx(ae.Check,{className:"h-3 w-3"})]},Y.key))})]})]})]}),u.jsx(Rl,{ref:$,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:It?u.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[u.jsx(ae.Loader2,{className:"h-5 w-5 animate-spin"}),u.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):Ze.length===0?u.jsxs("div",{className:"text-center py-8 text-slate-400",children:[u.jsx(ae.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:st})]}):Ze.slice().sort((Y,ce)=>new Date(ce.updatedAt||ce.createdAt||"").getTime()-new Date(Y.updatedAt||Y.createdAt||"").getTime()).map(Y=>u.jsx(pm,{thread:Y,isActive:I===Y.threadId,editingThreadId:M,editingTitle:F,onSelect:Ct,onStartEditing:Nt,onEditingTitleChange:ce=>L(ce),onSaveEditing:Vt,onCancelEditing:Et,onShare:()=>Ue(Y.threadId),onDelete:on,showEditTitle:r,showDeleteButton:n,formatDate:$e,getDisplayThreadTitle:At,secondaryLine:De&&St(Y)?yt(Y):void 0,itemClassName:s.threadItem,activeItemClassName:s.activeThread},Y.threadId))})}),u.jsx(tl,{open:G,onOpenChange:Y=>!Y&&Oe(),children:u.jsxs(Hs,{className:"max-w-md p-0",children:[u.jsx(Us,{children:u.jsx(Ws,{children:"Share thread"})}),u.jsxs(Sl,{children:[u.jsx(Cl,{autoFocus:!0,value:ke,onValueChange:Y=>Me(Y),placeholder:"Search for recipients..."}),u.jsxs(Tl,{children:[z&&u.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[B&&u.jsx(ae.Loader2,{className:"h-3 w-3 animate-spin"}),u.jsx("span",{className:z.startsWith("Failed")?"text-red-500":z.startsWith("Shared")?"text-emerald-500":"text-slate-600 dark:text-slate-400",children:z})]}),u.jsx(kl,{children:w?u.jsxs("span",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(ae.Loader2,{className:"h-4 w-4 animate-spin"}),"Loading recipients…"]}):"No matching recipients found"}),je.length>0&&u.jsx(El,{heading:"Recipients",children:je.map(Y=>u.jsx(Il,{onSelect:()=>Ge(Y),children:u.jsxs("div",{className:"flex flex-col items-start text-sm",children:[u.jsx("span",{className:"font-medium",children:Y.label}),Y.secondaryLabel&&u.jsx("span",{className:"text-xs text-muted-foreground",children:Y.secondaryLabel})]})},Y.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=b.useCallback(c=>{var d;(d=s.onThreadChange)==null||d.call(s,c)},[s]);return e==="fullscreen"?u.jsx(wr,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsx(Or,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?u.jsx(wr,{...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(oi,{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(Or,{onError:s.onError,enableFileUpload:!0})})]})})}):u.jsx(wr,{...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(oi,{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(Or,{onError:s.onError,enableFileUpload:!0})})]})})}function Kk({apiConfig:e,className:t="",onError:n}){return u.jsx(wr,{apiConfig:e,onError:n,children:u.jsx("div",{className:`h-full ${t}`,children:u.jsx(Or,{})})})}function qk({placeholder:e,onMessageSent:t}){const[n,r]=b.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(ae.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(ae.History,{size:14}),"History"]})})]}),u.jsx("div",{className:"flex-1 min-h-0",children:n==="chat"?u.jsx(Or,{placeholder:e??"Ask Serti AI anything...",autoFocus:!0,className:"h-full",onMessageSent:t}):u.jsx(oi,{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]=b.useState(!1);return n?u.jsx(wr,{...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(ae.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(ae.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(ae.Maximize2,{size:14}):u.jsx(ae.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:oe("gap-2 rounded-full px-3 font-semibold transition-all hover:scale-[1.01]",n),...s,children:[u.jsx(ae.Edit3,{size:16}),t??e]})}var Xk="Label",xm=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())}}));xm.displayName=Xk;var vm=xm;const Jk=Hr.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),bm=h.forwardRef(({className:e,...t},n)=>u.jsx(vm,{ref:n,className:oe(Jk(),e),...t}));bm.displayName=vm.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 ym=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",si=h.forwardRef((e,t)=>u.jsx(pe.span,{...e,ref:t,style:{...ym,...e.style}}));si.displayName=Zk;var Qk=si,eE=[" ","Enter","ArrowUp","ArrowDown"],tE=[" ","Enter"],dr="Select",[ii,ai,nE]=Jo(dr),[Fr,UN]=ln(dr,[nE,Ir]),li=Ir(),[rE,Gn]=Fr(dr),[oE,sE]=Fr(dr),Sm=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=li(t),[x,y]=h.useState(null),[w,S]=h.useState(null),[k,C]=h.useState(!1),T=Zo(c),[E,j]=On({prop:r,defaultProp:o??!1,onChange:s,caller:dr}),[_,D]=On({prop:i,defaultProp:a,onChange:l,caller:dr}),B=h.useRef(null),z=x?v||!!x.closest("form"):!0,[Q,P]=h.useState(new Set),q=Array.from(Q).map(K=>K.props.value).join(";");return u.jsx(ia,{...g,children:u.jsxs(rE,{required:p,scope:t,trigger:x,onTriggerChange:y,valueNode:w,onValueNodeChange:S,valueNodeHasChildren:k,onValueNodeHasChildrenChange:C,contentId:_t(),value:_,onValueChange:D,open:E,onOpenChange:j,dir:T,triggerPointerDownPosRef:B,disabled:m,children:[u.jsx(ii.Provider,{scope:t,children:u.jsx(oE,{scope:e.__scopeSelect,onNativeOptionAdd:h.useCallback(K=>{P(W=>new Set(W).add(K))},[]),onNativeOptionRemove:h.useCallback(K=>{P(W=>{const O=new Set(W);return O.delete(K),O})},[]),children:n})}),z?u.jsxs(Km,{"aria-hidden":!0,required:p,tabIndex:-1,name:d,autoComplete:f,value:_,onChange:K=>D(K.target.value),disabled:m,form:v,children:[_===void 0?u.jsx("option",{value:""}):null,Array.from(Q)]},q):null]})})};Sm.displayName=dr;var Cm="SelectTrigger",Tm=h.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=li(n),i=Gn(Cm,n),a=i.disabled||r,l=Pe(t,i.onTriggerChange),c=ai(n),d=h.useRef("touch"),[f,m,p]=Gm(g=>{const x=c().filter(S=>!S.disabled),y=x.find(S=>S.value===i.value),w=Ym(x,g,y);w!==void 0&&i.onValueChange(w.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(aa,{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":qm(i.value)?"":void 0,...o,ref:l,onClick:ie(o.onClick,g=>{g.currentTarget.focus(),d.current!=="mouse"&&v(g)}),onPointerDown:ie(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:ie(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())})})})});Tm.displayName=Cm;var km="SelectValue",Em=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=Gn(km,n),{onValueNodeHasChildrenChange:c}=l,d=s!==void 0,f=Pe(t,l.onValueNodeChange);return Tt(()=>{c(d)},[c,d]),u.jsx(pe.span,{...a,ref:f,style:{pointerEvents:"none"},children:qm(l.value)?u.jsx(u.Fragment,{children:i}):s})});Em.displayName=km;var iE="SelectIcon",Im=h.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return u.jsx(pe.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});Im.displayName=iE;var aE="SelectPortal",Nm=e=>u.jsx(io,{asChild:!0,...e});Nm.displayName=aE;var fr="SelectContent",Am=h.forwardRef((e,t)=>{const n=Gn(fr,e.__scopeSelect),[r,o]=h.useState();if(Tt(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?Ur.createPortal(u.jsx(jm,{scope:e.__scopeSelect,children:u.jsx(ii.Slot,{scope:e.__scopeSelect,children:u.jsx("div",{children:e.children})})}),s):null}return u.jsx(_m,{...e,ref:t})});Am.displayName=fr;var hn=10,[jm,Yn]=Fr(fr),lE="SelectContentImpl",cE=qt.createSlot("SelectContent.RemoveScroll"),_m=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,w=Gn(fr,n),[S,k]=h.useState(null),[C,T]=h.useState(null),E=Pe(t,F=>k(F)),[j,_]=h.useState(null),[D,B]=h.useState(null),z=ai(n),[Q,P]=h.useState(!1),q=h.useRef(!1);h.useEffect(()=>{if(S)return pa(S)},[S]),Wi();const K=h.useCallback(F=>{const[L,...J]=z().map(te=>te.ref.current),[ee]=J.slice(-1),G=document.activeElement;for(const te of F)if(te===G||(te==null||te.scrollIntoView({block:"nearest"}),te===L&&C&&(C.scrollTop=0),te===ee&&C&&(C.scrollTop=C.scrollHeight),te==null||te.focus(),document.activeElement!==G))return},[z,C]),W=h.useCallback(()=>K([j,S]),[K,j,S]);h.useEffect(()=>{Q&&W()},[Q,W]);const{onOpenChange:O,triggerPointerDownPosRef:I}=w;h.useEffect(()=>{if(S){let F={x:0,y:0};const L=ee=>{var G,te;F={x:Math.abs(Math.round(ee.pageX)-(((G=I.current)==null?void 0:G.x)??0)),y:Math.abs(Math.round(ee.pageY)-(((te=I.current)==null?void 0:te.y)??0))}},J=ee=>{F.x<=10&&F.y<=10?ee.preventDefault():S.contains(ee.target)||O(!1),document.removeEventListener("pointermove",L),I.current=null};return I.current!==null&&(document.addEventListener("pointermove",L),document.addEventListener("pointerup",J,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",L),document.removeEventListener("pointerup",J,{capture:!0})}}},[S,O,I]),h.useEffect(()=>{const F=()=>O(!1);return window.addEventListener("blur",F),window.addEventListener("resize",F),()=>{window.removeEventListener("blur",F),window.removeEventListener("resize",F)}},[O]);const[U,Z]=Gm(F=>{const L=z().filter(G=>!G.disabled),J=L.find(G=>G.ref.current===document.activeElement),ee=Ym(L,F,J);ee&&setTimeout(()=>ee.ref.current.focus())}),R=h.useCallback((F,L,J)=>{const ee=!q.current&&!J;(w.value!==void 0&&w.value===L||ee)&&(_(F),ee&&(q.current=!0))},[w.value]),$=h.useCallback(()=>S==null?void 0:S.focus(),[S]),A=h.useCallback((F,L,J)=>{const ee=!q.current&&!J;(w.value!==void 0&&w.value===L||ee)&&B(F)},[w.value]),M=r==="popper"?Ol:Pm,X=M===Ol?{side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:f,collisionBoundary:m,collisionPadding:p,sticky:v,hideWhenDetached:g,avoidCollisions:x}:{};return u.jsx(jm,{scope:n,content:S,viewport:C,onViewportChange:T,itemRefCallback:R,selectedItem:j,onItemLeave:$,itemTextRefCallback:A,focusSelectedItem:W,selectedItemText:D,position:r,isPositioned:Q,searchRef:U,children:u.jsx(vs,{as:cE,allowPinchZoom:!0,children:u.jsx(Qo,{asChild:!0,trapped:w.open,onMountAutoFocus:F=>{F.preventDefault()},onUnmountAutoFocus:ie(o,F=>{var L;(L=w.trigger)==null||L.focus({preventScroll:!0}),F.preventDefault()}),children:u.jsx(Sr,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:F=>F.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:u.jsx(M,{role:"listbox",id:w.contentId,"data-state":w.open?"open":"closed",dir:w.dir,onContextMenu:F=>F.preventDefault(),...y,...X,onPlaced:()=>P(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:ie(y.onKeyDown,F=>{const L=F.ctrlKey||F.altKey||F.metaKey;if(F.key==="Tab"&&F.preventDefault(),!L&&F.key.length===1&&Z(F.key),["ArrowUp","ArrowDown","Home","End"].includes(F.key)){let ee=z().filter(G=>!G.disabled).map(G=>G.ref.current);if(["ArrowUp","End"].includes(F.key)&&(ee=ee.slice().reverse()),["ArrowUp","ArrowDown"].includes(F.key)){const G=F.target,te=ee.indexOf(G);ee=ee.slice(te+1)}setTimeout(()=>K(ee)),F.preventDefault()}})})})})})})});_m.displayName=lE;var uE="SelectItemAlignedPosition",Pm=h.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=Gn(fr,n),i=Yn(fr,n),[a,l]=h.useState(null),[c,d]=h.useState(null),f=Pe(t,E=>d(E)),m=ai(n),p=h.useRef(!1),v=h.useRef(!0),{viewport:g,selectedItem:x,selectedItemText:y,focusSelectedItem:w}=i,S=h.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&c&&g&&x&&y){const E=s.trigger.getBoundingClientRect(),j=c.getBoundingClientRect(),_=s.valueNode.getBoundingClientRect(),D=y.getBoundingClientRect();if(s.dir!=="rtl"){const G=D.left-j.left,te=_.left-G,he=E.left-te,we=E.width+he,ke=Math.max(we,j.width),Me=window.innerWidth-hn,Ae=Nl(te,[hn,Math.max(hn,Me-ke)]);a.style.minWidth=we+"px",a.style.left=Ae+"px"}else{const G=j.right-D.right,te=window.innerWidth-_.right-G,he=window.innerWidth-E.right-te,we=E.width+he,ke=Math.max(we,j.width),Me=window.innerWidth-hn,Ae=Nl(te,[hn,Math.max(hn,Me-ke)]);a.style.minWidth=we+"px",a.style.right=Ae+"px"}const B=m(),z=window.innerHeight-hn*2,Q=g.scrollHeight,P=window.getComputedStyle(c),q=parseInt(P.borderTopWidth,10),K=parseInt(P.paddingTop,10),W=parseInt(P.borderBottomWidth,10),O=parseInt(P.paddingBottom,10),I=q+K+Q+O+W,U=Math.min(x.offsetHeight*5,I),Z=window.getComputedStyle(g),R=parseInt(Z.paddingTop,10),$=parseInt(Z.paddingBottom,10),A=E.top+E.height/2-hn,M=z-A,X=x.offsetHeight/2,F=x.offsetTop+X,L=q+K+F,J=I-L;if(L<=A){const G=B.length>0&&x===B[B.length-1].ref.current;a.style.bottom="0px";const te=c.clientHeight-g.offsetTop-g.offsetHeight,he=Math.max(M,X+(G?$:0)+te+W),we=L+he;a.style.height=we+"px"}else{const G=B.length>0&&x===B[0].ref.current;a.style.top="0px";const he=Math.max(A,q+g.offsetTop+(G?R:0)+X)+J;a.style.height=he+"px",g.scrollTop=L-A+g.offsetTop}a.style.margin=`${hn}px 0`,a.style.minHeight=U+"px",a.style.maxHeight=z+"px",r==null||r(),requestAnimationFrame(()=>p.current=!0)}},[m,s.trigger,s.valueNode,a,c,g,x,y,s.dir,r]);Tt(()=>S(),[S]);const[k,C]=h.useState();Tt(()=>{c&&C(window.getComputedStyle(c).zIndex)},[c]);const T=h.useCallback(E=>{E&&v.current===!0&&(S(),w==null||w(),v.current=!1)},[S,w]);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",Ol=h.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=hn,...s}=e,i=li(n);return u.jsx(la,{...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)"}})});Ol.displayName=dE;var[fE,Dl]=Fr(fr,{}),Ll="SelectViewport",Rm=h.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Yn(Ll,n),i=Dl(Ll,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(ii.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:ie(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-hn*2,g=parseFloat(f.style.minHeight),x=parseFloat(f.style.height),y=Math.max(g,x);if(y<v){const w=y+p,S=Math.min(v,w),k=w-S;f.style.height=S+"px",f.style.bottom==="0px"&&(d.scrollTop=k>0?k:0,f.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});Rm.displayName=Ll;var Mm="SelectGroup",[pE,hE]=Fr(Mm),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=Mm;var Om="SelectLabel",Dm=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=hE(Om,n);return u.jsx(pe.div,{id:o.id,...r,ref:t})});Dm.displayName=Om;var ci="SelectItem",[gE,Lm]=Fr(ci),$m=h.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=Gn(ci,n),l=Yn(ci,n),c=a.value===r,[d,f]=h.useState(s??""),[m,p]=h.useState(!1),v=Pe(t,w=>{var S;return(S=l.itemRefCallback)==null?void 0:S.call(l,w,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(w=>{f(S=>S||((w==null?void 0:w.textContent)??"").trim())},[]),children:u.jsx(ii.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:ie(i.onFocus,()=>p(!0)),onBlur:ie(i.onBlur,()=>p(!1)),onClick:ie(i.onClick,()=>{x.current!=="mouse"&&y()}),onPointerUp:ie(i.onPointerUp,()=>{x.current==="mouse"&&y()}),onPointerDown:ie(i.onPointerDown,w=>{x.current=w.pointerType}),onPointerMove:ie(i.onPointerMove,w=>{var S;x.current=w.pointerType,o?(S=l.onItemLeave)==null||S.call(l):x.current==="mouse"&&w.currentTarget.focus({preventScroll:!0})}),onPointerLeave:ie(i.onPointerLeave,w=>{var S;w.currentTarget===document.activeElement&&((S=l.onItemLeave)==null||S.call(l))}),onKeyDown:ie(i.onKeyDown,w=>{var k;((k=l.searchRef)==null?void 0:k.current)!==""&&w.key===" "||(tE.includes(w.key)&&y(),w.key===" "&&w.preventDefault())})})})})});$m.displayName=ci;var _o="SelectItemText",Fm=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=Gn(_o,n),a=Yn(_o,n),l=Lm(_o,n),c=sE(_o,n),[d,f]=h.useState(null),m=Pe(t,y=>f(y),l.onItemTextChange,y=>{var w;return(w=a.itemTextRefCallback)==null?void 0:w.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 Tt(()=>(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?Ur.createPortal(s.children,i.valueNode):null]})});Fm.displayName=_o;var Bm="SelectItemIndicator",zm=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Lm(Bm,n).isSelected?u.jsx(pe.span,{"aria-hidden":!0,...r,ref:t}):null});zm.displayName=Bm;var $l="SelectScrollUpButton",Hm=h.forwardRef((e,t)=>{const n=Yn($l,e.__scopeSelect),r=Dl($l,e.__scopeSelect),[o,s]=h.useState(!1),i=Pe(t,r.onScrollButtonChange);return Tt(()=>{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(Wm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});Hm.displayName=$l;var Fl="SelectScrollDownButton",Um=h.forwardRef((e,t)=>{const n=Yn(Fl,e.__scopeSelect),r=Dl(Fl,e.__scopeSelect),[o,s]=h.useState(!1),i=Pe(t,r.onScrollButtonChange);return Tt(()=>{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(Wm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});Um.displayName=Fl;var Wm=h.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=Yn("SelectScrollButton",n),i=h.useRef(null),a=ai(n),l=h.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return h.useEffect(()=>()=>l(),[l]),Tt(()=>{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:ie(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:ie(o.onPointerMove,()=>{var c;(c=s.onItemLeave)==null||c.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:ie(o.onPointerLeave,()=>{l()})})}),xE="SelectSeparator",Vm=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return u.jsx(pe.div,{"aria-hidden":!0,...r,ref:t})});Vm.displayName=xE;var Bl="SelectArrow",vE=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=li(n),s=Gn(Bl,n),i=Yn(Bl,n);return s.open&&i.position==="popper"?u.jsx(ca,{...o,...r,ref:t}):null});vE.displayName=Bl;var bE="SelectBubbleInput",Km=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:{...ym,...n.style},ref:s,defaultValue:t})});Km.displayName=bE;function qm(e){return e===""||e===void 0}function Gm(e){const t=dt(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 Ym(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=wE(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 wE(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var yE=Sm,Xm=Tm,SE=Em,CE=Im,TE=Nm,Jm=Am,kE=Rm,Zm=Dm,Qm=$m,EE=Fm,IE=zm,eg=Hm,tg=Um,ng=Vm;const NE=yE,AE=SE,rg=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Xm,{ref:r,className:oe("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(ae.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));rg.displayName=Xm.displayName;const og=h.forwardRef(({className:e,...t},n)=>u.jsx(eg,{ref:n,className:oe("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(ae.ChevronUp,{className:"h-4 w-4"})}));og.displayName=eg.displayName;const sg=h.forwardRef(({className:e,...t},n)=>u.jsx(tg,{ref:n,className:oe("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(ae.ChevronDown,{className:"h-4 w-4"})}));sg.displayName=tg.displayName;const ig=h.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>u.jsx(TE,{children:u.jsxs(Jm,{ref:o,className:oe("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(og,{}),u.jsx(kE,{className:oe("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),u.jsx(sg,{})]})}));ig.displayName=Jm.displayName;const jE=h.forwardRef(({className:e,...t},n)=>u.jsx(Zm,{ref:n,className:oe("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));jE.displayName=Zm.displayName;const ag=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Qm,{ref:r,className:oe("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(ae.Check,{className:"h-4 w-4"})})}),u.jsx(EE,{children:t})]}));ag.displayName=Qm.displayName;const _E=h.forwardRef(({className:e,...t},n)=>u.jsx(ng,{ref:n,className:oe("-mx-1 my-1 h-px bg-muted",e),...t}));_E.displayName=ng.displayName;var PE="Separator",lg="horizontal",RE=["horizontal","vertical"],cg=h.forwardRef((e,t)=>{const{decorative:n,orientation:r=lg,...o}=e,s=ME(r)?r:lg,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})});cg.displayName=PE;function ME(e){return RE.includes(e)}var ug=cg;const dg=h.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>u.jsx(ug,{ref:o,decorative:n,orientation:t,className:oe("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));dg.displayName=ug.displayName;var ui="Switch",[OE,WN]=ln(ui),[DE,LE]=OE(ui),fg=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,S=>p(S)),g=h.useRef(!1),x=m?d||!!m.closest("form"):!0,[y,w]=On({prop:o,defaultProp:s??!1,onChange:c,caller:ui});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":gg(y),"data-disabled":a?"":void 0,disabled:a,value:l,...f,ref:v,onClick:ie(e.onClick,S=>{w(k=>!k),x&&(g.current=S.isPropagationStopped(),g.current||S.stopPropagation())})}),x&&u.jsx(mg,{control:m,bubbles:!g.current,name:r,value:l,checked:y,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});fg.displayName=ui;var pg="SwitchThumb",hg=h.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=LE(pg,n);return u.jsx(pe.span,{"data-state":gg(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});hg.displayName=pg;var $E="SwitchBubbleInput",mg=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=yd(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}})});mg.displayName=$E;function gg(e){return e?"checked":"unchecked"}var xg=fg,FE=hg;const vg=h.forwardRef(({className:e,...t},n)=>u.jsx(xg,{className:oe("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:oe("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")})}));vg.displayName=xg.displayName;const BE=Qa,zE=mT,HE=el,bg=h.forwardRef(({className:e,...t},n)=>u.jsx(ko,{className:oe("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}));bg.displayName=ko.displayName;const UE=Hr.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(bg,{}),u.jsxs(Eo,{ref:o,className:oe(UE({side:e}),t),...r,children:[n,u.jsxs(ah,{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(ae.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));wg.displayName=Eo.displayName;const yg=({className:e,...t})=>u.jsx("div",{className:oe("flex flex-col space-y-2 text-center sm:text-left",e),...t});yg.displayName="SheetHeader";const Sg=h.forwardRef(({className:e,...t},n)=>u.jsx(lr,{ref:n,className:oe("text-lg font-semibold text-foreground",e),...t}));Sg.displayName=lr.displayName;const Cg=h.forwardRef(({className:e,...t},n)=>u.jsx(zs,{ref:n,className:oe("text-sm text-muted-foreground",e),...t}));Cg.displayName=zs.displayName;var[di,VN]=ln("Tooltip",[Ir]),fi=Ir(),Tg="TooltipProvider",WE=700,zl="tooltip.open",[VE,Hl]=di(Tg),kg=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})};kg.displayName=Tg;var Po="Tooltip",[KE,pi]=di(Po),Eg=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:s,disableHoverableContent:i,delayDuration:a}=e,l=Hl(Po,e.__scopeTooltip),c=fi(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,w]=On({prop:r,defaultProp:o??!1,onChange:E=>{E?(l.onOpen(),document.dispatchEvent(new CustomEvent(zl))):l.onClose(),s==null||s(E)},caller:Po}),S=h.useMemo(()=>y?x.current?"delayed-open":"instant-open":"closed",[y]),k=h.useCallback(()=>{window.clearTimeout(p.current),p.current=0,x.current=!1,w(!0)},[w]),C=h.useCallback(()=>{window.clearTimeout(p.current),p.current=0,w(!1)},[w]),T=h.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{x.current=!0,w(!0),p.current=0},g)},[g,w]);return h.useEffect(()=>()=>{p.current&&(window.clearTimeout(p.current),p.current=0)},[]),u.jsx(ia,{...c,children:u.jsx(KE,{scope:t,contentId:m,open:y,stateAttribute:S,trigger:d,onTriggerChange:f,onTriggerEnter:h.useCallback(()=>{l.isOpenDelayedRef.current?T():k()},[l.isOpenDelayedRef,T,k]),onTriggerLeave:h.useCallback(()=>{v?C():(window.clearTimeout(p.current),p.current=0)},[C,v]),onOpen:k,onClose:C,disableHoverableContent:v,children:n})})};Eg.displayName=Po;var Ul="TooltipTrigger",Ig=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=pi(Ul,n),s=Hl(Ul,n),i=fi(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(aa,{asChild:!0,...i,children:u.jsx(pe.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:l,onPointerMove:ie(e.onPointerMove,m=>{m.pointerType!=="touch"&&!d.current&&!s.isPointerInTransitRef.current&&(o.onTriggerEnter(),d.current=!0)}),onPointerLeave:ie(e.onPointerLeave,()=>{o.onTriggerLeave(),d.current=!1}),onPointerDown:ie(e.onPointerDown,()=>{o.open&&o.onClose(),c.current=!0,document.addEventListener("pointerup",f,{once:!0})}),onFocus:ie(e.onFocus,()=>{c.current||o.onOpen()}),onBlur:ie(e.onBlur,o.onClose),onClick:ie(e.onClick,o.onClose)})})});Ig.displayName=Ul;var qE="TooltipPortal",[KN,GE]=di(qE,{forceMount:void 0}),Br="TooltipContent",Ng=h.forwardRef((e,t)=>{const n=GE(Br,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,i=pi(Br,e.__scopeTooltip);return u.jsx(zt,{present:r||i.open,children:i.disableHoverableContent?u.jsx(Ag,{side:o,...s,ref:t}):u.jsx(YE,{side:o,...s,ref:t})})}),YE=h.forwardRef((e,t)=>{const n=pi(Br,e.__scopeTooltip),r=Hl(Br,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},w=eI(y,x.getBoundingClientRect()),S=tI(y,w),k=nI(g.getBoundingClientRect()),C=oI([...S,...k]);a(C),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},w=(l==null?void 0:l.contains(x))||(d==null?void 0:d.contains(x)),S=!rI(y,i);w?m():S&&(m(),c())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[l,d,i,c,m]),u.jsx(Ag,{...e,ref:s})}),[XE,JE]=di(Po,{isInside:!1}),ZE=qt.createSlottable("TooltipContent"),Ag=h.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:i,...a}=e,l=pi(Br,n),c=fi(n),{onClose:d}=l;return h.useEffect(()=>(document.addEventListener(zl,d),()=>document.removeEventListener(zl,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(Sr,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:f=>f.preventDefault(),onDismiss:d,children:u.jsxs(la,{"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})})]})})});Ng.displayName=Br;var jg="TooltipArrow",QE=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=fi(n);return JE(jg,n).isInside?null:u.jsx(ca,{...o,...r,ref:t})});QE.displayName=jg;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=kg,aI=Eg,lI=Ig,_g=Ng;const cI=iI,uI=aI,dI=lI,Pg=h.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(_g,{ref:r,sideOffset:t,className:oe("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=_g.displayName;var Wl="ToastProvider",[Vl,fI,pI]=Jo("Toast"),[Rg,qN]=ln("Toast",[pI]),[hI,hi]=Rg(Wl),Mg=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 \`${Wl}\`. Expected non-empty \`string\`.`),u.jsx(Vl.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})})};Mg.displayName=Wl;var Og="ToastViewport",mI=["F8"],Kl="toast.viewportPause",ql="toast.viewportResume",Dg=h.forwardRef((e,t)=>{const{__scopeToast:n,hotkey:r=mI,label:o="Notifications ({hotkey})",...s}=e,i=hi(Og,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 S;r.length!==0&&r.every(k=>y[k]||y.code===k)&&((S=f.current)==null||S.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 w=()=>{if(!i.isClosePausedRef.current){const T=new CustomEvent(Kl);y.dispatchEvent(T),i.isClosePausedRef.current=!0}},S=()=>{if(i.isClosePausedRef.current){const T=new CustomEvent(ql);y.dispatchEvent(T),i.isClosePausedRef.current=!1}},k=T=>{!x.contains(T.relatedTarget)&&S()},C=()=>{x.contains(document.activeElement)||S()};return x.addEventListener("focusin",w),x.addEventListener("focusout",k),x.addEventListener("pointermove",w),x.addEventListener("pointerleave",C),window.addEventListener("blur",w),window.addEventListener("focus",S),()=>{x.removeEventListener("focusin",w),x.removeEventListener("focusout",k),x.removeEventListener("pointermove",w),x.removeEventListener("pointerleave",C),window.removeEventListener("blur",w),window.removeEventListener("focus",S)}}},[v,i.isClosePausedRef]);const g=h.useCallback(({tabbingDirection:x})=>{const w=a().map(S=>{const k=S.ref.current,C=[k,...NI(k)];return x==="forwards"?C:C.reverse()});return(x==="forwards"?w.reverse():w).flat()},[a]);return h.useEffect(()=>{const x=f.current;if(x){const y=w=>{var C,T,E;const S=w.altKey||w.ctrlKey||w.metaKey;if(w.key==="Tab"&&!S){const j=document.activeElement,_=w.shiftKey;if(w.target===x&&_){(C=c.current)==null||C.focus();return}const z=g({tabbingDirection:_?"backwards":"forwards"}),Q=z.findIndex(P=>P===j);Xl(z.slice(Q+1))?w.preventDefault():_?(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(Ub,{ref:l,role:"region","aria-label":o.replace("{hotkey}",p),tabIndex:-1,style:{pointerEvents:v?void 0:"none"},children:[v&&u.jsx(Gl,{ref:c,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"forwards"});Xl(x)}}),u.jsx(Vl.Slot,{scope:n,children:u.jsx(pe.ol,{tabIndex:-1,...s,ref:m})}),v&&u.jsx(Gl,{ref:d,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"backwards"});Xl(x)}})]})});Dg.displayName=Og;var Lg="ToastFocusProxy",Gl=h.forwardRef((e,t)=>{const{__scopeToast:n,onFocusFromOutsideViewport:r,...o}=e,s=hi(Lg,n);return u.jsx(si,{tabIndex:0,...o,ref:t,style:{position:"fixed"},onFocus:i=>{var c;const a=i.relatedTarget;!((c=s.viewport)!=null&&c.contains(a))&&r()}})});Gl.displayName=Lg;var Ro="Toast",gI="toast.swipeStart",xI="toast.swipeMove",vI="toast.swipeCancel",bI="toast.swipeEnd",$g=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:Ro});return u.jsx(zt,{present:n||a,children:u.jsx(SI,{open:a,...i,ref:t,onClose:()=>l(!1),onPause:dt(e.onPause),onResume:dt(e.onResume),onSwipeStart:ie(e.onSwipeStart,c=>{c.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:ie(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:ie(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:ie(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)})})})});$g.displayName=Ro;var[wI,yI]=Rg(Ro,{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=hi(Ro,n),[x,y]=h.useState(null),w=Pe(t,P=>y(P)),S=h.useRef(null),k=h.useRef(null),C=o||g.duration,T=h.useRef(0),E=h.useRef(C),j=h.useRef(0),{onToastAdd:_,onToastRemove:D}=g,B=dt(()=>{var q;(x==null?void 0:x.contains(document.activeElement))&&((q=g.viewport)==null||q.focus()),i()}),z=h.useCallback(P=>{!P||P===1/0||(window.clearTimeout(j.current),T.current=new Date().getTime(),j.current=window.setTimeout(B,P))},[B]);h.useEffect(()=>{const P=g.viewport;if(P){const q=()=>{z(E.current),c==null||c()},K=()=>{const W=new Date().getTime()-T.current;E.current=E.current-W,window.clearTimeout(j.current),l==null||l()};return P.addEventListener(Kl,K),P.addEventListener(ql,q),()=>{P.removeEventListener(Kl,K),P.removeEventListener(ql,q)}}},[g.viewport,C,l,c,z]),h.useEffect(()=>{s&&!g.isClosePausedRef.current&&z(C)},[s,C,g.isClosePausedRef,z]),h.useEffect(()=>(_(),()=>D()),[_,D]);const Q=h.useMemo(()=>x?Vg(x):null,[x]);return g.viewport?u.jsxs(u.Fragment,{children:[Q&&u.jsx(CI,{__scopeToast:n,role:"status","aria-live":r==="foreground"?"assertive":"polite",children:Q}),u.jsx(wI,{scope:n,onClose:B,children:Ur.createPortal(u.jsx(Vl.ItemSlot,{scope:n,children:u.jsx(Hb,{asChild:!0,onEscapeKeyDown:ie(a,()=>{g.isFocusedToastEscapeKeyDownRef.current||B(),g.isFocusedToastEscapeKeyDownRef.current=!1}),children:u.jsx(pe.li,{tabIndex:0,"data-state":s?"open":"closed","data-swipe-direction":g.swipeDirection,...v,ref:w,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:ie(e.onKeyDown,P=>{P.key==="Escape"&&(a==null||a(P.nativeEvent),P.nativeEvent.defaultPrevented||(g.isFocusedToastEscapeKeyDownRef.current=!0,B()))}),onPointerDown:ie(e.onPointerDown,P=>{P.button===0&&(S.current={x:P.clientX,y:P.clientY})}),onPointerMove:ie(e.onPointerMove,P=>{if(!S.current)return;const q=P.clientX-S.current.x,K=P.clientY-S.current.y,W=!!k.current,O=["left","right"].includes(g.swipeDirection),I=["left","up"].includes(g.swipeDirection)?Math.min:Math.max,U=O?I(0,q):0,Z=O?0:I(0,K),R=P.pointerType==="touch"?10:2,$={x:U,y:Z},A={originalEvent:P,delta:$};W?(k.current=$,mi(xI,f,A,{discrete:!1})):Kg($,g.swipeDirection,R)?(k.current=$,mi(gI,d,A,{discrete:!1}),P.target.setPointerCapture(P.pointerId)):(Math.abs(q)>R||Math.abs(K)>R)&&(S.current=null)}),onPointerUp:ie(e.onPointerUp,P=>{const q=k.current,K=P.target;if(K.hasPointerCapture(P.pointerId)&&K.releasePointerCapture(P.pointerId),k.current=null,S.current=null,q){const W=P.currentTarget,O={originalEvent:P,delta:q};Kg(q,g.swipeDirection,g.swipeThreshold)?mi(bI,p,O,{discrete:!0}):mi(vI,m,O,{discrete:!0}),W.addEventListener("click",I=>I.preventDefault(),{once:!0})}})})})}),g.viewport)})]}):null}),CI=e=>{const{__scopeToast:t,children:n,...r}=e,o=hi(Ro,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(io,{asChild:!0,children:u.jsx(si,{...r,children:s&&u.jsxs(u.Fragment,{children:[o.label," ",n]})})})},TI="ToastTitle",Fg=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(pe.div,{...r,ref:t})});Fg.displayName=TI;var kI="ToastDescription",Bg=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(pe.div,{...r,ref:t})});Bg.displayName=kI;var zg="ToastAction",Hg=h.forwardRef((e,t)=>{const{altText:n,...r}=e;return n.trim()?u.jsx(Wg,{altText:n,asChild:!0,children:u.jsx(Yl,{...r,ref:t})}):(console.error(`Invalid prop \`altText\` supplied to \`${zg}\`. Expected non-empty \`string\`.`),null)});Hg.displayName=zg;var Ug="ToastClose",Yl=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e,o=yI(Ug,n);return u.jsx(Wg,{asChild:!0,children:u.jsx(pe.button,{type:"button",...r,ref:t,onClick:ie(e.onClick,o.onClose)})})});Yl.displayName=Ug;var Wg=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 Vg(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(...Vg(r))}}),t}function mi(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?zi(o,s):o.dispatchEvent(s)}var Kg=(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=dt(e);Tt(()=>{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 Xl(e){const t=document.activeElement;return e.some(n=>n===t?!0:(n.focus(),document.activeElement!==t))}var AI=Mg,qg=Dg,Gg=$g,Yg=Fg,Xg=Bg,Jg=Hg,Zg=Yl;const jI=AI,Qg=h.forwardRef(({className:e,...t},n)=>u.jsx(qg,{ref:n,className:oe("fixed bottom-0 right-0 z-[100] flex max-h-screen w-full flex-col p-4 md:max-w-[420px]",e),...t}));Qg.displayName=qg.displayName;const _I=Hr.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"}}),ex=h.forwardRef(({className:e,variant:t,...n},r)=>u.jsx(Gg,{ref:r,className:oe(_I({variant:t}),e),...n}));ex.displayName=Gg.displayName;const PI=h.forwardRef(({className:e,...t},n)=>u.jsx(Jg,{ref:n,className:oe("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}));PI.displayName=Jg.displayName;const tx=h.forwardRef(({className:e,...t},n)=>u.jsx(Zg,{ref:n,className:oe("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(ae.X,{className:"h-4 w-4"})}));tx.displayName=Zg.displayName;const nx=h.forwardRef(({className:e,...t},n)=>u.jsx(Yg,{ref:n,className:oe("text-sm font-semibold",e),...t}));nx.displayName=Yg.displayName;const rx=h.forwardRef(({className:e,...t},n)=>u.jsx(Xg,{ref:n,className:oe("text-sm opacity-90",e),...t}));rx.displayName=Xg.displayName;function RI(){const{toasts:e}=ol();return u.jsxs(jI,{children:[e.map(function({id:t,title:n,description:r,action:o,...s}){return u.jsxs(ex,{...s,children:[u.jsxs("div",{className:"grid gap-1",children:[n&&u.jsx(nx,{children:n}),r&&u.jsx(rx,{children:r})]}),o,u.jsx(tx,{})]},t)}),u.jsx(Qg,{})]})}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})=>b.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},b.createElement("div",{className:"sonner-spinner"},FI.map((n,r)=>b.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),zI=b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},b.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=b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},b.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=b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},b.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=b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},b.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=b.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"},b.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),b.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),KI=()=>{let[e,t]=b.useState(document.hidden);return b.useEffect(()=>{let n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e},Jl=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:Jl++,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],b.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)||Jl++;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}},Wt=new qI,GI=(e,t)=>{let n=(t==null?void 0:t.id)||Jl++;return Wt.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=()=>Wt.toasts,ZI=()=>Wt.getActiveToasts();Object.assign(XI,{success:Wt.success,info:Wt.info,warning:Wt.warning,error:Wt.error,custom:Wt.custom,message:Wt.message,promise:Wt.promise,dismiss:Wt.dismiss,loading:Wt.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 gi(e){return e.label!==void 0}var eN=3,tN="32px",nN="16px",ox=4e3,rN=356,oN=14,sN=20,iN=200;function mn(...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:w,index:S,toasts:k,expanded:C,removeToast:T,defaultRichColors:E,closeButton:j,style:_,cancelButtonStyle:D,actionButtonStyle:B,className:z="",descriptionClassName:Q="",duration:P,position:q,gap:K,loadingIcon:W,expandByDefault:O,classNames:I,icons:U,closeButtonAriaLabel:Z="Close toast",pauseWhenPageIsHidden:R}=e,[$,A]=b.useState(null),[M,X]=b.useState(null),[F,L]=b.useState(!1),[J,ee]=b.useState(!1),[G,te]=b.useState(!1),[he,we]=b.useState(!1),[ke,Me]=b.useState(!1),[Ae,Le]=b.useState(0),[qe,xt]=b.useState(0),vt=b.useRef(p.duration||P||ox),pt=b.useRef(null),Ue=b.useRef(null),Oe=S===0,Ge=S+1<=y,je=p.type,De=p.dismissible!==!1,Ze=p.className||"",It=p.descriptionClassName||"",st=b.useMemo(()=>w.findIndex(ge=>ge.toastId===p.id)||0,[w,p.id]),yt=b.useMemo(()=>{var ge;return(ge=p.closeButton)!=null?ge:j},[p.closeButton,j]),St=b.useMemo(()=>p.duration||P||ox,[p.duration,P]),Ct=b.useRef(0),kt=b.useRef(0),on=b.useRef(0),Nt=b.useRef(null),[Vt,Et]=q.split("-"),$e=b.useMemo(()=>w.reduce((ge,fe,ve)=>ve>=st?ge:ge+fe.height,0),[w,st]),We=KI(),At=p.invert||m,Y=je==="loading";kt.current=b.useMemo(()=>st*K+$e,[st,$e]),b.useEffect(()=>{vt.current=St},[St]),b.useEffect(()=>{L(!0)},[]),b.useEffect(()=>{let ge=Ue.current;if(ge){let fe=ge.getBoundingClientRect().height;return xt(fe),x(ve=>[{toastId:p.id,height:fe,position:p.position},...ve]),()=>x(ve=>ve.filter(_e=>_e.toastId!==p.id))}},[x,p.id]),b.useLayoutEffect(()=>{if(!F)return;let ge=Ue.current,fe=ge.style.height;ge.style.height="auto";let ve=ge.getBoundingClientRect().height;ge.style.height=fe,xt(ve),x(_e=>_e.find(Ve=>Ve.toastId===p.id)?_e.map(Ve=>Ve.toastId===p.id?{...Ve,height:ve}:Ve):[{toastId:p.id,height:ve,position:p.position},..._e])},[F,p.title,p.description,x,p.id]);let ce=b.useCallback(()=>{ee(!0),Le(kt.current),x(ge=>ge.filter(fe=>fe.toastId!==p.id)),setTimeout(()=>{T(p)},iN)},[p,T,x,kt]);b.useEffect(()=>{if(p.promise&&je==="loading"||p.duration===1/0||p.type==="loading")return;let ge;return C||g||R&&We?(()=>{if(on.current<Ct.current){let fe=new Date().getTime()-Ct.current;vt.current=vt.current-fe}on.current=new Date().getTime()})():vt.current!==1/0&&(Ct.current=new Date().getTime(),ge=setTimeout(()=>{var fe;(fe=p.onAutoClose)==null||fe.call(p,p),ce()},vt.current)),()=>clearTimeout(ge)},[C,g,p,je,R,We,ce]),b.useEffect(()=>{p.delete&&ce()},[ce,p.delete]);function ze(){var ge,fe,ve;return U!=null&&U.loading?b.createElement("div",{className:mn(I==null?void 0:I.loader,(ge=p==null?void 0:p.classNames)==null?void 0:ge.loader,"sonner-loader"),"data-visible":je==="loading"},U.loading):W?b.createElement("div",{className:mn(I==null?void 0:I.loader,(fe=p==null?void 0:p.classNames)==null?void 0:fe.loader,"sonner-loader"),"data-visible":je==="loading"},W):b.createElement(BI,{className:mn(I==null?void 0:I.loader,(ve=p==null?void 0:p.classNames)==null?void 0:ve.loader),visible:je==="loading"})}return b.createElement("li",{tabIndex:0,ref:Ue,className:mn(z,Ze,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[je],(n=p==null?void 0:p.classNames)==null?void 0:n[je]),"data-sonner-toast":"","data-rich-colors":(r=p.richColors)!=null?r:E,"data-styled":!(p.jsx||p.unstyled||v),"data-mounted":F,"data-promise":!!p.promise,"data-swiped":ke,"data-removed":J,"data-visible":Ge,"data-y-position":Vt,"data-x-position":Et,"data-index":S,"data-front":Oe,"data-swiping":G,"data-dismissible":De,"data-type":je,"data-invert":At,"data-swipe-out":he,"data-swipe-direction":M,"data-expanded":!!(C||O&&F),style:{"--index":S,"--toasts-before":S,"--z-index":k.length-S,"--offset":`${J?Ae:kt.current}px`,"--initial-height":O?"auto":`${qe}px`,..._,...p.style},onDragEnd:()=>{te(!1),A(null),Nt.current=null},onPointerDown:ge=>{Y||!De||(pt.current=new Date,Le(kt.current),ge.target.setPointerCapture(ge.pointerId),ge.target.tagName!=="BUTTON"&&(te(!0),Nt.current={x:ge.clientX,y:ge.clientY}))},onPointerUp:()=>{var ge,fe,ve,_e;if(he||!De)return;Nt.current=null;let Ve=Number(((ge=Ue.current)==null?void 0:ge.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),at=Number(((fe=Ue.current)==null?void 0:fe.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),lt=new Date().getTime()-((ve=pt.current)==null?void 0:ve.getTime()),Ne=$==="x"?Ve:at,ht=Math.abs(Ne)/lt;if(Math.abs(Ne)>=sN||ht>.11){Le(kt.current),(_e=p.onDismiss)==null||_e.call(p,p),X($==="x"?Ve>0?"right":"left":at>0?"down":"up"),ce(),we(!0),Me(!1);return}te(!1),A(null)},onPointerMove:ge=>{var fe,ve,_e,Ve;if(!Nt.current||!De||((fe=window.getSelection())==null?void 0:fe.toString().length)>0)return;let at=ge.clientY-Nt.current.y,lt=ge.clientX-Nt.current.x,Ne=(ve=e.swipeDirections)!=null?ve:aN(q);!$&&(Math.abs(lt)>1||Math.abs(at)>1)&&A(Math.abs(lt)>Math.abs(at)?"x":"y");let ht={x:0,y:0};$==="y"?(Ne.includes("top")||Ne.includes("bottom"))&&(Ne.includes("top")&&at<0||Ne.includes("bottom")&&at>0)&&(ht.y=at):$==="x"&&(Ne.includes("left")||Ne.includes("right"))&&(Ne.includes("left")&&lt<0||Ne.includes("right")&&lt>0)&&(ht.x=lt),(Math.abs(ht.x)>0||Math.abs(ht.y)>0)&&Me(!0),(_e=Ue.current)==null||_e.style.setProperty("--swipe-amount-x",`${ht.x}px`),(Ve=Ue.current)==null||Ve.style.setProperty("--swipe-amount-y",`${ht.y}px`)}},yt&&!p.jsx?b.createElement("button",{"aria-label":Z,"data-disabled":Y,"data-close-button":!0,onClick:Y||!De?()=>{}:()=>{var ge;ce(),(ge=p.onDismiss)==null||ge.call(p,p)},className:mn(I==null?void 0:I.closeButton,(o=p==null?void 0:p.classNames)==null?void 0:o.closeButton)},(s=U==null?void 0:U.close)!=null?s:VI):null,p.jsx||b.isValidElement(p.title)?p.jsx?p.jsx:typeof p.title=="function"?p.title():p.title:b.createElement(b.Fragment,null,je||p.icon||p.promise?b.createElement("div",{"data-icon":"",className:mn(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||ze():null,p.type!=="loading"?p.icon||(U==null?void 0:U[je])||$I(je):null):null,b.createElement("div",{"data-content":"",className:mn(I==null?void 0:I.content,(a=p==null?void 0:p.classNames)==null?void 0:a.content)},b.createElement("div",{"data-title":"",className:mn(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?b.createElement("div",{"data-description":"",className:mn(Q,It,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),b.isValidElement(p.cancel)?p.cancel:p.cancel&&gi(p.cancel)?b.createElement("button",{"data-button":!0,"data-cancel":!0,style:p.cancelButtonStyle||D,onClick:ge=>{var fe,ve;gi(p.cancel)&&De&&((ve=(fe=p.cancel).onClick)==null||ve.call(fe,ge),ce())},className:mn(I==null?void 0:I.cancelButton,(d=p==null?void 0:p.classNames)==null?void 0:d.cancelButton)},p.cancel.label):null,b.isValidElement(p.action)?p.action:p.action&&gi(p.action)?b.createElement("button",{"data-button":!0,"data-action":!0,style:p.actionButtonStyle||B,onClick:ge=>{var fe,ve;gi(p.action)&&((ve=(fe=p.action).onClick)==null||ve.call(fe,ge),!ge.defaultPrevented&&ce())},className:mn(I==null?void 0:I.actionButton,(f=p==null?void 0:p.classNames)==null?void 0:f.actionButton)},p.action.label):null))};function sx(){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=b.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=sx(),gap:y=oN,loadingIcon:w,icons:S,containerAriaLabel:k="Notifications",pauseWhenPageIsHidden:C}=e,[T,E]=b.useState([]),j=b.useMemo(()=>Array.from(new Set([r].concat(T.filter(R=>R.position).map(R=>R.position)))),[T,r]),[_,D]=b.useState([]),[B,z]=b.useState(!1),[Q,P]=b.useState(!1),[q,K]=b.useState(d!=="system"?d:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),W=b.useRef(null),O=o.join("+").replace(/Key/g,"").replace(/Digit/g,""),I=b.useRef(null),U=b.useRef(!1),Z=b.useCallback(R=>{E($=>{var A;return(A=$.find(M=>M.id===R.id))!=null&&A.delete||Wt.dismiss(R.id),$.filter(({id:M})=>M!==R.id)})},[]);return b.useEffect(()=>Wt.subscribe(R=>{if(R.dismiss){E($=>$.map(A=>A.id===R.id?{...A,delete:!0}:A));return}setTimeout(()=>{Mo.flushSync(()=>{E($=>{let A=$.findIndex(M=>M.id===R.id);return A!==-1?[...$.slice(0,A),{...$[A],...R},...$.slice(A+1)]:[R,...$]})})})}),[]),b.useEffect(()=>{if(d!=="system"){K(d);return}if(d==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?K("dark"):K("light")),typeof window>"u")return;let R=window.matchMedia("(prefers-color-scheme: dark)");try{R.addEventListener("change",({matches:$})=>{K($?"dark":"light")})}catch{R.addListener(({matches:A})=>{try{K(A?"dark":"light")}catch(M){console.error(M)}})}},[d]),b.useEffect(()=>{T.length<=1&&z(!1)},[T]),b.useEffect(()=>{let R=$=>{var A,M;o.every(X=>$[X]||$.code===X)&&(z(!0),(A=W.current)==null||A.focus()),$.code==="Escape"&&(document.activeElement===W.current||(M=W.current)!=null&&M.contains(document.activeElement))&&z(!1)};return document.addEventListener("keydown",R),()=>document.removeEventListener("keydown",R)},[o]),b.useEffect(()=>{if(W.current)return()=>{I.current&&(I.current.focus({preventScroll:!0}),I.current=null,U.current=!1)}},[W.current]),b.createElement("section",{ref:t,"aria-label":`${k} ${O}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},j.map((R,$)=>{var A;let[M,X]=R.split("-");return T.length?b.createElement("ol",{key:R,dir:x==="auto"?sx():x,tabIndex:-1,ref:W,className:a,"data-sonner-toaster":!0,"data-theme":q,"data-y-position":M,"data-lifted":B&&T.length>1&&!s,"data-x-position":X,style:{"--front-toast-height":`${((A=_[0])==null?void 0:A.height)||0}px`,"--width":`${rN}px`,"--gap":`${y}px`,...p,...cN(l,c)},onBlur:F=>{U.current&&!F.currentTarget.contains(F.relatedTarget)&&(U.current=!1,I.current&&(I.current.focus({preventScroll:!0}),I.current=null))},onFocus:F=>{F.target instanceof HTMLElement&&F.target.dataset.dismissible==="false"||U.current||(U.current=!0,I.current=F.relatedTarget)},onMouseEnter:()=>z(!0),onMouseMove:()=>z(!0),onMouseLeave:()=>{Q||z(!1)},onDragEnd:()=>z(!1),onPointerDown:F=>{F.target instanceof HTMLElement&&F.target.dataset.dismissible==="false"||P(!0)},onPointerUp:()=>P(!1)},T.filter(F=>!F.position&&$===0||F.position===R).map((F,L)=>{var J,ee;return b.createElement(lN,{key:F.id,icons:S,index:L,toast:F,defaultRichColors:f,duration:(J=g==null?void 0:g.duration)!=null?J:m,className:g==null?void 0:g.className,descriptionClassName:g==null?void 0:g.descriptionClassName,invert:n,visibleToasts:v,closeButton:(ee=g==null?void 0:g.closeButton)!=null?ee:i,interacting:Q,position:R,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:Z,toasts:T.filter(G=>G.position==F.position),heights:_.filter(G=>G.position==F.position),setHeights:D,expandByDefault:s,gap:y,loadingIcon:w,expanded:B,pauseWhenPageIsHidden:C,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=Kv,H.ApiClient=Vv,H.ApiProvider=ou,H.ArtifactRenderer=Ih,H.Badge=Fh,H.Button=Je,H.Card=al,H.CardContent=dl,H.CardDescription=ul,H.CardHeader=ll,H.CardTitle=cl,H.ChatApi=Go,H.ChatApp=Vk,H.ChatInput=Vf,H.ChatInputRow=Kf,H.ChatInterface=Or,H.ChatProviders=wr,H.ChatWidget=Gk,H.Command=Sl,H.CommandEmpty=kl,H.CommandGroup=El,H.CommandInput=Cl,H.CommandItem=Il,H.CommandList=Tl,H.DEFAULT_TIMEOUT_MS=Zc,H.Dialog=tl,H.DialogContent=Hs,H.DialogHeader=Us,H.DialogTitle=Ws,H.DropdownMenu=Ts,H.DropdownMenuContent=ho,H.DropdownMenuItem=Fn,H.DropdownMenuTrigger=ks,H.FileViewerModal=uh,H.HISTORY_TIMEOUT_MS=Qc,H.Input=Ml,H.InterruptPartRenderer=Ah,H.Label=bm,H.MarkdownContent=Kn,H.MessageComponent=Zs,H.MessageList=ml,H.MessageRow=hl,H.NewChatButton=Yk,H.PlotArtifact=Th,H.ResearchTaskArtifact=Eh,H.SETTINGS_STORAGE_KEY=Bi,H.ScrollArea=Rl,H.Select=NE,H.SelectContent=ig,H.SelectItem=ag,H.SelectTrigger=rg,H.SelectValue=AE,H.Separator=dg,H.Sheet=BE,H.SheetContent=wg,H.SheetDescription=Cg,H.SheetHeader=yg,H.SheetTitle=Sg,H.SheetTrigger=zE,H.SimpleChat=Kk,H.SimpleJsonView=Js,H.Sonner=dN,H.StreamProgress=jh,H.Switch=vg,H.Textarea=Ea,H.ThinkingIndicator=_h,H.ThreadListItem=pm,H.ThreadManager=oi,H.ThreadStateProvider=Iu,H.ThreadsProvider=mu,H.TimelineColumn=Sx,H.Toaster=RI,H.ToolComponent=Lh,H.Tooltip=uI,H.TooltipContent=Pg,H.TooltipProvider=cI,H.TooltipTrigger=dI,H.UserTextContent=Ph,H.applySettings=Eb,H.buildCheckpointIndex=tc,H.buildCheckpointPreviewMap=dx,H.chatApiClient=Nn,H.del=Pi,H.downloadFileById=tu,H.extractConfigFields=vi,H.fileToBase64=su,H.get=Yt,H.getChatToken=Xc,H.getCheckpointForMessage=fx,H.getCurrentSettings=kb,H.getDefaultApiConfig=Du,H.getDefaultChatSettings=Lu,H.getFileContent=Mi,H.getFileInfo=Gv,H.getMessageAttemptInfo=nc,H.getMessageDomKey=pl,H.getPreviewForMessage=xi,H.httpClient=Gt,H.hydrateHistorySnapshots=Xn,H.isEnvelope=au,H.listFiles=nu,H.loadStoredSettings=$u,H.onChatTokenChanged=Jc,H.post=qo,H.processAttachments=iu,H.put=eu,H.readNumber=oc,H.readString=Rn,H.resolveChatBaseUrl=xn,H.saveSettings=Fu,H.setChatToken=Ko,H.toPlainObject=Pn,H.unwrap=Ot,H.useApi=Jr,H.useCheckpointIndex=rc,H.useFilePreview=Mh,H.useHasChatSession=Sb,H.useParsedMessageContent=Oh,H.useShallowStableValue=Pu,H.useStream=Fi,H.useStreamingHook=Fi,H.useThreadHistoryState=Cu,H.useThreadManagerViewState=gm,H.useThreadState=to,H.useThreadStateUpdater=Eu,H.useThreads=xr,H.useThreadsState=pu,H.viewFileById=qv,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.477",
3
+ "version": "4.3.478",
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",