@waniwani/sdk 0.12.1 → 0.12.2
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/legacy/index.d.ts +87 -15
- package/dist/legacy/index.js +13 -13
- package/dist/legacy/index.js.map +1 -1
- package/dist/legacy/mcp/react.d.ts +87 -15
- package/dist/legacy/mcp/react.js +7 -7
- package/dist/legacy/mcp/react.js.map +1 -1
- package/dist/mcp/react.d.ts +87 -15
- package/dist/mcp/react.js +7 -7
- package/dist/mcp/react.js.map +1 -1
- package/package.json +1 -1
package/dist/legacy/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as Ir,b as Sr,c as yr,d as pt,e as mt,f as la,g as kr,h as br,i as Tr,j as Pr,k as ua,l as vr,m as lo,n as Ar,o as Rr,p as ht,u as uo}from"../chunk-4WLKD7DL.js";import{a as io,b as _l,c as Nl}from"../chunk-R6LESDWJ.js";import{b as yt,c as ft,d as Lr,e as Cr}from"../chunk-PYLRF5BB.js";import{d as f}from"../chunk-LPD7BHH5.js";f();f();f();f();var da="text/html+skybridge",ca="text/html;profile=mcp-app",Mr=async(e,t)=>{let a=e.endsWith("/")?e.slice(0,-1):e;return await(await fetch(`${a}${t}`)).text()};function Fr(e){return{"openai/widgetDescription":e.description,"openai/widgetPrefersBorder":e.prefersBorder,"openai/widgetDomain":e.widgetDomain,...e.widgetCSP&&{"openai/widgetCSP":e.widgetCSP}}}function Dr(e){let t=e.widgetCSP?{connectDomains:e.widgetCSP.connect_domains,resourceDomains:e.widgetCSP.resource_domains,frameDomains:e.widgetCSP.frame_domains,redirectDomains:e.widgetCSP.redirect_domains}:void 0;return{ui:{...t&&{csp:t},...e.widgetDomain&&{domain:e.widgetDomain},...e.prefersBorder!==void 0&&{prefersBorder:e.prefersBorder}}}}function co(e){return{...e.openaiTemplateUri&&{"openai/outputTemplate":e.openaiTemplateUri},"openai/toolInvocation/invoking":e.invoking,"openai/toolInvocation/invoked":e.invoked,"openai/widgetAccessible":!0,"openai/resultCanProduceWidget":!0,...e.mcpTemplateUri&&{ui:{resourceUri:e.mcpTemplateUri,...e.autoHeight&&{autoHeight:!0}}},...e.mcpTemplateUri&&{"ui/resourceUri":e.mcpTemplateUri}}}function Br(e){let{id:t,title:a,description:o,baseUrl:r,htmlPath:s,widgetDomain:n,prefersBorder:l=!0,autoHeight:i=!0}=e,u=e.widgetCSP??{connect_domains:[r],resource_domains:[r]};if(process.env.NODE_ENV==="development")try{let{hostname:L}=new URL(r);(L==="localhost"||L==="127.0.0.1")&&(u={...u,connect_domains:[...u.connect_domains||[],`ws://${L}:*`,`wss://${L}:*`],resource_domains:[...u.resource_domains||[],`http://${L}:*`]})}catch{}let c=`ui://widgets/apps-sdk/${t}.html`,d=`ui://widgets/ext-apps/${t}.html`,p=null,m=()=>(p||(p=Mr(r,s)),p),h=o;async function I(L){let S=await m();L.registerResource(`${t}-openai-widget`,c,{title:a,description:h,mimeType:da,_meta:{"openai/widgetDescription":h,"openai/widgetPrefersBorder":l}},async C=>({contents:[{uri:C.href,mimeType:da,text:S,_meta:Fr({description:h,prefersBorder:l,widgetDomain:n,widgetCSP:u})}]})),L.registerResource(`${t}-mcp-widget`,d,{title:a,description:h,mimeType:ca,_meta:{ui:{prefersBorder:l}}},async C=>({contents:[{uri:C.href,mimeType:ca,text:S,_meta:Dr({description:h,prefersBorder:l,widgetDomain:n,widgetCSP:u})}]}))}return{id:t,title:a,description:o,openaiUri:c,mcpUri:d,autoHeight:i,register:I}}f();f();var Ol="waniwani/client";function Er(e){if(typeof e=="object"&&e!==null)return e[Ol]}function Ul(e,t){let{resource:a,description:o,inputSchema:r,annotations:s,autoInjectResultText:n=!0}=e,l=e.id??a?.id,i=e.title??a?.title;if(!l)throw new Error("createTool: `id` is required when no resource is provided");if(!i)throw new Error("createTool: `title` is required when no resource is provided");let u=a?co({openaiTemplateUri:a.openaiUri,mcpTemplateUri:a.mcpUri,invoking:e.invoking??"Loading...",invoked:e.invoked??"Loaded",autoHeight:a.autoHeight}):void 0;return{id:l,title:i,description:o,async register(c){c.registerTool(l,{title:i,description:o,inputSchema:r,annotations:s,...u&&{_meta:u}},(async(d,p)=>{let m=p,h=m._meta??{},I=Er(m),L=await t(d,{extra:{_meta:h},waniwani:I});return a&&L.data?{content:[{type:"text",text:L.text}],structuredContent:L.data,_meta:{...u,...h,...n===!1?{"waniwani/autoInjectResultText":!1}:{}}}:{content:[{type:"text",text:L.text}],...L.data?{structuredContent:L.data}:{},...n===!1?{_meta:{"waniwani/autoInjectResultText":!1}}:{}}}))}}}async function Hl(e,t){await Promise.all(t.map(a=>a.register(e)))}f();f();import{Fragment as jl,jsx as kt,jsxs as zl}from"react/jsx-runtime";function ql(){let e=window.innerBaseUrl,t=window.__wwPassthroughOrigins??[],a=document.documentElement;new MutationObserver(i=>{i.forEach(u=>{if(u.type==="attributes"&&u.target===a){let c=u.attributeName;c&&c!=="suppresshydrationwarning"&&c!=="lang"&&c!=="class"&&c!=="style"&&a.removeAttribute(c)}})}).observe(a,{attributes:!0,attributeOldValue:!0});let r=history.replaceState.bind(history);history.replaceState=(i,u,c)=>{try{let d=new URL(String(c??""),window.location.href);r(null,u,d.pathname+d.search+d.hash)}catch{}};let s=history.pushState.bind(history);history.pushState=(i,u,c)=>{try{let d=new URL(String(c??""),window.location.href);s(null,u,d.pathname+d.search+d.hash)}catch{}};let n=new URL(e).origin,l=window.self!==window.top;if(window.addEventListener("click",i=>{let u=i?.target?.closest("a");if(!u||!u.href)return;let c=new URL(u.href,window.location.href);if(c.origin!==window.location.origin&&c.origin!==n)try{window.openai&&(window.openai?.openExternal({href:u.href}),i.preventDefault())}catch{console.warn("openExternal failed, likely not in OpenAI client")}},!0),l&&window.location.origin!==n){let i=window.fetch;window.fetch=((p,m)=>{let h=typeof p=="string"&&!/^[a-z][a-z0-9+.-]*:/i.test(p)&&!p.startsWith("//"),I;if(typeof p=="string"||p instanceof URL?I=new URL(p,window.location.href):I=new URL(p.url,window.location.href),I.origin===n)return typeof p=="string"||p instanceof URL?p=I.toString():p=new Request(I.toString(),p),i.call(window,p,{...m,mode:"cors"});if(t.indexOf(I.origin)!==-1)return i.call(window,p,m);if(h&&I.origin===window.location.origin){let L=new URL(e);return L.pathname=I.pathname,L.search=I.search,L.hash=I.hash,I=L,p=I.toString(),i.call(window,p,{...m,mode:"cors"})}return i.call(window,p,m)});let u=n.replace(/^http/,"ws"),c=window.WebSocket,d=((p,m)=>{let h=new URL(String(p),window.location.href);if(h.origin===window.location.origin||h.origin===window.location.origin.replace(/^http/,"ws")){let I=new URL(u);return I.pathname=h.pathname,I.search=h.search,I.hash=h.hash,new c(I.toString(),m)}return new c(p,m)});d.prototype=c.prototype,Object.assign(d,{CONNECTING:c.CONNECTING,OPEN:c.OPEN,CLOSING:c.CLOSING,CLOSED:c.CLOSED}),window.WebSocket=d}}var Wl=`(${ql.toString()})()`;function Gl({baseUrl:e,passthroughOrigins:t}){return zl(jl,{children:[kt("base",{href:e}),kt("script",{children:`window.innerBaseUrl = ${JSON.stringify(e)}`}),kt("script",{children:`window.__wwPassthroughOrigins = ${JSON.stringify(t??[])}`}),kt("script",{children:'window.__isChatGptApp = typeof window.openai !== "undefined";'}),kt("script",{children:Wl})]})}f();f();import{useCallback as He,useEffect as gt,useRef as fo,useState as De}from"react";f();var _r={theme:"dark",userAgent:{device:{type:"desktop"},capabilities:{hover:!0,touch:!1}},locale:"en",maxHeight:800,displayMode:"inline",safeArea:{insets:{top:0,bottom:0,left:0,right:0}},toolInput:{},toolOutput:null,toolResponseMetadata:null,widgetState:null},bt={..._r};function Tt(e){typeof window>"u"||window.openai||(bt={..._r,toolOutput:e??null},window.openai={...bt,requestDisplayMode:async({mode:t})=>(Ye("displayMode",t),{mode:t}),callTool:async(t,a)=>(console.log(`[DevMode] callTool: ${t}`,a),{result:JSON.stringify({mock:!0,tool:t,args:a})}),sendFollowUpMessage:async({prompt:t})=>{console.log(`[DevMode] sendFollowUpMessage: ${t}`)},openExternal:({href:t})=>{console.log(`[DevMode] openExternal: ${t}`),window.open(t,"_blank")},setWidgetState:async t=>{Ye("widgetState",t)}},window.dispatchEvent(new yt({globals:bt})))}function Ye(e,t){typeof window>"u"||!window.openai||(bt[e]=t,window.openai[e]=t,window.dispatchEvent(new yt({globals:{[e]:t}})))}function fa(){return{...bt}}function Pt(e){Ye("toolOutput",e)}function vt(e){Ye("displayMode",e)}function At(e){Ye("theme",e)}import{Fragment as po,jsx as D,jsxs as V}from"react/jsx-runtime";var pa=150;function Nr({className:e}){return V("svg",{className:e,viewBox:"0 0 24 24",fill:"none",role:"img","aria-label":"Dev Controls",children:[D("rect",{x:"4",y:"4",width:"10",height:"10",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),D("rect",{x:"10",y:"10",width:"10",height:"10",rx:"2",stroke:"currentColor",strokeWidth:"1.5",fill:"currentColor",fillOpacity:"0.15"})]})}function Vl({className:e}){return D("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:D("path",{d:"M18 6L6 18M6 6l12 12"})})}function $l({className:e}){return D("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 16 16",fill:"none",children:D("rect",{x:"2",y:"4",width:"12",height:"8",rx:"1.5",stroke:"currentColor",strokeWidth:"1.25"})})}function Xl({className:e}){return V("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 16 16",fill:"none",children:[D("rect",{x:"1.5",y:"3",width:"13",height:"10",rx:"1.5",stroke:"currentColor",strokeWidth:"1.25"}),D("rect",{x:"8.5",y:"7",width:"5",height:"4",rx:"0.75",fill:"currentColor"})]})}function Kl({className:e}){return D("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 16 16",fill:"none",children:D("path",{d:"M2 5.5V3.5C2 2.95 2.45 2.5 3 2.5H5.5M10.5 2.5H13C13.55 2.5 14 2.95 14 3.5V5.5M14 10.5V12.5C14 13.05 13.55 13.5 13 13.5H10.5M5.5 13.5H3C2.45 13.5 2 13.05 2 12.5V10.5",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})})}function Ql({className:e}){return V("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 16 16",fill:"none",children:[D("circle",{cx:"8",cy:"8",r:"2.5",stroke:"currentColor",strokeWidth:"1.25"}),D("path",{d:"M8 2v1.5M8 12.5V14M2 8h1.5M12.5 8H14M4.11 4.11l1.06 1.06M10.83 10.83l1.06 1.06M4.11 11.89l1.06-1.06M10.83 5.17l1.06-1.06",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round"})]})}function Jl({className:e}){return D("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 16 16",fill:"none",children:D("path",{d:"M13.5 9.5a5.5 5.5 0 01-7-7 5.5 5.5 0 107 7z",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})})}function Zl({className:e}){return V("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 16 16",fill:"none",children:[D("path",{d:"M2.5 8a5.5 5.5 0 019.37-3.9M13.5 8a5.5 5.5 0 01-9.37 3.9",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round"}),D("path",{d:"M12.5 2v3h-3M3.5 14v-3h3",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})]})}var Yl=`
|
|
1
|
+
import{a as yr,b as br,c as kr,d as pt,e as mt,f as ua,g as Tr,h as Pr,i as vr,j as Ar,k as da,l as Rr,m as uo,n as Mr,o as Fr,p as ht,u as co}from"../chunk-4WLKD7DL.js";import{a as lo,b as Wl,c as Gl}from"../chunk-R6LESDWJ.js";import{b as yt,c as ft,d as Ir,e as Sr}from"../chunk-PYLRF5BB.js";import{d as f}from"../chunk-LPD7BHH5.js";f();f();f();f();var ca="text/html+skybridge",fa="text/html;profile=mcp-app",Dr=async(e,t)=>{let a=e.endsWith("/")?e.slice(0,-1):e;return await(await fetch(`${a}${t}`)).text()};function Br(e){return{"openai/widgetDescription":e.description,"openai/widgetPrefersBorder":e.prefersBorder,"openai/widgetDomain":e.widgetDomain,...e.widgetCSP&&{"openai/widgetCSP":e.widgetCSP}}}function Er(e){let t=e.widgetCSP?{connectDomains:e.widgetCSP.connect_domains,resourceDomains:e.widgetCSP.resource_domains,frameDomains:e.widgetCSP.frame_domains,redirectDomains:e.widgetCSP.redirect_domains}:void 0;return{ui:{...t&&{csp:t},...e.widgetDomain&&{domain:e.widgetDomain},...e.prefersBorder!==void 0&&{prefersBorder:e.prefersBorder}}}}function fo(e){return{...e.openaiTemplateUri&&{"openai/outputTemplate":e.openaiTemplateUri},"openai/toolInvocation/invoking":e.invoking,"openai/toolInvocation/invoked":e.invoked,"openai/widgetAccessible":!0,"openai/resultCanProduceWidget":!0,...e.mcpTemplateUri&&{ui:{resourceUri:e.mcpTemplateUri,...e.autoHeight&&{autoHeight:!0}}},...e.mcpTemplateUri&&{"ui/resourceUri":e.mcpTemplateUri}}}function _r(e){let{id:t,title:a,description:o,baseUrl:r,htmlPath:s,widgetDomain:n,prefersBorder:l=!0,autoHeight:i=!0}=e,u=e.widgetCSP??{connect_domains:[r],resource_domains:[r]};if(process.env.NODE_ENV==="development")try{let{hostname:L}=new URL(r);(L==="localhost"||L==="127.0.0.1")&&(u={...u,connect_domains:[...u.connect_domains||[],`ws://${L}:*`,`wss://${L}:*`],resource_domains:[...u.resource_domains||[],`http://${L}:*`]})}catch{}let c=`ui://widgets/apps-sdk/${t}.html`,d=`ui://widgets/ext-apps/${t}.html`,p=null,m=()=>(p||(p=Dr(r,s)),p),h=o;async function I(L){let S=await m();L.registerResource(`${t}-openai-widget`,c,{title:a,description:h,mimeType:ca,_meta:{"openai/widgetDescription":h,"openai/widgetPrefersBorder":l}},async C=>({contents:[{uri:C.href,mimeType:ca,text:S,_meta:Br({description:h,prefersBorder:l,widgetDomain:n,widgetCSP:u})}]})),L.registerResource(`${t}-mcp-widget`,d,{title:a,description:h,mimeType:fa,_meta:{ui:{prefersBorder:l}}},async C=>({contents:[{uri:C.href,mimeType:fa,text:S,_meta:Er({description:h,prefersBorder:l,widgetDomain:n,widgetCSP:u})}]}))}return{id:t,title:a,description:o,openaiUri:c,mcpUri:d,autoHeight:i,register:I}}f();f();var jl="waniwani/client";function Nr(e){if(typeof e=="object"&&e!==null)return e[jl]}function zl(e,t){let{resource:a,description:o,inputSchema:r,annotations:s,autoInjectResultText:n=!0}=e,l=e.id??a?.id,i=e.title??a?.title;if(!l)throw new Error("createTool: `id` is required when no resource is provided");if(!i)throw new Error("createTool: `title` is required when no resource is provided");let u=a?fo({openaiTemplateUri:a.openaiUri,mcpTemplateUri:a.mcpUri,invoking:e.invoking??"Loading...",invoked:e.invoked??"Loaded",autoHeight:a.autoHeight}):void 0;return{id:l,title:i,description:o,async register(c){c.registerTool(l,{title:i,description:o,inputSchema:r,annotations:s,...u&&{_meta:u}},(async(d,p)=>{let m=p,h=m._meta??{},I=Nr(m),L=await t(d,{extra:{_meta:h},waniwani:I});return a&&L.data?{content:[{type:"text",text:L.text}],structuredContent:L.data,_meta:{...u,...h,...n===!1?{"waniwani/autoInjectResultText":!1}:{}}}:{content:[{type:"text",text:L.text}],...L.data?{structuredContent:L.data}:{},...n===!1?{_meta:{"waniwani/autoInjectResultText":!1}}:{}}}))}}}async function Vl(e,t){await Promise.all(t.map(a=>a.register(e)))}f();f();import{Fragment as Ql,jsx as bt,jsxs as Jl}from"react/jsx-runtime";function $l(){let e=window.innerBaseUrl,t=window.__wwPassthroughOrigins??[],a=document.documentElement;new MutationObserver(i=>{i.forEach(u=>{if(u.type==="attributes"&&u.target===a){let c=u.attributeName;c&&c!=="suppresshydrationwarning"&&c!=="lang"&&c!=="class"&&c!=="style"&&a.removeAttribute(c)}})}).observe(a,{attributes:!0,attributeOldValue:!0});let r=history.replaceState.bind(history);history.replaceState=(i,u,c)=>{try{let d=new URL(String(c??""),window.location.href);r(null,u,d.pathname+d.search+d.hash)}catch{}};let s=history.pushState.bind(history);history.pushState=(i,u,c)=>{try{let d=new URL(String(c??""),window.location.href);s(null,u,d.pathname+d.search+d.hash)}catch{}};let n=new URL(e).origin,l=window.self!==window.top;if(window.addEventListener("click",i=>{let u=i?.target?.closest("a");if(!u||!u.href)return;let c=new URL(u.href,window.location.href);if(c.origin!==window.location.origin&&c.origin!==n)try{window.openai&&(window.openai?.openExternal({href:u.href}),i.preventDefault())}catch{console.warn("openExternal failed, likely not in OpenAI client")}},!0),l&&window.location.origin!==n){let i=window.fetch;window.fetch=((p,m)=>{let h=typeof p=="string"&&!/^[a-z][a-z0-9+.-]*:/i.test(p)&&!p.startsWith("//"),I;if(typeof p=="string"||p instanceof URL?I=new URL(p,window.location.href):I=new URL(p.url,window.location.href),I.origin===n)return typeof p=="string"||p instanceof URL?p=I.toString():p=new Request(I.toString(),p),i.call(window,p,{...m,mode:"cors"});if(t.indexOf(I.origin)!==-1)return i.call(window,p,m);if(h&&I.origin===window.location.origin){let L=new URL(e);return L.pathname=I.pathname,L.search=I.search,L.hash=I.hash,I=L,p=I.toString(),i.call(window,p,{...m,mode:"cors"})}return i.call(window,p,m)});let u=n.replace(/^http/,"ws"),c=window.WebSocket,d=((p,m)=>{let h=new URL(String(p),window.location.href);if(h.origin===window.location.origin||h.origin===window.location.origin.replace(/^http/,"ws")){let I=new URL(u);return I.pathname=h.pathname,I.search=h.search,I.hash=h.hash,new c(I.toString(),m)}return new c(p,m)});d.prototype=c.prototype,Object.assign(d,{CONNECTING:c.CONNECTING,OPEN:c.OPEN,CLOSING:c.CLOSING,CLOSED:c.CLOSED}),window.WebSocket=d}}var Xl=`(${$l.toString()})()`;function Kl({baseUrl:e,passthroughOrigins:t}){return Jl(Ql,{children:[bt("base",{href:e}),bt("script",{children:`window.innerBaseUrl = ${JSON.stringify(e)}`}),bt("script",{children:`window.__wwPassthroughOrigins = ${JSON.stringify(t??[])}`}),bt("script",{children:'window.__isChatGptApp = typeof window.openai !== "undefined";'}),bt("script",{children:Xl})]})}f();f();import{useCallback as He,useEffect as gt,useRef as po,useState as De}from"react";f();var Ur={theme:"dark",userAgent:{device:{type:"desktop"},capabilities:{hover:!0,touch:!1}},locale:"en",maxHeight:800,displayMode:"inline",safeArea:{insets:{top:0,bottom:0,left:0,right:0}},toolInput:{},toolOutput:null,toolResponseMetadata:null,widgetState:null},kt={...Ur};function Tt(e){typeof window>"u"||window.openai||(kt={...Ur,toolOutput:e??null},window.openai={...kt,requestDisplayMode:async({mode:t})=>(Ye("displayMode",t),{mode:t}),callTool:async(t,a)=>(console.log(`[DevMode] callTool: ${t}`,a),{result:JSON.stringify({mock:!0,tool:t,args:a})}),sendFollowUpMessage:async({prompt:t})=>{console.log(`[DevMode] sendFollowUpMessage: ${t}`)},openExternal:({href:t})=>{console.log(`[DevMode] openExternal: ${t}`),window.open(t,"_blank")},setWidgetState:async t=>{Ye("widgetState",t)}},window.dispatchEvent(new yt({globals:kt})))}function Ye(e,t){typeof window>"u"||!window.openai||(kt[e]=t,window.openai[e]=t,window.dispatchEvent(new yt({globals:{[e]:t}})))}function pa(){return{...kt}}function Pt(e){Ye("toolOutput",e)}function vt(e){Ye("displayMode",e)}function At(e){Ye("theme",e)}import{Fragment as mo,jsx as D,jsxs as V}from"react/jsx-runtime";var ma=150;function Or({className:e}){return V("svg",{className:e,viewBox:"0 0 24 24",fill:"none",role:"img","aria-label":"Dev Controls",children:[D("rect",{x:"4",y:"4",width:"10",height:"10",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),D("rect",{x:"10",y:"10",width:"10",height:"10",rx:"2",stroke:"currentColor",strokeWidth:"1.5",fill:"currentColor",fillOpacity:"0.15"})]})}function Zl({className:e}){return D("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:D("path",{d:"M18 6L6 18M6 6l12 12"})})}function Yl({className:e}){return D("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 16 16",fill:"none",children:D("rect",{x:"2",y:"4",width:"12",height:"8",rx:"1.5",stroke:"currentColor",strokeWidth:"1.25"})})}function eu({className:e}){return V("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 16 16",fill:"none",children:[D("rect",{x:"1.5",y:"3",width:"13",height:"10",rx:"1.5",stroke:"currentColor",strokeWidth:"1.25"}),D("rect",{x:"8.5",y:"7",width:"5",height:"4",rx:"0.75",fill:"currentColor"})]})}function tu({className:e}){return D("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 16 16",fill:"none",children:D("path",{d:"M2 5.5V3.5C2 2.95 2.45 2.5 3 2.5H5.5M10.5 2.5H13C13.55 2.5 14 2.95 14 3.5V5.5M14 10.5V12.5C14 13.05 13.55 13.5 13 13.5H10.5M5.5 13.5H3C2.45 13.5 2 13.05 2 12.5V10.5",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})})}function au({className:e}){return V("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 16 16",fill:"none",children:[D("circle",{cx:"8",cy:"8",r:"2.5",stroke:"currentColor",strokeWidth:"1.25"}),D("path",{d:"M8 2v1.5M8 12.5V14M2 8h1.5M12.5 8H14M4.11 4.11l1.06 1.06M10.83 10.83l1.06 1.06M4.11 11.89l1.06-1.06M10.83 5.17l1.06-1.06",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round"})]})}function ou({className:e}){return D("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 16 16",fill:"none",children:D("path",{d:"M13.5 9.5a5.5 5.5 0 01-7-7 5.5 5.5 0 107 7z",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})})}function ru({className:e}){return V("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 16 16",fill:"none",children:[D("path",{d:"M2.5 8a5.5 5.5 0 019.37-3.9M13.5 8a5.5 5.5 0 01-9.37 3.9",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round"}),D("path",{d:"M12.5 2v3h-3M3.5 14v-3h3",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})]})}var su=`
|
|
2
2
|
@keyframes devPanelSlideIn {
|
|
3
3
|
0% {
|
|
4
4
|
opacity: 0;
|
|
@@ -46,28 +46,28 @@ import{a as Ir,b as Sr,c as yr,d as pt,e as mt,f as la,g as kr,h as br,i as Tr,j
|
|
|
46
46
|
.dev-json-editor::-webkit-scrollbar-thumb:hover {
|
|
47
47
|
background: rgba(255, 255, 255, 0.15);
|
|
48
48
|
}
|
|
49
|
-
`;function
|
|
49
|
+
`;function qr({defaultProps:e,widgetPaths:t,children:a}){let[o,r]=De(!1),[s,n]=De(!1);return gt(()=>{if(new URLSearchParams(window.location.search).get("platform")==="mcp-apps"){r(!0);return}if(t&&t.length>0){let i=window.location.pathname,u=t.some(c=>i===c||i.startsWith(`${c}/`));n(u),u&&Tt(e)}else Tt(e),n(!0);r(!0)},[e,t]),o?s?V(mo,{children:[D(nu,{children:a}),D(iu,{defaultProps:e})]}):D(mo,{children:a}):null}function nu({children:e}){return D("div",{className:"min-h-screen bg-[#212121] flex items-center justify-center p-8",children:D("div",{className:"relative w-full max-w-md overflow-hidden rounded-2xl sm:rounded-3xl border border-[#414141]",style:{boxShadow:"0px 0px 0px 1px #414141, 0px 4px 14px rgba(0,0,0,0.24)"},children:e})})}function Hr({options:e,value:t,onChange:a}){let o=e.findIndex(r=>r.value===t);return V("div",{className:"relative flex p-0.5 rounded-lg",style:{background:"rgba(255, 255, 255, 0.04)",border:"1px solid rgba(255, 255, 255, 0.06)"},children:[D("div",{className:"absolute top-0.5 bottom-0.5 rounded-md transition-transform duration-150 ease-out",style:{width:`calc(${100/e.length}% - 2px)`,left:"2px",transform:`translateX(calc(${o*100}% + ${o*2}px))`,background:"rgba(255, 255, 255, 0.1)"}}),e.map(r=>V("button",{type:"button",onClick:()=>a(r.value),className:`
|
|
50
50
|
relative z-10 flex-1 flex items-center justify-center gap-1.5 px-2 py-1.5
|
|
51
51
|
text-xs font-medium rounded-md transition-colors duration-150
|
|
52
52
|
${t===r.value?"text-white":"text-gray-400 hover:text-gray-300"}
|
|
53
|
-
`,children:[r.icon,D("span",{className:"capitalize",children:r.label})]},r.value))]})}function
|
|
53
|
+
`,children:[r.icon,D("span",{className:"capitalize",children:r.label})]},r.value))]})}function iu({defaultProps:e}){let[t,a]=De(()=>typeof window>"u"?!1:localStorage.getItem("dev-controls-open")==="true"),[o,r]=De(!1),[s,n]=De(t),[l,i]=De("inline"),[u,c]=De("dark"),[d,p]=De(!1),[m,h]=De(()=>JSON.stringify(e??{},null,2)),[I,L]=De(null),S=po(null),C=po(null),g=po(null);gt(()=>{let F=pa();i(F.displayMode),c(F.theme)},[]),gt(()=>{typeof window>"u"||(window.openai||(window.openai={}),window.openai.safeArea={insets:{top:0,bottom:d?ma:0,left:0,right:0}},window.dispatchEvent(new yt({globals:{safeArea:window.openai.safeArea}})))},[d]),gt(()=>{localStorage.setItem("dev-controls-open",String(t))},[t]);let b=He(()=>{n(!0),requestAnimationFrame(()=>{a(!0)})},[]),T=He(()=>{r(!0),a(!1),setTimeout(()=>{n(!1),r(!1)},150)},[]),P=He(()=>{t?T():b()},[t,b,T]);gt(()=>{let F=j=>{(j.metaKey||j.ctrlKey)&&j.shiftKey&&j.key==="d"&&(j.preventDefault(),P()),j.key==="Escape"&&t&&T()};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[t,P,T]),gt(()=>{if(!t)return;let F=j=>{g.current&&!g.current.contains(j.target)&&T()};return document.addEventListener("mousedown",F),()=>document.removeEventListener("mousedown",F)},[t,T]);let R=He(F=>{i(F),vt(F)},[]),v=He(F=>{c(F),At(F)},[]),_=He(F=>{try{let j=JSON.parse(F);L(null),Pt(j)}catch{L("Invalid JSON")}},[]),A=He(F=>{h(F),S.current&&clearTimeout(S.current),S.current=setTimeout(()=>{_(F)},500)},[_]),E=He(()=>{S.current&&clearTimeout(S.current),_(m)},[_,m]),y=He(()=>{let F=JSON.stringify(e??{},null,2);h(F),L(null),Pt(e??{}),i("inline"),vt("inline"),c("dark"),At("dark")},[e]),M=[{value:"inline",label:"inline",icon:D(Yl,{className:"w-3.5 h-3.5"})},{value:"pip",label:"pip",icon:D(eu,{className:"w-3.5 h-3.5"})},{value:"fullscreen",label:"full",icon:D(tu,{className:"w-3.5 h-3.5"})}],O=[{value:"light",label:"light",icon:D(au,{className:"w-3.5 h-3.5"})},{value:"dark",label:"dark",icon:D(ou,{className:"w-3.5 h-3.5"})}];return V(mo,{children:[D("style",{dangerouslySetInnerHTML:{__html:su}}),V("div",{ref:g,className:"fixed bottom-4 right-4 z-[9999] font-['Inter',_system-ui,_sans-serif]",children:[V("button",{type:"button",onClick:P,className:"group relative flex items-center justify-center w-11 h-11 rounded-xl transition-all duration-200 ease-out hover:scale-105 active:scale-95",style:{background:"rgba(14, 14, 16, 0.95)",backdropFilter:"blur(16px)",WebkitBackdropFilter:"blur(16px)",border:"1px solid rgba(255, 255, 255, 0.08)",boxShadow:`
|
|
54
54
|
0 4px 12px rgba(0, 0, 0, 0.4),
|
|
55
55
|
0 0 0 1px rgba(255, 255, 255, 0.05),
|
|
56
56
|
inset 0 1px 0 rgba(255, 255, 255, 0.04)
|
|
57
|
-
`},"aria-label":"Toggle Dev Controls","aria-expanded":t,children:[D(
|
|
57
|
+
`},"aria-label":"Toggle Dev Controls","aria-expanded":t,children:[D(Or,{className:`w-5 h-5 transition-all duration-200 ${t?"text-indigo-400 scale-110":"text-gray-300 group-hover:text-white"}`}),D("div",{className:"absolute inset-0 rounded-xl opacity-0 group-hover:opacity-100 transition-opacity duration-200 pointer-events-none",style:{background:"radial-gradient(circle at center, rgba(99, 102, 241, 0.15) 0%, transparent 70%)"}})]}),s&&V("div",{ref:C,className:`absolute bottom-14 right-0 w-80 ${t&&!o?"dev-panel-enter":"dev-panel-exit"}`,style:{maxHeight:"calc(100vh - 120px)",background:"rgba(14, 14, 16, 0.92)",backdropFilter:"blur(24px)",WebkitBackdropFilter:"blur(24px)",border:"1px solid rgba(255, 255, 255, 0.06)",borderRadius:"16px",boxShadow:`
|
|
58
58
|
0 25px 50px -12px rgba(0, 0, 0, 0.6),
|
|
59
59
|
0 0 0 1px rgba(255, 255, 255, 0.05),
|
|
60
60
|
inset 0 1px 0 rgba(255, 255, 255, 0.04)
|
|
61
|
-
`},children:[V("div",{className:"flex items-center justify-between px-4 py-3",style:{borderBottom:"1px solid rgba(255, 255, 255, 0.06)"},children:[V("div",{className:"flex items-center gap-2",children:[D(Nr,{className:"w-4 h-4 text-gray-400"}),D("span",{className:"text-sm font-medium text-white",children:"Dev Controls"})]}),V("div",{className:"flex items-center gap-2",children:[D("span",{className:"text-[10px] font-medium text-gray-500 px-1.5 py-0.5 rounded",style:{background:"rgba(255, 255, 255, 0.04)",border:"1px solid rgba(255, 255, 255, 0.06)"},children:typeof navigator<"u"&&navigator.platform?.includes("Mac")?"\u2318\u21E7D":"Ctrl+Shift+D"}),D("button",{type:"button",onClick:T,className:"p-1 rounded-md text-gray-500 hover:text-gray-300 hover:bg-white/5 transition-colors",children:D(Vl,{className:"w-4 h-4"})})]})]}),V("div",{className:"p-4 space-y-5 overflow-y-auto",style:{maxHeight:"calc(100vh - 200px)"},children:[V("div",{children:[D("label",{htmlFor:"display-mode",className:"text-[11px] font-medium uppercase tracking-wider text-gray-500 block mb-2",children:"Display Mode"}),D(Or,{options:M,value:l,onChange:R})]}),V("div",{children:[D("label",{htmlFor:"theme",className:"text-[11px] font-medium uppercase tracking-wider text-gray-500 block mb-2",children:"Theme"}),D(Or,{options:U,value:u,onChange:v})]}),V("div",{children:[D("label",{htmlFor:"safe-area",className:"text-[11px] font-medium uppercase tracking-wider text-gray-500 block mb-2",children:"Safe Area (Chat Input)"}),V("button",{type:"button",onClick:()=>p(!d),className:`w-full flex items-center justify-between px-3 py-2.5 rounded-lg text-xs font-medium transition-all duration-150 ${d?"text-emerald-400":"text-gray-400"}`,style:{background:d?"rgba(34, 197, 94, 0.1)":"rgba(255, 255, 255, 0.04)",border:d?"1px solid rgba(34, 197, 94, 0.3)":"1px solid rgba(255, 255, 255, 0.06)"},children:[D("span",{children:"Mock ChatGPT Input Bar"}),D("span",{className:`px-2 py-0.5 rounded text-[10px] font-semibold ${d?"bg-emerald-500/20 text-emerald-400":"bg-gray-500/20 text-gray-500"}`,children:d?"ON":"OFF"})]}),d&&V("p",{className:"text-[10px] text-gray-500 mt-1.5",children:["bottom: ",pa,"px"]})]}),V("div",{children:[D("label",{htmlFor:"widget-props",className:"text-[11px] font-medium uppercase tracking-wider text-gray-500 block mb-2",children:"Widget Props"}),D("textarea",{value:m,onChange:F=>A(F.target.value),onBlur:E,className:"dev-json-editor w-full min-h-[160px] text-xs text-gray-200 p-3 rounded-lg resize-none focus:outline-none transition-colors",style:{background:"rgba(0, 0, 0, 0.3)",border:I?"1px solid rgba(239, 68, 68, 0.5)":"1px solid rgba(255, 255, 255, 0.06)",fontFamily:"'JetBrains Mono', 'SF Mono', 'Fira Code', monospace",lineHeight:1.6},onFocus:F=>{I||(F.target.style.borderColor="rgba(99, 102, 241, 0.5)")},onBlurCapture:F=>{I||(F.target.style.borderColor="rgba(255, 255, 255, 0.06)")},spellCheck:!1}),I&&V("p",{className:"text-red-400 text-[11px] mt-1.5 flex items-center gap-1",children:[D("svg",{"aria-hidden":"true","aria-label":"Error",className:"w-3 h-3",viewBox:"0 0 16 16",fill:"currentColor",children:D("path",{d:"M8 1.5a6.5 6.5 0 100 13 6.5 6.5 0 000-13zM7 4.5h2v4H7v-4zm0 5h2v2H7v-2z"})}),I]})]}),V("button",{type:"button",onClick:y,className:"w-full flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-xs font-medium text-gray-400 transition-all duration-150 hover:text-gray-200",style:{background:"rgba(255, 255, 255, 0.04)",border:"1px solid rgba(255, 255, 255, 0.06)"},onMouseEnter:F=>{F.currentTarget.style.background="rgba(255, 255, 255, 0.08)",F.currentTarget.style.borderColor="rgba(255, 255, 255, 0.1)"},onMouseLeave:F=>{F.currentTarget.style.background="rgba(255, 255, 255, 0.04)",F.currentTarget.style.borderColor="rgba(255, 255, 255, 0.06)"},children:[D(Zl,{className:"w-3.5 h-3.5"}),"Reset to Defaults"]})]})]})]}),d&&V("div",{className:"fixed bottom-0 left-0 right-0 z-[9998] flex items-center justify-center pointer-events-none",style:{height:`${pa}px`,background:"linear-gradient(to top, #1a1a1a 0%, #1a1a1a 80%, transparent 100%)"},children:[V("div",{className:"w-full max-w-2xl mx-4 px-4 py-3 rounded-2xl bg-[#2f2f2f] border border-[#424242] flex items-center gap-3",children:[D("div",{className:"w-8 h-8 rounded-full bg-[#424242] flex items-center justify-center",children:D("svg",{"aria-hidden":"true",className:"w-4 h-4 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:D("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})}),D("div",{className:"flex-1 text-gray-400 text-sm",children:"Ask me anything..."}),D("div",{className:"w-8 h-8 rounded-full bg-[#424242] flex items-center justify-center",children:D("svg",{"aria-hidden":"true",className:"w-4 h-4 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:D("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11a7 7 0 01-7 7m0 0a7 7 0 01-7-7m7 7v4m0 0H8m4 0h4m-4-8a3 3 0 01-3-3V5a3 3 0 116 0v6a3 3 0 01-3 3z"})})})]}),V("div",{className:"absolute bottom-1 text-[10px] text-gray-600 font-mono",children:["Mock SafeArea: bottom=",pa,"px"]})]})]})}f();f();import{useCallback as su}from"react";f();import Rt,{useCallback as qr,useContext as ou,useEffect as Wr,useState as ho,useSyncExternalStore as ru}from"react";f();import{createContext as au}from"react";var mo=au(null);f();async function Hr(){let{detectPlatform:e}=await import("../platform-ZNBJH5XX.js");if(e()==="openai"){let{OpenAIWidgetClient:a}=await import("../openai-client-XYLENCIC.js");return new a}else{let{MCPAppsWidgetClient:a}=await import("../mcp-apps-client-RY3VD4L7.js");return new a}}function Gr({children:e,loading:t=null,onError:a}){let[o,r]=ho(null),[s,n]=ho(null),[l,i]=ho(!0);return Wr(()=>{let u=!0,c=null;async function d(){try{let p=await Hr();await p.connect(),u?(c=p,r(p),i(!1)):p.close()}catch(p){u&&(console.error("error",p),n(p instanceof Error?p:new Error(String(p))),i(!1))}}return d(),()=>{u=!1,c?.close()}},[]),Wr(()=>{if(!o)return;let u=c=>{document.documentElement.classList.toggle("dark",c==="dark"),document.documentElement.style.colorScheme=c==="dark"?"dark":"auto"};return u(o.getTheme()),o.onThemeChange(u)},[o]),s&&a?Rt.createElement(Rt.Fragment,null,a(s)):l||!o?Rt.createElement(Rt.Fragment,null,t):Rt.createElement(mo.Provider,{value:o},e)}function G(e){let t=ou(mo);if(!t)throw new Error("useWidgetClient must be used within a WidgetProvider");let a=qr(s=>e==="toolOutput"?t.onToolResult(()=>s()):e==="theme"?t.onThemeChange(()=>s()):e==="displayMode"?t.onDisplayModeChange(()=>s()):e==="safeArea"?t.onSafeAreaChange(()=>s()):e==="maxHeight"?t.onMaxHeightChange(()=>s()):e==="toolResponseMetadata"?t.onToolResponseMetadataChange(()=>s()):e==="widgetState"?t.onWidgetStateChange(()=>s()):()=>{},[t,e]),o=qr(()=>e==="toolOutput"?t.getToolOutput():e==="theme"?t.getTheme():e==="displayMode"?t.getDisplayMode():e==="locale"?t.getLocale():e==="safeArea"?t.getSafeArea():e==="maxHeight"?t.getMaxHeight():e==="toolResponseMetadata"?t.getToolResponseMetadata():e==="widgetState"?t.getWidgetState():null,[t,e]),r=ru(a,o,o);return e?r:t}function jr(){let e=G();return su((t,a)=>e.callTool(t,a),[e])}f();function zr(){return G("displayMode")}f();f();function ma(){return G("toolOutput")}function Vr(){return{data:ma()}}f();import{useSyncExternalStore as nu}from"react";function $r(){return nu(()=>()=>{},()=>typeof window>"u"?!1:window.__isChatGptApp===!0,()=>!1)}f();function Xr(){return G("locale")}f();function Kr(){return G("maxHeight")}f();import{useCallback as iu}from"react";function Qr(){let e=G();return iu(t=>e.openExternal(t),[e])}f();import{useCallback as lu}from"react";function Jr(){let e=G();return lu(t=>e.requestDisplayMode(t),[e])}f();function Zr(){return G("safeArea")}f();import{useCallback as uu}from"react";function Yr(){let e=G();return uu((t,a)=>{(async()=>{ft(a?.modelContext)&&await Promise.resolve(e.updateModelContext(a.modelContext)),await Promise.resolve(e.sendFollowUp(t))})().catch(o=>{console.error("Failed to send follow-up message:",o)})},[e])}f();function es(){return G("theme")}f();function ts(){return G("toolResponseMetadata")}f();import{useCallback as du}from"react";function as(){let e=G();return du(async t=>{await Promise.resolve(e.updateModelContext(t))},[e])}f();import{useCallback as cu,useEffect as fu,useState as pu}from"react";function os(e){let t=G("widgetState"),[a,o]=pu(()=>t??(typeof e=="function"?e():e??null));fu(()=>{o(t)},[t]);let r=cu(s=>{o(n=>{let l=typeof s=="function"?s(n):s;return io()==="openai"&&l!=null&&window.openai?.setWidgetState(l),l})},[]);return[a,r]}f();import{jsx as et,jsxs as rs}from"react/jsx-runtime";var mu=()=>rs("div",{className:"flex flex-col items-center justify-center h-full min-h-[120px] gap-4",children:[rs("div",{className:"flex gap-2",children:[et("div",{className:"w-3 h-3 rounded-full bg-gradient-to-r from-blue-400 to-cyan-400 animate-bounce [animation-delay:-0.3s]"}),et("div",{className:"w-3 h-3 rounded-full bg-gradient-to-r from-cyan-400 to-teal-400 animate-bounce [animation-delay:-0.15s]"}),et("div",{className:"w-3 h-3 rounded-full bg-gradient-to-r from-teal-400 to-emerald-400 animate-bounce"})]}),et("p",{className:"text-sm font-medium text-transparent bg-clip-text bg-gradient-to-r from-slate-400 via-slate-200 to-slate-400 bg-[length:200%_100%] animate-[shimmer_1.5s_ease-in-out_infinite]",children:"Loading widget..."}),et("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none",children:et("div",{className:"w-16 h-16 rounded-full border-2 border-blue-400/20 animate-ping"})}),et("style",{children:`
|
|
61
|
+
`},children:[V("div",{className:"flex items-center justify-between px-4 py-3",style:{borderBottom:"1px solid rgba(255, 255, 255, 0.06)"},children:[V("div",{className:"flex items-center gap-2",children:[D(Or,{className:"w-4 h-4 text-gray-400"}),D("span",{className:"text-sm font-medium text-white",children:"Dev Controls"})]}),V("div",{className:"flex items-center gap-2",children:[D("span",{className:"text-[10px] font-medium text-gray-500 px-1.5 py-0.5 rounded",style:{background:"rgba(255, 255, 255, 0.04)",border:"1px solid rgba(255, 255, 255, 0.06)"},children:typeof navigator<"u"&&navigator.platform?.includes("Mac")?"\u2318\u21E7D":"Ctrl+Shift+D"}),D("button",{type:"button",onClick:T,className:"p-1 rounded-md text-gray-500 hover:text-gray-300 hover:bg-white/5 transition-colors",children:D(Zl,{className:"w-4 h-4"})})]})]}),V("div",{className:"p-4 space-y-5 overflow-y-auto",style:{maxHeight:"calc(100vh - 200px)"},children:[V("div",{children:[D("label",{htmlFor:"display-mode",className:"text-[11px] font-medium uppercase tracking-wider text-gray-500 block mb-2",children:"Display Mode"}),D(Hr,{options:M,value:l,onChange:R})]}),V("div",{children:[D("label",{htmlFor:"theme",className:"text-[11px] font-medium uppercase tracking-wider text-gray-500 block mb-2",children:"Theme"}),D(Hr,{options:O,value:u,onChange:v})]}),V("div",{children:[D("label",{htmlFor:"safe-area",className:"text-[11px] font-medium uppercase tracking-wider text-gray-500 block mb-2",children:"Safe Area (Chat Input)"}),V("button",{type:"button",onClick:()=>p(!d),className:`w-full flex items-center justify-between px-3 py-2.5 rounded-lg text-xs font-medium transition-all duration-150 ${d?"text-emerald-400":"text-gray-400"}`,style:{background:d?"rgba(34, 197, 94, 0.1)":"rgba(255, 255, 255, 0.04)",border:d?"1px solid rgba(34, 197, 94, 0.3)":"1px solid rgba(255, 255, 255, 0.06)"},children:[D("span",{children:"Mock ChatGPT Input Bar"}),D("span",{className:`px-2 py-0.5 rounded text-[10px] font-semibold ${d?"bg-emerald-500/20 text-emerald-400":"bg-gray-500/20 text-gray-500"}`,children:d?"ON":"OFF"})]}),d&&V("p",{className:"text-[10px] text-gray-500 mt-1.5",children:["bottom: ",ma,"px"]})]}),V("div",{children:[D("label",{htmlFor:"widget-props",className:"text-[11px] font-medium uppercase tracking-wider text-gray-500 block mb-2",children:"Widget Props"}),D("textarea",{value:m,onChange:F=>A(F.target.value),onBlur:E,className:"dev-json-editor w-full min-h-[160px] text-xs text-gray-200 p-3 rounded-lg resize-none focus:outline-none transition-colors",style:{background:"rgba(0, 0, 0, 0.3)",border:I?"1px solid rgba(239, 68, 68, 0.5)":"1px solid rgba(255, 255, 255, 0.06)",fontFamily:"'JetBrains Mono', 'SF Mono', 'Fira Code', monospace",lineHeight:1.6},onFocus:F=>{I||(F.target.style.borderColor="rgba(99, 102, 241, 0.5)")},onBlurCapture:F=>{I||(F.target.style.borderColor="rgba(255, 255, 255, 0.06)")},spellCheck:!1}),I&&V("p",{className:"text-red-400 text-[11px] mt-1.5 flex items-center gap-1",children:[D("svg",{"aria-hidden":"true","aria-label":"Error",className:"w-3 h-3",viewBox:"0 0 16 16",fill:"currentColor",children:D("path",{d:"M8 1.5a6.5 6.5 0 100 13 6.5 6.5 0 000-13zM7 4.5h2v4H7v-4zm0 5h2v2H7v-2z"})}),I]})]}),V("button",{type:"button",onClick:y,className:"w-full flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-xs font-medium text-gray-400 transition-all duration-150 hover:text-gray-200",style:{background:"rgba(255, 255, 255, 0.04)",border:"1px solid rgba(255, 255, 255, 0.06)"},onMouseEnter:F=>{F.currentTarget.style.background="rgba(255, 255, 255, 0.08)",F.currentTarget.style.borderColor="rgba(255, 255, 255, 0.1)"},onMouseLeave:F=>{F.currentTarget.style.background="rgba(255, 255, 255, 0.04)",F.currentTarget.style.borderColor="rgba(255, 255, 255, 0.06)"},children:[D(ru,{className:"w-3.5 h-3.5"}),"Reset to Defaults"]})]})]})]}),d&&V("div",{className:"fixed bottom-0 left-0 right-0 z-[9998] flex items-center justify-center pointer-events-none",style:{height:`${ma}px`,background:"linear-gradient(to top, #1a1a1a 0%, #1a1a1a 80%, transparent 100%)"},children:[V("div",{className:"w-full max-w-2xl mx-4 px-4 py-3 rounded-2xl bg-[#2f2f2f] border border-[#424242] flex items-center gap-3",children:[D("div",{className:"w-8 h-8 rounded-full bg-[#424242] flex items-center justify-center",children:D("svg",{"aria-hidden":"true",className:"w-4 h-4 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:D("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})}),D("div",{className:"flex-1 text-gray-400 text-sm",children:"Ask me anything..."}),D("div",{className:"w-8 h-8 rounded-full bg-[#424242] flex items-center justify-center",children:D("svg",{"aria-hidden":"true",className:"w-4 h-4 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:D("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11a7 7 0 01-7 7m0 0a7 7 0 01-7-7m7 7v4m0 0H8m4 0h4m-4-8a3 3 0 01-3-3V5a3 3 0 116 0v6a3 3 0 01-3 3z"})})})]}),V("div",{className:"absolute bottom-1 text-[10px] text-gray-600 font-mono",children:["Mock SafeArea: bottom=",ma,"px"]})]})]})}f();f();import{useCallback as uu,useContext as du,useLayoutEffect as cu,useMemo as fu,useRef as Wr}from"react";f();import{createContext as lu}from"react";var Rt=lu(null);import{Fragment as Gr,jsx as ho}from"react/jsx-runtime";var pu="waniwani:send-follow-up:advanced:",mu=1e4;function jr(e){return`${pu}${e??"default"}`}function hu(e){try{let t=globalThis.localStorage?.getItem(jr(e));if(!t)return null;let a=JSON.parse(t);return typeof a?.at!="number"||typeof a?.byMountId!="string"?null:a}catch{return null}}function gu(e,t){try{globalThis.localStorage?.setItem(jr(e),JSON.stringify({at:Date.now(),byMountId:t}))}catch{}}function go(){return typeof window>"u"?!1:typeof window.openai=="object"}function wu(){return go()?window.openai:null}function xu(){return cu(()=>{let e=document.documentElement,t=document.body,a=e.getAttribute("style"),o=t.getAttribute("style"),r="margin:0!important;padding:0!important;border:0!important;background:transparent!important;background-color:transparent!important;height:0!important;min-height:0!important;max-height:0!important;overflow:hidden!important;";return e.setAttribute("style",r),t.setAttribute("style",r),()=>{a===null?e.removeAttribute("style"):e.setAttribute("style",a),o===null?t.removeAttribute("style"):t.setAttribute("style",o)}},[]),null}function zr(e){let t=du(Rt),a=Wr(e);a.current=e;let o=t?.getToolResponseMetadata?.()??null,r=wu()?.toolResponseMetadata??null,s=o??r,n=s&&typeof s.viewUUID=="string"?s.viewUUID:void 0,l=Wr("");l.current===""&&(l.current=crypto.randomUUID());let i=uu((c,d)=>{go()&&gu(n,l.current);try{Promise.resolve(a.current(c)).catch(p=>{console.error("[unstable_useSendFollowUpWithGhostGuard]",p)})}catch(p){console.error("[unstable_useSendFollowUpWithGhostGuard]",p)}},[n]),u=fu(()=>{let c=l.current;return function({children:p}){if(!go())return ho(Gr,{children:p});let m=hu(n);return m&&m.byMountId!==c&&Date.now()-m.at<mu?ho(xu,{}):ho(Gr,{children:p})}},[n]);return{sendFollowUp:i,Guard:u}}f();import{useCallback as Iu}from"react";f();import Mt,{useCallback as $r,useContext as Lu,useEffect as Xr,useState as wo,useSyncExternalStore as Cu}from"react";f();async function Vr(){let{detectPlatform:e}=await import("../platform-ZNBJH5XX.js");if(e()==="openai"){let{OpenAIWidgetClient:a}=await import("../openai-client-XYLENCIC.js");return new a}else{let{MCPAppsWidgetClient:a}=await import("../mcp-apps-client-RY3VD4L7.js");return new a}}function Kr({children:e,loading:t=null,onError:a}){let[o,r]=wo(null),[s,n]=wo(null),[l,i]=wo(!0);return Xr(()=>{let u=!0,c=null;async function d(){try{let p=await Vr();await p.connect(),u?(c=p,r(p),i(!1)):p.close()}catch(p){u&&(console.error("error",p),n(p instanceof Error?p:new Error(String(p))),i(!1))}}return d(),()=>{u=!1,c?.close()}},[]),Xr(()=>{if(!o)return;let u=c=>{document.documentElement.classList.toggle("dark",c==="dark"),document.documentElement.style.colorScheme=c==="dark"?"dark":"auto"};return u(o.getTheme()),o.onThemeChange(u)},[o]),s&&a?Mt.createElement(Mt.Fragment,null,a(s)):l||!o?Mt.createElement(Mt.Fragment,null,t):Mt.createElement(Rt.Provider,{value:o},e)}function G(e){let t=Lu(Rt);if(!t)throw new Error("useWidgetClient must be used within a WidgetProvider");let a=$r(s=>e==="toolOutput"?t.onToolResult(()=>s()):e==="theme"?t.onThemeChange(()=>s()):e==="displayMode"?t.onDisplayModeChange(()=>s()):e==="safeArea"?t.onSafeAreaChange(()=>s()):e==="maxHeight"?t.onMaxHeightChange(()=>s()):e==="toolResponseMetadata"?t.onToolResponseMetadataChange(()=>s()):e==="widgetState"?t.onWidgetStateChange(()=>s()):()=>{},[t,e]),o=$r(()=>e==="toolOutput"?t.getToolOutput():e==="theme"?t.getTheme():e==="displayMode"?t.getDisplayMode():e==="locale"?t.getLocale():e==="safeArea"?t.getSafeArea():e==="maxHeight"?t.getMaxHeight():e==="toolResponseMetadata"?t.getToolResponseMetadata():e==="widgetState"?t.getWidgetState():null,[t,e]),r=Cu(a,o,o);return e?r:t}function Qr(){let e=G();return Iu((t,a)=>e.callTool(t,a),[e])}f();function Jr(){return G("displayMode")}f();f();function ha(){return G("toolOutput")}function Zr(){return{data:ha()}}f();import{useSyncExternalStore as Su}from"react";function Yr(){return Su(()=>()=>{},()=>typeof window>"u"?!1:window.__isChatGptApp===!0,()=>!1)}f();function es(){return G("locale")}f();function ts(){return G("maxHeight")}f();import{useCallback as yu}from"react";function as(){let e=G();return yu(t=>e.openExternal(t),[e])}f();import{useCallback as bu}from"react";function os(){let e=G();return bu(t=>e.requestDisplayMode(t),[e])}f();function rs(){return G("safeArea")}f();import{useCallback as ku}from"react";function ss(){let e=G();return ku((t,a)=>{(async()=>{ft(a?.modelContext)&&await Promise.resolve(e.updateModelContext(a.modelContext)),await Promise.resolve(e.sendFollowUp(t))})().catch(o=>{console.error("Failed to send follow-up message:",o)})},[e])}f();function ns(){return G("theme")}f();function is(){return G("toolResponseMetadata")}f();import{useCallback as Tu}from"react";function ls(){let e=G();return Tu(async t=>{await Promise.resolve(e.updateModelContext(t))},[e])}f();import{useCallback as Pu,useEffect as vu,useState as Au}from"react";function us(e){let t=G("widgetState"),[a,o]=Au(()=>t??(typeof e=="function"?e():e??null));vu(()=>{o(t)},[t]);let r=Pu(s=>{o(n=>{let l=typeof s=="function"?s(n):s;return lo()==="openai"&&l!=null&&window.openai?.setWidgetState(l),l})},[]);return[a,r]}f();import{jsx as et,jsxs as ds}from"react/jsx-runtime";var Ru=()=>ds("div",{className:"flex flex-col items-center justify-center h-full min-h-[120px] gap-4",children:[ds("div",{className:"flex gap-2",children:[et("div",{className:"w-3 h-3 rounded-full bg-gradient-to-r from-blue-400 to-cyan-400 animate-bounce [animation-delay:-0.3s]"}),et("div",{className:"w-3 h-3 rounded-full bg-gradient-to-r from-cyan-400 to-teal-400 animate-bounce [animation-delay:-0.15s]"}),et("div",{className:"w-3 h-3 rounded-full bg-gradient-to-r from-teal-400 to-emerald-400 animate-bounce"})]}),et("p",{className:"text-sm font-medium text-transparent bg-clip-text bg-gradient-to-r from-slate-400 via-slate-200 to-slate-400 bg-[length:200%_100%] animate-[shimmer_1.5s_ease-in-out_infinite]",children:"Loading widget..."}),et("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none",children:et("div",{className:"w-16 h-16 rounded-full border-2 border-blue-400/20 animate-ping"})}),et("style",{children:`
|
|
62
62
|
@keyframes shimmer {
|
|
63
63
|
0% { background-position: 200% 0; }
|
|
64
64
|
100% { background-position: -200% 0; }
|
|
65
65
|
}
|
|
66
|
-
`})]});f();f();f();var
|
|
66
|
+
`})]});f();f();f();var Mu={debug:0,warn:1,error:2,none:3};function Fu(){let e=process.env.WANIWANI_LOG_LEVEL;return e&&e in Mu?e:process.env.WANIWANI_DEBUG?"debug":"none"}function Be(e,t){return t??Fu()==="debug"?(...o)=>console.log(`[waniwani:${e}]`,...o):()=>{}}f();function cs(e){if(e===!0)return{};if(!(e===!1||e===void 0))return e}f();function fs(){return function(t){return t.headers.set("Access-Control-Allow-Origin","*"),t.headers.set("Access-Control-Allow-Methods","GET, POST, PATCH, OPTIONS"),t.headers.set("Access-Control-Allow-Headers","Content-Type, Authorization, X-Session-Id, X-Client-User-Agent"),t.headers.set("Access-Control-Expose-Headers","X-Session-Id"),t}}function ps(e){return function(a,o){return e(new Response(JSON.stringify(a),{headers:{"Content-Type":"application/json"},status:o}))}}f();f();var Ie=class extends Error{constructor(a,o){super(a);this.status=o;this.name="WaniWaniError"}};f();function ms(e){let t=e.headers,a=t.get("x-vercel-ip-city")??t.get("cf-ipcity")??void 0,o=a?Du(a):void 0,r=t.get("x-vercel-ip-country")??t.get("cf-ipcountry")??void 0,s=t.get("x-vercel-ip-country-region")??void 0,n=t.get("x-vercel-ip-latitude")??t.get("cf-iplatitude")??void 0,l=t.get("x-vercel-ip-longitude")??t.get("cf-iplongitude")??void 0,i=t.get("x-vercel-ip-timezone")??t.get("cf-iptimezone")??void 0,u=t.get("x-real-ip")??t.get("x-forwarded-for")?.split(",")[0]?.trim()??t.get("cf-connecting-ip")??void 0;return{city:o,country:r,countryRegion:s,latitude:n,longitude:l,timezone:i,ip:u}}function Du(e){try{return decodeURIComponent(e)}catch{return e}}f();function hs(e,t){if(!ft(t))return e;let a=Sr(t);return a?[e,a].filter(Boolean).join(`
|
|
67
67
|
|
|
68
|
-
`):e}function ds(e){let{apiKey:t,apiUrl:a,source:o,systemPrompt:r,maxSteps:s,beforeRequest:n,mcpServerUrl:l,resolveConfig:i,debug:u,webSearch:c}=e,d=Be("chat",u);return async function(m){d("\u2192 POST",m.url);try{let h=await m.json(),I=h.messages??[],L=h.sessionId,S=h.modelContext,C=r,g=typeof h.extra=="object"&&h.extra!==null&&!Array.isArray(h.extra)?h.extra:void 0,k=h.visitorContext??null,T=ls(m),P={geo:T,client:k};if(d("body parsed \u2014 messages:",I.length,"sessionId:",L??"(none)","geo:",JSON.stringify(T)),n){d("running beforeRequest hook");try{let M=await n({messages:I,sessionId:L,modelContext:S,request:m,visitor:P});M&&(M.messages&&(I=M.messages),M.systemPrompt!==void 0&&(C=M.systemPrompt),M.sessionId!==void 0&&(L=M.sessionId),M.modelContext!==void 0&&(S=M.modelContext)),d("beforeRequest hook done \u2014 messages:",I.length,"sessionId:",L??"(none)")}catch(M){console.error("[waniwani:chat] beforeRequest hook error:",M);let U=M instanceof Ie?M.status:400,F=M instanceof Error?M.message:"Request rejected";return d("\u2190 returning",U,"from hook error"),Response.json({error:F},{status:U})}}let R=l??(await i()).mcpServerUrl;d("mcpServerUrl:",R),C=us(C,S);let v=`${a}/api/mcp/chat`;d("forwarding to",v);let _=m.headers.get("user-agent"),A=await fetch(v,{method:"POST",headers:{"Content-Type":"application/json","X-WaniWani-Stream-Protocol":"2",...t?{Authorization:`Bearer ${t}`}:{},..._?{"X-Client-User-Agent":_}:{}},body:JSON.stringify({messages:I,mcpServerUrl:R,sessionId:L,source:o,systemPrompt:C,maxSteps:s,visitor:P,webSearch:c,...g&&{extra:g}}),signal:m.signal});if(d("upstream response status:",A.status),!A.ok){let M=await A.text().catch(()=>"");return d("\u2190 returning",A.status,"upstream error:",M),new Response(M,{status:A.status,headers:{"Content-Type":A.headers.get("Content-Type")??"application/json"}})}let E=new Headers({"Content-Type":A.headers.get("Content-Type")??"text/event-stream"}),y=A.headers.get("x-session-id");return y&&E.set("x-session-id",y),d("\u2190 streaming response",A.status,"body null?",A.body===null),new Response(A.body,{status:A.status,headers:E})}catch(h){console.error("[waniwani:chat] handler error:",h);let I=h instanceof Error?h.message:"Unknown error occurred",L=h instanceof Ie?h.status:500;return d("\u2190 returning",L,"from caught error"),Response.json({error:I},{status:L})}}}f();function cs(e){let{mcpServerUrl:t,resolveConfig:a,debug:o}=e,r=Be("resource",o);return async function(n){r("\u2192 GET",n.toString());try{let l=n.searchParams.get("uri");if(r("uri:",l??"(missing)"),!l)return r("\u2190 400 missing uri"),Response.json({error:"Missing uri query parameter"},{status:400});let i=t??(await a()).mcpServerUrl;r("mcpServerUrl:",i);let u,c;try{[{createMCPClient:u},{StreamableHTTPClientTransport:c}]=await Promise.all([import("@ai-sdk/mcp"),import("@modelcontextprotocol/sdk/client/streamableHttp.js")]),r("MCP deps loaded")}catch(p){return console.error("[waniwani:resource] MCP deps import failed:",p),Response.json({error:"MCP resource handler requires @ai-sdk/mcp and @modelcontextprotocol/sdk. Install them to enable resource serving."},{status:501})}r("creating MCP client for",i);let d=await u({transport:new c(new URL(i))});try{r("reading resource:",l);let p=await d.readResource({uri:l});r("resource contents count:",p.contents.length);let m=p.contents[0];if(!m)return r("\u2190 404 resource not found"),Response.json({error:"Resource not found"},{status:404});let h;return"text"in m&&typeof m.text=="string"?h=m.text:"blob"in m&&typeof m.blob=="string"&&(h=atob(m.blob)),h?(r("\u2190 200 HTML length:",h.length),new Response(h,{headers:{"Content-Type":"text/html","Cache-Control":"private, max-age=300"}})):(r("\u2190 404 resource has no content, keys:",Object.keys(m)),Response.json({error:"Resource has no content"},{status:404}))}finally{await d.close(),r("MCP client closed")}}catch(l){console.error("[waniwani:resource] handler error:",l);let i=l instanceof Error?l.message:"Unknown error occurred",u=l instanceof Ie?l.status:500;return r("\u2190 returning",u,"from caught error"),Response.json({error:i},{status:u})}}}f();function fs(e){let{mcpServerUrl:t,resolveConfig:a,debug:o,source:r}=e,s=Be("tool",o);return async function(l){s("\u2192 POST",l.url);try{let i=await l.json(),{name:u,arguments:c}=i,d=l.headers.get("x-session-id")?.trim();if(!u||typeof u!="string")return s("\u2190 400 missing tool name"),Response.json({error:"Missing tool name"},{status:400});s("tool:",u,"args:",JSON.stringify(c),"sessionId:",d||"(none)");let p=t??(await a()).mcpServerUrl;s("mcpServerUrl:",p);let m,h;try{[{Client:m},{StreamableHTTPClientTransport:h}]=await Promise.all([import("@modelcontextprotocol/sdk/client/index.js"),import("@modelcontextprotocol/sdk/client/streamableHttp.js")]),s("MCP deps loaded")}catch(S){return console.error("[waniwani:tool] MCP deps import failed:",S),Response.json({error:"MCP tool handler requires @modelcontextprotocol/sdk. Install it to enable tool calls."},{status:501})}s("creating MCP client for",p);let I=new h(new URL(p)),L=new m({name:"waniwani-tool-caller",version:"1.0.0"});await L.connect(I);try{s("calling tool:",u);let S={};d&&(S["waniwani/sessionId"]=d),r&&(S["waniwani/source"]=r);let C=await L.callTool({name:u,arguments:c??{},...Object.keys(S).length>0?{_meta:S}:{}});return s("tool result received"),Response.json({content:C.content,structuredContent:C.structuredContent,_meta:C._meta,isError:C.isError})}finally{await L.close(),s("MCP client closed")}}catch(i){console.error("[waniwani:tool] handler error:",i);let u=i instanceof Error?i.message:"Unknown error occurred",c=i instanceof Ie?i.status:500;return s("\u2190 returning",c,"from caught error"),Response.json({error:u},{status:c})}}}f();function ps(e){let{mcpServerUrl:t,resolveConfig:a,debug:o}=e,r=Be("tools-list",o);return async function(){r("\u2192 GET tools/list");try{let n=t??(await a()).mcpServerUrl;r("mcpServerUrl:",n);let l,i;try{[{createMCPClient:l},{StreamableHTTPClientTransport:i}]=await Promise.all([import("@ai-sdk/mcp"),import("@modelcontextprotocol/sdk/client/streamableHttp.js")]),r("MCP deps loaded")}catch(c){return console.error("[waniwani:tools-list] MCP deps import failed:",c),Response.json({error:"MCP tools list handler requires @ai-sdk/mcp and @modelcontextprotocol/sdk. Install them to enable tool discovery."},{status:501})}r("creating MCP client for",n);let u=await l({transport:new i(new URL(n))});try{r("listing tools");let c=await u.listTools();r("tools count:",c.tools.length);let d={tools:c.tools.map(p=>({name:p.name,...p.title!==void 0&&{title:p.title},...p.description!==void 0&&{description:p.description},...p.inputSchema!==void 0&&{inputSchema:p.inputSchema},...p.outputSchema!==void 0&&{outputSchema:p.outputSchema},...p.annotations!==void 0&&{annotations:p.annotations},...p._meta!==void 0&&{_meta:p._meta}})),...c.nextCursor!==void 0&&{nextCursor:c.nextCursor}};return r("\u2190 200"),Response.json(d,{headers:{"Cache-Control":"private, max-age=60"}})}finally{await u.close(),r("MCP client closed")}}catch(n){console.error("[waniwani:tools-list] handler error:",n);let l=n instanceof Error?n.message:"Unknown error occurred",i=n instanceof Ie?n.status:500;return r("\u2190 returning",i,"from caught error"),Response.json({error:l},{status:i})}}}f();var xu=300*1e3;function ms(e,t){let a=null,o=null;return async function(){if(a&&Date.now()<a.expiresAt)return a.config;if(o)return o;o=(async()=>{if(!t)throw new Ie("WANIWANI_API_KEY is required for createChatHandler",401);let s=await fetch(`${e}/api/mcp/environments/config`,{method:"GET",headers:{Authorization:`Bearer ${t}`,"Content-Type":"application/json"}});if(!s.ok){let l=await s.text().catch(()=>"");throw new Ie(`Failed to resolve MCP environment config: ${s.status} ${l}`,s.status)}let n=await s.json();return a={config:n,expiresAt:Date.now()+xu},n})();try{return await o}finally{o=null}}}var Lu="https://app.waniwani.ai";function hs(e={}){let{apiKey:t=process.env.WANIWANI_API_KEY,apiUrl:a=Lu,source:o,systemPrompt:r,maxSteps:s=5,beforeRequest:n,mcpServerUrl:l,debug:i=!1,webSearch:u}=e,c=Be("router",i),d=ns(),p=is(d),m=ms(a,t),h=ds({apiKey:t,apiUrl:a,source:o,systemPrompt:r,maxSteps:s,beforeRequest:n,mcpServerUrl:l,resolveConfig:m,debug:i,webSearch:ss(u)}),I=cs({mcpServerUrl:l,resolveConfig:m,debug:i}),L=ps({mcpServerUrl:l,resolveConfig:m,debug:i}),S=fs({mcpServerUrl:l,resolveConfig:m,debug:i,source:o}),C=process.env.WANIWANI_EVAL==="1";async function g(R){c("\u2192 GET",R.url);try{let v=new URL(R.url),A=v.pathname.replace(/\/$/,"").split("/").filter(Boolean).at(-1);if(c("pathname:",v.pathname,"subRoute:",A),C&&A==="scenarios"){c("dispatching to scenarios handler (proxy to app API)");try{let y=await(await fetch(`${a}/api/mcp/scenarios`,{headers:{...t?{Authorization:`Bearer ${t}`}:{}}})).json();return p(y.data??y,200)}catch{return p([],200)}}if(A==="resource"){c("dispatching to resource handler");let E=await I(v);return c("\u2190 resource handler returned",E.status),d(E)}if(A==="config")return c("dispatching to config handler"),p({debug:i,eval:C},200);if(A==="tools"){c("dispatching to tools-list handler");let E=await L();return c("\u2190 tools-list handler returned",E.status),d(E)}return c("\u2190 404 no matching sub-route for",A),p({error:"Not found"},404)}catch(v){console.error("[waniwani:router] GET handler error:",v);let _=v instanceof Error?v.message:"Unknown error occurred";return c("\u2190 500 from caught error"),p({error:_},500)}}async function k(R){c("\u2192 POST",R.url);try{let v=new URL(R.url),A=v.pathname.replace(/\/$/,"").split("/").filter(Boolean).at(-1);if(c("pathname:",v.pathname,"subRoute:",A),C&&A==="scenarios"){c("dispatching to save-scenario handler (proxy to app API)");try{let y=await R.json(),M=await fetch(`${a}/api/mcp/scenarios`,{method:"POST",headers:{"Content-Type":"application/json",...t?{Authorization:`Bearer ${t}`}:{}},body:JSON.stringify(y)}),U=await M.json();return M.ok?p({ok:!0,scenario:U.data},200):p({error:U.message??"Failed to save scenario"},M.status)}catch(y){let M=y instanceof Error?y.message:"Failed to save scenario";return p({error:M},400)}}if(A==="tool"){c("dispatching to tool handler");let y=await S(R);return c("\u2190 tool handler returned",y.status),d(y)}c("dispatching to chat handler");let E=await h(R);return d(E)}catch(v){console.error("[waniwani:router] POST handler error:",v);let _=v instanceof Error?v.message:"Unknown error occurred";return c("\u2190 500 from caught error"),p({error:_},500)}}async function T(R){c("\u2192 PATCH",R.url);try{let v=new URL(R.url),_=v.pathname.replace(/\/$/,"").split("/").filter(Boolean),A=_.at(-1),E=_.at(-2);if(c("pathname:",v.pathname,"subRoute:",E,"id:",A),C&&E==="scenarios"&&A){c("dispatching to update-scenario handler (proxy to app API)");try{let y=await R.json(),M=await fetch(`${a}/api/mcp/scenarios/${A}`,{method:"PATCH",headers:{"Content-Type":"application/json",...t?{Authorization:`Bearer ${t}`}:{}},body:JSON.stringify(y)}),U=await M.json();return M.ok?p({ok:!0,scenario:U.data},200):p({error:U.message??"Failed to update scenario"},M.status)}catch(y){let M=y instanceof Error?y.message:"Failed to update scenario";return p({error:M},400)}}return c("\u2190 404 no matching sub-route for PATCH",E),p({error:"Not found"},404)}catch(v){console.error("[waniwani:router] PATCH handler error:",v);let _=v instanceof Error?v.message:"Unknown error occurred";return c("\u2190 500 from caught error"),p({error:_},500)}}function P(){return d(new Response(null,{status:204}))}return{handleChat:h,handleResource:I,handleTool:S,routeGet:g,routePost:k,routePatch:T,handleOptions:P}}var gs=!1;function Vw(e,t){!gs&&process.env.NODE_ENV!=="test"&&(console.warn("[waniwani-sdk] toNextJsHandler is deprecated; switch to toExpressJsHandler from @waniwani/sdk/express-js. It will be removed in a follow-up release."),gs=!0);let{apiKey:a,apiUrl:o}=e._config,r=t?.debug??process.env.WANIWANI_DEBUG==="1",s=hs({...t?.chat,apiKey:a,apiUrl:o,source:t?.source,debug:r});return{POST:s.routePost,GET:s.routeGet,PATCH:s.routePatch,OPTIONS:()=>s.handleOptions()}}f();import{forwardRef as Nm,useCallback as hr,useEffect as Om,useImperativeHandle as Um,useRef as Tl,useState as Pl}from"react";f();f();f();import{forwardRef as Iu,createElement as Su}from"react";f();var ha=(...e)=>e.filter((t,a,o)=>!!t&&t.trim()!==""&&o.indexOf(t)===a).join(" ").trim();f();var ws=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();f();f();var xs=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,a,o)=>o?o.toUpperCase():a.toLowerCase());var go=e=>{let t=xs(e);return t.charAt(0).toUpperCase()+t.slice(1)};f();import{forwardRef as Cu,createElement as Is}from"react";f();var Ls={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"};f();var Cs=e=>{for(let t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};var Ss=Cu(({color:e="currentColor",size:t=24,strokeWidth:a=2,absoluteStrokeWidth:o,className:r="",children:s,iconNode:n,...l},i)=>Is("svg",{ref:i,...Ls,width:t,height:t,stroke:e,strokeWidth:o?Number(a)*24/Number(t):a,className:ha("lucide",r),...!s&&!Cs(l)&&{"aria-hidden":"true"},...l},[...n.map(([u,c])=>Is(u,c)),...Array.isArray(s)?s:[s]]));var J=(e,t)=>{let a=Iu(({className:o,...r},s)=>Su(Ss,{ref:s,iconNode:t,className:ha(`lucide-${ws(go(e))}`,`lucide-${e}`,o),...r}));return a.displayName=go(e),a};f();var yu=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Mt=J("arrow-down",yu);f();var ku=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Ft=J("arrow-up",ku);f();var bu=[["path",{d:"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1",key:"ezmyqa"}],["path",{d:"M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1",key:"e1hn23"}]],$e=J("braces",bu);f();var Tu=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Dt=J("check",Tu);f();var Pu=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Bt=J("chevron-down",Pu);f();var vu=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Et=J("chevron-right",vu);f();var Au=[["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"}]],_t=J("clipboard-copy",Au);f();var Ru=[["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"}]],Nt=J("file",Ru);f();var Mu=[["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"}]],Ot=J("loader",Mu);f();var Fu=[["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"}]],Ut=J("paperclip",Fu);f();var Du=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],Ht=J("square",Du);f();var Bu=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],tt=J("x",Bu);import{useCallback as Ju}from"react";f();import{useCallback as Xe,useMemo as Eu,useRef as _u,useState as wo}from"react";var Nu={damping:.7,stiffness:.05,mass:1.25},Ou=70,Uu=1e3/60,Hu=350,ga=!1;globalThis.document?.addEventListener("mousedown",()=>{ga=!0});globalThis.document?.addEventListener("mouseup",()=>{ga=!1});globalThis.document?.addEventListener("click",()=>{ga=!1});var ks=(e={})=>{let[t,a]=wo(!1),[o,r]=wo(e.initial!==!1),[s,n]=wo(!1),l=_u(null);l.current=e;let i=Xe(()=>{if(!ga)return!1;let C=window.getSelection();if(!C||!C.rangeCount)return!1;let g=C.getRangeAt(0);return g.commonAncestorContainer.contains(L.current)||L.current?.contains(g.commonAncestorContainer)},[]),u=Xe(C=>{d.isAtBottom=C,r(C)},[]),c=Xe(C=>{d.escapedFromLock=C,a(C)},[]),d=Eu(()=>{let C;return{escapedFromLock:t,isAtBottom:o,resizeDifference:0,accumulated:0,velocity:0,listeners:new Set,get scrollTop(){return L.current?.scrollTop??0},set scrollTop(g){L.current&&(L.current.scrollTop=g,d.ignoreScrollToTop=L.current.scrollTop)},get targetScrollTop(){return!L.current||!S.current?0:L.current.scrollHeight-1-L.current.clientHeight},get calculatedTargetScrollTop(){if(!L.current||!S.current)return 0;let{targetScrollTop:g}=this;if(!e.targetScrollTop)return g;if(C?.targetScrollTop===g)return C.calculatedScrollTop;let k=Math.max(Math.min(e.targetScrollTop(g,{scrollElement:L.current,contentElement:S.current}),g),0);return C={targetScrollTop:g,calculatedScrollTop:k},requestAnimationFrame(()=>{C=void 0}),k},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=Ou}}},[]),p=Xe((C={})=>{typeof C=="string"&&(C={animation:C}),C.preserveScrollPosition||u(!0);let g=Date.now()+(Number(C.wait)||0),k=Lo(l.current,C.animation),{ignoreEscapes:T=!1}=C,P,R=d.calculatedTargetScrollTop;C.duration instanceof Promise?C.duration.finally(()=>{P=Date.now()}):P=g+(C.duration??0);let v=async()=>{let _=new Promise(requestAnimationFrame).then(()=>{if(!d.isAtBottom)return d.animation=void 0,!1;let{scrollTop:A}=d,E=performance.now(),y=(E-(d.lastTick??E))/Uu;if(d.animation||(d.animation={behavior:k,promise:_,ignoreEscapes:T}),d.animation.behavior===k&&(d.lastTick=E),i()||g>Date.now())return v();if(A<Math.min(R,d.calculatedTargetScrollTop)){if(d.animation?.behavior===k){if(k==="instant")return d.scrollTop=d.calculatedTargetScrollTop,v();d.velocity=(k.damping*d.velocity+k.stiffness*d.scrollDifference)/k.mass,d.accumulated+=d.velocity*y,d.scrollTop+=d.accumulated,d.scrollTop!==A&&(d.accumulated=0)}return v()}return P>Date.now()?(R=d.calculatedTargetScrollTop,v()):(d.animation=void 0,d.scrollTop<d.calculatedTargetScrollTop?p({animation:Lo(l.current,l.current.resize),ignoreEscapes:T,duration:Math.max(0,P-Date.now())||void 0}):d.isAtBottom)});return _.then(A=>(requestAnimationFrame(()=>{d.animation||(d.lastTick=void 0,d.velocity=0)}),A))};return C.wait!==!0&&(d.animation=void 0),d.animation?.behavior===k?d.animation.promise:v()},[u,i,d]),m=Xe(()=>{c(!0),u(!1)},[c,u]),h=Xe(({target:C})=>{if(C!==L.current)return;let{scrollTop:g,ignoreScrollToTop:k}=d,{lastScrollTop:T=g}=d;d.lastScrollTop=g,d.ignoreScrollToTop=void 0,k&&k>g&&(T=k),n(d.isNearBottom),setTimeout(()=>{if(d.resizeDifference||g===k)return;if(i()){c(!0),u(!1);return}let P=g>T,R=g<T;if(d.animation?.ignoreEscapes){d.scrollTop=T;return}R&&(c(!0),u(!1)),P&&c(!1),!d.escapedFromLock&&d.isNearBottom&&u(!0)},1)},[c,u,i,d]),I=Xe(({target:C,deltaY:g})=>{let k=C;for(;!["scroll","auto"].includes(getComputedStyle(k).overflow);){if(!k.parentElement)return;k=k.parentElement}k===L.current&&g<0&&L.current.scrollHeight>L.current.clientHeight&&!d.animation?.ignoreEscapes&&(c(!0),u(!1))},[c,u,d]),L=ys(C=>{L.current?.removeEventListener("scroll",h),L.current?.removeEventListener("wheel",I),C?.addEventListener("scroll",h,{passive:!0}),C?.addEventListener("wheel",I,{passive:!0})},[]),S=ys(C=>{if(d.resizeObserver?.disconnect(),!C)return;let g;d.resizeObserver=new ResizeObserver(([k])=>{let{height:T}=k.contentRect,P=T-(g??T);if(d.resizeDifference=P,d.scrollTop>d.targetScrollTop&&(d.scrollTop=d.targetScrollTop),n(d.isNearBottom),P>=0){let R=Lo(l.current,g?l.current.resize:l.current.initial);p({animation:R,wait:!0,preserveScrollPosition:!0,duration:R==="instant"?void 0:Hu})}else d.isNearBottom&&(c(!1),u(!0));g=T,requestAnimationFrame(()=>{setTimeout(()=>{d.resizeDifference===P&&(d.resizeDifference=0)},1)})}),d.resizeObserver?.observe(C)},[]);return{contentRef:S,scrollRef:L,scrollToBottom:p,stopScroll:m,isAtBottom:o||s,isNearBottom:s,escapedFromLock:t,state:d}};function ys(e,t){let a=Xe(o=>(a.current=o,e(o)),t);return a}var xo=new Map;function Lo(...e){let t={...Nu},a=!1;for(let r of e){if(r==="instant"){a=!0;continue}typeof r=="object"&&(a=!1,t.damping=r.damping??t.damping,t.stiffness=r.stiffness??t.stiffness,t.mass=r.mass??t.mass)}let o=JSON.stringify(t);return xo.has(o)||xo.set(o,Object.freeze(t)),a?"instant":xo.get(o)}f();import*as at from"react";import{createContext as qu,useContext as Wu,useEffect as Gu,useImperativeHandle as ju,useLayoutEffect as zu,useMemo as Vu,useRef as $u}from"react";var bs=qu(null),Xu=typeof window<"u"?zu:Gu;function qt({instance:e,children:t,resize:a,initial:o,mass:r,damping:s,stiffness:n,targetScrollTop:l,contextRef:i,...u}){let c=$u(null),d=at.useCallback((T,P)=>(k?.targetScrollTop??l)?.(T,P)??T,[l]),p=ks({mass:r,damping:s,stiffness:n,resize:a,initial:o,targetScrollTop:d}),{scrollRef:m,contentRef:h,scrollToBottom:I,stopScroll:L,isAtBottom:S,escapedFromLock:C,state:g}=e??p,k=Vu(()=>({scrollToBottom:I,stopScroll:L,scrollRef:m,isAtBottom:S,escapedFromLock:C,contentRef:h,state:g,get targetScrollTop(){return c.current},set targetScrollTop(T){c.current=T}}),[I,S,h,m,L,C,g]);return ju(i,()=>k,[k]),Xu(()=>{m.current&&getComputedStyle(m.current).overflow==="visible"&&(m.current.style.overflow="auto")},[]),at.createElement(bs.Provider,{value:k},at.createElement("div",{...u},typeof t=="function"?t(k):t))}(function(e){function t({children:a,scrollClassName:o,...r}){let s=Co();return at.createElement("div",{ref:s.scrollRef,style:{height:"100%",width:"100%",scrollbarGutter:"stable both-edges"},className:o},at.createElement("div",{...r,ref:s.contentRef},typeof a=="function"?a(s):a))}e.Content=t})(qt||(qt={}));function Co(){let e=Wu(bs);if(!e)throw new Error("use-stick-to-bottom component context must be used within a StickToBottom component");return e}f();var Ku=Sr({prefix:"ww"});function B(...e){return Ku(Ir(e))}f();import{jsx as Qu}from"react/jsx-runtime";var Ee=({className:e,variant:t="default",size:a="default",type:o="button",...r})=>Qu("button",{type:o,className:B("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});import{jsx as wa}from"react/jsx-runtime";var Ts=({className:e,...t})=>wa(qt,{className:B("ww:relative ww:flex-1 ww:overflow-y-hidden",e),initial:"smooth",resize:"smooth",role:"log",...t}),Ps=({className:e,...t})=>wa(qt.Content,{className:B("ww:flex ww:flex-col ww:gap-6 ww:px-4 ww:py-6 ww:mx-auto ww:w-full ww:max-w-3xl",e),...t}),vs=({className:e,...t})=>{let{isAtBottom:a,scrollToBottom:o}=Co(),r=Ju(()=>{o()},[o]);return!a&&wa(Ee,{className:B("ww:absolute ww:bottom-4 ww:left-[50%] ww:translate-x-[-50%] ww:rounded-full",e),onClick:r,size:"icon",variant:"outline",...t,children:wa(Mt,{className:"ww:size-4"})})};f();f();import Rs from"crypto";f();var As="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var Zu=128,ot,wt,Yu=e=>{!ot||ot.length<e?(ot=Buffer.allocUnsafe(e*Zu),Rs.randomFillSync(ot),wt=0):wt+e>ot.length&&(Rs.randomFillSync(ot),wt=0),wt+=e};var Wt=(e=21)=>{Yu(e|=0);let t="";for(let a=wt-e;a<wt;a++)t+=As[ot[a]&63];return t};import{createContext as ed,useCallback as qe,useContext as td,useEffect as Io,useMemo as ad,useRef as So,useState as Ms}from"react";import{jsx as Me,jsxs as Os}from"react/jsx-runtime";var od=async e=>{try{let a=await(await fetch(e)).blob();return new Promise(o=>{let r=new FileReader;r.onloadend=()=>o(r.result),r.onerror=()=>o(null),r.readAsDataURL(a)})}catch{return null}},Fs=ed(null),Ds=()=>{let e=td(Fs);if(!e)throw new Error("usePromptInputAttachments must be used within a PromptInput");return e},Bs=({className:e,accept:t,multiple:a,globalDrop:o,maxFiles:r,maxFileSize:s,onSubmit:n,children:l,...i})=>{let u=So(null),c=So(null),[d,p]=Ms([]),m=So(d);Io(()=>{m.current=d},[d]);let h=qe(()=>{u.current?.click()},[]),I=qe(T=>{let P=[...T];if(P.length===0)return;let R=_=>s?_.size<=s:!0,v=P.filter(R);p(_=>{let A=typeof r=="number"?Math.max(0,r-_.length):void 0,E=typeof A=="number"?v.slice(0,A):v;return[..._,...E.map(y=>({filename:y.name,id:Wt(),mediaType:y.type,type:"file",url:URL.createObjectURL(y)}))]})},[r,s]),L=qe(T=>{p(P=>{let R=P.find(v=>v.id===T);return R?.url&&URL.revokeObjectURL(R.url),P.filter(v=>v.id!==T)})},[]),S=qe(()=>{p(T=>{for(let P of T)P.url&&URL.revokeObjectURL(P.url);return[]})},[]);Io(()=>()=>{for(let T of m.current)T.url&&URL.revokeObjectURL(T.url)},[]);let C=qe(T=>{T.currentTarget.files&&I(T.currentTarget.files),T.currentTarget.value=""},[I]);Io(()=>{if(!o)return;let T=R=>{R.dataTransfer?.types?.includes("Files")&&R.preventDefault()},P=R=>{R.dataTransfer?.types?.includes("Files")&&R.preventDefault(),R.dataTransfer?.files&&R.dataTransfer.files.length>0&&I(R.dataTransfer.files)};return document.addEventListener("dragover",T),document.addEventListener("drop",P),()=>{document.removeEventListener("dragover",T),document.removeEventListener("drop",P)}},[I,o]);let g=qe(async T=>{T.preventDefault();let P=T.currentTarget,v=new FormData(P).get("message")||"";P.reset();let _=await Promise.all(d.map(async({id:A,...E})=>{if(E.url?.startsWith("blob:")){let y=await od(E.url);return{...E,url:y??E.url}}return E}));try{let A=n({files:_,text:v},T);A instanceof Promise&&await A,S()}catch{}},[d,n,S]),k=ad(()=>({add:I,clear:S,files:d,openFileDialog:h,remove:L}),[d,I,L,S,h]);return Os(Fs.Provider,{value:k,children:[Me("input",{accept:t,"aria-label":"Upload files",className:"ww:hidden",multiple:a,onChange:C,ref:u,title:"Upload files",type:"file"}),Me("form",{className:B("ww:flex ww:w-full ww:flex-col ww:rounded-lg ww:border ww:border-border ww:bg-background",e),onSubmit:g,ref:c,...i,children:l})]})};var Es=({onChange:e,onKeyDown:t,className:a,placeholder:o="What would you like to know?",...r})=>{let s=Ds(),[n,l]=Ms(!1),i=qe(c=>{if(t?.(c),!c.defaultPrevented){if(c.key==="Enter"){if(n||c.nativeEvent.isComposing||c.shiftKey)return;c.preventDefault();let{form:d}=c.currentTarget;if(d?.querySelector('button[type="submit"]')?.disabled)return;d?.requestSubmit()}if(c.key==="Backspace"&&c.currentTarget.value===""&&s.files.length>0){c.preventDefault();let d=s.files.at(-1);d&&s.remove(d.id)}}},[t,n,s]),u=qe(c=>{let d=c.clipboardData?.items;if(!d)return;let p=[];for(let m of d)if(m.kind==="file"){let h=m.getAsFile();h&&p.push(h)}p.length>0&&(c.preventDefault(),s.add(p))},[s]);return Me("textarea",{className:B("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-sm ww:outline-none ww:placeholder:text-muted-foreground",a),name:"message",onCompositionEnd:()=>l(!1),onCompositionStart:()=>l(!0),onKeyDown:i,onPaste:u,placeholder:o,onChange:e,...r})},_s=({className:e,status:t,onStop:a,onClick:o,children:r,...s})=>{let n=t==="submitted"||t==="streaming",l=Me(Ft,{className:"ww:size-4"});t==="submitted"?l=Me(Ot,{className:"ww:size-4 ww:animate-spin"}):t==="streaming"&&(l=Me(Ht,{className:"ww:size-4"}));let i=qe(u=>{if(n&&a){u.preventDefault(),a();return}o?.(u)},[n,a,o]);return Me(Ee,{"aria-label":n?"Stop":"Submit",className:B("ww:bg-foreground ww:text-background ww:hover:bg-foreground ww:rounded-full",e),onClick:i,size:"icon-sm",type:n&&a?"button":"submit",variant:"ghost",...s,children:r??l})},Ns=({className:e,children:t,...a})=>{let o=Ds();return o.files.length>0?Os(Ee,{className:B("ww:group ww:relative",e),onClick:()=>o.clear(),size:"icon-sm",type:"button",variant:"ghost","aria-label":"Remove all attachments",...a,children:[Me("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}),Me(tt,{className:"ww:absolute ww:size-4 ww:opacity-0 ww:transition-opacity ww:group-hover:opacity-100"})]}):Me(Ee,{className:B(e),onClick:()=>o.openFileDialog(),size:"icon-sm",type:"button",variant:"ghost",...a,children:t??Me(Ut,{className:"ww:size-4"})})};f();import{memo as rd,useCallback as sd}from"react";f();import{jsx as xt}from"react/jsx-runtime";var Us=({className:e,...t})=>xt("div",{className:B("ww:flex ww:flex-col ww:gap-1 ww:px-3 ww:py-2",e),...t}),Hs=({className:e,...t})=>xt("li",{className:B("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}),qs=({className:e,...t})=>xt("span",{className:B("ww:inline-block ww:size-2 ww:shrink-0 ww:rounded-full ww:border ww:border-muted-foreground/50",e),...t}),Ws=({className:e,...t})=>xt("span",{className:B("ww:line-clamp-1 ww:grow ww:break-words ww:text-muted-foreground",e),...t}),Gs=({className:e,...t})=>xt("div",{className:B("ww:flex ww:shrink-0 ww:gap-1 ww:opacity-0 ww:transition-opacity ww:group-hover:opacity-100",e),...t}),js=({className:e,...t})=>xt(Ee,{className:B("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 rt,jsxs as yo}from"react/jsx-runtime";var zs=rd(({message:e,onRemove:t})=>{let a=sd(()=>t(e.id),[t,e.id]);return yo(Hs,{children:[rt(qs,{}),rt(Ws,{children:e.text||"(attachment)"}),rt(Gs,{children:rt(js,{"aria-label":"Remove from queue",onClick:a,children:rt(tt,{className:"ww:size-3"})})})]})});zs.displayName="ChatQueueItem";function Vs({queuedMessages:e,onRemove:t,className:a}){return e.length===0?null:yo(Us,{className:B("ww:border-t ww:border-border",a),children:[yo("div",{className:"ww:text-[11px] ww:font-medium ww:text-muted-foreground ww:px-2",children:[e.length," queued"]}),rt("ul",{children:e.map(o=>rt(zs,{message:o,onRemove:t},o.id))})]})}f();import{useState as $s}from"react";import{jsx as nd}from"react/jsx-runtime";function Xs({messages:e,evalEnabled:t,api:a="/api/waniwani"}){let[o,r]=$s(!1),[s,n]=$s(null),l=async()=>{let u={name:`session-${new Date().toISOString().slice(0,19)}`,type:"functional",messages:e,mode:"manual"};r(!0),n(null);try{let c=await fetch(`${a}/scenarios`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(u)});if(!c.ok)throw new Error(`${c.status}`);n("saved")}catch{n("error")}finally{r(!1),setTimeout(()=>n(null),2e3)}};return!t||e.length===0?null:nd("button",{type:"button",onClick:l,disabled:o,title:"Save scenario to WaniWani",className:"ww:ml-auto ww:text-[10px] ww:font-mono ww:uppercase ww:tracking-wider ww:text-muted-foreground hover:ww:text-foreground ww:cursor-pointer ww:transition-colors ww:disabled:opacity-40",children:o?"saving...":s==="saved"?"saved":s==="error"?"error":"export"})}f();f();import{jsx as Gt,jsxs as ld}from"react/jsx-runtime";var Ks=({files:e,className:t,...a})=>e.length===0?null:Gt("div",{className:B("ww:flex ww:flex-wrap ww:gap-1.5",t),...a,children:e.map((o,r)=>Gt(id,{file:o},r))});function id({file:e}){return e.mediaType?.startsWith("image/")&&e.url?Gt("img",{src:e.url,alt:e.filename??"attachment",className:"ww:h-16 ww:max-w-32 ww:rounded ww:object-cover"}):ld("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:[Gt(Nt,{className:"ww:size-3 ww:shrink-0"}),Gt("span",{className:"ww:max-w-24 ww:truncate",children:e.filename??"file"})]})}f();import{jsx as Qs}from"react/jsx-runtime";var ko=({className:e,size:t=5,...a})=>Qs("div",{className:B("ww:flex ww:items-center ww:gap-1",e),...a,children:[0,1,2].map(o=>Qs("div",{className:"ww:rounded-full ww:bg-muted-foreground/60",style:{width:t,height:t,animation:"ww-pulse 1.4s ease-in-out infinite",animationDelay:`${o*.2}s`}},o))});f();f();f();f();f();f();var de={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};f();var _e={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};f();var ye={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"};f();f();f();function Js(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 Zs(e){return e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510}function Ys(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 en(e){return Js(e)?"ambiguous":Zs(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":Ys(e)?"wide":"neutral"}function ud(e){if(!Number.isSafeInteger(e))throw new TypeError(`Expected a code point, got \`${typeof e}\`.`)}function tn(e){return ud(e),en(e)}var dd=Object.defineProperty,cd=(e,t,a)=>t in e?dd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,fd=(e,t,a)=>cd(e,typeof t!="symbol"?t+"":t,a);function pd(e){return new RegExp("^\\p{Emoji_Presentation}","u").test(String.fromCodePoint(e))}function md(e){if(!e||e<4352)return!1;switch(tn(e)){case"fullwidth":case"halfwidth":return!0;case"wide":return!pd(e);case"narrow":return!1;case"ambiguous":return 917760<=e&&e<=917999?null:!1;case"neutral":return new RegExp("^\\p{sc=Hangul}","u").test(String.fromCodePoint(e))}}function hd(e,t){return t!==65025||!e||e<8216?!1:e===8216||e===8217||e===8220||e===8221}function gd(e){return e!==null&&e>=65024&&e<=65038}var wd=an(new RegExp("\\p{P}|\\p{S}","u")),xd=an(/\s/);function an(e){return t;function t(a){return a!==null&&a>-1&&e.test(String.fromCodePoint(a))}}var ke;(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})(ke||(ke={}));function Ke(e){if(e===de.eof||yr(e)||xd(e))return _e.characterGroupWhitespace;let t=0;if(e>=4352){if(gd(e))return ke.nonEmojiGeneralUseVS;switch(md(e)){case null:return ke.ivs;case!0:t|=ke.cjk;break}}return wd(e)&&(t|=_e.characterGroupPunctuation),t}function xa(e,t,a){if(!Cd(e))return e;let o=t(),r=Ke(o);return!o||st(r)?e:hd(o,a)?ke.cjkPunctuation:Ld(r)}function Ld(e){return e&~ke.ivs}function st(e){return!!(e&_e.characterGroupWhitespace)}function Lt(e){return(e&ke.cjkPunctuation)===_e.characterGroupPunctuation}function jt(e){return!!(e&ke.cjk)}function on(e){return e===ke.ivs}function rn(e){return!!(e&ke.cjkOrIvs)}function Cd(e){return e===ke.nonEmojiGeneralUseVS}function bo(e){return!!(e&ke.spaceOrPunctuation)}function La(e){return!!(e&&e>=55296&&e<=56319)}function Ca(e){return!!(e&&e>=56320&&e<=57343)}function Ia(e,t,a){if(t._bufferIndex<2)return e;let r=a({start:{...t,_bufferIndex:t._bufferIndex-2},end:t}).codePointAt(0);return r&&r>=65536?r:e}function Id(e,t,a){let o=e>=65536?2:1;if(t._bufferIndex<1+o)return null;let r=t._bufferIndex-o-2,s=a({start:{...t,_bufferIndex:r>=0?r:0},end:{...t,_bufferIndex:t._bufferIndex-o}}),n=s.charCodeAt(s.length-1);if(Number.isNaN(n))return null;if(s.length<2||n<56320||57343<n)return n;let l=s.codePointAt(0);return l&&l>=65536?l:n}var Sa=class{constructor(e,t,a){this.previousCode=e,this.nowPoint=t,this.sliceSerialize=a,fd(this,"cachedValue")}value(){return this.cachedValue===void 0&&(this.cachedValue=Id(this.previousCode,this.nowPoint,this.sliceSerialize)),this.cachedValue}};function ya(e,t,a){let o=a({start:t,end:{...t,_bufferIndex:t._bufferIndex+2}}).codePointAt(0);return o&&o>=65536?o:e}var To={name:"attention",resolveAll:Sd,tokenize:yd};function Sd(e,t){let a=-1,o,r,s,n,l,i,u,c;for(;++a<e.length;)if(e[a][0]==="enter"&&e[a][1].type==="attentionSequence"&&e[a][1]._close){for(o=a;o--;)if(e[o][0]==="exit"&&e[o][1].type==="attentionSequence"&&e[o][1]._open&&t.sliceSerialize(e[o][1]).charCodeAt(0)===t.sliceSerialize(e[a][1]).charCodeAt(0)){if((e[o][1]._close||e[a][1]._open)&&(e[a][1].end.offset-e[a][1].start.offset)%3&&!((e[o][1].end.offset-e[o][1].start.offset+e[a][1].end.offset-e[a][1].start.offset)%3))continue;i=e[o][1].end.offset-e[o][1].start.offset>1&&e[a][1].end.offset-e[a][1].start.offset>1?2:1;let d={...e[o][1].end},p={...e[a][1].start};sn(d,-i),sn(p,i),n={type:i>1?ye.strongSequence:ye.emphasisSequence,start:d,end:{...e[o][1].end}},l={type:i>1?ye.strongSequence:ye.emphasisSequence,start:{...e[a][1].start},end:p},s={type:i>1?ye.strongText:ye.emphasisText,start:{...e[o][1].end},end:{...e[a][1].start}},r={type:i>1?ye.strong:ye.emphasis,start:{...n.start},end:{...l.end}},e[o][1].end={...n.start},e[a][1].start={...l.end},u=[],e[o][1].end.offset-e[o][1].start.offset&&(u=mt(u,[["enter",e[o][1],t],["exit",e[o][1],t]])),u=mt(u,[["enter",r,t],["enter",n,t],["exit",n,t],["enter",s,t]]),t.parser.constructs.insideSpan.null,u=mt(u,la(t.parser.constructs.insideSpan.null,e.slice(o+1,a),t)),u=mt(u,[["exit",s,t],["enter",l,t],["exit",l,t],["exit",r,t]]),e[a][1].end.offset-e[a][1].start.offset?(c=2,u=mt(u,[["enter",e[a][1],t],["exit",e[a][1],t]])):c=0,pt(e,o-1,a-o+3,u),a=o+u.length-c-2;break}}for(a=-1;++a<e.length;)e[a][1].type==="attentionSequence"&&(e[a][1].type="data");return e}function yd(e,t){let a=this.parser.constructs.attentionMarkers.null,{now:o,sliceSerialize:r,previous:s}=this,n=Ca(s)?Ia(s,o(),r):s,l=Ke(n),i=new Sa(n,o(),r),u=xa(l,i.value.bind(i),n),c;return d;function d(m){return m===de.asterisk||de.underscore,c=m,e.enter("attentionSequence"),p(m)}function p(m){if(m===c)return e.consume(m),p;let h=e.exit("attentionSequence"),I=La(m)?ya(m,o(),r):m,L=Ke(I);let S=Lt(u),C=S||st(u),g=Lt(L),k=g||st(L),T=rn(u),P=!k||g&&(C||T)||a.includes(m),R=!C||S&&(k||jt(L))||a.includes(n);return h._open=!!(c===de.asterisk?P:P&&(bo(u)||!R)),h._close=!!(c===de.asterisk?R:R&&(bo(L)||!P)),t(m)}}function sn(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}function nn(){return{text:{[de.asterisk]:To,[de.underscore]:To},insideSpan:{null:[To]}}}function ln(){let e=this.data();(e.micromarkExtensions||(e.micromarkExtensions=[])).push(nn())}f();f();function un(e){let a=(e||{}).singleTilde,o={name:"strikethrough",tokenize:s,resolveAll:r};return a==null&&(a=!0),{text:{[de.tilde]:o},insideSpan:{null:[o]},attentionMarkers:{null:[de.tilde]}};function r(n,l){let i=-1;for(;++i<n.length;)if(n[i][0]==="enter"&&n[i][1].type==="strikethroughSequenceTemporary"&&n[i][1]._close){let u=i;for(;u--;)if(n[u][0]==="exit"&&n[u][1].type==="strikethroughSequenceTemporary"&&n[u][1]._open&&n[i][1].end.offset-n[i][1].start.offset===n[u][1].end.offset-n[u][1].start.offset){n[i][1].type="strikethroughSequence",n[u][1].type="strikethroughSequence";let c={type:"strikethrough",start:Object.assign({},n[u][1].start),end:Object.assign({},n[i][1].end)},d={type:"strikethroughText",start:Object.assign({},n[u][1].end),end:Object.assign({},n[i][1].start)},p=[["enter",c,l],["enter",n[u][1],l],["exit",n[u][1],l],["enter",d,l]],m=l.parser.constructs.insideSpan.null;m&&pt(p,p.length,0,la(m,n.slice(u+1,i),l)),pt(p,p.length,0,[["exit",d,l],["enter",n[i][1],l],["exit",n[i][1],l],["exit",c,l]]),pt(n,u-1,i-u+3,p),i=u+p.length-2;break}}for(i=-1;++i<n.length;)n[i][1].type==="strikethroughSequenceTemporary"&&(n[i][1].type=ye.data);return n}function s(n,l,i){let{now:u,sliceSerialize:c,previous:d}=this,p=Ca(d)?Ia(d,u(),c):d,m=Ke(p),h=new Sa(p,u(),c),I=xa(m,h.value.bind(h),p),L=this.events,S=0;return C;function C(k){return de.tilde,p===de.tilde&&L[L.length-1][1].type!==ye.characterEscape?i(k):(n.enter("strikethroughSequenceTemporary"),g(k))}function g(k){let T=Ke(p);if(k===de.tilde)return S>1?i(k):(n.consume(k),S++,g);if(S<2&&!a)return i(k);let P=n.exit("strikethroughSequenceTemporary"),R=La(k)?ya(k,u(),c):k,v=Ke(R),A=Lt(I)||st(I),y=Lt(v)||st(v),M=jt(I)||on(T);return P._open=!y||v===_e.attentionSideAfter&&(A||M),P._close=!A||T===_e.attentionSideAfter&&(y||jt(v)),l(k)}}}function dn(e){let t=this.data();(t.micromarkExtensions||(t.micromarkExtensions=[])).push(un(e))}var kd=new Set(["\u3002","\uFF0E","\uFF0C","\u3001","\uFF1F","\uFF01","\uFF1A","\uFF1B","\uFF08","\uFF09","\u3010","\u3011","\u300C","\u300D","\u300E","\u300F","\u3008","\u3009","\u300A","\u300B"]),bd=/^(https?:\/\/|mailto:|www\.)/i,Td=e=>{if(e.children.length!==1)return!1;let t=e.children[0];return t.type==="text"&&t.value===e.url},Pd=e=>{let t=0;for(let a of e){if(kd.has(a))return t;t+=a.length}return null},vd=(e,t)=>({...t,url:e,children:[{type:"text",value:e}]}),Ad=e=>({type:"text",value:e}),Rd=()=>e=>{kr(e,"link",(t,a,o)=>{if(!o||typeof a!="number"||!Td(t)||!bd.test(t.url))return;let r=Pd(t.url);if(r===null||r===0)return;let s=t.url.slice(0,r),n=t.url.slice(r),l=vd(s,t),i=Ad(n);return o.children.splice(a,1,l,i),a+1})};function Md(){let e=[ln],t=[Rd,dn],a=[...e,...t];return{name:"cjk",type:"cjk",remarkPluginsBefore:e,remarkPluginsAfter:t,remarkPlugins:a}}var cn=Md();f();f();f();f();f();var Z=class extends Error{constructor(t){super(t),this.name="ShikiError"}};f();function Fd(e){return _o(e)}function _o(e){return Array.isArray(e)?Dd(e):e instanceof RegExp?e:typeof e=="object"?Bd(e):e}function Dd(e){let t=[];for(let a=0,o=e.length;a<o;a++)t[a]=_o(e[a]);return t}function Bd(e){let t={};for(let a in e)t[a]=_o(e[a]);return t}function Cn(e,...t){return t.forEach(a=>{for(let o in a)e[o]=a[o]}),e}function In(e){let t=~e.lastIndexOf("/")||~e.lastIndexOf("\\");return t===0?e:~t===e.length-1?In(e.substring(0,e.length-1)):e.substr(~t+1)}var Po=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,ka=class{static hasCaptures(e){return e===null?!1:(Po.lastIndex=0,Po.test(e))}static replaceCaptures(e,t,a){return e.replace(Po,(o,r,s,n)=>{let l=a[parseInt(r||s,10)];if(l){let i=t.substring(l.start,l.end);for(;i[0]===".";)i=i.substring(1);switch(n){case"downcase":return i.toLowerCase();case"upcase":return i.toUpperCase();default:return i}}else return o})}};function Sn(e,t){return e<t?-1:e>t?1:0}function yn(e,t){if(e===null&&t===null)return 0;if(!e)return-1;if(!t)return 1;let a=e.length,o=t.length;if(a===o){for(let r=0;r<a;r++){let s=Sn(e[r],t[r]);if(s!==0)return s}return 0}return a-o}function fn(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 kn(e){return e.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var bn=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}},$t=class{constructor(e,t,a){this._colorMap=e,this._defaults=t,this._root=a}static createFromRawTheme(e,t){return this.createFromParsedTheme(Nd(e),t)}static createFromParsedTheme(e,t){return Ud(e,t)}_cachedMatchRoot=new bn(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,o=this._cachedMatchRoot.get(t).find(r=>Ed(e.parent,r.parentScopes));return o?new Tn(o.fontStyle,o.foreground,o.background):null}},vo=class ba{constructor(t,a){this.parent=t,this.scopeName=a}static push(t,a){for(let o of a)t=new ba(t,o);return t}static from(...t){let a=null;for(let o=0;o<t.length;o++)a=new ba(a,t[o]);return a}push(t){return new ba(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=[],o=this;for(;o&&o!==t;)a.push(o.scopeName),o=o.parent;return o===t?a.reverse():void 0}};function Ed(e,t){if(t.length===0)return!0;for(let a=0;a<t.length;a++){let o=t[a],r=!1;if(o===">"){if(a===t.length-1)return!1;o=t[++a],r=!0}for(;e&&!_d(e.scopeName,o);){if(r)return!1;e=e.parent}if(!e)return!1;e=e.parent}return!0}function _d(e,t){return t===e||e.startsWith(t)&&e[t.length]==="."}var Tn=class{constructor(e,t,a){this.fontStyle=e,this.foregroundId=t,this.backgroundId=a}};function Nd(e){if(!e)return[];if(!e.settings||!Array.isArray(e.settings))return[];let t=e.settings,a=[],o=0;for(let r=0,s=t.length;r<s;r++){let n=t[r];if(!n.settings)continue;let l;if(typeof n.scope=="string"){let d=n.scope;d=d.replace(/^[,]+/,""),d=d.replace(/[,]+$/,""),l=d.split(",")}else Array.isArray(n.scope)?l=n.scope:l=[""];let i=-1;if(typeof n.settings.fontStyle=="string"){i=0;let d=n.settings.fontStyle.split(" ");for(let p=0,m=d.length;p<m;p++)switch(d[p]){case"italic":i=i|1;break;case"bold":i=i|2;break;case"underline":i=i|4;break;case"strikethrough":i=i|8;break}}let u=null;typeof n.settings.foreground=="string"&&fn(n.settings.foreground)&&(u=n.settings.foreground);let c=null;typeof n.settings.background=="string"&&fn(n.settings.background)&&(c=n.settings.background);for(let d=0,p=l.length;d<p;d++){let h=l[d].trim().split(" "),I=h[h.length-1],L=null;h.length>1&&(L=h.slice(0,h.length-1),L.reverse()),a[o++]=new Od(I,L,r,i,u,c)}}return a}var Od=class{constructor(e,t,a,o,r,s){this.scope=e,this.parentScopes=t,this.index=a,this.fontStyle=o,this.foreground=r,this.background=s}},ce=(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))(ce||{});function Ud(e,t){e.sort((i,u)=>{let c=Sn(i.scope,u.scope);return c!==0||(c=yn(i.parentScopes,u.parentScopes),c!==0)?c:i.index-u.index});let a=0,o="#000000",r="#ffffff";for(;e.length>=1&&e[0].scope==="";){let i=e.shift();i.fontStyle!==-1&&(a=i.fontStyle),i.foreground!==null&&(o=i.foreground),i.background!==null&&(r=i.background)}let s=new Hd(t),n=new Tn(a,s.getId(o),s.getId(r)),l=new Wd(new Ro(0,null,-1,0,0),[]);for(let i=0,u=e.length;i<u;i++){let c=e[i];l.insert(0,c.scope,c.parentScopes,c.fontStyle,s.getId(c.foreground),s.getId(c.background))}return new $t(s,n,l)}var Hd=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)}},qd=Object.freeze([]),Ro=class Pn{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(t,a,o,r,s){this.scopeDepth=t,this.parentScopes=a||qd,this.fontStyle=o,this.foreground=r,this.background=s}clone(){return new Pn(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(t){let a=[];for(let o=0,r=t.length;o<r;o++)a[o]=t[o].clone();return a}acceptOverwrite(t,a,o,r){this.scopeDepth>t?console.log("how did this happen?"):this.scopeDepth=t,a!==-1&&(this.fontStyle=a),o!==0&&(this.foreground=o),r!==0&&(this.background=r)}},Wd=class Mo{constructor(t,a=[],o={}){this._mainRule=t,this._children=o,this._rulesWithParentScopes=a}_rulesWithParentScopes;static _cmpBySpecificity(t,a){if(t.scopeDepth!==a.scopeDepth)return a.scopeDepth-t.scopeDepth;let o=0,r=0;for(;t.parentScopes[o]===">"&&o++,a.parentScopes[r]===">"&&r++,!(o>=t.parentScopes.length||r>=a.parentScopes.length);){let s=a.parentScopes[r].length-t.parentScopes[o].length;if(s!==0)return s;o++,r++}return a.parentScopes.length-t.parentScopes.length}match(t){if(t!==""){let o=t.indexOf("."),r,s;if(o===-1?(r=t,s=""):(r=t.substring(0,o),s=t.substring(o+1)),this._children.hasOwnProperty(r))return this._children[r].match(s)}let a=this._rulesWithParentScopes.concat(this._mainRule);return a.sort(Mo._cmpBySpecificity),a}insert(t,a,o,r,s,n){if(a===""){this._doInsertHere(t,o,r,s,n);return}let l=a.indexOf("."),i,u;l===-1?(i=a,u=""):(i=a.substring(0,l),u=a.substring(l+1));let c;this._children.hasOwnProperty(i)?c=this._children[i]:(c=new Mo(this._mainRule.clone(),Ro.cloneArr(this._rulesWithParentScopes)),this._children[i]=c),c.insert(t+1,u,o,r,s,n)}_doInsertHere(t,a,o,r,s){if(a===null){this._mainRule.acceptOverwrite(t,o,r,s);return}for(let n=0,l=this._rulesWithParentScopes.length;n<l;n++){let i=this._rulesWithParentScopes[n];if(yn(i.parentScopes,a)===0){i.acceptOverwrite(t,o,r,s);return}}o===-1&&(o=this._mainRule.fontStyle),r===0&&(r=this._mainRule.foreground),s===0&&(s=this._mainRule.background),this._rulesWithParentScopes.push(new Ro(t,a,o,r,s))}},it=class Ae{static toBinaryStr(t){return t.toString(2).padStart(32,"0")}static print(t){let a=Ae.getLanguageId(t),o=Ae.getTokenType(t),r=Ae.getFontStyle(t),s=Ae.getForeground(t),n=Ae.getBackground(t);console.log({languageId:a,tokenType:o,fontStyle:r,foreground:s,background:n})}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,o,r,s,n,l){let i=Ae.getLanguageId(t),u=Ae.getTokenType(t),c=Ae.containsBalancedBrackets(t)?1:0,d=Ae.getFontStyle(t),p=Ae.getForeground(t),m=Ae.getBackground(t);return a!==0&&(i=a),o!==8&&(u=o),r!==null&&(c=r?1:0),s!==-1&&(d=s),n!==0&&(p=n),l!==0&&(m=l),(i<<0|u<<8|c<<10|d<<11|p<<15|m<<24)>>>0}};function Pa(e,t){let a=[],o=Gd(e),r=o.next();for(;r!==null;){let i=0;if(r.length===2&&r.charAt(1)===":"){switch(r.charAt(0)){case"R":i=1;break;case"L":i=-1;break;default:console.log(`Unknown priority ${r} in scope selector`)}r=o.next()}let u=n();if(a.push({matcher:u,priority:i}),r!==",")break;r=o.next()}return a;function s(){if(r==="-"){r=o.next();let i=s();return u=>!!i&&!i(u)}if(r==="("){r=o.next();let i=l();return r===")"&&(r=o.next()),i}if(pn(r)){let i=[];do i.push(r),r=o.next();while(pn(r));return u=>t(i,u)}return null}function n(){let i=[],u=s();for(;u;)i.push(u),u=s();return c=>i.every(d=>d(c))}function l(){let i=[],u=n();for(;u&&(i.push(u),r==="|"||r===",");){do r=o.next();while(r==="|"||r===",");u=n()}return c=>i.some(d=>d(c))}}function pn(e){return!!e&&!!e.match(/[\w\.:]+/)}function Gd(e){let t=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,a=t.exec(e);return{next:()=>{if(!a)return null;let o=a[0];return a=t.exec(e),o}}}function vn(e){typeof e.dispose=="function"&&e.dispose()}var Xt=class{constructor(e){this.scopeName=e}toKey(){return this.scopeName}},jd=class{constructor(e,t){this.scopeName=e,this.ruleName=t}toKey(){return`${this.scopeName}#${this.ruleName}`}},zd=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))}},Vd=class{constructor(e,t){this.repo=e,this.initialScopeName=t,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new Xt(this.initialScopeName)]}seenFullScopeRequests=new Set;seenPartialScopeRequests=new Set;Q;processQueue(){let e=this.Q;this.Q=[];let t=new zd;for(let a of e)$d(a,this.initialScopeName,this.repo,t);for(let a of t.references)if(a instanceof Xt){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 $d(e,t,a,o){let r=a.lookup(e.scopeName);if(!r){if(e.scopeName===t)throw new Error(`No grammar provided for <${t}>`);return}let s=a.lookup(t);e instanceof Xt?Ta({baseGrammar:s,selfGrammar:r},o):Fo(e.ruleName,{baseGrammar:s,selfGrammar:r,repository:r.repository},o);let n=a.injections(e.scopeName);if(n)for(let l of n)o.add(new Xt(l))}function Fo(e,t,a){if(t.repository&&t.repository[e]){let o=t.repository[e];va([o],t,a)}}function Ta(e,t){e.selfGrammar.patterns&&Array.isArray(e.selfGrammar.patterns)&&va(e.selfGrammar.patterns,{...e,repository:e.selfGrammar.repository},t),e.selfGrammar.injections&&va(Object.values(e.selfGrammar.injections),{...e,repository:e.selfGrammar.repository},t)}function va(e,t,a){for(let o of e){if(a.visitedRule.has(o))continue;a.visitedRule.add(o);let r=o.repository?Cn({},t.repository,o.repository):t.repository;Array.isArray(o.patterns)&&va(o.patterns,{...t,repository:r},a);let s=o.include;if(!s)continue;let n=An(s);switch(n.kind){case 0:Ta({...t,selfGrammar:t.baseGrammar},a);break;case 1:Ta(t,a);break;case 2:Fo(n.ruleName,{...t,repository:r},a);break;case 3:case 4:let l=n.scopeName===t.selfGrammar.scopeName?t.selfGrammar:n.scopeName===t.baseGrammar.scopeName?t.baseGrammar:void 0;if(l){let i={baseGrammar:t.baseGrammar,selfGrammar:l,repository:r};n.kind===4?Fo(n.ruleName,i,a):Ta(i,a)}else n.kind===4?a.add(new jd(n.scopeName,n.ruleName)):a.add(new Xt(n.scopeName));break}}}var Xd=class{kind=0},Kd=class{kind=1},Qd=class{constructor(e){this.ruleName=e}kind=2},Jd=class{constructor(e){this.scopeName=e}kind=3},Zd=class{constructor(e,t){this.scopeName=e,this.ruleName=t}kind=4};function An(e){if(e==="$base")return new Xd;if(e==="$self")return new Kd;let t=e.indexOf("#");if(t===-1)return new Jd(e);if(t===0)return new Qd(e.substring(1));{let a=e.substring(0,t),o=e.substring(t+1);return new Zd(a,o)}}var Yd=/\\(\d+)/,mn=/\\(\d+)/g;var ec=-1,Rn=-2;var Jt=class{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(e,t,a,o){this.$location=e,this.id=t,this._name=a||null,this._nameIsCapturing=ka.hasCaptures(this._name),this._contentName=o||null,this._contentNameIsCapturing=ka.hasCaptures(this._contentName)}get debugName(){let e=this.$location?`${In(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:ka.replaceCaptures(this._name,e,t)}getContentName(e,t){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:ka.replaceCaptures(this._contentName,e,t)}},tc=class extends Jt{retokenizeCapturedWithRuleId;constructor(e,t,a,o,r){super(e,t,a,o),this.retokenizeCapturedWithRuleId=r}dispose(){}collectPatterns(e,t){throw new Error("Not supported!")}compile(e,t){throw new Error("Not supported!")}compileAG(e,t,a,o){throw new Error("Not supported!")}},ac=class extends Jt{_match;captures;_cachedCompiledPatterns;constructor(e,t,a,o,r){super(e,t,a,null),this._match=new Kt(o,this.id),this.captures=r,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,o){return this._getCachedCompiledPatterns(e).compileAG(e,a,o)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new Qt,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},hn=class extends Jt{hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,a,o,r){super(e,t,a,o),this.patterns=r.patterns,this.hasMissingPatterns=r.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,o){return this._getCachedCompiledPatterns(e).compileAG(e,a,o)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new Qt,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Do=class extends Jt{_begin;beginCaptures;_end;endHasBackReferences;endCaptures;applyEndPatternLast;hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,a,o,r,s,n,l,i,u){super(e,t,a,o),this._begin=new Kt(r,this.id),this.beginCaptures=s,this._end=new Kt(n||"\uFFFF",-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=l,this.applyEndPatternLast=i||!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,o){return this._getCachedCompiledPatterns(e,t).compileAG(e,a,o)}_getCachedCompiledPatterns(e,t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Qt;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}},Aa=class extends Jt{_begin;beginCaptures;whileCaptures;_while;whileHasBackReferences;hasMissingPatterns;patterns;_cachedCompiledPatterns;_cachedCompiledWhilePatterns;constructor(e,t,a,o,r,s,n,l,i){super(e,t,a,o),this._begin=new Kt(r,this.id),this.beginCaptures=s,this.whileCaptures=l,this._while=new Kt(n,Rn),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=i.patterns,this.hasMissingPatterns=i.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,o){return this._getCachedCompiledPatterns(e).compileAG(e,a,o)}_getCachedCompiledPatterns(e){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Qt;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,o){return this._getCachedCompiledWhilePatterns(e,t).compileAG(e,a,o)}_getCachedCompiledWhilePatterns(e,t){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new Qt,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,t||"\uFFFF"),this._cachedCompiledWhilePatterns}},Mn=class he{static createCaptureRule(t,a,o,r,s){return t.registerRule(n=>new tc(a,n,o,r,s))}static getCompiledRuleId(t,a,o){return t.id||a.registerRule(r=>{if(t.id=r,t.match)return new ac(t.$vscodeTextmateLocation,t.id,t.name,t.match,he._compileCaptures(t.captures,a,o));if(typeof t.begin>"u"){t.repository&&(o=Cn({},o,t.repository));let s=t.patterns;return typeof s>"u"&&t.include&&(s=[{include:t.include}]),new hn(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,he._compilePatterns(s,a,o))}return t.while?new Aa(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,he._compileCaptures(t.beginCaptures||t.captures,a,o),t.while,he._compileCaptures(t.whileCaptures||t.captures,a,o),he._compilePatterns(t.patterns,a,o)):new Do(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,he._compileCaptures(t.beginCaptures||t.captures,a,o),t.end,he._compileCaptures(t.endCaptures||t.captures,a,o),t.applyEndPatternLast,he._compilePatterns(t.patterns,a,o))}),t.id}static _compileCaptures(t,a,o){let r=[];if(t){let s=0;for(let n in t){if(n==="$vscodeTextmateLocation")continue;let l=parseInt(n,10);l>s&&(s=l)}for(let n=0;n<=s;n++)r[n]=null;for(let n in t){if(n==="$vscodeTextmateLocation")continue;let l=parseInt(n,10),i=0;t[n].patterns&&(i=he.getCompiledRuleId(t[n],a,o)),r[l]=he.createCaptureRule(a,t[n].$vscodeTextmateLocation,t[n].name,t[n].contentName,i)}}return r}static _compilePatterns(t,a,o){let r=[];if(t)for(let s=0,n=t.length;s<n;s++){let l=t[s],i=-1;if(l.include){let u=An(l.include);switch(u.kind){case 0:case 1:i=he.getCompiledRuleId(o[l.include],a,o);break;case 2:let c=o[u.ruleName];c&&(i=he.getCompiledRuleId(c,a,o));break;case 3:case 4:let d=u.scopeName,p=u.kind===4?u.ruleName:null,m=a.getExternalGrammar(d,o);if(m)if(p){let h=m.repository[p];h&&(i=he.getCompiledRuleId(h,a,m.repository))}else i=he.getCompiledRuleId(m.repository.$self,a,m.repository);break}}else i=he.getCompiledRuleId(l,a,o);if(i!==-1){let u=a.getRule(i),c=!1;if((u instanceof hn||u instanceof Do||u instanceof Aa)&&u.hasMissingPatterns&&u.patterns.length===0&&(c=!0),c)continue;r.push(i)}}return{patterns:r,hasMissingPatterns:(t?t.length:0)!==r.length}}},Kt=class Fn{source;ruleId;hasAnchor;hasBackReferences;_anchorCache;constructor(t,a){if(t&&typeof t=="string"){let o=t.length,r=0,s=[],n=!1;for(let l=0;l<o;l++)if(t.charAt(l)==="\\"&&l+1<o){let u=t.charAt(l+1);u==="z"?(s.push(t.substring(r,l)),s.push("$(?!\\n)(?<!\\n)"),r=l+2):(u==="A"||u==="G")&&(n=!0),l++}this.hasAnchor=n,r===0?this.source=t:(s.push(t.substring(r,o)),this.source=s.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=Yd.test(this.source):this.hasBackReferences=!1}clone(){return new Fn(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 o=a.map(r=>t.substring(r.start,r.end));return mn.lastIndex=0,this.source.replace(mn,(r,s)=>kn(o[parseInt(s,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=[],o=[],r=[],s,n,l,i;for(s=0,n=this.source.length;s<n;s++)l=this.source.charAt(s),t[s]=l,a[s]=l,o[s]=l,r[s]=l,l==="\\"&&s+1<n&&(i=this.source.charAt(s+1),i==="A"?(t[s+1]="\uFFFF",a[s+1]="\uFFFF",o[s+1]="A",r[s+1]="A"):i==="G"?(t[s+1]="\uFFFF",a[s+1]="G",o[s+1]="\uFFFF",r[s+1]="G"):(t[s+1]=i,a[s+1]=i,o[s+1]=i,r[s+1]=i),s++);return{A0_G0:t.join(""),A0_G1:a.join(""),A1_G0:o.join(""),A1_G1:r.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}},Qt=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 gn(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 o=this._items.map(r=>r.resolveAnchors(t,a));return new gn(e,o,this._items.map(r=>r.ruleId))}},gn=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(`
|
|
69
|
-
`)}findNextMatchSync(e,t,a){let o=this.scanner.findNextMatchSync(e,t,a);return o?{ruleId:this.rules[o.index],captureIndices:o.captureIndices}:null}},
|
|
70
|
-
`;let s=this.createOnigString(e),n=s.content.length,l=new hc(a,e,this._tokenTypeMatchers,this.balancedBracketSelectors),i=Bn(this,s,r,0,t,l,!0,o);return vn(s),{lineLength:n,lineTokens:l,ruleStack:i.stack,stoppedEarly:i.stoppedEarly}}};function Ln(e,t){return e=Fd(e),e.repository=e.repository||{},e.repository.$self={$vscodeTextmateLocation:e.$vscodeTextmateLocation,patterns:e.patterns,name:e.scopeName},e.repository.$base=t||e.repository.$self,e}var Vt=class Ne{constructor(t,a,o){this.parent=t,this.scopePath=a,this.tokenAttributes=o}static fromExtension(t,a){let o=t,r=t?.scopePath??null;for(let s of a)r=vo.push(r,s.scopeNames),o=new Ne(o,r,s.encodedTokenAttributes);return o}static createRoot(t,a){return new Ne(null,new vo(null,t),a)}static createRootAndLookUpScopeName(t,a,o){let r=o.getMetadataForScope(t),s=new vo(null,t),n=o.themeProvider.themeMatch(s),l=Ne.mergeAttributes(a,r,n);return new Ne(null,s,l)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(" ")}equals(t){return Ne.equals(this,t)}static equals(t,a){do{if(t===a||!t&&!a)return!0;if(!t||!a||t.scopeName!==a.scopeName||t.tokenAttributes!==a.tokenAttributes)return!1;t=t.parent,a=a.parent}while(!0)}static mergeAttributes(t,a,o){let r=-1,s=0,n=0;return o!==null&&(r=o.fontStyle,s=o.foregroundId,n=o.backgroundId),it.set(t,a.languageId,a.tokenType,null,r,s,n)}pushAttributed(t,a){if(t===null)return this;if(t.indexOf(" ")===-1)return Ne._pushAttributed(this,t,a);let o=t.split(/ /g),r=this;for(let s of o)r=Ne._pushAttributed(r,s,a);return r}static _pushAttributed(t,a,o){let r=o.getMetadataForScope(a),s=t.scopePath.push(a),n=o.themeProvider.themeMatch(s),l=Ne.mergeAttributes(t.tokenAttributes,r,n);return new Ne(t,s,l)}getScopeNames(){return this.scopePath.getSegments()}getExtensionIfDefined(t){let a=[],o=this;for(;o&&o!==t;)a.push({encodedTokenAttributes:o.tokenAttributes,scopeNames:o.scopePath.getExtensionIfDefined(o.parent?.scopePath??null)}),o=o.parent;return o===t?a.reverse():void 0}},Eo=class nt{constructor(t,a,o,r,s,n,l,i){this.parent=t,this.ruleId=a,this.beginRuleCapturedEOL=s,this.endRule=n,this.nameScopesList=l,this.contentNameScopesList=i,this.depth=this.parent?this.parent.depth+1:1,this._enterPos=o,this._anchorPos=r}_stackElementBrand=void 0;static NULL=new nt(null,0,0,0,!1,null,null,null);_enterPos;_anchorPos;depth;equals(t){return t===null?!1:nt._equals(this,t)}static _equals(t,a){return t===a?!0:this._structuralEquals(t,a)?Vt.equals(t.contentNameScopesList,a.contentNameScopesList):!1}static _structuralEquals(t,a){do{if(t===a||!t&&!a)return!0;if(!t||!a||t.depth!==a.depth||t.ruleId!==a.ruleId||t.endRule!==a.endRule)return!1;t=t.parent,a=a.parent}while(!0)}clone(){return this}static _reset(t){for(;t;)t._enterPos=-1,t._anchorPos=-1,t=t.parent}reset(){nt._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(t,a,o,r,s,n,l){return new nt(this,t,a,o,r,s,n,l)}getEnterPos(){return this._enterPos}getAnchorPos(){return this._anchorPos}getRule(t){return t.getRule(this.ruleId)}toString(){let t=[];return this._writeString(t,0),"["+t.join(",")+"]"}_writeString(t,a){return this.parent&&(a=this.parent._writeString(t,a)),t[a++]=`(${this.ruleId}, ${this.nameScopesList?.toString()}, ${this.contentNameScopesList?.toString()})`,a}withContentNameScopesList(t){return this.contentNameScopesList===t?this:this.parent.push(this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,this.endRule,this.nameScopesList,t)}withEndRule(t){return this.endRule===t?this:new nt(this.parent,this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,t,this.nameScopesList,this.contentNameScopesList)}hasSameRuleAs(t){let a=this;for(;a&&a._enterPos===t._enterPos;){if(a.ruleId===t.ruleId)return!0;a=a.parent}return!1}toStateStackFrame(){return{ruleId:this.ruleId,beginRuleCapturedEOL:this.beginRuleCapturedEOL,endRule:this.endRule,nameScopesList:this.nameScopesList?.getExtensionIfDefined(this.parent?.nameScopesList??null)??[],contentNameScopesList:this.contentNameScopesList?.getExtensionIfDefined(this.nameScopesList)??[]}}static pushFrame(t,a){let o=Vt.fromExtension(t?.nameScopesList??null,a.nameScopesList);return new nt(t,a.ruleId,a.enterPos??-1,a.anchorPos??-1,a.beginRuleCapturedEOL,a.endRule,o,Vt.fromExtension(o,a.contentNameScopesList))}},mc=class{balancedBracketScopes;unbalancedBracketScopes;allowAny=!1;constructor(e,t){this.balancedBracketScopes=e.flatMap(a=>a==="*"?(this.allowAny=!0,[]):Pa(a,Ra).map(o=>o.matcher)),this.unbalancedBracketScopes=t.flatMap(a=>Pa(a,Ra).map(o=>o.matcher))}get matchesAlways(){return this.allowAny&&this.unbalancedBracketScopes.length===0}get matchesNever(){return this.balancedBracketScopes.length===0&&!this.allowAny}match(e){for(let t of this.unbalancedBracketScopes)if(t(e))return!1;for(let t of this.balancedBracketScopes)if(t(e))return!0;return this.allowAny}},hc=class{constructor(e,t,a,o){this.balancedBracketSelectors=o,this._emitBinaryTokens=e,this._tokenTypeOverrides=a,this._lineText=null,this._tokens=[],this._binaryTokens=[],this._lastTokenEndIndex=0}_emitBinaryTokens;_lineText;_tokens;_binaryTokens;_lastTokenEndIndex;_tokenTypeOverrides;produce(e,t){this.produceFromScopes(e.contentNameScopesList,t)}produceFromScopes(e,t){if(this._lastTokenEndIndex>=t)return;if(this._emitBinaryTokens){let o=e?.tokenAttributes??0,r=!1;if(this.balancedBracketSelectors?.matchesAlways&&(r=!0),this._tokenTypeOverrides.length>0||this.balancedBracketSelectors&&!this.balancedBracketSelectors.matchesAlways&&!this.balancedBracketSelectors.matchesNever){let s=e?.getScopeNames()??[];for(let n of this._tokenTypeOverrides)n.matcher(s)&&(o=it.set(o,0,n.type,null,-1,0,0));this.balancedBracketSelectors&&(r=this.balancedBracketSelectors.match(s))}if(r&&(o=it.set(o,0,8,r,-1,0,0)),this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-1]===o){this._lastTokenEndIndex=t;return}this._binaryTokens.push(this._lastTokenEndIndex),this._binaryTokens.push(o),this._lastTokenEndIndex=t;return}let a=e?.getScopeNames()??[];this._tokens.push({startIndex:this._lastTokenEndIndex,endIndex:t,scopes:a}),this._lastTokenEndIndex=t}getResult(e,t){return this._tokens.length>0&&this._tokens[this._tokens.length-1].startIndex===t-1&&this._tokens.pop(),this._tokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._tokens[this._tokens.length-1].startIndex=0),this._tokens}getBinaryResult(e,t){this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-2]===t-1&&(this._binaryTokens.pop(),this._binaryTokens.pop()),this._binaryTokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._binaryTokens[this._binaryTokens.length-2]=0);let a=new Uint32Array(this._binaryTokens.length);for(let o=0,r=this._binaryTokens.length;o<r;o++)a[o]=this._binaryTokens[o];return a}},gc=class{constructor(e,t){this._onigLib=t,this._theme=e}_grammars=new Map;_rawGrammars=new Map;_injectionGrammars=new Map;_theme;dispose(){for(let e of this._grammars.values())e.dispose()}setTheme(e){this._theme=e}getColorMap(){return this._theme.getColorMap()}addGrammar(e,t){this._rawGrammars.set(e.scopeName,e),t&&this._injectionGrammars.set(e.scopeName,t)}lookup(e){return this._rawGrammars.get(e)}injections(e){return this._injectionGrammars.get(e)}getDefaults(){return this._theme.getDefaults()}themeMatch(e){return this._theme.match(e)}grammarForScopeName(e,t,a,o,r){if(!this._grammars.has(e)){let s=this._rawGrammars.get(e);if(!s)return null;this._grammars.set(e,cc(e,s,t,a,o,r,this,this._onigLib))}return this._grammars.get(e)}},Nn=class{_options;_syncRegistry;_ensureGrammarCache;constructor(e){this._options=e,this._syncRegistry=new gc($t.createFromRawTheme(e.theme,e.colorMap),e.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(e,t){this._syncRegistry.setTheme($t.createFromRawTheme(e,t))}getColorMap(){return this._syncRegistry.getColorMap()}loadGrammarWithEmbeddedLanguages(e,t,a){return this.loadGrammarWithConfiguration(e,t,{embeddedLanguages:a})}loadGrammarWithConfiguration(e,t,a){return this._loadGrammar(e,t,a.embeddedLanguages,a.tokenTypes,new mc(a.balancedBracketSelectors||[],a.unbalancedBracketSelectors||[]))}loadGrammar(e){return this._loadGrammar(e,0,null,null,null)}_loadGrammar(e,t,a,o,r){let s=new Vd(this._syncRegistry,e);for(;s.Q.length>0;)s.Q.map(n=>this._loadSingleGrammar(n.scopeName)),s.processQueue();return this._grammarForScopeName(e,t,a,o,r)}_loadSingleGrammar(e){this._ensureGrammarCache.has(e)||(this._doLoadSingleGrammar(e),this._ensureGrammarCache.set(e,!0))}_doLoadSingleGrammar(e){let t=this._options.loadGrammar(e);if(t){let a=typeof this._options.getInjections=="function"?this._options.getInjections(e):void 0;this._syncRegistry.addGrammar(t,a)}}addGrammar(e,t=[],a=0,o=null){return this._syncRegistry.addGrammar(e,t),this._grammarForScopeName(e.scopeName,a,o)}_grammarForScopeName(e,t=0,a=null,o=null,r=null){return this._syncRegistry.grammarForScopeName(e,t,a,o,r)}},Ma=Eo.NULL;f();f();f();f();f();f();var wc=/["&'<>`]/g,xc=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,Lc=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,Cc=/[|\\{}()[\]^$+*?.]/g,On=new WeakMap;function Un(e,t){if(e=e.replace(t.subset?Ic(t.subset):wc,o),t.subset||t.escapeOnly)return e;return e.replace(xc,a).replace(Lc,o);function a(r,s,n){return t.format((r.charCodeAt(0)-55296)*1024+r.charCodeAt(1)-56320+65536,n.charCodeAt(s+2),t)}function o(r,s,n){return t.format(r.charCodeAt(0),n.charCodeAt(s+1),t)}}function Ic(e){let t=On.get(e);return t||(t=Sc(e),On.set(e,t)),t}function Sc(e){let t=[],a=-1;for(;++a<e.length;)t.push(e[a].replace(Cc,"\\$&"));return new RegExp("(?:"+t.join("|")+")","g")}f();f();var yc=/[\dA-Fa-f]/;function Hn(e,t,a){let o="&#x"+e.toString(16).toUpperCase();return a&&t&&!yc.test(String.fromCharCode(t))?o:o+";"}f();var kc=/\d/;function qn(e,t,a){let o="&#"+String(e);return a&&t&&!kc.test(String.fromCharCode(t))?o:o+";"}f();f();var Wn=["AElig","AMP","Aacute","Acirc","Agrave","Aring","Atilde","Auml","COPY","Ccedil","ETH","Eacute","Ecirc","Egrave","Euml","GT","Iacute","Icirc","Igrave","Iuml","LT","Ntilde","Oacute","Ocirc","Ograve","Oslash","Otilde","Ouml","QUOT","REG","THORN","Uacute","Ucirc","Ugrave","Uuml","Yacute","aacute","acirc","acute","aelig","agrave","amp","aring","atilde","auml","brvbar","ccedil","cedil","cent","copy","curren","deg","divide","eacute","ecirc","egrave","eth","euml","frac12","frac14","frac34","gt","iacute","icirc","iexcl","igrave","iquest","iuml","laquo","lt","macr","micro","middot","nbsp","not","ntilde","oacute","ocirc","ograve","ordf","ordm","oslash","otilde","ouml","para","plusmn","pound","quot","raquo","reg","sect","shy","sup1","sup2","sup3","szlig","thorn","times","uacute","ucirc","ugrave","uml","uuml","yacute","yen","yuml"];f();var Fa={nbsp:"\xA0",iexcl:"\xA1",cent:"\xA2",pound:"\xA3",curren:"\xA4",yen:"\xA5",brvbar:"\xA6",sect:"\xA7",uml:"\xA8",copy:"\xA9",ordf:"\xAA",laquo:"\xAB",not:"\xAC",shy:"\xAD",reg:"\xAE",macr:"\xAF",deg:"\xB0",plusmn:"\xB1",sup2:"\xB2",sup3:"\xB3",acute:"\xB4",micro:"\xB5",para:"\xB6",middot:"\xB7",cedil:"\xB8",sup1:"\xB9",ordm:"\xBA",raquo:"\xBB",frac14:"\xBC",frac12:"\xBD",frac34:"\xBE",iquest:"\xBF",Agrave:"\xC0",Aacute:"\xC1",Acirc:"\xC2",Atilde:"\xC3",Auml:"\xC4",Aring:"\xC5",AElig:"\xC6",Ccedil:"\xC7",Egrave:"\xC8",Eacute:"\xC9",Ecirc:"\xCA",Euml:"\xCB",Igrave:"\xCC",Iacute:"\xCD",Icirc:"\xCE",Iuml:"\xCF",ETH:"\xD0",Ntilde:"\xD1",Ograve:"\xD2",Oacute:"\xD3",Ocirc:"\xD4",Otilde:"\xD5",Ouml:"\xD6",times:"\xD7",Oslash:"\xD8",Ugrave:"\xD9",Uacute:"\xDA",Ucirc:"\xDB",Uuml:"\xDC",Yacute:"\xDD",THORN:"\xDE",szlig:"\xDF",agrave:"\xE0",aacute:"\xE1",acirc:"\xE2",atilde:"\xE3",auml:"\xE4",aring:"\xE5",aelig:"\xE6",ccedil:"\xE7",egrave:"\xE8",eacute:"\xE9",ecirc:"\xEA",euml:"\xEB",igrave:"\xEC",iacute:"\xED",icirc:"\xEE",iuml:"\xEF",eth:"\xF0",ntilde:"\xF1",ograve:"\xF2",oacute:"\xF3",ocirc:"\xF4",otilde:"\xF5",ouml:"\xF6",divide:"\xF7",oslash:"\xF8",ugrave:"\xF9",uacute:"\xFA",ucirc:"\xFB",uuml:"\xFC",yacute:"\xFD",thorn:"\xFE",yuml:"\xFF",fnof:"\u0192",Alpha:"\u0391",Beta:"\u0392",Gamma:"\u0393",Delta:"\u0394",Epsilon:"\u0395",Zeta:"\u0396",Eta:"\u0397",Theta:"\u0398",Iota:"\u0399",Kappa:"\u039A",Lambda:"\u039B",Mu:"\u039C",Nu:"\u039D",Xi:"\u039E",Omicron:"\u039F",Pi:"\u03A0",Rho:"\u03A1",Sigma:"\u03A3",Tau:"\u03A4",Upsilon:"\u03A5",Phi:"\u03A6",Chi:"\u03A7",Psi:"\u03A8",Omega:"\u03A9",alpha:"\u03B1",beta:"\u03B2",gamma:"\u03B3",delta:"\u03B4",epsilon:"\u03B5",zeta:"\u03B6",eta:"\u03B7",theta:"\u03B8",iota:"\u03B9",kappa:"\u03BA",lambda:"\u03BB",mu:"\u03BC",nu:"\u03BD",xi:"\u03BE",omicron:"\u03BF",pi:"\u03C0",rho:"\u03C1",sigmaf:"\u03C2",sigma:"\u03C3",tau:"\u03C4",upsilon:"\u03C5",phi:"\u03C6",chi:"\u03C7",psi:"\u03C8",omega:"\u03C9",thetasym:"\u03D1",upsih:"\u03D2",piv:"\u03D6",bull:"\u2022",hellip:"\u2026",prime:"\u2032",Prime:"\u2033",oline:"\u203E",frasl:"\u2044",weierp:"\u2118",image:"\u2111",real:"\u211C",trade:"\u2122",alefsym:"\u2135",larr:"\u2190",uarr:"\u2191",rarr:"\u2192",darr:"\u2193",harr:"\u2194",crarr:"\u21B5",lArr:"\u21D0",uArr:"\u21D1",rArr:"\u21D2",dArr:"\u21D3",hArr:"\u21D4",forall:"\u2200",part:"\u2202",exist:"\u2203",empty:"\u2205",nabla:"\u2207",isin:"\u2208",notin:"\u2209",ni:"\u220B",prod:"\u220F",sum:"\u2211",minus:"\u2212",lowast:"\u2217",radic:"\u221A",prop:"\u221D",infin:"\u221E",ang:"\u2220",and:"\u2227",or:"\u2228",cap:"\u2229",cup:"\u222A",int:"\u222B",there4:"\u2234",sim:"\u223C",cong:"\u2245",asymp:"\u2248",ne:"\u2260",equiv:"\u2261",le:"\u2264",ge:"\u2265",sub:"\u2282",sup:"\u2283",nsub:"\u2284",sube:"\u2286",supe:"\u2287",oplus:"\u2295",otimes:"\u2297",perp:"\u22A5",sdot:"\u22C5",lceil:"\u2308",rceil:"\u2309",lfloor:"\u230A",rfloor:"\u230B",lang:"\u2329",rang:"\u232A",loz:"\u25CA",spades:"\u2660",clubs:"\u2663",hearts:"\u2665",diams:"\u2666",quot:'"',amp:"&",lt:"<",gt:">",OElig:"\u0152",oelig:"\u0153",Scaron:"\u0160",scaron:"\u0161",Yuml:"\u0178",circ:"\u02C6",tilde:"\u02DC",ensp:"\u2002",emsp:"\u2003",thinsp:"\u2009",zwnj:"\u200C",zwj:"\u200D",lrm:"\u200E",rlm:"\u200F",ndash:"\u2013",mdash:"\u2014",lsquo:"\u2018",rsquo:"\u2019",sbquo:"\u201A",ldquo:"\u201C",rdquo:"\u201D",bdquo:"\u201E",dagger:"\u2020",Dagger:"\u2021",permil:"\u2030",lsaquo:"\u2039",rsaquo:"\u203A",euro:"\u20AC"};f();var Gn=["cent","copy","divide","gt","lt","not","para","times"];var jn={}.hasOwnProperty,No={},Da;for(Da in Fa)jn.call(Fa,Da)&&(No[Fa[Da]]=Da);var bc=/[^\dA-Za-z]/;function zn(e,t,a,o){let r=String.fromCharCode(e);if(jn.call(No,r)){let s=No[r],n="&"+s;return a&&Wn.includes(s)&&!Gn.includes(s)&&(!o||t&&t!==61&&bc.test(String.fromCharCode(t)))?n:n+";"}return""}function Vn(e,t,a){let o=Hn(e,t,a.omitOptionalSemicolons),r;if((a.useNamedReferences||a.useShortestReferences)&&(r=zn(e,t,a.omitOptionalSemicolons,a.attribute)),(a.useShortestReferences||!r)&&a.useShortestReferences){let s=qn(e,t,a.omitOptionalSemicolons);s.length<o.length&&(o=s)}return r&&(!a.useShortestReferences||r.length<o.length)?r:o}function We(e,t){return Un(e,Object.assign({format:Vn},t))}var Tc=/^>|^->|<!--|-->|--!>|<!-$/g,Pc=[">"],vc=["<",">"];function $n(e,t,a,o){return o.settings.bogusComments?"<?"+We(e.value,Object.assign({},o.settings.characterReferences,{subset:Pc}))+">":"<!--"+e.value.replace(Tc,r)+"-->";function r(s){return We(s,Object.assign({},o.settings.characterReferences,{subset:vc}))}}f();function Xn(e,t,a,o){return"<!"+(o.settings.upperDoctype?"DOCTYPE":"doctype")+(o.settings.tightDoctype?"":" ")+"html>"}f();f();f();var ae=Kn(1),Oo=Kn(-1),Ac=[];function Kn(e){return t;function t(a,o,r){let s=a?a.children:Ac,n=(o||0)+e,l=s[n];if(!r)for(;l&&ht(l);)n+=e,l=s[n];return l}}f();var Rc={}.hasOwnProperty;function Ba(e){return t;function t(a,o,r){return Rc.call(e,a.tagName)&&e[a.tagName](a,o,r)}}var Zt=Ba({body:Fc,caption:Uo,colgroup:Uo,dd:_c,dt:Ec,head:Uo,html:Mc,li:Bc,optgroup:Nc,option:Oc,p:Dc,rp:Qn,rt:Qn,tbody:Hc,td:Jn,tfoot:qc,th:Jn,thead:Uc,tr:Wc});function Uo(e,t,a){let o=ae(a,t,!0);return!o||o.type!=="comment"&&!(o.type==="text"&&ht(o.value.charAt(0)))}function Mc(e,t,a){let o=ae(a,t);return!o||o.type!=="comment"}function Fc(e,t,a){let o=ae(a,t);return!o||o.type!=="comment"}function Dc(e,t,a){let o=ae(a,t);return o?o.type==="element"&&(o.tagName==="address"||o.tagName==="article"||o.tagName==="aside"||o.tagName==="blockquote"||o.tagName==="details"||o.tagName==="div"||o.tagName==="dl"||o.tagName==="fieldset"||o.tagName==="figcaption"||o.tagName==="figure"||o.tagName==="footer"||o.tagName==="form"||o.tagName==="h1"||o.tagName==="h2"||o.tagName==="h3"||o.tagName==="h4"||o.tagName==="h5"||o.tagName==="h6"||o.tagName==="header"||o.tagName==="hgroup"||o.tagName==="hr"||o.tagName==="main"||o.tagName==="menu"||o.tagName==="nav"||o.tagName==="ol"||o.tagName==="p"||o.tagName==="pre"||o.tagName==="section"||o.tagName==="table"||o.tagName==="ul"):!a||!(a.type==="element"&&(a.tagName==="a"||a.tagName==="audio"||a.tagName==="del"||a.tagName==="ins"||a.tagName==="map"||a.tagName==="noscript"||a.tagName==="video"))}function Bc(e,t,a){let o=ae(a,t);return!o||o.type==="element"&&o.tagName==="li"}function Ec(e,t,a){let o=ae(a,t);return!!(o&&o.type==="element"&&(o.tagName==="dt"||o.tagName==="dd"))}function _c(e,t,a){let o=ae(a,t);return!o||o.type==="element"&&(o.tagName==="dt"||o.tagName==="dd")}function Qn(e,t,a){let o=ae(a,t);return!o||o.type==="element"&&(o.tagName==="rp"||o.tagName==="rt")}function Nc(e,t,a){let o=ae(a,t);return!o||o.type==="element"&&o.tagName==="optgroup"}function Oc(e,t,a){let o=ae(a,t);return!o||o.type==="element"&&(o.tagName==="option"||o.tagName==="optgroup")}function Uc(e,t,a){let o=ae(a,t);return!!(o&&o.type==="element"&&(o.tagName==="tbody"||o.tagName==="tfoot"))}function Hc(e,t,a){let o=ae(a,t);return!o||o.type==="element"&&(o.tagName==="tbody"||o.tagName==="tfoot")}function qc(e,t,a){return!ae(a,t)}function Wc(e,t,a){let o=ae(a,t);return!o||o.type==="element"&&o.tagName==="tr"}function Jn(e,t,a){let o=ae(a,t);return!o||o.type==="element"&&(o.tagName==="td"||o.tagName==="th")}f();var Zn=Ba({body:zc,colgroup:Vc,head:jc,html:Gc,tbody:$c});function Gc(e){let t=ae(e,-1);return!t||t.type!=="comment"}function jc(e){let t=new Set;for(let o of e.children)if(o.type==="element"&&(o.tagName==="base"||o.tagName==="title")){if(t.has(o.tagName))return!1;t.add(o.tagName)}let a=e.children[0];return!a||a.type==="element"}function zc(e){let t=ae(e,-1,!0);return!t||t.type!=="comment"&&!(t.type==="text"&&ht(t.value.charAt(0)))&&!(t.type==="element"&&(t.tagName==="meta"||t.tagName==="link"||t.tagName==="script"||t.tagName==="style"||t.tagName==="template"))}function Vc(e,t,a){let o=Oo(a,t),r=ae(e,-1,!0);return a&&o&&o.type==="element"&&o.tagName==="colgroup"&&Zt(o,a.children.indexOf(o),a)?!1:!!(r&&r.type==="element"&&r.tagName==="col")}function $c(e,t,a){let o=Oo(a,t),r=ae(e,-1);return a&&o&&o.type==="element"&&(o.tagName==="thead"||o.tagName==="tbody")&&Zt(o,a.children.indexOf(o),a)?!1:!!(r&&r.type==="element"&&r.tagName==="tr")}var Ea={name:[[`
|
|
68
|
+
`):e}function gs(e){let{apiKey:t,apiUrl:a,source:o,systemPrompt:r,maxSteps:s,beforeRequest:n,mcpServerUrl:l,resolveConfig:i,debug:u,webSearch:c}=e,d=Be("chat",u);return async function(m){d("\u2192 POST",m.url);try{let h=await m.json(),I=h.messages??[],L=h.sessionId,S=h.modelContext,C=r,g=typeof h.extra=="object"&&h.extra!==null&&!Array.isArray(h.extra)?h.extra:void 0,b=h.visitorContext??null,T=ms(m),P={geo:T,client:b};if(d("body parsed \u2014 messages:",I.length,"sessionId:",L??"(none)","geo:",JSON.stringify(T)),n){d("running beforeRequest hook");try{let M=await n({messages:I,sessionId:L,modelContext:S,request:m,visitor:P});M&&(M.messages&&(I=M.messages),M.systemPrompt!==void 0&&(C=M.systemPrompt),M.sessionId!==void 0&&(L=M.sessionId),M.modelContext!==void 0&&(S=M.modelContext)),d("beforeRequest hook done \u2014 messages:",I.length,"sessionId:",L??"(none)")}catch(M){console.error("[waniwani:chat] beforeRequest hook error:",M);let O=M instanceof Ie?M.status:400,F=M instanceof Error?M.message:"Request rejected";return d("\u2190 returning",O,"from hook error"),Response.json({error:F},{status:O})}}let R=l??(await i()).mcpServerUrl;d("mcpServerUrl:",R),C=hs(C,S);let v=`${a}/api/mcp/chat`;d("forwarding to",v);let _=m.headers.get("user-agent"),A=await fetch(v,{method:"POST",headers:{"Content-Type":"application/json","X-WaniWani-Stream-Protocol":"2",...t?{Authorization:`Bearer ${t}`}:{},..._?{"X-Client-User-Agent":_}:{}},body:JSON.stringify({messages:I,mcpServerUrl:R,sessionId:L,source:o,systemPrompt:C,maxSteps:s,visitor:P,webSearch:c,...g&&{extra:g}}),signal:m.signal});if(d("upstream response status:",A.status),!A.ok){let M=await A.text().catch(()=>"");return d("\u2190 returning",A.status,"upstream error:",M),new Response(M,{status:A.status,headers:{"Content-Type":A.headers.get("Content-Type")??"application/json"}})}let E=new Headers({"Content-Type":A.headers.get("Content-Type")??"text/event-stream"}),y=A.headers.get("x-session-id");return y&&E.set("x-session-id",y),d("\u2190 streaming response",A.status,"body null?",A.body===null),new Response(A.body,{status:A.status,headers:E})}catch(h){console.error("[waniwani:chat] handler error:",h);let I=h instanceof Error?h.message:"Unknown error occurred",L=h instanceof Ie?h.status:500;return d("\u2190 returning",L,"from caught error"),Response.json({error:I},{status:L})}}}f();function ws(e){let{mcpServerUrl:t,resolveConfig:a,debug:o}=e,r=Be("resource",o);return async function(n){r("\u2192 GET",n.toString());try{let l=n.searchParams.get("uri");if(r("uri:",l??"(missing)"),!l)return r("\u2190 400 missing uri"),Response.json({error:"Missing uri query parameter"},{status:400});let i=t??(await a()).mcpServerUrl;r("mcpServerUrl:",i);let u,c;try{[{createMCPClient:u},{StreamableHTTPClientTransport:c}]=await Promise.all([import("@ai-sdk/mcp"),import("@modelcontextprotocol/sdk/client/streamableHttp.js")]),r("MCP deps loaded")}catch(p){return console.error("[waniwani:resource] MCP deps import failed:",p),Response.json({error:"MCP resource handler requires @ai-sdk/mcp and @modelcontextprotocol/sdk. Install them to enable resource serving."},{status:501})}r("creating MCP client for",i);let d=await u({transport:new c(new URL(i))});try{r("reading resource:",l);let p=await d.readResource({uri:l});r("resource contents count:",p.contents.length);let m=p.contents[0];if(!m)return r("\u2190 404 resource not found"),Response.json({error:"Resource not found"},{status:404});let h;return"text"in m&&typeof m.text=="string"?h=m.text:"blob"in m&&typeof m.blob=="string"&&(h=atob(m.blob)),h?(r("\u2190 200 HTML length:",h.length),new Response(h,{headers:{"Content-Type":"text/html","Cache-Control":"private, max-age=300"}})):(r("\u2190 404 resource has no content, keys:",Object.keys(m)),Response.json({error:"Resource has no content"},{status:404}))}finally{await d.close(),r("MCP client closed")}}catch(l){console.error("[waniwani:resource] handler error:",l);let i=l instanceof Error?l.message:"Unknown error occurred",u=l instanceof Ie?l.status:500;return r("\u2190 returning",u,"from caught error"),Response.json({error:i},{status:u})}}}f();function xs(e){let{mcpServerUrl:t,resolveConfig:a,debug:o,source:r}=e,s=Be("tool",o);return async function(l){s("\u2192 POST",l.url);try{let i=await l.json(),{name:u,arguments:c}=i,d=l.headers.get("x-session-id")?.trim();if(!u||typeof u!="string")return s("\u2190 400 missing tool name"),Response.json({error:"Missing tool name"},{status:400});s("tool:",u,"args:",JSON.stringify(c),"sessionId:",d||"(none)");let p=t??(await a()).mcpServerUrl;s("mcpServerUrl:",p);let m,h;try{[{Client:m},{StreamableHTTPClientTransport:h}]=await Promise.all([import("@modelcontextprotocol/sdk/client/index.js"),import("@modelcontextprotocol/sdk/client/streamableHttp.js")]),s("MCP deps loaded")}catch(S){return console.error("[waniwani:tool] MCP deps import failed:",S),Response.json({error:"MCP tool handler requires @modelcontextprotocol/sdk. Install it to enable tool calls."},{status:501})}s("creating MCP client for",p);let I=new h(new URL(p)),L=new m({name:"waniwani-tool-caller",version:"1.0.0"});await L.connect(I);try{s("calling tool:",u);let S={};d&&(S["waniwani/sessionId"]=d),r&&(S["waniwani/source"]=r);let C=await L.callTool({name:u,arguments:c??{},...Object.keys(S).length>0?{_meta:S}:{}});return s("tool result received"),Response.json({content:C.content,structuredContent:C.structuredContent,_meta:C._meta,isError:C.isError})}finally{await L.close(),s("MCP client closed")}}catch(i){console.error("[waniwani:tool] handler error:",i);let u=i instanceof Error?i.message:"Unknown error occurred",c=i instanceof Ie?i.status:500;return s("\u2190 returning",c,"from caught error"),Response.json({error:u},{status:c})}}}f();function Ls(e){let{mcpServerUrl:t,resolveConfig:a,debug:o}=e,r=Be("tools-list",o);return async function(){r("\u2192 GET tools/list");try{let n=t??(await a()).mcpServerUrl;r("mcpServerUrl:",n);let l,i;try{[{createMCPClient:l},{StreamableHTTPClientTransport:i}]=await Promise.all([import("@ai-sdk/mcp"),import("@modelcontextprotocol/sdk/client/streamableHttp.js")]),r("MCP deps loaded")}catch(c){return console.error("[waniwani:tools-list] MCP deps import failed:",c),Response.json({error:"MCP tools list handler requires @ai-sdk/mcp and @modelcontextprotocol/sdk. Install them to enable tool discovery."},{status:501})}r("creating MCP client for",n);let u=await l({transport:new i(new URL(n))});try{r("listing tools");let c=await u.listTools();r("tools count:",c.tools.length);let d={tools:c.tools.map(p=>({name:p.name,...p.title!==void 0&&{title:p.title},...p.description!==void 0&&{description:p.description},...p.inputSchema!==void 0&&{inputSchema:p.inputSchema},...p.outputSchema!==void 0&&{outputSchema:p.outputSchema},...p.annotations!==void 0&&{annotations:p.annotations},...p._meta!==void 0&&{_meta:p._meta}})),...c.nextCursor!==void 0&&{nextCursor:c.nextCursor}};return r("\u2190 200"),Response.json(d,{headers:{"Cache-Control":"private, max-age=60"}})}finally{await u.close(),r("MCP client closed")}}catch(n){console.error("[waniwani:tools-list] handler error:",n);let l=n instanceof Error?n.message:"Unknown error occurred",i=n instanceof Ie?n.status:500;return r("\u2190 returning",i,"from caught error"),Response.json({error:l},{status:i})}}}f();var Bu=300*1e3;function Cs(e,t){let a=null,o=null;return async function(){if(a&&Date.now()<a.expiresAt)return a.config;if(o)return o;o=(async()=>{if(!t)throw new Ie("WANIWANI_API_KEY is required for createChatHandler",401);let s=await fetch(`${e}/api/mcp/environments/config`,{method:"GET",headers:{Authorization:`Bearer ${t}`,"Content-Type":"application/json"}});if(!s.ok){let l=await s.text().catch(()=>"");throw new Ie(`Failed to resolve MCP environment config: ${s.status} ${l}`,s.status)}let n=await s.json();return a={config:n,expiresAt:Date.now()+Bu},n})();try{return await o}finally{o=null}}}var Eu="https://app.waniwani.ai";function Is(e={}){let{apiKey:t=process.env.WANIWANI_API_KEY,apiUrl:a=Eu,source:o,systemPrompt:r,maxSteps:s=5,beforeRequest:n,mcpServerUrl:l,debug:i=!1,webSearch:u}=e,c=Be("router",i),d=fs(),p=ps(d),m=Cs(a,t),h=gs({apiKey:t,apiUrl:a,source:o,systemPrompt:r,maxSteps:s,beforeRequest:n,mcpServerUrl:l,resolveConfig:m,debug:i,webSearch:cs(u)}),I=ws({mcpServerUrl:l,resolveConfig:m,debug:i}),L=Ls({mcpServerUrl:l,resolveConfig:m,debug:i}),S=xs({mcpServerUrl:l,resolveConfig:m,debug:i,source:o}),C=process.env.WANIWANI_EVAL==="1";async function g(R){c("\u2192 GET",R.url);try{let v=new URL(R.url),A=v.pathname.replace(/\/$/,"").split("/").filter(Boolean).at(-1);if(c("pathname:",v.pathname,"subRoute:",A),C&&A==="scenarios"){c("dispatching to scenarios handler (proxy to app API)");try{let y=await(await fetch(`${a}/api/mcp/scenarios`,{headers:{...t?{Authorization:`Bearer ${t}`}:{}}})).json();return p(y.data??y,200)}catch{return p([],200)}}if(A==="resource"){c("dispatching to resource handler");let E=await I(v);return c("\u2190 resource handler returned",E.status),d(E)}if(A==="config")return c("dispatching to config handler"),p({debug:i,eval:C},200);if(A==="tools"){c("dispatching to tools-list handler");let E=await L();return c("\u2190 tools-list handler returned",E.status),d(E)}return c("\u2190 404 no matching sub-route for",A),p({error:"Not found"},404)}catch(v){console.error("[waniwani:router] GET handler error:",v);let _=v instanceof Error?v.message:"Unknown error occurred";return c("\u2190 500 from caught error"),p({error:_},500)}}async function b(R){c("\u2192 POST",R.url);try{let v=new URL(R.url),A=v.pathname.replace(/\/$/,"").split("/").filter(Boolean).at(-1);if(c("pathname:",v.pathname,"subRoute:",A),C&&A==="scenarios"){c("dispatching to save-scenario handler (proxy to app API)");try{let y=await R.json(),M=await fetch(`${a}/api/mcp/scenarios`,{method:"POST",headers:{"Content-Type":"application/json",...t?{Authorization:`Bearer ${t}`}:{}},body:JSON.stringify(y)}),O=await M.json();return M.ok?p({ok:!0,scenario:O.data},200):p({error:O.message??"Failed to save scenario"},M.status)}catch(y){let M=y instanceof Error?y.message:"Failed to save scenario";return p({error:M},400)}}if(A==="tool"){c("dispatching to tool handler");let y=await S(R);return c("\u2190 tool handler returned",y.status),d(y)}c("dispatching to chat handler");let E=await h(R);return d(E)}catch(v){console.error("[waniwani:router] POST handler error:",v);let _=v instanceof Error?v.message:"Unknown error occurred";return c("\u2190 500 from caught error"),p({error:_},500)}}async function T(R){c("\u2192 PATCH",R.url);try{let v=new URL(R.url),_=v.pathname.replace(/\/$/,"").split("/").filter(Boolean),A=_.at(-1),E=_.at(-2);if(c("pathname:",v.pathname,"subRoute:",E,"id:",A),C&&E==="scenarios"&&A){c("dispatching to update-scenario handler (proxy to app API)");try{let y=await R.json(),M=await fetch(`${a}/api/mcp/scenarios/${A}`,{method:"PATCH",headers:{"Content-Type":"application/json",...t?{Authorization:`Bearer ${t}`}:{}},body:JSON.stringify(y)}),O=await M.json();return M.ok?p({ok:!0,scenario:O.data},200):p({error:O.message??"Failed to update scenario"},M.status)}catch(y){let M=y instanceof Error?y.message:"Failed to update scenario";return p({error:M},400)}}return c("\u2190 404 no matching sub-route for PATCH",E),p({error:"Not found"},404)}catch(v){console.error("[waniwani:router] PATCH handler error:",v);let _=v instanceof Error?v.message:"Unknown error occurred";return c("\u2190 500 from caught error"),p({error:_},500)}}function P(){return d(new Response(null,{status:204}))}return{handleChat:h,handleResource:I,handleTool:S,routeGet:g,routePost:b,routePatch:T,handleOptions:P}}var Ss=!1;function mx(e,t){!Ss&&process.env.NODE_ENV!=="test"&&(console.warn("[waniwani-sdk] toNextJsHandler is deprecated; switch to toExpressJsHandler from @waniwani/sdk/express-js. It will be removed in a follow-up release."),Ss=!0);let{apiKey:a,apiUrl:o}=e._config,r=t?.debug??process.env.WANIWANI_DEBUG==="1",s=Is({...t?.chat,apiKey:a,apiUrl:o,source:t?.source,debug:r});return{POST:s.routePost,GET:s.routeGet,PATCH:s.routePatch,OPTIONS:()=>s.handleOptions()}}f();import{forwardRef as Ym,useCallback as wr,useEffect as eh,useImperativeHandle as th,useRef as Fl,useState as Dl}from"react";f();f();f();import{forwardRef as Nu,createElement as Uu}from"react";f();var ga=(...e)=>e.filter((t,a,o)=>!!t&&t.trim()!==""&&o.indexOf(t)===a).join(" ").trim();f();var ys=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();f();f();var bs=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,a,o)=>o?o.toUpperCase():a.toLowerCase());var xo=e=>{let t=bs(e);return t.charAt(0).toUpperCase()+t.slice(1)};f();import{forwardRef as _u,createElement as Ps}from"react";f();var ks={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"};f();var Ts=e=>{for(let t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};var vs=_u(({color:e="currentColor",size:t=24,strokeWidth:a=2,absoluteStrokeWidth:o,className:r="",children:s,iconNode:n,...l},i)=>Ps("svg",{ref:i,...ks,width:t,height:t,stroke:e,strokeWidth:o?Number(a)*24/Number(t):a,className:ga("lucide",r),...!s&&!Ts(l)&&{"aria-hidden":"true"},...l},[...n.map(([u,c])=>Ps(u,c)),...Array.isArray(s)?s:[s]]));var J=(e,t)=>{let a=Nu(({className:o,...r},s)=>Uu(vs,{ref:s,iconNode:t,className:ga(`lucide-${ys(xo(e))}`,`lucide-${e}`,o),...r}));return a.displayName=xo(e),a};f();var Ou=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Ft=J("arrow-down",Ou);f();var Hu=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Dt=J("arrow-up",Hu);f();var qu=[["path",{d:"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1",key:"ezmyqa"}],["path",{d:"M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1",key:"e1hn23"}]],$e=J("braces",qu);f();var Wu=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Bt=J("check",Wu);f();var Gu=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Et=J("chevron-down",Gu);f();var ju=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],_t=J("chevron-right",ju);f();var zu=[["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"}]],Nt=J("clipboard-copy",zu);f();var Vu=[["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"}]],Ut=J("file",Vu);f();var $u=[["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"}]],Ot=J("loader",$u);f();var Xu=[["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"}]],Ht=J("paperclip",Xu);f();var Ku=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],qt=J("square",Ku);f();var Qu=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],tt=J("x",Qu);import{useCallback as pd}from"react";f();import{useCallback as Xe,useMemo as Ju,useRef as Zu,useState as Lo}from"react";var Yu={damping:.7,stiffness:.05,mass:1.25},ed=70,td=1e3/60,ad=350,wa=!1;globalThis.document?.addEventListener("mousedown",()=>{wa=!0});globalThis.document?.addEventListener("mouseup",()=>{wa=!1});globalThis.document?.addEventListener("click",()=>{wa=!1});var Rs=(e={})=>{let[t,a]=Lo(!1),[o,r]=Lo(e.initial!==!1),[s,n]=Lo(!1),l=Zu(null);l.current=e;let i=Xe(()=>{if(!wa)return!1;let C=window.getSelection();if(!C||!C.rangeCount)return!1;let g=C.getRangeAt(0);return g.commonAncestorContainer.contains(L.current)||L.current?.contains(g.commonAncestorContainer)},[]),u=Xe(C=>{d.isAtBottom=C,r(C)},[]),c=Xe(C=>{d.escapedFromLock=C,a(C)},[]),d=Ju(()=>{let C;return{escapedFromLock:t,isAtBottom:o,resizeDifference:0,accumulated:0,velocity:0,listeners:new Set,get scrollTop(){return L.current?.scrollTop??0},set scrollTop(g){L.current&&(L.current.scrollTop=g,d.ignoreScrollToTop=L.current.scrollTop)},get targetScrollTop(){return!L.current||!S.current?0:L.current.scrollHeight-1-L.current.clientHeight},get calculatedTargetScrollTop(){if(!L.current||!S.current)return 0;let{targetScrollTop:g}=this;if(!e.targetScrollTop)return g;if(C?.targetScrollTop===g)return C.calculatedScrollTop;let b=Math.max(Math.min(e.targetScrollTop(g,{scrollElement:L.current,contentElement:S.current}),g),0);return C={targetScrollTop:g,calculatedScrollTop:b},requestAnimationFrame(()=>{C=void 0}),b},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=ed}}},[]),p=Xe((C={})=>{typeof C=="string"&&(C={animation:C}),C.preserveScrollPosition||u(!0);let g=Date.now()+(Number(C.wait)||0),b=Io(l.current,C.animation),{ignoreEscapes:T=!1}=C,P,R=d.calculatedTargetScrollTop;C.duration instanceof Promise?C.duration.finally(()=>{P=Date.now()}):P=g+(C.duration??0);let v=async()=>{let _=new Promise(requestAnimationFrame).then(()=>{if(!d.isAtBottom)return d.animation=void 0,!1;let{scrollTop:A}=d,E=performance.now(),y=(E-(d.lastTick??E))/td;if(d.animation||(d.animation={behavior:b,promise:_,ignoreEscapes:T}),d.animation.behavior===b&&(d.lastTick=E),i()||g>Date.now())return v();if(A<Math.min(R,d.calculatedTargetScrollTop)){if(d.animation?.behavior===b){if(b==="instant")return d.scrollTop=d.calculatedTargetScrollTop,v();d.velocity=(b.damping*d.velocity+b.stiffness*d.scrollDifference)/b.mass,d.accumulated+=d.velocity*y,d.scrollTop+=d.accumulated,d.scrollTop!==A&&(d.accumulated=0)}return v()}return P>Date.now()?(R=d.calculatedTargetScrollTop,v()):(d.animation=void 0,d.scrollTop<d.calculatedTargetScrollTop?p({animation:Io(l.current,l.current.resize),ignoreEscapes:T,duration:Math.max(0,P-Date.now())||void 0}):d.isAtBottom)});return _.then(A=>(requestAnimationFrame(()=>{d.animation||(d.lastTick=void 0,d.velocity=0)}),A))};return C.wait!==!0&&(d.animation=void 0),d.animation?.behavior===b?d.animation.promise:v()},[u,i,d]),m=Xe(()=>{c(!0),u(!1)},[c,u]),h=Xe(({target:C})=>{if(C!==L.current)return;let{scrollTop:g,ignoreScrollToTop:b}=d,{lastScrollTop:T=g}=d;d.lastScrollTop=g,d.ignoreScrollToTop=void 0,b&&b>g&&(T=b),n(d.isNearBottom),setTimeout(()=>{if(d.resizeDifference||g===b)return;if(i()){c(!0),u(!1);return}let P=g>T,R=g<T;if(d.animation?.ignoreEscapes){d.scrollTop=T;return}R&&(c(!0),u(!1)),P&&c(!1),!d.escapedFromLock&&d.isNearBottom&&u(!0)},1)},[c,u,i,d]),I=Xe(({target:C,deltaY:g})=>{let b=C;for(;!["scroll","auto"].includes(getComputedStyle(b).overflow);){if(!b.parentElement)return;b=b.parentElement}b===L.current&&g<0&&L.current.scrollHeight>L.current.clientHeight&&!d.animation?.ignoreEscapes&&(c(!0),u(!1))},[c,u,d]),L=As(C=>{L.current?.removeEventListener("scroll",h),L.current?.removeEventListener("wheel",I),C?.addEventListener("scroll",h,{passive:!0}),C?.addEventListener("wheel",I,{passive:!0})},[]),S=As(C=>{if(d.resizeObserver?.disconnect(),!C)return;let g;d.resizeObserver=new ResizeObserver(([b])=>{let{height:T}=b.contentRect,P=T-(g??T);if(d.resizeDifference=P,d.scrollTop>d.targetScrollTop&&(d.scrollTop=d.targetScrollTop),n(d.isNearBottom),P>=0){let R=Io(l.current,g?l.current.resize:l.current.initial);p({animation:R,wait:!0,preserveScrollPosition:!0,duration:R==="instant"?void 0:ad})}else d.isNearBottom&&(c(!1),u(!0));g=T,requestAnimationFrame(()=>{setTimeout(()=>{d.resizeDifference===P&&(d.resizeDifference=0)},1)})}),d.resizeObserver?.observe(C)},[]);return{contentRef:S,scrollRef:L,scrollToBottom:p,stopScroll:m,isAtBottom:o||s,isNearBottom:s,escapedFromLock:t,state:d}};function As(e,t){let a=Xe(o=>(a.current=o,e(o)),t);return a}var Co=new Map;function Io(...e){let t={...Yu},a=!1;for(let r of e){if(r==="instant"){a=!0;continue}typeof r=="object"&&(a=!1,t.damping=r.damping??t.damping,t.stiffness=r.stiffness??t.stiffness,t.mass=r.mass??t.mass)}let o=JSON.stringify(t);return Co.has(o)||Co.set(o,Object.freeze(t)),a?"instant":Co.get(o)}f();import*as at from"react";import{createContext as od,useContext as rd,useEffect as sd,useImperativeHandle as nd,useLayoutEffect as id,useMemo as ld,useRef as ud}from"react";var Ms=od(null),dd=typeof window<"u"?id:sd;function Wt({instance:e,children:t,resize:a,initial:o,mass:r,damping:s,stiffness:n,targetScrollTop:l,contextRef:i,...u}){let c=ud(null),d=at.useCallback((T,P)=>(b?.targetScrollTop??l)?.(T,P)??T,[l]),p=Rs({mass:r,damping:s,stiffness:n,resize:a,initial:o,targetScrollTop:d}),{scrollRef:m,contentRef:h,scrollToBottom:I,stopScroll:L,isAtBottom:S,escapedFromLock:C,state:g}=e??p,b=ld(()=>({scrollToBottom:I,stopScroll:L,scrollRef:m,isAtBottom:S,escapedFromLock:C,contentRef:h,state:g,get targetScrollTop(){return c.current},set targetScrollTop(T){c.current=T}}),[I,S,h,m,L,C,g]);return nd(i,()=>b,[b]),dd(()=>{m.current&&getComputedStyle(m.current).overflow==="visible"&&(m.current.style.overflow="auto")},[]),at.createElement(Ms.Provider,{value:b},at.createElement("div",{...u},typeof t=="function"?t(b):t))}(function(e){function t({children:a,scrollClassName:o,...r}){let s=So();return at.createElement("div",{ref:s.scrollRef,style:{height:"100%",width:"100%",scrollbarGutter:"stable both-edges"},className:o},at.createElement("div",{...r,ref:s.contentRef},typeof a=="function"?a(s):a))}e.Content=t})(Wt||(Wt={}));function So(){let e=rd(Ms);if(!e)throw new Error("use-stick-to-bottom component context must be used within a StickToBottom component");return e}f();var cd=br({prefix:"ww"});function B(...e){return cd(yr(e))}f();import{jsx as fd}from"react/jsx-runtime";var Ee=({className:e,variant:t="default",size:a="default",type:o="button",...r})=>fd("button",{type:o,className:B("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});import{jsx as xa}from"react/jsx-runtime";var Fs=({className:e,...t})=>xa(Wt,{className:B("ww:relative ww:flex-1 ww:overflow-y-hidden",e),initial:"smooth",resize:"smooth",role:"log",...t}),Ds=({className:e,...t})=>xa(Wt.Content,{className:B("ww:flex ww:flex-col ww:gap-6 ww:px-4 ww:py-6 ww:mx-auto ww:w-full ww:max-w-3xl",e),...t}),Bs=({className:e,...t})=>{let{isAtBottom:a,scrollToBottom:o}=So(),r=pd(()=>{o()},[o]);return!a&&xa(Ee,{className:B("ww:absolute ww:bottom-4 ww:left-[50%] ww:translate-x-[-50%] ww:rounded-full",e),onClick:r,size:"icon",variant:"outline",...t,children:xa(Ft,{className:"ww:size-4"})})};f();f();import _s from"crypto";f();var Es="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var md=128,ot,wt,hd=e=>{!ot||ot.length<e?(ot=Buffer.allocUnsafe(e*md),_s.randomFillSync(ot),wt=0):wt+e>ot.length&&(_s.randomFillSync(ot),wt=0),wt+=e};var Gt=(e=21)=>{hd(e|=0);let t="";for(let a=wt-e;a<wt;a++)t+=Es[ot[a]&63];return t};import{createContext as gd,useCallback as qe,useContext as wd,useEffect as yo,useMemo as xd,useRef as bo,useState as Ns}from"react";import{jsx as Me,jsxs as js}from"react/jsx-runtime";var Ld=async e=>{try{let a=await(await fetch(e)).blob();return new Promise(o=>{let r=new FileReader;r.onloadend=()=>o(r.result),r.onerror=()=>o(null),r.readAsDataURL(a)})}catch{return null}},Us=gd(null),Os=()=>{let e=wd(Us);if(!e)throw new Error("usePromptInputAttachments must be used within a PromptInput");return e},Hs=({className:e,accept:t,multiple:a,globalDrop:o,maxFiles:r,maxFileSize:s,onSubmit:n,children:l,...i})=>{let u=bo(null),c=bo(null),[d,p]=Ns([]),m=bo(d);yo(()=>{m.current=d},[d]);let h=qe(()=>{u.current?.click()},[]),I=qe(T=>{let P=[...T];if(P.length===0)return;let R=_=>s?_.size<=s:!0,v=P.filter(R);p(_=>{let A=typeof r=="number"?Math.max(0,r-_.length):void 0,E=typeof A=="number"?v.slice(0,A):v;return[..._,...E.map(y=>({filename:y.name,id:Gt(),mediaType:y.type,type:"file",url:URL.createObjectURL(y)}))]})},[r,s]),L=qe(T=>{p(P=>{let R=P.find(v=>v.id===T);return R?.url&&URL.revokeObjectURL(R.url),P.filter(v=>v.id!==T)})},[]),S=qe(()=>{p(T=>{for(let P of T)P.url&&URL.revokeObjectURL(P.url);return[]})},[]);yo(()=>()=>{for(let T of m.current)T.url&&URL.revokeObjectURL(T.url)},[]);let C=qe(T=>{T.currentTarget.files&&I(T.currentTarget.files),T.currentTarget.value=""},[I]);yo(()=>{if(!o)return;let T=R=>{R.dataTransfer?.types?.includes("Files")&&R.preventDefault()},P=R=>{R.dataTransfer?.types?.includes("Files")&&R.preventDefault(),R.dataTransfer?.files&&R.dataTransfer.files.length>0&&I(R.dataTransfer.files)};return document.addEventListener("dragover",T),document.addEventListener("drop",P),()=>{document.removeEventListener("dragover",T),document.removeEventListener("drop",P)}},[I,o]);let g=qe(async T=>{T.preventDefault();let P=T.currentTarget,v=new FormData(P).get("message")||"";P.reset();let _=await Promise.all(d.map(async({id:A,...E})=>{if(E.url?.startsWith("blob:")){let y=await Ld(E.url);return{...E,url:y??E.url}}return E}));try{let A=n({files:_,text:v},T);A instanceof Promise&&await A,S()}catch{}},[d,n,S]),b=xd(()=>({add:I,clear:S,files:d,openFileDialog:h,remove:L}),[d,I,L,S,h]);return js(Us.Provider,{value:b,children:[Me("input",{accept:t,"aria-label":"Upload files",className:"ww:hidden",multiple:a,onChange:C,ref:u,title:"Upload files",type:"file"}),Me("form",{className:B("ww:flex ww:w-full ww:flex-col ww:rounded-lg ww:border ww:border-border ww:bg-background",e),onSubmit:g,ref:c,...i,children:l})]})};var qs=({onChange:e,onKeyDown:t,className:a,placeholder:o="What would you like to know?",...r})=>{let s=Os(),[n,l]=Ns(!1),i=qe(c=>{if(t?.(c),!c.defaultPrevented){if(c.key==="Enter"){if(n||c.nativeEvent.isComposing||c.shiftKey)return;c.preventDefault();let{form:d}=c.currentTarget;if(d?.querySelector('button[type="submit"]')?.disabled)return;d?.requestSubmit()}if(c.key==="Backspace"&&c.currentTarget.value===""&&s.files.length>0){c.preventDefault();let d=s.files.at(-1);d&&s.remove(d.id)}}},[t,n,s]),u=qe(c=>{let d=c.clipboardData?.items;if(!d)return;let p=[];for(let m of d)if(m.kind==="file"){let h=m.getAsFile();h&&p.push(h)}p.length>0&&(c.preventDefault(),s.add(p))},[s]);return Me("textarea",{className:B("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-sm ww:outline-none ww:placeholder:text-muted-foreground",a),name:"message",onCompositionEnd:()=>l(!1),onCompositionStart:()=>l(!0),onKeyDown:i,onPaste:u,placeholder:o,onChange:e,...r})},Ws=({className:e,status:t,onStop:a,onClick:o,children:r,...s})=>{let n=t==="submitted"||t==="streaming",l=Me(Dt,{className:"ww:size-4"});t==="submitted"?l=Me(Ot,{className:"ww:size-4 ww:animate-spin"}):t==="streaming"&&(l=Me(qt,{className:"ww:size-4"}));let i=qe(u=>{if(n&&a){u.preventDefault(),a();return}o?.(u)},[n,a,o]);return Me(Ee,{"aria-label":n?"Stop":"Submit",className:B("ww:bg-foreground ww:text-background ww:hover:bg-foreground ww:rounded-full",e),onClick:i,size:"icon-sm",type:n&&a?"button":"submit",variant:"ghost",...s,children:r??l})},Gs=({className:e,children:t,...a})=>{let o=Os();return o.files.length>0?js(Ee,{className:B("ww:group ww:relative",e),onClick:()=>o.clear(),size:"icon-sm",type:"button",variant:"ghost","aria-label":"Remove all attachments",...a,children:[Me("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}),Me(tt,{className:"ww:absolute ww:size-4 ww:opacity-0 ww:transition-opacity ww:group-hover:opacity-100"})]}):Me(Ee,{className:B(e),onClick:()=>o.openFileDialog(),size:"icon-sm",type:"button",variant:"ghost",...a,children:t??Me(Ht,{className:"ww:size-4"})})};f();import{memo as Cd,useCallback as Id}from"react";f();import{jsx as xt}from"react/jsx-runtime";var zs=({className:e,...t})=>xt("div",{className:B("ww:flex ww:flex-col ww:gap-1 ww:px-3 ww:py-2",e),...t}),Vs=({className:e,...t})=>xt("li",{className:B("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}),$s=({className:e,...t})=>xt("span",{className:B("ww:inline-block ww:size-2 ww:shrink-0 ww:rounded-full ww:border ww:border-muted-foreground/50",e),...t}),Xs=({className:e,...t})=>xt("span",{className:B("ww:line-clamp-1 ww:grow ww:break-words ww:text-muted-foreground",e),...t}),Ks=({className:e,...t})=>xt("div",{className:B("ww:flex ww:shrink-0 ww:gap-1 ww:opacity-0 ww:transition-opacity ww:group-hover:opacity-100",e),...t}),Qs=({className:e,...t})=>xt(Ee,{className:B("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 rt,jsxs as ko}from"react/jsx-runtime";var Js=Cd(({message:e,onRemove:t})=>{let a=Id(()=>t(e.id),[t,e.id]);return ko(Vs,{children:[rt($s,{}),rt(Xs,{children:e.text||"(attachment)"}),rt(Ks,{children:rt(Qs,{"aria-label":"Remove from queue",onClick:a,children:rt(tt,{className:"ww:size-3"})})})]})});Js.displayName="ChatQueueItem";function Zs({queuedMessages:e,onRemove:t,className:a}){return e.length===0?null:ko(zs,{className:B("ww:border-t ww:border-border",a),children:[ko("div",{className:"ww:text-[11px] ww:font-medium ww:text-muted-foreground ww:px-2",children:[e.length," queued"]}),rt("ul",{children:e.map(o=>rt(Js,{message:o,onRemove:t},o.id))})]})}f();import{useState as Ys}from"react";import{jsx as Sd}from"react/jsx-runtime";function en({messages:e,evalEnabled:t,api:a="/api/waniwani"}){let[o,r]=Ys(!1),[s,n]=Ys(null),l=async()=>{let u={name:`session-${new Date().toISOString().slice(0,19)}`,type:"functional",messages:e,mode:"manual"};r(!0),n(null);try{let c=await fetch(`${a}/scenarios`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(u)});if(!c.ok)throw new Error(`${c.status}`);n("saved")}catch{n("error")}finally{r(!1),setTimeout(()=>n(null),2e3)}};return!t||e.length===0?null:Sd("button",{type:"button",onClick:l,disabled:o,title:"Save scenario to WaniWani",className:"ww:ml-auto ww:text-[10px] ww:font-mono ww:uppercase ww:tracking-wider ww:text-muted-foreground hover:ww:text-foreground ww:cursor-pointer ww:transition-colors ww:disabled:opacity-40",children:o?"saving...":s==="saved"?"saved":s==="error"?"error":"export"})}f();f();import{jsx as jt,jsxs as bd}from"react/jsx-runtime";var tn=({files:e,className:t,...a})=>e.length===0?null:jt("div",{className:B("ww:flex ww:flex-wrap ww:gap-1.5",t),...a,children:e.map((o,r)=>jt(yd,{file:o},r))});function yd({file:e}){return e.mediaType?.startsWith("image/")&&e.url?jt("img",{src:e.url,alt:e.filename??"attachment",className:"ww:h-16 ww:max-w-32 ww:rounded ww:object-cover"}):bd("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:[jt(Ut,{className:"ww:size-3 ww:shrink-0"}),jt("span",{className:"ww:max-w-24 ww:truncate",children:e.filename??"file"})]})}f();import{jsx as an}from"react/jsx-runtime";var To=({className:e,size:t=5,...a})=>an("div",{className:B("ww:flex ww:items-center ww:gap-1",e),...a,children:[0,1,2].map(o=>an("div",{className:"ww:rounded-full ww:bg-muted-foreground/60",style:{width:t,height:t,animation:"ww-pulse 1.4s ease-in-out infinite",animationDelay:`${o*.2}s`}},o))});f();f();f();f();f();f();var de={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};f();var _e={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};f();var ye={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"};f();f();f();function on(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 rn(e){return e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510}function sn(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 nn(e){return on(e)?"ambiguous":rn(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":sn(e)?"wide":"neutral"}function kd(e){if(!Number.isSafeInteger(e))throw new TypeError(`Expected a code point, got \`${typeof e}\`.`)}function ln(e){return kd(e),nn(e)}var Td=Object.defineProperty,Pd=(e,t,a)=>t in e?Td(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,vd=(e,t,a)=>Pd(e,typeof t!="symbol"?t+"":t,a);function Ad(e){return new RegExp("^\\p{Emoji_Presentation}","u").test(String.fromCodePoint(e))}function Rd(e){if(!e||e<4352)return!1;switch(ln(e)){case"fullwidth":case"halfwidth":return!0;case"wide":return!Ad(e);case"narrow":return!1;case"ambiguous":return 917760<=e&&e<=917999?null:!1;case"neutral":return new RegExp("^\\p{sc=Hangul}","u").test(String.fromCodePoint(e))}}function Md(e,t){return t!==65025||!e||e<8216?!1:e===8216||e===8217||e===8220||e===8221}function Fd(e){return e!==null&&e>=65024&&e<=65038}var Dd=un(new RegExp("\\p{P}|\\p{S}","u")),Bd=un(/\s/);function un(e){return t;function t(a){return a!==null&&a>-1&&e.test(String.fromCodePoint(a))}}var be;(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})(be||(be={}));function Ke(e){if(e===de.eof||kr(e)||Bd(e))return _e.characterGroupWhitespace;let t=0;if(e>=4352){if(Fd(e))return be.nonEmojiGeneralUseVS;switch(Rd(e)){case null:return be.ivs;case!0:t|=be.cjk;break}}return Dd(e)&&(t|=_e.characterGroupPunctuation),t}function La(e,t,a){if(!_d(e))return e;let o=t(),r=Ke(o);return!o||st(r)?e:Md(o,a)?be.cjkPunctuation:Ed(r)}function Ed(e){return e&~be.ivs}function st(e){return!!(e&_e.characterGroupWhitespace)}function Lt(e){return(e&be.cjkPunctuation)===_e.characterGroupPunctuation}function zt(e){return!!(e&be.cjk)}function dn(e){return e===be.ivs}function cn(e){return!!(e&be.cjkOrIvs)}function _d(e){return e===be.nonEmojiGeneralUseVS}function Po(e){return!!(e&be.spaceOrPunctuation)}function Ca(e){return!!(e&&e>=55296&&e<=56319)}function Ia(e){return!!(e&&e>=56320&&e<=57343)}function Sa(e,t,a){if(t._bufferIndex<2)return e;let r=a({start:{...t,_bufferIndex:t._bufferIndex-2},end:t}).codePointAt(0);return r&&r>=65536?r:e}function Nd(e,t,a){let o=e>=65536?2:1;if(t._bufferIndex<1+o)return null;let r=t._bufferIndex-o-2,s=a({start:{...t,_bufferIndex:r>=0?r:0},end:{...t,_bufferIndex:t._bufferIndex-o}}),n=s.charCodeAt(s.length-1);if(Number.isNaN(n))return null;if(s.length<2||n<56320||57343<n)return n;let l=s.codePointAt(0);return l&&l>=65536?l:n}var ya=class{constructor(e,t,a){this.previousCode=e,this.nowPoint=t,this.sliceSerialize=a,vd(this,"cachedValue")}value(){return this.cachedValue===void 0&&(this.cachedValue=Nd(this.previousCode,this.nowPoint,this.sliceSerialize)),this.cachedValue}};function ba(e,t,a){let o=a({start:t,end:{...t,_bufferIndex:t._bufferIndex+2}}).codePointAt(0);return o&&o>=65536?o:e}var vo={name:"attention",resolveAll:Ud,tokenize:Od};function Ud(e,t){let a=-1,o,r,s,n,l,i,u,c;for(;++a<e.length;)if(e[a][0]==="enter"&&e[a][1].type==="attentionSequence"&&e[a][1]._close){for(o=a;o--;)if(e[o][0]==="exit"&&e[o][1].type==="attentionSequence"&&e[o][1]._open&&t.sliceSerialize(e[o][1]).charCodeAt(0)===t.sliceSerialize(e[a][1]).charCodeAt(0)){if((e[o][1]._close||e[a][1]._open)&&(e[a][1].end.offset-e[a][1].start.offset)%3&&!((e[o][1].end.offset-e[o][1].start.offset+e[a][1].end.offset-e[a][1].start.offset)%3))continue;i=e[o][1].end.offset-e[o][1].start.offset>1&&e[a][1].end.offset-e[a][1].start.offset>1?2:1;let d={...e[o][1].end},p={...e[a][1].start};fn(d,-i),fn(p,i),n={type:i>1?ye.strongSequence:ye.emphasisSequence,start:d,end:{...e[o][1].end}},l={type:i>1?ye.strongSequence:ye.emphasisSequence,start:{...e[a][1].start},end:p},s={type:i>1?ye.strongText:ye.emphasisText,start:{...e[o][1].end},end:{...e[a][1].start}},r={type:i>1?ye.strong:ye.emphasis,start:{...n.start},end:{...l.end}},e[o][1].end={...n.start},e[a][1].start={...l.end},u=[],e[o][1].end.offset-e[o][1].start.offset&&(u=mt(u,[["enter",e[o][1],t],["exit",e[o][1],t]])),u=mt(u,[["enter",r,t],["enter",n,t],["exit",n,t],["enter",s,t]]),t.parser.constructs.insideSpan.null,u=mt(u,ua(t.parser.constructs.insideSpan.null,e.slice(o+1,a),t)),u=mt(u,[["exit",s,t],["enter",l,t],["exit",l,t],["exit",r,t]]),e[a][1].end.offset-e[a][1].start.offset?(c=2,u=mt(u,[["enter",e[a][1],t],["exit",e[a][1],t]])):c=0,pt(e,o-1,a-o+3,u),a=o+u.length-c-2;break}}for(a=-1;++a<e.length;)e[a][1].type==="attentionSequence"&&(e[a][1].type="data");return e}function Od(e,t){let a=this.parser.constructs.attentionMarkers.null,{now:o,sliceSerialize:r,previous:s}=this,n=Ia(s)?Sa(s,o(),r):s,l=Ke(n),i=new ya(n,o(),r),u=La(l,i.value.bind(i),n),c;return d;function d(m){return m===de.asterisk||de.underscore,c=m,e.enter("attentionSequence"),p(m)}function p(m){if(m===c)return e.consume(m),p;let h=e.exit("attentionSequence"),I=Ca(m)?ba(m,o(),r):m,L=Ke(I);let S=Lt(u),C=S||st(u),g=Lt(L),b=g||st(L),T=cn(u),P=!b||g&&(C||T)||a.includes(m),R=!C||S&&(b||zt(L))||a.includes(n);return h._open=!!(c===de.asterisk?P:P&&(Po(u)||!R)),h._close=!!(c===de.asterisk?R:R&&(Po(L)||!P)),t(m)}}function fn(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}function pn(){return{text:{[de.asterisk]:vo,[de.underscore]:vo},insideSpan:{null:[vo]}}}function mn(){let e=this.data();(e.micromarkExtensions||(e.micromarkExtensions=[])).push(pn())}f();f();function hn(e){let a=(e||{}).singleTilde,o={name:"strikethrough",tokenize:s,resolveAll:r};return a==null&&(a=!0),{text:{[de.tilde]:o},insideSpan:{null:[o]},attentionMarkers:{null:[de.tilde]}};function r(n,l){let i=-1;for(;++i<n.length;)if(n[i][0]==="enter"&&n[i][1].type==="strikethroughSequenceTemporary"&&n[i][1]._close){let u=i;for(;u--;)if(n[u][0]==="exit"&&n[u][1].type==="strikethroughSequenceTemporary"&&n[u][1]._open&&n[i][1].end.offset-n[i][1].start.offset===n[u][1].end.offset-n[u][1].start.offset){n[i][1].type="strikethroughSequence",n[u][1].type="strikethroughSequence";let c={type:"strikethrough",start:Object.assign({},n[u][1].start),end:Object.assign({},n[i][1].end)},d={type:"strikethroughText",start:Object.assign({},n[u][1].end),end:Object.assign({},n[i][1].start)},p=[["enter",c,l],["enter",n[u][1],l],["exit",n[u][1],l],["enter",d,l]],m=l.parser.constructs.insideSpan.null;m&&pt(p,p.length,0,ua(m,n.slice(u+1,i),l)),pt(p,p.length,0,[["exit",d,l],["enter",n[i][1],l],["exit",n[i][1],l],["exit",c,l]]),pt(n,u-1,i-u+3,p),i=u+p.length-2;break}}for(i=-1;++i<n.length;)n[i][1].type==="strikethroughSequenceTemporary"&&(n[i][1].type=ye.data);return n}function s(n,l,i){let{now:u,sliceSerialize:c,previous:d}=this,p=Ia(d)?Sa(d,u(),c):d,m=Ke(p),h=new ya(p,u(),c),I=La(m,h.value.bind(h),p),L=this.events,S=0;return C;function C(b){return de.tilde,p===de.tilde&&L[L.length-1][1].type!==ye.characterEscape?i(b):(n.enter("strikethroughSequenceTemporary"),g(b))}function g(b){let T=Ke(p);if(b===de.tilde)return S>1?i(b):(n.consume(b),S++,g);if(S<2&&!a)return i(b);let P=n.exit("strikethroughSequenceTemporary"),R=Ca(b)?ba(b,u(),c):b,v=Ke(R),A=Lt(I)||st(I),y=Lt(v)||st(v),M=zt(I)||dn(T);return P._open=!y||v===_e.attentionSideAfter&&(A||M),P._close=!A||T===_e.attentionSideAfter&&(y||zt(v)),l(b)}}}function gn(e){let t=this.data();(t.micromarkExtensions||(t.micromarkExtensions=[])).push(hn(e))}var Hd=new Set(["\u3002","\uFF0E","\uFF0C","\u3001","\uFF1F","\uFF01","\uFF1A","\uFF1B","\uFF08","\uFF09","\u3010","\u3011","\u300C","\u300D","\u300E","\u300F","\u3008","\u3009","\u300A","\u300B"]),qd=/^(https?:\/\/|mailto:|www\.)/i,Wd=e=>{if(e.children.length!==1)return!1;let t=e.children[0];return t.type==="text"&&t.value===e.url},Gd=e=>{let t=0;for(let a of e){if(Hd.has(a))return t;t+=a.length}return null},jd=(e,t)=>({...t,url:e,children:[{type:"text",value:e}]}),zd=e=>({type:"text",value:e}),Vd=()=>e=>{Tr(e,"link",(t,a,o)=>{if(!o||typeof a!="number"||!Wd(t)||!qd.test(t.url))return;let r=Gd(t.url);if(r===null||r===0)return;let s=t.url.slice(0,r),n=t.url.slice(r),l=jd(s,t),i=zd(n);return o.children.splice(a,1,l,i),a+1})};function $d(){let e=[mn],t=[Vd,gn],a=[...e,...t];return{name:"cjk",type:"cjk",remarkPluginsBefore:e,remarkPluginsAfter:t,remarkPlugins:a}}var wn=$d();f();f();f();f();f();var Z=class extends Error{constructor(t){super(t),this.name="ShikiError"}};f();function Xd(e){return Uo(e)}function Uo(e){return Array.isArray(e)?Kd(e):e instanceof RegExp?e:typeof e=="object"?Qd(e):e}function Kd(e){let t=[];for(let a=0,o=e.length;a<o;a++)t[a]=Uo(e[a]);return t}function Qd(e){let t={};for(let a in e)t[a]=Uo(e[a]);return t}function Tn(e,...t){return t.forEach(a=>{for(let o in a)e[o]=a[o]}),e}function Pn(e){let t=~e.lastIndexOf("/")||~e.lastIndexOf("\\");return t===0?e:~t===e.length-1?Pn(e.substring(0,e.length-1)):e.substr(~t+1)}var Ao=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,ka=class{static hasCaptures(e){return e===null?!1:(Ao.lastIndex=0,Ao.test(e))}static replaceCaptures(e,t,a){return e.replace(Ao,(o,r,s,n)=>{let l=a[parseInt(r||s,10)];if(l){let i=t.substring(l.start,l.end);for(;i[0]===".";)i=i.substring(1);switch(n){case"downcase":return i.toLowerCase();case"upcase":return i.toUpperCase();default:return i}}else return o})}};function vn(e,t){return e<t?-1:e>t?1:0}function An(e,t){if(e===null&&t===null)return 0;if(!e)return-1;if(!t)return 1;let a=e.length,o=t.length;if(a===o){for(let r=0;r<a;r++){let s=vn(e[r],t[r]);if(s!==0)return s}return 0}return a-o}function xn(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 Rn(e){return e.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var Mn=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}},Xt=class{constructor(e,t,a){this._colorMap=e,this._defaults=t,this._root=a}static createFromRawTheme(e,t){return this.createFromParsedTheme(Yd(e),t)}static createFromParsedTheme(e,t){return tc(e,t)}_cachedMatchRoot=new Mn(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,o=this._cachedMatchRoot.get(t).find(r=>Jd(e.parent,r.parentScopes));return o?new Fn(o.fontStyle,o.foreground,o.background):null}},Ro=class Ta{constructor(t,a){this.parent=t,this.scopeName=a}static push(t,a){for(let o of a)t=new Ta(t,o);return t}static from(...t){let a=null;for(let o=0;o<t.length;o++)a=new Ta(a,t[o]);return a}push(t){return new Ta(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=[],o=this;for(;o&&o!==t;)a.push(o.scopeName),o=o.parent;return o===t?a.reverse():void 0}};function Jd(e,t){if(t.length===0)return!0;for(let a=0;a<t.length;a++){let o=t[a],r=!1;if(o===">"){if(a===t.length-1)return!1;o=t[++a],r=!0}for(;e&&!Zd(e.scopeName,o);){if(r)return!1;e=e.parent}if(!e)return!1;e=e.parent}return!0}function Zd(e,t){return t===e||e.startsWith(t)&&e[t.length]==="."}var Fn=class{constructor(e,t,a){this.fontStyle=e,this.foregroundId=t,this.backgroundId=a}};function Yd(e){if(!e)return[];if(!e.settings||!Array.isArray(e.settings))return[];let t=e.settings,a=[],o=0;for(let r=0,s=t.length;r<s;r++){let n=t[r];if(!n.settings)continue;let l;if(typeof n.scope=="string"){let d=n.scope;d=d.replace(/^[,]+/,""),d=d.replace(/[,]+$/,""),l=d.split(",")}else Array.isArray(n.scope)?l=n.scope:l=[""];let i=-1;if(typeof n.settings.fontStyle=="string"){i=0;let d=n.settings.fontStyle.split(" ");for(let p=0,m=d.length;p<m;p++)switch(d[p]){case"italic":i=i|1;break;case"bold":i=i|2;break;case"underline":i=i|4;break;case"strikethrough":i=i|8;break}}let u=null;typeof n.settings.foreground=="string"&&xn(n.settings.foreground)&&(u=n.settings.foreground);let c=null;typeof n.settings.background=="string"&&xn(n.settings.background)&&(c=n.settings.background);for(let d=0,p=l.length;d<p;d++){let h=l[d].trim().split(" "),I=h[h.length-1],L=null;h.length>1&&(L=h.slice(0,h.length-1),L.reverse()),a[o++]=new ec(I,L,r,i,u,c)}}return a}var ec=class{constructor(e,t,a,o,r,s){this.scope=e,this.parentScopes=t,this.index=a,this.fontStyle=o,this.foreground=r,this.background=s}},ce=(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))(ce||{});function tc(e,t){e.sort((i,u)=>{let c=vn(i.scope,u.scope);return c!==0||(c=An(i.parentScopes,u.parentScopes),c!==0)?c:i.index-u.index});let a=0,o="#000000",r="#ffffff";for(;e.length>=1&&e[0].scope==="";){let i=e.shift();i.fontStyle!==-1&&(a=i.fontStyle),i.foreground!==null&&(o=i.foreground),i.background!==null&&(r=i.background)}let s=new ac(t),n=new Fn(a,s.getId(o),s.getId(r)),l=new rc(new Fo(0,null,-1,0,0),[]);for(let i=0,u=e.length;i<u;i++){let c=e[i];l.insert(0,c.scope,c.parentScopes,c.fontStyle,s.getId(c.foreground),s.getId(c.background))}return new Xt(s,n,l)}var ac=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)}},oc=Object.freeze([]),Fo=class Dn{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(t,a,o,r,s){this.scopeDepth=t,this.parentScopes=a||oc,this.fontStyle=o,this.foreground=r,this.background=s}clone(){return new Dn(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(t){let a=[];for(let o=0,r=t.length;o<r;o++)a[o]=t[o].clone();return a}acceptOverwrite(t,a,o,r){this.scopeDepth>t?console.log("how did this happen?"):this.scopeDepth=t,a!==-1&&(this.fontStyle=a),o!==0&&(this.foreground=o),r!==0&&(this.background=r)}},rc=class Do{constructor(t,a=[],o={}){this._mainRule=t,this._children=o,this._rulesWithParentScopes=a}_rulesWithParentScopes;static _cmpBySpecificity(t,a){if(t.scopeDepth!==a.scopeDepth)return a.scopeDepth-t.scopeDepth;let o=0,r=0;for(;t.parentScopes[o]===">"&&o++,a.parentScopes[r]===">"&&r++,!(o>=t.parentScopes.length||r>=a.parentScopes.length);){let s=a.parentScopes[r].length-t.parentScopes[o].length;if(s!==0)return s;o++,r++}return a.parentScopes.length-t.parentScopes.length}match(t){if(t!==""){let o=t.indexOf("."),r,s;if(o===-1?(r=t,s=""):(r=t.substring(0,o),s=t.substring(o+1)),this._children.hasOwnProperty(r))return this._children[r].match(s)}let a=this._rulesWithParentScopes.concat(this._mainRule);return a.sort(Do._cmpBySpecificity),a}insert(t,a,o,r,s,n){if(a===""){this._doInsertHere(t,o,r,s,n);return}let l=a.indexOf("."),i,u;l===-1?(i=a,u=""):(i=a.substring(0,l),u=a.substring(l+1));let c;this._children.hasOwnProperty(i)?c=this._children[i]:(c=new Do(this._mainRule.clone(),Fo.cloneArr(this._rulesWithParentScopes)),this._children[i]=c),c.insert(t+1,u,o,r,s,n)}_doInsertHere(t,a,o,r,s){if(a===null){this._mainRule.acceptOverwrite(t,o,r,s);return}for(let n=0,l=this._rulesWithParentScopes.length;n<l;n++){let i=this._rulesWithParentScopes[n];if(An(i.parentScopes,a)===0){i.acceptOverwrite(t,o,r,s);return}}o===-1&&(o=this._mainRule.fontStyle),r===0&&(r=this._mainRule.foreground),s===0&&(s=this._mainRule.background),this._rulesWithParentScopes.push(new Fo(t,a,o,r,s))}},it=class Ae{static toBinaryStr(t){return t.toString(2).padStart(32,"0")}static print(t){let a=Ae.getLanguageId(t),o=Ae.getTokenType(t),r=Ae.getFontStyle(t),s=Ae.getForeground(t),n=Ae.getBackground(t);console.log({languageId:a,tokenType:o,fontStyle:r,foreground:s,background:n})}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,o,r,s,n,l){let i=Ae.getLanguageId(t),u=Ae.getTokenType(t),c=Ae.containsBalancedBrackets(t)?1:0,d=Ae.getFontStyle(t),p=Ae.getForeground(t),m=Ae.getBackground(t);return a!==0&&(i=a),o!==8&&(u=o),r!==null&&(c=r?1:0),s!==-1&&(d=s),n!==0&&(p=n),l!==0&&(m=l),(i<<0|u<<8|c<<10|d<<11|p<<15|m<<24)>>>0}};function va(e,t){let a=[],o=sc(e),r=o.next();for(;r!==null;){let i=0;if(r.length===2&&r.charAt(1)===":"){switch(r.charAt(0)){case"R":i=1;break;case"L":i=-1;break;default:console.log(`Unknown priority ${r} in scope selector`)}r=o.next()}let u=n();if(a.push({matcher:u,priority:i}),r!==",")break;r=o.next()}return a;function s(){if(r==="-"){r=o.next();let i=s();return u=>!!i&&!i(u)}if(r==="("){r=o.next();let i=l();return r===")"&&(r=o.next()),i}if(Ln(r)){let i=[];do i.push(r),r=o.next();while(Ln(r));return u=>t(i,u)}return null}function n(){let i=[],u=s();for(;u;)i.push(u),u=s();return c=>i.every(d=>d(c))}function l(){let i=[],u=n();for(;u&&(i.push(u),r==="|"||r===",");){do r=o.next();while(r==="|"||r===",");u=n()}return c=>i.some(d=>d(c))}}function Ln(e){return!!e&&!!e.match(/[\w\.:]+/)}function sc(e){let t=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,a=t.exec(e);return{next:()=>{if(!a)return null;let o=a[0];return a=t.exec(e),o}}}function Bn(e){typeof e.dispose=="function"&&e.dispose()}var Kt=class{constructor(e){this.scopeName=e}toKey(){return this.scopeName}},nc=class{constructor(e,t){this.scopeName=e,this.ruleName=t}toKey(){return`${this.scopeName}#${this.ruleName}`}},ic=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))}},lc=class{constructor(e,t){this.repo=e,this.initialScopeName=t,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new Kt(this.initialScopeName)]}seenFullScopeRequests=new Set;seenPartialScopeRequests=new Set;Q;processQueue(){let e=this.Q;this.Q=[];let t=new ic;for(let a of e)uc(a,this.initialScopeName,this.repo,t);for(let a of t.references)if(a instanceof Kt){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 uc(e,t,a,o){let r=a.lookup(e.scopeName);if(!r){if(e.scopeName===t)throw new Error(`No grammar provided for <${t}>`);return}let s=a.lookup(t);e instanceof Kt?Pa({baseGrammar:s,selfGrammar:r},o):Bo(e.ruleName,{baseGrammar:s,selfGrammar:r,repository:r.repository},o);let n=a.injections(e.scopeName);if(n)for(let l of n)o.add(new Kt(l))}function Bo(e,t,a){if(t.repository&&t.repository[e]){let o=t.repository[e];Aa([o],t,a)}}function Pa(e,t){e.selfGrammar.patterns&&Array.isArray(e.selfGrammar.patterns)&&Aa(e.selfGrammar.patterns,{...e,repository:e.selfGrammar.repository},t),e.selfGrammar.injections&&Aa(Object.values(e.selfGrammar.injections),{...e,repository:e.selfGrammar.repository},t)}function Aa(e,t,a){for(let o of e){if(a.visitedRule.has(o))continue;a.visitedRule.add(o);let r=o.repository?Tn({},t.repository,o.repository):t.repository;Array.isArray(o.patterns)&&Aa(o.patterns,{...t,repository:r},a);let s=o.include;if(!s)continue;let n=En(s);switch(n.kind){case 0:Pa({...t,selfGrammar:t.baseGrammar},a);break;case 1:Pa(t,a);break;case 2:Bo(n.ruleName,{...t,repository:r},a);break;case 3:case 4:let l=n.scopeName===t.selfGrammar.scopeName?t.selfGrammar:n.scopeName===t.baseGrammar.scopeName?t.baseGrammar:void 0;if(l){let i={baseGrammar:t.baseGrammar,selfGrammar:l,repository:r};n.kind===4?Bo(n.ruleName,i,a):Pa(i,a)}else n.kind===4?a.add(new nc(n.scopeName,n.ruleName)):a.add(new Kt(n.scopeName));break}}}var dc=class{kind=0},cc=class{kind=1},fc=class{constructor(e){this.ruleName=e}kind=2},pc=class{constructor(e){this.scopeName=e}kind=3},mc=class{constructor(e,t){this.scopeName=e,this.ruleName=t}kind=4};function En(e){if(e==="$base")return new dc;if(e==="$self")return new cc;let t=e.indexOf("#");if(t===-1)return new pc(e);if(t===0)return new fc(e.substring(1));{let a=e.substring(0,t),o=e.substring(t+1);return new mc(a,o)}}var hc=/\\(\d+)/,Cn=/\\(\d+)/g;var gc=-1,_n=-2;var Zt=class{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(e,t,a,o){this.$location=e,this.id=t,this._name=a||null,this._nameIsCapturing=ka.hasCaptures(this._name),this._contentName=o||null,this._contentNameIsCapturing=ka.hasCaptures(this._contentName)}get debugName(){let e=this.$location?`${Pn(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:ka.replaceCaptures(this._name,e,t)}getContentName(e,t){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:ka.replaceCaptures(this._contentName,e,t)}},wc=class extends Zt{retokenizeCapturedWithRuleId;constructor(e,t,a,o,r){super(e,t,a,o),this.retokenizeCapturedWithRuleId=r}dispose(){}collectPatterns(e,t){throw new Error("Not supported!")}compile(e,t){throw new Error("Not supported!")}compileAG(e,t,a,o){throw new Error("Not supported!")}},xc=class extends Zt{_match;captures;_cachedCompiledPatterns;constructor(e,t,a,o,r){super(e,t,a,null),this._match=new Qt(o,this.id),this.captures=r,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,o){return this._getCachedCompiledPatterns(e).compileAG(e,a,o)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new Jt,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},In=class extends Zt{hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,a,o,r){super(e,t,a,o),this.patterns=r.patterns,this.hasMissingPatterns=r.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,o){return this._getCachedCompiledPatterns(e).compileAG(e,a,o)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new Jt,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Eo=class extends Zt{_begin;beginCaptures;_end;endHasBackReferences;endCaptures;applyEndPatternLast;hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,a,o,r,s,n,l,i,u){super(e,t,a,o),this._begin=new Qt(r,this.id),this.beginCaptures=s,this._end=new Qt(n||"\uFFFF",-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=l,this.applyEndPatternLast=i||!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,o){return this._getCachedCompiledPatterns(e,t).compileAG(e,a,o)}_getCachedCompiledPatterns(e,t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Jt;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}},Ra=class extends Zt{_begin;beginCaptures;whileCaptures;_while;whileHasBackReferences;hasMissingPatterns;patterns;_cachedCompiledPatterns;_cachedCompiledWhilePatterns;constructor(e,t,a,o,r,s,n,l,i){super(e,t,a,o),this._begin=new Qt(r,this.id),this.beginCaptures=s,this.whileCaptures=l,this._while=new Qt(n,_n),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=i.patterns,this.hasMissingPatterns=i.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,o){return this._getCachedCompiledPatterns(e).compileAG(e,a,o)}_getCachedCompiledPatterns(e){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Jt;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,o){return this._getCachedCompiledWhilePatterns(e,t).compileAG(e,a,o)}_getCachedCompiledWhilePatterns(e,t){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new Jt,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,t||"\uFFFF"),this._cachedCompiledWhilePatterns}},Nn=class he{static createCaptureRule(t,a,o,r,s){return t.registerRule(n=>new wc(a,n,o,r,s))}static getCompiledRuleId(t,a,o){return t.id||a.registerRule(r=>{if(t.id=r,t.match)return new xc(t.$vscodeTextmateLocation,t.id,t.name,t.match,he._compileCaptures(t.captures,a,o));if(typeof t.begin>"u"){t.repository&&(o=Tn({},o,t.repository));let s=t.patterns;return typeof s>"u"&&t.include&&(s=[{include:t.include}]),new In(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,he._compilePatterns(s,a,o))}return t.while?new Ra(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,he._compileCaptures(t.beginCaptures||t.captures,a,o),t.while,he._compileCaptures(t.whileCaptures||t.captures,a,o),he._compilePatterns(t.patterns,a,o)):new Eo(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,he._compileCaptures(t.beginCaptures||t.captures,a,o),t.end,he._compileCaptures(t.endCaptures||t.captures,a,o),t.applyEndPatternLast,he._compilePatterns(t.patterns,a,o))}),t.id}static _compileCaptures(t,a,o){let r=[];if(t){let s=0;for(let n in t){if(n==="$vscodeTextmateLocation")continue;let l=parseInt(n,10);l>s&&(s=l)}for(let n=0;n<=s;n++)r[n]=null;for(let n in t){if(n==="$vscodeTextmateLocation")continue;let l=parseInt(n,10),i=0;t[n].patterns&&(i=he.getCompiledRuleId(t[n],a,o)),r[l]=he.createCaptureRule(a,t[n].$vscodeTextmateLocation,t[n].name,t[n].contentName,i)}}return r}static _compilePatterns(t,a,o){let r=[];if(t)for(let s=0,n=t.length;s<n;s++){let l=t[s],i=-1;if(l.include){let u=En(l.include);switch(u.kind){case 0:case 1:i=he.getCompiledRuleId(o[l.include],a,o);break;case 2:let c=o[u.ruleName];c&&(i=he.getCompiledRuleId(c,a,o));break;case 3:case 4:let d=u.scopeName,p=u.kind===4?u.ruleName:null,m=a.getExternalGrammar(d,o);if(m)if(p){let h=m.repository[p];h&&(i=he.getCompiledRuleId(h,a,m.repository))}else i=he.getCompiledRuleId(m.repository.$self,a,m.repository);break}}else i=he.getCompiledRuleId(l,a,o);if(i!==-1){let u=a.getRule(i),c=!1;if((u instanceof In||u instanceof Eo||u instanceof Ra)&&u.hasMissingPatterns&&u.patterns.length===0&&(c=!0),c)continue;r.push(i)}}return{patterns:r,hasMissingPatterns:(t?t.length:0)!==r.length}}},Qt=class Un{source;ruleId;hasAnchor;hasBackReferences;_anchorCache;constructor(t,a){if(t&&typeof t=="string"){let o=t.length,r=0,s=[],n=!1;for(let l=0;l<o;l++)if(t.charAt(l)==="\\"&&l+1<o){let u=t.charAt(l+1);u==="z"?(s.push(t.substring(r,l)),s.push("$(?!\\n)(?<!\\n)"),r=l+2):(u==="A"||u==="G")&&(n=!0),l++}this.hasAnchor=n,r===0?this.source=t:(s.push(t.substring(r,o)),this.source=s.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=hc.test(this.source):this.hasBackReferences=!1}clone(){return new Un(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 o=a.map(r=>t.substring(r.start,r.end));return Cn.lastIndex=0,this.source.replace(Cn,(r,s)=>Rn(o[parseInt(s,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=[],o=[],r=[],s,n,l,i;for(s=0,n=this.source.length;s<n;s++)l=this.source.charAt(s),t[s]=l,a[s]=l,o[s]=l,r[s]=l,l==="\\"&&s+1<n&&(i=this.source.charAt(s+1),i==="A"?(t[s+1]="\uFFFF",a[s+1]="\uFFFF",o[s+1]="A",r[s+1]="A"):i==="G"?(t[s+1]="\uFFFF",a[s+1]="G",o[s+1]="\uFFFF",r[s+1]="G"):(t[s+1]=i,a[s+1]=i,o[s+1]=i,r[s+1]=i),s++);return{A0_G0:t.join(""),A0_G1:a.join(""),A1_G0:o.join(""),A1_G1:r.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}},Jt=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 Sn(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 o=this._items.map(r=>r.resolveAnchors(t,a));return new Sn(e,o,this._items.map(r=>r.ruleId))}},Sn=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(`
|
|
69
|
+
`)}findNextMatchSync(e,t,a){let o=this.scanner.findNextMatchSync(e,t,a);return o?{ruleId:this.rules[o.index],captureIndices:o.captureIndices}:null}},Mo=class{constructor(e,t){this.languageId=e,this.tokenType=t}},Lc=class _o{_defaultAttributes;_embeddedLanguagesMatcher;constructor(t,a){this._defaultAttributes=new Mo(t,8),this._embeddedLanguagesMatcher=new Cc(Object.entries(a||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(t){return t===null?_o._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(t)}static _NULL_SCOPE_METADATA=new Mo(0,0);_getBasicScopeAttributes=new Mn(t=>{let a=this._scopeToLanguage(t),o=this._toStandardTokenType(t);return new Mo(a,o)});_scopeToLanguage(t){return this._embeddedLanguagesMatcher.match(t)||0}_toStandardTokenType(t){let a=t.match(_o.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/},Cc=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,o])=>Rn(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])}},WI={InDebugMode:typeof process<"u"&&!!process.env.VSCODE_TEXTMATE_DEBUG},On=!1,yn=class{constructor(e,t){this.stack=e,this.stoppedEarly=t}};function Hn(e,t,a,o,r,s,n,l){let i=t.content.length,u=!1,c=-1;if(n){let m=Ic(e,t,a,o,r,s);r=m.stack,o=m.linePos,a=m.isFirstLine,c=m.anchorPosition}let d=Date.now();for(;!u;){if(l!==0&&Date.now()-d>l)return new yn(r,!0);p()}return new yn(r,!1);function p(){let m=Sc(e,t,a,o,r,c);if(!m){s.produce(r,i),u=!0;return}let h=m.captureIndices,I=m.matchedRuleId,L=h&&h.length>0?h[0].end>o:!1;if(I===gc){let S=r.getRule(e);s.produce(r,h[0].start),r=r.withContentNameScopesList(r.nameScopesList),Vt(e,t,a,r,s,S.endCaptures,h),s.produce(r,h[0].end);let C=r;if(r=r.parent,c=C.getAnchorPos(),!L&&C.getEnterPos()===o){r=C,s.produce(r,i),u=!0;return}}else{let S=e.getRule(I);s.produce(r,h[0].start);let C=r,g=S.getName(t.content,h),b=r.contentNameScopesList.pushAttributed(g,e);if(r=r.push(I,o,c,h[0].end===i,null,b,b),S instanceof Eo){let T=S;Vt(e,t,a,r,s,T.beginCaptures,h),s.produce(r,h[0].end),c=h[0].end;let P=T.getContentName(t.content,h),R=b.pushAttributed(P,e);if(r=r.withContentNameScopesList(R),T.endHasBackReferences&&(r=r.withEndRule(T.getEndWithResolvedBackReferences(t.content,h))),!L&&C.hasSameRuleAs(r)){r=r.pop(),s.produce(r,i),u=!0;return}}else if(S instanceof Ra){let T=S;Vt(e,t,a,r,s,T.beginCaptures,h),s.produce(r,h[0].end),c=h[0].end;let P=T.getContentName(t.content,h),R=b.pushAttributed(P,e);if(r=r.withContentNameScopesList(R),T.whileHasBackReferences&&(r=r.withEndRule(T.getWhileWithResolvedBackReferences(t.content,h))),!L&&C.hasSameRuleAs(r)){r=r.pop(),s.produce(r,i),u=!0;return}}else if(Vt(e,t,a,r,s,S.captures,h),s.produce(r,h[0].end),r=r.pop(),!L){r=r.safePop(),s.produce(r,i),u=!0;return}}h[0].end>o&&(o=h[0].end,a=!1)}}function Ic(e,t,a,o,r,s){let n=r.beginRuleCapturedEOL?0:-1,l=[];for(let i=r;i;i=i.pop()){let u=i.getRule(e);u instanceof Ra&&l.push({rule:u,stack:i})}for(let i=l.pop();i;i=l.pop()){let{ruleScanner:u,findOptions:c}=kc(i.rule,e,i.stack.endRule,a,o===n),d=u.findNextMatchSync(t,o,c);if(d){if(d.ruleId!==_n){r=i.stack.pop();break}d.captureIndices&&d.captureIndices.length&&(s.produce(i.stack,d.captureIndices[0].start),Vt(e,t,a,i.stack,s,i.rule.whileCaptures,d.captureIndices),s.produce(i.stack,d.captureIndices[0].end),n=d.captureIndices[0].end,d.captureIndices[0].end>o&&(o=d.captureIndices[0].end,a=!1))}else{r=i.stack.pop();break}}return{stack:r,linePos:o,anchorPosition:n,isFirstLine:a}}function Sc(e,t,a,o,r,s){let n=yc(e,t,a,o,r,s),l=e.getInjections();if(l.length===0)return n;let i=bc(l,e,t,a,o,r,s);if(!i)return n;if(!n)return i;let u=n.captureIndices[0].start,c=i.captureIndices[0].start;return c<u||i.priorityMatch&&c===u?i:n}function yc(e,t,a,o,r,s){let n=r.getRule(e),{ruleScanner:l,findOptions:i}=qn(n,e,r.endRule,a,o===s),u=l.findNextMatchSync(t,o,i);return u?{captureIndices:u.captureIndices,matchedRuleId:u.ruleId}:null}function bc(e,t,a,o,r,s,n){let l=Number.MAX_VALUE,i=null,u,c=0,d=s.contentNameScopesList.getScopeNames();for(let p=0,m=e.length;p<m;p++){let h=e[p];if(!h.matcher(d))continue;let I=t.getRule(h.ruleId),{ruleScanner:L,findOptions:S}=qn(I,t,null,o,r===n),C=L.findNextMatchSync(a,r,S);if(!C)continue;let g=C.captureIndices[0].start;if(!(g>=l)&&(l=g,i=C.captureIndices,u=C.ruleId,c=h.priority,l===r))break}return i?{priorityMatch:c===-1,captureIndices:i,matchedRuleId:u}:null}function qn(e,t,a,o,r){if(On){let n=e.compile(t,a),l=Wn(o,r);return{ruleScanner:n,findOptions:l}}return{ruleScanner:e.compileAG(t,a,o,r),findOptions:0}}function kc(e,t,a,o,r){if(On){let n=e.compileWhile(t,a),l=Wn(o,r);return{ruleScanner:n,findOptions:l}}return{ruleScanner:e.compileWhileAG(t,a,o,r),findOptions:0}}function Wn(e,t){let a=0;return e||(a|=1),t||(a|=4),a}function Vt(e,t,a,o,r,s,n){if(s.length===0)return;let l=t.content,i=Math.min(s.length,n.length),u=[],c=n[0].end;for(let d=0;d<i;d++){let p=s[d];if(p===null)continue;let m=n[d];if(m.length===0)continue;if(m.start>c)break;for(;u.length>0&&u[u.length-1].endPos<=m.start;)r.produceFromScopes(u[u.length-1].scopes,u[u.length-1].endPos),u.pop();if(u.length>0?r.produceFromScopes(u[u.length-1].scopes,m.start):r.produce(o,m.start),p.retokenizeCapturedWithRuleId){let I=p.getName(l,n),L=o.contentNameScopesList.pushAttributed(I,e),S=p.getContentName(l,n),C=L.pushAttributed(S,e),g=o.push(p.retokenizeCapturedWithRuleId,m.start,-1,!1,null,L,C),b=e.createOnigString(l.substring(0,m.end));Hn(e,b,a&&m.start===0,m.start,g,r,!1,0),Bn(b);continue}let h=p.getName(l,n);if(h!==null){let L=(u.length>0?u[u.length-1].scopes:o.contentNameScopesList).pushAttributed(h,e);u.push(new Tc(L,m.end))}}for(;u.length>0;)r.produceFromScopes(u[u.length-1].scopes,u[u.length-1].endPos),u.pop()}var Tc=class{scopes;endPos;constructor(e,t){this.scopes=e,this.endPos=t}};function Pc(e,t,a,o,r,s,n,l){return new Ac(e,t,a,o,r,s,n,l)}function bn(e,t,a,o,r){let s=va(t,Ma),n=Nn.getCompiledRuleId(a,o,r.repository);for(let l of s)e.push({debugSelector:t,matcher:l.matcher,ruleId:n,grammar:r,priority:l.priority})}function Ma(e,t){if(t.length<e.length)return!1;let a=0;return e.every(o=>{for(let r=a;r<t.length;r++)if(vc(t[r],o))return a=r+1,!0;return!1})}function vc(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 Ac=class{constructor(e,t,a,o,r,s,n,l){if(this._rootScopeName=e,this.balancedBracketSelectors=s,this._onigLib=l,this._basicScopeAttributesProvider=new Lc(a,o),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=n,this._grammar=kn(t,null),this._injections=null,this._tokenTypeMatchers=[],r)for(let i of Object.keys(r)){let u=va(i,Ma);for(let c of u)this._tokenTypeMatchers.push({matcher:c.matcher,type:r[i]})}}_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:r=>r===this._rootScopeName?this._grammar:this.getExternalGrammar(r),injections:r=>this._grammarRepository.injections(r)},t=[],a=this._rootScopeName,o=e.lookup(a);if(o){let r=o.injections;if(r)for(let n in r)bn(t,n,r[n],this,o);let s=this._grammarRepository.injections(a);s&&s.forEach(n=>{let l=this.getExternalGrammar(n);if(l){let i=l.injectionSelector;i&&bn(t,i,l,this,l)}})}return t.sort((r,s)=>r.priority-s.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]=kn(a,t&&t.$base),this._includedGrammars[e]}}tokenizeLine(e,t,a=0){let o=this._tokenize(e,t,!1,a);return{tokens:o.lineTokens.getResult(o.ruleStack,o.lineLength),ruleStack:o.ruleStack,stoppedEarly:o.stoppedEarly}}tokenizeLine2(e,t,a=0){let o=this._tokenize(e,t,!0,a);return{tokens:o.lineTokens.getBinaryResult(o.ruleStack,o.lineLength),ruleStack:o.ruleStack,stoppedEarly:o.stoppedEarly}}_tokenize(e,t,a,o){this._rootId===-1&&(this._rootId=Nn.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections());let r;if(!t||t===No.NULL){r=!0;let u=this._basicScopeAttributesProvider.getDefaultAttributes(),c=this.themeProvider.getDefaults(),d=it.set(0,u.languageId,u.tokenType,null,c.fontStyle,c.foregroundId,c.backgroundId),p=this.getRule(this._rootId).getName(null,null),m;p?m=$t.createRootAndLookUpScopeName(p,d,this):m=$t.createRoot("unknown",d),t=new No(null,this._rootId,-1,-1,!1,null,m,m)}else r=!1,t.reset();e=e+`
|
|
70
|
+
`;let s=this.createOnigString(e),n=s.content.length,l=new Mc(a,e,this._tokenTypeMatchers,this.balancedBracketSelectors),i=Hn(this,s,r,0,t,l,!0,o);return Bn(s),{lineLength:n,lineTokens:l,ruleStack:i.stack,stoppedEarly:i.stoppedEarly}}};function kn(e,t){return e=Xd(e),e.repository=e.repository||{},e.repository.$self={$vscodeTextmateLocation:e.$vscodeTextmateLocation,patterns:e.patterns,name:e.scopeName},e.repository.$base=t||e.repository.$self,e}var $t=class Ne{constructor(t,a,o){this.parent=t,this.scopePath=a,this.tokenAttributes=o}static fromExtension(t,a){let o=t,r=t?.scopePath??null;for(let s of a)r=Ro.push(r,s.scopeNames),o=new Ne(o,r,s.encodedTokenAttributes);return o}static createRoot(t,a){return new Ne(null,new Ro(null,t),a)}static createRootAndLookUpScopeName(t,a,o){let r=o.getMetadataForScope(t),s=new Ro(null,t),n=o.themeProvider.themeMatch(s),l=Ne.mergeAttributes(a,r,n);return new Ne(null,s,l)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(" ")}equals(t){return Ne.equals(this,t)}static equals(t,a){do{if(t===a||!t&&!a)return!0;if(!t||!a||t.scopeName!==a.scopeName||t.tokenAttributes!==a.tokenAttributes)return!1;t=t.parent,a=a.parent}while(!0)}static mergeAttributes(t,a,o){let r=-1,s=0,n=0;return o!==null&&(r=o.fontStyle,s=o.foregroundId,n=o.backgroundId),it.set(t,a.languageId,a.tokenType,null,r,s,n)}pushAttributed(t,a){if(t===null)return this;if(t.indexOf(" ")===-1)return Ne._pushAttributed(this,t,a);let o=t.split(/ /g),r=this;for(let s of o)r=Ne._pushAttributed(r,s,a);return r}static _pushAttributed(t,a,o){let r=o.getMetadataForScope(a),s=t.scopePath.push(a),n=o.themeProvider.themeMatch(s),l=Ne.mergeAttributes(t.tokenAttributes,r,n);return new Ne(t,s,l)}getScopeNames(){return this.scopePath.getSegments()}getExtensionIfDefined(t){let a=[],o=this;for(;o&&o!==t;)a.push({encodedTokenAttributes:o.tokenAttributes,scopeNames:o.scopePath.getExtensionIfDefined(o.parent?.scopePath??null)}),o=o.parent;return o===t?a.reverse():void 0}},No=class nt{constructor(t,a,o,r,s,n,l,i){this.parent=t,this.ruleId=a,this.beginRuleCapturedEOL=s,this.endRule=n,this.nameScopesList=l,this.contentNameScopesList=i,this.depth=this.parent?this.parent.depth+1:1,this._enterPos=o,this._anchorPos=r}_stackElementBrand=void 0;static NULL=new nt(null,0,0,0,!1,null,null,null);_enterPos;_anchorPos;depth;equals(t){return t===null?!1:nt._equals(this,t)}static _equals(t,a){return t===a?!0:this._structuralEquals(t,a)?$t.equals(t.contentNameScopesList,a.contentNameScopesList):!1}static _structuralEquals(t,a){do{if(t===a||!t&&!a)return!0;if(!t||!a||t.depth!==a.depth||t.ruleId!==a.ruleId||t.endRule!==a.endRule)return!1;t=t.parent,a=a.parent}while(!0)}clone(){return this}static _reset(t){for(;t;)t._enterPos=-1,t._anchorPos=-1,t=t.parent}reset(){nt._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(t,a,o,r,s,n,l){return new nt(this,t,a,o,r,s,n,l)}getEnterPos(){return this._enterPos}getAnchorPos(){return this._anchorPos}getRule(t){return t.getRule(this.ruleId)}toString(){let t=[];return this._writeString(t,0),"["+t.join(",")+"]"}_writeString(t,a){return this.parent&&(a=this.parent._writeString(t,a)),t[a++]=`(${this.ruleId}, ${this.nameScopesList?.toString()}, ${this.contentNameScopesList?.toString()})`,a}withContentNameScopesList(t){return this.contentNameScopesList===t?this:this.parent.push(this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,this.endRule,this.nameScopesList,t)}withEndRule(t){return this.endRule===t?this:new nt(this.parent,this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,t,this.nameScopesList,this.contentNameScopesList)}hasSameRuleAs(t){let a=this;for(;a&&a._enterPos===t._enterPos;){if(a.ruleId===t.ruleId)return!0;a=a.parent}return!1}toStateStackFrame(){return{ruleId:this.ruleId,beginRuleCapturedEOL:this.beginRuleCapturedEOL,endRule:this.endRule,nameScopesList:this.nameScopesList?.getExtensionIfDefined(this.parent?.nameScopesList??null)??[],contentNameScopesList:this.contentNameScopesList?.getExtensionIfDefined(this.nameScopesList)??[]}}static pushFrame(t,a){let o=$t.fromExtension(t?.nameScopesList??null,a.nameScopesList);return new nt(t,a.ruleId,a.enterPos??-1,a.anchorPos??-1,a.beginRuleCapturedEOL,a.endRule,o,$t.fromExtension(o,a.contentNameScopesList))}},Rc=class{balancedBracketScopes;unbalancedBracketScopes;allowAny=!1;constructor(e,t){this.balancedBracketScopes=e.flatMap(a=>a==="*"?(this.allowAny=!0,[]):va(a,Ma).map(o=>o.matcher)),this.unbalancedBracketScopes=t.flatMap(a=>va(a,Ma).map(o=>o.matcher))}get matchesAlways(){return this.allowAny&&this.unbalancedBracketScopes.length===0}get matchesNever(){return this.balancedBracketScopes.length===0&&!this.allowAny}match(e){for(let t of this.unbalancedBracketScopes)if(t(e))return!1;for(let t of this.balancedBracketScopes)if(t(e))return!0;return this.allowAny}},Mc=class{constructor(e,t,a,o){this.balancedBracketSelectors=o,this._emitBinaryTokens=e,this._tokenTypeOverrides=a,this._lineText=null,this._tokens=[],this._binaryTokens=[],this._lastTokenEndIndex=0}_emitBinaryTokens;_lineText;_tokens;_binaryTokens;_lastTokenEndIndex;_tokenTypeOverrides;produce(e,t){this.produceFromScopes(e.contentNameScopesList,t)}produceFromScopes(e,t){if(this._lastTokenEndIndex>=t)return;if(this._emitBinaryTokens){let o=e?.tokenAttributes??0,r=!1;if(this.balancedBracketSelectors?.matchesAlways&&(r=!0),this._tokenTypeOverrides.length>0||this.balancedBracketSelectors&&!this.balancedBracketSelectors.matchesAlways&&!this.balancedBracketSelectors.matchesNever){let s=e?.getScopeNames()??[];for(let n of this._tokenTypeOverrides)n.matcher(s)&&(o=it.set(o,0,n.type,null,-1,0,0));this.balancedBracketSelectors&&(r=this.balancedBracketSelectors.match(s))}if(r&&(o=it.set(o,0,8,r,-1,0,0)),this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-1]===o){this._lastTokenEndIndex=t;return}this._binaryTokens.push(this._lastTokenEndIndex),this._binaryTokens.push(o),this._lastTokenEndIndex=t;return}let a=e?.getScopeNames()??[];this._tokens.push({startIndex:this._lastTokenEndIndex,endIndex:t,scopes:a}),this._lastTokenEndIndex=t}getResult(e,t){return this._tokens.length>0&&this._tokens[this._tokens.length-1].startIndex===t-1&&this._tokens.pop(),this._tokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._tokens[this._tokens.length-1].startIndex=0),this._tokens}getBinaryResult(e,t){this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-2]===t-1&&(this._binaryTokens.pop(),this._binaryTokens.pop()),this._binaryTokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._binaryTokens[this._binaryTokens.length-2]=0);let a=new Uint32Array(this._binaryTokens.length);for(let o=0,r=this._binaryTokens.length;o<r;o++)a[o]=this._binaryTokens[o];return a}},Fc=class{constructor(e,t){this._onigLib=t,this._theme=e}_grammars=new Map;_rawGrammars=new Map;_injectionGrammars=new Map;_theme;dispose(){for(let e of this._grammars.values())e.dispose()}setTheme(e){this._theme=e}getColorMap(){return this._theme.getColorMap()}addGrammar(e,t){this._rawGrammars.set(e.scopeName,e),t&&this._injectionGrammars.set(e.scopeName,t)}lookup(e){return this._rawGrammars.get(e)}injections(e){return this._injectionGrammars.get(e)}getDefaults(){return this._theme.getDefaults()}themeMatch(e){return this._theme.match(e)}grammarForScopeName(e,t,a,o,r){if(!this._grammars.has(e)){let s=this._rawGrammars.get(e);if(!s)return null;this._grammars.set(e,Pc(e,s,t,a,o,r,this,this._onigLib))}return this._grammars.get(e)}},Gn=class{_options;_syncRegistry;_ensureGrammarCache;constructor(e){this._options=e,this._syncRegistry=new Fc(Xt.createFromRawTheme(e.theme,e.colorMap),e.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(e,t){this._syncRegistry.setTheme(Xt.createFromRawTheme(e,t))}getColorMap(){return this._syncRegistry.getColorMap()}loadGrammarWithEmbeddedLanguages(e,t,a){return this.loadGrammarWithConfiguration(e,t,{embeddedLanguages:a})}loadGrammarWithConfiguration(e,t,a){return this._loadGrammar(e,t,a.embeddedLanguages,a.tokenTypes,new Rc(a.balancedBracketSelectors||[],a.unbalancedBracketSelectors||[]))}loadGrammar(e){return this._loadGrammar(e,0,null,null,null)}_loadGrammar(e,t,a,o,r){let s=new lc(this._syncRegistry,e);for(;s.Q.length>0;)s.Q.map(n=>this._loadSingleGrammar(n.scopeName)),s.processQueue();return this._grammarForScopeName(e,t,a,o,r)}_loadSingleGrammar(e){this._ensureGrammarCache.has(e)||(this._doLoadSingleGrammar(e),this._ensureGrammarCache.set(e,!0))}_doLoadSingleGrammar(e){let t=this._options.loadGrammar(e);if(t){let a=typeof this._options.getInjections=="function"?this._options.getInjections(e):void 0;this._syncRegistry.addGrammar(t,a)}}addGrammar(e,t=[],a=0,o=null){return this._syncRegistry.addGrammar(e,t),this._grammarForScopeName(e.scopeName,a,o)}_grammarForScopeName(e,t=0,a=null,o=null,r=null){return this._syncRegistry.grammarForScopeName(e,t,a,o,r)}},Fa=No.NULL;f();f();f();f();f();f();var Dc=/["&'<>`]/g,Bc=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,Ec=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,_c=/[|\\{}()[\]^$+*?.]/g,jn=new WeakMap;function zn(e,t){if(e=e.replace(t.subset?Nc(t.subset):Dc,o),t.subset||t.escapeOnly)return e;return e.replace(Bc,a).replace(Ec,o);function a(r,s,n){return t.format((r.charCodeAt(0)-55296)*1024+r.charCodeAt(1)-56320+65536,n.charCodeAt(s+2),t)}function o(r,s,n){return t.format(r.charCodeAt(0),n.charCodeAt(s+1),t)}}function Nc(e){let t=jn.get(e);return t||(t=Uc(e),jn.set(e,t)),t}function Uc(e){let t=[],a=-1;for(;++a<e.length;)t.push(e[a].replace(_c,"\\$&"));return new RegExp("(?:"+t.join("|")+")","g")}f();f();var Oc=/[\dA-Fa-f]/;function Vn(e,t,a){let o="&#x"+e.toString(16).toUpperCase();return a&&t&&!Oc.test(String.fromCharCode(t))?o:o+";"}f();var Hc=/\d/;function $n(e,t,a){let o="&#"+String(e);return a&&t&&!Hc.test(String.fromCharCode(t))?o:o+";"}f();f();var Xn=["AElig","AMP","Aacute","Acirc","Agrave","Aring","Atilde","Auml","COPY","Ccedil","ETH","Eacute","Ecirc","Egrave","Euml","GT","Iacute","Icirc","Igrave","Iuml","LT","Ntilde","Oacute","Ocirc","Ograve","Oslash","Otilde","Ouml","QUOT","REG","THORN","Uacute","Ucirc","Ugrave","Uuml","Yacute","aacute","acirc","acute","aelig","agrave","amp","aring","atilde","auml","brvbar","ccedil","cedil","cent","copy","curren","deg","divide","eacute","ecirc","egrave","eth","euml","frac12","frac14","frac34","gt","iacute","icirc","iexcl","igrave","iquest","iuml","laquo","lt","macr","micro","middot","nbsp","not","ntilde","oacute","ocirc","ograve","ordf","ordm","oslash","otilde","ouml","para","plusmn","pound","quot","raquo","reg","sect","shy","sup1","sup2","sup3","szlig","thorn","times","uacute","ucirc","ugrave","uml","uuml","yacute","yen","yuml"];f();var Da={nbsp:"\xA0",iexcl:"\xA1",cent:"\xA2",pound:"\xA3",curren:"\xA4",yen:"\xA5",brvbar:"\xA6",sect:"\xA7",uml:"\xA8",copy:"\xA9",ordf:"\xAA",laquo:"\xAB",not:"\xAC",shy:"\xAD",reg:"\xAE",macr:"\xAF",deg:"\xB0",plusmn:"\xB1",sup2:"\xB2",sup3:"\xB3",acute:"\xB4",micro:"\xB5",para:"\xB6",middot:"\xB7",cedil:"\xB8",sup1:"\xB9",ordm:"\xBA",raquo:"\xBB",frac14:"\xBC",frac12:"\xBD",frac34:"\xBE",iquest:"\xBF",Agrave:"\xC0",Aacute:"\xC1",Acirc:"\xC2",Atilde:"\xC3",Auml:"\xC4",Aring:"\xC5",AElig:"\xC6",Ccedil:"\xC7",Egrave:"\xC8",Eacute:"\xC9",Ecirc:"\xCA",Euml:"\xCB",Igrave:"\xCC",Iacute:"\xCD",Icirc:"\xCE",Iuml:"\xCF",ETH:"\xD0",Ntilde:"\xD1",Ograve:"\xD2",Oacute:"\xD3",Ocirc:"\xD4",Otilde:"\xD5",Ouml:"\xD6",times:"\xD7",Oslash:"\xD8",Ugrave:"\xD9",Uacute:"\xDA",Ucirc:"\xDB",Uuml:"\xDC",Yacute:"\xDD",THORN:"\xDE",szlig:"\xDF",agrave:"\xE0",aacute:"\xE1",acirc:"\xE2",atilde:"\xE3",auml:"\xE4",aring:"\xE5",aelig:"\xE6",ccedil:"\xE7",egrave:"\xE8",eacute:"\xE9",ecirc:"\xEA",euml:"\xEB",igrave:"\xEC",iacute:"\xED",icirc:"\xEE",iuml:"\xEF",eth:"\xF0",ntilde:"\xF1",ograve:"\xF2",oacute:"\xF3",ocirc:"\xF4",otilde:"\xF5",ouml:"\xF6",divide:"\xF7",oslash:"\xF8",ugrave:"\xF9",uacute:"\xFA",ucirc:"\xFB",uuml:"\xFC",yacute:"\xFD",thorn:"\xFE",yuml:"\xFF",fnof:"\u0192",Alpha:"\u0391",Beta:"\u0392",Gamma:"\u0393",Delta:"\u0394",Epsilon:"\u0395",Zeta:"\u0396",Eta:"\u0397",Theta:"\u0398",Iota:"\u0399",Kappa:"\u039A",Lambda:"\u039B",Mu:"\u039C",Nu:"\u039D",Xi:"\u039E",Omicron:"\u039F",Pi:"\u03A0",Rho:"\u03A1",Sigma:"\u03A3",Tau:"\u03A4",Upsilon:"\u03A5",Phi:"\u03A6",Chi:"\u03A7",Psi:"\u03A8",Omega:"\u03A9",alpha:"\u03B1",beta:"\u03B2",gamma:"\u03B3",delta:"\u03B4",epsilon:"\u03B5",zeta:"\u03B6",eta:"\u03B7",theta:"\u03B8",iota:"\u03B9",kappa:"\u03BA",lambda:"\u03BB",mu:"\u03BC",nu:"\u03BD",xi:"\u03BE",omicron:"\u03BF",pi:"\u03C0",rho:"\u03C1",sigmaf:"\u03C2",sigma:"\u03C3",tau:"\u03C4",upsilon:"\u03C5",phi:"\u03C6",chi:"\u03C7",psi:"\u03C8",omega:"\u03C9",thetasym:"\u03D1",upsih:"\u03D2",piv:"\u03D6",bull:"\u2022",hellip:"\u2026",prime:"\u2032",Prime:"\u2033",oline:"\u203E",frasl:"\u2044",weierp:"\u2118",image:"\u2111",real:"\u211C",trade:"\u2122",alefsym:"\u2135",larr:"\u2190",uarr:"\u2191",rarr:"\u2192",darr:"\u2193",harr:"\u2194",crarr:"\u21B5",lArr:"\u21D0",uArr:"\u21D1",rArr:"\u21D2",dArr:"\u21D3",hArr:"\u21D4",forall:"\u2200",part:"\u2202",exist:"\u2203",empty:"\u2205",nabla:"\u2207",isin:"\u2208",notin:"\u2209",ni:"\u220B",prod:"\u220F",sum:"\u2211",minus:"\u2212",lowast:"\u2217",radic:"\u221A",prop:"\u221D",infin:"\u221E",ang:"\u2220",and:"\u2227",or:"\u2228",cap:"\u2229",cup:"\u222A",int:"\u222B",there4:"\u2234",sim:"\u223C",cong:"\u2245",asymp:"\u2248",ne:"\u2260",equiv:"\u2261",le:"\u2264",ge:"\u2265",sub:"\u2282",sup:"\u2283",nsub:"\u2284",sube:"\u2286",supe:"\u2287",oplus:"\u2295",otimes:"\u2297",perp:"\u22A5",sdot:"\u22C5",lceil:"\u2308",rceil:"\u2309",lfloor:"\u230A",rfloor:"\u230B",lang:"\u2329",rang:"\u232A",loz:"\u25CA",spades:"\u2660",clubs:"\u2663",hearts:"\u2665",diams:"\u2666",quot:'"',amp:"&",lt:"<",gt:">",OElig:"\u0152",oelig:"\u0153",Scaron:"\u0160",scaron:"\u0161",Yuml:"\u0178",circ:"\u02C6",tilde:"\u02DC",ensp:"\u2002",emsp:"\u2003",thinsp:"\u2009",zwnj:"\u200C",zwj:"\u200D",lrm:"\u200E",rlm:"\u200F",ndash:"\u2013",mdash:"\u2014",lsquo:"\u2018",rsquo:"\u2019",sbquo:"\u201A",ldquo:"\u201C",rdquo:"\u201D",bdquo:"\u201E",dagger:"\u2020",Dagger:"\u2021",permil:"\u2030",lsaquo:"\u2039",rsaquo:"\u203A",euro:"\u20AC"};f();var Kn=["cent","copy","divide","gt","lt","not","para","times"];var Qn={}.hasOwnProperty,Oo={},Ba;for(Ba in Da)Qn.call(Da,Ba)&&(Oo[Da[Ba]]=Ba);var qc=/[^\dA-Za-z]/;function Jn(e,t,a,o){let r=String.fromCharCode(e);if(Qn.call(Oo,r)){let s=Oo[r],n="&"+s;return a&&Xn.includes(s)&&!Kn.includes(s)&&(!o||t&&t!==61&&qc.test(String.fromCharCode(t)))?n:n+";"}return""}function Zn(e,t,a){let o=Vn(e,t,a.omitOptionalSemicolons),r;if((a.useNamedReferences||a.useShortestReferences)&&(r=Jn(e,t,a.omitOptionalSemicolons,a.attribute)),(a.useShortestReferences||!r)&&a.useShortestReferences){let s=$n(e,t,a.omitOptionalSemicolons);s.length<o.length&&(o=s)}return r&&(!a.useShortestReferences||r.length<o.length)?r:o}function We(e,t){return zn(e,Object.assign({format:Zn},t))}var Wc=/^>|^->|<!--|-->|--!>|<!-$/g,Gc=[">"],jc=["<",">"];function Yn(e,t,a,o){return o.settings.bogusComments?"<?"+We(e.value,Object.assign({},o.settings.characterReferences,{subset:Gc}))+">":"<!--"+e.value.replace(Wc,r)+"-->";function r(s){return We(s,Object.assign({},o.settings.characterReferences,{subset:jc}))}}f();function ei(e,t,a,o){return"<!"+(o.settings.upperDoctype?"DOCTYPE":"doctype")+(o.settings.tightDoctype?"":" ")+"html>"}f();f();f();var ae=ti(1),Ho=ti(-1),zc=[];function ti(e){return t;function t(a,o,r){let s=a?a.children:zc,n=(o||0)+e,l=s[n];if(!r)for(;l&&ht(l);)n+=e,l=s[n];return l}}f();var Vc={}.hasOwnProperty;function Ea(e){return t;function t(a,o,r){return Vc.call(e,a.tagName)&&e[a.tagName](a,o,r)}}var Yt=Ea({body:Xc,caption:qo,colgroup:qo,dd:Zc,dt:Jc,head:qo,html:$c,li:Qc,optgroup:Yc,option:ef,p:Kc,rp:ai,rt:ai,tbody:af,td:oi,tfoot:of,th:oi,thead:tf,tr:rf});function qo(e,t,a){let o=ae(a,t,!0);return!o||o.type!=="comment"&&!(o.type==="text"&&ht(o.value.charAt(0)))}function $c(e,t,a){let o=ae(a,t);return!o||o.type!=="comment"}function Xc(e,t,a){let o=ae(a,t);return!o||o.type!=="comment"}function Kc(e,t,a){let o=ae(a,t);return o?o.type==="element"&&(o.tagName==="address"||o.tagName==="article"||o.tagName==="aside"||o.tagName==="blockquote"||o.tagName==="details"||o.tagName==="div"||o.tagName==="dl"||o.tagName==="fieldset"||o.tagName==="figcaption"||o.tagName==="figure"||o.tagName==="footer"||o.tagName==="form"||o.tagName==="h1"||o.tagName==="h2"||o.tagName==="h3"||o.tagName==="h4"||o.tagName==="h5"||o.tagName==="h6"||o.tagName==="header"||o.tagName==="hgroup"||o.tagName==="hr"||o.tagName==="main"||o.tagName==="menu"||o.tagName==="nav"||o.tagName==="ol"||o.tagName==="p"||o.tagName==="pre"||o.tagName==="section"||o.tagName==="table"||o.tagName==="ul"):!a||!(a.type==="element"&&(a.tagName==="a"||a.tagName==="audio"||a.tagName==="del"||a.tagName==="ins"||a.tagName==="map"||a.tagName==="noscript"||a.tagName==="video"))}function Qc(e,t,a){let o=ae(a,t);return!o||o.type==="element"&&o.tagName==="li"}function Jc(e,t,a){let o=ae(a,t);return!!(o&&o.type==="element"&&(o.tagName==="dt"||o.tagName==="dd"))}function Zc(e,t,a){let o=ae(a,t);return!o||o.type==="element"&&(o.tagName==="dt"||o.tagName==="dd")}function ai(e,t,a){let o=ae(a,t);return!o||o.type==="element"&&(o.tagName==="rp"||o.tagName==="rt")}function Yc(e,t,a){let o=ae(a,t);return!o||o.type==="element"&&o.tagName==="optgroup"}function ef(e,t,a){let o=ae(a,t);return!o||o.type==="element"&&(o.tagName==="option"||o.tagName==="optgroup")}function tf(e,t,a){let o=ae(a,t);return!!(o&&o.type==="element"&&(o.tagName==="tbody"||o.tagName==="tfoot"))}function af(e,t,a){let o=ae(a,t);return!o||o.type==="element"&&(o.tagName==="tbody"||o.tagName==="tfoot")}function of(e,t,a){return!ae(a,t)}function rf(e,t,a){let o=ae(a,t);return!o||o.type==="element"&&o.tagName==="tr"}function oi(e,t,a){let o=ae(a,t);return!o||o.type==="element"&&(o.tagName==="td"||o.tagName==="th")}f();var ri=Ea({body:lf,colgroup:uf,head:nf,html:sf,tbody:df});function sf(e){let t=ae(e,-1);return!t||t.type!=="comment"}function nf(e){let t=new Set;for(let o of e.children)if(o.type==="element"&&(o.tagName==="base"||o.tagName==="title")){if(t.has(o.tagName))return!1;t.add(o.tagName)}let a=e.children[0];return!a||a.type==="element"}function lf(e){let t=ae(e,-1,!0);return!t||t.type!=="comment"&&!(t.type==="text"&&ht(t.value.charAt(0)))&&!(t.type==="element"&&(t.tagName==="meta"||t.tagName==="link"||t.tagName==="script"||t.tagName==="style"||t.tagName==="template"))}function uf(e,t,a){let o=Ho(a,t),r=ae(e,-1,!0);return a&&o&&o.type==="element"&&o.tagName==="colgroup"&&Yt(o,a.children.indexOf(o),a)?!1:!!(r&&r.type==="element"&&r.tagName==="col")}function df(e,t,a){let o=Ho(a,t),r=ae(e,-1);return a&&o&&o.type==="element"&&(o.tagName==="thead"||o.tagName==="tbody")&&Yt(o,a.children.indexOf(o),a)?!1:!!(r&&r.type==="element"&&r.tagName==="tr")}var _a={name:[[`
|
|
71
71
|
\f\r &/=>`.split(""),`
|
|
72
72
|
\f\r "&'/=>\``.split("")],[`\0
|
|
73
73
|
\f\r "&'/<=>`.split(""),`\0
|
|
@@ -75,11 +75,11 @@ import{a as Ir,b as Sr,c as yr,d as pt,e as mt,f as la,g as kr,h as br,i as Tr,j
|
|
|
75
75
|
\f\r &>`.split(""),`\0
|
|
76
76
|
\f\r "&'<=>\``.split("")],[`\0
|
|
77
77
|
\f\r "&'<=>\``.split(""),`\0
|
|
78
|
-
\f\r "&'<=>\``.split("")]],single:[["&'".split(""),"\"&'`".split("")],["\0&'".split(""),"\0\"&'`".split("")]],double:[['"&'.split(""),"\"&'`".split("")],['\0"&'.split(""),"\0\"&'`".split("")]]};function Yn(e,t,a,o){let r=o.schema,s=r.space==="svg"?!1:o.settings.omitOptionalTags,n=r.space==="svg"?o.settings.closeEmptyElements:o.settings.voids.includes(e.tagName.toLowerCase()),l=[],i;r.space==="html"&&e.tagName==="svg"&&(o.schema=ua);let u=Xc(o,e.properties),c=o.all(r.space==="html"&&e.tagName==="template"?e.content:e);return o.schema=r,c&&(n=!1),(u||!s||!Zn(e,t,a))&&(l.push("<",e.tagName,u?" "+u:""),n&&(r.space==="svg"||o.settings.closeSelfClosing)&&(i=u.charAt(u.length-1),(!o.settings.tightSelfClosing||i==="/"||i&&i!=='"'&&i!=="'")&&l.push(" "),l.push("/")),l.push(">")),l.push(c),!n&&(!s||!Zt(e,t,a))&&l.push("</"+e.tagName+">"),l.join("")}function Xc(e,t){let a=[],o=-1,r;if(t){for(r in t)if(t[r]!==null&&t[r]!==void 0){let s=Kc(e,r,t[r]);s&&a.push(s)}}for(;++o<a.length;){let s=e.settings.tightAttributes?a[o].charAt(a[o].length-1):void 0;o!==a.length-1&&s!=='"'&&s!=="'"&&(a[o]+=" ")}return a.join("")}function Kc(e,t,a){let o=Tr(e.schema,t),r=e.settings.allowParseErrors&&e.schema.space==="html"?0:1,s=e.settings.allowDangerousCharacters?0:1,n=e.quote,l;if(o.overloadedBoolean&&(a===o.attribute||a==="")?a=!0:(o.boolean||o.overloadedBoolean)&&(typeof a!="string"||a===o.attribute||a==="")&&(a=!!a),a==null||a===!1||typeof a=="number"&&Number.isNaN(a))return"";let i=We(o.attribute,Object.assign({},e.settings.characterReferences,{subset:Ea.name[r][s]}));return a===!0||(a=Array.isArray(a)?(o.commaSeparated?Ar:Rr)(a,{padLeft:!e.settings.tightCommaSeparatedLists}):String(a),e.settings.collapseEmptyAttributes&&!a)?i:(e.settings.preferUnquoted&&(l=We(a,Object.assign({},e.settings.characterReferences,{attribute:!0,subset:Ea.unquoted[r][s]}))),l!==a&&(e.settings.quoteSmart&&lo(a,n)>lo(a,e.alternative)&&(n=e.alternative),l=n+We(a,Object.assign({},e.settings.characterReferences,{subset:(n==="'"?Ea.single:Ea.double)[r][s],attribute:!0}))+n),i+(l&&"="+l))}f();f();var Qc=["<","&"];function _a(e,t,a,o){return a&&a.type==="element"&&(a.tagName==="script"||a.tagName==="style")?e.value:We(e.value,Object.assign({},o.settings.characterReferences,{subset:Qc}))}function ei(e,t,a,o){return o.settings.allowDangerousHtml?e.value:_a(e,t,a,o)}f();function ti(e,t,a,o){return o.all(e)}var ai=vr("type",{invalid:Jc,unknown:Zc,handlers:{comment:$n,doctype:Xn,element:Yn,raw:ei,root:ti,text:_a}});function Jc(e){throw new Error("Expected node, not `"+e+"`")}function Zc(e){let t=e;throw new Error("Cannot compile unknown node `"+t.type+"`")}var Yc={},ef={},tf=[];function Ho(e,t){let a=t||Yc,o=a.quote||'"',r=o==='"'?"'":'"';if(o!=='"'&&o!=="'")throw new Error("Invalid quote `"+o+"`, expected `'` or `\"`");return{one:af,all:of,settings:{omitOptionalTags:a.omitOptionalTags||!1,allowParseErrors:a.allowParseErrors||!1,allowDangerousCharacters:a.allowDangerousCharacters||!1,quoteSmart:a.quoteSmart||!1,preferUnquoted:a.preferUnquoted||!1,tightAttributes:a.tightAttributes||!1,upperDoctype:a.upperDoctype||!1,tightDoctype:a.tightDoctype||!1,bogusComments:a.bogusComments||!1,tightCommaSeparatedLists:a.tightCommaSeparatedLists||!1,tightSelfClosing:a.tightSelfClosing||!1,collapseEmptyAttributes:a.collapseEmptyAttributes||!1,allowDangerousHtml:a.allowDangerousHtml||!1,voids:a.voids||br,characterReferences:a.characterReferences||ef,closeSelfClosing:a.closeSelfClosing||!1,closeEmptyElements:a.closeEmptyElements||!1},schema:a.space==="svg"?ua:Pr,quote:o,alternative:r}.one(Array.isArray(e)?{type:"root",children:e}:e,void 0,void 0)}function af(e,t,a){return ai(e,t,a,this)}function of(e){let t=[],a=e&&e.children||tf,o=-1;for(;++o<a.length;)t[o]=this.one(a[o],o,e);return t.join("")}function Na(e,t){let a=typeof e=="string"?{}:{...e.colorReplacements},o=typeof e=="string"?e:e.name;for(let[r,s]of Object.entries(t?.colorReplacements||{}))typeof s=="string"?a[r]=s:r===o&&Object.assign(a,s);return a}function Je(e,t){return e&&(t?.[e?.toLowerCase()]||e)}function rf(e){return Array.isArray(e)?e:[e]}async function ui(e){return Promise.resolve(typeof e=="function"?e():e).then(t=>t.default||t)}function Vo(e){return!e||["plaintext","txt","text","plain"].includes(e)}function di(e){return e==="ansi"||Vo(e)}function $o(e){return e==="none"}function ci(e){return $o(e)}function fi(e,t){if(!t)return e;e.properties||={},e.properties.class||=[],typeof e.properties.class=="string"&&(e.properties.class=e.properties.class.split(/\s+/g)),Array.isArray(e.properties.class)||(e.properties.class=[]);let a=Array.isArray(t)?t:t.split(/\s+/g);for(let o of a)o&&!e.properties.class.includes(o)&&e.properties.class.push(o);return e}function Wa(e,t=!1){if(e.length===0)return[["",0]];let a=e.split(/(\r?\n)/g),o=0,r=[];for(let s=0;s<a.length;s+=2){let n=t?a[s]+(a[s+1]||""):a[s];r.push([n,o]),o+=a[s].length,o+=a[s+1]?.length||0}return r}function sf(e){let t=Wa(e,!0).map(([r])=>r);function a(r){if(r===e.length)return{line:t.length-1,character:t[t.length-1].length};let s=r,n=0;for(let l of t){if(s<l.length)break;s-=l.length,n++}return{line:n,character:s}}function o(r,s){let n=0;for(let l=0;l<r;l++)n+=t[l].length;return n+=s,n}return{lines:t,indexToPos:a,posToIndex:o}}function pi(e,t,a){let o=new Set;for(let s of e.matchAll(/:?lang=["']([^"']+)["']/g)){let n=s[1].toLowerCase().trim();n&&o.add(n)}for(let s of e.matchAll(/(?:```|~~~)([\w-]+)/g)){let n=s[1].toLowerCase().trim();n&&o.add(n)}for(let s of e.matchAll(/\\begin\{([\w-]+)\}/g)){let n=s[1].toLowerCase().trim();n&&o.add(n)}for(let s of e.matchAll(/<script\s+(?:type|lang)=["']([^"']+)["']/gi)){let n=s[1].toLowerCase().trim(),l=n.includes("/")?n.split("/").pop():n;l&&o.add(l)}if(!a)return Array.from(o);let r=a.getBundledLanguages();return Array.from(o).filter(s=>s&&r[s])}var Xo="light-dark()",nf=["color","background-color"];function lf(e,t){let a=0,o=[];for(let r of t)r>a&&o.push({...e,content:e.content.slice(a,r),offset:e.offset+a}),a=r;return a<e.content.length&&o.push({...e,content:e.content.slice(a),offset:e.offset+a}),o}function uf(e,t){let a=Array.from(t instanceof Set?t:new Set(t)).sort((o,r)=>o-r);return a.length?e.map(o=>o.flatMap(r=>{let s=a.filter(n=>r.offset<n&&n<r.offset+r.content.length).map(n=>n-r.offset).sort((n,l)=>n-l);return s.length?lf(r,s):r})):e}function df(e,t,a,o,r="css-vars"){let s={content:e.content,explanation:e.explanation,offset:e.offset},n=t.map(c=>Oa(e.variants[c])),l=new Set(n.flatMap(c=>Object.keys(c))),i={},u=(c,d)=>{let p=d==="color"?"":d==="background-color"?"-bg":`-${d}`;return a+t[c]+(d==="color"?"":p)};return n.forEach((c,d)=>{for(let p of l){let m=c[p]||"inherit";if(d===0&&o&&nf.includes(p))if(o===Xo&&n.length>1){let h=t.findIndex(C=>C==="light"),I=t.findIndex(C=>C==="dark");if(h===-1||I===-1)throw new Z('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');let L=n[h][p]||"inherit",S=n[I][p]||"inherit";i[p]=`light-dark(${L}, ${S})`,r==="css-vars"&&(i[u(d,p)]=m)}else i[p]=m;else r==="css-vars"&&(i[u(d,p)]=m)}}),s.htmlStyle=i,s}function Oa(e){let t={};if(e.color&&(t.color=e.color),e.bgColor&&(t["background-color"]=e.bgColor),e.fontStyle){e.fontStyle&ce.Italic&&(t["font-style"]="italic"),e.fontStyle&ce.Bold&&(t["font-weight"]="bold");let a=[];e.fontStyle&ce.Underline&&a.push("underline"),e.fontStyle&ce.Strikethrough&&a.push("line-through"),a.length&&(t["text-decoration"]=a.join(" "))}return t}function Go(e){return typeof e=="string"?e:Object.entries(e).map(([t,a])=>`${t}:${a}`).join(";")}var mi=new WeakMap;function Ga(e,t){mi.set(e,t)}function ea(e){return mi.get(e)}var Ct=class e{_stacks={};lang;get themes(){return Object.keys(this._stacks)}get theme(){return this.themes[0]}get _stack(){return this._stacks[this.theme]}static initial(t,a){return new e(Object.fromEntries(rf(a).map(o=>[o,Ma])),t)}constructor(...t){if(t.length===2){let[a,o]=t;this.lang=o,this._stacks=a}else{let[a,o,r]=t;this.lang=o,this._stacks={[r]:a}}}getInternalStack(t=this.theme){return this._stacks[t]}getScopes(t=this.theme){return cf(this._stacks[t])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}};function cf(e){let t=[],a=new Set;function o(r){if(a.has(r))return;a.add(r);let s=r?.nameScopesList?.scopeName;s&&t.push(s),r.parent&&o(r.parent)}return o(e),t}function ff(e,t){if(!(e instanceof Ct))throw new Z("Invalid grammar state");return e.getInternalStack(t)}function pf(){let e=new WeakMap;function t(a){if(!e.has(a.meta)){let o=function(n){if(typeof n=="number"){if(n<0||n>a.source.length)throw new Z(`Invalid decoration offset: ${n}. Code length: ${a.source.length}`);return{...r.indexToPos(n),offset:n}}else{let l=r.lines[n.line];if(l===void 0)throw new Z(`Invalid decoration position ${JSON.stringify(n)}. Lines length: ${r.lines.length}`);let i=n.character;if(i<0&&(i=l.length+i),i<0||i>l.length)throw new Z(`Invalid decoration position ${JSON.stringify(n)}. Line ${n.line} length: ${l.length}`);return{...n,character:i,offset:r.posToIndex(n.line,i)}}},r=sf(a.source),s=(a.options.decorations||[]).map(n=>({...n,start:o(n.start),end:o(n.end)}));mf(s),e.set(a.meta,{decorations:s,converter:r,source:a.source})}return e.get(a.meta)}return{name:"shiki:decorations",tokens(a){if(!this.options.decorations?.length)return;let r=t(this).decorations.flatMap(n=>[n.start.offset,n.end.offset]);return uf(a,r)},code(a){if(!this.options.decorations?.length)return;let o=t(this),r=Array.from(a.children).filter(c=>c.type==="element"&&c.tagName==="span");if(r.length!==o.converter.lines.length)throw new Z(`Number of lines in code element (${r.length}) does not match the number of lines in the source (${o.converter.lines.length}). Failed to apply decorations.`);function s(c,d,p,m){let h=r[c],I="",L=-1,S=-1;if(d===0&&(L=0),p===0&&(S=0),p===Number.POSITIVE_INFINITY&&(S=h.children.length),L===-1||S===-1)for(let g=0;g<h.children.length;g++)I+=hi(h.children[g]),L===-1&&I.length===d&&(L=g+1),S===-1&&I.length===p&&(S=g+1);if(L===-1)throw new Z(`Failed to find start index for decoration ${JSON.stringify(m.start)}`);if(S===-1)throw new Z(`Failed to find end index for decoration ${JSON.stringify(m.end)}`);let C=h.children.slice(L,S);if(!m.alwaysWrap&&C.length===h.children.length)l(h,m,"line");else if(!m.alwaysWrap&&C.length===1&&C[0].type==="element")l(C[0],m,"token");else{let g={type:"element",tagName:"span",properties:{},children:C};l(g,m,"wrapper"),h.children.splice(L,C.length,g)}}function n(c,d){r[c]=l(r[c],d,"line")}function l(c,d,p){let m=d.properties||{},h=d.transform||(I=>I);return c.tagName=d.tagName||"span",c.properties={...c.properties,...m,class:c.properties.class},d.properties?.class&&fi(c,d.properties.class),c=h(c,p)||c,c}let i=[],u=o.decorations.sort((c,d)=>d.start.offset-c.start.offset||c.end.offset-d.end.offset);for(let c of u){let{start:d,end:p}=c;if(d.line===p.line)s(d.line,d.character,p.character,c);else if(d.line<p.line){s(d.line,d.character,Number.POSITIVE_INFINITY,c);for(let m=d.line+1;m<p.line;m++)i.unshift(()=>n(m,c));s(p.line,0,p.character,c)}}i.forEach(c=>c())}}}function mf(e){for(let t=0;t<e.length;t++){let a=e[t];if(a.start.offset>a.end.offset)throw new Z(`Invalid decoration range: ${JSON.stringify(a.start)} - ${JSON.stringify(a.end)}`);for(let o=t+1;o<e.length;o++){let r=e[o],s=a.start.offset<=r.start.offset&&r.start.offset<a.end.offset,n=a.start.offset<r.end.offset&&r.end.offset<=a.end.offset,l=r.start.offset<=a.start.offset&&a.start.offset<r.end.offset,i=r.start.offset<a.end.offset&&a.end.offset<=r.end.offset;if(s||n||l||i){if(s&&n||l&&i||l&&a.start.offset===a.end.offset||n&&r.start.offset===r.end.offset)continue;throw new Z(`Decorations ${JSON.stringify(a.start)} and ${JSON.stringify(r.start)} intersect.`)}}}}function hi(e){return e.type==="text"?e.value:e.type==="element"?e.children.map(hi).join(""):""}var hf=[pf()];function Ua(e){let t=gf(e.transformers||[]);return[...t.pre,...t.normal,...t.post,...hf]}function gf(e){let t=[],a=[],o=[];for(let r of e)switch(r.enforce){case"pre":t.push(r);break;case"post":a.push(r);break;default:o.push(r)}return{pre:t,post:a,normal:o}}var lt=["black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite"],qo={1:"bold",2:"dim",3:"italic",4:"underline",7:"reverse",8:"hidden",9:"strikethrough"};function wf(e,t){let a=e.indexOf("\x1B",t);if(a!==-1&&e[a+1]==="["){let o=e.indexOf("m",a);if(o!==-1)return{sequence:e.substring(a+2,o).split(";"),startPosition:a,position:o+1}}return{position:e.length}}function oi(e){let t=e.shift();if(t==="2"){let a=e.splice(0,3).map(o=>Number.parseInt(o));return a.length!==3||a.some(o=>Number.isNaN(o))?void 0:{type:"rgb",rgb:a}}else if(t==="5"){let a=e.shift();if(a)return{type:"table",index:Number(a)}}}function xf(e){let t=[];for(;e.length>0;){let a=e.shift();if(!a)continue;let o=Number.parseInt(a);if(!Number.isNaN(o))if(o===0)t.push({type:"resetAll"});else if(o<=9)qo[o]&&t.push({type:"setDecoration",value:qo[o]});else if(o<=29){let r=qo[o-20];r&&(t.push({type:"resetDecoration",value:r}),r==="dim"&&t.push({type:"resetDecoration",value:"bold"}))}else if(o<=37)t.push({type:"setForegroundColor",value:{type:"named",name:lt[o-30]}});else if(o===38){let r=oi(e);r&&t.push({type:"setForegroundColor",value:r})}else if(o===39)t.push({type:"resetForegroundColor"});else if(o<=47)t.push({type:"setBackgroundColor",value:{type:"named",name:lt[o-40]}});else if(o===48){let r=oi(e);r&&t.push({type:"setBackgroundColor",value:r})}else o===49?t.push({type:"resetBackgroundColor"}):o===53?t.push({type:"setDecoration",value:"overline"}):o===55?t.push({type:"resetDecoration",value:"overline"}):o>=90&&o<=97?t.push({type:"setForegroundColor",value:{type:"named",name:lt[o-90+8]}}):o>=100&&o<=107&&t.push({type:"setBackgroundColor",value:{type:"named",name:lt[o-100+8]}})}return t}function Lf(){let e=null,t=null,a=new Set;return{parse(o){let r=[],s=0;do{let n=wf(o,s),l=n.sequence?o.substring(s,n.startPosition):o.substring(s);if(l.length>0&&r.push({value:l,foreground:e,background:t,decorations:new Set(a)}),n.sequence){let i=xf(n.sequence);for(let u of i)u.type==="resetAll"?(e=null,t=null,a.clear()):u.type==="resetForegroundColor"?e=null:u.type==="resetBackgroundColor"?t=null:u.type==="resetDecoration"&&a.delete(u.value);for(let u of i)u.type==="setForegroundColor"?e=u.value:u.type==="setBackgroundColor"?t=u.value:u.type==="setDecoration"&&a.add(u.value)}s=n.position}while(s<o.length);return r}}}var Cf={black:"#000000",red:"#bb0000",green:"#00bb00",yellow:"#bbbb00",blue:"#0000bb",magenta:"#ff00ff",cyan:"#00bbbb",white:"#eeeeee",brightBlack:"#555555",brightRed:"#ff5555",brightGreen:"#00ff00",brightYellow:"#ffff55",brightBlue:"#5555ff",brightMagenta:"#ff55ff",brightCyan:"#55ffff",brightWhite:"#ffffff"};function If(e=Cf){function t(l){return e[l]}function a(l){return`#${l.map(i=>Math.max(0,Math.min(i,255)).toString(16).padStart(2,"0")).join("")}`}let o;function r(){if(o)return o;o=[];for(let u=0;u<lt.length;u++)o.push(t(lt[u]));let l=[0,95,135,175,215,255];for(let u=0;u<6;u++)for(let c=0;c<6;c++)for(let d=0;d<6;d++)o.push(a([l[u],l[c],l[d]]));let i=8;for(let u=0;u<24;u++,i+=10)o.push(a([i,i,i]));return o}function s(l){return r()[l]}function n(l){switch(l.type){case"named":return t(l.name);case"rgb":return a(l.rgb);case"table":return s(l.index)}}return{value:n}}var Sf={black:"#000000",red:"#cd3131",green:"#0DBC79",yellow:"#E5E510",blue:"#2472C8",magenta:"#BC3FBC",cyan:"#11A8CD",white:"#E5E5E5",brightBlack:"#666666",brightRed:"#F14C4C",brightGreen:"#23D18B",brightYellow:"#F5F543",brightBlue:"#3B8EEA",brightMagenta:"#D670D6",brightCyan:"#29B8DB",brightWhite:"#FFFFFF"};function yf(e,t,a){let o=Na(e,a),r=Wa(t),s=Object.fromEntries(lt.map(i=>{let u=`terminal.ansi${i[0].toUpperCase()}${i.substring(1)}`,c=e.colors?.[u];return[i,c||Sf[i]]})),n=If(s),l=Lf();return r.map(i=>l.parse(i[0]).map(u=>{let c,d;u.decorations.has("reverse")?(c=u.background?n.value(u.background):e.bg,d=u.foreground?n.value(u.foreground):e.fg):(c=u.foreground?n.value(u.foreground):e.fg,d=u.background?n.value(u.background):void 0),c=Je(c,o),d=Je(d,o),u.decorations.has("dim")&&(c=kf(c));let p=ce.None;return u.decorations.has("bold")&&(p|=ce.Bold),u.decorations.has("italic")&&(p|=ce.Italic),u.decorations.has("underline")&&(p|=ce.Underline),u.decorations.has("strikethrough")&&(p|=ce.Strikethrough),{content:u.value,offset:i[1],color:c,bgColor:d,fontStyle:p}}))}function kf(e){let t=e.match(/#([0-9a-f]{3,8})/i);if(t){let o=t[1];if(o.length===8){let r=Math.round(Number.parseInt(o.slice(6,8),16)/2).toString(16).padStart(2,"0");return`#${o.slice(0,6)}${r}`}else{if(o.length===6)return`#${o}80`;if(o.length===4){let r=o[0],s=o[1],n=o[2],l=o[3],i=Math.round(Number.parseInt(`${l}${l}`,16)/2).toString(16).padStart(2,"0");return`#${r}${r}${s}${s}${n}${n}${i}`}else if(o.length===3){let r=o[0],s=o[1],n=o[2];return`#${r}${r}${s}${s}${n}${n}80`}}}let a=e.match(/var\((--[\w-]+-ansi-[\w-]+)\)/);return a?`var(${a[1]}-dim)`:e}function Ko(e,t,a={}){let{theme:o=e.getLoadedThemes()[0]}=a,r=e.resolveLangAlias(a.lang||"text");if(Vo(r)||$o(o))return Wa(t).map(i=>[{content:i[0],offset:i[1]}]);let{theme:s,colorMap:n}=e.setTheme(o);if(r==="ansi")return yf(s,t,a);let l=e.getLanguage(a.lang||"text");if(a.grammarState){if(a.grammarState.lang!==l.name)throw new Z(`Grammar state language "${a.grammarState.lang}" does not match highlight language "${l.name}"`);if(!a.grammarState.themes.includes(s.name))throw new Z(`Grammar state themes "${a.grammarState.themes}" do not contain highlight theme "${s.name}"`)}return Tf(t,l,s,n,a)}function bf(...e){if(e.length===2)return ea(e[1]);let[t,a,o={}]=e,{lang:r="text",theme:s=t.getLoadedThemes()[0]}=o;if(Vo(r)||$o(s))throw new Z("Plain language does not have grammar state");if(r==="ansi")throw new Z("ANSI language does not have grammar state");let{theme:n,colorMap:l}=t.setTheme(s),i=t.getLanguage(r);return new Ct(Qo(a,i,n,l,o).stateStack,i.name,n.name)}function Tf(e,t,a,o,r){let s=Qo(e,t,a,o,r),n=new Ct(s.stateStack,t.name,a.name);return Ga(s.tokens,n),s.tokens}function Qo(e,t,a,o,r){let s=Na(a,r),{tokenizeMaxLineLength:n=0,tokenizeTimeLimit:l=500}=r,i=Wa(e),u=r.grammarState?ff(r.grammarState,a.name)??Ma:r.grammarContextCode!=null?Qo(r.grammarContextCode,t,a,o,{...r,grammarState:void 0,grammarContextCode:void 0}).stateStack:Ma,c=[],d=[];for(let p=0,m=i.length;p<m;p++){let[h,I]=i[p];if(h===""){c=[],d.push([]);continue}if(n>0&&h.length>=n){c=[],d.push([{content:h,offset:I,color:"",fontStyle:0}]);continue}let L,S,C;r.includeExplanation&&(L=t.tokenizeLine(h,u,l),S=L.tokens,C=0);let g=t.tokenizeLine2(h,u,l),k=g.tokens.length/2;for(let T=0;T<k;T++){let P=g.tokens[2*T],R=T+1<k?g.tokens[2*T+2]:h.length;if(P===R)continue;let v=g.tokens[2*T+1],_=Je(o[it.getForeground(v)],s),A=it.getFontStyle(v),E={content:h.substring(P,R),offset:I+P,color:_,fontStyle:A};if(r.includeExplanation){let y=[];if(r.includeExplanation!=="scopeName")for(let U of a.settings){let F;switch(typeof U.scope){case"string":F=U.scope.split(/,/).map(j=>j.trim());break;case"object":F=U.scope;break;default:continue}y.push({settings:U,selectors:F.map(j=>j.split(/ /))})}E.explanation=[];let M=0;for(;P+M<R;){let U=S[C],F=h.substring(U.startIndex,U.endIndex);M+=F.length,E.explanation.push({content:F,scopes:r.includeExplanation==="scopeName"?Pf(U.scopes):vf(y,U.scopes)}),C+=1}}c.push(E)}d.push(c),c=[],u=g.ruleStack}return{tokens:d,stateStack:u}}function Pf(e){return e.map(t=>({scopeName:t}))}function vf(e,t){let a=[];for(let o=0,r=t.length;o<r;o++){let s=t[o];a[o]={scopeName:s,themeMatches:Rf(e,s,t.slice(0,o))}}return a}function ri(e,t){return e===t||t.substring(0,e.length)===e&&t[e.length]==="."}function Af(e,t,a){if(!ri(e[e.length-1],t))return!1;let o=e.length-2,r=a.length-1;for(;o>=0&&r>=0;)ri(e[o],a[r])&&(o-=1),r-=1;return o===-1}function Rf(e,t,a){let o=[];for(let{selectors:r,settings:s}of e)for(let n of r)if(Af(n,t,a)){o.push(s);break}return o}function gi(e,t,a){let o=Object.entries(a.themes).filter(i=>i[1]).map(i=>({color:i[0],theme:i[1]})),r=o.map(i=>{let u=Ko(e,t,{...a,theme:i.theme}),c=ea(u),d=typeof i.theme=="string"?i.theme:i.theme.name;return{tokens:u,state:c,theme:d}}),s=Mf(...r.map(i=>i.tokens)),n=s[0].map((i,u)=>i.map((c,d)=>{let p={content:c.content,variants:{},offset:c.offset};return"includeExplanation"in a&&a.includeExplanation&&(p.explanation=c.explanation),s.forEach((m,h)=>{let{content:I,explanation:L,offset:S,...C}=m[u][d];p.variants[o[h].color]=C}),p})),l=r[0].state?new Ct(Object.fromEntries(r.map(i=>[i.theme,i.state?.getInternalStack(i.theme)])),r[0].state.lang):void 0;return l&&Ga(n,l),n}function Mf(...e){let t=e.map(()=>[]),a=e.length;for(let o=0;o<e[0].length;o++){let r=e.map(i=>i[o]),s=t.map(()=>[]);t.forEach((i,u)=>i.push(s[u]));let n=r.map(()=>0),l=r.map(i=>i[0]);for(;l.every(i=>i);){let i=Math.min(...l.map(u=>u.content.length));for(let u=0;u<a;u++){let c=l[u];c.content.length===i?(s[u].push(c),n[u]+=1,l[u]=r[u][n[u]]):(s[u].push({...c,content:c.content.slice(0,i)}),l[u]={...c,content:c.content.slice(i),offset:c.offset+i})}}}return t}function Ha(e,t,a){let o,r,s,n,l,i;if("themes"in a){let{defaultColor:u="light",cssVariablePrefix:c="--shiki-",colorsRendering:d="css-vars"}=a,p=Object.entries(a.themes).filter(S=>S[1]).map(S=>({color:S[0],theme:S[1]})).sort((S,C)=>S.color===u?-1:C.color===u?1:0);if(p.length===0)throw new Z("`themes` option must not be empty");let m=gi(e,t,a);if(i=ea(m),u&&Xo!==u&&!p.find(S=>S.color===u))throw new Z(`\`themes\` option must contain the defaultColor key \`${u}\``);let h=p.map(S=>e.getTheme(S.theme)),I=p.map(S=>S.color);s=m.map(S=>S.map(C=>df(C,I,c,u,d))),i&&Ga(s,i);let L=p.map(S=>Na(S.theme,a));r=si(p,h,L,c,u,"fg",d),o=si(p,h,L,c,u,"bg",d),n=`shiki-themes ${h.map(S=>S.name).join(" ")}`,l=u?void 0:[r,o].join(";")}else if("theme"in a){let u=Na(a.theme,a);s=Ko(e,t,a);let c=e.getTheme(a.theme);o=Je(c.bg,u),r=Je(c.fg,u),n=c.name,i=ea(s)}else throw new Z("Invalid options, either `theme` or `themes` must be provided");return{tokens:s,fg:r,bg:o,themeName:n,rootStyle:l,grammarState:i}}function si(e,t,a,o,r,s,n){return e.map((l,i)=>{let u=Je(t[i][s],a[i])||"inherit",c=`${o+l.color}${s==="bg"?"-bg":""}:${u}`;if(i===0&&r){if(r===Xo&&e.length>1){let d=e.findIndex(I=>I.color==="light"),p=e.findIndex(I=>I.color==="dark");if(d===-1||p===-1)throw new Z('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');let m=Je(t[d][s],a[d])||"inherit",h=Je(t[p][s],a[p])||"inherit";return`light-dark(${m}, ${h});${c}`}return u}return n==="css-vars"?c:null}).filter(l=>!!l).join(";")}function qa(e,t,a,o={meta:{},options:a,codeToHast:(r,s)=>qa(e,r,s),codeToTokens:(r,s)=>Ha(e,r,s)}){let r=t;for(let h of Ua(a))r=h.preprocess?.call(o,r,a)||r;let{tokens:s,fg:n,bg:l,themeName:i,rootStyle:u,grammarState:c}=Ha(e,r,a),{mergeWhitespaces:d=!0,mergeSameStyleTokens:p=!1}=a;d===!0?s=Df(s):d==="never"&&(s=Bf(s)),p&&(s=Ef(s));let m={...o,get source(){return r}};for(let h of Ua(a))s=h.tokens?.call(m,s)||s;return Ff(s,{...a,fg:n,bg:l,themeName:i,rootStyle:a.rootStyle===!1?!1:a.rootStyle??u},m,c)}function Ff(e,t,a,o=ea(e)){let r=Ua(t),s=[],n={type:"root",children:[]},{structure:l="classic",tabindex:i="0"}=t,u={class:`shiki ${t.themeName||""}`};t.rootStyle!==!1&&(t.rootStyle!=null?u.style=t.rootStyle:u.style=`background-color:${t.bg};color:${t.fg}`),i!==!1&&i!=null&&(u.tabindex=i.toString());for(let[I,L]of Object.entries(t.meta||{}))I.startsWith("_")||(u[I]=L);let c={type:"element",tagName:"pre",properties:u,children:[],data:t.data},d={type:"element",tagName:"code",properties:{},children:s},p=[],m={...a,structure:l,addClassToHast:fi,get source(){return a.source},get tokens(){return e},get options(){return t},get root(){return n},get pre(){return c},get code(){return d},get lines(){return p}};if(e.forEach((I,L)=>{L&&(l==="inline"?n.children.push({type:"element",tagName:"br",properties:{},children:[]}):l==="classic"&&s.push({type:"text",value:`
|
|
79
|
-
`}));let S={type:"element",tagName:"span",properties:{class:"line"},children:[]},C=0;for(let g of I){let k={type:"element",tagName:"span",properties:{...g.htmlAttrs},children:[{type:"text",value:g.content}]},T=Go(g.htmlStyle||Oa(g));T&&(k.properties.style=T);for(let P of r)k=P?.span?.call(m,k,L+1,C,S,g)||k;l==="inline"?n.children.push(k):l==="classic"&&S.children.push(k),C+=g.content.length}if(l==="classic"){for(let g of r)S=g?.line?.call(m,S,L+1)||S;p.push(S),s.push(S)}else l==="inline"&&p.push(S)}),l==="classic"){for(let I of r)d=I?.code?.call(m,d)||d;c.children.push(d);for(let I of r)c=I?.pre?.call(m,c)||c;n.children.push(c)}else if(l==="inline"){let I=[],L={type:"element",tagName:"span",properties:{class:"line"},children:[]};for(let g of n.children)g.type==="element"&&g.tagName==="br"?(I.push(L),L={type:"element",tagName:"span",properties:{class:"line"},children:[]}):(g.type==="element"||g.type==="text")&&L.children.push(g);I.push(L);let C={type:"element",tagName:"code",properties:{},children:I};for(let g of r)C=g?.code?.call(m,C)||C;n.children=[];for(let g=0;g<C.children.length;g++){g>0&&n.children.push({type:"element",tagName:"br",properties:{},children:[]});let k=C.children[g];k.type==="element"&&n.children.push(...k.children)}}let h=n;for(let I of r)h=I?.root?.call(m,h)||h;return o&&Ga(h,o),h}function Df(e){return e.map(t=>{let a=[],o="",r;return t.forEach((s,n)=>{let i=!(s.fontStyle&&(s.fontStyle&ce.Underline||s.fontStyle&ce.Strikethrough));i&&s.content.match(/^\s+$/)&&t[n+1]?(r===void 0&&(r=s.offset),o+=s.content):o?(i?a.push({...s,offset:r,content:o+s.content}):a.push({content:o,offset:r},s),r=void 0,o=""):a.push(s)}),a})}function Bf(e){return e.map(t=>t.flatMap(a=>{if(a.content.match(/^\s+$/))return a;let o=a.content.match(/^(\s*)(.*?)(\s*)$/);if(!o)return a;let[,r,s,n]=o;if(!r&&!n)return a;let l=[{...a,offset:a.offset+r.length,content:s}];return r&&l.unshift({content:r,offset:a.offset}),n&&l.push({content:n,offset:a.offset+r.length+s.length}),l}))}function Ef(e){return e.map(t=>{let a=[];for(let o of t){if(a.length===0){a.push({...o});continue}let r=a[a.length-1],s=Go(r.htmlStyle||Oa(r)),n=Go(o.htmlStyle||Oa(o)),l=r.fontStyle&&(r.fontStyle&ce.Underline||r.fontStyle&ce.Strikethrough),i=o.fontStyle&&(o.fontStyle&ce.Underline||o.fontStyle&ce.Strikethrough);!l&&!i&&s===n?r.content+=o.content:a.push({...o})}return a})}var _f=Ho;function Nf(e,t,a){let o={meta:{},options:a,codeToHast:(s,n)=>qa(e,s,n),codeToTokens:(s,n)=>Ha(e,s,n)},r=_f(qa(e,t,a,o));for(let s of Ua(a))r=s.postprocess?.call(o,r,a)||r;return r}var ni={light:"#333333",dark:"#bbbbbb"},ii={light:"#fffffe",dark:"#1e1e1e"},li="__shiki_resolved";function Jo(e){if(e?.[li])return e;let t={...e};t.tokenColors&&!t.settings&&(t.settings=t.tokenColors,delete t.tokenColors),t.type||="dark",t.colorReplacements={...t.colorReplacements},t.settings||=[];let{bg:a,fg:o}=t;if(!a||!o){let l=t.settings?t.settings.find(i=>!i.name&&!i.scope):void 0;l?.settings?.foreground&&(o=l.settings.foreground),l?.settings?.background&&(a=l.settings.background),!o&&t?.colors?.["editor.foreground"]&&(o=t.colors["editor.foreground"]),!a&&t?.colors?.["editor.background"]&&(a=t.colors["editor.background"]),o||(o=t.type==="light"?ni.light:ni.dark),a||(a=t.type==="light"?ii.light:ii.dark),t.fg=o,t.bg=a}t.settings[0]&&t.settings[0].settings&&!t.settings[0].scope||t.settings.unshift({settings:{foreground:t.fg,background:t.bg}});let r=0,s=new Map;function n(l){if(s.has(l))return s.get(l);r+=1;let i=`#${r.toString(16).padStart(8,"0").toLowerCase()}`;return t.colorReplacements?.[`#${i}`]?n(l):(s.set(l,i),i)}t.settings=t.settings.map(l=>{let i=l.settings?.foreground&&!l.settings.foreground.startsWith("#"),u=l.settings?.background&&!l.settings.background.startsWith("#");if(!i&&!u)return l;let c={...l,settings:{...l.settings}};if(i){let d=n(l.settings.foreground);t.colorReplacements[d]=l.settings.foreground,c.settings.foreground=d}if(u){let d=n(l.settings.background);t.colorReplacements[d]=l.settings.background,c.settings.background=d}return c});for(let l of Object.keys(t.colors||{}))if((l==="editor.foreground"||l==="editor.background"||l.startsWith("terminal.ansi"))&&!t.colors[l]?.startsWith("#")){let i=n(t.colors[l]);t.colorReplacements[i]=t.colors[l],t.colors[l]=i}return Object.defineProperty(t,li,{enumerable:!1,writable:!1,value:!0}),t}async function wi(e){return Array.from(new Set((await Promise.all(e.filter(t=>!di(t)).map(async t=>await ui(t).then(a=>Array.isArray(a)?a:[a])))).flat()))}async function xi(e){return(await Promise.all(e.map(async a=>ci(a)?null:Jo(await ui(a))))).filter(a=>!!a)}var Wo=3,Of=!1;function Uf(e,t=3){if(Wo&&!(typeof Wo=="number"&&t>Wo)){if(Of)throw new Error(`[SHIKI DEPRECATE]: ${e}`);console.trace(`[SHIKI DEPRECATE]: ${e}`)}}var Qe=class extends Error{constructor(t){super(t),this.name="ShikiError"}};function Li(e,t){if(!t)return e;if(t[e]){let a=new Set([e]);for(;t[e];){if(e=t[e],a.has(e))throw new Qe(`Circular alias \`${Array.from(a).join(" -> ")} -> ${e}\``);a.add(e)}}return e}var jo=class extends Nn{constructor(t,a,o,r={}){super(t),this._resolver=t,this._themes=a,this._langs=o,this._alias=r,this._themes.map(s=>this.loadTheme(s)),this.loadLanguages(this._langs)}_resolvedThemes=new Map;_resolvedGrammars=new Map;_langMap=new Map;_langGraph=new Map;_textmateThemeCache=new WeakMap;_loadedThemesCache=null;_loadedLanguagesCache=null;getTheme(t){return typeof t=="string"?this._resolvedThemes.get(t):this.loadTheme(t)}loadTheme(t){let a=Jo(t);return a.name&&(this._resolvedThemes.set(a.name,a),this._loadedThemesCache=null),a}getLoadedThemes(){return this._loadedThemesCache||(this._loadedThemesCache=[...this._resolvedThemes.keys()]),this._loadedThemesCache}setTheme(t){let a=this._textmateThemeCache.get(t);a||(a=$t.createFromRawTheme(t),this._textmateThemeCache.set(t,a)),this._syncRegistry.setTheme(a)}getGrammar(t){return t=Li(t,this._alias),this._resolvedGrammars.get(t)}loadLanguage(t){if(this.getGrammar(t.name))return;let a=new Set([...this._langMap.values()].filter(s=>s.embeddedLangsLazy?.includes(t.name)));this._resolver.addLanguage(t);let o={balancedBracketSelectors:t.balancedBracketSelectors||["*"],unbalancedBracketSelectors:t.unbalancedBracketSelectors||[]};this._syncRegistry._rawGrammars.set(t.scopeName,t);let r=this.loadGrammarWithConfiguration(t.scopeName,1,o);if(r.name=t.name,this._resolvedGrammars.set(t.name,r),t.aliases&&t.aliases.forEach(s=>{this._alias[s]=t.name}),this._loadedLanguagesCache=null,a.size)for(let s of a)this._resolvedGrammars.delete(s.name),this._loadedLanguagesCache=null,this._syncRegistry?._injectionGrammars?.delete(s.scopeName),this._syncRegistry?._grammars?.delete(s.scopeName),this.loadLanguage(this._langMap.get(s.name))}dispose(){super.dispose(),this._resolvedThemes.clear(),this._resolvedGrammars.clear(),this._langMap.clear(),this._langGraph.clear(),this._loadedThemesCache=null}loadLanguages(t){for(let r of t)this.resolveEmbeddedLanguages(r);let a=Array.from(this._langGraph.entries()),o=a.filter(([r,s])=>!s);if(o.length){let r=a.filter(([s,n])=>n?(n.embeddedLanguages||n.embeddedLangs)?.some(i=>o.map(([u])=>u).includes(i)):!1).filter(s=>!o.includes(s));throw new Qe(`Missing languages ${o.map(([s])=>`\`${s}\``).join(", ")}, required by ${r.map(([s])=>`\`${s}\``).join(", ")}`)}for(let[r,s]of a)this._resolver.addLanguage(s);for(let[r,s]of a)this.loadLanguage(s)}getLoadedLanguages(){return this._loadedLanguagesCache||(this._loadedLanguagesCache=[...new Set([...this._resolvedGrammars.keys(),...Object.keys(this._alias)])]),this._loadedLanguagesCache}resolveEmbeddedLanguages(t){this._langMap.set(t.name,t),this._langGraph.set(t.name,t);let a=t.embeddedLanguages??t.embeddedLangs;if(a)for(let o of a)this._langGraph.set(o,this._langMap.get(o))}},zo=class{_langs=new Map;_scopeToLang=new Map;_injections=new Map;_onigLib;constructor(t,a){this._onigLib={createOnigScanner:o=>t.createScanner(o),createOnigString:o=>t.createString(o)},a.forEach(o=>this.addLanguage(o))}get onigLib(){return this._onigLib}getLangRegistration(t){return this._langs.get(t)}loadGrammar(t){return this._scopeToLang.get(t)}addLanguage(t){this._langs.set(t.name,t),t.aliases&&t.aliases.forEach(a=>{this._langs.set(a,t)}),this._scopeToLang.set(t.scopeName,t),t.injectTo&&t.injectTo.forEach(a=>{this._injections.get(a)||this._injections.set(a,[]),this._injections.get(a).push(t.scopeName)})}getInjections(t){let a=t.split("."),o=[];for(let r=1;r<=a.length;r++){let s=a.slice(0,r).join(".");o=[...o,...this._injections.get(s)||[]]}return o}},Yt=0;function Hf(e){Yt+=1,e.warnings!==!1&&Yt>=10&&Yt%10===0&&console.warn(`[Shiki] ${Yt} instances have been created. Shiki is supposed to be used as a singleton, consider refactoring your code to cache your highlighter instance; Or call \`highlighter.dispose()\` to release unused instances.`);let t=!1;if(!e.engine)throw new Qe("`engine` option is required for synchronous mode");let a=(e.langs||[]).flat(1),o=(e.themes||[]).flat(1).map(Jo),r=new zo(e.engine,a),s=new jo(r,o,a,e.langAlias),n;function l(g){return Li(g,e.langAlias)}function i(g){S();let k=s.getGrammar(typeof g=="string"?g:g.name);if(!k)throw new Qe(`Language \`${g}\` not found, you may need to load it first`);return k}function u(g){if(g==="none")return{bg:"",fg:"",name:"none",settings:[],type:"dark"};S();let k=s.getTheme(g);if(!k)throw new Qe(`Theme \`${g}\` not found, you may need to load it first`);return k}function c(g){S();let k=u(g);n!==g&&(s.setTheme(k),n=g);let T=s.getColorMap();return{theme:k,colorMap:T}}function d(){return S(),s.getLoadedThemes()}function p(){return S(),s.getLoadedLanguages()}function m(...g){S(),s.loadLanguages(g.flat(1))}async function h(...g){return m(await wi(g))}function I(...g){S();for(let k of g.flat(1))s.loadTheme(k)}async function L(...g){return S(),I(await xi(g))}function S(){if(t)throw new Qe("Shiki instance has been disposed")}function C(){t||(t=!0,s.dispose(),Yt-=1)}return{setTheme:c,getTheme:u,getLanguage:i,getLoadedThemes:d,getLoadedLanguages:p,resolveLangAlias:l,loadLanguage:h,loadLanguageSync:m,loadTheme:L,loadThemeSync:I,dispose:C,[Symbol.dispose]:C}}async function qf(e){e.engine||Uf("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");let[t,a,o]=await Promise.all([xi(e.themes||[]),wi(e.langs||[]),e.engine]);return Hf({...e,themes:t,langs:a,engine:o})}async function Wf(e){let t=await qf(e);return{getLastGrammarState:(...a)=>bf(t,...a),codeToTokensBase:(a,o)=>Ko(t,a,o),codeToTokensWithThemes:(a,o)=>gi(t,a,o),codeToTokens:(a,o)=>Ha(t,a,o),codeToHast:(a,o)=>qa(t,a,o),codeToHtml:(a,o)=>Nf(t,a,o),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...t,getInternalContext:()=>t}}function Ci(e){let t=e.langs,a=e.themes,o=e.engine;async function r(s){function n(d){if(typeof d=="string"){if(d=s.langAlias?.[d]||d,di(d))return[];let p=t[d];if(!p)throw new Z(`Language \`${d}\` is not included in this bundle. You may want to load it from external source.`);return p}return d}function l(d){if(ci(d))return"none";if(typeof d=="string"){let p=a[d];if(!p)throw new Z(`Theme \`${d}\` is not included in this bundle. You may want to load it from external source.`);return p}return d}let i=(s.themes??[]).map(d=>l(d)),u=(s.langs??[]).map(d=>n(d)),c=await Wf({engine:s.engine??o(),...s,themes:i,langs:u});return{...c,loadLanguage(...d){return c.loadLanguage(...d.map(n))},loadTheme(...d){return c.loadTheme(...d.map(l))},getBundledLanguages(){return t},getBundledThemes(){return a}}}return r}function Gf(e){let t;async function a(o={}){if(t){let r=await t;return await Promise.all([r.loadTheme(...o.themes||[]),r.loadLanguage(...o.langs||[])]),r}else{t=e({...o,themes:[],langs:[]});let r=await t;return await Promise.all([r.loadTheme(...o.themes||[]),r.loadLanguage(...o.langs||[])]),r}}return a}function Ii(e,t){let a=Gf(e);async function o(r,s){let n=await a({langs:[s.lang],themes:"theme"in s?[s.theme]:Object.values(s.themes)}),l=await t?.guessEmbeddedLanguages?.(r,s.lang,n);return l&&await n.loadLanguage(...l),n}return{getSingletonHighlighter(r){return a(r)},async codeToHtml(r,s){return(await o(r,s)).codeToHtml(r,s)},async codeToHast(r,s){return(await o(r,s)).codeToHast(r,s)},async codeToTokens(r,s){return(await o(r,s)).codeToTokens(r,s)},async codeToTokensBase(r,s){return(await o(r,s)).codeToTokensBase(r,s)},async codeToTokensWithThemes(r,s){return(await o(r,s)).codeToTokensWithThemes(r,s)},async getLastGrammarState(r,s){return(await a({langs:[s.lang],themes:[s.theme]})).getLastGrammarState(r,s)}}}f();var Zo=[{id:"abap",name:"ABAP",import:(()=>import("../abap-3IAGZ3PS.js"))},{id:"actionscript-3",name:"ActionScript",import:(()=>import("../actionscript-3-C46RIPM4.js"))},{id:"ada",name:"Ada",import:(()=>import("../ada-DNTYS66P.js"))},{id:"angular-html",name:"Angular HTML",import:(()=>import("../angular-html-VZSV3CDH.js"))},{id:"angular-ts",name:"Angular TypeScript",import:(()=>import("../angular-ts-UPMUIYI3.js"))},{id:"apache",name:"Apache Conf",import:(()=>import("../apache-DU26FTNI.js"))},{id:"apex",name:"Apex",import:(()=>import("../apex-OU63AG2P.js"))},{id:"apl",name:"APL",import:(()=>import("../apl-ZTMAKUPW.js"))},{id:"applescript",name:"AppleScript",import:(()=>import("../applescript-TT4XSRXH.js"))},{id:"ara",name:"Ara",import:(()=>import("../ara-Q7AJDKA4.js"))},{id:"asciidoc",name:"AsciiDoc",aliases:["adoc"],import:(()=>import("../asciidoc-WADBFJPS.js"))},{id:"asm",name:"Assembly",import:(()=>import("../asm-D3LJR7GV.js"))},{id:"astro",name:"Astro",import:(()=>import("../astro-ZC25ZSBI.js"))},{id:"awk",name:"AWK",import:(()=>import("../awk-DCAM52A7.js"))},{id:"ballerina",name:"Ballerina",import:(()=>import("../ballerina-44XARFEK.js"))},{id:"bat",name:"Batch File",aliases:["batch"],import:(()=>import("../bat-WM4RL2AB.js"))},{id:"beancount",name:"Beancount",import:(()=>import("../beancount-5PUWGPVT.js"))},{id:"berry",name:"Berry",aliases:["be"],import:(()=>import("../berry-YAK4XTWX.js"))},{id:"bibtex",name:"BibTeX",import:(()=>import("../bibtex-2ISWNMJJ.js"))},{id:"bicep",name:"Bicep",import:(()=>import("../bicep-EOACOM4G.js"))},{id:"blade",name:"Blade",import:(()=>import("../blade-BVUO2H7O.js"))},{id:"bsl",name:"1C (Enterprise)",aliases:["1c"],import:(()=>import("../bsl-TNLQPNE3.js"))},{id:"c",name:"C",import:(()=>import("../c-G7V525MX.js"))},{id:"c3",name:"C3",import:(()=>import("../c3-CDQIRWGP.js"))},{id:"cadence",name:"Cadence",aliases:["cdc"],import:(()=>import("../cadence-U32GKKTR.js"))},{id:"cairo",name:"Cairo",import:(()=>import("../cairo-26RR6N4F.js"))},{id:"clarity",name:"Clarity",import:(()=>import("../clarity-4JIHRN2V.js"))},{id:"clojure",name:"Clojure",aliases:["clj"],import:(()=>import("../clojure-PKTTXYYS.js"))},{id:"cmake",name:"CMake",import:(()=>import("../cmake-HXKHWGGH.js"))},{id:"cobol",name:"COBOL",import:(()=>import("../cobol-SKJIT3WM.js"))},{id:"codeowners",name:"CODEOWNERS",import:(()=>import("../codeowners-WCXRHQ2R.js"))},{id:"codeql",name:"CodeQL",aliases:["ql"],import:(()=>import("../codeql-XZZ2USHF.js"))},{id:"coffee",name:"CoffeeScript",aliases:["coffeescript"],import:(()=>import("../coffee-SGQWHBUL.js"))},{id:"common-lisp",name:"Common Lisp",aliases:["lisp"],import:(()=>import("../common-lisp-IK3DGBCK.js"))},{id:"coq",name:"Coq",import:(()=>import("../coq-UPTUVPLH.js"))},{id:"cpp",name:"C++",aliases:["c++"],import:(()=>import("../cpp-4EW5XLOK.js"))},{id:"crystal",name:"Crystal",import:(()=>import("../crystal-YFCJLEES.js"))},{id:"csharp",name:"C#",aliases:["c#","cs"],import:(()=>import("../csharp-6EXQ7B24.js"))},{id:"css",name:"CSS",import:(()=>import("../css-MH4LSMNV.js"))},{id:"csv",name:"CSV",import:(()=>import("../csv-CRTD5FOL.js"))},{id:"cue",name:"CUE",import:(()=>import("../cue-IFMTDLM2.js"))},{id:"cypher",name:"Cypher",aliases:["cql"],import:(()=>import("../cypher-WH7754G7.js"))},{id:"d",name:"D",import:(()=>import("../d-VFMGCSG3.js"))},{id:"dart",name:"Dart",import:(()=>import("../dart-CSERBUPM.js"))},{id:"dax",name:"DAX",import:(()=>import("../dax-Y4DTPR3K.js"))},{id:"desktop",name:"Desktop",import:(()=>import("../desktop-UYAYGPQT.js"))},{id:"diff",name:"Diff",import:(()=>import("../diff-BJDM3N45.js"))},{id:"docker",name:"Dockerfile",aliases:["dockerfile"],import:(()=>import("../docker-UOM4Q7PD.js"))},{id:"dotenv",name:"dotEnv",import:(()=>import("../dotenv-LK44WBD3.js"))},{id:"dream-maker",name:"Dream Maker",import:(()=>import("../dream-maker-7RP4JRQH.js"))},{id:"edge",name:"Edge",import:(()=>import("../edge-3LWPZYS7.js"))},{id:"elixir",name:"Elixir",import:(()=>import("../elixir-3H7W7YJZ.js"))},{id:"elm",name:"Elm",import:(()=>import("../elm-THYL2NRS.js"))},{id:"emacs-lisp",name:"Emacs Lisp",aliases:["elisp"],import:(()=>import("../emacs-lisp-YHLQYGNI.js"))},{id:"erb",name:"ERB",import:(()=>import("../erb-AXCKAI43.js"))},{id:"erlang",name:"Erlang",aliases:["erl"],import:(()=>import("../erlang-UNX5MMGA.js"))},{id:"fennel",name:"Fennel",import:(()=>import("../fennel-HYSSBG3N.js"))},{id:"fish",name:"Fish",import:(()=>import("../fish-PTKGQOJI.js"))},{id:"fluent",name:"Fluent",aliases:["ftl"],import:(()=>import("../fluent-LEZHPPJV.js"))},{id:"fortran-fixed-form",name:"Fortran (Fixed Form)",aliases:["f","for","f77"],import:(()=>import("../fortran-fixed-form-J5AMEFMB.js"))},{id:"fortran-free-form",name:"Fortran (Free Form)",aliases:["f90","f95","f03","f08","f18"],import:(()=>import("../fortran-free-form-S3BNTBLS.js"))},{id:"fsharp",name:"F#",aliases:["f#","fs"],import:(()=>import("../fsharp-H4OIW62Z.js"))},{id:"gdresource",name:"GDResource",aliases:["tscn","tres"],import:(()=>import("../gdresource-A6NTYFLM.js"))},{id:"gdscript",name:"GDScript",aliases:["gd"],import:(()=>import("../gdscript-YQUSJRNZ.js"))},{id:"gdshader",name:"GDShader",import:(()=>import("../gdshader-S5432GFE.js"))},{id:"genie",name:"Genie",import:(()=>import("../genie-RNVG5N7L.js"))},{id:"gherkin",name:"Gherkin",import:(()=>import("../gherkin-E5R62T6O.js"))},{id:"git-commit",name:"Git Commit Message",import:(()=>import("../git-commit-QGH6XOBG.js"))},{id:"git-rebase",name:"Git Rebase Message",import:(()=>import("../git-rebase-XTCZTXU4.js"))},{id:"gleam",name:"Gleam",import:(()=>import("../gleam-W5WZ7CST.js"))},{id:"glimmer-js",name:"Glimmer JS",aliases:["gjs"],import:(()=>import("../glimmer-js-ZXI6Y36F.js"))},{id:"glimmer-ts",name:"Glimmer TS",aliases:["gts"],import:(()=>import("../glimmer-ts-BJKMFBLF.js"))},{id:"glsl",name:"GLSL",import:(()=>import("../glsl-PVW2OPUD.js"))},{id:"gn",name:"GN",import:(()=>import("../gn-FCAO7WI5.js"))},{id:"gnuplot",name:"Gnuplot",import:(()=>import("../gnuplot-Q6SE5CHZ.js"))},{id:"go",name:"Go",import:(()=>import("../go-CPCZAAWX.js"))},{id:"graphql",name:"GraphQL",aliases:["gql"],import:(()=>import("../graphql-KHEFECOG.js"))},{id:"groovy",name:"Groovy",import:(()=>import("../groovy-PJAEBBJY.js"))},{id:"hack",name:"Hack",import:(()=>import("../hack-KV5GHBVV.js"))},{id:"haml",name:"Ruby Haml",import:(()=>import("../haml-6R7X7F2Q.js"))},{id:"handlebars",name:"Handlebars",aliases:["hbs"],import:(()=>import("../handlebars-U44VLSEQ.js"))},{id:"haskell",name:"Haskell",aliases:["hs"],import:(()=>import("../haskell-NX6XRMNO.js"))},{id:"haxe",name:"Haxe",import:(()=>import("../haxe-7YNB7FVC.js"))},{id:"hcl",name:"HashiCorp HCL",import:(()=>import("../hcl-ZF75ASCX.js"))},{id:"hjson",name:"Hjson",import:(()=>import("../hjson-65TX6QOC.js"))},{id:"hlsl",name:"HLSL",import:(()=>import("../hlsl-U2O526MI.js"))},{id:"html",name:"HTML",import:(()=>import("../html-MYZBE4UD.js"))},{id:"html-derivative",name:"HTML (Derivative)",import:(()=>import("../html-derivative-OWRPAN3G.js"))},{id:"http",name:"HTTP",import:(()=>import("../http-JSPDAWSO.js"))},{id:"hurl",name:"Hurl",import:(()=>import("../hurl-OT2SM4S7.js"))},{id:"hxml",name:"HXML",import:(()=>import("../hxml-IGTXIURH.js"))},{id:"hy",name:"Hy",import:(()=>import("../hy-CLDGXJYP.js"))},{id:"imba",name:"Imba",import:(()=>import("../imba-NWHLCVE5.js"))},{id:"ini",name:"INI",aliases:["properties"],import:(()=>import("../ini-R6WYP7NC.js"))},{id:"java",name:"Java",import:(()=>import("../java-DHBXDMBM.js"))},{id:"javascript",name:"JavaScript",aliases:["js","cjs","mjs"],import:(()=>import("../javascript-GNUEDNHO.js"))},{id:"jinja",name:"Jinja",import:(()=>import("../jinja-CCI3FGLW.js"))},{id:"jison",name:"Jison",import:(()=>import("../jison-64A6IJCV.js"))},{id:"json",name:"JSON",import:(()=>import("../json-2ELCHKXT.js"))},{id:"json5",name:"JSON5",import:(()=>import("../json5-QRH5UJYD.js"))},{id:"jsonc",name:"JSON with Comments",import:(()=>import("../jsonc-IXPVR4NY.js"))},{id:"jsonl",name:"JSON Lines",import:(()=>import("../jsonl-C57GMUK5.js"))},{id:"jsonnet",name:"Jsonnet",import:(()=>import("../jsonnet-VNADFLKI.js"))},{id:"jssm",name:"JSSM",aliases:["fsl"],import:(()=>import("../jssm-CW4ZYDSF.js"))},{id:"jsx",name:"JSX",import:(()=>import("../jsx-YTENXENT.js"))},{id:"julia",name:"Julia",aliases:["jl"],import:(()=>import("../julia-BWWONBRS.js"))},{id:"kdl",name:"KDL",import:(()=>import("../kdl-X3AS2HRT.js"))},{id:"kotlin",name:"Kotlin",aliases:["kt","kts"],import:(()=>import("../kotlin-WGITM75W.js"))},{id:"kusto",name:"Kusto",aliases:["kql"],import:(()=>import("../kusto-LT46F7AO.js"))},{id:"latex",name:"LaTeX",import:(()=>import("../latex-R4PJ7JDY.js"))},{id:"lean",name:"Lean 4",aliases:["lean4"],import:(()=>import("../lean-DYWOENAS.js"))},{id:"less",name:"Less",import:(()=>import("../less-ZYJT7MPU.js"))},{id:"liquid",name:"Liquid",import:(()=>import("../liquid-OSRU4KOW.js"))},{id:"llvm",name:"LLVM IR",import:(()=>import("../llvm-WBQ7MHV7.js"))},{id:"log",name:"Log file",import:(()=>import("../log-AXKDFD3L.js"))},{id:"logo",name:"Logo",import:(()=>import("../logo-E23LAFZY.js"))},{id:"lua",name:"Lua",import:(()=>import("../lua-QQ5QEPPO.js"))},{id:"luau",name:"Luau",import:(()=>import("../luau-D432BEB5.js"))},{id:"make",name:"Makefile",aliases:["makefile"],import:(()=>import("../make-QFMWQJMG.js"))},{id:"markdown",name:"Markdown",aliases:["md"],import:(()=>import("../markdown-D756RUOP.js"))},{id:"marko",name:"Marko",import:(()=>import("../marko-WVASNOGB.js"))},{id:"matlab",name:"MATLAB",import:(()=>import("../matlab-ZKZ7YBAH.js"))},{id:"mdc",name:"MDC",import:(()=>import("../mdc-PDOFYVVO.js"))},{id:"mdx",name:"MDX",import:(()=>import("../mdx-34BL2O4O.js"))},{id:"mermaid",name:"Mermaid",aliases:["mmd"],import:(()=>import("../mermaid-54Z3SAII.js"))},{id:"mipsasm",name:"MIPS Assembly",aliases:["mips"],import:(()=>import("../mipsasm-NKQWJEL7.js"))},{id:"mojo",name:"Mojo",import:(()=>import("../mojo-KRRNBH7O.js"))},{id:"moonbit",name:"MoonBit",aliases:["mbt","mbti"],import:(()=>import("../moonbit-LQ7JL5LZ.js"))},{id:"move",name:"Move",import:(()=>import("../move-4VWCI4YQ.js"))},{id:"narrat",name:"Narrat Language",aliases:["nar"],import:(()=>import("../narrat-4QSDQDLH.js"))},{id:"nextflow",name:"Nextflow",aliases:["nf"],import:(()=>import("../nextflow-DPCEWQNZ.js"))},{id:"nginx",name:"Nginx",import:(()=>import("../nginx-DXHAXQRH.js"))},{id:"nim",name:"Nim",import:(()=>import("../nim-WGQAUAVA.js"))},{id:"nix",name:"Nix",import:(()=>import("../nix-WAYR4BYU.js"))},{id:"nushell",name:"nushell",aliases:["nu"],import:(()=>import("../nushell-26KZW4VL.js"))},{id:"objective-c",name:"Objective-C",aliases:["objc"],import:(()=>import("../objective-c-246HWLKT.js"))},{id:"objective-cpp",name:"Objective-C++",import:(()=>import("../objective-cpp-RJUXXPYQ.js"))},{id:"ocaml",name:"OCaml",import:(()=>import("../ocaml-P7NGS7PR.js"))},{id:"odin",name:"Odin",import:(()=>import("../odin-UPPZCJGN.js"))},{id:"openscad",name:"OpenSCAD",aliases:["scad"],import:(()=>import("../openscad-JRK6K3FL.js"))},{id:"pascal",name:"Pascal",import:(()=>import("../pascal-RDFLUHHA.js"))},{id:"perl",name:"Perl",import:(()=>import("../perl-Y3ALUOFJ.js"))},{id:"php",name:"PHP",import:(()=>import("../php-QERWOQJG.js"))},{id:"pkl",name:"Pkl",import:(()=>import("../pkl-PAM76VXP.js"))},{id:"plsql",name:"PL/SQL",import:(()=>import("../plsql-3Y6UMFEG.js"))},{id:"po",name:"Gettext PO",aliases:["pot","potx"],import:(()=>import("../po-GNTAKCTE.js"))},{id:"polar",name:"Polar",import:(()=>import("../polar-EVTMRLGV.js"))},{id:"postcss",name:"PostCSS",import:(()=>import("../postcss-42343LW7.js"))},{id:"powerquery",name:"PowerQuery",import:(()=>import("../powerquery-M34PNR4X.js"))},{id:"powershell",name:"PowerShell",aliases:["ps","ps1"],import:(()=>import("../powershell-IR7ICFQW.js"))},{id:"prisma",name:"Prisma",import:(()=>import("../prisma-RXSIFLZX.js"))},{id:"prolog",name:"Prolog",import:(()=>import("../prolog-YBBQ4UD5.js"))},{id:"proto",name:"Protocol Buffer 3",aliases:["protobuf"],import:(()=>import("../proto-U4FF45G6.js"))},{id:"pug",name:"Pug",aliases:["jade"],import:(()=>import("../pug-7XNGVJEC.js"))},{id:"puppet",name:"Puppet",import:(()=>import("../puppet-HWOKIYJP.js"))},{id:"purescript",name:"PureScript",import:(()=>import("../purescript-D45AJS5J.js"))},{id:"python",name:"Python",aliases:["py"],import:(()=>import("../python-QWA7UE2I.js"))},{id:"qml",name:"QML",import:(()=>import("../qml-RHCWFR3S.js"))},{id:"qmldir",name:"QML Directory",import:(()=>import("../qmldir-FBDC3XMZ.js"))},{id:"qss",name:"Qt Style Sheets",import:(()=>import("../qss-AD3WZQ45.js"))},{id:"r",name:"R",import:(()=>import("../r-NHIAHDOD.js"))},{id:"racket",name:"Racket",import:(()=>import("../racket-7G65C5N5.js"))},{id:"raku",name:"Raku",aliases:["perl6"],import:(()=>import("../raku-IWS7BLGD.js"))},{id:"razor",name:"ASP.NET Razor",import:(()=>import("../razor-C2NV2YNT.js"))},{id:"reg",name:"Windows Registry Script",import:(()=>import("../reg-V4XLWESR.js"))},{id:"regexp",name:"RegExp",aliases:["regex"],import:(()=>import("../regexp-XP4MR635.js"))},{id:"rel",name:"Rel",import:(()=>import("../rel-DE6UXATM.js"))},{id:"riscv",name:"RISC-V",import:(()=>import("../riscv-5PDXBPPL.js"))},{id:"ron",name:"RON",import:(()=>import("../ron-WD6BJFDY.js"))},{id:"rosmsg",name:"ROS Interface",import:(()=>import("../rosmsg-7LDUCZRQ.js"))},{id:"rst",name:"reStructuredText",import:(()=>import("../rst-W5S2XFF7.js"))},{id:"ruby",name:"Ruby",aliases:["rb"],import:(()=>import("../ruby-EYYAUQUG.js"))},{id:"rust",name:"Rust",aliases:["rs"],import:(()=>import("../rust-Z2NYMT2Z.js"))},{id:"sas",name:"SAS",import:(()=>import("../sas-A4JCTK6H.js"))},{id:"sass",name:"Sass",import:(()=>import("../sass-75VDP7DE.js"))},{id:"scala",name:"Scala",import:(()=>import("../scala-7TJ4N6KC.js"))},{id:"scheme",name:"Scheme",import:(()=>import("../scheme-5XARZMKT.js"))},{id:"scss",name:"SCSS",import:(()=>import("../scss-4QR2BXFS.js"))},{id:"sdbl",name:"1C (Query)",aliases:["1c-query"],import:(()=>import("../sdbl-6M55AJVA.js"))},{id:"shaderlab",name:"ShaderLab",aliases:["shader"],import:(()=>import("../shaderlab-322XNY5V.js"))},{id:"shellscript",name:"Shell",aliases:["bash","sh","shell","zsh"],import:(()=>import("../shellscript-F23VVVTW.js"))},{id:"shellsession",name:"Shell Session",aliases:["console"],import:(()=>import("../shellsession-G65XJMCC.js"))},{id:"smalltalk",name:"Smalltalk",import:(()=>import("../smalltalk-LALIO5SC.js"))},{id:"solidity",name:"Solidity",import:(()=>import("../solidity-TQUKTJZZ.js"))},{id:"soy",name:"Closure Templates",aliases:["closure-templates"],import:(()=>import("../soy-G2LDZSDN.js"))},{id:"sparql",name:"SPARQL",import:(()=>import("../sparql-ARI3MVK7.js"))},{id:"splunk",name:"Splunk Query Language",aliases:["spl"],import:(()=>import("../splunk-QEFG3NPJ.js"))},{id:"sql",name:"SQL",import:(()=>import("../sql-SBP7VV3V.js"))},{id:"ssh-config",name:"SSH Config",import:(()=>import("../ssh-config-SC6RC6IV.js"))},{id:"stata",name:"Stata",import:(()=>import("../stata-MNI5YOQU.js"))},{id:"stylus",name:"Stylus",aliases:["styl"],import:(()=>import("../stylus-YYWEHAK3.js"))},{id:"surrealql",name:"SurrealQL",aliases:["surql"],import:(()=>import("../surrealql-5X7LI3J6.js"))},{id:"svelte",name:"Svelte",import:(()=>import("../svelte-EYZDXUS2.js"))},{id:"swift",name:"Swift",import:(()=>import("../swift-JEBLU4EM.js"))},{id:"system-verilog",name:"SystemVerilog",import:(()=>import("../system-verilog-46QRSGNM.js"))},{id:"systemd",name:"Systemd Units",import:(()=>import("../systemd-3PUVCSI7.js"))},{id:"talonscript",name:"TalonScript",aliases:["talon"],import:(()=>import("../talonscript-AK4LB3KC.js"))},{id:"tasl",name:"Tasl",import:(()=>import("../tasl-VHTYBUVI.js"))},{id:"tcl",name:"Tcl",import:(()=>import("../tcl-UUMKHRHL.js"))},{id:"templ",name:"Templ",import:(()=>import("../templ-KXQ2KV7D.js"))},{id:"terraform",name:"Terraform",aliases:["tf","tfvars"],import:(()=>import("../terraform-GCGIT2RL.js"))},{id:"tex",name:"TeX",import:(()=>import("../tex-L55DZDKV.js"))},{id:"toml",name:"TOML",import:(()=>import("../toml-7AH4HFBN.js"))},{id:"ts-tags",name:"TypeScript with Tags",aliases:["lit"],import:(()=>import("../ts-tags-TCQ23O6Y.js"))},{id:"tsv",name:"TSV",import:(()=>import("../tsv-EB3LRXYX.js"))},{id:"tsx",name:"TSX",import:(()=>import("../tsx-Y5YXGNIX.js"))},{id:"turtle",name:"Turtle",import:(()=>import("../turtle-KM6UGYIQ.js"))},{id:"twig",name:"Twig",import:(()=>import("../twig-JAL4753Y.js"))},{id:"typescript",name:"TypeScript",aliases:["ts","cts","mts"],import:(()=>import("../typescript-ZF5AMNEZ.js"))},{id:"typespec",name:"TypeSpec",aliases:["tsp"],import:(()=>import("../typespec-6JSRRA42.js"))},{id:"typst",name:"Typst",aliases:["typ"],import:(()=>import("../typst-ZOSAUKL5.js"))},{id:"v",name:"V",import:(()=>import("../v-HVLBO3DI.js"))},{id:"vala",name:"Vala",import:(()=>import("../vala-WWRVCJNF.js"))},{id:"vb",name:"Visual Basic",aliases:["cmd"],import:(()=>import("../vb-XFFF4O73.js"))},{id:"verilog",name:"Verilog",import:(()=>import("../verilog-XTDPJNP7.js"))},{id:"vhdl",name:"VHDL",import:(()=>import("../vhdl-OCZJ2AOZ.js"))},{id:"viml",name:"Vim Script",aliases:["vim","vimscript"],import:(()=>import("../viml-PVA3ZJ5L.js"))},{id:"vue",name:"Vue",import:(()=>import("../vue-D6SXQNWM.js"))},{id:"vue-html",name:"Vue HTML",import:(()=>import("../vue-html-G4DE7FYD.js"))},{id:"vue-vine",name:"Vue Vine",import:(()=>import("../vue-vine-T6MFB2MU.js"))},{id:"vyper",name:"Vyper",aliases:["vy"],import:(()=>import("../vyper-SBDFKHRI.js"))},{id:"wasm",name:"WebAssembly",import:(()=>import("../wasm-SXNE4SKX.js"))},{id:"wenyan",name:"Wenyan",aliases:["\u6587\u8A00"],import:(()=>import("../wenyan-PMSCJP7P.js"))},{id:"wgsl",name:"WGSL",import:(()=>import("../wgsl-DOXQU7M4.js"))},{id:"wikitext",name:"Wikitext",aliases:["mediawiki","wiki"],import:(()=>import("../wikitext-LGNEKWDX.js"))},{id:"wit",name:"WebAssembly Interface Types",import:(()=>import("../wit-G62U2KBE.js"))},{id:"wolfram",name:"Wolfram",aliases:["wl"],import:(()=>import("../wolfram-YTZHUYN6.js"))},{id:"xml",name:"XML",import:(()=>import("../xml-WGLM4CWK.js"))},{id:"xsl",name:"XSL",import:(()=>import("../xsl-KAAH2GEK.js"))},{id:"yaml",name:"YAML",aliases:["yml"],import:(()=>import("../yaml-JGEBDSVI.js"))},{id:"zenscript",name:"ZenScript",import:(()=>import("../zenscript-QQQPZNJ7.js"))},{id:"zig",name:"Zig",import:(()=>import("../zig-6LJUAPBA.js"))}],Si=Object.fromEntries(Zo.map(e=>[e.id,e.import])),yi=Object.fromEntries(Zo.flatMap(e=>e.aliases?.map(t=>[t,e.import])||[])),ta={...Si,...yi};f();var jf=[{id:"andromeeda",displayName:"Andromeeda",type:"dark",import:(()=>import("../andromeeda-XSK3JERF.js"))},{id:"aurora-x",displayName:"Aurora X",type:"dark",import:(()=>import("../aurora-x-CGSVHL4H.js"))},{id:"ayu-dark",displayName:"Ayu Dark",type:"dark",import:(()=>import("../ayu-dark-XYI57HMC.js"))},{id:"ayu-light",displayName:"Ayu Light",type:"light",import:(()=>import("../ayu-light-4PSGMDIC.js"))},{id:"ayu-mirage",displayName:"Ayu Mirage",type:"dark",import:(()=>import("../ayu-mirage-DU5SNMZX.js"))},{id:"catppuccin-frappe",displayName:"Catppuccin Frapp\xE9",type:"dark",import:(()=>import("../catppuccin-frappe-UZ4N3Z4I.js"))},{id:"catppuccin-latte",displayName:"Catppuccin Latte",type:"light",import:(()=>import("../catppuccin-latte-GCOWYLZG.js"))},{id:"catppuccin-macchiato",displayName:"Catppuccin Macchiato",type:"dark",import:(()=>import("../catppuccin-macchiato-PJD7W5WJ.js"))},{id:"catppuccin-mocha",displayName:"Catppuccin Mocha",type:"dark",import:(()=>import("../catppuccin-mocha-RRH4FOBS.js"))},{id:"dark-plus",displayName:"Dark Plus",type:"dark",import:(()=>import("../dark-plus-PSM5XP2I.js"))},{id:"dracula",displayName:"Dracula Theme",type:"dark",import:(()=>import("../dracula-2VHT5LK5.js"))},{id:"dracula-soft",displayName:"Dracula Theme Soft",type:"dark",import:(()=>import("../dracula-soft-MSCUO73T.js"))},{id:"everforest-dark",displayName:"Everforest Dark",type:"dark",import:(()=>import("../everforest-dark-AGVJEQ35.js"))},{id:"everforest-light",displayName:"Everforest Light",type:"light",import:(()=>import("../everforest-light-62GPFKVJ.js"))},{id:"github-dark",displayName:"GitHub Dark",type:"dark",import:(()=>import("../github-dark-5OJVMBCE.js"))},{id:"github-dark-default",displayName:"GitHub Dark Default",type:"dark",import:(()=>import("../github-dark-default-4WERFSZW.js"))},{id:"github-dark-dimmed",displayName:"GitHub Dark Dimmed",type:"dark",import:(()=>import("../github-dark-dimmed-7VD3SZKC.js"))},{id:"github-dark-high-contrast",displayName:"GitHub Dark High Contrast",type:"dark",import:(()=>import("../github-dark-high-contrast-FVMMS656.js"))},{id:"github-light",displayName:"GitHub Light",type:"light",import:(()=>import("../github-light-SE4LEKO7.js"))},{id:"github-light-default",displayName:"GitHub Light Default",type:"light",import:(()=>import("../github-light-default-TV7BYQGI.js"))},{id:"github-light-high-contrast",displayName:"GitHub Light High Contrast",type:"light",import:(()=>import("../github-light-high-contrast-WKO4I3G7.js"))},{id:"gruvbox-dark-hard",displayName:"Gruvbox Dark Hard",type:"dark",import:(()=>import("../gruvbox-dark-hard-LOYZQIGI.js"))},{id:"gruvbox-dark-medium",displayName:"Gruvbox Dark Medium",type:"dark",import:(()=>import("../gruvbox-dark-medium-UIMSJJ6K.js"))},{id:"gruvbox-dark-soft",displayName:"Gruvbox Dark Soft",type:"dark",import:(()=>import("../gruvbox-dark-soft-PU6RNTTO.js"))},{id:"gruvbox-light-hard",displayName:"Gruvbox Light Hard",type:"light",import:(()=>import("../gruvbox-light-hard-ZQJ7XSZF.js"))},{id:"gruvbox-light-medium",displayName:"Gruvbox Light Medium",type:"light",import:(()=>import("../gruvbox-light-medium-CD3ZGYV6.js"))},{id:"gruvbox-light-soft",displayName:"Gruvbox Light Soft",type:"light",import:(()=>import("../gruvbox-light-soft-S74MAGOM.js"))},{id:"horizon",displayName:"Horizon",type:"dark",import:(()=>import("../horizon-EAAZ4KVN.js"))},{id:"houston",displayName:"Houston",type:"dark",import:(()=>import("../houston-UNRWGR67.js"))},{id:"kanagawa-dragon",displayName:"Kanagawa Dragon",type:"dark",import:(()=>import("../kanagawa-dragon-BOSCCB42.js"))},{id:"kanagawa-lotus",displayName:"Kanagawa Lotus",type:"light",import:(()=>import("../kanagawa-lotus-NXMB2IVI.js"))},{id:"kanagawa-wave",displayName:"Kanagawa Wave",type:"dark",import:(()=>import("../kanagawa-wave-YOHS63UF.js"))},{id:"laserwave",displayName:"LaserWave",type:"dark",import:(()=>import("../laserwave-TS4AG4VO.js"))},{id:"light-plus",displayName:"Light Plus",type:"light",import:(()=>import("../light-plus-2HYW3NJ6.js"))},{id:"material-theme",displayName:"Material Theme",type:"dark",import:(()=>import("../material-theme-KPDVFAGV.js"))},{id:"material-theme-darker",displayName:"Material Theme Darker",type:"dark",import:(()=>import("../material-theme-darker-GVSTMSNT.js"))},{id:"material-theme-lighter",displayName:"Material Theme Lighter",type:"light",import:(()=>import("../material-theme-lighter-JWZNUXUH.js"))},{id:"material-theme-ocean",displayName:"Material Theme Ocean",type:"dark",import:(()=>import("../material-theme-ocean-MU4N3XNQ.js"))},{id:"material-theme-palenight",displayName:"Material Theme Palenight",type:"dark",import:(()=>import("../material-theme-palenight-VMWD73WM.js"))},{id:"min-dark",displayName:"Min Dark",type:"dark",import:(()=>import("../min-dark-ASEVSA24.js"))},{id:"min-light",displayName:"Min Light",type:"light",import:(()=>import("../min-light-3H54BB3D.js"))},{id:"monokai",displayName:"Monokai",type:"dark",import:(()=>import("../monokai-5QWQOFN6.js"))},{id:"night-owl",displayName:"Night Owl",type:"dark",import:(()=>import("../night-owl-4QQBS2UX.js"))},{id:"night-owl-light",displayName:"Night Owl Light",type:"light",import:(()=>import("../night-owl-light-HR6A2OQO.js"))},{id:"nord",displayName:"Nord",type:"dark",import:(()=>import("../nord-XK3AUNCF.js"))},{id:"one-dark-pro",displayName:"One Dark Pro",type:"dark",import:(()=>import("../one-dark-pro-ZV7CEA5M.js"))},{id:"one-light",displayName:"One Light",type:"light",import:(()=>import("../one-light-FKZJCKM6.js"))},{id:"plastic",displayName:"Plastic",type:"dark",import:(()=>import("../plastic-SXCQPKYC.js"))},{id:"poimandres",displayName:"Poimandres",type:"dark",import:(()=>import("../poimandres-S3UYVG4O.js"))},{id:"red",displayName:"Red",type:"dark",import:(()=>import("../red-A6OC2HVL.js"))},{id:"rose-pine",displayName:"Ros\xE9 Pine",type:"dark",import:(()=>import("../rose-pine-GLWOWPBK.js"))},{id:"rose-pine-dawn",displayName:"Ros\xE9 Pine Dawn",type:"light",import:(()=>import("../rose-pine-dawn-HYE6T7LV.js"))},{id:"rose-pine-moon",displayName:"Ros\xE9 Pine Moon",type:"dark",import:(()=>import("../rose-pine-moon-VHVTDDVO.js"))},{id:"slack-dark",displayName:"Slack Dark",type:"dark",import:(()=>import("../slack-dark-OPW5CYSY.js"))},{id:"slack-ochin",displayName:"Slack Ochin",type:"light",import:(()=>import("../slack-ochin-WTVMYBFH.js"))},{id:"snazzy-light",displayName:"Snazzy Light",type:"light",import:(()=>import("../snazzy-light-5UQ56PC5.js"))},{id:"solarized-dark",displayName:"Solarized Dark",type:"dark",import:(()=>import("../solarized-dark-DSMP6D7D.js"))},{id:"solarized-light",displayName:"Solarized Light",type:"light",import:(()=>import("../solarized-light-3IZTZCIV.js"))},{id:"synthwave-84",displayName:"Synthwave '84",type:"dark",import:(()=>import("../synthwave-84-JWI6CVJZ.js"))},{id:"tokyo-night",displayName:"Tokyo Night",type:"dark",import:(()=>import("../tokyo-night-SRK4SADJ.js"))},{id:"vesper",displayName:"Vesper",type:"dark",import:(()=>import("../vesper-WIZFPFI7.js"))},{id:"vitesse-black",displayName:"Vitesse Black",type:"dark",import:(()=>import("../vitesse-black-PEGI4HJX.js"))},{id:"vitesse-dark",displayName:"Vitesse Dark",type:"dark",import:(()=>import("../vitesse-dark-M2ZAGPXG.js"))},{id:"vitesse-light",displayName:"Vitesse Light",type:"light",import:(()=>import("../vitesse-light-RICZI4IG.js"))}],ki=Object.fromEntries(jf.map(e=>[e.id,e.import]));f();var aa=class extends Error{constructor(t){super(t),this.name="ShikiError"}};function zf(){return 2147483648}function Vf(){return typeof performance<"u"?performance.now():Date.now()}var $f=(e,t)=>e+(t-e%t)%t;async function Xf(e){let t,a,o={};function r(m){a=m,o.HEAPU8=new Uint8Array(m),o.HEAPU32=new Uint32Array(m)}function s(m,h,I){o.HEAPU8.copyWithin(m,h,h+I)}function n(m){try{return t.grow(m-a.byteLength+65535>>>16),r(t.buffer),1}catch{}}function l(m){let h=o.HEAPU8.length;m=m>>>0;let I=zf();if(m>I)return!1;for(let L=1;L<=4;L*=2){let S=h*(1+.2/L);S=Math.min(S,m+100663296);let C=Math.min(I,$f(Math.max(m,S),65536));if(n(C))return!0}return!1}let i=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function u(m,h,I=1024){let L=h+I,S=h;for(;m[S]&&!(S>=L);)++S;if(S-h>16&&m.buffer&&i)return i.decode(m.subarray(h,S));let C="";for(;h<S;){let g=m[h++];if(!(g&128)){C+=String.fromCharCode(g);continue}let k=m[h++]&63;if((g&224)===192){C+=String.fromCharCode((g&31)<<6|k);continue}let T=m[h++]&63;if((g&240)===224?g=(g&15)<<12|k<<6|T:g=(g&7)<<18|k<<12|T<<6|m[h++]&63,g<65536)C+=String.fromCharCode(g);else{let P=g-65536;C+=String.fromCharCode(55296|P>>10,56320|P&1023)}}return C}function c(m,h){return m?u(o.HEAPU8,m,h):""}let d={emscripten_get_now:Vf,emscripten_memcpy_big:s,emscripten_resize_heap:l,fd_write:()=>0};async function p(){let h=await e({env:d,wasi_snapshot_preview1:d});t=h.memory,r(t.buffer),Object.assign(o,h),o.UTF8ToString=c}return await p(),o}var Kf=Object.defineProperty,Qf=(e,t,a)=>t in e?Kf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,ne=(e,t,a)=>Qf(e,typeof t!="symbol"?t+"":t,a),le=null;function Jf(e){throw new aa(e.UTF8ToString(e.getLastOnigError()))}var za=class e{constructor(t){ne(this,"utf16Length"),ne(this,"utf8Length"),ne(this,"utf16Value"),ne(this,"utf8Value"),ne(this,"utf16OffsetToUtf8"),ne(this,"utf8OffsetToUtf16");let a=t.length,o=e._utf8ByteLength(t),r=o!==a,s=r?new Uint32Array(a+1):null;r&&(s[a]=o);let n=r?new Uint32Array(o+1):null;r&&(n[o]=a);let l=new Uint8Array(o),i=0;for(let u=0;u<a;u++){let c=t.charCodeAt(u),d=c,p=!1;if(c>=55296&&c<=56319&&u+1<a){let m=t.charCodeAt(u+1);m>=56320&&m<=57343&&(d=(c-55296<<10)+65536|m-56320,p=!0)}r&&(s[u]=i,p&&(s[u+1]=i),d<=127?n[i+0]=u:d<=2047?(n[i+0]=u,n[i+1]=u):d<=65535?(n[i+0]=u,n[i+1]=u,n[i+2]=u):(n[i+0]=u,n[i+1]=u,n[i+2]=u,n[i+3]=u)),d<=127?l[i++]=d:d<=2047?(l[i++]=192|(d&1984)>>>6,l[i++]=128|(d&63)>>>0):d<=65535?(l[i++]=224|(d&61440)>>>12,l[i++]=128|(d&4032)>>>6,l[i++]=128|(d&63)>>>0):(l[i++]=240|(d&1835008)>>>18,l[i++]=128|(d&258048)>>>12,l[i++]=128|(d&4032)>>>6,l[i++]=128|(d&63)>>>0),p&&u++}this.utf16Length=a,this.utf8Length=o,this.utf16Value=t,this.utf8Value=l,this.utf16OffsetToUtf8=s,this.utf8OffsetToUtf16=n}static _utf8ByteLength(t){let a=0;for(let o=0,r=t.length;o<r;o++){let s=t.charCodeAt(o),n=s,l=!1;if(s>=55296&&s<=56319&&o+1<r){let i=t.charCodeAt(o+1);i>=56320&&i<=57343&&(n=(s-55296<<10)+65536|i-56320,l=!0)}n<=127?a+=1:n<=2047?a+=2:n<=65535?a+=3:a+=4,l&&o++}return a}createString(t){let a=t.omalloc(this.utf8Length);return t.HEAPU8.set(this.utf8Value,a),a}},Va=class Oe{constructor(t){if(ne(this,"id",++Oe.LAST_ID),ne(this,"_onigBinding"),ne(this,"content"),ne(this,"utf16Length"),ne(this,"utf8Length"),ne(this,"utf16OffsetToUtf8"),ne(this,"utf8OffsetToUtf16"),ne(this,"ptr"),!le)throw new aa("Must invoke loadWasm first.");this._onigBinding=le,this.content=t;let a=new za(t);this.utf16Length=a.utf16Length,this.utf8Length=a.utf8Length,this.utf16OffsetToUtf8=a.utf16OffsetToUtf8,this.utf8OffsetToUtf16=a.utf8OffsetToUtf16,this.utf8Length<1e4&&!Oe._sharedPtrInUse?(Oe._sharedPtr||(Oe._sharedPtr=le.omalloc(1e4)),Oe._sharedPtrInUse=!0,le.HEAPU8.set(a.utf8Value,Oe._sharedPtr),this.ptr=Oe._sharedPtr):this.ptr=a.createString(le)}convertUtf8OffsetToUtf16(t){return this.utf8OffsetToUtf16?t<0?0:t>this.utf8Length?this.utf16Length:this.utf8OffsetToUtf16[t]:t}convertUtf16OffsetToUtf8(t){return this.utf16OffsetToUtf8?t<0?0:t>this.utf16Length?this.utf8Length:this.utf16OffsetToUtf8[t]:t}dispose(){this.ptr===Oe._sharedPtr?Oe._sharedPtrInUse=!1:this._onigBinding.ofree(this.ptr)}};ne(Va,"LAST_ID",0);ne(Va,"_sharedPtr",0);ne(Va,"_sharedPtrInUse",!1);var bi=Va,er=class{constructor(t){if(ne(this,"_onigBinding"),ne(this,"_ptr"),!le)throw new aa("Must invoke loadWasm first.");let a=[],o=[];for(let l=0,i=t.length;l<i;l++){let u=new za(t[l]);a[l]=u.createString(le),o[l]=u.utf8Length}let r=le.omalloc(4*t.length);le.HEAPU32.set(a,r/4);let s=le.omalloc(4*t.length);le.HEAPU32.set(o,s/4);let n=le.createOnigScanner(r,s,t.length);for(let l=0,i=t.length;l<i;l++)le.ofree(a[l]);le.ofree(s),le.ofree(r),n===0&&Jf(le),this._onigBinding=le,this._ptr=n}dispose(){this._onigBinding.freeOnigScanner(this._ptr)}findNextMatchSync(t,a,o){let r=0;if(typeof o=="number"&&(r=o),typeof t=="string"){t=new bi(t);let s=this._findNextMatchSync(t,a,!1,r);return t.dispose(),s}return this._findNextMatchSync(t,a,!1,r)}_findNextMatchSync(t,a,o,r){let s=this._onigBinding,n=s.findNextOnigScannerMatch(this._ptr,t.id,t.ptr,t.utf8Length,t.convertUtf16OffsetToUtf8(a),r);if(n===0)return null;let l=s.HEAPU32,i=n/4,u=l[i++],c=l[i++],d=[];for(let p=0;p<c;p++){let m=t.convertUtf8OffsetToUtf16(l[i++]),h=t.convertUtf8OffsetToUtf16(l[i++]);d[p]={start:m,end:h,length:h-m}}return{index:u,captureIndices:d}}};function Zf(e){return typeof e.instantiator=="function"}function Yf(e){return typeof e.default=="function"}function ep(e){return typeof e.data<"u"}function tp(e){return typeof Response<"u"&&e instanceof Response}function ap(e){return typeof ArrayBuffer<"u"&&(e instanceof ArrayBuffer||ArrayBuffer.isView(e))||typeof Buffer<"u"&&Buffer.isBuffer?.(e)||typeof SharedArrayBuffer<"u"&&e instanceof SharedArrayBuffer||typeof Uint32Array<"u"&&e instanceof Uint32Array}var ja;function op(e){if(ja)return ja;async function t(){le=await Xf(async a=>{let o=e;return o=await o,typeof o=="function"&&(o=await o(a)),typeof o=="function"&&(o=await o(a)),Zf(o)?o=await o.instantiator(a):Yf(o)?o=await o.default(a):(ep(o)&&(o=o.data),tp(o)?typeof WebAssembly.instantiateStreaming=="function"?o=await rp(o)(a):o=await sp(o)(a):ap(o)?o=await Yo(o)(a):o instanceof WebAssembly.Module?o=await Yo(o)(a):"default"in o&&o.default instanceof WebAssembly.Module&&(o=await Yo(o.default)(a))),"instance"in o&&(o=o.instance),"exports"in o&&(o=o.exports),o})}return ja=t(),ja}function Yo(e){return t=>WebAssembly.instantiate(e,t)}function rp(e){return t=>WebAssembly.instantiateStreaming(e,t)}function sp(e){return async t=>{let a=await e.arrayBuffer();return WebAssembly.instantiate(a,t)}}async function Ti(e){return e&&await op(e),{createScanner(t){return new er(t.map(a=>typeof a=="string"?a:a.source))},createString(t){return new bi(t)}}}var $a=Ci({langs:ta,themes:ki,engine:()=>Ti(import("../wasm-ISCPKFD2.js"))}),{codeToHtml:np,codeToHast:ip,codeToTokens:lp,codeToTokensBase:up,codeToTokensWithThemes:dp,getSingletonHighlighter:cp,getLastGrammarState:fp}=Ii($a,{guessEmbeddedLanguages:pi});var Pi=new Set(Object.keys(ta)),tr=new Map,ar=new Map,It=new Map,pp=(e,t)=>`${e}-${t[0]}-${t[1]}`,mp=(e,t,a)=>{let o=e.slice(0,100),r=e.length>100?e.slice(-100):"";return`${t}:${a[0]}:${a[1]}:${e.length}:${o}:${r}`},hp=(e,t)=>{let a=pp(e,t);if(tr.has(a))return tr.get(a);let o=$a({themes:t,langs:[e]});return tr.set(a,o),o};function gp(e={}){var t;let a=(t=e.themes)!=null?t:["github-light","github-dark"];return{name:"shiki",type:"code-highlighter",supportsLanguage(o){return Pi.has(o)},getSupportedLanguages(){return Array.from(Pi)},getThemes(){return a},highlight({code:o,language:r,themes:s},n){let l=mp(o,r,s);return ar.has(l)?ar.get(l):(n&&(It.has(l)||It.set(l,new Set),It.get(l).add(n)),hp(r,s).then(i=>{let u=i.getLoadedLanguages().includes(r)?r:"text",c=i.codeToTokens(o,{lang:u,themes:{light:s[0],dark:s[1]}});ar.set(l,c);let d=It.get(l);if(d){for(let p of d)p(c);It.delete(l)}}).catch(i=>{console.error("[Streamdown Code] Failed to highlight code:",i),It.delete(l)}),null)}}}var vi=gp();import{memo as wp}from"react";f();import{jsx as Xa}from"react/jsx-runtime";var Ka=({className:e,from:t,children:a,...o})=>Xa("div",{className:B("ww:group ww:flex ww:w-full",t==="user"?"is-user ww:ml-auto ww:max-w-[80%] ww:flex-col ww:items-end":"is-assistant ww:flex-col",e),...o,children:Xa("div",{className:B("ww:flex ww:min-w-0 ww:flex-col ww:gap-2","ww:w-full"),children:a})}),Qa=({children:e,className:t,...a})=>Xa("div",{className:B("ww:flex ww:w-fit ww:min-w-0 ww:max-w-full ww:flex-col ww:gap-2 ww:overflow-hidden ww:text-base","ww:group-[.is-user]:ml-auto ww:group-[.is-user]:rounded-lg ww:group-[.is-user]:bg-user-bubble ww:group-[.is-user]:px-4 ww:group-[.is-user]:py-3 ww:group-[.is-user]:text-primary-foreground","ww:group-[.is-assistant]:text-foreground",t),...a,children:e}),xp={cjk:cn,code:vi},Lp={enabled:!1},Ja=wp(({className:e,linkSafety:t,...a})=>Xa(uo,{className:B("ww:size-full ww:[&>*:first-child]:mt-0 ww:[&>*:last-child]:mb-0",e),linkSafety:t??Lp,plugins:xp,...a}),(e,t)=>e.children===t.children);Ja.displayName="MessageResponse";f();import{jsx as Cp}from"react/jsx-runtime";function Ai({className:e,text:t,...a}){return t?Cp("pre",{className:B("ww:mb-2 ww:overflow-x-auto ww:whitespace-pre-wrap ww:break-words ww:text-xs ww:font-mono ww:text-muted-foreground",e),...a,children:t}):null}f();import{createContext as Ip,useCallback as Sp,useContext as Di,useEffect as yp,useMemo as rr,useRef as kp,useState as sr}from"react";import{Fragment as Fi,jsx as $,jsxs as Ge}from"react/jsx-runtime";function bp(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 o=Object.entries(e),r=[],s=t-2;for(let[n,l]of o){if(s<=8)break;let i=n.length>4?`${n.slice(0,4)}\u2026`:n,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=`${i}\u2009${u}`;r.push(c),s-=c.length+3}return`{${r.join(", ")}}`}function Tp({text:e,className:t}){let[a,o]=sr(!1),r=kp(null);yp(()=>()=>{r.current&&clearTimeout(r.current)},[]);let s=Sp(async n=>{n.stopPropagation();try{await navigator.clipboard.writeText(e),o(!0),r.current&&clearTimeout(r.current),r.current=setTimeout(()=>o(!1),2e3)}catch{}},[e]);return $(Ee,{variant:"ghost",size:"sm",onClick:s,className:B("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:a?Ge(Fi,{children:[$(Dt,{className:"ww:size-3.5"}),$("span",{children:"Copied"})]}):Ge(Fi,{children:[$(_t,{className:"ww:size-3.5"}),$("span",{children:"Copy"})]})})}function Bi({data:e,label:t,className:a,...o}){let[r,s]=sr(!1),n=rr(()=>JSON.stringify(e,null,2),[e]),l=bp(e);return Ge("div",{className:B("ww:rounded-lg ww:bg-tool-card",a),...o,children:[Ge("div",{className:"ww:flex ww:items-center ww:justify-between ww:px-3 ww:pt-2.5 ww:pb-1.5",children:[$("span",{className:"ww:text-xs ww:font-medium ww:text-muted-foreground",children:t}),$(Tp,{text:n})]}),Ge("button",{type:"button",onClick:()=>s(i=>!i),className:"ww:flex ww:w-full ww:items-start ww:gap-2 ww:px-3 ww:pb-3 ww:text-left",children:[$(Et,{className:B("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?$("pre",{className:"ww:overflow-x-auto ww:text-xs ww:font-mono ww:text-foreground ww:whitespace-pre-wrap ww:break-all",children:$("code",{children:n})}):$("span",{className:"ww:truncate ww:text-xs ww:font-mono ww:text-foreground/80",children:l})]})]})}var nr=Ip({open:!1,toggle:()=>{}});function Ei({className:e,defaultOpen:t=!1,children:a,...o}){let[r,s]=sr(t);return $(nr.Provider,{value:{open:r,toggle:()=>s(n=>!n)},children:$("div",{className:B("ww:mb-4 ww:w-full",e),"data-state":r?"open":"closed",...o,children:a})})}function _i({className:e,title:t,state:a,...o}){let{open:r,toggle:s}=Di(nr),n=a==="input-available"||a==="input-streaming";return Ge("button",{type:"button",onClick:s,className:B("ww:flex ww:w-full ww:items-center ww:justify-between ww:gap-3 ww:py-1.5",e),"aria-expanded":r,...o,children:[Ge("div",{className:"ww:flex ww:min-w-0 ww:items-center ww:gap-2",children:[$($e,{className:"ww:size-4 ww:shrink-0 ww:text-muted-foreground"}),$("span",{className:"ww:truncate ww:text-sm ww:font-medium",children:t}),n&&$("span",{className:"ww:size-2 ww:shrink-0 ww:rounded-full ww:bg-primary ww:animate-pulse"})]}),$(Bt,{className:B("ww:size-4 ww:shrink-0 ww:text-muted-foreground ww:transition-transform ww:duration-200",r&&"ww:rotate-180")})]})}function Ni({className:e,title:t,state:a,...o}){let r=a==="input-available"||a==="input-streaming";return Ge("div",{className:B("ww:mb-4 ww:flex ww:items-center ww:gap-2 ww:py-1.5 ww:text-sm ww:text-muted-foreground ww:italic",e),...o,children:[$("span",{className:"ww:truncate",children:t}),r&&$("span",{className:"ww:size-2 ww:shrink-0 ww:rounded-full ww:bg-primary ww:animate-pulse"})]})}function Oi({className:e,children:t,...a}){let{open:o}=Di(nr);return $("div",{className:B("ww:grid ww:transition-[grid-template-rows,opacity] ww:duration-200 ww:ease-out",o?"ww:grid-rows-[1fr] ww:opacity-100":"ww:grid-rows-[0fr] ww:opacity-0"),children:$("div",{className:"ww:min-h-0 ww:overflow-hidden",children:$("div",{className:B("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 Ui({className:e,input:t,debug:a,...o}){let r=rr(()=>{if(!a&&typeof t=="object"&&t!==null&&!Array.isArray(t)){let{_meta:s,...n}=t;return n}return t},[t,a]);return $(Bi,{data:r,label:"Request",className:e,...o})}function or(e){if(!(typeof e!="object"||e===null))return e}function Hi(e){return or(e?.ui)}function qi(e){return or(or(e)?._meta)}function Ri(e){if(!e)return;let t=Hi(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 o=e["openai/outputTemplate"];if(typeof o=="string"&&o.length>0)return o}function Mi(e){return Hi(e)?.autoHeight===!0}function Za(e,t,a){if(e){let o=Ri(a?.[e]?._meta);if(o)return o}return Ri(qi(t))}function Wi(e,t,a){return e&&Mi(a?.[e]?._meta)?!0:Mi(qi(t))}function Gi({className:e,output:t,errorText:a,debug:o,...r}){let s=rr(()=>{if(!o&&typeof t=="object"&&t!==null&&!Array.isArray(t)){let{_meta:n,...l}=t;return l}return t},[t,o]);return t||a?a?Ge("div",{className:B("ww:space-y-2",e),...r,children:[$("h4",{className:"ww:text-xs ww:font-medium ww:uppercase ww:tracking-wide ww:text-muted-foreground",children:"Error"}),$("div",{className:"ww:rounded-lg ww:bg-destructive/10 ww:p-3 ww:text-xs ww:text-destructive",children:a})]}):$(Bi,{data:s,label:"Response",className:e,...r}):null}f();import{useCallback as Pp,useEffect as ji,useMemo as vp,useRef as xe,useState as zi}from"react";import{jsx as Up}from"react/jsx-runtime";var Ap="/api/mcp/resource",Rp=500,Mp=0,Fp=16,Dp="2026-01-26",Bp=300,Ep=3e3,_p=3;function Np(e){if(typeof e!="string")return;let t=e.trim();return t.length>0?t:void 0}function Op(e,t,a){return Za(e,t,a)?!1:t._meta?.["waniwani/autoInjectResultText"]!==!1}function Vi({resourceUri:e,toolInput:t,toolResult:a,resourceEndpoint:o=Ap,chatSessionId:r,isDark:s=!1,className:n,autoHeight:l=!1,onOpenLink:i,onFollowUp:u,onCallTool:c,onDisplayModeChange:d,isFullscreen:p=!1,toolDefinitions:m}){let h=xe(null),I=xe(t),L=xe(a),S=xe({width:0,height:0}),C=xe(null),g=xe(!1),k=xe(0),T=xe("inline"),[P,R]=zi(Mp),[v,_]=zi(void 0),A=xe(i),E=xe(u),y=xe(c),M=xe(d),U=xe(r),F=xe(m);I.current=t,L.current=a,A.current=i,E.current=u,y.current=c,M.current=d,U.current=r,F.current=m;let j=Pp(te=>l?Math.max(te+Fp,0):Math.min(Math.max(te,50),Rp),[l]),Te=vp(()=>{let te=o.includes("?")?"&":"?";return`${o}${te}uri=${encodeURIComponent(e)}`},[o,e]),Le=xe(s);return Le.current=s,ji(()=>{if(!g.current)return;let te=h.current;te?.contentWindow&&te.contentWindow.postMessage({jsonrpc:"2.0",method:"ui/notifications/host-context-changed",params:{theme:s?"dark":"light"}},"*")},[s]),ji(()=>{let te=h.current;if(!te)return;let me=!1,Se=!1,ge=null,Ce=null,je=setTimeout(()=>{if(me||Se||k.current>=_p)return;k.current+=1;let Y=new URL(te.src);Y.searchParams.set("_retry",String(k.current)),te.src=Y.toString()},Ep),N=Y=>{te.contentWindow?.postMessage(Y,"*")},ie=Y=>{if(me||Y.source!==te.contentWindow)return;let X=Y.data;if(!X||typeof X!="object"||X.jsonrpc!=="2.0")return;let oe=X.method,W=X.id;if(oe==="ui/initialize"&&W!=null){Se=!0,clearTimeout(je),N({jsonrpc:"2.0",id:W,result:{protocolVersion:X.params?.protocolVersion??Dp,hostInfo:{name:"WaniWani Chat",version:"1.0.0"},hostCapabilities:{openLinks:{},message:{text:{}},tools:{},updateModelContext:{text:{},structuredContent:{}}},hostContext:{theme:Le.current?"dark":"light",displayMode:T.current}}});return}if(oe==="ui/notifications/initialized"){g.current=!0;let z=I.current,K=L.current,q=K._meta&&typeof K._meta=="object"?K._meta:null,Q=Np(U.current),re=q&&typeof q.waniwani=="object"&&q.waniwani!==null?q.waniwani:null,Pe=re||Q?{...re??{},...Q?{sessionId:Q}:{}}:void 0,ze=q||Pe?{...q??{},...Pe?{waniwani:Pe}:{}}:void 0;N({jsonrpc:"2.0",method:"ui/notifications/tool-input",params:{arguments:z}});let dt=K.content??[{type:"text",text:JSON.stringify(K)}];N({jsonrpc:"2.0",method:"ui/notifications/tool-result",params:{content:dt,structuredContent:K.structuredContent,_meta:ze,meta:ze}});return}if(oe==="ui/notifications/size-changed"){let z=X.params,K=typeof z?.height=="number"?z.height:void 0,q=typeof z?.width=="number"?z.width:void 0,Q=S.current,re=K!==void 0&&K!==Q.height,Pe=q!==void 0&&q!==Q.width;if(!re&&!Pe)return;if(re&&K!==void 0){Q.height=K;let ze=j(K),dt=te.getBoundingClientRect().height;if(C.current&&(C.current.cancel(),C.current=null),R(ze),te.animate&&Math.abs(dt-ze)>2){let ct=te.animate([{height:`${dt}px`},{height:`${ze}px`}],{duration:Bp,easing:"ease-out",fill:"forwards"});C.current=ct,ct.onfinish=()=>{C.current===ct&&(ct.cancel(),C.current=null)}}}Pe&&l&&q!==void 0&&(Q.width=q,_(q));return}if(oe==="ui/open-link"&&W!=null){let z=X.params?.url;typeof z=="string"&&(A.current?A.current(z):window.open(z,"_blank","noopener,noreferrer")),N({jsonrpc:"2.0",id:W,result:{}});return}if(oe==="ui/message"&&W!=null){if(E.current&&X.params){let z=X.params,K=ge;if(ge=null,Ce){clearTimeout(Ce.timer);let q=Ce.text;Ce=null;let Q=(z.content??[]).map(re=>re.text??"").join("").trim();z={...z,content:[{type:"text",text:`${Q}
|
|
78
|
+
\f\r "&'<=>\``.split("")]],single:[["&'".split(""),"\"&'`".split("")],["\0&'".split(""),"\0\"&'`".split("")]],double:[['"&'.split(""),"\"&'`".split("")],['\0"&'.split(""),"\0\"&'`".split("")]]};function si(e,t,a,o){let r=o.schema,s=r.space==="svg"?!1:o.settings.omitOptionalTags,n=r.space==="svg"?o.settings.closeEmptyElements:o.settings.voids.includes(e.tagName.toLowerCase()),l=[],i;r.space==="html"&&e.tagName==="svg"&&(o.schema=da);let u=cf(o,e.properties),c=o.all(r.space==="html"&&e.tagName==="template"?e.content:e);return o.schema=r,c&&(n=!1),(u||!s||!ri(e,t,a))&&(l.push("<",e.tagName,u?" "+u:""),n&&(r.space==="svg"||o.settings.closeSelfClosing)&&(i=u.charAt(u.length-1),(!o.settings.tightSelfClosing||i==="/"||i&&i!=='"'&&i!=="'")&&l.push(" "),l.push("/")),l.push(">")),l.push(c),!n&&(!s||!Yt(e,t,a))&&l.push("</"+e.tagName+">"),l.join("")}function cf(e,t){let a=[],o=-1,r;if(t){for(r in t)if(t[r]!==null&&t[r]!==void 0){let s=ff(e,r,t[r]);s&&a.push(s)}}for(;++o<a.length;){let s=e.settings.tightAttributes?a[o].charAt(a[o].length-1):void 0;o!==a.length-1&&s!=='"'&&s!=="'"&&(a[o]+=" ")}return a.join("")}function ff(e,t,a){let o=vr(e.schema,t),r=e.settings.allowParseErrors&&e.schema.space==="html"?0:1,s=e.settings.allowDangerousCharacters?0:1,n=e.quote,l;if(o.overloadedBoolean&&(a===o.attribute||a==="")?a=!0:(o.boolean||o.overloadedBoolean)&&(typeof a!="string"||a===o.attribute||a==="")&&(a=!!a),a==null||a===!1||typeof a=="number"&&Number.isNaN(a))return"";let i=We(o.attribute,Object.assign({},e.settings.characterReferences,{subset:_a.name[r][s]}));return a===!0||(a=Array.isArray(a)?(o.commaSeparated?Mr:Fr)(a,{padLeft:!e.settings.tightCommaSeparatedLists}):String(a),e.settings.collapseEmptyAttributes&&!a)?i:(e.settings.preferUnquoted&&(l=We(a,Object.assign({},e.settings.characterReferences,{attribute:!0,subset:_a.unquoted[r][s]}))),l!==a&&(e.settings.quoteSmart&&uo(a,n)>uo(a,e.alternative)&&(n=e.alternative),l=n+We(a,Object.assign({},e.settings.characterReferences,{subset:(n==="'"?_a.single:_a.double)[r][s],attribute:!0}))+n),i+(l&&"="+l))}f();f();var pf=["<","&"];function Na(e,t,a,o){return a&&a.type==="element"&&(a.tagName==="script"||a.tagName==="style")?e.value:We(e.value,Object.assign({},o.settings.characterReferences,{subset:pf}))}function ni(e,t,a,o){return o.settings.allowDangerousHtml?e.value:Na(e,t,a,o)}f();function ii(e,t,a,o){return o.all(e)}var li=Rr("type",{invalid:mf,unknown:hf,handlers:{comment:Yn,doctype:ei,element:si,raw:ni,root:ii,text:Na}});function mf(e){throw new Error("Expected node, not `"+e+"`")}function hf(e){let t=e;throw new Error("Cannot compile unknown node `"+t.type+"`")}var gf={},wf={},xf=[];function Wo(e,t){let a=t||gf,o=a.quote||'"',r=o==='"'?"'":'"';if(o!=='"'&&o!=="'")throw new Error("Invalid quote `"+o+"`, expected `'` or `\"`");return{one:Lf,all:Cf,settings:{omitOptionalTags:a.omitOptionalTags||!1,allowParseErrors:a.allowParseErrors||!1,allowDangerousCharacters:a.allowDangerousCharacters||!1,quoteSmart:a.quoteSmart||!1,preferUnquoted:a.preferUnquoted||!1,tightAttributes:a.tightAttributes||!1,upperDoctype:a.upperDoctype||!1,tightDoctype:a.tightDoctype||!1,bogusComments:a.bogusComments||!1,tightCommaSeparatedLists:a.tightCommaSeparatedLists||!1,tightSelfClosing:a.tightSelfClosing||!1,collapseEmptyAttributes:a.collapseEmptyAttributes||!1,allowDangerousHtml:a.allowDangerousHtml||!1,voids:a.voids||Pr,characterReferences:a.characterReferences||wf,closeSelfClosing:a.closeSelfClosing||!1,closeEmptyElements:a.closeEmptyElements||!1},schema:a.space==="svg"?da:Ar,quote:o,alternative:r}.one(Array.isArray(e)?{type:"root",children:e}:e,void 0,void 0)}function Lf(e,t,a){return li(e,t,a,this)}function Cf(e){let t=[],a=e&&e.children||xf,o=-1;for(;++o<a.length;)t[o]=this.one(a[o],o,e);return t.join("")}function Ua(e,t){let a=typeof e=="string"?{}:{...e.colorReplacements},o=typeof e=="string"?e:e.name;for(let[r,s]of Object.entries(t?.colorReplacements||{}))typeof s=="string"?a[r]=s:r===o&&Object.assign(a,s);return a}function Je(e,t){return e&&(t?.[e?.toLowerCase()]||e)}function If(e){return Array.isArray(e)?e:[e]}async function hi(e){return Promise.resolve(typeof e=="function"?e():e).then(t=>t.default||t)}function Xo(e){return!e||["plaintext","txt","text","plain"].includes(e)}function gi(e){return e==="ansi"||Xo(e)}function Ko(e){return e==="none"}function wi(e){return Ko(e)}function xi(e,t){if(!t)return e;e.properties||={},e.properties.class||=[],typeof e.properties.class=="string"&&(e.properties.class=e.properties.class.split(/\s+/g)),Array.isArray(e.properties.class)||(e.properties.class=[]);let a=Array.isArray(t)?t:t.split(/\s+/g);for(let o of a)o&&!e.properties.class.includes(o)&&e.properties.class.push(o);return e}function Ga(e,t=!1){if(e.length===0)return[["",0]];let a=e.split(/(\r?\n)/g),o=0,r=[];for(let s=0;s<a.length;s+=2){let n=t?a[s]+(a[s+1]||""):a[s];r.push([n,o]),o+=a[s].length,o+=a[s+1]?.length||0}return r}function Sf(e){let t=Ga(e,!0).map(([r])=>r);function a(r){if(r===e.length)return{line:t.length-1,character:t[t.length-1].length};let s=r,n=0;for(let l of t){if(s<l.length)break;s-=l.length,n++}return{line:n,character:s}}function o(r,s){let n=0;for(let l=0;l<r;l++)n+=t[l].length;return n+=s,n}return{lines:t,indexToPos:a,posToIndex:o}}function Li(e,t,a){let o=new Set;for(let s of e.matchAll(/:?lang=["']([^"']+)["']/g)){let n=s[1].toLowerCase().trim();n&&o.add(n)}for(let s of e.matchAll(/(?:```|~~~)([\w-]+)/g)){let n=s[1].toLowerCase().trim();n&&o.add(n)}for(let s of e.matchAll(/\\begin\{([\w-]+)\}/g)){let n=s[1].toLowerCase().trim();n&&o.add(n)}for(let s of e.matchAll(/<script\s+(?:type|lang)=["']([^"']+)["']/gi)){let n=s[1].toLowerCase().trim(),l=n.includes("/")?n.split("/").pop():n;l&&o.add(l)}if(!a)return Array.from(o);let r=a.getBundledLanguages();return Array.from(o).filter(s=>s&&r[s])}var Qo="light-dark()",yf=["color","background-color"];function bf(e,t){let a=0,o=[];for(let r of t)r>a&&o.push({...e,content:e.content.slice(a,r),offset:e.offset+a}),a=r;return a<e.content.length&&o.push({...e,content:e.content.slice(a),offset:e.offset+a}),o}function kf(e,t){let a=Array.from(t instanceof Set?t:new Set(t)).sort((o,r)=>o-r);return a.length?e.map(o=>o.flatMap(r=>{let s=a.filter(n=>r.offset<n&&n<r.offset+r.content.length).map(n=>n-r.offset).sort((n,l)=>n-l);return s.length?bf(r,s):r})):e}function Tf(e,t,a,o,r="css-vars"){let s={content:e.content,explanation:e.explanation,offset:e.offset},n=t.map(c=>Oa(e.variants[c])),l=new Set(n.flatMap(c=>Object.keys(c))),i={},u=(c,d)=>{let p=d==="color"?"":d==="background-color"?"-bg":`-${d}`;return a+t[c]+(d==="color"?"":p)};return n.forEach((c,d)=>{for(let p of l){let m=c[p]||"inherit";if(d===0&&o&&yf.includes(p))if(o===Qo&&n.length>1){let h=t.findIndex(C=>C==="light"),I=t.findIndex(C=>C==="dark");if(h===-1||I===-1)throw new Z('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');let L=n[h][p]||"inherit",S=n[I][p]||"inherit";i[p]=`light-dark(${L}, ${S})`,r==="css-vars"&&(i[u(d,p)]=m)}else i[p]=m;else r==="css-vars"&&(i[u(d,p)]=m)}}),s.htmlStyle=i,s}function Oa(e){let t={};if(e.color&&(t.color=e.color),e.bgColor&&(t["background-color"]=e.bgColor),e.fontStyle){e.fontStyle&ce.Italic&&(t["font-style"]="italic"),e.fontStyle&ce.Bold&&(t["font-weight"]="bold");let a=[];e.fontStyle&ce.Underline&&a.push("underline"),e.fontStyle&ce.Strikethrough&&a.push("line-through"),a.length&&(t["text-decoration"]=a.join(" "))}return t}function zo(e){return typeof e=="string"?e:Object.entries(e).map(([t,a])=>`${t}:${a}`).join(";")}var Ci=new WeakMap;function ja(e,t){Ci.set(e,t)}function ta(e){return Ci.get(e)}var Ct=class e{_stacks={};lang;get themes(){return Object.keys(this._stacks)}get theme(){return this.themes[0]}get _stack(){return this._stacks[this.theme]}static initial(t,a){return new e(Object.fromEntries(If(a).map(o=>[o,Fa])),t)}constructor(...t){if(t.length===2){let[a,o]=t;this.lang=o,this._stacks=a}else{let[a,o,r]=t;this.lang=o,this._stacks={[r]:a}}}getInternalStack(t=this.theme){return this._stacks[t]}getScopes(t=this.theme){return Pf(this._stacks[t])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}};function Pf(e){let t=[],a=new Set;function o(r){if(a.has(r))return;a.add(r);let s=r?.nameScopesList?.scopeName;s&&t.push(s),r.parent&&o(r.parent)}return o(e),t}function vf(e,t){if(!(e instanceof Ct))throw new Z("Invalid grammar state");return e.getInternalStack(t)}function Af(){let e=new WeakMap;function t(a){if(!e.has(a.meta)){let o=function(n){if(typeof n=="number"){if(n<0||n>a.source.length)throw new Z(`Invalid decoration offset: ${n}. Code length: ${a.source.length}`);return{...r.indexToPos(n),offset:n}}else{let l=r.lines[n.line];if(l===void 0)throw new Z(`Invalid decoration position ${JSON.stringify(n)}. Lines length: ${r.lines.length}`);let i=n.character;if(i<0&&(i=l.length+i),i<0||i>l.length)throw new Z(`Invalid decoration position ${JSON.stringify(n)}. Line ${n.line} length: ${l.length}`);return{...n,character:i,offset:r.posToIndex(n.line,i)}}},r=Sf(a.source),s=(a.options.decorations||[]).map(n=>({...n,start:o(n.start),end:o(n.end)}));Rf(s),e.set(a.meta,{decorations:s,converter:r,source:a.source})}return e.get(a.meta)}return{name:"shiki:decorations",tokens(a){if(!this.options.decorations?.length)return;let r=t(this).decorations.flatMap(n=>[n.start.offset,n.end.offset]);return kf(a,r)},code(a){if(!this.options.decorations?.length)return;let o=t(this),r=Array.from(a.children).filter(c=>c.type==="element"&&c.tagName==="span");if(r.length!==o.converter.lines.length)throw new Z(`Number of lines in code element (${r.length}) does not match the number of lines in the source (${o.converter.lines.length}). Failed to apply decorations.`);function s(c,d,p,m){let h=r[c],I="",L=-1,S=-1;if(d===0&&(L=0),p===0&&(S=0),p===Number.POSITIVE_INFINITY&&(S=h.children.length),L===-1||S===-1)for(let g=0;g<h.children.length;g++)I+=Ii(h.children[g]),L===-1&&I.length===d&&(L=g+1),S===-1&&I.length===p&&(S=g+1);if(L===-1)throw new Z(`Failed to find start index for decoration ${JSON.stringify(m.start)}`);if(S===-1)throw new Z(`Failed to find end index for decoration ${JSON.stringify(m.end)}`);let C=h.children.slice(L,S);if(!m.alwaysWrap&&C.length===h.children.length)l(h,m,"line");else if(!m.alwaysWrap&&C.length===1&&C[0].type==="element")l(C[0],m,"token");else{let g={type:"element",tagName:"span",properties:{},children:C};l(g,m,"wrapper"),h.children.splice(L,C.length,g)}}function n(c,d){r[c]=l(r[c],d,"line")}function l(c,d,p){let m=d.properties||{},h=d.transform||(I=>I);return c.tagName=d.tagName||"span",c.properties={...c.properties,...m,class:c.properties.class},d.properties?.class&&xi(c,d.properties.class),c=h(c,p)||c,c}let i=[],u=o.decorations.sort((c,d)=>d.start.offset-c.start.offset||c.end.offset-d.end.offset);for(let c of u){let{start:d,end:p}=c;if(d.line===p.line)s(d.line,d.character,p.character,c);else if(d.line<p.line){s(d.line,d.character,Number.POSITIVE_INFINITY,c);for(let m=d.line+1;m<p.line;m++)i.unshift(()=>n(m,c));s(p.line,0,p.character,c)}}i.forEach(c=>c())}}}function Rf(e){for(let t=0;t<e.length;t++){let a=e[t];if(a.start.offset>a.end.offset)throw new Z(`Invalid decoration range: ${JSON.stringify(a.start)} - ${JSON.stringify(a.end)}`);for(let o=t+1;o<e.length;o++){let r=e[o],s=a.start.offset<=r.start.offset&&r.start.offset<a.end.offset,n=a.start.offset<r.end.offset&&r.end.offset<=a.end.offset,l=r.start.offset<=a.start.offset&&a.start.offset<r.end.offset,i=r.start.offset<a.end.offset&&a.end.offset<=r.end.offset;if(s||n||l||i){if(s&&n||l&&i||l&&a.start.offset===a.end.offset||n&&r.start.offset===r.end.offset)continue;throw new Z(`Decorations ${JSON.stringify(a.start)} and ${JSON.stringify(r.start)} intersect.`)}}}}function Ii(e){return e.type==="text"?e.value:e.type==="element"?e.children.map(Ii).join(""):""}var Mf=[Af()];function Ha(e){let t=Ff(e.transformers||[]);return[...t.pre,...t.normal,...t.post,...Mf]}function Ff(e){let t=[],a=[],o=[];for(let r of e)switch(r.enforce){case"pre":t.push(r);break;case"post":a.push(r);break;default:o.push(r)}return{pre:t,post:a,normal:o}}var lt=["black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite"],Go={1:"bold",2:"dim",3:"italic",4:"underline",7:"reverse",8:"hidden",9:"strikethrough"};function Df(e,t){let a=e.indexOf("\x1B",t);if(a!==-1&&e[a+1]==="["){let o=e.indexOf("m",a);if(o!==-1)return{sequence:e.substring(a+2,o).split(";"),startPosition:a,position:o+1}}return{position:e.length}}function ui(e){let t=e.shift();if(t==="2"){let a=e.splice(0,3).map(o=>Number.parseInt(o));return a.length!==3||a.some(o=>Number.isNaN(o))?void 0:{type:"rgb",rgb:a}}else if(t==="5"){let a=e.shift();if(a)return{type:"table",index:Number(a)}}}function Bf(e){let t=[];for(;e.length>0;){let a=e.shift();if(!a)continue;let o=Number.parseInt(a);if(!Number.isNaN(o))if(o===0)t.push({type:"resetAll"});else if(o<=9)Go[o]&&t.push({type:"setDecoration",value:Go[o]});else if(o<=29){let r=Go[o-20];r&&(t.push({type:"resetDecoration",value:r}),r==="dim"&&t.push({type:"resetDecoration",value:"bold"}))}else if(o<=37)t.push({type:"setForegroundColor",value:{type:"named",name:lt[o-30]}});else if(o===38){let r=ui(e);r&&t.push({type:"setForegroundColor",value:r})}else if(o===39)t.push({type:"resetForegroundColor"});else if(o<=47)t.push({type:"setBackgroundColor",value:{type:"named",name:lt[o-40]}});else if(o===48){let r=ui(e);r&&t.push({type:"setBackgroundColor",value:r})}else o===49?t.push({type:"resetBackgroundColor"}):o===53?t.push({type:"setDecoration",value:"overline"}):o===55?t.push({type:"resetDecoration",value:"overline"}):o>=90&&o<=97?t.push({type:"setForegroundColor",value:{type:"named",name:lt[o-90+8]}}):o>=100&&o<=107&&t.push({type:"setBackgroundColor",value:{type:"named",name:lt[o-100+8]}})}return t}function Ef(){let e=null,t=null,a=new Set;return{parse(o){let r=[],s=0;do{let n=Df(o,s),l=n.sequence?o.substring(s,n.startPosition):o.substring(s);if(l.length>0&&r.push({value:l,foreground:e,background:t,decorations:new Set(a)}),n.sequence){let i=Bf(n.sequence);for(let u of i)u.type==="resetAll"?(e=null,t=null,a.clear()):u.type==="resetForegroundColor"?e=null:u.type==="resetBackgroundColor"?t=null:u.type==="resetDecoration"&&a.delete(u.value);for(let u of i)u.type==="setForegroundColor"?e=u.value:u.type==="setBackgroundColor"?t=u.value:u.type==="setDecoration"&&a.add(u.value)}s=n.position}while(s<o.length);return r}}}var _f={black:"#000000",red:"#bb0000",green:"#00bb00",yellow:"#bbbb00",blue:"#0000bb",magenta:"#ff00ff",cyan:"#00bbbb",white:"#eeeeee",brightBlack:"#555555",brightRed:"#ff5555",brightGreen:"#00ff00",brightYellow:"#ffff55",brightBlue:"#5555ff",brightMagenta:"#ff55ff",brightCyan:"#55ffff",brightWhite:"#ffffff"};function Nf(e=_f){function t(l){return e[l]}function a(l){return`#${l.map(i=>Math.max(0,Math.min(i,255)).toString(16).padStart(2,"0")).join("")}`}let o;function r(){if(o)return o;o=[];for(let u=0;u<lt.length;u++)o.push(t(lt[u]));let l=[0,95,135,175,215,255];for(let u=0;u<6;u++)for(let c=0;c<6;c++)for(let d=0;d<6;d++)o.push(a([l[u],l[c],l[d]]));let i=8;for(let u=0;u<24;u++,i+=10)o.push(a([i,i,i]));return o}function s(l){return r()[l]}function n(l){switch(l.type){case"named":return t(l.name);case"rgb":return a(l.rgb);case"table":return s(l.index)}}return{value:n}}var Uf={black:"#000000",red:"#cd3131",green:"#0DBC79",yellow:"#E5E510",blue:"#2472C8",magenta:"#BC3FBC",cyan:"#11A8CD",white:"#E5E5E5",brightBlack:"#666666",brightRed:"#F14C4C",brightGreen:"#23D18B",brightYellow:"#F5F543",brightBlue:"#3B8EEA",brightMagenta:"#D670D6",brightCyan:"#29B8DB",brightWhite:"#FFFFFF"};function Of(e,t,a){let o=Ua(e,a),r=Ga(t),s=Object.fromEntries(lt.map(i=>{let u=`terminal.ansi${i[0].toUpperCase()}${i.substring(1)}`,c=e.colors?.[u];return[i,c||Uf[i]]})),n=Nf(s),l=Ef();return r.map(i=>l.parse(i[0]).map(u=>{let c,d;u.decorations.has("reverse")?(c=u.background?n.value(u.background):e.bg,d=u.foreground?n.value(u.foreground):e.fg):(c=u.foreground?n.value(u.foreground):e.fg,d=u.background?n.value(u.background):void 0),c=Je(c,o),d=Je(d,o),u.decorations.has("dim")&&(c=Hf(c));let p=ce.None;return u.decorations.has("bold")&&(p|=ce.Bold),u.decorations.has("italic")&&(p|=ce.Italic),u.decorations.has("underline")&&(p|=ce.Underline),u.decorations.has("strikethrough")&&(p|=ce.Strikethrough),{content:u.value,offset:i[1],color:c,bgColor:d,fontStyle:p}}))}function Hf(e){let t=e.match(/#([0-9a-f]{3,8})/i);if(t){let o=t[1];if(o.length===8){let r=Math.round(Number.parseInt(o.slice(6,8),16)/2).toString(16).padStart(2,"0");return`#${o.slice(0,6)}${r}`}else{if(o.length===6)return`#${o}80`;if(o.length===4){let r=o[0],s=o[1],n=o[2],l=o[3],i=Math.round(Number.parseInt(`${l}${l}`,16)/2).toString(16).padStart(2,"0");return`#${r}${r}${s}${s}${n}${n}${i}`}else if(o.length===3){let r=o[0],s=o[1],n=o[2];return`#${r}${r}${s}${s}${n}${n}80`}}}let a=e.match(/var\((--[\w-]+-ansi-[\w-]+)\)/);return a?`var(${a[1]}-dim)`:e}function Jo(e,t,a={}){let{theme:o=e.getLoadedThemes()[0]}=a,r=e.resolveLangAlias(a.lang||"text");if(Xo(r)||Ko(o))return Ga(t).map(i=>[{content:i[0],offset:i[1]}]);let{theme:s,colorMap:n}=e.setTheme(o);if(r==="ansi")return Of(s,t,a);let l=e.getLanguage(a.lang||"text");if(a.grammarState){if(a.grammarState.lang!==l.name)throw new Z(`Grammar state language "${a.grammarState.lang}" does not match highlight language "${l.name}"`);if(!a.grammarState.themes.includes(s.name))throw new Z(`Grammar state themes "${a.grammarState.themes}" do not contain highlight theme "${s.name}"`)}return Wf(t,l,s,n,a)}function qf(...e){if(e.length===2)return ta(e[1]);let[t,a,o={}]=e,{lang:r="text",theme:s=t.getLoadedThemes()[0]}=o;if(Xo(r)||Ko(s))throw new Z("Plain language does not have grammar state");if(r==="ansi")throw new Z("ANSI language does not have grammar state");let{theme:n,colorMap:l}=t.setTheme(s),i=t.getLanguage(r);return new Ct(Zo(a,i,n,l,o).stateStack,i.name,n.name)}function Wf(e,t,a,o,r){let s=Zo(e,t,a,o,r),n=new Ct(s.stateStack,t.name,a.name);return ja(s.tokens,n),s.tokens}function Zo(e,t,a,o,r){let s=Ua(a,r),{tokenizeMaxLineLength:n=0,tokenizeTimeLimit:l=500}=r,i=Ga(e),u=r.grammarState?vf(r.grammarState,a.name)??Fa:r.grammarContextCode!=null?Zo(r.grammarContextCode,t,a,o,{...r,grammarState:void 0,grammarContextCode:void 0}).stateStack:Fa,c=[],d=[];for(let p=0,m=i.length;p<m;p++){let[h,I]=i[p];if(h===""){c=[],d.push([]);continue}if(n>0&&h.length>=n){c=[],d.push([{content:h,offset:I,color:"",fontStyle:0}]);continue}let L,S,C;r.includeExplanation&&(L=t.tokenizeLine(h,u,l),S=L.tokens,C=0);let g=t.tokenizeLine2(h,u,l),b=g.tokens.length/2;for(let T=0;T<b;T++){let P=g.tokens[2*T],R=T+1<b?g.tokens[2*T+2]:h.length;if(P===R)continue;let v=g.tokens[2*T+1],_=Je(o[it.getForeground(v)],s),A=it.getFontStyle(v),E={content:h.substring(P,R),offset:I+P,color:_,fontStyle:A};if(r.includeExplanation){let y=[];if(r.includeExplanation!=="scopeName")for(let O of a.settings){let F;switch(typeof O.scope){case"string":F=O.scope.split(/,/).map(j=>j.trim());break;case"object":F=O.scope;break;default:continue}y.push({settings:O,selectors:F.map(j=>j.split(/ /))})}E.explanation=[];let M=0;for(;P+M<R;){let O=S[C],F=h.substring(O.startIndex,O.endIndex);M+=F.length,E.explanation.push({content:F,scopes:r.includeExplanation==="scopeName"?Gf(O.scopes):jf(y,O.scopes)}),C+=1}}c.push(E)}d.push(c),c=[],u=g.ruleStack}return{tokens:d,stateStack:u}}function Gf(e){return e.map(t=>({scopeName:t}))}function jf(e,t){let a=[];for(let o=0,r=t.length;o<r;o++){let s=t[o];a[o]={scopeName:s,themeMatches:Vf(e,s,t.slice(0,o))}}return a}function di(e,t){return e===t||t.substring(0,e.length)===e&&t[e.length]==="."}function zf(e,t,a){if(!di(e[e.length-1],t))return!1;let o=e.length-2,r=a.length-1;for(;o>=0&&r>=0;)di(e[o],a[r])&&(o-=1),r-=1;return o===-1}function Vf(e,t,a){let o=[];for(let{selectors:r,settings:s}of e)for(let n of r)if(zf(n,t,a)){o.push(s);break}return o}function Si(e,t,a){let o=Object.entries(a.themes).filter(i=>i[1]).map(i=>({color:i[0],theme:i[1]})),r=o.map(i=>{let u=Jo(e,t,{...a,theme:i.theme}),c=ta(u),d=typeof i.theme=="string"?i.theme:i.theme.name;return{tokens:u,state:c,theme:d}}),s=$f(...r.map(i=>i.tokens)),n=s[0].map((i,u)=>i.map((c,d)=>{let p={content:c.content,variants:{},offset:c.offset};return"includeExplanation"in a&&a.includeExplanation&&(p.explanation=c.explanation),s.forEach((m,h)=>{let{content:I,explanation:L,offset:S,...C}=m[u][d];p.variants[o[h].color]=C}),p})),l=r[0].state?new Ct(Object.fromEntries(r.map(i=>[i.theme,i.state?.getInternalStack(i.theme)])),r[0].state.lang):void 0;return l&&ja(n,l),n}function $f(...e){let t=e.map(()=>[]),a=e.length;for(let o=0;o<e[0].length;o++){let r=e.map(i=>i[o]),s=t.map(()=>[]);t.forEach((i,u)=>i.push(s[u]));let n=r.map(()=>0),l=r.map(i=>i[0]);for(;l.every(i=>i);){let i=Math.min(...l.map(u=>u.content.length));for(let u=0;u<a;u++){let c=l[u];c.content.length===i?(s[u].push(c),n[u]+=1,l[u]=r[u][n[u]]):(s[u].push({...c,content:c.content.slice(0,i)}),l[u]={...c,content:c.content.slice(i),offset:c.offset+i})}}}return t}function qa(e,t,a){let o,r,s,n,l,i;if("themes"in a){let{defaultColor:u="light",cssVariablePrefix:c="--shiki-",colorsRendering:d="css-vars"}=a,p=Object.entries(a.themes).filter(S=>S[1]).map(S=>({color:S[0],theme:S[1]})).sort((S,C)=>S.color===u?-1:C.color===u?1:0);if(p.length===0)throw new Z("`themes` option must not be empty");let m=Si(e,t,a);if(i=ta(m),u&&Qo!==u&&!p.find(S=>S.color===u))throw new Z(`\`themes\` option must contain the defaultColor key \`${u}\``);let h=p.map(S=>e.getTheme(S.theme)),I=p.map(S=>S.color);s=m.map(S=>S.map(C=>Tf(C,I,c,u,d))),i&&ja(s,i);let L=p.map(S=>Ua(S.theme,a));r=ci(p,h,L,c,u,"fg",d),o=ci(p,h,L,c,u,"bg",d),n=`shiki-themes ${h.map(S=>S.name).join(" ")}`,l=u?void 0:[r,o].join(";")}else if("theme"in a){let u=Ua(a.theme,a);s=Jo(e,t,a);let c=e.getTheme(a.theme);o=Je(c.bg,u),r=Je(c.fg,u),n=c.name,i=ta(s)}else throw new Z("Invalid options, either `theme` or `themes` must be provided");return{tokens:s,fg:r,bg:o,themeName:n,rootStyle:l,grammarState:i}}function ci(e,t,a,o,r,s,n){return e.map((l,i)=>{let u=Je(t[i][s],a[i])||"inherit",c=`${o+l.color}${s==="bg"?"-bg":""}:${u}`;if(i===0&&r){if(r===Qo&&e.length>1){let d=e.findIndex(I=>I.color==="light"),p=e.findIndex(I=>I.color==="dark");if(d===-1||p===-1)throw new Z('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');let m=Je(t[d][s],a[d])||"inherit",h=Je(t[p][s],a[p])||"inherit";return`light-dark(${m}, ${h});${c}`}return u}return n==="css-vars"?c:null}).filter(l=>!!l).join(";")}function Wa(e,t,a,o={meta:{},options:a,codeToHast:(r,s)=>Wa(e,r,s),codeToTokens:(r,s)=>qa(e,r,s)}){let r=t;for(let h of Ha(a))r=h.preprocess?.call(o,r,a)||r;let{tokens:s,fg:n,bg:l,themeName:i,rootStyle:u,grammarState:c}=qa(e,r,a),{mergeWhitespaces:d=!0,mergeSameStyleTokens:p=!1}=a;d===!0?s=Kf(s):d==="never"&&(s=Qf(s)),p&&(s=Jf(s));let m={...o,get source(){return r}};for(let h of Ha(a))s=h.tokens?.call(m,s)||s;return Xf(s,{...a,fg:n,bg:l,themeName:i,rootStyle:a.rootStyle===!1?!1:a.rootStyle??u},m,c)}function Xf(e,t,a,o=ta(e)){let r=Ha(t),s=[],n={type:"root",children:[]},{structure:l="classic",tabindex:i="0"}=t,u={class:`shiki ${t.themeName||""}`};t.rootStyle!==!1&&(t.rootStyle!=null?u.style=t.rootStyle:u.style=`background-color:${t.bg};color:${t.fg}`),i!==!1&&i!=null&&(u.tabindex=i.toString());for(let[I,L]of Object.entries(t.meta||{}))I.startsWith("_")||(u[I]=L);let c={type:"element",tagName:"pre",properties:u,children:[],data:t.data},d={type:"element",tagName:"code",properties:{},children:s},p=[],m={...a,structure:l,addClassToHast:xi,get source(){return a.source},get tokens(){return e},get options(){return t},get root(){return n},get pre(){return c},get code(){return d},get lines(){return p}};if(e.forEach((I,L)=>{L&&(l==="inline"?n.children.push({type:"element",tagName:"br",properties:{},children:[]}):l==="classic"&&s.push({type:"text",value:`
|
|
79
|
+
`}));let S={type:"element",tagName:"span",properties:{class:"line"},children:[]},C=0;for(let g of I){let b={type:"element",tagName:"span",properties:{...g.htmlAttrs},children:[{type:"text",value:g.content}]},T=zo(g.htmlStyle||Oa(g));T&&(b.properties.style=T);for(let P of r)b=P?.span?.call(m,b,L+1,C,S,g)||b;l==="inline"?n.children.push(b):l==="classic"&&S.children.push(b),C+=g.content.length}if(l==="classic"){for(let g of r)S=g?.line?.call(m,S,L+1)||S;p.push(S),s.push(S)}else l==="inline"&&p.push(S)}),l==="classic"){for(let I of r)d=I?.code?.call(m,d)||d;c.children.push(d);for(let I of r)c=I?.pre?.call(m,c)||c;n.children.push(c)}else if(l==="inline"){let I=[],L={type:"element",tagName:"span",properties:{class:"line"},children:[]};for(let g of n.children)g.type==="element"&&g.tagName==="br"?(I.push(L),L={type:"element",tagName:"span",properties:{class:"line"},children:[]}):(g.type==="element"||g.type==="text")&&L.children.push(g);I.push(L);let C={type:"element",tagName:"code",properties:{},children:I};for(let g of r)C=g?.code?.call(m,C)||C;n.children=[];for(let g=0;g<C.children.length;g++){g>0&&n.children.push({type:"element",tagName:"br",properties:{},children:[]});let b=C.children[g];b.type==="element"&&n.children.push(...b.children)}}let h=n;for(let I of r)h=I?.root?.call(m,h)||h;return o&&ja(h,o),h}function Kf(e){return e.map(t=>{let a=[],o="",r;return t.forEach((s,n)=>{let i=!(s.fontStyle&&(s.fontStyle&ce.Underline||s.fontStyle&ce.Strikethrough));i&&s.content.match(/^\s+$/)&&t[n+1]?(r===void 0&&(r=s.offset),o+=s.content):o?(i?a.push({...s,offset:r,content:o+s.content}):a.push({content:o,offset:r},s),r=void 0,o=""):a.push(s)}),a})}function Qf(e){return e.map(t=>t.flatMap(a=>{if(a.content.match(/^\s+$/))return a;let o=a.content.match(/^(\s*)(.*?)(\s*)$/);if(!o)return a;let[,r,s,n]=o;if(!r&&!n)return a;let l=[{...a,offset:a.offset+r.length,content:s}];return r&&l.unshift({content:r,offset:a.offset}),n&&l.push({content:n,offset:a.offset+r.length+s.length}),l}))}function Jf(e){return e.map(t=>{let a=[];for(let o of t){if(a.length===0){a.push({...o});continue}let r=a[a.length-1],s=zo(r.htmlStyle||Oa(r)),n=zo(o.htmlStyle||Oa(o)),l=r.fontStyle&&(r.fontStyle&ce.Underline||r.fontStyle&ce.Strikethrough),i=o.fontStyle&&(o.fontStyle&ce.Underline||o.fontStyle&ce.Strikethrough);!l&&!i&&s===n?r.content+=o.content:a.push({...o})}return a})}var Zf=Wo;function Yf(e,t,a){let o={meta:{},options:a,codeToHast:(s,n)=>Wa(e,s,n),codeToTokens:(s,n)=>qa(e,s,n)},r=Zf(Wa(e,t,a,o));for(let s of Ha(a))r=s.postprocess?.call(o,r,a)||r;return r}var fi={light:"#333333",dark:"#bbbbbb"},pi={light:"#fffffe",dark:"#1e1e1e"},mi="__shiki_resolved";function Yo(e){if(e?.[mi])return e;let t={...e};t.tokenColors&&!t.settings&&(t.settings=t.tokenColors,delete t.tokenColors),t.type||="dark",t.colorReplacements={...t.colorReplacements},t.settings||=[];let{bg:a,fg:o}=t;if(!a||!o){let l=t.settings?t.settings.find(i=>!i.name&&!i.scope):void 0;l?.settings?.foreground&&(o=l.settings.foreground),l?.settings?.background&&(a=l.settings.background),!o&&t?.colors?.["editor.foreground"]&&(o=t.colors["editor.foreground"]),!a&&t?.colors?.["editor.background"]&&(a=t.colors["editor.background"]),o||(o=t.type==="light"?fi.light:fi.dark),a||(a=t.type==="light"?pi.light:pi.dark),t.fg=o,t.bg=a}t.settings[0]&&t.settings[0].settings&&!t.settings[0].scope||t.settings.unshift({settings:{foreground:t.fg,background:t.bg}});let r=0,s=new Map;function n(l){if(s.has(l))return s.get(l);r+=1;let i=`#${r.toString(16).padStart(8,"0").toLowerCase()}`;return t.colorReplacements?.[`#${i}`]?n(l):(s.set(l,i),i)}t.settings=t.settings.map(l=>{let i=l.settings?.foreground&&!l.settings.foreground.startsWith("#"),u=l.settings?.background&&!l.settings.background.startsWith("#");if(!i&&!u)return l;let c={...l,settings:{...l.settings}};if(i){let d=n(l.settings.foreground);t.colorReplacements[d]=l.settings.foreground,c.settings.foreground=d}if(u){let d=n(l.settings.background);t.colorReplacements[d]=l.settings.background,c.settings.background=d}return c});for(let l of Object.keys(t.colors||{}))if((l==="editor.foreground"||l==="editor.background"||l.startsWith("terminal.ansi"))&&!t.colors[l]?.startsWith("#")){let i=n(t.colors[l]);t.colorReplacements[i]=t.colors[l],t.colors[l]=i}return Object.defineProperty(t,mi,{enumerable:!1,writable:!1,value:!0}),t}async function yi(e){return Array.from(new Set((await Promise.all(e.filter(t=>!gi(t)).map(async t=>await hi(t).then(a=>Array.isArray(a)?a:[a])))).flat()))}async function bi(e){return(await Promise.all(e.map(async a=>wi(a)?null:Yo(await hi(a))))).filter(a=>!!a)}var jo=3,ep=!1;function tp(e,t=3){if(jo&&!(typeof jo=="number"&&t>jo)){if(ep)throw new Error(`[SHIKI DEPRECATE]: ${e}`);console.trace(`[SHIKI DEPRECATE]: ${e}`)}}var Qe=class extends Error{constructor(t){super(t),this.name="ShikiError"}};function ki(e,t){if(!t)return e;if(t[e]){let a=new Set([e]);for(;t[e];){if(e=t[e],a.has(e))throw new Qe(`Circular alias \`${Array.from(a).join(" -> ")} -> ${e}\``);a.add(e)}}return e}var Vo=class extends Gn{constructor(t,a,o,r={}){super(t),this._resolver=t,this._themes=a,this._langs=o,this._alias=r,this._themes.map(s=>this.loadTheme(s)),this.loadLanguages(this._langs)}_resolvedThemes=new Map;_resolvedGrammars=new Map;_langMap=new Map;_langGraph=new Map;_textmateThemeCache=new WeakMap;_loadedThemesCache=null;_loadedLanguagesCache=null;getTheme(t){return typeof t=="string"?this._resolvedThemes.get(t):this.loadTheme(t)}loadTheme(t){let a=Yo(t);return a.name&&(this._resolvedThemes.set(a.name,a),this._loadedThemesCache=null),a}getLoadedThemes(){return this._loadedThemesCache||(this._loadedThemesCache=[...this._resolvedThemes.keys()]),this._loadedThemesCache}setTheme(t){let a=this._textmateThemeCache.get(t);a||(a=Xt.createFromRawTheme(t),this._textmateThemeCache.set(t,a)),this._syncRegistry.setTheme(a)}getGrammar(t){return t=ki(t,this._alias),this._resolvedGrammars.get(t)}loadLanguage(t){if(this.getGrammar(t.name))return;let a=new Set([...this._langMap.values()].filter(s=>s.embeddedLangsLazy?.includes(t.name)));this._resolver.addLanguage(t);let o={balancedBracketSelectors:t.balancedBracketSelectors||["*"],unbalancedBracketSelectors:t.unbalancedBracketSelectors||[]};this._syncRegistry._rawGrammars.set(t.scopeName,t);let r=this.loadGrammarWithConfiguration(t.scopeName,1,o);if(r.name=t.name,this._resolvedGrammars.set(t.name,r),t.aliases&&t.aliases.forEach(s=>{this._alias[s]=t.name}),this._loadedLanguagesCache=null,a.size)for(let s of a)this._resolvedGrammars.delete(s.name),this._loadedLanguagesCache=null,this._syncRegistry?._injectionGrammars?.delete(s.scopeName),this._syncRegistry?._grammars?.delete(s.scopeName),this.loadLanguage(this._langMap.get(s.name))}dispose(){super.dispose(),this._resolvedThemes.clear(),this._resolvedGrammars.clear(),this._langMap.clear(),this._langGraph.clear(),this._loadedThemesCache=null}loadLanguages(t){for(let r of t)this.resolveEmbeddedLanguages(r);let a=Array.from(this._langGraph.entries()),o=a.filter(([r,s])=>!s);if(o.length){let r=a.filter(([s,n])=>n?(n.embeddedLanguages||n.embeddedLangs)?.some(i=>o.map(([u])=>u).includes(i)):!1).filter(s=>!o.includes(s));throw new Qe(`Missing languages ${o.map(([s])=>`\`${s}\``).join(", ")}, required by ${r.map(([s])=>`\`${s}\``).join(", ")}`)}for(let[r,s]of a)this._resolver.addLanguage(s);for(let[r,s]of a)this.loadLanguage(s)}getLoadedLanguages(){return this._loadedLanguagesCache||(this._loadedLanguagesCache=[...new Set([...this._resolvedGrammars.keys(),...Object.keys(this._alias)])]),this._loadedLanguagesCache}resolveEmbeddedLanguages(t){this._langMap.set(t.name,t),this._langGraph.set(t.name,t);let a=t.embeddedLanguages??t.embeddedLangs;if(a)for(let o of a)this._langGraph.set(o,this._langMap.get(o))}},$o=class{_langs=new Map;_scopeToLang=new Map;_injections=new Map;_onigLib;constructor(t,a){this._onigLib={createOnigScanner:o=>t.createScanner(o),createOnigString:o=>t.createString(o)},a.forEach(o=>this.addLanguage(o))}get onigLib(){return this._onigLib}getLangRegistration(t){return this._langs.get(t)}loadGrammar(t){return this._scopeToLang.get(t)}addLanguage(t){this._langs.set(t.name,t),t.aliases&&t.aliases.forEach(a=>{this._langs.set(a,t)}),this._scopeToLang.set(t.scopeName,t),t.injectTo&&t.injectTo.forEach(a=>{this._injections.get(a)||this._injections.set(a,[]),this._injections.get(a).push(t.scopeName)})}getInjections(t){let a=t.split("."),o=[];for(let r=1;r<=a.length;r++){let s=a.slice(0,r).join(".");o=[...o,...this._injections.get(s)||[]]}return o}},ea=0;function ap(e){ea+=1,e.warnings!==!1&&ea>=10&&ea%10===0&&console.warn(`[Shiki] ${ea} instances have been created. Shiki is supposed to be used as a singleton, consider refactoring your code to cache your highlighter instance; Or call \`highlighter.dispose()\` to release unused instances.`);let t=!1;if(!e.engine)throw new Qe("`engine` option is required for synchronous mode");let a=(e.langs||[]).flat(1),o=(e.themes||[]).flat(1).map(Yo),r=new $o(e.engine,a),s=new Vo(r,o,a,e.langAlias),n;function l(g){return ki(g,e.langAlias)}function i(g){S();let b=s.getGrammar(typeof g=="string"?g:g.name);if(!b)throw new Qe(`Language \`${g}\` not found, you may need to load it first`);return b}function u(g){if(g==="none")return{bg:"",fg:"",name:"none",settings:[],type:"dark"};S();let b=s.getTheme(g);if(!b)throw new Qe(`Theme \`${g}\` not found, you may need to load it first`);return b}function c(g){S();let b=u(g);n!==g&&(s.setTheme(b),n=g);let T=s.getColorMap();return{theme:b,colorMap:T}}function d(){return S(),s.getLoadedThemes()}function p(){return S(),s.getLoadedLanguages()}function m(...g){S(),s.loadLanguages(g.flat(1))}async function h(...g){return m(await yi(g))}function I(...g){S();for(let b of g.flat(1))s.loadTheme(b)}async function L(...g){return S(),I(await bi(g))}function S(){if(t)throw new Qe("Shiki instance has been disposed")}function C(){t||(t=!0,s.dispose(),ea-=1)}return{setTheme:c,getTheme:u,getLanguage:i,getLoadedThemes:d,getLoadedLanguages:p,resolveLangAlias:l,loadLanguage:h,loadLanguageSync:m,loadTheme:L,loadThemeSync:I,dispose:C,[Symbol.dispose]:C}}async function op(e){e.engine||tp("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");let[t,a,o]=await Promise.all([bi(e.themes||[]),yi(e.langs||[]),e.engine]);return ap({...e,themes:t,langs:a,engine:o})}async function rp(e){let t=await op(e);return{getLastGrammarState:(...a)=>qf(t,...a),codeToTokensBase:(a,o)=>Jo(t,a,o),codeToTokensWithThemes:(a,o)=>Si(t,a,o),codeToTokens:(a,o)=>qa(t,a,o),codeToHast:(a,o)=>Wa(t,a,o),codeToHtml:(a,o)=>Yf(t,a,o),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...t,getInternalContext:()=>t}}function Ti(e){let t=e.langs,a=e.themes,o=e.engine;async function r(s){function n(d){if(typeof d=="string"){if(d=s.langAlias?.[d]||d,gi(d))return[];let p=t[d];if(!p)throw new Z(`Language \`${d}\` is not included in this bundle. You may want to load it from external source.`);return p}return d}function l(d){if(wi(d))return"none";if(typeof d=="string"){let p=a[d];if(!p)throw new Z(`Theme \`${d}\` is not included in this bundle. You may want to load it from external source.`);return p}return d}let i=(s.themes??[]).map(d=>l(d)),u=(s.langs??[]).map(d=>n(d)),c=await rp({engine:s.engine??o(),...s,themes:i,langs:u});return{...c,loadLanguage(...d){return c.loadLanguage(...d.map(n))},loadTheme(...d){return c.loadTheme(...d.map(l))},getBundledLanguages(){return t},getBundledThemes(){return a}}}return r}function sp(e){let t;async function a(o={}){if(t){let r=await t;return await Promise.all([r.loadTheme(...o.themes||[]),r.loadLanguage(...o.langs||[])]),r}else{t=e({...o,themes:[],langs:[]});let r=await t;return await Promise.all([r.loadTheme(...o.themes||[]),r.loadLanguage(...o.langs||[])]),r}}return a}function Pi(e,t){let a=sp(e);async function o(r,s){let n=await a({langs:[s.lang],themes:"theme"in s?[s.theme]:Object.values(s.themes)}),l=await t?.guessEmbeddedLanguages?.(r,s.lang,n);return l&&await n.loadLanguage(...l),n}return{getSingletonHighlighter(r){return a(r)},async codeToHtml(r,s){return(await o(r,s)).codeToHtml(r,s)},async codeToHast(r,s){return(await o(r,s)).codeToHast(r,s)},async codeToTokens(r,s){return(await o(r,s)).codeToTokens(r,s)},async codeToTokensBase(r,s){return(await o(r,s)).codeToTokensBase(r,s)},async codeToTokensWithThemes(r,s){return(await o(r,s)).codeToTokensWithThemes(r,s)},async getLastGrammarState(r,s){return(await a({langs:[s.lang],themes:[s.theme]})).getLastGrammarState(r,s)}}}f();var er=[{id:"abap",name:"ABAP",import:(()=>import("../abap-3IAGZ3PS.js"))},{id:"actionscript-3",name:"ActionScript",import:(()=>import("../actionscript-3-C46RIPM4.js"))},{id:"ada",name:"Ada",import:(()=>import("../ada-DNTYS66P.js"))},{id:"angular-html",name:"Angular HTML",import:(()=>import("../angular-html-VZSV3CDH.js"))},{id:"angular-ts",name:"Angular TypeScript",import:(()=>import("../angular-ts-UPMUIYI3.js"))},{id:"apache",name:"Apache Conf",import:(()=>import("../apache-DU26FTNI.js"))},{id:"apex",name:"Apex",import:(()=>import("../apex-OU63AG2P.js"))},{id:"apl",name:"APL",import:(()=>import("../apl-ZTMAKUPW.js"))},{id:"applescript",name:"AppleScript",import:(()=>import("../applescript-TT4XSRXH.js"))},{id:"ara",name:"Ara",import:(()=>import("../ara-Q7AJDKA4.js"))},{id:"asciidoc",name:"AsciiDoc",aliases:["adoc"],import:(()=>import("../asciidoc-WADBFJPS.js"))},{id:"asm",name:"Assembly",import:(()=>import("../asm-D3LJR7GV.js"))},{id:"astro",name:"Astro",import:(()=>import("../astro-ZC25ZSBI.js"))},{id:"awk",name:"AWK",import:(()=>import("../awk-DCAM52A7.js"))},{id:"ballerina",name:"Ballerina",import:(()=>import("../ballerina-44XARFEK.js"))},{id:"bat",name:"Batch File",aliases:["batch"],import:(()=>import("../bat-WM4RL2AB.js"))},{id:"beancount",name:"Beancount",import:(()=>import("../beancount-5PUWGPVT.js"))},{id:"berry",name:"Berry",aliases:["be"],import:(()=>import("../berry-YAK4XTWX.js"))},{id:"bibtex",name:"BibTeX",import:(()=>import("../bibtex-2ISWNMJJ.js"))},{id:"bicep",name:"Bicep",import:(()=>import("../bicep-EOACOM4G.js"))},{id:"blade",name:"Blade",import:(()=>import("../blade-BVUO2H7O.js"))},{id:"bsl",name:"1C (Enterprise)",aliases:["1c"],import:(()=>import("../bsl-TNLQPNE3.js"))},{id:"c",name:"C",import:(()=>import("../c-G7V525MX.js"))},{id:"c3",name:"C3",import:(()=>import("../c3-CDQIRWGP.js"))},{id:"cadence",name:"Cadence",aliases:["cdc"],import:(()=>import("../cadence-U32GKKTR.js"))},{id:"cairo",name:"Cairo",import:(()=>import("../cairo-26RR6N4F.js"))},{id:"clarity",name:"Clarity",import:(()=>import("../clarity-4JIHRN2V.js"))},{id:"clojure",name:"Clojure",aliases:["clj"],import:(()=>import("../clojure-PKTTXYYS.js"))},{id:"cmake",name:"CMake",import:(()=>import("../cmake-HXKHWGGH.js"))},{id:"cobol",name:"COBOL",import:(()=>import("../cobol-SKJIT3WM.js"))},{id:"codeowners",name:"CODEOWNERS",import:(()=>import("../codeowners-WCXRHQ2R.js"))},{id:"codeql",name:"CodeQL",aliases:["ql"],import:(()=>import("../codeql-XZZ2USHF.js"))},{id:"coffee",name:"CoffeeScript",aliases:["coffeescript"],import:(()=>import("../coffee-SGQWHBUL.js"))},{id:"common-lisp",name:"Common Lisp",aliases:["lisp"],import:(()=>import("../common-lisp-IK3DGBCK.js"))},{id:"coq",name:"Coq",import:(()=>import("../coq-UPTUVPLH.js"))},{id:"cpp",name:"C++",aliases:["c++"],import:(()=>import("../cpp-4EW5XLOK.js"))},{id:"crystal",name:"Crystal",import:(()=>import("../crystal-YFCJLEES.js"))},{id:"csharp",name:"C#",aliases:["c#","cs"],import:(()=>import("../csharp-6EXQ7B24.js"))},{id:"css",name:"CSS",import:(()=>import("../css-MH4LSMNV.js"))},{id:"csv",name:"CSV",import:(()=>import("../csv-CRTD5FOL.js"))},{id:"cue",name:"CUE",import:(()=>import("../cue-IFMTDLM2.js"))},{id:"cypher",name:"Cypher",aliases:["cql"],import:(()=>import("../cypher-WH7754G7.js"))},{id:"d",name:"D",import:(()=>import("../d-VFMGCSG3.js"))},{id:"dart",name:"Dart",import:(()=>import("../dart-CSERBUPM.js"))},{id:"dax",name:"DAX",import:(()=>import("../dax-Y4DTPR3K.js"))},{id:"desktop",name:"Desktop",import:(()=>import("../desktop-UYAYGPQT.js"))},{id:"diff",name:"Diff",import:(()=>import("../diff-BJDM3N45.js"))},{id:"docker",name:"Dockerfile",aliases:["dockerfile"],import:(()=>import("../docker-UOM4Q7PD.js"))},{id:"dotenv",name:"dotEnv",import:(()=>import("../dotenv-LK44WBD3.js"))},{id:"dream-maker",name:"Dream Maker",import:(()=>import("../dream-maker-7RP4JRQH.js"))},{id:"edge",name:"Edge",import:(()=>import("../edge-3LWPZYS7.js"))},{id:"elixir",name:"Elixir",import:(()=>import("../elixir-3H7W7YJZ.js"))},{id:"elm",name:"Elm",import:(()=>import("../elm-THYL2NRS.js"))},{id:"emacs-lisp",name:"Emacs Lisp",aliases:["elisp"],import:(()=>import("../emacs-lisp-YHLQYGNI.js"))},{id:"erb",name:"ERB",import:(()=>import("../erb-AXCKAI43.js"))},{id:"erlang",name:"Erlang",aliases:["erl"],import:(()=>import("../erlang-UNX5MMGA.js"))},{id:"fennel",name:"Fennel",import:(()=>import("../fennel-HYSSBG3N.js"))},{id:"fish",name:"Fish",import:(()=>import("../fish-PTKGQOJI.js"))},{id:"fluent",name:"Fluent",aliases:["ftl"],import:(()=>import("../fluent-LEZHPPJV.js"))},{id:"fortran-fixed-form",name:"Fortran (Fixed Form)",aliases:["f","for","f77"],import:(()=>import("../fortran-fixed-form-J5AMEFMB.js"))},{id:"fortran-free-form",name:"Fortran (Free Form)",aliases:["f90","f95","f03","f08","f18"],import:(()=>import("../fortran-free-form-S3BNTBLS.js"))},{id:"fsharp",name:"F#",aliases:["f#","fs"],import:(()=>import("../fsharp-H4OIW62Z.js"))},{id:"gdresource",name:"GDResource",aliases:["tscn","tres"],import:(()=>import("../gdresource-A6NTYFLM.js"))},{id:"gdscript",name:"GDScript",aliases:["gd"],import:(()=>import("../gdscript-YQUSJRNZ.js"))},{id:"gdshader",name:"GDShader",import:(()=>import("../gdshader-S5432GFE.js"))},{id:"genie",name:"Genie",import:(()=>import("../genie-RNVG5N7L.js"))},{id:"gherkin",name:"Gherkin",import:(()=>import("../gherkin-E5R62T6O.js"))},{id:"git-commit",name:"Git Commit Message",import:(()=>import("../git-commit-QGH6XOBG.js"))},{id:"git-rebase",name:"Git Rebase Message",import:(()=>import("../git-rebase-XTCZTXU4.js"))},{id:"gleam",name:"Gleam",import:(()=>import("../gleam-W5WZ7CST.js"))},{id:"glimmer-js",name:"Glimmer JS",aliases:["gjs"],import:(()=>import("../glimmer-js-ZXI6Y36F.js"))},{id:"glimmer-ts",name:"Glimmer TS",aliases:["gts"],import:(()=>import("../glimmer-ts-BJKMFBLF.js"))},{id:"glsl",name:"GLSL",import:(()=>import("../glsl-PVW2OPUD.js"))},{id:"gn",name:"GN",import:(()=>import("../gn-FCAO7WI5.js"))},{id:"gnuplot",name:"Gnuplot",import:(()=>import("../gnuplot-Q6SE5CHZ.js"))},{id:"go",name:"Go",import:(()=>import("../go-CPCZAAWX.js"))},{id:"graphql",name:"GraphQL",aliases:["gql"],import:(()=>import("../graphql-KHEFECOG.js"))},{id:"groovy",name:"Groovy",import:(()=>import("../groovy-PJAEBBJY.js"))},{id:"hack",name:"Hack",import:(()=>import("../hack-KV5GHBVV.js"))},{id:"haml",name:"Ruby Haml",import:(()=>import("../haml-6R7X7F2Q.js"))},{id:"handlebars",name:"Handlebars",aliases:["hbs"],import:(()=>import("../handlebars-U44VLSEQ.js"))},{id:"haskell",name:"Haskell",aliases:["hs"],import:(()=>import("../haskell-NX6XRMNO.js"))},{id:"haxe",name:"Haxe",import:(()=>import("../haxe-7YNB7FVC.js"))},{id:"hcl",name:"HashiCorp HCL",import:(()=>import("../hcl-ZF75ASCX.js"))},{id:"hjson",name:"Hjson",import:(()=>import("../hjson-65TX6QOC.js"))},{id:"hlsl",name:"HLSL",import:(()=>import("../hlsl-U2O526MI.js"))},{id:"html",name:"HTML",import:(()=>import("../html-MYZBE4UD.js"))},{id:"html-derivative",name:"HTML (Derivative)",import:(()=>import("../html-derivative-OWRPAN3G.js"))},{id:"http",name:"HTTP",import:(()=>import("../http-JSPDAWSO.js"))},{id:"hurl",name:"Hurl",import:(()=>import("../hurl-OT2SM4S7.js"))},{id:"hxml",name:"HXML",import:(()=>import("../hxml-IGTXIURH.js"))},{id:"hy",name:"Hy",import:(()=>import("../hy-CLDGXJYP.js"))},{id:"imba",name:"Imba",import:(()=>import("../imba-NWHLCVE5.js"))},{id:"ini",name:"INI",aliases:["properties"],import:(()=>import("../ini-R6WYP7NC.js"))},{id:"java",name:"Java",import:(()=>import("../java-DHBXDMBM.js"))},{id:"javascript",name:"JavaScript",aliases:["js","cjs","mjs"],import:(()=>import("../javascript-GNUEDNHO.js"))},{id:"jinja",name:"Jinja",import:(()=>import("../jinja-CCI3FGLW.js"))},{id:"jison",name:"Jison",import:(()=>import("../jison-64A6IJCV.js"))},{id:"json",name:"JSON",import:(()=>import("../json-2ELCHKXT.js"))},{id:"json5",name:"JSON5",import:(()=>import("../json5-QRH5UJYD.js"))},{id:"jsonc",name:"JSON with Comments",import:(()=>import("../jsonc-IXPVR4NY.js"))},{id:"jsonl",name:"JSON Lines",import:(()=>import("../jsonl-C57GMUK5.js"))},{id:"jsonnet",name:"Jsonnet",import:(()=>import("../jsonnet-VNADFLKI.js"))},{id:"jssm",name:"JSSM",aliases:["fsl"],import:(()=>import("../jssm-CW4ZYDSF.js"))},{id:"jsx",name:"JSX",import:(()=>import("../jsx-YTENXENT.js"))},{id:"julia",name:"Julia",aliases:["jl"],import:(()=>import("../julia-BWWONBRS.js"))},{id:"kdl",name:"KDL",import:(()=>import("../kdl-X3AS2HRT.js"))},{id:"kotlin",name:"Kotlin",aliases:["kt","kts"],import:(()=>import("../kotlin-WGITM75W.js"))},{id:"kusto",name:"Kusto",aliases:["kql"],import:(()=>import("../kusto-LT46F7AO.js"))},{id:"latex",name:"LaTeX",import:(()=>import("../latex-R4PJ7JDY.js"))},{id:"lean",name:"Lean 4",aliases:["lean4"],import:(()=>import("../lean-DYWOENAS.js"))},{id:"less",name:"Less",import:(()=>import("../less-ZYJT7MPU.js"))},{id:"liquid",name:"Liquid",import:(()=>import("../liquid-OSRU4KOW.js"))},{id:"llvm",name:"LLVM IR",import:(()=>import("../llvm-WBQ7MHV7.js"))},{id:"log",name:"Log file",import:(()=>import("../log-AXKDFD3L.js"))},{id:"logo",name:"Logo",import:(()=>import("../logo-E23LAFZY.js"))},{id:"lua",name:"Lua",import:(()=>import("../lua-QQ5QEPPO.js"))},{id:"luau",name:"Luau",import:(()=>import("../luau-D432BEB5.js"))},{id:"make",name:"Makefile",aliases:["makefile"],import:(()=>import("../make-QFMWQJMG.js"))},{id:"markdown",name:"Markdown",aliases:["md"],import:(()=>import("../markdown-D756RUOP.js"))},{id:"marko",name:"Marko",import:(()=>import("../marko-WVASNOGB.js"))},{id:"matlab",name:"MATLAB",import:(()=>import("../matlab-ZKZ7YBAH.js"))},{id:"mdc",name:"MDC",import:(()=>import("../mdc-PDOFYVVO.js"))},{id:"mdx",name:"MDX",import:(()=>import("../mdx-34BL2O4O.js"))},{id:"mermaid",name:"Mermaid",aliases:["mmd"],import:(()=>import("../mermaid-54Z3SAII.js"))},{id:"mipsasm",name:"MIPS Assembly",aliases:["mips"],import:(()=>import("../mipsasm-NKQWJEL7.js"))},{id:"mojo",name:"Mojo",import:(()=>import("../mojo-KRRNBH7O.js"))},{id:"moonbit",name:"MoonBit",aliases:["mbt","mbti"],import:(()=>import("../moonbit-LQ7JL5LZ.js"))},{id:"move",name:"Move",import:(()=>import("../move-4VWCI4YQ.js"))},{id:"narrat",name:"Narrat Language",aliases:["nar"],import:(()=>import("../narrat-4QSDQDLH.js"))},{id:"nextflow",name:"Nextflow",aliases:["nf"],import:(()=>import("../nextflow-DPCEWQNZ.js"))},{id:"nginx",name:"Nginx",import:(()=>import("../nginx-DXHAXQRH.js"))},{id:"nim",name:"Nim",import:(()=>import("../nim-WGQAUAVA.js"))},{id:"nix",name:"Nix",import:(()=>import("../nix-WAYR4BYU.js"))},{id:"nushell",name:"nushell",aliases:["nu"],import:(()=>import("../nushell-26KZW4VL.js"))},{id:"objective-c",name:"Objective-C",aliases:["objc"],import:(()=>import("../objective-c-246HWLKT.js"))},{id:"objective-cpp",name:"Objective-C++",import:(()=>import("../objective-cpp-RJUXXPYQ.js"))},{id:"ocaml",name:"OCaml",import:(()=>import("../ocaml-P7NGS7PR.js"))},{id:"odin",name:"Odin",import:(()=>import("../odin-UPPZCJGN.js"))},{id:"openscad",name:"OpenSCAD",aliases:["scad"],import:(()=>import("../openscad-JRK6K3FL.js"))},{id:"pascal",name:"Pascal",import:(()=>import("../pascal-RDFLUHHA.js"))},{id:"perl",name:"Perl",import:(()=>import("../perl-Y3ALUOFJ.js"))},{id:"php",name:"PHP",import:(()=>import("../php-QERWOQJG.js"))},{id:"pkl",name:"Pkl",import:(()=>import("../pkl-PAM76VXP.js"))},{id:"plsql",name:"PL/SQL",import:(()=>import("../plsql-3Y6UMFEG.js"))},{id:"po",name:"Gettext PO",aliases:["pot","potx"],import:(()=>import("../po-GNTAKCTE.js"))},{id:"polar",name:"Polar",import:(()=>import("../polar-EVTMRLGV.js"))},{id:"postcss",name:"PostCSS",import:(()=>import("../postcss-42343LW7.js"))},{id:"powerquery",name:"PowerQuery",import:(()=>import("../powerquery-M34PNR4X.js"))},{id:"powershell",name:"PowerShell",aliases:["ps","ps1"],import:(()=>import("../powershell-IR7ICFQW.js"))},{id:"prisma",name:"Prisma",import:(()=>import("../prisma-RXSIFLZX.js"))},{id:"prolog",name:"Prolog",import:(()=>import("../prolog-YBBQ4UD5.js"))},{id:"proto",name:"Protocol Buffer 3",aliases:["protobuf"],import:(()=>import("../proto-U4FF45G6.js"))},{id:"pug",name:"Pug",aliases:["jade"],import:(()=>import("../pug-7XNGVJEC.js"))},{id:"puppet",name:"Puppet",import:(()=>import("../puppet-HWOKIYJP.js"))},{id:"purescript",name:"PureScript",import:(()=>import("../purescript-D45AJS5J.js"))},{id:"python",name:"Python",aliases:["py"],import:(()=>import("../python-QWA7UE2I.js"))},{id:"qml",name:"QML",import:(()=>import("../qml-RHCWFR3S.js"))},{id:"qmldir",name:"QML Directory",import:(()=>import("../qmldir-FBDC3XMZ.js"))},{id:"qss",name:"Qt Style Sheets",import:(()=>import("../qss-AD3WZQ45.js"))},{id:"r",name:"R",import:(()=>import("../r-NHIAHDOD.js"))},{id:"racket",name:"Racket",import:(()=>import("../racket-7G65C5N5.js"))},{id:"raku",name:"Raku",aliases:["perl6"],import:(()=>import("../raku-IWS7BLGD.js"))},{id:"razor",name:"ASP.NET Razor",import:(()=>import("../razor-C2NV2YNT.js"))},{id:"reg",name:"Windows Registry Script",import:(()=>import("../reg-V4XLWESR.js"))},{id:"regexp",name:"RegExp",aliases:["regex"],import:(()=>import("../regexp-XP4MR635.js"))},{id:"rel",name:"Rel",import:(()=>import("../rel-DE6UXATM.js"))},{id:"riscv",name:"RISC-V",import:(()=>import("../riscv-5PDXBPPL.js"))},{id:"ron",name:"RON",import:(()=>import("../ron-WD6BJFDY.js"))},{id:"rosmsg",name:"ROS Interface",import:(()=>import("../rosmsg-7LDUCZRQ.js"))},{id:"rst",name:"reStructuredText",import:(()=>import("../rst-W5S2XFF7.js"))},{id:"ruby",name:"Ruby",aliases:["rb"],import:(()=>import("../ruby-EYYAUQUG.js"))},{id:"rust",name:"Rust",aliases:["rs"],import:(()=>import("../rust-Z2NYMT2Z.js"))},{id:"sas",name:"SAS",import:(()=>import("../sas-A4JCTK6H.js"))},{id:"sass",name:"Sass",import:(()=>import("../sass-75VDP7DE.js"))},{id:"scala",name:"Scala",import:(()=>import("../scala-7TJ4N6KC.js"))},{id:"scheme",name:"Scheme",import:(()=>import("../scheme-5XARZMKT.js"))},{id:"scss",name:"SCSS",import:(()=>import("../scss-4QR2BXFS.js"))},{id:"sdbl",name:"1C (Query)",aliases:["1c-query"],import:(()=>import("../sdbl-6M55AJVA.js"))},{id:"shaderlab",name:"ShaderLab",aliases:["shader"],import:(()=>import("../shaderlab-322XNY5V.js"))},{id:"shellscript",name:"Shell",aliases:["bash","sh","shell","zsh"],import:(()=>import("../shellscript-F23VVVTW.js"))},{id:"shellsession",name:"Shell Session",aliases:["console"],import:(()=>import("../shellsession-G65XJMCC.js"))},{id:"smalltalk",name:"Smalltalk",import:(()=>import("../smalltalk-LALIO5SC.js"))},{id:"solidity",name:"Solidity",import:(()=>import("../solidity-TQUKTJZZ.js"))},{id:"soy",name:"Closure Templates",aliases:["closure-templates"],import:(()=>import("../soy-G2LDZSDN.js"))},{id:"sparql",name:"SPARQL",import:(()=>import("../sparql-ARI3MVK7.js"))},{id:"splunk",name:"Splunk Query Language",aliases:["spl"],import:(()=>import("../splunk-QEFG3NPJ.js"))},{id:"sql",name:"SQL",import:(()=>import("../sql-SBP7VV3V.js"))},{id:"ssh-config",name:"SSH Config",import:(()=>import("../ssh-config-SC6RC6IV.js"))},{id:"stata",name:"Stata",import:(()=>import("../stata-MNI5YOQU.js"))},{id:"stylus",name:"Stylus",aliases:["styl"],import:(()=>import("../stylus-YYWEHAK3.js"))},{id:"surrealql",name:"SurrealQL",aliases:["surql"],import:(()=>import("../surrealql-5X7LI3J6.js"))},{id:"svelte",name:"Svelte",import:(()=>import("../svelte-EYZDXUS2.js"))},{id:"swift",name:"Swift",import:(()=>import("../swift-JEBLU4EM.js"))},{id:"system-verilog",name:"SystemVerilog",import:(()=>import("../system-verilog-46QRSGNM.js"))},{id:"systemd",name:"Systemd Units",import:(()=>import("../systemd-3PUVCSI7.js"))},{id:"talonscript",name:"TalonScript",aliases:["talon"],import:(()=>import("../talonscript-AK4LB3KC.js"))},{id:"tasl",name:"Tasl",import:(()=>import("../tasl-VHTYBUVI.js"))},{id:"tcl",name:"Tcl",import:(()=>import("../tcl-UUMKHRHL.js"))},{id:"templ",name:"Templ",import:(()=>import("../templ-KXQ2KV7D.js"))},{id:"terraform",name:"Terraform",aliases:["tf","tfvars"],import:(()=>import("../terraform-GCGIT2RL.js"))},{id:"tex",name:"TeX",import:(()=>import("../tex-L55DZDKV.js"))},{id:"toml",name:"TOML",import:(()=>import("../toml-7AH4HFBN.js"))},{id:"ts-tags",name:"TypeScript with Tags",aliases:["lit"],import:(()=>import("../ts-tags-TCQ23O6Y.js"))},{id:"tsv",name:"TSV",import:(()=>import("../tsv-EB3LRXYX.js"))},{id:"tsx",name:"TSX",import:(()=>import("../tsx-Y5YXGNIX.js"))},{id:"turtle",name:"Turtle",import:(()=>import("../turtle-KM6UGYIQ.js"))},{id:"twig",name:"Twig",import:(()=>import("../twig-JAL4753Y.js"))},{id:"typescript",name:"TypeScript",aliases:["ts","cts","mts"],import:(()=>import("../typescript-ZF5AMNEZ.js"))},{id:"typespec",name:"TypeSpec",aliases:["tsp"],import:(()=>import("../typespec-6JSRRA42.js"))},{id:"typst",name:"Typst",aliases:["typ"],import:(()=>import("../typst-ZOSAUKL5.js"))},{id:"v",name:"V",import:(()=>import("../v-HVLBO3DI.js"))},{id:"vala",name:"Vala",import:(()=>import("../vala-WWRVCJNF.js"))},{id:"vb",name:"Visual Basic",aliases:["cmd"],import:(()=>import("../vb-XFFF4O73.js"))},{id:"verilog",name:"Verilog",import:(()=>import("../verilog-XTDPJNP7.js"))},{id:"vhdl",name:"VHDL",import:(()=>import("../vhdl-OCZJ2AOZ.js"))},{id:"viml",name:"Vim Script",aliases:["vim","vimscript"],import:(()=>import("../viml-PVA3ZJ5L.js"))},{id:"vue",name:"Vue",import:(()=>import("../vue-D6SXQNWM.js"))},{id:"vue-html",name:"Vue HTML",import:(()=>import("../vue-html-G4DE7FYD.js"))},{id:"vue-vine",name:"Vue Vine",import:(()=>import("../vue-vine-T6MFB2MU.js"))},{id:"vyper",name:"Vyper",aliases:["vy"],import:(()=>import("../vyper-SBDFKHRI.js"))},{id:"wasm",name:"WebAssembly",import:(()=>import("../wasm-SXNE4SKX.js"))},{id:"wenyan",name:"Wenyan",aliases:["\u6587\u8A00"],import:(()=>import("../wenyan-PMSCJP7P.js"))},{id:"wgsl",name:"WGSL",import:(()=>import("../wgsl-DOXQU7M4.js"))},{id:"wikitext",name:"Wikitext",aliases:["mediawiki","wiki"],import:(()=>import("../wikitext-LGNEKWDX.js"))},{id:"wit",name:"WebAssembly Interface Types",import:(()=>import("../wit-G62U2KBE.js"))},{id:"wolfram",name:"Wolfram",aliases:["wl"],import:(()=>import("../wolfram-YTZHUYN6.js"))},{id:"xml",name:"XML",import:(()=>import("../xml-WGLM4CWK.js"))},{id:"xsl",name:"XSL",import:(()=>import("../xsl-KAAH2GEK.js"))},{id:"yaml",name:"YAML",aliases:["yml"],import:(()=>import("../yaml-JGEBDSVI.js"))},{id:"zenscript",name:"ZenScript",import:(()=>import("../zenscript-QQQPZNJ7.js"))},{id:"zig",name:"Zig",import:(()=>import("../zig-6LJUAPBA.js"))}],vi=Object.fromEntries(er.map(e=>[e.id,e.import])),Ai=Object.fromEntries(er.flatMap(e=>e.aliases?.map(t=>[t,e.import])||[])),aa={...vi,...Ai};f();var np=[{id:"andromeeda",displayName:"Andromeeda",type:"dark",import:(()=>import("../andromeeda-XSK3JERF.js"))},{id:"aurora-x",displayName:"Aurora X",type:"dark",import:(()=>import("../aurora-x-CGSVHL4H.js"))},{id:"ayu-dark",displayName:"Ayu Dark",type:"dark",import:(()=>import("../ayu-dark-XYI57HMC.js"))},{id:"ayu-light",displayName:"Ayu Light",type:"light",import:(()=>import("../ayu-light-4PSGMDIC.js"))},{id:"ayu-mirage",displayName:"Ayu Mirage",type:"dark",import:(()=>import("../ayu-mirage-DU5SNMZX.js"))},{id:"catppuccin-frappe",displayName:"Catppuccin Frapp\xE9",type:"dark",import:(()=>import("../catppuccin-frappe-UZ4N3Z4I.js"))},{id:"catppuccin-latte",displayName:"Catppuccin Latte",type:"light",import:(()=>import("../catppuccin-latte-GCOWYLZG.js"))},{id:"catppuccin-macchiato",displayName:"Catppuccin Macchiato",type:"dark",import:(()=>import("../catppuccin-macchiato-PJD7W5WJ.js"))},{id:"catppuccin-mocha",displayName:"Catppuccin Mocha",type:"dark",import:(()=>import("../catppuccin-mocha-RRH4FOBS.js"))},{id:"dark-plus",displayName:"Dark Plus",type:"dark",import:(()=>import("../dark-plus-PSM5XP2I.js"))},{id:"dracula",displayName:"Dracula Theme",type:"dark",import:(()=>import("../dracula-2VHT5LK5.js"))},{id:"dracula-soft",displayName:"Dracula Theme Soft",type:"dark",import:(()=>import("../dracula-soft-MSCUO73T.js"))},{id:"everforest-dark",displayName:"Everforest Dark",type:"dark",import:(()=>import("../everforest-dark-AGVJEQ35.js"))},{id:"everforest-light",displayName:"Everforest Light",type:"light",import:(()=>import("../everforest-light-62GPFKVJ.js"))},{id:"github-dark",displayName:"GitHub Dark",type:"dark",import:(()=>import("../github-dark-5OJVMBCE.js"))},{id:"github-dark-default",displayName:"GitHub Dark Default",type:"dark",import:(()=>import("../github-dark-default-4WERFSZW.js"))},{id:"github-dark-dimmed",displayName:"GitHub Dark Dimmed",type:"dark",import:(()=>import("../github-dark-dimmed-7VD3SZKC.js"))},{id:"github-dark-high-contrast",displayName:"GitHub Dark High Contrast",type:"dark",import:(()=>import("../github-dark-high-contrast-FVMMS656.js"))},{id:"github-light",displayName:"GitHub Light",type:"light",import:(()=>import("../github-light-SE4LEKO7.js"))},{id:"github-light-default",displayName:"GitHub Light Default",type:"light",import:(()=>import("../github-light-default-TV7BYQGI.js"))},{id:"github-light-high-contrast",displayName:"GitHub Light High Contrast",type:"light",import:(()=>import("../github-light-high-contrast-WKO4I3G7.js"))},{id:"gruvbox-dark-hard",displayName:"Gruvbox Dark Hard",type:"dark",import:(()=>import("../gruvbox-dark-hard-LOYZQIGI.js"))},{id:"gruvbox-dark-medium",displayName:"Gruvbox Dark Medium",type:"dark",import:(()=>import("../gruvbox-dark-medium-UIMSJJ6K.js"))},{id:"gruvbox-dark-soft",displayName:"Gruvbox Dark Soft",type:"dark",import:(()=>import("../gruvbox-dark-soft-PU6RNTTO.js"))},{id:"gruvbox-light-hard",displayName:"Gruvbox Light Hard",type:"light",import:(()=>import("../gruvbox-light-hard-ZQJ7XSZF.js"))},{id:"gruvbox-light-medium",displayName:"Gruvbox Light Medium",type:"light",import:(()=>import("../gruvbox-light-medium-CD3ZGYV6.js"))},{id:"gruvbox-light-soft",displayName:"Gruvbox Light Soft",type:"light",import:(()=>import("../gruvbox-light-soft-S74MAGOM.js"))},{id:"horizon",displayName:"Horizon",type:"dark",import:(()=>import("../horizon-EAAZ4KVN.js"))},{id:"houston",displayName:"Houston",type:"dark",import:(()=>import("../houston-UNRWGR67.js"))},{id:"kanagawa-dragon",displayName:"Kanagawa Dragon",type:"dark",import:(()=>import("../kanagawa-dragon-BOSCCB42.js"))},{id:"kanagawa-lotus",displayName:"Kanagawa Lotus",type:"light",import:(()=>import("../kanagawa-lotus-NXMB2IVI.js"))},{id:"kanagawa-wave",displayName:"Kanagawa Wave",type:"dark",import:(()=>import("../kanagawa-wave-YOHS63UF.js"))},{id:"laserwave",displayName:"LaserWave",type:"dark",import:(()=>import("../laserwave-TS4AG4VO.js"))},{id:"light-plus",displayName:"Light Plus",type:"light",import:(()=>import("../light-plus-2HYW3NJ6.js"))},{id:"material-theme",displayName:"Material Theme",type:"dark",import:(()=>import("../material-theme-KPDVFAGV.js"))},{id:"material-theme-darker",displayName:"Material Theme Darker",type:"dark",import:(()=>import("../material-theme-darker-GVSTMSNT.js"))},{id:"material-theme-lighter",displayName:"Material Theme Lighter",type:"light",import:(()=>import("../material-theme-lighter-JWZNUXUH.js"))},{id:"material-theme-ocean",displayName:"Material Theme Ocean",type:"dark",import:(()=>import("../material-theme-ocean-MU4N3XNQ.js"))},{id:"material-theme-palenight",displayName:"Material Theme Palenight",type:"dark",import:(()=>import("../material-theme-palenight-VMWD73WM.js"))},{id:"min-dark",displayName:"Min Dark",type:"dark",import:(()=>import("../min-dark-ASEVSA24.js"))},{id:"min-light",displayName:"Min Light",type:"light",import:(()=>import("../min-light-3H54BB3D.js"))},{id:"monokai",displayName:"Monokai",type:"dark",import:(()=>import("../monokai-5QWQOFN6.js"))},{id:"night-owl",displayName:"Night Owl",type:"dark",import:(()=>import("../night-owl-4QQBS2UX.js"))},{id:"night-owl-light",displayName:"Night Owl Light",type:"light",import:(()=>import("../night-owl-light-HR6A2OQO.js"))},{id:"nord",displayName:"Nord",type:"dark",import:(()=>import("../nord-XK3AUNCF.js"))},{id:"one-dark-pro",displayName:"One Dark Pro",type:"dark",import:(()=>import("../one-dark-pro-ZV7CEA5M.js"))},{id:"one-light",displayName:"One Light",type:"light",import:(()=>import("../one-light-FKZJCKM6.js"))},{id:"plastic",displayName:"Plastic",type:"dark",import:(()=>import("../plastic-SXCQPKYC.js"))},{id:"poimandres",displayName:"Poimandres",type:"dark",import:(()=>import("../poimandres-S3UYVG4O.js"))},{id:"red",displayName:"Red",type:"dark",import:(()=>import("../red-A6OC2HVL.js"))},{id:"rose-pine",displayName:"Ros\xE9 Pine",type:"dark",import:(()=>import("../rose-pine-GLWOWPBK.js"))},{id:"rose-pine-dawn",displayName:"Ros\xE9 Pine Dawn",type:"light",import:(()=>import("../rose-pine-dawn-HYE6T7LV.js"))},{id:"rose-pine-moon",displayName:"Ros\xE9 Pine Moon",type:"dark",import:(()=>import("../rose-pine-moon-VHVTDDVO.js"))},{id:"slack-dark",displayName:"Slack Dark",type:"dark",import:(()=>import("../slack-dark-OPW5CYSY.js"))},{id:"slack-ochin",displayName:"Slack Ochin",type:"light",import:(()=>import("../slack-ochin-WTVMYBFH.js"))},{id:"snazzy-light",displayName:"Snazzy Light",type:"light",import:(()=>import("../snazzy-light-5UQ56PC5.js"))},{id:"solarized-dark",displayName:"Solarized Dark",type:"dark",import:(()=>import("../solarized-dark-DSMP6D7D.js"))},{id:"solarized-light",displayName:"Solarized Light",type:"light",import:(()=>import("../solarized-light-3IZTZCIV.js"))},{id:"synthwave-84",displayName:"Synthwave '84",type:"dark",import:(()=>import("../synthwave-84-JWI6CVJZ.js"))},{id:"tokyo-night",displayName:"Tokyo Night",type:"dark",import:(()=>import("../tokyo-night-SRK4SADJ.js"))},{id:"vesper",displayName:"Vesper",type:"dark",import:(()=>import("../vesper-WIZFPFI7.js"))},{id:"vitesse-black",displayName:"Vitesse Black",type:"dark",import:(()=>import("../vitesse-black-PEGI4HJX.js"))},{id:"vitesse-dark",displayName:"Vitesse Dark",type:"dark",import:(()=>import("../vitesse-dark-M2ZAGPXG.js"))},{id:"vitesse-light",displayName:"Vitesse Light",type:"light",import:(()=>import("../vitesse-light-RICZI4IG.js"))}],Ri=Object.fromEntries(np.map(e=>[e.id,e.import]));f();var oa=class extends Error{constructor(t){super(t),this.name="ShikiError"}};function ip(){return 2147483648}function lp(){return typeof performance<"u"?performance.now():Date.now()}var up=(e,t)=>e+(t-e%t)%t;async function dp(e){let t,a,o={};function r(m){a=m,o.HEAPU8=new Uint8Array(m),o.HEAPU32=new Uint32Array(m)}function s(m,h,I){o.HEAPU8.copyWithin(m,h,h+I)}function n(m){try{return t.grow(m-a.byteLength+65535>>>16),r(t.buffer),1}catch{}}function l(m){let h=o.HEAPU8.length;m=m>>>0;let I=ip();if(m>I)return!1;for(let L=1;L<=4;L*=2){let S=h*(1+.2/L);S=Math.min(S,m+100663296);let C=Math.min(I,up(Math.max(m,S),65536));if(n(C))return!0}return!1}let i=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function u(m,h,I=1024){let L=h+I,S=h;for(;m[S]&&!(S>=L);)++S;if(S-h>16&&m.buffer&&i)return i.decode(m.subarray(h,S));let C="";for(;h<S;){let g=m[h++];if(!(g&128)){C+=String.fromCharCode(g);continue}let b=m[h++]&63;if((g&224)===192){C+=String.fromCharCode((g&31)<<6|b);continue}let T=m[h++]&63;if((g&240)===224?g=(g&15)<<12|b<<6|T:g=(g&7)<<18|b<<12|T<<6|m[h++]&63,g<65536)C+=String.fromCharCode(g);else{let P=g-65536;C+=String.fromCharCode(55296|P>>10,56320|P&1023)}}return C}function c(m,h){return m?u(o.HEAPU8,m,h):""}let d={emscripten_get_now:lp,emscripten_memcpy_big:s,emscripten_resize_heap:l,fd_write:()=>0};async function p(){let h=await e({env:d,wasi_snapshot_preview1:d});t=h.memory,r(t.buffer),Object.assign(o,h),o.UTF8ToString=c}return await p(),o}var cp=Object.defineProperty,fp=(e,t,a)=>t in e?cp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,ne=(e,t,a)=>fp(e,typeof t!="symbol"?t+"":t,a),le=null;function pp(e){throw new oa(e.UTF8ToString(e.getLastOnigError()))}var Va=class e{constructor(t){ne(this,"utf16Length"),ne(this,"utf8Length"),ne(this,"utf16Value"),ne(this,"utf8Value"),ne(this,"utf16OffsetToUtf8"),ne(this,"utf8OffsetToUtf16");let a=t.length,o=e._utf8ByteLength(t),r=o!==a,s=r?new Uint32Array(a+1):null;r&&(s[a]=o);let n=r?new Uint32Array(o+1):null;r&&(n[o]=a);let l=new Uint8Array(o),i=0;for(let u=0;u<a;u++){let c=t.charCodeAt(u),d=c,p=!1;if(c>=55296&&c<=56319&&u+1<a){let m=t.charCodeAt(u+1);m>=56320&&m<=57343&&(d=(c-55296<<10)+65536|m-56320,p=!0)}r&&(s[u]=i,p&&(s[u+1]=i),d<=127?n[i+0]=u:d<=2047?(n[i+0]=u,n[i+1]=u):d<=65535?(n[i+0]=u,n[i+1]=u,n[i+2]=u):(n[i+0]=u,n[i+1]=u,n[i+2]=u,n[i+3]=u)),d<=127?l[i++]=d:d<=2047?(l[i++]=192|(d&1984)>>>6,l[i++]=128|(d&63)>>>0):d<=65535?(l[i++]=224|(d&61440)>>>12,l[i++]=128|(d&4032)>>>6,l[i++]=128|(d&63)>>>0):(l[i++]=240|(d&1835008)>>>18,l[i++]=128|(d&258048)>>>12,l[i++]=128|(d&4032)>>>6,l[i++]=128|(d&63)>>>0),p&&u++}this.utf16Length=a,this.utf8Length=o,this.utf16Value=t,this.utf8Value=l,this.utf16OffsetToUtf8=s,this.utf8OffsetToUtf16=n}static _utf8ByteLength(t){let a=0;for(let o=0,r=t.length;o<r;o++){let s=t.charCodeAt(o),n=s,l=!1;if(s>=55296&&s<=56319&&o+1<r){let i=t.charCodeAt(o+1);i>=56320&&i<=57343&&(n=(s-55296<<10)+65536|i-56320,l=!0)}n<=127?a+=1:n<=2047?a+=2:n<=65535?a+=3:a+=4,l&&o++}return a}createString(t){let a=t.omalloc(this.utf8Length);return t.HEAPU8.set(this.utf8Value,a),a}},$a=class Ue{constructor(t){if(ne(this,"id",++Ue.LAST_ID),ne(this,"_onigBinding"),ne(this,"content"),ne(this,"utf16Length"),ne(this,"utf8Length"),ne(this,"utf16OffsetToUtf8"),ne(this,"utf8OffsetToUtf16"),ne(this,"ptr"),!le)throw new oa("Must invoke loadWasm first.");this._onigBinding=le,this.content=t;let a=new Va(t);this.utf16Length=a.utf16Length,this.utf8Length=a.utf8Length,this.utf16OffsetToUtf8=a.utf16OffsetToUtf8,this.utf8OffsetToUtf16=a.utf8OffsetToUtf16,this.utf8Length<1e4&&!Ue._sharedPtrInUse?(Ue._sharedPtr||(Ue._sharedPtr=le.omalloc(1e4)),Ue._sharedPtrInUse=!0,le.HEAPU8.set(a.utf8Value,Ue._sharedPtr),this.ptr=Ue._sharedPtr):this.ptr=a.createString(le)}convertUtf8OffsetToUtf16(t){return this.utf8OffsetToUtf16?t<0?0:t>this.utf8Length?this.utf16Length:this.utf8OffsetToUtf16[t]:t}convertUtf16OffsetToUtf8(t){return this.utf16OffsetToUtf8?t<0?0:t>this.utf16Length?this.utf8Length:this.utf16OffsetToUtf8[t]:t}dispose(){this.ptr===Ue._sharedPtr?Ue._sharedPtrInUse=!1:this._onigBinding.ofree(this.ptr)}};ne($a,"LAST_ID",0);ne($a,"_sharedPtr",0);ne($a,"_sharedPtrInUse",!1);var Mi=$a,ar=class{constructor(t){if(ne(this,"_onigBinding"),ne(this,"_ptr"),!le)throw new oa("Must invoke loadWasm first.");let a=[],o=[];for(let l=0,i=t.length;l<i;l++){let u=new Va(t[l]);a[l]=u.createString(le),o[l]=u.utf8Length}let r=le.omalloc(4*t.length);le.HEAPU32.set(a,r/4);let s=le.omalloc(4*t.length);le.HEAPU32.set(o,s/4);let n=le.createOnigScanner(r,s,t.length);for(let l=0,i=t.length;l<i;l++)le.ofree(a[l]);le.ofree(s),le.ofree(r),n===0&&pp(le),this._onigBinding=le,this._ptr=n}dispose(){this._onigBinding.freeOnigScanner(this._ptr)}findNextMatchSync(t,a,o){let r=0;if(typeof o=="number"&&(r=o),typeof t=="string"){t=new Mi(t);let s=this._findNextMatchSync(t,a,!1,r);return t.dispose(),s}return this._findNextMatchSync(t,a,!1,r)}_findNextMatchSync(t,a,o,r){let s=this._onigBinding,n=s.findNextOnigScannerMatch(this._ptr,t.id,t.ptr,t.utf8Length,t.convertUtf16OffsetToUtf8(a),r);if(n===0)return null;let l=s.HEAPU32,i=n/4,u=l[i++],c=l[i++],d=[];for(let p=0;p<c;p++){let m=t.convertUtf8OffsetToUtf16(l[i++]),h=t.convertUtf8OffsetToUtf16(l[i++]);d[p]={start:m,end:h,length:h-m}}return{index:u,captureIndices:d}}};function mp(e){return typeof e.instantiator=="function"}function hp(e){return typeof e.default=="function"}function gp(e){return typeof e.data<"u"}function wp(e){return typeof Response<"u"&&e instanceof Response}function xp(e){return typeof ArrayBuffer<"u"&&(e instanceof ArrayBuffer||ArrayBuffer.isView(e))||typeof Buffer<"u"&&Buffer.isBuffer?.(e)||typeof SharedArrayBuffer<"u"&&e instanceof SharedArrayBuffer||typeof Uint32Array<"u"&&e instanceof Uint32Array}var za;function Lp(e){if(za)return za;async function t(){le=await dp(async a=>{let o=e;return o=await o,typeof o=="function"&&(o=await o(a)),typeof o=="function"&&(o=await o(a)),mp(o)?o=await o.instantiator(a):hp(o)?o=await o.default(a):(gp(o)&&(o=o.data),wp(o)?typeof WebAssembly.instantiateStreaming=="function"?o=await Cp(o)(a):o=await Ip(o)(a):xp(o)?o=await tr(o)(a):o instanceof WebAssembly.Module?o=await tr(o)(a):"default"in o&&o.default instanceof WebAssembly.Module&&(o=await tr(o.default)(a))),"instance"in o&&(o=o.instance),"exports"in o&&(o=o.exports),o})}return za=t(),za}function tr(e){return t=>WebAssembly.instantiate(e,t)}function Cp(e){return t=>WebAssembly.instantiateStreaming(e,t)}function Ip(e){return async t=>{let a=await e.arrayBuffer();return WebAssembly.instantiate(a,t)}}async function Fi(e){return e&&await Lp(e),{createScanner(t){return new ar(t.map(a=>typeof a=="string"?a:a.source))},createString(t){return new Mi(t)}}}var Xa=Ti({langs:aa,themes:Ri,engine:()=>Fi(import("../wasm-ISCPKFD2.js"))}),{codeToHtml:Sp,codeToHast:yp,codeToTokens:bp,codeToTokensBase:kp,codeToTokensWithThemes:Tp,getSingletonHighlighter:Pp,getLastGrammarState:vp}=Pi(Xa,{guessEmbeddedLanguages:Li});var Di=new Set(Object.keys(aa)),or=new Map,rr=new Map,It=new Map,Ap=(e,t)=>`${e}-${t[0]}-${t[1]}`,Rp=(e,t,a)=>{let o=e.slice(0,100),r=e.length>100?e.slice(-100):"";return`${t}:${a[0]}:${a[1]}:${e.length}:${o}:${r}`},Mp=(e,t)=>{let a=Ap(e,t);if(or.has(a))return or.get(a);let o=Xa({themes:t,langs:[e]});return or.set(a,o),o};function Fp(e={}){var t;let a=(t=e.themes)!=null?t:["github-light","github-dark"];return{name:"shiki",type:"code-highlighter",supportsLanguage(o){return Di.has(o)},getSupportedLanguages(){return Array.from(Di)},getThemes(){return a},highlight({code:o,language:r,themes:s},n){let l=Rp(o,r,s);return rr.has(l)?rr.get(l):(n&&(It.has(l)||It.set(l,new Set),It.get(l).add(n)),Mp(r,s).then(i=>{let u=i.getLoadedLanguages().includes(r)?r:"text",c=i.codeToTokens(o,{lang:u,themes:{light:s[0],dark:s[1]}});rr.set(l,c);let d=It.get(l);if(d){for(let p of d)p(c);It.delete(l)}}).catch(i=>{console.error("[Streamdown Code] Failed to highlight code:",i),It.delete(l)}),null)}}}var Bi=Fp();import{memo as Dp}from"react";f();import{jsx as Ka}from"react/jsx-runtime";var Qa=({className:e,from:t,children:a,...o})=>Ka("div",{className:B("ww:group ww:flex ww:w-full",t==="user"?"is-user ww:ml-auto ww:max-w-[80%] ww:flex-col ww:items-end":"is-assistant ww:flex-col",e),...o,children:Ka("div",{className:B("ww:flex ww:min-w-0 ww:flex-col ww:gap-2","ww:w-full"),children:a})}),Ja=({children:e,className:t,...a})=>Ka("div",{className:B("ww:flex ww:w-fit ww:min-w-0 ww:max-w-full ww:flex-col ww:gap-2 ww:overflow-hidden ww:text-base","ww:group-[.is-user]:ml-auto ww:group-[.is-user]:rounded-lg ww:group-[.is-user]:bg-user-bubble ww:group-[.is-user]:px-4 ww:group-[.is-user]:py-3 ww:group-[.is-user]:text-primary-foreground","ww:group-[.is-assistant]:text-foreground",t),...a,children:e}),Bp={cjk:wn,code:Bi},Ep={enabled:!1},Za=Dp(({className:e,linkSafety:t,...a})=>Ka(co,{className:B("ww:size-full ww:[&>*:first-child]:mt-0 ww:[&>*:last-child]:mb-0",e),linkSafety:t??Ep,plugins:Bp,...a}),(e,t)=>e.children===t.children);Za.displayName="MessageResponse";f();import{jsx as _p}from"react/jsx-runtime";function Ei({className:e,text:t,...a}){return t?_p("pre",{className:B("ww:mb-2 ww:overflow-x-auto ww:whitespace-pre-wrap ww:break-words ww:text-xs ww:font-mono ww:text-muted-foreground",e),...a,children:t}):null}f();import{createContext as Np,useCallback as Up,useContext as Oi,useEffect as Op,useMemo as nr,useRef as Hp,useState as ir}from"react";import{Fragment as Ui,jsx as $,jsxs as Ge}from"react/jsx-runtime";function qp(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 o=Object.entries(e),r=[],s=t-2;for(let[n,l]of o){if(s<=8)break;let i=n.length>4?`${n.slice(0,4)}\u2026`:n,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=`${i}\u2009${u}`;r.push(c),s-=c.length+3}return`{${r.join(", ")}}`}function Wp({text:e,className:t}){let[a,o]=ir(!1),r=Hp(null);Op(()=>()=>{r.current&&clearTimeout(r.current)},[]);let s=Up(async n=>{n.stopPropagation();try{await navigator.clipboard.writeText(e),o(!0),r.current&&clearTimeout(r.current),r.current=setTimeout(()=>o(!1),2e3)}catch{}},[e]);return $(Ee,{variant:"ghost",size:"sm",onClick:s,className:B("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:a?Ge(Ui,{children:[$(Bt,{className:"ww:size-3.5"}),$("span",{children:"Copied"})]}):Ge(Ui,{children:[$(Nt,{className:"ww:size-3.5"}),$("span",{children:"Copy"})]})})}function Hi({data:e,label:t,className:a,...o}){let[r,s]=ir(!1),n=nr(()=>JSON.stringify(e,null,2),[e]),l=qp(e);return Ge("div",{className:B("ww:rounded-lg ww:bg-tool-card",a),...o,children:[Ge("div",{className:"ww:flex ww:items-center ww:justify-between ww:px-3 ww:pt-2.5 ww:pb-1.5",children:[$("span",{className:"ww:text-xs ww:font-medium ww:text-muted-foreground",children:t}),$(Wp,{text:n})]}),Ge("button",{type:"button",onClick:()=>s(i=>!i),className:"ww:flex ww:w-full ww:items-start ww:gap-2 ww:px-3 ww:pb-3 ww:text-left",children:[$(_t,{className:B("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?$("pre",{className:"ww:overflow-x-auto ww:text-xs ww:font-mono ww:text-foreground ww:whitespace-pre-wrap ww:break-all",children:$("code",{children:n})}):$("span",{className:"ww:truncate ww:text-xs ww:font-mono ww:text-foreground/80",children:l})]})]})}var lr=Np({open:!1,toggle:()=>{}});function qi({className:e,defaultOpen:t=!1,children:a,...o}){let[r,s]=ir(t);return $(lr.Provider,{value:{open:r,toggle:()=>s(n=>!n)},children:$("div",{className:B("ww:mb-4 ww:w-full",e),"data-state":r?"open":"closed",...o,children:a})})}function Wi({className:e,title:t,state:a,...o}){let{open:r,toggle:s}=Oi(lr),n=a==="input-available"||a==="input-streaming";return Ge("button",{type:"button",onClick:s,className:B("ww:flex ww:w-full ww:items-center ww:justify-between ww:gap-3 ww:py-1.5",e),"aria-expanded":r,...o,children:[Ge("div",{className:"ww:flex ww:min-w-0 ww:items-center ww:gap-2",children:[$($e,{className:"ww:size-4 ww:shrink-0 ww:text-muted-foreground"}),$("span",{className:"ww:truncate ww:text-sm ww:font-medium",children:t}),n&&$("span",{className:"ww:size-2 ww:shrink-0 ww:rounded-full ww:bg-primary ww:animate-pulse"})]}),$(Et,{className:B("ww:size-4 ww:shrink-0 ww:text-muted-foreground ww:transition-transform ww:duration-200",r&&"ww:rotate-180")})]})}function Gi({className:e,title:t,state:a,...o}){let r=a==="input-available"||a==="input-streaming";return Ge("div",{className:B("ww:mb-4 ww:flex ww:items-center ww:gap-2 ww:py-1.5 ww:text-sm ww:text-muted-foreground ww:italic",e),...o,children:[$("span",{className:"ww:truncate",children:t}),r&&$("span",{className:"ww:size-2 ww:shrink-0 ww:rounded-full ww:bg-primary ww:animate-pulse"})]})}function ji({className:e,children:t,...a}){let{open:o}=Oi(lr);return $("div",{className:B("ww:grid ww:transition-[grid-template-rows,opacity] ww:duration-200 ww:ease-out",o?"ww:grid-rows-[1fr] ww:opacity-100":"ww:grid-rows-[0fr] ww:opacity-0"),children:$("div",{className:"ww:min-h-0 ww:overflow-hidden",children:$("div",{className:B("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 zi({className:e,input:t,debug:a,...o}){let r=nr(()=>{if(!a&&typeof t=="object"&&t!==null&&!Array.isArray(t)){let{_meta:s,...n}=t;return n}return t},[t,a]);return $(Hi,{data:r,label:"Request",className:e,...o})}function sr(e){if(!(typeof e!="object"||e===null))return e}function Vi(e){return sr(e?.ui)}function $i(e){return sr(sr(e)?._meta)}function _i(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 o=e["openai/outputTemplate"];if(typeof o=="string"&&o.length>0)return o}function Ni(e){return Vi(e)?.autoHeight===!0}function Ya(e,t,a){if(e){let o=_i(a?.[e]?._meta);if(o)return o}return _i($i(t))}function Xi(e,t,a){return e&&Ni(a?.[e]?._meta)?!0:Ni($i(t))}function Ki({className:e,output:t,errorText:a,debug:o,...r}){let s=nr(()=>{if(!o&&typeof t=="object"&&t!==null&&!Array.isArray(t)){let{_meta:n,...l}=t;return l}return t},[t,o]);return t||a?a?Ge("div",{className:B("ww:space-y-2",e),...r,children:[$("h4",{className:"ww:text-xs ww:font-medium ww:uppercase ww:tracking-wide ww:text-muted-foreground",children:"Error"}),$("div",{className:"ww:rounded-lg ww:bg-destructive/10 ww:p-3 ww:text-xs ww:text-destructive",children:a})]}):$(Hi,{data:s,label:"Response",className:e,...r}):null}f();import{useCallback as Gp,useEffect as Qi,useMemo as jp,useRef as xe,useState as Ji}from"react";import{jsx as tm}from"react/jsx-runtime";var zp="/api/mcp/resource",Vp=500,$p=0,Xp=16,Kp="2026-01-26",Qp=300,Jp=3e3,Zp=3;function Yp(e){if(typeof e!="string")return;let t=e.trim();return t.length>0?t:void 0}function em(e,t,a){return Ya(e,t,a)?!1:t._meta?.["waniwani/autoInjectResultText"]!==!1}function Zi({resourceUri:e,toolInput:t,toolResult:a,resourceEndpoint:o=zp,chatSessionId:r,isDark:s=!1,className:n,autoHeight:l=!1,onOpenLink:i,onFollowUp:u,onCallTool:c,onDisplayModeChange:d,isFullscreen:p=!1,toolDefinitions:m}){let h=xe(null),I=xe(t),L=xe(a),S=xe({width:0,height:0}),C=xe(null),g=xe(!1),b=xe(0),T=xe("inline"),[P,R]=Ji($p),[v,_]=Ji(void 0),A=xe(i),E=xe(u),y=xe(c),M=xe(d),O=xe(r),F=xe(m);I.current=t,L.current=a,A.current=i,E.current=u,y.current=c,M.current=d,O.current=r,F.current=m;let j=Gp(te=>l?Math.max(te+Xp,0):Math.min(Math.max(te,50),Vp),[l]),Te=jp(()=>{let te=o.includes("?")?"&":"?";return`${o}${te}uri=${encodeURIComponent(e)}`},[o,e]),Le=xe(s);return Le.current=s,Qi(()=>{if(!g.current)return;let te=h.current;te?.contentWindow&&te.contentWindow.postMessage({jsonrpc:"2.0",method:"ui/notifications/host-context-changed",params:{theme:s?"dark":"light"}},"*")},[s]),Qi(()=>{let te=h.current;if(!te)return;let me=!1,Se=!1,ge=null,Ce=null,je=setTimeout(()=>{if(me||Se||b.current>=Zp)return;b.current+=1;let Y=new URL(te.src);Y.searchParams.set("_retry",String(b.current)),te.src=Y.toString()},Jp),N=Y=>{te.contentWindow?.postMessage(Y,"*")},ie=Y=>{if(me||Y.source!==te.contentWindow)return;let X=Y.data;if(!X||typeof X!="object"||X.jsonrpc!=="2.0")return;let oe=X.method,W=X.id;if(oe==="ui/initialize"&&W!=null){Se=!0,clearTimeout(je),N({jsonrpc:"2.0",id:W,result:{protocolVersion:X.params?.protocolVersion??Kp,hostInfo:{name:"WaniWani Chat",version:"1.0.0"},hostCapabilities:{openLinks:{},message:{text:{}},tools:{},updateModelContext:{text:{},structuredContent:{}}},hostContext:{theme:Le.current?"dark":"light",displayMode:T.current}}});return}if(oe==="ui/notifications/initialized"){g.current=!0;let z=I.current,K=L.current,q=K._meta&&typeof K._meta=="object"?K._meta:null,Q=Yp(O.current),re=q&&typeof q.waniwani=="object"&&q.waniwani!==null?q.waniwani:null,Pe=re||Q?{...re??{},...Q?{sessionId:Q}:{}}:void 0,ze=q||Pe?{...q??{},...Pe?{waniwani:Pe}:{}}:void 0;N({jsonrpc:"2.0",method:"ui/notifications/tool-input",params:{arguments:z}});let dt=K.content??[{type:"text",text:JSON.stringify(K)}];N({jsonrpc:"2.0",method:"ui/notifications/tool-result",params:{content:dt,structuredContent:K.structuredContent,_meta:ze,meta:ze}});return}if(oe==="ui/notifications/size-changed"){let z=X.params,K=typeof z?.height=="number"?z.height:void 0,q=typeof z?.width=="number"?z.width:void 0,Q=S.current,re=K!==void 0&&K!==Q.height,Pe=q!==void 0&&q!==Q.width;if(!re&&!Pe)return;if(re&&K!==void 0){Q.height=K;let ze=j(K),dt=te.getBoundingClientRect().height;if(C.current&&(C.current.cancel(),C.current=null),R(ze),te.animate&&Math.abs(dt-ze)>2){let ct=te.animate([{height:`${dt}px`},{height:`${ze}px`}],{duration:Qp,easing:"ease-out",fill:"forwards"});C.current=ct,ct.onfinish=()=>{C.current===ct&&(ct.cancel(),C.current=null)}}}Pe&&l&&q!==void 0&&(Q.width=q,_(q));return}if(oe==="ui/open-link"&&W!=null){let z=X.params?.url;typeof z=="string"&&(A.current?A.current(z):window.open(z,"_blank","noopener,noreferrer")),N({jsonrpc:"2.0",id:W,result:{}});return}if(oe==="ui/message"&&W!=null){if(E.current&&X.params){let z=X.params,K=ge;if(ge=null,Ce){clearTimeout(Ce.timer);let q=Ce.text;Ce=null;let Q=(z.content??[]).map(re=>re.text??"").join("").trim();z={...z,content:[{type:"text",text:`${Q}
|
|
80
80
|
|
|
81
|
-
${q}`}]}}E.current({...z,...K?{modelContext:K}:{}})}N({jsonrpc:"2.0",id:W,result:{}});return}if(oe==="ui/update-model-context"&&W!=null){ge=Lr(ge,X.params),N({jsonrpc:"2.0",id:W,result:{}});return}if(oe==="tools/call"&&W!=null){let z=y.current;if(!z){N({jsonrpc:"2.0",id:W,error:{code:-32601,message:"tools/call not supported"}});return}let K=X.params?.name;z({name:K,arguments:X.params?.arguments??{}}).then(q=>{N({jsonrpc:"2.0",id:W,result:q});let Q=q.content?.map(re=>re.text??"").join("").trim();Q&&Op(K,q,F.current)&&(Ce&&clearTimeout(Ce.timer),Ce={text:Q,timer:setTimeout(()=>{if(me)return;let re=ge;ge=null,Ce=null,E.current?.({role:"user",content:[{type:"text",text:Q}],...re?{modelContext:re}:{}})},500)})}).catch(q=>{let Q=q instanceof Error?q.message:"Tool call failed";N({jsonrpc:"2.0",id:W,error:{code:-32e3,message:Q}})});return}if(oe==="ui/request-display-mode"&&W!=null){let z=X.params?.mode,K=z==="fullscreen"||z==="inline"||z==="pip"?z:"inline";T.current=K,N({jsonrpc:"2.0",id:W,result:{mode:K}}),N({jsonrpc:"2.0",method:"ui/notifications/host-context-changed",params:{displayMode:K}}),M.current?.(K);return}if(oe==="ui/resource-teardown"&&W!=null){N({jsonrpc:"2.0",id:W,result:{}});return}oe==="ping"&&W!=null&&N({jsonrpc:"2.0",id:W,result:{}})};return window.addEventListener("message",ie),()=>{me=!0,clearTimeout(je),Ce&&clearTimeout(Ce.timer),window.removeEventListener("message",ie)}},[l,j]),Up("iframe",{ref:h,src:Te,sandbox:"allow-scripts allow-forms allow-same-origin allow-popups allow-popups-to-escape-sandbox",className:B(!p&&"ww:rounded-md ww:border ww:border-border",n),style:{height:p?"100%":P,minWidth:p||!v?void 0:`min(${v}px, 100%)`,width:"100%",border:"none",colorScheme:s?"dark":"auto"},title:"MCP App"})}f();import{jsx as oa,jsxs as Hp}from"react/jsx-runtime";function $i({icon:e,title:t,description:a,suggestions:o,onSuggestionSelect:r}){return Hp("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&&oa("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}),oa("h2",{className:"ww:text-lg ww:font-semibold ww:text-foreground",children:t}),a&&oa("p",{className:"ww:mt-1 ww:text-sm ww:text-muted-foreground ww:max-w-sm",children:a}),o&&o.length>0&&oa("div",{className:"ww:mt-6 ww:w-full ww:max-w-md ww:flex ww:flex-col ww:gap-2",children:o.map((s,n)=>oa("button",{type:"button",onClick:()=>r?.(s),className:B("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:`${n*50}ms`},children:s},s))})]})}f();import{Component as qp}from"react";import{jsx as Xi,jsxs as Wp}from"react/jsx-runtime";var Ya=class extends qp{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){console.warn("[WaniWani] Widget failed to render:",t.message)}render(){return this.state.hasError?Wp("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:[Xi("span",{children:"Widget failed to load"}),Xi("button",{type:"button",onClick:()=>this.setState({hasError:!1}),className:"ww:text-xs ww:font-medium ww:text-primary ww:hover:underline",children:"Retry"})]}):this.props.children}};import{Fragment as Gp,jsx as se,jsxs as St}from"react/jsx-runtime";function Ki(e){return e?e.replace(/[-_]/g," ").replace(/^\w/,t=>t.toUpperCase()):"Tool"}function Qi({messages:e,status:t,welcomeMessage:a,welcome:o,onSuggestionSelect:r,resourceEndpoint:s,chatSessionId:n,isDark:l,onFollowUp:i,onCallTool:u,onWidgetDisplayModeChange:c,fullscreenToolCallId:d,debug:p,showToolCalls:m=!0,toolDefinitions:h}){let I=t==="submitted"||t==="streaming",L=e[e.length-1],S=e.length>0,C=I&&(!S||L.role==="user"),g=d!=null;return St(Gp,{children:[!g&&(!S&&o?se($i,{...o,onSuggestionSelect:r}):a&&se(Ka,{from:"assistant",children:se(Qa,{children:se(Ja,{children:a})})})),e.map(k=>{let T=k.parts.filter(y=>y.type==="text"),P=k.parts.filter(y=>y.type==="reasoning"),R=k.parts.filter(y=>y.type==="file"),v=k.parts.filter(y=>"toolCallId"in y),_=k===L&&k.role==="assistant",A=T.length>0,E=g?v.some(y=>y.toolCallId===d):!1;return g&&!E?se("div",{style:{display:"none"}},k.id):St(Ka,{from:k.role,children:[!E&&P.map((y,M)=>se(Ai,{text:y.text},`reasoning-${k.id}-${M}`)),v.map(y=>{let M="output"in y?y.output:void 0,U=Za(y.toolName,M,h),F=Wi(y.toolName,M,h),j=y.toolCallId===d;return St("div",{style:j?{position:"absolute",inset:0,zIndex:10,display:"flex",flexDirection:"column",overflow:"hidden",background:"var(--ww-color-background)"}:void 0,children:[se("div",{style:j?{display:"none"}:void 0,children:m?St(Ei,{children:[se(_i,{title:y.title??Ki(y.toolName),state:y.state}),St(Oi,{children:[se(Ui,{input:y.input,debug:p}),M!==void 0&&se(Gi,{output:M,errorText:"errorText"in y?y.errorText:void 0,debug:p})]})]}):se(Ni,{title:y.title??Ki(y.toolName),state:y.state})}),U&&s&&M!==void 0&&se(Ya,{children:se(Vi,{isFullscreen:j,resourceUri:U,toolInput:y.input??{},toolResult:{content:M.content,structuredContent:M.structuredContent,_meta:M._meta},resourceEndpoint:s,chatSessionId:n,isDark:l,autoHeight:F,toolDefinitions:h,onFollowUp:i,onCallTool:u,onDisplayModeChange:c?Te=>c(Te,{toolCallId:y.toolCallId,resourceUri:U,toolInput:y.input??{},toolResult:{content:M.content,structuredContent:M.structuredContent,_meta:M._meta},autoHeight:F}):void 0})})]},y.toolCallId)}),!E&&se("div",{children:St(Qa,{children:[R.length>0&&se(Ks,{files:R}),A?T.map((y,M)=>se(Ja,{children:y.type==="text"?y.text:""},`${k.id}-${M}`)):_&&I&&se(ko,{})]})})]},k.id)}),!g&&C&&se(Ka,{from:"assistant",children:se(Qa,{children:se(ko,{})})})]})}f();import{jsx as Ji,jsxs as Vp}from"react/jsx-runtime";var jp="https://app.waniwani.ai/assets/waniwani-logo.svg",zp="https://waniwani.ai";function Zi(){return Vp("a",{href:zp,target:"_blank",rel:"noopener noreferrer",className:"ww:flex ww:items-center ww:gap-1.5 ww:text-[11px] ww:text-muted-foreground ww:opacity-70 hover:ww:opacity-100 ww:transition-opacity",children:[Ji("span",{children:"AI agent powered by"}),Ji("img",{src:jp,alt:"WaniWani",width:72,height:10,"data-waniwani-logo":"",className:"ww:h-2.5 ww:w-auto"})]})}f();import{jsx as eo}from"react/jsx-runtime";function Yi({suggestions:e,isLoading:t,onSelect:a,className:o,...r}){return e.length===0&&!t?null:eo("div",{className:B("ww:px-4 ww:py-2",o),...r,children:eo("div",{className:"ww:mx-auto ww:w-full ww:max-w-3xl ww:flex ww:flex-wrap ww:gap-2",children:t?[0,1,2].map(s=>eo("div",{className:"ww:h-7 ww:rounded-full ww:bg-accent ww:animate-pulse",style:{width:`${60+s*20}px`}},s)):e.map((s,n)=>eo("button",{type:"button",onClick:()=>a(s),className:B("ww:rounded-full ww:border ww:border-border ww:bg-background ww:px-3 ww:py-1 ww:text-xs","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:`${n*50}ms`},children:s},s))})})}f();import{useEffect as $p,useRef as Xp,useState as Kp}from"react";import{jsx as ee,jsxs as Ze}from"react/jsx-runtime";var el=20;function Qp(e){let t=Date.parse(e);if(Number.isNaN(t))return"";let a=Date.now()-t;return a<6e4?"just now":a<60*6e4?`${Math.floor(a/6e4)}m ago`:a<1440*6e4?`${Math.floor(a/(60*6e4))}h ago`:`${Math.floor(a/(1440*6e4))}d ago`}function Jp(){return Ze("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":"New chat",children:[ee("title",{children:"New chat"}),ee("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),ee("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}function Zp(){return Ze("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":"Thread history",children:[ee("title",{children:"Thread history"}),ee("path",{d:"M3 12a9 9 0 1 0 3-6.7"}),ee("polyline",{points:"3 4 3 9 8 9"}),ee("line",{x1:"12",y1:"7",x2:"12",y2:"12"}),ee("line",{x1:"12",y1:"12",x2:"15",y2:"14"})]})}function Yp(){return Ze("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":"Delete thread",children:[ee("title",{children:"Delete thread"}),ee("polyline",{points:"3 6 5 6 21 6"}),ee("path",{d:"M19 6l-2 14a2 2 0 0 1-2 2H9a2 2 0 0 1-2-2L5 6"}),ee("path",{d:"M10 11v6"}),ee("path",{d:"M14 11v6"})]})}function tl({threads:e,activeThreadId:t,onNewThread:a,onSelectThread:o,onDeleteThread:r}){let[s,n]=Kp(!1),l=Xp(null);$p(()=>{if(!s)return;let c=d=>{let p=l.current;p&&(d.composedPath().includes(p)||n(!1))};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[s]);let i=e.slice(0,el),u=Math.max(0,e.length-el);return Ze("div",{ref:l,className:"ww:relative ww:flex ww:items-center ww:gap-1",children:[ee("button",{type:"button",onClick:a,title:"New chat","aria-label":"New chat",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:ee(Jp,{})}),ee("button",{type:"button",onClick:()=>n(c=>!c),title:"Thread history","aria-label":"Thread history","aria-expanded":s,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:ee(Zp,{})}),s&&Ze("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:[i.length===0&&ee("div",{className:"ww:px-3 ww:py-3 ww:text-xs ww:text-muted-foreground",children:"No previous chats yet."}),i.map(c=>{let d=c.threadId===t;return Ze("div",{className:`ww:flex ww:items-center ww:gap-2 ww:px-3 ww:py-2 ww:text-xs hover:ww:bg-foreground/5 ${d?"ww:bg-foreground/5":""}`,children:[Ze("button",{type:"button",onClick:()=>{o(c.threadId),n(!1)},className:"ww:flex-1 ww:min-w-0 ww:text-left ww:cursor-pointer",children:[ee("div",{className:"ww:truncate ww:text-foreground ww:font-medium",children:c.title}),ee("div",{className:"ww:text-[10px] ww:text-muted-foreground",children:Qp(c.updatedAt)})]}),ee("button",{type:"button",onClick:p=>{p.stopPropagation(),r(c.threadId)},title:"Delete thread","aria-label":"Delete thread",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:ee(Yp,{})})]},c.threadId)}),u>0&&Ze("div",{className:"ww:px-3 ww:py-2 ww:text-[10px] ww:text-muted-foreground ww:border-t ww:border-border",children:[u," older thread",u===1?"":"s"," hidden"]})]})]})}f();import{useCallback as em,useRef as tm}from"react";function al(e){let t=tm(e);return t.current=e,em(async a=>{let{api:o,headers:r,onCallTool:s,sessionId:n}=t.current;if(s)return s(a);let l=`${o??"/api/waniwani"}/tool`,i=typeof n=="string"&&n.trim().length>0?n.trim():void 0,u=await fetch(l,{method:"POST",headers:{"Content-Type":"application/json",...i?{"X-Session-Id":i}:{},...r},body:JSON.stringify(a)});if(!u.ok)throw new Error(`Tool call failed: ${u.status} ${u.statusText}`);return u.json()},[])}f();import{useChat as xm}from"@ai-sdk/react";import{useCallback as fe,useEffect as Fe,useRef as ue,useState as ut}from"react";f();import{DefaultChatTransport as am,uiMessageChunkSchema as om}from"ai";function rm(e){let t=e?.cause,a=t?.issues??t?.errors;if(!Array.isArray(a))return null;let o=a.find(r=>r.code==="invalid_union");if(!o?.errors)return null;for(let r of o.errors){if(!Array.isArray(r)||r.some(l=>(l.code==="invalid_value"||l.code==="invalid_literal")&&l.path?.[0]==="type"))continue;let n=r.filter(l=>l.code==="unrecognized_keys").flatMap(l=>l.keys??[]);if(n.length>0)return n}return null}var to=class extends am{processResponseStream(t){let a="",o=om(),r=o.validate?.bind(o);return t.pipeThrough(new TextDecoderStream).pipeThrough(new TransformStream({async transform(s,n){a+=s;let l=a.split(`
|
|
82
|
-
`);a=l.pop()??"";for(let i of l){let u=i.trim();if(!u.startsWith("data:"))continue;let c=u.slice(5).trim();if(c!=="[DONE]")try{let d=JSON.parse(c);if(!r){n.enqueue(d);continue}let p=await r(d);if(p.success){n.enqueue(p.value);continue}let m=rm(p.error);if(m?.length){let h={...d};for(let L of m)delete h[L];let I=await r(h);I.success&&n.enqueue(I.value)}}catch{}}}}))}};f();f();var sm="waniwani-memory";var be="threads",ao="by_memoryUserId",nm="by_updatedAt";var rl="memoryUserId",ol="waniwani-memory-user-id",ir=null;function lr(){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 im(e,t){if(t<1&&(e.objectStoreNames.contains("ids")||e.createObjectStore("ids")),t<2&&!e.objectStoreNames.contains(be)){let a=e.createObjectStore(be,{keyPath:"threadId"});a.createIndex(ao,"memoryUserId",{unique:!1}),a.createIndex(nm,"updatedAt",{unique:!1})}}async function ur(){return new Promise((e,t)=>{let a=indexedDB.open(sm,2);a.onupgradeneeded=o=>{im(a.result,o.oldVersion)},a.onsuccess=()=>e(a.result),a.onerror=()=>t(a.error)})}async function lm(){return ur()}async function um(e){return new Promise((t,a)=>{let s=e.transaction("ids","readonly").objectStore("ids").get(rl);s.onsuccess=()=>t(typeof s.result=="string"?s.result:null),s.onerror=()=>a(s.error)})}async function dm(e,t){return new Promise((a,o)=>{let n=e.transaction("ids","readwrite").objectStore("ids").put(t,rl);n.onsuccess=()=>a(),n.onerror=()=>o(n.error)})}async function cm(){if(typeof indexedDB>"u")return null;try{let e=await lm();try{let t=await um(e);if(t)return t;let a=lr();return await dm(e,a),a}finally{e.close()}}catch{return null}}function fm(){try{let e=localStorage.getItem(ol);if(e)return e;let t=lr();return localStorage.setItem(ol,t),t}catch{return null}}async function sl(){let e=await cm();if(e)return e;let t=fm();return t||(ir||(ir=lr()),ir)}var nl=50,il=1e3;function oo(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.threadId=="string"&&typeof t.memoryUserId=="string"&&typeof t.title=="string"&&Array.isArray(t.messages)&&typeof t.createdAt=="string"&&typeof t.updatedAt=="string"}async function ro(e){if(typeof indexedDB>"u")return null;let t=null;try{return t=await ur(),await e(t)}catch{return null}finally{try{t?.close()}catch{}}}function dr(e){return new Promise((t,a)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>a(e.error)})}async function cr(e){return await ro(async a=>{let s=a.transaction(be,"readonly").objectStore(be).index(ao),l=(await dr(s.getAll(e))??[]).filter(oo);return l.sort((i,u)=>i.updatedAt<u.updatedAt?1:-1),l})??[]}async function fr(e){return await ro(async a=>{let r=a.transaction(be,"readonly").objectStore(be),s=await dr(r.get(e));return oo(s)?s:null})??null}async function pr(e){if(!oo(e))return;let t=e.messages.length>il?{...e,messages:e.messages.slice(e.messages.length-il)}:e;await ro(async a=>{await new Promise((i,u)=>{let c=a.transaction(be,"readwrite");c.oncomplete=()=>i(),c.onerror=()=>u(c.error),c.onabort=()=>u(c.error),c.objectStore(be).put(t)});let o=a.transaction(be,"readwrite"),r=o.objectStore(be),s=r.index(ao),l=(await dr(s.getAll(t.memoryUserId))??[]).filter(oo);if(l.length>nl){l.sort((u,c)=>u.updatedAt<c.updatedAt?-1:1);let i=l.slice(0,l.length-nl);for(let u of i)r.delete(u.threadId)}return await new Promise((i,u)=>{o.oncomplete=()=>i(),o.onerror=()=>u(o.error),o.onabort=()=>u(o.error)}),null})}async function ll(e){await ro(async t=>(await new Promise((a,o)=>{let r=t.transaction(be,"readwrite");r.oncomplete=()=>a(),r.onerror=()=>o(r.error),r.onabort=()=>o(r.error),r.objectStore(be).delete(e)}),null))}async function ul(e){return(await cr(e))[0]?.threadId??null}function dl(e){let t=e.trim();if(!t)return`Conversation on ${new Date().toISOString().slice(0,10)}`;let a=t.split(/\r?\n/,1)[0]??t;return a.length<=60?a:`${a.slice(0,60).trimEnd()}\u2026`}f();var cl="waniwani-visitor-id";function fl(e,t){return e.match(t)?.[1]??null}function pm(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,o]of t){let r=fl(e,o);if(r)return{name:a,version:r}}return null}function mm(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,o]of t){let r=fl(e,o);if(r)return{name:a,version:r.replace(/_/g,".")};if(a==="Linux"&&o.test(e))return{name:a,version:""}}return null}function hm(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 gm(e){let t=new TextEncoder().encode(e),a=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(a)).map(o=>o.toString(16).padStart(2,"0")).join("")}async function wm(){try{let a=localStorage.getItem(cl);if(a)return a}catch{}let e=[navigator.userAgent,screen.width,screen.height,screen.colorDepth,Intl.DateTimeFormat().resolvedOptions().timeZone,navigator.language,navigator.hardwareConcurrency??"",navigator.platform??""].join("|"),t=await gm(e);try{localStorage.setItem(cl,t)}catch{}return t}async function pl(){let e=navigator.userAgent,[t,a]=await Promise.all([wm(),sl()]);return{userAgent:e,browser:pm(e),os:mm(e),deviceType:hm(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 Lm="x-session-id",Cm=250;function ml(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():Wt()}function so(){return new Date().toISOString()}function hl(e){if(typeof e!="string")return;let t=e.trim();return t.length>0?t:void 0}async function Im(e,t){let a=`${e.replace(/\/$/,"")}/tools`,o=await fetch(a,{method:"GET",headers:t?{...t}:void 0});if(!o.ok)throw new Error(`[WaniWani] Failed to fetch /tools: ${o.status} ${o.statusText}`);let r=await o.json();if(!r||!Array.isArray(r.tools))return{};let s={};for(let n of r.tools)n&&typeof n.name=="string"&&(s[n.name]=n);return s}function gl(e){let{api:t="/api/waniwani",headers:a,body:o,onMessageSent:r,onResponseReceived:s,enableThreadHistory:n=!1,activeThreadId:l,onThreadChange:i}=e,u=ue(a),c=ue(o),d=ue(n);Fe(()=>{d.current=n},[n]);let p=ue(void 0),m=ue(null),[h,I]=ut(void 0),L=ue(h),[S,C]=ut(l),g=ue(S),[k,T]=ut([]),[P,R]=ut(!n),v=ue(void 0),_=ue(void 0),A=ue(void 0),E=ue(void 0),y=ue(0),M=ue(i);Fe(()=>{M.current=i},[i]);let U=fe(b=>{g.current=b,C(b),b&&M.current?.(b)},[]),F=fe(async()=>{if(!n)return;let b=m.current?.memoryUserId;if(!b)return;let O=await cr(b);T(O)},[n]),j=fe(()=>L.current,[]),Te=fe(b=>{let O=hl(b);O&&L.current!==O&&(L.current=O,I(O))},[]),Le=fe(()=>{L.current=void 0,I(void 0)},[]);Fe(()=>{u.current=a},[a]),Fe(()=>{c.current=o},[o]),Fe(()=>{let b=!1,O=y.current;return(async()=>{try{let ve=await pl();if(b)return;m.current=ve}catch{}if(!n)return;let H=m.current?.memoryUserId;if(!H){R(!0);return}try{let ve=l??await ul(H);if(b||O!==y.current)return;if(ve){let we=await fr(ve);if(b||O!==y.current)return;we&&we.memoryUserId===H&&(g.current=we.threadId,C(we.threadId),v.current=we.createdAt,_.current=we.title,we.sessionId&&(L.current=we.sessionId,I(we.sessionId)),oe(we.messages))}await F()}finally{b||R(!0)}})(),()=>{b=!0}},[]);let te=ue(new to({api:t,headers:()=>({...u.current}),body:()=>{let b={...c.current??{}},O=Object.hasOwn(b,"sessionId"),H=hl(b.sessionId);if(H)Te(H),b.sessionId=H;else if(O)Le(),delete b.sessionId;else{let Re=j();Re&&(b.sessionId=Re)}if(ft(p.current)&&(b.modelContext=p.current),m.current){let Re=m.current;b.visitorContext={timezone:Re.timezone,language:Re.language,languages:Re.languages,deviceType:Re.deviceType,referrer:Re.referrer,visitorId:Re.visitorId};let Ue=typeof b.visitor=="object"&&b.visitor!==null?b.visitor:{},El=typeof Ue.client=="object"&&Ue.client!==null?Ue.client:{};b.visitor={...Ue,client:{...El,memoryUserId:Re.memoryUserId}}}let ve=typeof b.extra=="object"&&b.extra!==null&&!Array.isArray(b.extra)?b.extra:void 0,we=m.current?.memoryUserId,Ve=m.current?.language,ia={};if(we&&(ia.memoryUserId=we),Ve&&(ia.locale=Ve),(Object.keys(ia).length>0||ve)&&(b.extra={...ia,...ve??{}}),d.current)if(Object.hasOwn(b,"threadId"))typeof b.threadId=="string"&&(g.current=b.threadId);else{let Ue=g.current;Ue||(Ue=ml(),v.current=so(),_.current=void 0,U(Ue)),b.threadId=Ue}return b},fetch:(async(b,O)=>{let H=await fetch(b,O);return p.current=void 0,Te(H.headers.get(Lm)),H})})),me=ue(null),Se=ue(null),ge=ue({}),[Ce,je]=ut(0),N=e.skipRemoteConfig===!0,ie=fe(async()=>{if(!N)try{let b=await Im(t,u.current);ge.current=b,je(O=>O+1)}catch(b){console.warn("[WaniWani] Failed to fetch tool definitions:",b instanceof Error?b.message:b)}},[t,N]);Fe(()=>{ie()},[ie]);let{messages:Y,sendMessage:X,setMessages:oe,status:W}=xm({messages:e.initialMessages,transport:te.current,onFinish({message:b}){s?.(),me.current&&(Se.current=b)},onError(b){console.warn("[WaniWani] Chat error:",b.message),me.current&&(me.current.reject(b),me.current=null)}}),z=ue(Y);Fe(()=>{z.current=Y},[Y]),Fe(()=>{if(W==="ready"&&me.current&&Se.current){let b=me.current,O=Se.current;me.current=null,Se.current=null,b.resolve(O)}},[W]);let[K,q]=ut(""),[Q,re]=ut([]),Pe=W==="submitted"||W==="streaming",ze=fe(b=>{re(O=>O.filter(H=>H.id!==b))},[]),dt=Pe&&Q.length>0,ct=fe(b=>{let O=!!b.text?.trim(),H=!!b.files?.length;if(O||H){if(Pe){if(Q.length>0)return;re(ve=>[...ve,{id:Wt(),text:b.text||"",files:b.files??[],modelContext:b.modelContext}]),q("");return}p.current=b.modelContext,X({text:b.text||"",files:b.files}),r?.(b.text||""),q("")}},[X,r,Pe,Q.length]),vl=fe(b=>new Promise((O,H)=>{me.current={resolve:O,reject:H},X({text:b}),r?.(b)}),[X,r]);Fe(()=>{if(W!=="ready"||Q.length===0)return;let[b,...O]=Q;re(O),p.current=b.modelContext,X({text:b.text,files:b.files.length>0?b.files:void 0}),r?.(b.text)},[W,X,r,Q]);let Al=fe(()=>{oe([]),re([]),Le(),q(""),ge.current={},je(b=>b+1),ie()},[oe,Le,ie]),sa=fe(()=>{if(!d.current)return;let b=m.current?.memoryUserId,O=g.current,H=z.current;if(!(!b||!O||H.length===0)){if(v.current||(v.current=so()),!_.current){let ve=H.find(Ve=>Ve.role==="user"),we=ve?ve.parts.map(Ve=>"text"in Ve&&typeof Ve.text=="string"?Ve.text:"").join(" "):"";_.current=dl(we)}return{threadId:O,memoryUserId:b,title:_.current,messages:H,sessionId:L.current,createdAt:v.current,updatedAt:so()}}},[]),gr=fe(async()=>{let b=sa();b&&(await pr(b),await F())},[sa,F]);Fe(()=>{if(n&&P&&!(W==="submitted"||W==="streaming")&&Y.length!==0)return A.current&&clearTimeout(A.current),A.current=setTimeout(()=>{A.current=void 0;let b=gr().finally(()=>{E.current===b&&(E.current=void 0)});E.current=b},Cm),()=>{A.current&&clearTimeout(A.current)}},[n,P,Y,W,gr]);let na=fe(()=>{let b=E.current,O=A.current,H=O?sa():void 0;return O&&(clearTimeout(O),A.current=void 0),(async()=>{b&&await b,H&&(await pr(H),await F())})()},[sa,F]),Rl=fe(()=>{y.current+=1,na(),oe([]),re([]),Le(),q("");let b=ml();return v.current=so(),_.current=void 0,U(b),F(),b},[oe,Le,U,F,na]),no=fe(async b=>{y.current+=1;let O=y.current;if(await na(),O!==y.current)return;let H=await fr(b);O===y.current&&H&&(U(H.threadId),v.current=H.createdAt,_.current=H.title,H.sessionId?(L.current=H.sessionId,I(H.sessionId)):Le(),oe(H.messages),re([]),q(""))},[oe,Le,U,na]),Ml=fe(async b=>{if(g.current===b){y.current+=1,A.current&&(clearTimeout(A.current),A.current=void 0);let O=E.current;O&&await O}await ll(b),await F(),g.current===b&&(oe([]),re([]),Le(),q(""),g.current=void 0,C(void 0),v.current=void 0,_.current=void 0)},[oe,Le,F]);Fe(()=>{n&&P&&l!==void 0&&l!==g.current&&no(l)},[l,n,P,no]);let Fl=fe(b=>{q(b.target.value)},[]),wr=Y[Y.length-1],xr=Y.length>0,Dl=Pe&&(!xr||wr.role==="user"),Bl=ge.current;return{messages:Y,status:W,text:K,setText:q,handleSubmit:ct,handleTextChange:Fl,isLoading:Pe,showLoaderBubble:Dl,lastMessage:wr,hasMessages:xr,sendMessage:X,sendMessageAndWait:vl,reset:Al,queuedMessages:Q,queueFull:dt,removeQueuedMessage:ze,sessionId:h,toolDefinitions:Bl,refreshToolDefinitions:ie,threads:k,activeThreadId:S,isThreadHistoryReady:P,startNewThread:Rl,switchThread:no,deleteThread:Ml}}f();import{useEffect as wl,useRef as Sm,useState as ym}from"react";var km={debug:!1,eval:!1};function xl(e="/api/waniwani",t,a=!1){let[o,r]=ym(km),s=Sm(t);return wl(()=>{s.current=t},[t]),wl(()=>{a||(async()=>{try{let n=s.current,i=await(await fetch(`${e}/config`,{headers:n?{...n}:void 0})).json();r({debug:i.debug===!0,eval:i.eval===!0})}catch{}})()},[e,a]),o}f();import{useCallback as bm,useEffect as mr,useRef as Tm,useState as Pm}from"react";function vm(e){for(let t of e.parts){let a=t;if(a.type==="data"||a.type==="data-suggestions"){let o=a.data;if(o&&Array.isArray(o.suggestions))return o.suggestions}}return null}function Ll(e){return typeof e=="object"&&e!==null&&"initial"in e}function Cl(e){let{messages:t,status:a,config:o}=e,r=Ll(o)&&o.initial?o.initial:void 0,[s,n]=Pm(r??[]),l=Tm(a),i=o===!0||Ll(o)&&o.dynamic!==!1,u=bm(()=>{n([])},[]),c=t.length>0;mr(()=>{!c&&r&&r.length>0&&n(r)},[r,c]);let d=t[t.length-1];return mr(()=>{d?.role==="user"&&u()},[d,u]),mr(()=>{let p=l.current;if(l.current=a,p==="streaming"&&a==="ready"&&i){let m=[...t].reverse().find(I=>I.role==="assistant");if(!m)return;let h=vm(m);h&&n(h)}},[a,i,t]),{suggestions:s,isLoading:!1,clear:u}}f();import{useEffect as Am,useRef as Rm,useState as Mm}from"react";var Fm=50,Dm=30,Bm=2e3,Il=500;function Sl(e,t=!0){let[a,o]=Mm(""),r=Rm(void 0);return Am(()=>{if(!t){o("");return}let s=0,n=!1,l=!1,i=()=>{l||(n?(s--,o(e.slice(0,s)),s<=0?(n=!1,r.current=setTimeout(i,Il)):r.current=setTimeout(i,Dm)):(s++,o(e.slice(0,s)),s>=e.length?(n=!0,r.current=setTimeout(i,Bm)):r.current=setTimeout(i,Fm)))};return r.current=setTimeout(i,Il),()=>{l=!0,clearTimeout(r.current)}},[e,t]),a}f();function yl(e,t){let a=t?.Authorization,o=typeof a=="string"&&a.startsWith("Bearer ")?a.slice(7):null;return o?`${e}/resource?token=${encodeURIComponent(o)}`:`${e}/resource`}f();var Em={primaryColor:"#6366f1",primaryForeground:"#1f2937",backgroundColor:"#ffffff",textColor:"#1f2937",mutedColor:"#6b7280",borderColor:"#e5e7eb",borderWidth:0,boxShadow:"none",assistantBubbleColor:"#f3f4f6",userBubbleColor:"#f4f4f4",inputBackgroundColor:"#f9fafb",borderRadius:16,messageBorderRadius:12,fontFamily:"system-ui, -apple-system, 'Segoe UI', sans-serif",headerBackgroundColor:"#ffffff",headerTextColor:"#1f2937",statusColor:"#22c55e",toolCardColor:"#f4f4f5"};var _m={primaryColor:["--ww-primary","--ww-color-primary"],primaryForeground:["--ww-primary-fg","--ww-color-primary-foreground"],backgroundColor:["--ww-bg","--ww-color-background"],textColor:["--ww-text","--ww-color-foreground","--ww-color-accent-foreground"],mutedColor:["--ww-muted","--ww-color-muted-foreground"],borderColor:["--ww-border","--ww-color-border"],borderWidth:["--ww-border-width"],boxShadow:["--ww-shadow"],assistantBubbleColor:["--ww-assistant-bubble","--ww-color-accent"],userBubbleColor:["--ww-user-bubble"],inputBackgroundColor:["--ww-input-bg","--ww-color-input"],borderRadius:["--ww-radius"],messageBorderRadius:["--ww-msg-radius"],fontFamily:["--ww-font"],headerBackgroundColor:["--ww-header-bg"],headerTextColor:["--ww-header-text"],statusColor:["--ww-status"],toolCardColor:["--ww-tool-card","--ww-color-tool-card"]};function kl(e){return{...Em,...e}}function bl(e){let t={};for(let[a,o]of Object.entries(_m)){let r=e[a];if(r===void 0)continue;let s=typeof r=="number"?`${r}px`:String(r);for(let n of o)t[n]=s}return t}import{jsx as pe,jsxs as ra}from"react/jsx-runtime";var Hm=Nm(function(t,a){let{theme:o,title:r="Assistant",width:s,height:n,className:l,allowAttachments:i=!1,welcomeMessage:u,welcome:c,placeholder:d="Ask me anything...",triggerEvent:p="triggerDemoRequest",api:m,debug:h,enableThreadHistory:I=!1,showToolCalls:L=!0}=t,S=m??"/api/waniwani",C=yl(S,t.headers),g=kl(o),k=bl(g),T=g.backgroundColor.replace("#",""),P=parseInt(T.substring(0,2),16),R=parseInt(T.substring(2,4),16),v=parseInt(T.substring(4,6),16),_=(P*299+R*587+v*114)/1e3<128,A=xl(S,t.headers,t.skipRemoteConfig),E=h??A.debug,y=gl({...t,api:S}),M=al({...t,api:S,sessionId:y.sessionId}),U=Sl(d,!y.text),[F,j]=Pl(!1),[Te,Le]=Pl(null),te=Tl(null),me=Tl(void 0),Se=hr(()=>{let N=te.current;if(!N)return;N.scrollIntoView({behavior:"smooth",block:"center"});let ie=N.querySelector("textarea");ie&&setTimeout(()=>ie.focus(),300),j(!0),clearTimeout(me.current),me.current=setTimeout(()=>j(!1),2e3)},[]),ge=Cl({messages:y.messages,status:y.status,config:t.suggestions}),Ce=hr(N=>{let ie=N.content.map(Y=>Y.text??"").join("").trim();ie&&y.handleSubmit({text:ie,files:[],modelContext:N.modelContext})},[y.handleSubmit]),je=hr(N=>{ge.clear(),y.handleSubmit({text:N,files:[]})},[ge.clear,y.handleSubmit]);return Um(a,()=>({sendMessage:N=>{y.handleSubmit({text:N,files:[]}),Se()},sendMessageAndWait:N=>y.sendMessageAndWait(N),reset:y.reset,focus:Se,get messages(){return y.messages}}),[y.handleSubmit,y.sendMessageAndWait,y.reset,y.messages,Se]),Om(()=>{if(!p)return;let N=ie=>{let Y=ie.detail,X=typeof Y?.message=="string"?Y.message:void 0;X&&y.handleSubmit({text:X,files:[]}),Se()};return window.addEventListener(p,N),()=>window.removeEventListener(p,N)},[p,y.handleSubmit,Se]),ra("div",{ref:te,style:{...k,width:s,height:n},"data-waniwani-chat":"","data-waniwani-layout":"card",..._?{"data-waniwani-dark":""}:{},className:B("ww:flex ww:flex-col ww:font-[family-name:var(--ww-font)] ww:text-foreground ww:bg-background ww:rounded-[var(--ww-radius)] ww:overflow-hidden",F&&"ww:ring-2 ww:ring-blue-400/70 ww:ring-offset-2 ww:ring-offset-background",l),children:[ra("div",{className:"ww:shrink-0 ww:flex ww:items-center ww:gap-2 ww:px-6 ww:py-3",style:{backgroundColor:g.headerBackgroundColor,color:g.headerTextColor},children:[pe("div",{className:"ww:text-sm ww:font-semibold ww:truncate ww:flex-1 ww:min-w-0",children:r}),pe(Xs,{messages:y.messages,evalEnabled:A.eval,api:S}),I&&pe(tl,{threads:y.threads,activeThreadId:y.activeThreadId,onNewThread:y.startNewThread,onSelectThread:N=>{y.switchThread(N)},onDeleteThread:N=>{y.deleteThread(N)}})]}),ra(Ts,{className:"ww:flex-1 ww:min-h-0 ww:bg-background",children:[pe(Ps,{scrollClassName:Te?"ww:!relative ww:!overflow-hidden":void 0,children:pe(Qi,{messages:y.messages,status:y.status,welcomeMessage:u,welcome:c,onSuggestionSelect:je,resourceEndpoint:C,chatSessionId:y.sessionId,isDark:_,onFollowUp:Ce,onCallTool:M,fullscreenToolCallId:Te,debug:E,showToolCalls:L,toolDefinitions:y.toolDefinitions,onWidgetDisplayModeChange:(N,ie)=>{Le(N==="fullscreen"?ie.toolCallId:null)}})}),pe(vs,{})]}),pe("div",{style:Te?{display:"none"}:void 0,children:pe(Yi,{suggestions:ge.suggestions,isLoading:ge.isLoading,onSelect:je})}),pe("div",{style:Te?{display:"none"}:void 0,children:pe(Vs,{queuedMessages:y.queuedMessages,onRemove:y.removeQueuedMessage})}),pe("div",{style:Te?{display:"none"}:void 0,children:pe("div",{className:"ww:shrink-0 ww:px-4 ww:pb-8 ww:pt-2 ww:bg-background",children:ra("div",{className:"ww:mx-auto ww:w-full ww:max-w-3xl",children:[pe(Bs,{onSubmit:y.handleSubmit,globalDrop:i,multiple:i,className:"ww:rounded-2xl ww:border-border ww:bg-input",children:ra("div",{className:"ww:flex ww:items-center ww:gap-1 ww:pl-4 ww:pr-3 ww:py-2.5",children:[i&&pe(Ns,{}),pe(Es,{onChange:y.handleTextChange,value:y.text,placeholder:U,className:"ww:min-h-0 ww:py-1 ww:px-0"}),pe(_s,{status:y.status,disabled:y.queueFull})]})}),pe(Zi,{})]})})})]})});export{Hm as ChatCard,Ur as DevModeProvider,Gl as InitializeNextJsInIframe,mu as LoadingWidget,Gr as WidgetProvider,Br as createResource,Ul as createTool,io as detectPlatform,fa as getMockState,Tt as initializeMockOpenAI,Nl as isMCPApps,_l as isOpenAI,Hl as registerTools,Vw as toNextJsHandler,vt as updateMockDisplayMode,Ye as updateMockGlobal,At as updateMockTheme,Pt as updateMockToolOutput,jr as useCallTool,zr as useDisplayMode,Vr as useFlowAction,$r as useIsChatGptApp,Xr as useLocale,Kr as useMaxHeight,Qr as useOpenExternal,Jr as useRequestDisplayMode,Zr as useSafeArea,Yr as useSendFollowUp,es as useTheme,ma as useToolOutput,ts as useToolResponseMetadata,as as useUpdateModelContext,G as useWidgetClient,os as useWidgetState};
|
|
81
|
+
${q}`}]}}E.current({...z,...K?{modelContext:K}:{}})}N({jsonrpc:"2.0",id:W,result:{}});return}if(oe==="ui/update-model-context"&&W!=null){ge=Ir(ge,X.params),N({jsonrpc:"2.0",id:W,result:{}});return}if(oe==="tools/call"&&W!=null){let z=y.current;if(!z){N({jsonrpc:"2.0",id:W,error:{code:-32601,message:"tools/call not supported"}});return}let K=X.params?.name;z({name:K,arguments:X.params?.arguments??{}}).then(q=>{N({jsonrpc:"2.0",id:W,result:q});let Q=q.content?.map(re=>re.text??"").join("").trim();Q&&em(K,q,F.current)&&(Ce&&clearTimeout(Ce.timer),Ce={text:Q,timer:setTimeout(()=>{if(me)return;let re=ge;ge=null,Ce=null,E.current?.({role:"user",content:[{type:"text",text:Q}],...re?{modelContext:re}:{}})},500)})}).catch(q=>{let Q=q instanceof Error?q.message:"Tool call failed";N({jsonrpc:"2.0",id:W,error:{code:-32e3,message:Q}})});return}if(oe==="ui/request-display-mode"&&W!=null){let z=X.params?.mode,K=z==="fullscreen"||z==="inline"||z==="pip"?z:"inline";T.current=K,N({jsonrpc:"2.0",id:W,result:{mode:K}}),N({jsonrpc:"2.0",method:"ui/notifications/host-context-changed",params:{displayMode:K}}),M.current?.(K);return}if(oe==="ui/resource-teardown"&&W!=null){N({jsonrpc:"2.0",id:W,result:{}});return}oe==="ping"&&W!=null&&N({jsonrpc:"2.0",id:W,result:{}})};return window.addEventListener("message",ie),()=>{me=!0,clearTimeout(je),Ce&&clearTimeout(Ce.timer),window.removeEventListener("message",ie)}},[l,j]),tm("iframe",{ref:h,src:Te,sandbox:"allow-scripts allow-forms allow-same-origin allow-popups allow-popups-to-escape-sandbox",className:B(!p&&"ww:rounded-md ww:border ww:border-border",n),style:{height:p?"100%":P,minWidth:p||!v?void 0:`min(${v}px, 100%)`,width:"100%",border:"none",colorScheme:s?"dark":"auto"},title:"MCP App"})}f();import{jsx as ra,jsxs as am}from"react/jsx-runtime";function Yi({icon:e,title:t,description:a,suggestions:o,onSuggestionSelect:r}){return am("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&&ra("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}),ra("h2",{className:"ww:text-lg ww:font-semibold ww:text-foreground",children:t}),a&&ra("p",{className:"ww:mt-1 ww:text-sm ww:text-muted-foreground ww:max-w-sm",children:a}),o&&o.length>0&&ra("div",{className:"ww:mt-6 ww:w-full ww:max-w-md ww:flex ww:flex-col ww:gap-2",children:o.map((s,n)=>ra("button",{type:"button",onClick:()=>r?.(s),className:B("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:`${n*50}ms`},children:s},s))})]})}f();import{Component as om}from"react";import{jsx as el,jsxs as rm}from"react/jsx-runtime";var eo=class extends om{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){console.warn("[WaniWani] Widget failed to render:",t.message)}render(){return this.state.hasError?rm("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:[el("span",{children:"Widget failed to load"}),el("button",{type:"button",onClick:()=>this.setState({hasError:!1}),className:"ww:text-xs ww:font-medium ww:text-primary ww:hover:underline",children:"Retry"})]}):this.props.children}};import{Fragment as sm,jsx as se,jsxs as St}from"react/jsx-runtime";function tl(e){return e?e.replace(/[-_]/g," ").replace(/^\w/,t=>t.toUpperCase()):"Tool"}function al({messages:e,status:t,welcomeMessage:a,welcome:o,onSuggestionSelect:r,resourceEndpoint:s,chatSessionId:n,isDark:l,onFollowUp:i,onCallTool:u,onWidgetDisplayModeChange:c,fullscreenToolCallId:d,debug:p,showToolCalls:m=!0,toolDefinitions:h}){let I=t==="submitted"||t==="streaming",L=e[e.length-1],S=e.length>0,C=I&&(!S||L.role==="user"),g=d!=null;return St(sm,{children:[!g&&(!S&&o?se(Yi,{...o,onSuggestionSelect:r}):a&&se(Qa,{from:"assistant",children:se(Ja,{children:se(Za,{children:a})})})),e.map(b=>{let T=b.parts.filter(y=>y.type==="text"),P=b.parts.filter(y=>y.type==="reasoning"),R=b.parts.filter(y=>y.type==="file"),v=b.parts.filter(y=>"toolCallId"in y),_=b===L&&b.role==="assistant",A=T.length>0,E=g?v.some(y=>y.toolCallId===d):!1;return g&&!E?se("div",{style:{display:"none"}},b.id):St(Qa,{from:b.role,children:[!E&&P.map((y,M)=>se(Ei,{text:y.text},`reasoning-${b.id}-${M}`)),v.map(y=>{let M="output"in y?y.output:void 0,O=Ya(y.toolName,M,h),F=Xi(y.toolName,M,h),j=y.toolCallId===d;return St("div",{style:j?{position:"absolute",inset:0,zIndex:10,display:"flex",flexDirection:"column",overflow:"hidden",background:"var(--ww-color-background)"}:void 0,children:[se("div",{style:j?{display:"none"}:void 0,children:m?St(qi,{children:[se(Wi,{title:y.title??tl(y.toolName),state:y.state}),St(ji,{children:[se(zi,{input:y.input,debug:p}),M!==void 0&&se(Ki,{output:M,errorText:"errorText"in y?y.errorText:void 0,debug:p})]})]}):se(Gi,{title:y.title??tl(y.toolName),state:y.state})}),O&&s&&M!==void 0&&se(eo,{children:se(Zi,{isFullscreen:j,resourceUri:O,toolInput:y.input??{},toolResult:{content:M.content,structuredContent:M.structuredContent,_meta:M._meta},resourceEndpoint:s,chatSessionId:n,isDark:l,autoHeight:F,toolDefinitions:h,onFollowUp:i,onCallTool:u,onDisplayModeChange:c?Te=>c(Te,{toolCallId:y.toolCallId,resourceUri:O,toolInput:y.input??{},toolResult:{content:M.content,structuredContent:M.structuredContent,_meta:M._meta},autoHeight:F}):void 0})})]},y.toolCallId)}),!E&&se("div",{children:St(Ja,{children:[R.length>0&&se(tn,{files:R}),A?T.map((y,M)=>se(Za,{children:y.type==="text"?y.text:""},`${b.id}-${M}`)):_&&I&&se(To,{})]})})]},b.id)}),!g&&C&&se(Qa,{from:"assistant",children:se(Ja,{children:se(To,{})})})]})}f();import{jsx as ol,jsxs as lm}from"react/jsx-runtime";var nm="https://app.waniwani.ai/assets/waniwani-logo.svg",im="https://waniwani.ai";function rl(){return lm("a",{href:im,target:"_blank",rel:"noopener noreferrer",className:"ww:flex ww:items-center ww:gap-1.5 ww:text-[11px] ww:text-muted-foreground ww:opacity-70 hover:ww:opacity-100 ww:transition-opacity",children:[ol("span",{children:"AI agent powered by"}),ol("img",{src:nm,alt:"WaniWani",width:72,height:10,"data-waniwani-logo":"",className:"ww:h-2.5 ww:w-auto"})]})}f();import{jsx as to}from"react/jsx-runtime";function sl({suggestions:e,isLoading:t,onSelect:a,className:o,...r}){return e.length===0&&!t?null:to("div",{className:B("ww:px-4 ww:py-2",o),...r,children:to("div",{className:"ww:mx-auto ww:w-full ww:max-w-3xl ww:flex ww:flex-wrap ww:gap-2",children:t?[0,1,2].map(s=>to("div",{className:"ww:h-7 ww:rounded-full ww:bg-accent ww:animate-pulse",style:{width:`${60+s*20}px`}},s)):e.map((s,n)=>to("button",{type:"button",onClick:()=>a(s),className:B("ww:rounded-full ww:border ww:border-border ww:bg-background ww:px-3 ww:py-1 ww:text-xs","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:`${n*50}ms`},children:s},s))})})}f();import{useEffect as um,useRef as dm,useState as cm}from"react";import{jsx as ee,jsxs as Ze}from"react/jsx-runtime";var nl=20;function fm(e){let t=Date.parse(e);if(Number.isNaN(t))return"";let a=Date.now()-t;return a<6e4?"just now":a<60*6e4?`${Math.floor(a/6e4)}m ago`:a<1440*6e4?`${Math.floor(a/(60*6e4))}h ago`:`${Math.floor(a/(1440*6e4))}d ago`}function pm(){return Ze("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":"New chat",children:[ee("title",{children:"New chat"}),ee("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),ee("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}function mm(){return Ze("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":"Thread history",children:[ee("title",{children:"Thread history"}),ee("path",{d:"M3 12a9 9 0 1 0 3-6.7"}),ee("polyline",{points:"3 4 3 9 8 9"}),ee("line",{x1:"12",y1:"7",x2:"12",y2:"12"}),ee("line",{x1:"12",y1:"12",x2:"15",y2:"14"})]})}function hm(){return Ze("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":"Delete thread",children:[ee("title",{children:"Delete thread"}),ee("polyline",{points:"3 6 5 6 21 6"}),ee("path",{d:"M19 6l-2 14a2 2 0 0 1-2 2H9a2 2 0 0 1-2-2L5 6"}),ee("path",{d:"M10 11v6"}),ee("path",{d:"M14 11v6"})]})}function il({threads:e,activeThreadId:t,onNewThread:a,onSelectThread:o,onDeleteThread:r}){let[s,n]=cm(!1),l=dm(null);um(()=>{if(!s)return;let c=d=>{let p=l.current;p&&(d.composedPath().includes(p)||n(!1))};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[s]);let i=e.slice(0,nl),u=Math.max(0,e.length-nl);return Ze("div",{ref:l,className:"ww:relative ww:flex ww:items-center ww:gap-1",children:[ee("button",{type:"button",onClick:a,title:"New chat","aria-label":"New chat",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:ee(pm,{})}),ee("button",{type:"button",onClick:()=>n(c=>!c),title:"Thread history","aria-label":"Thread history","aria-expanded":s,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:ee(mm,{})}),s&&Ze("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:[i.length===0&&ee("div",{className:"ww:px-3 ww:py-3 ww:text-xs ww:text-muted-foreground",children:"No previous chats yet."}),i.map(c=>{let d=c.threadId===t;return Ze("div",{className:`ww:flex ww:items-center ww:gap-2 ww:px-3 ww:py-2 ww:text-xs hover:ww:bg-foreground/5 ${d?"ww:bg-foreground/5":""}`,children:[Ze("button",{type:"button",onClick:()=>{o(c.threadId),n(!1)},className:"ww:flex-1 ww:min-w-0 ww:text-left ww:cursor-pointer",children:[ee("div",{className:"ww:truncate ww:text-foreground ww:font-medium",children:c.title}),ee("div",{className:"ww:text-[10px] ww:text-muted-foreground",children:fm(c.updatedAt)})]}),ee("button",{type:"button",onClick:p=>{p.stopPropagation(),r(c.threadId)},title:"Delete thread","aria-label":"Delete thread",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:ee(hm,{})})]},c.threadId)}),u>0&&Ze("div",{className:"ww:px-3 ww:py-2 ww:text-[10px] ww:text-muted-foreground ww:border-t ww:border-border",children:[u," older thread",u===1?"":"s"," hidden"]})]})]})}f();import{useCallback as gm,useRef as wm}from"react";function ll(e){let t=wm(e);return t.current=e,gm(async a=>{let{api:o,headers:r,onCallTool:s,sessionId:n}=t.current;if(s)return s(a);let l=`${o??"/api/waniwani"}/tool`,i=typeof n=="string"&&n.trim().length>0?n.trim():void 0,u=await fetch(l,{method:"POST",headers:{"Content-Type":"application/json",...i?{"X-Session-Id":i}:{},...r},body:JSON.stringify(a)});if(!u.ok)throw new Error(`Tool call failed: ${u.status} ${u.statusText}`);return u.json()},[])}f();import{useChat as Bm}from"@ai-sdk/react";import{useCallback as fe,useEffect as Fe,useRef as ue,useState as ut}from"react";f();import{DefaultChatTransport as xm,uiMessageChunkSchema as Lm}from"ai";function Cm(e){let t=e?.cause,a=t?.issues??t?.errors;if(!Array.isArray(a))return null;let o=a.find(r=>r.code==="invalid_union");if(!o?.errors)return null;for(let r of o.errors){if(!Array.isArray(r)||r.some(l=>(l.code==="invalid_value"||l.code==="invalid_literal")&&l.path?.[0]==="type"))continue;let n=r.filter(l=>l.code==="unrecognized_keys").flatMap(l=>l.keys??[]);if(n.length>0)return n}return null}var ao=class extends xm{processResponseStream(t){let a="",o=Lm(),r=o.validate?.bind(o);return t.pipeThrough(new TextDecoderStream).pipeThrough(new TransformStream({async transform(s,n){a+=s;let l=a.split(`
|
|
82
|
+
`);a=l.pop()??"";for(let i of l){let u=i.trim();if(!u.startsWith("data:"))continue;let c=u.slice(5).trim();if(c!=="[DONE]")try{let d=JSON.parse(c);if(!r){n.enqueue(d);continue}let p=await r(d);if(p.success){n.enqueue(p.value);continue}let m=Cm(p.error);if(m?.length){let h={...d};for(let L of m)delete h[L];let I=await r(h);I.success&&n.enqueue(I.value)}}catch{}}}}))}};f();f();var Im="waniwani-memory";var ke="threads",oo="by_memoryUserId",Sm="by_updatedAt";var dl="memoryUserId",ul="waniwani-memory-user-id",ur=null;function dr(){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 ym(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(oo,"memoryUserId",{unique:!1}),a.createIndex(Sm,"updatedAt",{unique:!1})}}async function cr(){return new Promise((e,t)=>{let a=indexedDB.open(Im,2);a.onupgradeneeded=o=>{ym(a.result,o.oldVersion)},a.onsuccess=()=>e(a.result),a.onerror=()=>t(a.error)})}async function bm(){return cr()}async function km(e){return new Promise((t,a)=>{let s=e.transaction("ids","readonly").objectStore("ids").get(dl);s.onsuccess=()=>t(typeof s.result=="string"?s.result:null),s.onerror=()=>a(s.error)})}async function Tm(e,t){return new Promise((a,o)=>{let n=e.transaction("ids","readwrite").objectStore("ids").put(t,dl);n.onsuccess=()=>a(),n.onerror=()=>o(n.error)})}async function Pm(){if(typeof indexedDB>"u")return null;try{let e=await bm();try{let t=await km(e);if(t)return t;let a=dr();return await Tm(e,a),a}finally{e.close()}}catch{return null}}function vm(){try{let e=localStorage.getItem(ul);if(e)return e;let t=dr();return localStorage.setItem(ul,t),t}catch{return null}}async function cl(){let e=await Pm();if(e)return e;let t=vm();return t||(ur||(ur=dr()),ur)}var fl=50,pl=1e3;function ro(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.threadId=="string"&&typeof t.memoryUserId=="string"&&typeof t.title=="string"&&Array.isArray(t.messages)&&typeof t.createdAt=="string"&&typeof t.updatedAt=="string"}async function so(e){if(typeof indexedDB>"u")return null;let t=null;try{return t=await cr(),await e(t)}catch{return null}finally{try{t?.close()}catch{}}}function fr(e){return new Promise((t,a)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>a(e.error)})}async function pr(e){return await so(async a=>{let s=a.transaction(ke,"readonly").objectStore(ke).index(oo),l=(await fr(s.getAll(e))??[]).filter(ro);return l.sort((i,u)=>i.updatedAt<u.updatedAt?1:-1),l})??[]}async function mr(e){return await so(async a=>{let r=a.transaction(ke,"readonly").objectStore(ke),s=await fr(r.get(e));return ro(s)?s:null})??null}async function hr(e){if(!ro(e))return;let t=e.messages.length>pl?{...e,messages:e.messages.slice(e.messages.length-pl)}:e;await so(async a=>{await new Promise((i,u)=>{let c=a.transaction(ke,"readwrite");c.oncomplete=()=>i(),c.onerror=()=>u(c.error),c.onabort=()=>u(c.error),c.objectStore(ke).put(t)});let o=a.transaction(ke,"readwrite"),r=o.objectStore(ke),s=r.index(oo),l=(await fr(s.getAll(t.memoryUserId))??[]).filter(ro);if(l.length>fl){l.sort((u,c)=>u.updatedAt<c.updatedAt?-1:1);let i=l.slice(0,l.length-fl);for(let u of i)r.delete(u.threadId)}return await new Promise((i,u)=>{o.oncomplete=()=>i(),o.onerror=()=>u(o.error),o.onabort=()=>u(o.error)}),null})}async function ml(e){await so(async t=>(await new Promise((a,o)=>{let r=t.transaction(ke,"readwrite");r.oncomplete=()=>a(),r.onerror=()=>o(r.error),r.onabort=()=>o(r.error),r.objectStore(ke).delete(e)}),null))}async function hl(e){return(await pr(e))[0]?.threadId??null}function gl(e){let t=e.trim();if(!t)return`Conversation on ${new Date().toISOString().slice(0,10)}`;let a=t.split(/\r?\n/,1)[0]??t;return a.length<=60?a:`${a.slice(0,60).trimEnd()}\u2026`}f();var wl="waniwani-visitor-id";function xl(e,t){return e.match(t)?.[1]??null}function Am(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,o]of t){let r=xl(e,o);if(r)return{name:a,version:r}}return null}function Rm(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,o]of t){let r=xl(e,o);if(r)return{name:a,version:r.replace(/_/g,".")};if(a==="Linux"&&o.test(e))return{name:a,version:""}}return null}function Mm(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 Fm(e){let t=new TextEncoder().encode(e),a=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(a)).map(o=>o.toString(16).padStart(2,"0")).join("")}async function Dm(){try{let a=localStorage.getItem(wl);if(a)return a}catch{}let e=[navigator.userAgent,screen.width,screen.height,screen.colorDepth,Intl.DateTimeFormat().resolvedOptions().timeZone,navigator.language,navigator.hardwareConcurrency??"",navigator.platform??""].join("|"),t=await Fm(e);try{localStorage.setItem(wl,t)}catch{}return t}async function Ll(){let e=navigator.userAgent,[t,a]=await Promise.all([Dm(),cl()]);return{userAgent:e,browser:Am(e),os:Rm(e),deviceType:Mm(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 Em="x-session-id",_m=250;function Cl(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():Gt()}function no(){return new Date().toISOString()}function Il(e){if(typeof e!="string")return;let t=e.trim();return t.length>0?t:void 0}async function Nm(e,t){let a=`${e.replace(/\/$/,"")}/tools`,o=await fetch(a,{method:"GET",headers:t?{...t}:void 0});if(!o.ok)throw new Error(`[WaniWani] Failed to fetch /tools: ${o.status} ${o.statusText}`);let r=await o.json();if(!r||!Array.isArray(r.tools))return{};let s={};for(let n of r.tools)n&&typeof n.name=="string"&&(s[n.name]=n);return s}function Sl(e){let{api:t="/api/waniwani",headers:a,body:o,onMessageSent:r,onResponseReceived:s,enableThreadHistory:n=!1,activeThreadId:l,onThreadChange:i}=e,u=ue(a),c=ue(o),d=ue(n);Fe(()=>{d.current=n},[n]);let p=ue(void 0),m=ue(null),[h,I]=ut(void 0),L=ue(h),[S,C]=ut(l),g=ue(S),[b,T]=ut([]),[P,R]=ut(!n),v=ue(void 0),_=ue(void 0),A=ue(void 0),E=ue(void 0),y=ue(0),M=ue(i);Fe(()=>{M.current=i},[i]);let O=fe(k=>{g.current=k,C(k),k&&M.current?.(k)},[]),F=fe(async()=>{if(!n)return;let k=m.current?.memoryUserId;if(!k)return;let U=await pr(k);T(U)},[n]),j=fe(()=>L.current,[]),Te=fe(k=>{let U=Il(k);U&&L.current!==U&&(L.current=U,I(U))},[]),Le=fe(()=>{L.current=void 0,I(void 0)},[]);Fe(()=>{u.current=a},[a]),Fe(()=>{c.current=o},[o]),Fe(()=>{let k=!1,U=y.current;return(async()=>{try{let ve=await Ll();if(k)return;m.current=ve}catch{}if(!n)return;let H=m.current?.memoryUserId;if(!H){R(!0);return}try{let ve=l??await hl(H);if(k||U!==y.current)return;if(ve){let we=await mr(ve);if(k||U!==y.current)return;we&&we.memoryUserId===H&&(g.current=we.threadId,C(we.threadId),v.current=we.createdAt,_.current=we.title,we.sessionId&&(L.current=we.sessionId,I(we.sessionId)),oe(we.messages))}await F()}finally{k||R(!0)}})(),()=>{k=!0}},[]);let te=ue(new ao({api:t,headers:()=>({...u.current}),body:()=>{let k={...c.current??{}},U=Object.hasOwn(k,"sessionId"),H=Il(k.sessionId);if(H)Te(H),k.sessionId=H;else if(U)Le(),delete k.sessionId;else{let Re=j();Re&&(k.sessionId=Re)}if(ft(p.current)&&(k.modelContext=p.current),m.current){let Re=m.current;k.visitorContext={timezone:Re.timezone,language:Re.language,languages:Re.languages,deviceType:Re.deviceType,referrer:Re.referrer,visitorId:Re.visitorId};let Oe=typeof k.visitor=="object"&&k.visitor!==null?k.visitor:{},ql=typeof Oe.client=="object"&&Oe.client!==null?Oe.client:{};k.visitor={...Oe,client:{...ql,memoryUserId:Re.memoryUserId}}}let ve=typeof k.extra=="object"&&k.extra!==null&&!Array.isArray(k.extra)?k.extra:void 0,we=m.current?.memoryUserId,Ve=m.current?.language,la={};if(we&&(la.memoryUserId=we),Ve&&(la.locale=Ve),(Object.keys(la).length>0||ve)&&(k.extra={...la,...ve??{}}),d.current)if(Object.hasOwn(k,"threadId"))typeof k.threadId=="string"&&(g.current=k.threadId);else{let Oe=g.current;Oe||(Oe=Cl(),v.current=no(),_.current=void 0,O(Oe)),k.threadId=Oe}return k},fetch:(async(k,U)=>{let H=await fetch(k,U);return p.current=void 0,Te(H.headers.get(Em)),H})})),me=ue(null),Se=ue(null),ge=ue({}),[Ce,je]=ut(0),N=e.skipRemoteConfig===!0,ie=fe(async()=>{if(!N)try{let k=await Nm(t,u.current);ge.current=k,je(U=>U+1)}catch(k){console.warn("[WaniWani] Failed to fetch tool definitions:",k instanceof Error?k.message:k)}},[t,N]);Fe(()=>{ie()},[ie]);let{messages:Y,sendMessage:X,setMessages:oe,status:W}=Bm({messages:e.initialMessages,transport:te.current,onFinish({message:k}){s?.(),me.current&&(Se.current=k)},onError(k){console.warn("[WaniWani] Chat error:",k.message),me.current&&(me.current.reject(k),me.current=null)}}),z=ue(Y);Fe(()=>{z.current=Y},[Y]),Fe(()=>{if(W==="ready"&&me.current&&Se.current){let k=me.current,U=Se.current;me.current=null,Se.current=null,k.resolve(U)}},[W]);let[K,q]=ut(""),[Q,re]=ut([]),Pe=W==="submitted"||W==="streaming",ze=fe(k=>{re(U=>U.filter(H=>H.id!==k))},[]),dt=Pe&&Q.length>0,ct=fe(k=>{let U=!!k.text?.trim(),H=!!k.files?.length;if(U||H){if(Pe){if(Q.length>0)return;re(ve=>[...ve,{id:Gt(),text:k.text||"",files:k.files??[],modelContext:k.modelContext}]),q("");return}p.current=k.modelContext,X({text:k.text||"",files:k.files}),r?.(k.text||""),q("")}},[X,r,Pe,Q.length]),Bl=fe(k=>new Promise((U,H)=>{me.current={resolve:U,reject:H},X({text:k}),r?.(k)}),[X,r]);Fe(()=>{if(W!=="ready"||Q.length===0)return;let[k,...U]=Q;re(U),p.current=k.modelContext,X({text:k.text,files:k.files.length>0?k.files:void 0}),r?.(k.text)},[W,X,r,Q]);let El=fe(()=>{oe([]),re([]),Le(),q(""),ge.current={},je(k=>k+1),ie()},[oe,Le,ie]),na=fe(()=>{if(!d.current)return;let k=m.current?.memoryUserId,U=g.current,H=z.current;if(!(!k||!U||H.length===0)){if(v.current||(v.current=no()),!_.current){let ve=H.find(Ve=>Ve.role==="user"),we=ve?ve.parts.map(Ve=>"text"in Ve&&typeof Ve.text=="string"?Ve.text:"").join(" "):"";_.current=gl(we)}return{threadId:U,memoryUserId:k,title:_.current,messages:H,sessionId:L.current,createdAt:v.current,updatedAt:no()}}},[]),xr=fe(async()=>{let k=na();k&&(await hr(k),await F())},[na,F]);Fe(()=>{if(n&&P&&!(W==="submitted"||W==="streaming")&&Y.length!==0)return A.current&&clearTimeout(A.current),A.current=setTimeout(()=>{A.current=void 0;let k=xr().finally(()=>{E.current===k&&(E.current=void 0)});E.current=k},_m),()=>{A.current&&clearTimeout(A.current)}},[n,P,Y,W,xr]);let ia=fe(()=>{let k=E.current,U=A.current,H=U?na():void 0;return U&&(clearTimeout(U),A.current=void 0),(async()=>{k&&await k,H&&(await hr(H),await F())})()},[na,F]),_l=fe(()=>{y.current+=1,ia(),oe([]),re([]),Le(),q("");let k=Cl();return v.current=no(),_.current=void 0,O(k),F(),k},[oe,Le,O,F,ia]),io=fe(async k=>{y.current+=1;let U=y.current;if(await ia(),U!==y.current)return;let H=await mr(k);U===y.current&&H&&(O(H.threadId),v.current=H.createdAt,_.current=H.title,H.sessionId?(L.current=H.sessionId,I(H.sessionId)):Le(),oe(H.messages),re([]),q(""))},[oe,Le,O,ia]),Nl=fe(async k=>{if(g.current===k){y.current+=1,A.current&&(clearTimeout(A.current),A.current=void 0);let U=E.current;U&&await U}await ml(k),await F(),g.current===k&&(oe([]),re([]),Le(),q(""),g.current=void 0,C(void 0),v.current=void 0,_.current=void 0)},[oe,Le,F]);Fe(()=>{n&&P&&l!==void 0&&l!==g.current&&io(l)},[l,n,P,io]);let Ul=fe(k=>{q(k.target.value)},[]),Lr=Y[Y.length-1],Cr=Y.length>0,Ol=Pe&&(!Cr||Lr.role==="user"),Hl=ge.current;return{messages:Y,status:W,text:K,setText:q,handleSubmit:ct,handleTextChange:Ul,isLoading:Pe,showLoaderBubble:Ol,lastMessage:Lr,hasMessages:Cr,sendMessage:X,sendMessageAndWait:Bl,reset:El,queuedMessages:Q,queueFull:dt,removeQueuedMessage:ze,sessionId:h,toolDefinitions:Hl,refreshToolDefinitions:ie,threads:b,activeThreadId:S,isThreadHistoryReady:P,startNewThread:_l,switchThread:io,deleteThread:Nl}}f();import{useEffect as yl,useRef as Um,useState as Om}from"react";var Hm={debug:!1,eval:!1};function bl(e="/api/waniwani",t,a=!1){let[o,r]=Om(Hm),s=Um(t);return yl(()=>{s.current=t},[t]),yl(()=>{a||(async()=>{try{let n=s.current,i=await(await fetch(`${e}/config`,{headers:n?{...n}:void 0})).json();r({debug:i.debug===!0,eval:i.eval===!0})}catch{}})()},[e,a]),o}f();import{useCallback as qm,useEffect as gr,useRef as Wm,useState as Gm}from"react";function jm(e){for(let t of e.parts){let a=t;if(a.type==="data"||a.type==="data-suggestions"){let o=a.data;if(o&&Array.isArray(o.suggestions))return o.suggestions}}return null}function kl(e){return typeof e=="object"&&e!==null&&"initial"in e}function Tl(e){let{messages:t,status:a,config:o}=e,r=kl(o)&&o.initial?o.initial:void 0,[s,n]=Gm(r??[]),l=Wm(a),i=o===!0||kl(o)&&o.dynamic!==!1,u=qm(()=>{n([])},[]),c=t.length>0;gr(()=>{!c&&r&&r.length>0&&n(r)},[r,c]);let d=t[t.length-1];return gr(()=>{d?.role==="user"&&u()},[d,u]),gr(()=>{let p=l.current;if(l.current=a,p==="streaming"&&a==="ready"&&i){let m=[...t].reverse().find(I=>I.role==="assistant");if(!m)return;let h=jm(m);h&&n(h)}},[a,i,t]),{suggestions:s,isLoading:!1,clear:u}}f();import{useEffect as zm,useRef as Vm,useState as $m}from"react";var Xm=50,Km=30,Qm=2e3,Pl=500;function vl(e,t=!0){let[a,o]=$m(""),r=Vm(void 0);return zm(()=>{if(!t){o("");return}let s=0,n=!1,l=!1,i=()=>{l||(n?(s--,o(e.slice(0,s)),s<=0?(n=!1,r.current=setTimeout(i,Pl)):r.current=setTimeout(i,Km)):(s++,o(e.slice(0,s)),s>=e.length?(n=!0,r.current=setTimeout(i,Qm)):r.current=setTimeout(i,Xm)))};return r.current=setTimeout(i,Pl),()=>{l=!0,clearTimeout(r.current)}},[e,t]),a}f();function Al(e,t){let a=t?.Authorization,o=typeof a=="string"&&a.startsWith("Bearer ")?a.slice(7):null;return o?`${e}/resource?token=${encodeURIComponent(o)}`:`${e}/resource`}f();var Jm={primaryColor:"#6366f1",primaryForeground:"#1f2937",backgroundColor:"#ffffff",textColor:"#1f2937",mutedColor:"#6b7280",borderColor:"#e5e7eb",borderWidth:0,boxShadow:"none",assistantBubbleColor:"#f3f4f6",userBubbleColor:"#f4f4f4",inputBackgroundColor:"#f9fafb",borderRadius:16,messageBorderRadius:12,fontFamily:"system-ui, -apple-system, 'Segoe UI', sans-serif",headerBackgroundColor:"#ffffff",headerTextColor:"#1f2937",statusColor:"#22c55e",toolCardColor:"#f4f4f5"};var Zm={primaryColor:["--ww-primary","--ww-color-primary"],primaryForeground:["--ww-primary-fg","--ww-color-primary-foreground"],backgroundColor:["--ww-bg","--ww-color-background"],textColor:["--ww-text","--ww-color-foreground","--ww-color-accent-foreground"],mutedColor:["--ww-muted","--ww-color-muted-foreground"],borderColor:["--ww-border","--ww-color-border"],borderWidth:["--ww-border-width"],boxShadow:["--ww-shadow"],assistantBubbleColor:["--ww-assistant-bubble","--ww-color-accent"],userBubbleColor:["--ww-user-bubble"],inputBackgroundColor:["--ww-input-bg","--ww-color-input"],borderRadius:["--ww-radius"],messageBorderRadius:["--ww-msg-radius"],fontFamily:["--ww-font"],headerBackgroundColor:["--ww-header-bg"],headerTextColor:["--ww-header-text"],statusColor:["--ww-status"],toolCardColor:["--ww-tool-card","--ww-color-tool-card"]};function Rl(e){return{...Jm,...e}}function Ml(e){let t={};for(let[a,o]of Object.entries(Zm)){let r=e[a];if(r===void 0)continue;let s=typeof r=="number"?`${r}px`:String(r);for(let n of o)t[n]=s}return t}import{jsx as pe,jsxs as sa}from"react/jsx-runtime";var ah=Ym(function(t,a){let{theme:o,title:r="Assistant",width:s,height:n,className:l,allowAttachments:i=!1,welcomeMessage:u,welcome:c,placeholder:d="Ask me anything...",triggerEvent:p="triggerDemoRequest",api:m,debug:h,enableThreadHistory:I=!1,showToolCalls:L=!0}=t,S=m??"/api/waniwani",C=Al(S,t.headers),g=Rl(o),b=Ml(g),T=g.backgroundColor.replace("#",""),P=parseInt(T.substring(0,2),16),R=parseInt(T.substring(2,4),16),v=parseInt(T.substring(4,6),16),_=(P*299+R*587+v*114)/1e3<128,A=bl(S,t.headers,t.skipRemoteConfig),E=h??A.debug,y=Sl({...t,api:S}),M=ll({...t,api:S,sessionId:y.sessionId}),O=vl(d,!y.text),[F,j]=Dl(!1),[Te,Le]=Dl(null),te=Fl(null),me=Fl(void 0),Se=wr(()=>{let N=te.current;if(!N)return;N.scrollIntoView({behavior:"smooth",block:"center"});let ie=N.querySelector("textarea");ie&&setTimeout(()=>ie.focus(),300),j(!0),clearTimeout(me.current),me.current=setTimeout(()=>j(!1),2e3)},[]),ge=Tl({messages:y.messages,status:y.status,config:t.suggestions}),Ce=wr(N=>{let ie=N.content.map(Y=>Y.text??"").join("").trim();ie&&y.handleSubmit({text:ie,files:[],modelContext:N.modelContext})},[y.handleSubmit]),je=wr(N=>{ge.clear(),y.handleSubmit({text:N,files:[]})},[ge.clear,y.handleSubmit]);return th(a,()=>({sendMessage:N=>{y.handleSubmit({text:N,files:[]}),Se()},sendMessageAndWait:N=>y.sendMessageAndWait(N),reset:y.reset,focus:Se,get messages(){return y.messages}}),[y.handleSubmit,y.sendMessageAndWait,y.reset,y.messages,Se]),eh(()=>{if(!p)return;let N=ie=>{let Y=ie.detail,X=typeof Y?.message=="string"?Y.message:void 0;X&&y.handleSubmit({text:X,files:[]}),Se()};return window.addEventListener(p,N),()=>window.removeEventListener(p,N)},[p,y.handleSubmit,Se]),sa("div",{ref:te,style:{...b,width:s,height:n},"data-waniwani-chat":"","data-waniwani-layout":"card",..._?{"data-waniwani-dark":""}:{},className:B("ww:flex ww:flex-col ww:font-[family-name:var(--ww-font)] ww:text-foreground ww:bg-background ww:rounded-[var(--ww-radius)] ww:overflow-hidden",F&&"ww:ring-2 ww:ring-blue-400/70 ww:ring-offset-2 ww:ring-offset-background",l),children:[sa("div",{className:"ww:shrink-0 ww:flex ww:items-center ww:gap-2 ww:px-6 ww:py-3",style:{backgroundColor:g.headerBackgroundColor,color:g.headerTextColor},children:[pe("div",{className:"ww:text-sm ww:font-semibold ww:truncate ww:flex-1 ww:min-w-0",children:r}),pe(en,{messages:y.messages,evalEnabled:A.eval,api:S}),I&&pe(il,{threads:y.threads,activeThreadId:y.activeThreadId,onNewThread:y.startNewThread,onSelectThread:N=>{y.switchThread(N)},onDeleteThread:N=>{y.deleteThread(N)}})]}),sa(Fs,{className:"ww:flex-1 ww:min-h-0 ww:bg-background",children:[pe(Ds,{scrollClassName:Te?"ww:!relative ww:!overflow-hidden":void 0,children:pe(al,{messages:y.messages,status:y.status,welcomeMessage:u,welcome:c,onSuggestionSelect:je,resourceEndpoint:C,chatSessionId:y.sessionId,isDark:_,onFollowUp:Ce,onCallTool:M,fullscreenToolCallId:Te,debug:E,showToolCalls:L,toolDefinitions:y.toolDefinitions,onWidgetDisplayModeChange:(N,ie)=>{Le(N==="fullscreen"?ie.toolCallId:null)}})}),pe(Bs,{})]}),pe("div",{style:Te?{display:"none"}:void 0,children:pe(sl,{suggestions:ge.suggestions,isLoading:ge.isLoading,onSelect:je})}),pe("div",{style:Te?{display:"none"}:void 0,children:pe(Zs,{queuedMessages:y.queuedMessages,onRemove:y.removeQueuedMessage})}),pe("div",{style:Te?{display:"none"}:void 0,children:pe("div",{className:"ww:shrink-0 ww:px-4 ww:pb-8 ww:pt-2 ww:bg-background",children:sa("div",{className:"ww:mx-auto ww:w-full ww:max-w-3xl",children:[pe(Hs,{onSubmit:y.handleSubmit,globalDrop:i,multiple:i,className:"ww:rounded-2xl ww:border-border ww:bg-input",children:sa("div",{className:"ww:flex ww:items-center ww:gap-1 ww:pl-4 ww:pr-3 ww:py-2.5",children:[i&&pe(Gs,{}),pe(qs,{onChange:y.handleTextChange,value:y.text,placeholder:O,className:"ww:min-h-0 ww:py-1 ww:px-0"}),pe(Ws,{status:y.status,disabled:y.queueFull})]})}),pe(rl,{})]})})})]})});export{ah as ChatCard,qr as DevModeProvider,Kl as InitializeNextJsInIframe,Ru as LoadingWidget,Kr as WidgetProvider,_r as createResource,zl as createTool,lo as detectPlatform,pa as getMockState,Tt as initializeMockOpenAI,Gl as isMCPApps,Wl as isOpenAI,Vl as registerTools,mx as toNextJsHandler,zr as unstable_useSendFollowUpWithGhostGuard,vt as updateMockDisplayMode,Ye as updateMockGlobal,At as updateMockTheme,Pt as updateMockToolOutput,Qr as useCallTool,Jr as useDisplayMode,Zr as useFlowAction,Yr as useIsChatGptApp,es as useLocale,ts as useMaxHeight,as as useOpenExternal,os as useRequestDisplayMode,rs as useSafeArea,ss as useSendFollowUp,ns as useTheme,ha as useToolOutput,is as useToolResponseMetadata,ls as useUpdateModelContext,G as useWidgetClient,us as useWidgetState};
|
|
83
83
|
/*! Bundled license information:
|
|
84
84
|
|
|
85
85
|
lucide-react/dist/esm/shared/src/utils/mergeClasses.js:
|