@waniwani/sdk 0.11.11 → 0.11.12

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.
Files changed (53) hide show
  1. package/README.md +92 -93
  2. package/dist/chat/embed.js +51 -51
  3. package/dist/chat/embed.js.map +1 -1
  4. package/dist/chat/express-js/index.d.ts +8 -1
  5. package/dist/chat/express-js/index.js.map +1 -1
  6. package/dist/chat/index.d.ts +1 -22
  7. package/dist/chat/index.js +7 -7
  8. package/dist/chat/index.js.map +1 -1
  9. package/dist/chat/next-js/index.d.ts +5 -3
  10. package/dist/chat/next-js/index.js.map +1 -1
  11. package/dist/chat/server/index.js +1 -1
  12. package/dist/chat/server/index.js.map +1 -1
  13. package/dist/chat/styles.css +1 -1
  14. package/dist/{chunk-DGSC74SV.js → chunk-DP6SAQTK.js} +1 -1
  15. package/dist/chunk-DP6SAQTK.js.map +1 -0
  16. package/dist/{chunk-5OQXAEHG.js → chunk-RZKVTH7F.js} +1 -1
  17. package/dist/chunk-RZKVTH7F.js.map +1 -0
  18. package/dist/legacy/chat/express-js/index.d.ts +407 -0
  19. package/dist/legacy/chat/express-js/index.js +10 -0
  20. package/dist/legacy/chat/express-js/index.js.map +1 -0
  21. package/dist/legacy/chat/next-js/index.d.ts +368 -0
  22. package/dist/legacy/chat/next-js/index.js +10 -0
  23. package/dist/legacy/chat/next-js/index.js.map +1 -0
  24. package/dist/legacy/index.d.ts +335 -0
  25. package/dist/legacy/index.js +2 -0
  26. package/dist/legacy/index.js.map +1 -0
  27. package/dist/legacy/mcp/react.d.ts +573 -0
  28. package/dist/legacy/mcp/react.js +68 -0
  29. package/dist/legacy/mcp/react.js.map +1 -0
  30. package/dist/mcp/index.d.ts +1153 -1117
  31. package/dist/mcp/index.js +5 -5
  32. package/dist/mcp/index.js.map +1 -1
  33. package/dist/mcp/react.d.ts +170 -74
  34. package/dist/mcp/react.js +7 -7
  35. package/dist/mcp/react.js.map +1 -1
  36. package/dist/{mcp-apps-client-PUL4H54S.js → mcp-apps-client-OFYMQOI3.js} +1 -1
  37. package/dist/mcp-apps-client-OFYMQOI3.js.map +1 -0
  38. package/dist/{openai-client-QAC3ZD5W.js → openai-client-TZIOCMXP.js} +2 -2
  39. package/dist/openai-client-TZIOCMXP.js.map +1 -0
  40. package/dist/platform-LKQFC3AJ.js +3 -0
  41. package/package.json +34 -21
  42. package/dist/chunk-5OQXAEHG.js.map +0 -1
  43. package/dist/chunk-DGSC74SV.js.map +0 -1
  44. package/dist/evals/index.d.ts +0 -156
  45. package/dist/evals/index.js +0 -2
  46. package/dist/evals/index.js.map +0 -1
  47. package/dist/evals/scorers.d.ts +0 -92
  48. package/dist/evals/scorers.js +0 -8
  49. package/dist/evals/scorers.js.map +0 -1
  50. package/dist/mcp-apps-client-PUL4H54S.js.map +0 -1
  51. package/dist/openai-client-QAC3ZD5W.js.map +0 -1
  52. package/dist/platform-GKYYQBCS.js +0 -3
  53. /package/dist/{platform-GKYYQBCS.js.map → platform-LKQFC3AJ.js.map} +0 -0
@@ -1,7 +1,7 @@
1
1
  "use client";
2
- import{a as Sr,b as yr,c as kr,d as it,e as lt,f as ua,g as br,h as Tr,i as Pr,j as Ar,k as da,l as vr,m as mo,n as Mr,o as Rr,p as ut,u as ho}from"../chunk-5JBHQYU5.js";import"../chunk-V3ZDECK5.js";import{forwardRef as Wc,useCallback as io,useEffect as wi,useImperativeHandle as zc,useRef as xi,useState as gr}from"react";import{forwardRef as Ni,createElement as Oi}from"react";var fa=(...e)=>e.filter((t,a,o)=>!!t&&t.trim()!==""&&o.indexOf(t)===a).join(" ").trim();var Fr=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();var Br=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,a,o)=>o?o.toUpperCase():a.toLowerCase());var go=e=>{let t=Br(e);return t.charAt(0).toUpperCase()+t.slice(1)};import{forwardRef as _i,createElement as _r}from"react";var Dr={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};var Er=e=>{for(let t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};var Nr=_i(({color:e="currentColor",size:t=24,strokeWidth:a=2,absoluteStrokeWidth:o,className:r="",children:s,iconNode:n,...l},i)=>_r("svg",{ref:i,...Dr,width:t,height:t,stroke:e,strokeWidth:o?Number(a)*24/Number(t):a,className:fa("lucide",r),...!s&&!Er(l)&&{"aria-hidden":"true"},...l},[...n.map(([u,f])=>_r(u,f)),...Array.isArray(s)?s:[s]]));var $=(e,t)=>{let a=Ni(({className:o,...r},s)=>Oi(Nr,{ref:s,iconNode:t,className:fa(`lucide-${Fr(go(e))}`,`lucide-${e}`,o),...r}));return a.displayName=go(e),a};var Ui=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],$e=$("arrow-down",Ui);var Hi=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Rt=$("arrow-up",Hi);var qi=[["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"}]],He=$("braces",qi);var Gi=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Ft=$("check",Gi);var Wi=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Bt=$("chevron-down",Wi);var zi=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Dt=$("chevron-right",zi);var ji=[["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"}]],Et=$("clipboard-copy",ji);var Vi=[["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"}]],_t=$("file",Vi);var $i=[["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"}]],Nt=$("loader",$i);var Xi=[["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"}]],Ot=$("paperclip",Xi);var Ki=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],Ut=$("square",Ki);var Qi=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Xe=$("x",Qi);import{useCallback as pl}from"react";import{useCallback as qe,useMemo as Ji,useRef as Zi,useState as wo}from"react";var Yi={damping:.7,stiffness:.05,mass:1.25},el=70,tl=1e3/60,al=350,ca=!1;globalThis.document?.addEventListener("mousedown",()=>{ca=!0});globalThis.document?.addEventListener("mouseup",()=>{ca=!1});globalThis.document?.addEventListener("click",()=>{ca=!1});var Ur=(e={})=>{let[t,a]=wo(!1),[o,r]=wo(e.initial!==!1),[s,n]=wo(!1),l=Zi(null);l.current=e;let i=qe(()=>{if(!ca)return!1;let w=window.getSelection();if(!w||!w.rangeCount)return!1;let m=w.getRangeAt(0);return m.commonAncestorContainer.contains(L.current)||L.current?.contains(m.commonAncestorContainer)},[]),u=qe(w=>{d.isAtBottom=w,r(w)},[]),f=qe(w=>{d.escapedFromLock=w,a(w)},[]),d=Ji(()=>{let w;return{escapedFromLock:t,isAtBottom:o,resizeDifference:0,accumulated:0,velocity:0,listeners:new Set,get scrollTop(){return L.current?.scrollTop??0},set scrollTop(m){L.current&&(L.current.scrollTop=m,d.ignoreScrollToTop=L.current.scrollTop)},get targetScrollTop(){return!L.current||!x.current?0:L.current.scrollHeight-1-L.current.clientHeight},get calculatedTargetScrollTop(){if(!L.current||!x.current)return 0;let{targetScrollTop:m}=this;if(!e.targetScrollTop)return m;if(w?.targetScrollTop===m)return w.calculatedScrollTop;let g=Math.max(Math.min(e.targetScrollTop(m,{scrollElement:L.current,contentElement:x.current}),m),0);return w={targetScrollTop:m,calculatedScrollTop:g},requestAnimationFrame(()=>{w=void 0}),g},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=el}}},[]),c=qe((w={})=>{typeof w=="string"&&(w={animation:w}),w.preserveScrollPosition||u(!0);let m=Date.now()+(Number(w.wait)||0),g=Lo(l.current,w.animation),{ignoreEscapes:C=!1}=w,b,y=d.calculatedTargetScrollTop;w.duration instanceof Promise?w.duration.finally(()=>{b=Date.now()}):b=m+(w.duration??0);let B=async()=>{let N=new Promise(requestAnimationFrame).then(()=>{if(!d.isAtBottom)return d.animation=void 0,!1;let{scrollTop:R}=d,k=performance.now(),P=(k-(d.lastTick??k))/tl;if(d.animation||(d.animation={behavior:g,promise:N,ignoreEscapes:C}),d.animation.behavior===g&&(d.lastTick=k),i()||m>Date.now())return B();if(R<Math.min(y,d.calculatedTargetScrollTop)){if(d.animation?.behavior===g){if(g==="instant")return d.scrollTop=d.calculatedTargetScrollTop,B();d.velocity=(g.damping*d.velocity+g.stiffness*d.scrollDifference)/g.mass,d.accumulated+=d.velocity*P,d.scrollTop+=d.accumulated,d.scrollTop!==R&&(d.accumulated=0)}return B()}return b>Date.now()?(y=d.calculatedTargetScrollTop,B()):(d.animation=void 0,d.scrollTop<d.calculatedTargetScrollTop?c({animation:Lo(l.current,l.current.resize),ignoreEscapes:C,duration:Math.max(0,b-Date.now())||void 0}):d.isAtBottom)});return N.then(R=>(requestAnimationFrame(()=>{d.animation||(d.lastTick=void 0,d.velocity=0)}),R))};return w.wait!==!0&&(d.animation=void 0),d.animation?.behavior===g?d.animation.promise:B()},[u,i,d]),p=qe(()=>{f(!0),u(!1)},[f,u]),h=qe(({target:w})=>{if(w!==L.current)return;let{scrollTop:m,ignoreScrollToTop:g}=d,{lastScrollTop:C=m}=d;d.lastScrollTop=m,d.ignoreScrollToTop=void 0,g&&g>m&&(C=g),n(d.isNearBottom),setTimeout(()=>{if(d.resizeDifference||m===g)return;if(i()){f(!0),u(!1);return}let b=m>C,y=m<C;if(d.animation?.ignoreEscapes){d.scrollTop=C;return}y&&(f(!0),u(!1)),b&&f(!1),!d.escapedFromLock&&d.isNearBottom&&u(!0)},1)},[f,u,i,d]),I=qe(({target:w,deltaY:m})=>{let g=w;for(;!["scroll","auto"].includes(getComputedStyle(g).overflow);){if(!g.parentElement)return;g=g.parentElement}g===L.current&&m<0&&L.current.scrollHeight>L.current.clientHeight&&!d.animation?.ignoreEscapes&&(f(!0),u(!1))},[f,u,d]),L=Or(w=>{L.current?.removeEventListener("scroll",h),L.current?.removeEventListener("wheel",I),w?.addEventListener("scroll",h,{passive:!0}),w?.addEventListener("wheel",I,{passive:!0})},[]),x=Or(w=>{if(d.resizeObserver?.disconnect(),!w)return;let m;d.resizeObserver=new ResizeObserver(([g])=>{let{height:C}=g.contentRect,b=C-(m??C);if(d.resizeDifference=b,d.scrollTop>d.targetScrollTop&&(d.scrollTop=d.targetScrollTop),n(d.isNearBottom),b>=0){let y=Lo(l.current,m?l.current.resize:l.current.initial);c({animation:y,wait:!0,preserveScrollPosition:!0,duration:y==="instant"?void 0:al})}else d.isNearBottom&&(f(!1),u(!0));m=C,requestAnimationFrame(()=>{setTimeout(()=>{d.resizeDifference===b&&(d.resizeDifference=0)},1)})}),d.resizeObserver?.observe(w)},[]);return{contentRef:x,scrollRef:L,scrollToBottom:c,stopScroll:p,isAtBottom:o||s,isNearBottom:s,escapedFromLock:t,state:d}};function Or(e,t){let a=qe(o=>(a.current=o,e(o)),t);return a}var xo=new Map;function Lo(...e){let t={...Yi},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)}import*as Ke from"react";import{createContext as ol,useContext as rl,useEffect as sl,useImperativeHandle as nl,useLayoutEffect as il,useMemo as ll,useRef as ul}from"react";var Hr=ol(null),dl=typeof window<"u"?il:sl;function Ht({instance:e,children:t,resize:a,initial:o,mass:r,damping:s,stiffness:n,targetScrollTop:l,contextRef:i,...u}){let f=ul(null),d=Ke.useCallback((C,b)=>(g?.targetScrollTop??l)?.(C,b)??C,[l]),c=Ur({mass:r,damping:s,stiffness:n,resize:a,initial:o,targetScrollTop:d}),{scrollRef:p,contentRef:h,scrollToBottom:I,stopScroll:L,isAtBottom:x,escapedFromLock:w,state:m}=e??c,g=ll(()=>({scrollToBottom:I,stopScroll:L,scrollRef:p,isAtBottom:x,escapedFromLock:w,contentRef:h,state:m,get targetScrollTop(){return f.current},set targetScrollTop(C){f.current=C}}),[I,x,h,p,L,w,m]);return nl(i,()=>g,[g]),dl(()=>{p.current&&getComputedStyle(p.current).overflow==="visible"&&(p.current.style.overflow="auto")},[]),Ke.createElement(Hr.Provider,{value:g},Ke.createElement("div",{...u},typeof t=="function"?t(g):t))}(function(e){function t({children:a,scrollClassName:o,...r}){let s=Co();return Ke.createElement("div",{ref:s.scrollRef,style:{height:"100%",width:"100%",scrollbarGutter:"stable both-edges"},className:o},Ke.createElement("div",{...r,ref:s.contentRef},typeof a=="function"?a(s):a))}e.Content=t})(Ht||(Ht={}));function Co(){let e=rl(Hr);if(!e)throw new Error("use-stick-to-bottom component context must be used within a StickToBottom component");return e}var fl=yr({prefix:"ww"});function T(...e){return fl(Sr(e))}import{jsx as cl}from"react/jsx-runtime";var Te=({className:e,variant:t="default",size:a="default",type:o="button",...r})=>cl("button",{type:o,className:T("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 pa}from"react/jsx-runtime";var ma=({className:e,...t})=>pa(Ht,{className:T("ww:relative ww:flex-1 ww:overflow-y-hidden",e),initial:"smooth",resize:"smooth",role:"log",...t}),ha=({className:e,...t})=>pa(Ht.Content,{className:T("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}),ga=({className:e,...t})=>{let{isAtBottom:a,scrollToBottom:o}=Co(),r=pl(()=>{o()},[o]);return!a&&pa(Te,{className:T("ww:absolute ww:bottom-4 ww:left-[50%] ww:translate-x-[-50%] ww:rounded-full",e),onClick:r,size:"icon",variant:"outline",...t,children:pa($e,{className:"ww:size-4"})})};import Gr from"crypto";var qr="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var ml=128,Qe,dt,hl=e=>{!Qe||Qe.length<e?(Qe=Buffer.allocUnsafe(e*ml),Gr.randomFillSync(Qe),dt=0):dt+e>Qe.length&&(Gr.randomFillSync(Qe),dt=0),dt+=e};var qt=(e=21)=>{hl(e|=0);let t="";for(let a=dt-e;a<dt;a++)t+=qr[Qe[a]&63];return t};import{createContext as gl,useCallback as Ee,useContext as wl,useEffect as Io,useMemo as xl,useRef as So,useState as Wr}from"react";import{jsx as ve,jsxs as Vr}from"react/jsx-runtime";var Ll=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}},zr=gl(null),jr=()=>{let e=wl(zr);if(!e)throw new Error("usePromptInputAttachments must be used within a PromptInput");return e},ft=({className:e,accept:t,multiple:a,globalDrop:o,maxFiles:r,maxFileSize:s,onSubmit:n,children:l,...i})=>{let u=So(null),f=So(null),[d,c]=Wr([]),p=So(d);Io(()=>{p.current=d},[d]);let h=Ee(()=>{u.current?.click()},[]),I=Ee(C=>{let b=[...C];if(b.length===0)return;let y=N=>s?N.size<=s:!0,B=b.filter(y);c(N=>{let R=typeof r=="number"?Math.max(0,r-N.length):void 0,k=typeof R=="number"?B.slice(0,R):B;return[...N,...k.map(P=>({filename:P.name,id:qt(),mediaType:P.type,type:"file",url:URL.createObjectURL(P)}))]})},[r,s]),L=Ee(C=>{c(b=>{let y=b.find(B=>B.id===C);return y?.url&&URL.revokeObjectURL(y.url),b.filter(B=>B.id!==C)})},[]),x=Ee(()=>{c(C=>{for(let b of C)b.url&&URL.revokeObjectURL(b.url);return[]})},[]);Io(()=>()=>{for(let C of p.current)C.url&&URL.revokeObjectURL(C.url)},[]);let w=Ee(C=>{C.currentTarget.files&&I(C.currentTarget.files),C.currentTarget.value=""},[I]);Io(()=>{if(!o)return;let C=y=>{y.dataTransfer?.types?.includes("Files")&&y.preventDefault()},b=y=>{y.dataTransfer?.types?.includes("Files")&&y.preventDefault(),y.dataTransfer?.files&&y.dataTransfer.files.length>0&&I(y.dataTransfer.files)};return document.addEventListener("dragover",C),document.addEventListener("drop",b),()=>{document.removeEventListener("dragover",C),document.removeEventListener("drop",b)}},[I,o]);let m=Ee(async C=>{C.preventDefault();let b=C.currentTarget,B=new FormData(b).get("message")||"";b.reset();let N=await Promise.all(d.map(async({id:R,...k})=>{if(k.url?.startsWith("blob:")){let P=await Ll(k.url);return{...k,url:P??k.url}}return k}));try{let R=n({files:N,text:B},C);R instanceof Promise&&await R,x()}catch{}},[d,n,x]),g=xl(()=>({add:I,clear:x,files:d,openFileDialog:h,remove:L}),[d,I,L,x,h]);return Vr(zr.Provider,{value:g,children:[ve("input",{accept:t,"aria-label":"Upload files",className:"ww:hidden",multiple:a,onChange:w,ref:u,title:"Upload files",type:"file"}),ve("form",{className:T("ww:flex ww:w-full ww:flex-col ww:rounded-lg ww:border ww:border-border ww:bg-background",e),onSubmit:m,ref:f,...i,children:l})]})};var ct=({onChange:e,onKeyDown:t,className:a,placeholder:o="What would you like to know?",...r})=>{let s=jr(),[n,l]=Wr(!1),i=Ee(f=>{if(t?.(f),!f.defaultPrevented){if(f.key==="Enter"){if(n||f.nativeEvent.isComposing||f.shiftKey)return;f.preventDefault();let{form:d}=f.currentTarget;if(d?.querySelector('button[type="submit"]')?.disabled)return;d?.requestSubmit()}if(f.key==="Backspace"&&f.currentTarget.value===""&&s.files.length>0){f.preventDefault();let d=s.files.at(-1);d&&s.remove(d.id)}}},[t,n,s]),u=Ee(f=>{let d=f.clipboardData?.items;if(!d)return;let c=[];for(let p of d)if(p.kind==="file"){let h=p.getAsFile();h&&c.push(h)}c.length>0&&(f.preventDefault(),s.add(c))},[s]);return ve("textarea",{className:T("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})},pt=({className:e,status:t,onStop:a,onClick:o,children:r,...s})=>{let n=t==="submitted"||t==="streaming",l=ve(Rt,{className:"ww:size-4"});t==="submitted"?l=ve(Nt,{className:"ww:size-4 ww:animate-spin"}):t==="streaming"&&(l=ve(Ut,{className:"ww:size-4"}));let i=Ee(u=>{if(n&&a){u.preventDefault(),a();return}o?.(u)},[n,a,o]);return ve(Te,{"aria-label":n?"Stop":"Submit",className:T("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})},mt=({className:e,children:t,...a})=>{let o=jr();return o.files.length>0?Vr(Te,{className:T("ww:group ww:relative",e),onClick:()=>o.clear(),size:"icon-sm",type:"button",variant:"ghost","aria-label":"Remove all attachments",...a,children:[ve("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}),ve(Xe,{className:"ww:absolute ww:size-4 ww:opacity-0 ww:transition-opacity ww:group-hover:opacity-100"})]}):ve(Te,{className:T(e),onClick:()=>o.openFileDialog(),size:"icon-sm",type:"button",variant:"ghost",...a,children:t??ve(Ot,{className:"ww:size-4"})})};import{memo as Cl,useCallback as Il}from"react";import{jsx as ht}from"react/jsx-runtime";var $r=({className:e,...t})=>ht("div",{className:T("ww:flex ww:flex-col ww:gap-1 ww:px-3 ww:py-2",e),...t}),Xr=({className:e,...t})=>ht("li",{className:T("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}),Kr=({className:e,...t})=>ht("span",{className:T("ww:inline-block ww:size-2 ww:shrink-0 ww:rounded-full ww:border ww:border-muted-foreground/50",e),...t}),Qr=({className:e,...t})=>ht("span",{className:T("ww:line-clamp-1 ww:grow ww:break-words ww:text-muted-foreground",e),...t}),Jr=({className:e,...t})=>ht("div",{className:T("ww:flex ww:shrink-0 ww:gap-1 ww:opacity-0 ww:transition-opacity ww:group-hover:opacity-100",e),...t}),Zr=({className:e,...t})=>ht(Te,{className:T("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 Je,jsxs as yo}from"react/jsx-runtime";var Yr=Cl(({message:e,onRemove:t})=>{let a=Il(()=>t(e.id),[t,e.id]);return yo(Xr,{children:[Je(Kr,{}),Je(Qr,{children:e.text||"(attachment)"}),Je(Jr,{children:Je(Zr,{"aria-label":"Remove from queue",onClick:a,children:Je(Xe,{className:"ww:size-3"})})})]})});Yr.displayName="ChatQueueItem";function gt({queuedMessages:e,onRemove:t,className:a}){return e.length===0?null:yo($r,{className:T("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"]}),Je("ul",{children:e.map(o=>Je(Yr,{message:o,onRemove:t},o.id))})]})}import{useState as es}from"react";import{jsx as Sl}from"react/jsx-runtime";function wa({messages:e,evalEnabled:t,api:a="/api/waniwani"}){let[o,r]=es(!1),[s,n]=es(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 f=await fetch(`${a}/scenarios`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(u)});if(!f.ok)throw new Error(`${f.status}`);n("saved")}catch{n("error")}finally{r(!1),setTimeout(()=>n(null),2e3)}};return!t||e.length===0?null:Sl("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"})}import{jsx as Gt,jsxs as kl}from"react/jsx-runtime";var ts=({files:e,className:t,...a})=>e.length===0?null:Gt("div",{className:T("ww:flex ww:flex-wrap ww:gap-1.5",t),...a,children:e.map((o,r)=>Gt(yl,{file:o},r))});function yl({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"}):kl("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(_t,{className:"ww:size-3 ww:shrink-0"}),Gt("span",{className:"ww:max-w-24 ww:truncate",children:e.filename??"file"})]})}import{jsx as as}from"react/jsx-runtime";var ko=({className:e,size:t=5,...a})=>as("div",{className:T("ww:flex ww:items-center ww:gap-1",e),...a,children:[0,1,2].map(o=>as("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))});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};var Re={attentionSideAfter:2,attentionSideBefore:1,atxHeadingOpeningFenceSizeMax:6,autolinkDomainSizeMax:63,autolinkSchemeSizeMax:32,cdataOpeningString:"CDATA[",characterGroupPunctuation:2,characterGroupWhitespace:1,characterReferenceDecimalSizeMax:7,characterReferenceHexadecimalSizeMax:6,characterReferenceNamedSizeMax:31,codeFencedSequenceSizeMin:3,contentTypeContent:"content",contentTypeDocument:"document",contentTypeFlow:"flow",contentTypeString:"string",contentTypeText:"text",hardBreakPrefixSizeMin:2,htmlBasic:6,htmlCdata:5,htmlComment:2,htmlComplete:7,htmlDeclaration:4,htmlInstruction:3,htmlRawSizeMax:8,htmlRaw:1,linkResourceDestinationBalanceMax:32,linkReferenceSizeMax:999,listItemValueSizeMax:10,numericBaseDecimal:10,numericBaseHexadecimal:16,tabSize:4,thematicBreakMarkerCountMin:3,v8MaxSafeChunkSize:1e4};var Ce={data:"data",whitespace:"whitespace",lineEnding:"lineEnding",lineEndingBlank:"lineEndingBlank",linePrefix:"linePrefix",lineSuffix:"lineSuffix",atxHeading:"atxHeading",atxHeadingSequence:"atxHeadingSequence",atxHeadingText:"atxHeadingText",autolink:"autolink",autolinkEmail:"autolinkEmail",autolinkMarker:"autolinkMarker",autolinkProtocol:"autolinkProtocol",characterEscape:"characterEscape",characterEscapeValue:"characterEscapeValue",characterReference:"characterReference",characterReferenceMarker:"characterReferenceMarker",characterReferenceMarkerNumeric:"characterReferenceMarkerNumeric",characterReferenceMarkerHexadecimal:"characterReferenceMarkerHexadecimal",characterReferenceValue:"characterReferenceValue",codeFenced:"codeFenced",codeFencedFence:"codeFencedFence",codeFencedFenceSequence:"codeFencedFenceSequence",codeFencedFenceInfo:"codeFencedFenceInfo",codeFencedFenceMeta:"codeFencedFenceMeta",codeFlowValue:"codeFlowValue",codeIndented:"codeIndented",codeText:"codeText",codeTextData:"codeTextData",codeTextPadding:"codeTextPadding",codeTextSequence:"codeTextSequence",content:"content",definition:"definition",definitionDestination:"definitionDestination",definitionDestinationLiteral:"definitionDestinationLiteral",definitionDestinationLiteralMarker:"definitionDestinationLiteralMarker",definitionDestinationRaw:"definitionDestinationRaw",definitionDestinationString:"definitionDestinationString",definitionLabel:"definitionLabel",definitionLabelMarker:"definitionLabelMarker",definitionLabelString:"definitionLabelString",definitionMarker:"definitionMarker",definitionTitle:"definitionTitle",definitionTitleMarker:"definitionTitleMarker",definitionTitleString:"definitionTitleString",emphasis:"emphasis",emphasisSequence:"emphasisSequence",emphasisText:"emphasisText",escapeMarker:"escapeMarker",hardBreakEscape:"hardBreakEscape",hardBreakTrailing:"hardBreakTrailing",htmlFlow:"htmlFlow",htmlFlowData:"htmlFlowData",htmlText:"htmlText",htmlTextData:"htmlTextData",image:"image",label:"label",labelText:"labelText",labelLink:"labelLink",labelImage:"labelImage",labelMarker:"labelMarker",labelImageMarker:"labelImageMarker",labelEnd:"labelEnd",link:"link",paragraph:"paragraph",reference:"reference",referenceMarker:"referenceMarker",referenceString:"referenceString",resource:"resource",resourceDestination:"resourceDestination",resourceDestinationLiteral:"resourceDestinationLiteral",resourceDestinationLiteralMarker:"resourceDestinationLiteralMarker",resourceDestinationRaw:"resourceDestinationRaw",resourceDestinationString:"resourceDestinationString",resourceMarker:"resourceMarker",resourceTitle:"resourceTitle",resourceTitleMarker:"resourceTitleMarker",resourceTitleString:"resourceTitleString",setextHeading:"setextHeading",setextHeadingText:"setextHeadingText",setextHeadingLine:"setextHeadingLine",setextHeadingLineSequence:"setextHeadingLineSequence",strong:"strong",strongSequence:"strongSequence",strongText:"strongText",thematicBreak:"thematicBreak",thematicBreakSequence:"thematicBreakSequence",blockQuote:"blockQuote",blockQuotePrefix:"blockQuotePrefix",blockQuoteMarker:"blockQuoteMarker",blockQuotePrefixWhitespace:"blockQuotePrefixWhitespace",listOrdered:"listOrdered",listUnordered:"listUnordered",listItemIndent:"listItemIndent",listItemMarker:"listItemMarker",listItemPrefix:"listItemPrefix",listItemPrefixWhitespace:"listItemPrefixWhitespace",listItemValue:"listItemValue",chunkDocument:"chunkDocument",chunkContent:"chunkContent",chunkFlow:"chunkFlow",chunkText:"chunkText",chunkString:"chunkString"};function os(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 rs(e){return e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510}function ss(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 ns(e){return os(e)?"ambiguous":rs(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":ss(e)?"wide":"neutral"}function bl(e){if(!Number.isSafeInteger(e))throw new TypeError(`Expected a code point, got \`${typeof e}\`.`)}function is(e){return bl(e),ns(e)}var Tl=Object.defineProperty,Pl=(e,t,a)=>t in e?Tl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,Al=(e,t,a)=>Pl(e,typeof t!="symbol"?t+"":t,a);function vl(e){return/^\p{Emoji_Presentation}/u.test(String.fromCodePoint(e))}function Ml(e){if(!e||e<4352)return!1;switch(is(e)){case"fullwidth":case"halfwidth":return!0;case"wide":return!vl(e);case"narrow":return!1;case"ambiguous":return 917760<=e&&e<=917999?null:!1;case"neutral":return/^\p{sc=Hangul}/u.test(String.fromCodePoint(e))}}function Rl(e,t){return t!==65025||!e||e<8216?!1:e===8216||e===8217||e===8220||e===8221}function Fl(e){return e!==null&&e>=65024&&e<=65038}var Bl=ls(/\p{P}|\p{S}/u),Dl=ls(/\s/);function ls(e){return t;function t(a){return a!==null&&a>-1&&e.test(String.fromCodePoint(a))}}var Ie;(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})(Ie||(Ie={}));function Ge(e){if(e===de.eof||kr(e)||Dl(e))return Re.characterGroupWhitespace;let t=0;if(e>=4352){if(Fl(e))return Ie.nonEmojiGeneralUseVS;switch(Ml(e)){case null:return Ie.ivs;case!0:t|=Ie.cjk;break}}return Bl(e)&&(t|=Re.characterGroupPunctuation),t}function xa(e,t,a){if(!_l(e))return e;let o=t(),r=Ge(o);return!o||Ze(r)?e:Rl(o,a)?Ie.cjkPunctuation:El(r)}function El(e){return e&~Ie.ivs}function Ze(e){return!!(e&Re.characterGroupWhitespace)}function wt(e){return(e&Ie.cjkPunctuation)===Re.characterGroupPunctuation}function Wt(e){return!!(e&Ie.cjk)}function us(e){return e===Ie.ivs}function ds(e){return!!(e&Ie.cjkOrIvs)}function _l(e){return e===Ie.nonEmojiGeneralUseVS}function bo(e){return!!(e&Ie.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 Nl(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,Al(this,"cachedValue")}value(){return this.cachedValue===void 0&&(this.cachedValue=Nl(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:Ol,tokenize:Ul};function Ol(e,t){let a=-1,o,r,s,n,l,i,u,f;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},c={...e[a][1].start};fs(d,-i),fs(c,i),n={type:i>1?Ce.strongSequence:Ce.emphasisSequence,start:d,end:{...e[o][1].end}},l={type:i>1?Ce.strongSequence:Ce.emphasisSequence,start:{...e[a][1].start},end:c},s={type:i>1?Ce.strongText:Ce.emphasisText,start:{...e[o][1].end},end:{...e[a][1].start}},r={type:i>1?Ce.strong:Ce.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=lt(u,[["enter",e[o][1],t],["exit",e[o][1],t]])),u=lt(u,[["enter",r,t],["enter",n,t],["exit",n,t],["enter",s,t]]),t.parser.constructs.insideSpan.null,u=lt(u,ua(t.parser.constructs.insideSpan.null,e.slice(o+1,a),t)),u=lt(u,[["exit",s,t],["enter",l,t],["exit",l,t],["exit",r,t]]),e[a][1].end.offset-e[a][1].start.offset?(f=2,u=lt(u,[["enter",e[a][1],t],["exit",e[a][1],t]])):f=0,it(e,o-1,a-o+3,u),a=o+u.length-f-2;break}}for(a=-1;++a<e.length;)e[a][1].type==="attentionSequence"&&(e[a][1].type="data");return e}function Ul(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=Ge(n),i=new Sa(n,o(),r),u=xa(l,i.value.bind(i),n),f;return d;function d(p){return p===de.asterisk||de.underscore,f=p,e.enter("attentionSequence"),c(p)}function c(p){if(p===f)return e.consume(p),c;let h=e.exit("attentionSequence"),I=La(p)?ya(p,o(),r):p,L=Ge(I);let x=wt(u),w=x||Ze(u),m=wt(L),g=m||Ze(L),C=ds(u),b=!g||m&&(w||C)||a.includes(p),y=!w||x&&(g||Wt(L))||a.includes(n);return h._open=!!(f===de.asterisk?b:b&&(bo(u)||!y)),h._close=!!(f===de.asterisk?y:y&&(bo(L)||!b)),t(p)}}function fs(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}function cs(){return{text:{[de.asterisk]:To,[de.underscore]:To},insideSpan:{null:[To]}}}function ps(){let e=this.data();(e.micromarkExtensions||(e.micromarkExtensions=[])).push(cs())}function ms(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 f={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)},c=[["enter",f,l],["enter",n[u][1],l],["exit",n[u][1],l],["enter",d,l]],p=l.parser.constructs.insideSpan.null;p&&it(c,c.length,0,ua(p,n.slice(u+1,i),l)),it(c,c.length,0,[["exit",d,l],["enter",n[i][1],l],["exit",n[i][1],l],["exit",f,l]]),it(n,u-1,i-u+3,c),i=u+c.length-2;break}}for(i=-1;++i<n.length;)n[i][1].type==="strikethroughSequenceTemporary"&&(n[i][1].type=Ce.data);return n}function s(n,l,i){let{now:u,sliceSerialize:f,previous:d}=this,c=Ca(d)?Ia(d,u(),f):d,p=Ge(c),h=new Sa(c,u(),f),I=xa(p,h.value.bind(h),c),L=this.events,x=0;return w;function w(g){return de.tilde,c===de.tilde&&L[L.length-1][1].type!==Ce.characterEscape?i(g):(n.enter("strikethroughSequenceTemporary"),m(g))}function m(g){let C=Ge(c);if(g===de.tilde)return x>1?i(g):(n.consume(g),x++,m);if(x<2&&!a)return i(g);let b=n.exit("strikethroughSequenceTemporary"),y=La(g)?ya(g,u(),f):g,B=Ge(y),R=wt(I)||Ze(I),P=wt(B)||Ze(B),Y=Wt(I)||us(C);return b._open=!P||B===Re.attentionSideAfter&&(R||Y),b._close=!R||C===Re.attentionSideAfter&&(P||Wt(B)),l(g)}}}function hs(e){let t=this.data();(t.micromarkExtensions||(t.micromarkExtensions=[])).push(ms(e))}var Hl=new Set(["\u3002","\uFF0E","\uFF0C","\u3001","\uFF1F","\uFF01","\uFF1A","\uFF1B","\uFF08","\uFF09","\u3010","\u3011","\u300C","\u300D","\u300E","\u300F","\u3008","\u3009","\u300A","\u300B"]),ql=/^(https?:\/\/|mailto:|www\.)/i,Gl=e=>{if(e.children.length!==1)return!1;let t=e.children[0];return t.type==="text"&&t.value===e.url},Wl=e=>{let t=0;for(let a of e){if(Hl.has(a))return t;t+=a.length}return null},zl=(e,t)=>({...t,url:e,children:[{type:"text",value:e}]}),jl=e=>({type:"text",value:e}),Vl=()=>e=>{br(e,"link",(t,a,o)=>{if(!o||typeof a!="number"||!Gl(t)||!ql.test(t.url))return;let r=Wl(t.url);if(r===null||r===0)return;let s=t.url.slice(0,r),n=t.url.slice(r),l=zl(s,t),i=jl(n);return o.children.splice(a,1,l,i),a+1})};function $l(){let e=[ps],t=[Vl,hs],a=[...e,...t];return{name:"cjk",type:"cjk",remarkPluginsBefore:e,remarkPluginsAfter:t,remarkPlugins:a}}var gs=$l();var K=class extends Error{constructor(t){super(t),this.name="ShikiError"}};function Xl(e){return _o(e)}function _o(e){return Array.isArray(e)?Kl(e):e instanceof RegExp?e:typeof e=="object"?Ql(e):e}function Kl(e){let t=[];for(let a=0,o=e.length;a<o;a++)t[a]=_o(e[a]);return t}function Ql(e){let t={};for(let a in e)t[a]=_o(e[a]);return t}function bs(e,...t){return t.forEach(a=>{for(let o in a)e[o]=a[o]}),e}function Ts(e){let t=~e.lastIndexOf("/")||~e.lastIndexOf("\\");return t===0?e:~t===e.length-1?Ts(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 Ps(e,t){return e<t?-1:e>t?1:0}function As(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=Ps(e[r],t[r]);if(s!==0)return s}return 0}return a-o}function ws(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 vs(e){return e.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var Ms=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}},Vt=class{constructor(e,t,a){this._colorMap=e,this._defaults=t,this._root=a}static createFromRawTheme(e,t){return this.createFromParsedTheme(Yl(e),t)}static createFromParsedTheme(e,t){return tu(e,t)}_cachedMatchRoot=new Ms(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=>Jl(e.parent,r.parentScopes));return o?new Rs(o.fontStyle,o.foreground,o.background):null}},Ao=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 Jl(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&&!Zl(e.scopeName,o);){if(r)return!1;e=e.parent}if(!e)return!1;e=e.parent}return!0}function Zl(e,t){return t===e||e.startsWith(t)&&e[t.length]==="."}var Rs=class{constructor(e,t,a){this.fontStyle=e,this.foregroundId=t,this.backgroundId=a}};function Yl(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 c=0,p=d.length;c<p;c++)switch(d[c]){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"&&ws(n.settings.foreground)&&(u=n.settings.foreground);let f=null;typeof n.settings.background=="string"&&ws(n.settings.background)&&(f=n.settings.background);for(let d=0,c=l.length;d<c;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 eu(I,L,r,i,u,f)}}return a}var eu=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}},fe=(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))(fe||{});function tu(e,t){e.sort((i,u)=>{let f=Ps(i.scope,u.scope);return f!==0||(f=As(i.parentScopes,u.parentScopes),f!==0)?f: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 au(t),n=new Rs(a,s.getId(o),s.getId(r)),l=new ru(new Mo(0,null,-1,0,0),[]);for(let i=0,u=e.length;i<u;i++){let f=e[i];l.insert(0,f.scope,f.parentScopes,f.fontStyle,s.getId(f.foreground),s.getId(f.background))}return new Vt(s,n,l)}var au=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)}},ou=Object.freeze([]),Mo=class Fs{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(t,a,o,r,s){this.scopeDepth=t,this.parentScopes=a||ou,this.fontStyle=o,this.foreground=r,this.background=s}clone(){return new Fs(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)}},ru=class Ro{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(Ro._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 f;this._children.hasOwnProperty(i)?f=this._children[i]:(f=new Ro(this._mainRule.clone(),Mo.cloneArr(this._rulesWithParentScopes)),this._children[i]=f),f.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(As(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 Mo(t,a,o,r,s))}},et=class Pe{static toBinaryStr(t){return t.toString(2).padStart(32,"0")}static print(t){let a=Pe.getLanguageId(t),o=Pe.getTokenType(t),r=Pe.getFontStyle(t),s=Pe.getForeground(t),n=Pe.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=Pe.getLanguageId(t),u=Pe.getTokenType(t),f=Pe.containsBalancedBrackets(t)?1:0,d=Pe.getFontStyle(t),c=Pe.getForeground(t),p=Pe.getBackground(t);return a!==0&&(i=a),o!==8&&(u=o),r!==null&&(f=r?1:0),s!==-1&&(d=s),n!==0&&(c=n),l!==0&&(p=l),(i<<0|u<<8|f<<10|d<<11|c<<15|p<<24)>>>0}};function Pa(e,t){let a=[],o=su(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(xs(r)){let i=[];do i.push(r),r=o.next();while(xs(r));return u=>t(i,u)}return null}function n(){let i=[],u=s();for(;u;)i.push(u),u=s();return f=>i.every(d=>d(f))}function l(){let i=[],u=n();for(;u&&(i.push(u),r==="|"||r===",");){do r=o.next();while(r==="|"||r===",");u=n()}return f=>i.some(d=>d(f))}}function xs(e){return!!e&&!!e.match(/[\w\.:]+/)}function su(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 Bs(e){typeof e.dispose=="function"&&e.dispose()}var $t=class{constructor(e){this.scopeName=e}toKey(){return this.scopeName}},nu=class{constructor(e,t){this.scopeName=e,this.ruleName=t}toKey(){return`${this.scopeName}#${this.ruleName}`}},iu=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))}},lu=class{constructor(e,t){this.repo=e,this.initialScopeName=t,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new $t(this.initialScopeName)]}seenFullScopeRequests=new Set;seenPartialScopeRequests=new Set;Q;processQueue(){let e=this.Q;this.Q=[];let t=new iu;for(let a of e)uu(a,this.initialScopeName,this.repo,t);for(let a of t.references)if(a instanceof $t){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 uu(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 $t?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 $t(l))}function Fo(e,t,a){if(t.repository&&t.repository[e]){let o=t.repository[e];Aa([o],t,a)}}function Ta(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?bs({},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=Ds(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 nu(n.scopeName,n.ruleName)):a.add(new $t(n.scopeName));break}}}var du=class{kind=0},fu=class{kind=1},cu=class{constructor(e){this.ruleName=e}kind=2},pu=class{constructor(e){this.scopeName=e}kind=3},mu=class{constructor(e,t){this.scopeName=e,this.ruleName=t}kind=4};function Ds(e){if(e==="$base")return new du;if(e==="$self")return new fu;let t=e.indexOf("#");if(t===-1)return new pu(e);if(t===0)return new cu(e.substring(1));{let a=e.substring(0,t),o=e.substring(t+1);return new mu(a,o)}}var hu=/\\(\d+)/,Ls=/\\(\d+)/g;var gu=-1,Es=-2;var Qt=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?`${Ts(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)}},wu=class extends Qt{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!")}},xu=class extends Qt{_match;captures;_cachedCompiledPatterns;constructor(e,t,a,o,r){super(e,t,a,null),this._match=new Xt(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 Kt,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Cs=class extends Qt{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 Kt,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Bo=class extends Qt{_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 Xt(r,this.id),this.beginCaptures=s,this._end=new Xt(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 Kt;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}},va=class extends Qt{_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 Xt(r,this.id),this.beginCaptures=s,this.whileCaptures=l,this._while=new Xt(n,Es),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 Kt;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 Kt,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,t||"\uFFFF"),this._cachedCompiledWhilePatterns}},_s=class me{static createCaptureRule(t,a,o,r,s){return t.registerRule(n=>new wu(a,n,o,r,s))}static getCompiledRuleId(t,a,o){return t.id||a.registerRule(r=>{if(t.id=r,t.match)return new xu(t.$vscodeTextmateLocation,t.id,t.name,t.match,me._compileCaptures(t.captures,a,o));if(typeof t.begin>"u"){t.repository&&(o=bs({},o,t.repository));let s=t.patterns;return typeof s>"u"&&t.include&&(s=[{include:t.include}]),new Cs(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,me._compilePatterns(s,a,o))}return t.while?new va(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,me._compileCaptures(t.beginCaptures||t.captures,a,o),t.while,me._compileCaptures(t.whileCaptures||t.captures,a,o),me._compilePatterns(t.patterns,a,o)):new Bo(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,me._compileCaptures(t.beginCaptures||t.captures,a,o),t.end,me._compileCaptures(t.endCaptures||t.captures,a,o),t.applyEndPatternLast,me._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=me.getCompiledRuleId(t[n],a,o)),r[l]=me.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=Ds(l.include);switch(u.kind){case 0:case 1:i=me.getCompiledRuleId(o[l.include],a,o);break;case 2:let f=o[u.ruleName];f&&(i=me.getCompiledRuleId(f,a,o));break;case 3:case 4:let d=u.scopeName,c=u.kind===4?u.ruleName:null,p=a.getExternalGrammar(d,o);if(p)if(c){let h=p.repository[c];h&&(i=me.getCompiledRuleId(h,a,p.repository))}else i=me.getCompiledRuleId(p.repository.$self,a,p.repository);break}}else i=me.getCompiledRuleId(l,a,o);if(i!==-1){let u=a.getRule(i),f=!1;if((u instanceof Cs||u instanceof Bo||u instanceof va)&&u.hasMissingPatterns&&u.patterns.length===0&&(f=!0),f)continue;r.push(i)}}return{patterns:r,hasMissingPatterns:(t?t.length:0)!==r.length}}},Xt=class Ns{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=hu.test(this.source):this.hasBackReferences=!1}clone(){return new Ns(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 Ls.lastIndex=0,this.source.replace(Ls,(r,s)=>vs(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}},Kt=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 Is(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 Is(e,o,this._items.map(r=>r.ruleId))}},Is=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(`
3
- `)}findNextMatchSync(e,t,a){let o=this.scanner.findNextMatchSync(e,t,a);return o?{ruleId:this.rules[o.index],captureIndices:o.captureIndices}:null}},vo=class{constructor(e,t){this.languageId=e,this.tokenType=t}},Lu=class Do{_defaultAttributes;_embeddedLanguagesMatcher;constructor(t,a){this._defaultAttributes=new vo(t,8),this._embeddedLanguagesMatcher=new Cu(Object.entries(a||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(t){return t===null?Do._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(t)}static _NULL_SCOPE_METADATA=new vo(0,0);_getBasicScopeAttributes=new Ms(t=>{let a=this._scopeToLanguage(t),o=this._toStandardTokenType(t);return new vo(a,o)});_scopeToLanguage(t){return this._embeddedLanguagesMatcher.match(t)||0}_toStandardTokenType(t){let a=t.match(Do.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/},Cu=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])=>vs(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])}},Xh={InDebugMode:typeof process<"u"&&!!process.env.VSCODE_TEXTMATE_DEBUG},Os=!1,Ss=class{constructor(e,t){this.stack=e,this.stoppedEarly=t}};function Us(e,t,a,o,r,s,n,l){let i=t.content.length,u=!1,f=-1;if(n){let p=Iu(e,t,a,o,r,s);r=p.stack,o=p.linePos,a=p.isFirstLine,f=p.anchorPosition}let d=Date.now();for(;!u;){if(l!==0&&Date.now()-d>l)return new Ss(r,!0);c()}return new Ss(r,!1);function c(){let p=Su(e,t,a,o,r,f);if(!p){s.produce(r,i),u=!0;return}let h=p.captureIndices,I=p.matchedRuleId,L=h&&h.length>0?h[0].end>o:!1;if(I===gu){let x=r.getRule(e);s.produce(r,h[0].start),r=r.withContentNameScopesList(r.nameScopesList),zt(e,t,a,r,s,x.endCaptures,h),s.produce(r,h[0].end);let w=r;if(r=r.parent,f=w.getAnchorPos(),!L&&w.getEnterPos()===o){r=w,s.produce(r,i),u=!0;return}}else{let x=e.getRule(I);s.produce(r,h[0].start);let w=r,m=x.getName(t.content,h),g=r.contentNameScopesList.pushAttributed(m,e);if(r=r.push(I,o,f,h[0].end===i,null,g,g),x instanceof Bo){let C=x;zt(e,t,a,r,s,C.beginCaptures,h),s.produce(r,h[0].end),f=h[0].end;let b=C.getContentName(t.content,h),y=g.pushAttributed(b,e);if(r=r.withContentNameScopesList(y),C.endHasBackReferences&&(r=r.withEndRule(C.getEndWithResolvedBackReferences(t.content,h))),!L&&w.hasSameRuleAs(r)){r=r.pop(),s.produce(r,i),u=!0;return}}else if(x instanceof va){let C=x;zt(e,t,a,r,s,C.beginCaptures,h),s.produce(r,h[0].end),f=h[0].end;let b=C.getContentName(t.content,h),y=g.pushAttributed(b,e);if(r=r.withContentNameScopesList(y),C.whileHasBackReferences&&(r=r.withEndRule(C.getWhileWithResolvedBackReferences(t.content,h))),!L&&w.hasSameRuleAs(r)){r=r.pop(),s.produce(r,i),u=!0;return}}else if(zt(e,t,a,r,s,x.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 Iu(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 va&&l.push({rule:u,stack:i})}for(let i=l.pop();i;i=l.pop()){let{ruleScanner:u,findOptions:f}=bu(i.rule,e,i.stack.endRule,a,o===n),d=u.findNextMatchSync(t,o,f);if(d){if(d.ruleId!==Es){r=i.stack.pop();break}d.captureIndices&&d.captureIndices.length&&(s.produce(i.stack,d.captureIndices[0].start),zt(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 Su(e,t,a,o,r,s){let n=yu(e,t,a,o,r,s),l=e.getInjections();if(l.length===0)return n;let i=ku(l,e,t,a,o,r,s);if(!i)return n;if(!n)return i;let u=n.captureIndices[0].start,f=i.captureIndices[0].start;return f<u||i.priorityMatch&&f===u?i:n}function yu(e,t,a,o,r,s){let n=r.getRule(e),{ruleScanner:l,findOptions:i}=Hs(n,e,r.endRule,a,o===s),u=l.findNextMatchSync(t,o,i);return u?{captureIndices:u.captureIndices,matchedRuleId:u.ruleId}:null}function ku(e,t,a,o,r,s,n){let l=Number.MAX_VALUE,i=null,u,f=0,d=s.contentNameScopesList.getScopeNames();for(let c=0,p=e.length;c<p;c++){let h=e[c];if(!h.matcher(d))continue;let I=t.getRule(h.ruleId),{ruleScanner:L,findOptions:x}=Hs(I,t,null,o,r===n),w=L.findNextMatchSync(a,r,x);if(!w)continue;let m=w.captureIndices[0].start;if(!(m>=l)&&(l=m,i=w.captureIndices,u=w.ruleId,f=h.priority,l===r))break}return i?{priorityMatch:f===-1,captureIndices:i,matchedRuleId:u}:null}function Hs(e,t,a,o,r){if(Os){let n=e.compile(t,a),l=qs(o,r);return{ruleScanner:n,findOptions:l}}return{ruleScanner:e.compileAG(t,a,o,r),findOptions:0}}function bu(e,t,a,o,r){if(Os){let n=e.compileWhile(t,a),l=qs(o,r);return{ruleScanner:n,findOptions:l}}return{ruleScanner:e.compileWhileAG(t,a,o,r),findOptions:0}}function qs(e,t){let a=0;return e||(a|=1),t||(a|=4),a}function zt(e,t,a,o,r,s,n){if(s.length===0)return;let l=t.content,i=Math.min(s.length,n.length),u=[],f=n[0].end;for(let d=0;d<i;d++){let c=s[d];if(c===null)continue;let p=n[d];if(p.length===0)continue;if(p.start>f)break;for(;u.length>0&&u[u.length-1].endPos<=p.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,p.start):r.produce(o,p.start),c.retokenizeCapturedWithRuleId){let I=c.getName(l,n),L=o.contentNameScopesList.pushAttributed(I,e),x=c.getContentName(l,n),w=L.pushAttributed(x,e),m=o.push(c.retokenizeCapturedWithRuleId,p.start,-1,!1,null,L,w),g=e.createOnigString(l.substring(0,p.end));Us(e,g,a&&p.start===0,p.start,m,r,!1,0),Bs(g);continue}let h=c.getName(l,n);if(h!==null){let L=(u.length>0?u[u.length-1].scopes:o.contentNameScopesList).pushAttributed(h,e);u.push(new Tu(L,p.end))}}for(;u.length>0;)r.produceFromScopes(u[u.length-1].scopes,u[u.length-1].endPos),u.pop()}var Tu=class{scopes;endPos;constructor(e,t){this.scopes=e,this.endPos=t}};function Pu(e,t,a,o,r,s,n,l){return new vu(e,t,a,o,r,s,n,l)}function ys(e,t,a,o,r){let s=Pa(t,Ma),n=_s.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(Au(t[r],o))return a=r+1,!0;return!1})}function Au(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 vu=class{constructor(e,t,a,o,r,s,n,l){if(this._rootScopeName=e,this.balancedBracketSelectors=s,this._onigLib=l,this._basicScopeAttributesProvider=new Lu(a,o),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=n,this._grammar=ks(t,null),this._injections=null,this._tokenTypeMatchers=[],r)for(let i of Object.keys(r)){let u=Pa(i,Ma);for(let f of u)this._tokenTypeMatchers.push({matcher:f.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)ys(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&&ys(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]=ks(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=_s.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections());let r;if(!t||t===Eo.NULL){r=!0;let u=this._basicScopeAttributesProvider.getDefaultAttributes(),f=this.themeProvider.getDefaults(),d=et.set(0,u.languageId,u.tokenType,null,f.fontStyle,f.foregroundId,f.backgroundId),c=this.getRule(this._rootId).getName(null,null),p;c?p=jt.createRootAndLookUpScopeName(c,d,this):p=jt.createRoot("unknown",d),t=new Eo(null,this._rootId,-1,-1,!1,null,p,p)}else r=!1,t.reset();e=e+`
4
- `;let s=this.createOnigString(e),n=s.content.length,l=new Ru(a,e,this._tokenTypeMatchers,this.balancedBracketSelectors),i=Us(this,s,r,0,t,l,!0,o);return Bs(s),{lineLength:n,lineTokens:l,ruleStack:i.stack,stoppedEarly:i.stoppedEarly}}};function ks(e,t){return e=Xl(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 jt=class Fe{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=Ao.push(r,s.scopeNames),o=new Fe(o,r,s.encodedTokenAttributes);return o}static createRoot(t,a){return new Fe(null,new Ao(null,t),a)}static createRootAndLookUpScopeName(t,a,o){let r=o.getMetadataForScope(t),s=new Ao(null,t),n=o.themeProvider.themeMatch(s),l=Fe.mergeAttributes(a,r,n);return new Fe(null,s,l)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(" ")}equals(t){return Fe.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),et.set(t,a.languageId,a.tokenType,null,r,s,n)}pushAttributed(t,a){if(t===null)return this;if(t.indexOf(" ")===-1)return Fe._pushAttributed(this,t,a);let o=t.split(/ /g),r=this;for(let s of o)r=Fe._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=Fe.mergeAttributes(t.tokenAttributes,r,n);return new Fe(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 Ye{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 Ye(null,0,0,0,!1,null,null,null);_enterPos;_anchorPos;depth;equals(t){return t===null?!1:Ye._equals(this,t)}static _equals(t,a){return t===a?!0:this._structuralEquals(t,a)?jt.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(){Ye._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(t,a,o,r,s,n,l){return new Ye(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 Ye(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=jt.fromExtension(t?.nameScopesList??null,a.nameScopesList);return new Ye(t,a.ruleId,a.enterPos??-1,a.anchorPos??-1,a.beginRuleCapturedEOL,a.endRule,o,jt.fromExtension(o,a.contentNameScopesList))}},Mu=class{balancedBracketScopes;unbalancedBracketScopes;allowAny=!1;constructor(e,t){this.balancedBracketScopes=e.flatMap(a=>a==="*"?(this.allowAny=!0,[]):Pa(a,Ma).map(o=>o.matcher)),this.unbalancedBracketScopes=t.flatMap(a=>Pa(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}},Ru=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=et.set(o,0,n.type,null,-1,0,0));this.balancedBracketSelectors&&(r=this.balancedBracketSelectors.match(s))}if(r&&(o=et.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}},Fu=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,Pu(e,s,t,a,o,r,this,this._onigLib))}return this._grammars.get(e)}},Gs=class{_options;_syncRegistry;_ensureGrammarCache;constructor(e){this._options=e,this._syncRegistry=new Fu(Vt.createFromRawTheme(e.theme,e.colorMap),e.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(e,t){this._syncRegistry.setTheme(Vt.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 Mu(a.balancedBracketSelectors||[],a.unbalancedBracketSelectors||[]))}loadGrammar(e){return this._loadGrammar(e,0,null,null,null)}_loadGrammar(e,t,a,o,r){let s=new lu(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)}},Ra=Eo.NULL;var Bu=/["&'<>`]/g,Du=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,Eu=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,_u=/[|\\{}()[\]^$+*?.]/g,Ws=new WeakMap;function zs(e,t){if(e=e.replace(t.subset?Nu(t.subset):Bu,o),t.subset||t.escapeOnly)return e;return e.replace(Du,a).replace(Eu,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 Nu(e){let t=Ws.get(e);return t||(t=Ou(e),Ws.set(e,t)),t}function Ou(e){let t=[],a=-1;for(;++a<e.length;)t.push(e[a].replace(_u,"\\$&"));return new RegExp("(?:"+t.join("|")+")","g")}var Uu=/[\dA-Fa-f]/;function js(e,t,a){let o="&#x"+e.toString(16).toUpperCase();return a&&t&&!Uu.test(String.fromCharCode(t))?o:o+";"}var Hu=/\d/;function Vs(e,t,a){let o="&#"+String(e);return a&&t&&!Hu.test(String.fromCharCode(t))?o:o+";"}var $s=["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"];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"};var Xs=["cent","copy","divide","gt","lt","not","para","times"];var Ks={}.hasOwnProperty,No={},Ba;for(Ba in Fa)Ks.call(Fa,Ba)&&(No[Fa[Ba]]=Ba);var qu=/[^\dA-Za-z]/;function Qs(e,t,a,o){let r=String.fromCharCode(e);if(Ks.call(No,r)){let s=No[r],n="&"+s;return a&&$s.includes(s)&&!Xs.includes(s)&&(!o||t&&t!==61&&qu.test(String.fromCharCode(t)))?n:n+";"}return""}function Js(e,t,a){let o=js(e,t,a.omitOptionalSemicolons),r;if((a.useNamedReferences||a.useShortestReferences)&&(r=Qs(e,t,a.omitOptionalSemicolons,a.attribute)),(a.useShortestReferences||!r)&&a.useShortestReferences){let s=Vs(e,t,a.omitOptionalSemicolons);s.length<o.length&&(o=s)}return r&&(!a.useShortestReferences||r.length<o.length)?r:o}function _e(e,t){return zs(e,Object.assign({format:Js},t))}var Gu=/^>|^->|<!--|-->|--!>|<!-$/g,Wu=[">"],zu=["<",">"];function Zs(e,t,a,o){return o.settings.bogusComments?"<?"+_e(e.value,Object.assign({},o.settings.characterReferences,{subset:Wu}))+">":"<!--"+e.value.replace(Gu,r)+"-->";function r(s){return _e(s,Object.assign({},o.settings.characterReferences,{subset:zu}))}}function Ys(e,t,a,o){return"<!"+(o.settings.upperDoctype?"DOCTYPE":"doctype")+(o.settings.tightDoctype?"":" ")+"html>"}var Z=en(1),Oo=en(-1),ju=[];function en(e){return t;function t(a,o,r){let s=a?a.children:ju,n=(o||0)+e,l=s[n];if(!r)for(;l&&ut(l);)n+=e,l=s[n];return l}}var Vu={}.hasOwnProperty;function Da(e){return t;function t(a,o,r){return Vu.call(e,a.tagName)&&e[a.tagName](a,o,r)}}var Jt=Da({body:Xu,caption:Uo,colgroup:Uo,dd:Zu,dt:Ju,head:Uo,html:$u,li:Qu,optgroup:Yu,option:ed,p:Ku,rp:tn,rt:tn,tbody:ad,td:an,tfoot:od,th:an,thead:td,tr:rd});function Uo(e,t,a){let o=Z(a,t,!0);return!o||o.type!=="comment"&&!(o.type==="text"&&ut(o.value.charAt(0)))}function $u(e,t,a){let o=Z(a,t);return!o||o.type!=="comment"}function Xu(e,t,a){let o=Z(a,t);return!o||o.type!=="comment"}function Ku(e,t,a){let o=Z(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 Qu(e,t,a){let o=Z(a,t);return!o||o.type==="element"&&o.tagName==="li"}function Ju(e,t,a){let o=Z(a,t);return!!(o&&o.type==="element"&&(o.tagName==="dt"||o.tagName==="dd"))}function Zu(e,t,a){let o=Z(a,t);return!o||o.type==="element"&&(o.tagName==="dt"||o.tagName==="dd")}function tn(e,t,a){let o=Z(a,t);return!o||o.type==="element"&&(o.tagName==="rp"||o.tagName==="rt")}function Yu(e,t,a){let o=Z(a,t);return!o||o.type==="element"&&o.tagName==="optgroup"}function ed(e,t,a){let o=Z(a,t);return!o||o.type==="element"&&(o.tagName==="option"||o.tagName==="optgroup")}function td(e,t,a){let o=Z(a,t);return!!(o&&o.type==="element"&&(o.tagName==="tbody"||o.tagName==="tfoot"))}function ad(e,t,a){let o=Z(a,t);return!o||o.type==="element"&&(o.tagName==="tbody"||o.tagName==="tfoot")}function od(e,t,a){return!Z(a,t)}function rd(e,t,a){let o=Z(a,t);return!o||o.type==="element"&&o.tagName==="tr"}function an(e,t,a){let o=Z(a,t);return!o||o.type==="element"&&(o.tagName==="td"||o.tagName==="th")}var on=Da({body:id,colgroup:ld,head:nd,html:sd,tbody:ud});function sd(e){let t=Z(e,-1);return!t||t.type!=="comment"}function nd(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 id(e){let t=Z(e,-1,!0);return!t||t.type!=="comment"&&!(t.type==="text"&&ut(t.value.charAt(0)))&&!(t.type==="element"&&(t.tagName==="meta"||t.tagName==="link"||t.tagName==="script"||t.tagName==="style"||t.tagName==="template"))}function ld(e,t,a){let o=Oo(a,t),r=Z(e,-1,!0);return a&&o&&o.type==="element"&&o.tagName==="colgroup"&&Jt(o,a.children.indexOf(o),a)?!1:!!(r&&r.type==="element"&&r.tagName==="col")}function ud(e,t,a){let o=Oo(a,t),r=Z(e,-1);return a&&o&&o.type==="element"&&(o.tagName==="thead"||o.tagName==="tbody")&&Jt(o,a.children.indexOf(o),a)?!1:!!(r&&r.type==="element"&&r.tagName==="tr")}var Ea={name:[[`
2
+ import{a as Lr,b as Ir,c as Cr,d as st,e as nt,f as na,g as Sr,h as yr,i as kr,j as br,k as ia,l as Tr,m as fo,n as Pr,o as Ar,p as it,u as co}from"../chunk-5JBHQYU5.js";import"../chunk-V3ZDECK5.js";import{forwardRef as _c,useCallback as ro,useEffect as mi,useImperativeHandle as Ec,useRef as hi,useState as pr}from"react";import{forwardRef as vi,createElement as Mi}from"react";var la=(...e)=>e.filter((t,a,o)=>!!t&&t.trim()!==""&&o.indexOf(t)===a).join(" ").trim();var vr=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();var Mr=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,a,o)=>o?o.toUpperCase():a.toLowerCase());var po=e=>{let t=Mr(e);return t.charAt(0).toUpperCase()+t.slice(1)};import{forwardRef as Ai,createElement as Br}from"react";var Rr={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};var Fr=e=>{for(let t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};var Dr=Ai(({color:e="currentColor",size:t=24,strokeWidth:a=2,absoluteStrokeWidth:o,className:r="",children:s,iconNode:n,...i},l)=>Br("svg",{ref:l,...Rr,width:t,height:t,stroke:e,strokeWidth:o?Number(a)*24/Number(t):a,className:la("lucide",r),...!s&&!Fr(i)&&{"aria-hidden":"true"},...i},[...n.map(([u,f])=>Br(u,f)),...Array.isArray(s)?s:[s]]));var V=(e,t)=>{let a=vi(({className:o,...r},s)=>Mi(Dr,{ref:s,iconNode:t,className:la(`lucide-${vr(po(e))}`,`lucide-${e}`,o),...r}));return a.displayName=po(e),a};var Ri=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],je=V("arrow-down",Ri);var Fi=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],vt=V("arrow-up",Fi);var Bi=[["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"}]],Oe=V("braces",Bi);var Di=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Mt=V("check",Di);var _i=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Rt=V("chevron-down",_i);var Ei=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Ft=V("chevron-right",Ei);var Ni=[["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"}]],Bt=V("clipboard-copy",Ni);var Oi=[["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"}]],Dt=V("file",Oi);var Ui=[["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"}]],_t=V("loader",Ui);var Hi=[["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"}]],Et=V("paperclip",Hi);var qi=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],Nt=V("square",qi);var Gi=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Ve=V("x",Gi);import{useCallback as sl}from"react";import{useCallback as Ue,useMemo as Wi,useRef as zi,useState as mo}from"react";var ji={damping:.7,stiffness:.05,mass:1.25},Vi=70,$i=1e3/60,Xi=350,ua=!1;globalThis.document?.addEventListener("mousedown",()=>{ua=!0});globalThis.document?.addEventListener("mouseup",()=>{ua=!1});globalThis.document?.addEventListener("click",()=>{ua=!1});var Er=(e={})=>{let[t,a]=mo(!1),[o,r]=mo(e.initial!==!1),[s,n]=mo(!1),i=zi(null);i.current=e;let l=Ue(()=>{if(!ua)return!1;let w=window.getSelection();if(!w||!w.rangeCount)return!1;let m=w.getRangeAt(0);return m.commonAncestorContainer.contains(L.current)||L.current?.contains(m.commonAncestorContainer)},[]),u=Ue(w=>{d.isAtBottom=w,r(w)},[]),f=Ue(w=>{d.escapedFromLock=w,a(w)},[]),d=Wi(()=>{let w;return{escapedFromLock:t,isAtBottom:o,resizeDifference:0,accumulated:0,velocity:0,listeners:new Set,get scrollTop(){return L.current?.scrollTop??0},set scrollTop(m){L.current&&(L.current.scrollTop=m,d.ignoreScrollToTop=L.current.scrollTop)},get targetScrollTop(){return!L.current||!x.current?0:L.current.scrollHeight-1-L.current.clientHeight},get calculatedTargetScrollTop(){if(!L.current||!x.current)return 0;let{targetScrollTop:m}=this;if(!e.targetScrollTop)return m;if(w?.targetScrollTop===m)return w.calculatedScrollTop;let g=Math.max(Math.min(e.targetScrollTop(m,{scrollElement:L.current,contentElement:x.current}),m),0);return w={targetScrollTop:m,calculatedScrollTop:g},requestAnimationFrame(()=>{w=void 0}),g},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=Vi}}},[]),c=Ue((w={})=>{typeof w=="string"&&(w={animation:w}),w.preserveScrollPosition||u(!0);let m=Date.now()+(Number(w.wait)||0),g=go(i.current,w.animation),{ignoreEscapes:I=!1}=w,b,y=d.calculatedTargetScrollTop;w.duration instanceof Promise?w.duration.finally(()=>{b=Date.now()}):b=m+(w.duration??0);let M=async()=>{let _=new Promise(requestAnimationFrame).then(()=>{if(!d.isAtBottom)return d.animation=void 0,!1;let{scrollTop:F}=d,k=performance.now(),A=(k-(d.lastTick??k))/$i;if(d.animation||(d.animation={behavior:g,promise:_,ignoreEscapes:I}),d.animation.behavior===g&&(d.lastTick=k),l()||m>Date.now())return M();if(F<Math.min(y,d.calculatedTargetScrollTop)){if(d.animation?.behavior===g){if(g==="instant")return d.scrollTop=d.calculatedTargetScrollTop,M();d.velocity=(g.damping*d.velocity+g.stiffness*d.scrollDifference)/g.mass,d.accumulated+=d.velocity*A,d.scrollTop+=d.accumulated,d.scrollTop!==F&&(d.accumulated=0)}return M()}return b>Date.now()?(y=d.calculatedTargetScrollTop,M()):(d.animation=void 0,d.scrollTop<d.calculatedTargetScrollTop?c({animation:go(i.current,i.current.resize),ignoreEscapes:I,duration:Math.max(0,b-Date.now())||void 0}):d.isAtBottom)});return _.then(F=>(requestAnimationFrame(()=>{d.animation||(d.lastTick=void 0,d.velocity=0)}),F))};return w.wait!==!0&&(d.animation=void 0),d.animation?.behavior===g?d.animation.promise:M()},[u,l,d]),p=Ue(()=>{f(!0),u(!1)},[f,u]),h=Ue(({target:w})=>{if(w!==L.current)return;let{scrollTop:m,ignoreScrollToTop:g}=d,{lastScrollTop:I=m}=d;d.lastScrollTop=m,d.ignoreScrollToTop=void 0,g&&g>m&&(I=g),n(d.isNearBottom),setTimeout(()=>{if(d.resizeDifference||m===g)return;if(l()){f(!0),u(!1);return}let b=m>I,y=m<I;if(d.animation?.ignoreEscapes){d.scrollTop=I;return}y&&(f(!0),u(!1)),b&&f(!1),!d.escapedFromLock&&d.isNearBottom&&u(!0)},1)},[f,u,l,d]),S=Ue(({target:w,deltaY:m})=>{let g=w;for(;!["scroll","auto"].includes(getComputedStyle(g).overflow);){if(!g.parentElement)return;g=g.parentElement}g===L.current&&m<0&&L.current.scrollHeight>L.current.clientHeight&&!d.animation?.ignoreEscapes&&(f(!0),u(!1))},[f,u,d]),L=_r(w=>{L.current?.removeEventListener("scroll",h),L.current?.removeEventListener("wheel",S),w?.addEventListener("scroll",h,{passive:!0}),w?.addEventListener("wheel",S,{passive:!0})},[]),x=_r(w=>{if(d.resizeObserver?.disconnect(),!w)return;let m;d.resizeObserver=new ResizeObserver(([g])=>{let{height:I}=g.contentRect,b=I-(m??I);if(d.resizeDifference=b,d.scrollTop>d.targetScrollTop&&(d.scrollTop=d.targetScrollTop),n(d.isNearBottom),b>=0){let y=go(i.current,m?i.current.resize:i.current.initial);c({animation:y,wait:!0,preserveScrollPosition:!0,duration:y==="instant"?void 0:Xi})}else d.isNearBottom&&(f(!1),u(!0));m=I,requestAnimationFrame(()=>{setTimeout(()=>{d.resizeDifference===b&&(d.resizeDifference=0)},1)})}),d.resizeObserver?.observe(w)},[]);return{contentRef:x,scrollRef:L,scrollToBottom:c,stopScroll:p,isAtBottom:o||s,isNearBottom:s,escapedFromLock:t,state:d}};function _r(e,t){let a=Ue(o=>(a.current=o,e(o)),t);return a}var ho=new Map;function go(...e){let t={...ji},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 ho.has(o)||ho.set(o,Object.freeze(t)),a?"instant":ho.get(o)}import*as $e from"react";import{createContext as Qi,useContext as Ki,useEffect as Ji,useImperativeHandle as Zi,useLayoutEffect as Yi,useMemo as el,useRef as tl}from"react";var Nr=Qi(null),al=typeof window<"u"?Yi:Ji;function Ot({instance:e,children:t,resize:a,initial:o,mass:r,damping:s,stiffness:n,targetScrollTop:i,contextRef:l,...u}){let f=tl(null),d=$e.useCallback((I,b)=>(g?.targetScrollTop??i)?.(I,b)??I,[i]),c=Er({mass:r,damping:s,stiffness:n,resize:a,initial:o,targetScrollTop:d}),{scrollRef:p,contentRef:h,scrollToBottom:S,stopScroll:L,isAtBottom:x,escapedFromLock:w,state:m}=e??c,g=el(()=>({scrollToBottom:S,stopScroll:L,scrollRef:p,isAtBottom:x,escapedFromLock:w,contentRef:h,state:m,get targetScrollTop(){return f.current},set targetScrollTop(I){f.current=I}}),[S,x,h,p,L,w,m]);return Zi(l,()=>g,[g]),al(()=>{p.current&&getComputedStyle(p.current).overflow==="visible"&&(p.current.style.overflow="auto")},[]),$e.createElement(Nr.Provider,{value:g},$e.createElement("div",{...u},typeof t=="function"?t(g):t))}(function(e){function t({children:a,scrollClassName:o,...r}){let s=wo();return $e.createElement("div",{ref:s.scrollRef,style:{height:"100%",width:"100%",scrollbarGutter:"stable both-edges"},className:o},$e.createElement("div",{...r,ref:s.contentRef},typeof a=="function"?a(s):a))}e.Content=t})(Ot||(Ot={}));function wo(){let e=Ki(Nr);if(!e)throw new Error("use-stick-to-bottom component context must be used within a StickToBottom component");return e}var ol=Ir({prefix:"ww"});function P(...e){return ol(Lr(e))}import{jsx as rl}from"react/jsx-runtime";var ke=({className:e,variant:t="default",size:a="default",type:o="button",...r})=>rl("button",{type:o,className:P("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 da}from"react/jsx-runtime";var fa=({className:e,...t})=>da(Ot,{className:P("ww:relative ww:flex-1 ww:overflow-y-hidden",e),initial:"smooth",resize:"smooth",role:"log",...t}),ca=({className:e,...t})=>da(Ot.Content,{className:P("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}),pa=({className:e,...t})=>{let{isAtBottom:a,scrollToBottom:o}=wo(),r=sl(()=>{o()},[o]);return!a&&da(ke,{className:P("ww:absolute ww:bottom-4 ww:left-[50%] ww:translate-x-[-50%] ww:rounded-full",e),onClick:r,size:"icon",variant:"outline",...t,children:da(je,{className:"ww:size-4"})})};import Ur from"crypto";var Or="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var nl=128,Xe,lt,il=e=>{!Xe||Xe.length<e?(Xe=Buffer.allocUnsafe(e*nl),Ur.randomFillSync(Xe),lt=0):lt+e>Xe.length&&(Ur.randomFillSync(Xe),lt=0),lt+=e};var Ut=(e=21)=>{il(e|=0);let t="";for(let a=lt-e;a<lt;a++)t+=Or[Xe[a]&63];return t};import{createContext as ll,useCallback as Be,useContext as ul,useEffect as xo,useMemo as dl,useRef as Lo,useState as Hr}from"react";import{jsx as Pe,jsxs as Wr}from"react/jsx-runtime";var fl=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}},qr=ll(null),Gr=()=>{let e=ul(qr);if(!e)throw new Error("usePromptInputAttachments must be used within a PromptInput");return e},ut=({className:e,accept:t,multiple:a,globalDrop:o,maxFiles:r,maxFileSize:s,onSubmit:n,children:i,...l})=>{let u=Lo(null),f=Lo(null),[d,c]=Hr([]),p=Lo(d);xo(()=>{p.current=d},[d]);let h=Be(()=>{u.current?.click()},[]),S=Be(I=>{let b=[...I];if(b.length===0)return;let y=_=>s?_.size<=s:!0,M=b.filter(y);c(_=>{let F=typeof r=="number"?Math.max(0,r-_.length):void 0,k=typeof F=="number"?M.slice(0,F):M;return[..._,...k.map(A=>({filename:A.name,id:Ut(),mediaType:A.type,type:"file",url:URL.createObjectURL(A)}))]})},[r,s]),L=Be(I=>{c(b=>{let y=b.find(M=>M.id===I);return y?.url&&URL.revokeObjectURL(y.url),b.filter(M=>M.id!==I)})},[]),x=Be(()=>{c(I=>{for(let b of I)b.url&&URL.revokeObjectURL(b.url);return[]})},[]);xo(()=>()=>{for(let I of p.current)I.url&&URL.revokeObjectURL(I.url)},[]);let w=Be(I=>{I.currentTarget.files&&S(I.currentTarget.files),I.currentTarget.value=""},[S]);xo(()=>{if(!o)return;let I=y=>{y.dataTransfer?.types?.includes("Files")&&y.preventDefault()},b=y=>{y.dataTransfer?.types?.includes("Files")&&y.preventDefault(),y.dataTransfer?.files&&y.dataTransfer.files.length>0&&S(y.dataTransfer.files)};return document.addEventListener("dragover",I),document.addEventListener("drop",b),()=>{document.removeEventListener("dragover",I),document.removeEventListener("drop",b)}},[S,o]);let m=Be(async I=>{I.preventDefault();let b=I.currentTarget,M=new FormData(b).get("message")||"";b.reset();let _=await Promise.all(d.map(async({id:F,...k})=>{if(k.url?.startsWith("blob:")){let A=await fl(k.url);return{...k,url:A??k.url}}return k}));try{let F=n({files:_,text:M},I);F instanceof Promise&&await F,x()}catch{}},[d,n,x]),g=dl(()=>({add:S,clear:x,files:d,openFileDialog:h,remove:L}),[d,S,L,x,h]);return Wr(qr.Provider,{value:g,children:[Pe("input",{accept:t,"aria-label":"Upload files",className:"ww:hidden",multiple:a,onChange:w,ref:u,title:"Upload files",type:"file"}),Pe("form",{className:P("ww:flex ww:w-full ww:flex-col ww:rounded-lg ww:border ww:border-border ww:bg-background",e),onSubmit:m,ref:f,...l,children:i})]})};var dt=({onChange:e,onKeyDown:t,className:a,placeholder:o="What would you like to know?",...r})=>{let s=Gr(),[n,i]=Hr(!1),l=Be(f=>{if(t?.(f),!f.defaultPrevented){if(f.key==="Enter"){if(n||f.nativeEvent.isComposing||f.shiftKey)return;f.preventDefault();let{form:d}=f.currentTarget;if(d?.querySelector('button[type="submit"]')?.disabled)return;d?.requestSubmit()}if(f.key==="Backspace"&&f.currentTarget.value===""&&s.files.length>0){f.preventDefault();let d=s.files.at(-1);d&&s.remove(d.id)}}},[t,n,s]),u=Be(f=>{let d=f.clipboardData?.items;if(!d)return;let c=[];for(let p of d)if(p.kind==="file"){let h=p.getAsFile();h&&c.push(h)}c.length>0&&(f.preventDefault(),s.add(c))},[s]);return Pe("textarea",{className:P("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:()=>i(!1),onCompositionStart:()=>i(!0),onKeyDown:l,onPaste:u,placeholder:o,onChange:e,...r})},ft=({className:e,status:t,onStop:a,onClick:o,children:r,...s})=>{let n=t==="submitted"||t==="streaming",i=Pe(vt,{className:"ww:size-4"});t==="submitted"?i=Pe(_t,{className:"ww:size-4 ww:animate-spin"}):t==="streaming"&&(i=Pe(Nt,{className:"ww:size-4"}));let l=Be(u=>{if(n&&a){u.preventDefault(),a();return}o?.(u)},[n,a,o]);return Pe(ke,{"aria-label":n?"Stop":"Submit",className:P("ww:bg-foreground ww:text-background ww:hover:bg-foreground ww:rounded-full",e),onClick:l,size:"icon-sm",type:n&&a?"button":"submit",variant:"ghost",...s,children:r??i})},ct=({className:e,children:t,...a})=>{let o=Gr();return o.files.length>0?Wr(ke,{className:P("ww:group ww:relative",e),onClick:()=>o.clear(),size:"icon-sm",type:"button",variant:"ghost","aria-label":"Remove all attachments",...a,children:[Pe("span",{className:"ww:flex ww:size-5 ww:items-center ww:justify-center ww:rounded-full ww:bg-primary ww:text-[10px] ww:font-medium ww:text-primary-foreground ww:transition-opacity ww:group-hover:opacity-0",children:o.files.length}),Pe(Ve,{className:"ww:absolute ww:size-4 ww:opacity-0 ww:transition-opacity ww:group-hover:opacity-100"})]}):Pe(ke,{className:P(e),onClick:()=>o.openFileDialog(),size:"icon-sm",type:"button",variant:"ghost",...a,children:t??Pe(Et,{className:"ww:size-4"})})};import{memo as cl,useCallback as pl}from"react";import{jsx as pt}from"react/jsx-runtime";var zr=({className:e,...t})=>pt("div",{className:P("ww:flex ww:flex-col ww:gap-1 ww:px-3 ww:py-2",e),...t}),jr=({className:e,...t})=>pt("li",{className:P("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}),Vr=({className:e,...t})=>pt("span",{className:P("ww:inline-block ww:size-2 ww:shrink-0 ww:rounded-full ww:border ww:border-muted-foreground/50",e),...t}),$r=({className:e,...t})=>pt("span",{className:P("ww:line-clamp-1 ww:grow ww:break-words ww:text-muted-foreground",e),...t}),Xr=({className:e,...t})=>pt("div",{className:P("ww:flex ww:shrink-0 ww:gap-1 ww:opacity-0 ww:transition-opacity ww:group-hover:opacity-100",e),...t}),Qr=({className:e,...t})=>pt(ke,{className:P("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 Qe,jsxs as Io}from"react/jsx-runtime";var Kr=cl(({message:e,onRemove:t})=>{let a=pl(()=>t(e.id),[t,e.id]);return Io(jr,{children:[Qe(Vr,{}),Qe($r,{children:e.text||"(attachment)"}),Qe(Xr,{children:Qe(Qr,{"aria-label":"Remove from queue",onClick:a,children:Qe(Ve,{className:"ww:size-3"})})})]})});Kr.displayName="ChatQueueItem";function mt({queuedMessages:e,onRemove:t,className:a}){return e.length===0?null:Io(zr,{className:P("ww:border-t ww:border-border",a),children:[Io("div",{className:"ww:text-[11px] ww:font-medium ww:text-muted-foreground ww:px-2",children:[e.length," queued"]}),Qe("ul",{children:e.map(o=>Qe(Kr,{message:o,onRemove:t},o.id))})]})}import{useState as Jr}from"react";import{jsx as ml}from"react/jsx-runtime";function ma({messages:e,evalEnabled:t,api:a="/api/waniwani"}){let[o,r]=Jr(!1),[s,n]=Jr(null),i=async()=>{let u={name:`session-${new Date().toISOString().slice(0,19)}`,type:"functional",messages:e,mode:"manual"};r(!0),n(null);try{let f=await fetch(`${a}/scenarios`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(u)});if(!f.ok)throw new Error(`${f.status}`);n("saved")}catch{n("error")}finally{r(!1),setTimeout(()=>n(null),2e3)}};return!t||e.length===0?null:ml("button",{type:"button",onClick:i,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"})}import{jsx as Ht,jsxs as gl}from"react/jsx-runtime";var Zr=({files:e,className:t,...a})=>e.length===0?null:Ht("div",{className:P("ww:flex ww:flex-wrap ww:gap-1.5",t),...a,children:e.map((o,r)=>Ht(hl,{file:o},r))});function hl({file:e}){return e.mediaType?.startsWith("image/")&&e.url?Ht("img",{src:e.url,alt:e.filename??"attachment",className:"ww:h-16 ww:max-w-32 ww:rounded ww:object-cover"}):gl("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:[Ht(Dt,{className:"ww:size-3 ww:shrink-0"}),Ht("span",{className:"ww:max-w-24 ww:truncate",children:e.filename??"file"})]})}import{jsx as Yr}from"react/jsx-runtime";var Co=({className:e,size:t=5,...a})=>Yr("div",{className:P("ww:flex ww:items-center ww:gap-1",e),...a,children:[0,1,2].map(o=>Yr("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))});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};var ve={attentionSideAfter:2,attentionSideBefore:1,atxHeadingOpeningFenceSizeMax:6,autolinkDomainSizeMax:63,autolinkSchemeSizeMax:32,cdataOpeningString:"CDATA[",characterGroupPunctuation:2,characterGroupWhitespace:1,characterReferenceDecimalSizeMax:7,characterReferenceHexadecimalSizeMax:6,characterReferenceNamedSizeMax:31,codeFencedSequenceSizeMin:3,contentTypeContent:"content",contentTypeDocument:"document",contentTypeFlow:"flow",contentTypeString:"string",contentTypeText:"text",hardBreakPrefixSizeMin:2,htmlBasic:6,htmlCdata:5,htmlComment:2,htmlComplete:7,htmlDeclaration:4,htmlInstruction:3,htmlRawSizeMax:8,htmlRaw:1,linkResourceDestinationBalanceMax:32,linkReferenceSizeMax:999,listItemValueSizeMax:10,numericBaseDecimal:10,numericBaseHexadecimal:16,tabSize:4,thematicBreakMarkerCountMin:3,v8MaxSafeChunkSize:1e4};var Le={data:"data",whitespace:"whitespace",lineEnding:"lineEnding",lineEndingBlank:"lineEndingBlank",linePrefix:"linePrefix",lineSuffix:"lineSuffix",atxHeading:"atxHeading",atxHeadingSequence:"atxHeadingSequence",atxHeadingText:"atxHeadingText",autolink:"autolink",autolinkEmail:"autolinkEmail",autolinkMarker:"autolinkMarker",autolinkProtocol:"autolinkProtocol",characterEscape:"characterEscape",characterEscapeValue:"characterEscapeValue",characterReference:"characterReference",characterReferenceMarker:"characterReferenceMarker",characterReferenceMarkerNumeric:"characterReferenceMarkerNumeric",characterReferenceMarkerHexadecimal:"characterReferenceMarkerHexadecimal",characterReferenceValue:"characterReferenceValue",codeFenced:"codeFenced",codeFencedFence:"codeFencedFence",codeFencedFenceSequence:"codeFencedFenceSequence",codeFencedFenceInfo:"codeFencedFenceInfo",codeFencedFenceMeta:"codeFencedFenceMeta",codeFlowValue:"codeFlowValue",codeIndented:"codeIndented",codeText:"codeText",codeTextData:"codeTextData",codeTextPadding:"codeTextPadding",codeTextSequence:"codeTextSequence",content:"content",definition:"definition",definitionDestination:"definitionDestination",definitionDestinationLiteral:"definitionDestinationLiteral",definitionDestinationLiteralMarker:"definitionDestinationLiteralMarker",definitionDestinationRaw:"definitionDestinationRaw",definitionDestinationString:"definitionDestinationString",definitionLabel:"definitionLabel",definitionLabelMarker:"definitionLabelMarker",definitionLabelString:"definitionLabelString",definitionMarker:"definitionMarker",definitionTitle:"definitionTitle",definitionTitleMarker:"definitionTitleMarker",definitionTitleString:"definitionTitleString",emphasis:"emphasis",emphasisSequence:"emphasisSequence",emphasisText:"emphasisText",escapeMarker:"escapeMarker",hardBreakEscape:"hardBreakEscape",hardBreakTrailing:"hardBreakTrailing",htmlFlow:"htmlFlow",htmlFlowData:"htmlFlowData",htmlText:"htmlText",htmlTextData:"htmlTextData",image:"image",label:"label",labelText:"labelText",labelLink:"labelLink",labelImage:"labelImage",labelMarker:"labelMarker",labelImageMarker:"labelImageMarker",labelEnd:"labelEnd",link:"link",paragraph:"paragraph",reference:"reference",referenceMarker:"referenceMarker",referenceString:"referenceString",resource:"resource",resourceDestination:"resourceDestination",resourceDestinationLiteral:"resourceDestinationLiteral",resourceDestinationLiteralMarker:"resourceDestinationLiteralMarker",resourceDestinationRaw:"resourceDestinationRaw",resourceDestinationString:"resourceDestinationString",resourceMarker:"resourceMarker",resourceTitle:"resourceTitle",resourceTitleMarker:"resourceTitleMarker",resourceTitleString:"resourceTitleString",setextHeading:"setextHeading",setextHeadingText:"setextHeadingText",setextHeadingLine:"setextHeadingLine",setextHeadingLineSequence:"setextHeadingLineSequence",strong:"strong",strongSequence:"strongSequence",strongText:"strongText",thematicBreak:"thematicBreak",thematicBreakSequence:"thematicBreakSequence",blockQuote:"blockQuote",blockQuotePrefix:"blockQuotePrefix",blockQuoteMarker:"blockQuoteMarker",blockQuotePrefixWhitespace:"blockQuotePrefixWhitespace",listOrdered:"listOrdered",listUnordered:"listUnordered",listItemIndent:"listItemIndent",listItemMarker:"listItemMarker",listItemPrefix:"listItemPrefix",listItemPrefixWhitespace:"listItemPrefixWhitespace",listItemValue:"listItemValue",chunkDocument:"chunkDocument",chunkContent:"chunkContent",chunkFlow:"chunkFlow",chunkText:"chunkText",chunkString:"chunkString"};function es(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 ts(e){return e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510}function as(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 os(e){return es(e)?"ambiguous":ts(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":as(e)?"wide":"neutral"}function wl(e){if(!Number.isSafeInteger(e))throw new TypeError(`Expected a code point, got \`${typeof e}\`.`)}function rs(e){return wl(e),os(e)}var xl=Object.defineProperty,Ll=(e,t,a)=>t in e?xl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,Il=(e,t,a)=>Ll(e,typeof t!="symbol"?t+"":t,a);function Cl(e){return/^\p{Emoji_Presentation}/u.test(String.fromCodePoint(e))}function Sl(e){if(!e||e<4352)return!1;switch(rs(e)){case"fullwidth":case"halfwidth":return!0;case"wide":return!Cl(e);case"narrow":return!1;case"ambiguous":return 917760<=e&&e<=917999?null:!1;case"neutral":return/^\p{sc=Hangul}/u.test(String.fromCodePoint(e))}}function yl(e,t){return t!==65025||!e||e<8216?!1:e===8216||e===8217||e===8220||e===8221}function kl(e){return e!==null&&e>=65024&&e<=65038}var bl=ss(/\p{P}|\p{S}/u),Tl=ss(/\s/);function ss(e){return t;function t(a){return a!==null&&a>-1&&e.test(String.fromCodePoint(a))}}var Ie;(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})(Ie||(Ie={}));function He(e){if(e===de.eof||Cr(e)||Tl(e))return ve.characterGroupWhitespace;let t=0;if(e>=4352){if(kl(e))return Ie.nonEmojiGeneralUseVS;switch(Sl(e)){case null:return Ie.ivs;case!0:t|=Ie.cjk;break}}return bl(e)&&(t|=ve.characterGroupPunctuation),t}function ha(e,t,a){if(!Al(e))return e;let o=t(),r=He(o);return!o||Ke(r)?e:yl(o,a)?Ie.cjkPunctuation:Pl(r)}function Pl(e){return e&~Ie.ivs}function Ke(e){return!!(e&ve.characterGroupWhitespace)}function ht(e){return(e&Ie.cjkPunctuation)===ve.characterGroupPunctuation}function qt(e){return!!(e&Ie.cjk)}function ns(e){return e===Ie.ivs}function is(e){return!!(e&Ie.cjkOrIvs)}function Al(e){return e===Ie.nonEmojiGeneralUseVS}function So(e){return!!(e&Ie.spaceOrPunctuation)}function ga(e){return!!(e&&e>=55296&&e<=56319)}function wa(e){return!!(e&&e>=56320&&e<=57343)}function xa(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 vl(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 i=s.codePointAt(0);return i&&i>=65536?i:n}var La=class{constructor(e,t,a){this.previousCode=e,this.nowPoint=t,this.sliceSerialize=a,Il(this,"cachedValue")}value(){return this.cachedValue===void 0&&(this.cachedValue=vl(this.previousCode,this.nowPoint,this.sliceSerialize)),this.cachedValue}};function Ia(e,t,a){let o=a({start:t,end:{...t,_bufferIndex:t._bufferIndex+2}}).codePointAt(0);return o&&o>=65536?o:e}var yo={name:"attention",resolveAll:Ml,tokenize:Rl};function Ml(e,t){let a=-1,o,r,s,n,i,l,u,f;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;l=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},c={...e[a][1].start};ls(d,-l),ls(c,l),n={type:l>1?Le.strongSequence:Le.emphasisSequence,start:d,end:{...e[o][1].end}},i={type:l>1?Le.strongSequence:Le.emphasisSequence,start:{...e[a][1].start},end:c},s={type:l>1?Le.strongText:Le.emphasisText,start:{...e[o][1].end},end:{...e[a][1].start}},r={type:l>1?Le.strong:Le.emphasis,start:{...n.start},end:{...i.end}},e[o][1].end={...n.start},e[a][1].start={...i.end},u=[],e[o][1].end.offset-e[o][1].start.offset&&(u=nt(u,[["enter",e[o][1],t],["exit",e[o][1],t]])),u=nt(u,[["enter",r,t],["enter",n,t],["exit",n,t],["enter",s,t]]),t.parser.constructs.insideSpan.null,u=nt(u,na(t.parser.constructs.insideSpan.null,e.slice(o+1,a),t)),u=nt(u,[["exit",s,t],["enter",i,t],["exit",i,t],["exit",r,t]]),e[a][1].end.offset-e[a][1].start.offset?(f=2,u=nt(u,[["enter",e[a][1],t],["exit",e[a][1],t]])):f=0,st(e,o-1,a-o+3,u),a=o+u.length-f-2;break}}for(a=-1;++a<e.length;)e[a][1].type==="attentionSequence"&&(e[a][1].type="data");return e}function Rl(e,t){let a=this.parser.constructs.attentionMarkers.null,{now:o,sliceSerialize:r,previous:s}=this,n=wa(s)?xa(s,o(),r):s,i=He(n),l=new La(n,o(),r),u=ha(i,l.value.bind(l),n),f;return d;function d(p){return p===de.asterisk||de.underscore,f=p,e.enter("attentionSequence"),c(p)}function c(p){if(p===f)return e.consume(p),c;let h=e.exit("attentionSequence"),S=ga(p)?Ia(p,o(),r):p,L=He(S);let x=ht(u),w=x||Ke(u),m=ht(L),g=m||Ke(L),I=is(u),b=!g||m&&(w||I)||a.includes(p),y=!w||x&&(g||qt(L))||a.includes(n);return h._open=!!(f===de.asterisk?b:b&&(So(u)||!y)),h._close=!!(f===de.asterisk?y:y&&(So(L)||!b)),t(p)}}function ls(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}function us(){return{text:{[de.asterisk]:yo,[de.underscore]:yo},insideSpan:{null:[yo]}}}function ds(){let e=this.data();(e.micromarkExtensions||(e.micromarkExtensions=[])).push(us())}function fs(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,i){let l=-1;for(;++l<n.length;)if(n[l][0]==="enter"&&n[l][1].type==="strikethroughSequenceTemporary"&&n[l][1]._close){let u=l;for(;u--;)if(n[u][0]==="exit"&&n[u][1].type==="strikethroughSequenceTemporary"&&n[u][1]._open&&n[l][1].end.offset-n[l][1].start.offset===n[u][1].end.offset-n[u][1].start.offset){n[l][1].type="strikethroughSequence",n[u][1].type="strikethroughSequence";let f={type:"strikethrough",start:Object.assign({},n[u][1].start),end:Object.assign({},n[l][1].end)},d={type:"strikethroughText",start:Object.assign({},n[u][1].end),end:Object.assign({},n[l][1].start)},c=[["enter",f,i],["enter",n[u][1],i],["exit",n[u][1],i],["enter",d,i]],p=i.parser.constructs.insideSpan.null;p&&st(c,c.length,0,na(p,n.slice(u+1,l),i)),st(c,c.length,0,[["exit",d,i],["enter",n[l][1],i],["exit",n[l][1],i],["exit",f,i]]),st(n,u-1,l-u+3,c),l=u+c.length-2;break}}for(l=-1;++l<n.length;)n[l][1].type==="strikethroughSequenceTemporary"&&(n[l][1].type=Le.data);return n}function s(n,i,l){let{now:u,sliceSerialize:f,previous:d}=this,c=wa(d)?xa(d,u(),f):d,p=He(c),h=new La(c,u(),f),S=ha(p,h.value.bind(h),c),L=this.events,x=0;return w;function w(g){return de.tilde,c===de.tilde&&L[L.length-1][1].type!==Le.characterEscape?l(g):(n.enter("strikethroughSequenceTemporary"),m(g))}function m(g){let I=He(c);if(g===de.tilde)return x>1?l(g):(n.consume(g),x++,m);if(x<2&&!a)return l(g);let b=n.exit("strikethroughSequenceTemporary"),y=ga(g)?Ia(g,u(),f):g,M=He(y),F=ht(S)||Ke(S),A=ht(M)||Ke(M),Q=qt(S)||ns(I);return b._open=!A||M===ve.attentionSideAfter&&(F||Q),b._close=!F||I===ve.attentionSideAfter&&(A||qt(M)),i(g)}}}function cs(e){let t=this.data();(t.micromarkExtensions||(t.micromarkExtensions=[])).push(fs(e))}var Fl=new Set(["\u3002","\uFF0E","\uFF0C","\u3001","\uFF1F","\uFF01","\uFF1A","\uFF1B","\uFF08","\uFF09","\u3010","\u3011","\u300C","\u300D","\u300E","\u300F","\u3008","\u3009","\u300A","\u300B"]),Bl=/^(https?:\/\/|mailto:|www\.)/i,Dl=e=>{if(e.children.length!==1)return!1;let t=e.children[0];return t.type==="text"&&t.value===e.url},_l=e=>{let t=0;for(let a of e){if(Fl.has(a))return t;t+=a.length}return null},El=(e,t)=>({...t,url:e,children:[{type:"text",value:e}]}),Nl=e=>({type:"text",value:e}),Ol=()=>e=>{Sr(e,"link",(t,a,o)=>{if(!o||typeof a!="number"||!Dl(t)||!Bl.test(t.url))return;let r=_l(t.url);if(r===null||r===0)return;let s=t.url.slice(0,r),n=t.url.slice(r),i=El(s,t),l=Nl(n);return o.children.splice(a,1,i,l),a+1})};function Ul(){let e=[ds],t=[Ol,cs],a=[...e,...t];return{name:"cjk",type:"cjk",remarkPluginsBefore:e,remarkPluginsAfter:t,remarkPlugins:a}}var ps=Ul();var X=class extends Error{constructor(t){super(t),this.name="ShikiError"}};function Hl(e){return Bo(e)}function Bo(e){return Array.isArray(e)?ql(e):e instanceof RegExp?e:typeof e=="object"?Gl(e):e}function ql(e){let t=[];for(let a=0,o=e.length;a<o;a++)t[a]=Bo(e[a]);return t}function Gl(e){let t={};for(let a in e)t[a]=Bo(e[a]);return t}function Ss(e,...t){return t.forEach(a=>{for(let o in a)e[o]=a[o]}),e}function ys(e){let t=~e.lastIndexOf("/")||~e.lastIndexOf("\\");return t===0?e:~t===e.length-1?ys(e.substring(0,e.length-1)):e.substr(~t+1)}var ko=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,Ca=class{static hasCaptures(e){return e===null?!1:(ko.lastIndex=0,ko.test(e))}static replaceCaptures(e,t,a){return e.replace(ko,(o,r,s,n)=>{let i=a[parseInt(r||s,10)];if(i){let l=t.substring(i.start,i.end);for(;l[0]===".";)l=l.substring(1);switch(n){case"downcase":return l.toLowerCase();case"upcase":return l.toUpperCase();default:return l}}else return o})}};function ks(e,t){return e<t?-1:e>t?1:0}function bs(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=ks(e[r],t[r]);if(s!==0)return s}return 0}return a-o}function ms(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 Ts(e){return e.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var Ps=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}},zt=class{constructor(e,t,a){this._colorMap=e,this._defaults=t,this._root=a}static createFromRawTheme(e,t){return this.createFromParsedTheme(jl(e),t)}static createFromParsedTheme(e,t){return $l(e,t)}_cachedMatchRoot=new Ps(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=>Wl(e.parent,r.parentScopes));return o?new As(o.fontStyle,o.foreground,o.background):null}},bo=class Sa{constructor(t,a){this.parent=t,this.scopeName=a}static push(t,a){for(let o of a)t=new Sa(t,o);return t}static from(...t){let a=null;for(let o=0;o<t.length;o++)a=new Sa(a,t[o]);return a}push(t){return new Sa(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 Wl(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&&!zl(e.scopeName,o);){if(r)return!1;e=e.parent}if(!e)return!1;e=e.parent}return!0}function zl(e,t){return t===e||e.startsWith(t)&&e[t.length]==="."}var As=class{constructor(e,t,a){this.fontStyle=e,this.foregroundId=t,this.backgroundId=a}};function jl(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 i;if(typeof n.scope=="string"){let d=n.scope;d=d.replace(/^[,]+/,""),d=d.replace(/[,]+$/,""),i=d.split(",")}else Array.isArray(n.scope)?i=n.scope:i=[""];let l=-1;if(typeof n.settings.fontStyle=="string"){l=0;let d=n.settings.fontStyle.split(" ");for(let c=0,p=d.length;c<p;c++)switch(d[c]){case"italic":l=l|1;break;case"bold":l=l|2;break;case"underline":l=l|4;break;case"strikethrough":l=l|8;break}}let u=null;typeof n.settings.foreground=="string"&&ms(n.settings.foreground)&&(u=n.settings.foreground);let f=null;typeof n.settings.background=="string"&&ms(n.settings.background)&&(f=n.settings.background);for(let d=0,c=i.length;d<c;d++){let h=i[d].trim().split(" "),S=h[h.length-1],L=null;h.length>1&&(L=h.slice(0,h.length-1),L.reverse()),a[o++]=new Vl(S,L,r,l,u,f)}}return a}var Vl=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}},fe=(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))(fe||{});function $l(e,t){e.sort((l,u)=>{let f=ks(l.scope,u.scope);return f!==0||(f=bs(l.parentScopes,u.parentScopes),f!==0)?f:l.index-u.index});let a=0,o="#000000",r="#ffffff";for(;e.length>=1&&e[0].scope==="";){let l=e.shift();l.fontStyle!==-1&&(a=l.fontStyle),l.foreground!==null&&(o=l.foreground),l.background!==null&&(r=l.background)}let s=new Xl(t),n=new As(a,s.getId(o),s.getId(r)),i=new Kl(new Po(0,null,-1,0,0),[]);for(let l=0,u=e.length;l<u;l++){let f=e[l];i.insert(0,f.scope,f.parentScopes,f.fontStyle,s.getId(f.foreground),s.getId(f.background))}return new zt(s,n,i)}var Xl=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)}},Ql=Object.freeze([]),Po=class vs{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(t,a,o,r,s){this.scopeDepth=t,this.parentScopes=a||Ql,this.fontStyle=o,this.foreground=r,this.background=s}clone(){return new vs(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)}},Kl=class Ao{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(Ao._cmpBySpecificity),a}insert(t,a,o,r,s,n){if(a===""){this._doInsertHere(t,o,r,s,n);return}let i=a.indexOf("."),l,u;i===-1?(l=a,u=""):(l=a.substring(0,i),u=a.substring(i+1));let f;this._children.hasOwnProperty(l)?f=this._children[l]:(f=new Ao(this._mainRule.clone(),Po.cloneArr(this._rulesWithParentScopes)),this._children[l]=f),f.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,i=this._rulesWithParentScopes.length;n<i;n++){let l=this._rulesWithParentScopes[n];if(bs(l.parentScopes,a)===0){l.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 Po(t,a,o,r,s))}},Ze=class be{static toBinaryStr(t){return t.toString(2).padStart(32,"0")}static print(t){let a=be.getLanguageId(t),o=be.getTokenType(t),r=be.getFontStyle(t),s=be.getForeground(t),n=be.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,i){let l=be.getLanguageId(t),u=be.getTokenType(t),f=be.containsBalancedBrackets(t)?1:0,d=be.getFontStyle(t),c=be.getForeground(t),p=be.getBackground(t);return a!==0&&(l=a),o!==8&&(u=o),r!==null&&(f=r?1:0),s!==-1&&(d=s),n!==0&&(c=n),i!==0&&(p=i),(l<<0|u<<8|f<<10|d<<11|c<<15|p<<24)>>>0}};function ka(e,t){let a=[],o=Jl(e),r=o.next();for(;r!==null;){let l=0;if(r.length===2&&r.charAt(1)===":"){switch(r.charAt(0)){case"R":l=1;break;case"L":l=-1;break;default:console.log(`Unknown priority ${r} in scope selector`)}r=o.next()}let u=n();if(a.push({matcher:u,priority:l}),r!==",")break;r=o.next()}return a;function s(){if(r==="-"){r=o.next();let l=s();return u=>!!l&&!l(u)}if(r==="("){r=o.next();let l=i();return r===")"&&(r=o.next()),l}if(hs(r)){let l=[];do l.push(r),r=o.next();while(hs(r));return u=>t(l,u)}return null}function n(){let l=[],u=s();for(;u;)l.push(u),u=s();return f=>l.every(d=>d(f))}function i(){let l=[],u=n();for(;u&&(l.push(u),r==="|"||r===",");){do r=o.next();while(r==="|"||r===",");u=n()}return f=>l.some(d=>d(f))}}function hs(e){return!!e&&!!e.match(/[\w\.:]+/)}function Jl(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 Ms(e){typeof e.dispose=="function"&&e.dispose()}var jt=class{constructor(e){this.scopeName=e}toKey(){return this.scopeName}},Zl=class{constructor(e,t){this.scopeName=e,this.ruleName=t}toKey(){return`${this.scopeName}#${this.ruleName}`}},Yl=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))}},eu=class{constructor(e,t){this.repo=e,this.initialScopeName=t,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new jt(this.initialScopeName)]}seenFullScopeRequests=new Set;seenPartialScopeRequests=new Set;Q;processQueue(){let e=this.Q;this.Q=[];let t=new Yl;for(let a of e)tu(a,this.initialScopeName,this.repo,t);for(let a of t.references)if(a instanceof jt){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 tu(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 jt?ya({baseGrammar:s,selfGrammar:r},o):vo(e.ruleName,{baseGrammar:s,selfGrammar:r,repository:r.repository},o);let n=a.injections(e.scopeName);if(n)for(let i of n)o.add(new jt(i))}function vo(e,t,a){if(t.repository&&t.repository[e]){let o=t.repository[e];ba([o],t,a)}}function ya(e,t){e.selfGrammar.patterns&&Array.isArray(e.selfGrammar.patterns)&&ba(e.selfGrammar.patterns,{...e,repository:e.selfGrammar.repository},t),e.selfGrammar.injections&&ba(Object.values(e.selfGrammar.injections),{...e,repository:e.selfGrammar.repository},t)}function ba(e,t,a){for(let o of e){if(a.visitedRule.has(o))continue;a.visitedRule.add(o);let r=o.repository?Ss({},t.repository,o.repository):t.repository;Array.isArray(o.patterns)&&ba(o.patterns,{...t,repository:r},a);let s=o.include;if(!s)continue;let n=Rs(s);switch(n.kind){case 0:ya({...t,selfGrammar:t.baseGrammar},a);break;case 1:ya(t,a);break;case 2:vo(n.ruleName,{...t,repository:r},a);break;case 3:case 4:let i=n.scopeName===t.selfGrammar.scopeName?t.selfGrammar:n.scopeName===t.baseGrammar.scopeName?t.baseGrammar:void 0;if(i){let l={baseGrammar:t.baseGrammar,selfGrammar:i,repository:r};n.kind===4?vo(n.ruleName,l,a):ya(l,a)}else n.kind===4?a.add(new Zl(n.scopeName,n.ruleName)):a.add(new jt(n.scopeName));break}}}var au=class{kind=0},ou=class{kind=1},ru=class{constructor(e){this.ruleName=e}kind=2},su=class{constructor(e){this.scopeName=e}kind=3},nu=class{constructor(e,t){this.scopeName=e,this.ruleName=t}kind=4};function Rs(e){if(e==="$base")return new au;if(e==="$self")return new ou;let t=e.indexOf("#");if(t===-1)return new su(e);if(t===0)return new ru(e.substring(1));{let a=e.substring(0,t),o=e.substring(t+1);return new nu(a,o)}}var iu=/\\(\d+)/,gs=/\\(\d+)/g;var lu=-1,Fs=-2;var Xt=class{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(e,t,a,o){this.$location=e,this.id=t,this._name=a||null,this._nameIsCapturing=Ca.hasCaptures(this._name),this._contentName=o||null,this._contentNameIsCapturing=Ca.hasCaptures(this._contentName)}get debugName(){let e=this.$location?`${ys(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:Ca.replaceCaptures(this._name,e,t)}getContentName(e,t){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:Ca.replaceCaptures(this._contentName,e,t)}},uu=class extends Xt{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!")}},du=class extends Xt{_match;captures;_cachedCompiledPatterns;constructor(e,t,a,o,r){super(e,t,a,null),this._match=new Vt(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 $t,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},ws=class extends Xt{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 $t,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Mo=class extends Xt{_begin;beginCaptures;_end;endHasBackReferences;endCaptures;applyEndPatternLast;hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,a,o,r,s,n,i,l,u){super(e,t,a,o),this._begin=new Vt(r,this.id),this.beginCaptures=s,this._end=new Vt(n||"\uFFFF",-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=i,this.applyEndPatternLast=l||!1,this.patterns=u.patterns,this.hasMissingPatterns=u.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(e,t){return this._end.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e,t).compile(e)}compileAG(e,t,a,o){return this._getCachedCompiledPatterns(e,t).compileAG(e,a,o)}_getCachedCompiledPatterns(e,t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new $t;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}},Ta=class extends Xt{_begin;beginCaptures;whileCaptures;_while;whileHasBackReferences;hasMissingPatterns;patterns;_cachedCompiledPatterns;_cachedCompiledWhilePatterns;constructor(e,t,a,o,r,s,n,i,l){super(e,t,a,o),this._begin=new Vt(r,this.id),this.beginCaptures=s,this.whileCaptures=i,this._while=new Vt(n,Fs),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=l.patterns,this.hasMissingPatterns=l.hasMissingPatterns,this._cachedCompiledPatterns=null,this._cachedCompiledWhilePatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null),this._cachedCompiledWhilePatterns&&(this._cachedCompiledWhilePatterns.dispose(),this._cachedCompiledWhilePatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugWhileRegExp(){return`${this._while.source}`}getWhileWithResolvedBackReferences(e,t){return this._while.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,a,o){return this._getCachedCompiledPatterns(e).compileAG(e,a,o)}_getCachedCompiledPatterns(e){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new $t;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 $t,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,t||"\uFFFF"),this._cachedCompiledWhilePatterns}},Bs=class me{static createCaptureRule(t,a,o,r,s){return t.registerRule(n=>new uu(a,n,o,r,s))}static getCompiledRuleId(t,a,o){return t.id||a.registerRule(r=>{if(t.id=r,t.match)return new du(t.$vscodeTextmateLocation,t.id,t.name,t.match,me._compileCaptures(t.captures,a,o));if(typeof t.begin>"u"){t.repository&&(o=Ss({},o,t.repository));let s=t.patterns;return typeof s>"u"&&t.include&&(s=[{include:t.include}]),new ws(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,me._compilePatterns(s,a,o))}return t.while?new Ta(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,me._compileCaptures(t.beginCaptures||t.captures,a,o),t.while,me._compileCaptures(t.whileCaptures||t.captures,a,o),me._compilePatterns(t.patterns,a,o)):new Mo(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,me._compileCaptures(t.beginCaptures||t.captures,a,o),t.end,me._compileCaptures(t.endCaptures||t.captures,a,o),t.applyEndPatternLast,me._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 i=parseInt(n,10);i>s&&(s=i)}for(let n=0;n<=s;n++)r[n]=null;for(let n in t){if(n==="$vscodeTextmateLocation")continue;let i=parseInt(n,10),l=0;t[n].patterns&&(l=me.getCompiledRuleId(t[n],a,o)),r[i]=me.createCaptureRule(a,t[n].$vscodeTextmateLocation,t[n].name,t[n].contentName,l)}}return r}static _compilePatterns(t,a,o){let r=[];if(t)for(let s=0,n=t.length;s<n;s++){let i=t[s],l=-1;if(i.include){let u=Rs(i.include);switch(u.kind){case 0:case 1:l=me.getCompiledRuleId(o[i.include],a,o);break;case 2:let f=o[u.ruleName];f&&(l=me.getCompiledRuleId(f,a,o));break;case 3:case 4:let d=u.scopeName,c=u.kind===4?u.ruleName:null,p=a.getExternalGrammar(d,o);if(p)if(c){let h=p.repository[c];h&&(l=me.getCompiledRuleId(h,a,p.repository))}else l=me.getCompiledRuleId(p.repository.$self,a,p.repository);break}}else l=me.getCompiledRuleId(i,a,o);if(l!==-1){let u=a.getRule(l),f=!1;if((u instanceof ws||u instanceof Mo||u instanceof Ta)&&u.hasMissingPatterns&&u.patterns.length===0&&(f=!0),f)continue;r.push(l)}}return{patterns:r,hasMissingPatterns:(t?t.length:0)!==r.length}}},Vt=class Ds{source;ruleId;hasAnchor;hasBackReferences;_anchorCache;constructor(t,a){if(t&&typeof t=="string"){let o=t.length,r=0,s=[],n=!1;for(let i=0;i<o;i++)if(t.charAt(i)==="\\"&&i+1<o){let u=t.charAt(i+1);u==="z"?(s.push(t.substring(r,i)),s.push("$(?!\\n)(?<!\\n)"),r=i+2):(u==="A"||u==="G")&&(n=!0),i++}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=iu.test(this.source):this.hasBackReferences=!1}clone(){return new Ds(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 gs.lastIndex=0,this.source.replace(gs,(r,s)=>Ts(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,i,l;for(s=0,n=this.source.length;s<n;s++)i=this.source.charAt(s),t[s]=i,a[s]=i,o[s]=i,r[s]=i,i==="\\"&&s+1<n&&(l=this.source.charAt(s+1),l==="A"?(t[s+1]="\uFFFF",a[s+1]="\uFFFF",o[s+1]="A",r[s+1]="A"):l==="G"?(t[s+1]="\uFFFF",a[s+1]="G",o[s+1]="\uFFFF",r[s+1]="G"):(t[s+1]=l,a[s+1]=l,o[s+1]=l,r[s+1]=l),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}},$t=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 xs(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 xs(e,o,this._items.map(r=>r.ruleId))}},xs=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(`
3
+ `)}findNextMatchSync(e,t,a){let o=this.scanner.findNextMatchSync(e,t,a);return o?{ruleId:this.rules[o.index],captureIndices:o.captureIndices}:null}},To=class{constructor(e,t){this.languageId=e,this.tokenType=t}},fu=class Ro{_defaultAttributes;_embeddedLanguagesMatcher;constructor(t,a){this._defaultAttributes=new To(t,8),this._embeddedLanguagesMatcher=new cu(Object.entries(a||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(t){return t===null?Ro._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(t)}static _NULL_SCOPE_METADATA=new To(0,0);_getBasicScopeAttributes=new Ps(t=>{let a=this._scopeToLanguage(t),o=this._toStandardTokenType(t);return new To(a,o)});_scopeToLanguage(t){return this._embeddedLanguagesMatcher.match(t)||0}_toStandardTokenType(t){let a=t.match(Ro.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/},cu=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])=>Ts(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])}},vh={InDebugMode:typeof process<"u"&&!!process.env.VSCODE_TEXTMATE_DEBUG},_s=!1,Ls=class{constructor(e,t){this.stack=e,this.stoppedEarly=t}};function Es(e,t,a,o,r,s,n,i){let l=t.content.length,u=!1,f=-1;if(n){let p=pu(e,t,a,o,r,s);r=p.stack,o=p.linePos,a=p.isFirstLine,f=p.anchorPosition}let d=Date.now();for(;!u;){if(i!==0&&Date.now()-d>i)return new Ls(r,!0);c()}return new Ls(r,!1);function c(){let p=mu(e,t,a,o,r,f);if(!p){s.produce(r,l),u=!0;return}let h=p.captureIndices,S=p.matchedRuleId,L=h&&h.length>0?h[0].end>o:!1;if(S===lu){let x=r.getRule(e);s.produce(r,h[0].start),r=r.withContentNameScopesList(r.nameScopesList),Gt(e,t,a,r,s,x.endCaptures,h),s.produce(r,h[0].end);let w=r;if(r=r.parent,f=w.getAnchorPos(),!L&&w.getEnterPos()===o){r=w,s.produce(r,l),u=!0;return}}else{let x=e.getRule(S);s.produce(r,h[0].start);let w=r,m=x.getName(t.content,h),g=r.contentNameScopesList.pushAttributed(m,e);if(r=r.push(S,o,f,h[0].end===l,null,g,g),x instanceof Mo){let I=x;Gt(e,t,a,r,s,I.beginCaptures,h),s.produce(r,h[0].end),f=h[0].end;let b=I.getContentName(t.content,h),y=g.pushAttributed(b,e);if(r=r.withContentNameScopesList(y),I.endHasBackReferences&&(r=r.withEndRule(I.getEndWithResolvedBackReferences(t.content,h))),!L&&w.hasSameRuleAs(r)){r=r.pop(),s.produce(r,l),u=!0;return}}else if(x instanceof Ta){let I=x;Gt(e,t,a,r,s,I.beginCaptures,h),s.produce(r,h[0].end),f=h[0].end;let b=I.getContentName(t.content,h),y=g.pushAttributed(b,e);if(r=r.withContentNameScopesList(y),I.whileHasBackReferences&&(r=r.withEndRule(I.getWhileWithResolvedBackReferences(t.content,h))),!L&&w.hasSameRuleAs(r)){r=r.pop(),s.produce(r,l),u=!0;return}}else if(Gt(e,t,a,r,s,x.captures,h),s.produce(r,h[0].end),r=r.pop(),!L){r=r.safePop(),s.produce(r,l),u=!0;return}}h[0].end>o&&(o=h[0].end,a=!1)}}function pu(e,t,a,o,r,s){let n=r.beginRuleCapturedEOL?0:-1,i=[];for(let l=r;l;l=l.pop()){let u=l.getRule(e);u instanceof Ta&&i.push({rule:u,stack:l})}for(let l=i.pop();l;l=i.pop()){let{ruleScanner:u,findOptions:f}=wu(l.rule,e,l.stack.endRule,a,o===n),d=u.findNextMatchSync(t,o,f);if(d){if(d.ruleId!==Fs){r=l.stack.pop();break}d.captureIndices&&d.captureIndices.length&&(s.produce(l.stack,d.captureIndices[0].start),Gt(e,t,a,l.stack,s,l.rule.whileCaptures,d.captureIndices),s.produce(l.stack,d.captureIndices[0].end),n=d.captureIndices[0].end,d.captureIndices[0].end>o&&(o=d.captureIndices[0].end,a=!1))}else{r=l.stack.pop();break}}return{stack:r,linePos:o,anchorPosition:n,isFirstLine:a}}function mu(e,t,a,o,r,s){let n=hu(e,t,a,o,r,s),i=e.getInjections();if(i.length===0)return n;let l=gu(i,e,t,a,o,r,s);if(!l)return n;if(!n)return l;let u=n.captureIndices[0].start,f=l.captureIndices[0].start;return f<u||l.priorityMatch&&f===u?l:n}function hu(e,t,a,o,r,s){let n=r.getRule(e),{ruleScanner:i,findOptions:l}=Ns(n,e,r.endRule,a,o===s),u=i.findNextMatchSync(t,o,l);return u?{captureIndices:u.captureIndices,matchedRuleId:u.ruleId}:null}function gu(e,t,a,o,r,s,n){let i=Number.MAX_VALUE,l=null,u,f=0,d=s.contentNameScopesList.getScopeNames();for(let c=0,p=e.length;c<p;c++){let h=e[c];if(!h.matcher(d))continue;let S=t.getRule(h.ruleId),{ruleScanner:L,findOptions:x}=Ns(S,t,null,o,r===n),w=L.findNextMatchSync(a,r,x);if(!w)continue;let m=w.captureIndices[0].start;if(!(m>=i)&&(i=m,l=w.captureIndices,u=w.ruleId,f=h.priority,i===r))break}return l?{priorityMatch:f===-1,captureIndices:l,matchedRuleId:u}:null}function Ns(e,t,a,o,r){if(_s){let n=e.compile(t,a),i=Os(o,r);return{ruleScanner:n,findOptions:i}}return{ruleScanner:e.compileAG(t,a,o,r),findOptions:0}}function wu(e,t,a,o,r){if(_s){let n=e.compileWhile(t,a),i=Os(o,r);return{ruleScanner:n,findOptions:i}}return{ruleScanner:e.compileWhileAG(t,a,o,r),findOptions:0}}function Os(e,t){let a=0;return e||(a|=1),t||(a|=4),a}function Gt(e,t,a,o,r,s,n){if(s.length===0)return;let i=t.content,l=Math.min(s.length,n.length),u=[],f=n[0].end;for(let d=0;d<l;d++){let c=s[d];if(c===null)continue;let p=n[d];if(p.length===0)continue;if(p.start>f)break;for(;u.length>0&&u[u.length-1].endPos<=p.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,p.start):r.produce(o,p.start),c.retokenizeCapturedWithRuleId){let S=c.getName(i,n),L=o.contentNameScopesList.pushAttributed(S,e),x=c.getContentName(i,n),w=L.pushAttributed(x,e),m=o.push(c.retokenizeCapturedWithRuleId,p.start,-1,!1,null,L,w),g=e.createOnigString(i.substring(0,p.end));Es(e,g,a&&p.start===0,p.start,m,r,!1,0),Ms(g);continue}let h=c.getName(i,n);if(h!==null){let L=(u.length>0?u[u.length-1].scopes:o.contentNameScopesList).pushAttributed(h,e);u.push(new xu(L,p.end))}}for(;u.length>0;)r.produceFromScopes(u[u.length-1].scopes,u[u.length-1].endPos),u.pop()}var xu=class{scopes;endPos;constructor(e,t){this.scopes=e,this.endPos=t}};function Lu(e,t,a,o,r,s,n,i){return new Cu(e,t,a,o,r,s,n,i)}function Is(e,t,a,o,r){let s=ka(t,Pa),n=Bs.getCompiledRuleId(a,o,r.repository);for(let i of s)e.push({debugSelector:t,matcher:i.matcher,ruleId:n,grammar:r,priority:i.priority})}function Pa(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(Iu(t[r],o))return a=r+1,!0;return!1})}function Iu(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 Cu=class{constructor(e,t,a,o,r,s,n,i){if(this._rootScopeName=e,this.balancedBracketSelectors=s,this._onigLib=i,this._basicScopeAttributesProvider=new fu(a,o),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=n,this._grammar=Cs(t,null),this._injections=null,this._tokenTypeMatchers=[],r)for(let l of Object.keys(r)){let u=ka(l,Pa);for(let f of u)this._tokenTypeMatchers.push({matcher:f.matcher,type:r[l]})}}_rootId;_lastRuleId;_ruleId2desc;_includedGrammars;_grammarRepository;_grammar;_injections;_basicScopeAttributesProvider;_tokenTypeMatchers;get themeProvider(){return this._grammarRepository}dispose(){for(let e of this._ruleId2desc)e&&e.dispose()}createOnigScanner(e){return this._onigLib.createOnigScanner(e)}createOnigString(e){return this._onigLib.createOnigString(e)}getMetadataForScope(e){return this._basicScopeAttributesProvider.getBasicScopeAttributes(e)}_collectInjections(){let e={lookup: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)Is(t,n,r[n],this,o);let s=this._grammarRepository.injections(a);s&&s.forEach(n=>{let i=this.getExternalGrammar(n);if(i){let l=i.injectionSelector;l&&Is(t,l,i,this,i)}})}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]=Cs(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=Bs.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections());let r;if(!t||t===Fo.NULL){r=!0;let u=this._basicScopeAttributesProvider.getDefaultAttributes(),f=this.themeProvider.getDefaults(),d=Ze.set(0,u.languageId,u.tokenType,null,f.fontStyle,f.foregroundId,f.backgroundId),c=this.getRule(this._rootId).getName(null,null),p;c?p=Wt.createRootAndLookUpScopeName(c,d,this):p=Wt.createRoot("unknown",d),t=new Fo(null,this._rootId,-1,-1,!1,null,p,p)}else r=!1,t.reset();e=e+`
4
+ `;let s=this.createOnigString(e),n=s.content.length,i=new yu(a,e,this._tokenTypeMatchers,this.balancedBracketSelectors),l=Es(this,s,r,0,t,i,!0,o);return Ms(s),{lineLength:n,lineTokens:i,ruleStack:l.stack,stoppedEarly:l.stoppedEarly}}};function Cs(e,t){return e=Hl(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 Wt=class Me{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=bo.push(r,s.scopeNames),o=new Me(o,r,s.encodedTokenAttributes);return o}static createRoot(t,a){return new Me(null,new bo(null,t),a)}static createRootAndLookUpScopeName(t,a,o){let r=o.getMetadataForScope(t),s=new bo(null,t),n=o.themeProvider.themeMatch(s),i=Me.mergeAttributes(a,r,n);return new Me(null,s,i)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(" ")}equals(t){return Me.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),Ze.set(t,a.languageId,a.tokenType,null,r,s,n)}pushAttributed(t,a){if(t===null)return this;if(t.indexOf(" ")===-1)return Me._pushAttributed(this,t,a);let o=t.split(/ /g),r=this;for(let s of o)r=Me._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),i=Me.mergeAttributes(t.tokenAttributes,r,n);return new Me(t,s,i)}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}},Fo=class Je{constructor(t,a,o,r,s,n,i,l){this.parent=t,this.ruleId=a,this.beginRuleCapturedEOL=s,this.endRule=n,this.nameScopesList=i,this.contentNameScopesList=l,this.depth=this.parent?this.parent.depth+1:1,this._enterPos=o,this._anchorPos=r}_stackElementBrand=void 0;static NULL=new Je(null,0,0,0,!1,null,null,null);_enterPos;_anchorPos;depth;equals(t){return t===null?!1:Je._equals(this,t)}static _equals(t,a){return t===a?!0:this._structuralEquals(t,a)?Wt.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(){Je._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(t,a,o,r,s,n,i){return new Je(this,t,a,o,r,s,n,i)}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 Je(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=Wt.fromExtension(t?.nameScopesList??null,a.nameScopesList);return new Je(t,a.ruleId,a.enterPos??-1,a.anchorPos??-1,a.beginRuleCapturedEOL,a.endRule,o,Wt.fromExtension(o,a.contentNameScopesList))}},Su=class{balancedBracketScopes;unbalancedBracketScopes;allowAny=!1;constructor(e,t){this.balancedBracketScopes=e.flatMap(a=>a==="*"?(this.allowAny=!0,[]):ka(a,Pa).map(o=>o.matcher)),this.unbalancedBracketScopes=t.flatMap(a=>ka(a,Pa).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}},yu=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=Ze.set(o,0,n.type,null,-1,0,0));this.balancedBracketSelectors&&(r=this.balancedBracketSelectors.match(s))}if(r&&(o=Ze.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}},ku=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,Lu(e,s,t,a,o,r,this,this._onigLib))}return this._grammars.get(e)}},Us=class{_options;_syncRegistry;_ensureGrammarCache;constructor(e){this._options=e,this._syncRegistry=new ku(zt.createFromRawTheme(e.theme,e.colorMap),e.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(e,t){this._syncRegistry.setTheme(zt.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 Su(a.balancedBracketSelectors||[],a.unbalancedBracketSelectors||[]))}loadGrammar(e){return this._loadGrammar(e,0,null,null,null)}_loadGrammar(e,t,a,o,r){let s=new eu(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)}},Aa=Fo.NULL;var bu=/["&'<>`]/g,Tu=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,Pu=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,Au=/[|\\{}()[\]^$+*?.]/g,Hs=new WeakMap;function qs(e,t){if(e=e.replace(t.subset?vu(t.subset):bu,o),t.subset||t.escapeOnly)return e;return e.replace(Tu,a).replace(Pu,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 vu(e){let t=Hs.get(e);return t||(t=Mu(e),Hs.set(e,t)),t}function Mu(e){let t=[],a=-1;for(;++a<e.length;)t.push(e[a].replace(Au,"\\$&"));return new RegExp("(?:"+t.join("|")+")","g")}var Ru=/[\dA-Fa-f]/;function Gs(e,t,a){let o="&#x"+e.toString(16).toUpperCase();return a&&t&&!Ru.test(String.fromCharCode(t))?o:o+";"}var Fu=/\d/;function Ws(e,t,a){let o="&#"+String(e);return a&&t&&!Fu.test(String.fromCharCode(t))?o:o+";"}var zs=["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"];var va={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"};var js=["cent","copy","divide","gt","lt","not","para","times"];var Vs={}.hasOwnProperty,Do={},Ma;for(Ma in va)Vs.call(va,Ma)&&(Do[va[Ma]]=Ma);var Bu=/[^\dA-Za-z]/;function $s(e,t,a,o){let r=String.fromCharCode(e);if(Vs.call(Do,r)){let s=Do[r],n="&"+s;return a&&zs.includes(s)&&!js.includes(s)&&(!o||t&&t!==61&&Bu.test(String.fromCharCode(t)))?n:n+";"}return""}function Xs(e,t,a){let o=Gs(e,t,a.omitOptionalSemicolons),r;if((a.useNamedReferences||a.useShortestReferences)&&(r=$s(e,t,a.omitOptionalSemicolons,a.attribute)),(a.useShortestReferences||!r)&&a.useShortestReferences){let s=Ws(e,t,a.omitOptionalSemicolons);s.length<o.length&&(o=s)}return r&&(!a.useShortestReferences||r.length<o.length)?r:o}function De(e,t){return qs(e,Object.assign({format:Xs},t))}var Du=/^>|^->|<!--|-->|--!>|<!-$/g,_u=[">"],Eu=["<",">"];function Qs(e,t,a,o){return o.settings.bogusComments?"<?"+De(e.value,Object.assign({},o.settings.characterReferences,{subset:_u}))+">":"<!--"+e.value.replace(Du,r)+"-->";function r(s){return De(s,Object.assign({},o.settings.characterReferences,{subset:Eu}))}}function Ks(e,t,a,o){return"<!"+(o.settings.upperDoctype?"DOCTYPE":"doctype")+(o.settings.tightDoctype?"":" ")+"html>"}var te=Js(1),_o=Js(-1),Nu=[];function Js(e){return t;function t(a,o,r){let s=a?a.children:Nu,n=(o||0)+e,i=s[n];if(!r)for(;i&&it(i);)n+=e,i=s[n];return i}}var Ou={}.hasOwnProperty;function Ra(e){return t;function t(a,o,r){return Ou.call(e,a.tagName)&&e[a.tagName](a,o,r)}}var Qt=Ra({body:Hu,caption:Eo,colgroup:Eo,dd:zu,dt:Wu,head:Eo,html:Uu,li:Gu,optgroup:ju,option:Vu,p:qu,rp:Zs,rt:Zs,tbody:Xu,td:Ys,tfoot:Qu,th:Ys,thead:$u,tr:Ku});function Eo(e,t,a){let o=te(a,t,!0);return!o||o.type!=="comment"&&!(o.type==="text"&&it(o.value.charAt(0)))}function Uu(e,t,a){let o=te(a,t);return!o||o.type!=="comment"}function Hu(e,t,a){let o=te(a,t);return!o||o.type!=="comment"}function qu(e,t,a){let o=te(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 Gu(e,t,a){let o=te(a,t);return!o||o.type==="element"&&o.tagName==="li"}function Wu(e,t,a){let o=te(a,t);return!!(o&&o.type==="element"&&(o.tagName==="dt"||o.tagName==="dd"))}function zu(e,t,a){let o=te(a,t);return!o||o.type==="element"&&(o.tagName==="dt"||o.tagName==="dd")}function Zs(e,t,a){let o=te(a,t);return!o||o.type==="element"&&(o.tagName==="rp"||o.tagName==="rt")}function ju(e,t,a){let o=te(a,t);return!o||o.type==="element"&&o.tagName==="optgroup"}function Vu(e,t,a){let o=te(a,t);return!o||o.type==="element"&&(o.tagName==="option"||o.tagName==="optgroup")}function $u(e,t,a){let o=te(a,t);return!!(o&&o.type==="element"&&(o.tagName==="tbody"||o.tagName==="tfoot"))}function Xu(e,t,a){let o=te(a,t);return!o||o.type==="element"&&(o.tagName==="tbody"||o.tagName==="tfoot")}function Qu(e,t,a){return!te(a,t)}function Ku(e,t,a){let o=te(a,t);return!o||o.type==="element"&&o.tagName==="tr"}function Ys(e,t,a){let o=te(a,t);return!o||o.type==="element"&&(o.tagName==="td"||o.tagName==="th")}var en=Ra({body:Yu,colgroup:ed,head:Zu,html:Ju,tbody:td});function Ju(e){let t=te(e,-1);return!t||t.type!=="comment"}function Zu(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 Yu(e){let t=te(e,-1,!0);return!t||t.type!=="comment"&&!(t.type==="text"&&it(t.value.charAt(0)))&&!(t.type==="element"&&(t.tagName==="meta"||t.tagName==="link"||t.tagName==="script"||t.tagName==="style"||t.tagName==="template"))}function ed(e,t,a){let o=_o(a,t),r=te(e,-1,!0);return a&&o&&o.type==="element"&&o.tagName==="colgroup"&&Qt(o,a.children.indexOf(o),a)?!1:!!(r&&r.type==="element"&&r.tagName==="col")}function td(e,t,a){let o=_o(a,t),r=te(e,-1);return a&&o&&o.type==="element"&&(o.tagName==="thead"||o.tagName==="tbody")&&Qt(o,a.children.indexOf(o),a)?!1:!!(r&&r.type==="element"&&r.tagName==="tr")}var Fa={name:[[`
5
5
  \f\r &/=>`.split(""),`
6
6
  \f\r "&'/=>\``.split("")],[`\0
7
7
  \f\r "&'/<=>`.split(""),`\0
@@ -9,11 +9,11 @@ import{a as Sr,b as yr,c as kr,d as it,e as lt,f as ua,g as br,h as Tr,i as Pr,j
9
9
  \f\r &>`.split(""),`\0
10
10
  \f\r "&'<=>\``.split("")],[`\0
11
11
  \f\r "&'<=>\``.split(""),`\0
12
- \f\r "&'<=>\``.split("")]],single:[["&'".split(""),"\"&'`".split("")],["\0&'".split(""),"\0\"&'`".split("")]],double:[['"&'.split(""),"\"&'`".split("")],['\0"&'.split(""),"\0\"&'`".split("")]]};function rn(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=dd(o,e.properties),f=o.all(r.space==="html"&&e.tagName==="template"?e.content:e);return o.schema=r,f&&(n=!1),(u||!s||!on(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(f),!n&&(!s||!Jt(e,t,a))&&l.push("</"+e.tagName+">"),l.join("")}function dd(e,t){let a=[],o=-1,r;if(t){for(r in t)if(t[r]!==null&&t[r]!==void 0){let s=fd(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 fd(e,t,a){let o=Pr(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=_e(o.attribute,Object.assign({},e.settings.characterReferences,{subset:Ea.name[r][s]}));return a===!0||(a=Array.isArray(a)?(o.commaSeparated?Mr:Rr)(a,{padLeft:!e.settings.tightCommaSeparatedLists}):String(a),e.settings.collapseEmptyAttributes&&!a)?i:(e.settings.preferUnquoted&&(l=_e(a,Object.assign({},e.settings.characterReferences,{attribute:!0,subset:Ea.unquoted[r][s]}))),l!==a&&(e.settings.quoteSmart&&mo(a,n)>mo(a,e.alternative)&&(n=e.alternative),l=n+_e(a,Object.assign({},e.settings.characterReferences,{subset:(n==="'"?Ea.single:Ea.double)[r][s],attribute:!0}))+n),i+(l&&"="+l))}var cd=["<","&"];function _a(e,t,a,o){return a&&a.type==="element"&&(a.tagName==="script"||a.tagName==="style")?e.value:_e(e.value,Object.assign({},o.settings.characterReferences,{subset:cd}))}function sn(e,t,a,o){return o.settings.allowDangerousHtml?e.value:_a(e,t,a,o)}function nn(e,t,a,o){return o.all(e)}var ln=vr("type",{invalid:pd,unknown:md,handlers:{comment:Zs,doctype:Ys,element:rn,raw:sn,root:nn,text:_a}});function pd(e){throw new Error("Expected node, not `"+e+"`")}function md(e){let t=e;throw new Error("Cannot compile unknown node `"+t.type+"`")}var hd={},gd={},wd=[];function Ho(e,t){let a=t||hd,o=a.quote||'"',r=o==='"'?"'":'"';if(o!=='"'&&o!=="'")throw new Error("Invalid quote `"+o+"`, expected `'` or `\"`");return{one:xd,all:Ld,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||Tr,characterReferences:a.characterReferences||gd,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 xd(e,t,a){return ln(e,t,a,this)}function Ld(e){let t=[],a=e&&e.children||wd,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 ze(e,t){return e&&(t?.[e?.toLowerCase()]||e)}function Cd(e){return Array.isArray(e)?e:[e]}async function hn(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 gn(e){return e==="ansi"||Vo(e)}function $o(e){return e==="none"}function wn(e){return $o(e)}function xn(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 Id(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 Ln(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()",Sd=["color","background-color"];function yd(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 kd(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?yd(r,s):r})):e}function bd(e,t,a,o,r="css-vars"){let s={content:e.content,explanation:e.explanation,offset:e.offset},n=t.map(f=>Oa(e.variants[f])),l=new Set(n.flatMap(f=>Object.keys(f))),i={},u=(f,d)=>{let c=d==="color"?"":d==="background-color"?"-bg":`-${d}`;return a+t[f]+(d==="color"?"":c)};return n.forEach((f,d)=>{for(let c of l){let p=f[c]||"inherit";if(d===0&&o&&Sd.includes(c))if(o===Xo&&n.length>1){let h=t.findIndex(w=>w==="light"),I=t.findIndex(w=>w==="dark");if(h===-1||I===-1)throw new K('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');let L=n[h][c]||"inherit",x=n[I][c]||"inherit";i[c]=`light-dark(${L}, ${x})`,r==="css-vars"&&(i[u(d,c)]=p)}else i[c]=p;else r==="css-vars"&&(i[u(d,c)]=p)}}),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&fe.Italic&&(t["font-style"]="italic"),e.fontStyle&fe.Bold&&(t["font-weight"]="bold");let a=[];e.fontStyle&fe.Underline&&a.push("underline"),e.fontStyle&fe.Strikethrough&&a.push("line-through"),a.length&&(t["text-decoration"]=a.join(" "))}return t}function Wo(e){return typeof e=="string"?e:Object.entries(e).map(([t,a])=>`${t}:${a}`).join(";")}var Cn=new WeakMap;function Wa(e,t){Cn.set(e,t)}function Yt(e){return Cn.get(e)}var xt=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(Cd(a).map(o=>[o,Ra])),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 Td(this._stacks[t])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}};function Td(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 Pd(e,t){if(!(e instanceof xt))throw new K("Invalid grammar state");return e.getInternalStack(t)}function Ad(){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 K(`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 K(`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 K(`Invalid decoration position ${JSON.stringify(n)}. Line ${n.line} length: ${l.length}`);return{...n,character:i,offset:r.posToIndex(n.line,i)}}},r=Id(a.source),s=(a.options.decorations||[]).map(n=>({...n,start:o(n.start),end:o(n.end)}));vd(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 kd(a,r)},code(a){if(!this.options.decorations?.length)return;let o=t(this),r=Array.from(a.children).filter(f=>f.type==="element"&&f.tagName==="span");if(r.length!==o.converter.lines.length)throw new K(`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(f,d,c,p){let h=r[f],I="",L=-1,x=-1;if(d===0&&(L=0),c===0&&(x=0),c===Number.POSITIVE_INFINITY&&(x=h.children.length),L===-1||x===-1)for(let m=0;m<h.children.length;m++)I+=In(h.children[m]),L===-1&&I.length===d&&(L=m+1),x===-1&&I.length===c&&(x=m+1);if(L===-1)throw new K(`Failed to find start index for decoration ${JSON.stringify(p.start)}`);if(x===-1)throw new K(`Failed to find end index for decoration ${JSON.stringify(p.end)}`);let w=h.children.slice(L,x);if(!p.alwaysWrap&&w.length===h.children.length)l(h,p,"line");else if(!p.alwaysWrap&&w.length===1&&w[0].type==="element")l(w[0],p,"token");else{let m={type:"element",tagName:"span",properties:{},children:w};l(m,p,"wrapper"),h.children.splice(L,w.length,m)}}function n(f,d){r[f]=l(r[f],d,"line")}function l(f,d,c){let p=d.properties||{},h=d.transform||(I=>I);return f.tagName=d.tagName||"span",f.properties={...f.properties,...p,class:f.properties.class},d.properties?.class&&xn(f,d.properties.class),f=h(f,c)||f,f}let i=[],u=o.decorations.sort((f,d)=>d.start.offset-f.start.offset||f.end.offset-d.end.offset);for(let f of u){let{start:d,end:c}=f;if(d.line===c.line)s(d.line,d.character,c.character,f);else if(d.line<c.line){s(d.line,d.character,Number.POSITIVE_INFINITY,f);for(let p=d.line+1;p<c.line;p++)i.unshift(()=>n(p,f));s(c.line,0,c.character,f)}}i.forEach(f=>f())}}}function vd(e){for(let t=0;t<e.length;t++){let a=e[t];if(a.start.offset>a.end.offset)throw new K(`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 K(`Decorations ${JSON.stringify(a.start)} and ${JSON.stringify(r.start)} intersect.`)}}}}function In(e){return e.type==="text"?e.value:e.type==="element"?e.children.map(In).join(""):""}var Md=[Ad()];function Ua(e){let t=Rd(e.transformers||[]);return[...t.pre,...t.normal,...t.post,...Md]}function Rd(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 tt=["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 Fd(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 un(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 Bd(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:tt[o-30]}});else if(o===38){let r=un(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:tt[o-40]}});else if(o===48){let r=un(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:tt[o-90+8]}}):o>=100&&o<=107&&t.push({type:"setBackgroundColor",value:{type:"named",name:tt[o-100+8]}})}return t}function Dd(){let e=null,t=null,a=new Set;return{parse(o){let r=[],s=0;do{let n=Fd(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=Bd(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 Ed={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 _d(e=Ed){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<tt.length;u++)o.push(t(tt[u]));let l=[0,95,135,175,215,255];for(let u=0;u<6;u++)for(let f=0;f<6;f++)for(let d=0;d<6;d++)o.push(a([l[u],l[f],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 Nd={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 Od(e,t,a){let o=Na(e,a),r=Ga(t),s=Object.fromEntries(tt.map(i=>{let u=`terminal.ansi${i[0].toUpperCase()}${i.substring(1)}`,f=e.colors?.[u];return[i,f||Nd[i]]})),n=_d(s),l=Dd();return r.map(i=>l.parse(i[0]).map(u=>{let f,d;u.decorations.has("reverse")?(f=u.background?n.value(u.background):e.bg,d=u.foreground?n.value(u.foreground):e.fg):(f=u.foreground?n.value(u.foreground):e.fg,d=u.background?n.value(u.background):void 0),f=ze(f,o),d=ze(d,o),u.decorations.has("dim")&&(f=Ud(f));let c=fe.None;return u.decorations.has("bold")&&(c|=fe.Bold),u.decorations.has("italic")&&(c|=fe.Italic),u.decorations.has("underline")&&(c|=fe.Underline),u.decorations.has("strikethrough")&&(c|=fe.Strikethrough),{content:u.value,offset:i[1],color:f,bgColor:d,fontStyle:c}}))}function Ud(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 Ga(t).map(i=>[{content:i[0],offset:i[1]}]);let{theme:s,colorMap:n}=e.setTheme(o);if(r==="ansi")return Od(s,t,a);let l=e.getLanguage(a.lang||"text");if(a.grammarState){if(a.grammarState.lang!==l.name)throw new K(`Grammar state language "${a.grammarState.lang}" does not match highlight language "${l.name}"`);if(!a.grammarState.themes.includes(s.name))throw new K(`Grammar state themes "${a.grammarState.themes}" do not contain highlight theme "${s.name}"`)}return qd(t,l,s,n,a)}function Hd(...e){if(e.length===2)return Yt(e[1]);let[t,a,o={}]=e,{lang:r="text",theme:s=t.getLoadedThemes()[0]}=o;if(Vo(r)||$o(s))throw new K("Plain language does not have grammar state");if(r==="ansi")throw new K("ANSI language does not have grammar state");let{theme:n,colorMap:l}=t.setTheme(s),i=t.getLanguage(r);return new xt(Qo(a,i,n,l,o).stateStack,i.name,n.name)}function qd(e,t,a,o,r){let s=Qo(e,t,a,o,r),n=new xt(s.stateStack,t.name,a.name);return Wa(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=Ga(e),u=r.grammarState?Pd(r.grammarState,a.name)??Ra:r.grammarContextCode!=null?Qo(r.grammarContextCode,t,a,o,{...r,grammarState:void 0,grammarContextCode:void 0}).stateStack:Ra,f=[],d=[];for(let c=0,p=i.length;c<p;c++){let[h,I]=i[c];if(h===""){f=[],d.push([]);continue}if(n>0&&h.length>=n){f=[],d.push([{content:h,offset:I,color:"",fontStyle:0}]);continue}let L,x,w;r.includeExplanation&&(L=t.tokenizeLine(h,u,l),x=L.tokens,w=0);let m=t.tokenizeLine2(h,u,l),g=m.tokens.length/2;for(let C=0;C<g;C++){let b=m.tokens[2*C],y=C+1<g?m.tokens[2*C+2]:h.length;if(b===y)continue;let B=m.tokens[2*C+1],N=ze(o[et.getForeground(B)],s),R=et.getFontStyle(B),k={content:h.substring(b,y),offset:I+b,color:N,fontStyle:R};if(r.includeExplanation){let P=[];if(r.includeExplanation!=="scopeName")for(let U of a.settings){let D;switch(typeof U.scope){case"string":D=U.scope.split(/,/).map(z=>z.trim());break;case"object":D=U.scope;break;default:continue}P.push({settings:U,selectors:D.map(z=>z.split(/ /))})}k.explanation=[];let Y=0;for(;b+Y<y;){let U=x[w],D=h.substring(U.startIndex,U.endIndex);Y+=D.length,k.explanation.push({content:D,scopes:r.includeExplanation==="scopeName"?Gd(U.scopes):Wd(P,U.scopes)}),w+=1}}f.push(k)}d.push(f),f=[],u=m.ruleStack}return{tokens:d,stateStack:u}}function Gd(e){return e.map(t=>({scopeName:t}))}function Wd(e,t){let a=[];for(let o=0,r=t.length;o<r;o++){let s=t[o];a[o]={scopeName:s,themeMatches:jd(e,s,t.slice(0,o))}}return a}function dn(e,t){return e===t||t.substring(0,e.length)===e&&t[e.length]==="."}function zd(e,t,a){if(!dn(e[e.length-1],t))return!1;let o=e.length-2,r=a.length-1;for(;o>=0&&r>=0;)dn(e[o],a[r])&&(o-=1),r-=1;return o===-1}function jd(e,t,a){let o=[];for(let{selectors:r,settings:s}of e)for(let n of r)if(zd(n,t,a)){o.push(s);break}return o}function Sn(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}),f=Yt(u),d=typeof i.theme=="string"?i.theme:i.theme.name;return{tokens:u,state:f,theme:d}}),s=Vd(...r.map(i=>i.tokens)),n=s[0].map((i,u)=>i.map((f,d)=>{let c={content:f.content,variants:{},offset:f.offset};return"includeExplanation"in a&&a.includeExplanation&&(c.explanation=f.explanation),s.forEach((p,h)=>{let{content:I,explanation:L,offset:x,...w}=p[u][d];c.variants[o[h].color]=w}),c})),l=r[0].state?new xt(Object.fromEntries(r.map(i=>[i.theme,i.state?.getInternalStack(i.theme)])),r[0].state.lang):void 0;return l&&Wa(n,l),n}function Vd(...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 f=l[u];f.content.length===i?(s[u].push(f),n[u]+=1,l[u]=r[u][n[u]]):(s[u].push({...f,content:f.content.slice(0,i)}),l[u]={...f,content:f.content.slice(i),offset:f.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:f="--shiki-",colorsRendering:d="css-vars"}=a,c=Object.entries(a.themes).filter(x=>x[1]).map(x=>({color:x[0],theme:x[1]})).sort((x,w)=>x.color===u?-1:w.color===u?1:0);if(c.length===0)throw new K("`themes` option must not be empty");let p=Sn(e,t,a);if(i=Yt(p),u&&Xo!==u&&!c.find(x=>x.color===u))throw new K(`\`themes\` option must contain the defaultColor key \`${u}\``);let h=c.map(x=>e.getTheme(x.theme)),I=c.map(x=>x.color);s=p.map(x=>x.map(w=>bd(w,I,f,u,d))),i&&Wa(s,i);let L=c.map(x=>Na(x.theme,a));r=fn(c,h,L,f,u,"fg",d),o=fn(c,h,L,f,u,"bg",d),n=`shiki-themes ${h.map(x=>x.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 f=e.getTheme(a.theme);o=ze(f.bg,u),r=ze(f.fg,u),n=f.name,i=Yt(s)}else throw new K("Invalid options, either `theme` or `themes` must be provided");return{tokens:s,fg:r,bg:o,themeName:n,rootStyle:l,grammarState:i}}function fn(e,t,a,o,r,s,n){return e.map((l,i)=>{let u=ze(t[i][s],a[i])||"inherit",f=`${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"),c=e.findIndex(I=>I.color==="dark");if(d===-1||c===-1)throw new K('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');let p=ze(t[d][s],a[d])||"inherit",h=ze(t[c][s],a[c])||"inherit";return`light-dark(${p}, ${h});${f}`}return u}return n==="css-vars"?f: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:f}=Ha(e,r,a),{mergeWhitespaces:d=!0,mergeSameStyleTokens:c=!1}=a;d===!0?s=Xd(s):d==="never"&&(s=Kd(s)),c&&(s=Qd(s));let p={...o,get source(){return r}};for(let h of Ua(a))s=h.tokens?.call(p,s)||s;return $d(s,{...a,fg:n,bg:l,themeName:i,rootStyle:a.rootStyle===!1?!1:a.rootStyle??u},p,f)}function $d(e,t,a,o=Yt(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 f={type:"element",tagName:"pre",properties:u,children:[],data:t.data},d={type:"element",tagName:"code",properties:{},children:s},c=[],p={...a,structure:l,addClassToHast:xn,get source(){return a.source},get tokens(){return e},get options(){return t},get root(){return n},get pre(){return f},get code(){return d},get lines(){return c}};if(e.forEach((I,L)=>{L&&(l==="inline"?n.children.push({type:"element",tagName:"br",properties:{},children:[]}):l==="classic"&&s.push({type:"text",value:`
13
- `}));let x={type:"element",tagName:"span",properties:{class:"line"},children:[]},w=0;for(let m of I){let g={type:"element",tagName:"span",properties:{...m.htmlAttrs},children:[{type:"text",value:m.content}]},C=Wo(m.htmlStyle||Oa(m));C&&(g.properties.style=C);for(let b of r)g=b?.span?.call(p,g,L+1,w,x,m)||g;l==="inline"?n.children.push(g):l==="classic"&&x.children.push(g),w+=m.content.length}if(l==="classic"){for(let m of r)x=m?.line?.call(p,x,L+1)||x;c.push(x),s.push(x)}else l==="inline"&&c.push(x)}),l==="classic"){for(let I of r)d=I?.code?.call(p,d)||d;f.children.push(d);for(let I of r)f=I?.pre?.call(p,f)||f;n.children.push(f)}else if(l==="inline"){let I=[],L={type:"element",tagName:"span",properties:{class:"line"},children:[]};for(let m of n.children)m.type==="element"&&m.tagName==="br"?(I.push(L),L={type:"element",tagName:"span",properties:{class:"line"},children:[]}):(m.type==="element"||m.type==="text")&&L.children.push(m);I.push(L);let w={type:"element",tagName:"code",properties:{},children:I};for(let m of r)w=m?.code?.call(p,w)||w;n.children=[];for(let m=0;m<w.children.length;m++){m>0&&n.children.push({type:"element",tagName:"br",properties:{},children:[]});let g=w.children[m];g.type==="element"&&n.children.push(...g.children)}}let h=n;for(let I of r)h=I?.root?.call(p,h)||h;return o&&Wa(h,o),h}function Xd(e){return e.map(t=>{let a=[],o="",r;return t.forEach((s,n)=>{let i=!(s.fontStyle&&(s.fontStyle&fe.Underline||s.fontStyle&fe.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 Kd(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 Qd(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=Wo(r.htmlStyle||Oa(r)),n=Wo(o.htmlStyle||Oa(o)),l=r.fontStyle&&(r.fontStyle&fe.Underline||r.fontStyle&fe.Strikethrough),i=o.fontStyle&&(o.fontStyle&fe.Underline||o.fontStyle&fe.Strikethrough);!l&&!i&&s===n?r.content+=o.content:a.push({...o})}return a})}var Jd=Ho;function Zd(e,t,a){let o={meta:{},options:a,codeToHast:(s,n)=>qa(e,s,n),codeToTokens:(s,n)=>Ha(e,s,n)},r=Jd(qa(e,t,a,o));for(let s of Ua(a))r=s.postprocess?.call(o,r,a)||r;return r}var cn={light:"#333333",dark:"#bbbbbb"},pn={light:"#fffffe",dark:"#1e1e1e"},mn="__shiki_resolved";function Jo(e){if(e?.[mn])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"?cn.light:cn.dark),a||(a=t.type==="light"?pn.light:pn.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 f={...l,settings:{...l.settings}};if(i){let d=n(l.settings.foreground);t.colorReplacements[d]=l.settings.foreground,f.settings.foreground=d}if(u){let d=n(l.settings.background);t.colorReplacements[d]=l.settings.background,f.settings.background=d}return f});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,mn,{enumerable:!1,writable:!1,value:!0}),t}async function yn(e){return Array.from(new Set((await Promise.all(e.filter(t=>!gn(t)).map(async t=>await hn(t).then(a=>Array.isArray(a)?a:[a])))).flat()))}async function kn(e){return(await Promise.all(e.map(async a=>wn(a)?null:Jo(await hn(a))))).filter(a=>!!a)}var Go=3,Yd=!1;function ef(e,t=3){if(Go&&!(typeof Go=="number"&&t>Go)){if(Yd)throw new Error(`[SHIKI DEPRECATE]: ${e}`);console.trace(`[SHIKI DEPRECATE]: ${e}`)}}var We=class extends Error{constructor(t){super(t),this.name="ShikiError"}};function bn(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 We(`Circular alias \`${Array.from(a).join(" -> ")} -> ${e}\``);a.add(e)}}return e}var zo=class extends Gs{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=Vt.createFromRawTheme(t),this._textmateThemeCache.set(t,a)),this._syncRegistry.setTheme(a)}getGrammar(t){return t=bn(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 We(`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))}},jo=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}},Zt=0;function tf(e){Zt+=1,e.warnings!==!1&&Zt>=10&&Zt%10===0&&console.warn(`[Shiki] ${Zt} 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 We("`engine` option is required for synchronous mode");let a=(e.langs||[]).flat(1),o=(e.themes||[]).flat(1).map(Jo),r=new jo(e.engine,a),s=new zo(r,o,a,e.langAlias),n;function l(m){return bn(m,e.langAlias)}function i(m){x();let g=s.getGrammar(typeof m=="string"?m:m.name);if(!g)throw new We(`Language \`${m}\` not found, you may need to load it first`);return g}function u(m){if(m==="none")return{bg:"",fg:"",name:"none",settings:[],type:"dark"};x();let g=s.getTheme(m);if(!g)throw new We(`Theme \`${m}\` not found, you may need to load it first`);return g}function f(m){x();let g=u(m);n!==m&&(s.setTheme(g),n=m);let C=s.getColorMap();return{theme:g,colorMap:C}}function d(){return x(),s.getLoadedThemes()}function c(){return x(),s.getLoadedLanguages()}function p(...m){x(),s.loadLanguages(m.flat(1))}async function h(...m){return p(await yn(m))}function I(...m){x();for(let g of m.flat(1))s.loadTheme(g)}async function L(...m){return x(),I(await kn(m))}function x(){if(t)throw new We("Shiki instance has been disposed")}function w(){t||(t=!0,s.dispose(),Zt-=1)}return{setTheme:f,getTheme:u,getLanguage:i,getLoadedThemes:d,getLoadedLanguages:c,resolveLangAlias:l,loadLanguage:h,loadLanguageSync:p,loadTheme:L,loadThemeSync:I,dispose:w,[Symbol.dispose]:w}}async function af(e){e.engine||ef("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");let[t,a,o]=await Promise.all([kn(e.themes||[]),yn(e.langs||[]),e.engine]);return tf({...e,themes:t,langs:a,engine:o})}async function of(e){let t=await af(e);return{getLastGrammarState:(...a)=>Hd(t,...a),codeToTokensBase:(a,o)=>Ko(t,a,o),codeToTokensWithThemes:(a,o)=>Sn(t,a,o),codeToTokens:(a,o)=>Ha(t,a,o),codeToHast:(a,o)=>qa(t,a,o),codeToHtml:(a,o)=>Zd(t,a,o),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...t,getInternalContext:()=>t}}function Tn(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,gn(d))return[];let c=t[d];if(!c)throw new K(`Language \`${d}\` is not included in this bundle. You may want to load it from external source.`);return c}return d}function l(d){if(wn(d))return"none";if(typeof d=="string"){let c=a[d];if(!c)throw new K(`Theme \`${d}\` is not included in this bundle. You may want to load it from external source.`);return c}return d}let i=(s.themes??[]).map(d=>l(d)),u=(s.langs??[]).map(d=>n(d)),f=await of({engine:s.engine??o(),...s,themes:i,langs:u});return{...f,loadLanguage(...d){return f.loadLanguage(...d.map(n))},loadTheme(...d){return f.loadTheme(...d.map(l))},getBundledLanguages(){return t},getBundledThemes(){return a}}}return r}function rf(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 Pn(e,t){let a=rf(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)}}}var Zo=[{id:"abap",name:"ABAP",import:(()=>import("../abap-KGVIZMDC.js"))},{id:"actionscript-3",name:"ActionScript",import:(()=>import("../actionscript-3-2UHK5QYP.js"))},{id:"ada",name:"Ada",import:(()=>import("../ada-JKTWR5BV.js"))},{id:"angular-html",name:"Angular HTML",import:(()=>import("../angular-html-EOIKHM3D.js"))},{id:"angular-ts",name:"Angular TypeScript",import:(()=>import("../angular-ts-A7ZNTSV6.js"))},{id:"apache",name:"Apache Conf",import:(()=>import("../apache-MPGFGQFB.js"))},{id:"apex",name:"Apex",import:(()=>import("../apex-BOAZL66Z.js"))},{id:"apl",name:"APL",import:(()=>import("../apl-QBN4KIYA.js"))},{id:"applescript",name:"AppleScript",import:(()=>import("../applescript-C4CJ3STL.js"))},{id:"ara",name:"Ara",import:(()=>import("../ara-FSFFBRSD.js"))},{id:"asciidoc",name:"AsciiDoc",aliases:["adoc"],import:(()=>import("../asciidoc-QQK2LANG.js"))},{id:"asm",name:"Assembly",import:(()=>import("../asm-X43A2VYW.js"))},{id:"astro",name:"Astro",import:(()=>import("../astro-OQUOYMBE.js"))},{id:"awk",name:"AWK",import:(()=>import("../awk-4Z3PRTF7.js"))},{id:"ballerina",name:"Ballerina",import:(()=>import("../ballerina-JCXSJ2QD.js"))},{id:"bat",name:"Batch File",aliases:["batch"],import:(()=>import("../bat-XFWR7RMZ.js"))},{id:"beancount",name:"Beancount",import:(()=>import("../beancount-7BBDB4BH.js"))},{id:"berry",name:"Berry",aliases:["be"],import:(()=>import("../berry-PQ2BEJIZ.js"))},{id:"bibtex",name:"BibTeX",import:(()=>import("../bibtex-J2PAB23I.js"))},{id:"bicep",name:"Bicep",import:(()=>import("../bicep-TNKT6R3W.js"))},{id:"blade",name:"Blade",import:(()=>import("../blade-QBDEYXMB.js"))},{id:"bsl",name:"1C (Enterprise)",aliases:["1c"],import:(()=>import("../bsl-PQW6E45S.js"))},{id:"c",name:"C",import:(()=>import("../c-PZBJFNXE.js"))},{id:"c3",name:"C3",import:(()=>import("../c3-GP7XYHE6.js"))},{id:"cadence",name:"Cadence",aliases:["cdc"],import:(()=>import("../cadence-NABGDHKY.js"))},{id:"cairo",name:"Cairo",import:(()=>import("../cairo-WQSC2GLN.js"))},{id:"clarity",name:"Clarity",import:(()=>import("../clarity-NXNSINKX.js"))},{id:"clojure",name:"Clojure",aliases:["clj"],import:(()=>import("../clojure-Y57BKRMA.js"))},{id:"cmake",name:"CMake",import:(()=>import("../cmake-LVMEA3JZ.js"))},{id:"cobol",name:"COBOL",import:(()=>import("../cobol-6DNJTKH3.js"))},{id:"codeowners",name:"CODEOWNERS",import:(()=>import("../codeowners-JYHOTXQS.js"))},{id:"codeql",name:"CodeQL",aliases:["ql"],import:(()=>import("../codeql-IWWSYR3L.js"))},{id:"coffee",name:"CoffeeScript",aliases:["coffeescript"],import:(()=>import("../coffee-NNDQ5QXC.js"))},{id:"common-lisp",name:"Common Lisp",aliases:["lisp"],import:(()=>import("../common-lisp-JKXCDYH3.js"))},{id:"coq",name:"Coq",import:(()=>import("../coq-BEHPNP64.js"))},{id:"cpp",name:"C++",aliases:["c++"],import:(()=>import("../cpp-IALOHSZA.js"))},{id:"crystal",name:"Crystal",import:(()=>import("../crystal-ZDP3FIUI.js"))},{id:"csharp",name:"C#",aliases:["c#","cs"],import:(()=>import("../csharp-ODFBXRGA.js"))},{id:"css",name:"CSS",import:(()=>import("../css-CJGL5AVH.js"))},{id:"csv",name:"CSV",import:(()=>import("../csv-LIK4TU3Z.js"))},{id:"cue",name:"CUE",import:(()=>import("../cue-UAAEAKHI.js"))},{id:"cypher",name:"Cypher",aliases:["cql"],import:(()=>import("../cypher-SZPVUQZJ.js"))},{id:"d",name:"D",import:(()=>import("../d-VSCA3XHG.js"))},{id:"dart",name:"Dart",import:(()=>import("../dart-A4PE6FIS.js"))},{id:"dax",name:"DAX",import:(()=>import("../dax-TILIKSFB.js"))},{id:"desktop",name:"Desktop",import:(()=>import("../desktop-75KK3D55.js"))},{id:"diff",name:"Diff",import:(()=>import("../diff-HOT6P45M.js"))},{id:"docker",name:"Dockerfile",aliases:["dockerfile"],import:(()=>import("../docker-FF35TY6T.js"))},{id:"dotenv",name:"dotEnv",import:(()=>import("../dotenv-FVPPHJI3.js"))},{id:"dream-maker",name:"Dream Maker",import:(()=>import("../dream-maker-SYE3ZPSJ.js"))},{id:"edge",name:"Edge",import:(()=>import("../edge-CCLQ2CKA.js"))},{id:"elixir",name:"Elixir",import:(()=>import("../elixir-F6DQGRKA.js"))},{id:"elm",name:"Elm",import:(()=>import("../elm-5QRQXDZ6.js"))},{id:"emacs-lisp",name:"Emacs Lisp",aliases:["elisp"],import:(()=>import("../emacs-lisp-NJ4S4OHV.js"))},{id:"erb",name:"ERB",import:(()=>import("../erb-HGSLHT5Y.js"))},{id:"erlang",name:"Erlang",aliases:["erl"],import:(()=>import("../erlang-APEONNZ6.js"))},{id:"fennel",name:"Fennel",import:(()=>import("../fennel-7OCMFVPS.js"))},{id:"fish",name:"Fish",import:(()=>import("../fish-BC46ME2N.js"))},{id:"fluent",name:"Fluent",aliases:["ftl"],import:(()=>import("../fluent-MXZS6EX3.js"))},{id:"fortran-fixed-form",name:"Fortran (Fixed Form)",aliases:["f","for","f77"],import:(()=>import("../fortran-fixed-form-35BC2KX6.js"))},{id:"fortran-free-form",name:"Fortran (Free Form)",aliases:["f90","f95","f03","f08","f18"],import:(()=>import("../fortran-free-form-AXRAI2HH.js"))},{id:"fsharp",name:"F#",aliases:["f#","fs"],import:(()=>import("../fsharp-JKNSQXHD.js"))},{id:"gdresource",name:"GDResource",aliases:["tscn","tres"],import:(()=>import("../gdresource-ZMKZGPZV.js"))},{id:"gdscript",name:"GDScript",aliases:["gd"],import:(()=>import("../gdscript-HNCVXEYB.js"))},{id:"gdshader",name:"GDShader",import:(()=>import("../gdshader-XAJ4QRYP.js"))},{id:"genie",name:"Genie",import:(()=>import("../genie-HEFVQZAP.js"))},{id:"gherkin",name:"Gherkin",import:(()=>import("../gherkin-OFBRDPXX.js"))},{id:"git-commit",name:"Git Commit Message",import:(()=>import("../git-commit-ZE2M3Q5H.js"))},{id:"git-rebase",name:"Git Rebase Message",import:(()=>import("../git-rebase-3N3INGLU.js"))},{id:"gleam",name:"Gleam",import:(()=>import("../gleam-NFFQFQLP.js"))},{id:"glimmer-js",name:"Glimmer JS",aliases:["gjs"],import:(()=>import("../glimmer-js-RSUW6JYN.js"))},{id:"glimmer-ts",name:"Glimmer TS",aliases:["gts"],import:(()=>import("../glimmer-ts-EZGWLX5T.js"))},{id:"glsl",name:"GLSL",import:(()=>import("../glsl-VJLRYEVJ.js"))},{id:"gn",name:"GN",import:(()=>import("../gn-UH2XQWLG.js"))},{id:"gnuplot",name:"Gnuplot",import:(()=>import("../gnuplot-K6IV6NNR.js"))},{id:"go",name:"Go",import:(()=>import("../go-BDV7RR5G.js"))},{id:"graphql",name:"GraphQL",aliases:["gql"],import:(()=>import("../graphql-YEJQLMOO.js"))},{id:"groovy",name:"Groovy",import:(()=>import("../groovy-SX7K3XGL.js"))},{id:"hack",name:"Hack",import:(()=>import("../hack-3TGPQNR2.js"))},{id:"haml",name:"Ruby Haml",import:(()=>import("../haml-335RVEQR.js"))},{id:"handlebars",name:"Handlebars",aliases:["hbs"],import:(()=>import("../handlebars-73IS6B2J.js"))},{id:"haskell",name:"Haskell",aliases:["hs"],import:(()=>import("../haskell-P5PTJARU.js"))},{id:"haxe",name:"Haxe",import:(()=>import("../haxe-RCPSSA3N.js"))},{id:"hcl",name:"HashiCorp HCL",import:(()=>import("../hcl-AKKZAVC2.js"))},{id:"hjson",name:"Hjson",import:(()=>import("../hjson-REXV6F6N.js"))},{id:"hlsl",name:"HLSL",import:(()=>import("../hlsl-AJ7VWOVL.js"))},{id:"html",name:"HTML",import:(()=>import("../html-654LNGWF.js"))},{id:"html-derivative",name:"HTML (Derivative)",import:(()=>import("../html-derivative-CMQ7BFDQ.js"))},{id:"http",name:"HTTP",import:(()=>import("../http-NEPTRAQZ.js"))},{id:"hurl",name:"Hurl",import:(()=>import("../hurl-V6ZX2Q3F.js"))},{id:"hxml",name:"HXML",import:(()=>import("../hxml-5BXJCAAU.js"))},{id:"hy",name:"Hy",import:(()=>import("../hy-SB4TMFE7.js"))},{id:"imba",name:"Imba",import:(()=>import("../imba-Y64MHYWP.js"))},{id:"ini",name:"INI",aliases:["properties"],import:(()=>import("../ini-J2OP4CNW.js"))},{id:"java",name:"Java",import:(()=>import("../java-MJKJ5GPP.js"))},{id:"javascript",name:"JavaScript",aliases:["js","cjs","mjs"],import:(()=>import("../javascript-IYAGHPR6.js"))},{id:"jinja",name:"Jinja",import:(()=>import("../jinja-WPD26JJ6.js"))},{id:"jison",name:"Jison",import:(()=>import("../jison-UYDZQBN5.js"))},{id:"json",name:"JSON",import:(()=>import("../json-5V4JESJO.js"))},{id:"json5",name:"JSON5",import:(()=>import("../json5-7SHUZD3R.js"))},{id:"jsonc",name:"JSON with Comments",import:(()=>import("../jsonc-X3Z34FN3.js"))},{id:"jsonl",name:"JSON Lines",import:(()=>import("../jsonl-6I3D2HM6.js"))},{id:"jsonnet",name:"Jsonnet",import:(()=>import("../jsonnet-PZEQIBYV.js"))},{id:"jssm",name:"JSSM",aliases:["fsl"],import:(()=>import("../jssm-GJJ25IKR.js"))},{id:"jsx",name:"JSX",import:(()=>import("../jsx-NI2J427C.js"))},{id:"julia",name:"Julia",aliases:["jl"],import:(()=>import("../julia-QPZ7EOS6.js"))},{id:"kdl",name:"KDL",import:(()=>import("../kdl-IA7HA2TL.js"))},{id:"kotlin",name:"Kotlin",aliases:["kt","kts"],import:(()=>import("../kotlin-CCRMGYMI.js"))},{id:"kusto",name:"Kusto",aliases:["kql"],import:(()=>import("../kusto-7DW25GYH.js"))},{id:"latex",name:"LaTeX",import:(()=>import("../latex-F2CTDTFG.js"))},{id:"lean",name:"Lean 4",aliases:["lean4"],import:(()=>import("../lean-MGJJWBTR.js"))},{id:"less",name:"Less",import:(()=>import("../less-WFSIMX5G.js"))},{id:"liquid",name:"Liquid",import:(()=>import("../liquid-7CFNUD3V.js"))},{id:"llvm",name:"LLVM IR",import:(()=>import("../llvm-CFQSEDXB.js"))},{id:"log",name:"Log file",import:(()=>import("../log-YQNML6LA.js"))},{id:"logo",name:"Logo",import:(()=>import("../logo-2PPKBL2M.js"))},{id:"lua",name:"Lua",import:(()=>import("../lua-RPAMRKNG.js"))},{id:"luau",name:"Luau",import:(()=>import("../luau-GR2DOH6N.js"))},{id:"make",name:"Makefile",aliases:["makefile"],import:(()=>import("../make-DQQEEPI4.js"))},{id:"markdown",name:"Markdown",aliases:["md"],import:(()=>import("../markdown-OC5ILZSY.js"))},{id:"marko",name:"Marko",import:(()=>import("../marko-XSB3CTWQ.js"))},{id:"matlab",name:"MATLAB",import:(()=>import("../matlab-YQY6FS4U.js"))},{id:"mdc",name:"MDC",import:(()=>import("../mdc-TEVTGSC7.js"))},{id:"mdx",name:"MDX",import:(()=>import("../mdx-ZIH2JLVR.js"))},{id:"mermaid",name:"Mermaid",aliases:["mmd"],import:(()=>import("../mermaid-WPX56SBB.js"))},{id:"mipsasm",name:"MIPS Assembly",aliases:["mips"],import:(()=>import("../mipsasm-IDXQRZ2B.js"))},{id:"mojo",name:"Mojo",import:(()=>import("../mojo-MH7EQVOK.js"))},{id:"moonbit",name:"MoonBit",aliases:["mbt","mbti"],import:(()=>import("../moonbit-5JDFTWKE.js"))},{id:"move",name:"Move",import:(()=>import("../move-RWSXKYDY.js"))},{id:"narrat",name:"Narrat Language",aliases:["nar"],import:(()=>import("../narrat-QJUEXMVV.js"))},{id:"nextflow",name:"Nextflow",aliases:["nf"],import:(()=>import("../nextflow-2EICNZA3.js"))},{id:"nginx",name:"Nginx",import:(()=>import("../nginx-RIWAEC5Z.js"))},{id:"nim",name:"Nim",import:(()=>import("../nim-JPSYX5KC.js"))},{id:"nix",name:"Nix",import:(()=>import("../nix-XCKQVWCN.js"))},{id:"nushell",name:"nushell",aliases:["nu"],import:(()=>import("../nushell-QGW7HANA.js"))},{id:"objective-c",name:"Objective-C",aliases:["objc"],import:(()=>import("../objective-c-V7KYXFHL.js"))},{id:"objective-cpp",name:"Objective-C++",import:(()=>import("../objective-cpp-NKUEWVGU.js"))},{id:"ocaml",name:"OCaml",import:(()=>import("../ocaml-QT2CZJZN.js"))},{id:"odin",name:"Odin",import:(()=>import("../odin-MVMIXBHP.js"))},{id:"openscad",name:"OpenSCAD",aliases:["scad"],import:(()=>import("../openscad-BJDUXUUZ.js"))},{id:"pascal",name:"Pascal",import:(()=>import("../pascal-HGWEFD6L.js"))},{id:"perl",name:"Perl",import:(()=>import("../perl-X4IFZB22.js"))},{id:"php",name:"PHP",import:(()=>import("../php-3V7EPUAN.js"))},{id:"pkl",name:"Pkl",import:(()=>import("../pkl-VA5ZK5DW.js"))},{id:"plsql",name:"PL/SQL",import:(()=>import("../plsql-J7A7YWFH.js"))},{id:"po",name:"Gettext PO",aliases:["pot","potx"],import:(()=>import("../po-5RDI65JX.js"))},{id:"polar",name:"Polar",import:(()=>import("../polar-VUJL2E7F.js"))},{id:"postcss",name:"PostCSS",import:(()=>import("../postcss-ESTB5G7N.js"))},{id:"powerquery",name:"PowerQuery",import:(()=>import("../powerquery-ODTEKQCW.js"))},{id:"powershell",name:"PowerShell",aliases:["ps","ps1"],import:(()=>import("../powershell-ZOYRAWBJ.js"))},{id:"prisma",name:"Prisma",import:(()=>import("../prisma-QHG2W5GE.js"))},{id:"prolog",name:"Prolog",import:(()=>import("../prolog-CSAPG5PH.js"))},{id:"proto",name:"Protocol Buffer 3",aliases:["protobuf"],import:(()=>import("../proto-WDNJBTSW.js"))},{id:"pug",name:"Pug",aliases:["jade"],import:(()=>import("../pug-P7LS6DER.js"))},{id:"puppet",name:"Puppet",import:(()=>import("../puppet-LHFWHTY3.js"))},{id:"purescript",name:"PureScript",import:(()=>import("../purescript-DUFJP4FY.js"))},{id:"python",name:"Python",aliases:["py"],import:(()=>import("../python-5ZNZSNQ2.js"))},{id:"qml",name:"QML",import:(()=>import("../qml-LTAXB6W5.js"))},{id:"qmldir",name:"QML Directory",import:(()=>import("../qmldir-7Z2ODQLM.js"))},{id:"qss",name:"Qt Style Sheets",import:(()=>import("../qss-FDFD3HQD.js"))},{id:"r",name:"R",import:(()=>import("../r-6ZOS53WN.js"))},{id:"racket",name:"Racket",import:(()=>import("../racket-7AYZPEUI.js"))},{id:"raku",name:"Raku",aliases:["perl6"],import:(()=>import("../raku-A4F6VHVG.js"))},{id:"razor",name:"ASP.NET Razor",import:(()=>import("../razor-4QOCK4UD.js"))},{id:"reg",name:"Windows Registry Script",import:(()=>import("../reg-FAPHGG66.js"))},{id:"regexp",name:"RegExp",aliases:["regex"],import:(()=>import("../regexp-5BYLYA2R.js"))},{id:"rel",name:"Rel",import:(()=>import("../rel-7DJ7HHU4.js"))},{id:"riscv",name:"RISC-V",import:(()=>import("../riscv-YIYJATFG.js"))},{id:"ron",name:"RON",import:(()=>import("../ron-HYYMCHTX.js"))},{id:"rosmsg",name:"ROS Interface",import:(()=>import("../rosmsg-FDNH6QF7.js"))},{id:"rst",name:"reStructuredText",import:(()=>import("../rst-WIWCR2KQ.js"))},{id:"ruby",name:"Ruby",aliases:["rb"],import:(()=>import("../ruby-LXZJUMFB.js"))},{id:"rust",name:"Rust",aliases:["rs"],import:(()=>import("../rust-V3GMJA2K.js"))},{id:"sas",name:"SAS",import:(()=>import("../sas-D3G4GB3X.js"))},{id:"sass",name:"Sass",import:(()=>import("../sass-JTO65AGR.js"))},{id:"scala",name:"Scala",import:(()=>import("../scala-4XQGFSVM.js"))},{id:"scheme",name:"Scheme",import:(()=>import("../scheme-CB7AC7IL.js"))},{id:"scss",name:"SCSS",import:(()=>import("../scss-6SKV4OGI.js"))},{id:"sdbl",name:"1C (Query)",aliases:["1c-query"],import:(()=>import("../sdbl-LKGZFJ46.js"))},{id:"shaderlab",name:"ShaderLab",aliases:["shader"],import:(()=>import("../shaderlab-K536DHEB.js"))},{id:"shellscript",name:"Shell",aliases:["bash","sh","shell","zsh"],import:(()=>import("../shellscript-LRNUKUSZ.js"))},{id:"shellsession",name:"Shell Session",aliases:["console"],import:(()=>import("../shellsession-IBQK7VWQ.js"))},{id:"smalltalk",name:"Smalltalk",import:(()=>import("../smalltalk-DQOSWAW7.js"))},{id:"solidity",name:"Solidity",import:(()=>import("../solidity-V2FMZEG4.js"))},{id:"soy",name:"Closure Templates",aliases:["closure-templates"],import:(()=>import("../soy-VW3CKXWF.js"))},{id:"sparql",name:"SPARQL",import:(()=>import("../sparql-L2VKP7YP.js"))},{id:"splunk",name:"Splunk Query Language",aliases:["spl"],import:(()=>import("../splunk-KDKHP7GC.js"))},{id:"sql",name:"SQL",import:(()=>import("../sql-UF27CALT.js"))},{id:"ssh-config",name:"SSH Config",import:(()=>import("../ssh-config-JC2DQ6ED.js"))},{id:"stata",name:"Stata",import:(()=>import("../stata-7PXCUY24.js"))},{id:"stylus",name:"Stylus",aliases:["styl"],import:(()=>import("../stylus-2L7N3EZD.js"))},{id:"surrealql",name:"SurrealQL",aliases:["surql"],import:(()=>import("../surrealql-ZY3E6XEL.js"))},{id:"svelte",name:"Svelte",import:(()=>import("../svelte-Q45XIK2A.js"))},{id:"swift",name:"Swift",import:(()=>import("../swift-XBH5HZSC.js"))},{id:"system-verilog",name:"SystemVerilog",import:(()=>import("../system-verilog-VRAUSZY3.js"))},{id:"systemd",name:"Systemd Units",import:(()=>import("../systemd-JOTSGJD4.js"))},{id:"talonscript",name:"TalonScript",aliases:["talon"],import:(()=>import("../talonscript-NNZRZKOU.js"))},{id:"tasl",name:"Tasl",import:(()=>import("../tasl-MBFZ4QNC.js"))},{id:"tcl",name:"Tcl",import:(()=>import("../tcl-4GEDCBVE.js"))},{id:"templ",name:"Templ",import:(()=>import("../templ-3XM7DLQ3.js"))},{id:"terraform",name:"Terraform",aliases:["tf","tfvars"],import:(()=>import("../terraform-XTHOS4UK.js"))},{id:"tex",name:"TeX",import:(()=>import("../tex-UXMN2CV7.js"))},{id:"toml",name:"TOML",import:(()=>import("../toml-J6K55ZSV.js"))},{id:"ts-tags",name:"TypeScript with Tags",aliases:["lit"],import:(()=>import("../ts-tags-7WGDLEKX.js"))},{id:"tsv",name:"TSV",import:(()=>import("../tsv-DOUJHQDQ.js"))},{id:"tsx",name:"TSX",import:(()=>import("../tsx-G5BMVRHK.js"))},{id:"turtle",name:"Turtle",import:(()=>import("../turtle-JHJ7W6U5.js"))},{id:"twig",name:"Twig",import:(()=>import("../twig-C6YWFFZU.js"))},{id:"typescript",name:"TypeScript",aliases:["ts","cts","mts"],import:(()=>import("../typescript-LMKEAHFC.js"))},{id:"typespec",name:"TypeSpec",aliases:["tsp"],import:(()=>import("../typespec-5CLTIJYY.js"))},{id:"typst",name:"Typst",aliases:["typ"],import:(()=>import("../typst-4W4Z436Z.js"))},{id:"v",name:"V",import:(()=>import("../v-Y4SBDBN7.js"))},{id:"vala",name:"Vala",import:(()=>import("../vala-UMKT2MFA.js"))},{id:"vb",name:"Visual Basic",aliases:["cmd"],import:(()=>import("../vb-DQ7A5WJU.js"))},{id:"verilog",name:"Verilog",import:(()=>import("../verilog-N6ZF7GQD.js"))},{id:"vhdl",name:"VHDL",import:(()=>import("../vhdl-BNYDT37G.js"))},{id:"viml",name:"Vim Script",aliases:["vim","vimscript"],import:(()=>import("../viml-37RMDCBC.js"))},{id:"vue",name:"Vue",import:(()=>import("../vue-O6SLORWU.js"))},{id:"vue-html",name:"Vue HTML",import:(()=>import("../vue-html-ZLTZN573.js"))},{id:"vue-vine",name:"Vue Vine",import:(()=>import("../vue-vine-6JKAZ54I.js"))},{id:"vyper",name:"Vyper",aliases:["vy"],import:(()=>import("../vyper-GVXF46KD.js"))},{id:"wasm",name:"WebAssembly",import:(()=>import("../wasm-NTB4O7GL.js"))},{id:"wenyan",name:"Wenyan",aliases:["\u6587\u8A00"],import:(()=>import("../wenyan-W7WB3BC7.js"))},{id:"wgsl",name:"WGSL",import:(()=>import("../wgsl-7GTDVXHG.js"))},{id:"wikitext",name:"Wikitext",aliases:["mediawiki","wiki"],import:(()=>import("../wikitext-ASAFPAIL.js"))},{id:"wit",name:"WebAssembly Interface Types",import:(()=>import("../wit-ZBCR6544.js"))},{id:"wolfram",name:"Wolfram",aliases:["wl"],import:(()=>import("../wolfram-SZRZOETJ.js"))},{id:"xml",name:"XML",import:(()=>import("../xml-EBTJCOTU.js"))},{id:"xsl",name:"XSL",import:(()=>import("../xsl-IBYEXWDX.js"))},{id:"yaml",name:"YAML",aliases:["yml"],import:(()=>import("../yaml-GMVQNECR.js"))},{id:"zenscript",name:"ZenScript",import:(()=>import("../zenscript-O2TZFP4A.js"))},{id:"zig",name:"Zig",import:(()=>import("../zig-ZLGM7IMN.js"))}],An=Object.fromEntries(Zo.map(e=>[e.id,e.import])),vn=Object.fromEntries(Zo.flatMap(e=>e.aliases?.map(t=>[t,e.import])||[])),ea={...An,...vn};var sf=[{id:"andromeeda",displayName:"Andromeeda",type:"dark",import:(()=>import("../andromeeda-HAPOYWX3.js"))},{id:"aurora-x",displayName:"Aurora X",type:"dark",import:(()=>import("../aurora-x-R6WAWEBC.js"))},{id:"ayu-dark",displayName:"Ayu Dark",type:"dark",import:(()=>import("../ayu-dark-KMD4YO7F.js"))},{id:"ayu-light",displayName:"Ayu Light",type:"light",import:(()=>import("../ayu-light-2ATPDILG.js"))},{id:"ayu-mirage",displayName:"Ayu Mirage",type:"dark",import:(()=>import("../ayu-mirage-LJ7PG5AM.js"))},{id:"catppuccin-frappe",displayName:"Catppuccin Frapp\xE9",type:"dark",import:(()=>import("../catppuccin-frappe-Z4Y2POK6.js"))},{id:"catppuccin-latte",displayName:"Catppuccin Latte",type:"light",import:(()=>import("../catppuccin-latte-4TQUIKX4.js"))},{id:"catppuccin-macchiato",displayName:"Catppuccin Macchiato",type:"dark",import:(()=>import("../catppuccin-macchiato-B7YYPERT.js"))},{id:"catppuccin-mocha",displayName:"Catppuccin Mocha",type:"dark",import:(()=>import("../catppuccin-mocha-KX33VXKA.js"))},{id:"dark-plus",displayName:"Dark Plus",type:"dark",import:(()=>import("../dark-plus-LNHXUR7U.js"))},{id:"dracula",displayName:"Dracula Theme",type:"dark",import:(()=>import("../dracula-T2CMBBQ5.js"))},{id:"dracula-soft",displayName:"Dracula Theme Soft",type:"dark",import:(()=>import("../dracula-soft-SMFRNKX2.js"))},{id:"everforest-dark",displayName:"Everforest Dark",type:"dark",import:(()=>import("../everforest-dark-DBZHIUAO.js"))},{id:"everforest-light",displayName:"Everforest Light",type:"light",import:(()=>import("../everforest-light-TDAGYJUK.js"))},{id:"github-dark",displayName:"GitHub Dark",type:"dark",import:(()=>import("../github-dark-3E25TTAN.js"))},{id:"github-dark-default",displayName:"GitHub Dark Default",type:"dark",import:(()=>import("../github-dark-default-KCBFVSS5.js"))},{id:"github-dark-dimmed",displayName:"GitHub Dark Dimmed",type:"dark",import:(()=>import("../github-dark-dimmed-WRCBXEVS.js"))},{id:"github-dark-high-contrast",displayName:"GitHub Dark High Contrast",type:"dark",import:(()=>import("../github-dark-high-contrast-ET7SAHAV.js"))},{id:"github-light",displayName:"GitHub Light",type:"light",import:(()=>import("../github-light-6FNTZH5H.js"))},{id:"github-light-default",displayName:"GitHub Light Default",type:"light",import:(()=>import("../github-light-default-GGTAKNM7.js"))},{id:"github-light-high-contrast",displayName:"GitHub Light High Contrast",type:"light",import:(()=>import("../github-light-high-contrast-LHYKPR5E.js"))},{id:"gruvbox-dark-hard",displayName:"Gruvbox Dark Hard",type:"dark",import:(()=>import("../gruvbox-dark-hard-IQWZCHF7.js"))},{id:"gruvbox-dark-medium",displayName:"Gruvbox Dark Medium",type:"dark",import:(()=>import("../gruvbox-dark-medium-ARPWF4FS.js"))},{id:"gruvbox-dark-soft",displayName:"Gruvbox Dark Soft",type:"dark",import:(()=>import("../gruvbox-dark-soft-ODS6FPID.js"))},{id:"gruvbox-light-hard",displayName:"Gruvbox Light Hard",type:"light",import:(()=>import("../gruvbox-light-hard-KFA5YFDW.js"))},{id:"gruvbox-light-medium",displayName:"Gruvbox Light Medium",type:"light",import:(()=>import("../gruvbox-light-medium-MMET4L3Y.js"))},{id:"gruvbox-light-soft",displayName:"Gruvbox Light Soft",type:"light",import:(()=>import("../gruvbox-light-soft-DBZDERMK.js"))},{id:"horizon",displayName:"Horizon",type:"dark",import:(()=>import("../horizon-FSOMPXNP.js"))},{id:"houston",displayName:"Houston",type:"dark",import:(()=>import("../houston-FAQBCORN.js"))},{id:"kanagawa-dragon",displayName:"Kanagawa Dragon",type:"dark",import:(()=>import("../kanagawa-dragon-JNDVF5RJ.js"))},{id:"kanagawa-lotus",displayName:"Kanagawa Lotus",type:"light",import:(()=>import("../kanagawa-lotus-S7JK6TQ6.js"))},{id:"kanagawa-wave",displayName:"Kanagawa Wave",type:"dark",import:(()=>import("../kanagawa-wave-QJJIMVEV.js"))},{id:"laserwave",displayName:"LaserWave",type:"dark",import:(()=>import("../laserwave-YFP3EJVX.js"))},{id:"light-plus",displayName:"Light Plus",type:"light",import:(()=>import("../light-plus-NGDHCPUZ.js"))},{id:"material-theme",displayName:"Material Theme",type:"dark",import:(()=>import("../material-theme-H2BHKUKX.js"))},{id:"material-theme-darker",displayName:"Material Theme Darker",type:"dark",import:(()=>import("../material-theme-darker-VENCGWTB.js"))},{id:"material-theme-lighter",displayName:"Material Theme Lighter",type:"light",import:(()=>import("../material-theme-lighter-SDMLS22W.js"))},{id:"material-theme-ocean",displayName:"Material Theme Ocean",type:"dark",import:(()=>import("../material-theme-ocean-UHDBRLVF.js"))},{id:"material-theme-palenight",displayName:"Material Theme Palenight",type:"dark",import:(()=>import("../material-theme-palenight-3TB2BEET.js"))},{id:"min-dark",displayName:"Min Dark",type:"dark",import:(()=>import("../min-dark-CQ5WKNT7.js"))},{id:"min-light",displayName:"Min Light",type:"light",import:(()=>import("../min-light-LZRD4NPR.js"))},{id:"monokai",displayName:"Monokai",type:"dark",import:(()=>import("../monokai-WHRY6275.js"))},{id:"night-owl",displayName:"Night Owl",type:"dark",import:(()=>import("../night-owl-7PNEW2JB.js"))},{id:"night-owl-light",displayName:"Night Owl Light",type:"light",import:(()=>import("../night-owl-light-GJUYOOJR.js"))},{id:"nord",displayName:"Nord",type:"dark",import:(()=>import("../nord-EVGUMUX2.js"))},{id:"one-dark-pro",displayName:"One Dark Pro",type:"dark",import:(()=>import("../one-dark-pro-PMTR3SA7.js"))},{id:"one-light",displayName:"One Light",type:"light",import:(()=>import("../one-light-O7WH4N5X.js"))},{id:"plastic",displayName:"Plastic",type:"dark",import:(()=>import("../plastic-FBVUW6NJ.js"))},{id:"poimandres",displayName:"Poimandres",type:"dark",import:(()=>import("../poimandres-WBB7GZAD.js"))},{id:"red",displayName:"Red",type:"dark",import:(()=>import("../red-7KAMONOP.js"))},{id:"rose-pine",displayName:"Ros\xE9 Pine",type:"dark",import:(()=>import("../rose-pine-F2G5IHZD.js"))},{id:"rose-pine-dawn",displayName:"Ros\xE9 Pine Dawn",type:"light",import:(()=>import("../rose-pine-dawn-ALZ7XGH2.js"))},{id:"rose-pine-moon",displayName:"Ros\xE9 Pine Moon",type:"dark",import:(()=>import("../rose-pine-moon-D3K4SWUL.js"))},{id:"slack-dark",displayName:"Slack Dark",type:"dark",import:(()=>import("../slack-dark-YFPJODWS.js"))},{id:"slack-ochin",displayName:"Slack Ochin",type:"light",import:(()=>import("../slack-ochin-H67AWZOI.js"))},{id:"snazzy-light",displayName:"Snazzy Light",type:"light",import:(()=>import("../snazzy-light-OUVS63VK.js"))},{id:"solarized-dark",displayName:"Solarized Dark",type:"dark",import:(()=>import("../solarized-dark-2RCAVEXJ.js"))},{id:"solarized-light",displayName:"Solarized Light",type:"light",import:(()=>import("../solarized-light-XFSENHTC.js"))},{id:"synthwave-84",displayName:"Synthwave '84",type:"dark",import:(()=>import("../synthwave-84-5XXB3K6S.js"))},{id:"tokyo-night",displayName:"Tokyo Night",type:"dark",import:(()=>import("../tokyo-night-CHJCCBJH.js"))},{id:"vesper",displayName:"Vesper",type:"dark",import:(()=>import("../vesper-Y5GIEAN4.js"))},{id:"vitesse-black",displayName:"Vitesse Black",type:"dark",import:(()=>import("../vitesse-black-7TI33KHX.js"))},{id:"vitesse-dark",displayName:"Vitesse Dark",type:"dark",import:(()=>import("../vitesse-dark-FOB25MRB.js"))},{id:"vitesse-light",displayName:"Vitesse Light",type:"light",import:(()=>import("../vitesse-light-4WCNCTCO.js"))}],Mn=Object.fromEntries(sf.map(e=>[e.id,e.import]));var ta=class extends Error{constructor(t){super(t),this.name="ShikiError"}};function nf(){return 2147483648}function lf(){return typeof performance<"u"?performance.now():Date.now()}var uf=(e,t)=>e+(t-e%t)%t;async function df(e){let t,a,o={};function r(p){a=p,o.HEAPU8=new Uint8Array(p),o.HEAPU32=new Uint32Array(p)}function s(p,h,I){o.HEAPU8.copyWithin(p,h,h+I)}function n(p){try{return t.grow(p-a.byteLength+65535>>>16),r(t.buffer),1}catch{}}function l(p){let h=o.HEAPU8.length;p=p>>>0;let I=nf();if(p>I)return!1;for(let L=1;L<=4;L*=2){let x=h*(1+.2/L);x=Math.min(x,p+100663296);let w=Math.min(I,uf(Math.max(p,x),65536));if(n(w))return!0}return!1}let i=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function u(p,h,I=1024){let L=h+I,x=h;for(;p[x]&&!(x>=L);)++x;if(x-h>16&&p.buffer&&i)return i.decode(p.subarray(h,x));let w="";for(;h<x;){let m=p[h++];if(!(m&128)){w+=String.fromCharCode(m);continue}let g=p[h++]&63;if((m&224)===192){w+=String.fromCharCode((m&31)<<6|g);continue}let C=p[h++]&63;if((m&240)===224?m=(m&15)<<12|g<<6|C:m=(m&7)<<18|g<<12|C<<6|p[h++]&63,m<65536)w+=String.fromCharCode(m);else{let b=m-65536;w+=String.fromCharCode(55296|b>>10,56320|b&1023)}}return w}function f(p,h){return p?u(o.HEAPU8,p,h):""}let d={emscripten_get_now:lf,emscripten_memcpy_big:s,emscripten_resize_heap:l,fd_write:()=>0};async function c(){let h=await e({env:d,wasi_snapshot_preview1:d});t=h.memory,r(t.buffer),Object.assign(o,h),o.UTF8ToString=f}return await c(),o}var ff=Object.defineProperty,cf=(e,t,a)=>t in e?ff(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,se=(e,t,a)=>cf(e,typeof t!="symbol"?t+"":t,a),ie=null;function pf(e){throw new ta(e.UTF8ToString(e.getLastOnigError()))}var ja=class e{constructor(t){se(this,"utf16Length"),se(this,"utf8Length"),se(this,"utf16Value"),se(this,"utf8Value"),se(this,"utf16OffsetToUtf8"),se(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 f=t.charCodeAt(u),d=f,c=!1;if(f>=55296&&f<=56319&&u+1<a){let p=t.charCodeAt(u+1);p>=56320&&p<=57343&&(d=(f-55296<<10)+65536|p-56320,c=!0)}r&&(s[u]=i,c&&(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),c&&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 Be{constructor(t){if(se(this,"id",++Be.LAST_ID),se(this,"_onigBinding"),se(this,"content"),se(this,"utf16Length"),se(this,"utf8Length"),se(this,"utf16OffsetToUtf8"),se(this,"utf8OffsetToUtf16"),se(this,"ptr"),!ie)throw new ta("Must invoke loadWasm first.");this._onigBinding=ie,this.content=t;let a=new ja(t);this.utf16Length=a.utf16Length,this.utf8Length=a.utf8Length,this.utf16OffsetToUtf8=a.utf16OffsetToUtf8,this.utf8OffsetToUtf16=a.utf8OffsetToUtf16,this.utf8Length<1e4&&!Be._sharedPtrInUse?(Be._sharedPtr||(Be._sharedPtr=ie.omalloc(1e4)),Be._sharedPtrInUse=!0,ie.HEAPU8.set(a.utf8Value,Be._sharedPtr),this.ptr=Be._sharedPtr):this.ptr=a.createString(ie)}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===Be._sharedPtr?Be._sharedPtrInUse=!1:this._onigBinding.ofree(this.ptr)}};se(Va,"LAST_ID",0);se(Va,"_sharedPtr",0);se(Va,"_sharedPtrInUse",!1);var Rn=Va,er=class{constructor(t){if(se(this,"_onigBinding"),se(this,"_ptr"),!ie)throw new ta("Must invoke loadWasm first.");let a=[],o=[];for(let l=0,i=t.length;l<i;l++){let u=new ja(t[l]);a[l]=u.createString(ie),o[l]=u.utf8Length}let r=ie.omalloc(4*t.length);ie.HEAPU32.set(a,r/4);let s=ie.omalloc(4*t.length);ie.HEAPU32.set(o,s/4);let n=ie.createOnigScanner(r,s,t.length);for(let l=0,i=t.length;l<i;l++)ie.ofree(a[l]);ie.ofree(s),ie.ofree(r),n===0&&pf(ie),this._onigBinding=ie,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 Rn(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++],f=l[i++],d=[];for(let c=0;c<f;c++){let p=t.convertUtf8OffsetToUtf16(l[i++]),h=t.convertUtf8OffsetToUtf16(l[i++]);d[c]={start:p,end:h,length:h-p}}return{index:u,captureIndices:d}}};function mf(e){return typeof e.instantiator=="function"}function hf(e){return typeof e.default=="function"}function gf(e){return typeof e.data<"u"}function wf(e){return typeof Response<"u"&&e instanceof Response}function xf(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 Lf(e){if(za)return za;async function t(){ie=await df(async a=>{let o=e;return o=await o,typeof o=="function"&&(o=await o(a)),typeof o=="function"&&(o=await o(a)),mf(o)?o=await o.instantiator(a):hf(o)?o=await o.default(a):(gf(o)&&(o=o.data),wf(o)?typeof WebAssembly.instantiateStreaming=="function"?o=await Cf(o)(a):o=await If(o)(a):xf(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 za=t(),za}function Yo(e){return t=>WebAssembly.instantiate(e,t)}function Cf(e){return t=>WebAssembly.instantiateStreaming(e,t)}function If(e){return async t=>{let a=await e.arrayBuffer();return WebAssembly.instantiate(a,t)}}async function Fn(e){return e&&await Lf(e),{createScanner(t){return new er(t.map(a=>typeof a=="string"?a:a.source))},createString(t){return new Rn(t)}}}var $a=Tn({langs:ea,themes:Mn,engine:()=>Fn(import("../wasm-EOPKAILK.js"))}),{codeToHtml:Sf,codeToHast:yf,codeToTokens:kf,codeToTokensBase:bf,codeToTokensWithThemes:Tf,getSingletonHighlighter:Pf,getLastGrammarState:Af}=Pn($a,{guessEmbeddedLanguages:Ln});var Bn=new Set(Object.keys(ea)),tr=new Map,ar=new Map,Lt=new Map,vf=(e,t)=>`${e}-${t[0]}-${t[1]}`,Mf=(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}`},Rf=(e,t)=>{let a=vf(e,t);if(tr.has(a))return tr.get(a);let o=$a({themes:t,langs:[e]});return tr.set(a,o),o};function Ff(e={}){var t;let a=(t=e.themes)!=null?t:["github-light","github-dark"];return{name:"shiki",type:"code-highlighter",supportsLanguage(o){return Bn.has(o)},getSupportedLanguages(){return Array.from(Bn)},getThemes(){return a},highlight({code:o,language:r,themes:s},n){let l=Mf(o,r,s);return ar.has(l)?ar.get(l):(n&&(Lt.has(l)||Lt.set(l,new Set),Lt.get(l).add(n)),Rf(r,s).then(i=>{let u=i.getLoadedLanguages().includes(r)?r:"text",f=i.codeToTokens(o,{lang:u,themes:{light:s[0],dark:s[1]}});ar.set(l,f);let d=Lt.get(l);if(d){for(let c of d)c(f);Lt.delete(l)}}).catch(i=>{console.error("[Streamdown Code] Failed to highlight code:",i),Lt.delete(l)}),null)}}}var Dn=Ff();import{memo as Bf}from"react";import{jsx as Xa}from"react/jsx-runtime";var Ka=({className:e,from:t,children:a,...o})=>Xa("div",{className:T("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:T("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:T("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}),Df={cjk:gs,code:Dn},Ja=Bf(({className:e,...t})=>Xa(ho,{className:T("ww:size-full ww:[&>*:first-child]:mt-0 ww:[&>*:last-child]:mb-0",e),plugins:Df,...t}),(e,t)=>e.children===t.children);Ja.displayName="MessageResponse";import{jsx as Ef}from"react/jsx-runtime";function En({className:e,text:t,...a}){return t?Ef("pre",{className:T("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}import{createContext as _f,useCallback as Nf,useContext as Un,useEffect as Of,useMemo as rr,useRef as Uf,useState as sr}from"react";import{Fragment as On,jsx as X,jsxs as je}from"react/jsx-runtime";function Hf(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 f=`${i}\u2009${u}`;r.push(f),s-=f.length+3}return`{${r.join(", ")}}`}function qf({text:e,className:t}){let[a,o]=sr(!1),r=Uf(null);Of(()=>()=>{r.current&&clearTimeout(r.current)},[]);let s=Nf(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 X(Te,{variant:"ghost",size:"sm",onClick:s,className:T("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?je(On,{children:[X(Ft,{className:"ww:size-3.5"}),X("span",{children:"Copied"})]}):je(On,{children:[X(Et,{className:"ww:size-3.5"}),X("span",{children:"Copy"})]})})}function Hn({data:e,label:t,className:a,...o}){let[r,s]=sr(!1),n=rr(()=>JSON.stringify(e,null,2),[e]),l=Hf(e);return je("div",{className:T("ww:rounded-lg ww:bg-tool-card",a),...o,children:[je("div",{className:"ww:flex ww:items-center ww:justify-between ww:px-3 ww:pt-2.5 ww:pb-1.5",children:[X("span",{className:"ww:text-xs ww:font-medium ww:text-muted-foreground",children:t}),X(qf,{text:n})]}),je("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:[X(Dt,{className:T("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?X("pre",{className:"ww:overflow-x-auto ww:text-xs ww:font-mono ww:text-foreground ww:whitespace-pre-wrap ww:break-all",children:X("code",{children:n})}):X("span",{className:"ww:truncate ww:text-xs ww:font-mono ww:text-foreground/80",children:l})]})]})}var nr=_f({open:!1,toggle:()=>{}});function qn({className:e,defaultOpen:t=!1,children:a,...o}){let[r,s]=sr(t);return X(nr.Provider,{value:{open:r,toggle:()=>s(n=>!n)},children:X("div",{className:T("ww:mb-4 ww:w-full",e),"data-state":r?"open":"closed",...o,children:a})})}function Gn({className:e,title:t,state:a,...o}){let{open:r,toggle:s}=Un(nr),n=a==="input-available"||a==="input-streaming";return je("button",{type:"button",onClick:s,className:T("ww:flex ww:w-full ww:items-center ww:justify-between ww:gap-3 ww:py-1.5",e),"aria-expanded":r,...o,children:[je("div",{className:"ww:flex ww:min-w-0 ww:items-center ww:gap-2",children:[X(He,{className:"ww:size-4 ww:shrink-0 ww:text-muted-foreground"}),X("span",{className:"ww:truncate ww:text-sm ww:font-medium",children:t}),n&&X("span",{className:"ww:size-2 ww:shrink-0 ww:rounded-full ww:bg-primary ww:animate-pulse"})]}),X(Bt,{className:T("ww:size-4 ww:shrink-0 ww:text-muted-foreground ww:transition-transform ww:duration-200",r&&"ww:rotate-180")})]})}function Wn({className:e,children:t,...a}){let{open:o}=Un(nr);return X("div",{className:T("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:X("div",{className:"ww:min-h-0 ww:overflow-hidden",children:X("div",{className:T("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 zn({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 X(Hn,{data:r,label:"Request",className:e,...o})}function or(e){if(!(typeof e!="object"||e===null))return e}function jn(e){return or(e?.ui)}function Vn(e){return or(or(e)?._meta)}function _n(e){if(!e)return;let t=jn(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 Nn(e){return jn(e)?.autoHeight===!0}function Za(e,t,a){if(e){let o=_n(a?.[e]?._meta);if(o)return o}return _n(Vn(t))}function $n(e,t,a){return e&&Nn(a?.[e]?._meta)?!0:Nn(Vn(t))}function Xn({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?je("div",{className:T("ww:space-y-2",e),...r,children:[X("h4",{className:"ww:text-xs ww:font-medium ww:uppercase ww:tracking-wide ww:text-muted-foreground",children:"Error"}),X("div",{className:"ww:rounded-lg ww:bg-destructive/10 ww:p-3 ww:text-xs ww:text-destructive",children:a})]}):X(Hn,{data:s,label:"Response",className:e,...r}):null}import{useCallback as Gf,useEffect as Qn,useMemo as Wf,useRef as xe,useState as Jn}from"react";function Ct(e){if(!e)return!1;let t=Array.isArray(e.content)&&e.content.length>0,a=typeof e.structuredContent=="object"&&e.structuredContent!==null&&Object.keys(e.structuredContent).length>0;return t||a}function Kn(e,t){return!Ct(e)&&!Ct(t)?null:Ct(e)?Ct(t)?{...e.content||t.content?{content:[...e.content??[],...t.content??[]]}:{},...e.structuredContent||t.structuredContent?{structuredContent:{...e.structuredContent??{},...t.structuredContent??{}}}:{}}:{...e.content?{content:[...e.content]}:{},...e.structuredContent?{structuredContent:{...e.structuredContent}}:{}}:{...t?.content?{content:[...t.content]}:{},...t?.structuredContent?{structuredContent:{...t.structuredContent}}:{}}}import{jsx as ec}from"react/jsx-runtime";var zf="/api/mcp/resource",jf=500,Vf=0,$f=16,Xf="2026-01-26",Kf=300,Qf=3e3,Jf=3;function Zf(e){if(typeof e!="string")return;let t=e.trim();return t.length>0?t:void 0}function Yf(e,t,a){return Za(e,t,a)?!1:t._meta?.["waniwani/autoInjectResultText"]!==!1}function ir({resourceUri:e,toolInput:t,toolResult:a,resourceEndpoint:o=zf,chatSessionId:r,isDark:s=!1,className:n,autoHeight:l=!1,onOpenLink:i,onFollowUp:u,onCallTool:f,onDisplayModeChange:d,isFullscreen:c=!1,toolDefinitions:p}){let h=xe(null),I=xe(t),L=xe(a),x=xe({width:0,height:0}),w=xe(null),m=xe(!1),g=xe(0),C=xe("inline"),[b,y]=Jn(Vf),[B,N]=Jn(void 0),R=xe(i),k=xe(u),P=xe(f),Y=xe(d),U=xe(r),D=xe(p);I.current=t,L.current=a,R.current=i,k.current=u,P.current=f,Y.current=d,U.current=r,D.current=p;let z=Gf(H=>l?Math.max(H+$f,0):Math.min(Math.max(H,50),jf),[l]),ae=Wf(()=>{let H=o.includes("?")?"&":"?";return`${o}${H}uri=${encodeURIComponent(e)}`},[o,e]),oe=xe(s);return oe.current=s,Qn(()=>{if(!m.current)return;let H=h.current;H?.contentWindow&&H.contentWindow.postMessage({jsonrpc:"2.0",method:"ui/notifications/host-context-changed",params:{theme:s?"dark":"light"}},"*")},[s]),Qn(()=>{let H=h.current;if(!H)return;let M=!1,v=!1,A=null,_=null,ge=setTimeout(()=>{if(M||v||g.current>=Jf)return;g.current+=1;let ue=new URL(H.src);ue.searchParams.set("_retry",String(g.current)),H.src=ue.toString()},Qf),re=ue=>{H.contentWindow?.postMessage(ue,"*")},Ne=ue=>{if(M||ue.source!==H.contentWindow)return;let Q=ue.data;if(!Q||typeof Q!="object"||Q.jsonrpc!=="2.0")return;let ee=Q.method,G=Q.id;if(ee==="ui/initialize"&&G!=null){v=!0,clearTimeout(ge),re({jsonrpc:"2.0",id:G,result:{protocolVersion:Q.params?.protocolVersion??Xf,hostInfo:{name:"WaniWani Chat",version:"1.0.0"},hostCapabilities:{openLinks:{},message:{text:{}},tools:{},updateModelContext:{text:{},structuredContent:{}}},hostContext:{theme:oe.current?"dark":"light",displayMode:C.current}}});return}if(ee==="ui/notifications/initialized"){m.current=!0;let W=I.current,j=L.current,q=j._meta&&typeof j._meta=="object"?j._meta:null,V=Zf(U.current),te=q&&typeof q.waniwani=="object"&&q.waniwani!==null?q.waniwani:null,ke=te||V?{...te??{},...V?{sessionId:V}:{}}:void 0,Oe=q||ke?{...q??{},...ke?{waniwani:ke}:{}}:void 0;re({jsonrpc:"2.0",method:"ui/notifications/tool-input",params:{arguments:W}});let st=j.content??[{type:"text",text:JSON.stringify(j)}];re({jsonrpc:"2.0",method:"ui/notifications/tool-result",params:{content:st,structuredContent:j.structuredContent,_meta:Oe,meta:Oe}});return}if(ee==="ui/notifications/size-changed"){let W=Q.params,j=typeof W?.height=="number"?W.height:void 0,q=typeof W?.width=="number"?W.width:void 0,V=x.current,te=j!==void 0&&j!==V.height,ke=q!==void 0&&q!==V.width;if(!te&&!ke)return;if(te&&j!==void 0){V.height=j;let Oe=z(j),st=H.getBoundingClientRect().height;if(w.current&&(w.current.cancel(),w.current=null),y(Oe),H.animate&&Math.abs(st-Oe)>2){let nt=H.animate([{height:`${st}px`},{height:`${Oe}px`}],{duration:Kf,easing:"ease-out",fill:"forwards"});w.current=nt,nt.onfinish=()=>{w.current===nt&&(nt.cancel(),w.current=null)}}}ke&&l&&q!==void 0&&(V.width=q,N(q));return}if(ee==="ui/open-link"&&G!=null){let W=Q.params?.url;typeof W=="string"&&(R.current?R.current(W):window.open(W,"_blank","noopener,noreferrer")),re({jsonrpc:"2.0",id:G,result:{}});return}if(ee==="ui/message"&&G!=null){if(k.current&&Q.params){let W=Q.params,j=A;if(A=null,_){clearTimeout(_.timer);let q=_.text;_=null;let V=(W.content??[]).map(te=>te.text??"").join("").trim();W={...W,content:[{type:"text",text:`${V}
12
+ \f\r "&'<=>\``.split("")]],single:[["&'".split(""),"\"&'`".split("")],["\0&'".split(""),"\0\"&'`".split("")]],double:[['"&'.split(""),"\"&'`".split("")],['\0"&'.split(""),"\0\"&'`".split("")]]};function tn(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()),i=[],l;r.space==="html"&&e.tagName==="svg"&&(o.schema=ia);let u=ad(o,e.properties),f=o.all(r.space==="html"&&e.tagName==="template"?e.content:e);return o.schema=r,f&&(n=!1),(u||!s||!en(e,t,a))&&(i.push("<",e.tagName,u?" "+u:""),n&&(r.space==="svg"||o.settings.closeSelfClosing)&&(l=u.charAt(u.length-1),(!o.settings.tightSelfClosing||l==="/"||l&&l!=='"'&&l!=="'")&&i.push(" "),i.push("/")),i.push(">")),i.push(f),!n&&(!s||!Qt(e,t,a))&&i.push("</"+e.tagName+">"),i.join("")}function ad(e,t){let a=[],o=-1,r;if(t){for(r in t)if(t[r]!==null&&t[r]!==void 0){let s=od(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 od(e,t,a){let o=kr(e.schema,t),r=e.settings.allowParseErrors&&e.schema.space==="html"?0:1,s=e.settings.allowDangerousCharacters?0:1,n=e.quote,i;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 l=De(o.attribute,Object.assign({},e.settings.characterReferences,{subset:Fa.name[r][s]}));return a===!0||(a=Array.isArray(a)?(o.commaSeparated?Pr:Ar)(a,{padLeft:!e.settings.tightCommaSeparatedLists}):String(a),e.settings.collapseEmptyAttributes&&!a)?l:(e.settings.preferUnquoted&&(i=De(a,Object.assign({},e.settings.characterReferences,{attribute:!0,subset:Fa.unquoted[r][s]}))),i!==a&&(e.settings.quoteSmart&&fo(a,n)>fo(a,e.alternative)&&(n=e.alternative),i=n+De(a,Object.assign({},e.settings.characterReferences,{subset:(n==="'"?Fa.single:Fa.double)[r][s],attribute:!0}))+n),l+(i&&"="+i))}var rd=["<","&"];function Ba(e,t,a,o){return a&&a.type==="element"&&(a.tagName==="script"||a.tagName==="style")?e.value:De(e.value,Object.assign({},o.settings.characterReferences,{subset:rd}))}function an(e,t,a,o){return o.settings.allowDangerousHtml?e.value:Ba(e,t,a,o)}function on(e,t,a,o){return o.all(e)}var rn=Tr("type",{invalid:sd,unknown:nd,handlers:{comment:Qs,doctype:Ks,element:tn,raw:an,root:on,text:Ba}});function sd(e){throw new Error("Expected node, not `"+e+"`")}function nd(e){let t=e;throw new Error("Cannot compile unknown node `"+t.type+"`")}var id={},ld={},ud=[];function No(e,t){let a=t||id,o=a.quote||'"',r=o==='"'?"'":'"';if(o!=='"'&&o!=="'")throw new Error("Invalid quote `"+o+"`, expected `'` or `\"`");return{one:dd,all:fd,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||yr,characterReferences:a.characterReferences||ld,closeSelfClosing:a.closeSelfClosing||!1,closeEmptyElements:a.closeEmptyElements||!1},schema:a.space==="svg"?ia:br,quote:o,alternative:r}.one(Array.isArray(e)?{type:"root",children:e}:e,void 0,void 0)}function dd(e,t,a){return rn(e,t,a,this)}function fd(e){let t=[],a=e&&e.children||ud,o=-1;for(;++o<a.length;)t[o]=this.one(a[o],o,e);return t.join("")}function Da(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 Ge(e,t){return e&&(t?.[e?.toLowerCase()]||e)}function cd(e){return Array.isArray(e)?e:[e]}async function cn(e){return Promise.resolve(typeof e=="function"?e():e).then(t=>t.default||t)}function Wo(e){return!e||["plaintext","txt","text","plain"].includes(e)}function pn(e){return e==="ansi"||Wo(e)}function zo(e){return e==="none"}function mn(e){return zo(e)}function hn(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 Ua(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 pd(e){let t=Ua(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 i of t){if(s<i.length)break;s-=i.length,n++}return{line:n,character:s}}function o(r,s){let n=0;for(let i=0;i<r;i++)n+=t[i].length;return n+=s,n}return{lines:t,indexToPos:a,posToIndex:o}}function gn(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(),i=n.includes("/")?n.split("/").pop():n;i&&o.add(i)}if(!a)return Array.from(o);let r=a.getBundledLanguages();return Array.from(o).filter(s=>s&&r[s])}var jo="light-dark()",md=["color","background-color"];function hd(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 gd(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,i)=>n-i);return s.length?hd(r,s):r})):e}function wd(e,t,a,o,r="css-vars"){let s={content:e.content,explanation:e.explanation,offset:e.offset},n=t.map(f=>_a(e.variants[f])),i=new Set(n.flatMap(f=>Object.keys(f))),l={},u=(f,d)=>{let c=d==="color"?"":d==="background-color"?"-bg":`-${d}`;return a+t[f]+(d==="color"?"":c)};return n.forEach((f,d)=>{for(let c of i){let p=f[c]||"inherit";if(d===0&&o&&md.includes(c))if(o===jo&&n.length>1){let h=t.findIndex(w=>w==="light"),S=t.findIndex(w=>w==="dark");if(h===-1||S===-1)throw new X('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');let L=n[h][c]||"inherit",x=n[S][c]||"inherit";l[c]=`light-dark(${L}, ${x})`,r==="css-vars"&&(l[u(d,c)]=p)}else l[c]=p;else r==="css-vars"&&(l[u(d,c)]=p)}}),s.htmlStyle=l,s}function _a(e){let t={};if(e.color&&(t.color=e.color),e.bgColor&&(t["background-color"]=e.bgColor),e.fontStyle){e.fontStyle&fe.Italic&&(t["font-style"]="italic"),e.fontStyle&fe.Bold&&(t["font-weight"]="bold");let a=[];e.fontStyle&fe.Underline&&a.push("underline"),e.fontStyle&fe.Strikethrough&&a.push("line-through"),a.length&&(t["text-decoration"]=a.join(" "))}return t}function Ho(e){return typeof e=="string"?e:Object.entries(e).map(([t,a])=>`${t}:${a}`).join(";")}var wn=new WeakMap;function Ha(e,t){wn.set(e,t)}function Jt(e){return wn.get(e)}var gt=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(cd(a).map(o=>[o,Aa])),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 xd(this._stacks[t])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}};function xd(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 Ld(e,t){if(!(e instanceof gt))throw new X("Invalid grammar state");return e.getInternalStack(t)}function Id(){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 X(`Invalid decoration offset: ${n}. Code length: ${a.source.length}`);return{...r.indexToPos(n),offset:n}}else{let i=r.lines[n.line];if(i===void 0)throw new X(`Invalid decoration position ${JSON.stringify(n)}. Lines length: ${r.lines.length}`);let l=n.character;if(l<0&&(l=i.length+l),l<0||l>i.length)throw new X(`Invalid decoration position ${JSON.stringify(n)}. Line ${n.line} length: ${i.length}`);return{...n,character:l,offset:r.posToIndex(n.line,l)}}},r=pd(a.source),s=(a.options.decorations||[]).map(n=>({...n,start:o(n.start),end:o(n.end)}));Cd(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 gd(a,r)},code(a){if(!this.options.decorations?.length)return;let o=t(this),r=Array.from(a.children).filter(f=>f.type==="element"&&f.tagName==="span");if(r.length!==o.converter.lines.length)throw new X(`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(f,d,c,p){let h=r[f],S="",L=-1,x=-1;if(d===0&&(L=0),c===0&&(x=0),c===Number.POSITIVE_INFINITY&&(x=h.children.length),L===-1||x===-1)for(let m=0;m<h.children.length;m++)S+=xn(h.children[m]),L===-1&&S.length===d&&(L=m+1),x===-1&&S.length===c&&(x=m+1);if(L===-1)throw new X(`Failed to find start index for decoration ${JSON.stringify(p.start)}`);if(x===-1)throw new X(`Failed to find end index for decoration ${JSON.stringify(p.end)}`);let w=h.children.slice(L,x);if(!p.alwaysWrap&&w.length===h.children.length)i(h,p,"line");else if(!p.alwaysWrap&&w.length===1&&w[0].type==="element")i(w[0],p,"token");else{let m={type:"element",tagName:"span",properties:{},children:w};i(m,p,"wrapper"),h.children.splice(L,w.length,m)}}function n(f,d){r[f]=i(r[f],d,"line")}function i(f,d,c){let p=d.properties||{},h=d.transform||(S=>S);return f.tagName=d.tagName||"span",f.properties={...f.properties,...p,class:f.properties.class},d.properties?.class&&hn(f,d.properties.class),f=h(f,c)||f,f}let l=[],u=o.decorations.sort((f,d)=>d.start.offset-f.start.offset||f.end.offset-d.end.offset);for(let f of u){let{start:d,end:c}=f;if(d.line===c.line)s(d.line,d.character,c.character,f);else if(d.line<c.line){s(d.line,d.character,Number.POSITIVE_INFINITY,f);for(let p=d.line+1;p<c.line;p++)l.unshift(()=>n(p,f));s(c.line,0,c.character,f)}}l.forEach(f=>f())}}}function Cd(e){for(let t=0;t<e.length;t++){let a=e[t];if(a.start.offset>a.end.offset)throw new X(`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,i=r.start.offset<=a.start.offset&&a.start.offset<r.end.offset,l=r.start.offset<a.end.offset&&a.end.offset<=r.end.offset;if(s||n||i||l){if(s&&n||i&&l||i&&a.start.offset===a.end.offset||n&&r.start.offset===r.end.offset)continue;throw new X(`Decorations ${JSON.stringify(a.start)} and ${JSON.stringify(r.start)} intersect.`)}}}}function xn(e){return e.type==="text"?e.value:e.type==="element"?e.children.map(xn).join(""):""}var Sd=[Id()];function Ea(e){let t=yd(e.transformers||[]);return[...t.pre,...t.normal,...t.post,...Sd]}function yd(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 Ye=["black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite"],Oo={1:"bold",2:"dim",3:"italic",4:"underline",7:"reverse",8:"hidden",9:"strikethrough"};function kd(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 sn(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 bd(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)Oo[o]&&t.push({type:"setDecoration",value:Oo[o]});else if(o<=29){let r=Oo[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:Ye[o-30]}});else if(o===38){let r=sn(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:Ye[o-40]}});else if(o===48){let r=sn(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:Ye[o-90+8]}}):o>=100&&o<=107&&t.push({type:"setBackgroundColor",value:{type:"named",name:Ye[o-100+8]}})}return t}function Td(){let e=null,t=null,a=new Set;return{parse(o){let r=[],s=0;do{let n=kd(o,s),i=n.sequence?o.substring(s,n.startPosition):o.substring(s);if(i.length>0&&r.push({value:i,foreground:e,background:t,decorations:new Set(a)}),n.sequence){let l=bd(n.sequence);for(let u of l)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 l)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 Pd={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 Ad(e=Pd){function t(i){return e[i]}function a(i){return`#${i.map(l=>Math.max(0,Math.min(l,255)).toString(16).padStart(2,"0")).join("")}`}let o;function r(){if(o)return o;o=[];for(let u=0;u<Ye.length;u++)o.push(t(Ye[u]));let i=[0,95,135,175,215,255];for(let u=0;u<6;u++)for(let f=0;f<6;f++)for(let d=0;d<6;d++)o.push(a([i[u],i[f],i[d]]));let l=8;for(let u=0;u<24;u++,l+=10)o.push(a([l,l,l]));return o}function s(i){return r()[i]}function n(i){switch(i.type){case"named":return t(i.name);case"rgb":return a(i.rgb);case"table":return s(i.index)}}return{value:n}}var vd={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 Md(e,t,a){let o=Da(e,a),r=Ua(t),s=Object.fromEntries(Ye.map(l=>{let u=`terminal.ansi${l[0].toUpperCase()}${l.substring(1)}`,f=e.colors?.[u];return[l,f||vd[l]]})),n=Ad(s),i=Td();return r.map(l=>i.parse(l[0]).map(u=>{let f,d;u.decorations.has("reverse")?(f=u.background?n.value(u.background):e.bg,d=u.foreground?n.value(u.foreground):e.fg):(f=u.foreground?n.value(u.foreground):e.fg,d=u.background?n.value(u.background):void 0),f=Ge(f,o),d=Ge(d,o),u.decorations.has("dim")&&(f=Rd(f));let c=fe.None;return u.decorations.has("bold")&&(c|=fe.Bold),u.decorations.has("italic")&&(c|=fe.Italic),u.decorations.has("underline")&&(c|=fe.Underline),u.decorations.has("strikethrough")&&(c|=fe.Strikethrough),{content:u.value,offset:l[1],color:f,bgColor:d,fontStyle:c}}))}function Rd(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],i=o[3],l=Math.round(Number.parseInt(`${i}${i}`,16)/2).toString(16).padStart(2,"0");return`#${r}${r}${s}${s}${n}${n}${l}`}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 Vo(e,t,a={}){let{theme:o=e.getLoadedThemes()[0]}=a,r=e.resolveLangAlias(a.lang||"text");if(Wo(r)||zo(o))return Ua(t).map(l=>[{content:l[0],offset:l[1]}]);let{theme:s,colorMap:n}=e.setTheme(o);if(r==="ansi")return Md(s,t,a);let i=e.getLanguage(a.lang||"text");if(a.grammarState){if(a.grammarState.lang!==i.name)throw new X(`Grammar state language "${a.grammarState.lang}" does not match highlight language "${i.name}"`);if(!a.grammarState.themes.includes(s.name))throw new X(`Grammar state themes "${a.grammarState.themes}" do not contain highlight theme "${s.name}"`)}return Bd(t,i,s,n,a)}function Fd(...e){if(e.length===2)return Jt(e[1]);let[t,a,o={}]=e,{lang:r="text",theme:s=t.getLoadedThemes()[0]}=o;if(Wo(r)||zo(s))throw new X("Plain language does not have grammar state");if(r==="ansi")throw new X("ANSI language does not have grammar state");let{theme:n,colorMap:i}=t.setTheme(s),l=t.getLanguage(r);return new gt($o(a,l,n,i,o).stateStack,l.name,n.name)}function Bd(e,t,a,o,r){let s=$o(e,t,a,o,r),n=new gt(s.stateStack,t.name,a.name);return Ha(s.tokens,n),s.tokens}function $o(e,t,a,o,r){let s=Da(a,r),{tokenizeMaxLineLength:n=0,tokenizeTimeLimit:i=500}=r,l=Ua(e),u=r.grammarState?Ld(r.grammarState,a.name)??Aa:r.grammarContextCode!=null?$o(r.grammarContextCode,t,a,o,{...r,grammarState:void 0,grammarContextCode:void 0}).stateStack:Aa,f=[],d=[];for(let c=0,p=l.length;c<p;c++){let[h,S]=l[c];if(h===""){f=[],d.push([]);continue}if(n>0&&h.length>=n){f=[],d.push([{content:h,offset:S,color:"",fontStyle:0}]);continue}let L,x,w;r.includeExplanation&&(L=t.tokenizeLine(h,u,i),x=L.tokens,w=0);let m=t.tokenizeLine2(h,u,i),g=m.tokens.length/2;for(let I=0;I<g;I++){let b=m.tokens[2*I],y=I+1<g?m.tokens[2*I+2]:h.length;if(b===y)continue;let M=m.tokens[2*I+1],_=Ge(o[Ze.getForeground(M)],s),F=Ze.getFontStyle(M),k={content:h.substring(b,y),offset:S+b,color:_,fontStyle:F};if(r.includeExplanation){let A=[];if(r.includeExplanation!=="scopeName")for(let O of a.settings){let D;switch(typeof O.scope){case"string":D=O.scope.split(/,/).map(W=>W.trim());break;case"object":D=O.scope;break;default:continue}A.push({settings:O,selectors:D.map(W=>W.split(/ /))})}k.explanation=[];let Q=0;for(;b+Q<y;){let O=x[w],D=h.substring(O.startIndex,O.endIndex);Q+=D.length,k.explanation.push({content:D,scopes:r.includeExplanation==="scopeName"?Dd(O.scopes):_d(A,O.scopes)}),w+=1}}f.push(k)}d.push(f),f=[],u=m.ruleStack}return{tokens:d,stateStack:u}}function Dd(e){return e.map(t=>({scopeName:t}))}function _d(e,t){let a=[];for(let o=0,r=t.length;o<r;o++){let s=t[o];a[o]={scopeName:s,themeMatches:Nd(e,s,t.slice(0,o))}}return a}function nn(e,t){return e===t||t.substring(0,e.length)===e&&t[e.length]==="."}function Ed(e,t,a){if(!nn(e[e.length-1],t))return!1;let o=e.length-2,r=a.length-1;for(;o>=0&&r>=0;)nn(e[o],a[r])&&(o-=1),r-=1;return o===-1}function Nd(e,t,a){let o=[];for(let{selectors:r,settings:s}of e)for(let n of r)if(Ed(n,t,a)){o.push(s);break}return o}function Ln(e,t,a){let o=Object.entries(a.themes).filter(l=>l[1]).map(l=>({color:l[0],theme:l[1]})),r=o.map(l=>{let u=Vo(e,t,{...a,theme:l.theme}),f=Jt(u),d=typeof l.theme=="string"?l.theme:l.theme.name;return{tokens:u,state:f,theme:d}}),s=Od(...r.map(l=>l.tokens)),n=s[0].map((l,u)=>l.map((f,d)=>{let c={content:f.content,variants:{},offset:f.offset};return"includeExplanation"in a&&a.includeExplanation&&(c.explanation=f.explanation),s.forEach((p,h)=>{let{content:S,explanation:L,offset:x,...w}=p[u][d];c.variants[o[h].color]=w}),c})),i=r[0].state?new gt(Object.fromEntries(r.map(l=>[l.theme,l.state?.getInternalStack(l.theme)])),r[0].state.lang):void 0;return i&&Ha(n,i),n}function Od(...e){let t=e.map(()=>[]),a=e.length;for(let o=0;o<e[0].length;o++){let r=e.map(l=>l[o]),s=t.map(()=>[]);t.forEach((l,u)=>l.push(s[u]));let n=r.map(()=>0),i=r.map(l=>l[0]);for(;i.every(l=>l);){let l=Math.min(...i.map(u=>u.content.length));for(let u=0;u<a;u++){let f=i[u];f.content.length===l?(s[u].push(f),n[u]+=1,i[u]=r[u][n[u]]):(s[u].push({...f,content:f.content.slice(0,l)}),i[u]={...f,content:f.content.slice(l),offset:f.offset+l})}}}return t}function Na(e,t,a){let o,r,s,n,i,l;if("themes"in a){let{defaultColor:u="light",cssVariablePrefix:f="--shiki-",colorsRendering:d="css-vars"}=a,c=Object.entries(a.themes).filter(x=>x[1]).map(x=>({color:x[0],theme:x[1]})).sort((x,w)=>x.color===u?-1:w.color===u?1:0);if(c.length===0)throw new X("`themes` option must not be empty");let p=Ln(e,t,a);if(l=Jt(p),u&&jo!==u&&!c.find(x=>x.color===u))throw new X(`\`themes\` option must contain the defaultColor key \`${u}\``);let h=c.map(x=>e.getTheme(x.theme)),S=c.map(x=>x.color);s=p.map(x=>x.map(w=>wd(w,S,f,u,d))),l&&Ha(s,l);let L=c.map(x=>Da(x.theme,a));r=ln(c,h,L,f,u,"fg",d),o=ln(c,h,L,f,u,"bg",d),n=`shiki-themes ${h.map(x=>x.name).join(" ")}`,i=u?void 0:[r,o].join(";")}else if("theme"in a){let u=Da(a.theme,a);s=Vo(e,t,a);let f=e.getTheme(a.theme);o=Ge(f.bg,u),r=Ge(f.fg,u),n=f.name,l=Jt(s)}else throw new X("Invalid options, either `theme` or `themes` must be provided");return{tokens:s,fg:r,bg:o,themeName:n,rootStyle:i,grammarState:l}}function ln(e,t,a,o,r,s,n){return e.map((i,l)=>{let u=Ge(t[l][s],a[l])||"inherit",f=`${o+i.color}${s==="bg"?"-bg":""}:${u}`;if(l===0&&r){if(r===jo&&e.length>1){let d=e.findIndex(S=>S.color==="light"),c=e.findIndex(S=>S.color==="dark");if(d===-1||c===-1)throw new X('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');let p=Ge(t[d][s],a[d])||"inherit",h=Ge(t[c][s],a[c])||"inherit";return`light-dark(${p}, ${h});${f}`}return u}return n==="css-vars"?f:null}).filter(i=>!!i).join(";")}function Oa(e,t,a,o={meta:{},options:a,codeToHast:(r,s)=>Oa(e,r,s),codeToTokens:(r,s)=>Na(e,r,s)}){let r=t;for(let h of Ea(a))r=h.preprocess?.call(o,r,a)||r;let{tokens:s,fg:n,bg:i,themeName:l,rootStyle:u,grammarState:f}=Na(e,r,a),{mergeWhitespaces:d=!0,mergeSameStyleTokens:c=!1}=a;d===!0?s=Hd(s):d==="never"&&(s=qd(s)),c&&(s=Gd(s));let p={...o,get source(){return r}};for(let h of Ea(a))s=h.tokens?.call(p,s)||s;return Ud(s,{...a,fg:n,bg:i,themeName:l,rootStyle:a.rootStyle===!1?!1:a.rootStyle??u},p,f)}function Ud(e,t,a,o=Jt(e)){let r=Ea(t),s=[],n={type:"root",children:[]},{structure:i="classic",tabindex:l="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}`),l!==!1&&l!=null&&(u.tabindex=l.toString());for(let[S,L]of Object.entries(t.meta||{}))S.startsWith("_")||(u[S]=L);let f={type:"element",tagName:"pre",properties:u,children:[],data:t.data},d={type:"element",tagName:"code",properties:{},children:s},c=[],p={...a,structure:i,addClassToHast:hn,get source(){return a.source},get tokens(){return e},get options(){return t},get root(){return n},get pre(){return f},get code(){return d},get lines(){return c}};if(e.forEach((S,L)=>{L&&(i==="inline"?n.children.push({type:"element",tagName:"br",properties:{},children:[]}):i==="classic"&&s.push({type:"text",value:`
13
+ `}));let x={type:"element",tagName:"span",properties:{class:"line"},children:[]},w=0;for(let m of S){let g={type:"element",tagName:"span",properties:{...m.htmlAttrs},children:[{type:"text",value:m.content}]},I=Ho(m.htmlStyle||_a(m));I&&(g.properties.style=I);for(let b of r)g=b?.span?.call(p,g,L+1,w,x,m)||g;i==="inline"?n.children.push(g):i==="classic"&&x.children.push(g),w+=m.content.length}if(i==="classic"){for(let m of r)x=m?.line?.call(p,x,L+1)||x;c.push(x),s.push(x)}else i==="inline"&&c.push(x)}),i==="classic"){for(let S of r)d=S?.code?.call(p,d)||d;f.children.push(d);for(let S of r)f=S?.pre?.call(p,f)||f;n.children.push(f)}else if(i==="inline"){let S=[],L={type:"element",tagName:"span",properties:{class:"line"},children:[]};for(let m of n.children)m.type==="element"&&m.tagName==="br"?(S.push(L),L={type:"element",tagName:"span",properties:{class:"line"},children:[]}):(m.type==="element"||m.type==="text")&&L.children.push(m);S.push(L);let w={type:"element",tagName:"code",properties:{},children:S};for(let m of r)w=m?.code?.call(p,w)||w;n.children=[];for(let m=0;m<w.children.length;m++){m>0&&n.children.push({type:"element",tagName:"br",properties:{},children:[]});let g=w.children[m];g.type==="element"&&n.children.push(...g.children)}}let h=n;for(let S of r)h=S?.root?.call(p,h)||h;return o&&Ha(h,o),h}function Hd(e){return e.map(t=>{let a=[],o="",r;return t.forEach((s,n)=>{let l=!(s.fontStyle&&(s.fontStyle&fe.Underline||s.fontStyle&fe.Strikethrough));l&&s.content.match(/^\s+$/)&&t[n+1]?(r===void 0&&(r=s.offset),o+=s.content):o?(l?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 qd(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 i=[{...a,offset:a.offset+r.length,content:s}];return r&&i.unshift({content:r,offset:a.offset}),n&&i.push({content:n,offset:a.offset+r.length+s.length}),i}))}function Gd(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=Ho(r.htmlStyle||_a(r)),n=Ho(o.htmlStyle||_a(o)),i=r.fontStyle&&(r.fontStyle&fe.Underline||r.fontStyle&fe.Strikethrough),l=o.fontStyle&&(o.fontStyle&fe.Underline||o.fontStyle&fe.Strikethrough);!i&&!l&&s===n?r.content+=o.content:a.push({...o})}return a})}var Wd=No;function zd(e,t,a){let o={meta:{},options:a,codeToHast:(s,n)=>Oa(e,s,n),codeToTokens:(s,n)=>Na(e,s,n)},r=Wd(Oa(e,t,a,o));for(let s of Ea(a))r=s.postprocess?.call(o,r,a)||r;return r}var un={light:"#333333",dark:"#bbbbbb"},dn={light:"#fffffe",dark:"#1e1e1e"},fn="__shiki_resolved";function Xo(e){if(e?.[fn])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 i=t.settings?t.settings.find(l=>!l.name&&!l.scope):void 0;i?.settings?.foreground&&(o=i.settings.foreground),i?.settings?.background&&(a=i.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"?un.light:un.dark),a||(a=t.type==="light"?dn.light:dn.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(i){if(s.has(i))return s.get(i);r+=1;let l=`#${r.toString(16).padStart(8,"0").toLowerCase()}`;return t.colorReplacements?.[`#${l}`]?n(i):(s.set(i,l),l)}t.settings=t.settings.map(i=>{let l=i.settings?.foreground&&!i.settings.foreground.startsWith("#"),u=i.settings?.background&&!i.settings.background.startsWith("#");if(!l&&!u)return i;let f={...i,settings:{...i.settings}};if(l){let d=n(i.settings.foreground);t.colorReplacements[d]=i.settings.foreground,f.settings.foreground=d}if(u){let d=n(i.settings.background);t.colorReplacements[d]=i.settings.background,f.settings.background=d}return f});for(let i of Object.keys(t.colors||{}))if((i==="editor.foreground"||i==="editor.background"||i.startsWith("terminal.ansi"))&&!t.colors[i]?.startsWith("#")){let l=n(t.colors[i]);t.colorReplacements[l]=t.colors[i],t.colors[i]=l}return Object.defineProperty(t,fn,{enumerable:!1,writable:!1,value:!0}),t}async function In(e){return Array.from(new Set((await Promise.all(e.filter(t=>!pn(t)).map(async t=>await cn(t).then(a=>Array.isArray(a)?a:[a])))).flat()))}async function Cn(e){return(await Promise.all(e.map(async a=>mn(a)?null:Xo(await cn(a))))).filter(a=>!!a)}var Uo=3,jd=!1;function Vd(e,t=3){if(Uo&&!(typeof Uo=="number"&&t>Uo)){if(jd)throw new Error(`[SHIKI DEPRECATE]: ${e}`);console.trace(`[SHIKI DEPRECATE]: ${e}`)}}var qe=class extends Error{constructor(t){super(t),this.name="ShikiError"}};function Sn(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 qo=class extends Us{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=Xo(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=zt.createFromRawTheme(t),this._textmateThemeCache.set(t,a)),this._syncRegistry.setTheme(a)}getGrammar(t){return t=Sn(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(l=>o.map(([u])=>u).includes(l)):!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))}},Go=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}},Kt=0;function $d(e){Kt+=1,e.warnings!==!1&&Kt>=10&&Kt%10===0&&console.warn(`[Shiki] ${Kt} 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(Xo),r=new Go(e.engine,a),s=new qo(r,o,a,e.langAlias),n;function i(m){return Sn(m,e.langAlias)}function l(m){x();let g=s.getGrammar(typeof m=="string"?m:m.name);if(!g)throw new qe(`Language \`${m}\` not found, you may need to load it first`);return g}function u(m){if(m==="none")return{bg:"",fg:"",name:"none",settings:[],type:"dark"};x();let g=s.getTheme(m);if(!g)throw new qe(`Theme \`${m}\` not found, you may need to load it first`);return g}function f(m){x();let g=u(m);n!==m&&(s.setTheme(g),n=m);let I=s.getColorMap();return{theme:g,colorMap:I}}function d(){return x(),s.getLoadedThemes()}function c(){return x(),s.getLoadedLanguages()}function p(...m){x(),s.loadLanguages(m.flat(1))}async function h(...m){return p(await In(m))}function S(...m){x();for(let g of m.flat(1))s.loadTheme(g)}async function L(...m){return x(),S(await Cn(m))}function x(){if(t)throw new qe("Shiki instance has been disposed")}function w(){t||(t=!0,s.dispose(),Kt-=1)}return{setTheme:f,getTheme:u,getLanguage:l,getLoadedThemes:d,getLoadedLanguages:c,resolveLangAlias:i,loadLanguage:h,loadLanguageSync:p,loadTheme:L,loadThemeSync:S,dispose:w,[Symbol.dispose]:w}}async function Xd(e){e.engine||Vd("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");let[t,a,o]=await Promise.all([Cn(e.themes||[]),In(e.langs||[]),e.engine]);return $d({...e,themes:t,langs:a,engine:o})}async function Qd(e){let t=await Xd(e);return{getLastGrammarState:(...a)=>Fd(t,...a),codeToTokensBase:(a,o)=>Vo(t,a,o),codeToTokensWithThemes:(a,o)=>Ln(t,a,o),codeToTokens:(a,o)=>Na(t,a,o),codeToHast:(a,o)=>Oa(t,a,o),codeToHtml:(a,o)=>zd(t,a,o),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...t,getInternalContext:()=>t}}function yn(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,pn(d))return[];let c=t[d];if(!c)throw new X(`Language \`${d}\` is not included in this bundle. You may want to load it from external source.`);return c}return d}function i(d){if(mn(d))return"none";if(typeof d=="string"){let c=a[d];if(!c)throw new X(`Theme \`${d}\` is not included in this bundle. You may want to load it from external source.`);return c}return d}let l=(s.themes??[]).map(d=>i(d)),u=(s.langs??[]).map(d=>n(d)),f=await Qd({engine:s.engine??o(),...s,themes:l,langs:u});return{...f,loadLanguage(...d){return f.loadLanguage(...d.map(n))},loadTheme(...d){return f.loadTheme(...d.map(i))},getBundledLanguages(){return t},getBundledThemes(){return a}}}return r}function Kd(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 kn(e,t){let a=Kd(e);async function o(r,s){let n=await a({langs:[s.lang],themes:"theme"in s?[s.theme]:Object.values(s.themes)}),i=await t?.guessEmbeddedLanguages?.(r,s.lang,n);return i&&await n.loadLanguage(...i),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)}}}var Qo=[{id:"abap",name:"ABAP",import:(()=>import("../abap-KGVIZMDC.js"))},{id:"actionscript-3",name:"ActionScript",import:(()=>import("../actionscript-3-2UHK5QYP.js"))},{id:"ada",name:"Ada",import:(()=>import("../ada-JKTWR5BV.js"))},{id:"angular-html",name:"Angular HTML",import:(()=>import("../angular-html-EOIKHM3D.js"))},{id:"angular-ts",name:"Angular TypeScript",import:(()=>import("../angular-ts-A7ZNTSV6.js"))},{id:"apache",name:"Apache Conf",import:(()=>import("../apache-MPGFGQFB.js"))},{id:"apex",name:"Apex",import:(()=>import("../apex-BOAZL66Z.js"))},{id:"apl",name:"APL",import:(()=>import("../apl-QBN4KIYA.js"))},{id:"applescript",name:"AppleScript",import:(()=>import("../applescript-C4CJ3STL.js"))},{id:"ara",name:"Ara",import:(()=>import("../ara-FSFFBRSD.js"))},{id:"asciidoc",name:"AsciiDoc",aliases:["adoc"],import:(()=>import("../asciidoc-QQK2LANG.js"))},{id:"asm",name:"Assembly",import:(()=>import("../asm-X43A2VYW.js"))},{id:"astro",name:"Astro",import:(()=>import("../astro-OQUOYMBE.js"))},{id:"awk",name:"AWK",import:(()=>import("../awk-4Z3PRTF7.js"))},{id:"ballerina",name:"Ballerina",import:(()=>import("../ballerina-JCXSJ2QD.js"))},{id:"bat",name:"Batch File",aliases:["batch"],import:(()=>import("../bat-XFWR7RMZ.js"))},{id:"beancount",name:"Beancount",import:(()=>import("../beancount-7BBDB4BH.js"))},{id:"berry",name:"Berry",aliases:["be"],import:(()=>import("../berry-PQ2BEJIZ.js"))},{id:"bibtex",name:"BibTeX",import:(()=>import("../bibtex-J2PAB23I.js"))},{id:"bicep",name:"Bicep",import:(()=>import("../bicep-TNKT6R3W.js"))},{id:"blade",name:"Blade",import:(()=>import("../blade-QBDEYXMB.js"))},{id:"bsl",name:"1C (Enterprise)",aliases:["1c"],import:(()=>import("../bsl-PQW6E45S.js"))},{id:"c",name:"C",import:(()=>import("../c-PZBJFNXE.js"))},{id:"c3",name:"C3",import:(()=>import("../c3-GP7XYHE6.js"))},{id:"cadence",name:"Cadence",aliases:["cdc"],import:(()=>import("../cadence-NABGDHKY.js"))},{id:"cairo",name:"Cairo",import:(()=>import("../cairo-WQSC2GLN.js"))},{id:"clarity",name:"Clarity",import:(()=>import("../clarity-NXNSINKX.js"))},{id:"clojure",name:"Clojure",aliases:["clj"],import:(()=>import("../clojure-Y57BKRMA.js"))},{id:"cmake",name:"CMake",import:(()=>import("../cmake-LVMEA3JZ.js"))},{id:"cobol",name:"COBOL",import:(()=>import("../cobol-6DNJTKH3.js"))},{id:"codeowners",name:"CODEOWNERS",import:(()=>import("../codeowners-JYHOTXQS.js"))},{id:"codeql",name:"CodeQL",aliases:["ql"],import:(()=>import("../codeql-IWWSYR3L.js"))},{id:"coffee",name:"CoffeeScript",aliases:["coffeescript"],import:(()=>import("../coffee-NNDQ5QXC.js"))},{id:"common-lisp",name:"Common Lisp",aliases:["lisp"],import:(()=>import("../common-lisp-JKXCDYH3.js"))},{id:"coq",name:"Coq",import:(()=>import("../coq-BEHPNP64.js"))},{id:"cpp",name:"C++",aliases:["c++"],import:(()=>import("../cpp-IALOHSZA.js"))},{id:"crystal",name:"Crystal",import:(()=>import("../crystal-ZDP3FIUI.js"))},{id:"csharp",name:"C#",aliases:["c#","cs"],import:(()=>import("../csharp-ODFBXRGA.js"))},{id:"css",name:"CSS",import:(()=>import("../css-CJGL5AVH.js"))},{id:"csv",name:"CSV",import:(()=>import("../csv-LIK4TU3Z.js"))},{id:"cue",name:"CUE",import:(()=>import("../cue-UAAEAKHI.js"))},{id:"cypher",name:"Cypher",aliases:["cql"],import:(()=>import("../cypher-SZPVUQZJ.js"))},{id:"d",name:"D",import:(()=>import("../d-VSCA3XHG.js"))},{id:"dart",name:"Dart",import:(()=>import("../dart-A4PE6FIS.js"))},{id:"dax",name:"DAX",import:(()=>import("../dax-TILIKSFB.js"))},{id:"desktop",name:"Desktop",import:(()=>import("../desktop-75KK3D55.js"))},{id:"diff",name:"Diff",import:(()=>import("../diff-HOT6P45M.js"))},{id:"docker",name:"Dockerfile",aliases:["dockerfile"],import:(()=>import("../docker-FF35TY6T.js"))},{id:"dotenv",name:"dotEnv",import:(()=>import("../dotenv-FVPPHJI3.js"))},{id:"dream-maker",name:"Dream Maker",import:(()=>import("../dream-maker-SYE3ZPSJ.js"))},{id:"edge",name:"Edge",import:(()=>import("../edge-CCLQ2CKA.js"))},{id:"elixir",name:"Elixir",import:(()=>import("../elixir-F6DQGRKA.js"))},{id:"elm",name:"Elm",import:(()=>import("../elm-5QRQXDZ6.js"))},{id:"emacs-lisp",name:"Emacs Lisp",aliases:["elisp"],import:(()=>import("../emacs-lisp-NJ4S4OHV.js"))},{id:"erb",name:"ERB",import:(()=>import("../erb-HGSLHT5Y.js"))},{id:"erlang",name:"Erlang",aliases:["erl"],import:(()=>import("../erlang-APEONNZ6.js"))},{id:"fennel",name:"Fennel",import:(()=>import("../fennel-7OCMFVPS.js"))},{id:"fish",name:"Fish",import:(()=>import("../fish-BC46ME2N.js"))},{id:"fluent",name:"Fluent",aliases:["ftl"],import:(()=>import("../fluent-MXZS6EX3.js"))},{id:"fortran-fixed-form",name:"Fortran (Fixed Form)",aliases:["f","for","f77"],import:(()=>import("../fortran-fixed-form-35BC2KX6.js"))},{id:"fortran-free-form",name:"Fortran (Free Form)",aliases:["f90","f95","f03","f08","f18"],import:(()=>import("../fortran-free-form-AXRAI2HH.js"))},{id:"fsharp",name:"F#",aliases:["f#","fs"],import:(()=>import("../fsharp-JKNSQXHD.js"))},{id:"gdresource",name:"GDResource",aliases:["tscn","tres"],import:(()=>import("../gdresource-ZMKZGPZV.js"))},{id:"gdscript",name:"GDScript",aliases:["gd"],import:(()=>import("../gdscript-HNCVXEYB.js"))},{id:"gdshader",name:"GDShader",import:(()=>import("../gdshader-XAJ4QRYP.js"))},{id:"genie",name:"Genie",import:(()=>import("../genie-HEFVQZAP.js"))},{id:"gherkin",name:"Gherkin",import:(()=>import("../gherkin-OFBRDPXX.js"))},{id:"git-commit",name:"Git Commit Message",import:(()=>import("../git-commit-ZE2M3Q5H.js"))},{id:"git-rebase",name:"Git Rebase Message",import:(()=>import("../git-rebase-3N3INGLU.js"))},{id:"gleam",name:"Gleam",import:(()=>import("../gleam-NFFQFQLP.js"))},{id:"glimmer-js",name:"Glimmer JS",aliases:["gjs"],import:(()=>import("../glimmer-js-RSUW6JYN.js"))},{id:"glimmer-ts",name:"Glimmer TS",aliases:["gts"],import:(()=>import("../glimmer-ts-EZGWLX5T.js"))},{id:"glsl",name:"GLSL",import:(()=>import("../glsl-VJLRYEVJ.js"))},{id:"gn",name:"GN",import:(()=>import("../gn-UH2XQWLG.js"))},{id:"gnuplot",name:"Gnuplot",import:(()=>import("../gnuplot-K6IV6NNR.js"))},{id:"go",name:"Go",import:(()=>import("../go-BDV7RR5G.js"))},{id:"graphql",name:"GraphQL",aliases:["gql"],import:(()=>import("../graphql-YEJQLMOO.js"))},{id:"groovy",name:"Groovy",import:(()=>import("../groovy-SX7K3XGL.js"))},{id:"hack",name:"Hack",import:(()=>import("../hack-3TGPQNR2.js"))},{id:"haml",name:"Ruby Haml",import:(()=>import("../haml-335RVEQR.js"))},{id:"handlebars",name:"Handlebars",aliases:["hbs"],import:(()=>import("../handlebars-73IS6B2J.js"))},{id:"haskell",name:"Haskell",aliases:["hs"],import:(()=>import("../haskell-P5PTJARU.js"))},{id:"haxe",name:"Haxe",import:(()=>import("../haxe-RCPSSA3N.js"))},{id:"hcl",name:"HashiCorp HCL",import:(()=>import("../hcl-AKKZAVC2.js"))},{id:"hjson",name:"Hjson",import:(()=>import("../hjson-REXV6F6N.js"))},{id:"hlsl",name:"HLSL",import:(()=>import("../hlsl-AJ7VWOVL.js"))},{id:"html",name:"HTML",import:(()=>import("../html-654LNGWF.js"))},{id:"html-derivative",name:"HTML (Derivative)",import:(()=>import("../html-derivative-CMQ7BFDQ.js"))},{id:"http",name:"HTTP",import:(()=>import("../http-NEPTRAQZ.js"))},{id:"hurl",name:"Hurl",import:(()=>import("../hurl-V6ZX2Q3F.js"))},{id:"hxml",name:"HXML",import:(()=>import("../hxml-5BXJCAAU.js"))},{id:"hy",name:"Hy",import:(()=>import("../hy-SB4TMFE7.js"))},{id:"imba",name:"Imba",import:(()=>import("../imba-Y64MHYWP.js"))},{id:"ini",name:"INI",aliases:["properties"],import:(()=>import("../ini-J2OP4CNW.js"))},{id:"java",name:"Java",import:(()=>import("../java-MJKJ5GPP.js"))},{id:"javascript",name:"JavaScript",aliases:["js","cjs","mjs"],import:(()=>import("../javascript-IYAGHPR6.js"))},{id:"jinja",name:"Jinja",import:(()=>import("../jinja-WPD26JJ6.js"))},{id:"jison",name:"Jison",import:(()=>import("../jison-UYDZQBN5.js"))},{id:"json",name:"JSON",import:(()=>import("../json-5V4JESJO.js"))},{id:"json5",name:"JSON5",import:(()=>import("../json5-7SHUZD3R.js"))},{id:"jsonc",name:"JSON with Comments",import:(()=>import("../jsonc-X3Z34FN3.js"))},{id:"jsonl",name:"JSON Lines",import:(()=>import("../jsonl-6I3D2HM6.js"))},{id:"jsonnet",name:"Jsonnet",import:(()=>import("../jsonnet-PZEQIBYV.js"))},{id:"jssm",name:"JSSM",aliases:["fsl"],import:(()=>import("../jssm-GJJ25IKR.js"))},{id:"jsx",name:"JSX",import:(()=>import("../jsx-NI2J427C.js"))},{id:"julia",name:"Julia",aliases:["jl"],import:(()=>import("../julia-QPZ7EOS6.js"))},{id:"kdl",name:"KDL",import:(()=>import("../kdl-IA7HA2TL.js"))},{id:"kotlin",name:"Kotlin",aliases:["kt","kts"],import:(()=>import("../kotlin-CCRMGYMI.js"))},{id:"kusto",name:"Kusto",aliases:["kql"],import:(()=>import("../kusto-7DW25GYH.js"))},{id:"latex",name:"LaTeX",import:(()=>import("../latex-F2CTDTFG.js"))},{id:"lean",name:"Lean 4",aliases:["lean4"],import:(()=>import("../lean-MGJJWBTR.js"))},{id:"less",name:"Less",import:(()=>import("../less-WFSIMX5G.js"))},{id:"liquid",name:"Liquid",import:(()=>import("../liquid-7CFNUD3V.js"))},{id:"llvm",name:"LLVM IR",import:(()=>import("../llvm-CFQSEDXB.js"))},{id:"log",name:"Log file",import:(()=>import("../log-YQNML6LA.js"))},{id:"logo",name:"Logo",import:(()=>import("../logo-2PPKBL2M.js"))},{id:"lua",name:"Lua",import:(()=>import("../lua-RPAMRKNG.js"))},{id:"luau",name:"Luau",import:(()=>import("../luau-GR2DOH6N.js"))},{id:"make",name:"Makefile",aliases:["makefile"],import:(()=>import("../make-DQQEEPI4.js"))},{id:"markdown",name:"Markdown",aliases:["md"],import:(()=>import("../markdown-OC5ILZSY.js"))},{id:"marko",name:"Marko",import:(()=>import("../marko-XSB3CTWQ.js"))},{id:"matlab",name:"MATLAB",import:(()=>import("../matlab-YQY6FS4U.js"))},{id:"mdc",name:"MDC",import:(()=>import("../mdc-TEVTGSC7.js"))},{id:"mdx",name:"MDX",import:(()=>import("../mdx-ZIH2JLVR.js"))},{id:"mermaid",name:"Mermaid",aliases:["mmd"],import:(()=>import("../mermaid-WPX56SBB.js"))},{id:"mipsasm",name:"MIPS Assembly",aliases:["mips"],import:(()=>import("../mipsasm-IDXQRZ2B.js"))},{id:"mojo",name:"Mojo",import:(()=>import("../mojo-MH7EQVOK.js"))},{id:"moonbit",name:"MoonBit",aliases:["mbt","mbti"],import:(()=>import("../moonbit-5JDFTWKE.js"))},{id:"move",name:"Move",import:(()=>import("../move-RWSXKYDY.js"))},{id:"narrat",name:"Narrat Language",aliases:["nar"],import:(()=>import("../narrat-QJUEXMVV.js"))},{id:"nextflow",name:"Nextflow",aliases:["nf"],import:(()=>import("../nextflow-2EICNZA3.js"))},{id:"nginx",name:"Nginx",import:(()=>import("../nginx-RIWAEC5Z.js"))},{id:"nim",name:"Nim",import:(()=>import("../nim-JPSYX5KC.js"))},{id:"nix",name:"Nix",import:(()=>import("../nix-XCKQVWCN.js"))},{id:"nushell",name:"nushell",aliases:["nu"],import:(()=>import("../nushell-QGW7HANA.js"))},{id:"objective-c",name:"Objective-C",aliases:["objc"],import:(()=>import("../objective-c-V7KYXFHL.js"))},{id:"objective-cpp",name:"Objective-C++",import:(()=>import("../objective-cpp-NKUEWVGU.js"))},{id:"ocaml",name:"OCaml",import:(()=>import("../ocaml-QT2CZJZN.js"))},{id:"odin",name:"Odin",import:(()=>import("../odin-MVMIXBHP.js"))},{id:"openscad",name:"OpenSCAD",aliases:["scad"],import:(()=>import("../openscad-BJDUXUUZ.js"))},{id:"pascal",name:"Pascal",import:(()=>import("../pascal-HGWEFD6L.js"))},{id:"perl",name:"Perl",import:(()=>import("../perl-X4IFZB22.js"))},{id:"php",name:"PHP",import:(()=>import("../php-3V7EPUAN.js"))},{id:"pkl",name:"Pkl",import:(()=>import("../pkl-VA5ZK5DW.js"))},{id:"plsql",name:"PL/SQL",import:(()=>import("../plsql-J7A7YWFH.js"))},{id:"po",name:"Gettext PO",aliases:["pot","potx"],import:(()=>import("../po-5RDI65JX.js"))},{id:"polar",name:"Polar",import:(()=>import("../polar-VUJL2E7F.js"))},{id:"postcss",name:"PostCSS",import:(()=>import("../postcss-ESTB5G7N.js"))},{id:"powerquery",name:"PowerQuery",import:(()=>import("../powerquery-ODTEKQCW.js"))},{id:"powershell",name:"PowerShell",aliases:["ps","ps1"],import:(()=>import("../powershell-ZOYRAWBJ.js"))},{id:"prisma",name:"Prisma",import:(()=>import("../prisma-QHG2W5GE.js"))},{id:"prolog",name:"Prolog",import:(()=>import("../prolog-CSAPG5PH.js"))},{id:"proto",name:"Protocol Buffer 3",aliases:["protobuf"],import:(()=>import("../proto-WDNJBTSW.js"))},{id:"pug",name:"Pug",aliases:["jade"],import:(()=>import("../pug-P7LS6DER.js"))},{id:"puppet",name:"Puppet",import:(()=>import("../puppet-LHFWHTY3.js"))},{id:"purescript",name:"PureScript",import:(()=>import("../purescript-DUFJP4FY.js"))},{id:"python",name:"Python",aliases:["py"],import:(()=>import("../python-5ZNZSNQ2.js"))},{id:"qml",name:"QML",import:(()=>import("../qml-LTAXB6W5.js"))},{id:"qmldir",name:"QML Directory",import:(()=>import("../qmldir-7Z2ODQLM.js"))},{id:"qss",name:"Qt Style Sheets",import:(()=>import("../qss-FDFD3HQD.js"))},{id:"r",name:"R",import:(()=>import("../r-6ZOS53WN.js"))},{id:"racket",name:"Racket",import:(()=>import("../racket-7AYZPEUI.js"))},{id:"raku",name:"Raku",aliases:["perl6"],import:(()=>import("../raku-A4F6VHVG.js"))},{id:"razor",name:"ASP.NET Razor",import:(()=>import("../razor-4QOCK4UD.js"))},{id:"reg",name:"Windows Registry Script",import:(()=>import("../reg-FAPHGG66.js"))},{id:"regexp",name:"RegExp",aliases:["regex"],import:(()=>import("../regexp-5BYLYA2R.js"))},{id:"rel",name:"Rel",import:(()=>import("../rel-7DJ7HHU4.js"))},{id:"riscv",name:"RISC-V",import:(()=>import("../riscv-YIYJATFG.js"))},{id:"ron",name:"RON",import:(()=>import("../ron-HYYMCHTX.js"))},{id:"rosmsg",name:"ROS Interface",import:(()=>import("../rosmsg-FDNH6QF7.js"))},{id:"rst",name:"reStructuredText",import:(()=>import("../rst-WIWCR2KQ.js"))},{id:"ruby",name:"Ruby",aliases:["rb"],import:(()=>import("../ruby-LXZJUMFB.js"))},{id:"rust",name:"Rust",aliases:["rs"],import:(()=>import("../rust-V3GMJA2K.js"))},{id:"sas",name:"SAS",import:(()=>import("../sas-D3G4GB3X.js"))},{id:"sass",name:"Sass",import:(()=>import("../sass-JTO65AGR.js"))},{id:"scala",name:"Scala",import:(()=>import("../scala-4XQGFSVM.js"))},{id:"scheme",name:"Scheme",import:(()=>import("../scheme-CB7AC7IL.js"))},{id:"scss",name:"SCSS",import:(()=>import("../scss-6SKV4OGI.js"))},{id:"sdbl",name:"1C (Query)",aliases:["1c-query"],import:(()=>import("../sdbl-LKGZFJ46.js"))},{id:"shaderlab",name:"ShaderLab",aliases:["shader"],import:(()=>import("../shaderlab-K536DHEB.js"))},{id:"shellscript",name:"Shell",aliases:["bash","sh","shell","zsh"],import:(()=>import("../shellscript-LRNUKUSZ.js"))},{id:"shellsession",name:"Shell Session",aliases:["console"],import:(()=>import("../shellsession-IBQK7VWQ.js"))},{id:"smalltalk",name:"Smalltalk",import:(()=>import("../smalltalk-DQOSWAW7.js"))},{id:"solidity",name:"Solidity",import:(()=>import("../solidity-V2FMZEG4.js"))},{id:"soy",name:"Closure Templates",aliases:["closure-templates"],import:(()=>import("../soy-VW3CKXWF.js"))},{id:"sparql",name:"SPARQL",import:(()=>import("../sparql-L2VKP7YP.js"))},{id:"splunk",name:"Splunk Query Language",aliases:["spl"],import:(()=>import("../splunk-KDKHP7GC.js"))},{id:"sql",name:"SQL",import:(()=>import("../sql-UF27CALT.js"))},{id:"ssh-config",name:"SSH Config",import:(()=>import("../ssh-config-JC2DQ6ED.js"))},{id:"stata",name:"Stata",import:(()=>import("../stata-7PXCUY24.js"))},{id:"stylus",name:"Stylus",aliases:["styl"],import:(()=>import("../stylus-2L7N3EZD.js"))},{id:"surrealql",name:"SurrealQL",aliases:["surql"],import:(()=>import("../surrealql-ZY3E6XEL.js"))},{id:"svelte",name:"Svelte",import:(()=>import("../svelte-Q45XIK2A.js"))},{id:"swift",name:"Swift",import:(()=>import("../swift-XBH5HZSC.js"))},{id:"system-verilog",name:"SystemVerilog",import:(()=>import("../system-verilog-VRAUSZY3.js"))},{id:"systemd",name:"Systemd Units",import:(()=>import("../systemd-JOTSGJD4.js"))},{id:"talonscript",name:"TalonScript",aliases:["talon"],import:(()=>import("../talonscript-NNZRZKOU.js"))},{id:"tasl",name:"Tasl",import:(()=>import("../tasl-MBFZ4QNC.js"))},{id:"tcl",name:"Tcl",import:(()=>import("../tcl-4GEDCBVE.js"))},{id:"templ",name:"Templ",import:(()=>import("../templ-3XM7DLQ3.js"))},{id:"terraform",name:"Terraform",aliases:["tf","tfvars"],import:(()=>import("../terraform-XTHOS4UK.js"))},{id:"tex",name:"TeX",import:(()=>import("../tex-UXMN2CV7.js"))},{id:"toml",name:"TOML",import:(()=>import("../toml-J6K55ZSV.js"))},{id:"ts-tags",name:"TypeScript with Tags",aliases:["lit"],import:(()=>import("../ts-tags-7WGDLEKX.js"))},{id:"tsv",name:"TSV",import:(()=>import("../tsv-DOUJHQDQ.js"))},{id:"tsx",name:"TSX",import:(()=>import("../tsx-G5BMVRHK.js"))},{id:"turtle",name:"Turtle",import:(()=>import("../turtle-JHJ7W6U5.js"))},{id:"twig",name:"Twig",import:(()=>import("../twig-C6YWFFZU.js"))},{id:"typescript",name:"TypeScript",aliases:["ts","cts","mts"],import:(()=>import("../typescript-LMKEAHFC.js"))},{id:"typespec",name:"TypeSpec",aliases:["tsp"],import:(()=>import("../typespec-5CLTIJYY.js"))},{id:"typst",name:"Typst",aliases:["typ"],import:(()=>import("../typst-4W4Z436Z.js"))},{id:"v",name:"V",import:(()=>import("../v-Y4SBDBN7.js"))},{id:"vala",name:"Vala",import:(()=>import("../vala-UMKT2MFA.js"))},{id:"vb",name:"Visual Basic",aliases:["cmd"],import:(()=>import("../vb-DQ7A5WJU.js"))},{id:"verilog",name:"Verilog",import:(()=>import("../verilog-N6ZF7GQD.js"))},{id:"vhdl",name:"VHDL",import:(()=>import("../vhdl-BNYDT37G.js"))},{id:"viml",name:"Vim Script",aliases:["vim","vimscript"],import:(()=>import("../viml-37RMDCBC.js"))},{id:"vue",name:"Vue",import:(()=>import("../vue-O6SLORWU.js"))},{id:"vue-html",name:"Vue HTML",import:(()=>import("../vue-html-ZLTZN573.js"))},{id:"vue-vine",name:"Vue Vine",import:(()=>import("../vue-vine-6JKAZ54I.js"))},{id:"vyper",name:"Vyper",aliases:["vy"],import:(()=>import("../vyper-GVXF46KD.js"))},{id:"wasm",name:"WebAssembly",import:(()=>import("../wasm-NTB4O7GL.js"))},{id:"wenyan",name:"Wenyan",aliases:["\u6587\u8A00"],import:(()=>import("../wenyan-W7WB3BC7.js"))},{id:"wgsl",name:"WGSL",import:(()=>import("../wgsl-7GTDVXHG.js"))},{id:"wikitext",name:"Wikitext",aliases:["mediawiki","wiki"],import:(()=>import("../wikitext-ASAFPAIL.js"))},{id:"wit",name:"WebAssembly Interface Types",import:(()=>import("../wit-ZBCR6544.js"))},{id:"wolfram",name:"Wolfram",aliases:["wl"],import:(()=>import("../wolfram-SZRZOETJ.js"))},{id:"xml",name:"XML",import:(()=>import("../xml-EBTJCOTU.js"))},{id:"xsl",name:"XSL",import:(()=>import("../xsl-IBYEXWDX.js"))},{id:"yaml",name:"YAML",aliases:["yml"],import:(()=>import("../yaml-GMVQNECR.js"))},{id:"zenscript",name:"ZenScript",import:(()=>import("../zenscript-O2TZFP4A.js"))},{id:"zig",name:"Zig",import:(()=>import("../zig-ZLGM7IMN.js"))}],bn=Object.fromEntries(Qo.map(e=>[e.id,e.import])),Tn=Object.fromEntries(Qo.flatMap(e=>e.aliases?.map(t=>[t,e.import])||[])),Zt={...bn,...Tn};var Jd=[{id:"andromeeda",displayName:"Andromeeda",type:"dark",import:(()=>import("../andromeeda-HAPOYWX3.js"))},{id:"aurora-x",displayName:"Aurora X",type:"dark",import:(()=>import("../aurora-x-R6WAWEBC.js"))},{id:"ayu-dark",displayName:"Ayu Dark",type:"dark",import:(()=>import("../ayu-dark-KMD4YO7F.js"))},{id:"ayu-light",displayName:"Ayu Light",type:"light",import:(()=>import("../ayu-light-2ATPDILG.js"))},{id:"ayu-mirage",displayName:"Ayu Mirage",type:"dark",import:(()=>import("../ayu-mirage-LJ7PG5AM.js"))},{id:"catppuccin-frappe",displayName:"Catppuccin Frapp\xE9",type:"dark",import:(()=>import("../catppuccin-frappe-Z4Y2POK6.js"))},{id:"catppuccin-latte",displayName:"Catppuccin Latte",type:"light",import:(()=>import("../catppuccin-latte-4TQUIKX4.js"))},{id:"catppuccin-macchiato",displayName:"Catppuccin Macchiato",type:"dark",import:(()=>import("../catppuccin-macchiato-B7YYPERT.js"))},{id:"catppuccin-mocha",displayName:"Catppuccin Mocha",type:"dark",import:(()=>import("../catppuccin-mocha-KX33VXKA.js"))},{id:"dark-plus",displayName:"Dark Plus",type:"dark",import:(()=>import("../dark-plus-LNHXUR7U.js"))},{id:"dracula",displayName:"Dracula Theme",type:"dark",import:(()=>import("../dracula-T2CMBBQ5.js"))},{id:"dracula-soft",displayName:"Dracula Theme Soft",type:"dark",import:(()=>import("../dracula-soft-SMFRNKX2.js"))},{id:"everforest-dark",displayName:"Everforest Dark",type:"dark",import:(()=>import("../everforest-dark-DBZHIUAO.js"))},{id:"everforest-light",displayName:"Everforest Light",type:"light",import:(()=>import("../everforest-light-TDAGYJUK.js"))},{id:"github-dark",displayName:"GitHub Dark",type:"dark",import:(()=>import("../github-dark-3E25TTAN.js"))},{id:"github-dark-default",displayName:"GitHub Dark Default",type:"dark",import:(()=>import("../github-dark-default-KCBFVSS5.js"))},{id:"github-dark-dimmed",displayName:"GitHub Dark Dimmed",type:"dark",import:(()=>import("../github-dark-dimmed-WRCBXEVS.js"))},{id:"github-dark-high-contrast",displayName:"GitHub Dark High Contrast",type:"dark",import:(()=>import("../github-dark-high-contrast-ET7SAHAV.js"))},{id:"github-light",displayName:"GitHub Light",type:"light",import:(()=>import("../github-light-6FNTZH5H.js"))},{id:"github-light-default",displayName:"GitHub Light Default",type:"light",import:(()=>import("../github-light-default-GGTAKNM7.js"))},{id:"github-light-high-contrast",displayName:"GitHub Light High Contrast",type:"light",import:(()=>import("../github-light-high-contrast-LHYKPR5E.js"))},{id:"gruvbox-dark-hard",displayName:"Gruvbox Dark Hard",type:"dark",import:(()=>import("../gruvbox-dark-hard-IQWZCHF7.js"))},{id:"gruvbox-dark-medium",displayName:"Gruvbox Dark Medium",type:"dark",import:(()=>import("../gruvbox-dark-medium-ARPWF4FS.js"))},{id:"gruvbox-dark-soft",displayName:"Gruvbox Dark Soft",type:"dark",import:(()=>import("../gruvbox-dark-soft-ODS6FPID.js"))},{id:"gruvbox-light-hard",displayName:"Gruvbox Light Hard",type:"light",import:(()=>import("../gruvbox-light-hard-KFA5YFDW.js"))},{id:"gruvbox-light-medium",displayName:"Gruvbox Light Medium",type:"light",import:(()=>import("../gruvbox-light-medium-MMET4L3Y.js"))},{id:"gruvbox-light-soft",displayName:"Gruvbox Light Soft",type:"light",import:(()=>import("../gruvbox-light-soft-DBZDERMK.js"))},{id:"horizon",displayName:"Horizon",type:"dark",import:(()=>import("../horizon-FSOMPXNP.js"))},{id:"houston",displayName:"Houston",type:"dark",import:(()=>import("../houston-FAQBCORN.js"))},{id:"kanagawa-dragon",displayName:"Kanagawa Dragon",type:"dark",import:(()=>import("../kanagawa-dragon-JNDVF5RJ.js"))},{id:"kanagawa-lotus",displayName:"Kanagawa Lotus",type:"light",import:(()=>import("../kanagawa-lotus-S7JK6TQ6.js"))},{id:"kanagawa-wave",displayName:"Kanagawa Wave",type:"dark",import:(()=>import("../kanagawa-wave-QJJIMVEV.js"))},{id:"laserwave",displayName:"LaserWave",type:"dark",import:(()=>import("../laserwave-YFP3EJVX.js"))},{id:"light-plus",displayName:"Light Plus",type:"light",import:(()=>import("../light-plus-NGDHCPUZ.js"))},{id:"material-theme",displayName:"Material Theme",type:"dark",import:(()=>import("../material-theme-H2BHKUKX.js"))},{id:"material-theme-darker",displayName:"Material Theme Darker",type:"dark",import:(()=>import("../material-theme-darker-VENCGWTB.js"))},{id:"material-theme-lighter",displayName:"Material Theme Lighter",type:"light",import:(()=>import("../material-theme-lighter-SDMLS22W.js"))},{id:"material-theme-ocean",displayName:"Material Theme Ocean",type:"dark",import:(()=>import("../material-theme-ocean-UHDBRLVF.js"))},{id:"material-theme-palenight",displayName:"Material Theme Palenight",type:"dark",import:(()=>import("../material-theme-palenight-3TB2BEET.js"))},{id:"min-dark",displayName:"Min Dark",type:"dark",import:(()=>import("../min-dark-CQ5WKNT7.js"))},{id:"min-light",displayName:"Min Light",type:"light",import:(()=>import("../min-light-LZRD4NPR.js"))},{id:"monokai",displayName:"Monokai",type:"dark",import:(()=>import("../monokai-WHRY6275.js"))},{id:"night-owl",displayName:"Night Owl",type:"dark",import:(()=>import("../night-owl-7PNEW2JB.js"))},{id:"night-owl-light",displayName:"Night Owl Light",type:"light",import:(()=>import("../night-owl-light-GJUYOOJR.js"))},{id:"nord",displayName:"Nord",type:"dark",import:(()=>import("../nord-EVGUMUX2.js"))},{id:"one-dark-pro",displayName:"One Dark Pro",type:"dark",import:(()=>import("../one-dark-pro-PMTR3SA7.js"))},{id:"one-light",displayName:"One Light",type:"light",import:(()=>import("../one-light-O7WH4N5X.js"))},{id:"plastic",displayName:"Plastic",type:"dark",import:(()=>import("../plastic-FBVUW6NJ.js"))},{id:"poimandres",displayName:"Poimandres",type:"dark",import:(()=>import("../poimandres-WBB7GZAD.js"))},{id:"red",displayName:"Red",type:"dark",import:(()=>import("../red-7KAMONOP.js"))},{id:"rose-pine",displayName:"Ros\xE9 Pine",type:"dark",import:(()=>import("../rose-pine-F2G5IHZD.js"))},{id:"rose-pine-dawn",displayName:"Ros\xE9 Pine Dawn",type:"light",import:(()=>import("../rose-pine-dawn-ALZ7XGH2.js"))},{id:"rose-pine-moon",displayName:"Ros\xE9 Pine Moon",type:"dark",import:(()=>import("../rose-pine-moon-D3K4SWUL.js"))},{id:"slack-dark",displayName:"Slack Dark",type:"dark",import:(()=>import("../slack-dark-YFPJODWS.js"))},{id:"slack-ochin",displayName:"Slack Ochin",type:"light",import:(()=>import("../slack-ochin-H67AWZOI.js"))},{id:"snazzy-light",displayName:"Snazzy Light",type:"light",import:(()=>import("../snazzy-light-OUVS63VK.js"))},{id:"solarized-dark",displayName:"Solarized Dark",type:"dark",import:(()=>import("../solarized-dark-2RCAVEXJ.js"))},{id:"solarized-light",displayName:"Solarized Light",type:"light",import:(()=>import("../solarized-light-XFSENHTC.js"))},{id:"synthwave-84",displayName:"Synthwave '84",type:"dark",import:(()=>import("../synthwave-84-5XXB3K6S.js"))},{id:"tokyo-night",displayName:"Tokyo Night",type:"dark",import:(()=>import("../tokyo-night-CHJCCBJH.js"))},{id:"vesper",displayName:"Vesper",type:"dark",import:(()=>import("../vesper-Y5GIEAN4.js"))},{id:"vitesse-black",displayName:"Vitesse Black",type:"dark",import:(()=>import("../vitesse-black-7TI33KHX.js"))},{id:"vitesse-dark",displayName:"Vitesse Dark",type:"dark",import:(()=>import("../vitesse-dark-FOB25MRB.js"))},{id:"vitesse-light",displayName:"Vitesse Light",type:"light",import:(()=>import("../vitesse-light-4WCNCTCO.js"))}],Pn=Object.fromEntries(Jd.map(e=>[e.id,e.import]));var Yt=class extends Error{constructor(t){super(t),this.name="ShikiError"}};function Zd(){return 2147483648}function Yd(){return typeof performance<"u"?performance.now():Date.now()}var ef=(e,t)=>e+(t-e%t)%t;async function tf(e){let t,a,o={};function r(p){a=p,o.HEAPU8=new Uint8Array(p),o.HEAPU32=new Uint32Array(p)}function s(p,h,S){o.HEAPU8.copyWithin(p,h,h+S)}function n(p){try{return t.grow(p-a.byteLength+65535>>>16),r(t.buffer),1}catch{}}function i(p){let h=o.HEAPU8.length;p=p>>>0;let S=Zd();if(p>S)return!1;for(let L=1;L<=4;L*=2){let x=h*(1+.2/L);x=Math.min(x,p+100663296);let w=Math.min(S,ef(Math.max(p,x),65536));if(n(w))return!0}return!1}let l=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function u(p,h,S=1024){let L=h+S,x=h;for(;p[x]&&!(x>=L);)++x;if(x-h>16&&p.buffer&&l)return l.decode(p.subarray(h,x));let w="";for(;h<x;){let m=p[h++];if(!(m&128)){w+=String.fromCharCode(m);continue}let g=p[h++]&63;if((m&224)===192){w+=String.fromCharCode((m&31)<<6|g);continue}let I=p[h++]&63;if((m&240)===224?m=(m&15)<<12|g<<6|I:m=(m&7)<<18|g<<12|I<<6|p[h++]&63,m<65536)w+=String.fromCharCode(m);else{let b=m-65536;w+=String.fromCharCode(55296|b>>10,56320|b&1023)}}return w}function f(p,h){return p?u(o.HEAPU8,p,h):""}let d={emscripten_get_now:Yd,emscripten_memcpy_big:s,emscripten_resize_heap:i,fd_write:()=>0};async function c(){let h=await e({env:d,wasi_snapshot_preview1:d});t=h.memory,r(t.buffer),Object.assign(o,h),o.UTF8ToString=f}return await c(),o}var af=Object.defineProperty,of=(e,t,a)=>t in e?af(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,re=(e,t,a)=>of(e,typeof t!="symbol"?t+"":t,a),ie=null;function rf(e){throw new Yt(e.UTF8ToString(e.getLastOnigError()))}var Ga=class e{constructor(t){re(this,"utf16Length"),re(this,"utf8Length"),re(this,"utf16Value"),re(this,"utf8Value"),re(this,"utf16OffsetToUtf8"),re(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 i=new Uint8Array(o),l=0;for(let u=0;u<a;u++){let f=t.charCodeAt(u),d=f,c=!1;if(f>=55296&&f<=56319&&u+1<a){let p=t.charCodeAt(u+1);p>=56320&&p<=57343&&(d=(f-55296<<10)+65536|p-56320,c=!0)}r&&(s[u]=l,c&&(s[u+1]=l),d<=127?n[l+0]=u:d<=2047?(n[l+0]=u,n[l+1]=u):d<=65535?(n[l+0]=u,n[l+1]=u,n[l+2]=u):(n[l+0]=u,n[l+1]=u,n[l+2]=u,n[l+3]=u)),d<=127?i[l++]=d:d<=2047?(i[l++]=192|(d&1984)>>>6,i[l++]=128|(d&63)>>>0):d<=65535?(i[l++]=224|(d&61440)>>>12,i[l++]=128|(d&4032)>>>6,i[l++]=128|(d&63)>>>0):(i[l++]=240|(d&1835008)>>>18,i[l++]=128|(d&258048)>>>12,i[l++]=128|(d&4032)>>>6,i[l++]=128|(d&63)>>>0),c&&u++}this.utf16Length=a,this.utf8Length=o,this.utf16Value=t,this.utf8Value=i,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,i=!1;if(s>=55296&&s<=56319&&o+1<r){let l=t.charCodeAt(o+1);l>=56320&&l<=57343&&(n=(s-55296<<10)+65536|l-56320,i=!0)}n<=127?a+=1:n<=2047?a+=2:n<=65535?a+=3:a+=4,i&&o++}return a}createString(t){let a=t.omalloc(this.utf8Length);return t.HEAPU8.set(this.utf8Value,a),a}},Wa=class Re{constructor(t){if(re(this,"id",++Re.LAST_ID),re(this,"_onigBinding"),re(this,"content"),re(this,"utf16Length"),re(this,"utf8Length"),re(this,"utf16OffsetToUtf8"),re(this,"utf8OffsetToUtf16"),re(this,"ptr"),!ie)throw new Yt("Must invoke loadWasm first.");this._onigBinding=ie,this.content=t;let a=new Ga(t);this.utf16Length=a.utf16Length,this.utf8Length=a.utf8Length,this.utf16OffsetToUtf8=a.utf16OffsetToUtf8,this.utf8OffsetToUtf16=a.utf8OffsetToUtf16,this.utf8Length<1e4&&!Re._sharedPtrInUse?(Re._sharedPtr||(Re._sharedPtr=ie.omalloc(1e4)),Re._sharedPtrInUse=!0,ie.HEAPU8.set(a.utf8Value,Re._sharedPtr),this.ptr=Re._sharedPtr):this.ptr=a.createString(ie)}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===Re._sharedPtr?Re._sharedPtrInUse=!1:this._onigBinding.ofree(this.ptr)}};re(Wa,"LAST_ID",0);re(Wa,"_sharedPtr",0);re(Wa,"_sharedPtrInUse",!1);var An=Wa,Jo=class{constructor(t){if(re(this,"_onigBinding"),re(this,"_ptr"),!ie)throw new Yt("Must invoke loadWasm first.");let a=[],o=[];for(let i=0,l=t.length;i<l;i++){let u=new Ga(t[i]);a[i]=u.createString(ie),o[i]=u.utf8Length}let r=ie.omalloc(4*t.length);ie.HEAPU32.set(a,r/4);let s=ie.omalloc(4*t.length);ie.HEAPU32.set(o,s/4);let n=ie.createOnigScanner(r,s,t.length);for(let i=0,l=t.length;i<l;i++)ie.ofree(a[i]);ie.ofree(s),ie.ofree(r),n===0&&rf(ie),this._onigBinding=ie,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 An(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 i=s.HEAPU32,l=n/4,u=i[l++],f=i[l++],d=[];for(let c=0;c<f;c++){let p=t.convertUtf8OffsetToUtf16(i[l++]),h=t.convertUtf8OffsetToUtf16(i[l++]);d[c]={start:p,end:h,length:h-p}}return{index:u,captureIndices:d}}};function sf(e){return typeof e.instantiator=="function"}function nf(e){return typeof e.default=="function"}function lf(e){return typeof e.data<"u"}function uf(e){return typeof Response<"u"&&e instanceof Response}function df(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 qa;function ff(e){if(qa)return qa;async function t(){ie=await tf(async a=>{let o=e;return o=await o,typeof o=="function"&&(o=await o(a)),typeof o=="function"&&(o=await o(a)),sf(o)?o=await o.instantiator(a):nf(o)?o=await o.default(a):(lf(o)&&(o=o.data),uf(o)?typeof WebAssembly.instantiateStreaming=="function"?o=await cf(o)(a):o=await pf(o)(a):df(o)?o=await Ko(o)(a):o instanceof WebAssembly.Module?o=await Ko(o)(a):"default"in o&&o.default instanceof WebAssembly.Module&&(o=await Ko(o.default)(a))),"instance"in o&&(o=o.instance),"exports"in o&&(o=o.exports),o})}return qa=t(),qa}function Ko(e){return t=>WebAssembly.instantiate(e,t)}function cf(e){return t=>WebAssembly.instantiateStreaming(e,t)}function pf(e){return async t=>{let a=await e.arrayBuffer();return WebAssembly.instantiate(a,t)}}async function vn(e){return e&&await ff(e),{createScanner(t){return new Jo(t.map(a=>typeof a=="string"?a:a.source))},createString(t){return new An(t)}}}var za=yn({langs:Zt,themes:Pn,engine:()=>vn(import("../wasm-EOPKAILK.js"))}),{codeToHtml:mf,codeToHast:hf,codeToTokens:gf,codeToTokensBase:wf,codeToTokensWithThemes:xf,getSingletonHighlighter:Lf,getLastGrammarState:If}=kn(za,{guessEmbeddedLanguages:gn});var Mn=new Set(Object.keys(Zt)),Zo=new Map,Yo=new Map,wt=new Map,Cf=(e,t)=>`${e}-${t[0]}-${t[1]}`,Sf=(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}`},yf=(e,t)=>{let a=Cf(e,t);if(Zo.has(a))return Zo.get(a);let o=za({themes:t,langs:[e]});return Zo.set(a,o),o};function kf(e={}){var t;let a=(t=e.themes)!=null?t:["github-light","github-dark"];return{name:"shiki",type:"code-highlighter",supportsLanguage(o){return Mn.has(o)},getSupportedLanguages(){return Array.from(Mn)},getThemes(){return a},highlight({code:o,language:r,themes:s},n){let i=Sf(o,r,s);return Yo.has(i)?Yo.get(i):(n&&(wt.has(i)||wt.set(i,new Set),wt.get(i).add(n)),yf(r,s).then(l=>{let u=l.getLoadedLanguages().includes(r)?r:"text",f=l.codeToTokens(o,{lang:u,themes:{light:s[0],dark:s[1]}});Yo.set(i,f);let d=wt.get(i);if(d){for(let c of d)c(f);wt.delete(i)}}).catch(l=>{console.error("[Streamdown Code] Failed to highlight code:",l),wt.delete(i)}),null)}}}var Rn=kf();import{memo as bf}from"react";import{jsx as ja}from"react/jsx-runtime";var Va=({className:e,from:t,children:a,...o})=>ja("div",{className:P("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:ja("div",{className:P("ww:flex ww:min-w-0 ww:flex-col ww:gap-2","ww:w-full"),children:a})}),$a=({children:e,className:t,...a})=>ja("div",{className:P("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}),Tf={cjk:ps,code:Rn},Xa=bf(({className:e,...t})=>ja(co,{className:P("ww:size-full ww:[&>*:first-child]:mt-0 ww:[&>*:last-child]:mb-0",e),plugins:Tf,...t}),(e,t)=>e.children===t.children);Xa.displayName="MessageResponse";import{jsx as Pf}from"react/jsx-runtime";function Fn({className:e,text:t,...a}){return t?Pf("pre",{className:P("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}import{createContext as Af,useCallback as vf,useContext as En,useEffect as Mf,useMemo as tr,useRef as Rf,useState as ar}from"react";import{Fragment as _n,jsx as $,jsxs as We}from"react/jsx-runtime";function Ff(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,i]of o){if(s<=8)break;let l=n.length>4?`${n.slice(0,4)}\u2026`:n,u;typeof i=="string"?u=i.length>2?`'${i.slice(0,1)}\u2026`:`'${i}'`:Array.isArray(i)?u=`Array(${i.length})`:typeof i=="object"&&i!==null?u="{\u2026}":u=String(i);let f=`${l}\u2009${u}`;r.push(f),s-=f.length+3}return`{${r.join(", ")}}`}function Bf({text:e,className:t}){let[a,o]=ar(!1),r=Rf(null);Mf(()=>()=>{r.current&&clearTimeout(r.current)},[]);let s=vf(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 $(ke,{variant:"ghost",size:"sm",onClick:s,className:P("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?We(_n,{children:[$(Mt,{className:"ww:size-3.5"}),$("span",{children:"Copied"})]}):We(_n,{children:[$(Bt,{className:"ww:size-3.5"}),$("span",{children:"Copy"})]})})}function Nn({data:e,label:t,className:a,...o}){let[r,s]=ar(!1),n=tr(()=>JSON.stringify(e,null,2),[e]),i=Ff(e);return We("div",{className:P("ww:rounded-lg ww:bg-tool-card",a),...o,children:[We("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}),$(Bf,{text:n})]}),We("button",{type:"button",onClick:()=>s(l=>!l),className:"ww:flex ww:w-full ww:items-start ww:gap-2 ww:px-3 ww:pb-3 ww:text-left",children:[$(Ft,{className:P("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:i})]})]})}var or=Af({open:!1,toggle:()=>{}});function On({className:e,defaultOpen:t=!1,children:a,...o}){let[r,s]=ar(t);return $(or.Provider,{value:{open:r,toggle:()=>s(n=>!n)},children:$("div",{className:P("ww:mb-4 ww:w-full",e),"data-state":r?"open":"closed",...o,children:a})})}function Un({className:e,title:t,state:a,...o}){let{open:r,toggle:s}=En(or),n=a==="input-available"||a==="input-streaming";return We("button",{type:"button",onClick:s,className:P("ww:flex ww:w-full ww:items-center ww:justify-between ww:gap-3 ww:py-1.5",e),"aria-expanded":r,...o,children:[We("div",{className:"ww:flex ww:min-w-0 ww:items-center ww:gap-2",children:[$(Oe,{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"})]}),$(Rt,{className:P("ww:size-4 ww:shrink-0 ww:text-muted-foreground ww:transition-transform ww:duration-200",r&&"ww:rotate-180")})]})}function Hn({className:e,children:t,...a}){let{open:o}=En(or);return $("div",{className:P("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:P("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 qn({className:e,input:t,debug:a,...o}){let r=tr(()=>{if(!a&&typeof t=="object"&&t!==null&&!Array.isArray(t)){let{_meta:s,...n}=t;return n}return t},[t,a]);return $(Nn,{data:r,label:"Request",className:e,...o})}function er(e){if(!(typeof e!="object"||e===null))return e}function Gn(e){return er(e?.ui)}function Wn(e){return er(er(e)?._meta)}function Bn(e){if(!e)return;let t=Gn(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 Dn(e){return Gn(e)?.autoHeight===!0}function Qa(e,t,a){if(e){let o=Bn(a?.[e]?._meta);if(o)return o}return Bn(Wn(t))}function zn(e,t,a){return e&&Dn(a?.[e]?._meta)?!0:Dn(Wn(t))}function jn({className:e,output:t,errorText:a,debug:o,...r}){let s=tr(()=>{if(!o&&typeof t=="object"&&t!==null&&!Array.isArray(t)){let{_meta:n,...i}=t;return i}return t},[t,o]);return t||a?a?We("div",{className:P("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})]}):$(Nn,{data:s,label:"Response",className:e,...r}):null}import{useCallback as Df,useEffect as $n,useMemo as _f,useRef as we,useState as Xn}from"react";function xt(e){if(!e)return!1;let t=Array.isArray(e.content)&&e.content.length>0,a=typeof e.structuredContent=="object"&&e.structuredContent!==null&&Object.keys(e.structuredContent).length>0;return t||a}function Vn(e,t){return!xt(e)&&!xt(t)?null:xt(e)?xt(t)?{...e.content||t.content?{content:[...e.content??[],...t.content??[]]}:{},...e.structuredContent||t.structuredContent?{structuredContent:{...e.structuredContent??{},...t.structuredContent??{}}}:{}}:{...e.content?{content:[...e.content]}:{},...e.structuredContent?{structuredContent:{...e.structuredContent}}:{}}:{...t?.content?{content:[...t.content]}:{},...t?.structuredContent?{structuredContent:{...t.structuredContent}}:{}}}import{jsx as Vf}from"react/jsx-runtime";var Ef="/api/mcp/resource",Nf=500,Of=0,Uf=16,Hf="2026-01-26",qf=300,Gf=3e3,Wf=3;function zf(e){if(typeof e!="string")return;let t=e.trim();return t.length>0?t:void 0}function jf(e,t,a){return Qa(e,t,a)?!1:t._meta?.["waniwani/autoInjectResultText"]!==!1}function rr({resourceUri:e,toolInput:t,toolResult:a,resourceEndpoint:o=Ef,chatSessionId:r,isDark:s=!1,className:n,autoHeight:i=!1,onOpenLink:l,onFollowUp:u,onCallTool:f,onDisplayModeChange:d,isFullscreen:c=!1,toolDefinitions:p}){let h=we(null),S=we(t),L=we(a),x=we({width:0,height:0}),w=we(null),m=we(!1),g=we(0),I=we("inline"),[b,y]=Xn(Of),[M,_]=Xn(void 0),F=we(l),k=we(u),A=we(f),Q=we(d),O=we(r),D=we(p);S.current=t,L.current=a,F.current=l,k.current=u,A.current=f,Q.current=d,O.current=r,D.current=p;let W=Df(U=>i?Math.max(U+Uf,0):Math.min(Math.max(U,50),Nf),[i]),Y=_f(()=>{let U=o.includes("?")?"&":"?";return`${o}${U}uri=${encodeURIComponent(e)}`},[o,e]),K=we(s);return K.current=s,$n(()=>{if(!m.current)return;let U=h.current;U?.contentWindow&&U.contentWindow.postMessage({jsonrpc:"2.0",method:"ui/notifications/host-context-changed",params:{theme:s?"dark":"light"}},"*")},[s]),$n(()=>{let U=h.current;if(!U)return;let v=!1,ee=!1,T=null,R=null,ne=setTimeout(()=>{if(v||ee||g.current>=Wf)return;g.current+=1;let ue=new URL(U.src);ue.searchParams.set("_retry",String(g.current)),U.src=ue.toString()},Gf),z=ue=>{U.contentWindow?.postMessage(ue,"*")},_e=ue=>{if(v||ue.source!==U.contentWindow)return;let J=ue.data;if(!J||typeof J!="object"||J.jsonrpc!=="2.0")return;let ae=J.method,H=J.id;if(ae==="ui/initialize"&&H!=null){ee=!0,clearTimeout(ne),z({jsonrpc:"2.0",id:H,result:{protocolVersion:J.params?.protocolVersion??Hf,hostInfo:{name:"WaniWani Chat",version:"1.0.0"},hostCapabilities:{openLinks:{},message:{text:{}},tools:{},updateModelContext:{text:{},structuredContent:{}}},hostContext:{theme:K.current?"dark":"light",displayMode:I.current}}});return}if(ae==="ui/notifications/initialized"){m.current=!0;let q=S.current,G=L.current,N=G._meta&&typeof G._meta=="object"?G._meta:null,j=zf(O.current),oe=N&&typeof N.waniwani=="object"&&N.waniwani!==null?N.waniwani:null,Se=oe||j?{...oe??{},...j?{sessionId:j}:{}}:void 0,Ee=N||Se?{...N??{},...Se?{waniwani:Se}:{}}:void 0;z({jsonrpc:"2.0",method:"ui/notifications/tool-input",params:{arguments:q}});let ot=G.content??[{type:"text",text:JSON.stringify(G)}];z({jsonrpc:"2.0",method:"ui/notifications/tool-result",params:{content:ot,structuredContent:G.structuredContent,_meta:Ee,meta:Ee}});return}if(ae==="ui/notifications/size-changed"){let q=J.params,G=typeof q?.height=="number"?q.height:void 0,N=typeof q?.width=="number"?q.width:void 0,j=x.current,oe=G!==void 0&&G!==j.height,Se=N!==void 0&&N!==j.width;if(!oe&&!Se)return;if(oe&&G!==void 0){j.height=G;let Ee=W(G),ot=U.getBoundingClientRect().height;if(w.current&&(w.current.cancel(),w.current=null),y(Ee),U.animate&&Math.abs(ot-Ee)>2){let rt=U.animate([{height:`${ot}px`},{height:`${Ee}px`}],{duration:qf,easing:"ease-out",fill:"forwards"});w.current=rt,rt.onfinish=()=>{w.current===rt&&(rt.cancel(),w.current=null)}}}Se&&i&&N!==void 0&&(j.width=N,_(N));return}if(ae==="ui/open-link"&&H!=null){let q=J.params?.url;typeof q=="string"&&(F.current?F.current(q):window.open(q,"_blank","noopener,noreferrer")),z({jsonrpc:"2.0",id:H,result:{}});return}if(ae==="ui/message"&&H!=null){if(k.current&&J.params){let q=J.params,G=T;if(T=null,R){clearTimeout(R.timer);let N=R.text;R=null;let j=(q.content??[]).map(oe=>oe.text??"").join("").trim();q={...q,content:[{type:"text",text:`${j}
14
14
 
15
- ${q}`}]}}k.current({...W,...j?{modelContext:j}:{}})}re({jsonrpc:"2.0",id:G,result:{}});return}if(ee==="ui/update-model-context"&&G!=null){A=Kn(A,Q.params),re({jsonrpc:"2.0",id:G,result:{}});return}if(ee==="tools/call"&&G!=null){let W=P.current;if(!W){re({jsonrpc:"2.0",id:G,error:{code:-32601,message:"tools/call not supported"}});return}let j=Q.params?.name;W({name:j,arguments:Q.params?.arguments??{}}).then(q=>{re({jsonrpc:"2.0",id:G,result:q});let V=q.content?.map(te=>te.text??"").join("").trim();V&&Yf(j,q,D.current)&&(_&&clearTimeout(_.timer),_={text:V,timer:setTimeout(()=>{if(M)return;let te=A;A=null,_=null,k.current?.({role:"user",content:[{type:"text",text:V}],...te?{modelContext:te}:{}})},500)})}).catch(q=>{let V=q instanceof Error?q.message:"Tool call failed";re({jsonrpc:"2.0",id:G,error:{code:-32e3,message:V}})});return}if(ee==="ui/request-display-mode"&&G!=null){let W=Q.params?.mode,j=W==="fullscreen"||W==="inline"||W==="pip"?W:"inline";C.current=j,re({jsonrpc:"2.0",id:G,result:{mode:j}}),re({jsonrpc:"2.0",method:"ui/notifications/host-context-changed",params:{displayMode:j}}),Y.current?.(j);return}if(ee==="ui/resource-teardown"&&G!=null){re({jsonrpc:"2.0",id:G,result:{}});return}ee==="ping"&&G!=null&&re({jsonrpc:"2.0",id:G,result:{}})};return window.addEventListener("message",Ne),()=>{M=!0,clearTimeout(ge),_&&clearTimeout(_.timer),window.removeEventListener("message",Ne)}},[l,z]),ec("iframe",{ref:h,src:ae,sandbox:"allow-scripts allow-forms allow-same-origin",className:T(!c&&"ww:rounded-md ww:border ww:border-border",n),style:{height:c?"100%":b,minWidth:c||!B?void 0:`min(${B}px, 100%)`,width:"100%",border:"none",colorScheme:s?"dark":"auto"},title:"MCP App"})}import{jsx as aa,jsxs as tc}from"react/jsx-runtime";function Zn({icon:e,title:t,description:a,suggestions:o,onSuggestionSelect:r}){return tc("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&&aa("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}),aa("h2",{className:"ww:text-lg ww:font-semibold ww:text-foreground",children:t}),a&&aa("p",{className:"ww:mt-1 ww:text-sm ww:text-muted-foreground ww:max-w-sm",children:a}),o&&o.length>0&&aa("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)=>aa("button",{type:"button",onClick:()=>r?.(s),className:T("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))})]})}import{Component as ac}from"react";import{jsx as Yn,jsxs as oc}from"react/jsx-runtime";var Ya=class extends ac{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){console.warn("[WaniWani] Widget failed to render:",t.message)}render(){return this.state.hasError?oc("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:[Yn("span",{children:"Widget failed to load"}),Yn("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 sc,jsx as ne,jsxs as It}from"react/jsx-runtime";function rc(e){return e?e.replace(/[-_]/g," ").replace(/^\w/,t=>t.toUpperCase()):"Tool"}function St({messages:e,status:t,welcomeMessage:a,welcome:o,onSuggestionSelect:r,resourceEndpoint:s,chatSessionId:n,isDark:l,onFollowUp:i,onCallTool:u,onWidgetDisplayModeChange:f,fullscreenToolCallId:d,debug:c,toolDefinitions:p}){let h=t==="submitted"||t==="streaming",I=e[e.length-1],L=e.length>0,x=h&&(!L||I.role==="user"),w=d!=null;return It(sc,{children:[!w&&(!L&&o?ne(Zn,{...o,onSuggestionSelect:r}):a&&ne(Ka,{from:"assistant",children:ne(Qa,{children:ne(Ja,{children:a})})})),e.map(m=>{let g=m.parts.filter(k=>k.type==="text"),C=m.parts.filter(k=>k.type==="reasoning"),b=m.parts.filter(k=>k.type==="file"),y=m.parts.filter(k=>"toolCallId"in k),B=m===I&&m.role==="assistant",N=g.length>0,R=w?y.some(k=>k.toolCallId===d):!1;return w&&!R?ne("div",{style:{display:"none"}},m.id):It(Ka,{from:m.role,children:[!R&&C.map((k,P)=>ne(En,{text:k.text},`reasoning-${m.id}-${P}`)),y.map(k=>{let P="output"in k?k.output:void 0,Y=Za(k.toolName,P,p),U=$n(k.toolName,P,p),D=k.toolCallId===d;return It("div",{style:D?{position:"absolute",inset:0,zIndex:10,display:"flex",flexDirection:"column",overflow:"hidden",background:"var(--ww-color-background)"}:void 0,children:[ne("div",{style:D?{display:"none"}:void 0,children:It(qn,{children:[ne(Gn,{title:k.title??rc(k.toolName),state:k.state}),It(Wn,{children:[ne(zn,{input:k.input,debug:c}),P!==void 0&&ne(Xn,{output:P,errorText:"errorText"in k?k.errorText:void 0,debug:c})]})]})}),Y&&s&&P!==void 0&&ne(Ya,{children:ne(ir,{isFullscreen:D,resourceUri:Y,toolInput:k.input??{},toolResult:{content:P.content,structuredContent:P.structuredContent,_meta:P._meta},resourceEndpoint:s,chatSessionId:n,isDark:l,autoHeight:U,toolDefinitions:p,onFollowUp:i,onCallTool:u,onDisplayModeChange:f?z=>f(z,{toolCallId:k.toolCallId,resourceUri:Y,toolInput:k.input??{},toolResult:{content:P.content,structuredContent:P.structuredContent,_meta:P._meta},autoHeight:U}):void 0})})]},k.toolCallId)}),!R&&ne("div",{children:It(Qa,{children:[b.length>0&&ne(ts,{files:b}),N?g.map((k,P)=>ne(Ja,{children:k.type==="text"?k.text:""},`${m.id}-${P}`)):B&&h&&ne(ko,{})]})})]},m.id)}),!w&&x&&ne(Ka,{from:"assistant",children:ne(Qa,{children:ne(ko,{})})})]})}import{jsx as eo}from"react/jsx-runtime";function yt({suggestions:e,isLoading:t,onSelect:a,className:o,...r}){return e.length===0&&!t?null:eo("div",{className:T("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:T("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))})})}import{useCallback as nc,useRef as ic}from"react";function kt(e){let t=ic(e);return t.current=e,nc(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()},[])}import{useChat as kc}from"@ai-sdk/react";import{useCallback as ce,useEffect as Me,useRef as le,useState as at}from"react";import{DefaultChatTransport as lc,uiMessageChunkSchema as uc}from"ai";function dc(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 lc{processResponseStream(t){let a="",o=uc(),r=o.validate?.bind(o);return t.pipeThrough(new TextDecoderStream).pipeThrough(new TransformStream({async transform(s,n){a+=s;let l=a.split(`
16
- `);a=l.pop()??"";for(let i of l){let u=i.trim();if(!u.startsWith("data:"))continue;let f=u.slice(5).trim();if(f!=="[DONE]")try{let d=JSON.parse(f);if(!r){n.enqueue(d);continue}let c=await r(d);if(c.success){n.enqueue(c.value);continue}let p=dc(c.error);if(p?.length){let h={...d};for(let L of p)delete h[L];let I=await r(h);I.success&&n.enqueue(I.value)}}catch{}}}}))}};var fc="waniwani-memory";var Se="threads",ao="by_memoryUserId",cc="by_updatedAt";var ti="memoryUserId",ei="waniwani-memory-user-id",lr=null;function ur(){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 pc(e,t){if(t<1&&(e.objectStoreNames.contains("ids")||e.createObjectStore("ids")),t<2&&!e.objectStoreNames.contains(Se)){let a=e.createObjectStore(Se,{keyPath:"threadId"});a.createIndex(ao,"memoryUserId",{unique:!1}),a.createIndex(cc,"updatedAt",{unique:!1})}}async function dr(){return new Promise((e,t)=>{let a=indexedDB.open(fc,2);a.onupgradeneeded=o=>{pc(a.result,o.oldVersion)},a.onsuccess=()=>e(a.result),a.onerror=()=>t(a.error)})}async function mc(){return dr()}async function hc(e){return new Promise((t,a)=>{let s=e.transaction("ids","readonly").objectStore("ids").get(ti);s.onsuccess=()=>t(typeof s.result=="string"?s.result:null),s.onerror=()=>a(s.error)})}async function gc(e,t){return new Promise((a,o)=>{let n=e.transaction("ids","readwrite").objectStore("ids").put(t,ti);n.onsuccess=()=>a(),n.onerror=()=>o(n.error)})}async function wc(){if(typeof indexedDB>"u")return null;try{let e=await mc();try{let t=await hc(e);if(t)return t;let a=ur();return await gc(e,a),a}finally{e.close()}}catch{return null}}function xc(){try{let e=localStorage.getItem(ei);if(e)return e;let t=ur();return localStorage.setItem(ei,t),t}catch{return null}}async function ai(){let e=await wc();if(e)return e;let t=xc();return t||(lr||(lr=ur()),lr)}var oi=50,ri=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 dr(),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 cr(e){return await ro(async a=>{let s=a.transaction(Se,"readonly").objectStore(Se).index(ao),l=(await fr(s.getAll(e))??[]).filter(oo);return l.sort((i,u)=>i.updatedAt<u.updatedAt?1:-1),l})??[]}async function pr(e){return await ro(async a=>{let r=a.transaction(Se,"readonly").objectStore(Se),s=await fr(r.get(e));return oo(s)?s:null})??null}async function mr(e){if(!oo(e))return;let t=e.messages.length>ri?{...e,messages:e.messages.slice(e.messages.length-ri)}:e;await ro(async a=>{await new Promise((i,u)=>{let f=a.transaction(Se,"readwrite");f.oncomplete=()=>i(),f.onerror=()=>u(f.error),f.onabort=()=>u(f.error),f.objectStore(Se).put(t)});let o=a.transaction(Se,"readwrite"),r=o.objectStore(Se),s=r.index(ao),l=(await fr(s.getAll(t.memoryUserId))??[]).filter(oo);if(l.length>oi){l.sort((u,f)=>u.updatedAt<f.updatedAt?-1:1);let i=l.slice(0,l.length-oi);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 si(e){await ro(async t=>(await new Promise((a,o)=>{let r=t.transaction(Se,"readwrite");r.oncomplete=()=>a(),r.onerror=()=>o(r.error),r.onabort=()=>o(r.error),r.objectStore(Se).delete(e)}),null))}async function ni(e){return(await cr(e))[0]?.threadId??null}function ii(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`}var li="waniwani-visitor-id";function ui(e,t){return e.match(t)?.[1]??null}function Lc(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=ui(e,o);if(r)return{name:a,version:r}}return null}function Cc(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=ui(e,o);if(r)return{name:a,version:r.replace(/_/g,".")};if(a==="Linux"&&o.test(e))return{name:a,version:""}}return null}function Ic(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 Sc(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 yc(){try{let a=localStorage.getItem(li);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 Sc(e);try{localStorage.setItem(li,t)}catch{}return t}async function di(){let e=navigator.userAgent,[t,a]=await Promise.all([yc(),ai()]);return{userAgent:e,browser:Lc(e),os:Cc(e),deviceType:Ic(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 bc="x-session-id",Tc=250;function fi(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():qt()}function so(){return new Date().toISOString()}function ci(e){if(typeof e!="string")return;let t=e.trim();return t.length>0?t:void 0}async function Pc(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 bt(e){let{api:t="/api/waniwani",headers:a,body:o,onMessageSent:r,onResponseReceived:s,enableThreadHistory:n=!1,activeThreadId:l,onThreadChange:i}=e,u=le(a),f=le(o),d=le(n);Me(()=>{d.current=n},[n]);let c=le(void 0),p=le(null),[h,I]=at(void 0),L=le(h),[x,w]=at(l),m=le(x),[g,C]=at([]),[b,y]=at(!n),B=le(void 0),N=le(void 0),R=le(void 0),k=le(void 0),P=le(0),Y=le(i);Me(()=>{Y.current=i},[i]);let U=ce(S=>{m.current=S,w(S),S&&Y.current?.(S)},[]),D=ce(async()=>{if(!n)return;let S=p.current?.memoryUserId;if(!S)return;let E=await cr(S);C(E)},[n]),z=ce(()=>L.current,[]),ae=ce(S=>{let E=ci(S);E&&L.current!==E&&(L.current=E,I(E))},[]),oe=ce(()=>{L.current=void 0,I(void 0)},[]);Me(()=>{u.current=a},[a]),Me(()=>{f.current=o},[o]),Me(()=>{let S=!1,E=P.current;return(async()=>{try{let be=await di();if(S)return;p.current=be}catch{}if(!n)return;let O=p.current?.memoryUserId;if(!O){y(!0);return}try{let be=l??await ni(O);if(S||E!==P.current)return;if(be){let we=await pr(be);if(S||E!==P.current)return;we&&we.memoryUserId===O&&(m.current=we.threadId,w(we.threadId),B.current=we.createdAt,N.current=we.title,we.sessionId&&(L.current=we.sessionId,I(we.sessionId)),ee(we.messages))}await D()}finally{S||y(!0)}})(),()=>{S=!0}},[]);let H=le(new to({api:t,headers:()=>({...u.current}),body:()=>{let S={...f.current??{}},E=Object.hasOwn(S,"sessionId"),O=ci(S.sessionId);if(O)ae(O),S.sessionId=O;else if(E)oe(),delete S.sessionId;else{let Ae=z();Ae&&(S.sessionId=Ae)}if(Ct(c.current)&&(S.modelContext=c.current),p.current){let Ae=p.current;S.visitorContext={timezone:Ae.timezone,language:Ae.language,languages:Ae.languages,deviceType:Ae.deviceType,referrer:Ae.referrer,visitorId:Ae.visitorId};let De=typeof S.visitor=="object"&&S.visitor!==null?S.visitor:{},Ei=typeof De.client=="object"&&De.client!==null?De.client:{};S.visitor={...De,client:{...Ei,memoryUserId:Ae.memoryUserId}}}let be=typeof S.extra=="object"&&S.extra!==null&&!Array.isArray(S.extra)?S.extra:void 0,we=p.current?.memoryUserId,Ue=p.current?.language,la={};if(we&&(la.memoryUserId=we),Ue&&(la.locale=Ue),(Object.keys(la).length>0||be)&&(S.extra={...la,...be??{}}),d.current)if(Object.hasOwn(S,"threadId"))typeof S.threadId=="string"&&(m.current=S.threadId);else{let De=m.current;De||(De=fi(),B.current=so(),N.current=void 0,U(De)),S.threadId=De}return S},fetch:(async(S,E)=>{let O=await fetch(S,E);return c.current=void 0,ae(O.headers.get(bc)),O})})),M=le(null),v=le(null),A=le({}),[_,ge]=at(0),re=e.skipRemoteConfig===!0,Ne=ce(async()=>{if(!re)try{let S=await Pc(t,u.current);A.current=S,ge(E=>E+1)}catch(S){console.warn("[WaniWani] Failed to fetch tool definitions:",S instanceof Error?S.message:S)}},[t,re]);Me(()=>{Ne()},[Ne]);let{messages:ue,sendMessage:Q,setMessages:ee,status:G}=kc({messages:e.initialMessages,transport:H.current,onFinish({message:S}){s?.(),M.current&&(v.current=S)},onError(S){console.warn("[WaniWani] Chat error:",S.message),M.current&&(M.current.reject(S),M.current=null)}}),W=le(ue);Me(()=>{W.current=ue},[ue]),Me(()=>{if(G==="ready"&&M.current&&v.current){let S=M.current,E=v.current;M.current=null,v.current=null,S.resolve(E)}},[G]);let[j,q]=at(""),[V,te]=at([]),ke=G==="submitted"||G==="streaming",Oe=ce(S=>{te(E=>E.filter(O=>O.id!==S))},[]),st=ke&&V.length>0,nt=ce(S=>{let E=!!S.text?.trim(),O=!!S.files?.length;if(E||O){if(ke){if(V.length>0)return;te(be=>[...be,{id:qt(),text:S.text||"",files:S.files??[],modelContext:S.modelContext}]),q("");return}c.current=S.modelContext,Q({text:S.text||"",files:S.files}),r?.(S.text||""),q("")}},[Q,r,ke,V.length]),Ai=ce(S=>new Promise((E,O)=>{M.current={resolve:E,reject:O},Q({text:S}),r?.(S)}),[Q,r]);Me(()=>{if(G!=="ready"||V.length===0)return;let[S,...E]=V;te(E),c.current=S.modelContext,Q({text:S.text,files:S.files.length>0?S.files:void 0}),r?.(S.text)},[G,Q,r,V]);let vi=ce(()=>{ee([]),te([]),oe(),q(""),A.current={},ge(S=>S+1),Ne()},[ee,oe,Ne]),na=ce(()=>{if(!d.current)return;let S=p.current?.memoryUserId,E=m.current,O=W.current;if(!(!S||!E||O.length===0)){if(B.current||(B.current=so()),!N.current){let be=O.find(Ue=>Ue.role==="user"),we=be?be.parts.map(Ue=>"text"in Ue&&typeof Ue.text=="string"?Ue.text:"").join(" "):"";N.current=ii(we)}return{threadId:E,memoryUserId:S,title:N.current,messages:O,sessionId:L.current,createdAt:B.current,updatedAt:so()}}},[]),Lr=ce(async()=>{let S=na();S&&(await mr(S),await D())},[na,D]);Me(()=>{if(n&&b&&!(G==="submitted"||G==="streaming")&&ue.length!==0)return R.current&&clearTimeout(R.current),R.current=setTimeout(()=>{R.current=void 0;let S=Lr().finally(()=>{k.current===S&&(k.current=void 0)});k.current=S},Tc),()=>{R.current&&clearTimeout(R.current)}},[n,b,ue,G,Lr]);let ia=ce(()=>{let S=k.current,E=R.current,O=E?na():void 0;return E&&(clearTimeout(E),R.current=void 0),(async()=>{S&&await S,O&&(await mr(O),await D())})()},[na,D]),Mi=ce(()=>{P.current+=1,ia(),ee([]),te([]),oe(),q("");let S=fi();return B.current=so(),N.current=void 0,U(S),D(),S},[ee,oe,U,D,ia]),po=ce(async S=>{P.current+=1;let E=P.current;if(await ia(),E!==P.current)return;let O=await pr(S);E===P.current&&O&&(U(O.threadId),B.current=O.createdAt,N.current=O.title,O.sessionId?(L.current=O.sessionId,I(O.sessionId)):oe(),ee(O.messages),te([]),q(""))},[ee,oe,U,ia]),Ri=ce(async S=>{if(m.current===S){P.current+=1,R.current&&(clearTimeout(R.current),R.current=void 0);let E=k.current;E&&await E}await si(S),await D(),m.current===S&&(ee([]),te([]),oe(),q(""),m.current=void 0,w(void 0),B.current=void 0,N.current=void 0)},[ee,oe,D]);Me(()=>{n&&b&&l!==void 0&&l!==m.current&&po(l)},[l,n,b,po]);let Fi=ce(S=>{q(S.target.value)},[]),Cr=ue[ue.length-1],Ir=ue.length>0,Bi=ke&&(!Ir||Cr.role==="user"),Di=A.current;return{messages:ue,status:G,text:j,setText:q,handleSubmit:nt,handleTextChange:Fi,isLoading:ke,showLoaderBubble:Bi,lastMessage:Cr,hasMessages:Ir,sendMessage:Q,sendMessageAndWait:Ai,reset:vi,queuedMessages:V,queueFull:st,removeQueuedMessage:Oe,sessionId:h,toolDefinitions:Di,refreshToolDefinitions:Ne,threads:g,activeThreadId:x,isThreadHistoryReady:b,startNewThread:Mi,switchThread:po,deleteThread:Ri}}import{useEffect as pi,useRef as Ac,useState as vc}from"react";var Mc={debug:!1,eval:!1};function Tt(e="/api/waniwani",t,a=!1){let[o,r]=vc(Mc),s=Ac(t);return pi(()=>{s.current=t},[t]),pi(()=>{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}import{useCallback as Rc,useEffect as hr,useRef as Fc,useState as Bc}from"react";function Dc(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 mi(e){return typeof e=="object"&&e!==null&&"initial"in e}function Pt(e){let{messages:t,status:a,config:o}=e,r=mi(o)&&o.initial?o.initial:void 0,[s,n]=Bc(r??[]),l=Fc(a),i=o===!0||mi(o)&&o.dynamic!==!1,u=Rc(()=>{n([])},[]),f=t.length>0;hr(()=>{!f&&r&&r.length>0&&n(r)},[r,f]);let d=t[t.length-1];return hr(()=>{d?.role==="user"&&u()},[d,u]),hr(()=>{let c=l.current;if(l.current=a,c==="streaming"&&a==="ready"&&i){let p=[...t].reverse().find(I=>I.role==="assistant");if(!p)return;let h=Dc(p);h&&n(h)}},[a,i,t]),{suggestions:s,isLoading:!1,clear:u}}import{useEffect as Ec,useRef as _c,useState as Nc}from"react";var Oc=50,Uc=30,Hc=2e3,hi=500;function At(e,t=!0){let[a,o]=Nc(""),r=_c(void 0);return Ec(()=>{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,hi)):r.current=setTimeout(i,Uc)):(s++,o(e.slice(0,s)),s>=e.length?(n=!0,r.current=setTimeout(i,Hc)):r.current=setTimeout(i,Oc)))};return r.current=setTimeout(i,hi),()=>{l=!0,clearTimeout(r.current)}},[e,t]),a}function no(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`}var gi={primaryColor:"#6366f1",primaryForeground:"#1f2937",backgroundColor:"#ffffff",textColor:"#1f2937",mutedColor:"#6b7280",borderColor:"#e5e7eb",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"},qc={backgroundColor:"#212121",headerBackgroundColor:"#1e1e1e",headerTextColor:"#ececec",textColor:"#ececec",primaryForeground:"#ffffff",mutedColor:"#8e8ea0",borderColor:"#444444",assistantBubbleColor:"#2f2f2f",userBubbleColor:"#303030",inputBackgroundColor:"#2f2f2f",primaryColor:"#6366f1",statusColor:"#22c55e",toolCardColor:"#262626"},Gc={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"],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 ot(e){return{...gi,...e}}function vt(e){let t=e.backgroundColor.replace("#",""),a=parseInt(t.substring(0,2),16),o=parseInt(t.substring(2,4),16),r=parseInt(t.substring(4,6),16);return(a*299+o*587+r*114)/1e3<128}function rt(e){let t={};for(let[a,o]of Object.entries(Gc)){let r=e[a],s=typeof r=="number"?`${r}px`:String(r);for(let n of o)t[n]=s}return t}import{jsx as Le,jsxs as oa}from"react/jsx-runtime";var wr=Wc(function(t,a){let{theme:o,title:r="Assistant",width:s=600,expandedWidth:n,expandedHeight:l=400,allowAttachments:i=!1,welcomeMessage:u,welcome:f,placeholder:d="Ask me anything...",triggerEvent:c="triggerDemoRequest",api:p}=t,h=n??Math.round((typeof s=="number"?s:600)*1.2),I=p??"/api/waniwani",L=no(I,t.headers),x=ot(o),w=rt(x),m=vt(x),g=Tt(p,t.headers,t.skipRemoteConfig),C=bt(t),b=kt({...t,sessionId:C.sessionId}),y=Pt({messages:C.messages,status:C.status,config:t.suggestions}),B=io(A=>{let _=A.content.map(ge=>ge.text??"").join("").trim();_&&C.handleSubmit({text:_,files:[],modelContext:A.modelContext})},[C.handleSubmit]),N=io(A=>{y.clear(),C.handleSubmit({text:A,files:[]})},[y.clear,C.handleSubmit]),R=At(d,!C.text),[k,P]=gr(!1),[Y,U]=gr(!1),[D,z]=gr(null),ae=xi(null),oe=xi(void 0),H=io(()=>{let A=ae.current;if(!A)return;A.scrollIntoView({behavior:"smooth",block:"center"});let _=A.querySelector("textarea");_&&setTimeout(()=>_.focus(),300),P(!0),U(!0),clearTimeout(oe.current),oe.current=setTimeout(()=>U(!1),2e3)},[]);zc(a,()=>({sendMessage:A=>{C.handleSubmit({text:A,files:[]}),H()},sendMessageAndWait:A=>C.sendMessageAndWait(A),reset:C.reset,focus:H,get messages(){return C.messages}}),[C.handleSubmit,C.sendMessageAndWait,C.reset,C.messages,H]),wi(()=>{if(!c)return;let A=_=>{let ge=_.detail,re=typeof ge?.message=="string"?ge.message:void 0;re&&C.handleSubmit({text:re,files:[]}),H()};return window.addEventListener(c,A),()=>window.removeEventListener(c,A)},[c,C.handleSubmit,H]);let M=k||D!==null;wi(()=>{if(!k)return;let A=_=>{ae.current&&!ae.current.contains(_.target)&&P(!1)};return document.addEventListener("mousedown",A),()=>document.removeEventListener("mousedown",A)},[k]);let v=io(()=>{P(!0)},[]);return oa("div",{ref:ae,style:{...w,width:M?h:s,transition:"width 0.4s cubic-bezier(0.16, 1, 0.3, 1)"},"data-waniwani-chat":"","data-waniwani-layout":"bar",...m?{"data-waniwani-dark":""}:{},className:"ww:flex ww:flex-col ww:font-[family-name:var(--ww-font)] ww:text-foreground",children:[oa("div",{style:{overflow:"hidden",backgroundColor:x.backgroundColor,borderRadius:"var(--ww-radius) var(--ww-radius) 0 0",maxHeight:M?l+200:0,opacity:M?1:0,transform:M?"scaleX(1)":"scaleX(0.88)",transformOrigin:"center bottom",transition:"max-height 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease-out, transform 0.4s cubic-bezier(0.16, 1, 0.3, 1)"},children:[oa("div",{className:"ww:shrink-0 ww:flex ww:items-center ww:px-6 ww:py-3",style:{backgroundColor:x.headerBackgroundColor,color:x.headerTextColor},children:[Le("div",{className:"ww:text-sm ww:font-semibold ww:truncate",children:r}),Le(wa,{messages:C.messages,evalEnabled:g.eval,api:I})]}),oa(ma,{className:"ww:flex-1",style:{height:l},children:[Le(ha,{scrollClassName:D?"ww:!relative ww:!overflow-hidden":void 0,children:Le(St,{messages:C.messages,status:C.status,welcomeMessage:u,welcome:f,onSuggestionSelect:N,resourceEndpoint:L,chatSessionId:C.sessionId,isDark:m,onFollowUp:B,onCallTool:b,fullscreenToolCallId:D,toolDefinitions:C.toolDefinitions,onWidgetDisplayModeChange:(A,_)=>{z(A==="fullscreen"?_.toolCallId:null)}})}),Le(ga,{})]}),Le("div",{style:D?{display:"none"}:void 0,children:Le(yt,{suggestions:y.suggestions,isLoading:y.isLoading,onSelect:N})}),Le("div",{style:D?{display:"none"}:void 0,children:Le(gt,{queuedMessages:C.queuedMessages,onRemove:C.removeQueuedMessage})})]}),Le("div",{style:{backgroundColor:M?x.backgroundColor:"transparent",borderRadius:M?"0 0 var(--ww-radius) var(--ww-radius)":void 0,boxShadow:M?"0 8px 24px rgba(0,0,0,0.1)":"none",transition:"background-color 0.2s ease, border-radius 0.3s ease, box-shadow 0.35s ease, padding 0.3s ease",padding:M?"8px 16px 16px":"0"},children:Le(ft,{onSubmit:C.handleSubmit,globalDrop:i,multiple:i,className:T("ww:rounded-2xl ww:border-border ww:bg-input ww:transition-all ww:duration-300",!M&&"ww:shadow-sm",Y&&"ww:ring-2 ww:ring-blue-400/70 ww:ring-offset-2 ww:ring-offset-background"),children:oa("div",{className:"ww:flex ww:items-center ww:gap-1 ww:pl-4 ww:pr-3 ww:py-2.5",children:[i&&Le(mt,{}),Le(ct,{onChange:C.handleTextChange,value:C.text,placeholder:R,onFocus:v,className:"ww:min-h-0 ww:py-1 ww:px-0"}),Le(pt,{status:C.status,disabled:C.queueFull})]})})})]})});import{useEffect as Vc,useRef as Si,useState as ra}from"react";import{useCallback as Li,useEffect as jc,useState as Ci}from"react";function Ii(e,t){let[a,o]=Ci([]),[r,s]=Ci(!1),n=Li(()=>{t&&(s(!0),fetch(`${e}/scenarios`).then(i=>i.json()).then(i=>o(Array.isArray(i)?i:[])).catch(()=>{}).finally(()=>s(!1)))},[e,t]);jc(()=>{n()},[n]);let l=Li(async(i,u)=>{let f=await fetch(`${e}/scenarios/${i}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:u})});if(!f.ok){let d=await f.json().catch(()=>null);throw new Error(d?.error??`Failed to rename scenario (${f.status})`)}o(d=>d.map(c=>c.id===i?{...c,name:u}:c))},[e]);return{scenarios:a,isLoading:r,reload:n,rename:l}}import{jsx as F,jsxs as ye}from"react/jsx-runtime";function $c(e){return e.parts.filter(t=>t.type==="text"&&typeof t.text=="string").map(t=>t.text).join("")}function Xc({className:e}){return ye("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",stroke:"none",className:e,role:"img",children:[F("title",{children:"Run scenario"}),F("path",{d:"M6 4l15 8-15 8V4z"})]})}function Kc({className:e}){return ye("svg",{xmlns:"http://www.w3.org/2000/svg",width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,role:"img",children:[F("title",{children:"Rename scenario"}),F("path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z"})]})}function Qc({className:e}){return ye("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:e,role:"img",children:[F("title",{children:"Confirm"}),F("path",{d:"M20 6 9 17l-5-5"})]})}function Jc({className:e}){return ye("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:e,role:"img",children:[F("title",{children:"Cancel"}),F("path",{d:"M18 6 6 18"}),F("path",{d:"m6 6 12 12"})]})}function yi({className:e}){return ye("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:T("ww:animate-spin",e),role:"img",children:[F("title",{children:"Running"}),F("path",{d:"M12 2v4"}),F("path",{d:"M12 18v4"}),F("path",{d:"m4.93 4.93 2.83 2.83"}),F("path",{d:"m16.24 16.24 2.83 2.83"}),F("path",{d:"M2 12h4"}),F("path",{d:"M18 12h4"}),F("path",{d:"m4.93 19.07 2.83-2.83"}),F("path",{d:"m16.24 4.93 2.83 2.83"})]})}function Zc(){return F("div",{className:"ww:px-3 ww:py-2 ww:space-y-3",children:[1,2,3,4].map(e=>ye("div",{className:"ww:flex ww:items-center ww:gap-2",children:[F("div",{className:"ww:h-1.5 ww:w-1.5 ww:rounded-full ww:bg-muted-foreground/20 ww:shrink-0 ww:animate-pulse"}),F("div",{className:"ww:h-3.5 ww:rounded ww:bg-muted-foreground/10 ww:animate-pulse",style:{width:`${50+e*10}%`,animationDelay:`${e*100}ms`}})]},e))})}function Yc({initialName:e,onSave:t,onCancel:a}){let o=Si(null),[r,s]=ra(e),[n,l]=ra(!1);Vc(()=>{o.current?.focus(),o.current?.select()},[]);let i=r.trim()!==""&&r.trim()!==e;async function u(){if(!(!i||n)){l(!0);try{await t(r.trim())}finally{l(!1)}}}function f(d){d.key==="Enter"?u():d.key==="Escape"&&a()}return ye("div",{className:"ww:flex ww:items-center ww:gap-1",children:[F("input",{ref:o,type:"text",value:r,onChange:d=>s(d.target.value),onKeyDown:f,disabled:n,className:"ww:flex-1 ww:min-w-0 ww:bg-transparent ww:text-xs ww:leading-normal ww:font-mono ww:text-foreground ww:outline-none ww:border-b ww:border-foreground/30 ww:p-0 ww:disabled:opacity-50"}),F("button",{type:"button",onClick:u,disabled:!i||n,className:"ww:bg-foreground ww:text-background ww:rounded-full ww:p-1 ww:disabled:opacity-30 ww:transition-colors ww:cursor-pointer ww:shrink-0",title:"Confirm rename",children:n?F(yi,{}):F(Qc,{})}),F("button",{type:"button",onClick:a,className:"ww:bg-foreground ww:text-background ww:rounded-full ww:p-1 ww:transition-colors ww:cursor-pointer ww:shrink-0",title:"Cancel",children:F(Jc,{})})]})}var ep=320;function tp({api:e,chatRef:t}){let a=e??"/api/waniwani",[o,r]=ra(null),[s,n]=ra(null),[l,i]=ra(null),u=Si(null),f=Tt(a),{scenarios:d,isLoading:c,reload:p,rename:h}=Ii(a,f.eval);async function I(x){u.current?.abort(),u.current=new AbortController,r(x.id);try{if(!t?.current)throw new Error("ScenarioPanel requires a chatRef prop pointing to the ChatCard/ChatBar");t.current.reset();let w=x.messages.filter(m=>m.role==="user");for(let m of w){let g=$c(m);g&&await t.current.sendMessageAndWait(g)}}catch(w){w.name!=="AbortError"&&console.error("[ScenarioPanel] run failed:",w)}finally{r(null)}}async function L(x,w){i(null);try{await h(x,w)}catch(m){let g=m instanceof Error?m.message:"Failed to rename scenario";i(g)}n(m=>m===x?null:m)}return f.eval?ye("div",{"data-waniwani-chat":"",className:"ww:flex ww:flex-col ww:h-full ww:overflow-hidden ww:text-foreground ww:border-l ww:border-border ww:shrink-0",style:{width:ep},children:[ye("div",{className:"ww:px-3 ww:py-2 ww:border-b ww:border-border/50 ww:flex ww:items-center ww:justify-between",children:[F("span",{className:"ww:text-[10px] ww:font-mono ww:uppercase ww:tracking-widest ww:text-foreground/60",children:"Scenarios"}),F("button",{type:"button",onClick:p,className:"ww:bg-foreground ww:text-background ww:rounded-full ww:p-1 ww:transition-colors ww:cursor-pointer",title:"Reload scenarios",children:ye("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",role:"img",children:[F("title",{children:"Reload scenarios"}),F("path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"}),F("path",{d:"M21 3v5h-5"})]})})]}),l&&ye("div",{className:"ww:mx-3 ww:my-2 ww:px-2 ww:py-1.5 ww:text-[11px] ww:font-mono ww:text-red-400 ww:bg-red-500/10 ww:rounded ww:flex ww:items-start ww:gap-1.5",children:[F("span",{className:"ww:flex-1",children:l}),F("button",{type:"button",onClick:()=>i(null),className:"ww:shrink-0 ww:text-red-400 ww:hover:text-red-300 ww:cursor-pointer",children:"\xD7"})]}),F("div",{className:"ww:flex-1 ww:overflow-y-auto ww:min-h-0",children:c?F(Zc,{}):d.length===0?F("p",{className:"ww:text-xs ww:font-mono ww:text-foreground/50 ww:text-center ww:py-8 ww:px-4",children:"No scenarios found"}):d.map(x=>{let w=o===x.id,m=s===x.id;return ye("div",{className:T("ww:group ww:flex ww:items-center ww:gap-1 ww:px-3 ww:py-2 ww:border-l-2 ww:transition-colors",w?"ww:border-[#03d916] ww:bg-[#03d916]/10":"ww:border-transparent ww:hover:bg-muted/50"),children:[F("div",{className:"ww:flex-1 ww:min-w-0",children:m?F(Yc,{initialName:x.name,onSave:g=>L(x.id,g),onCancel:()=>n(null)}):F("span",{className:"ww:block ww:truncate ww:text-xs ww:font-mono ww:text-foreground",title:x.name,children:x.name})}),!m&&ye("div",{className:"ww:flex ww:items-center ww:gap-1 ww:shrink-0",children:[!w&&F("button",{type:"button",onClick:()=>n(x.id),className:"ww:opacity-0 ww:group-hover:opacity-100 ww:bg-foreground ww:text-background ww:rounded-full ww:p-1 ww:transition-all ww:cursor-pointer",title:"Rename scenario",children:F(Kc,{})}),F("button",{type:"button",onClick:()=>I(x),disabled:o!==null,className:"ww:bg-foreground ww:text-background ww:rounded-full ww:p-1 ww:disabled:opacity-40 ww:transition-colors ww:cursor-pointer",title:"Run scenario",children:w?F(yi,{}):F(Xc,{})})]})]},x.id)})})]}):null}import{forwardRef as up,useCallback as xr,useEffect as dp,useImperativeHandle as fp,useRef as bi,useState as Ti}from"react";import{useEffect as ap,useRef as op,useState as rp}from"react";import{jsx as J,jsxs as Ve}from"react/jsx-runtime";var ki=20;function sp(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 np(){return Ve("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:[J("title",{children:"New chat"}),J("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),J("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}function ip(){return Ve("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:[J("title",{children:"Thread history"}),J("path",{d:"M3 12a9 9 0 1 0 3-6.7"}),J("polyline",{points:"3 4 3 9 8 9"}),J("line",{x1:"12",y1:"7",x2:"12",y2:"12"}),J("line",{x1:"12",y1:"12",x2:"15",y2:"14"})]})}function lp(){return Ve("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:[J("title",{children:"Delete thread"}),J("polyline",{points:"3 6 5 6 21 6"}),J("path",{d:"M19 6l-2 14a2 2 0 0 1-2 2H9a2 2 0 0 1-2-2L5 6"}),J("path",{d:"M10 11v6"}),J("path",{d:"M14 11v6"})]})}function lo({threads:e,activeThreadId:t,onNewThread:a,onSelectThread:o,onDeleteThread:r}){let[s,n]=rp(!1),l=op(null);ap(()=>{if(!s)return;let f=d=>{l.current&&!l.current.contains(d.target)&&n(!1)};return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[s]);let i=e.slice(0,ki),u=Math.max(0,e.length-ki);return Ve("div",{ref:l,className:"ww:relative ww:flex ww:items-center ww:gap-1",children:[J("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:J(np,{})}),J("button",{type:"button",onClick:()=>n(f=>!f),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:J(ip,{})}),s&&Ve("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&&J("div",{className:"ww:px-3 ww:py-3 ww:text-xs ww:text-muted-foreground",children:"No previous chats yet."}),i.map(f=>{let d=f.threadId===t;return Ve("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:[Ve("button",{type:"button",onClick:()=>{o(f.threadId),n(!1)},className:"ww:flex-1 ww:min-w-0 ww:text-left ww:cursor-pointer",children:[J("div",{className:"ww:truncate ww:text-foreground ww:font-medium",children:f.title}),J("div",{className:"ww:text-[10px] ww:text-muted-foreground",children:sp(f.updatedAt)})]}),J("button",{type:"button",onClick:c=>{c.stopPropagation(),r(f.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:J(lp,{})})]},f.threadId)}),u>0&&Ve("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"]})]})]})}import{jsx as pe,jsxs as uo}from"react/jsx-runtime";var cp=up(function(t,a){let{theme:o,title:r="Assistant",width:s,height:n,className:l,allowAttachments:i=!1,welcomeMessage:u,welcome:f,placeholder:d="Ask me anything...",triggerEvent:c="triggerDemoRequest",api:p,debug:h,enableThreadHistory:I=!1}=t,L=p??"/api/waniwani",x=no(L,t.headers),w=ot(o),m=rt(w),g=vt(w),C=Tt(L,t.headers,t.skipRemoteConfig),b=h??C.debug,y=bt({...t,api:L}),B=kt({...t,api:L,sessionId:y.sessionId}),N=At(d,!y.text),[R,k]=Ti(!1),[P,Y]=Ti(null),U=bi(null),D=bi(void 0),z=xr(()=>{let M=U.current;if(!M)return;M.scrollIntoView({behavior:"smooth",block:"center"});let v=M.querySelector("textarea");v&&setTimeout(()=>v.focus(),300),k(!0),clearTimeout(D.current),D.current=setTimeout(()=>k(!1),2e3)},[]),ae=Pt({messages:y.messages,status:y.status,config:t.suggestions}),oe=xr(M=>{let v=M.content.map(A=>A.text??"").join("").trim();v&&y.handleSubmit({text:v,files:[],modelContext:M.modelContext})},[y.handleSubmit]),H=xr(M=>{ae.clear(),y.handleSubmit({text:M,files:[]})},[ae.clear,y.handleSubmit]);return fp(a,()=>({sendMessage:M=>{y.handleSubmit({text:M,files:[]}),z()},sendMessageAndWait:M=>y.sendMessageAndWait(M),reset:y.reset,focus:z,get messages(){return y.messages}}),[y.handleSubmit,y.sendMessageAndWait,y.reset,y.messages,z]),dp(()=>{if(!c)return;let M=v=>{let A=v.detail,_=typeof A?.message=="string"?A.message:void 0;_&&y.handleSubmit({text:_,files:[]}),z()};return window.addEventListener(c,M),()=>window.removeEventListener(c,M)},[c,y.handleSubmit,z]),uo("div",{ref:U,style:{...m,width:s,height:n},"data-waniwani-chat":"","data-waniwani-layout":"card",...g?{"data-waniwani-dark":""}:{},className:T("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",R&&"ww:ring-2 ww:ring-blue-400/70 ww:ring-offset-2 ww:ring-offset-background",l),children:[uo("div",{className:"ww:shrink-0 ww:flex ww:items-center ww:gap-2 ww:px-6 ww:py-3",style:{backgroundColor:w.headerBackgroundColor,color:w.headerTextColor},children:[pe("div",{className:"ww:text-sm ww:font-semibold ww:truncate ww:flex-1 ww:min-w-0",children:r}),pe(wa,{messages:y.messages,evalEnabled:C.eval,api:L}),I&&pe(lo,{threads:y.threads,activeThreadId:y.activeThreadId,onNewThread:y.startNewThread,onSelectThread:M=>{y.switchThread(M)},onDeleteThread:M=>{y.deleteThread(M)}})]}),uo(ma,{className:"ww:flex-1 ww:min-h-0 ww:bg-background",children:[pe(ha,{scrollClassName:P?"ww:!relative ww:!overflow-hidden":void 0,children:pe(St,{messages:y.messages,status:y.status,welcomeMessage:u,welcome:f,onSuggestionSelect:H,resourceEndpoint:x,chatSessionId:y.sessionId,isDark:g,onFollowUp:oe,onCallTool:B,fullscreenToolCallId:P,debug:b,toolDefinitions:y.toolDefinitions,onWidgetDisplayModeChange:(M,v)=>{Y(M==="fullscreen"?v.toolCallId:null)}})}),pe(ga,{})]}),pe("div",{style:P?{display:"none"}:void 0,children:pe(yt,{suggestions:ae.suggestions,isLoading:ae.isLoading,onSelect:H})}),pe("div",{style:P?{display:"none"}:void 0,children:pe(gt,{queuedMessages:y.queuedMessages,onRemove:y.removeQueuedMessage})}),pe("div",{style:P?{display:"none"}:void 0,children:pe("div",{className:"ww:shrink-0 ww:px-4 ww:pb-8 ww:pt-2 ww:bg-background",children:pe("div",{className:"ww:mx-auto ww:w-full ww:max-w-3xl",children:pe(ft,{onSubmit:y.handleSubmit,globalDrop:i,multiple:i,className:"ww:rounded-2xl ww:border-border ww:bg-input",children:uo("div",{className:"ww:flex ww:items-center ww:gap-1 ww:pl-4 ww:pr-3 ww:py-2.5",children:[i&&pe(mt,{}),pe(ct,{onChange:y.handleTextChange,value:y.text,placeholder:N,className:"ww:min-h-0 ww:py-1 ww:px-0"}),pe(pt,{status:y.status,disabled:y.queueFull})]})})})})})]})});import{forwardRef as pp,useCallback as fo,useEffect as sa,useImperativeHandle as mp,useRef as co,useState as Pi}from"react";import{jsx as he,jsxs as Mt}from"react/jsx-runtime";var hp=pp(function(t,a){let{theme:o,className:r,allowAttachments:s=!1,welcomeMessage:n,welcome:l,placeholder:i="Ask me anything...",triggerEvent:u="triggerDemoRequest",api:f,mcp:d,debug:c=!1,readOnly:p=!1,title:h,headerActions:I,enableThreadHistory:L=!1}=t,x=ot(o),w=rt(x),m=vt(x),g=bt({...t,api:f}),C=kt({...t,api:f,sessionId:g.sessionId,onCallTool:d?.onCallTool}),b=At(i,!g.text),[y,B]=Pi(null),N=co(null),R=co(null),k=co(null),[P,Y]=Pi(!0),U=co(P);U.current=P;let D=fo(()=>{let v=N.current;if(!v)return;let A=v.querySelector("textarea");A&&A.focus()},[]),z=fo((v="smooth")=>{let A=R.current;A&&A.scrollTo({top:A.scrollHeight,behavior:v})},[]);sa(()=>{let v=k.current,A=R.current;if(!v||!A)return;let _=new IntersectionObserver(([ge])=>Y(ge.isIntersecting),{root:A,rootMargin:"0px 0px 200px 0px",threshold:0});return _.observe(v),()=>_.disconnect()},[]),sa(()=>{U.current&&z("smooth")},[g.messages.length,g.messages[g.messages.length-1]]),sa(()=>{z("auto")},[z]),sa(()=>{let v=R.current;if(!v||typeof ResizeObserver>"u")return;let A=new ResizeObserver(()=>{U.current&&z("auto")});return A.observe(v),()=>A.disconnect()},[z]);let ae=Pt({messages:g.messages,status:g.status,config:t.suggestions}),oe=fo(v=>{let A=v.content.map(_=>_.text??"").join("").trim();A&&g.handleSubmit({text:A,files:[],modelContext:v.modelContext})},[g.handleSubmit]),H=fo(v=>{ae.clear(),g.handleSubmit({text:v,files:[]})},[ae.clear,g.handleSubmit]);mp(a,()=>({sendMessage:v=>{g.handleSubmit({text:v,files:[]}),D()},sendMessageAndWait:v=>g.sendMessageAndWait(v),reset:g.reset,focus:D,get messages(){return g.messages}}),[g.handleSubmit,g.sendMessageAndWait,g.reset,g.messages,D]),sa(()=>{if(!u)return;let v=A=>{let _=A.detail,ge=typeof _?.message=="string"?_.message:void 0;ge&&g.handleSubmit({text:ge,files:[]}),D()};return window.addEventListener(u,v),()=>window.removeEventListener(u,v)},[u,g.handleSubmit,D]);let M=!!(h||L||I);return Mt("div",{ref:N,style:{...w,maxHeight:"inherit"},"data-waniwani-chat":"","data-waniwani-layout":"embed",...m?{"data-waniwani-dark":""}:{},className:T("ww:relative ww:w-full ww:h-full ww:flex ww:flex-col ww:bg-background ww:text-foreground ww:font-[family-name:var(--ww-font)] ww:overflow-hidden",r),children:[M&&Mt("div",{className:"ww:shrink-0 ww:flex ww:items-center ww:gap-2 ww:px-6 ww:py-3 ww:bg-background ww:border-b ww:border-border",style:{backgroundColor:x.headerBackgroundColor,color:x.headerTextColor},children:[h&&he("div",{className:"ww:text-sm ww:font-semibold ww:truncate ww:flex-1 ww:min-w-0",children:h}),!h&&he("div",{className:"ww:flex-1"}),I,L&&he(lo,{threads:g.threads,activeThreadId:g.activeThreadId,onNewThread:g.startNewThread,onSelectThread:v=>{g.switchThread(v)},onDeleteThread:v=>{g.deleteThread(v)}})]}),Mt("div",{ref:R,className:T("ww:relative ww:flex-1 ww:min-h-0",y?"ww:overflow-hidden":"ww:overflow-y-auto"),children:[Mt("div",{className:T("ww:mx-auto ww:w-full ww:max-w-3xl ww:px-4 ww:py-6 ww:flex ww:flex-col ww:gap-6",y&&"ww:!py-0"),children:[he(St,{messages:g.messages,status:g.status,welcomeMessage:n,welcome:l,onSuggestionSelect:H,resourceEndpoint:d?.resourceEndpoint,chatSessionId:g.sessionId,isDark:m,onFollowUp:oe,onCallTool:C,fullscreenToolCallId:y,debug:c,toolDefinitions:g.toolDefinitions,onWidgetDisplayModeChange:(v,A)=>{B(v==="fullscreen"?A.toolCallId:null)}}),he("div",{ref:k,"aria-hidden":!0,style:{height:1}})]}),!P&&!y&&he("div",{className:"ww:sticky ww:bottom-2 ww:flex ww:justify-center ww:pointer-events-none",children:he(Te,{type:"button",onClick:()=>z("smooth"),size:"icon",variant:"outline",className:"ww:rounded-full ww:shadow ww:pointer-events-auto","aria-label":"Scroll to latest",children:he($e,{className:"ww:size-4"})})})]}),!p&&Mt("div",{className:"ww:shrink-0 ww:bg-background",style:y?{display:"none"}:void 0,children:[he(yt,{suggestions:ae.suggestions,isLoading:ae.isLoading,onSelect:H}),he(gt,{queuedMessages:g.queuedMessages,onRemove:g.removeQueuedMessage}),he("div",{className:"ww:px-4 ww:pb-4 ww:pt-2",children:he("div",{className:"ww:mx-auto ww:w-full ww:max-w-3xl",children:he(ft,{onSubmit:g.handleSubmit,globalDrop:s,multiple:s,className:"ww:rounded-2xl ww:border-border ww:bg-input",children:Mt("div",{className:"ww:flex ww:items-center ww:gap-1 ww:pl-4 ww:pr-3 ww:py-2.5",children:[s&&he(mt,{}),he(ct,{onChange:g.handleTextChange,value:g.text,placeholder:b,className:"ww:min-h-0 ww:py-1 ww:px-0"}),he(pt,{status:g.status,disabled:g.queueFull})]})})})})]})]})});export{wr as ChatBar,cp as ChatCard,hp as ChatEmbed,wr as ChatWidget,qc as DARK_THEME,gi as DEFAULT_THEME,ir as McpAppFrame,tp as ScenarioPanel,ot as mergeTheme,rt as themeToCSSProperties};
15
+ ${N}`}]}}k.current({...q,...G?{modelContext:G}:{}})}z({jsonrpc:"2.0",id:H,result:{}});return}if(ae==="ui/update-model-context"&&H!=null){T=Vn(T,J.params),z({jsonrpc:"2.0",id:H,result:{}});return}if(ae==="tools/call"&&H!=null){let q=A.current;if(!q){z({jsonrpc:"2.0",id:H,error:{code:-32601,message:"tools/call not supported"}});return}let G=J.params?.name;q({name:G,arguments:J.params?.arguments??{}}).then(N=>{z({jsonrpc:"2.0",id:H,result:N});let j=N.content?.map(oe=>oe.text??"").join("").trim();j&&jf(G,N,D.current)&&(R&&clearTimeout(R.timer),R={text:j,timer:setTimeout(()=>{if(v)return;let oe=T;T=null,R=null,k.current?.({role:"user",content:[{type:"text",text:j}],...oe?{modelContext:oe}:{}})},500)})}).catch(N=>{let j=N instanceof Error?N.message:"Tool call failed";z({jsonrpc:"2.0",id:H,error:{code:-32e3,message:j}})});return}if(ae==="ui/request-display-mode"&&H!=null){let q=J.params?.mode,G=q==="fullscreen"||q==="inline"||q==="pip"?q:"inline";I.current=G,z({jsonrpc:"2.0",id:H,result:{mode:G}}),z({jsonrpc:"2.0",method:"ui/notifications/host-context-changed",params:{displayMode:G}}),Q.current?.(G);return}if(ae==="ui/resource-teardown"&&H!=null){z({jsonrpc:"2.0",id:H,result:{}});return}ae==="ping"&&H!=null&&z({jsonrpc:"2.0",id:H,result:{}})};return window.addEventListener("message",_e),()=>{v=!0,clearTimeout(ne),R&&clearTimeout(R.timer),window.removeEventListener("message",_e)}},[i,W]),Vf("iframe",{ref:h,src:Y,sandbox:"allow-scripts allow-forms allow-same-origin",className:P(!c&&"ww:rounded-md ww:border ww:border-border",n),style:{height:c?"100%":b,minWidth:c||!M?void 0:`min(${M}px, 100%)`,width:"100%",border:"none",colorScheme:s?"dark":"auto"},title:"MCP App"})}import{jsx as ea,jsxs as $f}from"react/jsx-runtime";function Qn({icon:e,title:t,description:a,suggestions:o,onSuggestionSelect:r}){return $f("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&&ea("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}),ea("h2",{className:"ww:text-lg ww:font-semibold ww:text-foreground",children:t}),a&&ea("p",{className:"ww:mt-1 ww:text-sm ww:text-muted-foreground ww:max-w-sm",children:a}),o&&o.length>0&&ea("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)=>ea("button",{type:"button",onClick:()=>r?.(s),className:P("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))})]})}import{Component as Xf}from"react";import{jsx as Kn,jsxs as Qf}from"react/jsx-runtime";var Ka=class extends Xf{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){console.warn("[WaniWani] Widget failed to render:",t.message)}render(){return this.state.hasError?Qf("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:[Kn("span",{children:"Widget failed to load"}),Kn("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 Jf,jsx as se,jsxs as Lt}from"react/jsx-runtime";function Kf(e){return e?e.replace(/[-_]/g," ").replace(/^\w/,t=>t.toUpperCase()):"Tool"}function It({messages:e,status:t,welcomeMessage:a,welcome:o,onSuggestionSelect:r,resourceEndpoint:s,chatSessionId:n,isDark:i,onFollowUp:l,onCallTool:u,onWidgetDisplayModeChange:f,fullscreenToolCallId:d,debug:c,toolDefinitions:p}){let h=t==="submitted"||t==="streaming",S=e[e.length-1],L=e.length>0,x=h&&(!L||S.role==="user"),w=d!=null;return Lt(Jf,{children:[!w&&(!L&&o?se(Qn,{...o,onSuggestionSelect:r}):a&&se(Va,{from:"assistant",children:se($a,{children:se(Xa,{children:a})})})),e.map(m=>{let g=m.parts.filter(k=>k.type==="text"),I=m.parts.filter(k=>k.type==="reasoning"),b=m.parts.filter(k=>k.type==="file"),y=m.parts.filter(k=>"toolCallId"in k),M=m===S&&m.role==="assistant",_=g.length>0,F=w?y.some(k=>k.toolCallId===d):!1;return w&&!F?se("div",{style:{display:"none"}},m.id):Lt(Va,{from:m.role,children:[!F&&I.map((k,A)=>se(Fn,{text:k.text},`reasoning-${m.id}-${A}`)),y.map(k=>{let A="output"in k?k.output:void 0,Q=Qa(k.toolName,A,p),O=zn(k.toolName,A,p),D=k.toolCallId===d;return Lt("div",{style:D?{position:"absolute",inset:0,zIndex:10,display:"flex",flexDirection:"column",overflow:"hidden",background:"var(--ww-color-background)"}:void 0,children:[se("div",{style:D?{display:"none"}:void 0,children:Lt(On,{children:[se(Un,{title:k.title??Kf(k.toolName),state:k.state}),Lt(Hn,{children:[se(qn,{input:k.input,debug:c}),A!==void 0&&se(jn,{output:A,errorText:"errorText"in k?k.errorText:void 0,debug:c})]})]})}),Q&&s&&A!==void 0&&se(Ka,{children:se(rr,{isFullscreen:D,resourceUri:Q,toolInput:k.input??{},toolResult:{content:A.content,structuredContent:A.structuredContent,_meta:A._meta},resourceEndpoint:s,chatSessionId:n,isDark:i,autoHeight:O,toolDefinitions:p,onFollowUp:l,onCallTool:u,onDisplayModeChange:f?W=>f(W,{toolCallId:k.toolCallId,resourceUri:Q,toolInput:k.input??{},toolResult:{content:A.content,structuredContent:A.structuredContent,_meta:A._meta},autoHeight:O}):void 0})})]},k.toolCallId)}),!F&&se("div",{children:Lt($a,{children:[b.length>0&&se(Zr,{files:b}),_?g.map((k,A)=>se(Xa,{children:k.type==="text"?k.text:""},`${m.id}-${A}`)):M&&h&&se(Co,{})]})})]},m.id)}),!w&&x&&se(Va,{from:"assistant",children:se($a,{children:se(Co,{})})})]})}import{jsx as Ja}from"react/jsx-runtime";function Ct({suggestions:e,isLoading:t,onSelect:a,className:o,...r}){return e.length===0&&!t?null:Ja("div",{className:P("ww:px-4 ww:py-2",o),...r,children:Ja("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=>Ja("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)=>Ja("button",{type:"button",onClick:()=>a(s),className:P("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))})})}import{useCallback as Zf,useRef as Yf}from"react";function St(e){let t=Yf(e);return t.current=e,Zf(async a=>{let{api:o,headers:r,onCallTool:s,sessionId:n}=t.current;if(s)return s(a);let i=`${o??"/api/waniwani"}/tool`,l=typeof n=="string"&&n.trim().length>0?n.trim():void 0,u=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json",...l?{"X-Session-Id":l}:{},...r},body:JSON.stringify(a)});if(!u.ok)throw new Error(`Tool call failed: ${u.status} ${u.statusText}`);return u.json()},[])}import{useChat as gc}from"@ai-sdk/react";import{useCallback as ce,useEffect as Ae,useRef as le,useState as et}from"react";import{DefaultChatTransport as ec,uiMessageChunkSchema as tc}from"ai";function ac(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(i=>(i.code==="invalid_value"||i.code==="invalid_literal")&&i.path?.[0]==="type"))continue;let n=r.filter(i=>i.code==="unrecognized_keys").flatMap(i=>i.keys??[]);if(n.length>0)return n}return null}var Za=class extends ec{processResponseStream(t){let a="",o=tc(),r=o.validate?.bind(o);return t.pipeThrough(new TextDecoderStream).pipeThrough(new TransformStream({async transform(s,n){a+=s;let i=a.split(`
16
+ `);a=i.pop()??"";for(let l of i){let u=l.trim();if(!u.startsWith("data:"))continue;let f=u.slice(5).trim();if(f!=="[DONE]")try{let d=JSON.parse(f);if(!r){n.enqueue(d);continue}let c=await r(d);if(c.success){n.enqueue(c.value);continue}let p=ac(c.error);if(p?.length){let h={...d};for(let L of p)delete h[L];let S=await r(h);S.success&&n.enqueue(S.value)}}catch{}}}}))}};var oc="waniwani-memory";var Ce="threads",Ya="by_memoryUserId",rc="by_updatedAt";var Zn="memoryUserId",Jn="waniwani-memory-user-id",sr=null;function nr(){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 sc(e,t){if(t<1&&(e.objectStoreNames.contains("ids")||e.createObjectStore("ids")),t<2&&!e.objectStoreNames.contains(Ce)){let a=e.createObjectStore(Ce,{keyPath:"threadId"});a.createIndex(Ya,"memoryUserId",{unique:!1}),a.createIndex(rc,"updatedAt",{unique:!1})}}async function ir(){return new Promise((e,t)=>{let a=indexedDB.open(oc,2);a.onupgradeneeded=o=>{sc(a.result,o.oldVersion)},a.onsuccess=()=>e(a.result),a.onerror=()=>t(a.error)})}async function nc(){return ir()}async function ic(e){return new Promise((t,a)=>{let s=e.transaction("ids","readonly").objectStore("ids").get(Zn);s.onsuccess=()=>t(typeof s.result=="string"?s.result:null),s.onerror=()=>a(s.error)})}async function lc(e,t){return new Promise((a,o)=>{let n=e.transaction("ids","readwrite").objectStore("ids").put(t,Zn);n.onsuccess=()=>a(),n.onerror=()=>o(n.error)})}async function uc(){if(typeof indexedDB>"u")return null;try{let e=await nc();try{let t=await ic(e);if(t)return t;let a=nr();return await lc(e,a),a}finally{e.close()}}catch{return null}}function dc(){try{let e=localStorage.getItem(Jn);if(e)return e;let t=nr();return localStorage.setItem(Jn,t),t}catch{return null}}async function Yn(){let e=await uc();if(e)return e;let t=dc();return t||(sr||(sr=nr()),sr)}var ei=50,ti=1e3;function eo(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 to(e){if(typeof indexedDB>"u")return null;let t=null;try{return t=await ir(),await e(t)}catch{return null}finally{try{t?.close()}catch{}}}function lr(e){return new Promise((t,a)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>a(e.error)})}async function ur(e){return await to(async a=>{let s=a.transaction(Ce,"readonly").objectStore(Ce).index(Ya),i=(await lr(s.getAll(e))??[]).filter(eo);return i.sort((l,u)=>l.updatedAt<u.updatedAt?1:-1),i})??[]}async function dr(e){return await to(async a=>{let r=a.transaction(Ce,"readonly").objectStore(Ce),s=await lr(r.get(e));return eo(s)?s:null})??null}async function fr(e){if(!eo(e))return;let t=e.messages.length>ti?{...e,messages:e.messages.slice(e.messages.length-ti)}:e;await to(async a=>{await new Promise((l,u)=>{let f=a.transaction(Ce,"readwrite");f.oncomplete=()=>l(),f.onerror=()=>u(f.error),f.onabort=()=>u(f.error),f.objectStore(Ce).put(t)});let o=a.transaction(Ce,"readwrite"),r=o.objectStore(Ce),s=r.index(Ya),i=(await lr(s.getAll(t.memoryUserId))??[]).filter(eo);if(i.length>ei){i.sort((u,f)=>u.updatedAt<f.updatedAt?-1:1);let l=i.slice(0,i.length-ei);for(let u of l)r.delete(u.threadId)}return await new Promise((l,u)=>{o.oncomplete=()=>l(),o.onerror=()=>u(o.error),o.onabort=()=>u(o.error)}),null})}async function ai(e){await to(async t=>(await new Promise((a,o)=>{let r=t.transaction(Ce,"readwrite");r.oncomplete=()=>a(),r.onerror=()=>o(r.error),r.onabort=()=>o(r.error),r.objectStore(Ce).delete(e)}),null))}async function oi(e){return(await ur(e))[0]?.threadId??null}function ri(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`}var si="waniwani-visitor-id";function ni(e,t){return e.match(t)?.[1]??null}function fc(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=ni(e,o);if(r)return{name:a,version:r}}return null}function cc(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=ni(e,o);if(r)return{name:a,version:r.replace(/_/g,".")};if(a==="Linux"&&o.test(e))return{name:a,version:""}}return null}function pc(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 mc(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 hc(){try{let a=localStorage.getItem(si);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 mc(e);try{localStorage.setItem(si,t)}catch{}return t}async function ii(){let e=navigator.userAgent,[t,a]=await Promise.all([hc(),Yn()]);return{userAgent:e,browser:fc(e),os:cc(e),deviceType:pc(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 wc="x-session-id",xc=250;function li(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():Ut()}function ao(){return new Date().toISOString()}function ui(e){if(typeof e!="string")return;let t=e.trim();return t.length>0?t:void 0}async function Lc(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 yt(e){let{api:t="/api/waniwani",headers:a,body:o,onMessageSent:r,onResponseReceived:s,enableThreadHistory:n=!1,activeThreadId:i,onThreadChange:l}=e,u=le(a),f=le(o),d=le(n);Ae(()=>{d.current=n},[n]);let c=le(void 0),p=le(null),[h,S]=et(void 0),L=le(h),[x,w]=et(i),m=le(x),[g,I]=et([]),[b,y]=et(!n),M=le(void 0),_=le(void 0),F=le(void 0),k=le(void 0),A=le(0),Q=le(l);Ae(()=>{Q.current=l},[l]);let O=ce(C=>{m.current=C,w(C),C&&Q.current?.(C)},[]),D=ce(async()=>{if(!n)return;let C=p.current?.memoryUserId;if(!C)return;let B=await ur(C);I(B)},[n]),W=ce(()=>L.current,[]),Y=ce(C=>{let B=ui(C);B&&L.current!==B&&(L.current=B,S(B))},[]),K=ce(()=>{L.current=void 0,S(void 0)},[]);Ae(()=>{u.current=a},[a]),Ae(()=>{f.current=o},[o]),Ae(()=>{let C=!1,B=A.current;return(async()=>{try{let ye=await ii();if(C)return;p.current=ye}catch{}if(!n)return;let E=p.current?.memoryUserId;if(!E){y(!0);return}try{let ye=i??await oi(E);if(C||B!==A.current)return;if(ye){let ge=await dr(ye);if(C||B!==A.current)return;ge&&ge.memoryUserId===E&&(m.current=ge.threadId,w(ge.threadId),M.current=ge.createdAt,_.current=ge.title,ge.sessionId&&(L.current=ge.sessionId,S(ge.sessionId)),ae(ge.messages))}await D()}finally{C||y(!0)}})(),()=>{C=!0}},[]);let U=le(new Za({api:t,headers:()=>({...u.current}),body:()=>{let C={...f.current??{}},B=Object.hasOwn(C,"sessionId"),E=ui(C.sessionId);if(E)Y(E),C.sessionId=E;else if(B)K(),delete C.sessionId;else{let Te=W();Te&&(C.sessionId=Te)}if(xt(c.current)&&(C.modelContext=c.current),p.current){let Te=p.current;C.visitorContext={timezone:Te.timezone,language:Te.language,languages:Te.languages,deviceType:Te.deviceType,referrer:Te.referrer,visitorId:Te.visitorId};let Fe=typeof C.visitor=="object"&&C.visitor!==null?C.visitor:{},Pi=typeof Fe.client=="object"&&Fe.client!==null?Fe.client:{};C.visitor={...Fe,client:{...Pi,memoryUserId:Te.memoryUserId}}}let ye=typeof C.extra=="object"&&C.extra!==null&&!Array.isArray(C.extra)?C.extra:void 0,ge=p.current?.memoryUserId,Ne=p.current?.language,sa={};if(ge&&(sa.memoryUserId=ge),Ne&&(sa.locale=Ne),(Object.keys(sa).length>0||ye)&&(C.extra={...sa,...ye??{}}),d.current)if(Object.hasOwn(C,"threadId"))typeof C.threadId=="string"&&(m.current=C.threadId);else{let Fe=m.current;Fe||(Fe=li(),M.current=ao(),_.current=void 0,O(Fe)),C.threadId=Fe}return C},fetch:(async(C,B)=>{let E=await fetch(C,B);return c.current=void 0,Y(E.headers.get(wc)),E})})),v=le(null),ee=le(null),T=le({}),[R,ne]=et(0),z=e.skipRemoteConfig===!0,_e=ce(async()=>{if(!z)try{let C=await Lc(t,u.current);T.current=C,ne(B=>B+1)}catch(C){console.warn("[WaniWani] Failed to fetch tool definitions:",C instanceof Error?C.message:C)}},[t,z]);Ae(()=>{_e()},[_e]);let{messages:ue,sendMessage:J,setMessages:ae,status:H}=gc({messages:e.initialMessages,transport:U.current,onFinish({message:C}){s?.(),v.current&&(ee.current=C)},onError(C){console.warn("[WaniWani] Chat error:",C.message),v.current&&(v.current.reject(C),v.current=null)}}),q=le(ue);Ae(()=>{q.current=ue},[ue]),Ae(()=>{if(H==="ready"&&v.current&&ee.current){let C=v.current,B=ee.current;v.current=null,ee.current=null,C.resolve(B)}},[H]);let[G,N]=et(""),[j,oe]=et([]),Se=H==="submitted"||H==="streaming",Ee=ce(C=>{oe(B=>B.filter(E=>E.id!==C))},[]),ot=Se&&j.length>0,rt=ce(C=>{let B=!!C.text?.trim(),E=!!C.files?.length;if(B||E){if(Se){if(j.length>0)return;oe(ye=>[...ye,{id:Ut(),text:C.text||"",files:C.files??[],modelContext:C.modelContext}]),N("");return}c.current=C.modelContext,J({text:C.text||"",files:C.files}),r?.(C.text||""),N("")}},[J,r,Se,j.length]),Ii=ce(C=>new Promise((B,E)=>{v.current={resolve:B,reject:E},J({text:C}),r?.(C)}),[J,r]);Ae(()=>{if(H!=="ready"||j.length===0)return;let[C,...B]=j;oe(B),c.current=C.modelContext,J({text:C.text,files:C.files.length>0?C.files:void 0}),r?.(C.text)},[H,J,r,j]);let Ci=ce(()=>{ae([]),oe([]),K(),N(""),T.current={},ne(C=>C+1),_e()},[ae,K,_e]),oa=ce(()=>{if(!d.current)return;let C=p.current?.memoryUserId,B=m.current,E=q.current;if(!(!C||!B||E.length===0)){if(M.current||(M.current=ao()),!_.current){let ye=E.find(Ne=>Ne.role==="user"),ge=ye?ye.parts.map(Ne=>"text"in Ne&&typeof Ne.text=="string"?Ne.text:"").join(" "):"";_.current=ri(ge)}return{threadId:B,memoryUserId:C,title:_.current,messages:E,sessionId:L.current,createdAt:M.current,updatedAt:ao()}}},[]),gr=ce(async()=>{let C=oa();C&&(await fr(C),await D())},[oa,D]);Ae(()=>{if(n&&b&&!(H==="submitted"||H==="streaming")&&ue.length!==0)return F.current&&clearTimeout(F.current),F.current=setTimeout(()=>{F.current=void 0;let C=gr().finally(()=>{k.current===C&&(k.current=void 0)});k.current=C},xc),()=>{F.current&&clearTimeout(F.current)}},[n,b,ue,H,gr]);let ra=ce(()=>{let C=k.current,B=F.current,E=B?oa():void 0;return B&&(clearTimeout(B),F.current=void 0),(async()=>{C&&await C,E&&(await fr(E),await D())})()},[oa,D]),Si=ce(()=>{A.current+=1,ra(),ae([]),oe([]),K(),N("");let C=li();return M.current=ao(),_.current=void 0,O(C),D(),C},[ae,K,O,D,ra]),uo=ce(async C=>{A.current+=1;let B=A.current;if(await ra(),B!==A.current)return;let E=await dr(C);B===A.current&&E&&(O(E.threadId),M.current=E.createdAt,_.current=E.title,E.sessionId?(L.current=E.sessionId,S(E.sessionId)):K(),ae(E.messages),oe([]),N(""))},[ae,K,O,ra]),yi=ce(async C=>{if(m.current===C){A.current+=1,F.current&&(clearTimeout(F.current),F.current=void 0);let B=k.current;B&&await B}await ai(C),await D(),m.current===C&&(ae([]),oe([]),K(),N(""),m.current=void 0,w(void 0),M.current=void 0,_.current=void 0)},[ae,K,D]);Ae(()=>{n&&b&&i!==void 0&&i!==m.current&&uo(i)},[i,n,b,uo]);let ki=ce(C=>{N(C.target.value)},[]),wr=ue[ue.length-1],xr=ue.length>0,bi=Se&&(!xr||wr.role==="user"),Ti=T.current;return{messages:ue,status:H,text:G,setText:N,handleSubmit:rt,handleTextChange:ki,isLoading:Se,showLoaderBubble:bi,lastMessage:wr,hasMessages:xr,sendMessage:J,sendMessageAndWait:Ii,reset:Ci,queuedMessages:j,queueFull:ot,removeQueuedMessage:Ee,sessionId:h,toolDefinitions:Ti,refreshToolDefinitions:_e,threads:g,activeThreadId:x,isThreadHistoryReady:b,startNewThread:Si,switchThread:uo,deleteThread:yi}}import{useEffect as di,useRef as Ic,useState as Cc}from"react";var Sc={debug:!1,eval:!1};function oo(e="/api/waniwani",t,a=!1){let[o,r]=Cc(Sc),s=Ic(t);return di(()=>{s.current=t},[t]),di(()=>{a||(async()=>{try{let n=s.current,l=await(await fetch(`${e}/config`,{headers:n?{...n}:void 0})).json();r({debug:l.debug===!0,eval:l.eval===!0})}catch{}})()},[e,a]),o}import{useCallback as yc,useEffect as cr,useRef as kc,useState as bc}from"react";function Tc(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 fi(e){return typeof e=="object"&&e!==null&&"initial"in e}function kt(e){let{messages:t,status:a,config:o}=e,r=fi(o)&&o.initial?o.initial:void 0,[s,n]=bc(r??[]),i=kc(a),l=o===!0||fi(o)&&o.dynamic!==!1,u=yc(()=>{n([])},[]),f=t.length>0;cr(()=>{!f&&r&&r.length>0&&n(r)},[r,f]);let d=t[t.length-1];return cr(()=>{d?.role==="user"&&u()},[d,u]),cr(()=>{let c=i.current;if(i.current=a,c==="streaming"&&a==="ready"&&l){let p=[...t].reverse().find(S=>S.role==="assistant");if(!p)return;let h=Tc(p);h&&n(h)}},[a,l,t]),{suggestions:s,isLoading:!1,clear:u}}import{useEffect as Pc,useRef as Ac,useState as vc}from"react";var Mc=50,Rc=30,Fc=2e3,ci=500;function bt(e,t=!0){let[a,o]=vc(""),r=Ac(void 0);return Pc(()=>{if(!t){o("");return}let s=0,n=!1,i=!1,l=()=>{i||(n?(s--,o(e.slice(0,s)),s<=0?(n=!1,r.current=setTimeout(l,ci)):r.current=setTimeout(l,Rc)):(s++,o(e.slice(0,s)),s>=e.length?(n=!0,r.current=setTimeout(l,Fc)):r.current=setTimeout(l,Mc)))};return r.current=setTimeout(l,ci),()=>{i=!0,clearTimeout(r.current)}},[e,t]),a}function Tt(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`}var pi={primaryColor:"#6366f1",primaryForeground:"#1f2937",backgroundColor:"#ffffff",textColor:"#1f2937",mutedColor:"#6b7280",borderColor:"#e5e7eb",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"},Bc={backgroundColor:"#212121",headerBackgroundColor:"#1e1e1e",headerTextColor:"#ececec",textColor:"#ececec",primaryForeground:"#ffffff",mutedColor:"#8e8ea0",borderColor:"#444444",assistantBubbleColor:"#2f2f2f",userBubbleColor:"#303030",inputBackgroundColor:"#2f2f2f",primaryColor:"#6366f1",statusColor:"#22c55e",toolCardColor:"#262626"},Dc={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"],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 tt(e){return{...pi,...e}}function Pt(e){let t=e.backgroundColor.replace("#",""),a=parseInt(t.substring(0,2),16),o=parseInt(t.substring(2,4),16),r=parseInt(t.substring(4,6),16);return(a*299+o*587+r*114)/1e3<128}function at(e){let t={};for(let[a,o]of Object.entries(Dc)){let r=e[a],s=typeof r=="number"?`${r}px`:String(r);for(let n of o)t[n]=s}return t}import{jsx as xe,jsxs as ta}from"react/jsx-runtime";var mr=_c(function(t,a){let{theme:o,title:r="Assistant",width:s=600,expandedWidth:n,expandedHeight:i=400,allowAttachments:l=!1,welcomeMessage:u,welcome:f,placeholder:d="Ask me anything...",triggerEvent:c="triggerDemoRequest",api:p}=t,h=n??Math.round((typeof s=="number"?s:600)*1.2),S=p??"/api/waniwani",L=Tt(S,t.headers),x=tt(o),w=at(x),m=Pt(x),g=oo(p,t.headers,t.skipRemoteConfig),I=yt(t),b=St({...t,sessionId:I.sessionId}),y=kt({messages:I.messages,status:I.status,config:t.suggestions}),M=ro(T=>{let R=T.content.map(ne=>ne.text??"").join("").trim();R&&I.handleSubmit({text:R,files:[],modelContext:T.modelContext})},[I.handleSubmit]),_=ro(T=>{y.clear(),I.handleSubmit({text:T,files:[]})},[y.clear,I.handleSubmit]),F=bt(d,!I.text),[k,A]=pr(!1),[Q,O]=pr(!1),[D,W]=pr(null),Y=hi(null),K=hi(void 0),U=ro(()=>{let T=Y.current;if(!T)return;T.scrollIntoView({behavior:"smooth",block:"center"});let R=T.querySelector("textarea");R&&setTimeout(()=>R.focus(),300),A(!0),O(!0),clearTimeout(K.current),K.current=setTimeout(()=>O(!1),2e3)},[]);Ec(a,()=>({sendMessage:T=>{I.handleSubmit({text:T,files:[]}),U()},sendMessageAndWait:T=>I.sendMessageAndWait(T),reset:I.reset,focus:U,get messages(){return I.messages}}),[I.handleSubmit,I.sendMessageAndWait,I.reset,I.messages,U]),mi(()=>{if(!c)return;let T=R=>{let ne=R.detail,z=typeof ne?.message=="string"?ne.message:void 0;z&&I.handleSubmit({text:z,files:[]}),U()};return window.addEventListener(c,T),()=>window.removeEventListener(c,T)},[c,I.handleSubmit,U]);let v=k||D!==null;mi(()=>{if(!k)return;let T=R=>{Y.current&&!Y.current.contains(R.target)&&A(!1)};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[k]);let ee=ro(()=>{A(!0)},[]);return ta("div",{ref:Y,style:{...w,width:v?h:s,transition:"width 0.4s cubic-bezier(0.16, 1, 0.3, 1)"},"data-waniwani-chat":"","data-waniwani-layout":"bar",...m?{"data-waniwani-dark":""}:{},className:"ww:flex ww:flex-col ww:font-[family-name:var(--ww-font)] ww:text-foreground",children:[ta("div",{style:{overflow:"hidden",backgroundColor:x.backgroundColor,borderRadius:"var(--ww-radius) var(--ww-radius) 0 0",maxHeight:v?i+200:0,opacity:v?1:0,transform:v?"scaleX(1)":"scaleX(0.88)",transformOrigin:"center bottom",transition:"max-height 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease-out, transform 0.4s cubic-bezier(0.16, 1, 0.3, 1)"},children:[ta("div",{className:"ww:shrink-0 ww:flex ww:items-center ww:px-6 ww:py-3",style:{backgroundColor:x.headerBackgroundColor,color:x.headerTextColor},children:[xe("div",{className:"ww:text-sm ww:font-semibold ww:truncate",children:r}),xe(ma,{messages:I.messages,evalEnabled:g.eval,api:S})]}),ta(fa,{className:"ww:flex-1",style:{height:i},children:[xe(ca,{scrollClassName:D?"ww:!relative ww:!overflow-hidden":void 0,children:xe(It,{messages:I.messages,status:I.status,welcomeMessage:u,welcome:f,onSuggestionSelect:_,resourceEndpoint:L,chatSessionId:I.sessionId,isDark:m,onFollowUp:M,onCallTool:b,fullscreenToolCallId:D,toolDefinitions:I.toolDefinitions,onWidgetDisplayModeChange:(T,R)=>{W(T==="fullscreen"?R.toolCallId:null)}})}),xe(pa,{})]}),xe("div",{style:D?{display:"none"}:void 0,children:xe(Ct,{suggestions:y.suggestions,isLoading:y.isLoading,onSelect:_})}),xe("div",{style:D?{display:"none"}:void 0,children:xe(mt,{queuedMessages:I.queuedMessages,onRemove:I.removeQueuedMessage})})]}),xe("div",{style:{backgroundColor:v?x.backgroundColor:"transparent",borderRadius:v?"0 0 var(--ww-radius) var(--ww-radius)":void 0,boxShadow:v?"0 8px 24px rgba(0,0,0,0.1)":"none",transition:"background-color 0.2s ease, border-radius 0.3s ease, box-shadow 0.35s ease, padding 0.3s ease",padding:v?"8px 16px 16px":"0"},children:xe(ut,{onSubmit:I.handleSubmit,globalDrop:l,multiple:l,className:P("ww:rounded-2xl ww:border-border ww:bg-input ww:transition-all ww:duration-300",!v&&"ww:shadow-sm",Q&&"ww:ring-2 ww:ring-blue-400/70 ww:ring-offset-2 ww:ring-offset-background"),children:ta("div",{className:"ww:flex ww:items-center ww:gap-1 ww:pl-4 ww:pr-3 ww:py-2.5",children:[l&&xe(ct,{}),xe(dt,{onChange:I.handleTextChange,value:I.text,placeholder:F,onFocus:ee,className:"ww:min-h-0 ww:py-1 ww:px-0"}),xe(ft,{status:I.status,disabled:I.queueFull})]})})})]})});import{forwardRef as zc,useCallback as hr,useEffect as jc,useImperativeHandle as Vc,useRef as wi,useState as xi}from"react";import{useEffect as Nc,useRef as Oc,useState as Uc}from"react";import{jsx as Z,jsxs as ze}from"react/jsx-runtime";var gi=20;function Hc(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 qc(){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:[Z("title",{children:"New chat"}),Z("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),Z("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}function Gc(){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:[Z("title",{children:"Thread history"}),Z("path",{d:"M3 12a9 9 0 1 0 3-6.7"}),Z("polyline",{points:"3 4 3 9 8 9"}),Z("line",{x1:"12",y1:"7",x2:"12",y2:"12"}),Z("line",{x1:"12",y1:"12",x2:"15",y2:"14"})]})}function Wc(){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:[Z("title",{children:"Delete thread"}),Z("polyline",{points:"3 6 5 6 21 6"}),Z("path",{d:"M19 6l-2 14a2 2 0 0 1-2 2H9a2 2 0 0 1-2-2L5 6"}),Z("path",{d:"M10 11v6"}),Z("path",{d:"M14 11v6"})]})}function so({threads:e,activeThreadId:t,onNewThread:a,onSelectThread:o,onDeleteThread:r}){let[s,n]=Uc(!1),i=Oc(null);Nc(()=>{if(!s)return;let f=d=>{let c=i.current;c&&(d.composedPath().includes(c)||n(!1))};return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[s]);let l=e.slice(0,gi),u=Math.max(0,e.length-gi);return ze("div",{ref:i,className:"ww:relative ww:flex ww:items-center ww:gap-1",children:[Z("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:Z(qc,{})}),Z("button",{type:"button",onClick:()=>n(f=>!f),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:Z(Gc,{})}),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:[l.length===0&&Z("div",{className:"ww:px-3 ww:py-3 ww:text-xs ww:text-muted-foreground",children:"No previous chats yet."}),l.map(f=>{let d=f.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(f.threadId),n(!1)},className:"ww:flex-1 ww:min-w-0 ww:text-left ww:cursor-pointer",children:[Z("div",{className:"ww:truncate ww:text-foreground ww:font-medium",children:f.title}),Z("div",{className:"ww:text-[10px] ww:text-muted-foreground",children:Hc(f.updatedAt)})]}),Z("button",{type:"button",onClick:c=>{c.stopPropagation(),r(f.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:Z(Wc,{})})]},f.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"]})]})]})}import{jsx as pe,jsxs as no}from"react/jsx-runtime";var $c=zc(function(t,a){let{theme:o,title:r="Assistant",width:s,height:n,className:i,allowAttachments:l=!1,welcomeMessage:u,welcome:f,placeholder:d="Ask me anything...",triggerEvent:c="triggerDemoRequest",api:p,debug:h,enableThreadHistory:S=!1}=t,L=p??"/api/waniwani",x=Tt(L,t.headers),w=tt(o),m=at(w),g=Pt(w),I=oo(L,t.headers,t.skipRemoteConfig),b=h??I.debug,y=yt({...t,api:L}),M=St({...t,api:L,sessionId:y.sessionId}),_=bt(d,!y.text),[F,k]=xi(!1),[A,Q]=xi(null),O=wi(null),D=wi(void 0),W=hr(()=>{let v=O.current;if(!v)return;v.scrollIntoView({behavior:"smooth",block:"center"});let ee=v.querySelector("textarea");ee&&setTimeout(()=>ee.focus(),300),k(!0),clearTimeout(D.current),D.current=setTimeout(()=>k(!1),2e3)},[]),Y=kt({messages:y.messages,status:y.status,config:t.suggestions}),K=hr(v=>{let ee=v.content.map(T=>T.text??"").join("").trim();ee&&y.handleSubmit({text:ee,files:[],modelContext:v.modelContext})},[y.handleSubmit]),U=hr(v=>{Y.clear(),y.handleSubmit({text:v,files:[]})},[Y.clear,y.handleSubmit]);return Vc(a,()=>({sendMessage:v=>{y.handleSubmit({text:v,files:[]}),W()},sendMessageAndWait:v=>y.sendMessageAndWait(v),reset:y.reset,focus:W,get messages(){return y.messages}}),[y.handleSubmit,y.sendMessageAndWait,y.reset,y.messages,W]),jc(()=>{if(!c)return;let v=ee=>{let T=ee.detail,R=typeof T?.message=="string"?T.message:void 0;R&&y.handleSubmit({text:R,files:[]}),W()};return window.addEventListener(c,v),()=>window.removeEventListener(c,v)},[c,y.handleSubmit,W]),no("div",{ref:O,style:{...m,width:s,height:n},"data-waniwani-chat":"","data-waniwani-layout":"card",...g?{"data-waniwani-dark":""}:{},className:P("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",i),children:[no("div",{className:"ww:shrink-0 ww:flex ww:items-center ww:gap-2 ww:px-6 ww:py-3",style:{backgroundColor:w.headerBackgroundColor,color:w.headerTextColor},children:[pe("div",{className:"ww:text-sm ww:font-semibold ww:truncate ww:flex-1 ww:min-w-0",children:r}),pe(ma,{messages:y.messages,evalEnabled:I.eval,api:L}),S&&pe(so,{threads:y.threads,activeThreadId:y.activeThreadId,onNewThread:y.startNewThread,onSelectThread:v=>{y.switchThread(v)},onDeleteThread:v=>{y.deleteThread(v)}})]}),no(fa,{className:"ww:flex-1 ww:min-h-0 ww:bg-background",children:[pe(ca,{scrollClassName:A?"ww:!relative ww:!overflow-hidden":void 0,children:pe(It,{messages:y.messages,status:y.status,welcomeMessage:u,welcome:f,onSuggestionSelect:U,resourceEndpoint:x,chatSessionId:y.sessionId,isDark:g,onFollowUp:K,onCallTool:M,fullscreenToolCallId:A,debug:b,toolDefinitions:y.toolDefinitions,onWidgetDisplayModeChange:(v,ee)=>{Q(v==="fullscreen"?ee.toolCallId:null)}})}),pe(pa,{})]}),pe("div",{style:A?{display:"none"}:void 0,children:pe(Ct,{suggestions:Y.suggestions,isLoading:Y.isLoading,onSelect:U})}),pe("div",{style:A?{display:"none"}:void 0,children:pe(mt,{queuedMessages:y.queuedMessages,onRemove:y.removeQueuedMessage})}),pe("div",{style:A?{display:"none"}:void 0,children:pe("div",{className:"ww:shrink-0 ww:px-4 ww:pb-8 ww:pt-2 ww:bg-background",children:pe("div",{className:"ww:mx-auto ww:w-full ww:max-w-3xl",children:pe(ut,{onSubmit:y.handleSubmit,globalDrop:l,multiple:l,className:"ww:rounded-2xl ww:border-border ww:bg-input",children:no("div",{className:"ww:flex ww:items-center ww:gap-1 ww:pl-4 ww:pr-3 ww:py-2.5",children:[l&&pe(ct,{}),pe(dt,{onChange:y.handleTextChange,value:y.text,placeholder:_,className:"ww:min-h-0 ww:py-1 ww:px-0"}),pe(ft,{status:y.status,disabled:y.queueFull})]})})})})})]})});import{forwardRef as Xc,useCallback as io,useEffect as aa,useImperativeHandle as Qc,useRef as lo,useState as Li}from"react";import{jsx as he,jsxs as At}from"react/jsx-runtime";var Kc=Xc(function(t,a){let{theme:o,className:r,allowAttachments:s=!1,welcomeMessage:n,welcome:i,placeholder:l="Ask me anything...",triggerEvent:u="triggerDemoRequest",api:f,mcp:d,debug:c=!1,readOnly:p=!1,title:h,headerActions:S,enableThreadHistory:L=!1}=t,x=tt(o),w=at(x),m=Pt(x),g=yt({...t,api:f}),I=St({...t,api:f,sessionId:g.sessionId,onCallTool:d?.onCallTool}),b=d?.resourceEndpoint??Tt(f,t.headers),y=bt(l,!g.text),[M,_]=Li(null),F=lo(null),k=lo(null),A=lo(null),[Q,O]=Li(!0),D=lo(Q);D.current=Q;let W=io(()=>{let T=F.current;if(!T)return;let R=T.querySelector("textarea");R&&R.focus()},[]),Y=io((T="smooth")=>{let R=k.current;R&&R.scrollTo({top:R.scrollHeight,behavior:T})},[]);aa(()=>{let T=A.current,R=k.current;if(!T||!R)return;let ne=new IntersectionObserver(([z])=>O(z.isIntersecting),{root:R,rootMargin:"0px 0px 200px 0px",threshold:0});return ne.observe(T),()=>ne.disconnect()},[]),aa(()=>{D.current&&Y("smooth")},[g.messages.length,g.messages[g.messages.length-1]]),aa(()=>{Y("auto")},[Y]),aa(()=>{let T=k.current;if(!T||typeof ResizeObserver>"u")return;let R=new ResizeObserver(()=>{D.current&&Y("auto")});return R.observe(T),()=>R.disconnect()},[Y]);let K=kt({messages:g.messages,status:g.status,config:t.suggestions}),U=io(T=>{let R=T.content.map(ne=>ne.text??"").join("").trim();R&&g.handleSubmit({text:R,files:[],modelContext:T.modelContext})},[g.handleSubmit]),v=io(T=>{K.clear(),g.handleSubmit({text:T,files:[]})},[K.clear,g.handleSubmit]);Qc(a,()=>({sendMessage:T=>{g.handleSubmit({text:T,files:[]}),W()},sendMessageAndWait:T=>g.sendMessageAndWait(T),reset:g.reset,focus:W,get messages(){return g.messages}}),[g.handleSubmit,g.sendMessageAndWait,g.reset,g.messages,W]),aa(()=>{if(!u)return;let T=R=>{let ne=R.detail,z=typeof ne?.message=="string"?ne.message:void 0;z&&g.handleSubmit({text:z,files:[]}),W()};return window.addEventListener(u,T),()=>window.removeEventListener(u,T)},[u,g.handleSubmit,W]);let ee=!!(h||L||S);return At("div",{ref:F,style:{...w,maxHeight:"inherit"},"data-waniwani-chat":"","data-waniwani-layout":"embed",...m?{"data-waniwani-dark":""}:{},className:P("ww:relative ww:w-full ww:h-full ww:flex ww:flex-col ww:bg-background ww:text-foreground ww:font-[family-name:var(--ww-font)] ww:overflow-hidden",r),children:[ee&&At("div",{className:"ww:shrink-0 ww:flex ww:items-center ww:gap-2 ww:px-6 ww:py-3 ww:bg-background ww:border-b ww:border-border",style:{backgroundColor:x.headerBackgroundColor,color:x.headerTextColor},children:[h&&he("div",{className:"ww:text-sm ww:font-semibold ww:truncate ww:flex-1 ww:min-w-0",children:h}),!h&&he("div",{className:"ww:flex-1"}),S,L&&he(so,{threads:g.threads,activeThreadId:g.activeThreadId,onNewThread:g.startNewThread,onSelectThread:T=>{g.switchThread(T)},onDeleteThread:T=>{g.deleteThread(T)}})]}),At("div",{ref:k,className:P("ww:relative ww:flex-1 ww:min-h-0",M?"ww:overflow-hidden":"ww:overflow-y-auto"),children:[At("div",{className:P("ww:mx-auto ww:w-full ww:max-w-3xl ww:px-4 ww:py-6 ww:flex ww:flex-col ww:gap-6",M&&"ww:!py-0"),children:[he(It,{messages:g.messages,status:g.status,welcomeMessage:n,welcome:i,onSuggestionSelect:v,resourceEndpoint:b,chatSessionId:g.sessionId,isDark:m,onFollowUp:U,onCallTool:I,fullscreenToolCallId:M,debug:c,toolDefinitions:g.toolDefinitions,onWidgetDisplayModeChange:(T,R)=>{_(T==="fullscreen"?R.toolCallId:null)}}),he("div",{ref:A,"aria-hidden":!0,style:{height:1}})]}),!Q&&!M&&he("div",{className:"ww:sticky ww:bottom-2 ww:flex ww:justify-center ww:pointer-events-none",children:he(ke,{type:"button",onClick:()=>Y("smooth"),size:"icon",variant:"outline",className:"ww:rounded-full ww:shadow ww:pointer-events-auto","aria-label":"Scroll to latest",children:he(je,{className:"ww:size-4"})})})]}),!p&&At("div",{className:"ww:shrink-0 ww:bg-background",style:M?{display:"none"}:void 0,children:[he(Ct,{suggestions:K.suggestions,isLoading:K.isLoading,onSelect:v}),he(mt,{queuedMessages:g.queuedMessages,onRemove:g.removeQueuedMessage}),he("div",{className:"ww:px-4 ww:pb-4 ww:pt-2",children:he("div",{className:"ww:mx-auto ww:w-full ww:max-w-3xl",children:he(ut,{onSubmit:g.handleSubmit,globalDrop:s,multiple:s,className:"ww:rounded-2xl ww:border-border ww:bg-input",children:At("div",{className:"ww:flex ww:items-center ww:gap-1 ww:pl-4 ww:pr-3 ww:py-2.5",children:[s&&he(ct,{}),he(dt,{onChange:g.handleTextChange,value:g.text,placeholder:y,className:"ww:min-h-0 ww:py-1 ww:px-0"}),he(ft,{status:g.status,disabled:g.queueFull})]})})})})]})]})});export{mr as ChatBar,$c as ChatCard,Kc as ChatEmbed,mr as ChatWidget,Bc as DARK_THEME,pi as DEFAULT_THEME,rr as McpAppFrame,tt as mergeTheme,at as themeToCSSProperties};
17
17
  /*! Bundled license information:
18
18
 
19
19
  lucide-react/dist/esm/shared/src/utils/mergeClasses.js: