@waniwani/sdk 0.22.0-beta.3 → 0.22.0-beta.4
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/chat/embed.js +1 -1
- package/dist/chat/index.js +1 -1
- package/package.json +1 -1
package/dist/chat/embed.js
CHANGED
|
@@ -118,7 +118,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let n="<p>An error
|
|
|
118
118
|
`)},bx=e=>{let t=!1;for(let n of e)if(n==="\\"||n==="|"){t=!0;break}if(!t)return e;let a=[];for(let n of e)n==="\\"?a.push("\\\\"):n==="|"?a.push("\\|"):a.push(n);return a.join("")},x6=e=>{let{headers:t,rows:a}=e;if(t.length===0)return"";let n=new Array(a.length+2),r=0,o=t.map(l=>bx(l));n[r]=`| ${o.join(" | ")} |`,r+=1;let i=new Array(t.length);for(let l=0;l<t.length;l+=1)i[l]="---";n[r]=`| ${i.join(" | ")} |`,r+=1;for(let l of a)if(l.length<t.length){let s=new Array(t.length);for(let u=0;u<t.length;u+=1)s[u]=u<l.length?bx(l[u]):"";n[r]=`| ${s.join(" | ")} |`,r+=1}else{let s=l.map(u=>bx(u));n[r]=`| ${s.join(" | ")} |`,r+=1}return n.join(`
|
|
119
119
|
`)},v6=({children:e,className:t,onCopy:a,onError:n,timeout:r=2e3})=>{let[o,i]=(0,_.useState)(!1),[l,s]=(0,_.useState)(!1),u=(0,_.useRef)(null),c=(0,_.useRef)(0),{isAnimating:d}=(0,_.useContext)(ya),f=async m=>{var x,S;if(typeof window>"u"||!((x=navigator?.clipboard)!=null&&x.write)){n?.(new Error("Clipboard API not available"));return}try{let w=(S=u.current)==null?void 0:S.closest('[data-streamdown="table-wrapper"]'),y=w?.querySelector("table");if(!y){n?.(new Error("Table not found"));return}let h=_R(y),b=m==="csv"?OR(h):y6(h),T=new ClipboardItem({"text/plain":new Blob([b],{type:"text/plain"}),"text/html":new Blob([y.outerHTML],{type:"text/html"})});await navigator.clipboard.write([T]),s(!0),i(!1),a?.(m),c.current=window.setTimeout(()=>s(!1),r)}catch(w){n?.(w)}};(0,_.useEffect)(()=>{let m=x=>{let S=x.composedPath();u.current&&!S.includes(u.current)&&i(!1)};return document.addEventListener("mousedown",m),()=>{document.removeEventListener("mousedown",m),window.clearTimeout(c.current)}},[]);let p=l?Tx:Lx;return(0,E.jsxs)("div",{className:"relative",ref:u,children:[(0,E.jsx)("button",{className:ce("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:d,onClick:()=>i(!o),title:"Copy table",type:"button",children:e??(0,E.jsx)(p,{size:14})}),o?(0,E.jsxs)("div",{className:"absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg",children:[(0,E.jsx)("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>f("csv"),title:"Copy table as CSV",type:"button",children:"CSV"}),(0,E.jsx)("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>f("tsv"),title:"Copy table as TSV",type:"button",children:"TSV"})]}):null]})},b6=({children:e,className:t,onDownload:a,onError:n})=>{let[r,o]=(0,_.useState)(!1),i=(0,_.useRef)(null),{isAnimating:l}=(0,_.useContext)(ya),s=u=>{var c;try{let d=(c=i.current)==null?void 0:c.closest('[data-streamdown="table-wrapper"]'),f=d?.querySelector("table");if(!f){n?.(new Error("Table not found"));return}let p=_R(f),m=u==="csv"?OR(p):x6(p);Ll(`table.${u==="csv"?"csv":"md"}`,m,u==="csv"?"text/csv":"text/markdown"),o(!1),a?.(u)}catch(d){n?.(d)}};return(0,_.useEffect)(()=>{let u=c=>{let d=c.composedPath();i.current&&!d.includes(i.current)&&o(!1)};return document.addEventListener("mousedown",u),()=>{document.removeEventListener("mousedown",u)}},[]),(0,E.jsxs)("div",{className:"relative",ref:i,children:[(0,E.jsx)("button",{className:ce("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:l,onClick:()=>o(!r),title:"Download table",type:"button",children:e??(0,E.jsx)(mp,{size:14})}),r?(0,E.jsxs)("div",{className:"absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg",children:[(0,E.jsx)("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>s("csv"),title:"Download table as CSV",type:"button",children:"CSV"}),(0,E.jsx)("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>s("markdown"),title:"Download table as Markdown",type:"button",children:"Markdown"})]}):null]})},S6=({children:e,className:t,showControls:a,...n})=>(0,E.jsxs)("div",{className:"my-4 flex flex-col space-y-2","data-streamdown":"table-wrapper",children:[a?(0,E.jsxs)("div",{className:"flex items-center justify-end gap-1",children:[(0,E.jsx)(v6,{}),(0,E.jsx)(b6,{})]}):null,(0,E.jsx)("div",{className:"overflow-x-auto",children:(0,E.jsx)("table",{className:ce("w-full border-collapse border border-border",t),"data-streamdown":"table",...n,children:e})})]}),I6=(0,_.lazy)(()=>Promise.resolve().then(()=>(xR(),yR)).then(e=>({default:e.CodeBlock}))),C6=(0,_.lazy)(()=>Promise.resolve().then(()=>(SR(),bR)).then(e=>({default:e.Mermaid}))),k6=/language-([^\s]+)/;kx=(e,t)=>typeof e=="boolean"?e:e[t]!==!1,fp=(e,t)=>{if(typeof e=="boolean")return e;let a=e.mermaid;return a===!1?!1:a===!0||a===void 0?!0:a[t]!==!1},Mx=(0,_.memo)(({children:e,className:t,node:a,...n})=>(0,E.jsx)("ol",{className:ce("list-inside list-decimal whitespace-normal [li_&]:pl-6",t),"data-streamdown":"ordered-list",...n,children:e}),(e,t)=>Lt(e,t));Mx.displayName="MarkdownOl";PR=(0,_.memo)(({children:e,className:t,node:a,...n})=>(0,E.jsx)("li",{className:ce("py-1 [&>p]:inline",t),"data-streamdown":"list-item",...n,children:e}),(e,t)=>e.className===t.className&&hp(e.node,t.node));PR.displayName="MarkdownLi";NR=(0,_.memo)(({children:e,className:t,node:a,...n})=>(0,E.jsx)("ul",{className:ce("list-inside list-disc whitespace-normal [li_&]:pl-6",t),"data-streamdown":"unordered-list",...n,children:e}),(e,t)=>Lt(e,t));NR.displayName="MarkdownUl";BR=(0,_.memo)(({className:e,node:t,...a})=>(0,E.jsx)("hr",{className:ce("my-6 border-border",e),"data-streamdown":"horizontal-rule",...a}),(e,t)=>Lt(e,t));BR.displayName="MarkdownHr";UR=(0,_.memo)(({children:e,className:t,node:a,...n})=>(0,E.jsx)("span",{className:ce("font-semibold",t),"data-streamdown":"strong",...n,children:e}),(e,t)=>Lt(e,t));UR.displayName="MarkdownStrong";T6=({children:e,className:t,href:a,node:n,...r})=>{let{linkSafety:o}=(0,_.useContext)(ya),[i,l]=(0,_.useState)(!1),s=a==="streamdown:incomplete-link",u=(0,_.useCallback)(async p=>{if(!(!(o!=null&&o.enabled&&a)||s)){if(p.preventDefault(),o.onLinkCheck&&await o.onLinkCheck(a)){window.open(a,"_blank","noreferrer");return}l(!0)}},[o,a,s]),c=(0,_.useCallback)(()=>{a&&window.open(a,"_blank","noreferrer")},[a]),d=(0,_.useCallback)(()=>{l(!1)},[]),f={url:a??"",isOpen:i,onClose:d,onConfirm:c};return o!=null&&o.enabled&&a?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)("button",{className:ce("wrap-anywhere appearance-none text-left font-medium text-primary underline",t),"data-incomplete":s,"data-streamdown":"link",onClick:u,type:"button",children:e}),o.renderModal?o.renderModal(f):(0,E.jsx)(f6,{...f})]}):(0,E.jsx)("a",{className:ce("wrap-anywhere font-medium text-primary underline",t),"data-incomplete":s,"data-streamdown":"link",href:a,rel:"noreferrer",target:"_blank",...r,children:e})},FR=(0,_.memo)(T6,(e,t)=>Lt(e,t)&&e.href===t.href);FR.displayName="MarkdownA";zR=(0,_.memo)(({children:e,className:t,node:a,...n})=>(0,E.jsx)("h1",{className:ce("mt-6 mb-2 font-semibold text-3xl",t),"data-streamdown":"heading-1",...n,children:e}),(e,t)=>Lt(e,t));zR.displayName="MarkdownH1";qR=(0,_.memo)(({children:e,className:t,node:a,...n})=>(0,E.jsx)("h2",{className:ce("mt-6 mb-2 font-semibold text-2xl",t),"data-streamdown":"heading-2",...n,children:e}),(e,t)=>Lt(e,t));qR.displayName="MarkdownH2";HR=(0,_.memo)(({children:e,className:t,node:a,...n})=>(0,E.jsx)("h3",{className:ce("mt-6 mb-2 font-semibold text-xl",t),"data-streamdown":"heading-3",...n,children:e}),(e,t)=>Lt(e,t));HR.displayName="MarkdownH3";jR=(0,_.memo)(({children:e,className:t,node:a,...n})=>(0,E.jsx)("h4",{className:ce("mt-6 mb-2 font-semibold text-lg",t),"data-streamdown":"heading-4",...n,children:e}),(e,t)=>Lt(e,t));jR.displayName="MarkdownH4";VR=(0,_.memo)(({children:e,className:t,node:a,...n})=>(0,E.jsx)("h5",{className:ce("mt-6 mb-2 font-semibold text-base",t),"data-streamdown":"heading-5",...n,children:e}),(e,t)=>Lt(e,t));VR.displayName="MarkdownH5";WR=(0,_.memo)(({children:e,className:t,node:a,...n})=>(0,E.jsx)("h6",{className:ce("mt-6 mb-2 font-semibold text-sm",t),"data-streamdown":"heading-6",...n,children:e}),(e,t)=>Lt(e,t));WR.displayName="MarkdownH6";GR=(0,_.memo)(({children:e,className:t,node:a,...n})=>{let{controls:r}=(0,_.useContext)(ya),o=kx(r,"table");return(0,E.jsx)(S6,{className:t,showControls:o,...n,children:e})},(e,t)=>Lt(e,t));GR.displayName="MarkdownTable";$R=(0,_.memo)(({children:e,className:t,node:a,...n})=>(0,E.jsx)("thead",{className:ce("bg-muted/80",t),"data-streamdown":"table-header",...n,children:e}),(e,t)=>Lt(e,t));$R.displayName="MarkdownThead";XR=(0,_.memo)(({children:e,className:t,node:a,...n})=>(0,E.jsx)("tbody",{className:ce("divide-y divide-border bg-muted/40",t),"data-streamdown":"table-body",...n,children:e}),(e,t)=>Lt(e,t));XR.displayName="MarkdownTbody";KR=(0,_.memo)(({children:e,className:t,node:a,...n})=>(0,E.jsx)("tr",{className:ce("border-border border-b",t),"data-streamdown":"table-row",...n,children:e}),(e,t)=>Lt(e,t));KR.displayName="MarkdownTr";YR=(0,_.memo)(({children:e,className:t,node:a,...n})=>(0,E.jsx)("th",{className:ce("whitespace-nowrap px-4 py-2 text-left font-semibold text-sm",t),"data-streamdown":"table-header-cell",...n,children:e}),(e,t)=>Lt(e,t));YR.displayName="MarkdownTh";ZR=(0,_.memo)(({children:e,className:t,node:a,...n})=>(0,E.jsx)("td",{className:ce("px-4 py-2 text-sm",t),"data-streamdown":"table-cell",...n,children:e}),(e,t)=>Lt(e,t));ZR.displayName="MarkdownTd";QR=(0,_.memo)(({children:e,className:t,node:a,...n})=>(0,E.jsx)("blockquote",{className:ce("my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic",t),"data-streamdown":"blockquote",...n,children:e}),(e,t)=>Lt(e,t));QR.displayName="MarkdownBlockquote";JR=(0,_.memo)(({children:e,className:t,node:a,...n})=>(0,E.jsx)("sup",{className:ce("text-sm",t),"data-streamdown":"superscript",...n,children:e}),(e,t)=>Lt(e,t));JR.displayName="MarkdownSup";e2=(0,_.memo)(({children:e,className:t,node:a,...n})=>(0,E.jsx)("sub",{className:ce("text-sm",t),"data-streamdown":"subscript",...n,children:e}),(e,t)=>Lt(e,t));e2.displayName="MarkdownSub";t2=(0,_.memo)(({children:e,className:t,node:a,...n})=>{if("data-footnotes"in n){let r=i=>{var l,s;if(!(0,_.isValidElement)(i))return!1;let u=Array.isArray(i.props.children)?i.props.children:[i.props.children],c=!1,d=!1;for(let f of u)if(f){if(typeof f=="string")f.trim()!==""&&(c=!0);else if((0,_.isValidElement)(f))if(((l=f.props)==null?void 0:l["data-footnote-backref"])!==void 0)d=!0;else{let p=Array.isArray(f.props.children)?f.props.children:[f.props.children];for(let m of p){if(typeof m=="string"&&m.trim()!==""){c=!0;break}if((0,_.isValidElement)(m)&&((s=m.props)==null?void 0:s["data-footnote-backref"])===void 0){c=!0;break}}}}return d&&!c},o=Array.isArray(e)?e.map(i=>{if(!(0,_.isValidElement)(i))return i;if(i.type===Mx){let l=(Array.isArray(i.props.children)?i.props.children:[i.props.children]).filter(s=>!r(s));return l.length===0?null:{...i,props:{...i.props,children:l}}}return i}):e;return(Array.isArray(o)?o.some(i=>i!==null):o!==null)?(0,E.jsx)("section",{className:t,...n,children:o}):null}return(0,E.jsx)("section",{className:t,...n,children:e})},(e,t)=>Lt(e,t));t2.displayName="MarkdownSection";L6=({node:e,className:t,children:a,...n})=>{var r,o,i;let l=((r=e?.position)==null?void 0:r.start.line)===((o=e?.position)==null?void 0:o.end.line),{mermaid:s,controls:u}=(0,_.useContext)(ya),c=Ex();if(l)return(0,E.jsx)("code",{className:ce("rounded bg-muted px-1.5 py-0.5 font-mono text-sm",t),"data-streamdown":"inline-code",...n,children:a});let d=t?.match(k6),f=(i=d?.at(1))!=null?i:"",p="";if((0,_.isValidElement)(a)&&a.props&&typeof a.props=="object"&&"children"in a.props&&typeof a.props.children=="string"?p=a.props.children:typeof a=="string"&&(p=a),f==="mermaid"&&c){let x=kx(u,"mermaid"),S=fp(u,"download"),w=fp(u,"copy"),y=fp(u,"fullscreen"),h=fp(u,"panZoom"),b=x&&(S||w||y);return(0,E.jsx)(_.Suspense,{fallback:(0,E.jsx)(TR,{}),children:(0,E.jsxs)("div",{className:ce("group relative my-4 h-auto rounded-xl border p-4",t),"data-streamdown":"mermaid-block",children:[b?(0,E.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[S?(0,E.jsx)(m6,{chart:p,config:s?.config}):null,w?(0,E.jsx)(CR,{code:p}):null,y?(0,E.jsx)(w6,{chart:p,config:s?.config}):null]}):null,(0,E.jsx)(C6,{chart:p,config:s?.config,showControls:h})]})})}let m=kx(u,"code");return(0,E.jsx)(_.Suspense,{fallback:(0,E.jsx)(TR,{}),children:(0,E.jsx)(I6,{className:ce("overflow-x-auto border-border border-t",t),code:p,language:f,children:m?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(l6,{code:p,language:f}),(0,E.jsx)(CR,{})]}):null})})},a2=(0,_.memo)(L6,(e,t)=>e.className===t.className&&hp(e.node,t.node));a2.displayName="MarkdownCode";n2=(0,_.memo)(u6,(e,t)=>e.className===t.className&&hp(e.node,t.node));n2.displayName="MarkdownImg";r2=(0,_.memo)(({children:e,className:t,node:a,...n})=>{var r,o;let i=(Array.isArray(e)?e:[e]).filter(l=>l!=null&&l!=="");if(i.length===1&&(0,_.isValidElement)(i[0])){let l=i[0].props.node,s=l?.tagName;if(s==="img")return(0,E.jsx)(E.Fragment,{children:e});if(s==="code"&&((r=l?.position)==null?void 0:r.start.line)!==((o=l?.position)==null?void 0:o.end.line))return(0,E.jsx)(E.Fragment,{children:e})}return(0,E.jsx)("p",{className:t,...n,children:e})},(e,t)=>Lt(e,t));r2.displayName="MarkdownParagraph";E6={ol:Mx,li:PR,ul:NR,hr:BR,strong:UR,a:FR,h1:zR,h2:qR,h3:HR,h4:jR,h5:VR,h6:WR,table:GR,thead:$R,tbody:XR,tr:KR,th:YR,td:ZR,blockquote:QR,code:a2,img:n2,pre:({children:e})=>e,sup:JR,sub:e2,p:r2,section:t2},LR=[],ER={allowDangerousHtml:!0},pp=new WeakMap,M6=class{constructor(){this.cache=new Map,this.keyCache=new WeakMap,this.maxSize=100}generateCacheKey(e){let t=this.keyCache.get(e);if(t)return t;let a=e.rehypePlugins,n=e.remarkPlugins,r=e.remarkRehypeOptions;if(!(a||n||r)){let c="default";return this.keyCache.set(e,c),c}let o=c=>{if(!c||c.length===0)return"";let d="";for(let f=0;f<c.length;f+=1){let p=c[f];if(f>0&&(d+=","),Array.isArray(p)){let[m,x]=p;if(typeof m=="function"){let S=pp.get(m);S||(S=m.name,pp.set(m,S)),d+=S}else d+=String(m);d+=":",d+=JSON.stringify(x)}else if(typeof p=="function"){let m=pp.get(p);m||(m=p.name,pp.set(p,m)),d+=m}else d+=String(p)}return d},i=o(a),l=o(n),s=r?JSON.stringify(r):"",u=`${l}::${i}::${s}`;return this.keyCache.set(e,u),u}get(e){let t=this.generateCacheKey(e),a=this.cache.get(t);return a&&(this.cache.delete(t),this.cache.set(t,a)),a}set(e,t){let a=this.generateCacheKey(e);if(this.cache.size>=this.maxSize){let n=this.cache.keys().next().value;n&&this.cache.delete(n)}this.cache.set(a,t)}clear(){this.cache.clear()}},MR=new M6,o2=e=>{let t=A6(e),a=e.children||"";return D6(t.runSync(t.parse(a),a),e)},A6=e=>{let t=MR.get(e);if(t)return t;let a=R6(e);return MR.set(e,a),a},R6=e=>{let t=e.rehypePlugins||LR,a=e.remarkPlugins||LR,n=e.remarkRehypeOptions?{...ER,...e.remarkRehypeOptions}:ER;return ix().use(Yf).use(a).use(ep,n).use(t)},D6=(e,t)=>Fy(e,{Fragment:E.Fragment,components:t.components,ignoreInvalidStyle:!0,jsx:E.jsx,jsxs:E.jsxs,passKeys:!0,passNode:!0}),_6=/\[\^[^\]\s]{1,200}\](?!:)/,O6=/\[\^[^\]\s]{1,200}\]:/,P6=/<\/(\w+)>/,N6=/<(\w+)[\s>]/,Sx=e=>{let t=0;for(;t<e.length&&(e[t]===" "||e[t]===" "||e[t]===`
|
|
120
120
|
`||e[t]==="\r");)t+=1;return t+1<e.length&&e[t]==="$"&&e[t+1]==="$"},B6=e=>{let t=e.length-1;for(;t>=0&&(e[t]===" "||e[t]===" "||e[t]===`
|
|
121
|
-
`||e[t]==="\r");)t-=1;return t>=1&&e[t]==="$"&&e[t-1]==="$"},Ix=e=>{let t=0;for(let a=0;a<e.length-1;a+=1)e[a]==="$"&&e[a+1]==="$"&&(t+=1,a+=1);return t},i2=e=>{let t=_6.test(e),a=O6.test(e);if(t||a)return[e];let n=Xa.lex(e,{gfm:!0}),r=[],o=[];for(let i of n){let l=i.raw,s=r.length;if(o.length>0){if(r[s-1]+=l,i.type==="html"){let u=l.match(P6);if(u){let c=u[1];o.at(-1)===c&&o.pop()}}continue}if(i.type==="html"&&i.block){let u=l.match(N6);if(u){let c=u[1];l.includes(`</${c}>`)||o.push(c)}}if(l.trim()==="$$"&&s>0){let u=r[s-1],c=Sx(u),d=Ix(u);if(c&&d%2===1){r[s-1]=u+l;continue}}if(s>0&&B6(l)){let u=r[s-1],c=Sx(u),d=Ix(u),f=Ix(l);if(c&&d%2===1&&!Sx(l)&&f===1){r[s-1]=u+l;continue}}r.push(l)}return r},l2={raw:zk,sanitize:[gf,{}],harden:[Uk,{allowedImagePrefixes:["*"],allowedLinkPrefixes:["*"],allowedProtocols:["*"],defaultOrigin:void 0,allowDataImages:!0}]},s2={gfm:[qf,{}]},U6=Object.values(l2),F6=Object.values(s2),z6={block:" \u258B",circle:" \u25CF"},q6={shikiTheme:["github-light","github-dark"],controls:!0,isAnimating:!1,mode:"streaming",mermaid:void 0,linkSafety:{enabled:!0}},ya=(0,_.createContext)(q6),Ax=(0,_.memo)(({content:e,shouldParseIncompleteMarkdown:t,index:a,...n})=>(0,E.jsx)(o2,{...n,children:e}),(e,t)=>{if(e.content!==t.content||e.index!==t.index)return!1;if(e.components!==t.components){let a=Object.keys(e.components||{}),n=Object.keys(t.components||{});if(a.length!==n.length||a.some(r=>{var o,i;return((o=e.components)==null?void 0:o[r])!==((i=t.components)==null?void 0:i[r])}))return!1}return!(e.rehypePlugins!==t.rehypePlugins||e.remarkPlugins!==t.remarkPlugins)});Ax.displayName="Block";H6=["github-light","github-dark"],El=(0,_.memo)(({children:e,mode:t="streaming",parseIncompleteMarkdown:a=!0,components:n,rehypePlugins:r=U6,remarkPlugins:o=F6,className:i,shikiTheme:l=H6,mermaid:s,controls:u=!0,isAnimating:c=!1,BlockComponent:d=Ax,parseMarkdownIntoBlocksFn:f=i2,caret:p,plugins:m,remend:x,linkSafety:S={enabled:!0},...w})=>{let y=(0,_.useId)(),[h,b]=(0,_.useTransition)(),T=(0,_.useMemo)(()=>typeof e!="string"?"":t==="streaming"&&a?QL(e,x):e,[e,t,a,x]),C=(0,_.useMemo)(()=>f(T),[T,f]),[M,D]=(0,_.useState)(C);(0,_.useEffect)(()=>{t==="streaming"?b(()=>{D(C)}):D(C)},[C,t]);let P=t==="streaming"?M:C,L=(0,_.useMemo)(()=>P.map((N,R)=>`${y}-${R}`),[P.length,y]),$=(0,_.useMemo)(()=>{var N,R;return{shikiTheme:(R=(N=m?.code)==null?void 0:N.getThemes())!=null?R:l,controls:u,isAnimating:c,mode:t,mermaid:s,linkSafety:S}},[l,u,c,t,s,S,m?.code]),H=(0,_.useMemo)(()=>({...E6,...n}),[n]),F=(0,_.useMemo)(()=>{let N=[];return m!=null&&m.cjk&&(N=[...N,...m.cjk.remarkPluginsBefore]),N=[...N,...o],m!=null&&m.cjk&&(N=[...N,...m.cjk.remarkPluginsAfter]),m!=null&&m.math&&(N=[...N,m.math.remarkPlugin]),N},[o,m?.math,m?.cjk]),W=(0,_.useMemo)(()=>m!=null&&m.math?[...r,m.math.rehypePlugin]:r,[r,m?.math]),V=(0,_.useMemo)(()=>p&&c?{"--streamdown-caret":`"${z6[p]}"`}:void 0,[p,c]);return t==="static"?(0,E.jsx)(Cx.Provider,{value:m??null,children:(0,E.jsx)(ya.Provider,{value:$,children:(0,E.jsx)("div",{className:ce("space-y-4 whitespace-normal *:first:mt-0 *:last:mb-0",i),children:(0,E.jsx)(o2,{components:H,rehypePlugins:W,remarkPlugins:F,...w,children:e})})})}):(0,E.jsx)(Cx.Provider,{value:m??null,children:(0,E.jsx)(ya.Provider,{value:$,children:(0,E.jsxs)("div",{className:ce("space-y-4 whitespace-normal *:first:mt-0 *:last:mb-0",p?"*:last:after:inline *:last:after:align-baseline *:last:after:content-(--streamdown-caret)":null,i),style:V,children:[P.length===0&&p&&c&&(0,E.jsx)("span",{}),P.map((N,R)=>(0,E.jsx)(d,{components:H,content:N,index:R,rehypePlugins:W,remarkPlugins:F,shouldParseIncompleteMarkdown:a,...w},L[R]))]})})})},(e,t)=>e.children===t.children&&e.shikiTheme===t.shikiTheme&&e.isAnimating===t.isAnimating&&e.mode===t.mode&&e.plugins===t.plugins&&e.className===t.className&&e.linkSafety===t.linkSafety);El.displayName="Streamdown";j6=({children:e,className:t,minZoom:a=.5,maxZoom:n=3,zoomStep:r=.1,showControls:o=!0,initialZoom:i=1,fullscreen:l=!1})=>{let s=(0,_.useRef)(null),u=(0,_.useRef)(null),[c,d]=(0,_.useState)(i),[f,p]=(0,_.useState)({x:0,y:0}),[m,x]=(0,_.useState)(!1),[S,w]=(0,_.useState)({x:0,y:0}),[y,h]=(0,_.useState)({x:0,y:0}),b=(0,_.useCallback)(H=>{d(F=>Math.max(a,Math.min(n,F+H)))},[a,n]),T=(0,_.useCallback)(()=>{b(r)},[b,r]),C=(0,_.useCallback)(()=>{b(-r)},[b,r]),M=(0,_.useCallback)(()=>{d(i),p({x:0,y:0})},[i]),D=(0,_.useCallback)(H=>{H.preventDefault();let F=H.deltaY>0?-r:r;b(F)},[b,r]),P=(0,_.useCallback)(H=>{if(H.button!==0||H.isPrimary===!1)return;x(!0),w({x:H.clientX,y:H.clientY}),h(f);let F=H.currentTarget;F instanceof HTMLElement&&F.setPointerCapture(H.pointerId)},[f]),L=(0,_.useCallback)(H=>{if(!m)return;H.preventDefault();let F=H.clientX-S.x,W=H.clientY-S.y;p({x:y.x+F,y:y.y+W})},[m,S,y]),$=(0,_.useCallback)(H=>{x(!1);let F=H.currentTarget;F instanceof HTMLElement&&F.releasePointerCapture(H.pointerId)},[]);return(0,_.useEffect)(()=>{let H=s.current;if(H)return H.addEventListener("wheel",D,{passive:!1}),()=>{H.removeEventListener("wheel",D)}},[D]),(0,_.useEffect)(()=>{let H=u.current;if(H&&m)return document.body.style.userSelect="none",H.addEventListener("pointermove",L,{passive:!1}),H.addEventListener("pointerup",$),H.addEventListener("pointercancel",$),()=>{document.body.style.userSelect="",H.removeEventListener("pointermove",L),H.removeEventListener("pointerup",$),H.removeEventListener("pointercancel",$)}},[m,L,$]),(0,E.jsxs)("div",{className:ce("relative flex flex-col",l?"h-full w-full":"min-h-28 w-full",t),ref:s,style:{cursor:m?"grabbing":"grab"},children:[o?(0,E.jsxs)("div",{className:ce("absolute z-10 flex flex-col gap-1 rounded-md border border-border bg-background/90 p-1 shadow-sm backdrop-blur-sm",l?"bottom-4 left-4":"bottom-2 left-2"),children:[(0,E.jsx)("button",{className:"flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",disabled:c>=n,onClick:T,title:"Zoom in",type:"button",children:(0,E.jsx)(o6,{size:16})}),(0,E.jsx)("button",{className:"flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",disabled:c<=a,onClick:C,title:"Zoom out",type:"button",children:(0,E.jsx)(i6,{size:16})}),(0,E.jsx)("button",{className:"flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",onClick:M,title:"Reset zoom and pan",type:"button",children:(0,E.jsx)(r6,{size:16})})]}):null,(0,E.jsx)("div",{className:ce("flex-1 origin-center transition-transform duration-150 ease-out",l?"flex h-full w-full items-center justify-center":"flex w-full items-center justify-center"),onPointerDown:P,ref:u,role:"application",style:{transform:`translate(${f.x}px, ${f.y}px) scale(${c})`,transformOrigin:"center center",touchAction:"none",willChange:"transform"},children:e})]})},vx=({chart:e,className:t,config:a,fullscreen:n=!1,showControls:r=!0})=>{let[o,i]=(0,_.useState)(null),[l,s]=(0,_.useState)(!1),[u,c]=(0,_.useState)(""),[d,f]=(0,_.useState)(""),[p,m]=(0,_.useState)(0),{mermaid:x}=(0,_.useContext)(ya),S=Ex(),w=x?.errorComponent,{shouldRender:y,containerRef:h}=t6({immediate:n});if((0,_.useEffect)(()=>{if(y){if(!S){i("Mermaid plugin not available. Please add the mermaid plugin to enable diagram rendering.");return}(async()=>{try{i(null),s(!0);let T=S.getMermaid(a),C=e.split("").reduce((P,L)=>(P<<5)-P+L.charCodeAt(0)|0,0),M=`mermaid-${Math.abs(C)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:D}=await T.render(M,e);c(D),f(D)}catch(T){if(!(d||u)){let C=T instanceof Error?T.message:"Failed to render Mermaid chart";i(C)}}finally{s(!1)}})()}},[e,a,p,y,S]),!(y||u||d))return(0,E.jsx)("div",{className:ce("my-4 min-h-[200px]",t),ref:h});if(l&&!u&&!d)return(0,E.jsx)("div",{className:ce("my-4 flex justify-center p-4",t),ref:h,children:(0,E.jsxs)("div",{className:"flex items-center space-x-2 text-muted-foreground",children:[(0,E.jsx)("div",{className:"h-4 w-4 animate-spin rounded-full border-current border-b-2"}),(0,E.jsx)("span",{className:"text-sm",children:"Loading diagram..."})]})});if(o&&!u&&!d)return w?(0,E.jsx)("div",{ref:h,children:(0,E.jsx)(w,{chart:e,error:o,retry:()=>m(C=>C+1)})}):(0,E.jsxs)("div",{className:ce("rounded-lg border border-red-200 bg-red-50 p-4",t),ref:h,children:[(0,E.jsxs)("p",{className:"font-mono text-red-700 text-sm",children:["Mermaid Error: ",o]}),(0,E.jsxs)("details",{className:"mt-2",children:[(0,E.jsx)("summary",{className:"cursor-pointer text-red-600 text-xs",children:"Show Code"}),(0,E.jsx)("pre",{className:"mt-2 overflow-x-auto rounded bg-red-100 p-2 text-red-800 text-xs",children:e})]})]});let b=u||d;return(0,E.jsx)("div",{className:ce("size-full",t),"data-streamdown":"mermaid",ref:h,children:(0,E.jsx)(j6,{className:ce(n?"size-full overflow-hidden":"my-4 overflow-hidden",t),fullscreen:n,maxZoom:3,minZoom:.5,showControls:r,zoomStep:.1,children:(0,E.jsx)("div",{"aria-label":"Mermaid chart",className:ce("flex justify-center",n?"size-full items-center":null),dangerouslySetInnerHTML:{__html:b},role:"img"})})})}});var D_=oa((kse,R_)=>{"use strict";function LV(e,t){if(typeof e!="function")throw new TypeError(`Expected the first argument to be a \`function\`, got \`${typeof e}\`.`);let a,n=0;return function(...o){clearTimeout(a);let i=Date.now(),l=i-n,s=t-l;s<=0?(n=i,e.apply(this,o)):a=setTimeout(()=>{n=Date.now(),e.apply(this,o)},s)}}R_.exports=LV});var Cv=typeof performance>"u"?0:performance.now(),kv=typeof window<"u"&&!!window.WaniWani?.chat;var fi=z(he(),1),$p=z(Ng(),1);var Bg="waniwani/suggestions";function il(e,t){for(let a of t){let n=e[a];if(typeof n=="string"&&n.length>0)return n}}var UB=["waniwani/sessionId","openai/sessionId","openai/session","sessionId","conversationId","mcp-session-id"],FB=["waniwani/requestId","openai/requestId","requestId","mcp/requestId"],zB=["waniwani/traceId","openai/traceId","traceId","mcp/traceId","openai/requestId","requestId"],qB=["waniwani/userId","openai/userId","externalUserId","userId","actorId"],HB=["waniwani/visitorId","visitorId"],jB=["correlationId","openai/requestId"];function mC(e){return e?il(e,UB):void 0}function hC(e){return e?il(e,FB):void 0}function gC(e){return e?il(e,zB):void 0}function wC(e){return e?il(e,qB):void 0}function yC(e){return e?il(e,HB):void 0}function xC(e){return e?il(e,jB):void 0}var VB=[{key:"openai/sessionId",source:"chatgpt"},{key:"openai/session",source:"chatgpt"}],WB=[{needle:"claude",source:"claude"},{needle:"chatgpt",source:"chatgpt"},{needle:"openai",source:"chatgpt"},{needle:"gemini",source:"gemini"}];function vC(e,t){if(e){let n=e["waniwani/source"];if(typeof n=="string"&&n.length>0)return n;for(let{key:r,source:o}of VB){let i=e[r];if(typeof i=="string"&&i.length>0)return o}}let a=t?.name;if(typeof a=="string"&&a.length>0){let n=a.toLowerCase();for(let{needle:r,source:o}of WB)if(n.includes(r))return o}}var GB="@waniwani/sdk";function bC(e,t={}){let a=t.now??(()=>new Date),n=t.generateId??$B,r=YB(e),o=Vd(e.meta),i=Vd(e.metadata),l=ZB(e,o),s=bn(e.eventId)??n(),u=QB(e.timestamp,a),c=bn(e.source)??vC(o)??t.source??GB,d=Ug(e)?{...e}:void 0,f={...i};return Object.keys(o).length>0&&(f.meta=o),d&&(f.rawLegacy=d),{id:s,type:"mcp.event",name:r,source:c,timestamp:u,correlation:l,properties:XB(e,r),metadata:f,rawLegacy:d}}function $B(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`evt_${crypto.randomUUID()}`:`evt_${Math.random().toString(36).slice(2,10)}_${Date.now().toString(36)}`}function XB(e,t){if(!Ug(e))return Vd(e.properties);let a=KB(e,t),n=Vd(e.properties);return{...a,...n}}function KB(e,t){switch(t){case"tool.called":{let a={};return bn(e.toolName)&&(a.name=e.toolName),bn(e.toolType)&&(a.type=e.toolType),a}case"link.clicked":{let a={};return bn(e.linkUrl)&&(a.url=e.linkUrl),a}default:return{}}}function YB(e){return Ug(e)?e.eventType:e.event}function ZB(e,t){let a=bn(e.requestId)??hC(t),n=bn(e.sessionId)??mC(t),r=bn(e.traceId)??gC(t),o=bn(e.externalUserId)??wC(t),i=bn(e.visitorId)??yC(t),l=bn(e.correlationId)??xC(t)??a,s={};return n&&(s.sessionId=n),r&&(s.traceId=r),a&&(s.requestId=a),l&&(s.correlationId=l),o&&(s.externalUserId=o),i&&(s.visitorId=i),s}function QB(e,t){if(e instanceof Date)return e.toISOString();if(typeof e=="string"){let a=new Date(e);if(!Number.isNaN(a.getTime()))return a.toISOString()}return t().toISOString()}function Vd(e){return!e||typeof e!="object"||Array.isArray(e)?{}:e}function bn(e){if(typeof e=="string"&&e.trim().length!==0)return e}function Ug(e){return"eventType"in e}function SC(e){return{priceShown:({amount:t,currency:a,itemId:n,label:r,...o})=>e({event:"price_shown",properties:{amount:t,currency:a,itemId:n,label:r},...o}),pricesCompared:({options:t,...a})=>e({event:"prices_compared",properties:{options:t},...a}),optionSelected:({id:t,amount:a,currency:n,...r})=>e({event:"option_selected",properties:{id:t,amount:a,currency:n},...r}),leadQualified:t=>{let{externalId:a,email:n,name:r,...o}=t??{};return e({event:"lead_qualified",properties:{externalId:a,email:n,name:r},...o})},converted:({amount:t,currency:a,occurredAt:n,...r})=>e({event:"converted",properties:{amount:t,currency:a,occurredAt:n},...r})}}var JB="/api/mcp/events/v2/batch";var IC="@waniwani/sdk";var eU=new Set([401,403]),tU=new Set([408,425,429,500,502,503,504]),aU=(e,t)=>globalThis.fetch(e,t);function CC(e){return new Fg(e)}var Fg=class{constructor(t){re(this,"endpointUrl");re(this,"flushIntervalMs");re(this,"maxBatchSize");re(this,"maxBufferSize");re(this,"maxRetries");re(this,"retryBaseDelayMs");re(this,"retryMaxDelayMs");re(this,"shutdownTimeoutMs");re(this,"sdkVersion");re(this,"fetchFn");re(this,"logger");re(this,"now");re(this,"sleep");re(this,"apiKey");re(this,"buffer",[]);re(this,"flushTimer");re(this,"flushScheduled",!1);re(this,"flushScheduledTimer");re(this,"flushInFlight");re(this,"inFlightCount",0);re(this,"isStopped",!1);re(this,"isShuttingDown",!1);this.endpointUrl=oU(t.apiUrl,t.endpointPath??JB),this.flushIntervalMs=t.flushIntervalMs??1e3,this.maxBatchSize=t.maxBatchSize??20,this.maxBufferSize=t.maxBufferSize??1e3,this.maxRetries=t.maxRetries??3,this.retryBaseDelayMs=t.retryBaseDelayMs??200,this.retryMaxDelayMs=t.retryMaxDelayMs??2e3,this.shutdownTimeoutMs=t.shutdownTimeoutMs??2e3,this.fetchFn=t.fetchFn??aU,this.logger=t.logger??console,this.now=t.now??(()=>new Date),this.sleep=t.sleep??(a=>new Promise(n=>setTimeout(n,a))),this.apiKey=t.apiKey,this.sdkVersion=t.sdkVersion,this.flushIntervalMs>0&&(this.flushTimer=setInterval(()=>{this.flush()},this.flushIntervalMs)),this.registerBrowserTeardown()}enqueue(t){if(this.isStopped||this.isShuttingDown){this.logger.warn("[Waniwani] Tracking transport is stopped, dropping event %s",t.id);return}if(this.buffer.length>=this.maxBufferSize){let a=this.buffer.length-this.maxBufferSize+1;this.buffer.splice(0,a),this.logger.warn("[Waniwani] Tracking buffer overflow, dropped %d oldest event(s)",a)}if(this.buffer.push(t),this.buffer.length>=this.maxBatchSize){this.flush();return}this.scheduleMicroFlush()}pendingEvents(){return this.buffer.length+this.inFlightCount}async flush(){return this.flushInFlight?this.flushInFlight:(this.flushInFlight=this.flushLoop().finally(()=>{this.flushInFlight=void 0}),this.flushInFlight)}async shutdown(t){this.isShuttingDown=!0,this.flushTimer&&(clearInterval(this.flushTimer),this.flushTimer=void 0),this.flushScheduledTimer&&(clearTimeout(this.flushScheduledTimer),this.flushScheduledTimer=void 0,this.flushScheduled=!1);let a=t?.timeoutMs??this.shutdownTimeoutMs,n=this.flush();if(!Number.isFinite(a)||a<=0)return await n,this.isStopped=!0,{timedOut:!1,pendingEvents:this.pendingEvents()};let r=Symbol("shutdown-timeout");return await Promise.race([n.then(()=>"flushed"),this.sleep(a).then(()=>r)])===r?(this.isStopped=!0,{timedOut:!0,pendingEvents:this.pendingEvents()}):(this.isStopped=!0,{timedOut:!1,pendingEvents:this.pendingEvents()})}registerBrowserTeardown(){if(typeof document>"u"||typeof window>"u")return;let t=()=>{document.visibilityState==="hidden"&&this.keepaliveFlush()};document.addEventListener("visibilitychange",t),window.addEventListener("pagehide",()=>this.keepaliveFlush())}keepaliveFlush(){if(this.isStopped||this.buffer.length===0)return;let t=this.buffer.splice(0,this.buffer.length);this.sendKeepaliveChunk(t)}sendKeepaliveChunk(t){let a=JSON.stringify(this.makeBatchRequest(t));if(a.length>6e4&&t.length>1){let n=Math.ceil(t.length/2);this.sendKeepaliveChunk(t.slice(0,n)),this.sendKeepaliveChunk(t.slice(n));return}try{this.fetchFn(this.endpointUrl,{method:"POST",headers:this.requestHeaders(),body:a,keepalive:!0}).catch(()=>{})}catch{}}requestHeaders(){let t={"Content-Type":"application/json","X-WaniWani-SDK":IC};return this.apiKey&&(t.Authorization=`Bearer ${this.apiKey}`),t}scheduleMicroFlush(){this.flushScheduled||(this.flushScheduled=!0,this.flushScheduledTimer=setTimeout(()=>{this.flushScheduledTimer=void 0,this.flushScheduled=!1,this.flush()},0))}async flushLoop(){for(;this.buffer.length>0&&!this.isStopped;){let t=this.buffer.splice(0,this.maxBatchSize);await this.sendBatchWithRetry(t)}}async sendBatchWithRetry(t){let a=0,n=t;for(;n.length>0&&!this.isStopped;){this.inFlightCount=n.length;let r=await this.sendBatchOnce(n);switch(this.inFlightCount=0,r.kind){case"success":return;case"auth":this.stopTransportForAuthFailure(r.status,n.length);return;case"permanent":this.logger.error("[Waniwani] Dropping %d event(s) after permanent failure: %s",n.length,r.reason);return;case"retryable":if(a>=this.maxRetries){this.logger.error("[Waniwani] Dropping %d event(s) after retry exhaustion: %s",n.length,r.reason);return}await this.sleep(this.backoffDelayMs(a)),a+=1;continue;case"partial":if(r.permanent.length>0&&this.logger.error("[Waniwani] Dropping %d event(s) rejected as permanent",r.permanent.length),r.retryable.length===0)return;if(a>=this.maxRetries){this.logger.error("[Waniwani] Dropping %d retryable event(s) after retry exhaustion",r.retryable.length);return}n=r.retryable,await this.sleep(this.backoffDelayMs(a)),a+=1;continue}}}async sendBatchOnce(t){let a;try{a=await this.fetchFn(this.endpointUrl,{method:"POST",headers:this.requestHeaders(),body:JSON.stringify(this.makeBatchRequest(t))})}catch(o){return{kind:"retryable",reason:iU(o)}}if(eU.has(a.status))return{kind:"auth",status:a.status};if(tU.has(a.status))return{kind:"retryable",reason:`HTTP ${a.status}`};if(!a.ok)return{kind:"permanent",reason:`HTTP ${a.status}`};let n=await rU(a);if(!n?.rejected||n.rejected.length===0)return{kind:"success"};let r=this.classifyRejectedEvents(t,n.rejected);return r.retryable.length===0&&r.permanent.length===0?{kind:"success"}:{kind:"partial",retryable:r.retryable,permanent:r.permanent}}makeBatchRequest(t){return{sentAt:this.now().toISOString(),source:{sdk:IC,version:this.sdkVersion??"0.0.0"},events:t}}classifyRejectedEvents(t,a){let n=new Map(t.map(i=>[i.id,i])),r=[],o=[];for(let i of a){let l=n.get(i.eventId);if(l){if(nU(i)){r.push(l);continue}o.push(l)}}return{retryable:r,permanent:o}}backoffDelayMs(t){let a=this.retryBaseDelayMs*2**t;return Math.min(a,this.retryMaxDelayMs)}stopTransportForAuthFailure(t,a){this.isStopped=!0;let n=this.buffer.length;this.buffer.splice(0,n),this.logger.error("[Waniwani] Auth failure (HTTP %d). Stopping tracking transport and dropping %d queued event(s)",t,a+n)}};function nU(e){if(e.retryable===!0)return!0;let t=e.code.toLowerCase();return t.includes("timeout")||t.includes("temporary")||t.includes("unavailable")||t.includes("rate_limit")||t.includes("transient")||t.includes("server")}async function rU(e){let t=await e.text();if(t)try{return JSON.parse(t)}catch{return}}function oU(e,t){let a=e.endsWith("/")?e:`${e}/`,n=t.startsWith("/")?t.slice(1):t;return`${a}${n}`}function iU(e){return e instanceof Error?e.message:String(e)}function kC(e){let{apiUrl:t,endpointPath:a}=lU(e.endpoint),n=CC({apiUrl:t,apiKey:e.token,endpointPath:a,flushIntervalMs:e.flushIntervalMs}),r,o=l=>typeof l=="function"?l():l,i=async l=>{let s=e.identity?.()??{},u=o(e.channelId),c=u===void 0?l.properties:{channelId:u,...l.properties},d=bC({sessionId:s.sessionId,visitorId:s.visitorId,externalUserId:s.externalUserId??r,traceId:s.traceId,...l,properties:c,metadata:{...e.metadata,...l.metadata}},{source:o(e.source)});return n.enqueue(d),{eventId:d.id}};return{track:Object.assign(i,SC(i)),identify(l,s){return r=l,i({event:"user.identified",externalUserId:l,properties:s})},flush:()=>n.flush(),shutdown:l=>n.shutdown(l)}}function lU(e){let t=new URL(e);return{apiUrl:t.origin,endpointPath:`${t.pathname}${t.search}`}}function ma(e,t,a){let[n,r=""]=e.split("?"),o=n.replace(/\/$/,""),i=new URLSearchParams(r);if(a)for(let[s,u]of Object.entries(a))i.set(s,u);let l=i.toString();return`${o}${t}${l?`?${l}`:""}`}var sU="/api/mcp/";function Wd(e,t){let[a=""]=e.split("?"),n="",r=a;try{let o=new URL(a);n=o.origin,r=o.pathname}catch{if(!a.startsWith("/"))return null}return r.startsWith(sU)?`${n}${t}`:null}function uU(){if(typeof window>"u")return!1;try{return window.WANIWANI_DEBUG?!0:!!window.localStorage?.getItem("WANIWANI_DEBUG")}catch{return!1}}function ha(...e){uU()&&console.log("[Waniwani]",...e)}var zg="waniwani-visitor-id";function cU(){try{if(typeof crypto<"u"){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();if(typeof crypto.getRandomValues=="function"){let e=crypto.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=Array.from(e,a=>a.toString(16).padStart(2,"0")).join("");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}}}catch{}return`v-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function Zt(){try{let t=localStorage.getItem(zg);if(t)return t}catch{}let e=cU();try{localStorage.setItem(zg,e)}catch{}return e}function ll(e){let t=typeof e=="string"?e.trim():"";if(!t)return Zt();try{localStorage.setItem(zg,t)}catch{}return t}function dU(e){return e!=null&&typeof e.then=="function"}function Xs(e){let t=!1,a=()=>{t=!0};if(e==null)return a;let n;try{n=typeof e=="function"?e():e}catch{return a}return dU(n)?n.then(r=>{t||ll(r??"")},()=>{}):ll(n??""),a}var fU="waniwani-memory";var Wa="threads",Gd="by_memoryUserId",pU="by_updatedAt";var LC="memoryUserId",TC="waniwani-memory-user-id",qg=null;function Hg(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}function mU(e,t){if(t<1&&(e.objectStoreNames.contains("ids")||e.createObjectStore("ids")),t<2&&!e.objectStoreNames.contains(Wa)){let a=e.createObjectStore(Wa,{keyPath:"threadId"});a.createIndex(Gd,"memoryUserId",{unique:!1}),a.createIndex(pU,"updatedAt",{unique:!1})}}async function jg(){return new Promise((e,t)=>{let a=indexedDB.open(fU,2);a.onupgradeneeded=n=>{mU(a.result,n.oldVersion)},a.onsuccess=()=>e(a.result),a.onerror=()=>t(a.error)})}async function hU(){return jg()}async function gU(e){return new Promise((t,a)=>{let o=e.transaction("ids","readonly").objectStore("ids").get(LC);o.onsuccess=()=>t(typeof o.result=="string"?o.result:null),o.onerror=()=>a(o.error)})}async function wU(e,t){return new Promise((a,n)=>{let i=e.transaction("ids","readwrite").objectStore("ids").put(t,LC);i.onsuccess=()=>a(),i.onerror=()=>n(i.error)})}async function yU(){if(typeof indexedDB>"u")return null;try{let e=await hU();try{let t=await gU(e);if(t)return t;let a=Hg();return await wU(e,a),a}finally{e.close()}}catch{return null}}function xU(){try{let e=localStorage.getItem(TC);if(e)return e;let t=Hg();return localStorage.setItem(TC,t),t}catch{return null}}async function EC(){let e=await yU();if(e)return e;let t=xU();return t||(qg||(qg=Hg()),qg)}function MC(e,t){return e.match(t)?.[1]??null}function vU(e){let t=[["Edge",/Edg(?:e|A|iOS)?\/(\S+)/],["Opera",/(?:OPR|Opera)\/(\S+)/],["Samsung Internet",/SamsungBrowser\/(\S+)/],["Firefox",/Firefox\/(\S+)/],["Chrome",/Chrome\/(\S+)/],["Safari",/Version\/(\S+).*Safari/]];for(let[a,n]of t){let r=MC(e,n);if(r)return{name:a,version:r}}return null}function bU(e){let t=[["iOS",/(?:iPhone|iPad|iPod).+?OS (\d+[_.\d]*)/],["Android",/Android (\d+[.\d]*)/],["macOS",/Mac OS X (\d+[_.\d]*)/],["Windows",/Windows NT (\d+[.\d]*)/],["ChromeOS",/CrOS \S+ (\d+[.\d]*)/],["Linux",/Linux/]];for(let[a,n]of t){let r=MC(e,n);if(r)return{name:a,version:r.replace(/_/g,".")};if(a==="Linux"&&n.test(e))return{name:a,version:""}}return null}function SU(e){return typeof navigator<"u"&&"userAgentData"in navigator&&navigator.userAgentData?.mobile?"mobile":/iPad|tablet|PlayBook/i.test(e)?"tablet":/Mobi|Android.*Mobile|iPhone|iPod/i.test(e)?"mobile":"desktop"}async function Ks(){let e=navigator.userAgent,t=Zt(),a=await EC();return{userAgent:e,browser:vU(e),os:bU(e),deviceType:SU(e),language:navigator.language,languages:[...navigator.languages],timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,screenWidth:screen.width,screenHeight:screen.height,viewportWidth:window.innerWidth,viewportHeight:window.innerHeight,colorDepth:screen.colorDepth,devicePixelRatio:window.devicePixelRatio??1,touchSupport:"ontouchstart"in window||navigator.maxTouchPoints>0,connectionType:navigator.connection?.effectiveType??"unknown",referrer:document.referrer,visitorId:t,memoryUserId:a}}var IU="0.22.0-beta.3",CU=40,kU=10,TU=6e5;function Wg(){return typeof performance>"u"?0:performance.now()}function Gg(e,t){let a={};return{metrics:a,has:n=>n in a,set(n,r){a[n]=r},mark(n,r=Wg()){if(!(n in a)){a[n]=r-t;try{performance.mark(`waniwani:${e}:${n}`,{startTime:r})}catch{}}}}}function LU(e){let t={};for(let[a,n]of Object.entries(e)){if(Object.keys(t).length>=CU)break;if(!Number.isFinite(n))continue;let r=Math.round(n);r<0||r>TU||(t[a]=r)}return t}function EU(e){let t={};for(let[a,n]of Object.entries(e)){if(Object.keys(t).length>=kU)break;(typeof n=="string"||typeof n=="boolean")&&(t[a]=n)}return t}function MU(){let e=navigator.connection;if(e)return{effectiveType:e.effectiveType,rtt:e.rtt,downlink:e.downlink,saveData:e.saveData}}function Xd(e){let t=e?.Authorization;return typeof t=="string"&&t.startsWith("Bearer ")?t.slice(7):void 0}function AU(e,t,a,n){return{kind:e,sdkVersion:IU,channelId:t.channelId||void 0,sessionId:e==="boot"?void 0:t.sessionId||void 0,visitorId:Zt(),pageHost:window.location.hostname,connection:MU(),tags:EU(a),metrics:LU(n)}}var Vg,$d=[];function $g(e){let t=String(e?.chatTimingLogs).trim().toLowerCase()==="true";Vg=t;let a=$d;if($d=[],t)for(let n of a)n()}function Kd(e,t,a,n){let{api:r,token:o}=t;if(!(typeof window>"u"||!r||!o||Vg===!1))try{let i=AU(e,t,a,n),l=()=>{ha("timing",i),fetch(ma(r,"/timing"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify(i),keepalive:!0}).catch(()=>{})};Vg?l():$d.length<20&&$d.push(l)}catch{}}var dr=Gg("boot",0),AC;function Uo(e,t){dr.mark(e,t)}function Yd(e){AC??(AC=e)}var RU=/cdn\.jsdelivr\.net\/npm\/@waniwani\/sdk@[^/]+\/dist\/chat\/embed\.js/,DU=/\/embed\.js(\?|$)/;function _U(){if(typeof performance>"u")return;let e=performance.getEntriesByType("navigation")[0];e?.responseStart&&dr.mark("navTtfb",e.responseStart),e?.domContentLoadedEventEnd&&dr.mark("navDomContentLoaded",e.domContentLoadedEventEnd);let t=performance.getEntriesByType("resource");for(let a of t)RU.test(a.name)?(dr.mark("bundleStart",a.startTime),dr.mark("bundleEnd",a.responseEnd)):DU.test(a.name)&&(dr.mark("loaderStart",a.startTime),dr.mark("loaderEnd",a.responseEnd))}function OU(){if(kv)return!0;try{return document.querySelectorAll('script[src*="@waniwani/sdk"]').length>1}catch{return!1}}function RC(e){_U(),dr.mark("bundleExecuted",Cv),Kd("boot",e,{configSource:AC,mode:e.mode,secondSdk:OU()},dr.metrics)}var PU=[["text-delta","firstText"],["tool-input-start","firstToolInput"],["tool-output-available","firstToolOutput"]];function DC(e){let t=Gg("turn",Wg());t.set("turnIndex",e);let a=!1;return{mark:n=>t.mark(n),instrument(n){if(!n.ok||!n.body||typeof TransformStream>"u")return n;try{let r=new TextDecoder,o=n.body.pipeThrough(new TransformStream({transform(i,l){t.mark("firstChunk");let s=r.decode(i,{stream:!0});for(let[u,c]of PU)!t.has(c)&&s.includes(u)&&t.mark(c);l.enqueue(i)}}));return new Response(o,{status:n.status,statusText:n.statusText,headers:n.headers})}catch{return n}},report(n,r){a||(a=!0,Kd("turn",n,r,t.metrics))}}}function NU(e){let t=e.indexOf("?");return t===-1?e:e.slice(0,t)}function _C(e,t){let a=Gg("widget",Wg()),n=!1;return{mark:r=>a.mark(r),has:r=>a.has(r),report(r,o){n||(n=!0,a.set("retries",o),t({widget:NU(e),outcome:r,metrics:a.metrics}))}}}var BU="/api/mcp/events/v2/batch",Xg=new Set;function UU(e,t,a){return`${e}|${t}|${a??""}`}function Ys(e){return Wd(e,BU)}async function OC(e){let{api:t,token:a,channelId:n,mode:r,source:o}=e;if(typeof window>"u"||!t||!a)return;let i=Ys(t);if(!i){ha("page.viewed skipped: the chat api is not a Waniwani endpoint");return}if(!n&&!o){ha("page.viewed skipped: no channelId or source to attribute it");return}let l=UU(t,a,n);if(!Xg.has(l)){Xg.add(l);try{let s=await Ks(),u=new Date().toISOString(),c=JSON.stringify({sentAt:u,source:{sdk:"@waniwani/sdk",version:"0.1.0"},events:[{id:crypto.randomUUID(),type:"mcp.event",name:"page.viewed",source:o,timestamp:u,correlation:{visitorId:s.visitorId},properties:{channelId:n,mode:r,url:window.location.href,referrer:s.referrer,deviceType:s.deviceType,language:s.language,timezone:s.timezone},metadata:{}}]}),d=fetch(i,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:c,keepalive:!0});Uo("pageViewSent"),await d}catch{Xg.delete(l)}}}function PC(e){let t=Ys(e.api);return t?kC({endpoint:t,token:e.token,channelId:e.channelId,source:e.getSource,identity:()=>({sessionId:e.getSessionId(),visitorId:Zt()})}):Zd("the chat api does not point at a Waniwani event ingest")}function Zd(e){let t=!1,a=async()=>(t||(t=!0,console.warn(`[Waniwani] track() is disabled: ${e}`)),{eventId:""});return{track:Object.assign(a,{priceShown:a,pricesCompared:a,optionSelected:a,leadQualified:a,converted:a}),identify:a,flush:async()=>{},shutdown:async()=>({timedOut:!1,pendingEvents:0})}}var Jd=z(he());var Qd=(...e)=>e.filter((t,a,n)=>!!t&&t.trim()!==""&&n.indexOf(t)===a).join(" ").trim();var NC=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();var BC=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,a,n)=>n?n.toUpperCase():a.toLowerCase());var Kg=e=>{let t=BC(e);return t.charAt(0).toUpperCase()+t.slice(1)};var Zs=z(he());var UC={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};var FC=e=>{for(let t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};var zC=(0,Zs.forwardRef)(({color:e="currentColor",size:t=24,strokeWidth:a=2,absoluteStrokeWidth:n,className:r="",children:o,iconNode:i,...l},s)=>(0,Zs.createElement)("svg",{ref:s,...UC,width:t,height:t,stroke:e,strokeWidth:n?Number(a)*24/Number(t):a,className:Qd("lucide",r),...!o&&!FC(l)&&{"aria-hidden":"true"},...l},[...i.map(([u,c])=>(0,Zs.createElement)(u,c)),...Array.isArray(o)?o:[o]]));var He=(e,t)=>{let a=(0,Jd.forwardRef)(({className:n,...r},o)=>(0,Jd.createElement)(zC,{ref:o,iconNode:t,className:Qd(`lucide-${NC(Kg(e))}`,`lucide-${e}`,n),...r}));return a.displayName=Kg(e),a};var FU=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Qs=He("arrow-down",FU);var zU=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Nn=He("arrow-up",zU);var qU=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Js=He("check",qU);var HU=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Qr=He("chevron-down",HU);var jU=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],eu=He("chevron-right",jU);var VU=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",key:"4jdomd"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4",key:"3hqy98"}],["path",{d:"M21 14H11",key:"1bme5i"}],["path",{d:"m15 10-4 4 4 4",key:"5dvupr"}]],tu=He("clipboard-copy",VU);var WU=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],fr=He("clock",WU);var GU=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],au=He("file-text",GU);var $U=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}]],sl=He("file",$U);var XU=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],nu=He("globe",XU);var KU=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],ru=He("image",KU);var YU=[["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m16.2 7.8 2.9-2.9",key:"r700ao"}],["path",{d:"M18 12h4",key:"wj9ykh"}],["path",{d:"m16.2 16.2 2.9 2.9",key:"1bxg5t"}],["path",{d:"M12 18v4",key:"jadmvz"}],["path",{d:"m4.9 19.1 2.9-2.9",key:"bwix9q"}],["path",{d:"M2 12h4",key:"j09sii"}],["path",{d:"m4.9 4.9 2.9 2.9",key:"giyufr"}]],ou=He("loader",YU);var ZU=[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]],ul=He("paperclip",ZU);var QU=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],iu=He("square",QU);var JU=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],Fo=He("wrench",JU);var e3=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Ga=He("x",e3);var t3=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],lu=He("zap",t3);var $e=z(he(),1),dO=z(dm(),1);var cl=z(he(),1),su=z(ae(),1);function r3(e){return 1-(1-e)**3}function o3({start:e=0,end:t=100,duration:a=1e3,delay:n=0,ease:r=r3,onUpdate:o,onEnd:i}){let l=performance.now()+n;function s(){let u=performance.now()-l,c=Math.min(u/a,1);o(e+(t-e)*r(c)),c<1?requestAnimationFrame(s):i&&i()}setTimeout(()=>requestAnimationFrame(s),n)}var i3=["80% 55%","69% 34%","8% 6%","41% 38%","86% 85%","82% 18%","51% 4%"],l3=[0,1,2,0,1,2,1];function s3(e){let t=[];for(let a=0;a<7;a++){let n=e[Math.min(l3[a],e.length-1)];t.push(`radial-gradient(at ${i3[a]}, ${n} 0px, transparent 50%)`)}return t.push(`linear-gradient(${e[0]} 0 100%)`),t}var u3=({children:e,className:t="",style:a,edgeSensitivity:n=30,backgroundColor:r="#120F17",borderRadius:o=28,coneSpread:i=25,animated:l=!1,colors:s=["#c084fc","#f472b6","#38bdf8"]})=>{let[u,c]=(0,cl.useState)(110),[d,f]=(0,cl.useState)(0),[p,m]=(0,cl.useState)(!1);(0,cl.useEffect)(()=>{if(!l)return;let T=110;m(!0),c(T),o3({ease:C=>C,duration:2e3,onUpdate:C=>{let M=C/100;c(T+360*M);let D=Math.min(M/.1,1),P=M>.85?(1-M)/.15:1;f(Math.min(D,P))},onEnd:()=>m(!1)})},[l]);let x=n+20,S=p?Math.max(0,(d*100-x)/(100-x)):0,y=s3(s).map(T=>`${T} border-box`),b=`conic-gradient(from ${`${u.toFixed(3)}deg`} at center, black ${i}%, transparent ${i+15}%, transparent ${100-i-15}%, black ${100-i}%)`;return(0,su.jsxs)("div",{className:`ww:relative ww:grid ww:isolate ww:border ${t}`,style:{background:r,borderRadius:typeof o=="number"?`${o}px`:o,transform:"translate3d(0, 0, 0.01px)",...a},children:[(0,su.jsx)("div",{className:"ww:absolute ww:inset-0 ww:rounded-[inherit] ww:-z-[1]",style:{border:"1px solid transparent",background:[`linear-gradient(${r} 0 100%) padding-box`,"linear-gradient(rgb(255 255 255 / 0%) 0% 100%) border-box",...y].join(", "),opacity:S,maskImage:b,WebkitMaskImage:b,transition:p?"opacity 0.25s ease-out":"opacity 0.75s ease-in-out"}}),(0,su.jsx)("div",{className:"ww:flex ww:flex-col ww:relative ww:overflow-auto ww:z-[1]",children:e})]})},tf=u3;Yg();Qg();var c3=WC({prefix:"ww"});function q(...e){return c3(af(e))}var uu=z(ae(),1);function dl({suggestions:e,isLoading:t,onSelect:a,align:n="start",className:r,...o}){return e.length===0&&!t?null:(0,uu.jsx)("div",{className:q("ww:px-4 ww:py-2",r),...o,children:(0,uu.jsx)("div",{className:q("ww:mx-auto ww:w-full ww:max-w-3xl ww:flex ww:flex-wrap ww:gap-2",n==="center"&&"ww:justify-center"),children:t?[0,1,2].map(i=>(0,uu.jsx)("div",{className:"ww:h-8 ww:rounded-full ww:bg-accent ww:animate-pulse",style:{width:`${60+i*20}px`}},i)):e.map((i,l)=>(0,uu.jsx)("button",{type:"button",onClick:()=>a(i),className:q("ww:rounded-full ww:border ww:border-border ww:bg-accent ww:px-3.5 ww:py-1.5 ww:text-sm","ww:text-foreground ww:hover:bg-border ww:hover:border-primary/30","ww:transition-all ww:duration-200 ww:ease-out ww:cursor-pointer","ww:animate-[ww-fade-in_0.2s_ease-out_both]"),style:{animationDelay:`${l*50}ms`},children:i},i))})})}var GC=z(he(),1),$C="(max-width: 639px)";function d3(e){let t=window.matchMedia($C);return t.addEventListener("change",e),()=>t.removeEventListener("change",e)}function f3(){return window.matchMedia($C).matches}function p3(){return!1}function XC(){return(0,GC.useSyncExternalStore)(d3,f3,p3)}var nf=z(he(),1);function Jg(e,t){return e.find(a=>a.text===t)?.id??null}async function KC(e){let{api:t,token:a,name:n,source:r,sessionId:o,properties:i}=e;if(typeof window>"u"||!t||!a)return;let l=Ys(t);if(l)try{let s=new Date().toISOString(),u=JSON.stringify({sentAt:s,source:{sdk:"@waniwani/sdk",version:"0.1.0"},events:[{id:crypto.randomUUID(),type:"mcp.event",name:n,source:r,timestamp:s,correlation:{visitorId:Zt(),sessionId:o},properties:{...i,url:window.location.href},metadata:{}}]});await fetch(l,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:u,keepalive:!0})}catch{}}async function YC(e){let{api:t,token:a,channelId:n,mode:r,source:o,sessionId:i,promptId:l,origin:s,text:u,index:c}=e;await KC({api:t,token:a,name:"suggestion.clicked",source:o,sessionId:i,properties:{promptId:l,origin:s,text:u,index:c,channelId:n,mode:r}})}function ZC(e,t){return t.map(a=>({id:Jg(e,a),text:a}))}async function QC(e){let{api:t,token:a,channelId:n,mode:r,source:o,sessionId:i,prompts:l,origin:s}=e;l.length!==0&&await KC({api:t,token:a,name:"suggestion.shown",source:o,sessionId:i,properties:{prompts:l,count:l.length,origin:s,channelId:n,mode:r}})}function fl(e){let{widgetEvents:t,api:a,token:n,channelId:r,source:o,mode:i,pagePrompts:l}=e,s=(0,nf.useRef)(e.getSessionId);s.current=e.getSessionId,(0,nf.useEffect)(()=>{if(!(!a||!n))return t.subscribe(u=>{if(u.name==="suggestion.clicked"){let{text:c,origin:d,index:f}=u.properties;YC({api:a,token:n,channelId:r,mode:i,source:o,sessionId:s.current(),promptId:Jg(l??[],c),origin:d,text:c,index:f});return}if(u.name==="suggestions.shown"){let{texts:c,origin:d}=u.properties;QC({api:a,token:n,channelId:r,mode:i,source:o,sessionId:s.current(),prompts:ZC(l??[],c),origin:d})}})},[t,a,n,r,o,i,l])}var pl=z(he(),1),m3=80,h3=50,g3=15e3,JC=500;function ml(e,t=!0){let[a,n]=(0,pl.useState)(""),r=(0,pl.useRef)(void 0);return(0,pl.useEffect)(()=>{if(!t){n("");return}let o=0,i=!1,l=!1,s=()=>{l||(i?(o--,n(e.slice(0,o)),o<=0?(i=!1,r.current=setTimeout(s,JC)):r.current=setTimeout(s,h3)):(o++,n(e.slice(0,o)),o>=e.length?(i=!0,r.current=setTimeout(s,g3)):r.current=setTimeout(s,m3)))};return r.current=setTimeout(s,JC),()=>{l=!0,clearTimeout(r.current)}},[e,t]),a}var Sn=z(he(),1);var ek=["en","fr","es"];function hl(e){return ek.includes(e)}function ew(e){if(e&&hl(e))return e;if(e){let a=e.split("-")[0]?.toLowerCase();if(a&&hl(a))return a}let t=[];if(typeof navigator<"u"&&(navigator.language&&t.push(navigator.language),navigator.languages&&t.push(...navigator.languages)),typeof document<"u"){let a=document.documentElement.getAttribute("lang");a&&t.push(a)}for(let a of t){let n=a.toLowerCase();if(hl(n))return n;let r=n.split("-")[0];if(r&&hl(r))return r}return"en"}var rf={promptInput:{placeholder:"What would you like to know?",uploadFiles:"Upload files",uploadFilesUpTo:"Upload a document, up to {limit}",uploadFilesUpToWithPages:"Upload a document, up to {limit} and {pages} pages",stop:"Stop",submit:"Submit",removeAttachments:"Remove all attachments",removeAttachment:"Remove attachment",uploading:"Uploading\u2026",retry:"Retry",retryUpload:"Retry the upload",uploadFailed:"The upload did not finish.",dropToAttach:"Drop to attach",errorAccept:"{name} is not a file type this chat accepts.",errorTooLarge:"{name} is larger than {limit}.",errorTooMany:"You can attach up to {limit} files."},workingIndicator:{default:"On it\u2026"},reasoning:{thinking:"Thinking\u2026",thoughtBrief:"Thought for a few seconds",thoughtForSeconds:e=>`Thought for ${e} second${e===1?"":"s"}`},chainOfThought:{working:"Working on it\u2026",done:"Thought process"},tool:{copy:"Copy",copied:"Copied",request:"Request",response:"Response",error:"Error"},attachments:{attachmentFallback:"attachment",kindPdf:"PDF",kindImage:"Image",kindFile:"File",fileFallback:"file"},threadMenu:{newChat:"New chat",threadHistory:"Thread history",deleteThread:"Delete thread",noPreviousChats:"No previous chats yet.",hiddenThreads:e=>`${e} older thread${e===1?"":"s"} hidden`},chatQueue:{attachmentFallback:"(attachment)",removeFromQueue:"Remove from queue",queued:e=>`${e} queued`},poweredBy:{label:"AI agent powered by"},aiDisclaimer:{default:"can make mistakes"},exportSession:{saving:"saving...",saved:"saved",error:"error",export:"export",tooltip:"Save scenario to Waniwani"},widgetErrorBoundary:{failedToLoad:"Widget failed to load",retry:"Retry"},launcher:{prompt:"Ask anything\u2026",open:"Open chat",close:"Close chat",minimize:"Minimize"}};var tk={promptInput:{placeholder:"\xBFQu\xE9 te gustar\xEDa saber?",uploadFiles:"Subir archivos",uploadFilesUpTo:"Subir un documento, hasta {limit}",uploadFilesUpToWithPages:"Subir un documento, hasta {limit} y {pages} p\xE1ginas",stop:"Detener",submit:"Enviar",removeAttachments:"Eliminar todos los archivos adjuntos",removeAttachment:"Quitar archivo",uploading:"Subiendo\u2026",retry:"Reintentar",retryUpload:"Reintentar la subida",uploadFailed:"La subida no se complet\xF3.",dropToAttach:"Suelta para adjuntar",errorAccept:"{name} no es un tipo de archivo que acepte este chat.",errorTooLarge:"{name} supera {limit}.",errorTooMany:"Puedes adjuntar hasta {limit} archivos."},workingIndicator:{default:"Un momento\u2026"},reasoning:{thinking:"Pensando\u2026",thoughtBrief:"Pensado durante unos segundos",thoughtForSeconds:e=>`Pensado durante ${e} segundo${e===1?"":"s"}`},chainOfThought:{working:"Estoy en ello\u2026",done:"Razonamiento"},tool:{copy:"Copiar",copied:"Copiado",request:"Solicitud",response:"Respuesta",error:"Error"},attachments:{attachmentFallback:"adjunto",kindPdf:"PDF",kindImage:"Imagen",kindFile:"Archivo",fileFallback:"archivo"},threadMenu:{newChat:"Nueva conversaci\xF3n",threadHistory:"Historial",deleteThread:"Eliminar conversaci\xF3n",noPreviousChats:"A\xFAn no hay conversaciones anteriores.",hiddenThreads:e=>`${e} conversaci\xF3n${e===1?"":"es"} anterior${e===1?"":"es"} oculta${e===1?"":"s"}`},chatQueue:{attachmentFallback:"(adjunto)",removeFromQueue:"Quitar de la cola",queued:e=>`${e} en cola`},poweredBy:{label:"Agente IA con tecnolog\xEDa de"},aiDisclaimer:{default:"puede cometer errores"},exportSession:{saving:"guardando...",saved:"guardado",error:"error",export:"exportar",tooltip:"Guardar escenario en Waniwani"},widgetErrorBoundary:{failedToLoad:"No se pudo cargar el widget",retry:"Reintentar"},launcher:{prompt:"Pregunta lo que quieras\u2026",open:"Abrir chat",close:"Cerrar chat",minimize:"Minimizar"}};var ak={promptInput:{placeholder:"Que souhaitez-vous savoir ?",uploadFiles:"Importer des fichiers",uploadFilesUpTo:"Joindre un document, jusqu'\xE0 {limit}",uploadFilesUpToWithPages:"Envoyer un document, jusqu'\xE0 {limit} et {pages} pages",stop:"Arr\xEAter",submit:"Envoyer",removeAttachments:"Supprimer toutes les pi\xE8ces jointes",removeAttachment:"Retirer la pi\xE8ce jointe",uploading:"Envoi en cours\u2026",retry:"R\xE9essayer",retryUpload:"R\xE9essayer l'envoi",uploadFailed:"L'envoi ne s'est pas termin\xE9.",dropToAttach:"D\xE9posez pour joindre",errorAccept:"{name} n'est pas un type de fichier accept\xE9 par ce chat.",errorTooLarge:"{name} d\xE9passe {limit}.",errorTooMany:"Vous pouvez joindre jusqu'\xE0 {limit} fichiers."},workingIndicator:{default:"Un instant\u2026"},reasoning:{thinking:"R\xE9flexion\u2026",thoughtBrief:"R\xE9flexion pendant quelques secondes",thoughtForSeconds:e=>`R\xE9flexion pendant ${e} seconde${e===1?"":"s"}`},chainOfThought:{working:"Je m'en occupe\u2026",done:"Raisonnement"},tool:{copy:"Copier",copied:"Copi\xE9",request:"Requ\xEAte",response:"R\xE9ponse",error:"Erreur"},attachments:{attachmentFallback:"pi\xE8ce jointe",kindPdf:"PDF",kindImage:"Image",kindFile:"Fichier",fileFallback:"fichier"},threadMenu:{newChat:"Nouvelle conversation",threadHistory:"Historique",deleteThread:"Supprimer la conversation",noPreviousChats:"Aucune conversation pr\xE9c\xE9dente.",hiddenThreads:e=>`${e} conversation${e===1?"":"s"} plus ancienne${e===1?"":"s"} masqu\xE9e${e===1?"":"s"}`},chatQueue:{attachmentFallback:"(pi\xE8ce jointe)",removeFromQueue:"Retirer de la file",queued:e=>`${e} en attente`},poweredBy:{label:"Agent IA propuls\xE9 par"},aiDisclaimer:{default:"peut faire des erreurs"},exportSession:{saving:"enregistrement...",saved:"enregistr\xE9",error:"erreur",export:"exporter",tooltip:"Enregistrer le sc\xE9nario dans Waniwani"},widgetErrorBoundary:{failedToLoad:"\xC9chec du chargement du widget",retry:"R\xE9essayer"},launcher:{prompt:"Posez votre question\u2026",open:"Ouvrir le chat",close:"Fermer le chat",minimize:"R\xE9duire"}};var tw={en:rf,fr:ak,es:tk};var rk=z(ae(),1),nk=(0,Sn.createContext)(null);function w3(e,t){if(!t)return e;let a={...e};for(let n of Object.keys(e)){let r=e[n],o=t[n];o&&typeof r=="object"&&(a[n]={...r,...o})}return a}function zo({children:e,locale:t,messages:a}){let n=!!(t&&y3(t)),r=n?t:"en",[o,i]=(0,Sn.useState)(r),[l,s]=(0,Sn.useState)(n);(0,Sn.useEffect)(()=>{i(ew(t)),s(!0)},[t]);let u=(0,Sn.useMemo)(()=>{let c=tw[o]??tw["en"];return{locale:o,t:w3(c,a),ready:l}},[o,a,l]);return(0,rk.jsx)(nk.Provider,{value:u,children:e})}function y3(e){return e==="en"||e==="fr"||e==="es"}function Ie(){let e=(0,Sn.useContext)(nk);return e||{locale:"en",t:rf,ready:!0}}function aw(e,t){let a=Date.now()-e;if(a<6e4)try{return new Intl.RelativeTimeFormat(t,{numeric:"auto",style:"narrow"}).format(0,"second")}catch{return"just now"}let n,r;a<60*6e4?(n=-Math.floor(a/6e4),r="minute"):a<1440*6e4?(n=-Math.floor(a/(60*6e4)),r="hour"):(n=-Math.floor(a/(1440*6e4)),r="day");try{return new Intl.RelativeTimeFormat(t,{numeric:"auto",style:"short"}).format(n,r)}catch{return`${Math.abs(n)}${r==="minute"?"m":r==="hour"?"h":"d"} ago`}}var ze=z(he(),1);var cu=(e=21)=>crypto.getRandomValues(new Uint8Array(e)).reduce((t,a)=>(a&=63,a<36?t+=a.toString(36):a<62?t+=(a-26).toString(36).toUpperCase():a>62?t+="-":t+="_",t),"");var Ce=z(he(),1);var qo=new Map;function ok(e,t){if(qo.has(e)){URL.revokeObjectURL(t);return}for(qo.set(e,t);qo.size>20;){let a=qo.keys().next();if(a.done)return;let n=qo.get(a.value);qo.delete(a.value),n&&URL.revokeObjectURL(n)}}function ik(e){return qo.get(e)}var lk=z(ae(),1),Bn=({className:e,variant:t="default",size:a="default",type:n="button",...r})=>(0,lk.jsx)("button",{type:n,className:q("ww:inline-flex ww:cursor-pointer ww:items-center ww:justify-center ww:rounded-md ww:font-medium ww:transition-colors ww:disabled:pointer-events-none ww:disabled:opacity-50",t==="default"&&"ww:bg-primary ww:text-primary-foreground ww:hover:bg-primary/90",t==="outline"&&"ww:border ww:border-border ww:bg-background ww:hover:bg-accent ww:hover:text-accent-foreground",t==="ghost"&&"ww:hover:bg-accent ww:hover:text-accent-foreground",a==="default"&&"ww:h-9 ww:px-4 ww:py-2 ww:text-sm",a==="sm"&&"ww:h-8 ww:px-3 ww:text-xs",a==="icon"&&"ww:size-9 ww:!rounded-full",a==="icon-sm"&&"ww:size-7 ww:!rounded-full",e),...r});var sk=z(he(),1);var bt=z(ae(),1),uk=({files:e,className:t,...a})=>e.length===0?null:(0,bt.jsx)("div",{className:q("ww:flex ww:flex-wrap ww:gap-1.5",t),...a,children:e.map((n,r)=>(0,bt.jsx)(x3,{file:n},r))});function x3({file:e}){let{t}=Ie();return e.mediaType?.startsWith("image/")&&e.url?(0,bt.jsx)("img",{src:e.url,alt:e.filename??t.attachments.attachmentFallback,className:"ww:h-16 ww:max-w-32 ww:rounded ww:object-cover"}):(0,bt.jsxs)("span",{className:"ww:inline-flex ww:items-center ww:gap-1.5 ww:rounded ww:bg-background/20 ww:px-2 ww:py-1 ww:text-xs",children:[(0,bt.jsx)(sl,{className:"ww:size-3 ww:shrink-0"}),(0,bt.jsx)("span",{className:"ww:max-w-24 ww:truncate",children:e.filename??t.attachments.fileFallback})]})}function ck(e,t){return e.startsWith("image/")?t.attachments.kindImage:e==="application/pdf"?t.attachments.kindPdf:t.attachments.kindFile}function v3({mediaType:e}){return e.startsWith("image/")?(0,bt.jsx)(ru,{className:"ww:size-5 ww:text-muted-foreground"}):e==="application/pdf"?(0,bt.jsx)(au,{className:"ww:size-5 ww:text-muted-foreground"}):(0,bt.jsx)(sl,{className:"ww:size-5 ww:text-muted-foreground"})}function nw({filename:e,mediaType:t,previewUrl:a,subtitle:n,tone:r="default",children:o,className:i}){let{t:l}=Ie(),s=ck(t,l);return(0,bt.jsxs)("li",{"aria-label":`${e}, ${s}`,className:q("ww:relative ww:flex ww:w-60 ww:max-w-full ww:cursor-default ww:items-center ww:gap-2.5 ww:overflow-hidden ww:rounded-xl ww:border ww:bg-background ww:p-2.5",r==="error"?"ww:border-destructive/50":"ww:border-border",i),children:[(0,bt.jsx)("span",{className:"ww:flex ww:size-10 ww:shrink-0 ww:items-center ww:justify-center ww:overflow-hidden ww:rounded-xl ww:bg-muted",children:a?(0,bt.jsx)("img",{alt:"",className:"ww:size-full ww:object-cover ww:object-center",src:a}):(0,bt.jsx)(v3,{mediaType:t})}),(0,bt.jsxs)("span",{className:"ww:flex ww:min-w-0 ww:flex-col",children:[(0,bt.jsx)("span",{className:"ww:truncate ww:font-medium ww:text-sm",title:e,children:e}),(0,bt.jsx)("span",{className:q("ww:truncate ww:text-xs",r==="error"?"ww:text-destructive":"ww:text-muted-foreground"),children:n??s})]}),o]})}function dk(e){if(typeof e!="object"||e===null)return[];let t=e.documents;return Array.isArray(t)?t.filter(a=>typeof a=="object"&&a!==null&&typeof a.documentId=="string"&&typeof a.filename=="string"&&typeof a.mediaType=="string"):[]}var fk=({documents:e,className:t,...a})=>e.length===0?null:(0,bt.jsx)("ul",{className:q("ww:flex ww:list-none ww:flex-wrap ww:items-end ww:justify-end ww:gap-2 ww:p-0",t),...a,children:e.map((n,r)=>(0,bt.jsx)(b3,{document:n},`${n.documentId}-${r}`))});function b3({document:e}){let{t}=Ie(),[a,n]=(0,sk.useState)(!1),r=e.mediaType.startsWith("image/")?ik(e.documentId):void 0;return r&&!a?(0,bt.jsx)("li",{children:(0,bt.jsx)("img",{alt:`${e.filename}, ${ck(e.mediaType,t)}`,className:"ww:max-h-80 ww:max-w-72 ww:rounded-xl ww:border ww:border-border ww:object-contain",onError:()=>n(!0),src:r,title:e.filename})}):(0,bt.jsx)(nw,{filename:e.filename,mediaType:e.mediaType})}var ht=z(ae(),1),S3=async e=>{try{let a=await(await fetch(e)).blob();return new Promise(n=>{let r=new FileReader;r.onloadend=()=>n(r.result),r.onerror=()=>n(null),r.readAsDataURL(a)})}catch{return null}},I3=(e,t)=>{if(!t)return!0;let a=t.split(",").map(o=>o.trim().toLowerCase()).filter(Boolean);if(a.length===0)return!0;let n=e.type.toLowerCase(),r=e.name.toLowerCase();return a.some(o=>o.startsWith(".")?r.endsWith(o):o.endsWith("/*")?n.startsWith(o.slice(0,-1)):n===o)},mk=(0,Ce.createContext)(null),of=()=>{let e=(0,Ce.useContext)(mk);if(!e)throw new Error("usePromptInputAttachments must be used within a PromptInput");return e},hk=({className:e,accept:t,multiple:a,globalDrop:n,maxFiles:r,maxFileSize:o,maxPdfPages:i,attachmentsEnabled:l=!0,upload:s,onDiscard:u,onError:c,onSubmit:d,children:f,...p})=>{let{t:m,locale:x}=Ie(),S=(0,Ce.useRef)(null),w=(0,Ce.useRef)(null),[y,h]=(0,Ce.useState)([]),b=(0,Ce.useRef)(y),T=(0,Ce.useRef)(new Map),C=(0,Ce.useRef)(s),M=(0,Ce.useRef)(c),D=(0,Ce.useRef)(u);(0,Ce.useEffect)(()=>{C.current=s,M.current=c,D.current=u},[s,c,u]);let P=(0,Ce.useCallback)(v=>{b.current=v,h(v)},[]),L=(0,Ce.useCallback)(()=>{S.current?.click()},[]),$=(0,Ce.useCallback)((v,K)=>{P(b.current.map(ee=>ee.id===v?{...ee,...K}:ee))},[P]),H=(0,Ce.useCallback)((v,K)=>{let ee=C.current;if(!ee)return;let we=new AbortController,Ge=ee(K,we.signal,me=>{$(v,{progress:me})}).then(me=>($(v,{status:"ready",progress:1,documentId:me.documentId,error:void 0}),me)).catch(me=>{if(we.signal.aborted)return null;let ye=me instanceof Error?me.message:m.promptInput.uploadFailed;return $(v,{status:"failed",error:ye}),M.current?.({code:"upload_failed",message:ye}),null});T.current.set(v,{file:K,controller:we,done:Ge})},[$,m]),F=(0,Ce.useCallback)(v=>{let K=[...v];if(!l||K.length===0)return;let ee=(de,Q)=>M.current?.({code:de,message:Q}),we=[];for(let de of K){if(!I3(de,t)){ee("accept",m.promptInput.errorAccept.replace("{name}",de.name));continue}if(o&&de.size>o){ee("max_file_size",m.promptInput.errorTooLarge.replace("{name}",de.name).replace("{limit}",gk(o,x)));continue}we.push(de)}if(we.length===0)return;let Ge=typeof r=="number"?Math.max(0,r-b.current.length):void 0,me=typeof Ge=="number"?we.slice(0,Ge):we;if(me.length<we.length&&ee("max_files",m.promptInput.errorTooMany.replace("{limit}",String(r))),me.length===0)return;let ye=!!C.current,le=me.map(de=>({file:de,item:{filename:de.name,id:cu(),mediaType:de.type,type:"file",url:URL.createObjectURL(de),status:ye?"uploading":"ready",progress:0}}));P([...b.current,...le.map(de=>de.item)]);for(let de of le)H(de.item.id,de.file)},[r,o,t,l,H,P,m,x]),W=(0,Ce.useCallback)(v=>{let K=T.current.get(v);K&&($(v,{status:"uploading",progress:0,error:void 0}),H(v,K.file))},[$,H]),V=(0,Ce.useCallback)((v,K)=>{T.current.get(v.id)?.controller.abort(),T.current.delete(v.id),v.url&&(!K&&!!v.documentId&&!!v.mediaType?.startsWith("image/")&&v.documentId?ok(v.documentId,v.url):URL.revokeObjectURL(v.url)),K&&v.documentId&&D.current?.({documentId:v.documentId,filename:v.filename??"",mediaType:v.mediaType??""})},[]),N=(0,Ce.useCallback)(v=>{let K=b.current.find(ee=>ee.id===v);K&&V(K,!0),P(b.current.filter(ee=>ee.id!==v))},[V,P]),R=(0,Ce.useCallback)(()=>{for(let v of b.current)V(v,!0);P([])},[V,P]),G=(0,Ce.useRef)(l);(0,Ce.useEffect)(()=>{let v=G.current;G.current=l,v&&!l&&R()},[l,R]);let ue=(0,Ce.useCallback)(()=>{for(let v of b.current)V(v,!1);P([])},[V,P]);(0,Ce.useEffect)(()=>()=>{for(let v of b.current)T.current.get(v.id)?.controller.abort(),v.url&&URL.revokeObjectURL(v.url)},[]);let I=(0,Ce.useCallback)(v=>{v.currentTarget.files&&F(v.currentTarget.files),v.currentTarget.value=""},[F]);(0,Ce.useEffect)(()=>{if(!n)return;let v=ee=>{ee.dataTransfer?.types?.includes("Files")&&ee.preventDefault()},K=ee=>{ee.dataTransfer?.types?.includes("Files")&&ee.preventDefault(),ee.dataTransfer?.files&&ee.dataTransfer.files.length>0&&F(ee.dataTransfer.files)};return document.addEventListener("dragover",v),document.addEventListener("drop",K),()=>{document.removeEventListener("dragover",v),document.removeEventListener("drop",K)}},[F,n]);let We=(0,Ce.useCallback)(async v=>{v.preventDefault();let K=v.currentTarget,ee=new FormData(K).get("message")||"",we=new Map;for(;we.size<T.current.size;)await Promise.all([...T.current.entries()].filter(([le])=>!we.has(le)).map(async([le,de])=>{we.set(le,await de.done)}));for(let le of we.keys())T.current.has(le)||we.delete(le);if([...we.values()].some(le=>le===null)){M.current?.({code:"upload_failed",message:m.promptInput.uploadFailed});return}let Ge=[...we.values()].filter(le=>le!==null),me=C.current?[]:b.current,ye=await Promise.all(me.map(async({id:le,status:de,progress:Q,error:Be,...qe})=>{if(qe.url?.startsWith("blob:")){let _e=await S3(qe.url);return{...qe,url:_e??qe.url}}return qe}));try{let le=d({documents:Ge,files:ye,text:ee},v);le instanceof Promise&&await le,K.reset(),ue()}catch{}},[d,ue,m]),Je=(0,Ce.useMemo)(()=>({add:F,clear:R,files:y,openFileDialog:L,remove:N,retry:W,maxFileSize:o,maxPdfPages:i}),[y,F,N,W,R,L,o,i]);return(0,ht.jsxs)(mk.Provider,{value:Je,children:[(0,ht.jsx)("input",{accept:t,"aria-label":m.promptInput.uploadFiles,className:"ww:hidden",multiple:a,onChange:I,ref:S,title:m.promptInput.uploadFiles,type:"file"}),(0,ht.jsx)("form",{className:q("ww:relative ww:flex ww:w-full ww:flex-col ww:rounded-lg ww:border ww:border-border ww:bg-background",e),onSubmit:We,ref:w,...p,children:f})]})},pk=1024*1024;function gk(e,t){let a=e>=pk;return new Intl.NumberFormat(t,{style:"unit",unit:a?"megabyte":"kilobyte",maximumFractionDigits:0}).format(a?e/pk:Math.max(1,e/1024))}var wk=({onChange:e,onKeyDown:t,className:a,placeholder:n,...r})=>{let{t:o}=Ie(),i=of(),[l,s]=(0,Ce.useState)(!1),u=n??o.promptInput.placeholder,c=(0,Ce.useCallback)(f=>{if(t?.(f),!f.defaultPrevented){if(f.key==="Enter"){if(l||f.nativeEvent.isComposing||f.shiftKey)return;f.preventDefault();let{form:p}=f.currentTarget;if(p?.querySelector('[data-submit-blocked="true"]')||p?.querySelector('button[type="submit"]')?.disabled)return;p?.requestSubmit()}if(f.key==="Backspace"&&f.currentTarget.value===""&&i.files.length>0){f.preventDefault();let p=i.files.at(-1);p&&i.remove(p.id)}}},[t,l,i]),d=(0,Ce.useCallback)(f=>{let p=f.clipboardData?.items;if(!p)return;let m=[];for(let x of p)if(x.kind==="file"){let S=x.getAsFile();S&&m.push(S)}m.length>0&&(f.preventDefault(),i.add(m))},[i]);return(0,ht.jsx)("textarea",{className:q("ww:field-sizing-content ww:max-h-48 ww:min-h-0 ww:w-full ww:resize-none ww:border-0 ww:bg-transparent ww:px-3 ww:py-2 ww:text-base ww:sm:text-sm ww:outline-none ww:placeholder:text-muted-foreground",a),name:"message",onCompositionEnd:()=>s(!1),onCompositionStart:()=>s(!0),onKeyDown:c,onPaste:d,placeholder:u,onChange:e,...r})},yk=({className:e,status:t,onStop:a,onClick:n,children:r,disabled:o,...i})=>{let{t:l}=Ie(),s=t==="submitted"||t==="streaming",u=s&&a!==void 0,c=(0,ht.jsx)(Nn,{className:"ww:size-4"});t==="submitted"?c=(0,ht.jsx)(ou,{className:"ww:size-4 ww:animate-spin"}):t==="streaming"&&(c=(0,ht.jsx)(iu,{className:"ww:size-4"}));let d=(0,Ce.useCallback)(f=>{if(s&&a){f.preventDefault(),a();return}n?.(f)},[s,a,n]);return(0,ht.jsx)(Bn,{"aria-label":s?l.promptInput.stop:l.promptInput.submit,className:q("ww:bg-foreground ww:text-background ww:hover:bg-foreground ww:rounded-full",e),"data-submit-blocked":o?"true":void 0,disabled:u?!1:o,onClick:d,size:"icon-sm",type:u?"button":"submit",variant:"ghost",...i,children:r??c})},xk=({className:e,children:t,...a})=>{let{t:n,locale:r}=Ie(),o=of();if(o.files.length>0)return(0,ht.jsxs)(Bn,{className:q("ww:group ww:relative",e),onClick:()=>o.clear(),size:"icon-sm",type:"button",variant:"ghost","aria-label":n.promptInput.removeAttachments,...a,children:[(0,ht.jsx)("span",{className:"ww:flex ww:size-5 ww:items-center ww:justify-center ww:rounded-full ww:bg-primary ww:text-[10px] ww:font-medium ww:text-primary-foreground ww:transition-opacity ww:group-hover:opacity-0",children:o.files.length}),(0,ht.jsx)(Ga,{className:"ww:absolute ww:size-4 ww:opacity-0 ww:transition-opacity ww:group-hover:opacity-100"})]});let l=o.maxFileSize?(o.maxPdfPages?n.promptInput.uploadFilesUpToWithPages.replace("{pages}",String(o.maxPdfPages)):n.promptInput.uploadFilesUpTo).replace("{limit}",gk(o.maxFileSize,r)):n.promptInput.uploadFiles;return(0,ht.jsx)(Bn,{"aria-label":l,className:q(e),title:l,onClick:()=>o.openFileDialog(),size:"icon-sm",type:"button",variant:"ghost",...a,children:t??(0,ht.jsx)(ul,{className:"ww:size-4"})})},vk=({className:e,...t})=>{let a=of();return a.files.length===0?null:(0,ht.jsx)("ul",{className:q("ww:flex ww:list-none ww:flex-wrap ww:gap-2 ww:p-0",e),...t,children:a.files.map(n=>(0,ht.jsx)(C3,{file:n},n.id))})};function C3({file:e}){let{t}=Ie(),a=of(),n=e.status==="failed",r=e.status==="uploading";return(0,ht.jsxs)(nw,{filename:e.filename??t.attachments.fileFallback,mediaType:e.mediaType??"",previewUrl:e.mediaType?.startsWith("image/")?e.url:void 0,subtitle:n?e.error:r?t.promptInput.uploading:void 0,tone:n?"error":"default",children:[n?(0,ht.jsx)("button",{"aria-label":t.promptInput.retryUpload,className:"ww:ml-auto ww:shrink-0 ww:text-destructive ww:text-xs ww:underline ww:underline-offset-2",onClick:()=>a.retry(e.id),type:"button",children:t.promptInput.retry}):null,(0,ht.jsx)("button",{"aria-label":t.promptInput.removeAttachment,className:q("ww:shrink-0 ww:rounded-full ww:p-1 ww:opacity-60 ww:transition-opacity hover:ww:bg-muted hover:ww:opacity-100",n?null:"ww:ml-auto"),onClick:()=>a.remove(e.id),type:"button",children:(0,ht.jsx)(Ga,{className:"ww:size-3.5"})}),r?(0,ht.jsx)("span",{"aria-hidden":!0,className:"ww:absolute ww:bottom-0 ww:left-0 ww:h-0.5 ww:bg-primary ww:transition-[width] ww:duration-200",style:{width:`${Math.round(e.progress*100)}%`}}):null]})}var bk=({enabled:e=!0})=>{let{t}=Ie(),[a,n]=(0,Ce.useState)(!1);return(0,Ce.useEffect)(()=>{if(!e)return;let r=0,o=u=>!!u.dataTransfer?.types?.includes("Files"),i=u=>{o(u)&&(r+=1,n(!0))},l=u=>{o(u)&&(r=Math.max(0,r-1),r===0&&n(!1))},s=()=>{r=0,n(!1)};return document.addEventListener("dragenter",i),document.addEventListener("dragleave",l),document.addEventListener("drop",s),()=>{document.removeEventListener("dragenter",i),document.removeEventListener("dragleave",l),document.removeEventListener("drop",s)}},[e]),e&&a?(0,ht.jsx)("div",{className:"ww:pointer-events-none ww:absolute ww:inset-0 ww:z-50 ww:flex ww:items-center ww:justify-center ww:rounded-2xl ww:border-2 ww:border-primary ww:border-dashed ww:bg-background/85",children:(0,ht.jsxs)("span",{className:"ww:flex ww:items-center ww:gap-2 ww:text-sm ww:font-medium",children:[(0,ht.jsx)(ul,{className:"ww:size-4"}),t.promptInput.dropToAttach]})}):null};var Ik=z(ae(),1);function Sk({text:e}){let{t}=Ie();return e===!1?null:(0,Ik.jsx)("span",{className:"ww:whitespace-nowrap ww:text-[10px] ww:sm:text-[11px] ww:text-muted-foreground ww:opacity-70",children:e||t.aiDisclaimer.default})}var lf=z(he(),1);var Ho=z(ae(),1),Ck=({className:e,...t})=>(0,Ho.jsx)("div",{className:q("ww:flex ww:flex-col ww:gap-1 ww:px-3 ww:py-2",e),...t}),kk=({className:e,...t})=>(0,Ho.jsx)("li",{className:q("ww:group ww:flex ww:items-center ww:gap-2 ww:rounded-md ww:px-2 ww:py-1 ww:text-sm ww:transition-colors ww:hover:bg-muted",e),...t}),Tk=({className:e,...t})=>(0,Ho.jsx)("span",{className:q("ww:inline-block ww:size-2 ww:shrink-0 ww:rounded-full ww:border ww:border-muted-foreground/50",e),...t}),Lk=({className:e,...t})=>(0,Ho.jsx)("span",{className:q("ww:line-clamp-1 ww:grow ww:break-words ww:text-muted-foreground",e),...t}),Ek=({className:e,...t})=>(0,Ho.jsx)("div",{className:q("ww:flex ww:shrink-0 ww:gap-1 ww:opacity-0 ww:transition-opacity ww:group-hover:opacity-100",e),...t}),Mk=({className:e,...t})=>(0,Ho.jsx)(Bn,{className:q("ww:size-auto ww:rounded ww:p-1 ww:text-muted-foreground ww:hover:bg-muted-foreground/10 ww:hover:text-foreground",e),size:"icon",type:"button",variant:"ghost",...t});var sn=z(ae(),1),Ak=(0,lf.memo)(({message:e,onRemove:t})=>{let{t:a}=Ie(),n=(0,lf.useCallback)(()=>t(e.id),[t,e.id]);return(0,sn.jsxs)(kk,{children:[(0,sn.jsx)(Tk,{}),(0,sn.jsx)(Lk,{children:e.text||a.chatQueue.attachmentFallback}),(0,sn.jsx)(Ek,{children:(0,sn.jsx)(Mk,{"aria-label":a.chatQueue.removeFromQueue,onClick:n,children:(0,sn.jsx)(Ga,{className:"ww:size-3"})})})]})});Ak.displayName="ChatQueueItem";function Rk({queuedMessages:e,onRemove:t,className:a}){let{t:n}=Ie();return e.length===0?null:(0,sn.jsxs)(Ck,{className:q("ww:border-t ww:border-border",a),children:[(0,sn.jsx)("div",{className:"ww:text-[11px] ww:font-medium ww:text-muted-foreground ww:px-2",children:n.chatQueue.queued(e.length)}),(0,sn.jsx)("ul",{children:e.map(r=>(0,sn.jsx)(Ak,{message:r,onRemove:t},r.id))})]})}var _a=z(he(),1);var St=z(he(),1);dp();var u2=z(he(),1);var c2=z(ae(),1),V6=({as:e="span",className:t,duration:a=2,style:n,children:r,...o})=>{let i={backgroundImage:"linear-gradient(90deg, var(--ww-color-muted-foreground) 0%, var(--ww-color-muted-foreground) 40%, var(--ww-color-foreground) 50%, var(--ww-color-muted-foreground) 60%, var(--ww-color-muted-foreground) 100%)",backgroundSize:"250% 100%",WebkitBackgroundClip:"text",backgroundClip:"text",color:"transparent",animation:`ww-shimmer ${a}s linear infinite`,...n};return(0,c2.jsx)(e,{"data-waniwani-shimmer":"",className:q("ww:inline-block",t),style:i,...o,children:r})},Tn=(0,u2.memo)(V6);Tn.displayName="Shimmer";var ua=z(ae(),1),d2=(0,St.createContext)(null);function f2(){let e=(0,St.useContext)(d2);if(!e)throw new Error("Reasoning components must be used within <Reasoning>");return e}var W6=1e3,G6=1e3,Uu=(0,St.memo)(({className:e,isStreaming:t=!1,open:a,defaultOpen:n,onOpenChange:r,duration:o,children:i,...l})=>{let s=n??t,u=n===!1,c=a!==void 0,[d,f]=(0,St.useState)(s),p=c?a:d,m=(0,St.useCallback)(M=>{c||f(M),r?.(M)},[c,r]),[x,S]=(0,St.useState)(void 0),w=o??x,y=(0,St.useRef)(t),[h,b]=(0,St.useState)(!1),T=(0,St.useRef)(null);(0,St.useEffect)(()=>{t?(y.current=!0,T.current===null&&(T.current=Date.now())):T.current!==null&&(S(Math.ceil((Date.now()-T.current)/G6)),T.current=null)},[t]),(0,St.useEffect)(()=>{t&&!p&&!u&&m(!0)},[t,p,u,m]),(0,St.useEffect)(()=>{if(y.current&&!t&&p&&!h){let M=setTimeout(()=>{m(!1),b(!0)},W6);return()=>clearTimeout(M)}},[t,p,h,m]);let C=(0,St.useMemo)(()=>({isStreaming:t,isOpen:p,setIsOpen:m,duration:w}),[t,p,m,w]);return(0,ua.jsx)(d2.Provider,{value:C,children:(0,ua.jsx)("div",{className:q("ww:mb-4 ww:flex ww:flex-col ww:gap-2",e),"data-state":p?"open":"closed",style:{animation:"ww-fade-in 0.2s ease-out"},...l,children:i})})});Uu.displayName="Reasoning";var Fu=(0,St.memo)(({className:e,children:t,getThinkingMessage:a,hideIcon:n=!1,onClick:r,...o})=>{let{t:i}=Ie(),{isStreaming:l,isOpen:s,duration:u,setIsOpen:c}=f2(),f=a??((p,m)=>p||m===0?(0,ua.jsx)(Tn,{duration:1.6,children:i.reasoning.thinking}):m===void 0?(0,ua.jsx)("span",{children:i.reasoning.thoughtBrief}):(0,ua.jsx)("span",{children:i.reasoning.thoughtForSeconds(m)}));return(0,ua.jsx)("button",{type:"button","aria-expanded":s,onClick:p=>{c(!s),r?.(p)},className:q("ww:flex ww:w-full ww:items-center ww:gap-2 ww:text-sm ww:text-muted-foreground ww:transition-colors ww:hover:text-foreground",e),...o,children:t??(0,ua.jsxs)(ua.Fragment,{children:[!n&&(0,ua.jsx)(fr,{className:"ww:size-4 ww:shrink-0"}),f(l,u)]})})});Fu.displayName="ReasoningTrigger";var zu=(0,St.memo)(({className:e,children:t,...a})=>{let{isOpen:n}=f2();return(0,ua.jsx)("div",{className:q("ww:grid ww:transition-[grid-template-rows,opacity] ww:duration-200 ww:ease-out",n?"ww:grid-rows-[1fr] ww:opacity-100":"ww:grid-rows-[0fr] ww:opacity-0"),children:(0,ua.jsx)("div",{className:"ww:min-h-0 ww:overflow-hidden",children:(0,ua.jsx)("div",{className:q("ww:text-sm ww:text-muted-foreground",e),...a,children:(0,ua.jsx)(El,{children:t})})})})});zu.displayName="ReasoningContent";var Ne=z(ae(),1),$6=500,p2=(0,_a.createContext)(null);function m2(){let e=(0,_a.useContext)(p2);if(!e)throw new Error("ChainOfThought components must be used within <ChainOfThought>");return e}function h2({className:e,isWorking:t=!1,activeStep:a,open:n,defaultOpen:r=!1,onOpenChange:o,children:i,...l}){let s=n!==void 0,[u,c]=(0,_a.useState)(r),d=s?n:u,f=(0,_a.useCallback)(S=>{s||c(S),o?.(S)},[s,o]),[p,m]=(0,_a.useState)(!t);(0,_a.useEffect)(()=>{if(t){m(!1);return}let S=setTimeout(()=>m(!0),$6);return()=>clearTimeout(S)},[t]);let x=(0,_a.useMemo)(()=>({open:d,setOpen:f,isWorking:t,settled:p,activeStep:a}),[d,f,t,p,a]);return(0,Ne.jsx)(p2.Provider,{value:x,children:(0,Ne.jsx)("div",{className:q("ww:mb-4 ww:flex ww:flex-col ww:gap-2",e),"data-state":d?"open":"closed",style:{animation:"ww-fade-in 0.2s ease-out"},...l,children:i})})}function g2({className:e,label:t,workingLabel:a,children:n,...r}){let{open:o,setOpen:i,isWorking:l,settled:s,activeStep:u}=m2();if(!s){let c=u?.icon,d=u?.label??a??t??"";return(0,Ne.jsx)("div",{className:q("ww:flex ww:min-h-5 ww:w-full ww:items-center ww:gap-1.5 ww:text-sm ww:text-muted-foreground",e),children:(0,Ne.jsxs)("span",{className:"ww:flex ww:min-w-0 ww:items-center ww:gap-1.5",style:{animation:"ww-fade-in 0.25s ease-out"},children:[c&&(0,Ne.jsx)(c,{className:q("ww:size-4 ww:shrink-0",l&&"ww:animate-pulse")}),(0,Ne.jsx)("span",{className:"ww:truncate",children:l?(0,Ne.jsx)(Tn,{duration:2.6,children:d}):d})]},d)})}return(0,Ne.jsxs)("button",{type:"button",onClick:()=>i(!o),"aria-expanded":o,className:q("ww:flex ww:min-h-5 ww:w-full ww:items-center ww:gap-1.5 ww:text-sm ww:text-muted-foreground ww:transition-colors ww:hover:text-foreground",e),style:{animation:"ww-fade-in 0.25s ease-out"},...r,children:[(0,Ne.jsx)("span",{className:"ww:truncate",children:n??t}),(0,Ne.jsx)(Qr,{className:q("ww:size-4 ww:shrink-0 ww:transition-transform ww:duration-200",o&&"ww:rotate-180")})]})}function w2({className:e,children:t,...a}){let{open:n}=m2();return(0,Ne.jsx)("div",{className:q("ww:grid ww:transition-[grid-template-rows,opacity] ww:duration-200 ww:ease-out",n?"ww:grid-rows-[1fr] ww:opacity-100":"ww:grid-rows-[0fr] ww:opacity-0"),children:(0,Ne.jsx)("div",{className:"ww:min-h-0 ww:overflow-hidden",children:(0,Ne.jsx)("div",{className:q("ww:flex ww:flex-col",e),...a,children:t})})})}function y2({icon:e,isLast:t,running:a,error:n}){return(0,Ne.jsxs)("div",{className:"ww:flex ww:flex-col ww:items-center ww:self-stretch",children:[(0,Ne.jsx)("span",{className:"ww:flex ww:h-5 ww:items-center",children:(0,Ne.jsx)(e,{className:q("ww:size-4 ww:shrink-0",n?"ww:text-destructive":a?"ww:animate-pulse ww:text-foreground":"ww:text-muted-foreground")})}),!t&&(0,Ne.jsx)("span",{className:"ww:w-px ww:flex-1 ww:bg-border"})]})}function Rx({className:e,icon:t,title:a,state:n,isLast:r=!1,children:o,...i}){let l=n==="input-available"||n==="input-streaming",s=n==="output-error",u=o!=null,[c,d]=(0,_a.useState)(!1),f=a??"",p=l?(0,Ne.jsx)(Tn,{duration:1.6,children:f}):(0,Ne.jsx)("span",{className:"ww:truncate",children:f});return(0,Ne.jsxs)("div",{className:q("ww:flex ww:gap-2",e),...i,children:[(0,Ne.jsx)(y2,{icon:t,isLast:r,running:l,error:s}),(0,Ne.jsxs)("div",{className:q("ww:min-w-0 ww:flex-1",!r&&"ww:pb-3"),children:[u?(0,Ne.jsxs)("button",{type:"button",onClick:()=>d(m=>!m),"aria-expanded":c,className:"ww:flex ww:w-full ww:items-center ww:gap-1.5 ww:text-left ww:text-sm ww:text-muted-foreground ww:transition-colors ww:hover:text-foreground",children:[p,(0,Ne.jsx)(Qr,{className:q("ww:size-3.5 ww:shrink-0 ww:transition-transform ww:duration-200",c&&"ww:rotate-180")})]}):(0,Ne.jsx)("div",{className:"ww:flex ww:items-center ww:text-sm ww:text-muted-foreground",children:p}),u&&(0,Ne.jsx)("div",{className:q("ww:grid ww:transition-[grid-template-rows,opacity] ww:duration-200 ww:ease-out",c?"ww:grid-rows-[1fr] ww:opacity-100":"ww:grid-rows-[0fr] ww:opacity-0"),children:(0,Ne.jsx)("div",{className:"ww:min-h-0 ww:overflow-hidden",children:(0,Ne.jsx)("div",{className:"ww:mt-2 ww:space-y-3 ww:rounded-lg ww:border ww:border-border ww:bg-background ww:p-3",children:o})})})]})]})}function x2({isStreaming:e=!1,isLast:t=!1,children:a}){return(0,Ne.jsxs)("div",{className:"ww:flex ww:gap-2",children:[(0,Ne.jsx)(y2,{icon:fr,isLast:t,running:e}),(0,Ne.jsx)("div",{className:q("ww:min-w-0 ww:flex-1",!t&&"ww:pb-3"),children:(0,Ne.jsxs)(Uu,{isStreaming:e,className:"ww:mb-0",children:[(0,Ne.jsx)(Fu,{hideIcon:!0}),(0,Ne.jsx)(zu,{children:a})]})})]})}var Dx={name:"cjk-noop",type:"cjk",remarkPluginsBefore:[],remarkPluginsAfter:[],remarkPlugins:[]};var v2={name:"shiki-noop",type:"code-highlighter",supportsLanguage:()=>!1,getSupportedLanguages:()=>[],getThemes:()=>["github-light","github-dark"],highlight:()=>null};var I2=z(he(),1);var vr=z(he(),1),X6=5,b2=400;function S2(e,t,a={}){let{msPerChar:n=X6}=a,[r,o]=(0,vr.useState)(t?"":e),i=(0,vr.useRef)(e),l=(0,vr.useRef)(t?0:e.length),s=(0,vr.useRef)(0),u=(0,vr.useRef)(null);return(e.length<l.current||!e.startsWith(r.slice(0,l.current)))&&(l.current=t?0:e.length),i.current=e,(0,vr.useEffect)(()=>{if(!t){u.current!==null&&(cancelAnimationFrame(u.current),u.current=null),l.current=e.length,o(e);return}if(i.current.length-l.current>b2&&(l.current=i.current.length-b2),u.current!==null)return;let d=f=>{let p=i.current;if(l.current>=p.length){u.current=null;return}s.current===0&&(s.current=f);let m=f-s.current;if(m>=n){let x=Math.min(Math.floor(m/n),p.length-l.current);l.current+=x,o(p.slice(0,l.current)),s.current=f}u.current=requestAnimationFrame(d)};return u.current=requestAnimationFrame(d),()=>{u.current!==null&&(cancelAnimationFrame(u.current),u.current=null)}},[e,t,n]),r}var qu=z(ae(),1),_x=({className:e,from:t,children:a,...n})=>(0,qu.jsx)("div",{className:q("ww-message ww:group ww:flex ww:w-full",t==="user"?"ww-message-user is-user ww:ml-auto ww:flex-col ww:items-end ww:[max-width:var(--ww-msg-max-width,80%)]":"ww-message-assistant is-assistant ww:flex-col",e),...n,children:(0,qu.jsx)("div",{className:q("ww:flex ww:min-w-0 ww:flex-col ww:gap-2","ww:w-full"),children:a})}),Ox=({children:e,className:t,...a})=>(0,qu.jsx)("div",{className:q("ww-bubble ww:flex ww:w-fit ww:min-w-0 ww:max-w-full ww:flex-col ww:gap-2 ww:overflow-hidden","ww:[font-size:var(--ww-font-size,1rem)] ww:[line-height:var(--ww-line-height,1.5)]","ww:group-[.is-user]:ml-auto ww:group-[.is-user]:bg-user-bubble ww:group-[.is-user]:[color:var(--ww-color-user-bubble-text)] ww:group-[.is-user]:[border-radius:var(--ww-msg-radius,8px)] ww:group-[.is-user]:[padding:var(--ww-msg-pad-y,12px)_var(--ww-msg-pad-x,16px)]","ww:group-[.is-assistant]:text-foreground",t),...a,children:e}),K6={cjk:Dx,code:v2},Y6={cjk:Dx},Z6={enabled:!1};function Q6({className:e,linkSafety:t,isStreaming:a,children:n,...r}){let i=S2(typeof n=="string"?n:"",!!a),l=typeof n=="string"?i:n;return(0,qu.jsx)(El,{className:q("ww:size-full ww:[&>*:first-child]:mt-0 ww:[&>*:last-child]:mb-0",e),linkSafety:t??Z6,plugins:a?Y6:K6,...r,children:l})}var gp=(0,I2.memo)(Q6,(e,t)=>e.children===t.children&&e.isStreaming===t.isStreaming);gp.displayName="MessageResponse";var Vt=z(he(),1);function Px(e){if(!(typeof e!="object"||e===null))return e}function C2(e){return Px(e?.ui)}function Nx(e){if(!e)return;let t=C2(e)?.resourceUri;if(typeof t=="string"&&t.length>0)return t;let a=e["ui/resourceUri"];if(typeof a=="string"&&a.length>0)return a;let n=e["openai/outputTemplate"];if(typeof n=="string"&&n.length>0)return n}function Hu(e){return C2(e)?.autoHeight===!0}function Bx(e){return Px(Px(e)?._meta)}var Te=z(ae(),1);function J6(e,t=80){if(e==null)return String(e);if(typeof e!="object")return String(e).slice(0,t);if(Array.isArray(e))return`Array(${e.length})`;let a=JSON.stringify(e);if(a.length<=t)return a;let n=Object.entries(e),r=[],o=t-2;for(let[i,l]of n){if(o<=8)break;let s=i.length>4?`${i.slice(0,4)}\u2026`:i,u;typeof l=="string"?u=l.length>2?`'${l.slice(0,1)}\u2026`:`'${l}'`:Array.isArray(l)?u=`Array(${l.length})`:typeof l=="object"&&l!==null?u="{\u2026}":u=String(l);let c=`${s}\u2009${u}`;r.push(c),o-=c.length+3}return`{${r.join(", ")}}`}function e9({text:e,className:t}){let{t:a}=Ie(),[n,r]=(0,Vt.useState)(!1),o=(0,Vt.useRef)(null);(0,Vt.useEffect)(()=>()=>{o.current&&clearTimeout(o.current)},[]);let i=(0,Vt.useCallback)(async l=>{l.stopPropagation();try{await navigator.clipboard.writeText(e),r(!0),o.current&&clearTimeout(o.current),o.current=setTimeout(()=>r(!1),2e3)}catch{}},[e]);return(0,Te.jsx)(Bn,{variant:"ghost",size:"sm",onClick:i,className:q("ww:h-auto ww:gap-1 ww:px-1.5 ww:py-0.5 ww:text-xs ww:text-muted-foreground ww:hover:text-foreground",t),children:n?(0,Te.jsxs)(Te.Fragment,{children:[(0,Te.jsx)(Js,{className:"ww:size-3.5"}),(0,Te.jsx)("span",{children:a.tool.copied})]}):(0,Te.jsxs)(Te.Fragment,{children:[(0,Te.jsx)(tu,{className:"ww:size-3.5"}),(0,Te.jsx)("span",{children:a.tool.copy})]})})}function k2({data:e,label:t,className:a,...n}){let[r,o]=(0,Vt.useState)(!1),i=(0,Vt.useMemo)(()=>JSON.stringify(e,null,2),[e]),l=J6(e);return(0,Te.jsxs)("div",{className:q("ww:rounded-lg ww:bg-tool-card",a),...n,children:[(0,Te.jsxs)("div",{className:"ww:flex ww:items-center ww:justify-between ww:px-3 ww:pt-2.5 ww:pb-1.5",children:[(0,Te.jsx)("span",{className:"ww:text-xs ww:font-medium ww:text-muted-foreground",children:t}),(0,Te.jsx)(e9,{text:i})]}),(0,Te.jsxs)("button",{type:"button",onClick:()=>o(s=>!s),className:"ww:flex ww:w-full ww:items-start ww:gap-2 ww:px-3 ww:pb-3 ww:text-left",children:[(0,Te.jsx)(eu,{className:q("ww:mt-0.5 ww:size-3.5 ww:shrink-0 ww:text-muted-foreground ww:transition-transform ww:duration-150",r&&"ww:rotate-90")}),r?(0,Te.jsx)("pre",{className:"ww:overflow-x-auto ww:text-xs ww:font-mono ww:text-foreground ww:whitespace-pre-wrap ww:break-all",children:(0,Te.jsx)("code",{children:i})}):(0,Te.jsx)("span",{className:"ww:truncate ww:text-xs ww:font-mono ww:text-foreground/80",children:l})]})]})}var Ux=(0,Vt.createContext)({open:!1,toggle:()=>{}});function T2({className:e,defaultOpen:t=!1,children:a,...n}){let[r,o]=(0,Vt.useState)(t);return(0,Te.jsx)(Ux.Provider,{value:{open:r,toggle:()=>o(i=>!i)},children:(0,Te.jsx)("div",{className:q("ww:mb-4 ww:w-full",e),"data-state":r?"open":"closed",style:{animation:"ww-fade-in 0.2s ease-out"},...n,children:a})})}function L2({className:e,title:t,state:a,...n}){let{open:r,toggle:o}=(0,Vt.useContext)(Ux),i=a==="input-available"||a==="input-streaming",l=t??"";return(0,Te.jsxs)("button",{type:"button",onClick:o,className:q("ww:flex ww:w-full ww:items-center ww:gap-2 ww:text-sm ww:text-muted-foreground ww:transition-colors ww:hover:text-foreground",e),"aria-expanded":r,...n,children:[(0,Te.jsx)(Fo,{className:"ww:size-4 ww:shrink-0"}),(0,Te.jsx)("span",{className:"ww:truncate",children:i?(0,Te.jsx)(Tn,{duration:1.6,children:l}):l}),(0,Te.jsx)(Qr,{className:q("ww:size-4 ww:shrink-0 ww:transition-transform ww:duration-200",r&&"ww:rotate-180")})]})}function E2({className:e,title:t,state:a,...n}){let r=a==="input-available"||a==="input-streaming",o=t??"";return(0,Te.jsx)("div",{className:q("ww:mb-4 ww:flex ww:items-center ww:gap-2 ww:text-sm ww:text-muted-foreground",e),style:{animation:"ww-fade-in 0.2s ease-out"},...n,children:(0,Te.jsx)("span",{className:"ww:truncate",children:r?(0,Te.jsx)(Tn,{duration:1.6,children:o}):o})})}function M2({className:e,children:t,...a}){let{open:n}=(0,Vt.useContext)(Ux);return(0,Te.jsx)("div",{className:q("ww:grid ww:transition-[grid-template-rows,opacity] ww:duration-200 ww:ease-out",n?"ww:grid-rows-[1fr] ww:opacity-100":"ww:grid-rows-[0fr] ww:opacity-0"),children:(0,Te.jsx)("div",{className:"ww:min-h-0 ww:overflow-hidden",children:(0,Te.jsx)("div",{className:q("ww:mt-2 ww:space-y-3 ww:rounded-lg ww:border ww:border-border ww:bg-background ww:p-3",e),...a,children:t})})})}function Fx({className:e,input:t,debug:a,...n}){let{t:r}=Ie(),o=(0,Vt.useMemo)(()=>{if(!a&&typeof t=="object"&&t!==null&&!Array.isArray(t)){let{_meta:i,...l}=t;return l}return t},[t,a]);return(0,Te.jsx)(k2,{data:o,label:r.tool.request,className:e,...n})}function ju(e,t,a){if(e){let n=Nx(a?.[e]?._meta);if(n)return n}return Nx(Bx(t))}function A2(e,t,a){return e&&Hu(a?.[e]?._meta)?!0:Hu(Bx(t))}function zx({className:e,output:t,errorText:a,debug:n,...r}){let{t:o}=Ie(),i=(0,Vt.useMemo)(()=>{if(!n&&typeof t=="object"&&t!==null&&!Array.isArray(t)){let{_meta:l,...s}=t;return s}return t},[t,n]);return t||a?a?(0,Te.jsxs)("div",{className:q("ww:space-y-2",e),...r,children:[(0,Te.jsx)("h4",{className:"ww:text-xs ww:font-medium ww:uppercase ww:tracking-wide ww:text-muted-foreground",children:o.tool.error}),(0,Te.jsx)("div",{className:"ww:rounded-lg ww:bg-destructive/10 ww:p-3 ww:text-xs ww:text-destructive",children:a})]}):(0,Te.jsx)(k2,{data:i,label:o.tool.response,className:e,...r}):null}var Vu=z(ae(),1);function R2(e){return e.type==="text"||e.type==="reasoning"||e.type==="file"||"toolCallId"in e}function D2(e){return e.parts.some(R2)}function _2(e,t,a){if(t!=="submitted"&&t!=="streaming")return!1;let n=e[e.length-1];return!n||n.role!=="assistant"?!0:!n.parts.some(o=>!(!R2(o)||a?.ignoreToolParts&&"toolCallId"in o||a?.ignoreReasoningParts&&o.type==="reasoning"))}function O2({className:e,...t}){let{t:a}=Ie();return(0,Vu.jsxs)("div",{"aria-live":"polite",className:q("ww:mb-4 ww:flex ww:w-full ww:items-center ww:gap-2 ww:text-sm ww:text-muted-foreground",e),style:{animation:"ww-fade-in 0.2s ease-out"},...t,children:[(0,Vu.jsx)(lu,{className:"ww:size-4 ww:shrink-0"}),(0,Vu.jsx)(Tn,{duration:1.6,children:a.workingIndicator.default})]})}var Qe=z(he(),1);function li(e){if(!e)return!1;let t=Array.isArray(e.content)&&e.content.length>0,a=typeof e.structuredContent=="object"&&e.structuredContent!==null&&Object.keys(e.structuredContent).length>0;return t||a}function P2(e,t){return!li(e)&&!li(t)?null:li(e)?li(t)?{...e.content||t.content?{content:[...e.content??[],...t.content??[]]}:{},...e.structuredContent||t.structuredContent?{structuredContent:{...e.structuredContent??{},...t.structuredContent??{}}}:{}}:{...e.content?{content:[...e.content]}:{},...e.structuredContent?{structuredContent:{...e.structuredContent}}:{}}:{...t?.content?{content:[...t.content]}:{},...t?.structuredContent?{structuredContent:{...t.structuredContent}}:{}}}var br=z(he(),1);var N2=(0,br.createContext)(()=>{});function B2(){return(0,br.useContext)(N2)}var U2=N2.Provider;function t9(e){let t=window.requestIdleCallback;typeof t=="function"?t(e):setTimeout(e,500)}function Ml(e){let t=(0,br.useRef)(e);t.current=e;let a=(0,br.useRef)(!1);(0,br.useEffect)(()=>{if(!e.painted||a.current)return;a.current=!0;let n=requestAnimationFrame(()=>{let r=t.current;Uo(r.paintMark),t9(()=>RC(r))});return()=>cancelAnimationFrame(n)},[e.painted])}var F2=z(ae(),1),a9="/api/mcp/resource",n9=500,r9=0,o9=16,i9="2026-01-26",l9=300,s9=3e3,u9=3,c9=2e3;function d9(e){if(typeof e!="string")return;let t=e.trim();return t.length>0?t:void 0}function f9(e,t,a){return ju(e,t,a)?!1:t._meta?.["waniwani/autoInjectResultText"]!==!1}function wp({resourceUri:e,toolInput:t,toolResult:a,resourceEndpoint:n=a9,chatSessionId:r,isDark:o=!1,className:i,autoHeight:l=!1,onOpenLink:s,onFollowUp:u,onCallTool:c,onDisplayModeChange:d,isFullscreen:f=!1,toolDefinitions:p}){let m=(0,Qe.useRef)(null),x=(0,Qe.useRef)(t),S=(0,Qe.useRef)(a),w=(0,Qe.useRef)({width:0,height:0}),y=(0,Qe.useRef)(null),h=(0,Qe.useRef)(!1),b=(0,Qe.useRef)(0),T=(0,Qe.useRef)("inline"),[C,M]=(0,Qe.useState)(r9),[D,P]=(0,Qe.useState)(void 0),L=(0,Qe.useRef)(s),$=(0,Qe.useRef)(u),H=(0,Qe.useRef)(c),F=(0,Qe.useRef)(d),W=(0,Qe.useRef)(r),V=(0,Qe.useRef)(p);x.current=t,S.current=a,L.current=s,$.current=u,H.current=c,F.current=d,W.current=r,V.current=p;let N=(0,Qe.useCallback)(v=>l?Math.max(v+o9,0):Math.min(Math.max(v,50),n9),[l]),R=(0,Qe.useMemo)(()=>{let v=n.includes("?")?"&":"?";return`${n}${v}uri=${encodeURIComponent(e)}`},[n,e]),G=B2(),ue=(0,Qe.useRef)(null),I=(0,Qe.useRef)(void 0);(0,Qe.useEffect)(()=>{let v=_C(e,G);return ue.current=v,()=>{clearTimeout(I.current),v.has("initialized")||v.report("timeout",b.current),ue.current=null}},[e,G]);let We=(0,Qe.useRef)(o);We.current=o;let Je=(0,Qe.useRef)(f);return(0,Qe.useEffect)(()=>{Je.current=f,w.current.height=-1,y.current&&(y.current.cancel(),y.current=null)},[f]),(0,Qe.useEffect)(()=>{if(!h.current)return;let v=m.current;v?.contentWindow&&v.contentWindow.postMessage({jsonrpc:"2.0",method:"ui/notifications/host-context-changed",params:{theme:o?"dark":"light"}},"*")},[o]),(0,Qe.useEffect)(()=>{let v=m.current;if(!v)return;let K=!1,ee=!1,we=null,Ge=null,me=setTimeout(()=>{if(K||ee||b.current>=u9)return;b.current+=1;let de=new URL(v.src);de.searchParams.set("_retry",String(b.current)),v.src=de.toString()},s9),ye=de=>{v.contentWindow?.postMessage(de,"*")},le=de=>{if(K||de.source!==v.contentWindow)return;let Q=de.data;if(!Q||typeof Q!="object"||Q.jsonrpc!=="2.0")return;let Be=Q.method,qe=Q.id;if(Be==="ui/initialize"&&qe!=null){ee=!0,ue.current?.mark("initialize"),clearTimeout(me),ye({jsonrpc:"2.0",id:qe,result:{protocolVersion:Q.params?.protocolVersion??i9,hostInfo:{name:"Waniwani Chat",version:"1.0.0"},hostCapabilities:{openLinks:{},message:{text:{}},tools:{},updateModelContext:{text:{},structuredContent:{}}},hostContext:{theme:We.current?"dark":"light",displayMode:T.current}}});return}if(Be==="ui/notifications/initialized"){h.current=!0,ue.current?.mark("initialized"),I.current=setTimeout(()=>ue.current?.report("ok",b.current),c9);let _e=x.current,ke=S.current,xe=ke._meta&&typeof ke._meta=="object"?ke._meta:null,Y=d9(W.current),Oe=xe&&typeof xe.waniwani=="object"&&xe.waniwani!==null?xe.waniwani:null,rt=Oe||Y?{...Oe??{},...Y?{sessionId:Y}:{}}:void 0,ba=xe||rt?{...xe??{},...rt?{waniwani:rt}:{}}:void 0;ye({jsonrpc:"2.0",method:"ui/notifications/tool-input",params:{arguments:_e}});let Sa=ke.content??[{type:"text",text:JSON.stringify(ke)}];ye({jsonrpc:"2.0",method:"ui/notifications/tool-result",params:{content:Sa,structuredContent:ke.structuredContent,_meta:ba,meta:ba}});return}if(Be==="ui/notifications/size-changed"){clearTimeout(I.current),ue.current?.mark("firstSize"),ue.current?.report("ok",b.current);let _e=Q.params,ke=typeof _e?.height=="number"?_e.height:void 0,xe=typeof _e?.width=="number"?_e.width:void 0,Y=w.current,Oe=ke!==void 0&&ke!==Y.height,rt=xe!==void 0&&xe!==Y.width;if(!Oe&&!rt)return;if(Oe&&ke!==void 0){if(Y.height=ke,Je.current)return;let ba=N(ke),Sa=v.getBoundingClientRect().height;if(y.current&&(y.current.cancel(),y.current=null),M(ba),v.animate&&Math.abs(Sa-ba)>2){let ra=v.animate([{height:`${Sa}px`},{height:`${ba}px`}],{duration:l9,easing:"ease-out",fill:"forwards"});y.current=ra,ra.onfinish=()=>{y.current===ra&&(ra.cancel(),y.current=null)}}}rt&&l&&xe!==void 0&&(Y.width=xe,P(xe));return}if(Be==="ui/open-link"&&qe!=null){let _e=Q.params?.url;typeof _e=="string"&&(L.current?L.current(_e):window.open(_e,"_blank","noopener,noreferrer")),ye({jsonrpc:"2.0",id:qe,result:{}});return}if(Be==="ui/message"&&qe!=null){if($.current&&Q.params){let _e=Q.params,ke=we;if(we=null,Ge){clearTimeout(Ge.timer);let xe=Ge.text;Ge=null;let Y=(_e.content??[]).map(Oe=>Oe.text??"").join("").trim();_e={..._e,content:[{type:"text",text:`${Y}
|
|
121
|
+
`||e[t]==="\r");)t-=1;return t>=1&&e[t]==="$"&&e[t-1]==="$"},Ix=e=>{let t=0;for(let a=0;a<e.length-1;a+=1)e[a]==="$"&&e[a+1]==="$"&&(t+=1,a+=1);return t},i2=e=>{let t=_6.test(e),a=O6.test(e);if(t||a)return[e];let n=Xa.lex(e,{gfm:!0}),r=[],o=[];for(let i of n){let l=i.raw,s=r.length;if(o.length>0){if(r[s-1]+=l,i.type==="html"){let u=l.match(P6);if(u){let c=u[1];o.at(-1)===c&&o.pop()}}continue}if(i.type==="html"&&i.block){let u=l.match(N6);if(u){let c=u[1];l.includes(`</${c}>`)||o.push(c)}}if(l.trim()==="$$"&&s>0){let u=r[s-1],c=Sx(u),d=Ix(u);if(c&&d%2===1){r[s-1]=u+l;continue}}if(s>0&&B6(l)){let u=r[s-1],c=Sx(u),d=Ix(u),f=Ix(l);if(c&&d%2===1&&!Sx(l)&&f===1){r[s-1]=u+l;continue}}r.push(l)}return r},l2={raw:zk,sanitize:[gf,{}],harden:[Uk,{allowedImagePrefixes:["*"],allowedLinkPrefixes:["*"],allowedProtocols:["*"],defaultOrigin:void 0,allowDataImages:!0}]},s2={gfm:[qf,{}]},U6=Object.values(l2),F6=Object.values(s2),z6={block:" \u258B",circle:" \u25CF"},q6={shikiTheme:["github-light","github-dark"],controls:!0,isAnimating:!1,mode:"streaming",mermaid:void 0,linkSafety:{enabled:!0}},ya=(0,_.createContext)(q6),Ax=(0,_.memo)(({content:e,shouldParseIncompleteMarkdown:t,index:a,...n})=>(0,E.jsx)(o2,{...n,children:e}),(e,t)=>{if(e.content!==t.content||e.index!==t.index)return!1;if(e.components!==t.components){let a=Object.keys(e.components||{}),n=Object.keys(t.components||{});if(a.length!==n.length||a.some(r=>{var o,i;return((o=e.components)==null?void 0:o[r])!==((i=t.components)==null?void 0:i[r])}))return!1}return!(e.rehypePlugins!==t.rehypePlugins||e.remarkPlugins!==t.remarkPlugins)});Ax.displayName="Block";H6=["github-light","github-dark"],El=(0,_.memo)(({children:e,mode:t="streaming",parseIncompleteMarkdown:a=!0,components:n,rehypePlugins:r=U6,remarkPlugins:o=F6,className:i,shikiTheme:l=H6,mermaid:s,controls:u=!0,isAnimating:c=!1,BlockComponent:d=Ax,parseMarkdownIntoBlocksFn:f=i2,caret:p,plugins:m,remend:x,linkSafety:S={enabled:!0},...w})=>{let y=(0,_.useId)(),[h,b]=(0,_.useTransition)(),T=(0,_.useMemo)(()=>typeof e!="string"?"":t==="streaming"&&a?QL(e,x):e,[e,t,a,x]),C=(0,_.useMemo)(()=>f(T),[T,f]),[M,D]=(0,_.useState)(C);(0,_.useEffect)(()=>{t==="streaming"?b(()=>{D(C)}):D(C)},[C,t]);let P=t==="streaming"?M:C,L=(0,_.useMemo)(()=>P.map((N,R)=>`${y}-${R}`),[P.length,y]),$=(0,_.useMemo)(()=>{var N,R;return{shikiTheme:(R=(N=m?.code)==null?void 0:N.getThemes())!=null?R:l,controls:u,isAnimating:c,mode:t,mermaid:s,linkSafety:S}},[l,u,c,t,s,S,m?.code]),H=(0,_.useMemo)(()=>({...E6,...n}),[n]),F=(0,_.useMemo)(()=>{let N=[];return m!=null&&m.cjk&&(N=[...N,...m.cjk.remarkPluginsBefore]),N=[...N,...o],m!=null&&m.cjk&&(N=[...N,...m.cjk.remarkPluginsAfter]),m!=null&&m.math&&(N=[...N,m.math.remarkPlugin]),N},[o,m?.math,m?.cjk]),W=(0,_.useMemo)(()=>m!=null&&m.math?[...r,m.math.rehypePlugin]:r,[r,m?.math]),V=(0,_.useMemo)(()=>p&&c?{"--streamdown-caret":`"${z6[p]}"`}:void 0,[p,c]);return t==="static"?(0,E.jsx)(Cx.Provider,{value:m??null,children:(0,E.jsx)(ya.Provider,{value:$,children:(0,E.jsx)("div",{className:ce("space-y-4 whitespace-normal *:first:mt-0 *:last:mb-0",i),children:(0,E.jsx)(o2,{components:H,rehypePlugins:W,remarkPlugins:F,...w,children:e})})})}):(0,E.jsx)(Cx.Provider,{value:m??null,children:(0,E.jsx)(ya.Provider,{value:$,children:(0,E.jsxs)("div",{className:ce("space-y-4 whitespace-normal *:first:mt-0 *:last:mb-0",p?"*:last:after:inline *:last:after:align-baseline *:last:after:content-(--streamdown-caret)":null,i),style:V,children:[P.length===0&&p&&c&&(0,E.jsx)("span",{}),P.map((N,R)=>(0,E.jsx)(d,{components:H,content:N,index:R,rehypePlugins:W,remarkPlugins:F,shouldParseIncompleteMarkdown:a,...w},L[R]))]})})})},(e,t)=>e.children===t.children&&e.shikiTheme===t.shikiTheme&&e.isAnimating===t.isAnimating&&e.mode===t.mode&&e.plugins===t.plugins&&e.className===t.className&&e.linkSafety===t.linkSafety);El.displayName="Streamdown";j6=({children:e,className:t,minZoom:a=.5,maxZoom:n=3,zoomStep:r=.1,showControls:o=!0,initialZoom:i=1,fullscreen:l=!1})=>{let s=(0,_.useRef)(null),u=(0,_.useRef)(null),[c,d]=(0,_.useState)(i),[f,p]=(0,_.useState)({x:0,y:0}),[m,x]=(0,_.useState)(!1),[S,w]=(0,_.useState)({x:0,y:0}),[y,h]=(0,_.useState)({x:0,y:0}),b=(0,_.useCallback)(H=>{d(F=>Math.max(a,Math.min(n,F+H)))},[a,n]),T=(0,_.useCallback)(()=>{b(r)},[b,r]),C=(0,_.useCallback)(()=>{b(-r)},[b,r]),M=(0,_.useCallback)(()=>{d(i),p({x:0,y:0})},[i]),D=(0,_.useCallback)(H=>{H.preventDefault();let F=H.deltaY>0?-r:r;b(F)},[b,r]),P=(0,_.useCallback)(H=>{if(H.button!==0||H.isPrimary===!1)return;x(!0),w({x:H.clientX,y:H.clientY}),h(f);let F=H.currentTarget;F instanceof HTMLElement&&F.setPointerCapture(H.pointerId)},[f]),L=(0,_.useCallback)(H=>{if(!m)return;H.preventDefault();let F=H.clientX-S.x,W=H.clientY-S.y;p({x:y.x+F,y:y.y+W})},[m,S,y]),$=(0,_.useCallback)(H=>{x(!1);let F=H.currentTarget;F instanceof HTMLElement&&F.releasePointerCapture(H.pointerId)},[]);return(0,_.useEffect)(()=>{let H=s.current;if(H)return H.addEventListener("wheel",D,{passive:!1}),()=>{H.removeEventListener("wheel",D)}},[D]),(0,_.useEffect)(()=>{let H=u.current;if(H&&m)return document.body.style.userSelect="none",H.addEventListener("pointermove",L,{passive:!1}),H.addEventListener("pointerup",$),H.addEventListener("pointercancel",$),()=>{document.body.style.userSelect="",H.removeEventListener("pointermove",L),H.removeEventListener("pointerup",$),H.removeEventListener("pointercancel",$)}},[m,L,$]),(0,E.jsxs)("div",{className:ce("relative flex flex-col",l?"h-full w-full":"min-h-28 w-full",t),ref:s,style:{cursor:m?"grabbing":"grab"},children:[o?(0,E.jsxs)("div",{className:ce("absolute z-10 flex flex-col gap-1 rounded-md border border-border bg-background/90 p-1 shadow-sm backdrop-blur-sm",l?"bottom-4 left-4":"bottom-2 left-2"),children:[(0,E.jsx)("button",{className:"flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",disabled:c>=n,onClick:T,title:"Zoom in",type:"button",children:(0,E.jsx)(o6,{size:16})}),(0,E.jsx)("button",{className:"flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",disabled:c<=a,onClick:C,title:"Zoom out",type:"button",children:(0,E.jsx)(i6,{size:16})}),(0,E.jsx)("button",{className:"flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",onClick:M,title:"Reset zoom and pan",type:"button",children:(0,E.jsx)(r6,{size:16})})]}):null,(0,E.jsx)("div",{className:ce("flex-1 origin-center transition-transform duration-150 ease-out",l?"flex h-full w-full items-center justify-center":"flex w-full items-center justify-center"),onPointerDown:P,ref:u,role:"application",style:{transform:`translate(${f.x}px, ${f.y}px) scale(${c})`,transformOrigin:"center center",touchAction:"none",willChange:"transform"},children:e})]})},vx=({chart:e,className:t,config:a,fullscreen:n=!1,showControls:r=!0})=>{let[o,i]=(0,_.useState)(null),[l,s]=(0,_.useState)(!1),[u,c]=(0,_.useState)(""),[d,f]=(0,_.useState)(""),[p,m]=(0,_.useState)(0),{mermaid:x}=(0,_.useContext)(ya),S=Ex(),w=x?.errorComponent,{shouldRender:y,containerRef:h}=t6({immediate:n});if((0,_.useEffect)(()=>{if(y){if(!S){i("Mermaid plugin not available. Please add the mermaid plugin to enable diagram rendering.");return}(async()=>{try{i(null),s(!0);let T=S.getMermaid(a),C=e.split("").reduce((P,L)=>(P<<5)-P+L.charCodeAt(0)|0,0),M=`mermaid-${Math.abs(C)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:D}=await T.render(M,e);c(D),f(D)}catch(T){if(!(d||u)){let C=T instanceof Error?T.message:"Failed to render Mermaid chart";i(C)}}finally{s(!1)}})()}},[e,a,p,y,S]),!(y||u||d))return(0,E.jsx)("div",{className:ce("my-4 min-h-[200px]",t),ref:h});if(l&&!u&&!d)return(0,E.jsx)("div",{className:ce("my-4 flex justify-center p-4",t),ref:h,children:(0,E.jsxs)("div",{className:"flex items-center space-x-2 text-muted-foreground",children:[(0,E.jsx)("div",{className:"h-4 w-4 animate-spin rounded-full border-current border-b-2"}),(0,E.jsx)("span",{className:"text-sm",children:"Loading diagram..."})]})});if(o&&!u&&!d)return w?(0,E.jsx)("div",{ref:h,children:(0,E.jsx)(w,{chart:e,error:o,retry:()=>m(C=>C+1)})}):(0,E.jsxs)("div",{className:ce("rounded-lg border border-red-200 bg-red-50 p-4",t),ref:h,children:[(0,E.jsxs)("p",{className:"font-mono text-red-700 text-sm",children:["Mermaid Error: ",o]}),(0,E.jsxs)("details",{className:"mt-2",children:[(0,E.jsx)("summary",{className:"cursor-pointer text-red-600 text-xs",children:"Show Code"}),(0,E.jsx)("pre",{className:"mt-2 overflow-x-auto rounded bg-red-100 p-2 text-red-800 text-xs",children:e})]})]});let b=u||d;return(0,E.jsx)("div",{className:ce("size-full",t),"data-streamdown":"mermaid",ref:h,children:(0,E.jsx)(j6,{className:ce(n?"size-full overflow-hidden":"my-4 overflow-hidden",t),fullscreen:n,maxZoom:3,minZoom:.5,showControls:r,zoomStep:.1,children:(0,E.jsx)("div",{"aria-label":"Mermaid chart",className:ce("flex justify-center",n?"size-full items-center":null),dangerouslySetInnerHTML:{__html:b},role:"img"})})})}});var D_=oa((kse,R_)=>{"use strict";function LV(e,t){if(typeof e!="function")throw new TypeError(`Expected the first argument to be a \`function\`, got \`${typeof e}\`.`);let a,n=0;return function(...o){clearTimeout(a);let i=Date.now(),l=i-n,s=t-l;s<=0?(n=i,e.apply(this,o)):a=setTimeout(()=>{n=Date.now(),e.apply(this,o)},s)}}R_.exports=LV});var Cv=typeof performance>"u"?0:performance.now(),kv=typeof window<"u"&&!!window.WaniWani?.chat;var fi=z(he(),1),$p=z(Ng(),1);var Bg="waniwani/suggestions";function il(e,t){for(let a of t){let n=e[a];if(typeof n=="string"&&n.length>0)return n}}var UB=["waniwani/sessionId","openai/sessionId","openai/session","sessionId","conversationId","mcp-session-id"],FB=["waniwani/requestId","openai/requestId","requestId","mcp/requestId"],zB=["waniwani/traceId","openai/traceId","traceId","mcp/traceId","openai/requestId","requestId"],qB=["waniwani/userId","openai/userId","externalUserId","userId","actorId"],HB=["waniwani/visitorId","visitorId"],jB=["correlationId","openai/requestId"];function mC(e){return e?il(e,UB):void 0}function hC(e){return e?il(e,FB):void 0}function gC(e){return e?il(e,zB):void 0}function wC(e){return e?il(e,qB):void 0}function yC(e){return e?il(e,HB):void 0}function xC(e){return e?il(e,jB):void 0}var VB=[{key:"openai/sessionId",source:"chatgpt"},{key:"openai/session",source:"chatgpt"}],WB=[{needle:"claude",source:"claude"},{needle:"chatgpt",source:"chatgpt"},{needle:"openai",source:"chatgpt"},{needle:"gemini",source:"gemini"}];function vC(e,t){if(e){let n=e["waniwani/source"];if(typeof n=="string"&&n.length>0)return n;for(let{key:r,source:o}of VB){let i=e[r];if(typeof i=="string"&&i.length>0)return o}}let a=t?.name;if(typeof a=="string"&&a.length>0){let n=a.toLowerCase();for(let{needle:r,source:o}of WB)if(n.includes(r))return o}}var GB="@waniwani/sdk";function bC(e,t={}){let a=t.now??(()=>new Date),n=t.generateId??$B,r=YB(e),o=Vd(e.meta),i=Vd(e.metadata),l=ZB(e,o),s=bn(e.eventId)??n(),u=QB(e.timestamp,a),c=bn(e.source)??vC(o)??t.source??GB,d=Ug(e)?{...e}:void 0,f={...i};return Object.keys(o).length>0&&(f.meta=o),d&&(f.rawLegacy=d),{id:s,type:"mcp.event",name:r,source:c,timestamp:u,correlation:l,properties:XB(e,r),metadata:f,rawLegacy:d}}function $B(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`evt_${crypto.randomUUID()}`:`evt_${Math.random().toString(36).slice(2,10)}_${Date.now().toString(36)}`}function XB(e,t){if(!Ug(e))return Vd(e.properties);let a=KB(e,t),n=Vd(e.properties);return{...a,...n}}function KB(e,t){switch(t){case"tool.called":{let a={};return bn(e.toolName)&&(a.name=e.toolName),bn(e.toolType)&&(a.type=e.toolType),a}case"link.clicked":{let a={};return bn(e.linkUrl)&&(a.url=e.linkUrl),a}default:return{}}}function YB(e){return Ug(e)?e.eventType:e.event}function ZB(e,t){let a=bn(e.requestId)??hC(t),n=bn(e.sessionId)??mC(t),r=bn(e.traceId)??gC(t),o=bn(e.externalUserId)??wC(t),i=bn(e.visitorId)??yC(t),l=bn(e.correlationId)??xC(t)??a,s={};return n&&(s.sessionId=n),r&&(s.traceId=r),a&&(s.requestId=a),l&&(s.correlationId=l),o&&(s.externalUserId=o),i&&(s.visitorId=i),s}function QB(e,t){if(e instanceof Date)return e.toISOString();if(typeof e=="string"){let a=new Date(e);if(!Number.isNaN(a.getTime()))return a.toISOString()}return t().toISOString()}function Vd(e){return!e||typeof e!="object"||Array.isArray(e)?{}:e}function bn(e){if(typeof e=="string"&&e.trim().length!==0)return e}function Ug(e){return"eventType"in e}function SC(e){return{priceShown:({amount:t,currency:a,itemId:n,label:r,...o})=>e({event:"price_shown",properties:{amount:t,currency:a,itemId:n,label:r},...o}),pricesCompared:({options:t,...a})=>e({event:"prices_compared",properties:{options:t},...a}),optionSelected:({id:t,amount:a,currency:n,...r})=>e({event:"option_selected",properties:{id:t,amount:a,currency:n},...r}),leadQualified:t=>{let{externalId:a,email:n,name:r,...o}=t??{};return e({event:"lead_qualified",properties:{externalId:a,email:n,name:r},...o})},converted:({amount:t,currency:a,occurredAt:n,...r})=>e({event:"converted",properties:{amount:t,currency:a,occurredAt:n},...r})}}var JB="/api/mcp/events/v2/batch";var IC="@waniwani/sdk";var eU=new Set([401,403]),tU=new Set([408,425,429,500,502,503,504]),aU=(e,t)=>globalThis.fetch(e,t);function CC(e){return new Fg(e)}var Fg=class{constructor(t){re(this,"endpointUrl");re(this,"flushIntervalMs");re(this,"maxBatchSize");re(this,"maxBufferSize");re(this,"maxRetries");re(this,"retryBaseDelayMs");re(this,"retryMaxDelayMs");re(this,"shutdownTimeoutMs");re(this,"sdkVersion");re(this,"fetchFn");re(this,"logger");re(this,"now");re(this,"sleep");re(this,"apiKey");re(this,"buffer",[]);re(this,"flushTimer");re(this,"flushScheduled",!1);re(this,"flushScheduledTimer");re(this,"flushInFlight");re(this,"inFlightCount",0);re(this,"isStopped",!1);re(this,"isShuttingDown",!1);this.endpointUrl=oU(t.apiUrl,t.endpointPath??JB),this.flushIntervalMs=t.flushIntervalMs??1e3,this.maxBatchSize=t.maxBatchSize??20,this.maxBufferSize=t.maxBufferSize??1e3,this.maxRetries=t.maxRetries??3,this.retryBaseDelayMs=t.retryBaseDelayMs??200,this.retryMaxDelayMs=t.retryMaxDelayMs??2e3,this.shutdownTimeoutMs=t.shutdownTimeoutMs??2e3,this.fetchFn=t.fetchFn??aU,this.logger=t.logger??console,this.now=t.now??(()=>new Date),this.sleep=t.sleep??(a=>new Promise(n=>setTimeout(n,a))),this.apiKey=t.apiKey,this.sdkVersion=t.sdkVersion,this.flushIntervalMs>0&&(this.flushTimer=setInterval(()=>{this.flush()},this.flushIntervalMs)),this.registerBrowserTeardown()}enqueue(t){if(this.isStopped||this.isShuttingDown){this.logger.warn("[Waniwani] Tracking transport is stopped, dropping event %s",t.id);return}if(this.buffer.length>=this.maxBufferSize){let a=this.buffer.length-this.maxBufferSize+1;this.buffer.splice(0,a),this.logger.warn("[Waniwani] Tracking buffer overflow, dropped %d oldest event(s)",a)}if(this.buffer.push(t),this.buffer.length>=this.maxBatchSize){this.flush();return}this.scheduleMicroFlush()}pendingEvents(){return this.buffer.length+this.inFlightCount}async flush(){return this.flushInFlight?this.flushInFlight:(this.flushInFlight=this.flushLoop().finally(()=>{this.flushInFlight=void 0}),this.flushInFlight)}async shutdown(t){this.isShuttingDown=!0,this.flushTimer&&(clearInterval(this.flushTimer),this.flushTimer=void 0),this.flushScheduledTimer&&(clearTimeout(this.flushScheduledTimer),this.flushScheduledTimer=void 0,this.flushScheduled=!1);let a=t?.timeoutMs??this.shutdownTimeoutMs,n=this.flush();if(!Number.isFinite(a)||a<=0)return await n,this.isStopped=!0,{timedOut:!1,pendingEvents:this.pendingEvents()};let r=Symbol("shutdown-timeout");return await Promise.race([n.then(()=>"flushed"),this.sleep(a).then(()=>r)])===r?(this.isStopped=!0,{timedOut:!0,pendingEvents:this.pendingEvents()}):(this.isStopped=!0,{timedOut:!1,pendingEvents:this.pendingEvents()})}registerBrowserTeardown(){if(typeof document>"u"||typeof window>"u")return;let t=()=>{document.visibilityState==="hidden"&&this.keepaliveFlush()};document.addEventListener("visibilitychange",t),window.addEventListener("pagehide",()=>this.keepaliveFlush())}keepaliveFlush(){if(this.isStopped||this.buffer.length===0)return;let t=this.buffer.splice(0,this.buffer.length);this.sendKeepaliveChunk(t)}sendKeepaliveChunk(t){let a=JSON.stringify(this.makeBatchRequest(t));if(a.length>6e4&&t.length>1){let n=Math.ceil(t.length/2);this.sendKeepaliveChunk(t.slice(0,n)),this.sendKeepaliveChunk(t.slice(n));return}try{this.fetchFn(this.endpointUrl,{method:"POST",headers:this.requestHeaders(),body:a,keepalive:!0}).catch(()=>{})}catch{}}requestHeaders(){let t={"Content-Type":"application/json","X-WaniWani-SDK":IC};return this.apiKey&&(t.Authorization=`Bearer ${this.apiKey}`),t}scheduleMicroFlush(){this.flushScheduled||(this.flushScheduled=!0,this.flushScheduledTimer=setTimeout(()=>{this.flushScheduledTimer=void 0,this.flushScheduled=!1,this.flush()},0))}async flushLoop(){for(;this.buffer.length>0&&!this.isStopped;){let t=this.buffer.splice(0,this.maxBatchSize);await this.sendBatchWithRetry(t)}}async sendBatchWithRetry(t){let a=0,n=t;for(;n.length>0&&!this.isStopped;){this.inFlightCount=n.length;let r=await this.sendBatchOnce(n);switch(this.inFlightCount=0,r.kind){case"success":return;case"auth":this.stopTransportForAuthFailure(r.status,n.length);return;case"permanent":this.logger.error("[Waniwani] Dropping %d event(s) after permanent failure: %s",n.length,r.reason);return;case"retryable":if(a>=this.maxRetries){this.logger.error("[Waniwani] Dropping %d event(s) after retry exhaustion: %s",n.length,r.reason);return}await this.sleep(this.backoffDelayMs(a)),a+=1;continue;case"partial":if(r.permanent.length>0&&this.logger.error("[Waniwani] Dropping %d event(s) rejected as permanent",r.permanent.length),r.retryable.length===0)return;if(a>=this.maxRetries){this.logger.error("[Waniwani] Dropping %d retryable event(s) after retry exhaustion",r.retryable.length);return}n=r.retryable,await this.sleep(this.backoffDelayMs(a)),a+=1;continue}}}async sendBatchOnce(t){let a;try{a=await this.fetchFn(this.endpointUrl,{method:"POST",headers:this.requestHeaders(),body:JSON.stringify(this.makeBatchRequest(t))})}catch(o){return{kind:"retryable",reason:iU(o)}}if(eU.has(a.status))return{kind:"auth",status:a.status};if(tU.has(a.status))return{kind:"retryable",reason:`HTTP ${a.status}`};if(!a.ok)return{kind:"permanent",reason:`HTTP ${a.status}`};let n=await rU(a);if(!n?.rejected||n.rejected.length===0)return{kind:"success"};let r=this.classifyRejectedEvents(t,n.rejected);return r.retryable.length===0&&r.permanent.length===0?{kind:"success"}:{kind:"partial",retryable:r.retryable,permanent:r.permanent}}makeBatchRequest(t){return{sentAt:this.now().toISOString(),source:{sdk:IC,version:this.sdkVersion??"0.0.0"},events:t}}classifyRejectedEvents(t,a){let n=new Map(t.map(i=>[i.id,i])),r=[],o=[];for(let i of a){let l=n.get(i.eventId);if(l){if(nU(i)){r.push(l);continue}o.push(l)}}return{retryable:r,permanent:o}}backoffDelayMs(t){let a=this.retryBaseDelayMs*2**t;return Math.min(a,this.retryMaxDelayMs)}stopTransportForAuthFailure(t,a){this.isStopped=!0;let n=this.buffer.length;this.buffer.splice(0,n),this.logger.error("[Waniwani] Auth failure (HTTP %d). Stopping tracking transport and dropping %d queued event(s)",t,a+n)}};function nU(e){if(e.retryable===!0)return!0;let t=e.code.toLowerCase();return t.includes("timeout")||t.includes("temporary")||t.includes("unavailable")||t.includes("rate_limit")||t.includes("transient")||t.includes("server")}async function rU(e){let t=await e.text();if(t)try{return JSON.parse(t)}catch{return}}function oU(e,t){let a=e.endsWith("/")?e:`${e}/`,n=t.startsWith("/")?t.slice(1):t;return`${a}${n}`}function iU(e){return e instanceof Error?e.message:String(e)}function kC(e){let{apiUrl:t,endpointPath:a}=lU(e.endpoint),n=CC({apiUrl:t,apiKey:e.token,endpointPath:a,flushIntervalMs:e.flushIntervalMs}),r,o=l=>typeof l=="function"?l():l,i=async l=>{let s=e.identity?.()??{},u=o(e.channelId),c=u===void 0?l.properties:{channelId:u,...l.properties},d=bC({sessionId:s.sessionId,visitorId:s.visitorId,externalUserId:s.externalUserId??r,traceId:s.traceId,...l,properties:c,metadata:{...e.metadata,...l.metadata}},{source:o(e.source)});return n.enqueue(d),{eventId:d.id}};return{track:Object.assign(i,SC(i)),identify(l,s){return r=l,i({event:"user.identified",externalUserId:l,properties:s})},flush:()=>n.flush(),shutdown:l=>n.shutdown(l)}}function lU(e){let t=new URL(e);return{apiUrl:t.origin,endpointPath:`${t.pathname}${t.search}`}}function ma(e,t,a){let[n,r=""]=e.split("?"),o=n.replace(/\/$/,""),i=new URLSearchParams(r);if(a)for(let[s,u]of Object.entries(a))i.set(s,u);let l=i.toString();return`${o}${t}${l?`?${l}`:""}`}var sU="/api/mcp/";function Wd(e,t){let[a=""]=e.split("?"),n="",r=a;try{let o=new URL(a);n=o.origin,r=o.pathname}catch{if(!a.startsWith("/"))return null}return r.startsWith(sU)?`${n}${t}`:null}function uU(){if(typeof window>"u")return!1;try{return window.WANIWANI_DEBUG?!0:!!window.localStorage?.getItem("WANIWANI_DEBUG")}catch{return!1}}function ha(...e){uU()&&console.log("[Waniwani]",...e)}var zg="waniwani-visitor-id";function cU(){try{if(typeof crypto<"u"){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();if(typeof crypto.getRandomValues=="function"){let e=crypto.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=Array.from(e,a=>a.toString(16).padStart(2,"0")).join("");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}}}catch{}return`v-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function Zt(){try{let t=localStorage.getItem(zg);if(t)return t}catch{}let e=cU();try{localStorage.setItem(zg,e)}catch{}return e}function ll(e){let t=typeof e=="string"?e.trim():"";if(!t)return Zt();try{localStorage.setItem(zg,t)}catch{}return t}function dU(e){return e!=null&&typeof e.then=="function"}function Xs(e){let t=!1,a=()=>{t=!0};if(e==null)return a;let n;try{n=typeof e=="function"?e():e}catch{return a}return dU(n)?n.then(r=>{t||ll(r??"")},()=>{}):ll(n??""),a}var fU="waniwani-memory";var Wa="threads",Gd="by_memoryUserId",pU="by_updatedAt";var LC="memoryUserId",TC="waniwani-memory-user-id",qg=null;function Hg(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}function mU(e,t){if(t<1&&(e.objectStoreNames.contains("ids")||e.createObjectStore("ids")),t<2&&!e.objectStoreNames.contains(Wa)){let a=e.createObjectStore(Wa,{keyPath:"threadId"});a.createIndex(Gd,"memoryUserId",{unique:!1}),a.createIndex(pU,"updatedAt",{unique:!1})}}async function jg(){return new Promise((e,t)=>{let a=indexedDB.open(fU,2);a.onupgradeneeded=n=>{mU(a.result,n.oldVersion)},a.onsuccess=()=>e(a.result),a.onerror=()=>t(a.error)})}async function hU(){return jg()}async function gU(e){return new Promise((t,a)=>{let o=e.transaction("ids","readonly").objectStore("ids").get(LC);o.onsuccess=()=>t(typeof o.result=="string"?o.result:null),o.onerror=()=>a(o.error)})}async function wU(e,t){return new Promise((a,n)=>{let i=e.transaction("ids","readwrite").objectStore("ids").put(t,LC);i.onsuccess=()=>a(),i.onerror=()=>n(i.error)})}async function yU(){if(typeof indexedDB>"u")return null;try{let e=await hU();try{let t=await gU(e);if(t)return t;let a=Hg();return await wU(e,a),a}finally{e.close()}}catch{return null}}function xU(){try{let e=localStorage.getItem(TC);if(e)return e;let t=Hg();return localStorage.setItem(TC,t),t}catch{return null}}async function EC(){let e=await yU();if(e)return e;let t=xU();return t||(qg||(qg=Hg()),qg)}function MC(e,t){return e.match(t)?.[1]??null}function vU(e){let t=[["Edge",/Edg(?:e|A|iOS)?\/(\S+)/],["Opera",/(?:OPR|Opera)\/(\S+)/],["Samsung Internet",/SamsungBrowser\/(\S+)/],["Firefox",/Firefox\/(\S+)/],["Chrome",/Chrome\/(\S+)/],["Safari",/Version\/(\S+).*Safari/]];for(let[a,n]of t){let r=MC(e,n);if(r)return{name:a,version:r}}return null}function bU(e){let t=[["iOS",/(?:iPhone|iPad|iPod).+?OS (\d+[_.\d]*)/],["Android",/Android (\d+[.\d]*)/],["macOS",/Mac OS X (\d+[_.\d]*)/],["Windows",/Windows NT (\d+[.\d]*)/],["ChromeOS",/CrOS \S+ (\d+[.\d]*)/],["Linux",/Linux/]];for(let[a,n]of t){let r=MC(e,n);if(r)return{name:a,version:r.replace(/_/g,".")};if(a==="Linux"&&n.test(e))return{name:a,version:""}}return null}function SU(e){return typeof navigator<"u"&&"userAgentData"in navigator&&navigator.userAgentData?.mobile?"mobile":/iPad|tablet|PlayBook/i.test(e)?"tablet":/Mobi|Android.*Mobile|iPhone|iPod/i.test(e)?"mobile":"desktop"}async function Ks(){let e=navigator.userAgent,t=Zt(),a=await EC();return{userAgent:e,browser:vU(e),os:bU(e),deviceType:SU(e),language:navigator.language,languages:[...navigator.languages],timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,screenWidth:screen.width,screenHeight:screen.height,viewportWidth:window.innerWidth,viewportHeight:window.innerHeight,colorDepth:screen.colorDepth,devicePixelRatio:window.devicePixelRatio??1,touchSupport:"ontouchstart"in window||navigator.maxTouchPoints>0,connectionType:navigator.connection?.effectiveType??"unknown",referrer:document.referrer,visitorId:t,memoryUserId:a}}var IU="0.22.0-beta.4",CU=40,kU=10,TU=6e5;function Wg(){return typeof performance>"u"?0:performance.now()}function Gg(e,t){let a={};return{metrics:a,has:n=>n in a,set(n,r){a[n]=r},mark(n,r=Wg()){if(!(n in a)){a[n]=r-t;try{performance.mark(`waniwani:${e}:${n}`,{startTime:r})}catch{}}}}}function LU(e){let t={};for(let[a,n]of Object.entries(e)){if(Object.keys(t).length>=CU)break;if(!Number.isFinite(n))continue;let r=Math.round(n);r<0||r>TU||(t[a]=r)}return t}function EU(e){let t={};for(let[a,n]of Object.entries(e)){if(Object.keys(t).length>=kU)break;(typeof n=="string"||typeof n=="boolean")&&(t[a]=n)}return t}function MU(){let e=navigator.connection;if(e)return{effectiveType:e.effectiveType,rtt:e.rtt,downlink:e.downlink,saveData:e.saveData}}function Xd(e){let t=e?.Authorization;return typeof t=="string"&&t.startsWith("Bearer ")?t.slice(7):void 0}function AU(e,t,a,n){return{kind:e,sdkVersion:IU,channelId:t.channelId||void 0,sessionId:e==="boot"?void 0:t.sessionId||void 0,visitorId:Zt(),pageHost:window.location.hostname,connection:MU(),tags:EU(a),metrics:LU(n)}}var Vg,$d=[];function $g(e){let t=String(e?.chatTimingLogs).trim().toLowerCase()==="true";Vg=t;let a=$d;if($d=[],t)for(let n of a)n()}function Kd(e,t,a,n){let{api:r,token:o}=t;if(!(typeof window>"u"||!r||!o||Vg===!1))try{let i=AU(e,t,a,n),l=()=>{ha("timing",i),fetch(ma(r,"/timing"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify(i),keepalive:!0}).catch(()=>{})};Vg?l():$d.length<20&&$d.push(l)}catch{}}var dr=Gg("boot",0),AC;function Uo(e,t){dr.mark(e,t)}function Yd(e){AC??(AC=e)}var RU=/cdn\.jsdelivr\.net\/npm\/@waniwani\/sdk@[^/]+\/dist\/chat\/embed\.js/,DU=/\/embed\.js(\?|$)/;function _U(){if(typeof performance>"u")return;let e=performance.getEntriesByType("navigation")[0];e?.responseStart&&dr.mark("navTtfb",e.responseStart),e?.domContentLoadedEventEnd&&dr.mark("navDomContentLoaded",e.domContentLoadedEventEnd);let t=performance.getEntriesByType("resource");for(let a of t)RU.test(a.name)?(dr.mark("bundleStart",a.startTime),dr.mark("bundleEnd",a.responseEnd)):DU.test(a.name)&&(dr.mark("loaderStart",a.startTime),dr.mark("loaderEnd",a.responseEnd))}function OU(){if(kv)return!0;try{return document.querySelectorAll('script[src*="@waniwani/sdk"]').length>1}catch{return!1}}function RC(e){_U(),dr.mark("bundleExecuted",Cv),Kd("boot",e,{configSource:AC,mode:e.mode,secondSdk:OU()},dr.metrics)}var PU=[["text-delta","firstText"],["tool-input-start","firstToolInput"],["tool-output-available","firstToolOutput"]];function DC(e){let t=Gg("turn",Wg());t.set("turnIndex",e);let a=!1;return{mark:n=>t.mark(n),instrument(n){if(!n.ok||!n.body||typeof TransformStream>"u")return n;try{let r=new TextDecoder,o=n.body.pipeThrough(new TransformStream({transform(i,l){t.mark("firstChunk");let s=r.decode(i,{stream:!0});for(let[u,c]of PU)!t.has(c)&&s.includes(u)&&t.mark(c);l.enqueue(i)}}));return new Response(o,{status:n.status,statusText:n.statusText,headers:n.headers})}catch{return n}},report(n,r){a||(a=!0,Kd("turn",n,r,t.metrics))}}}function NU(e){let t=e.indexOf("?");return t===-1?e:e.slice(0,t)}function _C(e,t){let a=Gg("widget",Wg()),n=!1;return{mark:r=>a.mark(r),has:r=>a.has(r),report(r,o){n||(n=!0,a.set("retries",o),t({widget:NU(e),outcome:r,metrics:a.metrics}))}}}var BU="/api/mcp/events/v2/batch",Xg=new Set;function UU(e,t,a){return`${e}|${t}|${a??""}`}function Ys(e){return Wd(e,BU)}async function OC(e){let{api:t,token:a,channelId:n,mode:r,source:o}=e;if(typeof window>"u"||!t||!a)return;let i=Ys(t);if(!i){ha("page.viewed skipped: the chat api is not a Waniwani endpoint");return}if(!n&&!o){ha("page.viewed skipped: no channelId or source to attribute it");return}let l=UU(t,a,n);if(!Xg.has(l)){Xg.add(l);try{let s=await Ks(),u=new Date().toISOString(),c=JSON.stringify({sentAt:u,source:{sdk:"@waniwani/sdk",version:"0.1.0"},events:[{id:crypto.randomUUID(),type:"mcp.event",name:"page.viewed",source:o,timestamp:u,correlation:{visitorId:s.visitorId},properties:{channelId:n,mode:r,url:window.location.href,referrer:s.referrer,deviceType:s.deviceType,language:s.language,timezone:s.timezone},metadata:{}}]}),d=fetch(i,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:c,keepalive:!0});Uo("pageViewSent"),await d}catch{Xg.delete(l)}}}function PC(e){let t=Ys(e.api);return t?kC({endpoint:t,token:e.token,channelId:e.channelId,source:e.getSource,identity:()=>({sessionId:e.getSessionId(),visitorId:Zt()})}):Zd("the chat api does not point at a Waniwani event ingest")}function Zd(e){let t=!1,a=async()=>(t||(t=!0,console.warn(`[Waniwani] track() is disabled: ${e}`)),{eventId:""});return{track:Object.assign(a,{priceShown:a,pricesCompared:a,optionSelected:a,leadQualified:a,converted:a}),identify:a,flush:async()=>{},shutdown:async()=>({timedOut:!1,pendingEvents:0})}}var Jd=z(he());var Qd=(...e)=>e.filter((t,a,n)=>!!t&&t.trim()!==""&&n.indexOf(t)===a).join(" ").trim();var NC=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();var BC=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,a,n)=>n?n.toUpperCase():a.toLowerCase());var Kg=e=>{let t=BC(e);return t.charAt(0).toUpperCase()+t.slice(1)};var Zs=z(he());var UC={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};var FC=e=>{for(let t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};var zC=(0,Zs.forwardRef)(({color:e="currentColor",size:t=24,strokeWidth:a=2,absoluteStrokeWidth:n,className:r="",children:o,iconNode:i,...l},s)=>(0,Zs.createElement)("svg",{ref:s,...UC,width:t,height:t,stroke:e,strokeWidth:n?Number(a)*24/Number(t):a,className:Qd("lucide",r),...!o&&!FC(l)&&{"aria-hidden":"true"},...l},[...i.map(([u,c])=>(0,Zs.createElement)(u,c)),...Array.isArray(o)?o:[o]]));var He=(e,t)=>{let a=(0,Jd.forwardRef)(({className:n,...r},o)=>(0,Jd.createElement)(zC,{ref:o,iconNode:t,className:Qd(`lucide-${NC(Kg(e))}`,`lucide-${e}`,n),...r}));return a.displayName=Kg(e),a};var FU=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Qs=He("arrow-down",FU);var zU=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Nn=He("arrow-up",zU);var qU=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Js=He("check",qU);var HU=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Qr=He("chevron-down",HU);var jU=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],eu=He("chevron-right",jU);var VU=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",key:"4jdomd"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4",key:"3hqy98"}],["path",{d:"M21 14H11",key:"1bme5i"}],["path",{d:"m15 10-4 4 4 4",key:"5dvupr"}]],tu=He("clipboard-copy",VU);var WU=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],fr=He("clock",WU);var GU=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],au=He("file-text",GU);var $U=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}]],sl=He("file",$U);var XU=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],nu=He("globe",XU);var KU=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],ru=He("image",KU);var YU=[["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m16.2 7.8 2.9-2.9",key:"r700ao"}],["path",{d:"M18 12h4",key:"wj9ykh"}],["path",{d:"m16.2 16.2 2.9 2.9",key:"1bxg5t"}],["path",{d:"M12 18v4",key:"jadmvz"}],["path",{d:"m4.9 19.1 2.9-2.9",key:"bwix9q"}],["path",{d:"M2 12h4",key:"j09sii"}],["path",{d:"m4.9 4.9 2.9 2.9",key:"giyufr"}]],ou=He("loader",YU);var ZU=[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]],ul=He("paperclip",ZU);var QU=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],iu=He("square",QU);var JU=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],Fo=He("wrench",JU);var e3=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Ga=He("x",e3);var t3=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],lu=He("zap",t3);var $e=z(he(),1),dO=z(dm(),1);var cl=z(he(),1),su=z(ae(),1);function r3(e){return 1-(1-e)**3}function o3({start:e=0,end:t=100,duration:a=1e3,delay:n=0,ease:r=r3,onUpdate:o,onEnd:i}){let l=performance.now()+n;function s(){let u=performance.now()-l,c=Math.min(u/a,1);o(e+(t-e)*r(c)),c<1?requestAnimationFrame(s):i&&i()}setTimeout(()=>requestAnimationFrame(s),n)}var i3=["80% 55%","69% 34%","8% 6%","41% 38%","86% 85%","82% 18%","51% 4%"],l3=[0,1,2,0,1,2,1];function s3(e){let t=[];for(let a=0;a<7;a++){let n=e[Math.min(l3[a],e.length-1)];t.push(`radial-gradient(at ${i3[a]}, ${n} 0px, transparent 50%)`)}return t.push(`linear-gradient(${e[0]} 0 100%)`),t}var u3=({children:e,className:t="",style:a,edgeSensitivity:n=30,backgroundColor:r="#120F17",borderRadius:o=28,coneSpread:i=25,animated:l=!1,colors:s=["#c084fc","#f472b6","#38bdf8"]})=>{let[u,c]=(0,cl.useState)(110),[d,f]=(0,cl.useState)(0),[p,m]=(0,cl.useState)(!1);(0,cl.useEffect)(()=>{if(!l)return;let T=110;m(!0),c(T),o3({ease:C=>C,duration:2e3,onUpdate:C=>{let M=C/100;c(T+360*M);let D=Math.min(M/.1,1),P=M>.85?(1-M)/.15:1;f(Math.min(D,P))},onEnd:()=>m(!1)})},[l]);let x=n+20,S=p?Math.max(0,(d*100-x)/(100-x)):0,y=s3(s).map(T=>`${T} border-box`),b=`conic-gradient(from ${`${u.toFixed(3)}deg`} at center, black ${i}%, transparent ${i+15}%, transparent ${100-i-15}%, black ${100-i}%)`;return(0,su.jsxs)("div",{className:`ww:relative ww:grid ww:isolate ww:border ${t}`,style:{background:r,borderRadius:typeof o=="number"?`${o}px`:o,transform:"translate3d(0, 0, 0.01px)",...a},children:[(0,su.jsx)("div",{className:"ww:absolute ww:inset-0 ww:rounded-[inherit] ww:-z-[1]",style:{border:"1px solid transparent",background:[`linear-gradient(${r} 0 100%) padding-box`,"linear-gradient(rgb(255 255 255 / 0%) 0% 100%) border-box",...y].join(", "),opacity:S,maskImage:b,WebkitMaskImage:b,transition:p?"opacity 0.25s ease-out":"opacity 0.75s ease-in-out"}}),(0,su.jsx)("div",{className:"ww:flex ww:flex-col ww:relative ww:overflow-auto ww:z-[1]",children:e})]})},tf=u3;Yg();Qg();var c3=WC({prefix:"ww"});function q(...e){return c3(af(e))}var uu=z(ae(),1);function dl({suggestions:e,isLoading:t,onSelect:a,align:n="start",className:r,...o}){return e.length===0&&!t?null:(0,uu.jsx)("div",{className:q("ww:px-4 ww:py-2",r),...o,children:(0,uu.jsx)("div",{className:q("ww:mx-auto ww:w-full ww:max-w-3xl ww:flex ww:flex-wrap ww:gap-2",n==="center"&&"ww:justify-center"),children:t?[0,1,2].map(i=>(0,uu.jsx)("div",{className:"ww:h-8 ww:rounded-full ww:bg-accent ww:animate-pulse",style:{width:`${60+i*20}px`}},i)):e.map((i,l)=>(0,uu.jsx)("button",{type:"button",onClick:()=>a(i),className:q("ww:rounded-full ww:border ww:border-border ww:bg-accent ww:px-3.5 ww:py-1.5 ww:text-sm","ww:text-foreground ww:hover:bg-border ww:hover:border-primary/30","ww:transition-all ww:duration-200 ww:ease-out ww:cursor-pointer","ww:animate-[ww-fade-in_0.2s_ease-out_both]"),style:{animationDelay:`${l*50}ms`},children:i},i))})})}var GC=z(he(),1),$C="(max-width: 639px)";function d3(e){let t=window.matchMedia($C);return t.addEventListener("change",e),()=>t.removeEventListener("change",e)}function f3(){return window.matchMedia($C).matches}function p3(){return!1}function XC(){return(0,GC.useSyncExternalStore)(d3,f3,p3)}var nf=z(he(),1);function Jg(e,t){return e.find(a=>a.text===t)?.id??null}async function KC(e){let{api:t,token:a,name:n,source:r,sessionId:o,properties:i}=e;if(typeof window>"u"||!t||!a)return;let l=Ys(t);if(l)try{let s=new Date().toISOString(),u=JSON.stringify({sentAt:s,source:{sdk:"@waniwani/sdk",version:"0.1.0"},events:[{id:crypto.randomUUID(),type:"mcp.event",name:n,source:r,timestamp:s,correlation:{visitorId:Zt(),sessionId:o},properties:{...i,url:window.location.href},metadata:{}}]});await fetch(l,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:u,keepalive:!0})}catch{}}async function YC(e){let{api:t,token:a,channelId:n,mode:r,source:o,sessionId:i,promptId:l,origin:s,text:u,index:c}=e;await KC({api:t,token:a,name:"suggestion.clicked",source:o,sessionId:i,properties:{promptId:l,origin:s,text:u,index:c,channelId:n,mode:r}})}function ZC(e,t){return t.map(a=>({id:Jg(e,a),text:a}))}async function QC(e){let{api:t,token:a,channelId:n,mode:r,source:o,sessionId:i,prompts:l,origin:s}=e;l.length!==0&&await KC({api:t,token:a,name:"suggestion.shown",source:o,sessionId:i,properties:{prompts:l,count:l.length,origin:s,channelId:n,mode:r}})}function fl(e){let{widgetEvents:t,api:a,token:n,channelId:r,source:o,mode:i,pagePrompts:l}=e,s=(0,nf.useRef)(e.getSessionId);s.current=e.getSessionId,(0,nf.useEffect)(()=>{if(!(!a||!n))return t.subscribe(u=>{if(u.name==="suggestion.clicked"){let{text:c,origin:d,index:f}=u.properties;YC({api:a,token:n,channelId:r,mode:i,source:o,sessionId:s.current(),promptId:Jg(l??[],c),origin:d,text:c,index:f});return}if(u.name==="suggestions.shown"){let{texts:c,origin:d}=u.properties;QC({api:a,token:n,channelId:r,mode:i,source:o,sessionId:s.current(),prompts:ZC(l??[],c),origin:d})}})},[t,a,n,r,o,i,l])}var pl=z(he(),1),m3=80,h3=50,g3=15e3,JC=500;function ml(e,t=!0){let[a,n]=(0,pl.useState)(""),r=(0,pl.useRef)(void 0);return(0,pl.useEffect)(()=>{if(!t){n("");return}let o=0,i=!1,l=!1,s=()=>{l||(i?(o--,n(e.slice(0,o)),o<=0?(i=!1,r.current=setTimeout(s,JC)):r.current=setTimeout(s,h3)):(o++,n(e.slice(0,o)),o>=e.length?(i=!0,r.current=setTimeout(s,g3)):r.current=setTimeout(s,m3)))};return r.current=setTimeout(s,JC),()=>{l=!0,clearTimeout(r.current)}},[e,t]),a}var Sn=z(he(),1);var ek=["en","fr","es"];function hl(e){return ek.includes(e)}function ew(e){if(e&&hl(e))return e;if(e){let a=e.split("-")[0]?.toLowerCase();if(a&&hl(a))return a}let t=[];if(typeof navigator<"u"&&(navigator.language&&t.push(navigator.language),navigator.languages&&t.push(...navigator.languages)),typeof document<"u"){let a=document.documentElement.getAttribute("lang");a&&t.push(a)}for(let a of t){let n=a.toLowerCase();if(hl(n))return n;let r=n.split("-")[0];if(r&&hl(r))return r}return"en"}var rf={promptInput:{placeholder:"What would you like to know?",uploadFiles:"Upload files",uploadFilesUpTo:"Upload a document, up to {limit}",uploadFilesUpToWithPages:"Upload a document, up to {limit} and {pages} pages",stop:"Stop",submit:"Submit",removeAttachments:"Remove all attachments",removeAttachment:"Remove attachment",uploading:"Uploading\u2026",retry:"Retry",retryUpload:"Retry the upload",uploadFailed:"The upload did not finish.",dropToAttach:"Drop to attach",errorAccept:"{name} is not a file type this chat accepts.",errorTooLarge:"{name} is larger than {limit}.",errorTooMany:"You can attach up to {limit} files."},workingIndicator:{default:"On it\u2026"},reasoning:{thinking:"Thinking\u2026",thoughtBrief:"Thought for a few seconds",thoughtForSeconds:e=>`Thought for ${e} second${e===1?"":"s"}`},chainOfThought:{working:"Working on it\u2026",done:"Thought process"},tool:{copy:"Copy",copied:"Copied",request:"Request",response:"Response",error:"Error"},attachments:{attachmentFallback:"attachment",kindPdf:"PDF",kindImage:"Image",kindFile:"File",fileFallback:"file"},threadMenu:{newChat:"New chat",threadHistory:"Thread history",deleteThread:"Delete thread",noPreviousChats:"No previous chats yet.",hiddenThreads:e=>`${e} older thread${e===1?"":"s"} hidden`},chatQueue:{attachmentFallback:"(attachment)",removeFromQueue:"Remove from queue",queued:e=>`${e} queued`},poweredBy:{label:"AI agent powered by"},aiDisclaimer:{default:"can make mistakes"},exportSession:{saving:"saving...",saved:"saved",error:"error",export:"export",tooltip:"Save scenario to Waniwani"},widgetErrorBoundary:{failedToLoad:"Widget failed to load",retry:"Retry"},launcher:{prompt:"Ask anything\u2026",open:"Open chat",close:"Close chat",minimize:"Minimize"}};var tk={promptInput:{placeholder:"\xBFQu\xE9 te gustar\xEDa saber?",uploadFiles:"Subir archivos",uploadFilesUpTo:"Subir un documento, hasta {limit}",uploadFilesUpToWithPages:"Subir un documento, hasta {limit} y {pages} p\xE1ginas",stop:"Detener",submit:"Enviar",removeAttachments:"Eliminar todos los archivos adjuntos",removeAttachment:"Quitar archivo",uploading:"Subiendo\u2026",retry:"Reintentar",retryUpload:"Reintentar la subida",uploadFailed:"La subida no se complet\xF3.",dropToAttach:"Suelta para adjuntar",errorAccept:"{name} no es un tipo de archivo que acepte este chat.",errorTooLarge:"{name} supera {limit}.",errorTooMany:"Puedes adjuntar hasta {limit} archivos."},workingIndicator:{default:"Un momento\u2026"},reasoning:{thinking:"Pensando\u2026",thoughtBrief:"Pensado durante unos segundos",thoughtForSeconds:e=>`Pensado durante ${e} segundo${e===1?"":"s"}`},chainOfThought:{working:"Estoy en ello\u2026",done:"Razonamiento"},tool:{copy:"Copiar",copied:"Copiado",request:"Solicitud",response:"Respuesta",error:"Error"},attachments:{attachmentFallback:"adjunto",kindPdf:"PDF",kindImage:"Imagen",kindFile:"Archivo",fileFallback:"archivo"},threadMenu:{newChat:"Nueva conversaci\xF3n",threadHistory:"Historial",deleteThread:"Eliminar conversaci\xF3n",noPreviousChats:"A\xFAn no hay conversaciones anteriores.",hiddenThreads:e=>`${e} conversaci\xF3n${e===1?"":"es"} anterior${e===1?"":"es"} oculta${e===1?"":"s"}`},chatQueue:{attachmentFallback:"(adjunto)",removeFromQueue:"Quitar de la cola",queued:e=>`${e} en cola`},poweredBy:{label:"Agente IA con tecnolog\xEDa de"},aiDisclaimer:{default:"puede cometer errores"},exportSession:{saving:"guardando...",saved:"guardado",error:"error",export:"exportar",tooltip:"Guardar escenario en Waniwani"},widgetErrorBoundary:{failedToLoad:"No se pudo cargar el widget",retry:"Reintentar"},launcher:{prompt:"Pregunta lo que quieras\u2026",open:"Abrir chat",close:"Cerrar chat",minimize:"Minimizar"}};var ak={promptInput:{placeholder:"Que souhaitez-vous savoir ?",uploadFiles:"Importer des fichiers",uploadFilesUpTo:"Joindre un document, jusqu'\xE0 {limit}",uploadFilesUpToWithPages:"Envoyer un document, jusqu'\xE0 {limit} et {pages} pages",stop:"Arr\xEAter",submit:"Envoyer",removeAttachments:"Supprimer toutes les pi\xE8ces jointes",removeAttachment:"Retirer la pi\xE8ce jointe",uploading:"Envoi en cours\u2026",retry:"R\xE9essayer",retryUpload:"R\xE9essayer l'envoi",uploadFailed:"L'envoi ne s'est pas termin\xE9.",dropToAttach:"D\xE9posez pour joindre",errorAccept:"{name} n'est pas un type de fichier accept\xE9 par ce chat.",errorTooLarge:"{name} d\xE9passe {limit}.",errorTooMany:"Vous pouvez joindre jusqu'\xE0 {limit} fichiers."},workingIndicator:{default:"Un instant\u2026"},reasoning:{thinking:"R\xE9flexion\u2026",thoughtBrief:"R\xE9flexion pendant quelques secondes",thoughtForSeconds:e=>`R\xE9flexion pendant ${e} seconde${e===1?"":"s"}`},chainOfThought:{working:"Je m'en occupe\u2026",done:"Raisonnement"},tool:{copy:"Copier",copied:"Copi\xE9",request:"Requ\xEAte",response:"R\xE9ponse",error:"Erreur"},attachments:{attachmentFallback:"pi\xE8ce jointe",kindPdf:"PDF",kindImage:"Image",kindFile:"Fichier",fileFallback:"fichier"},threadMenu:{newChat:"Nouvelle conversation",threadHistory:"Historique",deleteThread:"Supprimer la conversation",noPreviousChats:"Aucune conversation pr\xE9c\xE9dente.",hiddenThreads:e=>`${e} conversation${e===1?"":"s"} plus ancienne${e===1?"":"s"} masqu\xE9e${e===1?"":"s"}`},chatQueue:{attachmentFallback:"(pi\xE8ce jointe)",removeFromQueue:"Retirer de la file",queued:e=>`${e} en attente`},poweredBy:{label:"Agent IA propuls\xE9 par"},aiDisclaimer:{default:"peut faire des erreurs"},exportSession:{saving:"enregistrement...",saved:"enregistr\xE9",error:"erreur",export:"exporter",tooltip:"Enregistrer le sc\xE9nario dans Waniwani"},widgetErrorBoundary:{failedToLoad:"\xC9chec du chargement du widget",retry:"R\xE9essayer"},launcher:{prompt:"Posez votre question\u2026",open:"Ouvrir le chat",close:"Fermer le chat",minimize:"R\xE9duire"}};var tw={en:rf,fr:ak,es:tk};var rk=z(ae(),1),nk=(0,Sn.createContext)(null);function w3(e,t){if(!t)return e;let a={...e};for(let n of Object.keys(e)){let r=e[n],o=t[n];o&&typeof r=="object"&&(a[n]={...r,...o})}return a}function zo({children:e,locale:t,messages:a}){let n=!!(t&&y3(t)),r=n?t:"en",[o,i]=(0,Sn.useState)(r),[l,s]=(0,Sn.useState)(n);(0,Sn.useEffect)(()=>{i(ew(t)),s(!0)},[t]);let u=(0,Sn.useMemo)(()=>{let c=tw[o]??tw["en"];return{locale:o,t:w3(c,a),ready:l}},[o,a,l]);return(0,rk.jsx)(nk.Provider,{value:u,children:e})}function y3(e){return e==="en"||e==="fr"||e==="es"}function Ie(){let e=(0,Sn.useContext)(nk);return e||{locale:"en",t:rf,ready:!0}}function aw(e,t){let a=Date.now()-e;if(a<6e4)try{return new Intl.RelativeTimeFormat(t,{numeric:"auto",style:"narrow"}).format(0,"second")}catch{return"just now"}let n,r;a<60*6e4?(n=-Math.floor(a/6e4),r="minute"):a<1440*6e4?(n=-Math.floor(a/(60*6e4)),r="hour"):(n=-Math.floor(a/(1440*6e4)),r="day");try{return new Intl.RelativeTimeFormat(t,{numeric:"auto",style:"short"}).format(n,r)}catch{return`${Math.abs(n)}${r==="minute"?"m":r==="hour"?"h":"d"} ago`}}var ze=z(he(),1);var cu=(e=21)=>crypto.getRandomValues(new Uint8Array(e)).reduce((t,a)=>(a&=63,a<36?t+=a.toString(36):a<62?t+=(a-26).toString(36).toUpperCase():a>62?t+="-":t+="_",t),"");var Ce=z(he(),1);var qo=new Map;function ok(e,t){if(qo.has(e)){URL.revokeObjectURL(t);return}for(qo.set(e,t);qo.size>20;){let a=qo.keys().next();if(a.done)return;let n=qo.get(a.value);qo.delete(a.value),n&&URL.revokeObjectURL(n)}}function ik(e){return qo.get(e)}var lk=z(ae(),1),Bn=({className:e,variant:t="default",size:a="default",type:n="button",...r})=>(0,lk.jsx)("button",{type:n,className:q("ww:inline-flex ww:cursor-pointer ww:items-center ww:justify-center ww:rounded-md ww:font-medium ww:transition-colors ww:disabled:pointer-events-none ww:disabled:opacity-50",t==="default"&&"ww:bg-primary ww:text-primary-foreground ww:hover:bg-primary/90",t==="outline"&&"ww:border ww:border-border ww:bg-background ww:hover:bg-accent ww:hover:text-accent-foreground",t==="ghost"&&"ww:hover:bg-accent ww:hover:text-accent-foreground",a==="default"&&"ww:h-9 ww:px-4 ww:py-2 ww:text-sm",a==="sm"&&"ww:h-8 ww:px-3 ww:text-xs",a==="icon"&&"ww:size-9 ww:!rounded-full",a==="icon-sm"&&"ww:size-7 ww:!rounded-full",e),...r});var sk=z(he(),1);var bt=z(ae(),1),uk=({files:e,className:t,...a})=>e.length===0?null:(0,bt.jsx)("div",{className:q("ww:flex ww:flex-wrap ww:gap-1.5",t),...a,children:e.map((n,r)=>(0,bt.jsx)(x3,{file:n},r))});function x3({file:e}){let{t}=Ie();return e.mediaType?.startsWith("image/")&&e.url?(0,bt.jsx)("img",{src:e.url,alt:e.filename??t.attachments.attachmentFallback,className:"ww:h-16 ww:max-w-32 ww:rounded ww:object-cover"}):(0,bt.jsxs)("span",{className:"ww:inline-flex ww:items-center ww:gap-1.5 ww:rounded ww:bg-background/20 ww:px-2 ww:py-1 ww:text-xs",children:[(0,bt.jsx)(sl,{className:"ww:size-3 ww:shrink-0"}),(0,bt.jsx)("span",{className:"ww:max-w-24 ww:truncate",children:e.filename??t.attachments.fileFallback})]})}function ck(e,t){return e.startsWith("image/")?t.attachments.kindImage:e==="application/pdf"?t.attachments.kindPdf:t.attachments.kindFile}function v3({mediaType:e}){return e.startsWith("image/")?(0,bt.jsx)(ru,{className:"ww:size-5 ww:text-muted-foreground"}):e==="application/pdf"?(0,bt.jsx)(au,{className:"ww:size-5 ww:text-muted-foreground"}):(0,bt.jsx)(sl,{className:"ww:size-5 ww:text-muted-foreground"})}function nw({filename:e,mediaType:t,previewUrl:a,subtitle:n,tone:r="default",children:o,className:i}){let{t:l}=Ie(),s=ck(t,l);return(0,bt.jsxs)("li",{"aria-label":`${e}, ${s}`,className:q("ww:relative ww:flex ww:w-60 ww:max-w-full ww:cursor-default ww:items-center ww:gap-2.5 ww:overflow-hidden ww:rounded-xl ww:border ww:bg-background ww:p-2.5",r==="error"?"ww:border-destructive/50":"ww:border-border",i),children:[(0,bt.jsx)("span",{className:"ww:flex ww:size-10 ww:shrink-0 ww:items-center ww:justify-center ww:overflow-hidden ww:rounded-xl ww:bg-muted",children:a?(0,bt.jsx)("img",{alt:"",className:"ww:size-full ww:object-cover ww:object-center",src:a}):(0,bt.jsx)(v3,{mediaType:t})}),(0,bt.jsxs)("span",{className:"ww:flex ww:min-w-0 ww:flex-col",children:[(0,bt.jsx)("span",{className:"ww:truncate ww:font-medium ww:text-sm",title:e,children:e}),(0,bt.jsx)("span",{className:q("ww:truncate ww:text-xs",r==="error"?"ww:text-destructive":"ww:text-muted-foreground"),children:n??s})]}),o]})}function dk(e){if(typeof e!="object"||e===null)return[];let t=e.documents;return Array.isArray(t)?t.filter(a=>typeof a=="object"&&a!==null&&typeof a.documentId=="string"&&typeof a.filename=="string"&&typeof a.mediaType=="string"):[]}var fk=({documents:e,className:t,...a})=>e.length===0?null:(0,bt.jsx)("ul",{className:q("ww:flex ww:list-none ww:flex-wrap ww:items-end ww:justify-end ww:gap-2 ww:p-0",t),...a,children:e.map((n,r)=>(0,bt.jsx)(b3,{document:n},`${n.documentId}-${r}`))});function b3({document:e}){let{t}=Ie(),[a,n]=(0,sk.useState)(!1),r=e.mediaType.startsWith("image/")?ik(e.documentId):void 0;return r&&!a?(0,bt.jsx)("li",{children:(0,bt.jsx)("img",{alt:`${e.filename}, ${ck(e.mediaType,t)}`,className:"ww:max-h-80 ww:max-w-72 ww:rounded-xl ww:border ww:border-border ww:object-contain",onError:()=>n(!0),src:r,title:e.filename})}):(0,bt.jsx)(nw,{filename:e.filename,mediaType:e.mediaType})}var ht=z(ae(),1),S3=async e=>{try{let a=await(await fetch(e)).blob();return new Promise(n=>{let r=new FileReader;r.onloadend=()=>n(r.result),r.onerror=()=>n(null),r.readAsDataURL(a)})}catch{return null}},I3=(e,t)=>{if(!t)return!0;let a=t.split(",").map(o=>o.trim().toLowerCase()).filter(Boolean);if(a.length===0)return!0;let n=e.type.toLowerCase(),r=e.name.toLowerCase();return a.some(o=>o.startsWith(".")?r.endsWith(o):o.endsWith("/*")?n.startsWith(o.slice(0,-1)):n===o)},mk=(0,Ce.createContext)(null),of=()=>{let e=(0,Ce.useContext)(mk);if(!e)throw new Error("usePromptInputAttachments must be used within a PromptInput");return e},hk=({className:e,accept:t,multiple:a,globalDrop:n,maxFiles:r,maxFileSize:o,maxPdfPages:i,attachmentsEnabled:l=!0,upload:s,onDiscard:u,onError:c,onSubmit:d,children:f,...p})=>{let{t:m,locale:x}=Ie(),S=(0,Ce.useRef)(null),w=(0,Ce.useRef)(null),[y,h]=(0,Ce.useState)([]),b=(0,Ce.useRef)(y),T=(0,Ce.useRef)(new Map),C=(0,Ce.useRef)(s),M=(0,Ce.useRef)(c),D=(0,Ce.useRef)(u);(0,Ce.useEffect)(()=>{C.current=s,M.current=c,D.current=u},[s,c,u]);let P=(0,Ce.useCallback)(v=>{b.current=v,h(v)},[]),L=(0,Ce.useCallback)(()=>{S.current?.click()},[]),$=(0,Ce.useCallback)((v,K)=>{P(b.current.map(ee=>ee.id===v?{...ee,...K}:ee))},[P]),H=(0,Ce.useCallback)((v,K)=>{let ee=C.current;if(!ee)return;let we=new AbortController,Ge=ee(K,we.signal,me=>{$(v,{progress:me})}).then(me=>($(v,{status:"ready",progress:1,documentId:me.documentId,error:void 0}),me)).catch(me=>{if(we.signal.aborted)return null;let ye=me instanceof Error?me.message:m.promptInput.uploadFailed;return $(v,{status:"failed",error:ye}),M.current?.({code:"upload_failed",message:ye}),null});T.current.set(v,{file:K,controller:we,done:Ge})},[$,m]),F=(0,Ce.useCallback)(v=>{let K=[...v];if(!l||K.length===0)return;let ee=(de,Q)=>M.current?.({code:de,message:Q}),we=[];for(let de of K){if(!I3(de,t)){ee("accept",m.promptInput.errorAccept.replace("{name}",de.name));continue}if(o&&de.size>o){ee("max_file_size",m.promptInput.errorTooLarge.replace("{name}",de.name).replace("{limit}",gk(o,x)));continue}we.push(de)}if(we.length===0)return;let Ge=typeof r=="number"?Math.max(0,r-b.current.length):void 0,me=typeof Ge=="number"?we.slice(0,Ge):we;if(me.length<we.length&&ee("max_files",m.promptInput.errorTooMany.replace("{limit}",String(r))),me.length===0)return;let ye=!!C.current,le=me.map(de=>({file:de,item:{filename:de.name,id:cu(),mediaType:de.type,type:"file",url:URL.createObjectURL(de),status:ye?"uploading":"ready",progress:0}}));P([...b.current,...le.map(de=>de.item)]);for(let de of le)H(de.item.id,de.file)},[r,o,t,l,H,P,m,x]),W=(0,Ce.useCallback)(v=>{let K=T.current.get(v);K&&($(v,{status:"uploading",progress:0,error:void 0}),H(v,K.file))},[$,H]),V=(0,Ce.useCallback)((v,K)=>{T.current.get(v.id)?.controller.abort(),T.current.delete(v.id),v.url&&(!K&&!!v.documentId&&!!v.mediaType?.startsWith("image/")&&v.documentId?ok(v.documentId,v.url):URL.revokeObjectURL(v.url)),K&&v.documentId&&D.current?.({documentId:v.documentId,filename:v.filename??"",mediaType:v.mediaType??""})},[]),N=(0,Ce.useCallback)(v=>{let K=b.current.find(ee=>ee.id===v);K&&V(K,!0),P(b.current.filter(ee=>ee.id!==v))},[V,P]),R=(0,Ce.useCallback)(()=>{for(let v of b.current)V(v,!0);P([])},[V,P]),G=(0,Ce.useRef)(l);(0,Ce.useEffect)(()=>{let v=G.current;G.current=l,v&&!l&&R()},[l,R]);let ue=(0,Ce.useCallback)(()=>{for(let v of b.current)V(v,!1);P([])},[V,P]);(0,Ce.useEffect)(()=>()=>{for(let v of b.current)T.current.get(v.id)?.controller.abort(),v.url&&URL.revokeObjectURL(v.url)},[]);let I=(0,Ce.useCallback)(v=>{v.currentTarget.files&&F(v.currentTarget.files),v.currentTarget.value=""},[F]);(0,Ce.useEffect)(()=>{if(!n)return;let v=ee=>{ee.dataTransfer?.types?.includes("Files")&&ee.preventDefault()},K=ee=>{ee.dataTransfer?.types?.includes("Files")&&ee.preventDefault(),ee.dataTransfer?.files&&ee.dataTransfer.files.length>0&&F(ee.dataTransfer.files)};return document.addEventListener("dragover",v),document.addEventListener("drop",K),()=>{document.removeEventListener("dragover",v),document.removeEventListener("drop",K)}},[F,n]);let We=(0,Ce.useCallback)(async v=>{v.preventDefault();let K=v.currentTarget,ee=new FormData(K).get("message")||"",we=new Map;for(;we.size<T.current.size;)await Promise.all([...T.current.entries()].filter(([le])=>!we.has(le)).map(async([le,de])=>{we.set(le,await de.done)}));for(let le of we.keys())T.current.has(le)||we.delete(le);if([...we.values()].some(le=>le===null)){M.current?.({code:"upload_failed",message:m.promptInput.uploadFailed});return}let Ge=[...we.values()].filter(le=>le!==null),me=C.current?[]:b.current,ye=await Promise.all(me.map(async({id:le,status:de,progress:Q,error:Be,...qe})=>{if(qe.url?.startsWith("blob:")){let _e=await S3(qe.url);return{...qe,url:_e??qe.url}}return qe}));try{let le=d({documents:Ge,files:ye,text:ee},v);le instanceof Promise&&await le,K.reset(),ue()}catch{}},[d,ue,m]),Je=(0,Ce.useMemo)(()=>({add:F,clear:R,files:y,openFileDialog:L,remove:N,retry:W,maxFileSize:o,maxPdfPages:i}),[y,F,N,W,R,L,o,i]);return(0,ht.jsxs)(mk.Provider,{value:Je,children:[(0,ht.jsx)("input",{accept:t,"aria-label":m.promptInput.uploadFiles,className:"ww:hidden",multiple:a,onChange:I,ref:S,title:m.promptInput.uploadFiles,type:"file"}),(0,ht.jsx)("form",{className:q("ww:relative ww:flex ww:w-full ww:flex-col ww:rounded-lg ww:border ww:border-border ww:bg-background",e),onSubmit:We,ref:w,...p,children:f})]})},pk=1024*1024;function gk(e,t){let a=e>=pk;return new Intl.NumberFormat(t,{style:"unit",unit:a?"megabyte":"kilobyte",maximumFractionDigits:0}).format(a?e/pk:Math.max(1,e/1024))}var wk=({onChange:e,onKeyDown:t,className:a,placeholder:n,...r})=>{let{t:o}=Ie(),i=of(),[l,s]=(0,Ce.useState)(!1),u=n??o.promptInput.placeholder,c=(0,Ce.useCallback)(f=>{if(t?.(f),!f.defaultPrevented){if(f.key==="Enter"){if(l||f.nativeEvent.isComposing||f.shiftKey)return;f.preventDefault();let{form:p}=f.currentTarget;if(p?.querySelector('[data-submit-blocked="true"]')||p?.querySelector('button[type="submit"]')?.disabled)return;p?.requestSubmit()}if(f.key==="Backspace"&&f.currentTarget.value===""&&i.files.length>0){f.preventDefault();let p=i.files.at(-1);p&&i.remove(p.id)}}},[t,l,i]),d=(0,Ce.useCallback)(f=>{let p=f.clipboardData?.items;if(!p)return;let m=[];for(let x of p)if(x.kind==="file"){let S=x.getAsFile();S&&m.push(S)}m.length>0&&(f.preventDefault(),i.add(m))},[i]);return(0,ht.jsx)("textarea",{className:q("ww:field-sizing-content ww:max-h-48 ww:min-h-0 ww:w-full ww:resize-none ww:border-0 ww:bg-transparent ww:px-3 ww:py-2 ww:text-base ww:sm:text-sm ww:outline-none ww:placeholder:text-muted-foreground",a),name:"message",onCompositionEnd:()=>s(!1),onCompositionStart:()=>s(!0),onKeyDown:c,onPaste:d,placeholder:u,onChange:e,...r})},yk=({className:e,status:t,onStop:a,onClick:n,children:r,disabled:o,...i})=>{let{t:l}=Ie(),s=t==="submitted"||t==="streaming",u=s&&a!==void 0,c=(0,ht.jsx)(Nn,{className:"ww:size-4"});t==="submitted"?c=(0,ht.jsx)(ou,{className:"ww:size-4 ww:animate-spin"}):t==="streaming"&&(c=(0,ht.jsx)(iu,{className:"ww:size-4"}));let d=(0,Ce.useCallback)(f=>{if(s&&a){f.preventDefault(),a();return}n?.(f)},[s,a,n]);return(0,ht.jsx)(Bn,{"aria-label":s?l.promptInput.stop:l.promptInput.submit,className:q("ww:bg-foreground ww:text-background ww:hover:bg-foreground ww:rounded-full",e),"data-submit-blocked":o?"true":void 0,disabled:u?!1:o,onClick:d,size:"icon-sm",type:u?"button":"submit",variant:"ghost",...i,children:r??c})},xk=({className:e,children:t,...a})=>{let{t:n,locale:r}=Ie(),o=of();if(o.files.length>0)return(0,ht.jsxs)(Bn,{className:q("ww:group ww:relative",e),onClick:()=>o.clear(),size:"icon-sm",type:"button",variant:"ghost","aria-label":n.promptInput.removeAttachments,...a,children:[(0,ht.jsx)("span",{className:"ww:flex ww:size-5 ww:items-center ww:justify-center ww:rounded-full ww:bg-primary ww:text-[10px] ww:font-medium ww:text-primary-foreground ww:transition-opacity ww:group-hover:opacity-0",children:o.files.length}),(0,ht.jsx)(Ga,{className:"ww:absolute ww:size-4 ww:opacity-0 ww:transition-opacity ww:group-hover:opacity-100"})]});let l=o.maxFileSize?(o.maxPdfPages?n.promptInput.uploadFilesUpToWithPages.replace("{pages}",String(o.maxPdfPages)):n.promptInput.uploadFilesUpTo).replace("{limit}",gk(o.maxFileSize,r)):n.promptInput.uploadFiles;return(0,ht.jsx)(Bn,{"aria-label":l,className:q(e),title:l,onClick:()=>o.openFileDialog(),size:"icon-sm",type:"button",variant:"ghost",...a,children:t??(0,ht.jsx)(ul,{className:"ww:size-4"})})},vk=({className:e,...t})=>{let a=of();return a.files.length===0?null:(0,ht.jsx)("ul",{className:q("ww:flex ww:list-none ww:flex-wrap ww:gap-2 ww:p-0",e),...t,children:a.files.map(n=>(0,ht.jsx)(C3,{file:n},n.id))})};function C3({file:e}){let{t}=Ie(),a=of(),n=e.status==="failed",r=e.status==="uploading";return(0,ht.jsxs)(nw,{filename:e.filename??t.attachments.fileFallback,mediaType:e.mediaType??"",previewUrl:e.mediaType?.startsWith("image/")?e.url:void 0,subtitle:n?e.error:r?t.promptInput.uploading:void 0,tone:n?"error":"default",children:[n?(0,ht.jsx)("button",{"aria-label":t.promptInput.retryUpload,className:"ww:ml-auto ww:shrink-0 ww:text-destructive ww:text-xs ww:underline ww:underline-offset-2",onClick:()=>a.retry(e.id),type:"button",children:t.promptInput.retry}):null,(0,ht.jsx)("button",{"aria-label":t.promptInput.removeAttachment,className:q("ww:shrink-0 ww:rounded-full ww:p-1 ww:opacity-60 ww:transition-opacity hover:ww:bg-muted hover:ww:opacity-100",n?null:"ww:ml-auto"),onClick:()=>a.remove(e.id),type:"button",children:(0,ht.jsx)(Ga,{className:"ww:size-3.5"})}),r?(0,ht.jsx)("span",{"aria-hidden":!0,className:"ww:absolute ww:bottom-0 ww:left-0 ww:h-0.5 ww:bg-primary ww:transition-[width] ww:duration-200",style:{width:`${Math.round(e.progress*100)}%`}}):null]})}var bk=({enabled:e=!0})=>{let{t}=Ie(),[a,n]=(0,Ce.useState)(!1);return(0,Ce.useEffect)(()=>{if(!e)return;let r=0,o=u=>!!u.dataTransfer?.types?.includes("Files"),i=u=>{o(u)&&(r+=1,n(!0))},l=u=>{o(u)&&(r=Math.max(0,r-1),r===0&&n(!1))},s=()=>{r=0,n(!1)};return document.addEventListener("dragenter",i),document.addEventListener("dragleave",l),document.addEventListener("drop",s),()=>{document.removeEventListener("dragenter",i),document.removeEventListener("dragleave",l),document.removeEventListener("drop",s)}},[e]),e&&a?(0,ht.jsx)("div",{className:"ww:pointer-events-none ww:absolute ww:inset-0 ww:z-50 ww:flex ww:items-center ww:justify-center ww:rounded-2xl ww:border-2 ww:border-primary ww:border-dashed ww:bg-background/85",children:(0,ht.jsxs)("span",{className:"ww:flex ww:items-center ww:gap-2 ww:text-sm ww:font-medium",children:[(0,ht.jsx)(ul,{className:"ww:size-4"}),t.promptInput.dropToAttach]})}):null};var Ik=z(ae(),1);function Sk({text:e}){let{t}=Ie();return e===!1?null:(0,Ik.jsx)("span",{className:"ww:whitespace-nowrap ww:text-[10px] ww:sm:text-[11px] ww:text-muted-foreground ww:opacity-70",children:e||t.aiDisclaimer.default})}var lf=z(he(),1);var Ho=z(ae(),1),Ck=({className:e,...t})=>(0,Ho.jsx)("div",{className:q("ww:flex ww:flex-col ww:gap-1 ww:px-3 ww:py-2",e),...t}),kk=({className:e,...t})=>(0,Ho.jsx)("li",{className:q("ww:group ww:flex ww:items-center ww:gap-2 ww:rounded-md ww:px-2 ww:py-1 ww:text-sm ww:transition-colors ww:hover:bg-muted",e),...t}),Tk=({className:e,...t})=>(0,Ho.jsx)("span",{className:q("ww:inline-block ww:size-2 ww:shrink-0 ww:rounded-full ww:border ww:border-muted-foreground/50",e),...t}),Lk=({className:e,...t})=>(0,Ho.jsx)("span",{className:q("ww:line-clamp-1 ww:grow ww:break-words ww:text-muted-foreground",e),...t}),Ek=({className:e,...t})=>(0,Ho.jsx)("div",{className:q("ww:flex ww:shrink-0 ww:gap-1 ww:opacity-0 ww:transition-opacity ww:group-hover:opacity-100",e),...t}),Mk=({className:e,...t})=>(0,Ho.jsx)(Bn,{className:q("ww:size-auto ww:rounded ww:p-1 ww:text-muted-foreground ww:hover:bg-muted-foreground/10 ww:hover:text-foreground",e),size:"icon",type:"button",variant:"ghost",...t});var sn=z(ae(),1),Ak=(0,lf.memo)(({message:e,onRemove:t})=>{let{t:a}=Ie(),n=(0,lf.useCallback)(()=>t(e.id),[t,e.id]);return(0,sn.jsxs)(kk,{children:[(0,sn.jsx)(Tk,{}),(0,sn.jsx)(Lk,{children:e.text||a.chatQueue.attachmentFallback}),(0,sn.jsx)(Ek,{children:(0,sn.jsx)(Mk,{"aria-label":a.chatQueue.removeFromQueue,onClick:n,children:(0,sn.jsx)(Ga,{className:"ww:size-3"})})})]})});Ak.displayName="ChatQueueItem";function Rk({queuedMessages:e,onRemove:t,className:a}){let{t:n}=Ie();return e.length===0?null:(0,sn.jsxs)(Ck,{className:q("ww:border-t ww:border-border",a),children:[(0,sn.jsx)("div",{className:"ww:text-[11px] ww:font-medium ww:text-muted-foreground ww:px-2",children:n.chatQueue.queued(e.length)}),(0,sn.jsx)("ul",{children:e.map(r=>(0,sn.jsx)(Ak,{message:r,onRemove:t},r.id))})]})}var _a=z(he(),1);var St=z(he(),1);dp();var u2=z(he(),1);var c2=z(ae(),1),V6=({as:e="span",className:t,duration:a=2,style:n,children:r,...o})=>{let i={backgroundImage:"linear-gradient(90deg, var(--ww-color-muted-foreground) 0%, var(--ww-color-muted-foreground) 40%, var(--ww-color-foreground) 50%, var(--ww-color-muted-foreground) 60%, var(--ww-color-muted-foreground) 100%)",backgroundSize:"250% 100%",WebkitBackgroundClip:"text",backgroundClip:"text",color:"transparent",animation:`ww-shimmer ${a}s linear infinite`,...n};return(0,c2.jsx)(e,{"data-waniwani-shimmer":"",className:q("ww:inline-block",t),style:i,...o,children:r})},Tn=(0,u2.memo)(V6);Tn.displayName="Shimmer";var ua=z(ae(),1),d2=(0,St.createContext)(null);function f2(){let e=(0,St.useContext)(d2);if(!e)throw new Error("Reasoning components must be used within <Reasoning>");return e}var W6=1e3,G6=1e3,Uu=(0,St.memo)(({className:e,isStreaming:t=!1,open:a,defaultOpen:n,onOpenChange:r,duration:o,children:i,...l})=>{let s=n??t,u=n===!1,c=a!==void 0,[d,f]=(0,St.useState)(s),p=c?a:d,m=(0,St.useCallback)(M=>{c||f(M),r?.(M)},[c,r]),[x,S]=(0,St.useState)(void 0),w=o??x,y=(0,St.useRef)(t),[h,b]=(0,St.useState)(!1),T=(0,St.useRef)(null);(0,St.useEffect)(()=>{t?(y.current=!0,T.current===null&&(T.current=Date.now())):T.current!==null&&(S(Math.ceil((Date.now()-T.current)/G6)),T.current=null)},[t]),(0,St.useEffect)(()=>{t&&!p&&!u&&m(!0)},[t,p,u,m]),(0,St.useEffect)(()=>{if(y.current&&!t&&p&&!h){let M=setTimeout(()=>{m(!1),b(!0)},W6);return()=>clearTimeout(M)}},[t,p,h,m]);let C=(0,St.useMemo)(()=>({isStreaming:t,isOpen:p,setIsOpen:m,duration:w}),[t,p,m,w]);return(0,ua.jsx)(d2.Provider,{value:C,children:(0,ua.jsx)("div",{className:q("ww:mb-4 ww:flex ww:flex-col ww:gap-2",e),"data-state":p?"open":"closed",style:{animation:"ww-fade-in 0.2s ease-out"},...l,children:i})})});Uu.displayName="Reasoning";var Fu=(0,St.memo)(({className:e,children:t,getThinkingMessage:a,hideIcon:n=!1,onClick:r,...o})=>{let{t:i}=Ie(),{isStreaming:l,isOpen:s,duration:u,setIsOpen:c}=f2(),f=a??((p,m)=>p||m===0?(0,ua.jsx)(Tn,{duration:1.6,children:i.reasoning.thinking}):m===void 0?(0,ua.jsx)("span",{children:i.reasoning.thoughtBrief}):(0,ua.jsx)("span",{children:i.reasoning.thoughtForSeconds(m)}));return(0,ua.jsx)("button",{type:"button","aria-expanded":s,onClick:p=>{c(!s),r?.(p)},className:q("ww:flex ww:w-full ww:items-center ww:gap-2 ww:text-sm ww:text-muted-foreground ww:transition-colors ww:hover:text-foreground",e),...o,children:t??(0,ua.jsxs)(ua.Fragment,{children:[!n&&(0,ua.jsx)(fr,{className:"ww:size-4 ww:shrink-0"}),f(l,u)]})})});Fu.displayName="ReasoningTrigger";var zu=(0,St.memo)(({className:e,children:t,...a})=>{let{isOpen:n}=f2();return(0,ua.jsx)("div",{className:q("ww:grid ww:transition-[grid-template-rows,opacity] ww:duration-200 ww:ease-out",n?"ww:grid-rows-[1fr] ww:opacity-100":"ww:grid-rows-[0fr] ww:opacity-0"),children:(0,ua.jsx)("div",{className:"ww:min-h-0 ww:overflow-hidden",children:(0,ua.jsx)("div",{className:q("ww:text-sm ww:text-muted-foreground",e),...a,children:(0,ua.jsx)(El,{children:t})})})})});zu.displayName="ReasoningContent";var Ne=z(ae(),1),$6=500,p2=(0,_a.createContext)(null);function m2(){let e=(0,_a.useContext)(p2);if(!e)throw new Error("ChainOfThought components must be used within <ChainOfThought>");return e}function h2({className:e,isWorking:t=!1,activeStep:a,open:n,defaultOpen:r=!1,onOpenChange:o,children:i,...l}){let s=n!==void 0,[u,c]=(0,_a.useState)(r),d=s?n:u,f=(0,_a.useCallback)(S=>{s||c(S),o?.(S)},[s,o]),[p,m]=(0,_a.useState)(!t);(0,_a.useEffect)(()=>{if(t){m(!1);return}let S=setTimeout(()=>m(!0),$6);return()=>clearTimeout(S)},[t]);let x=(0,_a.useMemo)(()=>({open:d,setOpen:f,isWorking:t,settled:p,activeStep:a}),[d,f,t,p,a]);return(0,Ne.jsx)(p2.Provider,{value:x,children:(0,Ne.jsx)("div",{className:q("ww:mb-4 ww:flex ww:flex-col ww:gap-2",e),"data-state":d?"open":"closed",style:{animation:"ww-fade-in 0.2s ease-out"},...l,children:i})})}function g2({className:e,label:t,workingLabel:a,children:n,...r}){let{open:o,setOpen:i,isWorking:l,settled:s,activeStep:u}=m2();if(!s){let c=u?.icon,d=u?.label??a??t??"";return(0,Ne.jsx)("div",{className:q("ww:flex ww:min-h-5 ww:w-full ww:items-center ww:gap-1.5 ww:text-sm ww:text-muted-foreground",e),children:(0,Ne.jsxs)("span",{className:"ww:flex ww:min-w-0 ww:items-center ww:gap-1.5",style:{animation:"ww-fade-in 0.25s ease-out"},children:[c&&(0,Ne.jsx)(c,{className:q("ww:size-4 ww:shrink-0",l&&"ww:animate-pulse")}),(0,Ne.jsx)("span",{className:"ww:truncate",children:l?(0,Ne.jsx)(Tn,{duration:2.6,children:d}):d})]},d)})}return(0,Ne.jsxs)("button",{type:"button",onClick:()=>i(!o),"aria-expanded":o,className:q("ww:flex ww:min-h-5 ww:w-full ww:items-center ww:gap-1.5 ww:text-sm ww:text-muted-foreground ww:transition-colors ww:hover:text-foreground",e),style:{animation:"ww-fade-in 0.25s ease-out"},...r,children:[(0,Ne.jsx)("span",{className:"ww:truncate",children:n??t}),(0,Ne.jsx)(Qr,{className:q("ww:size-4 ww:shrink-0 ww:transition-transform ww:duration-200",o&&"ww:rotate-180")})]})}function w2({className:e,children:t,...a}){let{open:n}=m2();return(0,Ne.jsx)("div",{className:q("ww:grid ww:transition-[grid-template-rows,opacity] ww:duration-200 ww:ease-out",n?"ww:grid-rows-[1fr] ww:opacity-100":"ww:grid-rows-[0fr] ww:opacity-0"),children:(0,Ne.jsx)("div",{className:"ww:min-h-0 ww:overflow-hidden",children:(0,Ne.jsx)("div",{className:q("ww:flex ww:flex-col",e),...a,children:t})})})}function y2({icon:e,isLast:t,running:a,error:n}){return(0,Ne.jsxs)("div",{className:"ww:flex ww:flex-col ww:items-center ww:self-stretch",children:[(0,Ne.jsx)("span",{className:"ww:flex ww:h-5 ww:items-center",children:(0,Ne.jsx)(e,{className:q("ww:size-4 ww:shrink-0",n?"ww:text-destructive":a?"ww:animate-pulse ww:text-foreground":"ww:text-muted-foreground")})}),!t&&(0,Ne.jsx)("span",{className:"ww:w-px ww:flex-1 ww:bg-border"})]})}function Rx({className:e,icon:t,title:a,state:n,isLast:r=!1,children:o,...i}){let l=n==="input-available"||n==="input-streaming",s=n==="output-error",u=o!=null,[c,d]=(0,_a.useState)(!1),f=a??"",p=l?(0,Ne.jsx)(Tn,{duration:1.6,children:f}):(0,Ne.jsx)("span",{className:"ww:truncate",children:f});return(0,Ne.jsxs)("div",{className:q("ww:flex ww:gap-2",e),...i,children:[(0,Ne.jsx)(y2,{icon:t,isLast:r,running:l,error:s}),(0,Ne.jsxs)("div",{className:q("ww:min-w-0 ww:flex-1",!r&&"ww:pb-3"),children:[u?(0,Ne.jsxs)("button",{type:"button",onClick:()=>d(m=>!m),"aria-expanded":c,className:"ww:flex ww:w-full ww:items-center ww:gap-1.5 ww:text-left ww:text-sm ww:text-muted-foreground ww:transition-colors ww:hover:text-foreground",children:[p,(0,Ne.jsx)(Qr,{className:q("ww:size-3.5 ww:shrink-0 ww:transition-transform ww:duration-200",c&&"ww:rotate-180")})]}):(0,Ne.jsx)("div",{className:"ww:flex ww:items-center ww:text-sm ww:text-muted-foreground",children:p}),u&&(0,Ne.jsx)("div",{className:q("ww:grid ww:transition-[grid-template-rows,opacity] ww:duration-200 ww:ease-out",c?"ww:grid-rows-[1fr] ww:opacity-100":"ww:grid-rows-[0fr] ww:opacity-0"),children:(0,Ne.jsx)("div",{className:"ww:min-h-0 ww:overflow-hidden",children:(0,Ne.jsx)("div",{className:"ww:mt-2 ww:space-y-3 ww:rounded-lg ww:border ww:border-border ww:bg-background ww:p-3",children:o})})})]})]})}function x2({isStreaming:e=!1,isLast:t=!1,children:a}){return(0,Ne.jsxs)("div",{className:"ww:flex ww:gap-2",children:[(0,Ne.jsx)(y2,{icon:fr,isLast:t,running:e}),(0,Ne.jsx)("div",{className:q("ww:min-w-0 ww:flex-1",!t&&"ww:pb-3"),children:(0,Ne.jsxs)(Uu,{isStreaming:e,className:"ww:mb-0",children:[(0,Ne.jsx)(Fu,{hideIcon:!0}),(0,Ne.jsx)(zu,{children:a})]})})]})}var Dx={name:"cjk-noop",type:"cjk",remarkPluginsBefore:[],remarkPluginsAfter:[],remarkPlugins:[]};var v2={name:"shiki-noop",type:"code-highlighter",supportsLanguage:()=>!1,getSupportedLanguages:()=>[],getThemes:()=>["github-light","github-dark"],highlight:()=>null};var I2=z(he(),1);var vr=z(he(),1),X6=5,b2=400;function S2(e,t,a={}){let{msPerChar:n=X6}=a,[r,o]=(0,vr.useState)(t?"":e),i=(0,vr.useRef)(e),l=(0,vr.useRef)(t?0:e.length),s=(0,vr.useRef)(0),u=(0,vr.useRef)(null);return(e.length<l.current||!e.startsWith(r.slice(0,l.current)))&&(l.current=t?0:e.length),i.current=e,(0,vr.useEffect)(()=>{if(!t){u.current!==null&&(cancelAnimationFrame(u.current),u.current=null),l.current=e.length,o(e);return}if(i.current.length-l.current>b2&&(l.current=i.current.length-b2),u.current!==null)return;let d=f=>{let p=i.current;if(l.current>=p.length){u.current=null;return}s.current===0&&(s.current=f);let m=f-s.current;if(m>=n){let x=Math.min(Math.floor(m/n),p.length-l.current);l.current+=x,o(p.slice(0,l.current)),s.current=f}u.current=requestAnimationFrame(d)};return u.current=requestAnimationFrame(d),()=>{u.current!==null&&(cancelAnimationFrame(u.current),u.current=null)}},[e,t,n]),r}var qu=z(ae(),1),_x=({className:e,from:t,children:a,...n})=>(0,qu.jsx)("div",{className:q("ww-message ww:group ww:flex ww:w-full",t==="user"?"ww-message-user is-user ww:ml-auto ww:flex-col ww:items-end ww:[max-width:var(--ww-msg-max-width,80%)]":"ww-message-assistant is-assistant ww:flex-col",e),...n,children:(0,qu.jsx)("div",{className:q("ww:flex ww:min-w-0 ww:flex-col ww:gap-2","ww:w-full"),children:a})}),Ox=({children:e,className:t,...a})=>(0,qu.jsx)("div",{className:q("ww-bubble ww:flex ww:w-fit ww:min-w-0 ww:max-w-full ww:flex-col ww:gap-2 ww:overflow-hidden","ww:[font-size:var(--ww-font-size,1rem)] ww:[line-height:var(--ww-line-height,1.5)]","ww:group-[.is-user]:ml-auto ww:group-[.is-user]:bg-user-bubble ww:group-[.is-user]:[color:var(--ww-color-user-bubble-text)] ww:group-[.is-user]:[border-radius:var(--ww-msg-radius,8px)] ww:group-[.is-user]:[padding:var(--ww-msg-pad-y,12px)_var(--ww-msg-pad-x,16px)]","ww:group-[.is-assistant]:text-foreground",t),...a,children:e}),K6={cjk:Dx,code:v2},Y6={cjk:Dx},Z6={enabled:!1};function Q6({className:e,linkSafety:t,isStreaming:a,children:n,...r}){let i=S2(typeof n=="string"?n:"",!!a),l=typeof n=="string"?i:n;return(0,qu.jsx)(El,{className:q("ww:size-full ww:[&>*:first-child]:mt-0 ww:[&>*:last-child]:mb-0",e),linkSafety:t??Z6,plugins:a?Y6:K6,...r,children:l})}var gp=(0,I2.memo)(Q6,(e,t)=>e.children===t.children&&e.isStreaming===t.isStreaming);gp.displayName="MessageResponse";var Vt=z(he(),1);function Px(e){if(!(typeof e!="object"||e===null))return e}function C2(e){return Px(e?.ui)}function Nx(e){if(!e)return;let t=C2(e)?.resourceUri;if(typeof t=="string"&&t.length>0)return t;let a=e["ui/resourceUri"];if(typeof a=="string"&&a.length>0)return a;let n=e["openai/outputTemplate"];if(typeof n=="string"&&n.length>0)return n}function Hu(e){return C2(e)?.autoHeight===!0}function Bx(e){return Px(Px(e)?._meta)}var Te=z(ae(),1);function J6(e,t=80){if(e==null)return String(e);if(typeof e!="object")return String(e).slice(0,t);if(Array.isArray(e))return`Array(${e.length})`;let a=JSON.stringify(e);if(a.length<=t)return a;let n=Object.entries(e),r=[],o=t-2;for(let[i,l]of n){if(o<=8)break;let s=i.length>4?`${i.slice(0,4)}\u2026`:i,u;typeof l=="string"?u=l.length>2?`'${l.slice(0,1)}\u2026`:`'${l}'`:Array.isArray(l)?u=`Array(${l.length})`:typeof l=="object"&&l!==null?u="{\u2026}":u=String(l);let c=`${s}\u2009${u}`;r.push(c),o-=c.length+3}return`{${r.join(", ")}}`}function e9({text:e,className:t}){let{t:a}=Ie(),[n,r]=(0,Vt.useState)(!1),o=(0,Vt.useRef)(null);(0,Vt.useEffect)(()=>()=>{o.current&&clearTimeout(o.current)},[]);let i=(0,Vt.useCallback)(async l=>{l.stopPropagation();try{await navigator.clipboard.writeText(e),r(!0),o.current&&clearTimeout(o.current),o.current=setTimeout(()=>r(!1),2e3)}catch{}},[e]);return(0,Te.jsx)(Bn,{variant:"ghost",size:"sm",onClick:i,className:q("ww:h-auto ww:gap-1 ww:px-1.5 ww:py-0.5 ww:text-xs ww:text-muted-foreground ww:hover:text-foreground",t),children:n?(0,Te.jsxs)(Te.Fragment,{children:[(0,Te.jsx)(Js,{className:"ww:size-3.5"}),(0,Te.jsx)("span",{children:a.tool.copied})]}):(0,Te.jsxs)(Te.Fragment,{children:[(0,Te.jsx)(tu,{className:"ww:size-3.5"}),(0,Te.jsx)("span",{children:a.tool.copy})]})})}function k2({data:e,label:t,className:a,...n}){let[r,o]=(0,Vt.useState)(!1),i=(0,Vt.useMemo)(()=>JSON.stringify(e,null,2),[e]),l=J6(e);return(0,Te.jsxs)("div",{className:q("ww:rounded-lg ww:bg-tool-card",a),...n,children:[(0,Te.jsxs)("div",{className:"ww:flex ww:items-center ww:justify-between ww:px-3 ww:pt-2.5 ww:pb-1.5",children:[(0,Te.jsx)("span",{className:"ww:text-xs ww:font-medium ww:text-muted-foreground",children:t}),(0,Te.jsx)(e9,{text:i})]}),(0,Te.jsxs)("button",{type:"button",onClick:()=>o(s=>!s),className:"ww:flex ww:w-full ww:items-start ww:gap-2 ww:px-3 ww:pb-3 ww:text-left",children:[(0,Te.jsx)(eu,{className:q("ww:mt-0.5 ww:size-3.5 ww:shrink-0 ww:text-muted-foreground ww:transition-transform ww:duration-150",r&&"ww:rotate-90")}),r?(0,Te.jsx)("pre",{className:"ww:overflow-x-auto ww:text-xs ww:font-mono ww:text-foreground ww:whitespace-pre-wrap ww:break-all",children:(0,Te.jsx)("code",{children:i})}):(0,Te.jsx)("span",{className:"ww:truncate ww:text-xs ww:font-mono ww:text-foreground/80",children:l})]})]})}var Ux=(0,Vt.createContext)({open:!1,toggle:()=>{}});function T2({className:e,defaultOpen:t=!1,children:a,...n}){let[r,o]=(0,Vt.useState)(t);return(0,Te.jsx)(Ux.Provider,{value:{open:r,toggle:()=>o(i=>!i)},children:(0,Te.jsx)("div",{className:q("ww:mb-4 ww:w-full",e),"data-state":r?"open":"closed",style:{animation:"ww-fade-in 0.2s ease-out"},...n,children:a})})}function L2({className:e,title:t,state:a,...n}){let{open:r,toggle:o}=(0,Vt.useContext)(Ux),i=a==="input-available"||a==="input-streaming",l=t??"";return(0,Te.jsxs)("button",{type:"button",onClick:o,className:q("ww:flex ww:w-full ww:items-center ww:gap-2 ww:text-sm ww:text-muted-foreground ww:transition-colors ww:hover:text-foreground",e),"aria-expanded":r,...n,children:[(0,Te.jsx)(Fo,{className:"ww:size-4 ww:shrink-0"}),(0,Te.jsx)("span",{className:"ww:truncate",children:i?(0,Te.jsx)(Tn,{duration:1.6,children:l}):l}),(0,Te.jsx)(Qr,{className:q("ww:size-4 ww:shrink-0 ww:transition-transform ww:duration-200",r&&"ww:rotate-180")})]})}function E2({className:e,title:t,state:a,...n}){let r=a==="input-available"||a==="input-streaming",o=t??"";return(0,Te.jsx)("div",{className:q("ww:mb-4 ww:flex ww:items-center ww:gap-2 ww:text-sm ww:text-muted-foreground",e),style:{animation:"ww-fade-in 0.2s ease-out"},...n,children:(0,Te.jsx)("span",{className:"ww:truncate",children:r?(0,Te.jsx)(Tn,{duration:1.6,children:o}):o})})}function M2({className:e,children:t,...a}){let{open:n}=(0,Vt.useContext)(Ux);return(0,Te.jsx)("div",{className:q("ww:grid ww:transition-[grid-template-rows,opacity] ww:duration-200 ww:ease-out",n?"ww:grid-rows-[1fr] ww:opacity-100":"ww:grid-rows-[0fr] ww:opacity-0"),children:(0,Te.jsx)("div",{className:"ww:min-h-0 ww:overflow-hidden",children:(0,Te.jsx)("div",{className:q("ww:mt-2 ww:space-y-3 ww:rounded-lg ww:border ww:border-border ww:bg-background ww:p-3",e),...a,children:t})})})}function Fx({className:e,input:t,debug:a,...n}){let{t:r}=Ie(),o=(0,Vt.useMemo)(()=>{if(!a&&typeof t=="object"&&t!==null&&!Array.isArray(t)){let{_meta:i,...l}=t;return l}return t},[t,a]);return(0,Te.jsx)(k2,{data:o,label:r.tool.request,className:e,...n})}function ju(e,t,a){if(e){let n=Nx(a?.[e]?._meta);if(n)return n}return Nx(Bx(t))}function A2(e,t,a){return e&&Hu(a?.[e]?._meta)?!0:Hu(Bx(t))}function zx({className:e,output:t,errorText:a,debug:n,...r}){let{t:o}=Ie(),i=(0,Vt.useMemo)(()=>{if(!n&&typeof t=="object"&&t!==null&&!Array.isArray(t)){let{_meta:l,...s}=t;return s}return t},[t,n]);return t||a?a?(0,Te.jsxs)("div",{className:q("ww:space-y-2",e),...r,children:[(0,Te.jsx)("h4",{className:"ww:text-xs ww:font-medium ww:uppercase ww:tracking-wide ww:text-muted-foreground",children:o.tool.error}),(0,Te.jsx)("div",{className:"ww:rounded-lg ww:bg-destructive/10 ww:p-3 ww:text-xs ww:text-destructive",children:a})]}):(0,Te.jsx)(k2,{data:i,label:o.tool.response,className:e,...r}):null}var Vu=z(ae(),1);function R2(e){return e.type==="text"||e.type==="reasoning"||e.type==="file"||"toolCallId"in e}function D2(e){return e.parts.some(R2)}function _2(e,t,a){if(t!=="submitted"&&t!=="streaming")return!1;let n=e[e.length-1];return!n||n.role!=="assistant"?!0:!n.parts.some(o=>!(!R2(o)||a?.ignoreToolParts&&"toolCallId"in o||a?.ignoreReasoningParts&&o.type==="reasoning"))}function O2({className:e,...t}){let{t:a}=Ie();return(0,Vu.jsxs)("div",{"aria-live":"polite",className:q("ww:mb-4 ww:flex ww:w-full ww:items-center ww:gap-2 ww:text-sm ww:text-muted-foreground",e),style:{animation:"ww-fade-in 0.2s ease-out"},...t,children:[(0,Vu.jsx)(lu,{className:"ww:size-4 ww:shrink-0"}),(0,Vu.jsx)(Tn,{duration:1.6,children:a.workingIndicator.default})]})}var Qe=z(he(),1);function li(e){if(!e)return!1;let t=Array.isArray(e.content)&&e.content.length>0,a=typeof e.structuredContent=="object"&&e.structuredContent!==null&&Object.keys(e.structuredContent).length>0;return t||a}function P2(e,t){return!li(e)&&!li(t)?null:li(e)?li(t)?{...e.content||t.content?{content:[...e.content??[],...t.content??[]]}:{},...e.structuredContent||t.structuredContent?{structuredContent:{...e.structuredContent??{},...t.structuredContent??{}}}:{}}:{...e.content?{content:[...e.content]}:{},...e.structuredContent?{structuredContent:{...e.structuredContent}}:{}}:{...t?.content?{content:[...t.content]}:{},...t?.structuredContent?{structuredContent:{...t.structuredContent}}:{}}}var br=z(he(),1);var N2=(0,br.createContext)(()=>{});function B2(){return(0,br.useContext)(N2)}var U2=N2.Provider;function t9(e){let t=window.requestIdleCallback;typeof t=="function"?t(e):setTimeout(e,500)}function Ml(e){let t=(0,br.useRef)(e);t.current=e;let a=(0,br.useRef)(!1);(0,br.useEffect)(()=>{if(!e.painted||a.current)return;a.current=!0;let n=requestAnimationFrame(()=>{let r=t.current;Uo(r.paintMark),t9(()=>RC(r))});return()=>cancelAnimationFrame(n)},[e.painted])}var F2=z(ae(),1),a9="/api/mcp/resource",n9=500,r9=0,o9=16,i9="2026-01-26",l9=300,s9=3e3,u9=3,c9=2e3;function d9(e){if(typeof e!="string")return;let t=e.trim();return t.length>0?t:void 0}function f9(e,t,a){return ju(e,t,a)?!1:t._meta?.["waniwani/autoInjectResultText"]!==!1}function wp({resourceUri:e,toolInput:t,toolResult:a,resourceEndpoint:n=a9,chatSessionId:r,isDark:o=!1,className:i,autoHeight:l=!1,onOpenLink:s,onFollowUp:u,onCallTool:c,onDisplayModeChange:d,isFullscreen:f=!1,toolDefinitions:p}){let m=(0,Qe.useRef)(null),x=(0,Qe.useRef)(t),S=(0,Qe.useRef)(a),w=(0,Qe.useRef)({width:0,height:0}),y=(0,Qe.useRef)(null),h=(0,Qe.useRef)(!1),b=(0,Qe.useRef)(0),T=(0,Qe.useRef)("inline"),[C,M]=(0,Qe.useState)(r9),[D,P]=(0,Qe.useState)(void 0),L=(0,Qe.useRef)(s),$=(0,Qe.useRef)(u),H=(0,Qe.useRef)(c),F=(0,Qe.useRef)(d),W=(0,Qe.useRef)(r),V=(0,Qe.useRef)(p);x.current=t,S.current=a,L.current=s,$.current=u,H.current=c,F.current=d,W.current=r,V.current=p;let N=(0,Qe.useCallback)(v=>l?Math.max(v+o9,0):Math.min(Math.max(v,50),n9),[l]),R=(0,Qe.useMemo)(()=>{let v=n.includes("?")?"&":"?";return`${n}${v}uri=${encodeURIComponent(e)}`},[n,e]),G=B2(),ue=(0,Qe.useRef)(null),I=(0,Qe.useRef)(void 0);(0,Qe.useEffect)(()=>{let v=_C(e,G);return ue.current=v,()=>{clearTimeout(I.current),v.has("initialized")||v.report("timeout",b.current),ue.current=null}},[e,G]);let We=(0,Qe.useRef)(o);We.current=o;let Je=(0,Qe.useRef)(f);return(0,Qe.useEffect)(()=>{Je.current=f,w.current.height=-1,y.current&&(y.current.cancel(),y.current=null)},[f]),(0,Qe.useEffect)(()=>{if(!h.current)return;let v=m.current;v?.contentWindow&&v.contentWindow.postMessage({jsonrpc:"2.0",method:"ui/notifications/host-context-changed",params:{theme:o?"dark":"light"}},"*")},[o]),(0,Qe.useEffect)(()=>{let v=m.current;if(!v)return;let K=!1,ee=!1,we=null,Ge=null,me=setTimeout(()=>{if(K||ee||b.current>=u9)return;b.current+=1;let de=new URL(v.src);de.searchParams.set("_retry",String(b.current)),v.src=de.toString()},s9),ye=de=>{v.contentWindow?.postMessage(de,"*")},le=de=>{if(K||de.source!==v.contentWindow)return;let Q=de.data;if(!Q||typeof Q!="object"||Q.jsonrpc!=="2.0")return;let Be=Q.method,qe=Q.id;if(Be==="ui/initialize"&&qe!=null){ee=!0,ue.current?.mark("initialize"),clearTimeout(me),ye({jsonrpc:"2.0",id:qe,result:{protocolVersion:Q.params?.protocolVersion??i9,hostInfo:{name:"Waniwani Chat",version:"1.0.0"},hostCapabilities:{openLinks:{},message:{text:{}},tools:{},updateModelContext:{text:{},structuredContent:{}}},hostContext:{theme:We.current?"dark":"light",displayMode:T.current}}});return}if(Be==="ui/notifications/initialized"){h.current=!0,ue.current?.mark("initialized"),I.current=setTimeout(()=>ue.current?.report("ok",b.current),c9);let _e=x.current,ke=S.current,xe=ke._meta&&typeof ke._meta=="object"?ke._meta:null,Y=d9(W.current),Oe=xe&&typeof xe.waniwani=="object"&&xe.waniwani!==null?xe.waniwani:null,rt=Oe||Y?{...Oe??{},...Y?{sessionId:Y}:{}}:void 0,ba=xe||rt?{...xe??{},...rt?{waniwani:rt}:{}}:void 0;ye({jsonrpc:"2.0",method:"ui/notifications/tool-input",params:{arguments:_e}});let Sa=ke.content??[{type:"text",text:JSON.stringify(ke)}];ye({jsonrpc:"2.0",method:"ui/notifications/tool-result",params:{content:Sa,structuredContent:ke.structuredContent,_meta:ba,meta:ba}});return}if(Be==="ui/notifications/size-changed"){clearTimeout(I.current),ue.current?.mark("firstSize"),ue.current?.report("ok",b.current);let _e=Q.params,ke=typeof _e?.height=="number"?_e.height:void 0,xe=typeof _e?.width=="number"?_e.width:void 0,Y=w.current,Oe=ke!==void 0&&ke!==Y.height,rt=xe!==void 0&&xe!==Y.width;if(!Oe&&!rt)return;if(Oe&&ke!==void 0){if(Y.height=ke,Je.current)return;let ba=N(ke),Sa=v.getBoundingClientRect().height;if(y.current&&(y.current.cancel(),y.current=null),M(ba),v.animate&&Math.abs(Sa-ba)>2){let ra=v.animate([{height:`${Sa}px`},{height:`${ba}px`}],{duration:l9,easing:"ease-out",fill:"forwards"});y.current=ra,ra.onfinish=()=>{y.current===ra&&(ra.cancel(),y.current=null)}}}rt&&l&&xe!==void 0&&(Y.width=xe,P(xe));return}if(Be==="ui/open-link"&&qe!=null){let _e=Q.params?.url;typeof _e=="string"&&(L.current?L.current(_e):window.open(_e,"_blank","noopener,noreferrer")),ye({jsonrpc:"2.0",id:qe,result:{}});return}if(Be==="ui/message"&&qe!=null){if($.current&&Q.params){let _e=Q.params,ke=we;if(we=null,Ge){clearTimeout(Ge.timer);let xe=Ge.text;Ge=null;let Y=(_e.content??[]).map(Oe=>Oe.text??"").join("").trim();_e={..._e,content:[{type:"text",text:`${Y}
|
|
122
122
|
|
|
123
123
|
${xe}`}]}}$.current({..._e,...ke?{modelContext:ke}:{}})}ye({jsonrpc:"2.0",id:qe,result:{}});return}if(Be==="ui/update-model-context"&&qe!=null){we=P2(we,Q.params),ye({jsonrpc:"2.0",id:qe,result:{}});return}if(Be==="tools/call"&&qe!=null){let _e=H.current;if(!_e){ye({jsonrpc:"2.0",id:qe,error:{code:-32601,message:"tools/call not supported"}});return}let ke=Q.params?.name;_e({name:ke,arguments:Q.params?.arguments??{}}).then(xe=>{ye({jsonrpc:"2.0",id:qe,result:xe});let Y=xe.content?.map(Oe=>Oe.text??"").join("").trim();Y&&f9(ke,xe,V.current)&&(Ge&&clearTimeout(Ge.timer),Ge={text:Y,timer:setTimeout(()=>{if(K)return;let Oe=we;we=null,Ge=null,$.current?.({role:"user",content:[{type:"text",text:Y}],...Oe?{modelContext:Oe}:{}})},500)})}).catch(xe=>{let Y=xe instanceof Error?xe.message:"Tool call failed";ye({jsonrpc:"2.0",id:qe,error:{code:-32e3,message:Y}})});return}if(Be==="ui/request-display-mode"&&qe!=null){let _e=Q.params?.mode,ke=_e==="fullscreen"||_e==="inline"||_e==="pip"?_e:"inline";T.current=ke,ye({jsonrpc:"2.0",id:qe,result:{mode:ke}}),ye({jsonrpc:"2.0",method:"ui/notifications/host-context-changed",params:{displayMode:ke}}),F.current?.(ke);return}if(Be==="ui/resource-teardown"&&qe!=null){ye({jsonrpc:"2.0",id:qe,result:{}});return}Be==="ping"&&qe!=null&&ye({jsonrpc:"2.0",id:qe,result:{}})};return window.addEventListener("message",le),()=>{K=!0,clearTimeout(me),Ge&&clearTimeout(Ge.timer),window.removeEventListener("message",le)}},[l,N]),(0,F2.jsx)("iframe",{ref:m,src:R,onLoad:()=>ue.current?.mark("iframeLoad"),sandbox:"allow-scripts allow-forms allow-same-origin allow-popups allow-popups-to-escape-sandbox",className:q(!f&&"ww:rounded-md ww:border ww:border-border",i),style:{height:f?"100%":C,minWidth:f||!D?void 0:`min(${D}px, 100%)`,width:"100%",border:"none",colorScheme:o?"dark":"auto"},title:"MCP App"})}var uo=z(ae(),1);function z2({icon:e,title:t,description:a,suggestions:n,onSuggestionSelect:r}){return(0,uo.jsxs)("div",{className:"ww:flex ww:flex-col ww:items-center ww:justify-center ww:py-12 ww:px-6 ww:text-center ww:min-h-full",children:[e&&(0,uo.jsx)("div",{className:"ww:mb-4 ww:flex ww:items-center ww:justify-center ww:size-12 ww:rounded-xl ww:bg-foreground ww:text-background",children:e}),(0,uo.jsx)("h2",{className:"ww:text-lg ww:font-semibold ww:text-foreground",children:t}),a&&(0,uo.jsx)("p",{className:"ww:mt-1 ww:text-sm ww:text-muted-foreground ww:max-w-sm",children:a}),n&&n.length>0&&(0,uo.jsx)("div",{className:"ww:mt-6 ww:w-full ww:max-w-md ww:flex ww:flex-col ww:gap-2",children:n.map((o,i)=>(0,uo.jsx)("button",{type:"button",onClick:()=>r?.(o),className:q("ww:w-full ww:text-left ww:rounded-xl ww:border ww:border-border ww:bg-background ww:px-4 ww:py-3 ww:text-sm","ww:text-foreground ww:hover:bg-accent ww:hover:border-primary/30","ww:transition-all ww:duration-200 ww:ease-out ww:cursor-pointer","ww:animate-[ww-fade-in_0.2s_ease-out_both]"),style:{animationDelay:`${i*50}ms`},children:o},o))})]})}var q2=z(he(),1);var Al=z(ae(),1);function p9({onRetry:e}){let{t}=Ie();return(0,Al.jsxs)("div",{className:"ww:flex ww:items-center ww:justify-between ww:rounded-md ww:border ww:border-border ww:bg-muted/50 ww:px-4 ww:py-3 ww:text-sm ww:text-muted-foreground",children:[(0,Al.jsx)("span",{children:t.widgetErrorBoundary.failedToLoad}),(0,Al.jsx)("button",{type:"button",onClick:e,className:"ww:text-xs ww:font-medium ww:text-primary ww:hover:underline",children:t.widgetErrorBoundary.retry})]})}var yp=class extends q2.Component{constructor(){super(...arguments);re(this,"state",{hasError:!1})}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(a){console.warn("[Waniwani] Widget failed to render:",a.message)}render(){return this.state.hasError?(0,Al.jsx)(p9,{onRetry:()=>this.setState({hasError:!1})}):this.props.children}};var Le=z(ae(),1);function qx(e){return e?e.replace(/[-_]/g," ").replace(/^\w/,t=>t.toUpperCase()):"Tool"}function H2(e){return e&&/search|find|lookup|query|web|browse|google/i.test(e)?nu:Fo}function j2({messages:e,status:t,welcomeMessage:a,welcome:n,onSuggestionSelect:r,resourceEndpoint:o,chatSessionId:i,isDark:l,onFollowUp:s,onCallTool:u,onWidgetDisplayModeChange:c,fullscreenToolCallId:d,debug:f,showToolCalls:p=!0,toolDefinitions:m,messageClassNames:x}){let{t:S}=Ie(),w=e[e.length-1],y=e.length>0,h=d!=null,b=!h&&_2(e,t,{ignoreToolParts:p===!1,ignoreReasoningParts:p===!1});return(0,Le.jsxs)(Le.Fragment,{children:[!h&&(!y&&n?(0,Le.jsx)(z2,{...n,onSuggestionSelect:r}):a&&(0,Le.jsx)(_x,{from:"assistant",children:(0,Le.jsx)(Ox,{children:(0,Le.jsx)(gp,{children:a})})})),e.map(T=>{let C=T.parts.filter(N=>N.type==="text"),M=T.parts.filter(N=>N.type==="reasoning"),D=T.parts.filter(N=>N.type==="file"),P=dk(T.metadata),L=T.parts.filter(N=>"toolCallId"in N),$=T.parts.filter(N=>N.type==="reasoning"||"toolCallId"in N),H=T===w&&T.role==="assistant",F=C.length>0,W=h?L.some(N=>N.toolCallId===d):!1,V=p!==!1&&!W&&$.length>=2;return h&&!W?(0,Le.jsx)("div",{style:{display:"none"}},T.id):T.role==="assistant"&&!D2(T)?(0,Le.jsx)("div",{style:{display:"none"}},T.id):p===!1&&T.role==="assistant"&&!F&&D.length===0&&L.every(N=>{let R="output"in N?N.output:void 0;return R===void 0||!o||!ju(N.toolName,R,m)})?(0,Le.jsx)("div",{style:{display:"none"}},T.id):(0,Le.jsxs)(_x,{from:T.role,className:x?.message,children:[p!==!1&&!W&&!V&&M.map((N,R)=>(0,Le.jsxs)(Uu,{isStreaming:N.state==="streaming",children:[(0,Le.jsx)(Fu,{}),(0,Le.jsx)(zu,{children:N.text})]},`reasoning-${T.id}-${R}`)),V&&(()=>{let N=$[$.length-1],R=N.type==="reasoning"?{icon:fr,label:S.reasoning.thinking}:{icon:H2(N.toolName),label:N.title??qx(N.toolName)};return(0,Le.jsxs)(h2,{isWorking:H&&(t==="streaming"||t==="submitted"),activeStep:R,children:[(0,Le.jsx)(g2,{workingLabel:S.chainOfThought.working,label:S.chainOfThought.done}),(0,Le.jsx)(w2,{children:$.map((G,ue)=>{let I=ue===$.length-1;if(G.type==="reasoning")return(0,Le.jsx)(x2,{isStreaming:G.state==="streaming",isLast:I,children:G.text},`reasoning-${T.id}-${ue}`);let We=G.title??qx(G.toolName),Je=H2(G.toolName);if(p==="titles-only")return(0,Le.jsx)(Rx,{icon:Je,title:We,state:G.state,isLast:I},G.toolCallId);let v="output"in G?G.output:void 0;return(0,Le.jsxs)(Rx,{icon:Je,title:We,state:G.state,isLast:I,children:[(0,Le.jsx)(Fx,{input:G.input,debug:f}),v!==void 0&&(0,Le.jsx)(zx,{output:v,errorText:"errorText"in G?G.errorText:void 0,debug:f})]},G.toolCallId)})})]})})(),p!==!1&&!W&&!V&&L.length===1&&(()=>{let N=L[0],R=N.title??qx(N.toolName);if(p==="titles-only")return(0,Le.jsx)(E2,{title:R,state:N.state});let G="output"in N?N.output:void 0;return(0,Le.jsxs)(T2,{children:[(0,Le.jsx)(L2,{title:R,state:N.state}),(0,Le.jsxs)(M2,{children:[(0,Le.jsx)(Fx,{input:N.input,debug:f}),G!==void 0&&(0,Le.jsx)(zx,{output:G,errorText:"errorText"in N?N.errorText:void 0,debug:f})]})]})})(),L.map(N=>{let R="output"in N?N.output:void 0,G=ju(N.toolName,R,m),ue=A2(N.toolName,R,m),I=N.toolCallId===d;return G&&o&&R!==void 0?(0,Le.jsx)("div",{style:I?{position:"absolute",inset:0,zIndex:10,display:"flex",flexDirection:"column",overflow:"hidden",background:"var(--ww-color-background)"}:void 0,children:G&&o&&R!==void 0&&(0,Le.jsx)(yp,{children:(0,Le.jsx)(wp,{isFullscreen:I,resourceUri:G,toolInput:N.input??{},toolResult:{content:R.content,structuredContent:R.structuredContent,_meta:R._meta},resourceEndpoint:o,chatSessionId:i,isDark:l,autoHeight:ue,toolDefinitions:m,onFollowUp:s,onCallTool:u,onDisplayModeChange:c?We=>c(We,{toolCallId:N.toolCallId,resourceUri:G,toolInput:N.input??{},toolResult:{content:R.content,structuredContent:R.structuredContent,_meta:R._meta},autoHeight:ue}):void 0})})},N.toolCallId):null}),!W&&P.length>0&&(0,Le.jsx)(fk,{documents:P}),!W&&(0,Le.jsx)("div",{children:(0,Le.jsxs)(Ox,{className:q(T.role==="user"?x?.userBubble:x?.assistantBubble),children:[D.length>0&&(0,Le.jsx)(uk,{files:D}),F?C.map((N,R)=>{let G=H&&t==="streaming"&&R===C.length-1;return(0,Le.jsx)(gp,{isStreaming:G,children:N.type==="text"?N.text:""},`${T.id}-${R}`)}):null]})})]},T.id)}),b&&(0,Le.jsx)(O2,{})]})}var co=z(ae(),1);function m9({label:e}){return(0,co.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",role:"img","aria-label":e,children:[(0,co.jsx)("title",{children:e}),(0,co.jsx)("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),(0,co.jsx)("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}function xp({onClick:e}){let{t}=Ie();return(0,co.jsx)("button",{type:"button",onClick:e,title:t.threadMenu.newChat,"aria-label":t.threadMenu.newChat,className:"ww:p-1.5 ww:rounded-md ww:text-muted-foreground hover:ww:text-foreground hover:ww:bg-foreground/5 ww:transition-colors ww:cursor-pointer",children:(0,co.jsx)(m9,{label:t.threadMenu.newChat})})}var Wu=z(ae(),1),h9="https://app.waniwani.ai/assets/waniwani-logo.svg",g9="https://waniwani.ai";function V2(){let{t:e}=Ie();return(0,Wu.jsxs)("a",{href:g9,target:"_blank",rel:"noopener noreferrer",className:"ww:flex ww:items-center ww:gap-1.5 ww:whitespace-nowrap ww:text-[10px] ww:sm:text-[11px] ww:text-muted-foreground ww:opacity-70 hover:ww:opacity-100 ww:transition-opacity",children:[(0,Wu.jsx)("span",{children:e.poweredBy.label}),(0,Wu.jsx)("img",{src:h9,alt:"Waniwani",width:72,height:10,"data-waniwani-logo":"",className:"ww:h-2.5 ww:w-auto"})]})}var Rl=z(he(),1);var ut=z(ae(),1),W2=20;function w9({label:e}){return(0,ut.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",role:"img","aria-label":e,children:[(0,ut.jsx)("title",{children:e}),(0,ut.jsx)("path",{d:"M3 12a9 9 0 1 0 3-6.7"}),(0,ut.jsx)("polyline",{points:"3 4 3 9 8 9"}),(0,ut.jsx)("line",{x1:"12",y1:"7",x2:"12",y2:"12"}),(0,ut.jsx)("line",{x1:"12",y1:"12",x2:"15",y2:"14"})]})}function y9({label:e}){return(0,ut.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",role:"img","aria-label":e,children:[(0,ut.jsx)("title",{children:e}),(0,ut.jsx)("polyline",{points:"3 6 5 6 21 6"}),(0,ut.jsx)("path",{d:"M19 6l-2 14a2 2 0 0 1-2 2H9a2 2 0 0 1-2-2L5 6"}),(0,ut.jsx)("path",{d:"M10 11v6"}),(0,ut.jsx)("path",{d:"M14 11v6"})]})}function G2({threads:e,activeThreadId:t,onNewThread:a,onSelectThread:n,onDeleteThread:r}){let{locale:o,t:i}=Ie(),[l,s]=(0,Rl.useState)(!1),u=(0,Rl.useRef)(null);(0,Rl.useEffect)(()=>{if(!l)return;let f=p=>{let m=u.current;m&&(p.composedPath().includes(m)||s(!1))};return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[l]);let c=e.slice(0,W2),d=Math.max(0,e.length-W2);return(0,ut.jsxs)("div",{ref:u,className:"ww:relative ww:flex ww:items-center ww:gap-1",children:[(0,ut.jsx)(xp,{onClick:a}),(0,ut.jsx)("button",{type:"button",onClick:()=>s(f=>!f),title:i.threadMenu.threadHistory,"aria-label":i.threadMenu.threadHistory,"aria-expanded":l,className:"ww:p-1.5 ww:rounded-md ww:text-muted-foreground hover:ww:text-foreground hover:ww:bg-foreground/5 ww:transition-colors ww:cursor-pointer",children:(0,ut.jsx)(w9,{label:i.threadMenu.threadHistory})}),l&&(0,ut.jsxs)("div",{role:"menu",className:"ww:absolute ww:right-0 ww:top-full ww:mt-1 ww:w-72 ww:max-h-80 ww:overflow-y-auto ww:rounded-lg ww:border ww:border-border ww:bg-background ww:shadow-lg ww:z-50",children:[c.length===0&&(0,ut.jsx)("div",{className:"ww:px-3 ww:py-3 ww:text-xs ww:text-muted-foreground",children:i.threadMenu.noPreviousChats}),c.map(f=>{let p=f.threadId===t,m=Date.parse(f.updatedAt);return(0,ut.jsxs)("div",{className:`ww:flex ww:items-center ww:gap-2 ww:px-3 ww:py-2 ww:text-xs hover:ww:bg-foreground/5 ${p?"ww:bg-foreground/5":""}`,children:[(0,ut.jsxs)("button",{type:"button",onClick:()=>{n(f.threadId),s(!1)},className:"ww:flex-1 ww:min-w-0 ww:text-left ww:cursor-pointer",children:[(0,ut.jsx)("div",{className:"ww:truncate ww:text-foreground ww:font-medium",children:f.title}),(0,ut.jsx)("div",{className:"ww:text-[10px] ww:text-muted-foreground",children:Number.isNaN(m)?"":aw(m,o)})]}),(0,ut.jsx)("button",{type:"button",onClick:x=>{x.stopPropagation(),r(f.threadId)},title:i.threadMenu.deleteThread,"aria-label":i.threadMenu.deleteThread,className:"ww:p-1 ww:rounded ww:text-muted-foreground hover:ww:text-foreground hover:ww:bg-foreground/10 ww:transition-colors ww:cursor-pointer",children:(0,ut.jsx)(y9,{label:i.threadMenu.deleteThread})})]},f.threadId)}),d>0&&(0,ut.jsx)("div",{className:"ww:px-3 ww:py-2 ww:text-[10px] ww:text-muted-foreground ww:border-t ww:border-border",children:i.threadMenu.hiddenThreads(d)})]})]})}var vp=z(he(),1);function Dl(e){let t=new Set;return{subscribe(a){return t.add(a),()=>{t.delete(a)}},emit(a){let{sessionId:n,...r}=a,o=a.name==="session.started"?a.properties.sessionId:void 0,i={...r,mode:e.mode,sessionId:Object.hasOwn(a,"sessionId")?n:o??e.getSessionId?.(),timestamp:Date.now()};for(let l of[...t])try{l(i)}catch(s){console.warn("[Waniwani] onEvent subscriber threw:",s)}}}}function $2(){return{subscribe(){return()=>{}},emit(){}}}var X2=(0,vp.createContext)($2());function bp(){return(0,vp.useContext)(X2)}var _l=X2.Provider;var Sp=z(he(),1);function K2(e){let t=(0,Sp.useRef)(e);return t.current=e,(0,Sp.useCallback)(async a=>{let{api:n,headers:r,onCallTool:o,sessionId:i}=t.current;if(o)return o(a);let l=ma(n??"/api/waniwani","/tool"),s=typeof i=="string"&&i.trim().length>0?i.trim():void 0,u=await fetch(l,{method:"POST",headers:{"Content-Type":"application/json",...s?{"X-Session-Id":s}:{},...r},body:JSON.stringify(a)});if(!u.ok)throw new Error(`Tool call failed: ${u.status} ${u.statusText}`);return u.json()},[])}var pn=z(he(),1);var CD="vercel.ai.error",x9=Symbol.for(CD),Y2,Z2,Fe=class kD extends(Z2=Error,Y2=x9,Z2){constructor({name:t,message:a,cause:n}){super(a),this[Y2]=!0,this.name=t,this.cause=n}static isInstance(t){return kD.hasMarker(t,CD)}static hasMarker(t,a){let n=Symbol.for(a);return t!=null&&typeof t=="object"&&n in t&&typeof t[n]=="boolean"&&t[n]===!0}},TD="AI_APICallError",LD=`vercel.ai.error.${TD}`,v9=Symbol.for(LD),Q2,J2,Kie=class extends(J2=Fe,Q2=v9,J2){constructor({message:e,url:t,requestBodyValues:a,statusCode:n,responseHeaders:r,responseBody:o,cause:i,isRetryable:l=n!=null&&(n===408||n===409||n===429||n>=500),data:s}){super({name:TD,message:e,cause:i}),this[Q2]=!0,this.url=t,this.requestBodyValues=a,this.statusCode=n,this.responseHeaders=r,this.responseBody=o,this.isRetryable=l,this.data=s}static isInstance(e){return Fe.hasMarker(e,LD)}},ED="AI_EmptyResponseBodyError",MD=`vercel.ai.error.${ED}`,b9=Symbol.for(MD),eD,tD,Yie=class extends(tD=Fe,eD=b9,tD){constructor({message:e="Empty response body"}={}){super({name:ED,message:e}),this[eD]=!0}static isInstance(e){return Fe.hasMarker(e,MD)}};function AD(e){return e==null?"unknown error":typeof e=="string"?e:e instanceof Error?e.message:JSON.stringify(e)}var RD="AI_InvalidArgumentError",DD=`vercel.ai.error.${RD}`,S9=Symbol.for(DD),aD,nD,_D=class extends(nD=Fe,aD=S9,nD){constructor({message:e,cause:t,argument:a}){super({name:RD,message:e,cause:t}),this[aD]=!0,this.argument=a}static isInstance(e){return Fe.hasMarker(e,DD)}},OD="AI_InvalidPromptError",PD=`vercel.ai.error.${OD}`,I9=Symbol.for(PD),rD,oD,Zie=class extends(oD=Fe,rD=I9,oD){constructor({prompt:e,message:t,cause:a}){super({name:OD,message:`Invalid prompt: ${t}`,cause:a}),this[rD]=!0,this.prompt=e}static isInstance(e){return Fe.hasMarker(e,PD)}},ND="AI_InvalidResponseDataError",BD=`vercel.ai.error.${ND}`,C9=Symbol.for(BD),iD,lD,Qie=class extends(lD=Fe,iD=C9,lD){constructor({data:e,message:t=`Invalid response data: ${JSON.stringify(e)}.`}){super({name:ND,message:t}),this[iD]=!0,this.data=e}static isInstance(e){return Fe.hasMarker(e,BD)}},UD="AI_JSONParseError",FD=`vercel.ai.error.${UD}`,k9=Symbol.for(FD),sD,uD,jx=class extends(uD=Fe,sD=k9,uD){constructor({text:e,cause:t}){super({name:UD,message:`JSON parsing failed: Text: ${e}.
|
|
124
124
|
Error message: ${AD(t)}`,cause:t}),this[sD]=!0,this.text=e}static isInstance(e){return Fe.hasMarker(e,FD)}},zD="AI_LoadAPIKeyError",qD=`vercel.ai.error.${zD}`,T9=Symbol.for(qD),cD,dD,Jie=class extends(dD=Fe,cD=T9,dD){constructor({message:e}){super({name:zD,message:e}),this[cD]=!0}static isInstance(e){return Fe.hasMarker(e,qD)}},HD="AI_LoadSettingError",jD=`vercel.ai.error.${HD}`,L9=Symbol.for(jD),fD,pD,ele=class extends(pD=Fe,fD=L9,pD){constructor({message:e}){super({name:HD,message:e}),this[fD]=!0}static isInstance(e){return Fe.hasMarker(e,jD)}},VD="AI_NoContentGeneratedError",WD=`vercel.ai.error.${VD}`,E9=Symbol.for(WD),mD,hD,tle=class extends(hD=Fe,mD=E9,hD){constructor({message:e="No content generated."}={}){super({name:VD,message:e}),this[mD]=!0}static isInstance(e){return Fe.hasMarker(e,WD)}},GD="AI_NoSuchModelError",$D=`vercel.ai.error.${GD}`,M9=Symbol.for($D),gD,wD,ale=class extends(wD=Fe,gD=M9,wD){constructor({errorName:e=GD,modelId:t,modelType:a,message:n=`No such ${a}: ${t}`}){super({name:e,message:n}),this[gD]=!0,this.modelId=t,this.modelType=a}static isInstance(e){return Fe.hasMarker(e,$D)}},XD="AI_TooManyEmbeddingValuesForCallError",KD=`vercel.ai.error.${XD}`,A9=Symbol.for(KD),yD,xD,nle=class extends(xD=Fe,yD=A9,xD){constructor(e){super({name:XD,message:`Too many values for a single embedding call. The ${e.provider} model "${e.modelId}" can only embed up to ${e.maxEmbeddingsPerCall} values per call, but ${e.values.length} values were provided.`}),this[yD]=!0,this.provider=e.provider,this.modelId=e.modelId,this.maxEmbeddingsPerCall=e.maxEmbeddingsPerCall,this.values=e.values}static isInstance(e){return Fe.hasMarker(e,KD)}},YD="AI_TypeValidationError",ZD=`vercel.ai.error.${YD}`,R9=Symbol.for(ZD),vD,bD,qn=class Hx extends(bD=Fe,vD=R9,bD){constructor({value:t,cause:a,context:n}){let r="Type validation failed";if(n?.field&&(r+=` for ${n.field}`),n?.entityName||n?.entityId){r+=" (";let o=[];n.entityName&&o.push(n.entityName),n.entityId&&o.push(`id: "${n.entityId}"`),r+=o.join(", "),r+=")"}super({name:YD,message:`${r}: Value: ${JSON.stringify(t)}.
|
package/dist/chat/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{a as li,b as ui,c as di,d as ci,e as fi,f as Lr,g as pi,h as mi,i as hi,j as gi,k as qo,l as wi,m as ea,n as ta,o as Cr,p as aa,u as wa}from"../chunk-QIQG7C7A.js";import"../chunk-V3ZDECK5.js";import{useCallback as Cm,useEffect as Er,useMemo as Sm,useRef as Fe,useState as el}from"react";function Nt(e){if(!e)return!1;let t=Array.isArray(e.content)&&e.content.length>0,a=typeof e.structuredContent=="object"&&e.structuredContent!==null&&Object.keys(e.structuredContent).length>0;return t||a}function Ii(e,t){return!Nt(e)&&!Nt(t)?null:Nt(e)?Nt(t)?{...e.content||t.content?{content:[...e.content??[],...t.content??[]]}:{},...e.structuredContent||t.structuredContent?{structuredContent:{...e.structuredContent??{},...t.structuredContent??{}}}:{}}:{...e.content?{content:[...e.content]}:{},...e.structuredContent?{structuredContent:{...e.structuredContent}}:{}}:{...t?.content?{content:[...t.content]}:{},...t?.structuredContent?{structuredContent:{...t.structuredContent}}:{}}}import{forwardRef as sp,createElement as ip}from"react";var Sr=(...e)=>e.filter((t,a,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===a).join(" ").trim();var xi=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();var yi=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,a,r)=>r?r.toUpperCase():a.toLowerCase());var Ho=e=>{let t=yi(e);return t.charAt(0).toUpperCase()+t.slice(1)};import{forwardRef as np,createElement as Si}from"react";var Li={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};var Ci=e=>{for(let t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};var bi=np(({color:e="currentColor",size:t=24,strokeWidth:a=2,absoluteStrokeWidth:r,className:o="",children:n,iconNode:s,...i},l)=>Si("svg",{ref:l,...Li,width:t,height:t,stroke:e,strokeWidth:r?Number(a)*24/Number(t):a,className:Sr("lucide",o),...!n&&!Ci(i)&&{"aria-hidden":"true"},...i},[...s.map(([u,d])=>Si(u,d)),...Array.isArray(n)?n:[n]]));var de=(e,t)=>{let a=sp(({className:r,...o},n)=>ip(bi,{ref:n,iconNode:t,className:Sr(`lucide-${xi(Ho(e))}`,`lucide-${e}`,r),...o}));return a.displayName=Ho(e),a};var lp=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Ia=de("arrow-down",lp);var up=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],xa=de("arrow-up",up);var dp=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],ya=de("check",dp);var cp=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],bt=de("chevron-down",cp);var fp=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],La=de("chevron-right",fp);var pp=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",key:"4jdomd"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4",key:"3hqy98"}],["path",{d:"M21 14H11",key:"1bme5i"}],["path",{d:"m15 10-4 4 4 4",key:"5dvupr"}]],Ca=de("clipboard-copy",pp);var mp=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],gt=de("clock",mp);var hp=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],Sa=de("file-text",hp);var gp=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}]],ra=de("file",gp);var wp=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],ba=de("globe",wp);var Ip=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],va=de("image",Ip);var xp=[["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m16.2 7.8 2.9-2.9",key:"r700ao"}],["path",{d:"M18 12h4",key:"wj9ykh"}],["path",{d:"m16.2 16.2 2.9 2.9",key:"1bxg5t"}],["path",{d:"M12 18v4",key:"jadmvz"}],["path",{d:"m4.9 19.1 2.9-2.9",key:"bwix9q"}],["path",{d:"M2 12h4",key:"j09sii"}],["path",{d:"m4.9 4.9 2.9 2.9",key:"giyufr"}]],ka=de("loader",xp);var yp=[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]],oa=de("paperclip",yp);var Lp=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],Ta=de("square",Lp);var Cp=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],qt=de("wrench",Cp);var Sp=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],vt=de("x",Sp);var bp=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],Aa=de("zap",bp);import{createContext as Op,useCallback as Up,useContext as Mi,useEffect as Np,useMemo as Xo,useRef as qp,useState as Qo}from"react";function $o(e){if(!(typeof e!="object"||e===null))return e}function vi(e){return $o(e?.ui)}function Wo(e){if(!e)return;let t=vi(e)?.resourceUri;if(typeof t=="string"&&t.length>0)return t;let a=e["ui/resourceUri"];if(typeof a=="string"&&a.length>0)return a;let r=e["openai/outputTemplate"];if(typeof r=="string"&&r.length>0)return r}function Pa(e){return vi(e)?.autoHeight===!0}function jo(e){return $o($o(e)?._meta)}import{createContext as vp,useContext as kp,useEffect as Tp,useMemo as Ap,useState as Pi}from"react";var ki=["en","fr","es"];function na(e){return ki.includes(e)}function zo(e){if(e&&na(e))return e;if(e){let a=e.split("-")[0]?.toLowerCase();if(a&&na(a))return a}let t=[];if(typeof navigator<"u"&&(navigator.language&&t.push(navigator.language),navigator.languages&&t.push(...navigator.languages)),typeof document<"u"){let a=document.documentElement.getAttribute("lang");a&&t.push(a)}for(let a of t){let r=a.toLowerCase();if(na(r))return r;let o=r.split("-")[0];if(o&&na(o))return o}return"en"}var br={promptInput:{placeholder:"What would you like to know?",uploadFiles:"Upload files",uploadFilesUpTo:"Upload a document, up to {limit}",uploadFilesUpToWithPages:"Upload a document, up to {limit} and {pages} pages",stop:"Stop",submit:"Submit",removeAttachments:"Remove all attachments",removeAttachment:"Remove attachment",uploading:"Uploading\u2026",retry:"Retry",retryUpload:"Retry the upload",uploadFailed:"The upload did not finish.",dropToAttach:"Drop to attach",errorAccept:"{name} is not a file type this chat accepts.",errorTooLarge:"{name} is larger than {limit}.",errorTooMany:"You can attach up to {limit} files."},workingIndicator:{default:"On it\u2026"},reasoning:{thinking:"Thinking\u2026",thoughtBrief:"Thought for a few seconds",thoughtForSeconds:e=>`Thought for ${e} second${e===1?"":"s"}`},chainOfThought:{working:"Working on it\u2026",done:"Thought process"},tool:{copy:"Copy",copied:"Copied",request:"Request",response:"Response",error:"Error"},attachments:{attachmentFallback:"attachment",kindPdf:"PDF",kindImage:"Image",kindFile:"File",fileFallback:"file"},threadMenu:{newChat:"New chat",threadHistory:"Thread history",deleteThread:"Delete thread",noPreviousChats:"No previous chats yet.",hiddenThreads:e=>`${e} older thread${e===1?"":"s"} hidden`},chatQueue:{attachmentFallback:"(attachment)",removeFromQueue:"Remove from queue",queued:e=>`${e} queued`},poweredBy:{label:"AI agent powered by"},aiDisclaimer:{default:"can make mistakes"},exportSession:{saving:"saving...",saved:"saved",error:"error",export:"export",tooltip:"Save scenario to Waniwani"},widgetErrorBoundary:{failedToLoad:"Widget failed to load",retry:"Retry"},launcher:{prompt:"Ask anything\u2026",open:"Open chat",close:"Close chat",minimize:"Minimize"}};var Ti={promptInput:{placeholder:"\xBFQu\xE9 te gustar\xEDa saber?",uploadFiles:"Subir archivos",uploadFilesUpTo:"Subir un documento, hasta {limit}",uploadFilesUpToWithPages:"Subir un documento, hasta {limit} y {pages} p\xE1ginas",stop:"Detener",submit:"Enviar",removeAttachments:"Eliminar todos los archivos adjuntos",removeAttachment:"Quitar archivo",uploading:"Subiendo\u2026",retry:"Reintentar",retryUpload:"Reintentar la subida",uploadFailed:"La subida no se complet\xF3.",dropToAttach:"Suelta para adjuntar",errorAccept:"{name} no es un tipo de archivo que acepte este chat.",errorTooLarge:"{name} supera {limit}.",errorTooMany:"Puedes adjuntar hasta {limit} archivos."},workingIndicator:{default:"Un momento\u2026"},reasoning:{thinking:"Pensando\u2026",thoughtBrief:"Pensado durante unos segundos",thoughtForSeconds:e=>`Pensado durante ${e} segundo${e===1?"":"s"}`},chainOfThought:{working:"Estoy en ello\u2026",done:"Razonamiento"},tool:{copy:"Copiar",copied:"Copiado",request:"Solicitud",response:"Respuesta",error:"Error"},attachments:{attachmentFallback:"adjunto",kindPdf:"PDF",kindImage:"Imagen",kindFile:"Archivo",fileFallback:"archivo"},threadMenu:{newChat:"Nueva conversaci\xF3n",threadHistory:"Historial",deleteThread:"Eliminar conversaci\xF3n",noPreviousChats:"A\xFAn no hay conversaciones anteriores.",hiddenThreads:e=>`${e} conversaci\xF3n${e===1?"":"es"} anterior${e===1?"":"es"} oculta${e===1?"":"s"}`},chatQueue:{attachmentFallback:"(adjunto)",removeFromQueue:"Quitar de la cola",queued:e=>`${e} en cola`},poweredBy:{label:"Agente IA con tecnolog\xEDa de"},aiDisclaimer:{default:"puede cometer errores"},exportSession:{saving:"guardando...",saved:"guardado",error:"error",export:"exportar",tooltip:"Guardar escenario en Waniwani"},widgetErrorBoundary:{failedToLoad:"No se pudo cargar el widget",retry:"Reintentar"},launcher:{prompt:"Pregunta lo que quieras\u2026",open:"Abrir chat",close:"Cerrar chat",minimize:"Minimizar"}};var Ai={promptInput:{placeholder:"Que souhaitez-vous savoir ?",uploadFiles:"Importer des fichiers",uploadFilesUpTo:"Joindre un document, jusqu'\xE0 {limit}",uploadFilesUpToWithPages:"Envoyer un document, jusqu'\xE0 {limit} et {pages} pages",stop:"Arr\xEAter",submit:"Envoyer",removeAttachments:"Supprimer toutes les pi\xE8ces jointes",removeAttachment:"Retirer la pi\xE8ce jointe",uploading:"Envoi en cours\u2026",retry:"R\xE9essayer",retryUpload:"R\xE9essayer l'envoi",uploadFailed:"L'envoi ne s'est pas termin\xE9.",dropToAttach:"D\xE9posez pour joindre",errorAccept:"{name} n'est pas un type de fichier accept\xE9 par ce chat.",errorTooLarge:"{name} d\xE9passe {limit}.",errorTooMany:"Vous pouvez joindre jusqu'\xE0 {limit} fichiers."},workingIndicator:{default:"Un instant\u2026"},reasoning:{thinking:"R\xE9flexion\u2026",thoughtBrief:"R\xE9flexion pendant quelques secondes",thoughtForSeconds:e=>`R\xE9flexion pendant ${e} seconde${e===1?"":"s"}`},chainOfThought:{working:"Je m'en occupe\u2026",done:"Raisonnement"},tool:{copy:"Copier",copied:"Copi\xE9",request:"Requ\xEAte",response:"R\xE9ponse",error:"Erreur"},attachments:{attachmentFallback:"pi\xE8ce jointe",kindPdf:"PDF",kindImage:"Image",kindFile:"Fichier",fileFallback:"fichier"},threadMenu:{newChat:"Nouvelle conversation",threadHistory:"Historique",deleteThread:"Supprimer la conversation",noPreviousChats:"Aucune conversation pr\xE9c\xE9dente.",hiddenThreads:e=>`${e} conversation${e===1?"":"s"} plus ancienne${e===1?"":"s"} masqu\xE9e${e===1?"":"s"}`},chatQueue:{attachmentFallback:"(pi\xE8ce jointe)",removeFromQueue:"Retirer de la file",queued:e=>`${e} en attente`},poweredBy:{label:"Agent IA propuls\xE9 par"},aiDisclaimer:{default:"peut faire des erreurs"},exportSession:{saving:"enregistrement...",saved:"enregistr\xE9",error:"erreur",export:"exporter",tooltip:"Enregistrer le sc\xE9nario dans Waniwani"},widgetErrorBoundary:{failedToLoad:"\xC9chec du chargement du widget",retry:"R\xE9essayer"},launcher:{prompt:"Posez votre question\u2026",open:"Ouvrir le chat",close:"Fermer le chat",minimize:"R\xE9duire"}};var Vo={en:br,fr:Ai,es:Ti};import{jsx as Ep}from"react/jsx-runtime";var Ri=vp(null);function Pp(e,t){if(!t)return e;let a={...e};for(let r of Object.keys(e)){let o=e[r],n=t[r];n&&typeof o=="object"&&(a[r]={...o,...n})}return a}function Go({children:e,locale:t,messages:a}){let r=!!(t&&Rp(t)),o=r?t:"en",[n,s]=Pi(o),[i,l]=Pi(r);Tp(()=>{s(zo(t)),l(!0)},[t]);let u=Ap(()=>{let d=Vo[n]??Vo["en"];return{locale:n,t:Pp(d,a),ready:i}},[n,a,i]);return Ep(Ri.Provider,{value:u,children:e})}function Rp(e){return e==="en"||e==="fr"||e==="es"}function ae(){let e=kp(Ri);return e||{locale:"en",t:br,ready:!0}}function Ko(e,t){let a=Date.now()-e;if(a<6e4)try{return new Intl.RelativeTimeFormat(t,{numeric:"auto",style:"narrow"}).format(0,"second")}catch{return"just now"}let r,o;a<60*6e4?(r=-Math.floor(a/6e4),o="minute"):a<1440*6e4?(r=-Math.floor(a/(60*6e4)),o="hour"):(r=-Math.floor(a/(1440*6e4)),o="day");try{return new Intl.RelativeTimeFormat(t,{numeric:"auto",style:"short"}).format(r,o)}catch{return`${Math.abs(r)}${o==="minute"?"m":o==="hour"?"h":"d"} ago`}}var Mp=ui({prefix:"ww"});function A(...e){return Mp(li(e))}import{jsx as Fp}from"react/jsx-runtime";var lt=({className:e,variant:t="default",size:a="default",type:r="button",...o})=>Fp("button",{type:r,className:A("ww:inline-flex ww:cursor-pointer ww:items-center ww:justify-center ww:rounded-md ww:font-medium ww:transition-colors ww:disabled:pointer-events-none ww:disabled:opacity-50",t==="default"&&"ww:bg-primary ww:text-primary-foreground ww:hover:bg-primary/90",t==="outline"&&"ww:border ww:border-border ww:bg-background ww:hover:bg-accent ww:hover:text-accent-foreground",t==="ghost"&&"ww:hover:bg-accent ww:hover:text-accent-foreground",a==="default"&&"ww:h-9 ww:px-4 ww:py-2 ww:text-sm",a==="sm"&&"ww:h-8 ww:px-3 ww:text-xs",a==="icon"&&"ww:size-9 ww:!rounded-full",a==="icon-sm"&&"ww:size-7 ww:!rounded-full",e),...o});import{memo as _p}from"react";import{jsx as Bp}from"react/jsx-runtime";var Dp=({as:e="span",className:t,duration:a=2,style:r,children:o,...n})=>{let s={backgroundImage:"linear-gradient(90deg, var(--ww-color-muted-foreground) 0%, var(--ww-color-muted-foreground) 40%, var(--ww-color-foreground) 50%, var(--ww-color-muted-foreground) 60%, var(--ww-color-muted-foreground) 100%)",backgroundSize:"250% 100%",WebkitBackgroundClip:"text",backgroundClip:"text",color:"transparent",animation:`ww-shimmer ${a}s linear infinite`,...r};return Bp(e,{"data-waniwani-shimmer":"",className:A("ww:inline-block",t),style:s,...n,children:o})},tt=_p(Dp);tt.displayName="Shimmer";import{Fragment as Ei,jsx as ge,jsxs as Ht}from"react/jsx-runtime";function Hp(e,t=80){if(e==null)return String(e);if(typeof e!="object")return String(e).slice(0,t);if(Array.isArray(e))return`Array(${e.length})`;let a=JSON.stringify(e);if(a.length<=t)return a;let r=Object.entries(e),o=[],n=t-2;for(let[s,i]of r){if(n<=8)break;let l=s.length>4?`${s.slice(0,4)}\u2026`:s,u;typeof i=="string"?u=i.length>2?`'${i.slice(0,1)}\u2026`:`'${i}'`:Array.isArray(i)?u=`Array(${i.length})`:typeof i=="object"&&i!==null?u="{\u2026}":u=String(i);let d=`${l}\u2009${u}`;o.push(d),n-=d.length+3}return`{${o.join(", ")}}`}function $p({text:e,className:t}){let{t:a}=ae(),[r,o]=Qo(!1),n=qp(null);Np(()=>()=>{n.current&&clearTimeout(n.current)},[]);let s=Up(async i=>{i.stopPropagation();try{await navigator.clipboard.writeText(e),o(!0),n.current&&clearTimeout(n.current),n.current=setTimeout(()=>o(!1),2e3)}catch{}},[e]);return ge(lt,{variant:"ghost",size:"sm",onClick:s,className:A("ww:h-auto ww:gap-1 ww:px-1.5 ww:py-0.5 ww:text-xs ww:text-muted-foreground ww:hover:text-foreground",t),children:r?Ht(Ei,{children:[ge(ya,{className:"ww:size-3.5"}),ge("span",{children:a.tool.copied})]}):Ht(Ei,{children:[ge(Ca,{className:"ww:size-3.5"}),ge("span",{children:a.tool.copy})]})})}function Fi({data:e,label:t,className:a,...r}){let[o,n]=Qo(!1),s=Xo(()=>JSON.stringify(e,null,2),[e]),i=Hp(e);return Ht("div",{className:A("ww:rounded-lg ww:bg-tool-card",a),...r,children:[Ht("div",{className:"ww:flex ww:items-center ww:justify-between ww:px-3 ww:pt-2.5 ww:pb-1.5",children:[ge("span",{className:"ww:text-xs ww:font-medium ww:text-muted-foreground",children:t}),ge($p,{text:s})]}),Ht("button",{type:"button",onClick:()=>n(l=>!l),className:"ww:flex ww:w-full ww:items-start ww:gap-2 ww:px-3 ww:pb-3 ww:text-left",children:[ge(La,{className:A("ww:mt-0.5 ww:size-3.5 ww:shrink-0 ww:text-muted-foreground ww:transition-transform ww:duration-150",o&&"ww:rotate-90")}),o?ge("pre",{className:"ww:overflow-x-auto ww:text-xs ww:font-mono ww:text-foreground ww:whitespace-pre-wrap ww:break-all",children:ge("code",{children:s})}):ge("span",{className:"ww:truncate ww:text-xs ww:font-mono ww:text-foreground/80",children:i})]})]})}var Jo=Op({open:!1,toggle:()=>{}});function _i({className:e,defaultOpen:t=!1,children:a,...r}){let[o,n]=Qo(t);return ge(Jo.Provider,{value:{open:o,toggle:()=>n(s=>!s)},children:ge("div",{className:A("ww:mb-4 ww:w-full",e),"data-state":o?"open":"closed",style:{animation:"ww-fade-in 0.2s ease-out"},...r,children:a})})}function Di({className:e,title:t,state:a,...r}){let{open:o,toggle:n}=Mi(Jo),s=a==="input-available"||a==="input-streaming",i=t??"";return Ht("button",{type:"button",onClick:n,className:A("ww:flex ww:w-full ww:items-center ww:gap-2 ww:text-sm ww:text-muted-foreground ww:transition-colors ww:hover:text-foreground",e),"aria-expanded":o,...r,children:[ge(qt,{className:"ww:size-4 ww:shrink-0"}),ge("span",{className:"ww:truncate",children:s?ge(tt,{duration:1.6,children:i}):i}),ge(bt,{className:A("ww:size-4 ww:shrink-0 ww:transition-transform ww:duration-200",o&&"ww:rotate-180")})]})}function Bi({className:e,title:t,state:a,...r}){let o=a==="input-available"||a==="input-streaming",n=t??"";return ge("div",{className:A("ww:mb-4 ww:flex ww:items-center ww:gap-2 ww:text-sm ww:text-muted-foreground",e),style:{animation:"ww-fade-in 0.2s ease-out"},...r,children:ge("span",{className:"ww:truncate",children:o?ge(tt,{duration:1.6,children:n}):n})})}function Oi({className:e,children:t,...a}){let{open:r}=Mi(Jo);return ge("div",{className:A("ww:grid ww:transition-[grid-template-rows,opacity] ww:duration-200 ww:ease-out",r?"ww:grid-rows-[1fr] ww:opacity-100":"ww:grid-rows-[0fr] ww:opacity-0"),children:ge("div",{className:"ww:min-h-0 ww:overflow-hidden",children:ge("div",{className:A("ww:mt-2 ww:space-y-3 ww:rounded-lg ww:border ww:border-border ww:bg-background ww:p-3",e),...a,children:t})})})}function Yo({className:e,input:t,debug:a,...r}){let{t:o}=ae(),n=Xo(()=>{if(!a&&typeof t=="object"&&t!==null&&!Array.isArray(t)){let{_meta:s,...i}=t;return i}return t},[t,a]);return ge(Fi,{data:n,label:o.tool.request,className:e,...r})}function Ra(e,t,a){if(e){let r=Wo(a?.[e]?._meta);if(r)return r}return Wo(jo(t))}function Ui(e,t,a){return e&&Pa(a?.[e]?._meta)?!0:Pa(jo(t))}function Zo({className:e,output:t,errorText:a,debug:r,...o}){let{t:n}=ae(),s=Xo(()=>{if(!r&&typeof t=="object"&&t!==null&&!Array.isArray(t)){let{_meta:i,...l}=t;return l}return t},[t,r]);return t||a?a?Ht("div",{className:A("ww:space-y-2",e),...o,children:[ge("h4",{className:"ww:text-xs ww:font-medium ww:uppercase ww:tracking-wide ww:text-muted-foreground",children:n.tool.error}),ge("div",{className:"ww:rounded-lg ww:bg-destructive/10 ww:p-3 ww:text-xs ww:text-destructive",children:a})]}):ge(Fi,{data:s,label:n.tool.response,className:e,...o}):null}var Ni=typeof performance>"u"?0:performance.now(),qi=typeof window<"u"&&!!window.WaniWani?.chat;function at(e,t,a){let[r,o=""]=e.split("?"),n=r.replace(/\/$/,""),s=new URLSearchParams(o);if(a)for(let[l,u]of Object.entries(a))s.set(l,u);let i=s.toString();return`${n}${t}${i?`?${i}`:""}`}var Wp="/api/mcp/";function vr(e,t){let[a=""]=e.split("?"),r="",o=a;try{let n=new URL(a);r=n.origin,o=n.pathname}catch{if(!a.startsWith("/"))return null}return o.startsWith(Wp)?`${r}${t}`:null}function jp(){if(typeof window>"u")return!1;try{return window.WANIWANI_DEBUG?!0:!!window.localStorage?.getItem("WANIWANI_DEBUG")}catch{return!1}}function ut(...e){jp()&&console.log("[Waniwani]",...e)}var en="waniwani-visitor-id";function zp(){try{if(typeof crypto<"u"){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();if(typeof crypto.getRandomValues=="function"){let e=crypto.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=Array.from(e,a=>a.toString(16).padStart(2,"0")).join("");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}}}catch{}return`v-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function Ge(){try{let t=localStorage.getItem(en);if(t)return t}catch{}let e=zp();try{localStorage.setItem(en,e)}catch{}return e}function tn(e){let t=typeof e=="string"?e.trim():"";if(!t)return Ge();try{localStorage.setItem(en,t)}catch{}return t}function Vp(e){return e!=null&&typeof e.then=="function"}function an(e){let t=!1,a=()=>{t=!0};if(e==null)return a;let r;try{r=typeof e=="function"?e():e}catch{return a}return Vp(r)?r.then(o=>{t||tn(o??"")},()=>{}):tn(r??""),a}var Gp="waniwani-memory";var Ke="threads",kr="by_memoryUserId",Kp="by_updatedAt";var $i="memoryUserId",Hi="waniwani-memory-user-id",rn=null;function on(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}function Xp(e,t){if(t<1&&(e.objectStoreNames.contains("ids")||e.createObjectStore("ids")),t<2&&!e.objectStoreNames.contains(Ke)){let a=e.createObjectStore(Ke,{keyPath:"threadId"});a.createIndex(kr,"memoryUserId",{unique:!1}),a.createIndex(Kp,"updatedAt",{unique:!1})}}async function nn(){return new Promise((e,t)=>{let a=indexedDB.open(Gp,2);a.onupgradeneeded=r=>{Xp(a.result,r.oldVersion)},a.onsuccess=()=>e(a.result),a.onerror=()=>t(a.error)})}async function Qp(){return nn()}async function Jp(e){return new Promise((t,a)=>{let n=e.transaction("ids","readonly").objectStore("ids").get($i);n.onsuccess=()=>t(typeof n.result=="string"?n.result:null),n.onerror=()=>a(n.error)})}async function Yp(e,t){return new Promise((a,r)=>{let s=e.transaction("ids","readwrite").objectStore("ids").put(t,$i);s.onsuccess=()=>a(),s.onerror=()=>r(s.error)})}async function Zp(){if(typeof indexedDB>"u")return null;try{let e=await Qp();try{let t=await Jp(e);if(t)return t;let a=on();return await Yp(e,a),a}finally{e.close()}}catch{return null}}function em(){try{let e=localStorage.getItem(Hi);if(e)return e;let t=on();return localStorage.setItem(Hi,t),t}catch{return null}}async function Wi(){let e=await Zp();if(e)return e;let t=em();return t||(rn||(rn=on()),rn)}function ji(e,t){return e.match(t)?.[1]??null}function tm(e){let t=[["Edge",/Edg(?:e|A|iOS)?\/(\S+)/],["Opera",/(?:OPR|Opera)\/(\S+)/],["Samsung Internet",/SamsungBrowser\/(\S+)/],["Firefox",/Firefox\/(\S+)/],["Chrome",/Chrome\/(\S+)/],["Safari",/Version\/(\S+).*Safari/]];for(let[a,r]of t){let o=ji(e,r);if(o)return{name:a,version:o}}return null}function am(e){let t=[["iOS",/(?:iPhone|iPad|iPod).+?OS (\d+[_.\d]*)/],["Android",/Android (\d+[.\d]*)/],["macOS",/Mac OS X (\d+[_.\d]*)/],["Windows",/Windows NT (\d+[.\d]*)/],["ChromeOS",/CrOS \S+ (\d+[.\d]*)/],["Linux",/Linux/]];for(let[a,r]of t){let o=ji(e,r);if(o)return{name:a,version:o.replace(/_/g,".")};if(a==="Linux"&&r.test(e))return{name:a,version:""}}return null}function rm(e){return typeof navigator<"u"&&"userAgentData"in navigator&&navigator.userAgentData?.mobile?"mobile":/iPad|tablet|PlayBook/i.test(e)?"tablet":/Mobi|Android.*Mobile|iPhone|iPod/i.test(e)?"mobile":"desktop"}async function Ea(){let e=navigator.userAgent,t=Ge(),a=await Wi();return{userAgent:e,browser:tm(e),os:am(e),deviceType:rm(e),language:navigator.language,languages:[...navigator.languages],timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,screenWidth:screen.width,screenHeight:screen.height,viewportWidth:window.innerWidth,viewportHeight:window.innerHeight,colorDepth:screen.colorDepth,devicePixelRatio:window.devicePixelRatio??1,touchSupport:"ontouchstart"in window||navigator.maxTouchPoints>0,connectionType:navigator.connection?.effectiveType??"unknown",referrer:document.referrer,visitorId:t,memoryUserId:a}}var om="0.22.0-beta.3",nm=40,sm=10,im=6e5;function ln(){return typeof performance>"u"?0:performance.now()}function un(e,t){let a={};return{metrics:a,has:r=>r in a,set(r,o){a[r]=o},mark(r,o=ln()){if(!(r in a)){a[r]=o-t;try{performance.mark(`waniwani:${e}:${r}`,{startTime:o})}catch{}}}}}function lm(e){let t={};for(let[a,r]of Object.entries(e)){if(Object.keys(t).length>=nm)break;if(!Number.isFinite(r))continue;let o=Math.round(r);o<0||o>im||(t[a]=o)}return t}function um(e){let t={};for(let[a,r]of Object.entries(e)){if(Object.keys(t).length>=sm)break;(typeof r=="string"||typeof r=="boolean")&&(t[a]=r)}return t}function dm(){let e=navigator.connection;if(e)return{effectiveType:e.effectiveType,rtt:e.rtt,downlink:e.downlink,saveData:e.saveData}}function Ar(e){let t=e?.Authorization;return typeof t=="string"&&t.startsWith("Bearer ")?t.slice(7):void 0}function cm(e,t,a,r){return{kind:e,sdkVersion:om,channelId:t.channelId||void 0,sessionId:e==="boot"?void 0:t.sessionId||void 0,visitorId:Ge(),pageHost:window.location.hostname,connection:dm(),tags:um(a),metrics:lm(r)}}var sn,Tr=[];function Pr(e){let t=String(e?.chatTimingLogs).trim().toLowerCase()==="true";sn=t;let a=Tr;if(Tr=[],t)for(let r of a)r()}function Rr(e,t,a,r){let{api:o,token:n}=t;if(!(typeof window>"u"||!o||!n||sn===!1))try{let s=cm(e,t,a,r),i=()=>{ut("timing",s),fetch(at(o,"/timing"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify(s),keepalive:!0}).catch(()=>{})};sn?i():Tr.length<20&&Tr.push(i)}catch{}}var wt=un("boot",0),zi;function $t(e,t){wt.mark(e,t)}function Ma(e){zi??=e}var fm=/cdn\.jsdelivr\.net\/npm\/@waniwani\/sdk@[^/]+\/dist\/chat\/embed\.js/,pm=/\/embed\.js(\?|$)/;function mm(){if(typeof performance>"u")return;let e=performance.getEntriesByType("navigation")[0];e?.responseStart&&wt.mark("navTtfb",e.responseStart),e?.domContentLoadedEventEnd&&wt.mark("navDomContentLoaded",e.domContentLoadedEventEnd);let t=performance.getEntriesByType("resource");for(let a of t)fm.test(a.name)?(wt.mark("bundleStart",a.startTime),wt.mark("bundleEnd",a.responseEnd)):pm.test(a.name)&&(wt.mark("loaderStart",a.startTime),wt.mark("loaderEnd",a.responseEnd))}function hm(){if(qi)return!0;try{return document.querySelectorAll('script[src*="@waniwani/sdk"]').length>1}catch{return!1}}function Vi(e){mm(),wt.mark("bundleExecuted",Ni),Rr("boot",e,{configSource:zi,mode:e.mode,secondSdk:hm()},wt.metrics)}var gm=[["text-delta","firstText"],["tool-input-start","firstToolInput"],["tool-output-available","firstToolOutput"]];function Gi(e){let t=un("turn",ln());t.set("turnIndex",e);let a=!1;return{mark:r=>t.mark(r),instrument(r){if(!r.ok||!r.body||typeof TransformStream>"u")return r;try{let o=new TextDecoder,n=r.body.pipeThrough(new TransformStream({transform(s,i){t.mark("firstChunk");let l=o.decode(s,{stream:!0});for(let[u,d]of gm)!t.has(d)&&l.includes(u)&&t.mark(d);i.enqueue(s)}}));return new Response(n,{status:r.status,statusText:r.statusText,headers:r.headers})}catch{return r}},report(r,o){a||(a=!0,Rr("turn",r,o,t.metrics))}}}function wm(e){let t=e.indexOf("?");return t===-1?e:e.slice(0,t)}function Ki(e,t){let a=un("widget",ln()),r=!1;return{mark:o=>a.mark(o),has:o=>a.has(o),report(o,n){r||(r=!0,a.set("retries",n),t({widget:wm(e),outcome:o,metrics:a.metrics}))}}}import{createContext as Im,useContext as xm,useEffect as ym,useRef as Xi}from"react";var Qi=Im(()=>{});function Ji(){return xm(Qi)}var Yi=Qi.Provider;function Lm(e){let t=window.requestIdleCallback;typeof t=="function"?t(e):setTimeout(e,500)}function Zi(e){let t=Xi(e);t.current=e;let a=Xi(!1);ym(()=>{if(!e.painted||a.current)return;a.current=!0;let r=requestAnimationFrame(()=>{let o=t.current;$t(o.paintMark),Lm(()=>Vi(o))});return()=>cancelAnimationFrame(r)},[e.painted])}import{jsx as Dm}from"react/jsx-runtime";var bm="/api/mcp/resource",vm=500,km=0,Tm=16,Am="2026-01-26",Pm=300,Rm=3e3,Em=3,Mm=2e3;function Fm(e){if(typeof e!="string")return;let t=e.trim();return t.length>0?t:void 0}function _m(e,t,a){return Ra(e,t,a)?!1:t._meta?.["waniwani/autoInjectResultText"]!==!1}function Fa({resourceUri:e,toolInput:t,toolResult:a,resourceEndpoint:r=bm,chatSessionId:o,isDark:n=!1,className:s,autoHeight:i=!1,onOpenLink:l,onFollowUp:u,onCallTool:d,onDisplayModeChange:c,isFullscreen:f=!1,toolDefinitions:p}){let m=Fe(null),L=Fe(t),C=Fe(a),y=Fe({width:0,height:0}),S=Fe(null),I=Fe(!1),x=Fe(0),v=Fe("inline"),[N,U]=el(km),[j,ie]=el(void 0),z=Fe(l),G=Fe(u),q=Fe(d),ee=Fe(c),W=Fe(o),Q=Fe(p);L.current=t,C.current=a,z.current=l,G.current=u,q.current=d,ee.current=c,W.current=o,Q.current=p;let E=Cm(k=>i?Math.max(k+Tm,0):Math.min(Math.max(k,50),vm),[i]),b=Sm(()=>{let k=r.includes("?")?"&":"?";return`${r}${k}uri=${encodeURIComponent(e)}`},[r,e]),_=Ji(),oe=Fe(null),ne=Fe(void 0);Er(()=>{let k=Ki(e,_);return oe.current=k,()=>{clearTimeout(ne.current),k.has("initialized")||k.report("timeout",x.current),oe.current=null}},[e,_]);let Ae=Fe(n);Ae.current=n;let Ne=Fe(f);return Er(()=>{Ne.current=f,y.current.height=-1,S.current&&(S.current.cancel(),S.current=null)},[f]),Er(()=>{if(!I.current)return;let k=m.current;k?.contentWindow&&k.contentWindow.postMessage({jsonrpc:"2.0",method:"ui/notifications/host-context-changed",params:{theme:n?"dark":"light"}},"*")},[n]),Er(()=>{let k=m.current;if(!k)return;let H=!1,$=!1,se=null,he=null,Ie=setTimeout(()=>{if(H||$||x.current>=Em)return;x.current+=1;let X=new URL(k.src);X.searchParams.set("_retry",String(x.current)),k.src=X.toString()},Rm),ce=X=>{k.contentWindow?.postMessage(X,"*")},K=X=>{if(H||X.source!==k.contentWindow)return;let pe=X.data;if(!pe||typeof pe!="object"||pe.jsonrpc!=="2.0")return;let Ce=pe.method,le=pe.id;if(Ce==="ui/initialize"&&le!=null){$=!0,oe.current?.mark("initialize"),clearTimeout(Ie),ce({jsonrpc:"2.0",id:le,result:{protocolVersion:pe.params?.protocolVersion??Am,hostInfo:{name:"Waniwani Chat",version:"1.0.0"},hostCapabilities:{openLinks:{},message:{text:{}},tools:{},updateModelContext:{text:{},structuredContent:{}}},hostContext:{theme:Ae.current?"dark":"light",displayMode:v.current}}});return}if(Ce==="ui/notifications/initialized"){I.current=!0,oe.current?.mark("initialized"),ne.current=setTimeout(()=>oe.current?.report("ok",x.current),Mm);let re=L.current,te=C.current,Z=te._meta&&typeof te._meta=="object"?te._meta:null,J=Fm(W.current),me=Z&&typeof Z.waniwani=="object"&&Z.waniwani!==null?Z.waniwani:null,T=me||J?{...me??{},...J?{sessionId:J}:{}}:void 0,Be=Z||T?{...Z??{},...T?{waniwani:T}:{}}:void 0;ce({jsonrpc:"2.0",method:"ui/notifications/tool-input",params:{arguments:re}});let D=te.content??[{type:"text",text:JSON.stringify(te)}];ce({jsonrpc:"2.0",method:"ui/notifications/tool-result",params:{content:D,structuredContent:te.structuredContent,_meta:Be,meta:Be}});return}if(Ce==="ui/notifications/size-changed"){clearTimeout(ne.current),oe.current?.mark("firstSize"),oe.current?.report("ok",x.current);let re=pe.params,te=typeof re?.height=="number"?re.height:void 0,Z=typeof re?.width=="number"?re.width:void 0,J=y.current,me=te!==void 0&&te!==J.height,T=Z!==void 0&&Z!==J.width;if(!me&&!T)return;if(me&&te!==void 0){if(J.height=te,Ne.current)return;let Be=E(te),D=k.getBoundingClientRect().height;if(S.current&&(S.current.cancel(),S.current=null),U(Be),k.animate&&Math.abs(D-Be)>2){let R=k.animate([{height:`${D}px`},{height:`${Be}px`}],{duration:Pm,easing:"ease-out",fill:"forwards"});S.current=R,R.onfinish=()=>{S.current===R&&(R.cancel(),S.current=null)}}}T&&i&&Z!==void 0&&(J.width=Z,ie(Z));return}if(Ce==="ui/open-link"&&le!=null){let re=pe.params?.url;typeof re=="string"&&(z.current?z.current(re):window.open(re,"_blank","noopener,noreferrer")),ce({jsonrpc:"2.0",id:le,result:{}});return}if(Ce==="ui/message"&&le!=null){if(G.current&&pe.params){let re=pe.params,te=se;if(se=null,he){clearTimeout(he.timer);let Z=he.text;he=null;let J=(re.content??[]).map(me=>me.text??"").join("").trim();re={...re,content:[{type:"text",text:`${J}
|
|
2
|
+
import{a as li,b as ui,c as di,d as ci,e as fi,f as Lr,g as pi,h as mi,i as hi,j as gi,k as qo,l as wi,m as ea,n as ta,o as Cr,p as aa,u as wa}from"../chunk-QIQG7C7A.js";import"../chunk-V3ZDECK5.js";import{useCallback as Cm,useEffect as Er,useMemo as Sm,useRef as Fe,useState as el}from"react";function Nt(e){if(!e)return!1;let t=Array.isArray(e.content)&&e.content.length>0,a=typeof e.structuredContent=="object"&&e.structuredContent!==null&&Object.keys(e.structuredContent).length>0;return t||a}function Ii(e,t){return!Nt(e)&&!Nt(t)?null:Nt(e)?Nt(t)?{...e.content||t.content?{content:[...e.content??[],...t.content??[]]}:{},...e.structuredContent||t.structuredContent?{structuredContent:{...e.structuredContent??{},...t.structuredContent??{}}}:{}}:{...e.content?{content:[...e.content]}:{},...e.structuredContent?{structuredContent:{...e.structuredContent}}:{}}:{...t?.content?{content:[...t.content]}:{},...t?.structuredContent?{structuredContent:{...t.structuredContent}}:{}}}import{forwardRef as sp,createElement as ip}from"react";var Sr=(...e)=>e.filter((t,a,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===a).join(" ").trim();var xi=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();var yi=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,a,r)=>r?r.toUpperCase():a.toLowerCase());var Ho=e=>{let t=yi(e);return t.charAt(0).toUpperCase()+t.slice(1)};import{forwardRef as np,createElement as Si}from"react";var Li={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};var Ci=e=>{for(let t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};var bi=np(({color:e="currentColor",size:t=24,strokeWidth:a=2,absoluteStrokeWidth:r,className:o="",children:n,iconNode:s,...i},l)=>Si("svg",{ref:l,...Li,width:t,height:t,stroke:e,strokeWidth:r?Number(a)*24/Number(t):a,className:Sr("lucide",o),...!n&&!Ci(i)&&{"aria-hidden":"true"},...i},[...s.map(([u,d])=>Si(u,d)),...Array.isArray(n)?n:[n]]));var de=(e,t)=>{let a=sp(({className:r,...o},n)=>ip(bi,{ref:n,iconNode:t,className:Sr(`lucide-${xi(Ho(e))}`,`lucide-${e}`,r),...o}));return a.displayName=Ho(e),a};var lp=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Ia=de("arrow-down",lp);var up=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],xa=de("arrow-up",up);var dp=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],ya=de("check",dp);var cp=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],bt=de("chevron-down",cp);var fp=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],La=de("chevron-right",fp);var pp=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",key:"4jdomd"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4",key:"3hqy98"}],["path",{d:"M21 14H11",key:"1bme5i"}],["path",{d:"m15 10-4 4 4 4",key:"5dvupr"}]],Ca=de("clipboard-copy",pp);var mp=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],gt=de("clock",mp);var hp=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],Sa=de("file-text",hp);var gp=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}]],ra=de("file",gp);var wp=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],ba=de("globe",wp);var Ip=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],va=de("image",Ip);var xp=[["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m16.2 7.8 2.9-2.9",key:"r700ao"}],["path",{d:"M18 12h4",key:"wj9ykh"}],["path",{d:"m16.2 16.2 2.9 2.9",key:"1bxg5t"}],["path",{d:"M12 18v4",key:"jadmvz"}],["path",{d:"m4.9 19.1 2.9-2.9",key:"bwix9q"}],["path",{d:"M2 12h4",key:"j09sii"}],["path",{d:"m4.9 4.9 2.9 2.9",key:"giyufr"}]],ka=de("loader",xp);var yp=[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]],oa=de("paperclip",yp);var Lp=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],Ta=de("square",Lp);var Cp=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],qt=de("wrench",Cp);var Sp=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],vt=de("x",Sp);var bp=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],Aa=de("zap",bp);import{createContext as Op,useCallback as Up,useContext as Mi,useEffect as Np,useMemo as Xo,useRef as qp,useState as Qo}from"react";function $o(e){if(!(typeof e!="object"||e===null))return e}function vi(e){return $o(e?.ui)}function Wo(e){if(!e)return;let t=vi(e)?.resourceUri;if(typeof t=="string"&&t.length>0)return t;let a=e["ui/resourceUri"];if(typeof a=="string"&&a.length>0)return a;let r=e["openai/outputTemplate"];if(typeof r=="string"&&r.length>0)return r}function Pa(e){return vi(e)?.autoHeight===!0}function jo(e){return $o($o(e)?._meta)}import{createContext as vp,useContext as kp,useEffect as Tp,useMemo as Ap,useState as Pi}from"react";var ki=["en","fr","es"];function na(e){return ki.includes(e)}function zo(e){if(e&&na(e))return e;if(e){let a=e.split("-")[0]?.toLowerCase();if(a&&na(a))return a}let t=[];if(typeof navigator<"u"&&(navigator.language&&t.push(navigator.language),navigator.languages&&t.push(...navigator.languages)),typeof document<"u"){let a=document.documentElement.getAttribute("lang");a&&t.push(a)}for(let a of t){let r=a.toLowerCase();if(na(r))return r;let o=r.split("-")[0];if(o&&na(o))return o}return"en"}var br={promptInput:{placeholder:"What would you like to know?",uploadFiles:"Upload files",uploadFilesUpTo:"Upload a document, up to {limit}",uploadFilesUpToWithPages:"Upload a document, up to {limit} and {pages} pages",stop:"Stop",submit:"Submit",removeAttachments:"Remove all attachments",removeAttachment:"Remove attachment",uploading:"Uploading\u2026",retry:"Retry",retryUpload:"Retry the upload",uploadFailed:"The upload did not finish.",dropToAttach:"Drop to attach",errorAccept:"{name} is not a file type this chat accepts.",errorTooLarge:"{name} is larger than {limit}.",errorTooMany:"You can attach up to {limit} files."},workingIndicator:{default:"On it\u2026"},reasoning:{thinking:"Thinking\u2026",thoughtBrief:"Thought for a few seconds",thoughtForSeconds:e=>`Thought for ${e} second${e===1?"":"s"}`},chainOfThought:{working:"Working on it\u2026",done:"Thought process"},tool:{copy:"Copy",copied:"Copied",request:"Request",response:"Response",error:"Error"},attachments:{attachmentFallback:"attachment",kindPdf:"PDF",kindImage:"Image",kindFile:"File",fileFallback:"file"},threadMenu:{newChat:"New chat",threadHistory:"Thread history",deleteThread:"Delete thread",noPreviousChats:"No previous chats yet.",hiddenThreads:e=>`${e} older thread${e===1?"":"s"} hidden`},chatQueue:{attachmentFallback:"(attachment)",removeFromQueue:"Remove from queue",queued:e=>`${e} queued`},poweredBy:{label:"AI agent powered by"},aiDisclaimer:{default:"can make mistakes"},exportSession:{saving:"saving...",saved:"saved",error:"error",export:"export",tooltip:"Save scenario to Waniwani"},widgetErrorBoundary:{failedToLoad:"Widget failed to load",retry:"Retry"},launcher:{prompt:"Ask anything\u2026",open:"Open chat",close:"Close chat",minimize:"Minimize"}};var Ti={promptInput:{placeholder:"\xBFQu\xE9 te gustar\xEDa saber?",uploadFiles:"Subir archivos",uploadFilesUpTo:"Subir un documento, hasta {limit}",uploadFilesUpToWithPages:"Subir un documento, hasta {limit} y {pages} p\xE1ginas",stop:"Detener",submit:"Enviar",removeAttachments:"Eliminar todos los archivos adjuntos",removeAttachment:"Quitar archivo",uploading:"Subiendo\u2026",retry:"Reintentar",retryUpload:"Reintentar la subida",uploadFailed:"La subida no se complet\xF3.",dropToAttach:"Suelta para adjuntar",errorAccept:"{name} no es un tipo de archivo que acepte este chat.",errorTooLarge:"{name} supera {limit}.",errorTooMany:"Puedes adjuntar hasta {limit} archivos."},workingIndicator:{default:"Un momento\u2026"},reasoning:{thinking:"Pensando\u2026",thoughtBrief:"Pensado durante unos segundos",thoughtForSeconds:e=>`Pensado durante ${e} segundo${e===1?"":"s"}`},chainOfThought:{working:"Estoy en ello\u2026",done:"Razonamiento"},tool:{copy:"Copiar",copied:"Copiado",request:"Solicitud",response:"Respuesta",error:"Error"},attachments:{attachmentFallback:"adjunto",kindPdf:"PDF",kindImage:"Imagen",kindFile:"Archivo",fileFallback:"archivo"},threadMenu:{newChat:"Nueva conversaci\xF3n",threadHistory:"Historial",deleteThread:"Eliminar conversaci\xF3n",noPreviousChats:"A\xFAn no hay conversaciones anteriores.",hiddenThreads:e=>`${e} conversaci\xF3n${e===1?"":"es"} anterior${e===1?"":"es"} oculta${e===1?"":"s"}`},chatQueue:{attachmentFallback:"(adjunto)",removeFromQueue:"Quitar de la cola",queued:e=>`${e} en cola`},poweredBy:{label:"Agente IA con tecnolog\xEDa de"},aiDisclaimer:{default:"puede cometer errores"},exportSession:{saving:"guardando...",saved:"guardado",error:"error",export:"exportar",tooltip:"Guardar escenario en Waniwani"},widgetErrorBoundary:{failedToLoad:"No se pudo cargar el widget",retry:"Reintentar"},launcher:{prompt:"Pregunta lo que quieras\u2026",open:"Abrir chat",close:"Cerrar chat",minimize:"Minimizar"}};var Ai={promptInput:{placeholder:"Que souhaitez-vous savoir ?",uploadFiles:"Importer des fichiers",uploadFilesUpTo:"Joindre un document, jusqu'\xE0 {limit}",uploadFilesUpToWithPages:"Envoyer un document, jusqu'\xE0 {limit} et {pages} pages",stop:"Arr\xEAter",submit:"Envoyer",removeAttachments:"Supprimer toutes les pi\xE8ces jointes",removeAttachment:"Retirer la pi\xE8ce jointe",uploading:"Envoi en cours\u2026",retry:"R\xE9essayer",retryUpload:"R\xE9essayer l'envoi",uploadFailed:"L'envoi ne s'est pas termin\xE9.",dropToAttach:"D\xE9posez pour joindre",errorAccept:"{name} n'est pas un type de fichier accept\xE9 par ce chat.",errorTooLarge:"{name} d\xE9passe {limit}.",errorTooMany:"Vous pouvez joindre jusqu'\xE0 {limit} fichiers."},workingIndicator:{default:"Un instant\u2026"},reasoning:{thinking:"R\xE9flexion\u2026",thoughtBrief:"R\xE9flexion pendant quelques secondes",thoughtForSeconds:e=>`R\xE9flexion pendant ${e} seconde${e===1?"":"s"}`},chainOfThought:{working:"Je m'en occupe\u2026",done:"Raisonnement"},tool:{copy:"Copier",copied:"Copi\xE9",request:"Requ\xEAte",response:"R\xE9ponse",error:"Erreur"},attachments:{attachmentFallback:"pi\xE8ce jointe",kindPdf:"PDF",kindImage:"Image",kindFile:"Fichier",fileFallback:"fichier"},threadMenu:{newChat:"Nouvelle conversation",threadHistory:"Historique",deleteThread:"Supprimer la conversation",noPreviousChats:"Aucune conversation pr\xE9c\xE9dente.",hiddenThreads:e=>`${e} conversation${e===1?"":"s"} plus ancienne${e===1?"":"s"} masqu\xE9e${e===1?"":"s"}`},chatQueue:{attachmentFallback:"(pi\xE8ce jointe)",removeFromQueue:"Retirer de la file",queued:e=>`${e} en attente`},poweredBy:{label:"Agent IA propuls\xE9 par"},aiDisclaimer:{default:"peut faire des erreurs"},exportSession:{saving:"enregistrement...",saved:"enregistr\xE9",error:"erreur",export:"exporter",tooltip:"Enregistrer le sc\xE9nario dans Waniwani"},widgetErrorBoundary:{failedToLoad:"\xC9chec du chargement du widget",retry:"R\xE9essayer"},launcher:{prompt:"Posez votre question\u2026",open:"Ouvrir le chat",close:"Fermer le chat",minimize:"R\xE9duire"}};var Vo={en:br,fr:Ai,es:Ti};import{jsx as Ep}from"react/jsx-runtime";var Ri=vp(null);function Pp(e,t){if(!t)return e;let a={...e};for(let r of Object.keys(e)){let o=e[r],n=t[r];n&&typeof o=="object"&&(a[r]={...o,...n})}return a}function Go({children:e,locale:t,messages:a}){let r=!!(t&&Rp(t)),o=r?t:"en",[n,s]=Pi(o),[i,l]=Pi(r);Tp(()=>{s(zo(t)),l(!0)},[t]);let u=Ap(()=>{let d=Vo[n]??Vo["en"];return{locale:n,t:Pp(d,a),ready:i}},[n,a,i]);return Ep(Ri.Provider,{value:u,children:e})}function Rp(e){return e==="en"||e==="fr"||e==="es"}function ae(){let e=kp(Ri);return e||{locale:"en",t:br,ready:!0}}function Ko(e,t){let a=Date.now()-e;if(a<6e4)try{return new Intl.RelativeTimeFormat(t,{numeric:"auto",style:"narrow"}).format(0,"second")}catch{return"just now"}let r,o;a<60*6e4?(r=-Math.floor(a/6e4),o="minute"):a<1440*6e4?(r=-Math.floor(a/(60*6e4)),o="hour"):(r=-Math.floor(a/(1440*6e4)),o="day");try{return new Intl.RelativeTimeFormat(t,{numeric:"auto",style:"short"}).format(r,o)}catch{return`${Math.abs(r)}${o==="minute"?"m":o==="hour"?"h":"d"} ago`}}var Mp=ui({prefix:"ww"});function A(...e){return Mp(li(e))}import{jsx as Fp}from"react/jsx-runtime";var lt=({className:e,variant:t="default",size:a="default",type:r="button",...o})=>Fp("button",{type:r,className:A("ww:inline-flex ww:cursor-pointer ww:items-center ww:justify-center ww:rounded-md ww:font-medium ww:transition-colors ww:disabled:pointer-events-none ww:disabled:opacity-50",t==="default"&&"ww:bg-primary ww:text-primary-foreground ww:hover:bg-primary/90",t==="outline"&&"ww:border ww:border-border ww:bg-background ww:hover:bg-accent ww:hover:text-accent-foreground",t==="ghost"&&"ww:hover:bg-accent ww:hover:text-accent-foreground",a==="default"&&"ww:h-9 ww:px-4 ww:py-2 ww:text-sm",a==="sm"&&"ww:h-8 ww:px-3 ww:text-xs",a==="icon"&&"ww:size-9 ww:!rounded-full",a==="icon-sm"&&"ww:size-7 ww:!rounded-full",e),...o});import{memo as _p}from"react";import{jsx as Bp}from"react/jsx-runtime";var Dp=({as:e="span",className:t,duration:a=2,style:r,children:o,...n})=>{let s={backgroundImage:"linear-gradient(90deg, var(--ww-color-muted-foreground) 0%, var(--ww-color-muted-foreground) 40%, var(--ww-color-foreground) 50%, var(--ww-color-muted-foreground) 60%, var(--ww-color-muted-foreground) 100%)",backgroundSize:"250% 100%",WebkitBackgroundClip:"text",backgroundClip:"text",color:"transparent",animation:`ww-shimmer ${a}s linear infinite`,...r};return Bp(e,{"data-waniwani-shimmer":"",className:A("ww:inline-block",t),style:s,...n,children:o})},tt=_p(Dp);tt.displayName="Shimmer";import{Fragment as Ei,jsx as ge,jsxs as Ht}from"react/jsx-runtime";function Hp(e,t=80){if(e==null)return String(e);if(typeof e!="object")return String(e).slice(0,t);if(Array.isArray(e))return`Array(${e.length})`;let a=JSON.stringify(e);if(a.length<=t)return a;let r=Object.entries(e),o=[],n=t-2;for(let[s,i]of r){if(n<=8)break;let l=s.length>4?`${s.slice(0,4)}\u2026`:s,u;typeof i=="string"?u=i.length>2?`'${i.slice(0,1)}\u2026`:`'${i}'`:Array.isArray(i)?u=`Array(${i.length})`:typeof i=="object"&&i!==null?u="{\u2026}":u=String(i);let d=`${l}\u2009${u}`;o.push(d),n-=d.length+3}return`{${o.join(", ")}}`}function $p({text:e,className:t}){let{t:a}=ae(),[r,o]=Qo(!1),n=qp(null);Np(()=>()=>{n.current&&clearTimeout(n.current)},[]);let s=Up(async i=>{i.stopPropagation();try{await navigator.clipboard.writeText(e),o(!0),n.current&&clearTimeout(n.current),n.current=setTimeout(()=>o(!1),2e3)}catch{}},[e]);return ge(lt,{variant:"ghost",size:"sm",onClick:s,className:A("ww:h-auto ww:gap-1 ww:px-1.5 ww:py-0.5 ww:text-xs ww:text-muted-foreground ww:hover:text-foreground",t),children:r?Ht(Ei,{children:[ge(ya,{className:"ww:size-3.5"}),ge("span",{children:a.tool.copied})]}):Ht(Ei,{children:[ge(Ca,{className:"ww:size-3.5"}),ge("span",{children:a.tool.copy})]})})}function Fi({data:e,label:t,className:a,...r}){let[o,n]=Qo(!1),s=Xo(()=>JSON.stringify(e,null,2),[e]),i=Hp(e);return Ht("div",{className:A("ww:rounded-lg ww:bg-tool-card",a),...r,children:[Ht("div",{className:"ww:flex ww:items-center ww:justify-between ww:px-3 ww:pt-2.5 ww:pb-1.5",children:[ge("span",{className:"ww:text-xs ww:font-medium ww:text-muted-foreground",children:t}),ge($p,{text:s})]}),Ht("button",{type:"button",onClick:()=>n(l=>!l),className:"ww:flex ww:w-full ww:items-start ww:gap-2 ww:px-3 ww:pb-3 ww:text-left",children:[ge(La,{className:A("ww:mt-0.5 ww:size-3.5 ww:shrink-0 ww:text-muted-foreground ww:transition-transform ww:duration-150",o&&"ww:rotate-90")}),o?ge("pre",{className:"ww:overflow-x-auto ww:text-xs ww:font-mono ww:text-foreground ww:whitespace-pre-wrap ww:break-all",children:ge("code",{children:s})}):ge("span",{className:"ww:truncate ww:text-xs ww:font-mono ww:text-foreground/80",children:i})]})]})}var Jo=Op({open:!1,toggle:()=>{}});function _i({className:e,defaultOpen:t=!1,children:a,...r}){let[o,n]=Qo(t);return ge(Jo.Provider,{value:{open:o,toggle:()=>n(s=>!s)},children:ge("div",{className:A("ww:mb-4 ww:w-full",e),"data-state":o?"open":"closed",style:{animation:"ww-fade-in 0.2s ease-out"},...r,children:a})})}function Di({className:e,title:t,state:a,...r}){let{open:o,toggle:n}=Mi(Jo),s=a==="input-available"||a==="input-streaming",i=t??"";return Ht("button",{type:"button",onClick:n,className:A("ww:flex ww:w-full ww:items-center ww:gap-2 ww:text-sm ww:text-muted-foreground ww:transition-colors ww:hover:text-foreground",e),"aria-expanded":o,...r,children:[ge(qt,{className:"ww:size-4 ww:shrink-0"}),ge("span",{className:"ww:truncate",children:s?ge(tt,{duration:1.6,children:i}):i}),ge(bt,{className:A("ww:size-4 ww:shrink-0 ww:transition-transform ww:duration-200",o&&"ww:rotate-180")})]})}function Bi({className:e,title:t,state:a,...r}){let o=a==="input-available"||a==="input-streaming",n=t??"";return ge("div",{className:A("ww:mb-4 ww:flex ww:items-center ww:gap-2 ww:text-sm ww:text-muted-foreground",e),style:{animation:"ww-fade-in 0.2s ease-out"},...r,children:ge("span",{className:"ww:truncate",children:o?ge(tt,{duration:1.6,children:n}):n})})}function Oi({className:e,children:t,...a}){let{open:r}=Mi(Jo);return ge("div",{className:A("ww:grid ww:transition-[grid-template-rows,opacity] ww:duration-200 ww:ease-out",r?"ww:grid-rows-[1fr] ww:opacity-100":"ww:grid-rows-[0fr] ww:opacity-0"),children:ge("div",{className:"ww:min-h-0 ww:overflow-hidden",children:ge("div",{className:A("ww:mt-2 ww:space-y-3 ww:rounded-lg ww:border ww:border-border ww:bg-background ww:p-3",e),...a,children:t})})})}function Yo({className:e,input:t,debug:a,...r}){let{t:o}=ae(),n=Xo(()=>{if(!a&&typeof t=="object"&&t!==null&&!Array.isArray(t)){let{_meta:s,...i}=t;return i}return t},[t,a]);return ge(Fi,{data:n,label:o.tool.request,className:e,...r})}function Ra(e,t,a){if(e){let r=Wo(a?.[e]?._meta);if(r)return r}return Wo(jo(t))}function Ui(e,t,a){return e&&Pa(a?.[e]?._meta)?!0:Pa(jo(t))}function Zo({className:e,output:t,errorText:a,debug:r,...o}){let{t:n}=ae(),s=Xo(()=>{if(!r&&typeof t=="object"&&t!==null&&!Array.isArray(t)){let{_meta:i,...l}=t;return l}return t},[t,r]);return t||a?a?Ht("div",{className:A("ww:space-y-2",e),...o,children:[ge("h4",{className:"ww:text-xs ww:font-medium ww:uppercase ww:tracking-wide ww:text-muted-foreground",children:n.tool.error}),ge("div",{className:"ww:rounded-lg ww:bg-destructive/10 ww:p-3 ww:text-xs ww:text-destructive",children:a})]}):ge(Fi,{data:s,label:n.tool.response,className:e,...o}):null}var Ni=typeof performance>"u"?0:performance.now(),qi=typeof window<"u"&&!!window.WaniWani?.chat;function at(e,t,a){let[r,o=""]=e.split("?"),n=r.replace(/\/$/,""),s=new URLSearchParams(o);if(a)for(let[l,u]of Object.entries(a))s.set(l,u);let i=s.toString();return`${n}${t}${i?`?${i}`:""}`}var Wp="/api/mcp/";function vr(e,t){let[a=""]=e.split("?"),r="",o=a;try{let n=new URL(a);r=n.origin,o=n.pathname}catch{if(!a.startsWith("/"))return null}return o.startsWith(Wp)?`${r}${t}`:null}function jp(){if(typeof window>"u")return!1;try{return window.WANIWANI_DEBUG?!0:!!window.localStorage?.getItem("WANIWANI_DEBUG")}catch{return!1}}function ut(...e){jp()&&console.log("[Waniwani]",...e)}var en="waniwani-visitor-id";function zp(){try{if(typeof crypto<"u"){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();if(typeof crypto.getRandomValues=="function"){let e=crypto.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=Array.from(e,a=>a.toString(16).padStart(2,"0")).join("");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}}}catch{}return`v-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function Ge(){try{let t=localStorage.getItem(en);if(t)return t}catch{}let e=zp();try{localStorage.setItem(en,e)}catch{}return e}function tn(e){let t=typeof e=="string"?e.trim():"";if(!t)return Ge();try{localStorage.setItem(en,t)}catch{}return t}function Vp(e){return e!=null&&typeof e.then=="function"}function an(e){let t=!1,a=()=>{t=!0};if(e==null)return a;let r;try{r=typeof e=="function"?e():e}catch{return a}return Vp(r)?r.then(o=>{t||tn(o??"")},()=>{}):tn(r??""),a}var Gp="waniwani-memory";var Ke="threads",kr="by_memoryUserId",Kp="by_updatedAt";var $i="memoryUserId",Hi="waniwani-memory-user-id",rn=null;function on(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}function Xp(e,t){if(t<1&&(e.objectStoreNames.contains("ids")||e.createObjectStore("ids")),t<2&&!e.objectStoreNames.contains(Ke)){let a=e.createObjectStore(Ke,{keyPath:"threadId"});a.createIndex(kr,"memoryUserId",{unique:!1}),a.createIndex(Kp,"updatedAt",{unique:!1})}}async function nn(){return new Promise((e,t)=>{let a=indexedDB.open(Gp,2);a.onupgradeneeded=r=>{Xp(a.result,r.oldVersion)},a.onsuccess=()=>e(a.result),a.onerror=()=>t(a.error)})}async function Qp(){return nn()}async function Jp(e){return new Promise((t,a)=>{let n=e.transaction("ids","readonly").objectStore("ids").get($i);n.onsuccess=()=>t(typeof n.result=="string"?n.result:null),n.onerror=()=>a(n.error)})}async function Yp(e,t){return new Promise((a,r)=>{let s=e.transaction("ids","readwrite").objectStore("ids").put(t,$i);s.onsuccess=()=>a(),s.onerror=()=>r(s.error)})}async function Zp(){if(typeof indexedDB>"u")return null;try{let e=await Qp();try{let t=await Jp(e);if(t)return t;let a=on();return await Yp(e,a),a}finally{e.close()}}catch{return null}}function em(){try{let e=localStorage.getItem(Hi);if(e)return e;let t=on();return localStorage.setItem(Hi,t),t}catch{return null}}async function Wi(){let e=await Zp();if(e)return e;let t=em();return t||(rn||(rn=on()),rn)}function ji(e,t){return e.match(t)?.[1]??null}function tm(e){let t=[["Edge",/Edg(?:e|A|iOS)?\/(\S+)/],["Opera",/(?:OPR|Opera)\/(\S+)/],["Samsung Internet",/SamsungBrowser\/(\S+)/],["Firefox",/Firefox\/(\S+)/],["Chrome",/Chrome\/(\S+)/],["Safari",/Version\/(\S+).*Safari/]];for(let[a,r]of t){let o=ji(e,r);if(o)return{name:a,version:o}}return null}function am(e){let t=[["iOS",/(?:iPhone|iPad|iPod).+?OS (\d+[_.\d]*)/],["Android",/Android (\d+[.\d]*)/],["macOS",/Mac OS X (\d+[_.\d]*)/],["Windows",/Windows NT (\d+[.\d]*)/],["ChromeOS",/CrOS \S+ (\d+[.\d]*)/],["Linux",/Linux/]];for(let[a,r]of t){let o=ji(e,r);if(o)return{name:a,version:o.replace(/_/g,".")};if(a==="Linux"&&r.test(e))return{name:a,version:""}}return null}function rm(e){return typeof navigator<"u"&&"userAgentData"in navigator&&navigator.userAgentData?.mobile?"mobile":/iPad|tablet|PlayBook/i.test(e)?"tablet":/Mobi|Android.*Mobile|iPhone|iPod/i.test(e)?"mobile":"desktop"}async function Ea(){let e=navigator.userAgent,t=Ge(),a=await Wi();return{userAgent:e,browser:tm(e),os:am(e),deviceType:rm(e),language:navigator.language,languages:[...navigator.languages],timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,screenWidth:screen.width,screenHeight:screen.height,viewportWidth:window.innerWidth,viewportHeight:window.innerHeight,colorDepth:screen.colorDepth,devicePixelRatio:window.devicePixelRatio??1,touchSupport:"ontouchstart"in window||navigator.maxTouchPoints>0,connectionType:navigator.connection?.effectiveType??"unknown",referrer:document.referrer,visitorId:t,memoryUserId:a}}var om="0.22.0-beta.4",nm=40,sm=10,im=6e5;function ln(){return typeof performance>"u"?0:performance.now()}function un(e,t){let a={};return{metrics:a,has:r=>r in a,set(r,o){a[r]=o},mark(r,o=ln()){if(!(r in a)){a[r]=o-t;try{performance.mark(`waniwani:${e}:${r}`,{startTime:o})}catch{}}}}}function lm(e){let t={};for(let[a,r]of Object.entries(e)){if(Object.keys(t).length>=nm)break;if(!Number.isFinite(r))continue;let o=Math.round(r);o<0||o>im||(t[a]=o)}return t}function um(e){let t={};for(let[a,r]of Object.entries(e)){if(Object.keys(t).length>=sm)break;(typeof r=="string"||typeof r=="boolean")&&(t[a]=r)}return t}function dm(){let e=navigator.connection;if(e)return{effectiveType:e.effectiveType,rtt:e.rtt,downlink:e.downlink,saveData:e.saveData}}function Ar(e){let t=e?.Authorization;return typeof t=="string"&&t.startsWith("Bearer ")?t.slice(7):void 0}function cm(e,t,a,r){return{kind:e,sdkVersion:om,channelId:t.channelId||void 0,sessionId:e==="boot"?void 0:t.sessionId||void 0,visitorId:Ge(),pageHost:window.location.hostname,connection:dm(),tags:um(a),metrics:lm(r)}}var sn,Tr=[];function Pr(e){let t=String(e?.chatTimingLogs).trim().toLowerCase()==="true";sn=t;let a=Tr;if(Tr=[],t)for(let r of a)r()}function Rr(e,t,a,r){let{api:o,token:n}=t;if(!(typeof window>"u"||!o||!n||sn===!1))try{let s=cm(e,t,a,r),i=()=>{ut("timing",s),fetch(at(o,"/timing"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify(s),keepalive:!0}).catch(()=>{})};sn?i():Tr.length<20&&Tr.push(i)}catch{}}var wt=un("boot",0),zi;function $t(e,t){wt.mark(e,t)}function Ma(e){zi??=e}var fm=/cdn\.jsdelivr\.net\/npm\/@waniwani\/sdk@[^/]+\/dist\/chat\/embed\.js/,pm=/\/embed\.js(\?|$)/;function mm(){if(typeof performance>"u")return;let e=performance.getEntriesByType("navigation")[0];e?.responseStart&&wt.mark("navTtfb",e.responseStart),e?.domContentLoadedEventEnd&&wt.mark("navDomContentLoaded",e.domContentLoadedEventEnd);let t=performance.getEntriesByType("resource");for(let a of t)fm.test(a.name)?(wt.mark("bundleStart",a.startTime),wt.mark("bundleEnd",a.responseEnd)):pm.test(a.name)&&(wt.mark("loaderStart",a.startTime),wt.mark("loaderEnd",a.responseEnd))}function hm(){if(qi)return!0;try{return document.querySelectorAll('script[src*="@waniwani/sdk"]').length>1}catch{return!1}}function Vi(e){mm(),wt.mark("bundleExecuted",Ni),Rr("boot",e,{configSource:zi,mode:e.mode,secondSdk:hm()},wt.metrics)}var gm=[["text-delta","firstText"],["tool-input-start","firstToolInput"],["tool-output-available","firstToolOutput"]];function Gi(e){let t=un("turn",ln());t.set("turnIndex",e);let a=!1;return{mark:r=>t.mark(r),instrument(r){if(!r.ok||!r.body||typeof TransformStream>"u")return r;try{let o=new TextDecoder,n=r.body.pipeThrough(new TransformStream({transform(s,i){t.mark("firstChunk");let l=o.decode(s,{stream:!0});for(let[u,d]of gm)!t.has(d)&&l.includes(u)&&t.mark(d);i.enqueue(s)}}));return new Response(n,{status:r.status,statusText:r.statusText,headers:r.headers})}catch{return r}},report(r,o){a||(a=!0,Rr("turn",r,o,t.metrics))}}}function wm(e){let t=e.indexOf("?");return t===-1?e:e.slice(0,t)}function Ki(e,t){let a=un("widget",ln()),r=!1;return{mark:o=>a.mark(o),has:o=>a.has(o),report(o,n){r||(r=!0,a.set("retries",n),t({widget:wm(e),outcome:o,metrics:a.metrics}))}}}import{createContext as Im,useContext as xm,useEffect as ym,useRef as Xi}from"react";var Qi=Im(()=>{});function Ji(){return xm(Qi)}var Yi=Qi.Provider;function Lm(e){let t=window.requestIdleCallback;typeof t=="function"?t(e):setTimeout(e,500)}function Zi(e){let t=Xi(e);t.current=e;let a=Xi(!1);ym(()=>{if(!e.painted||a.current)return;a.current=!0;let r=requestAnimationFrame(()=>{let o=t.current;$t(o.paintMark),Lm(()=>Vi(o))});return()=>cancelAnimationFrame(r)},[e.painted])}import{jsx as Dm}from"react/jsx-runtime";var bm="/api/mcp/resource",vm=500,km=0,Tm=16,Am="2026-01-26",Pm=300,Rm=3e3,Em=3,Mm=2e3;function Fm(e){if(typeof e!="string")return;let t=e.trim();return t.length>0?t:void 0}function _m(e,t,a){return Ra(e,t,a)?!1:t._meta?.["waniwani/autoInjectResultText"]!==!1}function Fa({resourceUri:e,toolInput:t,toolResult:a,resourceEndpoint:r=bm,chatSessionId:o,isDark:n=!1,className:s,autoHeight:i=!1,onOpenLink:l,onFollowUp:u,onCallTool:d,onDisplayModeChange:c,isFullscreen:f=!1,toolDefinitions:p}){let m=Fe(null),L=Fe(t),C=Fe(a),y=Fe({width:0,height:0}),S=Fe(null),I=Fe(!1),x=Fe(0),v=Fe("inline"),[N,U]=el(km),[j,ie]=el(void 0),z=Fe(l),G=Fe(u),q=Fe(d),ee=Fe(c),W=Fe(o),Q=Fe(p);L.current=t,C.current=a,z.current=l,G.current=u,q.current=d,ee.current=c,W.current=o,Q.current=p;let E=Cm(k=>i?Math.max(k+Tm,0):Math.min(Math.max(k,50),vm),[i]),b=Sm(()=>{let k=r.includes("?")?"&":"?";return`${r}${k}uri=${encodeURIComponent(e)}`},[r,e]),_=Ji(),oe=Fe(null),ne=Fe(void 0);Er(()=>{let k=Ki(e,_);return oe.current=k,()=>{clearTimeout(ne.current),k.has("initialized")||k.report("timeout",x.current),oe.current=null}},[e,_]);let Ae=Fe(n);Ae.current=n;let Ne=Fe(f);return Er(()=>{Ne.current=f,y.current.height=-1,S.current&&(S.current.cancel(),S.current=null)},[f]),Er(()=>{if(!I.current)return;let k=m.current;k?.contentWindow&&k.contentWindow.postMessage({jsonrpc:"2.0",method:"ui/notifications/host-context-changed",params:{theme:n?"dark":"light"}},"*")},[n]),Er(()=>{let k=m.current;if(!k)return;let H=!1,$=!1,se=null,he=null,Ie=setTimeout(()=>{if(H||$||x.current>=Em)return;x.current+=1;let X=new URL(k.src);X.searchParams.set("_retry",String(x.current)),k.src=X.toString()},Rm),ce=X=>{k.contentWindow?.postMessage(X,"*")},K=X=>{if(H||X.source!==k.contentWindow)return;let pe=X.data;if(!pe||typeof pe!="object"||pe.jsonrpc!=="2.0")return;let Ce=pe.method,le=pe.id;if(Ce==="ui/initialize"&&le!=null){$=!0,oe.current?.mark("initialize"),clearTimeout(Ie),ce({jsonrpc:"2.0",id:le,result:{protocolVersion:pe.params?.protocolVersion??Am,hostInfo:{name:"Waniwani Chat",version:"1.0.0"},hostCapabilities:{openLinks:{},message:{text:{}},tools:{},updateModelContext:{text:{},structuredContent:{}}},hostContext:{theme:Ae.current?"dark":"light",displayMode:v.current}}});return}if(Ce==="ui/notifications/initialized"){I.current=!0,oe.current?.mark("initialized"),ne.current=setTimeout(()=>oe.current?.report("ok",x.current),Mm);let re=L.current,te=C.current,Z=te._meta&&typeof te._meta=="object"?te._meta:null,J=Fm(W.current),me=Z&&typeof Z.waniwani=="object"&&Z.waniwani!==null?Z.waniwani:null,T=me||J?{...me??{},...J?{sessionId:J}:{}}:void 0,Be=Z||T?{...Z??{},...T?{waniwani:T}:{}}:void 0;ce({jsonrpc:"2.0",method:"ui/notifications/tool-input",params:{arguments:re}});let D=te.content??[{type:"text",text:JSON.stringify(te)}];ce({jsonrpc:"2.0",method:"ui/notifications/tool-result",params:{content:D,structuredContent:te.structuredContent,_meta:Be,meta:Be}});return}if(Ce==="ui/notifications/size-changed"){clearTimeout(ne.current),oe.current?.mark("firstSize"),oe.current?.report("ok",x.current);let re=pe.params,te=typeof re?.height=="number"?re.height:void 0,Z=typeof re?.width=="number"?re.width:void 0,J=y.current,me=te!==void 0&&te!==J.height,T=Z!==void 0&&Z!==J.width;if(!me&&!T)return;if(me&&te!==void 0){if(J.height=te,Ne.current)return;let Be=E(te),D=k.getBoundingClientRect().height;if(S.current&&(S.current.cancel(),S.current=null),U(Be),k.animate&&Math.abs(D-Be)>2){let R=k.animate([{height:`${D}px`},{height:`${Be}px`}],{duration:Pm,easing:"ease-out",fill:"forwards"});S.current=R,R.onfinish=()=>{S.current===R&&(R.cancel(),S.current=null)}}}T&&i&&Z!==void 0&&(J.width=Z,ie(Z));return}if(Ce==="ui/open-link"&&le!=null){let re=pe.params?.url;typeof re=="string"&&(z.current?z.current(re):window.open(re,"_blank","noopener,noreferrer")),ce({jsonrpc:"2.0",id:le,result:{}});return}if(Ce==="ui/message"&&le!=null){if(G.current&&pe.params){let re=pe.params,te=se;if(se=null,he){clearTimeout(he.timer);let Z=he.text;he=null;let J=(re.content??[]).map(me=>me.text??"").join("").trim();re={...re,content:[{type:"text",text:`${J}
|
|
3
3
|
|
|
4
4
|
${Z}`}]}}G.current({...re,...te?{modelContext:te}:{}})}ce({jsonrpc:"2.0",id:le,result:{}});return}if(Ce==="ui/update-model-context"&&le!=null){se=Ii(se,pe.params),ce({jsonrpc:"2.0",id:le,result:{}});return}if(Ce==="tools/call"&&le!=null){let re=q.current;if(!re){ce({jsonrpc:"2.0",id:le,error:{code:-32601,message:"tools/call not supported"}});return}let te=pe.params?.name;re({name:te,arguments:pe.params?.arguments??{}}).then(Z=>{ce({jsonrpc:"2.0",id:le,result:Z});let J=Z.content?.map(me=>me.text??"").join("").trim();J&&_m(te,Z,Q.current)&&(he&&clearTimeout(he.timer),he={text:J,timer:setTimeout(()=>{if(H)return;let me=se;se=null,he=null,G.current?.({role:"user",content:[{type:"text",text:J}],...me?{modelContext:me}:{}})},500)})}).catch(Z=>{let J=Z instanceof Error?Z.message:"Tool call failed";ce({jsonrpc:"2.0",id:le,error:{code:-32e3,message:J}})});return}if(Ce==="ui/request-display-mode"&&le!=null){let re=pe.params?.mode,te=re==="fullscreen"||re==="inline"||re==="pip"?re:"inline";v.current=te,ce({jsonrpc:"2.0",id:le,result:{mode:te}}),ce({jsonrpc:"2.0",method:"ui/notifications/host-context-changed",params:{displayMode:te}}),ee.current?.(te);return}if(Ce==="ui/resource-teardown"&&le!=null){ce({jsonrpc:"2.0",id:le,result:{}});return}Ce==="ping"&&le!=null&&ce({jsonrpc:"2.0",id:le,result:{}})};return window.addEventListener("message",K),()=>{H=!0,clearTimeout(Ie),he&&clearTimeout(he.timer),window.removeEventListener("message",K)}},[i,E]),Dm("iframe",{ref:m,src:b,onLoad:()=>oe.current?.mark("iframeLoad"),sandbox:"allow-scripts allow-forms allow-same-origin allow-popups allow-popups-to-escape-sandbox",className:A(!f&&"ww:rounded-md ww:border ww:border-border",s),style:{height:f?"100%":N,minWidth:f||!j?void 0:`min(${j}px, 100%)`,width:"100%",border:"none",colorScheme:n?"dark":"auto"},title:"MCP App"})}import{useCallback as Bm,useEffect as dn,useState as Om}from"react";import{jsx as cn,jsxs as Nm}from"react/jsx-runtime";var tl=672,al=32;function Um({widget:e,onCallTool:t,toolsEndpoint:a,headers:r,resourceEndpoint:o,onClose:n,isDark:s=!1}){let[i,l]=Om(null);dn(()=>{let p=()=>l({width:window.innerWidth,height:window.innerHeight});return p(),window.addEventListener("resize",p),()=>window.removeEventListener("resize",p)},[]);let u=e?.preview===!0;dn(()=>{if(!e||!u)return;let p=m=>{m.key==="Escape"&&n()};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[e,u,n]),dn(()=>{if(!e)return;let p=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=p}},[e]);let d=Bm(async p=>{if(t)return t(p);if(!a)throw new Error("webmcp overlay needs onCallTool");let m=await fetch(a,{method:"POST",headers:{"content-type":"application/json",...r},body:JSON.stringify({action:"call",...p})});if(!m.ok)throw new Error(`webmcp tool call failed: ${m.status}`);return await m.json()},[t,a,r]);if(!e)return null;let c=i?Math.min(tl,i.width-al):tl,f=i?i.height-al:void 0;return Nm("div",{role:"dialog","aria-modal":"true","aria-label":"Waniwani",className:A("ww:fixed ww:inset-0 ww:z-[2147483000] ww:flex ww:items-center ww:justify-center ww:bg-black/45 ww:backdrop-blur-md",s&&"dark"),children:[u&&cn("button",{type:"button","aria-label":"Close",onClick:n,className:"ww:absolute ww:inset-0 ww:h-full ww:w-full ww:cursor-pointer ww:border-none ww:bg-transparent ww:p-0"}),cn("div",{className:"ww:relative ww:overflow-auto ww:rounded-2xl ww:bg-background ww:shadow-2xl",style:{width:c,maxHeight:f},children:cn(Fa,{resourceUri:e.viewUri,resourceEndpoint:o,toolInput:e.data,toolResult:e.result,autoHeight:Pa(e.result._meta),isDark:s,onCallTool:d,onOpenLink:p=>window.open(p,"_blank","noopener")},`${o}|${e.viewUri}`)})]})}import{forwardRef as tc,useCallback as er,useEffect as xt,useImperativeHandle as kx,useRef as _t,useState as bo}from"react";var _a=(e=21)=>crypto.getRandomValues(new Uint8Array(e)).reduce((t,a)=>(a&=63,a<36?t+=a.toString(36):a<62?t+=(a-26).toString(36).toUpperCase():a>62?t+="-":t+="_",t),"");import{createContext as jm,useCallback as We,useContext as zm,useEffect as Da,useMemo as Vm,useRef as kt,useState as mn}from"react";var Wt=new Map;function rl(e,t){if(Wt.has(e)){URL.revokeObjectURL(t);return}for(Wt.set(e,t);Wt.size>20;){let a=Wt.keys().next();if(a.done)return;let r=Wt.get(a.value);Wt.delete(a.value),r&&URL.revokeObjectURL(r)}}function ol(e){return Wt.get(e)}import{useState as qm}from"react";import{jsx as _e,jsxs as fn}from"react/jsx-runtime";var nl=({files:e,className:t,...a})=>e.length===0?null:_e("div",{className:A("ww:flex ww:flex-wrap ww:gap-1.5",t),...a,children:e.map((r,o)=>_e(Hm,{file:r},o))});function Hm({file:e}){let{t}=ae();return e.mediaType?.startsWith("image/")&&e.url?_e("img",{src:e.url,alt:e.filename??t.attachments.attachmentFallback,className:"ww:h-16 ww:max-w-32 ww:rounded ww:object-cover"}):fn("span",{className:"ww:inline-flex ww:items-center ww:gap-1.5 ww:rounded ww:bg-background/20 ww:px-2 ww:py-1 ww:text-xs",children:[_e(ra,{className:"ww:size-3 ww:shrink-0"}),_e("span",{className:"ww:max-w-24 ww:truncate",children:e.filename??t.attachments.fileFallback})]})}function sl(e,t){return e.startsWith("image/")?t.attachments.kindImage:e==="application/pdf"?t.attachments.kindPdf:t.attachments.kindFile}function $m({mediaType:e}){return e.startsWith("image/")?_e(va,{className:"ww:size-5 ww:text-muted-foreground"}):e==="application/pdf"?_e(Sa,{className:"ww:size-5 ww:text-muted-foreground"}):_e(ra,{className:"ww:size-5 ww:text-muted-foreground"})}function pn({filename:e,mediaType:t,previewUrl:a,subtitle:r,tone:o="default",children:n,className:s}){let{t:i}=ae(),l=sl(t,i);return fn("li",{"aria-label":`${e}, ${l}`,className:A("ww:relative ww:flex ww:w-60 ww:max-w-full ww:cursor-default ww:items-center ww:gap-2.5 ww:overflow-hidden ww:rounded-xl ww:border ww:bg-background ww:p-2.5",o==="error"?"ww:border-destructive/50":"ww:border-border",s),children:[_e("span",{className:"ww:flex ww:size-10 ww:shrink-0 ww:items-center ww:justify-center ww:overflow-hidden ww:rounded-xl ww:bg-muted",children:a?_e("img",{alt:"",className:"ww:size-full ww:object-cover ww:object-center",src:a}):_e($m,{mediaType:t})}),fn("span",{className:"ww:flex ww:min-w-0 ww:flex-col",children:[_e("span",{className:"ww:truncate ww:font-medium ww:text-sm",title:e,children:e}),_e("span",{className:A("ww:truncate ww:text-xs",o==="error"?"ww:text-destructive":"ww:text-muted-foreground"),children:r??l})]}),n]})}function il(e){if(typeof e!="object"||e===null)return[];let t=e.documents;return Array.isArray(t)?t.filter(a=>typeof a=="object"&&a!==null&&typeof a.documentId=="string"&&typeof a.filename=="string"&&typeof a.mediaType=="string"):[]}var ll=({documents:e,className:t,...a})=>e.length===0?null:_e("ul",{className:A("ww:flex ww:list-none ww:flex-wrap ww:items-end ww:justify-end ww:gap-2 ww:p-0",t),...a,children:e.map((r,o)=>_e(Wm,{document:r},`${r.documentId}-${o}`))});function Wm({document:e}){let{t}=ae(),[a,r]=qm(!1),o=e.mediaType.startsWith("image/")?ol(e.documentId):void 0;return o&&!a?_e("li",{children:_e("img",{alt:`${e.filename}, ${sl(e.mediaType,t)}`,className:"ww:max-h-80 ww:max-w-72 ww:rounded-xl ww:border ww:border-border ww:object-contain",onError:()=>r(!0),src:o,title:e.filename})}):_e(pn,{filename:e.filename,mediaType:e.mediaType})}import{jsx as Pe,jsxs as Fr}from"react/jsx-runtime";var Gm=async e=>{try{let a=await(await fetch(e)).blob();return new Promise(r=>{let o=new FileReader;o.onloadend=()=>r(o.result),o.onerror=()=>r(null),o.readAsDataURL(a)})}catch{return null}},Km=(e,t)=>{if(!t)return!0;let a=t.split(",").map(n=>n.trim().toLowerCase()).filter(Boolean);if(a.length===0)return!0;let r=e.type.toLowerCase(),o=e.name.toLowerCase();return a.some(n=>n.startsWith(".")?o.endsWith(n):n.endsWith("/*")?r.startsWith(n.slice(0,-1)):r===n)},dl=jm(null),Mr=()=>{let e=zm(dl);if(!e)throw new Error("usePromptInputAttachments must be used within a PromptInput");return e},cl=({className:e,accept:t,multiple:a,globalDrop:r,maxFiles:o,maxFileSize:n,maxPdfPages:s,attachmentsEnabled:i=!0,upload:l,onDiscard:u,onError:d,onSubmit:c,children:f,...p})=>{let{t:m,locale:L}=ae(),C=kt(null),y=kt(null),[S,I]=mn([]),x=kt(S),v=kt(new Map),N=kt(l),U=kt(d),j=kt(u);Da(()=>{N.current=l,U.current=d,j.current=u},[l,d,u]);let ie=We(k=>{x.current=k,I(k)},[]),z=We(()=>{C.current?.click()},[]),G=We((k,H)=>{ie(x.current.map($=>$.id===k?{...$,...H}:$))},[ie]),q=We((k,H)=>{let $=N.current;if(!$)return;let se=new AbortController,he=$(H,se.signal,Ie=>{G(k,{progress:Ie})}).then(Ie=>(G(k,{status:"ready",progress:1,documentId:Ie.documentId,error:void 0}),Ie)).catch(Ie=>{if(se.signal.aborted)return null;let ce=Ie instanceof Error?Ie.message:m.promptInput.uploadFailed;return G(k,{status:"failed",error:ce}),U.current?.({code:"upload_failed",message:ce}),null});v.current.set(k,{file:H,controller:se,done:he})},[G,m]),ee=We(k=>{let H=[...k];if(!i||H.length===0)return;let $=(X,pe)=>U.current?.({code:X,message:pe}),se=[];for(let X of H){if(!Km(X,t)){$("accept",m.promptInput.errorAccept.replace("{name}",X.name));continue}if(n&&X.size>n){$("max_file_size",m.promptInput.errorTooLarge.replace("{name}",X.name).replace("{limit}",fl(n,L)));continue}se.push(X)}if(se.length===0)return;let he=typeof o=="number"?Math.max(0,o-x.current.length):void 0,Ie=typeof he=="number"?se.slice(0,he):se;if(Ie.length<se.length&&$("max_files",m.promptInput.errorTooMany.replace("{limit}",String(o))),Ie.length===0)return;let ce=!!N.current,K=Ie.map(X=>({file:X,item:{filename:X.name,id:_a(),mediaType:X.type,type:"file",url:URL.createObjectURL(X),status:ce?"uploading":"ready",progress:0}}));ie([...x.current,...K.map(X=>X.item)]);for(let X of K)q(X.item.id,X.file)},[o,n,t,i,q,ie,m,L]),W=We(k=>{let H=v.current.get(k);H&&(G(k,{status:"uploading",progress:0,error:void 0}),q(k,H.file))},[G,q]),Q=We((k,H)=>{v.current.get(k.id)?.controller.abort(),v.current.delete(k.id),k.url&&(!H&&!!k.documentId&&!!k.mediaType?.startsWith("image/")&&k.documentId?rl(k.documentId,k.url):URL.revokeObjectURL(k.url)),H&&k.documentId&&j.current?.({documentId:k.documentId,filename:k.filename??"",mediaType:k.mediaType??""})},[]),E=We(k=>{let H=x.current.find($=>$.id===k);H&&Q(H,!0),ie(x.current.filter($=>$.id!==k))},[Q,ie]),b=We(()=>{for(let k of x.current)Q(k,!0);ie([])},[Q,ie]),_=kt(i);Da(()=>{let k=_.current;_.current=i,k&&!i&&b()},[i,b]);let oe=We(()=>{for(let k of x.current)Q(k,!1);ie([])},[Q,ie]);Da(()=>()=>{for(let k of x.current)v.current.get(k.id)?.controller.abort(),k.url&&URL.revokeObjectURL(k.url)},[]);let ne=We(k=>{k.currentTarget.files&&ee(k.currentTarget.files),k.currentTarget.value=""},[ee]);Da(()=>{if(!r)return;let k=$=>{$.dataTransfer?.types?.includes("Files")&&$.preventDefault()},H=$=>{$.dataTransfer?.types?.includes("Files")&&$.preventDefault(),$.dataTransfer?.files&&$.dataTransfer.files.length>0&&ee($.dataTransfer.files)};return document.addEventListener("dragover",k),document.addEventListener("drop",H),()=>{document.removeEventListener("dragover",k),document.removeEventListener("drop",H)}},[ee,r]);let Ae=We(async k=>{k.preventDefault();let H=k.currentTarget,$=new FormData(H).get("message")||"",se=new Map;for(;se.size<v.current.size;)await Promise.all([...v.current.entries()].filter(([K])=>!se.has(K)).map(async([K,X])=>{se.set(K,await X.done)}));for(let K of se.keys())v.current.has(K)||se.delete(K);if([...se.values()].some(K=>K===null)){U.current?.({code:"upload_failed",message:m.promptInput.uploadFailed});return}let he=[...se.values()].filter(K=>K!==null),Ie=N.current?[]:x.current,ce=await Promise.all(Ie.map(async({id:K,status:X,progress:pe,error:Ce,...le})=>{if(le.url?.startsWith("blob:")){let re=await Gm(le.url);return{...le,url:re??le.url}}return le}));try{let K=c({documents:he,files:ce,text:$},k);K instanceof Promise&&await K,H.reset(),oe()}catch{}},[c,oe,m]),Ne=Vm(()=>({add:ee,clear:b,files:S,openFileDialog:z,remove:E,retry:W,maxFileSize:n,maxPdfPages:s}),[S,ee,E,W,b,z,n,s]);return Fr(dl.Provider,{value:Ne,children:[Pe("input",{accept:t,"aria-label":m.promptInput.uploadFiles,className:"ww:hidden",multiple:a,onChange:ne,ref:C,title:m.promptInput.uploadFiles,type:"file"}),Pe("form",{className:A("ww:relative ww:flex ww:w-full ww:flex-col ww:rounded-lg ww:border ww:border-border ww:bg-background",e),onSubmit:Ae,ref:y,...p,children:f})]})},ul=1024*1024;function fl(e,t){let a=e>=ul;return new Intl.NumberFormat(t,{style:"unit",unit:a?"megabyte":"kilobyte",maximumFractionDigits:0}).format(a?e/ul:Math.max(1,e/1024))}var pl=({onChange:e,onKeyDown:t,className:a,placeholder:r,...o})=>{let{t:n}=ae(),s=Mr(),[i,l]=mn(!1),u=r??n.promptInput.placeholder,d=We(f=>{if(t?.(f),!f.defaultPrevented){if(f.key==="Enter"){if(i||f.nativeEvent.isComposing||f.shiftKey)return;f.preventDefault();let{form:p}=f.currentTarget;if(p?.querySelector('[data-submit-blocked="true"]')||p?.querySelector('button[type="submit"]')?.disabled)return;p?.requestSubmit()}if(f.key==="Backspace"&&f.currentTarget.value===""&&s.files.length>0){f.preventDefault();let p=s.files.at(-1);p&&s.remove(p.id)}}},[t,i,s]),c=We(f=>{let p=f.clipboardData?.items;if(!p)return;let m=[];for(let L of p)if(L.kind==="file"){let C=L.getAsFile();C&&m.push(C)}m.length>0&&(f.preventDefault(),s.add(m))},[s]);return Pe("textarea",{className:A("ww:field-sizing-content ww:max-h-48 ww:min-h-0 ww:w-full ww:resize-none ww:border-0 ww:bg-transparent ww:px-3 ww:py-2 ww:text-base ww:sm:text-sm ww:outline-none ww:placeholder:text-muted-foreground",a),name:"message",onCompositionEnd:()=>l(!1),onCompositionStart:()=>l(!0),onKeyDown:d,onPaste:c,placeholder:u,onChange:e,...o})},ml=({className:e,status:t,onStop:a,onClick:r,children:o,disabled:n,...s})=>{let{t:i}=ae(),l=t==="submitted"||t==="streaming",u=l&&a!==void 0,d=Pe(xa,{className:"ww:size-4"});t==="submitted"?d=Pe(ka,{className:"ww:size-4 ww:animate-spin"}):t==="streaming"&&(d=Pe(Ta,{className:"ww:size-4"}));let c=We(f=>{if(l&&a){f.preventDefault(),a();return}r?.(f)},[l,a,r]);return Pe(lt,{"aria-label":l?i.promptInput.stop:i.promptInput.submit,className:A("ww:bg-foreground ww:text-background ww:hover:bg-foreground ww:rounded-full",e),"data-submit-blocked":n?"true":void 0,disabled:u?!1:n,onClick:c,size:"icon-sm",type:u?"button":"submit",variant:"ghost",...s,children:o??d})},hl=({className:e,children:t,...a})=>{let{t:r,locale:o}=ae(),n=Mr();if(n.files.length>0)return Fr(lt,{className:A("ww:group ww:relative",e),onClick:()=>n.clear(),size:"icon-sm",type:"button",variant:"ghost","aria-label":r.promptInput.removeAttachments,...a,children:[Pe("span",{className:"ww:flex ww:size-5 ww:items-center ww:justify-center ww:rounded-full ww:bg-primary ww:text-[10px] ww:font-medium ww:text-primary-foreground ww:transition-opacity ww:group-hover:opacity-0",children:n.files.length}),Pe(vt,{className:"ww:absolute ww:size-4 ww:opacity-0 ww:transition-opacity ww:group-hover:opacity-100"})]});let i=n.maxFileSize?(n.maxPdfPages?r.promptInput.uploadFilesUpToWithPages.replace("{pages}",String(n.maxPdfPages)):r.promptInput.uploadFilesUpTo).replace("{limit}",fl(n.maxFileSize,o)):r.promptInput.uploadFiles;return Pe(lt,{"aria-label":i,className:A(e),title:i,onClick:()=>n.openFileDialog(),size:"icon-sm",type:"button",variant:"ghost",...a,children:t??Pe(oa,{className:"ww:size-4"})})},gl=({className:e,...t})=>{let a=Mr();return a.files.length===0?null:Pe("ul",{className:A("ww:flex ww:list-none ww:flex-wrap ww:gap-2 ww:p-0",e),...t,children:a.files.map(r=>Pe(Xm,{file:r},r.id))})};function Xm({file:e}){let{t}=ae(),a=Mr(),r=e.status==="failed",o=e.status==="uploading";return Fr(pn,{filename:e.filename??t.attachments.fileFallback,mediaType:e.mediaType??"",previewUrl:e.mediaType?.startsWith("image/")?e.url:void 0,subtitle:r?e.error:o?t.promptInput.uploading:void 0,tone:r?"error":"default",children:[r?Pe("button",{"aria-label":t.promptInput.retryUpload,className:"ww:ml-auto ww:shrink-0 ww:text-destructive ww:text-xs ww:underline ww:underline-offset-2",onClick:()=>a.retry(e.id),type:"button",children:t.promptInput.retry}):null,Pe("button",{"aria-label":t.promptInput.removeAttachment,className:A("ww:shrink-0 ww:rounded-full ww:p-1 ww:opacity-60 ww:transition-opacity hover:ww:bg-muted hover:ww:opacity-100",r?null:"ww:ml-auto"),onClick:()=>a.remove(e.id),type:"button",children:Pe(vt,{className:"ww:size-3.5"})}),o?Pe("span",{"aria-hidden":!0,className:"ww:absolute ww:bottom-0 ww:left-0 ww:h-0.5 ww:bg-primary ww:transition-[width] ww:duration-200",style:{width:`${Math.round(e.progress*100)}%`}}):null]})}var wl=({enabled:e=!0})=>{let{t}=ae(),[a,r]=mn(!1);return Da(()=>{if(!e)return;let o=0,n=u=>!!u.dataTransfer?.types?.includes("Files"),s=u=>{n(u)&&(o+=1,r(!0))},i=u=>{n(u)&&(o=Math.max(0,o-1),o===0&&r(!1))},l=()=>{o=0,r(!1)};return document.addEventListener("dragenter",s),document.addEventListener("dragleave",i),document.addEventListener("drop",l),()=>{document.removeEventListener("dragenter",s),document.removeEventListener("dragleave",i),document.removeEventListener("drop",l)}},[e]),e&&a?Pe("div",{className:"ww:pointer-events-none ww:absolute ww:inset-0 ww:z-50 ww:flex ww:items-center ww:justify-center ww:rounded-2xl ww:border-2 ww:border-primary ww:border-dashed ww:bg-background/85",children:Fr("span",{className:"ww:flex ww:items-center ww:gap-2 ww:text-sm ww:font-medium",children:[Pe(oa,{className:"ww:size-4"}),t.promptInput.dropToAttach]})}):null};import{jsx as Qm}from"react/jsx-runtime";function Il({text:e}){let{t}=ae();return e===!1?null:Qm("span",{className:"ww:whitespace-nowrap ww:text-[10px] ww:sm:text-[11px] ww:text-muted-foreground ww:opacity-70",children:e||t.aiDisclaimer.default})}import{memo as Jm,useCallback as Ym}from"react";import{jsx as ia}from"react/jsx-runtime";var xl=({className:e,...t})=>ia("div",{className:A("ww:flex ww:flex-col ww:gap-1 ww:px-3 ww:py-2",e),...t}),yl=({className:e,...t})=>ia("li",{className:A("ww:group ww:flex ww:items-center ww:gap-2 ww:rounded-md ww:px-2 ww:py-1 ww:text-sm ww:transition-colors ww:hover:bg-muted",e),...t}),Ll=({className:e,...t})=>ia("span",{className:A("ww:inline-block ww:size-2 ww:shrink-0 ww:rounded-full ww:border ww:border-muted-foreground/50",e),...t}),Cl=({className:e,...t})=>ia("span",{className:A("ww:line-clamp-1 ww:grow ww:break-words ww:text-muted-foreground",e),...t}),Sl=({className:e,...t})=>ia("div",{className:A("ww:flex ww:shrink-0 ww:gap-1 ww:opacity-0 ww:transition-opacity ww:group-hover:opacity-100",e),...t}),bl=({className:e,...t})=>ia(lt,{className:A("ww:size-auto ww:rounded ww:p-1 ww:text-muted-foreground ww:hover:bg-muted-foreground/10 ww:hover:text-foreground",e),size:"icon",type:"button",variant:"ghost",...t});import{jsx as Tt,jsxs as Tl}from"react/jsx-runtime";var vl=Jm(({message:e,onRemove:t})=>{let{t:a}=ae(),r=Ym(()=>t(e.id),[t,e.id]);return Tl(yl,{children:[Tt(Ll,{}),Tt(Cl,{children:e.text||a.chatQueue.attachmentFallback}),Tt(Sl,{children:Tt(bl,{"aria-label":a.chatQueue.removeFromQueue,onClick:r,children:Tt(vt,{className:"ww:size-3"})})})]})});vl.displayName="ChatQueueItem";function kl({queuedMessages:e,onRemove:t,className:a}){let{t:r}=ae();return e.length===0?null:Tl(xl,{className:A("ww:border-t ww:border-border",a),children:[Tt("div",{className:"ww:text-[11px] ww:font-medium ww:text-muted-foreground ww:px-2",children:r.chatQueue.queued(e.length)}),Tt("ul",{children:e.map(o=>Tt(vl,{message:o,onRemove:t},o.id))})]})}import{createContext as ih,useCallback as lh,useContext as uh,useEffect as dh,useMemo as ch,useState as In}from"react";import{createContext as Zm,memo as wn,useCallback as eh,useContext as th,useEffect as hn,useMemo as ah,useRef as Al,useState as gn}from"react";import{Fragment as nh,jsx as rt,jsxs as sh}from"react/jsx-runtime";var Pl=Zm(null);function Rl(){let e=th(Pl);if(!e)throw new Error("Reasoning components must be used within <Reasoning>");return e}var rh=1e3,oh=1e3,Ba=wn(({className:e,isStreaming:t=!1,open:a,defaultOpen:r,onOpenChange:o,duration:n,children:s,...i})=>{let l=r??t,u=r===!1,d=a!==void 0,[c,f]=gn(l),p=d?a:c,m=eh(U=>{d||f(U),o?.(U)},[d,o]),[L,C]=gn(void 0),y=n??L,S=Al(t),[I,x]=gn(!1),v=Al(null);hn(()=>{t?(S.current=!0,v.current===null&&(v.current=Date.now())):v.current!==null&&(C(Math.ceil((Date.now()-v.current)/oh)),v.current=null)},[t]),hn(()=>{t&&!p&&!u&&m(!0)},[t,p,u,m]),hn(()=>{if(S.current&&!t&&p&&!I){let U=setTimeout(()=>{m(!1),x(!0)},rh);return()=>clearTimeout(U)}},[t,p,I,m]);let N=ah(()=>({isStreaming:t,isOpen:p,setIsOpen:m,duration:y}),[t,p,m,y]);return rt(Pl.Provider,{value:N,children:rt("div",{className:A("ww:mb-4 ww:flex ww:flex-col ww:gap-2",e),"data-state":p?"open":"closed",style:{animation:"ww-fade-in 0.2s ease-out"},...i,children:s})})});Ba.displayName="Reasoning";var Oa=wn(({className:e,children:t,getThinkingMessage:a,hideIcon:r=!1,onClick:o,...n})=>{let{t:s}=ae(),{isStreaming:i,isOpen:l,duration:u,setIsOpen:d}=Rl(),f=a??((p,m)=>p||m===0?rt(tt,{duration:1.6,children:s.reasoning.thinking}):m===void 0?rt("span",{children:s.reasoning.thoughtBrief}):rt("span",{children:s.reasoning.thoughtForSeconds(m)}));return rt("button",{type:"button","aria-expanded":l,onClick:p=>{d(!l),o?.(p)},className:A("ww:flex ww:w-full ww:items-center ww:gap-2 ww:text-sm ww:text-muted-foreground ww:transition-colors ww:hover:text-foreground",e),...n,children:t??sh(nh,{children:[!r&&rt(gt,{className:"ww:size-4 ww:shrink-0"}),f(i,u)]})})});Oa.displayName="ReasoningTrigger";var Ua=wn(({className:e,children:t,...a})=>{let{isOpen:r}=Rl();return rt("div",{className:A("ww:grid ww:transition-[grid-template-rows,opacity] ww:duration-200 ww:ease-out",r?"ww:grid-rows-[1fr] ww:opacity-100":"ww:grid-rows-[0fr] ww:opacity-0"),children:rt("div",{className:"ww:min-h-0 ww:overflow-hidden",children:rt("div",{className:A("ww:text-sm ww:text-muted-foreground",e),...a,children:rt(wa,{children:t})})})})});Ua.displayName="ReasoningContent";import{jsx as xe,jsxs as At}from"react/jsx-runtime";var fh=500,El=ih(null);function Ml(){let e=uh(El);if(!e)throw new Error("ChainOfThought components must be used within <ChainOfThought>");return e}function Fl({className:e,isWorking:t=!1,activeStep:a,open:r,defaultOpen:o=!1,onOpenChange:n,children:s,...i}){let l=r!==void 0,[u,d]=In(o),c=l?r:u,f=lh(C=>{l||d(C),n?.(C)},[l,n]),[p,m]=In(!t);dh(()=>{if(t){m(!1);return}let C=setTimeout(()=>m(!0),fh);return()=>clearTimeout(C)},[t]);let L=ch(()=>({open:c,setOpen:f,isWorking:t,settled:p,activeStep:a}),[c,f,t,p,a]);return xe(El.Provider,{value:L,children:xe("div",{className:A("ww:mb-4 ww:flex ww:flex-col ww:gap-2",e),"data-state":c?"open":"closed",style:{animation:"ww-fade-in 0.2s ease-out"},...i,children:s})})}function _l({className:e,label:t,workingLabel:a,children:r,...o}){let{open:n,setOpen:s,isWorking:i,settled:l,activeStep:u}=Ml();if(!l){let d=u?.icon,c=u?.label??a??t??"";return xe("div",{className:A("ww:flex ww:min-h-5 ww:w-full ww:items-center ww:gap-1.5 ww:text-sm ww:text-muted-foreground",e),children:At("span",{className:"ww:flex ww:min-w-0 ww:items-center ww:gap-1.5",style:{animation:"ww-fade-in 0.25s ease-out"},children:[d&&xe(d,{className:A("ww:size-4 ww:shrink-0",i&&"ww:animate-pulse")}),xe("span",{className:"ww:truncate",children:i?xe(tt,{duration:2.6,children:c}):c})]},c)})}return At("button",{type:"button",onClick:()=>s(!n),"aria-expanded":n,className:A("ww:flex ww:min-h-5 ww:w-full ww:items-center ww:gap-1.5 ww:text-sm ww:text-muted-foreground ww:transition-colors ww:hover:text-foreground",e),style:{animation:"ww-fade-in 0.25s ease-out"},...o,children:[xe("span",{className:"ww:truncate",children:r??t}),xe(bt,{className:A("ww:size-4 ww:shrink-0 ww:transition-transform ww:duration-200",n&&"ww:rotate-180")})]})}function Dl({className:e,children:t,...a}){let{open:r}=Ml();return xe("div",{className:A("ww:grid ww:transition-[grid-template-rows,opacity] ww:duration-200 ww:ease-out",r?"ww:grid-rows-[1fr] ww:opacity-100":"ww:grid-rows-[0fr] ww:opacity-0"),children:xe("div",{className:"ww:min-h-0 ww:overflow-hidden",children:xe("div",{className:A("ww:flex ww:flex-col",e),...a,children:t})})})}function Bl({icon:e,isLast:t,running:a,error:r}){return At("div",{className:"ww:flex ww:flex-col ww:items-center ww:self-stretch",children:[xe("span",{className:"ww:flex ww:h-5 ww:items-center",children:xe(e,{className:A("ww:size-4 ww:shrink-0",r?"ww:text-destructive":a?"ww:animate-pulse ww:text-foreground":"ww:text-muted-foreground")})}),!t&&xe("span",{className:"ww:w-px ww:flex-1 ww:bg-border"})]})}function xn({className:e,icon:t,title:a,state:r,isLast:o=!1,children:n,...s}){let i=r==="input-available"||r==="input-streaming",l=r==="output-error",u=n!=null,[d,c]=In(!1),f=a??"",p=i?xe(tt,{duration:1.6,children:f}):xe("span",{className:"ww:truncate",children:f});return At("div",{className:A("ww:flex ww:gap-2",e),...s,children:[xe(Bl,{icon:t,isLast:o,running:i,error:l}),At("div",{className:A("ww:min-w-0 ww:flex-1",!o&&"ww:pb-3"),children:[u?At("button",{type:"button",onClick:()=>c(m=>!m),"aria-expanded":d,className:"ww:flex ww:w-full ww:items-center ww:gap-1.5 ww:text-left ww:text-sm ww:text-muted-foreground ww:transition-colors ww:hover:text-foreground",children:[p,xe(bt,{className:A("ww:size-3.5 ww:shrink-0 ww:transition-transform ww:duration-200",d&&"ww:rotate-180")})]}):xe("div",{className:"ww:flex ww:items-center ww:text-sm ww:text-muted-foreground",children:p}),u&&xe("div",{className:A("ww:grid ww:transition-[grid-template-rows,opacity] ww:duration-200 ww:ease-out",d?"ww:grid-rows-[1fr] ww:opacity-100":"ww:grid-rows-[0fr] ww:opacity-0"),children:xe("div",{className:"ww:min-h-0 ww:overflow-hidden",children:xe("div",{className:"ww:mt-2 ww:space-y-3 ww:rounded-lg ww:border ww:border-border ww:bg-background ww:p-3",children:n})})})]})]})}function Ol({isStreaming:e=!1,isLast:t=!1,children:a}){return At("div",{className:"ww:flex ww:gap-2",children:[xe(Bl,{icon:gt,isLast:t,running:e}),xe("div",{className:A("ww:min-w-0 ww:flex-1",!t&&"ww:pb-3"),children:At(Ba,{isStreaming:e,className:"ww:mb-0",children:[xe(Oa,{hideIcon:!0}),xe(Ua,{children:a})]})})]})}var Oe={carriageReturn:-5,lineFeed:-4,carriageReturnLineFeed:-3,horizontalTab:-2,virtualSpace:-1,eof:null,nul:0,soh:1,stx:2,etx:3,eot:4,enq:5,ack:6,bel:7,bs:8,ht:9,lf:10,vt:11,ff:12,cr:13,so:14,si:15,dle:16,dc1:17,dc2:18,dc3:19,dc4:20,nak:21,syn:22,etb:23,can:24,em:25,sub:26,esc:27,fs:28,gs:29,rs:30,us:31,space:32,exclamationMark:33,quotationMark:34,numberSign:35,dollarSign:36,percentSign:37,ampersand:38,apostrophe:39,leftParenthesis:40,rightParenthesis:41,asterisk:42,plusSign:43,comma:44,dash:45,dot:46,slash:47,digit0:48,digit1:49,digit2:50,digit3:51,digit4:52,digit5:53,digit6:54,digit7:55,digit8:56,digit9:57,colon:58,semicolon:59,lessThan:60,equalsTo:61,greaterThan:62,questionMark:63,atSign:64,uppercaseA:65,uppercaseB:66,uppercaseC:67,uppercaseD:68,uppercaseE:69,uppercaseF:70,uppercaseG:71,uppercaseH:72,uppercaseI:73,uppercaseJ:74,uppercaseK:75,uppercaseL:76,uppercaseM:77,uppercaseN:78,uppercaseO:79,uppercaseP:80,uppercaseQ:81,uppercaseR:82,uppercaseS:83,uppercaseT:84,uppercaseU:85,uppercaseV:86,uppercaseW:87,uppercaseX:88,uppercaseY:89,uppercaseZ:90,leftSquareBracket:91,backslash:92,rightSquareBracket:93,caret:94,underscore:95,graveAccent:96,lowercaseA:97,lowercaseB:98,lowercaseC:99,lowercaseD:100,lowercaseE:101,lowercaseF:102,lowercaseG:103,lowercaseH:104,lowercaseI:105,lowercaseJ:106,lowercaseK:107,lowercaseL:108,lowercaseM:109,lowercaseN:110,lowercaseO:111,lowercaseP:112,lowercaseQ:113,lowercaseR:114,lowercaseS:115,lowercaseT:116,lowercaseU:117,lowercaseV:118,lowercaseW:119,lowercaseX:120,lowercaseY:121,lowercaseZ:122,leftCurlyBrace:123,verticalBar:124,rightCurlyBrace:125,tilde:126,del:127,byteOrderMarker:65279,replacementCharacter:65533};var dt={attentionSideAfter:2,attentionSideBefore:1,atxHeadingOpeningFenceSizeMax:6,autolinkDomainSizeMax:63,autolinkSchemeSizeMax:32,cdataOpeningString:"CDATA[",characterGroupPunctuation:2,characterGroupWhitespace:1,characterReferenceDecimalSizeMax:7,characterReferenceHexadecimalSizeMax:6,characterReferenceNamedSizeMax:31,codeFencedSequenceSizeMin:3,contentTypeContent:"content",contentTypeDocument:"document",contentTypeFlow:"flow",contentTypeString:"string",contentTypeText:"text",hardBreakPrefixSizeMin:2,htmlBasic:6,htmlCdata:5,htmlComment:2,htmlComplete:7,htmlDeclaration:4,htmlInstruction:3,htmlRawSizeMax:8,htmlRaw:1,linkResourceDestinationBalanceMax:32,linkReferenceSizeMax:999,listItemValueSizeMax:10,numericBaseDecimal:10,numericBaseHexadecimal:16,tabSize:4,thematicBreakMarkerCountMin:3,v8MaxSafeChunkSize:1e4};var Xe={data:"data",whitespace:"whitespace",lineEnding:"lineEnding",lineEndingBlank:"lineEndingBlank",linePrefix:"linePrefix",lineSuffix:"lineSuffix",atxHeading:"atxHeading",atxHeadingSequence:"atxHeadingSequence",atxHeadingText:"atxHeadingText",autolink:"autolink",autolinkEmail:"autolinkEmail",autolinkMarker:"autolinkMarker",autolinkProtocol:"autolinkProtocol",characterEscape:"characterEscape",characterEscapeValue:"characterEscapeValue",characterReference:"characterReference",characterReferenceMarker:"characterReferenceMarker",characterReferenceMarkerNumeric:"characterReferenceMarkerNumeric",characterReferenceMarkerHexadecimal:"characterReferenceMarkerHexadecimal",characterReferenceValue:"characterReferenceValue",codeFenced:"codeFenced",codeFencedFence:"codeFencedFence",codeFencedFenceSequence:"codeFencedFenceSequence",codeFencedFenceInfo:"codeFencedFenceInfo",codeFencedFenceMeta:"codeFencedFenceMeta",codeFlowValue:"codeFlowValue",codeIndented:"codeIndented",codeText:"codeText",codeTextData:"codeTextData",codeTextPadding:"codeTextPadding",codeTextSequence:"codeTextSequence",content:"content",definition:"definition",definitionDestination:"definitionDestination",definitionDestinationLiteral:"definitionDestinationLiteral",definitionDestinationLiteralMarker:"definitionDestinationLiteralMarker",definitionDestinationRaw:"definitionDestinationRaw",definitionDestinationString:"definitionDestinationString",definitionLabel:"definitionLabel",definitionLabelMarker:"definitionLabelMarker",definitionLabelString:"definitionLabelString",definitionMarker:"definitionMarker",definitionTitle:"definitionTitle",definitionTitleMarker:"definitionTitleMarker",definitionTitleString:"definitionTitleString",emphasis:"emphasis",emphasisSequence:"emphasisSequence",emphasisText:"emphasisText",escapeMarker:"escapeMarker",hardBreakEscape:"hardBreakEscape",hardBreakTrailing:"hardBreakTrailing",htmlFlow:"htmlFlow",htmlFlowData:"htmlFlowData",htmlText:"htmlText",htmlTextData:"htmlTextData",image:"image",label:"label",labelText:"labelText",labelLink:"labelLink",labelImage:"labelImage",labelMarker:"labelMarker",labelImageMarker:"labelImageMarker",labelEnd:"labelEnd",link:"link",paragraph:"paragraph",reference:"reference",referenceMarker:"referenceMarker",referenceString:"referenceString",resource:"resource",resourceDestination:"resourceDestination",resourceDestinationLiteral:"resourceDestinationLiteral",resourceDestinationLiteralMarker:"resourceDestinationLiteralMarker",resourceDestinationRaw:"resourceDestinationRaw",resourceDestinationString:"resourceDestinationString",resourceMarker:"resourceMarker",resourceTitle:"resourceTitle",resourceTitleMarker:"resourceTitleMarker",resourceTitleString:"resourceTitleString",setextHeading:"setextHeading",setextHeadingText:"setextHeadingText",setextHeadingLine:"setextHeadingLine",setextHeadingLineSequence:"setextHeadingLineSequence",strong:"strong",strongSequence:"strongSequence",strongText:"strongText",thematicBreak:"thematicBreak",thematicBreakSequence:"thematicBreakSequence",blockQuote:"blockQuote",blockQuotePrefix:"blockQuotePrefix",blockQuoteMarker:"blockQuoteMarker",blockQuotePrefixWhitespace:"blockQuotePrefixWhitespace",listOrdered:"listOrdered",listUnordered:"listUnordered",listItemIndent:"listItemIndent",listItemMarker:"listItemMarker",listItemPrefix:"listItemPrefix",listItemPrefixWhitespace:"listItemPrefixWhitespace",listItemValue:"listItemValue",chunkDocument:"chunkDocument",chunkContent:"chunkContent",chunkFlow:"chunkFlow",chunkText:"chunkText",chunkString:"chunkString"};function Ul(e){return e===161||e===164||e===167||e===168||e===170||e===173||e===174||e>=176&&e<=180||e>=182&&e<=186||e>=188&&e<=191||e===198||e===208||e===215||e===216||e>=222&&e<=225||e===230||e>=232&&e<=234||e===236||e===237||e===240||e===242||e===243||e>=247&&e<=250||e===252||e===254||e===257||e===273||e===275||e===283||e===294||e===295||e===299||e>=305&&e<=307||e===312||e>=319&&e<=322||e===324||e>=328&&e<=331||e===333||e===338||e===339||e===358||e===359||e===363||e===462||e===464||e===466||e===468||e===470||e===472||e===474||e===476||e===593||e===609||e===708||e===711||e>=713&&e<=715||e===717||e===720||e>=728&&e<=731||e===733||e===735||e>=768&&e<=879||e>=913&&e<=929||e>=931&&e<=937||e>=945&&e<=961||e>=963&&e<=969||e===1025||e>=1040&&e<=1103||e===1105||e===8208||e>=8211&&e<=8214||e===8216||e===8217||e===8220||e===8221||e>=8224&&e<=8226||e>=8228&&e<=8231||e===8240||e===8242||e===8243||e===8245||e===8251||e===8254||e===8308||e===8319||e>=8321&&e<=8324||e===8364||e===8451||e===8453||e===8457||e===8467||e===8470||e===8481||e===8482||e===8486||e===8491||e===8531||e===8532||e>=8539&&e<=8542||e>=8544&&e<=8555||e>=8560&&e<=8569||e===8585||e>=8592&&e<=8601||e===8632||e===8633||e===8658||e===8660||e===8679||e===8704||e===8706||e===8707||e===8711||e===8712||e===8715||e===8719||e===8721||e===8725||e===8730||e>=8733&&e<=8736||e===8739||e===8741||e>=8743&&e<=8748||e===8750||e>=8756&&e<=8759||e===8764||e===8765||e===8776||e===8780||e===8786||e===8800||e===8801||e>=8804&&e<=8807||e===8810||e===8811||e===8814||e===8815||e===8834||e===8835||e===8838||e===8839||e===8853||e===8857||e===8869||e===8895||e===8978||e>=9312&&e<=9449||e>=9451&&e<=9547||e>=9552&&e<=9587||e>=9600&&e<=9615||e>=9618&&e<=9621||e===9632||e===9633||e>=9635&&e<=9641||e===9650||e===9651||e===9654||e===9655||e===9660||e===9661||e===9664||e===9665||e>=9670&&e<=9672||e===9675||e>=9678&&e<=9681||e>=9698&&e<=9701||e===9711||e===9733||e===9734||e===9737||e===9742||e===9743||e===9756||e===9758||e===9792||e===9794||e===9824||e===9825||e>=9827&&e<=9829||e>=9831&&e<=9834||e===9836||e===9837||e===9839||e===9886||e===9887||e===9919||e>=9926&&e<=9933||e>=9935&&e<=9939||e>=9941&&e<=9953||e===9955||e===9960||e===9961||e>=9963&&e<=9969||e===9972||e>=9974&&e<=9977||e===9979||e===9980||e===9982||e===9983||e===10045||e>=10102&&e<=10111||e>=11094&&e<=11097||e>=12872&&e<=12879||e>=57344&&e<=63743||e>=65024&&e<=65039||e===65533||e>=127232&&e<=127242||e>=127248&&e<=127277||e>=127280&&e<=127337||e>=127344&&e<=127373||e===127375||e===127376||e>=127387&&e<=127404||e>=917760&&e<=917999||e>=983040&&e<=1048573||e>=1048576&&e<=1114109}function Nl(e){return e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510}function ql(e){return e>=4352&&e<=4447||e===8986||e===8987||e===9001||e===9002||e>=9193&&e<=9196||e===9200||e===9203||e===9725||e===9726||e===9748||e===9749||e>=9776&&e<=9783||e>=9800&&e<=9811||e===9855||e>=9866&&e<=9871||e===9875||e===9889||e===9898||e===9899||e===9917||e===9918||e===9924||e===9925||e===9934||e===9940||e===9962||e===9970||e===9971||e===9973||e===9978||e===9981||e===9989||e===9994||e===9995||e===10024||e===10060||e===10062||e>=10067&&e<=10069||e===10071||e>=10133&&e<=10135||e===10160||e===10175||e===11035||e===11036||e===11088||e===11093||e>=11904&&e<=11929||e>=11931&&e<=12019||e>=12032&&e<=12245||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12353&&e<=12438||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12773||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=42124||e>=42128&&e<=42182||e>=43360&&e<=43388||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=94176&&e<=94180||e>=94192&&e<=94198||e>=94208&&e<=101589||e>=101631&&e<=101662||e>=101760&&e<=101874||e>=110576&&e<=110579||e>=110581&&e<=110587||e===110589||e===110590||e>=110592&&e<=110882||e===110898||e>=110928&&e<=110930||e===110933||e>=110948&&e<=110951||e>=110960&&e<=111355||e>=119552&&e<=119638||e>=119648&&e<=119670||e===126980||e===127183||e===127374||e>=127377&&e<=127386||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e===127568||e===127569||e>=127584&&e<=127589||e>=127744&&e<=127776||e>=127789&&e<=127797||e>=127799&&e<=127868||e>=127870&&e<=127891||e>=127904&&e<=127946||e>=127951&&e<=127955||e>=127968&&e<=127984||e===127988||e>=127992&&e<=128062||e===128064||e>=128066&&e<=128252||e>=128255&&e<=128317||e>=128331&&e<=128334||e>=128336&&e<=128359||e===128378||e===128405||e===128406||e===128420||e>=128507&&e<=128591||e>=128640&&e<=128709||e===128716||e>=128720&&e<=128722||e>=128725&&e<=128728||e>=128732&&e<=128735||e===128747||e===128748||e>=128756&&e<=128764||e>=128992&&e<=129003||e===129008||e>=129292&&e<=129338||e>=129340&&e<=129349||e>=129351&&e<=129535||e>=129648&&e<=129660||e>=129664&&e<=129674||e>=129678&&e<=129734||e===129736||e>=129741&&e<=129756||e>=129759&&e<=129770||e>=129775&&e<=129784||e>=131072&&e<=196605||e>=196608&&e<=262141}function Hl(e){return Ul(e)?"ambiguous":Nl(e)?"fullwidth":e===8361||e>=65377&&e<=65470||e>=65474&&e<=65479||e>=65482&&e<=65487||e>=65490&&e<=65495||e>=65498&&e<=65500||e>=65512&&e<=65518?"halfwidth":e>=32&&e<=126||e===162||e===163||e===165||e===166||e===172||e===175||e>=10214&&e<=10221||e===10629||e===10630?"narrow":ql(e)?"wide":"neutral"}function ph(e){if(!Number.isSafeInteger(e))throw new TypeError(`Expected a code point, got \`${typeof e}\`.`)}function $l(e){return ph(e),Hl(e)}var mh=Object.defineProperty,hh=(e,t,a)=>t in e?mh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,gh=(e,t,a)=>hh(e,typeof t!="symbol"?t+"":t,a);function wh(e){return/^\p{Emoji_Presentation}/u.test(String.fromCodePoint(e))}function Ih(e){if(!e||e<4352)return!1;switch($l(e)){case"fullwidth":case"halfwidth":return!0;case"wide":return!wh(e);case"narrow":return!1;case"ambiguous":return 917760<=e&&e<=917999?null:!1;case"neutral":return/^\p{sc=Hangul}/u.test(String.fromCodePoint(e))}}function xh(e,t){return t!==65025||!e||e<8216?!1:e===8216||e===8217||e===8220||e===8221}function yh(e){return e!==null&&e>=65024&&e<=65038}var Lh=Wl(/\p{P}|\p{S}/u),Ch=Wl(/\s/);function Wl(e){return t;function t(a){return a!==null&&a>-1&&e.test(String.fromCodePoint(a))}}var Qe;(e=>{e.spaceOrPunctuation=3,e.cjk=4096,e.cjkPunctuation=4098,e.ivs=8192,e.cjkOrIvs=12288,e.nonEmojiGeneralUseVS=16384,e.variationSelector=24576,e.ivsToCjkRightShift=1})(Qe||(Qe={}));function Pt(e){if(e===Oe.eof||wi(e)||Ch(e))return dt.characterGroupWhitespace;let t=0;if(e>=4352){if(yh(e))return Qe.nonEmojiGeneralUseVS;switch(Ih(e)){case null:return Qe.ivs;case!0:t|=Qe.cjk;break}}return Lh(e)&&(t|=dt.characterGroupPunctuation),t}function _r(e,t,a){if(!bh(e))return e;let r=t(),o=Pt(r);return!r||jt(o)?e:xh(r,a)?Qe.cjkPunctuation:Sh(o)}function Sh(e){return e&~Qe.ivs}function jt(e){return!!(e&dt.characterGroupWhitespace)}function la(e){return(e&Qe.cjkPunctuation)===dt.characterGroupPunctuation}function Na(e){return!!(e&Qe.cjk)}function jl(e){return e===Qe.ivs}function zl(e){return!!(e&Qe.cjkOrIvs)}function bh(e){return e===Qe.nonEmojiGeneralUseVS}function yn(e){return!!(e&Qe.spaceOrPunctuation)}function Dr(e){return!!(e&&e>=55296&&e<=56319)}function Br(e){return!!(e&&e>=56320&&e<=57343)}function Or(e,t,a){if(t._bufferIndex<2)return e;let o=a({start:{...t,_bufferIndex:t._bufferIndex-2},end:t}).codePointAt(0);return o&&o>=65536?o:e}function vh(e,t,a){let r=e>=65536?2:1;if(t._bufferIndex<1+r)return null;let o=t._bufferIndex-r-2,n=a({start:{...t,_bufferIndex:o>=0?o:0},end:{...t,_bufferIndex:t._bufferIndex-r}}),s=n.charCodeAt(n.length-1);if(Number.isNaN(s))return null;if(n.length<2||s<56320||57343<s)return s;let i=n.codePointAt(0);return i&&i>=65536?i:s}var Ur=class{constructor(e,t,a){this.previousCode=e,this.nowPoint=t,this.sliceSerialize=a,gh(this,"cachedValue")}value(){return this.cachedValue===void 0&&(this.cachedValue=vh(this.previousCode,this.nowPoint,this.sliceSerialize)),this.cachedValue}};function Nr(e,t,a){let r=a({start:t,end:{...t,_bufferIndex:t._bufferIndex+2}}).codePointAt(0);return r&&r>=65536?r:e}var Ln={name:"attention",resolveAll:kh,tokenize:Th};function kh(e,t){let a=-1,r,o,n,s,i,l,u,d;for(;++a<e.length;)if(e[a][0]==="enter"&&e[a][1].type==="attentionSequence"&&e[a][1]._close){for(r=a;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[a][1]).charCodeAt(0)){if((e[r][1]._close||e[a][1]._open)&&(e[a][1].end.offset-e[a][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[a][1].end.offset-e[a][1].start.offset)%3))continue;l=e[r][1].end.offset-e[r][1].start.offset>1&&e[a][1].end.offset-e[a][1].start.offset>1?2:1;let c={...e[r][1].end},f={...e[a][1].start};Vl(c,-l),Vl(f,l),s={type:l>1?Xe.strongSequence:Xe.emphasisSequence,start:c,end:{...e[r][1].end}},i={type:l>1?Xe.strongSequence:Xe.emphasisSequence,start:{...e[a][1].start},end:f},n={type:l>1?Xe.strongText:Xe.emphasisText,start:{...e[r][1].end},end:{...e[a][1].start}},o={type:l>1?Xe.strong:Xe.emphasis,start:{...s.start},end:{...i.end}},e[r][1].end={...s.start},e[a][1].start={...i.end},u=[],e[r][1].end.offset-e[r][1].start.offset&&(u=ta(u,[["enter",e[r][1],t],["exit",e[r][1],t]])),u=ta(u,[["enter",o,t],["enter",s,t],["exit",s,t],["enter",n,t]]),t.parser.constructs.insideSpan.null,u=ta(u,Cr(t.parser.constructs.insideSpan.null,e.slice(r+1,a),t)),u=ta(u,[["exit",n,t],["enter",i,t],["exit",i,t],["exit",o,t]]),e[a][1].end.offset-e[a][1].start.offset?(d=2,u=ta(u,[["enter",e[a][1],t],["exit",e[a][1],t]])):d=0,ea(e,r-1,a-r+3,u),a=r+u.length-d-2;break}}for(a=-1;++a<e.length;)e[a][1].type==="attentionSequence"&&(e[a][1].type="data");return e}function Th(e,t){let a=this.parser.constructs.attentionMarkers.null,{now:r,sliceSerialize:o,previous:n}=this,s=Br(n)?Or(n,r(),o):n,i=Pt(s),l=new Ur(s,r(),o),u=_r(i,l.value.bind(l),s),d;return c;function c(p){return p===Oe.asterisk||Oe.underscore,d=p,e.enter("attentionSequence"),f(p)}function f(p){if(p===d)return e.consume(p),f;let m=e.exit("attentionSequence"),L=Dr(p)?Nr(p,r(),o):p,C=Pt(L);let y=la(u),S=y||jt(u),I=la(C),x=I||jt(C),v=zl(u),N=!x||I&&(S||v)||a.includes(p),U=!S||y&&(x||Na(C))||a.includes(s);return m._open=!!(d===Oe.asterisk?N:N&&(yn(u)||!U)),m._close=!!(d===Oe.asterisk?U:U&&(yn(C)||!N)),t(p)}}function Vl(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}function Gl(){return{text:{[Oe.asterisk]:Ln,[Oe.underscore]:Ln},insideSpan:{null:[Ln]}}}function Kl(){let e=this.data();(e.micromarkExtensions||(e.micromarkExtensions=[])).push(Gl())}function Xl(e){let a=(e||{}).singleTilde,r={name:"strikethrough",tokenize:n,resolveAll:o};return a==null&&(a=!0),{text:{[Oe.tilde]:r},insideSpan:{null:[r]},attentionMarkers:{null:[Oe.tilde]}};function o(s,i){let l=-1;for(;++l<s.length;)if(s[l][0]==="enter"&&s[l][1].type==="strikethroughSequenceTemporary"&&s[l][1]._close){let u=l;for(;u--;)if(s[u][0]==="exit"&&s[u][1].type==="strikethroughSequenceTemporary"&&s[u][1]._open&&s[l][1].end.offset-s[l][1].start.offset===s[u][1].end.offset-s[u][1].start.offset){s[l][1].type="strikethroughSequence",s[u][1].type="strikethroughSequence";let d={type:"strikethrough",start:Object.assign({},s[u][1].start),end:Object.assign({},s[l][1].end)},c={type:"strikethroughText",start:Object.assign({},s[u][1].end),end:Object.assign({},s[l][1].start)},f=[["enter",d,i],["enter",s[u][1],i],["exit",s[u][1],i],["enter",c,i]],p=i.parser.constructs.insideSpan.null;p&&ea(f,f.length,0,Cr(p,s.slice(u+1,l),i)),ea(f,f.length,0,[["exit",c,i],["enter",s[l][1],i],["exit",s[l][1],i],["exit",d,i]]),ea(s,u-1,l-u+3,f),l=u+f.length-2;break}}for(l=-1;++l<s.length;)s[l][1].type==="strikethroughSequenceTemporary"&&(s[l][1].type=Xe.data);return s}function n(s,i,l){let{now:u,sliceSerialize:d,previous:c}=this,f=Br(c)?Or(c,u(),d):c,p=Pt(f),m=new Ur(f,u(),d),L=_r(p,m.value.bind(m),f),C=this.events,y=0;return S;function S(x){return Oe.tilde,f===Oe.tilde&&C[C.length-1][1].type!==Xe.characterEscape?l(x):(s.enter("strikethroughSequenceTemporary"),I(x))}function I(x){let v=Pt(f);if(x===Oe.tilde)return y>1?l(x):(s.consume(x),y++,I);if(y<2&&!a)return l(x);let N=s.exit("strikethroughSequenceTemporary"),U=Dr(x)?Nr(x,u(),d):x,j=Pt(U),z=la(L)||jt(L),q=la(j)||jt(j),ee=Na(L)||jl(v);return N._open=!q||j===dt.attentionSideAfter&&(z||ee),N._close=!z||v===dt.attentionSideAfter&&(q||Na(j)),i(x)}}}function Ql(e){let t=this.data();(t.micromarkExtensions||(t.micromarkExtensions=[])).push(Xl(e))}var Ah=new Set(["\u3002","\uFF0E","\uFF0C","\u3001","\uFF1F","\uFF01","\uFF1A","\uFF1B","\uFF08","\uFF09","\u3010","\u3011","\u300C","\u300D","\u300E","\u300F","\u3008","\u3009","\u300A","\u300B"]),Ph=/^(https?:\/\/|mailto:|www\.)/i,Rh=e=>{if(e.children.length!==1)return!1;let t=e.children[0];return t.type==="text"&&t.value===e.url},Eh=e=>{let t=0;for(let a of e){if(Ah.has(a))return t;t+=a.length}return null},Mh=(e,t)=>({...t,url:e,children:[{type:"text",value:e}]}),Fh=e=>({type:"text",value:e}),_h=()=>e=>{di(e,"link",(t,a,r)=>{if(!r||typeof a!="number"||!Rh(t)||!Ph.test(t.url))return;let o=Eh(t.url);if(o===null||o===0)return;let n=t.url.slice(0,o),s=t.url.slice(o),i=Mh(n,t),l=Fh(s);return r.children.splice(a,1,i,l),a+1})};function Dh(){let e=[Kl],t=[_h,Ql],a=[...e,...t];return{name:"cjk",type:"cjk",remarkPluginsBefore:e,remarkPluginsAfter:t,remarkPlugins:a}}var Cn=Dh();var Se=class extends Error{constructor(t){super(t),this.name="ShikiError"}};function Bh(e){return Mn(e)}function Mn(e){return Array.isArray(e)?Oh(e):e instanceof RegExp?e:typeof e=="object"?Uh(e):e}function Oh(e){let t=[];for(let a=0,r=e.length;a<r;a++)t[a]=Mn(e[a]);return t}function Uh(e){let t={};for(let a in e)t[a]=Mn(e[a]);return t}function nu(e,...t){return t.forEach(a=>{for(let r in a)e[r]=a[r]}),e}function su(e){let t=~e.lastIndexOf("/")||~e.lastIndexOf("\\");return t===0?e:~t===e.length-1?su(e.substring(0,e.length-1)):e.substr(~t+1)}var Sn=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,qr=class{static hasCaptures(e){return e===null?!1:(Sn.lastIndex=0,Sn.test(e))}static replaceCaptures(e,t,a){return e.replace(Sn,(r,o,n,s)=>{let i=a[parseInt(o||n,10)];if(i){let l=t.substring(i.start,i.end);for(;l[0]===".";)l=l.substring(1);switch(s){case"downcase":return l.toLowerCase();case"upcase":return l.toUpperCase();default:return l}}else return r})}};function iu(e,t){return e<t?-1:e>t?1:0}function lu(e,t){if(e===null&&t===null)return 0;if(!e)return-1;if(!t)return 1;let a=e.length,r=t.length;if(a===r){for(let o=0;o<a;o++){let n=iu(e[o],t[o]);if(n!==0)return n}return 0}return a-r}function Jl(e){return!!(/^#[0-9a-f]{6}$/i.test(e)||/^#[0-9a-f]{8}$/i.test(e)||/^#[0-9a-f]{3}$/i.test(e)||/^#[0-9a-f]{4}$/i.test(e))}function uu(e){return e.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var du=class{constructor(e){this.fn=e}cache=new Map;get(e){if(this.cache.has(e))return this.cache.get(e);let t=this.fn(e);return this.cache.set(e,t),t}},$a=class{constructor(e,t,a){this._colorMap=e,this._defaults=t,this._root=a}static createFromRawTheme(e,t){return this.createFromParsedTheme(Hh(e),t)}static createFromParsedTheme(e,t){return Wh(e,t)}_cachedMatchRoot=new du(e=>this._root.match(e));getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(e){if(e===null)return this._defaults;let t=e.scopeName,r=this._cachedMatchRoot.get(t).find(o=>Nh(e.parent,o.parentScopes));return r?new cu(r.fontStyle,r.foreground,r.background):null}},bn=class Hr{constructor(t,a){this.parent=t,this.scopeName=a}static push(t,a){for(let r of a)t=new Hr(t,r);return t}static from(...t){let a=null;for(let r=0;r<t.length;r++)a=new Hr(a,t[r]);return a}push(t){return new Hr(this,t)}getSegments(){let t=this,a=[];for(;t;)a.push(t.scopeName),t=t.parent;return a.reverse(),a}toString(){return this.getSegments().join(" ")}extends(t){return this===t?!0:this.parent===null?!1:this.parent.extends(t)}getExtensionIfDefined(t){let a=[],r=this;for(;r&&r!==t;)a.push(r.scopeName),r=r.parent;return r===t?a.reverse():void 0}};function Nh(e,t){if(t.length===0)return!0;for(let a=0;a<t.length;a++){let r=t[a],o=!1;if(r===">"){if(a===t.length-1)return!1;r=t[++a],o=!0}for(;e&&!qh(e.scopeName,r);){if(o)return!1;e=e.parent}if(!e)return!1;e=e.parent}return!0}function qh(e,t){return t===e||e.startsWith(t)&&e[t.length]==="."}var cu=class{constructor(e,t,a){this.fontStyle=e,this.foregroundId=t,this.backgroundId=a}};function Hh(e){if(!e)return[];if(!e.settings||!Array.isArray(e.settings))return[];let t=e.settings,a=[],r=0;for(let o=0,n=t.length;o<n;o++){let s=t[o];if(!s.settings)continue;let i;if(typeof s.scope=="string"){let c=s.scope;c=c.replace(/^[,]+/,""),c=c.replace(/[,]+$/,""),i=c.split(",")}else Array.isArray(s.scope)?i=s.scope:i=[""];let l=-1;if(typeof s.settings.fontStyle=="string"){l=0;let c=s.settings.fontStyle.split(" ");for(let f=0,p=c.length;f<p;f++)switch(c[f]){case"italic":l=l|1;break;case"bold":l=l|2;break;case"underline":l=l|4;break;case"strikethrough":l=l|8;break}}let u=null;typeof s.settings.foreground=="string"&&Jl(s.settings.foreground)&&(u=s.settings.foreground);let d=null;typeof s.settings.background=="string"&&Jl(s.settings.background)&&(d=s.settings.background);for(let c=0,f=i.length;c<f;c++){let m=i[c].trim().split(" "),L=m[m.length-1],C=null;m.length>1&&(C=m.slice(0,m.length-1),C.reverse()),a[r++]=new $h(L,C,o,l,u,d)}}return a}var $h=class{constructor(e,t,a,r,o,n){this.scope=e,this.parentScopes=t,this.index=a,this.fontStyle=r,this.foreground=o,this.background=n}},Ue=(e=>(e[e.NotSet=-1]="NotSet",e[e.None=0]="None",e[e.Italic=1]="Italic",e[e.Bold=2]="Bold",e[e.Underline=4]="Underline",e[e.Strikethrough=8]="Strikethrough",e))(Ue||{});function Wh(e,t){e.sort((l,u)=>{let d=iu(l.scope,u.scope);return d!==0||(d=lu(l.parentScopes,u.parentScopes),d!==0)?d:l.index-u.index});let a=0,r="#000000",o="#ffffff";for(;e.length>=1&&e[0].scope==="";){let l=e.shift();l.fontStyle!==-1&&(a=l.fontStyle),l.foreground!==null&&(r=l.foreground),l.background!==null&&(o=l.background)}let n=new jh(t),s=new cu(a,n.getId(r),n.getId(o)),i=new Vh(new kn(0,null,-1,0,0),[]);for(let l=0,u=e.length;l<u;l++){let d=e[l];i.insert(0,d.scope,d.parentScopes,d.fontStyle,n.getId(d.foreground),n.getId(d.background))}return new $a(n,s,i)}var jh=class{_isFrozen;_lastColorId;_id2color;_color2id;constructor(e){if(this._lastColorId=0,this._id2color=[],this._color2id=Object.create(null),Array.isArray(e)){this._isFrozen=!0;for(let t=0,a=e.length;t<a;t++)this._color2id[e[t]]=t,this._id2color[t]=e[t]}else this._isFrozen=!1}getId(e){if(e===null)return 0;e=e.toUpperCase();let t=this._color2id[e];if(t)return t;if(this._isFrozen)throw new Error(`Missing color in color map - ${e}`);return t=++this._lastColorId,this._color2id[e]=t,this._id2color[t]=e,t}getColorMap(){return this._id2color.slice(0)}},zh=Object.freeze([]),kn=class fu{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(t,a,r,o,n){this.scopeDepth=t,this.parentScopes=a||zh,this.fontStyle=r,this.foreground=o,this.background=n}clone(){return new fu(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(t){let a=[];for(let r=0,o=t.length;r<o;r++)a[r]=t[r].clone();return a}acceptOverwrite(t,a,r,o){this.scopeDepth>t?console.log("how did this happen?"):this.scopeDepth=t,a!==-1&&(this.fontStyle=a),r!==0&&(this.foreground=r),o!==0&&(this.background=o)}},Vh=class Tn{constructor(t,a=[],r={}){this._mainRule=t,this._children=r,this._rulesWithParentScopes=a}_rulesWithParentScopes;static _cmpBySpecificity(t,a){if(t.scopeDepth!==a.scopeDepth)return a.scopeDepth-t.scopeDepth;let r=0,o=0;for(;t.parentScopes[r]===">"&&r++,a.parentScopes[o]===">"&&o++,!(r>=t.parentScopes.length||o>=a.parentScopes.length);){let n=a.parentScopes[o].length-t.parentScopes[r].length;if(n!==0)return n;r++,o++}return a.parentScopes.length-t.parentScopes.length}match(t){if(t!==""){let r=t.indexOf("."),o,n;if(r===-1?(o=t,n=""):(o=t.substring(0,r),n=t.substring(r+1)),this._children.hasOwnProperty(o))return this._children[o].match(n)}let a=this._rulesWithParentScopes.concat(this._mainRule);return a.sort(Tn._cmpBySpecificity),a}insert(t,a,r,o,n,s){if(a===""){this._doInsertHere(t,r,o,n,s);return}let i=a.indexOf("."),l,u;i===-1?(l=a,u=""):(l=a.substring(0,i),u=a.substring(i+1));let d;this._children.hasOwnProperty(l)?d=this._children[l]:(d=new Tn(this._mainRule.clone(),kn.cloneArr(this._rulesWithParentScopes)),this._children[l]=d),d.insert(t+1,u,r,o,n,s)}_doInsertHere(t,a,r,o,n){if(a===null){this._mainRule.acceptOverwrite(t,r,o,n);return}for(let s=0,i=this._rulesWithParentScopes.length;s<i;s++){let l=this._rulesWithParentScopes[s];if(lu(l.parentScopes,a)===0){l.acceptOverwrite(t,r,o,n);return}}r===-1&&(r=this._mainRule.fontStyle),o===0&&(o=this._mainRule.foreground),n===0&&(n=this._mainRule.background),this._rulesWithParentScopes.push(new kn(t,a,r,o,n))}},Vt=class Ye{static toBinaryStr(t){return t.toString(2).padStart(32,"0")}static print(t){let a=Ye.getLanguageId(t),r=Ye.getTokenType(t),o=Ye.getFontStyle(t),n=Ye.getForeground(t),s=Ye.getBackground(t);console.log({languageId:a,tokenType:r,fontStyle:o,foreground:n,background:s})}static getLanguageId(t){return(t&255)>>>0}static getTokenType(t){return(t&768)>>>8}static containsBalancedBrackets(t){return(t&1024)!==0}static getFontStyle(t){return(t&30720)>>>11}static getForeground(t){return(t&16744448)>>>15}static getBackground(t){return(t&4278190080)>>>24}static set(t,a,r,o,n,s,i){let l=Ye.getLanguageId(t),u=Ye.getTokenType(t),d=Ye.containsBalancedBrackets(t)?1:0,c=Ye.getFontStyle(t),f=Ye.getForeground(t),p=Ye.getBackground(t);return a!==0&&(l=a),r!==8&&(u=r),o!==null&&(d=o?1:0),n!==-1&&(c=n),s!==0&&(f=s),i!==0&&(p=i),(l<<0|u<<8|d<<10|c<<11|f<<15|p<<24)>>>0}};function Wr(e,t){let a=[],r=Gh(e),o=r.next();for(;o!==null;){let l=0;if(o.length===2&&o.charAt(1)===":"){switch(o.charAt(0)){case"R":l=1;break;case"L":l=-1;break;default:console.log(`Unknown priority ${o} in scope selector`)}o=r.next()}let u=s();if(a.push({matcher:u,priority:l}),o!==",")break;o=r.next()}return a;function n(){if(o==="-"){o=r.next();let l=n();return u=>!!l&&!l(u)}if(o==="("){o=r.next();let l=i();return o===")"&&(o=r.next()),l}if(Yl(o)){let l=[];do l.push(o),o=r.next();while(Yl(o));return u=>t(l,u)}return null}function s(){let l=[],u=n();for(;u;)l.push(u),u=n();return d=>l.every(c=>c(d))}function i(){let l=[],u=s();for(;u&&(l.push(u),o==="|"||o===",");){do o=r.next();while(o==="|"||o===",");u=s()}return d=>l.some(c=>c(d))}}function Yl(e){return!!e&&!!e.match(/[\w\.:]+/)}function Gh(e){let t=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,a=t.exec(e);return{next:()=>{if(!a)return null;let r=a[0];return a=t.exec(e),r}}}function pu(e){typeof e.dispose=="function"&&e.dispose()}var Wa=class{constructor(e){this.scopeName=e}toKey(){return this.scopeName}},Kh=class{constructor(e,t){this.scopeName=e,this.ruleName=t}toKey(){return`${this.scopeName}#${this.ruleName}`}},Xh=class{_references=[];_seenReferenceKeys=new Set;get references(){return this._references}visitedRule=new Set;add(e){let t=e.toKey();this._seenReferenceKeys.has(t)||(this._seenReferenceKeys.add(t),this._references.push(e))}},Qh=class{constructor(e,t){this.repo=e,this.initialScopeName=t,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new Wa(this.initialScopeName)]}seenFullScopeRequests=new Set;seenPartialScopeRequests=new Set;Q;processQueue(){let e=this.Q;this.Q=[];let t=new Xh;for(let a of e)Jh(a,this.initialScopeName,this.repo,t);for(let a of t.references)if(a instanceof Wa){if(this.seenFullScopeRequests.has(a.scopeName))continue;this.seenFullScopeRequests.add(a.scopeName),this.Q.push(a)}else{if(this.seenFullScopeRequests.has(a.scopeName)||this.seenPartialScopeRequests.has(a.toKey()))continue;this.seenPartialScopeRequests.add(a.toKey()),this.Q.push(a)}}};function Jh(e,t,a,r){let o=a.lookup(e.scopeName);if(!o){if(e.scopeName===t)throw new Error(`No grammar provided for <${t}>`);return}let n=a.lookup(t);e instanceof Wa?$r({baseGrammar:n,selfGrammar:o},r):An(e.ruleName,{baseGrammar:n,selfGrammar:o,repository:o.repository},r);let s=a.injections(e.scopeName);if(s)for(let i of s)r.add(new Wa(i))}function An(e,t,a){if(t.repository&&t.repository[e]){let r=t.repository[e];jr([r],t,a)}}function $r(e,t){e.selfGrammar.patterns&&Array.isArray(e.selfGrammar.patterns)&&jr(e.selfGrammar.patterns,{...e,repository:e.selfGrammar.repository},t),e.selfGrammar.injections&&jr(Object.values(e.selfGrammar.injections),{...e,repository:e.selfGrammar.repository},t)}function jr(e,t,a){for(let r of e){if(a.visitedRule.has(r))continue;a.visitedRule.add(r);let o=r.repository?nu({},t.repository,r.repository):t.repository;Array.isArray(r.patterns)&&jr(r.patterns,{...t,repository:o},a);let n=r.include;if(!n)continue;let s=mu(n);switch(s.kind){case 0:$r({...t,selfGrammar:t.baseGrammar},a);break;case 1:$r(t,a);break;case 2:An(s.ruleName,{...t,repository:o},a);break;case 3:case 4:let i=s.scopeName===t.selfGrammar.scopeName?t.selfGrammar:s.scopeName===t.baseGrammar.scopeName?t.baseGrammar:void 0;if(i){let l={baseGrammar:t.baseGrammar,selfGrammar:i,repository:o};s.kind===4?An(s.ruleName,l,a):$r(l,a)}else s.kind===4?a.add(new Kh(s.scopeName,s.ruleName)):a.add(new Wa(s.scopeName));break}}}var Yh=class{kind=0},Zh=class{kind=1},eg=class{constructor(e){this.ruleName=e}kind=2},tg=class{constructor(e){this.scopeName=e}kind=3},ag=class{constructor(e,t){this.scopeName=e,this.ruleName=t}kind=4};function mu(e){if(e==="$base")return new Yh;if(e==="$self")return new Zh;let t=e.indexOf("#");if(t===-1)return new tg(e);if(t===0)return new eg(e.substring(1));{let a=e.substring(0,t),r=e.substring(t+1);return new ag(a,r)}}var rg=/\\(\d+)/,Zl=/\\(\d+)/g;var og=-1,hu=-2;var Va=class{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(e,t,a,r){this.$location=e,this.id=t,this._name=a||null,this._nameIsCapturing=qr.hasCaptures(this._name),this._contentName=r||null,this._contentNameIsCapturing=qr.hasCaptures(this._contentName)}get debugName(){let e=this.$location?`${su(this.$location.filename)}:${this.$location.line}`:"unknown";return`${this.constructor.name}#${this.id} @ ${e}`}getName(e,t){return!this._nameIsCapturing||this._name===null||e===null||t===null?this._name:qr.replaceCaptures(this._name,e,t)}getContentName(e,t){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:qr.replaceCaptures(this._contentName,e,t)}},ng=class extends Va{retokenizeCapturedWithRuleId;constructor(e,t,a,r,o){super(e,t,a,r),this.retokenizeCapturedWithRuleId=o}dispose(){}collectPatterns(e,t){throw new Error("Not supported!")}compile(e,t){throw new Error("Not supported!")}compileAG(e,t,a,r){throw new Error("Not supported!")}},sg=class extends Va{_match;captures;_cachedCompiledPatterns;constructor(e,t,a,r,o){super(e,t,a,null),this._match=new ja(r,this.id),this.captures=o,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(e,t){t.push(this._match)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,a,r){return this._getCachedCompiledPatterns(e).compileAG(e,a,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new za,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},eu=class extends Va{hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,a,r,o){super(e,t,a,r),this.patterns=o.patterns,this.hasMissingPatterns=o.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}collectPatterns(e,t){for(let a of this.patterns)e.getRule(a).collectPatterns(e,t)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,a,r){return this._getCachedCompiledPatterns(e).compileAG(e,a,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new za,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Pn=class extends Va{_begin;beginCaptures;_end;endHasBackReferences;endCaptures;applyEndPatternLast;hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,a,r,o,n,s,i,l,u){super(e,t,a,r),this._begin=new ja(o,this.id),this.beginCaptures=n,this._end=new ja(s||"\uFFFF",-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=i,this.applyEndPatternLast=l||!1,this.patterns=u.patterns,this.hasMissingPatterns=u.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(e,t){return this._end.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e,t).compile(e)}compileAG(e,t,a,r){return this._getCachedCompiledPatterns(e,t).compileAG(e,a,r)}_getCachedCompiledPatterns(e,t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new za;for(let a of this.patterns)e.getRule(a).collectPatterns(e,this._cachedCompiledPatterns);this.applyEndPatternLast?this._cachedCompiledPatterns.push(this._end.hasBackReferences?this._end.clone():this._end):this._cachedCompiledPatterns.unshift(this._end.hasBackReferences?this._end.clone():this._end)}return this._end.hasBackReferences&&(this.applyEndPatternLast?this._cachedCompiledPatterns.setSource(this._cachedCompiledPatterns.length()-1,t):this._cachedCompiledPatterns.setSource(0,t)),this._cachedCompiledPatterns}},zr=class extends Va{_begin;beginCaptures;whileCaptures;_while;whileHasBackReferences;hasMissingPatterns;patterns;_cachedCompiledPatterns;_cachedCompiledWhilePatterns;constructor(e,t,a,r,o,n,s,i,l){super(e,t,a,r),this._begin=new ja(o,this.id),this.beginCaptures=n,this.whileCaptures=i,this._while=new ja(s,hu),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=l.patterns,this.hasMissingPatterns=l.hasMissingPatterns,this._cachedCompiledPatterns=null,this._cachedCompiledWhilePatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null),this._cachedCompiledWhilePatterns&&(this._cachedCompiledWhilePatterns.dispose(),this._cachedCompiledWhilePatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugWhileRegExp(){return`${this._while.source}`}getWhileWithResolvedBackReferences(e,t){return this._while.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,a,r){return this._getCachedCompiledPatterns(e).compileAG(e,a,r)}_getCachedCompiledPatterns(e){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new za;for(let t of this.patterns)e.getRule(t).collectPatterns(e,this._cachedCompiledPatterns)}return this._cachedCompiledPatterns}compileWhile(e,t){return this._getCachedCompiledWhilePatterns(e,t).compile(e)}compileWhileAG(e,t,a,r){return this._getCachedCompiledWhilePatterns(e,t).compileAG(e,a,r)}_getCachedCompiledWhilePatterns(e,t){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new za,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,t||"\uFFFF"),this._cachedCompiledWhilePatterns}},gu=class qe{static createCaptureRule(t,a,r,o,n){return t.registerRule(s=>new ng(a,s,r,o,n))}static getCompiledRuleId(t,a,r){return t.id||a.registerRule(o=>{if(t.id=o,t.match)return new sg(t.$vscodeTextmateLocation,t.id,t.name,t.match,qe._compileCaptures(t.captures,a,r));if(typeof t.begin>"u"){t.repository&&(r=nu({},r,t.repository));let n=t.patterns;return typeof n>"u"&&t.include&&(n=[{include:t.include}]),new eu(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,qe._compilePatterns(n,a,r))}return t.while?new zr(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,qe._compileCaptures(t.beginCaptures||t.captures,a,r),t.while,qe._compileCaptures(t.whileCaptures||t.captures,a,r),qe._compilePatterns(t.patterns,a,r)):new Pn(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,qe._compileCaptures(t.beginCaptures||t.captures,a,r),t.end,qe._compileCaptures(t.endCaptures||t.captures,a,r),t.applyEndPatternLast,qe._compilePatterns(t.patterns,a,r))}),t.id}static _compileCaptures(t,a,r){let o=[];if(t){let n=0;for(let s in t){if(s==="$vscodeTextmateLocation")continue;let i=parseInt(s,10);i>n&&(n=i)}for(let s=0;s<=n;s++)o[s]=null;for(let s in t){if(s==="$vscodeTextmateLocation")continue;let i=parseInt(s,10),l=0;t[s].patterns&&(l=qe.getCompiledRuleId(t[s],a,r)),o[i]=qe.createCaptureRule(a,t[s].$vscodeTextmateLocation,t[s].name,t[s].contentName,l)}}return o}static _compilePatterns(t,a,r){let o=[];if(t)for(let n=0,s=t.length;n<s;n++){let i=t[n],l=-1;if(i.include){let u=mu(i.include);switch(u.kind){case 0:case 1:l=qe.getCompiledRuleId(r[i.include],a,r);break;case 2:let d=r[u.ruleName];d&&(l=qe.getCompiledRuleId(d,a,r));break;case 3:case 4:let c=u.scopeName,f=u.kind===4?u.ruleName:null,p=a.getExternalGrammar(c,r);if(p)if(f){let m=p.repository[f];m&&(l=qe.getCompiledRuleId(m,a,p.repository))}else l=qe.getCompiledRuleId(p.repository.$self,a,p.repository);break}}else l=qe.getCompiledRuleId(i,a,r);if(l!==-1){let u=a.getRule(l),d=!1;if((u instanceof eu||u instanceof Pn||u instanceof zr)&&u.hasMissingPatterns&&u.patterns.length===0&&(d=!0),d)continue;o.push(l)}}return{patterns:o,hasMissingPatterns:(t?t.length:0)!==o.length}}},ja=class wu{source;ruleId;hasAnchor;hasBackReferences;_anchorCache;constructor(t,a){if(t&&typeof t=="string"){let r=t.length,o=0,n=[],s=!1;for(let i=0;i<r;i++)if(t.charAt(i)==="\\"&&i+1<r){let u=t.charAt(i+1);u==="z"?(n.push(t.substring(o,i)),n.push("$(?!\\n)(?<!\\n)"),o=i+2):(u==="A"||u==="G")&&(s=!0),i++}this.hasAnchor=s,o===0?this.source=t:(n.push(t.substring(o,r)),this.source=n.join(""))}else this.hasAnchor=!1,this.source=t;this.hasAnchor?this._anchorCache=this._buildAnchorCache():this._anchorCache=null,this.ruleId=a,typeof this.source=="string"?this.hasBackReferences=rg.test(this.source):this.hasBackReferences=!1}clone(){return new wu(this.source,this.ruleId)}setSource(t){this.source!==t&&(this.source=t,this.hasAnchor&&(this._anchorCache=this._buildAnchorCache()))}resolveBackReferences(t,a){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let r=a.map(o=>t.substring(o.start,o.end));return Zl.lastIndex=0,this.source.replace(Zl,(o,n)=>uu(r[parseInt(n,10)]||""))}_buildAnchorCache(){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let t=[],a=[],r=[],o=[],n,s,i,l;for(n=0,s=this.source.length;n<s;n++)i=this.source.charAt(n),t[n]=i,a[n]=i,r[n]=i,o[n]=i,i==="\\"&&n+1<s&&(l=this.source.charAt(n+1),l==="A"?(t[n+1]="\uFFFF",a[n+1]="\uFFFF",r[n+1]="A",o[n+1]="A"):l==="G"?(t[n+1]="\uFFFF",a[n+1]="G",r[n+1]="\uFFFF",o[n+1]="G"):(t[n+1]=l,a[n+1]=l,r[n+1]=l,o[n+1]=l),n++);return{A0_G0:t.join(""),A0_G1:a.join(""),A1_G0:r.join(""),A1_G1:o.join("")}}resolveAnchors(t,a){return!this.hasAnchor||!this._anchorCache||typeof this.source!="string"?this.source:t?a?this._anchorCache.A1_G1:this._anchorCache.A1_G0:a?this._anchorCache.A0_G1:this._anchorCache.A0_G0}},za=class{_items;_hasAnchors;_cached;_anchorCache;constructor(){this._items=[],this._hasAnchors=!1,this._cached=null,this._anchorCache={A0_G0:null,A0_G1:null,A1_G0:null,A1_G1:null}}dispose(){this._disposeCaches()}_disposeCaches(){this._cached&&(this._cached.dispose(),this._cached=null),this._anchorCache.A0_G0&&(this._anchorCache.A0_G0.dispose(),this._anchorCache.A0_G0=null),this._anchorCache.A0_G1&&(this._anchorCache.A0_G1.dispose(),this._anchorCache.A0_G1=null),this._anchorCache.A1_G0&&(this._anchorCache.A1_G0.dispose(),this._anchorCache.A1_G0=null),this._anchorCache.A1_G1&&(this._anchorCache.A1_G1.dispose(),this._anchorCache.A1_G1=null)}push(e){this._items.push(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}unshift(e){this._items.unshift(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}length(){return this._items.length}setSource(e,t){this._items[e].source!==t&&(this._disposeCaches(),this._items[e].setSource(t))}compile(e){if(!this._cached){let t=this._items.map(a=>a.source);this._cached=new tu(e,t,this._items.map(a=>a.ruleId))}return this._cached}compileAG(e,t,a){return this._hasAnchors?t?a?(this._anchorCache.A1_G1||(this._anchorCache.A1_G1=this._resolveAnchors(e,t,a)),this._anchorCache.A1_G1):(this._anchorCache.A1_G0||(this._anchorCache.A1_G0=this._resolveAnchors(e,t,a)),this._anchorCache.A1_G0):a?(this._anchorCache.A0_G1||(this._anchorCache.A0_G1=this._resolveAnchors(e,t,a)),this._anchorCache.A0_G1):(this._anchorCache.A0_G0||(this._anchorCache.A0_G0=this._resolveAnchors(e,t,a)),this._anchorCache.A0_G0):this.compile(e)}_resolveAnchors(e,t,a){let r=this._items.map(o=>o.resolveAnchors(t,a));return new tu(e,r,this._items.map(o=>o.ruleId))}},tu=class{constructor(e,t,a){this.regExps=t,this.rules=a,this.scanner=e.createOnigScanner(t)}scanner;dispose(){typeof this.scanner.dispose=="function"&&this.scanner.dispose()}toString(){let e=[];for(let t=0,a=this.rules.length;t<a;t++)e.push(" - "+this.rules[t]+": "+this.regExps[t]);return e.join(`
|
|
5
5
|
`)}findNextMatchSync(e,t,a){let r=this.scanner.findNextMatchSync(e,t,a);return r?{ruleId:this.rules[r.index],captureIndices:r.captureIndices}:null}},vn=class{constructor(e,t){this.languageId=e,this.tokenType=t}},ig=class Rn{_defaultAttributes;_embeddedLanguagesMatcher;constructor(t,a){this._defaultAttributes=new vn(t,8),this._embeddedLanguagesMatcher=new lg(Object.entries(a||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(t){return t===null?Rn._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(t)}static _NULL_SCOPE_METADATA=new vn(0,0);_getBasicScopeAttributes=new du(t=>{let a=this._scopeToLanguage(t),r=this._toStandardTokenType(t);return new vn(a,r)});_scopeToLanguage(t){return this._embeddedLanguagesMatcher.match(t)||0}_toStandardTokenType(t){let a=t.match(Rn.STANDARD_TOKEN_TYPE_REGEXP);if(!a)return 8;switch(a[1]){case"comment":return 1;case"string":return 2;case"regex":return 3;case"meta.embedded":return 0}throw new Error("Unexpected match for standard token type!")}static STANDARD_TOKEN_TYPE_REGEXP=/\b(comment|string|regex|meta\.embedded)\b/},lg=class{values;scopesRegExp;constructor(e){if(e.length===0)this.values=null,this.scopesRegExp=null;else{this.values=new Map(e);let t=e.map(([a,r])=>uu(a));t.sort(),t.reverse(),this.scopesRegExp=new RegExp(`^((${t.join(")|(")}))($|\\.)`,"")}}match(e){if(!this.scopesRegExp)return;let t=e.match(this.scopesRegExp);if(t)return this.values.get(t[1])}},rk={InDebugMode:typeof process<"u"&&!!process.env.VSCODE_TEXTMATE_DEBUG},Iu=!1,au=class{constructor(e,t){this.stack=e,this.stoppedEarly=t}};function xu(e,t,a,r,o,n,s,i){let l=t.content.length,u=!1,d=-1;if(s){let p=ug(e,t,a,r,o,n);o=p.stack,r=p.linePos,a=p.isFirstLine,d=p.anchorPosition}let c=Date.now();for(;!u;){if(i!==0&&Date.now()-c>i)return new au(o,!0);f()}return new au(o,!1);function f(){let p=dg(e,t,a,r,o,d);if(!p){n.produce(o,l),u=!0;return}let m=p.captureIndices,L=p.matchedRuleId,C=m&&m.length>0?m[0].end>r:!1;if(L===og){let y=o.getRule(e);n.produce(o,m[0].start),o=o.withContentNameScopesList(o.nameScopesList),qa(e,t,a,o,n,y.endCaptures,m),n.produce(o,m[0].end);let S=o;if(o=o.parent,d=S.getAnchorPos(),!C&&S.getEnterPos()===r){o=S,n.produce(o,l),u=!0;return}}else{let y=e.getRule(L);n.produce(o,m[0].start);let S=o,I=y.getName(t.content,m),x=o.contentNameScopesList.pushAttributed(I,e);if(o=o.push(L,r,d,m[0].end===l,null,x,x),y instanceof Pn){let v=y;qa(e,t,a,o,n,v.beginCaptures,m),n.produce(o,m[0].end),d=m[0].end;let N=v.getContentName(t.content,m),U=x.pushAttributed(N,e);if(o=o.withContentNameScopesList(U),v.endHasBackReferences&&(o=o.withEndRule(v.getEndWithResolvedBackReferences(t.content,m))),!C&&S.hasSameRuleAs(o)){o=o.pop(),n.produce(o,l),u=!0;return}}else if(y instanceof zr){let v=y;qa(e,t,a,o,n,v.beginCaptures,m),n.produce(o,m[0].end),d=m[0].end;let N=v.getContentName(t.content,m),U=x.pushAttributed(N,e);if(o=o.withContentNameScopesList(U),v.whileHasBackReferences&&(o=o.withEndRule(v.getWhileWithResolvedBackReferences(t.content,m))),!C&&S.hasSameRuleAs(o)){o=o.pop(),n.produce(o,l),u=!0;return}}else if(qa(e,t,a,o,n,y.captures,m),n.produce(o,m[0].end),o=o.pop(),!C){o=o.safePop(),n.produce(o,l),u=!0;return}}m[0].end>r&&(r=m[0].end,a=!1)}}function ug(e,t,a,r,o,n){let s=o.beginRuleCapturedEOL?0:-1,i=[];for(let l=o;l;l=l.pop()){let u=l.getRule(e);u instanceof zr&&i.push({rule:u,stack:l})}for(let l=i.pop();l;l=i.pop()){let{ruleScanner:u,findOptions:d}=pg(l.rule,e,l.stack.endRule,a,r===s),c=u.findNextMatchSync(t,r,d);if(c){if(c.ruleId!==hu){o=l.stack.pop();break}c.captureIndices&&c.captureIndices.length&&(n.produce(l.stack,c.captureIndices[0].start),qa(e,t,a,l.stack,n,l.rule.whileCaptures,c.captureIndices),n.produce(l.stack,c.captureIndices[0].end),s=c.captureIndices[0].end,c.captureIndices[0].end>r&&(r=c.captureIndices[0].end,a=!1))}else{o=l.stack.pop();break}}return{stack:o,linePos:r,anchorPosition:s,isFirstLine:a}}function dg(e,t,a,r,o,n){let s=cg(e,t,a,r,o,n),i=e.getInjections();if(i.length===0)return s;let l=fg(i,e,t,a,r,o,n);if(!l)return s;if(!s)return l;let u=s.captureIndices[0].start,d=l.captureIndices[0].start;return d<u||l.priorityMatch&&d===u?l:s}function cg(e,t,a,r,o,n){let s=o.getRule(e),{ruleScanner:i,findOptions:l}=yu(s,e,o.endRule,a,r===n),u=i.findNextMatchSync(t,r,l);return u?{captureIndices:u.captureIndices,matchedRuleId:u.ruleId}:null}function fg(e,t,a,r,o,n,s){let i=Number.MAX_VALUE,l=null,u,d=0,c=n.contentNameScopesList.getScopeNames();for(let f=0,p=e.length;f<p;f++){let m=e[f];if(!m.matcher(c))continue;let L=t.getRule(m.ruleId),{ruleScanner:C,findOptions:y}=yu(L,t,null,r,o===s),S=C.findNextMatchSync(a,o,y);if(!S)continue;let I=S.captureIndices[0].start;if(!(I>=i)&&(i=I,l=S.captureIndices,u=S.ruleId,d=m.priority,i===o))break}return l?{priorityMatch:d===-1,captureIndices:l,matchedRuleId:u}:null}function yu(e,t,a,r,o){if(Iu){let s=e.compile(t,a),i=Lu(r,o);return{ruleScanner:s,findOptions:i}}return{ruleScanner:e.compileAG(t,a,r,o),findOptions:0}}function pg(e,t,a,r,o){if(Iu){let s=e.compileWhile(t,a),i=Lu(r,o);return{ruleScanner:s,findOptions:i}}return{ruleScanner:e.compileWhileAG(t,a,r,o),findOptions:0}}function Lu(e,t){let a=0;return e||(a|=1),t||(a|=4),a}function qa(e,t,a,r,o,n,s){if(n.length===0)return;let i=t.content,l=Math.min(n.length,s.length),u=[],d=s[0].end;for(let c=0;c<l;c++){let f=n[c];if(f===null)continue;let p=s[c];if(p.length===0)continue;if(p.start>d)break;for(;u.length>0&&u[u.length-1].endPos<=p.start;)o.produceFromScopes(u[u.length-1].scopes,u[u.length-1].endPos),u.pop();if(u.length>0?o.produceFromScopes(u[u.length-1].scopes,p.start):o.produce(r,p.start),f.retokenizeCapturedWithRuleId){let L=f.getName(i,s),C=r.contentNameScopesList.pushAttributed(L,e),y=f.getContentName(i,s),S=C.pushAttributed(y,e),I=r.push(f.retokenizeCapturedWithRuleId,p.start,-1,!1,null,C,S),x=e.createOnigString(i.substring(0,p.end));xu(e,x,a&&p.start===0,p.start,I,o,!1,0),pu(x);continue}let m=f.getName(i,s);if(m!==null){let C=(u.length>0?u[u.length-1].scopes:r.contentNameScopesList).pushAttributed(m,e);u.push(new mg(C,p.end))}}for(;u.length>0;)o.produceFromScopes(u[u.length-1].scopes,u[u.length-1].endPos),u.pop()}var mg=class{scopes;endPos;constructor(e,t){this.scopes=e,this.endPos=t}};function hg(e,t,a,r,o,n,s,i){return new wg(e,t,a,r,o,n,s,i)}function ru(e,t,a,r,o){let n=Wr(t,Vr),s=gu.getCompiledRuleId(a,r,o.repository);for(let i of n)e.push({debugSelector:t,matcher:i.matcher,ruleId:s,grammar:o,priority:i.priority})}function Vr(e,t){if(t.length<e.length)return!1;let a=0;return e.every(r=>{for(let o=a;o<t.length;o++)if(gg(t[o],r))return a=o+1,!0;return!1})}function gg(e,t){if(!e)return!1;if(e===t)return!0;let a=t.length;return e.length>a&&e.substr(0,a)===t&&e[a]==="."}var wg=class{constructor(e,t,a,r,o,n,s,i){if(this._rootScopeName=e,this.balancedBracketSelectors=n,this._onigLib=i,this._basicScopeAttributesProvider=new ig(a,r),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=s,this._grammar=ou(t,null),this._injections=null,this._tokenTypeMatchers=[],o)for(let l of Object.keys(o)){let u=Wr(l,Vr);for(let d of u)this._tokenTypeMatchers.push({matcher:d.matcher,type:o[l]})}}_rootId;_lastRuleId;_ruleId2desc;_includedGrammars;_grammarRepository;_grammar;_injections;_basicScopeAttributesProvider;_tokenTypeMatchers;get themeProvider(){return this._grammarRepository}dispose(){for(let e of this._ruleId2desc)e&&e.dispose()}createOnigScanner(e){return this._onigLib.createOnigScanner(e)}createOnigString(e){return this._onigLib.createOnigString(e)}getMetadataForScope(e){return this._basicScopeAttributesProvider.getBasicScopeAttributes(e)}_collectInjections(){let e={lookup:o=>o===this._rootScopeName?this._grammar:this.getExternalGrammar(o),injections:o=>this._grammarRepository.injections(o)},t=[],a=this._rootScopeName,r=e.lookup(a);if(r){let o=r.injections;if(o)for(let s in o)ru(t,s,o[s],this,r);let n=this._grammarRepository.injections(a);n&&n.forEach(s=>{let i=this.getExternalGrammar(s);if(i){let l=i.injectionSelector;l&&ru(t,l,i,this,i)}})}return t.sort((o,n)=>o.priority-n.priority),t}getInjections(){return this._injections===null&&(this._injections=this._collectInjections()),this._injections}registerRule(e){let t=++this._lastRuleId,a=e(t);return this._ruleId2desc[t]=a,a}getRule(e){return this._ruleId2desc[e]}getExternalGrammar(e,t){if(this._includedGrammars[e])return this._includedGrammars[e];if(this._grammarRepository){let a=this._grammarRepository.lookup(e);if(a)return this._includedGrammars[e]=ou(a,t&&t.$base),this._includedGrammars[e]}}tokenizeLine(e,t,a=0){let r=this._tokenize(e,t,!1,a);return{tokens:r.lineTokens.getResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}tokenizeLine2(e,t,a=0){let r=this._tokenize(e,t,!0,a);return{tokens:r.lineTokens.getBinaryResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}_tokenize(e,t,a,r){this._rootId===-1&&(this._rootId=gu.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections());let o;if(!t||t===En.NULL){o=!0;let u=this._basicScopeAttributesProvider.getDefaultAttributes(),d=this.themeProvider.getDefaults(),c=Vt.set(0,u.languageId,u.tokenType,null,d.fontStyle,d.foregroundId,d.backgroundId),f=this.getRule(this._rootId).getName(null,null),p;f?p=Ha.createRootAndLookUpScopeName(f,c,this):p=Ha.createRoot("unknown",c),t=new En(null,this._rootId,-1,-1,!1,null,p,p)}else o=!1,t.reset();e=e+`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@waniwani/sdk",
|
|
3
|
-
"version": "0.22.0-beta.
|
|
3
|
+
"version": "0.22.0-beta.4",
|
|
4
4
|
"description": "MCP distribution SDK. Build sales funnels, lead generation, booking, and quote apps on top of your MCP server. Event tracking, flows, widgets, knowledge base.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|