@json-to-office/jto 2.4.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +123 -39
- package/dist/cli.js.map +1 -1
- package/dist/client/assets/HomePage-BlzZ7qG4.js +245 -0
- package/dist/client/assets/HomePage-BlzZ7qG4.js.map +1 -0
- package/dist/client/assets/{JsonEditorPage-DjLAUBv5.js → JsonEditorPage-kWuP_kL3.js} +3 -3
- package/dist/client/assets/{JsonEditorPage-DjLAUBv5.js.map → JsonEditorPage-kWuP_kL3.js.map} +1 -1
- package/dist/client/assets/{MonacoPluginProvider-D_GUFwWQ.js → MonacoPluginProvider-Dbv1PrO2.js} +6 -6
- package/dist/client/assets/{MonacoPluginProvider-D_GUFwWQ.js.map → MonacoPluginProvider-Dbv1PrO2.js.map} +1 -1
- package/dist/client/assets/{_virtual_jto-plugin-type-libs-9elxvZT2.js → _virtual_jto-plugin-type-libs-B6KyD9RL.js} +9182 -4529
- package/dist/client/assets/{_virtual_jto-plugin-type-libs-9elxvZT2.js.map → _virtual_jto-plugin-type-libs-B6KyD9RL.js.map} +1 -1
- package/dist/client/assets/_virtual_jto-sandbox-runtime-Bzo2M5U7.js +2 -0
- package/dist/client/assets/_virtual_jto-sandbox-runtime-Bzo2M5U7.js.map +1 -0
- package/dist/client/assets/editor-CwEocOY2.js +16 -0
- package/dist/client/assets/editor-CwEocOY2.js.map +1 -0
- package/dist/client/assets/editor-monaco-json-D_oiidNg.js +24 -0
- package/dist/client/assets/editor-monaco-json-D_oiidNg.js.map +1 -0
- package/dist/client/assets/index--kF4jVbp.css +1 -0
- package/dist/client/assets/index-DFJaEoi0.js +27 -0
- package/dist/client/assets/index-DFJaEoi0.js.map +1 -0
- package/dist/client/assets/index-UheDso2P.js +2 -0
- package/dist/client/assets/index-UheDso2P.js.map +1 -0
- package/dist/client/assets/preview-CWdUATNl.js +4 -0
- package/dist/client/assets/preview-CWdUATNl.js.map +1 -0
- package/dist/client/assets/useQualityAnalysis-Cl4QPeOT.js +6 -0
- package/dist/client/assets/useQualityAnalysis-Cl4QPeOT.js.map +1 -0
- package/dist/client/index.html +2 -2
- package/dist/client/templates/client-report-blocks.docx.json +791 -0
- package/dist/client/templates/consulting-deck-blocks.pptx.json +455 -0
- package/dist/client/templates/data-report-presentation.pptx.json +108 -36
- package/dist/client/templates/management-plan.pptx.json +100 -22
- package/dist/client/templates/minimalist-pitch-deck.pptx.json +172 -101
- package/dist/prompts/instructions-edit-document-pptx-blocks.md +77 -0
- package/dist/prompts/instructions-edit-document-pptx-slides.md +15 -21
- package/dist/prompts/instructions-edit-document-pptx.md +34 -53
- package/dist/prompts/instructions-edit-pptx.md +9 -8
- package/dist/prompts/instructions-generate-pptx.md +13 -17
- package/dist/prompts/pptx-core.md +104 -127
- package/dist/prompts/pptx-design.md +115 -109
- package/package.json +10 -9
- package/dist/client/assets/HomePage-mtUb6jxc.js +0 -251
- package/dist/client/assets/HomePage-mtUb6jxc.js.map +0 -1
- package/dist/client/assets/_virtual_jto-sandbox-runtime-Dqq17bow.js +0 -2
- package/dist/client/assets/_virtual_jto-sandbox-runtime-Dqq17bow.js.map +0 -1
- package/dist/client/assets/editor-ZbEHVEFs.js +0 -16
- package/dist/client/assets/editor-ZbEHVEFs.js.map +0 -1
- package/dist/client/assets/editor-monaco-json-FaaVfftD.js +0 -24
- package/dist/client/assets/editor-monaco-json-FaaVfftD.js.map +0 -1
- package/dist/client/assets/editor-refs-store-DAEAPqEk.js +0 -2
- package/dist/client/assets/editor-refs-store-DAEAPqEk.js.map +0 -1
- package/dist/client/assets/index-Bj6ZAKUc.css +0 -1
- package/dist/client/assets/index-DRbATnbJ.js +0 -5
- package/dist/client/assets/index-DRbATnbJ.js.map +0 -1
- package/dist/client/assets/preview-CM2ywF-8.js +0 -4
- package/dist/client/assets/preview-CM2ywF-8.js.map +0 -1
- package/dist/client/assets/useQualityAnalysis-ClgkaIc2.js +0 -6
- package/dist/client/assets/useQualityAnalysis-ClgkaIc2.js.map +0 -1
- package/dist/prompts/instructions-edit-document-pptx-templates.md +0 -63
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/editor-CwEocOY2.js","assets/react-vendor-BmQ2Ko_D.js","assets/editor-monaco-json-D_oiidNg.js","assets/index-DFJaEoi0.js","assets/query-vendor--rhYD8mC.js","assets/radix-ui-BzbaiLpZ.js","assets/ui-vendor-BsAtAN16.js","assets/monaco-editor-DJsdM0WK.js","assets/state-vendor-Cq67_JbF.js","assets/index--kF4jVbp.css","assets/index-UheDso2P.js","assets/MonacoPluginProvider-Dbv1PrO2.js","assets/useQualityAnalysis-Cl4QPeOT.js","assets/preview-CWdUATNl.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var lg=Object.defineProperty;var cg=(e,t,n)=>t in e?lg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Or=(e,t,n)=>cg(e,typeof t!="symbol"?t+"":t,n);import{r as g,j as l,c as je,R as nd,g as ga}from"./react-vendor-BmQ2Ko_D.js";import{u as vn,s as rd,p as ug,a as ke,T as xa,v as dg,i as fg,b as Io,c as qs,d as an,g as pg,e as Jt,B as hg,f as gr,h as id,j as mg,k as gg,S as xg,O as yg,l as bg,M as vg,D as wg,m as kg}from"./MonacoPluginProvider-Dbv1PrO2.js";import{A as Sg,F as at,c as W,u as _r,S as cn,a as oi,T as Oi,C as jg,E as _g,b as Ng,d as Cg,e as Ye,f as Xe,g as Qe,p as Eg,h as sd,i as od,_ as ad,j as Pi,k as Tg,l as Ig,m as Ag,n as Pr,s as Gs,W as ld,o as Hi}from"./index-DFJaEoi0.js";import{b as cd,c as ya,d as ud,e as js,f as _s,D as Ns,O as Cs,g as zg,V as Og,G as Pg,h as dd,I as Dg,i as Rg,j as fd,k as $g,l as pd,m as Mg,n as Fg,L as hd,S as md,o as gd,p as xd,q as yd,r as Nr,s as Lg,t as Bg,u as Zg,v as bd,w as vd,x as wd,y as kd,z as Sd,B as jd,E as _d,F as Nd,H as Cd,J as Vg,K as Ug,M as Jg,N as Ed,Q as Td,U as Id,W as Ad,X as zd,Y as Od,Z as Pd,_ as Dd,$ as Rd,a0 as $d,a1 as Hg,a2 as Md,a3 as Wg,a4 as qg,a5 as Fd,a6 as Gg,a7 as Kg,a8 as Yg,a9 as Xg,aa as Ld,ab as Bd,ac as Zd}from"./radix-ui-BzbaiLpZ.js";import{X as wn,C as ki,a as un,b as Qg,d as Si,G as Vd,F as ex,e as Cr,f as Ud,P as tx,g as nx,h as Jd,i as Hd,E as ba,B as Qi,H as rx,T as Ao,L as zo,j as ix,k as sx,S as Wd,I as ox,l as ax,m as Oo,n as lx,o as cx,p as ux,q as dx,r as fx,s as px,t as hx,u as mx,v as Es,w as gx,M as xx,x as Dt,y as qd,z as yx,A as bx,D as vx,J as wx,K as Gd,N as kx,O as Sx,Q as jx,R as _x,U as Nx,V as Cx,W as Kd,Y as Ex,Z as Po,_ as va,$ as Yd,a0 as Tx,a1 as Xd,a2 as Jr,a3 as Ix,a4 as Ax,a5 as zx,a6 as gl,a7 as Do}from"./ui-vendor-BsAtAN16.js";import{B as Ce,d as xl}from"./index-UheDso2P.js";import{u as wa,a as Ox,d as Px,p as Dx,b as Rx,e as $x}from"./state-vendor-Cq67_JbF.js";import{b as Mx}from"./query-vendor--rhYD8mC.js";let Di=null,Dr=null;const Fx=1e4;function Lx(e,t){return t.aborted?Promise.reject(yl(t)):new Promise((n,r)=>{const i=()=>r(yl(t));t.addEventListener("abort",i,{once:!0}),e.then(n,r).finally(()=>{t.removeEventListener("abort",i)})})}function yl(e){return e.reason??new DOMException("Aborted","AbortError")}async function Bx(e){return Di||(Dr||(Dr=(async()=>{const t=await fetch(`${Sg}/discovery/themes/builtin`,{signal:AbortSignal.timeout(Fx)});if(!t.ok)throw new Error(`Built-in themes unavailable (${t.status})`);const n=await t.json();if(!n.success||!n.data)throw new Error(n.error??"Built-in themes unavailable");return Di=n.data,Di})().finally(()=>{Dr=null})),e?Lx(Dr,e):Dr)}class hn extends Error{constructor(n,r,i){super(n);Or(this,"pluginName");Or(this,"path");this.name="PluginExpansionError",this.pluginName=r,this.path=i}}const Zx=20,Vx=1e4;function ai(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function bl(e,t){const n=new Set;if(t.size===0)return n;const r=i=>{if(Array.isArray(i)){i.forEach(r);return}ai(i)&&(typeof i.name=="string"&&t.has(i.name)&&n.add(i.name),Array.isArray(i.children)&&i.children.forEach(r))};return ai(e)&&Array.isArray(e.children)&&e.children.forEach(r),n}const Ux=/^https?:\/\/\S+/i;function es(e,t=new Set){if(typeof e=="string")Ux.test(e)&&t.add(e);else if(Array.isArray(e))for(const n of e)es(n,t);else if(ai(e))for(const n of Object.values(e))es(n,t);return t}function Jx(e,t){if(!e.startsWith("/")||t.size===0)return{path:e,insidePlugin:!1};const n=e.split("/");for(let r=n.length;r>1;r--){const i=n.slice(0,r).join("/"),s=t.get(i);if(!s)continue;if(s.synthetic)return{path:s.authored,insidePlugin:!0};const o=n.slice(r).join("/");return{path:o?`${s.authored}/${o}`:s.authored,insidePlugin:!1}}return{path:e,insidePlugin:!1}}async function Hx(e,t){const{plugins:n,theme:r,render:i,signal:s}=t,o=t.maxDepth??Zx,a=t.maxNodes??Vx,c=[],u=new Map,d=es(e);let f=0;function h(v){if(s!=null&&s.aborted)throw new hn("Expansion was cancelled",void 0,v)}async function p(v,k,y,_,x){if(k>o)throw new hn(`Maximum component nesting depth exceeded (${o}). Check for circular component references.`,void 0,y);const A=[],E=(w,S,O)=>{const B=`${_}/${A.length}`;return(O||B!==S)&&u.set(B,{authored:S,synthetic:O}),A.push(w),B};for(let w=0;w<v.length;w++){h(y);const S=v[w],O=x??`${y}/${w}`,B=x!==void 0;if(!ai(S)||typeof S.name!="string"){E(S,O,B);continue}const N=n.get(S.name);if(!N){if(Array.isArray(S.children)){const P=`${_}/${A.length}`,J=await p(S.children,k+1,`${O}/children`,`${P}/children`,B?x:void 0);E({...S,children:J},O,B)}else E(S,O,B);continue}if(S.enabled===!1)continue;if(S.props===void 0||S.props===null)throw new hn(`Custom component '${S.name}' must have a 'props' property. Use format: { name: '${S.name}', props: {...} }`,S.name,O);const R=typeof S.version=="string"?S.version:void 0;if(R!==void 0&&!N.versions.includes(R))throw new hn(`Component "${S.name}" does not have version "${R}". Available versions: ${N.versions.join(", ")}`,S.name,O);const T=Array.isArray(S.children)?await p(S.children,k+1,`${O}/children`,`${O}/children`,O):void 0,F=R?`${S.name}@${R}`:S.name;let $;try{$=await i({name:S.name,version:R,props:S.props,theme:r,children:T},s)}catch(P){throw s!=null&&s.aborted?P:new hn(`Error processing custom component '${S.name}': ${P instanceof Error?P.message:String(P)}`,S.name,O)}for(const P of $.warnings??[])c.push({component:F,message:P.message,severity:"warning",...P.context?{context:P.context}:{}});if(!Array.isArray($.components))throw new hn(`Custom component '${S.name}' must render an array of components.`,S.name,O);for(const P of es($.components))d.has(P)||c.push({component:F,message:`Plugin output references a remote source the document did not: ${P}`,severity:"warning",context:{code:"PLUGIN_REMOTE_SOURCE",url:P,path:O}});if(f+=$.components.length,f>a)throw new hn(`Plugin expansion produced more than ${a} components; stopping at '${S.name}'.`,S.name,O);const Z=await p($.components,k+1,O,_,O);for(const P of Z)E(P,O,!0)}return A}if(!ai(e)||!Array.isArray(e.children))return{document:e,warnings:c,pathMap:u};const m=await p(e.children,0,"/children","/children",void 0);return{document:{...e,children:m},warnings:c,pathMap:u}}function mt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Wx(e,t){if(!mt(t))return e;const n=mt(e.fonts)?e.fonts:{},r={...n};if(mt(t.fonts))for(const[o,a]of Object.entries(t.fonts)){const c=n[o],u=mt(c)?c:{};r[o]=mt(a)?{...u,...a}:a}const i=mt(e.styles)?e.styles:{},s={...i};if(mt(t.styles))for(const[o,a]of Object.entries(t.styles)){const c=i[o],u=mt(c)?c:{};s[o]=mt(a)?{...u,...a}:a}return{...e,colors:{...mt(e.colors)?e.colors:{},...mt(t.colors)?t.colors:{}},fonts:r,...Object.keys(s).length>0?{styles:s}:{}}}const vl={docx:"minimal",pptx:"default"};function qx(e,t){const{format:n,customThemes:r,builtinThemes:i}=t,s=mt(e)&&mt(e.props)?e.props:{},o=s.theme;if(n==="pptx"&&mt(o))return{theme:o};const a=typeof o=="string"&&o.length>0?o:vl[n];let c=r[a];if(c===void 0&&n==="docx"){const f=a.toLowerCase(),h=Object.keys(r).find(p=>p.toLowerCase()===f);h&&(c=r[h])}c===void 0&&(c=i[a]);let u;if(c===void 0){const f=vl[n],h=[...Object.keys(i),...Object.keys(r)].sort();u={message:`Theme "${a}" not found; falling back to "${f}". Available themes: ${h.join(", ")}.`,context:{code:"theme_not_found",requested:a,available:h}},c=i[f]}c===void 0&&(c=Object.values(i)[0]??{});const d=n==="docx"&&mt(c)&&s.themeOverrides?Wx(c,s.themeOverrides):c;return u?{theme:d,warning:u}:{theme:d}}const Ks=e=>({path:e,insidePlugin:!1});function Gx(e){if(!e.enabled)return"is turned off — enable it in the plugin header or the sidebar";if(e.status==="compiling"||e.status==="idle")return"is still compiling — try again in a moment";const t=e.diagnostics.filter(n=>n.severity==="error");return t.length>0?`has ${t.length} error${t.length===1?"":"s"} — open ${e.docName} to fix ${t.length===1?"it":"them"}`:`failed to load — open ${e.docName}`}async function Ro(e,t={}){var y;const n=vn.getState(),r=rd(n),i=Object.values(n.records).filter(_=>_.metadata);if(i.length===0)return{text:e,warnings:[],expanded:!1,remap:Ks};let s;try{s=JSON.parse(e)}catch{return{text:e,warnings:[],expanded:!1,remap:Ks}}const o=new Set(r.map(_=>_.metadata.name)),a=new Map;for(const _ of i){const x=_.metadata.name;!o.has(x)&&!a.has(x)&&a.set(x,_)}const c=bl(s,new Set(a.keys()));if(c.size>0){const[_]=c,x=a.get(_);throw new hn(`"${_}" is a browser plugin that ${Gx(x)}.`,_)}if(bl(s,o).size===0)return{text:e,warnings:[],expanded:!1,remap:Ks};const d=new Map,f=new Map;for(const _ of r)d.set(_.metadata.name,{name:_.metadata.name,versions:_.metadata.versions.map(x=>x.version)}),f.set(_.metadata.name,_.docName);let h={};try{h=await Bx(t.signal)}catch(_){if((y=t.signal)!=null&&y.aborted)throw _}const p=qx(s,{format:at,customThemes:t.customThemes??{},builtinThemes:h}),m=await Hx(s,{plugins:d,theme:p.theme,signal:t.signal,render:(_,x)=>ug.render(f.get(_.name),_,x)}),v=p.warning?[{component:"theme",message:p.warning.message,severity:"warning",context:p.warning.context},...m.warnings]:m.warnings,k=m.pathMap;return{text:JSON.stringify(m.document,null,2),warnings:v,expanded:!0,remap:_=>Jx(_,k)}}const ct=cd,Kx=ud,wl=ya,Qd=g.forwardRef(({className:e,...t},n)=>l.jsx(Cs,{ref:n,className:W("fixed inset-0 z-50 bg-black/50",e),...t}));Qd.displayName=Cs.displayName;const lt=g.forwardRef(({className:e,children:t,...n},r)=>l.jsxs(Kx,{children:[l.jsx(Qd,{}),l.jsxs(js,{ref:r,className:W("bg-background fixed top-[50%] left-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border p-6 shadow-lg sm:rounded-lg",e),...n,children:[t,l.jsxs(ya,{className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 cursor-pointer rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-none disabled:pointer-events-none",children:[l.jsx(wn,{className:"h-4 w-4"}),l.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));lt.displayName=js.displayName;const qt=({className:e,...t})=>l.jsx("div",{className:W("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});qt.displayName="DialogHeader";const kn=({className:e,...t})=>l.jsx("div",{className:W("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});kn.displayName="DialogFooter";const Gt=g.forwardRef(({className:e,...t},n)=>l.jsx(_s,{ref:n,className:W("text-lg leading-none font-semibold tracking-tight",e),...t}));Gt.displayName=_s.displayName;const dn=g.forwardRef(({className:e,...t},n)=>l.jsx(Ns,{ref:n,className:W("text-muted-foreground text-sm",e),...t}));dn.displayName=Ns.displayName;const li=zg,ef=Pg,ci=Og,xr=g.forwardRef(({className:e,children:t,...n},r)=>l.jsxs(dd,{ref:r,className:W("border-input ring-offset-background placeholder:text-muted-foreground focus:ring-ring flex min-h-9 w-full min-w-0 items-center justify-between gap-2 rounded-sm border bg-background px-3 py-2 text-sm shadow-xs focus:ring-1 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50 [&>span]:min-w-0 [&>span]:whitespace-normal [&>span]:break-words text-left cursor-pointer",e),...n,children:[t,l.jsx(Dg,{asChild:!0,children:l.jsx(ki,{className:"h-4 w-4 shrink-0 opacity-50"})})]}));xr.displayName=dd.displayName;const tf=g.forwardRef(({className:e,...t},n)=>l.jsx(md,{ref:n,className:W("flex cursor-default items-center justify-center py-1",e),...t,children:l.jsx(Qg,{className:"h-4 w-4"})}));tf.displayName=md.displayName;const nf=g.forwardRef(({className:e,...t},n)=>l.jsx(gd,{ref:n,className:W("flex cursor-default items-center justify-center py-1",e),...t,children:l.jsx(ki,{className:"h-4 w-4"})}));nf.displayName=gd.displayName;const yr=g.forwardRef(({className:e,children:t,position:n="popper",...r},i)=>l.jsx(Rg,{children:l.jsxs(fd,{ref:i,className:W("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-lg border shadow-md",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[l.jsx(tf,{}),l.jsx($g,{className:W("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),l.jsx(nf,{})]})}));yr.displayName=fd.displayName;const ka=g.forwardRef(({className:e,...t},n)=>l.jsx(hd,{ref:n,className:W("px-2 py-1.5 text-sm font-semibold",e),...t}));ka.displayName=hd.displayName;const Mn=g.forwardRef(({className:e,children:t,...n},r)=>l.jsxs(pd,{ref:r,className:W("focus:bg-accent focus:text-accent-foreground relative flex w-full cursor-pointer items-center rounded-sm py-1.5 pr-8 pl-2 text-sm outline-none select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[l.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:l.jsx(Mg,{children:l.jsx(un,{className:"h-4 w-4"})})}),l.jsx(Fg,{children:t})]}));Mn.displayName=pd.displayName;const Yx=g.forwardRef(({className:e,...t},n)=>l.jsx(xd,{ref:n,className:W("bg-muted -mx-1 my-1 h-px",e),...t}));Yx.displayName=xd.displayName;const br=g.forwardRef(({className:e,type:t,...n},r)=>l.jsx("input",{type:t,className:W("border-input file:text-foreground placeholder:text-muted-foreground focus-visible:ring-ring flex h-9 w-full rounded-sm border bg-background px-3 py-1 text-sm shadow-xs transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium focus-visible:ring-1 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",e),ref:r,...n}));br.displayName="Input";const Xx=Si("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Xr=g.forwardRef(({className:e,...t},n)=>l.jsx(yd,{ref:n,className:W(Xx(),e),...t}));Xr.displayName=yd.displayName;const Qx=Si("inline-flex items-center rounded-md border px-2.5 py-1 text-xs font-medium transition-colors focus:outline-none",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground",secondary:"border-transparent bg-secondary text-secondary-foreground",destructive:"border-transparent bg-destructive text-destructive-foreground",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function tn({className:e,variant:t,...n}){return l.jsx("div",{className:W(Qx({variant:t}),e),...n})}const ey=({open:e,onOpenChange:t})=>{const{documents:n,documentTypes:r,activeTab:i,createDocument:s,openDocument:o}=ke(wa(T=>({documents:T.documents,documentTypes:T.documentTypes,activeTab:T.activeTab,createDocument:T.createDocument,openDocument:T.openDocument}))),a=g.useContext(xa),{toast:c}=_r(),u=g.useMemo(()=>n.filter(T=>r[T.name]!=="application/json+theme"),[n,r]),[d,f]=g.useState(""),[h,p]=g.useState(""),[m,v]=g.useState("playground"),[k,y]=g.useState(!1),[_,x]=g.useState(null),[A,E]=g.useState(null),[w,S]=g.useState(null),O=()=>{x(null),E(null),S(null)};g.useEffect(()=>{if(!e)return;x(null),E(null),S(null);const T=u.map($=>$.name),F=T.includes(i)?i:T[0]??"";p(F),f(T.find($=>$!==F)??"")},[e]);const B=async()=>{const T=u.find($=>$.name===d),F=u.find($=>$.name===h);if(!(!T||!F)){y(!0),x(null),E(null),S(null);try{const $=a?dg(a.getState().customThemes):{},[Z,P]=await Promise.all([Ro(T.text,{customThemes:$}),Ro(F.text,{customThemes:$})]),J=await fetch(oi.diff,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldDefinition:Z.text,newDefinition:P.text,options:{author:m||"playground"}})}),V=await J.json();if(!J.ok||!V.success){const X=Array.isArray(V.errors)?`: ${V.errors.slice(0,3).map(j=>j.message||String(j)).join("; ")}`:"";throw new Error((V.error||`Diff failed (${J.status})`)+X)}E(V.data.summary),S(V.data.document)}catch($){x($ instanceof Error?$.message:"Diff failed")}finally{y(!1)}}},N=()=>{if(!w)return;const T=new Set(n.map(Z=>Z.name));let F=`${h}-redline`,$=2;for(;T.has(F);)F=`${h}-redline-${$++}`;s(F,JSON.stringify(w,null,2)),o(F),c({title:`Redline created: ${F}`}),t(!1)},R=A?A.tracked.modified+A.tracked.inserted+A.tracked.deleted:0;return l.jsx(ct,{open:e,onOpenChange:t,children:l.jsxs(lt,{className:"sm:max-w-[560px]",children:[l.jsxs(qt,{children:[l.jsxs(Gt,{className:"flex items-center gap-2",children:[l.jsx(Vd,{className:"size-4"}),"Compare documents"]}),l.jsx(dn,{children:"Diff two versions into a redline with native Word tracked changes (accept/reject in Word)."})]}),l.jsxs("div",{className:"grid gap-4 py-2",children:[l.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[l.jsxs("div",{className:"grid gap-1.5",children:[l.jsx(Xr,{htmlFor:"diff-base",children:"Base (old)"}),l.jsxs(li,{value:d,onValueChange:T=>{f(T),O()},children:[l.jsx(xr,{id:"diff-base",children:l.jsx(ci,{placeholder:"Select document"})}),l.jsx(yr,{children:u.map(T=>l.jsx(Mn,{value:T.name,children:T.name},T.name))})]})]}),l.jsxs("div",{className:"grid gap-1.5",children:[l.jsx(Xr,{htmlFor:"diff-revised",children:"Revised (new)"}),l.jsxs(li,{value:h,onValueChange:T=>{p(T),O()},children:[l.jsx(xr,{id:"diff-revised",children:l.jsx(ci,{placeholder:"Select document"})}),l.jsx(yr,{children:u.map(T=>l.jsx(Mn,{value:T.name,children:T.name},T.name))})]})]})]}),l.jsxs("div",{className:"grid gap-1.5",children:[l.jsx(Xr,{htmlFor:"diff-author",children:"Revision author"}),l.jsx(br,{id:"diff-author",value:m,onChange:T=>{v(T.target.value),O()},placeholder:"playground"})]}),_&&l.jsx("p",{className:"text-sm text-destructive",role:"alert",children:_}),A&&l.jsxs("div",{className:"rounded-md border p-3 text-sm grid gap-2",children:[l.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[l.jsxs(tn,{variant:"secondary",children:[A.tracked.inserted," inserted"]}),l.jsxs(tn,{variant:"secondary",children:[A.tracked.deleted," deleted"]}),l.jsxs(tn,{variant:"secondary",children:[A.tracked.modified," modified"]}),l.jsxs("span",{className:"text-muted-foreground text-xs",children:[A.unchangedBlocks," blocks unchanged"]})]}),R===0&&A.untracked.length===0&&l.jsx("p",{className:"text-muted-foreground",children:"The documents are identical."}),A.untracked.length>0&&l.jsxs("div",{className:"grid gap-1 max-h-32 overflow-y-auto",children:[l.jsxs("p",{className:"font-medium text-warning-bg-foreground",children:[A.untracked.length," change(s) not expressible as tracked changes:"]}),A.untracked.map((T,F)=>l.jsxs("p",{className:"text-xs text-muted-foreground",children:[T.path," [",T.component,"] ",T.detail]},F))]}),A.notes.map((T,F)=>l.jsxs("p",{className:"text-xs text-muted-foreground",children:["Note: ",T]},F))]})]}),l.jsx(kn,{children:A&&R+A.untracked.length>0?l.jsxs(Ce,{onClick:N,children:[l.jsx(ex,{className:"size-4 mr-1"}),"Open redline"]}):l.jsxs(Ce,{onClick:B,disabled:k||!d||!h||d===h,children:[k&&l.jsx(cn,{className:"size-4 mr-1"}),"Compare"]})})]})})};var ji=e=>e.type==="checkbox",On=e=>e instanceof Date,gt=e=>e==null;const rf=e=>typeof e=="object";var nt=e=>!gt(e)&&!Array.isArray(e)&&rf(e)&&!On(e),sf=e=>nt(e)&&e.target?ji(e.target)?e.target.checked:e.target.value:e,ty=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,of=(e,t)=>e.has(ty(t)),ny=e=>{const t=e.constructor&&e.constructor.prototype;return nt(t)&&t.hasOwnProperty("isPrototypeOf")},Sa=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function wt(e){let t;const n=Array.isArray(e),r=typeof FileList<"u"?e instanceof FileList:!1;if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set(e);else if(!(Sa&&(e instanceof Blob||r))&&(n||nt(e)))if(t=n?[]:{},!n&&!ny(e))t=e;else for(const i in e)e.hasOwnProperty(i)&&(t[i]=wt(e[i]));else return e;return t}var Ts=e=>Array.isArray(e)?e.filter(Boolean):[],tt=e=>e===void 0,ue=(e,t,n)=>{if(!t||!nt(e))return n;const r=Ts(t.split(/[,[\].]+?/)).reduce((i,s)=>gt(i)?i:i[s],e);return tt(r)||r===e?tt(e[t])?n:e[t]:r},Rt=e=>typeof e=="boolean",ja=e=>/^\w*$/.test(e),af=e=>Ts(e.replace(/["|']|\]/g,"").split(/\.|\[/)),Le=(e,t,n)=>{let r=-1;const i=ja(t)?[t]:af(t),s=i.length,o=s-1;for(;++r<s;){const a=i[r];let c=n;if(r!==o){const u=e[a];c=nt(u)||Array.isArray(u)?u:isNaN(+i[r+1])?{}:[]}if(a==="__proto__"||a==="constructor"||a==="prototype")return;e[a]=c,e=e[a]}return e};const ts={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},Ut={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},sn={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},lf=je.createContext(null),Is=()=>je.useContext(lf),ry=e=>{const{children:t,...n}=e;return je.createElement(lf.Provider,{value:n},t)};var cf=(e,t,n,r=!0)=>{const i={defaultValues:t._defaultValues};for(const s in e)Object.defineProperty(i,s,{get:()=>{const o=s;return t._proxyFormState[o]!==Ut.all&&(t._proxyFormState[o]=!r||Ut.all),n&&(n[o]=!0),e[o]}});return i},kt=e=>nt(e)&&!Object.keys(e).length,uf=(e,t,n,r)=>{n(e);const{name:i,...s}=e;return kt(s)||Object.keys(s).length>=Object.keys(t).length||Object.keys(s).find(o=>t[o]===(!r||Ut.all))},Qr=e=>Array.isArray(e)?e:[e],df=(e,t,n)=>!e||!t||e===t||Qr(e).some(r=>r&&(n?r===t:r.startsWith(t)||t.startsWith(r)));function _a(e){const t=je.useRef(e);t.current=e,je.useEffect(()=>{const n=!e.disabled&&t.current.subject&&t.current.subject.subscribe({next:t.current.next});return()=>{n&&n.unsubscribe()}},[e.disabled])}function iy(e){const t=Is(),{control:n=t.control,disabled:r,name:i,exact:s}=e||{},[o,a]=je.useState(n._formState),c=je.useRef(!0),u=je.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1}),d=je.useRef(i);return d.current=i,_a({disabled:r,next:f=>c.current&&df(d.current,f.name,s)&&uf(f,u.current,n._updateFormState)&&a({...n._formState,...f}),subject:n._subjects.state}),je.useEffect(()=>(c.current=!0,u.current.isValid&&n._updateValid(!0),()=>{c.current=!1}),[n]),je.useMemo(()=>cf(o,n,u.current,!1),[o,n])}var en=e=>typeof e=="string",ff=(e,t,n,r,i)=>en(e)?(r&&t.watch.add(e),ue(n,e,i)):Array.isArray(e)?e.map(s=>(r&&t.watch.add(s),ue(n,s))):(r&&(t.watchAll=!0),n);function sy(e){const t=Is(),{control:n=t.control,name:r,defaultValue:i,disabled:s,exact:o}=e||{},a=je.useRef(r);a.current=r,_a({disabled:s,subject:n._subjects.values,next:d=>{df(a.current,d.name,o)&&u(wt(ff(a.current,n._names,d.values||n._formValues,!1,i)))}});const[c,u]=je.useState(n._getWatch(r,i));return je.useEffect(()=>n._removeUnmounted()),c}function oy(e){const t=Is(),{name:n,disabled:r,control:i=t.control,shouldUnregister:s}=e,o=of(i._names.array,n),a=sy({control:i,name:n,defaultValue:ue(i._formValues,n,ue(i._defaultValues,n,e.defaultValue)),exact:!0}),c=iy({control:i,name:n,exact:!0}),u=je.useRef(i.register(n,{...e.rules,value:a,...Rt(e.disabled)?{disabled:e.disabled}:{}})),d=je.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!ue(c.errors,n)},isDirty:{enumerable:!0,get:()=>!!ue(c.dirtyFields,n)},isTouched:{enumerable:!0,get:()=>!!ue(c.touchedFields,n)},isValidating:{enumerable:!0,get:()=>!!ue(c.validatingFields,n)},error:{enumerable:!0,get:()=>ue(c.errors,n)}}),[c,n]),f=je.useMemo(()=>({name:n,value:a,...Rt(r)||c.disabled?{disabled:c.disabled||r}:{},onChange:h=>u.current.onChange({target:{value:sf(h),name:n},type:ts.CHANGE}),onBlur:()=>u.current.onBlur({target:{value:ue(i._formValues,n),name:n},type:ts.BLUR}),ref:h=>{const p=ue(i._fields,n);p&&h&&(p._f.ref={focus:()=>h.focus(),select:()=>h.select(),setCustomValidity:m=>h.setCustomValidity(m),reportValidity:()=>h.reportValidity()})}}),[n,i._formValues,r,c.disabled,a,i._fields]);return je.useEffect(()=>{const h=i._options.shouldUnregister||s,p=(m,v)=>{const k=ue(i._fields,m);k&&k._f&&(k._f.mount=v)};if(p(n,!0),h){const m=wt(ue(i._options.defaultValues,n));Le(i._defaultValues,n,m),tt(ue(i._formValues,n))&&Le(i._formValues,n,m)}return!o&&i.register(n),()=>{(o?h&&!i._state.action:h)?i.unregister(n):p(n,!1)}},[n,i,o,s]),je.useEffect(()=>{i._updateDisabledField({disabled:r,fields:i._fields,name:n})},[r,n,i]),je.useMemo(()=>({field:f,formState:c,fieldState:d}),[f,c,d])}const ay=e=>e.render(oy(e));var ly=(e,t,n,r,i)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:i||!0}}:{},kl=e=>({isOnSubmit:!e||e===Ut.onSubmit,isOnBlur:e===Ut.onBlur,isOnChange:e===Ut.onChange,isOnAll:e===Ut.all,isOnTouch:e===Ut.onTouched}),Sl=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some(r=>e.startsWith(r)&&/^\.\w+/.test(e.slice(r.length))));const ei=(e,t,n,r)=>{for(const i of n||Object.keys(e)){const s=ue(e,i);if(s){const{_f:o,...a}=s;if(o){if(o.refs&&o.refs[0]&&t(o.refs[0],i)&&!r)return!0;if(o.ref&&t(o.ref,o.name)&&!r)return!0;if(ei(a,t))break}else if(nt(a)&&ei(a,t))break}}};var cy=(e,t,n)=>{const r=Qr(ue(e,n));return Le(r,"root",t[n]),Le(e,n,r),e},Na=e=>e.type==="file",Qt=e=>typeof e=="function",ns=e=>{if(!Sa)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},Wi=e=>en(e),Ca=e=>e.type==="radio",rs=e=>e instanceof RegExp;const jl={value:!1,isValid:!1},_l={value:!0,isValid:!0};var pf=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter(n=>n&&n.checked&&!n.disabled).map(n=>n.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!tt(e[0].attributes.value)?tt(e[0].value)||e[0].value===""?_l:{value:e[0].value,isValid:!0}:_l:jl}return jl};const Nl={isValid:!1,value:null};var hf=e=>Array.isArray(e)?e.reduce((t,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:t,Nl):Nl;function Cl(e,t,n="validate"){if(Wi(e)||Array.isArray(e)&&e.every(Wi)||Rt(e)&&!e)return{type:n,message:Wi(e)?e:"",ref:t}}var Jn=e=>nt(e)&&!rs(e)?e:{value:e,message:""},El=async(e,t,n,r,i,s)=>{const{ref:o,refs:a,required:c,maxLength:u,minLength:d,min:f,max:h,pattern:p,validate:m,name:v,valueAsNumber:k,mount:y}=e._f,_=ue(n,v);if(!y||t.has(v))return{};const x=a?a[0]:o,A=T=>{i&&x.reportValidity&&(x.setCustomValidity(Rt(T)?"":T||""),x.reportValidity())},E={},w=Ca(o),S=ji(o),O=w||S,B=(k||Na(o))&&tt(o.value)&&tt(_)||ns(o)&&o.value===""||_===""||Array.isArray(_)&&!_.length,N=ly.bind(null,v,r,E),R=(T,F,$,Z=sn.maxLength,P=sn.minLength)=>{const J=T?F:$;E[v]={type:T?Z:P,message:J,ref:o,...N(T?Z:P,J)}};if(s?!Array.isArray(_)||!_.length:c&&(!O&&(B||gt(_))||Rt(_)&&!_||S&&!pf(a).isValid||w&&!hf(a).isValid)){const{value:T,message:F}=Wi(c)?{value:!!c,message:c}:Jn(c);if(T&&(E[v]={type:sn.required,message:F,ref:x,...N(sn.required,F)},!r))return A(F),E}if(!B&&(!gt(f)||!gt(h))){let T,F;const $=Jn(h),Z=Jn(f);if(!gt(_)&&!isNaN(_)){const P=o.valueAsNumber||_&&+_;gt($.value)||(T=P>$.value),gt(Z.value)||(F=P<Z.value)}else{const P=o.valueAsDate||new Date(_),J=j=>new Date(new Date().toDateString()+" "+j),V=o.type=="time",X=o.type=="week";en($.value)&&_&&(T=V?J(_)>J($.value):X?_>$.value:P>new Date($.value)),en(Z.value)&&_&&(F=V?J(_)<J(Z.value):X?_<Z.value:P<new Date(Z.value))}if((T||F)&&(R(!!T,$.message,Z.message,sn.max,sn.min),!r))return A(E[v].message),E}if((u||d)&&!B&&(en(_)||s&&Array.isArray(_))){const T=Jn(u),F=Jn(d),$=!gt(T.value)&&_.length>+T.value,Z=!gt(F.value)&&_.length<+F.value;if(($||Z)&&(R($,T.message,F.message),!r))return A(E[v].message),E}if(p&&!B&&en(_)){const{value:T,message:F}=Jn(p);if(rs(T)&&!_.match(T)&&(E[v]={type:sn.pattern,message:F,ref:o,...N(sn.pattern,F)},!r))return A(F),E}if(m){if(Qt(m)){const T=await m(_,n),F=Cl(T,x);if(F&&(E[v]={...F,...N(sn.validate,F.message)},!r))return A(F.message),E}else if(nt(m)){let T={};for(const F in m){if(!kt(T)&&!r)break;const $=Cl(await m[F](_,n),x,F);$&&(T={...$,...N(F,$.message)},A($.message),r&&(E[v]=T))}if(!kt(T)&&(E[v]={ref:x,...T},!r))return E}}return A(!0),E};function uy(e,t){const n=t.slice(0,-1).length;let r=0;for(;r<n;)e=tt(e)?r++:e[t[r++]];return e}function dy(e){for(const t in e)if(e.hasOwnProperty(t)&&!tt(e[t]))return!1;return!0}function st(e,t){const n=Array.isArray(t)?t:ja(t)?[t]:af(t),r=n.length===1?e:uy(e,n),i=n.length-1,s=n[i];return r&&delete r[s],i!==0&&(nt(r)&&kt(r)||Array.isArray(r)&&dy(r))&&st(e,n.slice(0,-1)),e}var Ys=()=>{let e=[];return{get observers(){return e},next:i=>{for(const s of e)s.next&&s.next(i)},subscribe:i=>(e.push(i),{unsubscribe:()=>{e=e.filter(s=>s!==i)}}),unsubscribe:()=>{e=[]}}},$o=e=>gt(e)||!rf(e);function xn(e,t){if($o(e)||$o(t))return e===t;if(On(e)&&On(t))return e.getTime()===t.getTime();const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const i of n){const s=e[i];if(!r.includes(i))return!1;if(i!=="ref"){const o=t[i];if(On(s)&&On(o)||nt(s)&&nt(o)||Array.isArray(s)&&Array.isArray(o)?!xn(s,o):s!==o)return!1}}return!0}var mf=e=>e.type==="select-multiple",fy=e=>Ca(e)||ji(e),Xs=e=>ns(e)&&e.isConnected,gf=e=>{for(const t in e)if(Qt(e[t]))return!0;return!1};function is(e,t={}){const n=Array.isArray(e);if(nt(e)||n)for(const r in e)Array.isArray(e[r])||nt(e[r])&&!gf(e[r])?(t[r]=Array.isArray(e[r])?[]:{},is(e[r],t[r])):gt(e[r])||(t[r]=!0);return t}function xf(e,t,n){const r=Array.isArray(e);if(nt(e)||r)for(const i in e)Array.isArray(e[i])||nt(e[i])&&!gf(e[i])?tt(t)||$o(n[i])?n[i]=Array.isArray(e[i])?is(e[i],[]):{...is(e[i])}:xf(e[i],gt(t)?{}:t[i],n[i]):n[i]=!xn(e[i],t[i]);return n}var Rr=(e,t)=>xf(e,t,is(t)),yf=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>tt(e)?e:t?e===""?NaN:e&&+e:n&&en(e)?new Date(e):r?r(e):e;function Qs(e){const t=e.ref;return Na(t)?t.files:Ca(t)?hf(e.refs).value:mf(t)?[...t.selectedOptions].map(({value:n})=>n):ji(t)?pf(e.refs).value:yf(tt(t.value)?e.ref.value:t.value,e)}var py=(e,t,n,r)=>{const i={};for(const s of e){const o=ue(t,s);o&&Le(i,s,o._f)}return{criteriaMode:n,names:[...e],fields:i,shouldUseNativeValidation:r}},$r=e=>tt(e)?e:rs(e)?e.source:nt(e)?rs(e.value)?e.value.source:e.value:e;const Tl="AsyncFunction";var hy=e=>!!e&&!!e.validate&&!!(Qt(e.validate)&&e.validate.constructor.name===Tl||nt(e.validate)&&Object.values(e.validate).find(t=>t.constructor.name===Tl)),my=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function Il(e,t,n){const r=ue(e,n);if(r||ja(n))return{error:r,name:n};const i=n.split(".");for(;i.length;){const s=i.join("."),o=ue(t,s),a=ue(e,s);if(o&&!Array.isArray(o)&&n!==s)return{name:n};if(a&&a.type)return{name:s,error:a};i.pop()}return{name:n}}var gy=(e,t,n,r,i)=>i.isOnAll?!1:!n&&i.isOnTouch?!(t||e):(n?r.isOnBlur:i.isOnBlur)?!e:(n?r.isOnChange:i.isOnChange)?e:!0,xy=(e,t)=>!Ts(ue(e,t)).length&&st(e,t);const yy={mode:Ut.onSubmit,reValidateMode:Ut.onChange,shouldFocusError:!0};function by(e={}){let t={...yy,...e},n={submitCount:0,isDirty:!1,isLoading:Qt(t.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1},r={},i=nt(t.defaultValues)||nt(t.values)?wt(t.defaultValues||t.values)||{}:{},s=t.shouldUnregister?{}:wt(i),o={action:!1,mount:!1,watch:!1},a={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},c,u=0;const d={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},f={values:Ys(),array:Ys(),state:Ys()},h=kl(t.mode),p=kl(t.reValidateMode),m=t.criteriaMode===Ut.all,v=C=>z=>{clearTimeout(u),u=setTimeout(C,z)},k=async C=>{if(!t.disabled&&(d.isValid||C)){const z=t.resolver?kt((await O()).errors):await N(r,!0);z!==n.isValid&&f.state.next({isValid:z})}},y=(C,z)=>{!t.disabled&&(d.isValidating||d.validatingFields)&&((C||Array.from(a.mount)).forEach(L=>{L&&(z?Le(n.validatingFields,L,z):st(n.validatingFields,L))}),f.state.next({validatingFields:n.validatingFields,isValidating:!kt(n.validatingFields)}))},_=(C,z=[],L,se,ie=!0,ee=!0)=>{if(se&&L&&!t.disabled){if(o.action=!0,ee&&Array.isArray(ue(r,C))){const me=L(ue(r,C),se.argA,se.argB);ie&&Le(r,C,me)}if(ee&&Array.isArray(ue(n.errors,C))){const me=L(ue(n.errors,C),se.argA,se.argB);ie&&Le(n.errors,C,me),xy(n.errors,C)}if(d.touchedFields&&ee&&Array.isArray(ue(n.touchedFields,C))){const me=L(ue(n.touchedFields,C),se.argA,se.argB);ie&&Le(n.touchedFields,C,me)}d.dirtyFields&&(n.dirtyFields=Rr(i,s)),f.state.next({name:C,isDirty:T(C,z),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else Le(s,C,z)},x=(C,z)=>{Le(n.errors,C,z),f.state.next({errors:n.errors})},A=C=>{n.errors=C,f.state.next({errors:n.errors,isValid:!1})},E=(C,z,L,se)=>{const ie=ue(r,C);if(ie){const ee=ue(s,C,tt(L)?ue(i,C):L);tt(ee)||se&&se.defaultChecked||z?Le(s,C,z?ee:Qs(ie._f)):Z(C,ee),o.mount&&k()}},w=(C,z,L,se,ie)=>{let ee=!1,me=!1;const we={name:C};if(!t.disabled){const U=!!(ue(r,C)&&ue(r,C)._f&&ue(r,C)._f.disabled);if(!L||se){d.isDirty&&(me=n.isDirty,n.isDirty=we.isDirty=T(),ee=me!==we.isDirty);const Y=U||xn(ue(i,C),z);me=!!(!U&&ue(n.dirtyFields,C)),Y||U?st(n.dirtyFields,C):Le(n.dirtyFields,C,!0),we.dirtyFields=n.dirtyFields,ee=ee||d.dirtyFields&&me!==!Y}if(L){const Y=ue(n.touchedFields,C);Y||(Le(n.touchedFields,C,L),we.touchedFields=n.touchedFields,ee=ee||d.touchedFields&&Y!==L)}ee&&ie&&f.state.next(we)}return ee?we:{}},S=(C,z,L,se)=>{const ie=ue(n.errors,C),ee=d.isValid&&Rt(z)&&n.isValid!==z;if(t.delayError&&L?(c=v(()=>x(C,L)),c(t.delayError)):(clearTimeout(u),c=null,L?Le(n.errors,C,L):st(n.errors,C)),(L?!xn(ie,L):ie)||!kt(se)||ee){const me={...se,...ee&&Rt(z)?{isValid:z}:{},errors:n.errors,name:C};n={...n,...me},f.state.next(me)}},O=async C=>{y(C,!0);const z=await t.resolver(s,t.context,py(C||a.mount,r,t.criteriaMode,t.shouldUseNativeValidation));return y(C),z},B=async C=>{const{errors:z}=await O(C);if(C)for(const L of C){const se=ue(z,L);se?Le(n.errors,L,se):st(n.errors,L)}else n.errors=z;return z},N=async(C,z,L={valid:!0})=>{for(const se in C){const ie=C[se];if(ie){const{_f:ee,...me}=ie;if(ee){const we=a.array.has(ee.name),U=ie._f&&hy(ie._f);U&&d.validatingFields&&y([se],!0);const Y=await El(ie,a.disabled,s,m,t.shouldUseNativeValidation&&!z,we);if(U&&d.validatingFields&&y([se]),Y[ee.name]&&(L.valid=!1,z))break;!z&&(ue(Y,ee.name)?we?cy(n.errors,Y,ee.name):Le(n.errors,ee.name,Y[ee.name]):st(n.errors,ee.name))}!kt(me)&&await N(me,z,L)}}return L.valid},R=()=>{for(const C of a.unMount){const z=ue(r,C);z&&(z._f.refs?z._f.refs.every(L=>!Xs(L)):!Xs(z._f.ref))&&Q(C)}a.unMount=new Set},T=(C,z)=>!t.disabled&&(C&&z&&Le(s,C,z),!xn(ye(),i)),F=(C,z,L)=>ff(C,a,{...o.mount?s:tt(z)?i:en(C)?{[C]:z}:z},L,z),$=C=>Ts(ue(o.mount?s:i,C,t.shouldUnregister?ue(i,C,[]):[])),Z=(C,z,L={})=>{const se=ue(r,C);let ie=z;if(se){const ee=se._f;ee&&(!ee.disabled&&Le(s,C,yf(z,ee)),ie=ns(ee.ref)&>(z)?"":z,mf(ee.ref)?[...ee.ref.options].forEach(me=>me.selected=ie.includes(me.value)):ee.refs?ji(ee.ref)?ee.refs.length>1?ee.refs.forEach(me=>(!me.defaultChecked||!me.disabled)&&(me.checked=Array.isArray(ie)?!!ie.find(we=>we===me.value):ie===me.value)):ee.refs[0]&&(ee.refs[0].checked=!!ie):ee.refs.forEach(me=>me.checked=me.value===ie):Na(ee.ref)?ee.ref.value="":(ee.ref.value=ie,ee.ref.type||f.values.next({name:C,values:{...s}})))}(L.shouldDirty||L.shouldTouch)&&w(C,ie,L.shouldTouch,L.shouldDirty,!0),L.shouldValidate&&j(C)},P=(C,z,L)=>{for(const se in z){const ie=z[se],ee=`${C}.${se}`,me=ue(r,ee);(a.array.has(C)||nt(ie)||me&&!me._f)&&!On(ie)?P(ee,ie,L):Z(ee,ie,L)}},J=(C,z,L={})=>{const se=ue(r,C),ie=a.array.has(C),ee=wt(z);Le(s,C,ee),ie?(f.array.next({name:C,values:{...s}}),(d.isDirty||d.dirtyFields)&&L.shouldDirty&&f.state.next({name:C,dirtyFields:Rr(i,s),isDirty:T(C,ee)})):se&&!se._f&&!gt(ee)?P(C,ee,L):Z(C,ee,L),Sl(C,a)&&f.state.next({...n}),f.values.next({name:o.mount?C:void 0,values:{...s}})},V=async C=>{o.mount=!0;const z=C.target;let L=z.name,se=!0;const ie=ue(r,L),ee=()=>z.type?Qs(ie._f):sf(C),me=we=>{se=Number.isNaN(we)||On(we)&&isNaN(we.getTime())||xn(we,ue(s,L,we))};if(ie){let we,U;const Y=ee(),ge=C.type===ts.BLUR||C.type===ts.FOCUS_OUT,_e=!my(ie._f)&&!t.resolver&&!ue(n.errors,L)&&!ie._f.deps||gy(ge,ue(n.touchedFields,L),n.isSubmitted,p,h),M=Sl(L,a,ge);Le(s,L,Y),ge?(ie._f.onBlur&&ie._f.onBlur(C),c&&c(0)):ie._f.onChange&&ie._f.onChange(C);const D=w(L,Y,ge,!1),xe=!kt(D)||M;if(!ge&&f.values.next({name:L,type:C.type,values:{...s}}),_e)return d.isValid&&(t.mode==="onBlur"&&ge?k():ge||k()),xe&&f.state.next({name:L,...M?{}:D});if(!ge&&M&&f.state.next({...n}),t.resolver){const{errors:de}=await O([L]);if(me(Y),se){const Me=Il(n.errors,r,L),Je=Il(de,r,Me.name||L);we=Je.error,L=Je.name,U=kt(de)}}else y([L],!0),we=(await El(ie,a.disabled,s,m,t.shouldUseNativeValidation))[L],y([L]),me(Y),se&&(we?U=!1:d.isValid&&(U=await N(r,!0)));se&&(ie._f.deps&&j(ie._f.deps),S(L,U,we,D))}},X=(C,z)=>{if(ue(n.errors,z)&&C.focus)return C.focus(),1},j=async(C,z={})=>{let L,se;const ie=Qr(C);if(t.resolver){const ee=await B(tt(C)?C:ie);L=kt(ee),se=C?!ie.some(me=>ue(ee,me)):L}else C?(se=(await Promise.all(ie.map(async ee=>{const me=ue(r,ee);return await N(me&&me._f?{[ee]:me}:me)}))).every(Boolean),!(!se&&!n.isValid)&&k()):se=L=await N(r);return f.state.next({...!en(C)||d.isValid&&L!==n.isValid?{}:{name:C},...t.resolver||!C?{isValid:L}:{},errors:n.errors}),z.shouldFocus&&!se&&ei(r,X,C?ie:a.mount),se},ye=C=>{const z={...o.mount?s:i};return tt(C)?z:en(C)?ue(z,C):C.map(L=>ue(z,L))},ce=(C,z)=>({invalid:!!ue((z||n).errors,C),isDirty:!!ue((z||n).dirtyFields,C),error:ue((z||n).errors,C),isValidating:!!ue(n.validatingFields,C),isTouched:!!ue((z||n).touchedFields,C)}),b=C=>{C&&Qr(C).forEach(z=>st(n.errors,z)),f.state.next({errors:C?n.errors:{}})},G=(C,z,L)=>{const se=(ue(r,C,{_f:{}})._f||{}).ref,ie=ue(n.errors,C)||{},{ref:ee,message:me,type:we,...U}=ie;Le(n.errors,C,{...U,...z,ref:se}),f.state.next({name:C,errors:n.errors,isValid:!1}),L&&L.shouldFocus&&se&&se.focus&&se.focus()},ne=(C,z)=>Qt(C)?f.values.subscribe({next:L=>C(F(void 0,z),L)}):F(C,z,!0),Q=(C,z={})=>{for(const L of C?Qr(C):a.mount)a.mount.delete(L),a.array.delete(L),z.keepValue||(st(r,L),st(s,L)),!z.keepError&&st(n.errors,L),!z.keepDirty&&st(n.dirtyFields,L),!z.keepTouched&&st(n.touchedFields,L),!z.keepIsValidating&&st(n.validatingFields,L),!t.shouldUnregister&&!z.keepDefaultValue&&st(i,L);f.values.next({values:{...s}}),f.state.next({...n,...z.keepDirty?{isDirty:T()}:{}}),!z.keepIsValid&&k()},oe=({disabled:C,name:z,field:L,fields:se})=>{(Rt(C)&&o.mount||C||a.disabled.has(z))&&(C?a.disabled.add(z):a.disabled.delete(z),w(z,Qs(L?L._f:ue(se,z)._f),!1,!1,!0))},I=(C,z={})=>{let L=ue(r,C);const se=Rt(z.disabled)||Rt(t.disabled);return Le(r,C,{...L||{},_f:{...L&&L._f?L._f:{ref:{name:C}},name:C,mount:!0,...z}}),a.mount.add(C),L?oe({field:L,disabled:Rt(z.disabled)?z.disabled:t.disabled,name:C}):E(C,!0,z.value),{...se?{disabled:z.disabled||t.disabled}:{},...t.progressive?{required:!!z.required,min:$r(z.min),max:$r(z.max),minLength:$r(z.minLength),maxLength:$r(z.maxLength),pattern:$r(z.pattern)}:{},name:C,onChange:V,onBlur:V,ref:ie=>{if(ie){I(C,z),L=ue(r,C);const ee=tt(ie.value)&&ie.querySelectorAll&&ie.querySelectorAll("input,select,textarea")[0]||ie,me=fy(ee),we=L._f.refs||[];if(me?we.find(U=>U===ee):ee===L._f.ref)return;Le(r,C,{_f:{...L._f,...me?{refs:[...we.filter(Xs),ee,...Array.isArray(ue(i,C))?[{}]:[]],ref:{type:ee.type,name:C}}:{ref:ee}}}),E(C,!1,void 0,ee)}else L=ue(r,C,{}),L._f&&(L._f.mount=!1),(t.shouldUnregister||z.shouldUnregister)&&!(of(a.array,C)&&o.action)&&a.unMount.add(C)}}},re=()=>t.shouldFocusError&&ei(r,X,a.mount),ae=C=>{Rt(C)&&(f.state.next({disabled:C}),ei(r,(z,L)=>{const se=ue(r,L);se&&(z.disabled=se._f.disabled||C,Array.isArray(se._f.refs)&&se._f.refs.forEach(ie=>{ie.disabled=se._f.disabled||C}))},0,!1))},H=(C,z)=>async L=>{let se;L&&(L.preventDefault&&L.preventDefault(),L.persist&&L.persist());let ie=wt(s);if(a.disabled.size)for(const ee of a.disabled)Le(ie,ee,void 0);if(f.state.next({isSubmitting:!0}),t.resolver){const{errors:ee,values:me}=await O();n.errors=ee,ie=me}else await N(r);if(st(n.errors,"root"),kt(n.errors)){f.state.next({errors:{}});try{await C(ie,L)}catch(ee){se=ee}}else z&&await z({...n.errors},L),re(),setTimeout(re);if(f.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:kt(n.errors)&&!se,submitCount:n.submitCount+1,errors:n.errors}),se)throw se},K=(C,z={})=>{ue(r,C)&&(tt(z.defaultValue)?J(C,wt(ue(i,C))):(J(C,z.defaultValue),Le(i,C,wt(z.defaultValue))),z.keepTouched||st(n.touchedFields,C),z.keepDirty||(st(n.dirtyFields,C),n.isDirty=z.defaultValue?T(C,wt(ue(i,C))):T()),z.keepError||(st(n.errors,C),d.isValid&&k()),f.state.next({...n}))},pe=(C,z={})=>{const L=C?wt(C):i,se=wt(L),ie=kt(C),ee=ie?i:se;if(z.keepDefaultValues||(i=L),!z.keepValues){if(z.keepDirtyValues){const me=new Set([...a.mount,...Object.keys(Rr(i,s))]);for(const we of Array.from(me))ue(n.dirtyFields,we)?Le(ee,we,ue(s,we)):J(we,ue(ee,we))}else{if(Sa&&tt(C))for(const me of a.mount){const we=ue(r,me);if(we&&we._f){const U=Array.isArray(we._f.refs)?we._f.refs[0]:we._f.ref;if(ns(U)){const Y=U.closest("form");if(Y){Y.reset();break}}}}r={}}s=t.shouldUnregister?z.keepDefaultValues?wt(i):{}:wt(ee),f.array.next({values:{...ee}}),f.values.next({values:{...ee}})}a={mount:z.keepDirtyValues?a.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},o.mount=!d.isValid||!!z.keepIsValid||!!z.keepDirtyValues,o.watch=!!t.shouldUnregister,f.state.next({submitCount:z.keepSubmitCount?n.submitCount:0,isDirty:ie?!1:z.keepDirty?n.isDirty:!!(z.keepDefaultValues&&!xn(C,i)),isSubmitted:z.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:ie?{}:z.keepDirtyValues?z.keepDefaultValues&&s?Rr(i,s):n.dirtyFields:z.keepDefaultValues&&C?Rr(i,C):z.keepDirty?n.dirtyFields:{},touchedFields:z.keepTouched?n.touchedFields:{},errors:z.keepErrors?n.errors:{},isSubmitSuccessful:z.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1})},fe=(C,z)=>pe(Qt(C)?C(s):C,z);return{control:{register:I,unregister:Q,getFieldState:ce,handleSubmit:H,setError:G,_executeSchema:O,_getWatch:F,_getDirty:T,_updateValid:k,_removeUnmounted:R,_updateFieldArray:_,_updateDisabledField:oe,_getFieldArray:$,_reset:pe,_resetDefaultValues:()=>Qt(t.defaultValues)&&t.defaultValues().then(C=>{fe(C,t.resetOptions),f.state.next({isLoading:!1})}),_updateFormState:C=>{n={...n,...C}},_disableForm:ae,_subjects:f,_proxyFormState:d,_setErrors:A,get _fields(){return r},get _formValues(){return s},get _state(){return o},set _state(C){o=C},get _defaultValues(){return i},get _names(){return a},set _names(C){a=C},get _formState(){return n},set _formState(C){n=C},get _options(){return t},set _options(C){t={...t,...C}}},trigger:j,register:I,handleSubmit:H,watch:ne,setValue:J,getValues:ye,reset:fe,resetField:K,clearErrors:b,unregister:Q,setError:G,setFocus:(C,z={})=>{const L=ue(r,C),se=L&&L._f;if(se){const ie=se.refs?se.refs[0]:se.ref;ie.focus&&(ie.focus(),z.shouldSelect&&Qt(ie.select)&&ie.select())}},getFieldState:ce}}function vy(e={}){const t=je.useRef(void 0),n=je.useRef(void 0),[r,i]=je.useState({isDirty:!1,isValidating:!1,isLoading:Qt(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,defaultValues:Qt(e.defaultValues)?void 0:e.defaultValues});t.current||(t.current={...by(e),formState:r});const s=t.current.control;return s._options=e,_a({subject:s._subjects.state,next:o=>{uf(o,s._proxyFormState,s._updateFormState,!0)&&i({...s._formState})}}),je.useEffect(()=>s._disableForm(e.disabled),[s,e.disabled]),je.useEffect(()=>{if(s._proxyFormState.isDirty){const o=s._getDirty();o!==r.isDirty&&s._subjects.state.next({isDirty:o})}},[s,r.isDirty]),je.useEffect(()=>{e.values&&!xn(e.values,n.current)?(s._reset(e.values,s._options.resetOptions),n.current=e.values,i(o=>({...o}))):s._resetDefaultValues()},[e.values,s]),je.useEffect(()=>{e.errors&&s._setErrors(e.errors)},[e.errors,s]),je.useEffect(()=>{s._state.mount||(s._updateValid(),s._state.mount=!0),s._state.watch&&(s._state.watch=!1,s._subjects.state.next({...s._formState})),s._removeUnmounted()}),je.useEffect(()=>{e.shouldUnregister&&s._subjects.values.next({values:s._getWatch()})},[e.shouldUnregister,s]),t.current.formState=cf(r,s),t.current}function wy(e){return async t=>{const n=e(t);if(n.success&&n.data)return{values:n.data,errors:{}};const r={};if(n.errors)for(const i of n.errors){const s=i.path||"root";r[s]||(r[s]={type:"validation",message:i.message})}return{values:{},errors:r}}}const ky=ry,bf=g.createContext({}),Al=({...e})=>l.jsx(bf.Provider,{value:{name:e.name},children:l.jsx(ay,{...e})}),As=()=>{const e=g.useContext(bf),t=g.useContext(vf),{getFieldState:n,formState:r}=Is(),i=n(e.name,r);if(!e)throw new Error("useFormField should be used within <FormField>");const{id:s}=t;return{id:s,name:e.name,formItemId:`${s}-form-item`,formDescriptionId:`${s}-form-item-description`,formMessageId:`${s}-form-item-message`,...i}},vf=g.createContext({}),Mo=g.forwardRef(({className:e,...t},n)=>{const r=g.useId();return l.jsx(vf.Provider,{value:{id:r},children:l.jsx("div",{ref:n,className:W("space-y-2",e),...t})})});Mo.displayName="FormItem";const Fo=g.forwardRef(({className:e,...t},n)=>{const{error:r,formItemId:i}=As();return l.jsx(Xr,{ref:n,className:W(r&&"text-destructive",e),htmlFor:i,...t})});Fo.displayName="FormLabel";const Lo=g.forwardRef(({...e},t)=>{const{error:n,formItemId:r,formDescriptionId:i,formMessageId:s}=As();return l.jsx(Nr,{ref:t,id:r,"aria-describedby":n?`${i} ${s}`:`${i}`,"aria-invalid":!!n,...e})});Lo.displayName="FormControl";const wf=g.forwardRef(({className:e,...t},n)=>{const{formDescriptionId:r}=As();return l.jsx("p",{ref:n,id:r,className:W("text-muted-foreground text-[0.8rem]",e),...t})});wf.displayName="FormDescription";const Bo=g.forwardRef(({className:e,children:t,...n},r)=>{const{error:i,formMessageId:s}=As(),o=i?String(i==null?void 0:i.message):t;return o?l.jsx("p",{ref:r,id:s,className:W("text-destructive text-[0.8rem] font-medium",e),...n,children:o}):null});Bo.displayName="FormMessage";function Ea(){const e=new Date,t=n=>String(n).padStart(2,"0");return`Chat ${t(e.getMonth()+1)}/${t(e.getDate())} ${t(e.getHours())}:${t(e.getMinutes())}`}const kf=()=>({chatOpen:!1,scope:"global",model:"opus",contextAttachments:[],threads:{},activeThreadId:{}}),Sy=(e=kf())=>Ox()(Px(Dx((t,n)=>({...e,toggleChat:()=>t(r=>({chatOpen:!r.chatOpen})),openChat:()=>t({chatOpen:!0}),closeChat:()=>t({chatOpen:!1}),addContext:r=>t(i=>({contextAttachments:[...i.contextAttachments,r]})),removeContext:r=>t(i=>({contextAttachments:i.contextAttachments.filter((s,o)=>o!==r)})),clearContext:()=>t({contextAttachments:[]}),setScope:r=>t({scope:r}),setModel:r=>t({model:r}),createThread:r=>{const i=crypto.randomUUID(),s=Date.now(),o={id:i,documentName:r,title:Ea(),messages:[],createdAt:s,updatedAt:s};return t(a=>({threads:{...a.threads,[i]:o},activeThreadId:{...a.activeThreadId,[r]:i}})),i},deleteThread:r=>{const i=n(),s=i.threads[r];if(!s)return;const o=Object.fromEntries(Object.entries(i.threads).filter(([u])=>u!==r)),a=s.documentName,c={...i.activeThreadId};if(c[a]===r){const u=Object.values(o).filter(d=>d.documentName===a);u.length>0?(u.sort((d,f)=>f.updatedAt-d.updatedAt),c[a]=u[0].id):delete c[a]}t({threads:o,activeThreadId:c})},switchThread:r=>{const s=n().threads[r];s&&t(o=>({activeThreadId:{...o.activeThreadId,[s.documentName]:r}}))},updateThreadMessages:(r,i)=>{t(s=>{const o=s.threads[r];return o?{threads:{...s.threads,[r]:{...o,messages:i,updatedAt:Date.now()}}}:s})},updateThreadTitle:(r,i)=>{t(s=>{const o=s.threads[r];return o?{threads:{...s.threads,[r]:{...o,title:i}}}:s})},deleteThreadsForDocument:r=>{t(i=>{const s={...i.threads},o={...i.activeThreadId};for(const[a,c]of Object.entries(s))c.documentName===r&&delete s[a];return delete o[r],{threads:s,activeThreadId:o}})},renameThreadsForDocument:(r,i)=>{t(s=>{const o={...s.threads},a={...s.activeThreadId};for(const[c,u]of Object.entries(o))u.documentName===r&&(o[c]={...u,documentName:i});return r in a&&(a[i]=a[r],delete a[r]),{threads:o,activeThreadId:a}})},clearChat:()=>{t(r=>({contextAttachments:[]}))}}),{name:"chat-storage",version:2,storage:Rx(()=>fg),partialize:t=>({threads:t.threads,activeThreadId:t.activeThreadId,scope:t.scope,model:t.model}),migrate:(t,n)=>{if(n===0&&t){const r=t.chatMessages;if(Array.isArray(r)&&r.length>0){const i=crypto.randomUUID(),s=Date.now();return{threads:{[i]:{id:i,documentName:"__migrated__",title:"Migrated Chat",messages:r,createdAt:s,updatedAt:s}},activeThreadId:{__migrated__:i}}}return{threads:{},activeThreadId:{}}}return n<2&&(t==null?void 0:t.scope)==="templates"?{...t,scope:"blocks"}:t}}))),Sf=g.createContext(void 0),jy=({children:e})=>{const t=g.useRef(null);return t.current||(t.current=Sy(kf())),l.jsx(Sf.Provider,{value:t.current,children:e})},De=e=>{const t=g.useContext(Sf);if(!t)throw new Error("useChatStore must be used within ChatStoreProvider");return $x(t,e)};function jf(e){return`${e.split(/[^a-zA-Z0-9]+/).filter(Boolean).map((n,r)=>r===0?n.charAt(0).toLowerCase()+n.slice(1):n.charAt(0).toUpperCase()+n.slice(1)).join("")||"custom"}Component`}function _y(e){const t=jf(e);return`import { Type } from '@sinclair/typebox';
|
|
3
|
+
import { createComponent, createVersion } from '@json-to-office/core-docx';
|
|
4
|
+
import type { ComponentDefinition } from '@json-to-office/shared-docx';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Props are a TypeBox schema: it validates the JSON, drives editor
|
|
8
|
+
* completions, and types \`props\` inside render().
|
|
9
|
+
*/
|
|
10
|
+
const PropsSchema = Type.Object(
|
|
11
|
+
{
|
|
12
|
+
title: Type.String({ description: 'Short heading for the callout' }),
|
|
13
|
+
text: Type.String({
|
|
14
|
+
description: 'Body text; inline markdown such as **bold** is allowed',
|
|
15
|
+
}),
|
|
16
|
+
tone: Type.Optional(
|
|
17
|
+
Type.Union([Type.Literal('info'), Type.Literal('warning')], {
|
|
18
|
+
default: 'info',
|
|
19
|
+
description: 'Which theme colour the heading takes',
|
|
20
|
+
})
|
|
21
|
+
),
|
|
22
|
+
},
|
|
23
|
+
{ additionalProperties: false }
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* A titled callout: a heading and a paragraph, coloured from the active theme.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* \`\`\`json
|
|
31
|
+
* {
|
|
32
|
+
* "name": "${e}",
|
|
33
|
+
* "props": {
|
|
34
|
+
* "title": "Note",
|
|
35
|
+
* "text": "This block was produced by a plugin written in the playground.",
|
|
36
|
+
* "tone": "info"
|
|
37
|
+
* }
|
|
38
|
+
* }
|
|
39
|
+
* \`\`\`
|
|
40
|
+
*/
|
|
41
|
+
export const ${t} = createComponent({
|
|
42
|
+
name: '${e}',
|
|
43
|
+
versions: {
|
|
44
|
+
'1.0.0': createVersion({
|
|
45
|
+
propsSchema: PropsSchema,
|
|
46
|
+
description: 'Titled callout coloured from the theme',
|
|
47
|
+
render: async ({ props, theme, addWarning }) => {
|
|
48
|
+
const color =
|
|
49
|
+
props.tone === 'warning' ? theme.colors.secondary : theme.colors.accent;
|
|
50
|
+
if (!props.text.trim()) {
|
|
51
|
+
addWarning('Callout has no text', { title: props.title });
|
|
52
|
+
}
|
|
53
|
+
const components: ComponentDefinition[] = [
|
|
54
|
+
{
|
|
55
|
+
name: 'paragraph',
|
|
56
|
+
props: {
|
|
57
|
+
text: props.title,
|
|
58
|
+
font: { bold: true, size: 12, color },
|
|
59
|
+
spacing: { before: 8, after: 2 },
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: 'paragraph',
|
|
64
|
+
props: { text: props.text, spacing: { after: 10 } },
|
|
65
|
+
},
|
|
66
|
+
];
|
|
67
|
+
return components;
|
|
68
|
+
},
|
|
69
|
+
}),
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
`}function Ny(e){const t=jf(e);return`import { Type } from '@sinclair/typebox';
|
|
73
|
+
import { createComponent, createVersion } from '@json-to-office/json-to-pptx';
|
|
74
|
+
import type { PptxComponentDefinition } from '@json-to-office/shared-pptx';
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Props are a TypeBox schema: it validates the JSON, drives editor
|
|
78
|
+
* completions, and types \`props\` inside render().
|
|
79
|
+
*/
|
|
80
|
+
const PropsSchema = Type.Object(
|
|
81
|
+
{
|
|
82
|
+
label: Type.String({ description: 'What the number measures' }),
|
|
83
|
+
value: Type.String({ description: 'The number, already formatted' }),
|
|
84
|
+
x: Type.Optional(Type.Number({ default: 0.5, description: 'Left edge, inches' })),
|
|
85
|
+
y: Type.Optional(Type.Number({ default: 1.5, description: 'Top edge, inches' })),
|
|
86
|
+
w: Type.Optional(Type.Number({ default: 3, description: 'Width, inches' })),
|
|
87
|
+
},
|
|
88
|
+
{ additionalProperties: false }
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* A KPI tile: a large value over its label, coloured from the active theme.
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* \`\`\`json
|
|
96
|
+
* {
|
|
97
|
+
* "name": "${e}",
|
|
98
|
+
* "props": { "label": "Revenue", "value": "$4.2M", "x": 0.5, "y": 1.5, "w": 3 }
|
|
99
|
+
* }
|
|
100
|
+
* \`\`\`
|
|
101
|
+
*/
|
|
102
|
+
export const ${t} = createComponent({
|
|
103
|
+
name: '${e}',
|
|
104
|
+
versions: {
|
|
105
|
+
'1.0.0': createVersion({
|
|
106
|
+
propsSchema: PropsSchema,
|
|
107
|
+
description: 'KPI tile: large value over its label',
|
|
108
|
+
render: async ({ props, theme, addWarning }) => {
|
|
109
|
+
const x = props.x ?? 0.5;
|
|
110
|
+
const y = props.y ?? 1.5;
|
|
111
|
+
const w = props.w ?? 3;
|
|
112
|
+
if (!props.value.trim()) {
|
|
113
|
+
addWarning('KPI tile has no value', { label: props.label });
|
|
114
|
+
}
|
|
115
|
+
const components: PptxComponentDefinition[] = [
|
|
116
|
+
{
|
|
117
|
+
name: 'text',
|
|
118
|
+
props: {
|
|
119
|
+
text: props.value,
|
|
120
|
+
x,
|
|
121
|
+
y,
|
|
122
|
+
w,
|
|
123
|
+
h: 0.9,
|
|
124
|
+
fontSize: 36,
|
|
125
|
+
bold: true,
|
|
126
|
+
color: theme.colors.primary,
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
name: 'text',
|
|
131
|
+
props: {
|
|
132
|
+
text: props.label,
|
|
133
|
+
x,
|
|
134
|
+
y: y + 0.9,
|
|
135
|
+
w,
|
|
136
|
+
h: 0.4,
|
|
137
|
+
fontSize: 12,
|
|
138
|
+
color: theme.colors.text2 ?? theme.colors.text,
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
];
|
|
142
|
+
return components;
|
|
143
|
+
},
|
|
144
|
+
}),
|
|
145
|
+
},
|
|
146
|
+
});
|
|
147
|
+
`}function Cy(e,t){return e==="docx"?_y(t):Ny(t)}function Ey(e){const t=e.match(/createComponent\s*\(\s*\{[^}]*?\bname\s*:\s*(['"`])([^'"`]+)\1/);return t?t[2]:null}function Ty(e,t){return e.replace(/(createComponent\s*\(\s*\{[^}]*?\bname\s*:\s*)(['"`])([^'"`]+)\2/,(n,r,i)=>`${r}${i}${t}${i}`)}function Iy(e){const t=e.replace(/\.component\.ts$/i,"").replace(/\.ts$/i,"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");return t?/^[a-z]/.test(t)?t:`x-${t}`:"custom-block"}function Ay(e,t,n){return t.filter(r=>r.name!==n).every(r=>r.name!==e)}function zy(e,t,n,r){const i={},s=[];e!=="delete"&&(i.name=Oi.String({minLength:1,maxLength:120,pattern:"^[a-zA-Z0-9-_. ]+$",description:"Document name (e.g., my-report.docx.json or my-theme.theme.json)"}),s.push("name")),e==="create"&&(i.template=Oi.Optional(Oi.String({description:"Template selection"})));const o=Oi.Object(i,{additionalProperties:!1,required:s.length>0?s:void 0});return{schema:o,validate:a=>{const c=[];if(!jg(o,a))for(const d of _g(o,a))c.push({path:d.path.replace(/^\//,""),message:d.message});const u=a;if(e!=="delete"&&u.name){const d=u.name.trim();d?(u.name=d,t((r==null?void 0:r(d))??d)||c.push({path:"name",message:"Document with this name already exists"})):c.push({path:"name",message:"Name can't be empty"})}return e==="create"&&(n!=null&&n.length)&&u.template&&(n.some(d=>d.name===u.template)||c.push({path:"template",message:"You must select a valid template"})),{success:c.length===0,data:c.length===0?u:void 0,errors:c}}}}function Oy(e,t,n){return e==="create"?{name:"",template:t}:e==="update"?{name:n}:{}}const Py=e=>({create:{title:e==="theme"?"New Theme":e==="plugin"?"New Plugin":"New Document",description:e==="theme"?"Create a new theme from scratch or based on discovered themes.":e==="plugin"?"Write a custom component in TypeScript. It compiles and runs in your browser; documents use it by name like any built-in component.":"Create a new document from scratch or based on discovered documents.",button:"Create",buttonVariant:"default"},update:{title:"Rename Document",description:"Give your document a new name.",button:"Save",buttonVariant:"default"},delete:{title:"Are you absolutely sure?",description:"This action cannot be undone. Are you sure you want to permanently delete this document?",button:"Confirm",buttonVariant:"destructive"}}),Hn="__empty__";function Dy({mode:e,shouldReset:t,postSubmit:n,selectedName:r,discoveredDocuments:i,discoveredThemes:s,discoveredPlugins:o,isTheme:a,isPlugin:c}){const[u,d]=g.useState(!1),[f,h]=g.useState(null),[p,m]=g.useState("idle"),{toast:v}=_r(),k=c?"plugin":a?"theme":"document",y=Py(k),{documents:_,openTabs:x,createDocument:A,renameDocument:E,deleteDocument:w,openDocument:S,closeDocument:O,documentTypes:B}=ke(I=>I),{updateTheme:N,removeTheme:R}=Io(I=>I),T=vn(I=>I.rename),F=vn(I=>I.remove),$=De(I=>I.renameThreadsForDocument),Z=De(I=>I.deleteThreadsForDocument),P=g.useMemo(()=>k==="plugin"?(o||[]).map(I=>({name:I.name,path:I.filePath,location:I.location==="current"?"current":"downstream",description:I.description})):k==="theme"?s||[]:i||[],[k,i,s,o]),J=g.useMemo(()=>{const I={current:[],downstream:[]};return P.forEach(re=>{I[re.location]&&I[re.location].push(re)}),I},[P]),V=g.useMemo(()=>P.map(I=>({name:I.name,type:"application/json",text:"",mtime:new Date,ctime:new Date,atime:new Date})),[P]),X=k==="plugin"||e==="update"&&!!r&&B[r]==="application/typescript+plugin",j=g.useMemo(()=>zy(e,I=>Ay(I,_,r),V,X?qs:void 0),[e,_,r,V,X]),ye=j.schema,ce=g.useMemo(()=>{const I=new Map;return P.forEach(re=>I.set(re.path,re)),I},[P]),b=Hn,G=vy({resolver:wy(j.validate),defaultValues:Oy(e,void 0,r)}),[ne,Q]=g.useState(b);g.useEffect(()=>{if(ne&&ne!==Hn&&e==="create"){const I=ce.get(ne);if(I){h(null),m("loading");let re=!1;const ae=k==="plugin"?`/api/discovery/plugins/${encodeURIComponent(I.name)}/source`:`/api/discovery/${k==="theme"?"themes":"documents"}/${encodeURIComponent(I.name)}/content`;return fetch(ae).then(H=>{if(!H.ok)throw new Error(`Failed to fetch content: ${H.statusText}`);return H.text()}).then(H=>{if(!re){if(k==="plugin"){const K=Ey(H);h(K?Ty(H,`${K}-custom`):H)}else{const K=JSON.parse(H);h(JSON.stringify(K,null,2))}m("idle")}}).catch(H=>{re||(console.error("Failed to copy template:",H),h(null),m("error"))}),()=>{re=!0}}}m("idle")},[ne,e,ce,k]),g.useEffect(()=>{t&&(G.reset(),h(null),m("idle"),Q(b))},[G,t]);const oe=G.handleSubmit(async({name:I,template:re})=>{d(!0);try{if(await new Promise(ae=>setTimeout(ae,200)),e==="create"){const ae=ne?ce.get(ne):P.find(z=>z.name===re);let H,K=I;if(!!ne&&ne!==Hn&&f===null){v({title:p==="loading"?"Template still loading":`Could not copy ${(ae==null?void 0:ae.name)??"the selected template"}`,description:p==="loading"?"Wait for the template to finish loading, then try again.":"Pick another template, or create an empty one instead.",variant:"destructive"});return}if(k==="plugin")K=qs(K),H=f||Cy(at,Iy(K));else if(a){const z=K.replace(/\.(json|theme)$/i,"").toLowerCase().replace(/\s+/g,"-"),L=at==="docx"?Ng(z):{name:z,colors:{primary:"#2563EB",secondary:"#64748B",accent:"#F8FAFC",background:"#FFFFFF",text:"#334155"},fonts:{heading:"Calibri",body:"Calibri"},defaults:{fontSize:18,fontColor:"#334155"}};H=f||JSON.stringify(L,null,2);const se=`.${at}.theme.json`;K.endsWith(se)||(K=K.replace(/\.(pptx|docx)\.theme\.json$/i,"").replace(/\.theme\.json$/i,"").replace(/\.json$/i,""),K+=se)}else{const z=ae;H=f||JSON.stringify(at==="docx"?{name:"docx",props:{theme:(z==null?void 0:z.theme)||"default",metadata:{title:(z==null?void 0:z.title)||K.replace(/\.(json|js)$/i,"")}},children:[{name:"section",props:{},children:[{name:"paragraph",props:{text:"Start writing your document content here..."}}]}]}:{name:"pptx",props:{title:(z==null?void 0:z.title)||K.replace(/\.(json|js)$/i,""),theme:(z==null?void 0:z.theme)||"default"},children:[{name:"slide",props:{},children:[{name:"text",props:{text:"Start writing your presentation content here...",fontSize:24,y:2,x:1,w:8}}]}]},null,2);const L=at==="docx"?".docx.json":".pptx.json";!K.endsWith(L)&&!K.endsWith(".json")&&(K+=L)}const fe=K.match(/(\.(pptx|docx)(\.theme)?\.json|\.json|\.component\.ts)$/i),Re=fe?fe[0]:"",Oe=K.slice(0,K.length-Re.length);let $e=K,C=1;for(;_.some(z=>z.name===$e);)C++,$e=`${Oe} (${C})${Re}`;K=$e,A(K,H),S(K),a&&N(K,H)}else if(e==="update"){const ae=r;let H=I;const K=B[ae]==="application/typescript+plugin";if(K&&(H=qs(H)),H!==ae&&_.some(fe=>fe.name===H)){v({title:`"${H}" already exists`,description:"Pick another name.",variant:"destructive"});return}const pe=x.includes(ae);pe&&O(ae),K&&T(ae,H),E(ae,H),$(ae,H),pe&&S(H)}else if(e==="delete"){const ae=r,H=B[ae]==="application/typescript+plugin";O(ae),w(ae),Z(ae),a&&R(ae),H&&F(ae)}n()}finally{d(!1)}});return l.jsx(ky,{...G,children:l.jsxs("form",{onSubmit:oe,children:[l.jsxs(qt,{children:[l.jsx(Gt,{children:y[e].title}),l.jsx(dn,{children:y[e].description})]}),l.jsxs("div",{className:"flex flex-col gap-4 py-4",children:[ye.properties&&"name"in ye.properties&&l.jsx(Al,{control:G.control,name:"name",render:({field:I})=>l.jsxs(Mo,{children:[l.jsx(Fo,{children:"Name"}),l.jsx(Lo,{children:l.jsx(br,{placeholder:"Enter a name or select a template below",autoComplete:"off",...I})}),l.jsx(Bo,{})]})}),e==="create"&&l.jsx(Al,{control:G.control,name:"template",render:({field:I})=>l.jsxs(Mo,{children:[l.jsx(Fo,{children:k==="theme"?"Base Theme":k==="plugin"?"Start from":"Base Document"}),l.jsxs(li,{onValueChange:re=>{if(re===Hn)I.onChange(void 0),G.setValue("name",""),Q(Hn),h(null);else{const ae=ce.get(re);ae&&(I.onChange(ae.name),G.setValue("name",ae.name),Q(re))}},defaultValue:b,children:[l.jsx(Lo,{children:l.jsx(xr,{children:l.jsx(ci,{placeholder:`Select a discovered ${k}`})})}),l.jsxs(yr,{className:"max-h-[300px]",children:[l.jsx(Mn,{value:Hn,children:k==="plugin"?`Starter ${at} component`:`Empty ${k}`}),Object.entries(J).map(([re,ae])=>ae.length===0?null:l.jsxs(ef,{children:[l.jsx(ka,{children:re==="current"?"📁 Current Directory":"📦 Project"}),ae.map(H=>{let K;return H.title&&H.title!==H.name?K=H.title:H.description&&(K=H.description.length>40?H.description.substring(0,40)+"...":H.description),l.jsx(Mn,{value:H.path,className:"pl-6",children:l.jsxs("span",{className:"flex flex-col",children:[l.jsx("span",{className:"font-medium",children:H.name}),K&&l.jsx("span",{className:"text-muted-foreground text-xs",children:K})]})},H.path)})]},re))]})]}),l.jsx(wf,{children:k==="plugin"?'Start from the starter component, or copy a plugin discovered on disk — the copy is renamed "<name>-custom" so both can exist':`Start empty or select a discovered ${k} as a starting point`}),l.jsx(Bo,{})]})})]}),l.jsx(kn,{children:l.jsx(Ce,{type:"submit",variant:y[e].buttonVariant,disabled:u,children:u?l.jsxs(l.Fragment,{children:[l.jsx(cn,{size:"sm",className:"mr-2"}),e==="create"?"Creating...":e==="update"?"Saving...":"Deleting..."]}):y[e].button})})]})})}const Dn=je.memo(Dy);function on(e,t){return t?e.toLowerCase().includes(t.toLowerCase()):!0}function zs({text:e,query:t}){if(!t)return l.jsx(l.Fragment,{children:e});const n=e.toLowerCase().indexOf(t.toLowerCase());return n===-1?l.jsx(l.Fragment,{children:e}):l.jsxs(l.Fragment,{children:[e.slice(0,n),l.jsx("mark",{className:"bg-transparent p-0 font-semibold text-current",children:e.slice(n,n+t.length)}),e.slice(n+t.length)]})}function Zo({children:e,count:t,actions:n,className:r,open:i,onToggle:s}){const o=l.jsxs(l.Fragment,{children:[l.jsx(Cr,{"aria-hidden":!0,className:W("size-3 shrink-0 transition-transform duration-150 ease-out",i&&"rotate-90")}),l.jsx("span",{className:"text-[11px] font-medium tracking-[0.08em] uppercase",children:e}),t!==void 0&&l.jsx("span",{className:"text-[11px] font-normal tabular-nums text-sidebar-foreground/65",children:t})]});return l.jsxs("div",{className:W("flex h-6 shrink-0 items-center gap-1.5 select-none",r),children:[l.jsx("button",{type:"button",onClick:s,"aria-expanded":i,className:W("flex h-6 min-w-0 flex-1 cursor-pointer items-center gap-1.5 rounded-sm px-1","text-sidebar-foreground/70 transition-colors","hover:bg-sidebar-accent/60 hover:text-sidebar-foreground","focus-visible:ring-sidebar-ring focus-visible:ring-1 focus-visible:outline-none"),children:o}),n&&l.jsx("div",{className:"flex shrink-0 items-center gap-0.5 pr-1",children:n})]})}const Et=je.forwardRef(({className:e,...t},n)=>l.jsx("button",{ref:n,type:"button",className:W("flex size-5 shrink-0 cursor-pointer items-center justify-center rounded-sm","text-sidebar-foreground/55 transition-colors","hover:bg-sidebar-accent hover:text-sidebar-foreground","focus-visible:ring-sidebar-ring focus-visible:ring-1 focus-visible:outline-none","disabled:pointer-events-none disabled:opacity-40","[&>svg]:size-3.5",e),...t}));Et.displayName="RailIconButton";function zl({tone:e,className:t}){return l.jsx("span",{"aria-hidden":!0,className:W("size-1.5 shrink-0 rounded-full",e==="preview"?"bg-data-blue":"bg-warning",t)})}function Vo({icon:e,label:t,onClick:n,hint:r}){return n?l.jsxs("button",{type:"button",onClick:n,title:r,className:W("flex h-7 w-full cursor-pointer items-center gap-2 rounded-sm px-2","text-[13px] text-sidebar-foreground/70 transition-colors","hover:bg-sidebar-accent hover:text-sidebar-foreground","focus-visible:ring-sidebar-ring focus-visible:ring-1 focus-visible:outline-none"),children:[l.jsx(e,{className:"size-3.5 shrink-0"}),l.jsx("span",{className:"truncate",children:t})]}):l.jsx("p",{className:"px-2 py-1 text-[12px] leading-tight text-sidebar-foreground/70",children:t})}const _f=Lg,Nf=Bg,Ry=g.forwardRef(({className:e,inset:t,children:n,...r},i)=>l.jsxs(kd,{ref:i,className:W("focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground flex cursor-pointer items-center rounded-sm px-2 py-1.5 text-sm outline-none select-none",t&&"pl-8",e),...r,children:[n,l.jsx(Cr,{className:"ml-auto h-4 w-4"})]}));Ry.displayName=kd.displayName;const $y=g.forwardRef(({className:e,...t},n)=>l.jsx(Sd,{ref:n,className:W("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] overflow-hidden rounded-lg border p-1 shadow-lg",e),...t}));$y.displayName=Sd.displayName;const Ta=g.forwardRef(({className:e,...t},n)=>l.jsx(Zg,{children:l.jsx(bd,{ref:n,className:W("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] overflow-hidden rounded-lg border p-1 shadow-md",e),...t})}));Ta.displayName=bd.displayName;const Ia=g.forwardRef(({className:e,inset:t,...n},r)=>l.jsx(wd,{ref:r,className:W("focus:bg-accent focus:text-accent-foreground relative flex cursor-pointer items-center rounded-sm px-2 py-1.5 text-sm outline-none select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));Ia.displayName=wd.displayName;const My=g.forwardRef(({className:e,children:t,checked:n,...r},i)=>l.jsxs(jd,{ref:i,className:W("focus:bg-accent focus:text-accent-foreground relative flex cursor-pointer items-center rounded-sm py-1.5 pr-2 pl-8 text-sm outline-none select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[l.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:l.jsx(_d,{children:l.jsx(un,{className:"h-4 w-4"})})}),t]}));My.displayName=jd.displayName;const Fy=g.forwardRef(({className:e,children:t,...n},r)=>l.jsxs(Nd,{ref:r,className:W("focus:bg-accent focus:text-accent-foreground relative flex cursor-pointer items-center rounded-sm py-1.5 pr-2 pl-8 text-sm outline-none select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[l.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:l.jsx(_d,{children:l.jsx(Ud,{className:"h-4 w-4 fill-current"})})}),t]}));Fy.displayName=Nd.displayName;const Ly=g.forwardRef(({className:e,inset:t,...n},r)=>l.jsx(Cd,{ref:r,className:W("text-foreground px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));Ly.displayName=Cd.displayName;const Aa=g.forwardRef(({className:e,...t},n)=>l.jsx(vd,{ref:n,className:W("bg-border -mx-1 my-1 h-px",e),...t}));Aa.displayName=vd.displayName;const Cf=({className:e,...t})=>l.jsx("span",{className:W("text-muted-foreground ml-auto text-xs tracking-widest",e),...t});Cf.displayName="ContextMenuShortcut";const _i=Vg,Ni=Ug,By=g.forwardRef(({className:e,inset:t,children:n,...r},i)=>l.jsxs(zd,{ref:i,className:W("focus:bg-accent data-[state=open]:bg-accent flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none select-none [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",t&&"pl-8",e),...r,children:[n,l.jsx(Cr,{className:"ml-auto"})]}));By.displayName=zd.displayName;const Zy=g.forwardRef(({className:e,...t},n)=>l.jsx(Od,{ref:n,className:W("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] overflow-hidden rounded-lg border p-1 shadow-lg",e),...t}));Zy.displayName=Od.displayName;const Er=g.forwardRef(({className:e,sideOffset:t=4,...n},r)=>l.jsx(Jg,{children:l.jsx(Ed,{ref:r,sideOffset:t,className:W("bg-popover text-popover-foreground z-50 min-w-[8rem] overflow-hidden rounded-lg border p-1 shadow-md","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));Er.displayName=Ed.displayName;const $t=g.forwardRef(({className:e,inset:t,...n},r)=>l.jsx(Td,{ref:r,className:W("focus:bg-accent focus:text-accent-foreground relative flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-sm transition-colors outline-none select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>svg]:size-4 [&>svg]:shrink-0",t&&"pl-8",e),...n}));$t.displayName=Td.displayName;const Vy=g.forwardRef(({className:e,children:t,checked:n,...r},i)=>l.jsxs(Pd,{ref:i,className:W("focus:bg-accent focus:text-accent-foreground relative flex cursor-pointer items-center rounded-sm py-1.5 pr-2 pl-8 text-sm transition-colors outline-none select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[l.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:l.jsx(Dd,{children:l.jsx(un,{className:"h-4 w-4"})})}),t]}));Vy.displayName=Pd.displayName;const Uy=g.forwardRef(({className:e,children:t,...n},r)=>l.jsxs(Rd,{ref:r,className:W("focus:bg-accent focus:text-accent-foreground relative flex cursor-pointer items-center rounded-sm py-1.5 pr-2 pl-8 text-sm transition-colors outline-none select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[l.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:l.jsx(Dd,{children:l.jsx(Ud,{className:"h-2 w-2 fill-current"})})}),t]}));Uy.displayName=Rd.displayName;const za=g.forwardRef(({className:e,inset:t,...n},r)=>l.jsx(Ad,{ref:r,className:W("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));za.displayName=Ad.displayName;const Fn=g.forwardRef(({className:e,...t},n)=>l.jsx(Id,{ref:n,className:W("bg-muted -mx-1 my-1 h-px",e),...t}));Fn.displayName=Id.displayName;const Ef=({className:e,...t})=>l.jsx("span",{className:W("ml-auto text-xs tracking-widest opacity-60",e),...t});Ef.displayName="DropdownMenuShortcut";const Tf=g.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},i)=>l.jsx($d,{ref:i,decorative:n,orientation:t,className:W("bg-border shrink-0",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));Tf.displayName=$d.displayName;const If=cd,Jy=Hg,Hy=ud,Af=g.forwardRef(({className:e,...t},n)=>l.jsx(Cs,{className:W("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...t,ref:n}));Af.displayName=Cs.displayName;const Wy=Si("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500 data-[state=open]:animate-in data-[state=closed]:animate-out",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),Oa=g.forwardRef(({side:e="right",className:t,children:n,...r},i)=>l.jsxs(Hy,{children:[l.jsx(Af,{}),l.jsxs(js,{ref:i,className:W(Wy({side:e}),t),...r,children:[l.jsxs(ya,{className:"ring-offset-background focus:ring-ring data-[state=open]:bg-secondary absolute top-4 right-4 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-none disabled:pointer-events-none",children:[l.jsx(wn,{className:"h-4 w-4"}),l.jsx("span",{className:"sr-only",children:"Close"})]}),n]})]}));Oa.displayName=js.displayName;const qy=g.forwardRef(({className:e,...t},n)=>l.jsx(_s,{ref:n,className:W("text-foreground text-lg font-semibold",e),...t}));qy.displayName=_s.displayName;const Gy=g.forwardRef(({className:e,...t},n)=>l.jsx(Ns,{ref:n,className:W("text-muted-foreground text-sm",e),...t}));Gy.displayName=Ns.displayName;function ti({className:e,...t}){return l.jsx("div",{className:W("bg-primary/10 animate-pulse rounded-md",e),...t})}const eo=768,to=1200;function zf(e){return typeof window<"u"?window.innerWidth<e:!1}function Of(){const[e,t]=g.useState(()=>zf(eo));return g.useEffect(()=>{const n=window.matchMedia(`(max-width: ${eo-1}px)`),r=()=>{t(window.innerWidth<eo)};return n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),e}function Ky(){const[e,t]=g.useState(()=>zf(to));return g.useEffect(()=>{const n=window.matchMedia(`(max-width: ${to-1}px)`),r=()=>{t(window.innerWidth<to)};return n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),e}const Yy="sidebar_state",Xy=60*60*24*7,Qy="16rem",eb="18rem",tb="3rem",nb="b",Pf=g.createContext(null);function Os(){const e=g.useContext(Pf);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}const Df=g.forwardRef(({defaultOpen:e=!0,open:t,onOpenChange:n,className:r,style:i,children:s,...o},a)=>{const c=Of(),[u,d]=g.useState(!1),[f,h]=g.useState(e),p=t??f,m=g.useCallback(_=>{const x=typeof _=="function"?_(p):_;n?n(x):h(x),document.cookie=`${Yy}=${x}; path=/; max-age=${Xy}`},[n,p]),v=g.useCallback(()=>c?d(_=>!_):m(_=>!_),[c,m,d]);g.useEffect(()=>{const _=A=>{var S;const E=A;if(!E)return!1;const w=(S=E.tagName)==null?void 0:S.toLowerCase();return w==="input"||w==="textarea"||w==="select"||E.isContentEditable?!0:!!(E.closest&&E.closest(".monaco-editor"))},x=A=>{const E=A.metaKey||A.ctrlKey,w=A.key.toLowerCase();if(E&&w===nb){A.preventDefault(),v();return}E&&w==="s"&&!_(A.target)&&(A.preventDefault(),v())};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[v]);const k=p?"expanded":"collapsed",y=g.useMemo(()=>({state:k,open:p,setOpen:m,isMobile:c,openMobile:u,setOpenMobile:d,toggleSidebar:v}),[k,p,m,c,u,d,v]);return l.jsx(Pf.Provider,{value:y,children:l.jsx(Cg,{delayDuration:0,children:l.jsx("div",{style:{"--sidebar-width":Qy,"--sidebar-width-icon":tb,...i},className:W("group/sidebar-wrapper has-[[data-variant=inset]]:bg-sidebar flex min-h-svh w-full",r),ref:a,...o,children:s})})})});Df.displayName="SidebarProvider";const Rf=g.forwardRef(({side:e="left",variant:t="sidebar",collapsible:n="offcanvas",className:r,children:i,...s},o)=>{const{isMobile:a,state:c,openMobile:u,setOpenMobile:d}=Os();return n==="none"?l.jsx("div",{className:W("bg-sidebar text-sidebar-foreground flex h-full w-[--sidebar-width] flex-col",r),ref:o,...s,children:i}):a?l.jsx(If,{open:u,onOpenChange:d,...s,children:l.jsx(Oa,{"data-sidebar":"sidebar","data-mobile":"true",className:"bg-sidebar text-sidebar-foreground w-[--sidebar-width] p-0 [&>button]:hidden",style:{"--sidebar-width":eb},side:e,children:l.jsx("div",{className:"flex h-full w-full flex-col",children:i})})}):l.jsxs("div",{ref:o,className:"group peer text-sidebar-foreground hidden md:block","data-state":c,"data-collapsible":c==="collapsed"?n:"","data-variant":t,"data-side":e,children:[l.jsx("div",{className:W("relative h-svh w-[--sidebar-width] bg-transparent transition-[width] duration-200 ease-linear","group-data-[collapsible=offcanvas]:w-0","group-data-[side=right]:rotate-180",t==="floating"||t==="inset"?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon]")}),l.jsx("div",{className:W("fixed inset-y-0 z-10 hidden h-svh w-[--sidebar-width] transition-[left,right,width] duration-200 ease-linear md:flex",e==="left"?"left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]":"right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",t==="floating"||t==="inset"?"p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4)_+2px)]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon] group-data-[side=left]:border-r group-data-[side=right]:border-l",r),...s,children:l.jsx("div",{"data-sidebar":"sidebar",className:"bg-sidebar group-data-[variant=floating]:border-sidebar-border flex h-full w-full flex-col group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:shadow",children:i})})]})});Rf.displayName="Sidebar";const rb=g.forwardRef(({className:e,onClick:t,...n},r)=>{const{toggleSidebar:i}=Os();return l.jsxs(Ce,{ref:r,"data-sidebar":"trigger",variant:"ghost",size:"icon",className:W("h-7 w-7",e),onClick:s=>{t==null||t(s),i()},...n,children:[l.jsx(tx,{}),l.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});rb.displayName="SidebarTrigger";const ib=g.forwardRef(({className:e,...t},n)=>{const{toggleSidebar:r}=Os();return l.jsx("button",{ref:n,"data-sidebar":"rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:r,title:"Toggle Sidebar",className:W("hover:after:bg-sidebar-border absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] sm:flex","[[data-side=left]_&]:cursor-w-resize [[data-side=right]_&]:cursor-e-resize","[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize","group-data-[collapsible=offcanvas]:hover:bg-sidebar group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full","[[data-side=left][data-collapsible=offcanvas]_&]:-right-2","[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",e),...t})});ib.displayName="SidebarRail";const sb=g.forwardRef(({className:e,...t},n)=>l.jsx("main",{ref:n,className:W("bg-background relative flex min-h-svh flex-1 flex-col","peer-data-[variant=inset]:min-h-[calc(100svh-theme(spacing.4))] md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow md:peer-data-[state=collapsed]:peer-data-[variant=inset]:ml-2",e),...t}));sb.displayName="SidebarInset";const ob=g.forwardRef(({className:e,...t},n)=>l.jsx(br,{ref:n,"data-sidebar":"input",className:W("bg-background focus-visible:ring-sidebar-ring h-8 w-full shadow-none focus-visible:ring-2",e),...t}));ob.displayName="SidebarInput";const Uo=g.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,"data-sidebar":"header",className:W("flex flex-col gap-2 p-2",e),...t}));Uo.displayName="SidebarHeader";const $f=g.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,"data-sidebar":"footer",className:W("flex flex-col gap-2 p-2",e),...t}));$f.displayName="SidebarFooter";const ab=g.forwardRef(({className:e,...t},n)=>l.jsx(Tf,{ref:n,"data-sidebar":"separator",className:W("bg-sidebar-border mx-2 w-auto",e),...t}));ab.displayName="SidebarSeparator";const Jo=g.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,"data-sidebar":"content",className:W("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",e),...t}));Jo.displayName="SidebarContent";const lb=g.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,"data-sidebar":"group",className:W("relative flex w-full min-w-0 flex-col p-2",e),...t}));lb.displayName="SidebarGroup";const cb=g.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const i=t?Nr:"div";return l.jsx(i,{ref:r,"data-sidebar":"group-label",className:W("text-sidebar-foreground/70 ring-sidebar-ring flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium transition-[margin,opa] duration-200 ease-linear outline-none focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",e),...n})});cb.displayName="SidebarGroupLabel";const ub=g.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const i=t?Nr:"button";return l.jsx(i,{ref:r,"data-sidebar":"group-action",className:W("text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground absolute top-3.5 right-3 flex aspect-square w-5 items-center justify-center rounded-md p-0 transition-transform outline-none focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0 cursor-pointer","after:absolute after:-inset-2 after:md:hidden","group-data-[collapsible=icon]:hidden",e),...n})});ub.displayName="SidebarGroupAction";const db=g.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,"data-sidebar":"group-content",className:W("w-full text-sm",e),...t}));db.displayName="SidebarGroupContent";const er=g.forwardRef(({className:e,...t},n)=>l.jsx("ul",{ref:n,"data-sidebar":"menu",className:W("flex w-full min-w-0 flex-col gap-1",e),...t}));er.displayName="SidebarMenu";const Mf=g.forwardRef(({className:e,...t},n)=>l.jsx("li",{ref:n,"data-sidebar":"menu-item",className:W("group/menu-item relative",e),...t}));Mf.displayName="SidebarMenuItem";const fb=Si("peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-none ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-[[data-sidebar=menu-action]]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:!size-8 group-data-[collapsible=icon]:!p-2 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 cursor-pointer",{variants:{variant:{default:"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",outline:"bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"},size:{default:"h-8 text-sm",sm:"h-7 text-xs",lg:"h-12 text-sm group-data-[collapsible=icon]:!p-0"}},defaultVariants:{variant:"default",size:"default"}}),Ff=g.forwardRef(({asChild:e=!1,isActive:t=!1,variant:n="default",size:r="default",tooltip:i,className:s,...o},a)=>{const c=e?Nr:"button",{isMobile:u,state:d}=Os(),f=l.jsx(c,{ref:a,"data-sidebar":"menu-button","data-size":r,"data-active":t,className:W(fb({variant:n,size:r}),s),...o});return i?(typeof i=="string"&&(i={children:i}),l.jsxs(Ye,{children:[l.jsx(Xe,{asChild:!0,children:f}),l.jsx(Qe,{side:"right",align:"center",hidden:d!=="collapsed"||u,...i})]})):f});Ff.displayName="SidebarMenuButton";const Lf=g.forwardRef(({className:e,asChild:t=!1,showOnHover:n=!1,...r},i)=>{const s=t?Nr:"button";return l.jsx(s,{ref:i,"data-sidebar":"menu-action",className:W("text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground peer-hover/menu-button:text-sidebar-accent-foreground absolute top-1.5 right-1 flex aspect-square w-5 items-center justify-center rounded-md p-0 transition-transform outline-none focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0 cursor-pointer","after:absolute after:-inset-2 after:md:hidden","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",n&&"peer-data-[active=true]/menu-button:text-sidebar-accent-foreground group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 md:opacity-0",e),...r})});Lf.displayName="SidebarMenuAction";const pb=g.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,"data-sidebar":"menu-badge",className:W("text-sidebar-foreground pointer-events-none absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums select-none","peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",e),...t}));pb.displayName="SidebarMenuBadge";const hb=g.forwardRef(({className:e,showIcon:t=!1,...n},r)=>{const i=g.useMemo(()=>`${Math.floor(Math.random()*40)+50}%`,[]);return l.jsxs("div",{ref:r,"data-sidebar":"menu-skeleton",className:W("flex h-8 items-center gap-2 rounded-md px-2",e),...n,children:[t&&l.jsx(ti,{className:"size-4 rounded-md","data-sidebar":"menu-skeleton-icon"}),l.jsx(ti,{className:"h-4 max-w-[--skeleton-width] flex-1","data-sidebar":"menu-skeleton-text",style:{"--skeleton-width":i}})]})});hb.displayName="SidebarMenuSkeleton";const mb=g.forwardRef(({className:e,...t},n)=>l.jsx("ul",{ref:n,"data-sidebar":"menu-sub",className:W("border-sidebar-border mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l px-2.5 py-0.5","group-data-[collapsible=icon]:hidden",e),...t}));mb.displayName="SidebarMenuSub";const gb=g.forwardRef(({...e},t)=>l.jsx("li",{ref:t,...e}));gb.displayName="SidebarMenuSubItem";const xb=g.forwardRef(({asChild:e=!1,size:t="md",isActive:n,className:r,...i},s)=>{const o=e?Nr:"a";return l.jsx(o,{ref:s,"data-sidebar":"menu-sub-button","data-size":t,"data-active":n,className:W("text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground active:bg-sidebar-accent active:text-sidebar-accent-foreground [&>svg]:text-sidebar-accent-foreground flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 outline-none focus-visible:ring-2 disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 cursor-pointer","data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground",t==="sm"&&"text-xs",t==="md"&&"text-sm","group-data-[collapsible=icon]:hidden",r),...i})});xb.displayName="SidebarMenuSubButton";function ni(e,t){const n=URL.createObjectURL(t),r=document.createElement("a");r.href=n,r.style.display="none",r.download=e,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(n)}const yb=typeof window<"u"?navigator.userAgent.toUpperCase().indexOf("MAC")>=0:!1;function bb({document:e,compact:t=!1,query:n=""}){const r=g.useRef(null),[i,s]=g.useState(!1),[o,a]=g.useState(!1),[c,u]=g.useState(!1),[d,f]=g.useState(!1),h=ke(b=>b.openDocument),p=ke(b=>b.documentTypes),m=ke(b=>b.activeTab),v=an(b=>b.name),k=an(b=>b.text),y=an(b=>b.isGenerating),_=p[e.name]||"application/json+report",x=_==="application/json+theme",A=_==="application/typescript+plugin",E=m===e.name,[w,S]=g.useState(v),[O,B]=g.useState(k),N=100,R=0;g.useEffect(()=>{const b=setTimeout(()=>{v&&k?(S(v),B(k)):y||(S(""),B(""))},y?N:R);return()=>clearTimeout(b)},[v,k,y]);const T=w===e.name,F=b=>{var ne;const G=new Set;try{const Q=JSON.parse(b);(ne=Q.props)!=null&&ne.theme&&G.add(Q.props.theme),Q.children&&Array.isArray(Q.children)&&Q.children.forEach(oe=>{var I;oe.name==="docx"&&((I=oe.props)!=null&&I.theme)&&G.add(oe.props.theme)})}catch{}return G},$=g.useMemo(()=>{if(!x||!O)return!1;try{const b=JSON.parse(e.text),G=pg(b);if(G)return F(O).has(G)}catch{}return!1},[x,O,e.text]),Z=g.useCallback(()=>{u(!1)},[]),P=g.useCallback(()=>{f(!1)},[]),J=E?null:T?"preview":$?"in-use":null,V=E?"Editing":T?"In preview":$?"Used by preview":null,X=g.useMemo(()=>[{key:"open",label:"Open",shortcut:yb?"⌘⏎":"⌃⏎",run:()=>h(e.name)},{key:"download",label:"Download…",separatorBefore:!0,run:()=>ni(e.name,new Blob([e.text],{type:e.type}))},{key:"rename",label:"Rename…",shortcut:"⏎",separatorBefore:!0,run:()=>u(!0)},{key:"delete",label:"Delete",shortcut:"⌫",danger:!0,run:()=>f(!0)}],[e.name,e.text,e.type,h]),j=x?nx:A?Jd:Hd,ye=i||o,ce=l.jsxs(Ff,{size:"sm",ref:r,"aria-label":V?`${e.name} — ${V}`:e.name,className:W("relative h-7 rounded-sm text-[13px] font-normal","text-sidebar-foreground/85 transition-colors","hover:bg-sidebar-accent/60 hover:text-sidebar-foreground",t?"size-7 justify-center px-0":"gap-2 pr-7 pl-2",ye&&"bg-sidebar-accent/60 text-sidebar-foreground",E&&"bg-sidebar-accent text-sidebar-accent-foreground font-medium"),title:V?`${e.name} — ${V}`:e.name,onClick:()=>{h(e.name)},onKeyDown:b=>{var G;(b.ctrlKey||b.metaKey)&&b.key==="Enter"?(h(e.name),b.preventDefault()):b.key==="Enter"?(u(!0),b.preventDefault()):b.key==="Backspace"||b.key==="Delete"?(f(!0),b.preventDefault()):b.key==="Escape"&&((G=r.current)==null||G.blur(),b.preventDefault())},children:[E&&l.jsx("span",{"aria-hidden":!0,className:W("bg-primary absolute top-1 bottom-1 left-0 w-[2px] rounded-full",t&&"top-1.5 bottom-1.5")}),l.jsx(j,{className:W("size-3.5 shrink-0",x?"text-accent2":"text-sidebar-foreground/60",E&&!x&&"text-sidebar-accent-foreground/70")}),!t&&l.jsx("span",{className:"flex-1 truncate",children:l.jsx(zs,{text:e.name,query:n})}),t&&J&&l.jsx(zl,{tone:J,className:"absolute top-1 right-1 size-1.5 ring-2 ring-[hsl(var(--sidebar))]"})]});return l.jsxs(Mf,{children:[l.jsxs(_f,{onOpenChange:s,children:[l.jsx(Nf,{className:"block",children:t?l.jsxs(Ye,{children:[l.jsx(Xe,{asChild:!0,children:ce}),l.jsx(Qe,{side:"right",children:l.jsxs("div",{className:"text-xs",children:[l.jsx("div",{children:e.name}),l.jsx("div",{className:"opacity-70",children:V??(x?"Theme":A?"Plugin":"Document")})]})})]}):ce}),l.jsx(Ta,{className:"w-44",children:X.map(b=>l.jsxs(je.Fragment,{children:[b.separatorBefore&&l.jsx(Aa,{}),l.jsxs(Ia,{onClick:b.run,className:W(b.danger&&"text-destructive focus:text-destructive"),children:[b.label,b.shortcut&&l.jsx(Cf,{children:b.shortcut})]})]},b.key))})]}),!t&&l.jsxs(l.Fragment,{children:[J&&l.jsx(zl,{tone:J,className:W("pointer-events-none absolute top-1/2 right-2.5 -translate-y-1/2 transition-opacity","group-hover/menu-item:opacity-0 group-focus-within/menu-item:opacity-0",o&&"opacity-0")}),l.jsxs(_i,{onOpenChange:a,children:[l.jsx(Ni,{asChild:!0,children:l.jsx(Lf,{showOnHover:!0,"aria-label":`Actions for ${e.name}`,className:"top-1 size-5 rounded-sm text-sidebar-foreground/55 hover:text-sidebar-foreground [&>svg]:size-3.5",children:l.jsx(ba,{})})}),l.jsx(Er,{side:"right",align:"start",className:"w-44",children:X.map(b=>l.jsxs(je.Fragment,{children:[b.separatorBefore&&l.jsx(Fn,{}),l.jsxs($t,{onClick:b.run,className:W(b.danger&&"text-destructive focus:text-destructive"),children:[b.label,b.shortcut&&l.jsx(Ef,{children:b.shortcut})]})]},b.key))})]})]}),l.jsx(ct,{open:c,onOpenChange:u,children:l.jsx(lt,{className:"sm:max-w-[425px]",onCloseAutoFocus:b=>{var G;b.preventDefault(),(G=r.current)==null||G.focus()},children:l.jsx(Dn,{mode:"update",shouldReset:!c,postSubmit:Z,selectedName:e.name})})}),l.jsx(ct,{open:d,onOpenChange:f,children:l.jsx(lt,{className:"sm:max-w-[425px]",onCloseAutoFocus:b=>{var G;b.preventDefault(),(G=r.current)==null||G.focus()},children:l.jsx(Dn,{mode:"delete",shouldReset:!d,postSubmit:P,selectedName:e.name})})})]})}const Mr=je.memo(bb),vb=60,wb=/§jtoc:\d+§/g;function Ae(e,t){if(!(!e||e.type!=="object"||!e.children))for(const n of e.children){if(n.type!=="property"||!n.children)continue;const[r,i]=n.children;if((r==null?void 0:r.value)===t)return i}}function ot(e){return(e==null?void 0:e.type)==="string"&&typeof e.value=="string"?e.value:void 0}function Ho(e){return(e==null?void 0:e.type)==="number"&&typeof e.value=="number"?e.value:void 0}function It(e){return(e==null?void 0:e.type)==="array"&&e.children?e.children:[]}function St(e,t=vb,n=!1){const r=e.replace(wb,"…"),i=n?r.replace(/\s*\n\s*/g," ").trim():r.split(`
|
|
148
|
+
`)[0].trim();return i.length>t?`${i.slice(0,t-1)}…`:i}function kb(e){const t=It(Ae(e,"columns"));if(t.length>0)return`${Math.max(0,...t.map(i=>It(Ae(i,"cells")).length))}×${t.length}`;const n=It(Ae(e,"rows"));if(n.length>0){const r=n[0],i=(r==null?void 0:r.type)==="array"?It(r).length:It(Ae(r,"cells")).length;return i>0?`${n.length}×${i}`:`${n.length} rows`}}function Sb(e){const t=ot(Ae(e,"alt"));if(t)return St(t);const n=ot(Ae(e,"src"));if(n){if(n.startsWith("data:")){const i=n.slice(5).split(/[;,]/)[0];return i?`image (${i.split("/").pop()})`:"image"}const r=n.split(/[?#]/)[0].split("/").pop();if(r)return St(r,40)}return"image"}function jb(e,t){var r;const n=ot(Ae(t,"text"));switch(e){case"heading":{const i=Ho(Ae(t,"level"))??1;return{label:n?St(n):"heading",detail:`H${i}`}}case"text":return{label:n?St(n):"text",detail:ot(Ae(t,"style"))};case"paragraph":return{label:n?St(n):"paragraph"};case"chart":case"highcharts":{const i=ot(Ae(t,"title"))??ot(Ae(Ae(t,"options"),"title"));return{label:i?St(i):e,detail:ot(Ae(t,"type"))}}case"table":return{label:"table",detail:kb(t)};case"image":return{label:Sb(t)};case"shape":return{label:ot(Ae(t,"type"))??"shape"};case"list":{const i=It(Ae(t,"items"));return{label:"list",detail:i.length>0?`${i.length} items`:void 0}}case"section":{const i=ot(Ae(Ae(t,"meta"),"title"))??ot(Ae(t,"title"));return{label:i?St(i):"section"}}case"statistic":{const i=ot(Ae(t,"value"))??((r=Ho(Ae(t,"value")))==null?void 0:r.toString()),s=ot(Ae(t,"label"));return{label:St(s??i??"statistic"),detail:i}}default:return{label:n?St(n):e}}}function Ci(e){if(e.type!=="object")return null;const t=ot(Ae(e,"name"));return t?{name:t,props:Ae(e,"props"),childrenArr:Ae(e,"children")}:null}function _b(e){let t;for(const n of It(e)){const r=Ci(n);if(!r)continue;const i=ot(Ae(r.props,"text"));if(i){if(r.name==="heading"||r.name==="text")return St(i,48);r.name==="paragraph"&&t===void 0&&(t=St(i,48))}}return t}function ss(e,t,n){let{label:r,detail:i}=jb(t.name,t.props);return r===t.name&&t.childrenArr&&(r=_b(t.childrenArr)??r),{id:"",kind:t.name,label:r,detail:i,start:e.offset,end:e.offset+e.length,children:Bf(t.childrenArr),reorder:n}}function Bf(e){if(!e||e.type!=="array")return[];const t=`arr@${e.offset}`,n=[];for(const r of It(e)){const i=Ci(r);i&&n.push(ss(r,i,{groupId:t,sliceStart:r.offset,sliceEnd:r.offset+r.length}))}return n}function Nb(e){const t=Ae(e,"props"),n=ot(Ae(Ae(t,"meta"),"title"));if(n)return St(n,48,!0);let r;const i=(o,a)=>{a&&(!r||o<r.rank)&&(r={rank:o,text:a})},s=(o,a)=>{const c=Ci(o);if(c){if(c.name==="block"){const u=Ae(c.props,"slots");if((u==null?void 0:u.type)==="object"&&u.children)for(const d of u.children){if(d.type!=="property"||!d.children)continue;const[f,h]=d.children,p=typeof(f==null?void 0:f.value)=="string"?f.value:"",m=h?ot(h):void 0;i(p==="title"?0:p==="subtitle"||p.startsWith("heading")?1:2,m)}return}if(c.name==="text"||c.name==="heading"){const u=ot(Ae(c.props,"text"));if(u){const d=ot(Ae(c.props,"style"))??"";i(d==="title"?0:d.startsWith("heading")?1:2,u)}}if(a<1)for(const u of It(c.childrenArr))s(u,a+1)}};for(const o of It(Ae(e,"children")))s(o,0);return r?St(r.text,48,!0):void 0}function Cb(e){const t=Ae(e,"children");if(!t||t.type!=="array")return[];const n=`arr@${t.offset}`,r=[];let i=0;for(const s of It(t)){const o=Ci(s);if(!o)continue;const a={groupId:n,sliceStart:s.offset,sliceEnd:s.offset+s.length};o.name==="slide"?(i+=1,r.push({id:"",kind:"slide",label:Nb(s)??`Slide ${i}`,detail:`${i}`,start:s.offset,end:s.offset+s.length,children:Bf(o.childrenArr),reorder:a})):r.push(ss(s,o,a))}return r}function Eb(e){const t=Ae(e,"children");if(!t||t.type!=="array")return[];const n=`arr@${t.offset}`,r=[],i=[];for(const o of It(t)){const a=Ci(o);if(!a)continue;const c={groupId:n,sliceStart:o.offset,sliceEnd:o.offset+o.length},u=()=>i.length?i[i.length-1].node.children:r;if(a.name==="heading"){const d=Ho(Ae(a.props,"level"))??1;for(;i.length&&i[i.length-1].level>=d;)i.pop();const f=ss(o,a,c);u().push(f),i.push({level:d,node:f})}else u().push(ss(o,a,c))}const s=o=>{o.children.forEach(s);const a=o.children[o.children.length-1];o.kind==="heading"&&a&&(o.end=Math.max(o.end,a.end),o.reorder&&a.reorder&&(o.reorder.sliceEnd=Math.max(o.reorder.sliceEnd,a.reorder.sliceEnd)))};return r.forEach(s),r}function Ol(e){switch(e.type){case"string":return St(String(e.value??""),24);case"number":case"boolean":return String(e.value);case"array":return`${It(e).length} items`;case"object":return;default:return}}function Tb(e){if(e.type!=="object"||!e.children)return[];const t=[];for(const n of e.children){if(n.type!=="property"||!n.children)continue;const[r,i]=n.children,s=typeof(r==null?void 0:r.value)=="string"?r.value:void 0;if(!s||s==="$schema"||!i)continue;const o=[];if(i.type==="object"&&i.children)for(const a of i.children){if(a.type!=="property"||!a.children)continue;const[c,u]=a.children,d=typeof(c==null?void 0:c.value)=="string"?c.value:void 0;!d||!u||o.push({id:"",kind:"key",label:d,detail:Ol(u),start:a.offset,end:a.offset+a.length,children:[]})}t.push({id:"",kind:"key",label:s,detail:o.length===0?Ol(i):void 0,start:n.offset,end:n.offset+n.length,children:o})}return t}function Pl(e,t,n){if(!e.trim())return[];const r=Eg(e,[],{allowTrailingComma:!0});if(!r)return[];const i=n==="theme"?Tb(r):t==="pptx"?Cb(r):Eb(r);return Zf(i,""),i}function Zf(e,t){e.forEach((n,r)=>{n.id=t?`${t}.${r}`:`${r}`,Zf(n.children,n.id)})}function Vf(e,t){const n=[];let r=e;for(;;){const i=r.find(s=>t>=s.start&&t<s.end);if(!i)return n;n.push(i.id),r=i.children}}function Ib(e,t){const n=new Set;for(const r of t)for(const i of Vf(e,r))n.add(i);return n}function Ab(e,t,n,r){if(n===r||n<0||r<0||n>=t.length||r>=t.length)return null;const i=t.map(d=>d.reorder);if(i.some(d=>!d))return null;const s=i[0].groupId;if(i.some(d=>d.groupId!==s))return null;for(let d=1;d<i.length;d++)if(i[d].sliceStart<i[d-1].sliceEnd)return null;const o=i.map(d=>e.slice(d.sliceStart,d.sliceEnd)),a=[];for(let d=1;d<i.length;d++){const f=e.slice(i[d-1].sliceEnd,i[d].sliceStart);if((f.match(/,/g)??[]).length!==1)return null;a.push(f)}const c=o.map((d,f)=>f);c.splice(r,0,c.splice(n,1)[0]);let u="";return c.forEach((d,f)=>{u+=o[d],f<a.length&&(u+=a[f])}),{start:i[0].sliceStart,end:i[i.length-1].sliceEnd,text:u}}const zb={slide:ux,heading:cx,text:Ao,paragraph:lx,chart:Oo,highcharts:Oo,table:ax,image:ox,shape:Wd,list:sx,toc:ix,section:zo,columns:zo,"text-box":Ao,statistic:rx,key:Qi};function Ob(e,t){let n=e,r=null;for(const i of t.split(".")){if(r=n[Number(i)]??null,!r)return null;n=r.children}return r}function Pb(e){const t=e.lastIndexOf(".");return t===-1?"":e.slice(0,t)}function Db(){const{activeTab:e,documentTypes:t}=ke(wa(S=>({activeTab:S.activeTab,documentTypes:S.documentTypes}))),n=ke(S=>{var O;return S.activeTab?(O=S.documents.find(B=>B.name===S.activeTab))==null?void 0:O.text:void 0}),r=sd(S=>e?S.editors.get(e)??null:null),i=e&&t[e]==="application/json+theme"?"theme":"document",[s,o]=g.useState([]),[a,c]=g.useState(null),[u,d]=g.useState(()=>new Set),[f,h]=g.useState(()=>new Set),[p,m]=g.useState(null),v=g.useRef(s);v.current=s;const k=g.useRef(null),y=g.useRef(null),_=g.useCallback(()=>{var B;if(!e){o([]);return}const S=((B=r==null?void 0:r.editor.getModel())==null?void 0:B.getValue())??n??"",O=Pl(S,at,i);if(o(O),y.current!==e){y.current=e;const N=new Set;if(i==="document"&&at==="docx")for(const R of O)R.kind==="heading"&&N.add(R.id);h(N),c(null)}},[e,r,n,i]);g.useEffect(()=>{_();const S=r==null?void 0:r.editor.getModel();if(!S)return;const O=xl(_,300),B=S.onDidChangeContent(()=>O());return()=>{O.cancel(),B.dispose()}},[_,r]),g.useEffect(()=>{if(!r)return;const{editor:S}=r,O=xl(()=>{const N=S.getModel(),R=S.getPosition();if(!N||!R)return;const T=N.getOffsetAt(R),F=Vf(v.current,T);if(F.length===0){c(null);return}c(F[F.length-1]);const $=F.slice(0,-1);$.length&&h(Z=>{if($.every(J=>Z.has(J)))return Z;const P=new Set(Z);for(const J of $)P.add(J);return P})},150),B=S.onDidChangeCursorPosition(()=>O());return()=>{O.cancel(),B.dispose()}},[r]),g.useEffect(()=>{if(!a||!k.current)return;const S=k.current.querySelector(`[data-oid="${CSS.escape(a)}"]`);S==null||S.scrollIntoView({block:"nearest"})},[a]),g.useEffect(()=>{if(!r){d(new Set);return}const{editor:S,monaco:O}=r,B=()=>{const R=S.getModel();if(!R)return;const T=O.editor.getModelMarkers({resource:R.uri}).filter(F=>F.severity===O.MarkerSeverity.Error).map(F=>R.getOffsetAt({lineNumber:F.startLineNumber,column:F.startColumn}));d(Ib(v.current,T))};B();const N=O.editor.onDidChangeMarkers(R=>{const T=S.getModel();T&&R.some(F=>F.toString()===T.uri.toString())&&B()});return()=>N.dispose()},[r,s]);const x=g.useCallback(S=>{h(O=>{const B=new Set(O);return B.has(S)?B.delete(S):B.add(S),B})},[]),A=g.useCallback(S=>{if(c(S.id),!r)return;const{editor:O,monaco:B}=r,N=O.getModel();if(!N)return;const R=N.getPositionAt(S.start),T=N.getPositionAt(S.end),F=new B.Range(R.lineNumber,R.column,T.lineNumber,T.column);O.revealRangeNearTopIfOutsideViewport(F,B.editor.ScrollType.Smooth),O.setPosition(R),O.focus();const $=O.deltaDecorations([],[{range:F,options:{className:"jto-outline-flash"}}]);window.setTimeout(()=>O.deltaDecorations($,[]),700)},[r]),E=g.useCallback(S=>{var ye;if(!r||!S.overId)return;const{editor:O,monaco:B,collapse:N}=r,R=O.getModel();if(!R)return;const T=R.getValue(),F=Pl(T,at,i),$=S.parentId?((ye=Ob(F,S.parentId))==null?void 0:ye.children)??[]:F,Z=$.findIndex(ce=>ce.id===S.dragId),P=$.findIndex(ce=>ce.id===S.overId);if(Z===-1||P===-1)return;let J=P+(S.overHalf==="after"?1:0);Z<J&&(J-=1);const V=Ab(T,$,Z,J);if(!V)return;const X=R.getPositionAt(V.start),j=R.getPositionAt(V.end);O.executeEdits("outline-reorder",[{range:new B.Range(X.lineNumber,X.column,j.lineNumber,j.column),text:V.text}]),N==null||N.resyncDecorations()},[r,i]),w=g.useMemo(()=>{const S=[],O=(B,N,R)=>{var $,Z;const T=(Z=($=B[0])==null?void 0:$.reorder)==null?void 0:Z.groupId,F=B.length>1&&T!==void 0&&B.every(P=>{var J;return((J=P.reorder)==null?void 0:J.groupId)===T});B.forEach(P=>{const J=zb[P.kind]??dx,V=P.children.length>0,X=f.has(P.id),j=a===P.id,ye=(p==null?void 0:p.overId)===P.id;S.push(l.jsxs("div",{"data-oid":P.id,role:"treeitem","aria-selected":j,"aria-expanded":V?X:void 0,tabIndex:0,draggable:F,onClick:()=>A(P),onKeyDown:ce=>{(ce.key==="Enter"||ce.key===" ")&&(ce.preventDefault(),A(P)),ce.key==="ArrowRight"&&V&&!X&&x(P.id),ce.key==="ArrowLeft"&&V&&X&&x(P.id)},onDragStart:ce=>{ce.dataTransfer.setData("text/plain",P.id),ce.dataTransfer.effectAllowed="move",m({dragId:P.id,parentId:R,overId:null,overHalf:"before"})},onDragOver:ce=>{if(!p||p.dragId===P.id||Pb(p.dragId)!==R)return;ce.preventDefault(),ce.dataTransfer.dropEffect="move";const b=ce.currentTarget.getBoundingClientRect(),G=ce.clientY<b.top+b.height/2?"before":"after";(p.overId!==P.id||p.overHalf!==G)&&m({...p,overId:P.id,overHalf:G})},onDrop:ce=>{ce.preventDefault(),p&&E({...p,overId:P.id,overHalf:p.overHalf}),m(null)},onDragEnd:()=>m(null),className:W("group flex h-6 w-full cursor-pointer items-center gap-1 rounded-sm pr-1","text-[12px] text-sidebar-foreground/80 transition-colors select-none","hover:bg-sidebar-accent hover:text-sidebar-foreground","focus-visible:ring-sidebar-ring focus-visible:ring-1 focus-visible:outline-none",j&&"bg-sidebar-accent font-medium text-sidebar-foreground",ye&&(p==null?void 0:p.overHalf)==="before"&&"shadow-[inset_0_2px_0_hsl(var(--ring))]",ye&&(p==null?void 0:p.overHalf)==="after"&&"shadow-[inset_0_-2px_0_hsl(var(--ring))]"),style:{paddingLeft:4+N*12},children:[V?l.jsx("span",{role:"button","aria-label":X?"Collapse":"Expand",onClick:ce=>{ce.stopPropagation(),x(P.id)},className:"flex size-3.5 shrink-0 items-center justify-center rounded-xs text-sidebar-foreground/55 hover:text-sidebar-foreground",children:l.jsx(Cr,{className:W("size-3 transition-transform",X&&"rotate-90")})}):l.jsx("span",{className:"size-3.5 shrink-0"}),P.kind==="slide"&&l.jsx("span",{className:"w-3 shrink-0 text-right text-[10px] tabular-nums text-sidebar-foreground/50",children:P.detail}),l.jsx(J,{className:"size-3.5 shrink-0 text-sidebar-foreground/55"}),l.jsx("span",{className:"min-w-0 flex-1 truncate",children:P.label}),P.kind!=="slide"&&P.detail&&l.jsx("span",{className:"shrink-0 text-[10px] text-sidebar-foreground/50",children:P.detail}),u.has(P.id)&&l.jsx("span",{"aria-label":"Contains validation errors",className:"bg-destructive size-1.5 shrink-0 rounded-full"})]},P.id)),V&&X&&O(P.children,N+1,P.id)})};return O(s,0,""),S},[s,f,a,u,p,A,x,E]);return!e||s.length===0?null:l.jsx("li",{className:"list-none",children:l.jsx("div",{ref:k,role:"tree","aria-label":`Outline of ${e}`,className:"border-sidebar-border/70 my-0.5 ml-[15px] max-h-[38vh] overflow-y-auto border-l pl-1",children:w})})}const Dl=g.memo(Db);async function Rb(e,t){const n=JSON.stringify({name:e,props:t,children:[]},null,2);await navigator.clipboard.writeText(n)}const ui=g.forwardRef(({className:e,children:t,...n},r)=>l.jsxs(Md,{ref:r,className:W("relative overflow-hidden",e),...n,children:[l.jsx(Wg,{className:"h-full w-full rounded-[inherit]",children:t}),l.jsx(Uf,{}),l.jsx(qg,{})]}));ui.displayName=Md.displayName;const Uf=g.forwardRef(({className:e,orientation:t="vertical",...n},r)=>l.jsx(Fd,{ref:r,orientation:t,className:W("flex touch-none transition-colors select-none",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:l.jsx(Gg,{className:"bg-border relative flex-1 rounded-full"})}));Uf.displayName=Fd.displayName;function Pa({className:e,...t}){return l.jsx(Kg,{"data-slot":"switch",className:W("peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-switch-off focus-visible:ring-ring inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent transition-colors outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 cursor-pointer",e),...t,children:l.jsx(Yg,{"data-slot":"switch-thumb",className:W("bg-background pointer-events-none block size-4 rounded-full shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0")})})}const $b=Si("relative w-full rounded-sm border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7",{variants:{variant:{default:"bg-card text-foreground",destructive:"border-transparent bg-destructive-bg text-destructive-bg-foreground [&>svg]:text-destructive-bg-foreground",warning:"border-transparent bg-warning-bg text-warning-bg-foreground [&>svg]:text-warning-bg-foreground",success:"border-transparent bg-success-bg text-success-bg-foreground [&>svg]:text-success-bg-foreground",info:"border-transparent bg-data-blue-bg text-data-blue-bg-foreground [&>svg]:text-data-blue-bg-foreground"}},defaultVariants:{variant:"default"}}),lr=g.forwardRef(({className:e,variant:t,...n},r)=>l.jsx("div",{ref:r,role:"alert",className:W($b({variant:t}),e),...n}));lr.displayName="Alert";const Mb=g.forwardRef(({className:e,...t},n)=>l.jsx("h5",{ref:n,className:W("mb-1 font-medium leading-none tracking-tight",e),...t}));Mb.displayName="AlertTitle";const cr=g.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:W("text-sm [&_p]:leading-relaxed",e),...t}));cr.displayName="AlertDescription";const os=g.memo(({keyName:e,value:t,depth:n=0,isLast:r=!1})=>{const[i,s]=g.useState(n<2),o=t!==null&&typeof t=="object",a=Array.isArray(t),c=()=>s(!i),u=()=>t===null?l.jsx("span",{className:"text-muted-foreground",children:"null"}):t===void 0?l.jsx("span",{className:"text-muted-foreground",children:"undefined"}):typeof t=="boolean"?l.jsx("span",{className:"text-warning",children:String(t)}):typeof t=="number"?l.jsx("span",{className:"text-success",children:t}):typeof t=="string"?t.startsWith("http")?l.jsxs("span",{className:"text-data-blue",children:['"',t,'"']}):t.startsWith("#/")?l.jsxs("span",{className:"text-warning",children:['"',t,'"']}):l.jsxs("span",{className:"text-destructive",children:['"',t,'"']}):null,d=o?Object.keys(t).length:0;return l.jsxs("div",{className:W("text-sm",n>0&&"ml-4"),children:[l.jsxs("div",{className:"flex items-start hover:bg-muted/30 rounded-sm px-1 py-0.5",children:[o&&l.jsx("button",{onClick:c,className:"mr-1 hover:bg-muted rounded-sm p-0.5","aria-label":i?"Collapse":"Expand",children:i?l.jsx(ki,{className:"h-3 w-3"}):l.jsx(Cr,{className:"h-3 w-3"})}),!o&&l.jsx("span",{className:"w-4"}),e&&l.jsxs(l.Fragment,{children:[l.jsxs("span",{className:"text-data-blue",children:['"',e,'"']}),l.jsx("span",{className:"mx-1",children:":"})]}),o?l.jsxs("span",{className:"text-muted-foreground",children:[a?"[":"{",!i&&l.jsxs("span",{className:"mx-1 text-xs",children:[d," ",a?"items":"properties"]}),!i&&(a?"]":"}")]}):u(),!o&&!r&&l.jsx("span",{className:"text-muted-foreground",children:","})]}),o&&i&&l.jsxs("div",{className:"ml-4",children:[a?t.map((f,h)=>l.jsx(os,{keyName:String(h),value:f,depth:n+1,isLast:h===t.length-1},h)):Object.entries(t).map(([f,h],p,m)=>l.jsx(os,{keyName:f,value:h,depth:n+1,isLast:p===m.length-1},f)),l.jsx("div",{className:"ml-4",children:l.jsxs("span",{className:"text-muted-foreground",children:[a?"]":"}",!r&&","]})})]})]})});os.displayName="JsonNode";const as=g.memo(({schema:e,loading:t=!1,error:n,className:r})=>t?l.jsxs("div",{className:W("space-y-4",r),children:[l.jsx(ti,{className:"h-8 w-64"}),l.jsx(ti,{className:"h-4 w-full"}),l.jsx(ti,{className:"h-64 w-full"})]}):n?l.jsx(lr,{variant:"destructive",className:r,children:l.jsx(cr,{children:n})}):e?l.jsx(ui,{className:W("h-full w-full rounded-md border bg-muted/10 p-4",r),children:l.jsx("div",{className:"font-mono text-xs",children:l.jsx(os,{value:e})})}):l.jsx(lr,{className:r,children:l.jsx(cr,{children:"No schema available"})}));as.displayName="SchemaViewer";function Fb({plugins:e,initialFocusedPlugin:t}){var x,A;const n=Jt(E=>E.togglePlugin),r=Jt(E=>E.isPluginSelected),i=Jt(E=>E.selectedPlugins),s=Jt(E=>E.isApplyingPlugins),[o,a]=g.useState(null),[c,u]=g.useState(null),[d,f]=g.useState("properties");g.useEffect(()=>{if(t){const E=e.find(w=>w.name===t);if(E){a(E);return}}e.length>0&&!o&&a(e[0])},[t,e]);const h=g.useMemo(()=>{const E={current:[],downstream:[],upstream:[]};return e.forEach(w=>{E[w.location]&&E[w.location].push(w)}),E},[e]),p=async(E,w)=>{o&&(await Rb(o.name,E.props),u(w),setTimeout(()=>u(null),2e3))},m=E=>{switch(E){case"current":return"Current Directory";case"downstream":return"Project";case"upstream":return"Parent Directories";default:return E}},v=E=>{switch(E){case"current":return l.jsx(xx,{className:"size-3"});case"downstream":return l.jsx(gx,{className:"size-3"});case"upstream":return l.jsx(Hd,{className:"size-3"});default:return null}},k=((x=o==null?void 0:o.schema)==null?void 0:x.properties)&&Object.keys(o.schema.properties).length>0,y=(A=o==null?void 0:o.schema)==null?void 0:A.jsonSchema,_=(o==null?void 0:o.examples)&&o.examples.length>0;return l.jsxs(l.Fragment,{children:[l.jsxs(qt,{children:[l.jsxs(Gt,{className:"flex items-center gap-2",children:[l.jsx(fx,{className:"size-5 text-warning"}),"Plugins",l.jsxs(tn,{variant:"secondary",className:"font-normal",children:[i.size," active"]})]}),l.jsxs(dn,{children:[e.length," plugin",e.length!==1?"s":""," discovered in your project"]})]}),l.jsxs("div",{className:"mt-3 flex gap-0 h-[600px] border rounded-lg overflow-hidden",children:[l.jsx("div",{className:"w-[240px] flex-none border-r bg-muted/30",children:l.jsx(ui,{className:"h-full",children:l.jsx("div",{className:"p-2 space-y-3",children:Object.entries(h).map(([E,w])=>w.length===0?null:l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1 text-[11px] font-medium text-muted-foreground uppercase tracking-wider",children:[v(E),m(E)]}),l.jsx("div",{className:"space-y-0.5",children:w.map(S=>{const O=r(S.name),B=(o==null?void 0:o.name)===S.name;return l.jsxs("button",{onClick:()=>a(S),className:W("w-full text-left px-2 py-1.5 rounded-md transition-colors cursor-pointer","flex items-center gap-2",B?"bg-accent text-accent-foreground":"hover:bg-accent/50 text-foreground"),children:[l.jsx("div",{className:W("size-1.5 rounded-full flex-none transition-colors",O?"bg-warning":"bg-muted-foreground/30")}),l.jsx("span",{className:"text-sm font-medium truncate flex-1",children:S.name})]},S.name)})})]},E))})})}),o?l.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[l.jsxs("div",{className:"flex-none px-5 py-4 border-b bg-background",children:[l.jsxs("div",{className:"flex items-start justify-between gap-3",children:[l.jsxs("div",{className:"min-w-0",children:[l.jsxs("div",{className:"flex items-center gap-2.5",children:[l.jsx("h3",{className:"text-base font-semibold truncate",children:o.name}),o.version&&l.jsxs(tn,{variant:"outline",className:"font-mono text-[11px] flex-none",children:["v",o.version]})]}),o.description&&l.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:o.description})]}),l.jsxs("div",{className:"flex items-center gap-2 flex-none pt-0.5",children:[l.jsx("span",{className:"text-xs text-muted-foreground",children:r(o.name)?"On":"Off"}),l.jsx(Pa,{checked:r(o.name),onCheckedChange:()=>n(o),disabled:s,"aria-label":`Toggle ${o.name}`})]})]}),l.jsxs("div",{className:"flex items-center gap-1.5 mt-2 text-xs text-muted-foreground",children:[v(o.location),l.jsx("span",{children:m(o.location)}),l.jsx("span",{className:"text-muted-foreground/60 mx-1",children:"/"}),l.jsx("span",{className:"font-mono truncate",children:o.relativePath})]})]}),l.jsxs("div",{className:"flex-none px-5 pt-3 pb-0 flex gap-1 border-b bg-background",children:[k&&l.jsx("button",{onClick:()=>f("properties"),className:W("px-3 py-1.5 text-sm font-medium rounded-t-md border-b-2 transition-colors cursor-pointer",d==="properties"?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),children:l.jsxs("span",{className:"flex items-center gap-1.5",children:[l.jsx(Qi,{className:"size-3.5"}),"Properties"]})}),y&&l.jsx("button",{onClick:()=>f("schema"),className:W("px-3 py-1.5 text-sm font-medium rounded-t-md border-b-2 transition-colors cursor-pointer",d==="schema"?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),children:l.jsxs("span",{className:"flex items-center gap-1.5",children:[l.jsx(px,{className:"size-3.5"}),"Schema"]})}),_&&l.jsx("button",{onClick:()=>f("examples"),className:W("px-3 py-1.5 text-sm font-medium rounded-t-md border-b-2 transition-colors cursor-pointer",d==="examples"?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),children:l.jsxs("span",{className:"flex items-center gap-1.5",children:[l.jsx(hx,{className:"size-3.5"}),"Examples",l.jsx(tn,{variant:"secondary",className:"text-[10px] px-1.5 py-0 h-4",children:o.examples.length})]})})]}),l.jsx(ui,{className:"flex-1",children:l.jsxs("div",{className:"p-5",children:[d==="properties"&&k&&l.jsx("div",{className:"space-y-1",children:Object.entries(o.schema.properties).map(([E,w])=>l.jsx(Lb,{name:E,prop:w},E))}),d==="schema"&&y&&l.jsx(as,{schema:o.schema.jsonSchema,loading:!1,className:"h-[420px]"}),d==="examples"&&_&&o.examples.map((E,w)=>l.jsxs("div",{className:W(w>0&&"mt-4 pt-4 border-t"),children:[l.jsxs("div",{className:"flex items-center justify-between mb-2",children:[l.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[E.title&&l.jsx("span",{className:"font-medium text-sm truncate",children:E.title}),!E.title&&l.jsxs("span",{className:"text-sm text-muted-foreground",children:["Example ",w+1]})]}),l.jsx(Ce,{size:"sm",variant:"ghost",className:"h-7 px-2 text-xs flex-none",onClick:()=>p(E,w),children:c===w?l.jsxs(l.Fragment,{children:[l.jsx(mx,{className:"size-3 mr-1 text-success"}),"Copied"]}):l.jsxs(l.Fragment,{children:[l.jsx(Es,{className:"size-3 mr-1"}),"Copy"]})})]}),E.description&&l.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:E.description}),l.jsx("pre",{className:"p-3 bg-muted rounded-md overflow-x-auto text-xs font-mono leading-relaxed",children:JSON.stringify(E.props,null,2)})]},w)),!k&&!y&&!_&&l.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[l.jsx(Qi,{className:"size-10 mx-auto mb-3 opacity-20"}),l.jsx("p",{className:"text-sm",children:"No schema or examples available for this plugin"})]})]})})]}):l.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:l.jsx("p",{className:"text-sm",children:"Select a plugin to view details"})})]})]})}function Lb({name:e,prop:t}){var o;const[n,r]=g.useState(!1),i=t.description||t.enum||t.default!==void 0||t.items||t.properties,s=t.type||(t.enum?"enum":t.oneOf?"oneOf":"—");return l.jsxs("div",{className:"rounded-md border",children:[l.jsxs("button",{onClick:()=>i&&r(!n),className:W("w-full text-left flex items-center gap-2 px-3 py-2 text-sm",i&&"cursor-pointer hover:bg-muted/50"),children:[i?n?l.jsx(ki,{className:"size-3 text-muted-foreground flex-none"}):l.jsx(Cr,{className:"size-3 text-muted-foreground flex-none"}):l.jsx("span",{className:"size-3 flex-none"}),l.jsx("span",{className:"font-mono font-medium text-xs",children:e}),l.jsx(tn,{variant:"outline",className:"text-[10px] px-1.5 py-0 h-4 flex-none",children:s}),t.optional===!1&&l.jsx("span",{className:"text-[10px] text-destructive font-medium flex-none",children:"required"}),l.jsx("span",{className:"flex-1"}),t.default!==void 0&&l.jsxs("span",{className:"text-[10px] font-mono text-muted-foreground flex-none",children:["= ",JSON.stringify(t.default)]})]}),n&&i&&l.jsxs("div",{className:"px-3 pb-2 pt-0 ml-5 text-xs space-y-1 text-muted-foreground",children:[t.description&&l.jsx("p",{children:t.description}),t.enum&&l.jsxs("p",{children:[l.jsx("span",{className:"font-medium text-foreground",children:"Values: "}),t.enum.map((a,c)=>l.jsxs("span",{children:[c>0&&", ",l.jsx("code",{className:"bg-muted px-1 rounded-sm",children:JSON.stringify(a)})]},c))]}),((o=t.items)==null?void 0:o.type)&&l.jsxs("p",{children:[l.jsx("span",{className:"font-medium text-foreground",children:"Items: "}),t.items.type]})]})]})}const Bb={current:"Current directory",downstream:"Project"};function Rl({location:e}){return l.jsx("li",{className:"list-none px-2 pt-2 pb-0.5 text-[10px] tracking-[0.08em] text-sidebar-foreground/65 uppercase",children:Bb[e]??e})}function $l({name:e,subtitle:t,query:n,onSelect:r}){return l.jsx("li",{className:"list-none",children:l.jsxs("button",{type:"button",onClick:r,title:t?`${e} — ${t}`:e,"aria-label":`Add ${e} to workspace`,className:W("group/row flex h-7 w-full cursor-pointer items-center gap-2 rounded-sm pr-1 pl-2","text-[13px] text-sidebar-foreground/70 transition-colors","hover:bg-sidebar-accent/60 hover:text-sidebar-foreground","focus-visible:ring-sidebar-ring focus-visible:ring-1 focus-visible:outline-none"),children:[l.jsx("span",{className:"min-w-0 flex-1 truncate text-left",children:l.jsx(zs,{text:e,query:n})}),l.jsx(Dt,{"aria-hidden":!0,className:"size-3.5 shrink-0 text-sidebar-foreground/45 opacity-0 transition-opacity group-hover/row:opacity-100 group-focus-visible/row:opacity-100"})]})})}function Ml({children:e}){return l.jsx("div",{className:"px-2 pt-2 pb-0.5 text-[10px] tracking-[0.08em] text-sidebar-foreground/65 uppercase",children:e})}function Zb({document:e,query:t}){var B;const n=g.useRef(null),[r,i]=g.useState(!1),[s,o]=g.useState(!1),[a,c]=g.useState(!1),[u,d]=g.useState(!1),f=ke(N=>N.openDocument),h=ke(N=>N.activeTab),p=vn(N=>N.records[e.name]),m=vn(N=>N.setEnabled),v=h===e.name,k=(p==null?void 0:p.enabled)??!0,y=(p==null?void 0:p.status)??"idle",_=(B=p==null?void 0:p.metadata)==null?void 0:B.name,x=((p==null?void 0:p.diagnostics)??[]).filter(N=>N.severity==="error").length,A=y==="ready"?`Ready${_?` — used as "${_}"`:""}`:y==="error"?x>0?`${x} error${x===1?"":"s"} — open to fix`:"Failed to load — open to fix":y==="compiling"?"Compiling…":"Not compiled yet",E=g.useCallback(N=>{m(e.name,N),window.dispatchEvent(new CustomEvent(hg,{detail:{docName:e.name}}))},[e.name,m]),w=g.useMemo(()=>[{key:"open",label:"Open",run:()=>f(e.name)},{key:"download",label:"Download…",separatorBefore:!0,run:()=>ni(e.name,new Blob([e.text],{type:"text/typescript"}))},{key:"rename",label:"Rename…",separatorBefore:!0,run:()=>c(!0)},{key:"delete",label:"Delete",danger:!0,run:()=>d(!0)}],[e.name,e.text,f]),S=`browser-plugin-${e.name}`,O=r||s;return l.jsxs("li",{className:"group/menu-item relative list-none",children:[l.jsxs(_f,{onOpenChange:o,children:[l.jsx(Nf,{className:"block",children:l.jsxs("div",{className:W("flex h-7 w-full items-center gap-1 rounded-sm pr-1 pl-2 transition-colors","hover:bg-sidebar-accent/60",O&&"bg-sidebar-accent/60",v&&"bg-sidebar-accent font-medium"),title:`${e.name} — ${A}`,children:[v&&l.jsx("span",{"aria-hidden":!0,className:"bg-primary absolute top-1 bottom-1 left-0 w-[2px] rounded-full"}),l.jsxs("button",{ref:n,type:"button",onClick:()=>f(e.name),"aria-label":`${e.name} — ${A}`,className:W("flex h-7 min-w-0 flex-1 cursor-pointer items-center gap-2 text-[13px]","focus-visible:ring-sidebar-ring rounded-sm focus-visible:ring-1 focus-visible:outline-none",k?"text-sidebar-foreground/85":"text-sidebar-foreground/60"),children:[l.jsx(Jd,{className:W("size-3.5 shrink-0",v?"text-sidebar-accent-foreground/70":"text-sidebar-foreground/60")}),l.jsx("span",{className:"truncate",children:l.jsx(zs,{text:e.name,query:t})}),y==="compiling"&&l.jsx(cn,{size:"sm",className:"shrink-0"}),y==="ready"&&l.jsx(yx,{"aria-hidden":!0,className:"size-3 shrink-0 text-success"}),y==="error"&&l.jsx(bx,{"aria-hidden":!0,className:"size-3 shrink-0 text-destructive"})]}),l.jsxs(_i,{onOpenChange:i,children:[l.jsx(Ni,{asChild:!0,children:l.jsx(Et,{"aria-label":`Actions for ${e.name}`,className:W("opacity-0 group-hover/menu-item:opacity-100 focus-visible:opacity-100",O&&"opacity-100"),children:l.jsx(ba,{})})}),l.jsx(Er,{side:"right",align:"start",className:"w-44",children:w.map(N=>l.jsxs(je.Fragment,{children:[N.separatorBefore&&l.jsx(Fn,{}),l.jsx($t,{onClick:N.run,className:W(N.danger&&"text-destructive focus:text-destructive"),children:N.label})]},N.key))})]}),l.jsx(Pa,{id:S,checked:k,onCheckedChange:E,className:"shrink-0","aria-label":`Enable ${e.name}`,title:"On: expanded in every build. Off: a document that names it fails to build until it is switched back on."})]})}),l.jsx(Ta,{className:"w-44",children:w.map(N=>l.jsxs(je.Fragment,{children:[N.separatorBefore&&l.jsx(Aa,{}),l.jsx(Ia,{onClick:N.run,className:W(N.danger&&"text-destructive focus:text-destructive"),children:N.label})]},N.key))})]}),l.jsx(ct,{open:a,onOpenChange:c,children:l.jsx(lt,{className:"sm:max-w-[425px]",onCloseAutoFocus:N=>{var R;N.preventDefault(),(R=n.current)==null||R.focus()},children:l.jsx(Dn,{mode:"update",shouldReset:!a,postSubmit:()=>c(!1),selectedName:e.name,isPlugin:!0})})}),l.jsx(ct,{open:u,onOpenChange:d,children:l.jsx(lt,{className:"sm:max-w-[425px]",onCloseAutoFocus:N=>{var R;N.preventDefault(),(R=n.current)==null||R.focus()},children:l.jsx(Dn,{mode:"delete",shouldReset:!u,postSubmit:()=>d(!1),selectedName:e.name,isPlugin:!0})})})]})}const Vb=je.memo(Zb);function Ub({plugins:e,browserPlugins:t,query:n,open:r,onToggleSection:i,onShowPluginDetails:s,onNewPlugin:o,isPluginSelected:a,onTogglePlugin:c,isApplyingPlugins:u,diskPluginsLoadable:d,activeCount:f,totalCount:h}){const p=e.length>0&&t.length>0;return l.jsxs("section",{className:"border-sidebar-border/70 mt-3 border-t pt-2",children:[l.jsx(Zo,{open:r,onToggle:i,count:h>0?`${f}/${h}`:void 0,actions:l.jsxs(Ye,{children:[l.jsx(Xe,{asChild:!0,children:l.jsx(Et,{"aria-label":"New plugin",onClick:o,children:l.jsx(Dt,{})})}),l.jsx(Qe,{side:"bottom",children:"New plugin"})]}),children:"Plugins"}),r&&l.jsxs("div",{className:"flex flex-col gap-0.5",children:[p&&l.jsx(Ml,{children:"In this browser"}),l.jsx("ul",{className:"flex flex-col gap-0.5",children:t.map(m=>l.jsx(Vb,{document:m,query:n},m.name))}),p&&l.jsx(Ml,{children:"On disk"}),e.length>0&&!d&&l.jsxs("p",{className:"text-sidebar-foreground/60 px-2 pt-0.5 pb-1 text-[11px] leading-snug",children:["This server does not load plugins from disk, so these cannot be switched on. Set ",l.jsx("code",{children:"PLUGIN_AUTOLOAD=true"})," on the deployment, or write one in the browser."]}),e.map(m=>{const v=a(m.name)&&d,k=`plugin-switch-${m.filePath||m.name}`;return l.jsxs("div",{title:m.description?`${m.name} — ${m.description}`:m.name,className:W("group/row flex h-7 w-full items-center gap-1 rounded-sm pr-1 pl-2","transition-colors hover:bg-sidebar-accent/60"),children:[l.jsx("button",{type:"button",onClick:()=>s(m.name),"aria-label":`Details for ${m.name}`,className:W("flex h-7 min-w-0 flex-1 cursor-pointer items-center text-[13px]","focus-visible:ring-sidebar-ring rounded-sm focus-visible:ring-1 focus-visible:outline-none",v?"text-sidebar-foreground":"text-sidebar-foreground/70"),children:l.jsx("span",{className:"truncate",children:l.jsx(zs,{text:m.name,query:n})})}),l.jsx(Et,{"aria-label":`Details for ${m.name}`,onClick:y=>{y.stopPropagation(),s(m.name)},className:"opacity-0 group-hover/row:opacity-100 focus-visible:opacity-100",children:l.jsx(qd,{})}),l.jsx(Pa,{id:k,checked:v,onCheckedChange:()=>c(m),disabled:u||!d,className:"shrink-0","aria-label":`Toggle ${m.name} plugin`,title:d?"On: the server loads this plugin from disk for every build.":"This server does not load plugins from disk (PLUGIN_AUTOLOAD is off)."})]},m.filePath||m.name)}),e.length+t.length===0&&l.jsx(Vo,{icon:Dt,label:"New plugin",hint:"Write a custom component in TypeScript, in the browser",onClick:o})]})]})}function Fl(e){return g.useMemo(()=>{const t=["current","downstream"],n=new Map;return e.forEach(r=>{const i=n.get(r.location);i?i.push(r):n.set(r.location,[r])}),[...n.entries()].sort(([r],[i])=>t.indexOf(r)-t.indexOf(i))},[e])}function Jf({children:e,className:t}){return l.jsx("kbd",{"data-slot":"kbd",className:W("pointer-events-none inline-flex h-5 w-fit min-w-5 select-none items-center justify-center gap-1 rounded-sm bg-muted px-1 font-sans text-xs font-medium text-muted-foreground",t),children:e})}function Jb({children:e,className:t}){return l.jsx("span",{className:W("inline-flex items-center gap-0.5",t),children:e})}const Ri=typeof navigator<"u"&&/Mac|iPod|iPhone|iPad/.test(navigator.platform);function di({shortcut:e,className:t}){const r=e.split("+").map(i=>i.trim().toLowerCase()).map(i=>{switch(i){case"mod":return Ri?"⌘":"Ctrl";case"shift":return Ri?"⇧":"Shift";case"alt":return Ri?"⌥":"Alt";case"ctrl":return Ri?"⌃":"Ctrl";case"enter":return"↵";default:return i.toUpperCase()}});return l.jsx(Jb,{className:t,children:r.map((i,s)=>l.jsx(Jf,{children:i},s))})}function Hb({className:e}={}){const{theme:t,setTheme:n}=od(),r=t==="system"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":t,i=g.useCallback(()=>{n(r==="dark"?"light":"dark")},[r,n]);return l.jsxs(Ye,{children:[l.jsx(Xe,{asChild:!0,children:l.jsxs(Ce,{variant:"ghost",size:"icon",onClick:i,className:e,children:[l.jsx(vx,{className:"hidden dark:block"}),l.jsx(wx,{className:"block dark:hidden"}),l.jsx("span",{className:"sr-only",children:"Toggle theme"})]})}),l.jsx(Qe,{children:l.jsx("p",{children:"Toggle theme"})})]})}function Wb({discoveryData:e,onToggleSidebar:t,isCollapsed:n=!1,isAnimating:r=!1}){const{documents:i,documentTypes:s,createDocument:o,openDocument:a,activeTab:c}=ke(wa(D=>({documents:D.documents,documentTypes:D.documentTypes,createDocument:D.createDocument,openDocument:D.openDocument,activeTab:D.activeTab}))),u=Io(D=>D.updateTheme),d=Io(D=>D.removeTheme),f=g.useContext(xa),[h,p]=g.useState(!1),[m,v]=g.useState(!1),[k,y]=g.useState(!1),[_,x]=g.useState(!1),A=vn(D=>rd(D).length),[E,w]=g.useState(null),S=Jt(D=>D.togglePlugin),O=Jt(D=>D.isPluginSelected),B=Jt(D=>D.selectedPlugins),N=Jt(D=>D.isApplyingPlugins),[R,T]=g.useState(!1),[F,$]=g.useState(new Set(["documents","themes"])),[Z,P]=g.useState(""),J=g.useRef(null),{toast:V}=_r(),X=i.filter(D=>(s[D.name]??"application/json+report")==="application/json+report"),j=i.filter(D=>s[D.name]==="application/json+theme"),ye=i.filter(D=>s[D.name]==="application/typescript+plugin"),ce=g.useCallback(()=>{p(!1)},[]),b=g.useCallback(()=>{v(!1)},[]),G=g.useCallback(()=>{y(!1),$(D=>new Set(D).add("plugins"))},[]),ne=g.useRef(new Map);g.useEffect(()=>{const D=ne.current,xe=new Map;j.forEach(de=>{xe.set(de.name,de.text),D.get(de.name)!==de.text&&u(de.name,de.text)}),D.forEach((de,Me)=>{xe.has(Me)||d(Me)}),ne.current=xe},[j,u,d]);const Q=g.useRef(!1);g.useEffect(()=>{if(Q.current||!f)return;Q.current=!0;const D=new Set(j.map(de=>de.name));Object.keys(f.getState().customThemes).forEach(de=>{D.has(de)||d(de)})},[j,d,f]);const oe=g.useCallback(D=>{$(xe=>{const de=new Set(xe);return de.has(D)?de.delete(D):de.add(D),de})},[]),{resolvedTheme:I}=od(),re=I==="dark"?"https://ik.imagekit.io/wiseair/Brand%20assets/wiseair-logo-white.svg?updatedAt=1751359555877":"https://ik.imagekit.io/wiseair/Brand%20assets/wiseair-logo.svg?updatedAt=1749817149276",ae=g.useCallback(async(D,xe)=>{if(i.some(de=>de.name===D)){a(D);return}try{const de=await fetch(`/api/discovery/${xe?"themes":"documents"}/${encodeURIComponent(D)}/content`);if(!de.ok)throw new Error(de.statusText);const Me=await de.text(),Je=JSON.parse(Me);o(D,JSON.stringify(Je,null,2),{templateSource:D}),a(D),V({title:`Added ${xe?"theme":"document"}: ${D}`})}catch{V({title:"Failed to load",description:`Could not load ${D}`,variant:"destructive"})}},[i,o,a,V]);g.useEffect(()=>{if(n)return;const D=xe=>{var Je,it,Lt,Ot,ml;if(xe.key!=="/"||xe.metaKey||xe.ctrlKey||xe.altKey)return;const de=xe.target,Me=(Je=de==null?void 0:de.tagName)==null?void 0:Je.toLowerCase();Me==="input"||Me==="textarea"||Me==="select"||de!=null&&de.isContentEditable||(it=de==null?void 0:de.closest)!=null&&it.call(de,".monaco-editor")||(Lt=J.current)!=null&&Lt.closest('[aria-hidden="true"], [inert]')||(xe.preventDefault(),(Ot=J.current)==null||Ot.focus(),(ml=J.current)==null||ml.select())};return window.addEventListener("keydown",D),()=>window.removeEventListener("keydown",D)},[n]);const H=Z.trim(),K=g.useMemo(()=>new Set(i.map(D=>D.name)),[i]),pe=g.useMemo(()=>X.filter(D=>on(D.name,H)),[X,H]),fe=g.useMemo(()=>j.filter(D=>on(D.name,H)),[j,H]),Re=g.useMemo(()=>ye.filter(D=>on(D.name,H)),[ye,H]),Oe=g.useMemo(()=>((e==null?void 0:e.documents)??[]).filter(D=>!K.has(D.name)&&(on(D.name,H)||on(D.title??"",H))),[e,H,K]),$e=g.useMemo(()=>((e==null?void 0:e.themes)??[]).filter(D=>!K.has(D.name)&&(on(D.name,H)||on(D.description??"",H))),[e,H,K]),C=Fl(Oe),z=Fl($e),L=(e==null?void 0:e.pluginAutoload)??!0,se=g.useMemo(()=>(L?((e==null?void 0:e.plugins)??[]).filter(xe=>B.has(xe.name)).length:0)+A,[e,B,L,A]),ie=((e==null?void 0:e.plugins.length)??0)+ye.length,ee=g.useMemo(()=>((e==null?void 0:e.plugins)??[]).filter(D=>on(D.name,H)||on(D.description??"",H)),[e,H]),me=D=>H.length>0||F.has(D),we=me("documents"),U=me("themes"),Y=pe.length+Oe.length,ge=fe.length+$e.length,_e=H.length>0&&pe.length===0&&fe.length===0&&Re.length===0&&Oe.length===0&&$e.length===0&&ee.length===0,M=W("transition-opacity duration-150 ease-out",r?"opacity-0":"opacity-100");return l.jsxs(l.Fragment,{children:[l.jsxs(Rf,{collapsible:"none",style:{"--sidebar-width":n?"3rem":"16rem"},children:[n?l.jsxs(l.Fragment,{children:[l.jsx(Uo,{className:W("gap-0 p-1.5",M),children:l.jsxs(Ye,{children:[l.jsx(Xe,{asChild:!0,children:l.jsx(Et,{className:"mx-auto size-7","aria-label":"Expand sidebar","aria-expanded":!1,onClick:t,children:l.jsx(Gd,{})})}),l.jsxs(Qe,{side:"right",className:"flex items-center gap-2",children:[l.jsx("span",{children:"Expand sidebar"}),l.jsx(di,{shortcut:"mod+b"})]})]})}),l.jsxs(Jo,{className:W("gap-2 px-1 py-1",M),children:[l.jsxs(er,{className:"items-center gap-0.5",children:[X.map(D=>l.jsx(Mr,{document:D,compact:!0},D.name)),l.jsxs(Ye,{children:[l.jsx(Xe,{asChild:!0,children:l.jsx(Et,{className:"size-7","aria-label":"New document",onClick:()=>p(!0),children:l.jsx(Dt,{})})}),l.jsx(Qe,{side:"right",children:"New document"})]})]}),l.jsx("div",{className:"bg-sidebar-border/70 mx-auto h-px w-6"}),l.jsxs(er,{className:"items-center gap-0.5",children:[j.map(D=>l.jsx(Mr,{document:D,compact:!0},D.name)),l.jsxs(Ye,{children:[l.jsx(Xe,{asChild:!0,children:l.jsx(Et,{className:"size-7","aria-label":"New theme",onClick:()=>v(!0),children:l.jsx(Dt,{})})}),l.jsx(Qe,{side:"right",children:"New theme"})]})]}),l.jsx("div",{className:"bg-sidebar-border/70 mx-auto h-px w-6"}),l.jsxs(er,{className:"items-center gap-0.5",children:[ye.map(D=>l.jsx(Mr,{document:D,compact:!0},D.name)),l.jsxs(Ye,{children:[l.jsx(Xe,{asChild:!0,children:l.jsx(Et,{className:"size-7","aria-label":"New plugin",onClick:()=>y(!0),children:l.jsx(Dt,{})})}),l.jsx(Qe,{side:"right",children:"New plugin"})]})]})]})]}):l.jsxs(l.Fragment,{children:[l.jsxs(Uo,{className:W("gap-0 p-2",M),children:[l.jsxs("div",{className:"flex h-7 items-center justify-between gap-1",children:[l.jsx("a",{href:"/","aria-label":"JSON to Office home",className:"focus-visible:ring-sidebar-ring flex items-center rounded-sm pl-1 focus-visible:ring-1 focus-visible:outline-none",children:l.jsx("img",{src:re,alt:"Wiseair",className:"h-[18px] w-auto max-w-[110px] shrink-0"})}),l.jsxs(Ye,{children:[l.jsx(Xe,{asChild:!0,children:l.jsx(Et,{"aria-label":"Collapse sidebar","aria-expanded":!0,onClick:t,children:l.jsx(kx,{})})}),l.jsxs(Qe,{side:"right",className:"flex items-center gap-2",children:[l.jsx("span",{children:"Collapse sidebar"}),l.jsx(di,{shortcut:"mod+b"})]})]})]}),l.jsxs("div",{className:"relative mt-2",children:[l.jsx(Sx,{"aria-hidden":!0,className:"pointer-events-none absolute top-1/2 left-2 size-3.5 -translate-y-1/2 text-sidebar-foreground/40"}),l.jsx("input",{ref:J,type:"text",value:Z,spellCheck:!1,autoComplete:"off",placeholder:"Filter files…","aria-label":"Filter documents, themes and plugins",onChange:D=>P(D.target.value),onKeyDown:D=>{D.key==="Escape"&&(D.preventDefault(),P(""),D.currentTarget.blur())},className:W("border-sidebar-border/70 bg-sidebar-accent/40 h-7 w-full rounded-sm border","pr-7 pl-7 text-[13px] text-sidebar-foreground transition-colors","placeholder:text-sidebar-foreground/60","focus-visible:border-sidebar-ring focus-visible:bg-sidebar-accent/60","focus-visible:ring-sidebar-ring focus-visible:ring-1 focus-visible:outline-none")}),H?l.jsx(Et,{"aria-label":"Clear filter",onClick:()=>{var D;P(""),(D=J.current)==null||D.focus()},className:"absolute top-1/2 right-1 -translate-y-1/2",children:l.jsx(wn,{})}):l.jsx(Jf,{className:"absolute top-1/2 right-1.5 h-4 min-w-4 -translate-y-1/2 bg-transparent px-0 text-[10px] text-sidebar-foreground/65",children:"/"})]})]}),l.jsx(Jo,{className:W("gap-0 px-2 pb-2",M),children:_e?l.jsxs("div",{className:"px-1 py-6 text-center",children:[l.jsxs("p",{className:"text-[13px] text-sidebar-foreground/70",children:["No files match “",H,"”"]}),l.jsx("button",{type:"button",onClick:()=>{var D;P(""),(D=J.current)==null||D.focus()},className:"text-sidebar-foreground/70 hover:text-sidebar-foreground focus-visible:ring-sidebar-ring mt-1 cursor-pointer rounded-sm text-[12px] underline-offset-2 hover:underline focus-visible:ring-1 focus-visible:outline-none",children:"Clear filter"})]}):l.jsxs(l.Fragment,{children:[(Y>0||!H)&&l.jsxs("section",{children:[l.jsx(Zo,{open:we,onToggle:()=>oe("documents"),count:Y||void 0,actions:l.jsxs(l.Fragment,{children:[at==="docx"&&l.jsxs(Ye,{children:[l.jsx(Xe,{asChild:!0,children:l.jsx(Et,{"aria-label":"Compare documents",disabled:X.length<2,onClick:()=>T(!0),children:l.jsx(Vd,{})})}),l.jsx(Qe,{side:"bottom",children:X.length<2?"Compare needs two documents":"Compare documents (redline)"})]}),l.jsxs(Ye,{children:[l.jsx(Xe,{asChild:!0,children:l.jsx(Et,{"aria-label":"New document",onClick:()=>p(!0),children:l.jsx(Dt,{})})}),l.jsx(Qe,{side:"bottom",children:"New document"})]})]}),children:"Documents"}),we&&l.jsxs(er,{className:"gap-0.5",children:[pe.map(D=>l.jsxs(g.Fragment,{children:[l.jsx(Mr,{document:D,query:H}),!H&&c===D.name&&l.jsx(Dl,{})]},D.name)),C.map(([D,xe])=>l.jsxs(g.Fragment,{children:[C.length>1&&l.jsx(Rl,{location:D}),xe.map(de=>l.jsx($l,{name:de.name,subtitle:de.title,query:H,onSelect:()=>ae(de.name,!1)},de.path||de.name))]},D)),Y===0&&l.jsx("li",{className:"list-none",children:l.jsx(Vo,{icon:Dt,label:"New document",onClick:()=>p(!0)})})]})]}),(ge>0||!H)&&l.jsxs("section",{className:"mt-3",children:[l.jsx(Zo,{open:U,onToggle:()=>oe("themes"),count:ge||void 0,actions:l.jsxs(Ye,{children:[l.jsx(Xe,{asChild:!0,children:l.jsx(Et,{"aria-label":"New theme",onClick:()=>v(!0),children:l.jsx(Dt,{})})}),l.jsx(Qe,{side:"bottom",children:"New theme"})]}),children:"Themes"}),U&&l.jsxs(er,{className:"gap-0.5",children:[fe.map(D=>l.jsxs(g.Fragment,{children:[l.jsx(Mr,{document:D,query:H}),!H&&c===D.name&&l.jsx(Dl,{})]},D.name)),z.map(([D,xe])=>l.jsxs(g.Fragment,{children:[z.length>1&&l.jsx(Rl,{location:D}),xe.map(de=>l.jsx($l,{name:de.name,subtitle:de.description,query:H,onSelect:()=>ae(de.name,!0)},de.path||de.name))]},D)),ge===0&&l.jsx("li",{className:"list-none",children:l.jsx(Vo,{icon:Dt,label:"New theme",onClick:()=>v(!0)})})]})]}),l.jsx(Ub,{plugins:ee,browserPlugins:Re,query:H,open:me("plugins"),onToggleSection:()=>oe("plugins"),onShowPluginDetails:D=>{w(D),x(!0)},onNewPlugin:()=>y(!0),isPluginSelected:O,onTogglePlugin:S,isApplyingPlugins:N,diskPluginsLoadable:L,activeCount:se,totalCount:ie})]})})]}),l.jsx($f,{className:W("border-sidebar-border/70 gap-0 border-t p-1.5",M),children:l.jsx("div",{className:W("flex items-center",n?"justify-center":"justify-start"),children:l.jsx(Hb,{className:"size-7 rounded-sm text-sidebar-foreground/70 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground [&_svg]:size-3.5"})})})]}),l.jsx(ct,{open:h,onOpenChange:p,children:l.jsx(lt,{className:"sm:max-w-[525px]",children:l.jsx(Dn,{mode:"create",shouldReset:!h,postSubmit:ce,discoveredDocuments:(e==null?void 0:e.documents)||[]})})}),l.jsx(ct,{open:m,onOpenChange:v,children:l.jsx(lt,{className:"sm:max-w-[525px]",children:l.jsx(Dn,{mode:"create",shouldReset:!m,postSubmit:b,discoveredThemes:(e==null?void 0:e.themes)||[],isTheme:!0})})}),l.jsx(ct,{open:k,onOpenChange:y,children:l.jsx(lt,{className:"sm:max-w-[525px]",children:l.jsx(Dn,{mode:"create",shouldReset:!k,postSubmit:G,discoveredPlugins:(e==null?void 0:e.plugins)||[],isPlugin:!0})})}),l.jsx(ct,{open:_,onOpenChange:D=>{x(D),D||w(null)},children:l.jsx(lt,{className:"max-h-[85vh] overflow-hidden sm:max-w-5xl",children:l.jsx(Fb,{plugins:(e==null?void 0:e.plugins)||[],initialFocusedPlugin:E})})}),l.jsx(ey,{open:R,onOpenChange:T})]})}const Ll=g.memo(Wb),qb=g.lazy(()=>ad(()=>import("./editor-CwEocOY2.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12])).then(e=>({default:e.Editor})));function Bl(){return l.jsx(g.Suspense,{fallback:l.jsx("div",{className:"flex items-center justify-center h-full",children:l.jsxs("div",{className:"text-center",children:[l.jsx(cn,{className:"w-8 h-8 mx-auto mb-2"}),l.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading editor..."})]})}),children:l.jsx(qb,{})})}const Gb=g.lazy(()=>ad(()=>import("./preview-CWdUATNl.js"),__vite__mapDeps([13,1,3,4,5,6,7,8,9,10,12,11])).then(e=>({default:e.Preview})));function Zl(){return l.jsx(g.Suspense,{fallback:l.jsx("div",{className:"flex items-center justify-center h-full",children:l.jsxs("div",{className:"text-center",children:[l.jsx(cn,{className:"w-8 h-8 mx-auto mb-2"}),l.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading preview..."})]})}),children:l.jsx(Gb,{})})}const{createElement:vr,createContext:Kb,forwardRef:Hf,useCallback:bt,useContext:Wf,useEffect:Rn,useImperativeHandle:qf,useLayoutEffect:Yb,useMemo:Xb,useRef:jt,useState:ur}=nd,Vl=nd[`useId${Math.random()}`.slice(0,5)],Qb=Yb,Ps=Kb(null);Ps.displayName="PanelGroupContext";const $n=Qb,ev=typeof Vl=="function"?Vl:()=>null;let tv=0;function Da(e=null){const t=ev(),n=jt(e||t||null);return n.current===null&&(n.current=""+tv++),e??n.current}function Gf({children:e,className:t="",collapsedSize:n,collapsible:r,defaultSize:i,forwardedRef:s,id:o,maxSize:a,minSize:c,onCollapse:u,onExpand:d,onResize:f,order:h,style:p,tagName:m="div",...v}){const k=Wf(Ps);if(k===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:y,expandPanel:_,getPanelSize:x,getPanelStyle:A,groupId:E,isPanelCollapsed:w,reevaluatePanelConstraints:S,registerPanel:O,resizePanel:B,unregisterPanel:N}=k,R=Da(o),T=jt({callbacks:{onCollapse:u,onExpand:d,onResize:f},constraints:{collapsedSize:n,collapsible:r,defaultSize:i,maxSize:a,minSize:c},id:R,idIsFromProps:o!==void 0,order:h});jt({didLogMissingDefaultSizeWarning:!1}),$n(()=>{const{callbacks:$,constraints:Z}=T.current,P={...Z};T.current.id=R,T.current.idIsFromProps=o!==void 0,T.current.order=h,$.onCollapse=u,$.onExpand=d,$.onResize=f,Z.collapsedSize=n,Z.collapsible=r,Z.defaultSize=i,Z.maxSize=a,Z.minSize=c,(P.collapsedSize!==Z.collapsedSize||P.collapsible!==Z.collapsible||P.maxSize!==Z.maxSize||P.minSize!==Z.minSize)&&S(T.current,P)}),$n(()=>{const $=T.current;return O($),()=>{N($)}},[h,R,O,N]),qf(s,()=>({collapse:()=>{y(T.current)},expand:$=>{_(T.current,$)},getId(){return R},getSize(){return x(T.current)},isCollapsed(){return w(T.current)},isExpanded(){return!w(T.current)},resize:$=>{B(T.current,$)}}),[y,_,x,w,R,B]);const F=A(T.current,i);return vr(m,{...v,children:e,className:t,id:o,style:{...F,...p},"data-panel":"","data-panel-collapsible":r||void 0,"data-panel-group-id":E,"data-panel-id":R,"data-panel-size":parseFloat(""+F.flexGrow).toFixed(1)})}const Kf=Hf((e,t)=>vr(Gf,{...e,forwardedRef:t}));Gf.displayName="Panel";Kf.displayName="forwardRef(Panel)";let Wo=null,Pn=null;function nv(e,t){if(t){const n=(t&tp)!==0,r=(t&np)!==0,i=(t&rp)!==0,s=(t&ip)!==0;if(n)return i?"se-resize":s?"ne-resize":"e-resize";if(r)return i?"sw-resize":s?"nw-resize":"w-resize";if(i)return"s-resize";if(s)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}function rv(){Pn!==null&&(document.head.removeChild(Pn),Wo=null,Pn=null)}function no(e,t){const n=nv(e,t);Wo!==n&&(Wo=n,Pn===null&&(Pn=document.createElement("style"),document.head.appendChild(Pn)),Pn.innerHTML=`*{cursor: ${n}!important;}`)}function Yf(e){return e.type==="keydown"}function Xf(e){return e.type.startsWith("pointer")}function Qf(e){return e.type.startsWith("mouse")}function Ds(e){if(Xf(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(Qf(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function iv(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function sv(e,t,n){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function ov(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:Hl(e),b:Hl(t)};let r;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),r=e;Ee(r,"Stacking order can only be calculated for elements with a common ancestor");const i={a:Jl(Ul(n.a)),b:Jl(Ul(n.b))};if(i.a===i.b){const s=r.childNodes,o={a:n.a.at(-1),b:n.b.at(-1)};let a=s.length;for(;a--;){const c=s[a];if(c===o.a)return 1;if(c===o.b)return-1}}return Math.sign(i.a-i.b)}const av=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function lv(e){var t;const n=getComputedStyle((t=ep(e))!==null&&t!==void 0?t:e).display;return n==="flex"||n==="inline-flex"}function cv(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||lv(e))||+t.opacity<1||"transform"in t&&t.transform!=="none"||"webkitTransform"in t&&t.webkitTransform!=="none"||"mixBlendMode"in t&&t.mixBlendMode!=="normal"||"filter"in t&&t.filter!=="none"||"webkitFilter"in t&&t.webkitFilter!=="none"||"isolation"in t&&t.isolation==="isolate"||av.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function Ul(e){let t=e.length;for(;t--;){const n=e[t];if(Ee(n,"Missing node"),cv(n))return n}return null}function Jl(e){return e&&Number(getComputedStyle(e).zIndex)||0}function Hl(e){const t=[];for(;e;)t.push(e),e=ep(e);return t}function ep(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}const tp=1,np=2,rp=4,ip=8,uv=iv()==="coarse";let Ht=[],dr=!1,yn=new Map,Rs=new Map;const fi=new Set;function dv(e,t,n,r,i){var s;const{ownerDocument:o}=t,a={direction:n,element:t,hitAreaMargins:r,setResizeHandlerState:i},c=(s=yn.get(o))!==null&&s!==void 0?s:0;return yn.set(o,c+1),fi.add(a),ls(),function(){var d;Rs.delete(e),fi.delete(a);const f=(d=yn.get(o))!==null&&d!==void 0?d:1;if(yn.set(o,f-1),ls(),f===1&&yn.delete(o),Ht.includes(a)){const h=Ht.indexOf(a);h>=0&&Ht.splice(h,1),$a(),i("up",!0,null)}}}function Wl(e){const{target:t}=e,{x:n,y:r}=Ds(e);dr=!0,Ra({target:t,x:n,y:r}),ls(),Ht.length>0&&(cs("down",e),e.preventDefault(),e.stopPropagation())}function Fr(e){const{x:t,y:n}=Ds(e);if(dr&&e.buttons===0&&(dr=!1,cs("up",e)),!dr){const{target:r}=e;Ra({target:r,x:t,y:n})}cs("move",e),$a(),Ht.length>0&&e.preventDefault()}function Wn(e){const{target:t}=e,{x:n,y:r}=Ds(e);Rs.clear(),dr=!1,Ht.length>0&&e.preventDefault(),cs("up",e),Ra({target:t,x:n,y:r}),$a(),ls()}function Ra({target:e,x:t,y:n}){Ht.splice(0);let r=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(r=e),fi.forEach(i=>{const{element:s,hitAreaMargins:o}=i,a=s.getBoundingClientRect(),{bottom:c,left:u,right:d,top:f}=a,h=uv?o.coarse:o.fine;if(t>=u-h&&t<=d+h&&n>=f-h&&n<=c+h){if(r!==null&&document.contains(r)&&s!==r&&!s.contains(r)&&!r.contains(s)&&ov(r,s)>0){let m=r,v=!1;for(;m&&!m.contains(s);){if(sv(m.getBoundingClientRect(),a)){v=!0;break}m=m.parentElement}if(v)return}Ht.push(i)}})}function ro(e,t){Rs.set(e,t)}function $a(){let e=!1,t=!1;Ht.forEach(r=>{const{direction:i}=r;i==="horizontal"?e=!0:t=!0});let n=0;Rs.forEach(r=>{n|=r}),e&&t?no("intersection",n):e?no("horizontal",n):t?no("vertical",n):rv()}function ls(){yn.forEach((e,t)=>{const{body:n}=t;n.removeEventListener("contextmenu",Wn),n.removeEventListener("pointerdown",Wl),n.removeEventListener("pointerleave",Fr),n.removeEventListener("pointermove",Fr)}),window.removeEventListener("pointerup",Wn),window.removeEventListener("pointercancel",Wn),fi.size>0&&(dr?(Ht.length>0&&yn.forEach((e,t)=>{const{body:n}=t;e>0&&(n.addEventListener("contextmenu",Wn),n.addEventListener("pointerleave",Fr),n.addEventListener("pointermove",Fr))}),window.addEventListener("pointerup",Wn),window.addEventListener("pointercancel",Wn)):yn.forEach((e,t)=>{const{body:n}=t;e>0&&(n.addEventListener("pointerdown",Wl,{capture:!0}),n.addEventListener("pointermove",Fr))}))}function cs(e,t){fi.forEach(n=>{const{setResizeHandlerState:r}=n,i=Ht.includes(n);r(e,i,t)})}function fv(){const[e,t]=ur(0);return bt(()=>t(n=>n+1),[])}function Ee(e,t){if(!e)throw console.error(t),Error(t)}const Ma=10;function Ln(e,t,n=Ma){return e.toFixed(n)===t.toFixed(n)?0:e>t?1:-1}function ln(e,t,n=Ma){return Ln(e,t,n)===0}function Tt(e,t,n){return Ln(e,t,n)===0}function pv(e,t,n){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++){const i=e[r],s=t[r];if(!Tt(i,s,n))return!1}return!0}function sr({panelConstraints:e,panelIndex:t,size:n}){const r=e[t];Ee(r!=null,`Panel constraints not found for index ${t}`);let{collapsedSize:i=0,collapsible:s,maxSize:o=100,minSize:a=0}=r;if(Ln(n,a)<0)if(s){const c=(i+a)/2;Ln(n,c)<0?n=i:n=a}else n=a;return n=Math.min(o,n),n=parseFloat(n.toFixed(Ma)),n}function Hr({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:s}){if(Tt(e,0))return t;const o=[...t],[a,c]=r;Ee(a!=null,"Invalid first pivot index"),Ee(c!=null,"Invalid second pivot index");let u=0;if(s==="keyboard"){{const f=e<0?c:a,h=n[f];Ee(h,`Panel constraints not found for index ${f}`);const{collapsedSize:p=0,collapsible:m,minSize:v=0}=h;if(m){const k=t[f];if(Ee(k!=null,`Previous layout not found for panel index ${f}`),Tt(k,p)){const y=v-k;Ln(y,Math.abs(e))>0&&(e=e<0?0-y:y)}}}{const f=e<0?a:c,h=n[f];Ee(h,`No panel constraints found for index ${f}`);const{collapsedSize:p=0,collapsible:m,minSize:v=0}=h;if(m){const k=t[f];if(Ee(k!=null,`Previous layout not found for panel index ${f}`),Tt(k,v)){const y=k-p;Ln(y,Math.abs(e))>0&&(e=e<0?0-y:y)}}}}{const f=e<0?1:-1;let h=e<0?c:a,p=0;for(;;){const v=t[h];Ee(v!=null,`Previous layout not found for panel index ${h}`);const y=sr({panelConstraints:n,panelIndex:h,size:100})-v;if(p+=y,h+=f,h<0||h>=n.length)break}const m=Math.min(Math.abs(e),Math.abs(p));e=e<0?0-m:m}{let h=e<0?a:c;for(;h>=0&&h<n.length;){const p=Math.abs(e)-Math.abs(u),m=t[h];Ee(m!=null,`Previous layout not found for panel index ${h}`);const v=m-p,k=sr({panelConstraints:n,panelIndex:h,size:v});if(!Tt(m,k)&&(u+=m-k,o[h]=k,u.toPrecision(3).localeCompare(Math.abs(e).toPrecision(3),void 0,{numeric:!0})>=0))break;e<0?h--:h++}}if(pv(i,o))return i;{const f=e<0?c:a,h=t[f];Ee(h!=null,`Previous layout not found for panel index ${f}`);const p=h+u,m=sr({panelConstraints:n,panelIndex:f,size:p});if(o[f]=m,!Tt(m,p)){let v=p-m,y=e<0?c:a;for(;y>=0&&y<n.length;){const _=o[y];Ee(_!=null,`Previous layout not found for panel index ${y}`);const x=_+v,A=sr({panelConstraints:n,panelIndex:y,size:x});if(Tt(_,A)||(v-=A-_,o[y]=A),Tt(v,0))break;e>0?y--:y++}}}const d=o.reduce((f,h)=>h+f,0);return Tt(d,100)?o:i}function hv({layout:e,panelsArray:t,pivotIndices:n}){let r=0,i=100,s=0,o=0;const a=n[0];Ee(a!=null,"No pivot index found"),t.forEach((f,h)=>{const{constraints:p}=f,{maxSize:m=100,minSize:v=0}=p;h===a?(r=v,i=m):(s+=v,o+=m)});const c=Math.min(i,100-s),u=Math.max(r,100-o),d=e[a];return{valueMax:c,valueMin:u,valueNow:d}}function pi(e,t=document){return Array.from(t.querySelectorAll(`[data-panel-resize-handle-id][data-panel-group-id="${e}"]`))}function sp(e,t,n=document){const i=pi(e,n).findIndex(s=>s.getAttribute("data-panel-resize-handle-id")===t);return i??null}function op(e,t,n){const r=sp(e,t,n);return r!=null?[r,r+1]:[-1,-1]}function ap(e,t=document){var n;if(t instanceof HTMLElement&&(t==null||(n=t.dataset)===null||n===void 0?void 0:n.panelGroupId)==e)return t;const r=t.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return r||null}function $s(e,t=document){const n=t.querySelector(`[data-panel-resize-handle-id="${e}"]`);return n||null}function mv(e,t,n,r=document){var i,s,o,a;const c=$s(t,r),u=pi(e,r),d=c?u.indexOf(c):-1,f=(i=(s=n[d])===null||s===void 0?void 0:s.id)!==null&&i!==void 0?i:null,h=(o=(a=n[d+1])===null||a===void 0?void 0:a.id)!==null&&o!==void 0?o:null;return[f,h]}function gv({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:r,panelDataArray:i,panelGroupElement:s,setLayout:o}){jt({didWarnAboutMissingResizeHandle:!1}),$n(()=>{if(!s)return;const a=pi(n,s);for(let c=0;c<i.length-1;c++){const{valueMax:u,valueMin:d,valueNow:f}=hv({layout:r,panelsArray:i,pivotIndices:[c,c+1]}),h=a[c];if(h!=null){const p=i[c];Ee(p,`No panel data found for index "${c}"`),h.setAttribute("aria-controls",p.id),h.setAttribute("aria-valuemax",""+Math.round(u)),h.setAttribute("aria-valuemin",""+Math.round(d)),h.setAttribute("aria-valuenow",f!=null?""+Math.round(f):"")}}return()=>{a.forEach((c,u)=>{c.removeAttribute("aria-controls"),c.removeAttribute("aria-valuemax"),c.removeAttribute("aria-valuemin"),c.removeAttribute("aria-valuenow")})}},[n,r,i,s]),Rn(()=>{if(!s)return;const a=t.current;Ee(a,"Eager values not found");const{panelDataArray:c}=a,u=ap(n,s);Ee(u!=null,`No group found for id "${n}"`);const d=pi(n,s);Ee(d,`No resize handles found for group id "${n}"`);const f=d.map(h=>{const p=h.getAttribute("data-panel-resize-handle-id");Ee(p,"Resize handle element has no handle id attribute");const[m,v]=mv(n,p,c,s);if(m==null||v==null)return()=>{};const k=y=>{if(!y.defaultPrevented)switch(y.key){case"Enter":{y.preventDefault();const _=c.findIndex(x=>x.id===m);if(_>=0){const x=c[_];Ee(x,`No panel data found for index ${_}`);const A=r[_],{collapsedSize:E=0,collapsible:w,minSize:S=0}=x.constraints;if(A!=null&&w){const O=Hr({delta:Tt(A,E)?S-E:E-A,initialLayout:r,panelConstraints:c.map(B=>B.constraints),pivotIndices:op(n,p,s),prevLayout:r,trigger:"keyboard"});r!==O&&o(O)}}break}}};return h.addEventListener("keydown",k),()=>{h.removeEventListener("keydown",k)}});return()=>{f.forEach(h=>h())}},[s,e,t,n,r,i,o])}function ql(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function lp(e,t){const n=e==="horizontal",{x:r,y:i}=Ds(t);return n?r:i}function xv(e,t,n,r,i){const s=n==="horizontal",o=$s(t,i);Ee(o,`No resize handle element found for id "${t}"`);const a=o.getAttribute("data-panel-group-id");Ee(a,"Resize handle element has no group id attribute");let{initialCursorPosition:c}=r;const u=lp(n,e),d=ap(a,i);Ee(d,`No group element found for id "${a}"`);const f=d.getBoundingClientRect(),h=s?f.width:f.height;return(u-c)/h*100}function yv(e,t,n,r,i,s){if(Yf(e)){const o=n==="horizontal";let a=0;e.shiftKey?a=100:i!=null?a=i:a=10;let c=0;switch(e.key){case"ArrowDown":c=o?0:a;break;case"ArrowLeft":c=o?-a:0;break;case"ArrowRight":c=o?a:0;break;case"ArrowUp":c=o?0:-a;break;case"End":c=100;break;case"Home":c=-100;break}return c}else return r==null?0:xv(e,t,n,r,s)}function bv({panelDataArray:e}){const t=Array(e.length),n=e.map(s=>s.constraints);let r=0,i=100;for(let s=0;s<e.length;s++){const o=n[s];Ee(o,`Panel constraints not found for index ${s}`);const{defaultSize:a}=o;a!=null&&(r++,t[s]=a,i-=a)}for(let s=0;s<e.length;s++){const o=n[s];Ee(o,`Panel constraints not found for index ${s}`);const{defaultSize:a}=o;if(a!=null)continue;const c=e.length-r,u=i/c;r++,t[s]=u,i-=u}return t}function qn(e,t,n){t.forEach((r,i)=>{const s=e[i];Ee(s,`Panel data not found for index ${i}`);const{callbacks:o,constraints:a,id:c}=s,{collapsedSize:u=0,collapsible:d}=a,f=n[c];if(f==null||r!==f){n[c]=r;const{onCollapse:h,onExpand:p,onResize:m}=o;m&&m(r,f),d&&(h||p)&&(p&&(f==null||ln(f,u))&&!ln(r,u)&&p(),h&&(f==null||!ln(f,u))&&ln(r,u)&&h())}})}function $i(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function vv({defaultSize:e,dragState:t,layout:n,panelData:r,panelIndex:i,precision:s=3}){const o=n[i];let a;return o==null?a=e!=null?e.toPrecision(s):"1":r.length===1?a="1":a=o.toPrecision(s),{flexBasis:0,flexGrow:a,flexShrink:1,overflow:"hidden",pointerEvents:t!==null?"none":void 0}}function wv(e,t=10){let n=null;return(...i)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...i)},t)}}function Gl(e){try{if(typeof localStorage<"u")e.getItem=t=>localStorage.getItem(t),e.setItem=(t,n)=>{localStorage.setItem(t,n)};else throw new Error("localStorage not supported in this environment")}catch(t){console.error(t),e.getItem=()=>null,e.setItem=()=>{}}}function cp(e){return`react-resizable-panels:${e}`}function up(e){return e.map(t=>{const{constraints:n,id:r,idIsFromProps:i,order:s}=t;return i?r:s?`${s}:${JSON.stringify(n)}`:JSON.stringify(n)}).sort((t,n)=>t.localeCompare(n)).join(",")}function dp(e,t){try{const n=cp(e),r=t.getItem(n);if(r){const i=JSON.parse(r);if(typeof i=="object"&&i!=null)return i}}catch{}return null}function kv(e,t,n){var r,i;const s=(r=dp(e,n))!==null&&r!==void 0?r:{},o=up(t);return(i=s[o])!==null&&i!==void 0?i:null}function Sv(e,t,n,r,i){var s;const o=cp(e),a=up(t),c=(s=dp(e,i))!==null&&s!==void 0?s:{};c[a]={expandToSizes:Object.fromEntries(n.entries()),layout:r};try{i.setItem(o,JSON.stringify(c))}catch(u){console.error(u)}}function Kl({layout:e,panelConstraints:t}){const n=[...e],r=n.reduce((s,o)=>s+o,0);if(n.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${n.map(s=>`${s}%`).join(", ")}`);if(!Tt(r,100)&&n.length>0)for(let s=0;s<t.length;s++){const o=n[s];Ee(o!=null,`No layout data found for index ${s}`);const a=100/r*o;n[s]=a}let i=0;for(let s=0;s<t.length;s++){const o=n[s];Ee(o!=null,`No layout data found for index ${s}`);const a=sr({panelConstraints:t,panelIndex:s,size:o});o!=a&&(i+=o-a,n[s]=a)}if(!Tt(i,0))for(let s=0;s<t.length;s++){const o=n[s];Ee(o!=null,`No layout data found for index ${s}`);const a=o+i,c=sr({panelConstraints:t,panelIndex:s,size:a});if(o!==c&&(i-=c-o,n[s]=c,Tt(i,0)))break}return n}const jv=100,Wr={getItem:e=>(Gl(Wr),Wr.getItem(e)),setItem:(e,t)=>{Gl(Wr),Wr.setItem(e,t)}},Yl={};function fp({autoSaveId:e=null,children:t,className:n="",direction:r,forwardedRef:i,id:s=null,onLayout:o=null,keyboardResizeBy:a=null,storage:c=Wr,style:u,tagName:d="div",...f}){const h=Da(s),p=jt(null),[m,v]=ur(null),[k,y]=ur([]),_=fv(),x=jt({}),A=jt(new Map),E=jt(0),w=jt({autoSaveId:e,direction:r,dragState:m,id:h,keyboardResizeBy:a,onLayout:o,storage:c}),S=jt({layout:k,panelDataArray:[],panelDataArrayChanged:!1});jt({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),qf(i,()=>({getId:()=>w.current.id,getLayout:()=>{const{layout:b}=S.current;return b},setLayout:b=>{const{onLayout:G}=w.current,{layout:ne,panelDataArray:Q}=S.current,oe=Kl({layout:b,panelConstraints:Q.map(I=>I.constraints)});ql(ne,oe)||(y(oe),S.current.layout=oe,G&&G(oe),qn(Q,oe,x.current))}}),[]),$n(()=>{w.current.autoSaveId=e,w.current.direction=r,w.current.dragState=m,w.current.id=h,w.current.onLayout=o,w.current.storage=c}),gv({committedValuesRef:w,eagerValuesRef:S,groupId:h,layout:k,panelDataArray:S.current.panelDataArray,setLayout:y,panelGroupElement:p.current}),Rn(()=>{const{panelDataArray:b}=S.current;if(e){if(k.length===0||k.length!==b.length)return;let G=Yl[e];G==null&&(G=wv(Sv,jv),Yl[e]=G);const ne=[...b],Q=new Map(A.current);G(e,ne,Q,k,c)}},[e,k,c]),Rn(()=>{});const O=bt(b=>{const{onLayout:G}=w.current,{layout:ne,panelDataArray:Q}=S.current;if(b.constraints.collapsible){const oe=Q.map(H=>H.constraints),{collapsedSize:I=0,panelSize:re,pivotIndices:ae}=En(Q,b,ne);if(Ee(re!=null,`Panel size not found for panel "${b.id}"`),!ln(re,I)){A.current.set(b.id,re);const K=tr(Q,b)===Q.length-1?re-I:I-re,pe=Hr({delta:K,initialLayout:ne,panelConstraints:oe,pivotIndices:ae,prevLayout:ne,trigger:"imperative-api"});$i(ne,pe)||(y(pe),S.current.layout=pe,G&&G(pe),qn(Q,pe,x.current))}}},[]),B=bt((b,G)=>{const{onLayout:ne}=w.current,{layout:Q,panelDataArray:oe}=S.current;if(b.constraints.collapsible){const I=oe.map(fe=>fe.constraints),{collapsedSize:re=0,panelSize:ae=0,minSize:H=0,pivotIndices:K}=En(oe,b,Q),pe=G??H;if(ln(ae,re)){const fe=A.current.get(b.id),Re=fe!=null&&fe>=pe?fe:pe,$e=tr(oe,b)===oe.length-1?ae-Re:Re-ae,C=Hr({delta:$e,initialLayout:Q,panelConstraints:I,pivotIndices:K,prevLayout:Q,trigger:"imperative-api"});$i(Q,C)||(y(C),S.current.layout=C,ne&&ne(C),qn(oe,C,x.current))}}},[]),N=bt(b=>{const{layout:G,panelDataArray:ne}=S.current,{panelSize:Q}=En(ne,b,G);return Ee(Q!=null,`Panel size not found for panel "${b.id}"`),Q},[]),R=bt((b,G)=>{const{panelDataArray:ne}=S.current,Q=tr(ne,b);return vv({defaultSize:G,dragState:m,layout:k,panelData:ne,panelIndex:Q})},[m,k]),T=bt(b=>{const{layout:G,panelDataArray:ne}=S.current,{collapsedSize:Q=0,collapsible:oe,panelSize:I}=En(ne,b,G);return Ee(I!=null,`Panel size not found for panel "${b.id}"`),oe===!0&&ln(I,Q)},[]),F=bt(b=>{const{layout:G,panelDataArray:ne}=S.current,{collapsedSize:Q=0,collapsible:oe,panelSize:I}=En(ne,b,G);return Ee(I!=null,`Panel size not found for panel "${b.id}"`),!oe||Ln(I,Q)>0},[]),$=bt(b=>{const{panelDataArray:G}=S.current;G.push(b),G.sort((ne,Q)=>{const oe=ne.order,I=Q.order;return oe==null&&I==null?0:oe==null?-1:I==null?1:oe-I}),S.current.panelDataArrayChanged=!0,_()},[_]);$n(()=>{if(S.current.panelDataArrayChanged){S.current.panelDataArrayChanged=!1;const{autoSaveId:b,onLayout:G,storage:ne}=w.current,{layout:Q,panelDataArray:oe}=S.current;let I=null;if(b){const ae=kv(b,oe,ne);ae&&(A.current=new Map(Object.entries(ae.expandToSizes)),I=ae.layout)}I==null&&(I=bv({panelDataArray:oe}));const re=Kl({layout:I,panelConstraints:oe.map(ae=>ae.constraints)});ql(Q,re)||(y(re),S.current.layout=re,G&&G(re),qn(oe,re,x.current))}}),$n(()=>{const b=S.current;return()=>{b.layout=[]}},[]);const Z=bt(b=>{let G=!1;const ne=p.current;return ne&&window.getComputedStyle(ne,null).getPropertyValue("direction")==="rtl"&&(G=!0),function(oe){oe.preventDefault();const I=p.current;if(!I)return()=>null;const{direction:re,dragState:ae,id:H,keyboardResizeBy:K,onLayout:pe}=w.current,{layout:fe,panelDataArray:Re}=S.current,{initialLayout:Oe}=ae??{},$e=op(H,b,I);let C=yv(oe,b,re,ae,K,I);const z=re==="horizontal";z&&G&&(C=-C);const L=Re.map(ee=>ee.constraints),se=Hr({delta:C,initialLayout:Oe??fe,panelConstraints:L,pivotIndices:$e,prevLayout:fe,trigger:Yf(oe)?"keyboard":"mouse-or-touch"}),ie=!$i(fe,se);(Xf(oe)||Qf(oe))&&E.current!=C&&(E.current=C,!ie&&C!==0?z?ro(b,C<0?tp:np):ro(b,C<0?rp:ip):ro(b,0)),ie&&(y(se),S.current.layout=se,pe&&pe(se),qn(Re,se,x.current))}},[]),P=bt((b,G)=>{const{onLayout:ne}=w.current,{layout:Q,panelDataArray:oe}=S.current,I=oe.map(fe=>fe.constraints),{panelSize:re,pivotIndices:ae}=En(oe,b,Q);Ee(re!=null,`Panel size not found for panel "${b.id}"`);const K=tr(oe,b)===oe.length-1?re-G:G-re,pe=Hr({delta:K,initialLayout:Q,panelConstraints:I,pivotIndices:ae,prevLayout:Q,trigger:"imperative-api"});$i(Q,pe)||(y(pe),S.current.layout=pe,ne&&ne(pe),qn(oe,pe,x.current))},[]),J=bt((b,G)=>{const{layout:ne,panelDataArray:Q}=S.current,{collapsedSize:oe=0,collapsible:I}=G,{collapsedSize:re=0,collapsible:ae,maxSize:H=100,minSize:K=0}=b.constraints,{panelSize:pe}=En(Q,b,ne);pe!=null&&(I&&ae&&ln(pe,oe)?ln(oe,re)||P(b,re):pe<K?P(b,K):pe>H&&P(b,H))},[P]),V=bt((b,G)=>{const{direction:ne}=w.current,{layout:Q}=S.current;if(!p.current)return;const oe=$s(b,p.current);Ee(oe,`Drag handle element not found for id "${b}"`);const I=lp(ne,G);v({dragHandleId:b,dragHandleRect:oe.getBoundingClientRect(),initialCursorPosition:I,initialLayout:Q})},[]),X=bt(()=>{v(null)},[]),j=bt(b=>{const{panelDataArray:G}=S.current,ne=tr(G,b);ne>=0&&(G.splice(ne,1),delete x.current[b.id],S.current.panelDataArrayChanged=!0,_())},[_]),ye=Xb(()=>({collapsePanel:O,direction:r,dragState:m,expandPanel:B,getPanelSize:N,getPanelStyle:R,groupId:h,isPanelCollapsed:T,isPanelExpanded:F,reevaluatePanelConstraints:J,registerPanel:$,registerResizeHandle:Z,resizePanel:P,startDragging:V,stopDragging:X,unregisterPanel:j,panelGroupElement:p.current}),[O,m,r,B,N,R,h,T,F,J,$,Z,P,V,X,j]),ce={display:"flex",flexDirection:r==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return vr(Ps.Provider,{value:ye},vr(d,{...f,children:t,className:n,id:s,ref:p,style:{...ce,...u},"data-panel-group":"","data-panel-group-direction":r,"data-panel-group-id":h}))}const pp=Hf((e,t)=>vr(fp,{...e,forwardedRef:t}));fp.displayName="PanelGroup";pp.displayName="forwardRef(PanelGroup)";function tr(e,t){return e.findIndex(n=>n===t||n.id===t.id)}function En(e,t,n){const r=tr(e,t),s=r===e.length-1?[r-1,r]:[r,r+1],o=n[r];return{...t.constraints,panelSize:o,pivotIndices:s}}function _v({disabled:e,handleId:t,resizeHandler:n,panelGroupElement:r}){Rn(()=>{if(e||n==null||r==null)return;const i=$s(t,r);if(i==null)return;const s=o=>{if(!o.defaultPrevented)switch(o.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{o.preventDefault(),n(o);break}case"F6":{o.preventDefault();const a=i.getAttribute("data-panel-group-id");Ee(a,`No group element found for id "${a}"`);const c=pi(a,r),u=sp(a,t,r);Ee(u!==null,`No resize element found for id "${t}"`);const d=o.shiftKey?u>0?u-1:c.length-1:u+1<c.length?u+1:0;c[d].focus();break}}};return i.addEventListener("keydown",s),()=>{i.removeEventListener("keydown",s)}},[r,e,t,n])}function hp({children:e=null,className:t="",disabled:n=!1,hitAreaMargins:r,id:i,onBlur:s,onDragging:o,onFocus:a,style:c={},tabIndex:u=0,tagName:d="div",...f}){var h,p;const m=jt(null),v=jt({onDragging:o});Rn(()=>{v.current.onDragging=o});const k=Wf(Ps);if(k===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:y,groupId:_,registerResizeHandle:x,startDragging:A,stopDragging:E,panelGroupElement:w}=k,S=Da(i),[O,B]=ur("inactive"),[N,R]=ur(!1),[T,F]=ur(null),$=jt({state:O});$n(()=>{$.current.state=O}),Rn(()=>{if(n)F(null);else{const V=x(S);F(()=>V)}},[n,S,x]);const Z=(h=r==null?void 0:r.coarse)!==null&&h!==void 0?h:15,P=(p=r==null?void 0:r.fine)!==null&&p!==void 0?p:5;return Rn(()=>{if(n||T==null)return;const V=m.current;return Ee(V,"Element ref not attached"),dv(S,V,y,{coarse:Z,fine:P},(j,ye,ce)=>{if(ye)switch(j){case"down":{B("drag"),Ee(ce,'Expected event to be defined for "down" action'),A(S,ce);const{onDragging:b}=v.current;b&&b(!0);break}case"move":{const{state:b}=$.current;b!=="drag"&&B("hover"),Ee(ce,'Expected event to be defined for "move" action'),T(ce);break}case"up":{B("hover"),E();const{onDragging:b}=v.current;b&&b(!1);break}}else B("inactive")})},[Z,y,n,P,x,S,T,A,E]),_v({disabled:n,handleId:S,resizeHandler:T,panelGroupElement:w}),vr(d,{...f,children:e,className:t,id:i,onBlur:()=>{R(!1),s==null||s()},onFocus:()=>{R(!0),a==null||a()},ref:m,role:"separator",style:{...{touchAction:"none",userSelect:"none"},...c},tabIndex:u,"data-panel-group-direction":y,"data-panel-group-id":_,"data-resize-handle":"","data-resize-handle-active":O==="drag"?"pointer":N?"keyboard":void 0,"data-resize-handle-state":O,"data-panel-resize-handle-enabled":!n,"data-panel-resize-handle-id":S})}hp.displayName="PanelResizeHandle";const Nv=({className:e,...t})=>l.jsx(pp,{className:W("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...t}),io=Kf,Xl=({withHandle:e,className:t,...n})=>l.jsx(hp,{className:W("bg-border focus-visible:ring-ring relative flex w-px items-center justify-center after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-offset-1 focus-visible:outline-none data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:-translate-y-1/2 data-[panel-group-direction=vertical]:after:translate-x-0 [&[data-panel-group-direction=vertical]>div]:rotate-90",t),...n,children:e&&l.jsx("div",{className:"bg-border z-10 flex h-4 w-3 items-center justify-center rounded-sm border",children:l.jsx(jx,{className:"h-2.5 w-2.5"})})}),mp=g.forwardRef(({className:e,...t},n)=>l.jsx("textarea",{className:W("flex min-h-[80px] w-full rounded-sm border border-input bg-background px-3 py-2 text-sm shadow-xs","placeholder:text-muted-foreground","focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring","disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...t}));mp.displayName="Textarea";class Cv{constructor(t){Or(this,"client");this.client=Mx.create({baseURL:t||void 0||"/api",headers:{"Content-Type":"application/json"}})}get(t,n){return this.client.get(t,n)}post(t,n,r){return this.client.post(t,n,r)}put(t,n,r){return this.client.put(t,n,r)}delete(t,n){return this.client.delete(t,n)}patch(t,n,r){return this.client.patch(t,n,r)}}const Ev=new Cv;class Tv extends Error{constructor(n,r){super(n);Or(this,"quality");this.name="QualityGateFailedError",this.quality=r}}function Iv(e,t){return e??t}function Av(e){var n;const t=(n=e==null?void 0:e.split(";",1)[0])==null?void 0:n.trim().toLowerCase();return t?t==="application/json"||t.startsWith("application/")&&t.endsWith("+json"):!1}async function zv(e){if(Av(e.headers.get("content-type")))try{return await e.json()}catch{return}}function Ql(e,t){if(t!=null&&t.error)return t.error;if(t!=null&&t.message)return t.message;if(e.ok)return`The server answered ${e.status} but not with a document. This usually means a proxy or extension replaced the response.`;switch(e.status){case 502:case 503:case 504:return`The server did not finish generating (${e.status}). It usually ran out of memory or restarted mid-request — documents with many full-page images or inline SVGs are the common cause. Try again, or split the document and generate it in parts.`;case 413:return"The document is too large for the server to accept (413). Remove or shrink its largest embedded assets.";case 429:return"Too many requests (429). Wait a moment before generating again.";default:return`Generation failed (${e.status}${e.statusText?` ${e.statusText}`:""}).`}}function Ov(){const e=g.useRef(null),t=gr(s=>s.generationBackend),n=id(),r=g.useCallback(async(s,o,a,c,u)=>{e.current&&e.current.abort();const d=new AbortController;e.current=d;const f=Iv(u==null?void 0:u.renderer,t);try{c==null||c("parsing","Validating JSON structure...");let h;try{h=JSON.parse(o)}catch(B){throw new Error(`Invalid JSON: ${B instanceof Error?B.message:"Unknown parse error"}`)}c==null||c("building",`Building ${Pi.toLowerCase()} structure...`);const p={jsonDefinition:h,options:{...u,sourceName:n(s),...f?{renderer:f}:{}}};p.customThemes=a??{},c==null||c("rendering",`Generating ${at.toUpperCase()} content...`);const m={"Content-Type":"application/json"};u!=null&&u.bypassCache&&(m["X-Bypass-Cache"]="true");const v=await fetch(oi.generate,{method:"POST",headers:m,body:JSON.stringify(p),signal:d.signal}),k=await zv(v);if(v.status===400&&(k==null?void 0:k.code)==="QUALITY_GATE_FAILED")throw new Tv(Ql(v,k),k.quality);if(!v.ok||!(k!=null&&k.success))throw new Error(Ql(v,k));const{data:y,cache:_,warnings:x}=k,A=_.status==="HIT"?"HIT":_.status==="MISS"?"MISS":"UNKNOWN",E=A==="HIT"?`Served from cache (Hit rate: ${_.hitRate})`:`Generated fresh ${Pi.toLowerCase()}`;c==null||c("finalizing",E);const w=globalThis.atob(y.document),S=new Uint8Array(w.length);for(let B=0;B<w.length;B++)S[B]=w.charCodeAt(B);const O=new Blob([S],{type:y.contentType});if(O.size===0)throw new Error(`Received empty ${Pi.toLowerCase()} from API`);return{name:s,text:o,blob:O,...f?{renderer:f}:{},filename:y.filename,fileId:y.fileId,cacheStatus:A,cacheHitRate:_.hitRate,warnings:x}}catch(h){throw h instanceof Error&&h.name==="AbortError"?new Error(`${Pi} generation was cancelled`):h}finally{e.current===d&&(e.current=null)}},[t,n]),i=g.useCallback(()=>{e.current&&(e.current.abort(),e.current=null)},[]);return{generatePresentation:r,generateDocument:r,cancelGeneration:i}}const qi={ids:[],default:null};let ec;function Pv(){return ec??(ec=(async()=>{var e;try{const t=await fetch(oi.renderers);if(!t.ok)return qi;const n=await t.json();return!(n!=null&&n.success)||!Array.isArray((e=n.data)==null?void 0:e.ids)?qi:n.data}catch{return qi}})()),ec}function Dv(){const[e,t]=g.useState(qi);return g.useEffect(()=>{let n=!1;return Pv().then(r=>{n||t(r)}),()=>{n=!0}},[]),e}function Rv(e){if(!e||e.length===0)return null;const t=[{name:"heading",props:{level:1,text:"Document Generation Warnings"}},{name:"paragraph",props:{text:`${e.length} warning(s) were generated during document processing.`,spacing:{after:240}}}],n=new Map;for(const r of e){const i=n.get(r.component)||[];i.push(r),n.set(r.component,i)}for(const[r,i]of n.entries()){t.push({name:"heading",props:{level:2,text:`Component: ${r}`}});const s=[];for(const o of i){let a=o.message;if(o.context&&Object.keys(o.context).length>0){const c=Object.entries(o.context).map(([u,d])=>`${u}: ${JSON.stringify(d)}`).join(", ");a+=` (${c})`}s.push(a)}t.push({name:"list",props:{items:s,spacing:{after:120}}})}return{name:"docx",props:{metadata:{title:"Generation Warnings"},theme:"minimal"},children:t}}function $v({open:e,onClose:t,nonSafeFonts:n,onChoose:r}){const[i,s]=je.useState("custom");je.useEffect(()=>{e&&s("custom")},[e]);const o=n.length===1?n[0]:n.slice(0,3).join(", ")+(n.length>3?` +${n.length-3} more`:""),a=[{value:"custom",title:"Keep custom fonts",desc:"Recipients with the font installed see the authored typeface. Others get a generic fallback."},{value:"substitute",title:"Convert to safe fonts",desc:"Rewrite non-safe families to Calibri / Georgia / Consolas so every recipient sees the same glyphs."}];return l.jsx(ct,{open:e,onOpenChange:c=>!c&&t(),children:l.jsxs(lt,{className:"max-w-md",children:[l.jsxs(qt,{children:[l.jsx(Gt,{children:"Non-safe fonts in this document"}),l.jsxs(dn,{children:[o," ",n.length===1?"is":"are"," not in the built-in safe list. Choose how to export."]})]}),l.jsx("div",{className:"grid gap-2 py-2",children:a.map(c=>{const u=i===c.value;return l.jsxs("button",{type:"button",onClick:()=>s(c.value),className:`text-left rounded-md border px-3 py-2 transition-colors ${u?"border-primary bg-primary/5":"border-border hover:bg-muted/40"}`,children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:`h-3.5 w-3.5 rounded-full border flex items-center justify-center ${u?"border-primary":"border-muted-foreground/50"}`,children:u&&l.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-primary"})}),l.jsx("span",{className:"text-sm font-medium",children:c.title})]}),l.jsx("p",{className:"mt-1 text-xs text-muted-foreground pl-6",children:c.desc})]},c.value)})}),l.jsxs(kn,{children:[l.jsx(Ce,{variant:"outline",size:"sm",onClick:t,children:"Cancel"}),l.jsx(Ce,{size:"sm",onClick:()=>{r(i),t()},children:"Download"})]})]})})}function Mv(e){const t=e.hasPendingDiff?"Review the proposed change first":e.parses?void 0:"The visual view needs the JSON to parse";return{view:t?"json":e.preferred??"visual",forcedReason:t}}function Fv(e){try{const t=JSON.parse(e);return!!t&&typeof t=="object"&&!Array.isArray(t)}catch{return!1}}function Lv(){const e=gr(c=>c.setSettings),t=gr(c=>c.themeEditorView),n=ke(c=>c.activeTab&&c.documentTypes[c.activeTab]==="application/json+theme"?c.activeTab:""),r=ke(c=>{if(!n)return!0;const u=c.documents.find(d=>d.name===n);return u?Fv(u.text):!0}),i=ke(c=>!!n&&c.pendingDiffs[n]!==void 0),s=g.useCallback(c=>e({themeEditorView:c}),[e]);if(!n)return null;const{view:o,forcedReason:a}=Mv({preferred:t,parses:r,hasPendingDiff:i});return l.jsxs("div",{role:"tablist","aria-label":"Theme editor view",title:a,className:"flex h-7 shrink-0 items-center rounded-sm border border-border/70 bg-muted/60 p-0.5",children:[l.jsx(tc,{active:o==="visual",disabled:a!==void 0,onClick:()=>s("visual"),icon:_x,label:"Visual"}),l.jsx(tc,{active:o==="json",onClick:()=>s("json"),icon:Qi,label:"JSON"})]})}function tc({active:e,disabled:t,onClick:n,icon:r,label:i}){return l.jsxs("button",{type:"button",role:"tab","aria-selected":e,"aria-label":i,disabled:t,onClick:n,className:W("flex h-6 cursor-pointer items-center gap-1.5 rounded-[3px] px-2 text-xs transition-colors","focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none","disabled:cursor-not-allowed disabled:opacity-50",e?"bg-background text-foreground shadow-xs":"text-muted-foreground hover:text-foreground"),children:[l.jsx(r,{className:"size-3.5"}),l.jsx("span",{className:"hidden md:inline",children:i})]})}const Bv=je.memo(Lv);function so(){return l.jsx("span",{className:"rounded-sm bg-warning/15 px-1 py-px text-[10px] font-semibold uppercase leading-none tracking-wide text-warning",children:"experimental"})}function nc(){return l.jsx("span",{className:"rounded-sm bg-muted px-1 py-px text-[10px] font-semibold uppercase leading-none tracking-wide text-muted-foreground",children:"default"})}function Zv({name:e,blob:t,onManualRender:n,isGenerating:r,isRendering:i,onShowCacheMetrics:s,onShowSchemas:o,onShowFonts:a,documentText:c,editorDocumentText:u,editorDocumentName:d,warnings:f,onToggleChat:h,chatOpen:p,onTogglePreview:m,previewOpen:v}){const[k,y]=g.useState(!1),[_,x]=g.useState(!1),[A,E]=g.useState(!1),[w,S]=g.useState(!1),[O,B]=g.useState(!1),[N,R]=g.useState(null),{toast:T}=_r(),F=id(),{generateDocument:$}=Ov(),Z=g.useContext(xa),P=Dv(),J=gr(K=>K.generationBackend),V=gr(K=>K.setSettings),X=J??P.default??void 0,j=g.useCallback(()=>{const K={},{customThemes:pe}=Z.getState();return Object.values(pe).forEach(fe=>{fe.valid&&fe.parsed&&(K[fe.name]=fe.parsed)}),K},[Z]),ye=je.useMemo(()=>{if(!c)return[];try{const K=JSON.parse(c);return[...(at==="pptx"?Tg:Ig)(K)].filter(fe=>!Ag(fe))}catch{return[]}},[c]),[ce,b]=g.useState(!1),G=g.useCallback(async()=>{if(t){y(!0);try{await new Promise(K=>setTimeout(K,100)),ni(`${e}${Pr}`,t)}finally{setTimeout(()=>y(!1),500)}}},[t,e]),ne=g.useCallback(async()=>{if(t){if(ye.length===0){await G();return}b(!0)}},[t,ye.length,G]),Q=g.useCallback(async K=>{var pe;if(c){y(!0);try{const fe=await $(e,c,j(),void 0,{bypassCache:!0,fonts:{mode:K}});if(fe.blob.size===0)T({title:"Export failed",description:"The server returned an empty document.",variant:"destructive"});else{ni(`${e}${Pr}`,fe.blob);const Re=(pe=fe.warnings)==null?void 0:pe.find(Oe=>{var $e,C;return(($e=Oe.context)==null?void 0:$e.code)==="FONT_MODE_SUBSTITUTED"||((C=Oe.context)==null?void 0:C.code)==="FONT_MODE_CUSTOM"});Re&&T({title:K==="substitute"?"Fonts substituted":"Non-safe fonts kept",description:Re.message})}}catch(fe){T({title:"Export failed",description:fe instanceof Error?fe.message:String(fe),variant:"destructive"})}finally{setTimeout(()=>y(!1),500)}}},[c,e,$,T,j]),oe=g.useCallback(async()=>{if(!(!f||f.length===0)){x(!0);try{const K=Rv(f);if(!K){T({title:"No warnings",description:"There are no warnings to download.",variant:"destructive"});return}const pe=await $("warnings",JSON.stringify(K,null,2),{});pe&&typeof pe=="object"&&"blob"in pe&&pe.blob&&(ni(`${e}-warnings${Pr}`,pe.blob),T({title:"Warnings downloaded",description:`Downloaded warnings document with ${f.length} warning(s).`}))}catch(K){console.error("Failed to generate warnings document:",K),T({title:"Download failed",description:K instanceof Error?K.message:"Failed to generate warnings document",variant:"destructive"})}finally{setTimeout(()=>x(!1),500)}}},[f,e,$,T]),I=g.useCallback(async()=>{E(!0);try{await Ev.delete(`/${at}/cache`),window.dispatchEvent(new CustomEvent("cache:cleared")),T({title:"Cache Cleared",description:"All active caches have been successfully cleared.",variant:"default"})}catch(K){console.error("Failed to clear cache:",K),T({title:"Cache Clear Failed",description:"Failed to clear caches. Please try again.",variant:"destructive"})}finally{E(!1)}},[T]),re=u??c,ae=g.useCallback(()=>{var fe,Re;if(!re){T({title:"No document available",description:"Please select a document to copy standard components",variant:"destructive"});return}try{JSON.parse(re)}catch{T({title:"Document is not valid JSON",description:"Fix the JSON errors in the editor, then copy again",variant:"destructive"});return}B(!0);const K=(async()=>{const Oe=j(),$e=await Ro(re,{customThemes:Oe}),C=await fetch(`/api/${at}/standard-components`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonDefinition:$e.text,customThemes:Oe,options:{sourceName:F(d??e)}})});if(!C.ok){let L=`Request failed with status ${C.status}`;try{const se=await C.json(),ie=se.error??se.message;typeof ie=="string"&&ie&&(L=ie)}catch{}throw new Error(L)}const z=await C.json();return JSON.stringify(z.data,null,2)})();let pe;typeof ClipboardItem<"u"&&((fe=navigator.clipboard)!=null&&fe.write)?pe=navigator.clipboard.write([new ClipboardItem({"text/plain":K.then(Oe=>new Blob([Oe],{type:"text/plain"}))})]):(Re=navigator.clipboard)!=null&&Re.writeText?pe=K.then(Oe=>navigator.clipboard.writeText(Oe)):pe=Promise.reject(new Error("Clipboard is not available in this context")),(async()=>{try{await pe,T({title:"Copied to clipboard",description:"Standard components JSON has been copied"})}catch(Oe){let $e=null;try{$e=await K}catch(C){console.error("Error fetching standard components:",C),T({title:"Failed to get standard components",description:C instanceof Error?C.message:"Request failed",variant:"destructive"});return}console.error("Clipboard write failed:",Oe),R($e)}finally{B(!1)}})()},[re,e,d,F,j,T]),H=g.useCallback(async()=>{if(N!=null)try{await navigator.clipboard.writeText(N),T({title:"Copied to clipboard",description:"Standard components JSON has been copied"}),R(null)}catch{T({title:"Clipboard unavailable",description:"Select the JSON in the dialog and copy it manually",variant:"destructive"})}},[N,T]);return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"bg-sidebar border-b flex flex-row flex-nowrap items-center justify-between gap-x-2 px-3 py-1.5",children:[l.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[l.jsx("p",{className:"text-foreground text-sm font-semibold tracking-tight truncate flex-1 min-w-0",children:e}),l.jsxs(Ye,{children:[l.jsx(Xe,{asChild:!0,children:l.jsx("button",{type:"button","aria-label":"Preview disclaimer",className:"cursor-help inline-flex items-center justify-center h-6 w-6 rounded-sm hover:bg-muted/60 shrink-0",children:l.jsx(qd,{className:"h-3.5 w-3.5 text-muted-foreground"})})}),l.jsx(Qe,{className:"max-w-sm",children:l.jsxs("p",{className:"text-sm",children:["Preview converts the file to a PDF with LibreOffice. Download the ",Pr," to verify fidelity."]})})]})]}),l.jsxs("div",{className:"flex flex-row items-center gap-x-1 shrink-0",children:[l.jsx(Bv,{}),l.jsxs(Ye,{children:[l.jsx(Xe,{asChild:!0,children:l.jsxs(Ce,{variant:"default",size:"sm",className:"gap-1.5 h-7 px-2.5",onClick:n,"aria-label":"Render preview",disabled:r||i||v===!1,children:[i?l.jsx(cn,{size:"sm"}):l.jsx(Nx,{className:"h-3.5 w-3.5"}),l.jsx("span",{className:"text-xs font-medium hidden sm:inline",children:"Run"})]})}),l.jsx(Qe,{children:l.jsx("p",{children:v===!1?"Open preview to run":i?"Rendering preview...":"Render preview"})})]}),l.jsx("div",{className:"w-px h-4 bg-border/60 mx-1"}),l.jsxs(Ye,{children:[l.jsx(Xe,{asChild:!0,children:l.jsxs(Ce,{variant:"outline",size:"sm",className:"gap-1.5 h-7 px-2.5",disabled:!t||k||r,onClick:ne,children:[k?l.jsx(cn,{size:"sm"}):l.jsx(Cx,{className:"h-3.5 w-3.5"}),l.jsx("span",{className:"text-xs font-medium hidden sm:inline",children:"Download"})]})}),l.jsx(Qe,{children:l.jsxs("p",{children:["Download ",Pr]})})]}),f&&f.length>0&&l.jsxs(Ye,{children:[l.jsx(Xe,{asChild:!0,children:l.jsx(Ce,{variant:"outline",size:"icon",className:"h-7 w-7 border-transparent bg-warning/10 text-warning hover:bg-warning/20",disabled:_||r,onClick:oe,children:_?l.jsx(cn,{size:"sm"}):l.jsx(Kd,{className:"h-3.5 w-3.5"})})}),l.jsx(Qe,{children:l.jsxs("p",{children:["Download warnings (",f.length,")"]})})]}),P.ids.length>1&&l.jsxs(li,{value:X,onValueChange:K=>V({generationBackend:K}),children:[l.jsxs(Ye,{children:[l.jsx(Xe,{asChild:!0,children:l.jsxs(xr,{"aria-label":"Renderer",className:"hidden h-7 w-auto min-h-0 gap-1.5 px-2 text-xs lg:flex [&>span]:flex [&>span]:items-center [&>span]:gap-1.5 [&>span]:whitespace-nowrap",children:[l.jsx(zo,{className:"h-3.5 w-3.5 shrink-0 opacity-60"}),l.jsxs(ci,{placeholder:"Renderer",children:[l.jsx("span",{className:"font-medium",children:X}),X!==P.default&&l.jsx(so,{})]})]})}),l.jsx(Qe,{children:l.jsxs("p",{children:["Renderer that writes the ",at.toUpperCase()," file. A non-default one may refuse a document it cannot express."]})})]}),l.jsx(yr,{className:"min-w-[var(--radix-select-trigger-width)] text-sidebar-foreground",children:l.jsxs(ef,{children:[l.jsx(ka,{className:"px-2 py-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Renderer"}),P.ids.map(K=>l.jsx(Mn,{value:K,className:"text-xs",children:l.jsxs("span",{className:"flex items-center gap-1.5 whitespace-nowrap",children:[l.jsx("span",{className:"font-medium",children:K}),K===P.default?l.jsx(nc,{}):l.jsx(so,{})]})},K))]})})]}),l.jsx("div",{className:"w-px h-4 bg-border/60 mx-1"}),l.jsxs(_i,{children:[l.jsxs(Ye,{children:[l.jsx(Xe,{asChild:!0,children:l.jsx(Ni,{asChild:!0,children:l.jsx(Ce,{variant:"ghost",size:"icon",className:"h-7 w-7",children:l.jsx(ba,{className:"h-3.5 w-3.5"})})})}),l.jsx(Qe,{children:l.jsx("p",{children:"More actions"})})]}),l.jsxs(Er,{align:"end",className:"w-52",children:[o&&l.jsxs($t,{onClick:o,children:[l.jsx(Ex,{className:"h-4 w-4 mr-2"}),"View JSON Schemas"]}),a&&l.jsxs($t,{onClick:a,children:[l.jsx(Ao,{className:"h-4 w-4 mr-2"}),"Browse fonts"]}),s&&l.jsxs($t,{onClick:s,children:[l.jsx(Oo,{className:"h-4 w-4 mr-2"}),"View cache metrics"]}),re?l.jsxs($t,{onClick:ae,disabled:O,children:[l.jsx(Po,{className:"h-4 w-4 mr-2"}),O?"Copying...":"Copy standard components"]}):l.jsxs(Ye,{children:[l.jsx(Xe,{asChild:!0,children:l.jsx("span",{className:"block",children:l.jsxs($t,{disabled:!0,children:[l.jsx(Po,{className:"h-4 w-4 mr-2"}),"Copy standard components"]})})}),l.jsx(Qe,{side:"left",children:l.jsx("p",{children:"No document selected — open or select a document first"})})]}),l.jsx(Fn,{}),l.jsxs($t,{onClick:()=>S(!0),disabled:A,className:"text-destructive focus:text-destructive",children:[l.jsx(va,{className:"h-4 w-4 mr-2"}),A?"Clearing...":"Clear all caches"]}),P.ids.length>1&&l.jsxs(l.Fragment,{children:[l.jsx(Fn,{className:"lg:hidden"}),l.jsx(za,{className:"lg:hidden px-2 py-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Renderer"}),P.ids.map(K=>l.jsxs($t,{className:"lg:hidden gap-1.5",onClick:()=>V({generationBackend:K}),children:[l.jsx(un,{className:`h-3.5 w-3.5 shrink-0 ${X===K?"opacity-100":"opacity-0"}`}),l.jsx("span",{className:"font-medium",children:K}),K===P.default?l.jsx(nc,{}):l.jsx(so,{})]},K))]})]})]}),m&&l.jsxs(Ye,{children:[l.jsx(Xe,{asChild:!0,children:l.jsx(Ce,{variant:v?"default":"ghost",size:"icon",className:"h-7 w-7",onClick:m,children:v?l.jsx(Yd,{className:"h-3.5 w-3.5"}):l.jsx(Tx,{className:"h-3.5 w-3.5"})})}),l.jsx(Qe,{children:l.jsxs("span",{className:"flex items-center gap-1.5",children:[v?"Hide":"Show"," Preview"," ",l.jsx(di,{shortcut:"mod+shift+p"})]})})]}),h&&l.jsxs(Ye,{children:[l.jsx(Xe,{asChild:!0,children:l.jsx(Ce,{variant:p?"default":"ghost",size:"icon",className:"h-7 w-7",onClick:h,children:l.jsx(Xd,{className:"h-3.5 w-3.5"})})}),l.jsx(Qe,{children:l.jsxs("span",{className:"flex items-center gap-1.5",children:[p?"Close":"Open"," AI Chat"," ",l.jsx(di,{shortcut:"mod+shift+j"})]})})]})]})]}),l.jsx($v,{open:ce,onClose:()=>b(!1),nonSafeFonts:ye,onChoose:Q}),l.jsx(ct,{open:N!=null,onOpenChange:K=>{K||R(null)},children:l.jsxs(lt,{className:"max-w-lg",children:[l.jsxs(qt,{children:[l.jsx(Gt,{children:"Standard components"}),l.jsx(dn,{children:"The browser blocked the automatic clipboard write. Copy the JSON from here instead."})]}),l.jsx(mp,{readOnly:!0,value:N??"",className:"h-64 font-mono text-xs",onFocus:K=>K.currentTarget.select()}),l.jsxs(kn,{children:[l.jsx(Ce,{variant:"outline",size:"sm",onClick:()=>R(null),children:"Close"}),l.jsx(Ce,{size:"sm",onClick:H,children:"Copy to clipboard"})]})]})}),l.jsx(ct,{open:w,onOpenChange:S,children:l.jsxs(lt,{className:"max-w-sm",children:[l.jsxs(qt,{children:[l.jsx(Gt,{children:"Clear all caches?"}),l.jsx(dn,{children:"This will clear the document, component, and rasterized-visual caches. Next generation will be uncached."})]}),l.jsxs(kn,{children:[l.jsx(Ce,{variant:"outline",size:"sm",onClick:()=>S(!1),children:"Cancel"}),l.jsx(Ce,{variant:"destructive",size:"sm",disabled:A,onClick:async()=>{await I(),S(!1)},children:A?l.jsx(cn,{size:"sm"}):"Clear"})]})]})})]})}const Vv=je.memo(Zv),gp=Xg,Fa=g.forwardRef(({className:e,...t},n)=>l.jsx(Ld,{ref:n,className:W("bg-muted text-muted-foreground inline-flex h-9 items-center justify-center rounded-sm p-1",e),...t}));Fa.displayName=Ld.displayName;const fr=g.forwardRef(({className:e,...t},n)=>l.jsx(Bd,{ref:n,className:W("ring-offset-background focus-visible:ring-ring data-[state=active]:bg-background data-[state=active]:text-foreground inline-flex cursor-pointer items-center justify-center rounded-sm px-3 py-1 text-sm font-medium whitespace-nowrap transition-all focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:pointer-events-none disabled:opacity-50",e),...t}));fr.displayName=Bd.displayName;const pr=g.forwardRef(({className:e,...t},n)=>l.jsx(Zd,{ref:n,className:W("ring-offset-background focus-visible:ring-ring mt-2 focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none",e),...t}));pr.displayName=Zd.displayName;async function Uv(e){if(navigator.clipboard&&navigator.clipboard.writeText)try{return await navigator.clipboard.writeText(e),!0}catch(t){console.warn("Clipboard API failed, falling back to legacy method:",t)}try{const t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.top="0",t.style.left="0",t.style.width="2em",t.style.height="2em",t.style.padding="0",t.style.border="none",t.style.outline="none",t.style.boxShadow="none",t.style.background="transparent",document.body.appendChild(t),t.focus(),t.select();const n=document.execCommand("copy");return document.body.removeChild(t),n}catch(t){return console.error("Failed to copy text to clipboard:",t),!1}}function Jv(e){try{const t=typeof e=="string"?JSON.parse(e):e;return JSON.stringify(t,null,2)}catch(t){return console.error("Failed to format schema:",t),typeof e=="string"?e:JSON.stringify(e)}}async function Hv(e){const t=Jv(e);return Uv(t)}const Wv=({open:e,onOpenChange:t,defaultTab:n="document"})=>{const[r,i]=g.useState(n),[s,o]=g.useState(null),[a,c]=g.useState(null),[u,d]=g.useState(!1),[f,h]=g.useState(!1),[p,m]=g.useState(null),[v,k]=g.useState(null),[y,_]=g.useState(!1),{toast:x}=_r(),A=Jt(P=>P.selectedPlugins),E=Array.from(A),w=vn(mg);g.useEffect(()=>{n&&i(n)},[n]);const S=g.useCallback(async()=>{d(!0),m(null);try{const P=await Gs.fetchDocumentSchema(E,gg(vn.getState()));o(P)}catch(P){const J=P instanceof Error?P.message:"Failed to load document schema";m(J),x({variant:"destructive",title:"Error loading schema",description:J})}finally{d(!1)}},[E,w,x]),O=g.useCallback(async()=>{if(!a){h(!0),k(null);try{const P=await Gs.fetchThemeSchema();c(P)}catch(P){const J=P instanceof Error?P.message:"Failed to load theme schema";k(J),x({variant:"destructive",title:"Error loading schema",description:J})}finally{h(!1)}}},[a,x]),[B,N]=g.useState([]),[R,T]=g.useState(w);g.useEffect(()=>{e||(o(null),m(null))},[e]),g.useEffect(()=>{if(!e)return;const P=E.length!==B.length||E.some((V,X)=>V!==B[X]),J=w!==R;r==="document"?(!s||P||J)&&((P||J)&&(Gs.clearPluginSchemaCache(),N([...E]),T(w)),u||S()):r==="theme"&&!a&&!f&&O()},[r,e,s,a,u,f,E,B,w,R,S,O]);const F=E.length,$=r==="document"?s:a,Z=async()=>{if($)try{await Hv($)&&(_(!0),x({title:"Schema copied",description:"The JSON schema has been copied to your clipboard"}),setTimeout(()=>_(!1),2e3))}catch(P){console.error("Copy failed:",P)}};return l.jsx(ct,{open:e,onOpenChange:t,children:l.jsxs(lt,{className:"max-w-4xl max-h-[90vh] overflow-hidden flex flex-col",children:[l.jsx(qt,{children:l.jsx(Gt,{children:"Schema Viewer"})}),l.jsxs(gp,{value:r,onValueChange:P=>i(P),className:"flex-1 overflow-hidden flex flex-col",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs(Fa,{children:[l.jsxs(fr,{value:"document",className:"flex items-center gap-1",children:["Document",F>0&&l.jsxs(tn,{variant:"secondary",className:"ml-1 text-xs px-1 py-0",children:["+",F]})]}),l.jsx(fr,{value:"theme",children:"Theme"})]}),l.jsx("div",{className:"ml-auto",children:l.jsx(Ce,{variant:"ghost",size:"icon",onClick:Z,disabled:y||!$,"aria-label":"Copy schema",children:y?l.jsx(un,{className:"h-4 w-4"}):l.jsx(Es,{className:"h-4 w-4"})})})]}),l.jsxs("div",{className:"flex-1 overflow-auto mt-4",children:[l.jsx(pr,{value:"document",className:"h-full",children:l.jsx(as,{schema:s,loading:u,error:p||void 0})}),l.jsx(pr,{value:"theme",className:"h-full",children:l.jsx(as,{schema:a,loading:f,error:v||void 0})})]})]})]})})};function La(e,t){var r;const n=sd.getState().getEditor(e);return(r=n==null?void 0:n.flushPendingSave)==null||r.call(n),n?n.toStorageValue(n.editor.getValue()):t}function xp(e,t,n){if(t.length===0)return n;const r=rc(e,t[0]);let i=r;for(let s=0;s<t.length-1;s++){const o=t[s],a=t[s+1],c=i[o],u=rc(c,a);i[o]=u,i=u}return i[t[t.length-1]]=n,r}function rc(e,t){return typeof t=="number"?Array.isArray(e)?[...e]:[]:e&&typeof e=="object"&&!Array.isArray(e)?{...e}:{}}const ic=2*1024*1024,sc=12*1024*1024;function qv(e){if(e.length<4)return"unknown";const[t,n,r,i]=e;return t===0&&n===1&&r===0&&i===0||t===116&&n===114&&r===117&&i===101||t===116&&n===116&&r===99&&i===102?"ttf":t===79&&n===84&&r===84&&i===79?"otf":t===119&&n===79&&r===70&&i===70?"woff":t===119&&n===79&&r===70&&i===50?"woff2":"unknown"}function Gv(e){let n="";for(let r=0;r<e.length;r+=32768)n+=String.fromCharCode(...e.subarray(r,r+32768));return btoa(n)}function us(e){return e>=1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:`${Math.round(e/1024)} KB`}function Kv(e,t){if(t.length===0)return{ok:!1,message:`"${e}" is empty.`};if(t.length>ic)return{ok:!1,message:`"${e}" is ${us(t.length)}. The limit is ${us(ic)} per font, because the bytes travel inside the document JSON.`};const n=qv(t);return n==="woff"||n==="woff2"?{ok:!1,message:`"${e}" is a ${n.toUpperCase()} file. Upload the TTF or OTF instead — the preview renderer cannot register web font formats.`}:n!=="ttf"&&n!=="otf"?{ok:!1,message:`"${e}" does not look like a TTF or OTF font file.`}:{ok:!0,format:n,base64:Gv(t)}}const Yv=new Set(["italic","oblique"]);function Xv(e){const t=e.replace(/\.[^.]+$/,""),n=t.split(/[-_\s]+/).filter(Boolean),r=new Map;for(const[o,a]of Object.entries(ld))r.set(a.toLowerCase(),Number(o));let i=400,s=!1;for(;n.length>1;){const o=n[n.length-1].toLowerCase();if(Yv.has(o)){s=!0,n.pop();continue}const a=r.get(o);if(a!==void 0){i=a,n.pop();continue}break}return{family:n.join(" ")||t,weight:i,italic:s}}function Qv(e,t){const n=Array.isArray(e)?[...e]:[],r=n.findIndex(i=>{var s;return((s=i==null?void 0:i.family)==null?void 0:s.toLowerCase())===t.family.toLowerCase()});return r>=0?n[r]=t:n.push(t),n}function ew(e){return e.kind==="safe"||e.kind==="google"?null:{weight:"weight"in e&&e.weight?e.weight:400,italic:"italic"in e?!!e.italic:!1}}function tw(e,t,n,r){const i=((e==null?void 0:e.sources)??[]).filter(a=>{const c=ew(a);return c?!n.some(u=>u.weight===c.weight&&u.italic===c.italic):!0}),s=n.map(a=>({kind:"data",data:a.data,weight:a.weight,italic:a.italic})),o=r??(e==null?void 0:e.category);return{id:(e==null?void 0:e.id)??t,family:t,...o?{category:o}:{},sources:[...i,...s]}}function nw(e,t){let n=Array.isArray(e)?[...e]:[];for(const r of t){const i=r.sources.filter(o=>o.kind==="data").map(o=>({data:o.data,weight:o.weight??400,italic:o.italic??!1}));if(i.length===0)continue;const s=n.find(o=>{var a;return((a=o==null?void 0:o.family)==null?void 0:a.toLowerCase())===r.family.toLowerCase()});n=Qv(n,tw(s,r.family,i,r.category))}return n}function rw(e,t){const n=(e.sources??[]).filter(r=>r.format==="ttf"||r.format==="otf").map(r=>({kind:"data",data:r.data,weight:r.weight,italic:r.italic}));return n.length===0?null:{id:e.family,family:e.family,...t?{category:t}:{},sources:n}}function iw(e){const t=new TextEncoder().encode(e).length;return t<=sc?null:`Adding this font would push the document to ${us(t)}, past the ${us(sc)} limit. Remove a font from props.fontRegistry, or use fewer weights.`}const oc=new Set,sw=(e,t,n)=>`${e.toLowerCase()}|${t}|${n?"i":"r"}`;function ac(e,t){var d;if(typeof document>"u"||!e.trim())return;const n=`gf-${e.replace(/\s+/g,"-")}`,r=document.getElementById(n),i=new Set(t&&t.length>0?t:[400,700]),s=new Set(((d=r==null?void 0:r.dataset.weights)==null?void 0:d.split(",").map(Number).filter(f=>!Number.isNaN(f)))??[]),o=new Set([...s,...i]);if(r&&o.size===s.size)return;const a=[...o].sort((f,h)=>f-h).join(";"),c=`https://fonts.googleapis.com/css2?family=${encodeURIComponent(e)}:wght@${a}&display=swap`,u=r??document.createElement("link");r||(u.id=n,u.rel="stylesheet",document.head.appendChild(u)),u.href=c,u.dataset.weights=[...o].sort((f,h)=>f-h).join(",")}function ow(e){const t=e.startsWith("data:")?e.slice(e.indexOf(",")+1):e,n=atob(t),r=new Uint8Array(n.length);for(let i=0;i<n.length;i++)r[i]=n.charCodeAt(i);return r}async function aw(e,t,n,r){const i=sw(e,n,r);if(!oc.has(i))try{if(typeof FontFace>"u"||!(document!=null&&document.fonts))return;const s=ow(t),o=new FontFace(e,s.buffer,{weight:String(n),style:r?"italic":"normal"});await o.load(),document.fonts.add(o),oc.add(i)}catch{}}const lw={safe:[],google:[]};function cw(){const e=ke(i=>i.activeTab),t=ke(i=>i.documents),n=ke(i=>i.documentTypes),r=ke(i=>i.saveDocument);return g.useCallback(i=>{if(!e)return{ok:!1,error:"No active file"};if(n[e]!=="application/json+theme")return{ok:!1,error:"Fonts are registered on themes, not documents. Open a .theme.json file and try again."};const s=t.find(u=>u.name===e);if(!s)return{ok:!1,error:"Active theme not found"};const o=La(e,s.text);let a;try{a=JSON.parse(o)}catch(u){return{ok:!1,error:`Active theme is not valid JSON: ${u.message}`}}const c=i(a);return r(e,JSON.stringify(c,null,2)),{ok:!0,name:e}},[e,t,n,r])}function uw(){const e=ke(r=>r.activeTab),t=ke(r=>r.documents),n=ke(r=>r.saveDocument);return g.useCallback((r,i)=>{if(!e)return{ok:!1,error:"No active file"};const s=t.find(u=>u.name===e);if(!s)return{ok:!1,error:"Active document not found"};const o=La(e,s.text);let a;try{a=JSON.parse(o)}catch(u){return{ok:!1,error:`Active document is not valid JSON: ${u.message}`}}const c=xp(a,r,i);return n(e,JSON.stringify(c,null,2)),{ok:!0,name:e}},[e,t,n])}function dw(){const e=ke(i=>i.activeTab),t=ke(i=>i.documents),n=ke(i=>i.documentTypes),r=ke(i=>i.saveDocument);return g.useCallback(i=>{var h;if(i.length===0)return{ok:!0,name:e};if(!e)return{ok:!1,error:"No active file"};if(n[e]==="application/json+theme")return{ok:!1,error:"Custom fonts are registered on the document, not the theme. Open the .docx.json / .pptx.json tab and try again."};const s=t.find(p=>p.name===e);if(!s)return{ok:!1,error:"Active document not found"};const o=La(e,s.text);let a;try{a=JSON.parse(o)}catch(p){return{ok:!1,error:`Active document is not valid JSON: ${p.message}`}}const c=nw((h=a==null?void 0:a.props)==null?void 0:h.fontRegistry,i),u=xp(a,["props","fontRegistry"],c),d=JSON.stringify(u,null,2),f=iw(d);return f?{ok:!1,error:f}:(r(e,d),{ok:!0,name:e})},[e,t,n,r])}function fw(e,t,n){(!e.fonts||typeof e.fonts!="object")&&(e.fonts={});const r=e.fonts[t];r&&typeof r=="object"?e.fonts[t]={...r,family:n}:e.fonts[t]=n}function lc(e){return e.map((t,n)=>typeof t=="number"?`[${t}]`:n===0?t:`.${t}`).join("")}const pw=({open:e,onOpenChange:t})=>{const n=Hi(I=>I.open),r=Hi(I=>I.contextual),i=Hi(I=>I.close),s=e??n,o=r,a=g.useCallback(I=>{t&&t(I),I||i()},[t,i]),[c,u]=g.useState(lw),[d,f]=g.useState(!1),[h,p]=g.useState(""),[m,v]=g.useState("safe"),[k,y]=g.useState(null),[_,x]=g.useState(null),[A,E]=g.useState(!1),[w,S]=g.useState(!1),[O,B]=g.useState(""),[N,R]=g.useState([]),T=g.useRef(null),{toast:F}=_r(),$=cw(),Z=uw(),P=dw(),J=ke(I=>I.activeTab),V=ke(I=>I.documentTypes),X=J&&V[J]==="application/json+theme",j=!!o||X;g.useEffect(()=>{s&&(c.safe.length>0||c.google.length>0||(f(!0),fetch(oi.fonts.catalog).then(I=>I.json()).then(I=>u(I)).catch(I=>{F({variant:"destructive",title:"Font catalog unavailable",description:I.message})}).finally(()=>f(!1))))},[s,c,F]),g.useEffect(()=>{if(!(m!=="google"||c.google.length===0))for(const I of c.google)ac(I.family,I.weights)},[m,c]);const ye=g.useMemo(()=>c.safe.filter(I=>I.toLowerCase().includes(h.toLowerCase())),[c.safe,h]),ce=g.useMemo(()=>c.google.filter(I=>I.family.toLowerCase().includes(h.toLowerCase())),[c.google,h]),b=g.useCallback(async I=>{try{await navigator.clipboard.writeText(I),x(I),setTimeout(()=>x(null),1500)}catch{F({variant:"destructive",title:"Copy failed",description:"Your browser blocked clipboard write."})}},[F]),G=g.useCallback(async(I,re,ae)=>{y(I);try{const H=$(K=>(fw(K,ae,I),K));if(!H.ok){F({variant:"destructive",title:"Could not insert font",description:H.error});return}F({title:"Font inserted",description:`${I} set as ${ae} font in "${H.name}".`})}finally{y(null)}},[$,F]),ne=g.useCallback(async I=>{if(o){y(I);try{const re=Z(o.jsonPath,I);if(!re.ok){F({variant:"destructive",title:"Could not insert font",description:re.error});return}F({title:"Font inserted",description:`${I} set at ${lc(o.jsonPath)}.`}),a(!1)}finally{y(null)}}},[o,Z,F,a]),Q=g.useCallback(async I=>{if(!(!I||I.length===0)){E(!0);try{const re=[];for(const H of Array.from(I)){const K=new Uint8Array(await H.arrayBuffer()),pe=Kv(H.name,K);if(!pe.ok){F({variant:"destructive",title:"Font rejected",description:pe.message});continue}re.push({identity:Xv(H.name),base64:pe.base64})}if(re.length===0)return;const ae=P(re.map(({identity:H,base64:K})=>({id:H.family,family:H.family,sources:[{kind:"data",data:K,weight:H.weight,italic:H.italic}]})));if(!ae.ok){F({variant:"destructive",title:"Could not register font",description:ae.error});return}for(const{identity:H,base64:K}of re)aw(H.family,K,H.weight,H.italic),F({title:`Added ${H.family}`,description:`Registered at weight ${H.weight}${H.italic?" italic":""} in props.fontRegistry. Reference it as "${H.family}".`})}catch(re){F({variant:"destructive",title:"Upload failed",description:re.message})}finally{E(!1),T.current&&(T.current.value="")}}},[P,F]),oe=g.useCallback(async()=>{var re,ae;const I=O.trim();if(I){S(!0),R([]);try{const H=await fetch(oi.fonts.materialize,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({family:I,weights:[400,700],italics:!1})});if(H.status===429)throw new Error("Too many font fetches — the playground allows 20 every 15 minutes. Try again shortly.");if(!H.ok){const Oe=await H.json().catch(()=>({}));throw new Error(Oe.error??`Materialize failed (${H.status})`)}const K=await H.json();R(K.warnings??[]);const pe=(re=c.google.find(Oe=>Oe.family.toLowerCase()===K.family.toLowerCase()))==null?void 0:re.category,fe=rw(K,pe);if(!fe){F({variant:"destructive",title:"Nothing to embed",description:((ae=K.warnings)==null?void 0:ae.join(" · "))||`Google Fonts has no family named "${I}".`});return}const Re=P([fe]);if(!Re.ok){F({variant:"destructive",title:"Could not register font",description:Re.error});return}ac(K.family,[400,700]),F({title:`Added ${K.family}`,description:`Embedded ${fe.sources.length} weight(s) in props.fontRegistry.`})}catch(H){F({variant:"destructive",title:"Google Fonts fetch failed",description:H.message})}finally{S(!1)}}},[O,c.google,P,F]);return l.jsx(ct,{open:s,onOpenChange:a,children:l.jsxs(lt,{className:"max-w-4xl max-h-[90vh] overflow-hidden flex flex-col",children:[l.jsx(qt,{children:l.jsx(Gt,{children:o?`Font for ${lc(o.jsonPath)}`:"Fonts"})}),!o&&!X&&m!=="custom"&&l.jsx(lr,{children:l.jsxs(cr,{children:["Fonts are registered on themes. Open a ",l.jsx("code",{children:".theme.json"})," ","file to apply a font — the buttons below are disabled until you do."]})}),l.jsxs(gp,{value:m,onValueChange:I=>v(I),className:"flex-1 overflow-hidden flex flex-col",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs(Fa,{children:[l.jsxs(fr,{value:"safe",children:["Safe",l.jsx(tn,{variant:"secondary",className:"ml-1 text-xs px-1 py-0",children:c.safe.length})]}),l.jsxs(fr,{value:"google",children:["Google",l.jsx(tn,{variant:"secondary",className:"ml-1 text-xs px-1 py-0",children:c.google.length})]}),l.jsx(fr,{value:"custom",children:"Custom"})]}),l.jsx(br,{type:"search",placeholder:"Search fonts...",value:h,onChange:I=>p(I.target.value),className:"ml-auto max-w-xs"})]}),l.jsxs("div",{className:"flex-1 overflow-auto mt-4 pr-2",children:[l.jsx(pr,{value:"safe",className:"m-0",children:d&&ye.length===0?l.jsxs("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:[l.jsx(Jr,{className:"animate-spin mr-2"})," Loading catalog..."]}):l.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:ye.map(I=>l.jsx(cc,{family:I,meta:l.jsx("span",{className:"text-xs",children:"Installed with Office"}),previewStyle:{fontFamily:`"${I}", sans-serif`},onCopy:()=>b(I),copied:_===I,contextual:!!o,onUseThis:()=>ne(I),onInsertHeading:()=>G(I,"safe","heading"),onInsertBody:()=>G(I,"safe","body"),applying:k===I,disabled:!j},I))})}),l.jsx(pr,{value:"google",className:"m-0",children:d&&ce.length===0?l.jsxs("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:[l.jsx(Jr,{className:"animate-spin mr-2"})," Loading catalog..."]}):l.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:ce.map(I=>l.jsx(cc,{family:I.family,meta:l.jsxs("span",{className:"text-xs",children:[I.category," · ",I.weights.length," weights"]}),previewStyle:{fontFamily:`"${I.family}", sans-serif`},onCopy:()=>b(I.family),copied:_===I.family,contextual:!!o,onUseThis:()=>ne(I.family),onInsertHeading:()=>G(I.family,"google","heading"),onInsertBody:()=>G(I.family,"google","body"),applying:k===I.family,disabled:!j,extraAction:l.jsx(mw,{family:I.family,weights:I.weights,hasItalic:I.hasItalic})},I.family))})}),l.jsx(pr,{value:"custom",className:"m-0 flex flex-col gap-6",children:X?l.jsx(lr,{children:l.jsxs(cr,{children:["Custom fonts are stored on the document (",l.jsx("code",{children:"props.fontRegistry"}),"), because the bytes travel with the JSON. Open a document tab to add one."]})}):l.jsxs(l.Fragment,{children:[l.jsxs("section",{className:"flex flex-col gap-2",children:[l.jsx("h3",{className:"text-sm font-medium",children:"Upload a font file"}),l.jsxs("p",{className:"text-xs text-muted-foreground",children:["TTF or OTF, up to 2 MB each. The font is embedded in the document as base64, so it survives export and re-import — and renders in the preview. The family and weight are guessed from the filename (e.g."," ",l.jsx("code",{children:"Geist-SemiBold.ttf"}),")."]}),l.jsxs("div",{onDragOver:I=>I.preventDefault(),onDrop:I=>{I.preventDefault(),Q(I.dataTransfer.files)},className:"rounded-md border border-dashed p-6 text-center",children:[l.jsx("input",{ref:T,type:"file",accept:".ttf,.otf,font/ttf,font/otf",multiple:!0,className:"hidden",onChange:I=>void Q(I.target.files)}),l.jsxs(Ce,{variant:"secondary",disabled:A,onClick:()=>{var I;return(I=T.current)==null?void 0:I.click()},children:[A?l.jsx(Jr,{className:"animate-spin mr-2 h-4 w-4"}):l.jsx(Ix,{className:"mr-2 h-4 w-4"}),"Choose font files"]}),l.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:"or drop them here"})]})]}),l.jsxs("section",{className:"flex flex-col gap-2",children:[l.jsx("h3",{className:"text-sm font-medium",children:"Embed any Google font"}),l.jsxs("p",{className:"text-xs text-muted-foreground",children:["Not limited to the ",c.google.length," curated families — type any Google Fonts family name and its regular and bold weights are fetched and embedded."]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(br,{placeholder:"e.g. Geist",value:O,onChange:I=>B(I.target.value),onKeyDown:I=>{I.key==="Enter"&&oe()}}),l.jsxs(Ce,{onClick:()=>void oe(),disabled:w||O.trim()==="",children:[w&&l.jsx(Jr,{className:"animate-spin mr-2 h-4 w-4"}),"Embed"]})]}),N.length>0&&l.jsx(lr,{children:l.jsx(cr,{className:"text-xs",children:N.join(" · ")})})]})]})})]})]})]})})},hw="The quick brown fox jumps over the lazy dog",mw=({family:e,weights:t,hasItalic:n})=>{const r=g.useMemo(()=>[...t].sort((i,s)=>i-s),[t]);return l.jsxs(_i,{children:[l.jsx(Ni,{asChild:!0,children:l.jsx(Ce,{size:"sm",variant:"ghost","aria-label":"Show variants",children:"Variants"})}),l.jsxs(Er,{align:"end",className:"min-w-[260px]",children:[l.jsxs(za,{className:"text-xs text-muted-foreground",children:[r.length," weight",r.length===1?"":"s",n?" · italic available":""]}),l.jsx(Fn,{}),r.map(i=>{const s=ld[i]??String(i);return l.jsxs("div",{className:"flex flex-col gap-0.5 px-2 py-1.5",children:[l.jsx("span",{className:"truncate",style:{fontFamily:`"${e}", sans-serif`,fontWeight:i},children:s}),l.jsxs("span",{className:"text-xs text-muted-foreground font-mono",children:["fontWeight: ",i]})]},i)})]})]})},cc=({family:e,meta:t,previewStyle:n,onCopy:r,copied:i,contextual:s,onUseThis:o,onInsertHeading:a,onInsertBody:c,applying:u,disabled:d,extraAction:f})=>l.jsxs("div",{className:"border rounded-md p-3 flex flex-col gap-2 bg-card",children:[l.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[l.jsx("div",{className:"font-medium truncate",children:e}),l.jsx("div",{className:"text-muted-foreground",children:t})]}),l.jsx("div",{className:"text-lg truncate",style:n,"aria-hidden":!0,children:hw}),l.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[s?l.jsx(Ce,{size:"sm",onClick:o,disabled:u||d,"aria-label":`Use ${e} at the target path`,children:"Use this font"}):l.jsxs(l.Fragment,{children:[l.jsx(Ce,{size:"sm",variant:"secondary",onClick:a,disabled:u||d,"aria-label":`Set ${e} as heading font`,children:"Set heading"}),l.jsx(Ce,{size:"sm",variant:"secondary",onClick:c,disabled:u||d,"aria-label":`Set ${e} as body font`,children:"Set body"})]}),f,l.jsx(Ce,{size:"sm",variant:"ghost",className:"ml-auto",onClick:r,"aria-label":`Copy ${e}`,children:i?l.jsx(un,{className:"h-4 w-4"}):l.jsx(Es,{className:"h-4 w-4"})})]})]});function uc({previewOpen:e,onTogglePreview:t}){const n=an(w=>w.name||""),r=an(w=>w.blob),i=an(w=>w.isGenerating),s=an(w=>w.text),o=an(w=>w.warnings),a=an(w=>w.isRendering),c=gr(w=>w.useGlobalPreviewHeader??!0),u=ke(w=>w.activeTab),d=ke(w=>w.documentTypes),f=u&&d[u]==="application/json+theme"?"theme":"document",h=ke(w=>{var S;return w.activeTab&&(w.documentTypes[w.activeTab]??"application/json+report")==="application/json+report"?(S=w.documents.find(O=>O.name===w.activeTab))==null?void 0:S.text:void 0}),p=ke(w=>w.activeTab&&(w.documentTypes[w.activeTab]??"application/json+report")==="application/json+report"?w.activeTab:void 0),m=De(w=>w.chatOpen),v=De(w=>w.toggleChat),[k,y]=je.useState(!1),_=Hi(w=>w.openFor);if(!c)return null;const x=g.useCallback(()=>{window.dispatchEvent(new CustomEvent("preview:manualRender"))},[]),A=g.useCallback(()=>{window.dispatchEvent(new CustomEvent("preview:showCacheMetrics"))},[]),E=(n==null?void 0:n.trim())||"Preview";return l.jsxs("div",{className:"sticky top-0 z-20",children:[l.jsx(Vv,{name:E,blob:r,onManualRender:x,isGenerating:i,isRendering:!!a,onShowCacheMetrics:A,onShowSchemas:()=>y(!0),onShowFonts:()=>_(),documentText:s,editorDocumentText:h,editorDocumentName:p,warnings:o,onToggleChat:v,chatOpen:m,onTogglePreview:t,previewOpen:e}),l.jsx(Wv,{open:k,onOpenChange:y,defaultTab:f==="theme"?"theme":"document"}),l.jsx(pw,{})]})}function gw(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const xw=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,yw=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,bw={};function dc(e,t){return(bw.jsx?yw:xw).test(e)}const vw=/[ \t\n\f\r]/g;function ww(e){return typeof e=="object"?e.type==="text"?fc(e.value):!1:fc(e)}function fc(e){return e.replace(vw,"")===""}class Ei{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}Ei.prototype.normal={};Ei.prototype.property={};Ei.prototype.space=void 0;function yp(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new Ei(n,r,t)}function qo(e){return e.toLowerCase()}class _t{constructor(t,n){this.attribute=n,this.property=t}}_t.prototype.attribute="";_t.prototype.booleanish=!1;_t.prototype.boolean=!1;_t.prototype.commaOrSpaceSeparated=!1;_t.prototype.commaSeparated=!1;_t.prototype.defined=!1;_t.prototype.mustUseProperty=!1;_t.prototype.number=!1;_t.prototype.overloadedBoolean=!1;_t.prototype.property="";_t.prototype.spaceSeparated=!1;_t.prototype.space=void 0;let kw=0;const Ne=Vn(),rt=Vn(),Go=Vn(),te=Vn(),Ve=Vn(),hr=Vn(),Ct=Vn();function Vn(){return 2**++kw}const Ko=Object.freeze(Object.defineProperty({__proto__:null,boolean:Ne,booleanish:rt,commaOrSpaceSeparated:Ct,commaSeparated:hr,number:te,overloadedBoolean:Go,spaceSeparated:Ve},Symbol.toStringTag,{value:"Module"})),oo=Object.keys(Ko);class Ba extends _t{constructor(t,n,r,i){let s=-1;if(super(t,n),pc(this,"space",i),typeof r=="number")for(;++s<oo.length;){const o=oo[s];pc(this,oo[s],(r&Ko[o])===Ko[o])}}}Ba.prototype.defined=!0;function pc(e,t,n){n&&(e[t]=n)}function Tr(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const s=new Ba(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[qo(r)]=r,n[qo(s.attribute)]=r}return new Ei(t,n,e.space)}const bp=Tr({properties:{ariaActiveDescendant:null,ariaAtomic:rt,ariaAutoComplete:null,ariaBusy:rt,ariaChecked:rt,ariaColCount:te,ariaColIndex:te,ariaColSpan:te,ariaControls:Ve,ariaCurrent:null,ariaDescribedBy:Ve,ariaDetails:null,ariaDisabled:rt,ariaDropEffect:Ve,ariaErrorMessage:null,ariaExpanded:rt,ariaFlowTo:Ve,ariaGrabbed:rt,ariaHasPopup:null,ariaHidden:rt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Ve,ariaLevel:te,ariaLive:null,ariaModal:rt,ariaMultiLine:rt,ariaMultiSelectable:rt,ariaOrientation:null,ariaOwns:Ve,ariaPlaceholder:null,ariaPosInSet:te,ariaPressed:rt,ariaReadOnly:rt,ariaRelevant:null,ariaRequired:rt,ariaRoleDescription:Ve,ariaRowCount:te,ariaRowIndex:te,ariaRowSpan:te,ariaSelected:rt,ariaSetSize:te,ariaSort:null,ariaValueMax:te,ariaValueMin:te,ariaValueNow:te,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function vp(e,t){return t in e?e[t]:t}function wp(e,t){return vp(e,t.toLowerCase())}const Sw=Tr({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:hr,acceptCharset:Ve,accessKey:Ve,action:null,allow:null,allowFullScreen:Ne,allowPaymentRequest:Ne,allowUserMedia:Ne,alt:null,as:null,async:Ne,autoCapitalize:null,autoComplete:Ve,autoFocus:Ne,autoPlay:Ne,blocking:Ve,capture:null,charSet:null,checked:Ne,cite:null,className:Ve,cols:te,colSpan:null,content:null,contentEditable:rt,controls:Ne,controlsList:Ve,coords:te|hr,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Ne,defer:Ne,dir:null,dirName:null,disabled:Ne,download:Go,draggable:rt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Ne,formTarget:null,headers:Ve,height:te,hidden:Go,high:te,href:null,hrefLang:null,htmlFor:Ve,httpEquiv:Ve,id:null,imageSizes:null,imageSrcSet:null,inert:Ne,inputMode:null,integrity:null,is:null,isMap:Ne,itemId:null,itemProp:Ve,itemRef:Ve,itemScope:Ne,itemType:Ve,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Ne,low:te,manifest:null,max:null,maxLength:te,media:null,method:null,min:null,minLength:te,multiple:Ne,muted:Ne,name:null,nonce:null,noModule:Ne,noValidate:Ne,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:Ne,optimum:te,pattern:null,ping:Ve,placeholder:null,playsInline:Ne,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Ne,referrerPolicy:null,rel:Ve,required:Ne,reversed:Ne,rows:te,rowSpan:te,sandbox:Ve,scope:null,scoped:Ne,seamless:Ne,selected:Ne,shadowRootClonable:Ne,shadowRootDelegatesFocus:Ne,shadowRootMode:null,shape:null,size:te,sizes:null,slot:null,span:te,spellCheck:rt,src:null,srcDoc:null,srcLang:null,srcSet:null,start:te,step:null,style:null,tabIndex:te,target:null,title:null,translate:null,type:null,typeMustMatch:Ne,useMap:null,value:rt,width:te,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Ve,axis:null,background:null,bgColor:null,border:te,borderColor:null,bottomMargin:te,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Ne,declare:Ne,event:null,face:null,frame:null,frameBorder:null,hSpace:te,leftMargin:te,link:null,longDesc:null,lowSrc:null,marginHeight:te,marginWidth:te,noResize:Ne,noHref:Ne,noShade:Ne,noWrap:Ne,object:null,profile:null,prompt:null,rev:null,rightMargin:te,rules:null,scheme:null,scrolling:rt,standby:null,summary:null,text:null,topMargin:te,valueType:null,version:null,vAlign:null,vLink:null,vSpace:te,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Ne,disableRemotePlayback:Ne,prefix:null,property:null,results:te,security:null,unselectable:null},space:"html",transform:wp}),jw=Tr({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Ct,accentHeight:te,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:te,amplitude:te,arabicForm:null,ascent:te,attributeName:null,attributeType:null,azimuth:te,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:te,by:null,calcMode:null,capHeight:te,className:Ve,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:te,diffuseConstant:te,direction:null,display:null,dur:null,divisor:te,dominantBaseline:null,download:Ne,dx:null,dy:null,edgeMode:null,editable:null,elevation:te,enableBackground:null,end:null,event:null,exponent:te,externalResourcesRequired:null,fill:null,fillOpacity:te,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:hr,g2:hr,glyphName:hr,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:te,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:te,horizOriginX:te,horizOriginY:te,id:null,ideographic:te,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:te,k:te,k1:te,k2:te,k3:te,k4:te,kernelMatrix:Ct,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:te,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:te,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:te,overlineThickness:te,paintOrder:null,panose1:null,path:null,pathLength:te,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Ve,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:te,pointsAtY:te,pointsAtZ:te,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Ct,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Ct,rev:Ct,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Ct,requiredFeatures:Ct,requiredFonts:Ct,requiredFormats:Ct,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:te,specularExponent:te,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:te,strikethroughThickness:te,string:null,stroke:null,strokeDashArray:Ct,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:te,strokeOpacity:te,strokeWidth:null,style:null,surfaceScale:te,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Ct,tabIndex:te,tableValues:null,target:null,targetX:te,targetY:te,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Ct,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:te,underlineThickness:te,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:te,values:null,vAlphabetic:te,vMathematical:te,vectorEffect:null,vHanging:te,vIdeographic:te,version:null,vertAdvY:te,vertOriginX:te,vertOriginY:te,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:te,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:vp}),kp=Tr({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),Sp=Tr({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:wp}),jp=Tr({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),_w={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},Nw=/[A-Z]/g,hc=/-[a-z]/g,Cw=/^data[-\w.:]+$/i;function Ew(e,t){const n=qo(t);let r=t,i=_t;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&Cw.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(hc,Iw);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!hc.test(s)){let o=s.replace(Nw,Tw);o.charAt(0)!=="-"&&(o="-"+o),t="data"+o}}i=Ba}return new i(r,t)}function Tw(e){return"-"+e.toLowerCase()}function Iw(e){return e.charAt(1).toUpperCase()}const Aw=yp([bp,Sw,kp,Sp,jp],"html"),Za=yp([bp,jw,kp,Sp,jp],"svg");function zw(e){return e.join(" ").trim()}var Gn={},ao,mc;function Ow(){if(mc)return ao;mc=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,o=/^[;\s]*/,a=/^\s+|\s+$/g,c=`
|
|
149
|
+
`,u="/",d="*",f="",h="comment",p="declaration";function m(k,y){if(typeof k!="string")throw new TypeError("First argument must be a string");if(!k)return[];y=y||{};var _=1,x=1;function A($){var Z=$.match(t);Z&&(_+=Z.length);var P=$.lastIndexOf(c);x=~P?$.length-P:x+$.length}function E(){var $={line:_,column:x};return function(Z){return Z.position=new w($),B(),Z}}function w($){this.start=$,this.end={line:_,column:x},this.source=y.source}w.prototype.content=k;function S($){var Z=new Error(y.source+":"+_+":"+x+": "+$);if(Z.reason=$,Z.filename=y.source,Z.line=_,Z.column=x,Z.source=k,!y.silent)throw Z}function O($){var Z=$.exec(k);if(Z){var P=Z[0];return A(P),k=k.slice(P.length),Z}}function B(){O(n)}function N($){var Z;for($=$||[];Z=R();)Z!==!1&&$.push(Z);return $}function R(){var $=E();if(!(u!=k.charAt(0)||d!=k.charAt(1))){for(var Z=2;f!=k.charAt(Z)&&(d!=k.charAt(Z)||u!=k.charAt(Z+1));)++Z;if(Z+=2,f===k.charAt(Z-1))return S("End of comment missing");var P=k.slice(2,Z-2);return x+=2,A(P),k=k.slice(Z),x+=2,$({type:h,comment:P})}}function T(){var $=E(),Z=O(r);if(Z){if(R(),!O(i))return S("property missing ':'");var P=O(s),J=$({type:p,property:v(Z[0].replace(e,f)),value:P?v(P[0].replace(e,f)):f});return O(o),J}}function F(){var $=[];N($);for(var Z;Z=T();)Z!==!1&&($.push(Z),N($));return $}return B(),F()}function v(k){return k?k.replace(a,f):f}return ao=m,ao}var gc;function Pw(){if(gc)return Gn;gc=1;var e=Gn&&Gn.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Gn,"__esModule",{value:!0}),Gn.default=n;const t=e(Ow());function n(r,i){let s=null;if(!r||typeof r!="string")return s;const o=(0,t.default)(r),a=typeof i=="function";return o.forEach(c=>{if(c.type!=="declaration")return;const{property:u,value:d}=c;a?i(u,d,c):d&&(s=s||{},s[u]=d)}),s}return Gn}var Lr={},xc;function Dw(){if(xc)return Lr;xc=1,Object.defineProperty(Lr,"__esModule",{value:!0}),Lr.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,i=/^-(ms)-/,s=function(u){return!u||n.test(u)||e.test(u)},o=function(u,d){return d.toUpperCase()},a=function(u,d){return"".concat(d,"-")},c=function(u,d){return d===void 0&&(d={}),s(u)?u:(u=u.toLowerCase(),d.reactCompat?u=u.replace(i,a):u=u.replace(r,a),u.replace(t,o))};return Lr.camelCase=c,Lr}var Br,yc;function Rw(){if(yc)return Br;yc=1;var e=Br&&Br.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},t=e(Pw()),n=Dw();function r(i,s){var o={};return!i||typeof i!="string"||(0,t.default)(i,function(a,c){a&&c&&(o[(0,n.camelCase)(a,s)]=c)}),o}return r.default=r,Br=r,Br}var $w=Rw();const Mw=ga($w),_p=Np("end"),Va=Np("start");function Np(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function Fw(e){const t=Va(e),n=_p(e);if(t&&n)return{start:t,end:n}}function ri(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?bc(e.position):"start"in e||"end"in e?bc(e):"line"in e||"column"in e?Yo(e):""}function Yo(e){return vc(e&&e.line)+":"+vc(e&&e.column)}function bc(e){return Yo(e&&e.start)+"-"+Yo(e&&e.end)}function vc(e){return e&&typeof e=="number"?e:1}class dt extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",s={},o=!1;if(n&&("line"in n&&"column"in n?s={place:n}:"start"in n&&"end"in n?s={place:n}:"type"in n?s={ancestors:[n],place:n.position}:s={...n}),typeof t=="string"?i=t:!s.cause&&t&&(o=!0,i=t.message,s.cause=t),!s.ruleId&&!s.source&&typeof r=="string"){const c=r.indexOf(":");c===-1?s.ruleId=r:(s.source=r.slice(0,c),s.ruleId=r.slice(c+1))}if(!s.place&&s.ancestors&&s.ancestors){const c=s.ancestors[s.ancestors.length-1];c&&(s.place=c.position)}const a=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=a?a.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=a?a.line:void 0,this.name=ri(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=o&&s.cause&&typeof s.cause.stack=="string"?s.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}dt.prototype.file="";dt.prototype.name="";dt.prototype.reason="";dt.prototype.message="";dt.prototype.stack="";dt.prototype.column=void 0;dt.prototype.line=void 0;dt.prototype.ancestors=void 0;dt.prototype.cause=void 0;dt.prototype.fatal=void 0;dt.prototype.place=void 0;dt.prototype.ruleId=void 0;dt.prototype.source=void 0;const Ua={}.hasOwnProperty,Lw=new Map,Bw=/[A-Z]/g,Zw=new Set(["table","tbody","thead","tfoot","tr"]),Vw=new Set(["td","th"]),Cp="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Uw(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=Xw(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=Yw(n,t.jsx,t.jsxs)}const i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?Za:Aw,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},s=Ep(i,e,void 0);return s&&typeof s!="string"?s:i.create(e,i.Fragment,{children:s||void 0},void 0)}function Ep(e,t,n){if(t.type==="element")return Jw(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return Hw(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return qw(e,t,n);if(t.type==="mdxjsEsm")return Ww(e,t);if(t.type==="root")return Gw(e,t,n);if(t.type==="text")return Kw(e,t)}function Jw(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=Za,e.schema=i),e.ancestors.push(t);const s=Ip(e,t.tagName,!1),o=Qw(e,t);let a=Ha(e,t);return Zw.has(t.tagName)&&(a=a.filter(function(c){return typeof c=="string"?!ww(c):!0})),Tp(e,o,s,t),Ja(o,a),e.ancestors.pop(),e.schema=r,e.create(t,s,o,n)}function Hw(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}hi(e,t.position)}function Ww(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);hi(e,t.position)}function qw(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=Za,e.schema=i),e.ancestors.push(t);const s=t.name===null?e.Fragment:Ip(e,t.name,!0),o=e0(e,t),a=Ha(e,t);return Tp(e,o,s,t),Ja(o,a),e.ancestors.pop(),e.schema=r,e.create(t,s,o,n)}function Gw(e,t,n){const r={};return Ja(r,Ha(e,t)),e.create(t,e.Fragment,r,n)}function Kw(e,t){return t.value}function Tp(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Ja(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function Yw(e,t,n){return r;function r(i,s,o,a){const u=Array.isArray(o.children)?n:t;return a?u(s,o,a):u(s,o)}}function Xw(e,t){return n;function n(r,i,s,o){const a=Array.isArray(s.children),c=Va(r);return t(i,s,o,a,{columnNumber:c?c.column-1:void 0,fileName:e,lineNumber:c?c.line:void 0},void 0)}}function Qw(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&Ua.call(t.properties,i)){const s=t0(e,i,t.properties[i]);if(s){const[o,a]=s;e.tableCellAlignToStyle&&o==="align"&&typeof a=="string"&&Vw.has(t.tagName)?r=a:n[o]=a}}if(r){const s=n.style||(n.style={});s[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function e0(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const s=r.data.estree.body[0];s.type;const o=s.expression;o.type;const a=o.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else hi(e,t.position);else{const i=r.name;let s;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const a=r.value.data.estree.body[0];a.type,s=e.evaluater.evaluateExpression(a.expression)}else hi(e,t.position);else s=r.value===null?!0:r.value;n[i]=s}return n}function Ha(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:Lw;for(;++r<t.children.length;){const s=t.children[r];let o;if(e.passKeys){const c=s.type==="element"?s.tagName:s.type==="mdxJsxFlowElement"||s.type==="mdxJsxTextElement"?s.name:void 0;if(c){const u=i.get(c)||0;o=c+"-"+u,i.set(c,u+1)}}const a=Ep(e,s,o);a!==void 0&&n.push(a)}return n}function t0(e,t,n){const r=Ew(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?gw(n):zw(n)),r.property==="style"){let i=typeof n=="object"?n:n0(e,String(n));return e.stylePropertyNameCase==="css"&&(i=r0(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&r.space?_w[r.property]||r.property:r.attribute,n]}}function n0(e,t){try{return Mw(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,i=new dt("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw i.file=e.filePath||void 0,i.url=Cp+"#cannot-parse-style-attribute",i}}function Ip(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const i=t.split(".");let s=-1,o;for(;++s<i.length;){const a=dc(i[s])?{type:"Identifier",name:i[s]}:{type:"Literal",value:i[s]};o=o?{type:"MemberExpression",object:o,property:a,computed:!!(s&&a.type==="Literal"),optional:!1}:a}r=o}else r=dc(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const i=r.value;return Ua.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(r);hi(e)}function hi(e,t){const n=new dt("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=Cp+"#cannot-handle-mdx-estrees-without-createevaluater",n}function r0(e){const t={};let n;for(n in e)Ua.call(e,n)&&(t[i0(n)]=e[n]);return t}function i0(e){let t=e.replace(Bw,s0);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function s0(e){return"-"+e.toLowerCase()}const lo={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},o0={};function Wa(e,t){const n=o0,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return Ap(e,r,i)}function Ap(e,t,n){if(a0(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return wc(e.children,t,n)}return Array.isArray(e)?wc(e,t,n):""}function wc(e,t,n){const r=[];let i=-1;for(;++i<e.length;)r[i]=Ap(e[i],t,n);return r.join("")}function a0(e){return!!(e&&typeof e=="object")}const kc=document.createElement("i");function qa(e){const t="&"+e+";";kc.innerHTML=t;const n=kc.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function At(e,t,n,r){const i=e.length;let s=0,o;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);s<r.length;)o=r.slice(s,s+1e4),o.unshift(t,0),e.splice(...o),s+=1e4,t+=1e4}function Mt(e,t){return e.length>0?(At(e,e.length,0,t),e):t}const Sc={}.hasOwnProperty;function zp(e){const t={};let n=-1;for(;++n<e.length;)l0(t,e[n]);return t}function l0(e,t){let n;for(n in t){const i=(Sc.call(e,n)?e[n]:void 0)||(e[n]={}),s=t[n];let o;if(s)for(o in s){Sc.call(i,o)||(i[o]=[]);const a=s[o];c0(i[o],Array.isArray(a)?a:a?[a]:[])}}}function c0(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);At(e,0,0,r)}function Op(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function Wt(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const xt=_n(/[A-Za-z]/),ut=_n(/[\dA-Za-z]/),u0=_n(/[#-'*+\--9=?A-Z^-~]/);function ds(e){return e!==null&&(e<32||e===127)}const Xo=_n(/\d/),d0=_n(/[\dA-Fa-f]/),f0=_n(/[!-/:-@[-`{-~]/);function be(e){return e!==null&&e<-2}function Ze(e){return e!==null&&(e<0||e===32)}function Ie(e){return e===-2||e===-1||e===32}const Ms=_n(new RegExp("\\p{P}|\\p{S}","u")),Bn=_n(/\s/);function _n(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Ir(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const s=e.charCodeAt(n);let o="";if(s===37&&ut(e.charCodeAt(n+1))&&ut(e.charCodeAt(n+2)))i=2;else if(s<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(s))||(o=String.fromCharCode(s));else if(s>55295&&s<57344){const a=e.charCodeAt(n+1);s<56320&&a>56319&&a<57344?(o=String.fromCharCode(s,a),i=1):o="�"}else o=String.fromCharCode(s);o&&(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,o=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function Pe(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let s=0;return o;function o(c){return Ie(c)?(e.enter(n),a(c)):t(c)}function a(c){return Ie(c)&&s++<i?(e.consume(c),a):(e.exit(n),t(c))}}const p0={tokenize:h0};function h0(e){const t=e.attempt(this.parser.constructs.contentInitial,r,i);let n;return t;function r(a){if(a===null){e.consume(a);return}return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),Pe(e,t,"linePrefix")}function i(a){return e.enter("paragraph"),s(a)}function s(a){const c=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=c),n=c,o(a)}function o(a){if(a===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(a);return}return be(a)?(e.consume(a),e.exit("chunkText"),s):(e.consume(a),o)}}const m0={tokenize:g0},jc={tokenize:x0};function g0(e){const t=this,n=[];let r=0,i,s,o;return a;function a(x){if(r<n.length){const A=n[r];return t.containerState=A[1],e.attempt(A[0].continuation,c,u)(x)}return u(x)}function c(x){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&_();const A=t.events.length;let E=A,w;for(;E--;)if(t.events[E][0]==="exit"&&t.events[E][1].type==="chunkFlow"){w=t.events[E][1].end;break}y(r);let S=A;for(;S<t.events.length;)t.events[S][1].end={...w},S++;return At(t.events,E+1,0,t.events.slice(A)),t.events.length=S,u(x)}return a(x)}function u(x){if(r===n.length){if(!i)return h(x);if(i.currentConstruct&&i.currentConstruct.concrete)return m(x);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(jc,d,f)(x)}function d(x){return i&&_(),y(r),h(x)}function f(x){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(x)}function h(x){return t.containerState={},e.attempt(jc,p,m)(x)}function p(x){return r++,n.push([t.currentConstruct,t.containerState]),h(x)}function m(x){if(x===null){i&&_(),y(0),e.consume(x);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:s}),v(x)}function v(x){if(x===null){k(e.exit("chunkFlow"),!0),y(0),e.consume(x);return}return be(x)?(e.consume(x),k(e.exit("chunkFlow")),r=0,t.interrupt=void 0,a):(e.consume(x),v)}function k(x,A){const E=t.sliceStream(x);if(A&&E.push(null),x.previous=s,s&&(s.next=x),s=x,i.defineSkip(x.start),i.write(E),t.parser.lazy[x.start.line]){let w=i.events.length;for(;w--;)if(i.events[w][1].start.offset<o&&(!i.events[w][1].end||i.events[w][1].end.offset>o))return;const S=t.events.length;let O=S,B,N;for(;O--;)if(t.events[O][0]==="exit"&&t.events[O][1].type==="chunkFlow"){if(B){N=t.events[O][1].end;break}B=!0}for(y(r),w=S;w<t.events.length;)t.events[w][1].end={...N},w++;At(t.events,O+1,0,t.events.slice(S)),t.events.length=w}}function y(x){let A=n.length;for(;A-- >x;){const E=n[A];t.containerState=E[1],E[0].exit.call(t,e)}n.length=x}function _(){i.write([null]),s=void 0,i=void 0,t.containerState._closeFlow=void 0}}function x0(e,t,n){return Pe(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function wr(e){if(e===null||Ze(e)||Bn(e))return 1;if(Ms(e))return 2}function Fs(e,t,n){const r=[];let i=-1;for(;++i<e.length;){const s=e[i].resolveAll;s&&!r.includes(s)&&(t=s(t,n),r.push(s))}return t}const Qo={name:"attention",resolveAll:y0,tokenize:b0};function y0(e,t){let n=-1,r,i,s,o,a,c,u,d;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const f={...e[r][1].end},h={...e[n][1].start};_c(f,-c),_c(h,c),o={type:c>1?"strongSequence":"emphasisSequence",start:f,end:{...e[r][1].end}},a={type:c>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:h},s={type:c>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:c>1?"strong":"emphasis",start:{...o.start},end:{...a.end}},e[r][1].end={...o.start},e[n][1].start={...a.end},u=[],e[r][1].end.offset-e[r][1].start.offset&&(u=Mt(u,[["enter",e[r][1],t],["exit",e[r][1],t]])),u=Mt(u,[["enter",i,t],["enter",o,t],["exit",o,t],["enter",s,t]]),u=Mt(u,Fs(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),u=Mt(u,[["exit",s,t],["enter",a,t],["exit",a,t],["exit",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(d=2,u=Mt(u,[["enter",e[n][1],t],["exit",e[n][1],t]])):d=0,At(e,r-1,n-r+3,u),n=r+u.length-d-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function b0(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=wr(r);let s;return o;function o(c){return s=c,e.enter("attentionSequence"),a(c)}function a(c){if(c===s)return e.consume(c),a;const u=e.exit("attentionSequence"),d=wr(c),f=!d||d===2&&i||n.includes(c),h=!i||i===2&&d||n.includes(r);return u._open=!!(s===42?f:f&&(i||!h)),u._close=!!(s===42?h:h&&(d||!f)),t(c)}}function _c(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const v0={name:"autolink",tokenize:w0};function w0(e,t,n){let r=0;return i;function i(p){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),s}function s(p){return xt(p)?(e.consume(p),o):p===64?n(p):u(p)}function o(p){return p===43||p===45||p===46||ut(p)?(r=1,a(p)):u(p)}function a(p){return p===58?(e.consume(p),r=0,c):(p===43||p===45||p===46||ut(p))&&r++<32?(e.consume(p),a):(r=0,u(p))}function c(p){return p===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):p===null||p===32||p===60||ds(p)?n(p):(e.consume(p),c)}function u(p){return p===64?(e.consume(p),d):u0(p)?(e.consume(p),u):n(p)}function d(p){return ut(p)?f(p):n(p)}function f(p){return p===46?(e.consume(p),r=0,d):p===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):h(p)}function h(p){if((p===45||ut(p))&&r++<63){const m=p===45?h:f;return e.consume(p),m}return n(p)}}const Ti={partial:!0,tokenize:k0};function k0(e,t,n){return r;function r(s){return Ie(s)?Pe(e,i,"linePrefix")(s):i(s)}function i(s){return s===null||be(s)?t(s):n(s)}}const Pp={continuation:{tokenize:j0},exit:_0,name:"blockQuote",tokenize:S0};function S0(e,t,n){const r=this;return i;function i(o){if(o===62){const a=r.containerState;return a.open||(e.enter("blockQuote",{_container:!0}),a.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(o),e.exit("blockQuoteMarker"),s}return n(o)}function s(o){return Ie(o)?(e.enter("blockQuotePrefixWhitespace"),e.consume(o),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(o))}}function j0(e,t,n){const r=this;return i;function i(o){return Ie(o)?Pe(e,s,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o):s(o)}function s(o){return e.attempt(Pp,t,n)(o)}}function _0(e){e.exit("blockQuote")}const Dp={name:"characterEscape",tokenize:N0};function N0(e,t,n){return r;function r(s){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(s),e.exit("escapeMarker"),i}function i(s){return f0(s)?(e.enter("characterEscapeValue"),e.consume(s),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(s)}}const Rp={name:"characterReference",tokenize:C0};function C0(e,t,n){const r=this;let i=0,s,o;return a;function a(f){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(f),e.exit("characterReferenceMarker"),c}function c(f){return f===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(f),e.exit("characterReferenceMarkerNumeric"),u):(e.enter("characterReferenceValue"),s=31,o=ut,d(f))}function u(f){return f===88||f===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(f),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),s=6,o=d0,d):(e.enter("characterReferenceValue"),s=7,o=Xo,d(f))}function d(f){if(f===59&&i){const h=e.exit("characterReferenceValue");return o===ut&&!qa(r.sliceSerialize(h))?n(f):(e.enter("characterReferenceMarker"),e.consume(f),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return o(f)&&i++<s?(e.consume(f),d):n(f)}}const Nc={partial:!0,tokenize:T0},Cc={concrete:!0,name:"codeFenced",tokenize:E0};function E0(e,t,n){const r=this,i={partial:!0,tokenize:E};let s=0,o=0,a;return c;function c(w){return u(w)}function u(w){const S=r.events[r.events.length-1];return s=S&&S[1].type==="linePrefix"?S[2].sliceSerialize(S[1],!0).length:0,a=w,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),d(w)}function d(w){return w===a?(o++,e.consume(w),d):o<3?n(w):(e.exit("codeFencedFenceSequence"),Ie(w)?Pe(e,f,"whitespace")(w):f(w))}function f(w){return w===null||be(w)?(e.exit("codeFencedFence"),r.interrupt?t(w):e.check(Nc,v,A)(w)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),h(w))}function h(w){return w===null||be(w)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),f(w)):Ie(w)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Pe(e,p,"whitespace")(w)):w===96&&w===a?n(w):(e.consume(w),h)}function p(w){return w===null||be(w)?f(w):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),m(w))}function m(w){return w===null||be(w)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),f(w)):w===96&&w===a?n(w):(e.consume(w),m)}function v(w){return e.attempt(i,A,k)(w)}function k(w){return e.enter("lineEnding"),e.consume(w),e.exit("lineEnding"),y}function y(w){return s>0&&Ie(w)?Pe(e,_,"linePrefix",s+1)(w):_(w)}function _(w){return w===null||be(w)?e.check(Nc,v,A)(w):(e.enter("codeFlowValue"),x(w))}function x(w){return w===null||be(w)?(e.exit("codeFlowValue"),_(w)):(e.consume(w),x)}function A(w){return e.exit("codeFenced"),t(w)}function E(w,S,O){let B=0;return N;function N(Z){return w.enter("lineEnding"),w.consume(Z),w.exit("lineEnding"),R}function R(Z){return w.enter("codeFencedFence"),Ie(Z)?Pe(w,T,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(Z):T(Z)}function T(Z){return Z===a?(w.enter("codeFencedFenceSequence"),F(Z)):O(Z)}function F(Z){return Z===a?(B++,w.consume(Z),F):B>=o?(w.exit("codeFencedFenceSequence"),Ie(Z)?Pe(w,$,"whitespace")(Z):$(Z)):O(Z)}function $(Z){return Z===null||be(Z)?(w.exit("codeFencedFence"),S(Z)):O(Z)}}}function T0(e,t,n){const r=this;return i;function i(o){return o===null?n(o):(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),s)}function s(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}const co={name:"codeIndented",tokenize:A0},I0={partial:!0,tokenize:z0};function A0(e,t,n){const r=this;return i;function i(u){return e.enter("codeIndented"),Pe(e,s,"linePrefix",5)(u)}function s(u){const d=r.events[r.events.length-1];return d&&d[1].type==="linePrefix"&&d[2].sliceSerialize(d[1],!0).length>=4?o(u):n(u)}function o(u){return u===null?c(u):be(u)?e.attempt(I0,o,c)(u):(e.enter("codeFlowValue"),a(u))}function a(u){return u===null||be(u)?(e.exit("codeFlowValue"),o(u)):(e.consume(u),a)}function c(u){return e.exit("codeIndented"),t(u)}}function z0(e,t,n){const r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):be(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),i):Pe(e,s,"linePrefix",5)(o)}function s(o){const a=r.events[r.events.length-1];return a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?t(o):be(o)?i(o):n(o)}}const O0={name:"codeText",previous:D0,resolve:P0,tokenize:R0};function P0(e){let t=e.length-4,n=3,r,i;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(i=r):(r===t||e[r][1].type==="lineEnding")&&(e[i][1].type="codeTextData",r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function D0(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function R0(e,t,n){let r=0,i,s;return o;function o(f){return e.enter("codeText"),e.enter("codeTextSequence"),a(f)}function a(f){return f===96?(e.consume(f),r++,a):(e.exit("codeTextSequence"),c(f))}function c(f){return f===null?n(f):f===32?(e.enter("space"),e.consume(f),e.exit("space"),c):f===96?(s=e.enter("codeTextSequence"),i=0,d(f)):be(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),c):(e.enter("codeTextData"),u(f))}function u(f){return f===null||f===32||f===96||be(f)?(e.exit("codeTextData"),c(f)):(e.consume(f),u)}function d(f){return f===96?(e.consume(f),i++,d):i===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(f)):(s.type="codeTextData",u(f))}}class $0{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const i=n||0;this.setCursor(Math.trunc(t));const s=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&Zr(this.left,r),s.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),Zr(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Zr(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);Zr(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Zr(this.left,n.reverse())}}}function Zr(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function $p(e){const t={};let n=-1,r,i,s,o,a,c,u;const d=new $0(e);for(;++n<d.length;){for(;n in t;)n=t[n];if(r=d.get(n),n&&r[1].type==="chunkFlow"&&d.get(n-1)[1].type==="listItemPrefix"&&(c=r[1]._tokenizer.events,s=0,s<c.length&&c[s][1].type==="lineEndingBlank"&&(s+=2),s<c.length&&c[s][1].type==="content"))for(;++s<c.length&&c[s][1].type!=="content";)c[s][1].type==="chunkText"&&(c[s][1]._isInFirstContentOfListItem=!0,s++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,M0(d,n)),n=t[n],u=!0);else if(r[1]._container){for(s=n,i=void 0;s--;)if(o=d.get(s),o[1].type==="lineEnding"||o[1].type==="lineEndingBlank")o[0]==="enter"&&(i&&(d.get(i)[1].type="lineEndingBlank"),o[1].type="lineEnding",i=s);else if(!(o[1].type==="linePrefix"||o[1].type==="listItemIndent"))break;i&&(r[1].end={...d.get(i)[1].start},a=d.slice(i,n),a.unshift(r),d.splice(i,n-i+1,a))}}return At(e,0,Number.POSITIVE_INFINITY,d.slice(0)),!u}function M0(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const s=[];let o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));const a=o.events,c=[],u={};let d,f,h=-1,p=n,m=0,v=0;const k=[v];for(;p;){for(;e.get(++i)[1]!==p;);s.push(i),p._tokenizer||(d=r.sliceStream(p),p.next||d.push(null),f&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(d),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),f=p,p=p.next}for(p=n;++h<a.length;)a[h][0]==="exit"&&a[h-1][0]==="enter"&&a[h][1].type===a[h-1][1].type&&a[h][1].start.line!==a[h][1].end.line&&(v=h+1,k.push(v),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):k.pop(),h=k.length;h--;){const y=a.slice(k[h],k[h+1]),_=s.pop();c.push([_,_+y.length-1]),e.splice(_,2,y)}for(c.reverse(),h=-1;++h<c.length;)u[m+c[h][0]]=m+c[h][1],m+=c[h][1]-c[h][0]-1;return u}const F0={resolve:B0,tokenize:Z0},L0={partial:!0,tokenize:V0};function B0(e){return $p(e),e}function Z0(e,t){let n;return r;function r(a){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),i(a)}function i(a){return a===null?s(a):be(a)?e.check(L0,o,s)(a):(e.consume(a),i)}function s(a){return e.exit("chunkContent"),e.exit("content"),t(a)}function o(a){return e.consume(a),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,i}}function V0(e,t,n){const r=this;return i;function i(o){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),Pe(e,s,"linePrefix")}function s(o){if(o===null||be(o))return n(o);const a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?t(o):e.interrupt(r.parser.constructs.flow,n,t)(o)}}function Mp(e,t,n,r,i,s,o,a,c){const u=c||Number.POSITIVE_INFINITY;let d=0;return f;function f(y){return y===60?(e.enter(r),e.enter(i),e.enter(s),e.consume(y),e.exit(s),h):y===null||y===32||y===41||ds(y)?n(y):(e.enter(r),e.enter(o),e.enter(a),e.enter("chunkString",{contentType:"string"}),v(y))}function h(y){return y===62?(e.enter(s),e.consume(y),e.exit(s),e.exit(i),e.exit(r),t):(e.enter(a),e.enter("chunkString",{contentType:"string"}),p(y))}function p(y){return y===62?(e.exit("chunkString"),e.exit(a),h(y)):y===null||y===60||be(y)?n(y):(e.consume(y),y===92?m:p)}function m(y){return y===60||y===62||y===92?(e.consume(y),p):p(y)}function v(y){return!d&&(y===null||y===41||Ze(y))?(e.exit("chunkString"),e.exit(a),e.exit(o),e.exit(r),t(y)):d<u&&y===40?(e.consume(y),d++,v):y===41?(e.consume(y),d--,v):y===null||y===32||y===40||ds(y)?n(y):(e.consume(y),y===92?k:v)}function k(y){return y===40||y===41||y===92?(e.consume(y),v):v(y)}}function Fp(e,t,n,r,i,s){const o=this;let a=0,c;return u;function u(p){return e.enter(r),e.enter(i),e.consume(p),e.exit(i),e.enter(s),d}function d(p){return a>999||p===null||p===91||p===93&&!c||p===94&&!a&&"_hiddenFootnoteSupport"in o.parser.constructs?n(p):p===93?(e.exit(s),e.enter(i),e.consume(p),e.exit(i),e.exit(r),t):be(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),d):(e.enter("chunkString",{contentType:"string"}),f(p))}function f(p){return p===null||p===91||p===93||be(p)||a++>999?(e.exit("chunkString"),d(p)):(e.consume(p),c||(c=!Ie(p)),p===92?h:f)}function h(p){return p===91||p===92||p===93?(e.consume(p),a++,f):f(p)}}function Lp(e,t,n,r,i,s){let o;return a;function a(h){return h===34||h===39||h===40?(e.enter(r),e.enter(i),e.consume(h),e.exit(i),o=h===40?41:h,c):n(h)}function c(h){return h===o?(e.enter(i),e.consume(h),e.exit(i),e.exit(r),t):(e.enter(s),u(h))}function u(h){return h===o?(e.exit(s),c(o)):h===null?n(h):be(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),Pe(e,u,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),d(h))}function d(h){return h===o||h===null||be(h)?(e.exit("chunkString"),u(h)):(e.consume(h),h===92?f:d)}function f(h){return h===o||h===92?(e.consume(h),d):d(h)}}function ii(e,t){let n;return r;function r(i){return be(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):Ie(i)?Pe(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const U0={name:"definition",tokenize:H0},J0={partial:!0,tokenize:W0};function H0(e,t,n){const r=this;let i;return s;function s(p){return e.enter("definition"),o(p)}function o(p){return Fp.call(r,e,a,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(p)}function a(p){return i=Wt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),p===58?(e.enter("definitionMarker"),e.consume(p),e.exit("definitionMarker"),c):n(p)}function c(p){return Ze(p)?ii(e,u)(p):u(p)}function u(p){return Mp(e,d,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(p)}function d(p){return e.attempt(J0,f,f)(p)}function f(p){return Ie(p)?Pe(e,h,"whitespace")(p):h(p)}function h(p){return p===null||be(p)?(e.exit("definition"),r.parser.defined.push(i),t(p)):n(p)}}function W0(e,t,n){return r;function r(a){return Ze(a)?ii(e,i)(a):n(a)}function i(a){return Lp(e,s,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(a)}function s(a){return Ie(a)?Pe(e,o,"whitespace")(a):o(a)}function o(a){return a===null||be(a)?t(a):n(a)}}const q0={name:"hardBreakEscape",tokenize:G0};function G0(e,t,n){return r;function r(s){return e.enter("hardBreakEscape"),e.consume(s),i}function i(s){return be(s)?(e.exit("hardBreakEscape"),t(s)):n(s)}}const K0={name:"headingAtx",resolve:Y0,tokenize:X0};function Y0(e,t){let n=e.length-2,r=3,i,s;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(i={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},s={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},At(e,r,n-r+1,[["enter",i,t],["enter",s,t],["exit",s,t],["exit",i,t]])),e}function X0(e,t,n){let r=0;return i;function i(d){return e.enter("atxHeading"),s(d)}function s(d){return e.enter("atxHeadingSequence"),o(d)}function o(d){return d===35&&r++<6?(e.consume(d),o):d===null||Ze(d)?(e.exit("atxHeadingSequence"),a(d)):n(d)}function a(d){return d===35?(e.enter("atxHeadingSequence"),c(d)):d===null||be(d)?(e.exit("atxHeading"),t(d)):Ie(d)?Pe(e,a,"whitespace")(d):(e.enter("atxHeadingText"),u(d))}function c(d){return d===35?(e.consume(d),c):(e.exit("atxHeadingSequence"),a(d))}function u(d){return d===null||d===35||Ze(d)?(e.exit("atxHeadingText"),a(d)):(e.consume(d),u)}}const Q0=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],Ec=["pre","script","style","textarea"],ek={concrete:!0,name:"htmlFlow",resolveTo:rk,tokenize:ik},tk={partial:!0,tokenize:ok},nk={partial:!0,tokenize:sk};function rk(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function ik(e,t,n){const r=this;let i,s,o,a,c;return u;function u(b){return d(b)}function d(b){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(b),f}function f(b){return b===33?(e.consume(b),h):b===47?(e.consume(b),s=!0,v):b===63?(e.consume(b),i=3,r.interrupt?t:j):xt(b)?(e.consume(b),o=String.fromCharCode(b),k):n(b)}function h(b){return b===45?(e.consume(b),i=2,p):b===91?(e.consume(b),i=5,a=0,m):xt(b)?(e.consume(b),i=4,r.interrupt?t:j):n(b)}function p(b){return b===45?(e.consume(b),r.interrupt?t:j):n(b)}function m(b){const G="CDATA[";return b===G.charCodeAt(a++)?(e.consume(b),a===G.length?r.interrupt?t:T:m):n(b)}function v(b){return xt(b)?(e.consume(b),o=String.fromCharCode(b),k):n(b)}function k(b){if(b===null||b===47||b===62||Ze(b)){const G=b===47,ne=o.toLowerCase();return!G&&!s&&Ec.includes(ne)?(i=1,r.interrupt?t(b):T(b)):Q0.includes(o.toLowerCase())?(i=6,G?(e.consume(b),y):r.interrupt?t(b):T(b)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(b):s?_(b):x(b))}return b===45||ut(b)?(e.consume(b),o+=String.fromCharCode(b),k):n(b)}function y(b){return b===62?(e.consume(b),r.interrupt?t:T):n(b)}function _(b){return Ie(b)?(e.consume(b),_):N(b)}function x(b){return b===47?(e.consume(b),N):b===58||b===95||xt(b)?(e.consume(b),A):Ie(b)?(e.consume(b),x):N(b)}function A(b){return b===45||b===46||b===58||b===95||ut(b)?(e.consume(b),A):E(b)}function E(b){return b===61?(e.consume(b),w):Ie(b)?(e.consume(b),E):x(b)}function w(b){return b===null||b===60||b===61||b===62||b===96?n(b):b===34||b===39?(e.consume(b),c=b,S):Ie(b)?(e.consume(b),w):O(b)}function S(b){return b===c?(e.consume(b),c=null,B):b===null||be(b)?n(b):(e.consume(b),S)}function O(b){return b===null||b===34||b===39||b===47||b===60||b===61||b===62||b===96||Ze(b)?E(b):(e.consume(b),O)}function B(b){return b===47||b===62||Ie(b)?x(b):n(b)}function N(b){return b===62?(e.consume(b),R):n(b)}function R(b){return b===null||be(b)?T(b):Ie(b)?(e.consume(b),R):n(b)}function T(b){return b===45&&i===2?(e.consume(b),P):b===60&&i===1?(e.consume(b),J):b===62&&i===4?(e.consume(b),ye):b===63&&i===3?(e.consume(b),j):b===93&&i===5?(e.consume(b),X):be(b)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(tk,ce,F)(b)):b===null||be(b)?(e.exit("htmlFlowData"),F(b)):(e.consume(b),T)}function F(b){return e.check(nk,$,ce)(b)}function $(b){return e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),Z}function Z(b){return b===null||be(b)?F(b):(e.enter("htmlFlowData"),T(b))}function P(b){return b===45?(e.consume(b),j):T(b)}function J(b){return b===47?(e.consume(b),o="",V):T(b)}function V(b){if(b===62){const G=o.toLowerCase();return Ec.includes(G)?(e.consume(b),ye):T(b)}return xt(b)&&o.length<8?(e.consume(b),o+=String.fromCharCode(b),V):T(b)}function X(b){return b===93?(e.consume(b),j):T(b)}function j(b){return b===62?(e.consume(b),ye):b===45&&i===2?(e.consume(b),j):T(b)}function ye(b){return b===null||be(b)?(e.exit("htmlFlowData"),ce(b)):(e.consume(b),ye)}function ce(b){return e.exit("htmlFlow"),t(b)}}function sk(e,t,n){const r=this;return i;function i(o){return be(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),s):n(o)}function s(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}function ok(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(Ti,t,n)}}const ak={name:"htmlText",tokenize:lk};function lk(e,t,n){const r=this;let i,s,o;return a;function a(j){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(j),c}function c(j){return j===33?(e.consume(j),u):j===47?(e.consume(j),E):j===63?(e.consume(j),x):xt(j)?(e.consume(j),O):n(j)}function u(j){return j===45?(e.consume(j),d):j===91?(e.consume(j),s=0,m):xt(j)?(e.consume(j),_):n(j)}function d(j){return j===45?(e.consume(j),p):n(j)}function f(j){return j===null?n(j):j===45?(e.consume(j),h):be(j)?(o=f,J(j)):(e.consume(j),f)}function h(j){return j===45?(e.consume(j),p):f(j)}function p(j){return j===62?P(j):j===45?h(j):f(j)}function m(j){const ye="CDATA[";return j===ye.charCodeAt(s++)?(e.consume(j),s===ye.length?v:m):n(j)}function v(j){return j===null?n(j):j===93?(e.consume(j),k):be(j)?(o=v,J(j)):(e.consume(j),v)}function k(j){return j===93?(e.consume(j),y):v(j)}function y(j){return j===62?P(j):j===93?(e.consume(j),y):v(j)}function _(j){return j===null||j===62?P(j):be(j)?(o=_,J(j)):(e.consume(j),_)}function x(j){return j===null?n(j):j===63?(e.consume(j),A):be(j)?(o=x,J(j)):(e.consume(j),x)}function A(j){return j===62?P(j):x(j)}function E(j){return xt(j)?(e.consume(j),w):n(j)}function w(j){return j===45||ut(j)?(e.consume(j),w):S(j)}function S(j){return be(j)?(o=S,J(j)):Ie(j)?(e.consume(j),S):P(j)}function O(j){return j===45||ut(j)?(e.consume(j),O):j===47||j===62||Ze(j)?B(j):n(j)}function B(j){return j===47?(e.consume(j),P):j===58||j===95||xt(j)?(e.consume(j),N):be(j)?(o=B,J(j)):Ie(j)?(e.consume(j),B):P(j)}function N(j){return j===45||j===46||j===58||j===95||ut(j)?(e.consume(j),N):R(j)}function R(j){return j===61?(e.consume(j),T):be(j)?(o=R,J(j)):Ie(j)?(e.consume(j),R):B(j)}function T(j){return j===null||j===60||j===61||j===62||j===96?n(j):j===34||j===39?(e.consume(j),i=j,F):be(j)?(o=T,J(j)):Ie(j)?(e.consume(j),T):(e.consume(j),$)}function F(j){return j===i?(e.consume(j),i=void 0,Z):j===null?n(j):be(j)?(o=F,J(j)):(e.consume(j),F)}function $(j){return j===null||j===34||j===39||j===60||j===61||j===96?n(j):j===47||j===62||Ze(j)?B(j):(e.consume(j),$)}function Z(j){return j===47||j===62||Ze(j)?B(j):n(j)}function P(j){return j===62?(e.consume(j),e.exit("htmlTextData"),e.exit("htmlText"),t):n(j)}function J(j){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(j),e.exit("lineEnding"),V}function V(j){return Ie(j)?Pe(e,X,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(j):X(j)}function X(j){return e.enter("htmlTextData"),o(j)}}const Ga={name:"labelEnd",resolveAll:fk,resolveTo:pk,tokenize:hk},ck={tokenize:mk},uk={tokenize:gk},dk={tokenize:xk};function fk(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const i=r.type==="labelImage"?4:2;r.type="data",t+=i}}return e.length!==n.length&&At(e,0,e.length,n),e}function pk(e,t){let n=e.length,r=0,i,s,o,a;for(;n--;)if(i=e[n][1],s){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;e[n][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(o){if(e[n][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(s=n,i.type!=="labelLink")){r=2;break}}else i.type==="labelEnd"&&(o=n);const c={type:e[s][1].type==="labelLink"?"link":"image",start:{...e[s][1].start},end:{...e[e.length-1][1].end}},u={type:"label",start:{...e[s][1].start},end:{...e[o][1].end}},d={type:"labelText",start:{...e[s+r+2][1].end},end:{...e[o-2][1].start}};return a=[["enter",c,t],["enter",u,t]],a=Mt(a,e.slice(s+1,s+r+3)),a=Mt(a,[["enter",d,t]]),a=Mt(a,Fs(t.parser.constructs.insideSpan.null,e.slice(s+r+4,o-3),t)),a=Mt(a,[["exit",d,t],e[o-2],e[o-1],["exit",u,t]]),a=Mt(a,e.slice(o+1)),a=Mt(a,[["exit",c,t]]),At(e,s,e.length,a),e}function hk(e,t,n){const r=this;let i=r.events.length,s,o;for(;i--;)if((r.events[i][1].type==="labelImage"||r.events[i][1].type==="labelLink")&&!r.events[i][1]._balanced){s=r.events[i][1];break}return a;function a(h){return s?s._inactive?f(h):(o=r.parser.defined.includes(Wt(r.sliceSerialize({start:s.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(h),e.exit("labelMarker"),e.exit("labelEnd"),c):n(h)}function c(h){return h===40?e.attempt(ck,d,o?d:f)(h):h===91?e.attempt(uk,d,o?u:f)(h):o?d(h):f(h)}function u(h){return e.attempt(dk,d,f)(h)}function d(h){return t(h)}function f(h){return s._balanced=!0,n(h)}}function mk(e,t,n){return r;function r(f){return e.enter("resource"),e.enter("resourceMarker"),e.consume(f),e.exit("resourceMarker"),i}function i(f){return Ze(f)?ii(e,s)(f):s(f)}function s(f){return f===41?d(f):Mp(e,o,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(f)}function o(f){return Ze(f)?ii(e,c)(f):d(f)}function a(f){return n(f)}function c(f){return f===34||f===39||f===40?Lp(e,u,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(f):d(f)}function u(f){return Ze(f)?ii(e,d)(f):d(f)}function d(f){return f===41?(e.enter("resourceMarker"),e.consume(f),e.exit("resourceMarker"),e.exit("resource"),t):n(f)}}function gk(e,t,n){const r=this;return i;function i(a){return Fp.call(r,e,s,o,"reference","referenceMarker","referenceString")(a)}function s(a){return r.parser.defined.includes(Wt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(a):n(a)}function o(a){return n(a)}}function xk(e,t,n){return r;function r(s){return e.enter("reference"),e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),i}function i(s){return s===93?(e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),e.exit("reference"),t):n(s)}}const yk={name:"labelStartImage",resolveAll:Ga.resolveAll,tokenize:bk};function bk(e,t,n){const r=this;return i;function i(a){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(a),e.exit("labelImageMarker"),s}function s(a){return a===91?(e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelImage"),o):n(a)}function o(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):t(a)}}const vk={name:"labelStartLink",resolveAll:Ga.resolveAll,tokenize:wk};function wk(e,t,n){const r=this;return i;function i(o){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(o),e.exit("labelMarker"),e.exit("labelLink"),s}function s(o){return o===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(o):t(o)}}const uo={name:"lineEnding",tokenize:kk};function kk(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),Pe(e,t,"linePrefix")}}const Gi={name:"thematicBreak",tokenize:Sk};function Sk(e,t,n){let r=0,i;return s;function s(u){return e.enter("thematicBreak"),o(u)}function o(u){return i=u,a(u)}function a(u){return u===i?(e.enter("thematicBreakSequence"),c(u)):r>=3&&(u===null||be(u))?(e.exit("thematicBreak"),t(u)):n(u)}function c(u){return u===i?(e.consume(u),r++,c):(e.exit("thematicBreakSequence"),Ie(u)?Pe(e,a,"whitespace")(u):a(u))}}const vt={continuation:{tokenize:Ck},exit:Tk,name:"list",tokenize:Nk},jk={partial:!0,tokenize:Ik},_k={partial:!0,tokenize:Ek};function Nk(e,t,n){const r=this,i=r.events[r.events.length-1];let s=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,o=0;return a;function a(p){const m=r.containerState.type||(p===42||p===43||p===45?"listUnordered":"listOrdered");if(m==="listUnordered"?!r.containerState.marker||p===r.containerState.marker:Xo(p)){if(r.containerState.type||(r.containerState.type=m,e.enter(m,{_container:!0})),m==="listUnordered")return e.enter("listItemPrefix"),p===42||p===45?e.check(Gi,n,u)(p):u(p);if(!r.interrupt||p===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),c(p)}return n(p)}function c(p){return Xo(p)&&++o<10?(e.consume(p),c):(!r.interrupt||o<2)&&(r.containerState.marker?p===r.containerState.marker:p===41||p===46)?(e.exit("listItemValue"),u(p)):n(p)}function u(p){return e.enter("listItemMarker"),e.consume(p),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||p,e.check(Ti,r.interrupt?n:d,e.attempt(jk,h,f))}function d(p){return r.containerState.initialBlankLine=!0,s++,h(p)}function f(p){return Ie(p)?(e.enter("listItemPrefixWhitespace"),e.consume(p),e.exit("listItemPrefixWhitespace"),h):n(p)}function h(p){return r.containerState.size=s+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(p)}}function Ck(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Ti,i,s);function i(a){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Pe(e,t,"listItemIndent",r.containerState.size+1)(a)}function s(a){return r.containerState.furtherBlankLines||!Ie(a)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(a)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(_k,t,o)(a))}function o(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,Pe(e,e.attempt(vt,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}function Ek(e,t,n){const r=this;return Pe(e,i,"listItemIndent",r.containerState.size+1);function i(s){const o=r.events[r.events.length-1];return o&&o[1].type==="listItemIndent"&&o[2].sliceSerialize(o[1],!0).length===r.containerState.size?t(s):n(s)}}function Tk(e){e.exit(this.containerState.type)}function Ik(e,t,n){const r=this;return Pe(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(s){const o=r.events[r.events.length-1];return!Ie(s)&&o&&o[1].type==="listItemPrefixWhitespace"?t(s):n(s)}}const Tc={name:"setextUnderline",resolveTo:Ak,tokenize:zk};function Ak(e,t){let n=e.length,r,i,s;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(i=n)}else e[n][1].type==="content"&&e.splice(n,1),!s&&e[n][1].type==="definition"&&(s=n);const o={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type="setextHeadingText",s?(e.splice(i,0,["enter",o,t]),e.splice(s+1,0,["exit",e[r][1],t]),e[r][1].end={...e[s][1].end}):e[r][1]=o,e.push(["exit",o,t]),e}function zk(e,t,n){const r=this;let i;return s;function s(u){let d=r.events.length,f;for(;d--;)if(r.events[d][1].type!=="lineEnding"&&r.events[d][1].type!=="linePrefix"&&r.events[d][1].type!=="content"){f=r.events[d][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||f)?(e.enter("setextHeadingLine"),i=u,o(u)):n(u)}function o(u){return e.enter("setextHeadingLineSequence"),a(u)}function a(u){return u===i?(e.consume(u),a):(e.exit("setextHeadingLineSequence"),Ie(u)?Pe(e,c,"lineSuffix")(u):c(u))}function c(u){return u===null||be(u)?(e.exit("setextHeadingLine"),t(u)):n(u)}}const Ok={tokenize:Pk};function Pk(e){const t=this,n=e.attempt(Ti,r,e.attempt(this.parser.constructs.flowInitial,i,Pe(e,e.attempt(this.parser.constructs.flow,i,e.attempt(F0,i)),"linePrefix")));return n;function r(s){if(s===null){e.consume(s);return}return e.enter("lineEndingBlank"),e.consume(s),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function i(s){if(s===null){e.consume(s);return}return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const Dk={resolveAll:Zp()},Rk=Bp("string"),$k=Bp("text");function Bp(e){return{resolveAll:Zp(e==="text"?Mk:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],s=n.attempt(i,o,a);return o;function o(d){return u(d)?s(d):a(d)}function a(d){if(d===null){n.consume(d);return}return n.enter("data"),n.consume(d),c}function c(d){return u(d)?(n.exit("data"),s(d)):(n.consume(d),c)}function u(d){if(d===null)return!0;const f=i[d];let h=-1;if(f)for(;++h<f.length;){const p=f[h];if(!p.previous||p.previous.call(r,r.previous))return!0}return!1}}}function Zp(e){return t;function t(n,r){let i=-1,s;for(;++i<=n.length;)s===void 0?n[i]&&n[i][1].type==="data"&&(s=i,i++):(!n[i]||n[i][1].type!=="data")&&(i!==s+2&&(n[s][1].end=n[i-1][1].end,n.splice(s+2,i-s-2),i=s+2),s=void 0);return e?e(n,r):n}}function Mk(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],i=t.sliceStream(r);let s=i.length,o=-1,a=0,c;for(;s--;){const u=i[s];if(typeof u=="string"){for(o=u.length;u.charCodeAt(o-1)===32;)a++,o--;if(o)break;o=-1}else if(u===-2)c=!0,a++;else if(u!==-1){s++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(a=0),a){const u={type:n===e.length||c||a<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:s?o:r.start._bufferIndex+o,_index:r.start._index+s,line:r.end.line,column:r.end.column-a,offset:r.end.offset-a},end:{...r.end}};r.end={...u.start},r.start.offset===r.end.offset?Object.assign(r,u):(e.splice(n,0,["enter",u,t],["exit",u,t]),n+=2)}n++}return e}const Fk={42:vt,43:vt,45:vt,48:vt,49:vt,50:vt,51:vt,52:vt,53:vt,54:vt,55:vt,56:vt,57:vt,62:Pp},Lk={91:U0},Bk={[-2]:co,[-1]:co,32:co},Zk={35:K0,42:Gi,45:[Tc,Gi],60:ek,61:Tc,95:Gi,96:Cc,126:Cc},Vk={38:Rp,92:Dp},Uk={[-5]:uo,[-4]:uo,[-3]:uo,33:yk,38:Rp,42:Qo,60:[v0,ak],91:vk,92:[q0,Dp],93:Ga,95:Qo,96:O0},Jk={null:[Qo,Dk]},Hk={null:[42,95]},Wk={null:[]},qk=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:Hk,contentInitial:Lk,disable:Wk,document:Fk,flow:Zk,flowInitial:Bk,insideSpan:Jk,string:Vk,text:Uk},Symbol.toStringTag,{value:"Module"}));function Gk(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const i={},s=[];let o=[],a=[];const c={attempt:S(E),check:S(w),consume:_,enter:x,exit:A,interrupt:S(w,{interrupt:!0})},u={code:null,containerState:{},defineSkip:v,events:[],now:m,parser:e,previous:null,sliceSerialize:h,sliceStream:p,write:f};let d=t.tokenize.call(u,c);return t.resolveAll&&s.push(t),u;function f(R){return o=Mt(o,R),k(),o[o.length-1]!==null?[]:(O(t,0),u.events=Fs(s,u.events,u),u.events)}function h(R,T){return Yk(p(R),T)}function p(R){return Kk(o,R)}function m(){const{_bufferIndex:R,_index:T,line:F,column:$,offset:Z}=r;return{_bufferIndex:R,_index:T,line:F,column:$,offset:Z}}function v(R){i[R.line]=R.column,N()}function k(){let R;for(;r._index<o.length;){const T=o[r._index];if(typeof T=="string")for(R=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===R&&r._bufferIndex<T.length;)y(T.charCodeAt(r._bufferIndex));else y(T)}}function y(R){d=d(R)}function _(R){be(R)?(r.line++,r.column=1,r.offset+=R===-3?2:1,N()):R!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),u.previous=R}function x(R,T){const F=T||{};return F.type=R,F.start=m(),u.events.push(["enter",F,u]),a.push(F),F}function A(R){const T=a.pop();return T.end=m(),u.events.push(["exit",T,u]),T}function E(R,T){O(R,T.from)}function w(R,T){T.restore()}function S(R,T){return F;function F($,Z,P){let J,V,X,j;return Array.isArray($)?ce($):"tokenize"in $?ce([$]):ye($);function ye(Q){return oe;function oe(I){const re=I!==null&&Q[I],ae=I!==null&&Q.null,H=[...Array.isArray(re)?re:re?[re]:[],...Array.isArray(ae)?ae:ae?[ae]:[]];return ce(H)(I)}}function ce(Q){return J=Q,V=0,Q.length===0?P:b(Q[V])}function b(Q){return oe;function oe(I){return j=B(),X=Q,Q.partial||(u.currentConstruct=Q),Q.name&&u.parser.constructs.disable.null.includes(Q.name)?ne():Q.tokenize.call(T?Object.assign(Object.create(u),T):u,c,G,ne)(I)}}function G(Q){return R(X,j),Z}function ne(Q){return j.restore(),++V<J.length?b(J[V]):P}}}function O(R,T){R.resolveAll&&!s.includes(R)&&s.push(R),R.resolve&&At(u.events,T,u.events.length-T,R.resolve(u.events.slice(T),u)),R.resolveTo&&(u.events=R.resolveTo(u.events,u))}function B(){const R=m(),T=u.previous,F=u.currentConstruct,$=u.events.length,Z=Array.from(a);return{from:$,restore:P};function P(){r=R,u.previous=T,u.currentConstruct=F,u.events.length=$,a=Z,N()}}function N(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function Kk(e,t){const n=t.start._index,r=t.start._bufferIndex,i=t.end._index,s=t.end._bufferIndex;let o;if(n===i)o=[e[n].slice(r,s)];else{if(o=e.slice(n,i),r>-1){const a=o[0];typeof a=="string"?o[0]=a.slice(r):o.shift()}s>0&&o.push(e[i].slice(0,s))}return o}function Yk(e,t){let n=-1;const r=[];let i;for(;++n<e.length;){const s=e[n];let o;if(typeof s=="string")o=s;else switch(s){case-5:{o="\r";break}case-4:{o=`
|
|
150
|
+
`;break}case-3:{o=`\r
|
|
151
|
+
`;break}case-2:{o=t?" ":" ";break}case-1:{if(!t&&i)continue;o=" ";break}default:o=String.fromCharCode(s)}i=s===-2,r.push(o)}return r.join("")}function Xk(e){const r={constructs:zp([qk,...(e||{}).extensions||[]]),content:i(p0),defined:[],document:i(m0),flow:i(Ok),lazy:{},string:i(Rk),text:i($k)};return r;function i(s){return o;function o(a){return Gk(r,s,a)}}}function Qk(e){for(;!$p(e););return e}const Ic=/[\0\t\n\r]/g;function eS(){let e=1,t="",n=!0,r;return i;function i(s,o,a){const c=[];let u,d,f,h,p;for(s=t+(typeof s=="string"?s.toString():new TextDecoder(o||void 0).decode(s)),f=0,t="",n&&(s.charCodeAt(0)===65279&&f++,n=void 0);f<s.length;){if(Ic.lastIndex=f,u=Ic.exec(s),h=u&&u.index!==void 0?u.index:s.length,p=s.charCodeAt(h),!u){t=s.slice(f);break}if(p===10&&f===h&&r)c.push(-3),r=void 0;else switch(r&&(c.push(-5),r=void 0),f<h&&(c.push(s.slice(f,h)),e+=h-f),p){case 0:{c.push(65533),e++;break}case 9:{for(d=Math.ceil(e/4)*4,c.push(-2);e++<d;)c.push(-1);break}case 10:{c.push(-4),e=1;break}default:r=!0,e=1}f=h+1}return a&&(r&&c.push(-5),t&&c.push(t),c.push(null)),c}}const tS=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function nS(e){return e.replace(tS,rS)}function rS(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),s=i===120||i===88;return Op(n.slice(s?2:1),s?16:10)}return qa(n)||e}const Vp={}.hasOwnProperty;function iS(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),sS(n)(Qk(Xk(n).document().write(eS()(e,t,!0))))}function sS(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(z),autolinkProtocol:B,autolinkEmail:B,atxHeading:s(Re),blockQuote:s(ae),characterEscape:B,characterReference:B,codeFenced:s(H),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:s(H,o),codeText:s(K,o),codeTextData:B,data:B,codeFlowValue:B,definition:s(pe),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:s(fe),hardBreakEscape:s(Oe),hardBreakTrailing:s(Oe),htmlFlow:s($e,o),htmlFlowData:B,htmlText:s($e,o),htmlTextData:B,image:s(C),label:o,link:s(z),listItem:s(se),listItemValue:h,listOrdered:s(L,f),listUnordered:s(L),paragraph:s(ie),reference:b,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:s(Re),strong:s(ee),thematicBreak:s(we)},exit:{atxHeading:c(),atxHeadingSequence:E,autolink:c(),autolinkEmail:re,autolinkProtocol:I,blockQuote:c(),characterEscapeValue:N,characterReferenceMarkerHexadecimal:ne,characterReferenceMarkerNumeric:ne,characterReferenceValue:Q,characterReference:oe,codeFenced:c(k),codeFencedFence:v,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:N,codeIndented:c(y),codeText:c(Z),codeTextData:N,data:N,definition:c(),definitionDestinationString:A,definitionLabelString:_,definitionTitleString:x,emphasis:c(),hardBreakEscape:c(T),hardBreakTrailing:c(T),htmlFlow:c(F),htmlFlowData:N,htmlText:c($),htmlTextData:N,image:c(J),label:X,labelText:V,lineEnding:R,link:c(P),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:G,resourceDestinationString:j,resourceTitleString:ye,resource:ce,setextHeading:c(O),setextHeadingLineSequence:S,setextHeadingText:w,strong:c(),thematicBreak:c()}};Up(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(U){let Y={type:"root",children:[]};const ge={stack:[Y],tokenStack:[],config:t,enter:a,exit:u,buffer:o,resume:d,data:n},_e=[];let M=-1;for(;++M<U.length;)if(U[M][1].type==="listOrdered"||U[M][1].type==="listUnordered")if(U[M][0]==="enter")_e.push(M);else{const D=_e.pop();M=i(U,D,M)}for(M=-1;++M<U.length;){const D=t[U[M][0]];Vp.call(D,U[M][1].type)&&D[U[M][1].type].call(Object.assign({sliceSerialize:U[M][2].sliceSerialize},ge),U[M][1])}if(ge.tokenStack.length>0){const D=ge.tokenStack[ge.tokenStack.length-1];(D[1]||Ac).call(ge,void 0,D[0])}for(Y.position={start:pn(U.length>0?U[0][1].start:{line:1,column:1,offset:0}),end:pn(U.length>0?U[U.length-2][1].end:{line:1,column:1,offset:0})},M=-1;++M<t.transforms.length;)Y=t.transforms[M](Y)||Y;return Y}function i(U,Y,ge){let _e=Y-1,M=-1,D=!1,xe,de,Me,Je;for(;++_e<=ge;){const it=U[_e];switch(it[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{it[0]==="enter"?M++:M--,Je=void 0;break}case"lineEndingBlank":{it[0]==="enter"&&(xe&&!Je&&!M&&!Me&&(Me=_e),Je=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Je=void 0}if(!M&&it[0]==="enter"&&it[1].type==="listItemPrefix"||M===-1&&it[0]==="exit"&&(it[1].type==="listUnordered"||it[1].type==="listOrdered")){if(xe){let Lt=_e;for(de=void 0;Lt--;){const Ot=U[Lt];if(Ot[1].type==="lineEnding"||Ot[1].type==="lineEndingBlank"){if(Ot[0]==="exit")continue;de&&(U[de][1].type="lineEndingBlank",D=!0),Ot[1].type="lineEnding",de=Lt}else if(!(Ot[1].type==="linePrefix"||Ot[1].type==="blockQuotePrefix"||Ot[1].type==="blockQuotePrefixWhitespace"||Ot[1].type==="blockQuoteMarker"||Ot[1].type==="listItemIndent"))break}Me&&(!de||Me<de)&&(xe._spread=!0),xe.end=Object.assign({},de?U[de][1].start:it[1].end),U.splice(de||_e,0,["exit",xe,it[2]]),_e++,ge++}if(it[1].type==="listItemPrefix"){const Lt={type:"listItem",_spread:!1,start:Object.assign({},it[1].start),end:void 0};xe=Lt,U.splice(_e,0,["enter",Lt,it[2]]),_e++,ge++,Me=void 0,Je=!0}}}return U[Y][1]._spread=D,ge}function s(U,Y){return ge;function ge(_e){a.call(this,U(_e),_e),Y&&Y.call(this,_e)}}function o(){this.stack.push({type:"fragment",children:[]})}function a(U,Y,ge){this.stack[this.stack.length-1].children.push(U),this.stack.push(U),this.tokenStack.push([Y,ge||void 0]),U.position={start:pn(Y.start),end:void 0}}function c(U){return Y;function Y(ge){U&&U.call(this,ge),u.call(this,ge)}}function u(U,Y){const ge=this.stack.pop(),_e=this.tokenStack.pop();if(_e)_e[0].type!==U.type&&(Y?Y.call(this,U,_e[0]):(_e[1]||Ac).call(this,U,_e[0]));else throw new Error("Cannot close `"+U.type+"` ("+ri({start:U.start,end:U.end})+"): it’s not open");ge.position.end=pn(U.end)}function d(){return Wa(this.stack.pop())}function f(){this.data.expectingFirstListItemValue=!0}function h(U){if(this.data.expectingFirstListItemValue){const Y=this.stack[this.stack.length-2];Y.start=Number.parseInt(this.sliceSerialize(U),10),this.data.expectingFirstListItemValue=void 0}}function p(){const U=this.resume(),Y=this.stack[this.stack.length-1];Y.lang=U}function m(){const U=this.resume(),Y=this.stack[this.stack.length-1];Y.meta=U}function v(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function k(){const U=this.resume(),Y=this.stack[this.stack.length-1];Y.value=U.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function y(){const U=this.resume(),Y=this.stack[this.stack.length-1];Y.value=U.replace(/(\r?\n|\r)$/g,"")}function _(U){const Y=this.resume(),ge=this.stack[this.stack.length-1];ge.label=Y,ge.identifier=Wt(this.sliceSerialize(U)).toLowerCase()}function x(){const U=this.resume(),Y=this.stack[this.stack.length-1];Y.title=U}function A(){const U=this.resume(),Y=this.stack[this.stack.length-1];Y.url=U}function E(U){const Y=this.stack[this.stack.length-1];if(!Y.depth){const ge=this.sliceSerialize(U).length;Y.depth=ge}}function w(){this.data.setextHeadingSlurpLineEnding=!0}function S(U){const Y=this.stack[this.stack.length-1];Y.depth=this.sliceSerialize(U).codePointAt(0)===61?1:2}function O(){this.data.setextHeadingSlurpLineEnding=void 0}function B(U){const ge=this.stack[this.stack.length-1].children;let _e=ge[ge.length-1];(!_e||_e.type!=="text")&&(_e=me(),_e.position={start:pn(U.start),end:void 0},ge.push(_e)),this.stack.push(_e)}function N(U){const Y=this.stack.pop();Y.value+=this.sliceSerialize(U),Y.position.end=pn(U.end)}function R(U){const Y=this.stack[this.stack.length-1];if(this.data.atHardBreak){const ge=Y.children[Y.children.length-1];ge.position.end=pn(U.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(Y.type)&&(B.call(this,U),N.call(this,U))}function T(){this.data.atHardBreak=!0}function F(){const U=this.resume(),Y=this.stack[this.stack.length-1];Y.value=U}function $(){const U=this.resume(),Y=this.stack[this.stack.length-1];Y.value=U}function Z(){const U=this.resume(),Y=this.stack[this.stack.length-1];Y.value=U}function P(){const U=this.stack[this.stack.length-1];if(this.data.inReference){const Y=this.data.referenceType||"shortcut";U.type+="Reference",U.referenceType=Y,delete U.url,delete U.title}else delete U.identifier,delete U.label;this.data.referenceType=void 0}function J(){const U=this.stack[this.stack.length-1];if(this.data.inReference){const Y=this.data.referenceType||"shortcut";U.type+="Reference",U.referenceType=Y,delete U.url,delete U.title}else delete U.identifier,delete U.label;this.data.referenceType=void 0}function V(U){const Y=this.sliceSerialize(U),ge=this.stack[this.stack.length-2];ge.label=nS(Y),ge.identifier=Wt(Y).toLowerCase()}function X(){const U=this.stack[this.stack.length-1],Y=this.resume(),ge=this.stack[this.stack.length-1];if(this.data.inReference=!0,ge.type==="link"){const _e=U.children;ge.children=_e}else ge.alt=Y}function j(){const U=this.resume(),Y=this.stack[this.stack.length-1];Y.url=U}function ye(){const U=this.resume(),Y=this.stack[this.stack.length-1];Y.title=U}function ce(){this.data.inReference=void 0}function b(){this.data.referenceType="collapsed"}function G(U){const Y=this.resume(),ge=this.stack[this.stack.length-1];ge.label=Y,ge.identifier=Wt(this.sliceSerialize(U)).toLowerCase(),this.data.referenceType="full"}function ne(U){this.data.characterReferenceType=U.type}function Q(U){const Y=this.sliceSerialize(U),ge=this.data.characterReferenceType;let _e;ge?(_e=Op(Y,ge==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):_e=qa(Y);const M=this.stack[this.stack.length-1];M.value+=_e}function oe(U){const Y=this.stack.pop();Y.position.end=pn(U.end)}function I(U){N.call(this,U);const Y=this.stack[this.stack.length-1];Y.url=this.sliceSerialize(U)}function re(U){N.call(this,U);const Y=this.stack[this.stack.length-1];Y.url="mailto:"+this.sliceSerialize(U)}function ae(){return{type:"blockquote",children:[]}}function H(){return{type:"code",lang:null,meta:null,value:""}}function K(){return{type:"inlineCode",value:""}}function pe(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function fe(){return{type:"emphasis",children:[]}}function Re(){return{type:"heading",depth:0,children:[]}}function Oe(){return{type:"break"}}function $e(){return{type:"html",value:""}}function C(){return{type:"image",title:null,url:"",alt:null}}function z(){return{type:"link",title:null,url:"",children:[]}}function L(U){return{type:"list",ordered:U.type==="listOrdered",start:null,spread:U._spread,children:[]}}function se(U){return{type:"listItem",spread:U._spread,checked:null,children:[]}}function ie(){return{type:"paragraph",children:[]}}function ee(){return{type:"strong",children:[]}}function me(){return{type:"text",value:""}}function we(){return{type:"thematicBreak"}}}function pn(e){return{line:e.line,column:e.column,offset:e.offset}}function Up(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?Up(e,r):oS(e,r)}}function oS(e,t){let n;for(n in t)if(Vp.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function Ac(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+ri({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+ri({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+ri({start:t.start,end:t.end})+") is still open")}function aS(e){const t=this;t.parser=n;function n(r){return iS(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function lS(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function cS(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
|
|
152
|
+
`}]}function uS(e,t){const n=t.value?t.value+`
|
|
153
|
+
`:"",r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=["language-"+i[0]]);let s={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(s.data={meta:t.meta}),e.patch(t,s),s=e.applyData(t,s),s={type:"element",tagName:"pre",properties:{},children:[s]},e.patch(t,s),s}function dS(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function fS(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function pS(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),i=Ir(r.toLowerCase()),s=e.footnoteOrder.indexOf(r);let o,a=e.footnoteCounts.get(r);a===void 0?(a=0,e.footnoteOrder.push(r),o=e.footnoteOrder.length):o=s+1,a+=1,e.footnoteCounts.set(r,a);const c={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+i,id:n+"fnref-"+i+(a>1?"-"+a:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(o)}]};e.patch(t,c);const u={type:"element",tagName:"sup",properties:{},children:[c]};return e.patch(t,u),e.applyData(t,u)}function hS(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function mS(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function Jp(e,t){const n=t.referenceType;let r="]";if(n==="collapsed"?r+="[]":n==="full"&&(r+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+r}];const i=e.all(t),s=i[0];s&&s.type==="text"?s.value="["+s.value:i.unshift({type:"text",value:"["});const o=i[i.length-1];return o&&o.type==="text"?o.value+=r:i.push({type:"text",value:r}),i}function gS(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Jp(e,t);const i={src:Ir(r.url||""),alt:t.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);const s={type:"element",tagName:"img",properties:i,children:[]};return e.patch(t,s),e.applyData(t,s)}function xS(e,t){const n={src:Ir(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function yS(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const r={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function bS(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Jp(e,t);const i={href:Ir(r.url||"")};r.title!==null&&r.title!==void 0&&(i.title=r.title);const s={type:"element",tagName:"a",properties:i,children:e.all(t)};return e.patch(t,s),e.applyData(t,s)}function vS(e,t){const n={href:Ir(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function wS(e,t,n){const r=e.all(t),i=n?kS(n):Hp(t),s={},o=[];if(typeof t.checked=="boolean"){const d=r[0];let f;d&&d.type==="element"&&d.tagName==="p"?f=d:(f={type:"element",tagName:"p",properties:{},children:[]},r.unshift(f)),f.children.length>0&&f.children.unshift({type:"text",value:" "}),f.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),s.className=["task-list-item"]}let a=-1;for(;++a<r.length;){const d=r[a];(i||a!==0||d.type!=="element"||d.tagName!=="p")&&o.push({type:"text",value:`
|
|
154
|
+
`}),d.type==="element"&&d.tagName==="p"&&!i?o.push(...d.children):o.push(d)}const c=r[r.length-1];c&&(i||c.type!=="element"||c.tagName!=="p")&&o.push({type:"text",value:`
|
|
155
|
+
`});const u={type:"element",tagName:"li",properties:s,children:o};return e.patch(t,u),e.applyData(t,u)}function kS(e){let t=!1;if(e.type==="list"){t=e.spread||!1;const n=e.children;let r=-1;for(;!t&&++r<n.length;)t=Hp(n[r])}return t}function Hp(e){const t=e.spread;return t??e.children.length>1}function SS(e,t){const n={},r=e.all(t);let i=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++i<r.length;){const o=r[i];if(o.type==="element"&&o.tagName==="li"&&o.properties&&Array.isArray(o.properties.className)&&o.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const s={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,s),e.applyData(t,s)}function jS(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function _S(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function NS(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function CS(e,t){const n=e.all(t),r=n.shift(),i=[];if(r){const o={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],o),i.push(o)}if(n.length>0){const o={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},a=Va(t.children[1]),c=_p(t.children[t.children.length-1]);a&&c&&(o.position={start:a,end:c}),i.push(o)}const s={type:"element",tagName:"table",properties:{},children:e.wrap(i,!0)};return e.patch(t,s),e.applyData(t,s)}function ES(e,t,n){const r=n?n.children:void 0,s=(r?r.indexOf(t):1)===0?"th":"td",o=n&&n.type==="table"?n.align:void 0,a=o?o.length:t.children.length;let c=-1;const u=[];for(;++c<a;){const f=t.children[c],h={},p=o?o[c]:void 0;p&&(h.align=p);let m={type:"element",tagName:s,properties:h,children:[]};f&&(m.children=e.all(f),e.patch(f,m),m=e.applyData(f,m)),u.push(m)}const d={type:"element",tagName:"tr",properties:{},children:e.wrap(u,!0)};return e.patch(t,d),e.applyData(t,d)}function TS(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const zc=9,Oc=32;function IS(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),i=0;const s=[];for(;r;)s.push(Pc(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return s.push(Pc(t.slice(i),i>0,!1)),s.join("")}function Pc(e,t,n){let r=0,i=e.length;if(t){let s=e.codePointAt(r);for(;s===zc||s===Oc;)r++,s=e.codePointAt(r)}if(n){let s=e.codePointAt(i-1);for(;s===zc||s===Oc;)i--,s=e.codePointAt(i-1)}return i>r?e.slice(r,i):""}function AS(e,t){const n={type:"text",value:IS(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function zS(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const OS={blockquote:lS,break:cS,code:uS,delete:dS,emphasis:fS,footnoteReference:pS,heading:hS,html:mS,imageReference:gS,image:xS,inlineCode:yS,linkReference:bS,link:vS,listItem:wS,list:SS,paragraph:jS,root:_S,strong:NS,table:CS,tableCell:TS,tableRow:ES,text:AS,thematicBreak:zS,toml:Mi,yaml:Mi,definition:Mi,footnoteDefinition:Mi};function Mi(){}const Wp=-1,Ls=0,si=1,fs=2,Ka=3,Ya=4,Xa=5,Qa=6,qp=7,Gp=8,Dc=typeof self=="object"?self:globalThis,PS=(e,t)=>{const n=(i,s)=>(e.set(s,i),i),r=i=>{if(e.has(i))return e.get(i);const[s,o]=t[i];switch(s){case Ls:case Wp:return n(o,i);case si:{const a=n([],i);for(const c of o)a.push(r(c));return a}case fs:{const a=n({},i);for(const[c,u]of o)a[r(c)]=r(u);return a}case Ka:return n(new Date(o),i);case Ya:{const{source:a,flags:c}=o;return n(new RegExp(a,c),i)}case Xa:{const a=n(new Map,i);for(const[c,u]of o)a.set(r(c),r(u));return a}case Qa:{const a=n(new Set,i);for(const c of o)a.add(r(c));return a}case qp:{const{name:a,message:c}=o;return n(new Dc[a](c),i)}case Gp:return n(BigInt(o),i);case"BigInt":return n(Object(BigInt(o)),i);case"ArrayBuffer":return n(new Uint8Array(o).buffer,o);case"DataView":{const{buffer:a}=new Uint8Array(o);return n(new DataView(a),o)}}return n(new Dc[s](o),i)};return r},Rc=e=>PS(new Map,e)(0),Kn="",{toString:DS}={},{keys:RS}=Object,Vr=e=>{const t=typeof e;if(t!=="object"||!e)return[Ls,t];const n=DS.call(e).slice(8,-1);switch(n){case"Array":return[si,Kn];case"Object":return[fs,Kn];case"Date":return[Ka,Kn];case"RegExp":return[Ya,Kn];case"Map":return[Xa,Kn];case"Set":return[Qa,Kn];case"DataView":return[si,n]}return n.includes("Array")?[si,n]:n.includes("Error")?[qp,n]:[fs,n]},Fi=([e,t])=>e===Ls&&(t==="function"||t==="symbol"),$S=(e,t,n,r)=>{const i=(o,a)=>{const c=r.push(o)-1;return n.set(a,c),c},s=o=>{if(n.has(o))return n.get(o);let[a,c]=Vr(o);switch(a){case Ls:{let d=o;switch(c){case"bigint":a=Gp,d=o.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+c);d=null;break;case"undefined":return i([Wp],o)}return i([a,d],o)}case si:{if(c){let h=o;return c==="DataView"?h=new Uint8Array(o.buffer):c==="ArrayBuffer"&&(h=new Uint8Array(o)),i([c,[...h]],o)}const d=[],f=i([a,d],o);for(const h of o)d.push(s(h));return f}case fs:{if(c)switch(c){case"BigInt":return i([c,o.toString()],o);case"Boolean":case"Number":case"String":return i([c,o.valueOf()],o)}if(t&&"toJSON"in o)return s(o.toJSON());const d=[],f=i([a,d],o);for(const h of RS(o))(e||!Fi(Vr(o[h])))&&d.push([s(h),s(o[h])]);return f}case Ka:return i([a,o.toISOString()],o);case Ya:{const{source:d,flags:f}=o;return i([a,{source:d,flags:f}],o)}case Xa:{const d=[],f=i([a,d],o);for(const[h,p]of o)(e||!(Fi(Vr(h))||Fi(Vr(p))))&&d.push([s(h),s(p)]);return f}case Qa:{const d=[],f=i([a,d],o);for(const h of o)(e||!Fi(Vr(h)))&&d.push(s(h));return f}}const{message:u}=o;return i([a,{name:c,message:u}],o)};return s},$c=(e,{json:t,lossy:n}={})=>{const r=[];return $S(!(t||n),!!t,new Map,r)(e),r},ps=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?Rc($c(e,t)):structuredClone(e):(e,t)=>Rc($c(e,t));function MS(e,t){const n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function FS(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function LS(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||MS,r=e.options.footnoteBackLabel||FS,i=e.options.footnoteLabel||"Footnotes",s=e.options.footnoteLabelTagName||"h2",o=e.options.footnoteLabelProperties||{className:["sr-only"]},a=[];let c=-1;for(;++c<e.footnoteOrder.length;){const u=e.footnoteById.get(e.footnoteOrder[c]);if(!u)continue;const d=e.all(u),f=String(u.identifier).toUpperCase(),h=Ir(f.toLowerCase());let p=0;const m=[],v=e.footnoteCounts.get(f);for(;v!==void 0&&++p<=v;){m.length>0&&m.push({type:"text",value:" "});let _=typeof n=="string"?n:n(c,p);typeof _=="string"&&(_={type:"text",value:_}),m.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+h+(p>1?"-"+p:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(c,p),className:["data-footnote-backref"]},children:Array.isArray(_)?_:[_]})}const k=d[d.length-1];if(k&&k.type==="element"&&k.tagName==="p"){const _=k.children[k.children.length-1];_&&_.type==="text"?_.value+=" ":k.children.push({type:"text",value:" "}),k.children.push(...m)}else d.push(...m);const y={type:"element",tagName:"li",properties:{id:t+"fn-"+h},children:e.wrap(d,!0)};e.patch(u,y),a.push(y)}if(a.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:s,properties:{...ps(o),id:"footnote-label"},children:[{type:"text",value:i}]},{type:"text",value:`
|
|
156
|
+
`},{type:"element",tagName:"ol",properties:{},children:e.wrap(a,!0)},{type:"text",value:`
|
|
157
|
+
`}]}}const Bs=function(e){if(e==null)return US;if(typeof e=="function")return Zs(e);if(typeof e=="object")return Array.isArray(e)?BS(e):ZS(e);if(typeof e=="string")return VS(e);throw new Error("Expected function, string, or object as test")};function BS(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=Bs(e[n]);return Zs(r);function r(...i){let s=-1;for(;++s<t.length;)if(t[s].apply(this,i))return!0;return!1}}function ZS(e){const t=e;return Zs(n);function n(r){const i=r;let s;for(s in e)if(i[s]!==t[s])return!1;return!0}}function VS(e){return Zs(t);function t(n){return n&&n.type===e}}function Zs(e){return t;function t(n,r,i){return!!(JS(n)&&e.call(this,n,typeof r=="number"?r:void 0,i||void 0))}}function US(){return!0}function JS(e){return e!==null&&typeof e=="object"&&"type"in e}const Kp=[],HS=!0,ea=!1,WS="skip";function Yp(e,t,n,r){let i;typeof t=="function"&&typeof n!="function"?(r=n,n=t):i=t;const s=Bs(i),o=r?-1:1;a(e,void 0,[])();function a(c,u,d){const f=c&&typeof c=="object"?c:{};if(typeof f.type=="string"){const p=typeof f.tagName=="string"?f.tagName:typeof f.name=="string"?f.name:void 0;Object.defineProperty(h,"name",{value:"node ("+(c.type+(p?"<"+p+">":""))+")"})}return h;function h(){let p=Kp,m,v,k;if((!t||s(c,u,d[d.length-1]||void 0))&&(p=qS(n(c,d)),p[0]===ea))return p;if("children"in c&&c.children){const y=c;if(y.children&&p[0]!==WS)for(v=(r?y.children.length:-1)+o,k=d.concat(y);v>-1&&v<y.children.length;){const _=y.children[v];if(m=a(_,v,k)(),m[0]===ea)return m;v=typeof m[1]=="number"?m[1]:v+o}}return p}}}function qS(e){return Array.isArray(e)?e:typeof e=="number"?[HS,e]:e==null?Kp:[e]}function el(e,t,n,r){let i,s,o;typeof t=="function"&&typeof n!="function"?(s=void 0,o=t,i=n):(s=t,o=n,i=r),Yp(e,s,a,i);function a(c,u){const d=u[u.length-1],f=d?d.children.indexOf(c):void 0;return o(c,f,d)}}const ta={}.hasOwnProperty,GS={};function KS(e,t){const n=t||GS,r=new Map,i=new Map,s=new Map,o={...OS,...n.handlers},a={all:u,applyData:XS,definitionById:r,footnoteById:i,footnoteCounts:s,footnoteOrder:[],handlers:o,one:c,options:n,patch:YS,wrap:e1};return el(e,function(d){if(d.type==="definition"||d.type==="footnoteDefinition"){const f=d.type==="definition"?r:i,h=String(d.identifier).toUpperCase();f.has(h)||f.set(h,d)}}),a;function c(d,f){const h=d.type,p=a.handlers[h];if(ta.call(a.handlers,h)&&p)return p(a,d,f);if(a.options.passThrough&&a.options.passThrough.includes(h)){if("children"in d){const{children:v,...k}=d,y=ps(k);return y.children=a.all(d),y}return ps(d)}return(a.options.unknownHandler||QS)(a,d,f)}function u(d){const f=[];if("children"in d){const h=d.children;let p=-1;for(;++p<h.length;){const m=a.one(h[p],d);if(m){if(p&&h[p-1].type==="break"&&(!Array.isArray(m)&&m.type==="text"&&(m.value=Mc(m.value)),!Array.isArray(m)&&m.type==="element")){const v=m.children[0];v&&v.type==="text"&&(v.value=Mc(v.value))}Array.isArray(m)?f.push(...m):f.push(m)}}}return f}}function YS(e,t){e.position&&(t.position=Fw(e))}function XS(e,t){let n=t;if(e&&e.data){const r=e.data.hName,i=e.data.hChildren,s=e.data.hProperties;if(typeof r=="string")if(n.type==="element")n.tagName=r;else{const o="children"in n?n.children:[n];n={type:"element",tagName:r,properties:{},children:o}}n.type==="element"&&s&&Object.assign(n.properties,ps(s)),"children"in n&&n.children&&i!==null&&i!==void 0&&(n.children=i)}return n}function QS(e,t){const n=t.data||{},r="value"in t&&!(ta.call(n,"hProperties")||ta.call(n,"hChildren"))?{type:"text",value:t.value}:{type:"element",tagName:"div",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function e1(e,t){const n=[];let r=-1;for(t&&n.push({type:"text",value:`
|
|
158
|
+
`});++r<e.length;)r&&n.push({type:"text",value:`
|
|
159
|
+
`}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:`
|
|
160
|
+
`}),n}function Mc(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function Fc(e,t){const n=KS(e,t),r=n.one(e,void 0),i=LS(n),s=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return i&&s.children.push({type:"text",value:`
|
|
161
|
+
`},i),s}function t1(e,t){return e&&"run"in e?async function(n,r){const i=Fc(n,{file:r,...t});await e.run(i,r)}:function(n,r){return Fc(n,{file:r,...e||t})}}function Lc(e){if(e)throw e}var fo,Bc;function n1(){if(Bc)return fo;Bc=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=function(u){return typeof Array.isArray=="function"?Array.isArray(u):t.call(u)==="[object Array]"},s=function(u){if(!u||t.call(u)!=="[object Object]")return!1;var d=e.call(u,"constructor"),f=u.constructor&&u.constructor.prototype&&e.call(u.constructor.prototype,"isPrototypeOf");if(u.constructor&&!d&&!f)return!1;var h;for(h in u);return typeof h>"u"||e.call(u,h)},o=function(u,d){n&&d.name==="__proto__"?n(u,d.name,{enumerable:!0,configurable:!0,value:d.newValue,writable:!0}):u[d.name]=d.newValue},a=function(u,d){if(d==="__proto__")if(e.call(u,d)){if(r)return r(u,d).value}else return;return u[d]};return fo=function c(){var u,d,f,h,p,m,v=arguments[0],k=1,y=arguments.length,_=!1;for(typeof v=="boolean"&&(_=v,v=arguments[1]||{},k=2),(v==null||typeof v!="object"&&typeof v!="function")&&(v={});k<y;++k)if(u=arguments[k],u!=null)for(d in u)f=a(v,d),h=a(u,d),v!==h&&(_&&h&&(s(h)||(p=i(h)))?(p?(p=!1,m=f&&i(f)?f:[]):m=f&&s(f)?f:{},o(v,{name:d,newValue:c(_,m,h)})):typeof h<"u"&&o(v,{name:d,newValue:h}));return v},fo}var r1=n1();const po=ga(r1);function na(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function i1(){const e=[],t={run:n,use:r};return t;function n(...i){let s=-1;const o=i.pop();if(typeof o!="function")throw new TypeError("Expected function as last argument, not "+o);a(null,...i);function a(c,...u){const d=e[++s];let f=-1;if(c){o(c);return}for(;++f<i.length;)(u[f]===null||u[f]===void 0)&&(u[f]=i[f]);i=u,d?s1(d,a)(...u):o(null,...u)}}function r(i){if(typeof i!="function")throw new TypeError("Expected `middelware` to be a function, not "+i);return e.push(i),t}}function s1(e,t){let n;return r;function r(...o){const a=e.length>o.length;let c;a&&o.push(i);try{c=e.apply(this,o)}catch(u){const d=u;if(a&&n)throw d;return i(d)}a||(c&&c.then&&typeof c.then=="function"?c.then(s,i):c instanceof Error?i(c):s(c))}function i(o,...a){n||(n=!0,t(o,...a))}function s(o){i(null,o)}}const Yt={basename:o1,dirname:a1,extname:l1,join:c1,sep:"/"};function o1(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Ii(e);let n=0,r=-1,i=e.length,s;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(s){n=i+1;break}}else r<0&&(s=!0,r=i+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let o=-1,a=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(s){n=i+1;break}}else o<0&&(s=!0,o=i+1),a>-1&&(e.codePointAt(i)===t.codePointAt(a--)?a<0&&(r=i):(a=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function a1(e){if(Ii(e),e.length===0)return".";let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||(r=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function l1(e){Ii(e);let t=e.length,n=-1,r=0,i=-1,s=0,o;for(;t--;){const a=e.codePointAt(t);if(a===47){if(o){r=t+1;break}continue}n<0&&(o=!0,n=t+1),a===46?i<0?i=t:s!==1&&(s=1):i>-1&&(s=-1)}return i<0||n<0||s===0||s===1&&i===n-1&&i===r+1?"":e.slice(i,n)}function c1(...e){let t=-1,n;for(;++t<e.length;)Ii(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":u1(n)}function u1(e){Ii(e);const t=e.codePointAt(0)===47;let n=d1(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function d1(e,t){let n="",r=0,i=-1,s=0,o=-1,a,c;for(;++o<=e.length;){if(o<e.length)a=e.codePointAt(o);else{if(a===47)break;a=47}if(a===47){if(!(i===o-1||s===1))if(i!==o-1&&s===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(c=n.lastIndexOf("/"),c!==n.length-1){c<0?(n="",r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf("/")),i=o,s=0;continue}}else if(n.length>0){n="",r=0,i=o,s=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1;i=o,s=0}else a===46&&s>-1?s++:s=-1}return n}function Ii(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const f1={cwd:p1};function p1(){return"/"}function ra(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function h1(e){if(typeof e=="string")e=new URL(e);else if(!ra(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return m1(e)}function m1(e){if(e.hostname!==""){const r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}const t=e.pathname;let n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){const r=t.codePointAt(n+2);if(r===70||r===102){const i=new TypeError("File URL path must not include encoded / characters");throw i.code="ERR_INVALID_FILE_URL_PATH",i}}return decodeURIComponent(t)}const ho=["history","path","basename","stem","extname","dirname"];class Xp{constructor(t){let n;t?ra(t)?n={path:t}:typeof t=="string"||g1(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":f1.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<ho.length;){const s=ho[r];s in n&&n[s]!==void 0&&n[s]!==null&&(this[s]=s==="history"?[...n[s]]:n[s])}let i;for(i in n)ho.includes(i)||(this[i]=n[i])}get basename(){return typeof this.path=="string"?Yt.basename(this.path):void 0}set basename(t){go(t,"basename"),mo(t,"basename"),this.path=Yt.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Yt.dirname(this.path):void 0}set dirname(t){Zc(this.basename,"dirname"),this.path=Yt.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Yt.extname(this.path):void 0}set extname(t){if(mo(t,"extname"),Zc(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=Yt.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){ra(t)&&(t=h1(t)),go(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Yt.basename(this.path,this.extname):void 0}set stem(t){go(t,"stem"),mo(t,"stem"),this.path=Yt.join(this.dirname||"",t+(this.extname||""))}fail(t,n,r){const i=this.message(t,n,r);throw i.fatal=!0,i}info(t,n,r){const i=this.message(t,n,r);return i.fatal=void 0,i}message(t,n,r){const i=new dt(t,n,r);return this.path&&(i.name=this.path+":"+i.name,i.file=this.path),i.fatal=!1,this.messages.push(i),i}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function mo(e,t){if(e&&e.includes(Yt.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Yt.sep+"`")}function go(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function Zc(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function g1(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const x1=function(e){const r=this.constructor.prototype,i=r[e],s=function(){return i.apply(s,arguments)};return Object.setPrototypeOf(s,r),s},y1={}.hasOwnProperty;class tl extends x1{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=i1()}copy(){const t=new tl;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(po(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(bo("data",this.frozen),this.namespace[t]=n,this):y1.call(this.namespace,t)&&this.namespace[t]||void 0:t?(bo("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;const t=this;for(;++this.freezeIndex<this.attachers.length;){const[n,...r]=this.attachers[this.freezeIndex];if(r[0]===!1)continue;r[0]===!0&&(r[0]=void 0);const i=n.call(t,...r);typeof i=="function"&&this.transformers.use(i)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const n=Li(t),r=this.parser||this.Parser;return xo("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),xo("process",this.parser||this.Parser),yo("process",this.compiler||this.Compiler),n?i(void 0,n):new Promise(i);function i(s,o){const a=Li(t),c=r.parse(a);r.run(c,a,function(d,f,h){if(d||!f||!h)return u(d);const p=f,m=r.stringify(p,h);w1(m)?h.value=m:h.result=m,u(d,h)});function u(d,f){d||!f?o(d):s?s(f):n(void 0,f)}}}processSync(t){let n=!1,r;return this.freeze(),xo("processSync",this.parser||this.Parser),yo("processSync",this.compiler||this.Compiler),this.process(t,i),Uc("processSync","process",n),r;function i(s,o){n=!0,Lc(s),r=o}}run(t,n,r){Vc(t),this.freeze();const i=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?s(void 0,r):new Promise(s);function s(o,a){const c=Li(n);i.run(t,c,u);function u(d,f,h){const p=f||t;d?a(d):o?o(p):r(void 0,p,h)}}}runSync(t,n){let r=!1,i;return this.run(t,n,s),Uc("runSync","run",r),i;function s(o,a){Lc(o),i=a,r=!0}}stringify(t,n){this.freeze();const r=Li(n),i=this.compiler||this.Compiler;return yo("stringify",i),Vc(t),i(t,r)}use(t,...n){const r=this.attachers,i=this.namespace;if(bo("use",this.frozen),t!=null)if(typeof t=="function")c(t,n);else if(typeof t=="object")Array.isArray(t)?a(t):o(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function s(u){if(typeof u=="function")c(u,[]);else if(typeof u=="object")if(Array.isArray(u)){const[d,...f]=u;c(d,f)}else o(u);else throw new TypeError("Expected usable value, not `"+u+"`")}function o(u){if(!("plugins"in u)&&!("settings"in u))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");a(u.plugins),u.settings&&(i.settings=po(!0,i.settings,u.settings))}function a(u){let d=-1;if(u!=null)if(Array.isArray(u))for(;++d<u.length;){const f=u[d];s(f)}else throw new TypeError("Expected a list of plugins, not `"+u+"`")}function c(u,d){let f=-1,h=-1;for(;++f<r.length;)if(r[f][0]===u){h=f;break}if(h===-1)r.push([u,...d]);else if(d.length>0){let[p,...m]=d;const v=r[h][1];na(v)&&na(p)&&(p=po(!0,v,p)),r[h]=[u,p,...m]}}}}const b1=new tl().freeze();function xo(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function yo(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function bo(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function Vc(e){if(!na(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function Uc(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Li(e){return v1(e)?e:new Xp(e)}function v1(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function w1(e){return typeof e=="string"||k1(e)}function k1(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const S1="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",Jc=[],Hc={allowDangerousHtml:!0},j1=/^(https?|ircs?|mailto|xmpp)$/i,_1=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function N1(e){const t=C1(e),n=E1(e);return T1(t.runSync(t.parse(n),n),e)}function C1(e){const t=e.rehypePlugins||Jc,n=e.remarkPlugins||Jc,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...Hc}:Hc;return b1().use(aS).use(n).use(t1,r).use(t)}function E1(e){const t=e.children||"",n=new Xp;return typeof t=="string"&&(n.value=t),n}function T1(e,t){const n=t.allowedElements,r=t.allowElement,i=t.components,s=t.disallowedElements,o=t.skipHtml,a=t.unwrapDisallowed,c=t.urlTransform||I1;for(const d of _1)Object.hasOwn(t,d.from)&&(""+d.from+(d.to?"use `"+d.to+"` instead":"remove it")+S1+d.id,void 0);return el(e,u),Uw(e,{Fragment:l.Fragment,components:i,ignoreInvalidStyle:!0,jsx:l.jsx,jsxs:l.jsxs,passKeys:!0,passNode:!0});function u(d,f,h){if(d.type==="raw"&&h&&typeof f=="number")return o?h.children.splice(f,1):h.children[f]={type:"text",value:d.value},f;if(d.type==="element"){let p;for(p in lo)if(Object.hasOwn(lo,p)&&Object.hasOwn(d.properties,p)){const m=d.properties[p],v=lo[p];(v===null||v.includes(d.tagName))&&(d.properties[p]=c(String(m||""),p,d))}}if(d.type==="element"){let p=n?!n.includes(d.tagName):s?s.includes(d.tagName):!1;if(!p&&r&&typeof f=="number"&&(p=!r(d,f,h)),p&&h&&typeof f=="number")return a&&d.children?h.children.splice(f,1,...d.children):h.children.splice(f,1),f}}}function I1(e){const t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),i=e.indexOf("/");return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||j1.test(e.slice(0,t))?e:""}function Wc(e,t){const n=String(e);if(typeof t!="string")throw new TypeError("Expected character");let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}function A1(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function z1(e,t,n){const i=Bs((n||{}).ignore||[]),s=O1(t);let o=-1;for(;++o<s.length;)Yp(e,"text",a);function a(u,d){let f=-1,h;for(;++f<d.length;){const p=d[f],m=h?h.children:void 0;if(i(p,m?m.indexOf(p):void 0,h))return;h=p}if(h)return c(u,d)}function c(u,d){const f=d[d.length-1],h=s[o][0],p=s[o][1];let m=0;const k=f.children.indexOf(u);let y=!1,_=[];h.lastIndex=0;let x=h.exec(u.value);for(;x;){const A=x.index,E={index:x.index,input:x.input,stack:[...d,u]};let w=p(...x,E);if(typeof w=="string"&&(w=w.length>0?{type:"text",value:w}:void 0),w===!1?h.lastIndex=A+1:(m!==A&&_.push({type:"text",value:u.value.slice(m,A)}),Array.isArray(w)?_.push(...w):w&&_.push(w),m=A+x[0].length,y=!0),!h.global)break;x=h.exec(u.value)}return y?(m<u.value.length&&_.push({type:"text",value:u.value.slice(m)}),f.children.splice(k,1,..._)):_=[u],k+_.length}}function O1(e){const t=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");const n=!e[0]||Array.isArray(e[0])?e:[e];let r=-1;for(;++r<n.length;){const i=n[r];t.push([P1(i[0]),D1(i[1])])}return t}function P1(e){return typeof e=="string"?new RegExp(A1(e),"g"):e}function D1(e){return typeof e=="function"?e:function(){return e}}const vo="phrasing",wo=["autolink","link","image","label"];function R1(){return{transforms:[V1],enter:{literalAutolink:M1,literalAutolinkEmail:ko,literalAutolinkHttp:ko,literalAutolinkWww:ko},exit:{literalAutolink:Z1,literalAutolinkEmail:B1,literalAutolinkHttp:F1,literalAutolinkWww:L1}}}function $1(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:vo,notInConstruct:wo},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:vo,notInConstruct:wo},{character:":",before:"[ps]",after:"\\/",inConstruct:vo,notInConstruct:wo}]}}function M1(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function ko(e){this.config.enter.autolinkProtocol.call(this,e)}function F1(e){this.config.exit.autolinkProtocol.call(this,e)}function L1(e){this.config.exit.data.call(this,e);const t=this.stack[this.stack.length-1];t.type,t.url="http://"+this.sliceSerialize(e)}function B1(e){this.config.exit.autolinkEmail.call(this,e)}function Z1(e){this.exit(e)}function V1(e){z1(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,U1],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),J1]],{ignore:["link","linkReference"]})}function U1(e,t,n,r,i){let s="";if(!Qp(i)||(/^w/i.test(t)&&(n=t+n,t="",s="http://"),!H1(n)))return!1;const o=W1(n+r);if(!o[0])return!1;const a={type:"link",title:null,url:s+t+o[0],children:[{type:"text",value:t+o[0]}]};return o[1]?[a,{type:"text",value:o[1]}]:a}function J1(e,t,n,r){return!Qp(r,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function H1(e){const t=e.split(".");return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function W1(e){const t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(")");const i=Wc(e,"(");let s=Wc(e,")");for(;r!==-1&&i>s;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(")"),s++;return[e,n]}function Qp(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||Bn(n)||Ms(n))&&(!t||n!==47)}eh.peek=nj;function q1(){this.buffer()}function G1(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function K1(){this.buffer()}function Y1(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function X1(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Wt(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Q1(e){this.exit(e)}function ej(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Wt(this.sliceSerialize(e)).toLowerCase(),n.label=t}function tj(e){this.exit(e)}function nj(){return"["}function eh(e,t,n,r){const i=n.createTracker(r);let s=i.move("[^");const o=n.enter("footnoteReference"),a=n.enter("reference");return s+=i.move(n.safe(n.associationId(e),{after:"]",before:s})),a(),o(),s+=i.move("]"),s}function rj(){return{enter:{gfmFootnoteCallString:q1,gfmFootnoteCall:G1,gfmFootnoteDefinitionLabelString:K1,gfmFootnoteDefinition:Y1},exit:{gfmFootnoteCallString:X1,gfmFootnoteCall:Q1,gfmFootnoteDefinitionLabelString:ej,gfmFootnoteDefinition:tj}}}function ij(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:eh},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(r,i,s,o){const a=s.createTracker(o);let c=a.move("[^");const u=s.enter("footnoteDefinition"),d=s.enter("label");return c+=a.move(s.safe(s.associationId(r),{before:c,after:"]"})),d(),c+=a.move("]:"),r.children&&r.children.length>0&&(a.shift(4),c+=a.move((t?`
|
|
162
|
+
`:" ")+s.indentLines(s.containerFlow(r,a.current()),t?th:sj))),u(),c}}function sj(e,t,n){return t===0?e:th(e,t,n)}function th(e,t,n){return(n?"":" ")+e}const oj=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];nh.peek=dj;function aj(){return{canContainEols:["delete"],enter:{strikethrough:cj},exit:{strikethrough:uj}}}function lj(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:oj}],handlers:{delete:nh}}}function cj(e){this.enter({type:"delete",children:[]},e)}function uj(e){this.exit(e)}function nh(e,t,n,r){const i=n.createTracker(r),s=n.enter("strikethrough");let o=i.move("~~");return o+=n.containerPhrasing(e,{...i.current(),before:o,after:"~"}),o+=i.move("~~"),s(),o}function dj(){return"~"}function fj(e){return e.length}function pj(e,t){const n=t||{},r=(n.align||[]).concat(),i=n.stringLength||fj,s=[],o=[],a=[],c=[];let u=0,d=-1;for(;++d<e.length;){const v=[],k=[];let y=-1;for(e[d].length>u&&(u=e[d].length);++y<e[d].length;){const _=hj(e[d][y]);if(n.alignDelimiters!==!1){const x=i(_);k[y]=x,(c[y]===void 0||x>c[y])&&(c[y]=x)}v.push(_)}o[d]=v,a[d]=k}let f=-1;if(typeof r=="object"&&"length"in r)for(;++f<u;)s[f]=qc(r[f]);else{const v=qc(r);for(;++f<u;)s[f]=v}f=-1;const h=[],p=[];for(;++f<u;){const v=s[f];let k="",y="";v===99?(k=":",y=":"):v===108?k=":":v===114&&(y=":");let _=n.alignDelimiters===!1?1:Math.max(1,c[f]-k.length-y.length);const x=k+"-".repeat(_)+y;n.alignDelimiters!==!1&&(_=k.length+_+y.length,_>c[f]&&(c[f]=_),p[f]=_),h[f]=x}o.splice(1,0,h),a.splice(1,0,p),d=-1;const m=[];for(;++d<o.length;){const v=o[d],k=a[d];f=-1;const y=[];for(;++f<u;){const _=v[f]||"";let x="",A="";if(n.alignDelimiters!==!1){const E=c[f]-(k[f]||0),w=s[f];w===114?x=" ".repeat(E):w===99?E%2?(x=" ".repeat(E/2+.5),A=" ".repeat(E/2-.5)):(x=" ".repeat(E/2),A=x):A=" ".repeat(E)}n.delimiterStart!==!1&&!f&&y.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&_==="")&&(n.delimiterStart!==!1||f)&&y.push(" "),n.alignDelimiters!==!1&&y.push(x),y.push(_),n.alignDelimiters!==!1&&y.push(A),n.padding!==!1&&y.push(" "),(n.delimiterEnd!==!1||f!==u-1)&&y.push("|")}m.push(n.delimiterEnd===!1?y.join("").replace(/ +$/,""):y.join(""))}return m.join(`
|
|
163
|
+
`)}function hj(e){return e==null?"":String(e)}function qc(e){const t=typeof e=="string"?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function mj(e,t,n,r){const i=n.enter("blockquote"),s=n.createTracker(r);s.move("> "),s.shift(2);const o=n.indentLines(n.containerFlow(e,s.current()),gj);return i(),o}function gj(e,t,n){return">"+(n?"":" ")+e}function xj(e,t){return Gc(e,t.inConstruct,!0)&&!Gc(e,t.notInConstruct,!1)}function Gc(e,t,n){if(typeof t=="string"&&(t=[t]),!t||t.length===0)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function Kc(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
|
|
164
|
+
`&&xj(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?"":" ";return`\\
|
|
165
|
+
`}function yj(e,t){const n=String(e);let r=n.indexOf(t),i=r,s=0,o=0;if(typeof t!="string")throw new TypeError("Expected substring");for(;r!==-1;)r===i?++s>o&&(o=s):s=1,i=r+t.length,r=n.indexOf(t,i);return o}function bj(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function vj(e){const t=e.options.fence||"`";if(t!=="`"&&t!=="~")throw new Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function wj(e,t,n,r){const i=vj(n),s=e.value||"",o=i==="`"?"GraveAccent":"Tilde";if(bj(e,n)){const f=n.enter("codeIndented"),h=n.indentLines(s,kj);return f(),h}const a=n.createTracker(r),c=i.repeat(Math.max(yj(s,i)+1,3)),u=n.enter("codeFenced");let d=a.move(c);if(e.lang){const f=n.enter(`codeFencedLang${o}`);d+=a.move(n.safe(e.lang,{before:d,after:" ",encode:["`"],...a.current()})),f()}if(e.lang&&e.meta){const f=n.enter(`codeFencedMeta${o}`);d+=a.move(" "),d+=a.move(n.safe(e.meta,{before:d,after:`
|
|
166
|
+
`,encode:["`"],...a.current()})),f()}return d+=a.move(`
|
|
167
|
+
`),s&&(d+=a.move(s+`
|
|
168
|
+
`)),d+=a.move(c),u(),d}function kj(e,t,n){return(n?"":" ")+e}function nl(e){const t=e.options.quote||'"';if(t!=='"'&&t!=="'")throw new Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function Sj(e,t,n,r){const i=nl(n),s=i==='"'?"Quote":"Apostrophe",o=n.enter("definition");let a=n.enter("label");const c=n.createTracker(r);let u=c.move("[");return u+=c.move(n.safe(n.associationId(e),{before:u,after:"]",...c.current()})),u+=c.move("]: "),a(),!e.url||/[\0- \u007F]/.test(e.url)?(a=n.enter("destinationLiteral"),u+=c.move("<"),u+=c.move(n.safe(e.url,{before:u,after:">",...c.current()})),u+=c.move(">")):(a=n.enter("destinationRaw"),u+=c.move(n.safe(e.url,{before:u,after:e.title?" ":`
|
|
169
|
+
`,...c.current()}))),a(),e.title&&(a=n.enter(`title${s}`),u+=c.move(" "+i),u+=c.move(n.safe(e.title,{before:u,after:i,...c.current()})),u+=c.move(i),a()),o(),u}function jj(e){const t=e.options.emphasis||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function mi(e){return"&#x"+e.toString(16).toUpperCase()+";"}function hs(e,t,n){const r=wr(e),i=wr(t);return r===void 0?i===void 0?n==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}rh.peek=_j;function rh(e,t,n,r){const i=jj(n),s=n.enter("emphasis"),o=n.createTracker(r),a=o.move(i);let c=o.move(n.containerPhrasing(e,{after:i,before:a,...o.current()}));const u=c.charCodeAt(0),d=hs(r.before.charCodeAt(r.before.length-1),u,i);d.inside&&(c=mi(u)+c.slice(1));const f=c.charCodeAt(c.length-1),h=hs(r.after.charCodeAt(0),f,i);h.inside&&(c=c.slice(0,-1)+mi(f));const p=o.move(i);return s(),n.attentionEncodeSurroundingInfo={after:h.outside,before:d.outside},a+c+p}function _j(e,t,n){return n.options.emphasis||"*"}function Nj(e,t){let n=!1;return el(e,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return n=!0,ea}),!!((!e.depth||e.depth<3)&&Wa(e)&&(t.options.setext||n))}function Cj(e,t,n,r){const i=Math.max(Math.min(6,e.depth||1),1),s=n.createTracker(r);if(Nj(e,n)){const d=n.enter("headingSetext"),f=n.enter("phrasing"),h=n.containerPhrasing(e,{...s.current(),before:`
|
|
170
|
+
`,after:`
|
|
171
|
+
`});return f(),d(),h+`
|
|
172
|
+
`+(i===1?"=":"-").repeat(h.length-(Math.max(h.lastIndexOf("\r"),h.lastIndexOf(`
|
|
173
|
+
`))+1))}const o="#".repeat(i),a=n.enter("headingAtx"),c=n.enter("phrasing");s.move(o+" ");let u=n.containerPhrasing(e,{before:"# ",after:`
|
|
174
|
+
`,...s.current()});return/^[\t ]/.test(u)&&(u=mi(u.charCodeAt(0))+u.slice(1)),u=u?o+" "+u:o,n.options.closeAtx&&(u+=" "+o),c(),a(),u}ih.peek=Ej;function ih(e){return e.value||""}function Ej(){return"<"}sh.peek=Tj;function sh(e,t,n,r){const i=nl(n),s=i==='"'?"Quote":"Apostrophe",o=n.enter("image");let a=n.enter("label");const c=n.createTracker(r);let u=c.move("![");return u+=c.move(n.safe(e.alt,{before:u,after:"]",...c.current()})),u+=c.move("]("),a(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(a=n.enter("destinationLiteral"),u+=c.move("<"),u+=c.move(n.safe(e.url,{before:u,after:">",...c.current()})),u+=c.move(">")):(a=n.enter("destinationRaw"),u+=c.move(n.safe(e.url,{before:u,after:e.title?" ":")",...c.current()}))),a(),e.title&&(a=n.enter(`title${s}`),u+=c.move(" "+i),u+=c.move(n.safe(e.title,{before:u,after:i,...c.current()})),u+=c.move(i),a()),u+=c.move(")"),o(),u}function Tj(){return"!"}oh.peek=Ij;function oh(e,t,n,r){const i=e.referenceType,s=n.enter("imageReference");let o=n.enter("label");const a=n.createTracker(r);let c=a.move("![");const u=n.safe(e.alt,{before:c,after:"]",...a.current()});c+=a.move(u+"]["),o();const d=n.stack;n.stack=[],o=n.enter("reference");const f=n.safe(n.associationId(e),{before:c,after:"]",...a.current()});return o(),n.stack=d,s(),i==="full"||!u||u!==f?c+=a.move(f+"]"):i==="shortcut"?c=c.slice(0,-1):c+=a.move("]"),c}function Ij(){return"!"}ah.peek=Aj;function ah(e,t,n){let r=e.value||"",i="`",s=-1;for(;new RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++s<n.unsafe.length;){const o=n.unsafe[s],a=n.compilePattern(o);let c;if(o.atBreak)for(;c=a.exec(r);){let u=c.index;r.charCodeAt(u)===10&&r.charCodeAt(u-1)===13&&u--,r=r.slice(0,u)+" "+r.slice(c.index+1)}}return i+r+i}function Aj(){return"`"}function lh(e,t){const n=Wa(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(n===e.url||"mailto:"+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}ch.peek=zj;function ch(e,t,n,r){const i=nl(n),s=i==='"'?"Quote":"Apostrophe",o=n.createTracker(r);let a,c;if(lh(e,n)){const d=n.stack;n.stack=[],a=n.enter("autolink");let f=o.move("<");return f+=o.move(n.containerPhrasing(e,{before:f,after:">",...o.current()})),f+=o.move(">"),a(),n.stack=d,f}a=n.enter("link"),c=n.enter("label");let u=o.move("[");return u+=o.move(n.containerPhrasing(e,{before:u,after:"](",...o.current()})),u+=o.move("]("),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter("destinationLiteral"),u+=o.move("<"),u+=o.move(n.safe(e.url,{before:u,after:">",...o.current()})),u+=o.move(">")):(c=n.enter("destinationRaw"),u+=o.move(n.safe(e.url,{before:u,after:e.title?" ":")",...o.current()}))),c(),e.title&&(c=n.enter(`title${s}`),u+=o.move(" "+i),u+=o.move(n.safe(e.title,{before:u,after:i,...o.current()})),u+=o.move(i),c()),u+=o.move(")"),a(),u}function zj(e,t,n){return lh(e,n)?"<":"["}uh.peek=Oj;function uh(e,t,n,r){const i=e.referenceType,s=n.enter("linkReference");let o=n.enter("label");const a=n.createTracker(r);let c=a.move("[");const u=n.containerPhrasing(e,{before:c,after:"]",...a.current()});c+=a.move(u+"]["),o();const d=n.stack;n.stack=[],o=n.enter("reference");const f=n.safe(n.associationId(e),{before:c,after:"]",...a.current()});return o(),n.stack=d,s(),i==="full"||!u||u!==f?c+=a.move(f+"]"):i==="shortcut"?c=c.slice(0,-1):c+=a.move("]"),c}function Oj(){return"["}function rl(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function Pj(e){const t=rl(e),n=e.options.bulletOther;if(!n)return t==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function Dj(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function dh(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function Rj(e,t,n,r){const i=n.enter("list"),s=n.bulletCurrent;let o=e.ordered?Dj(n):rl(n);const a=e.ordered?o==="."?")":".":Pj(n);let c=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){const d=e.children?e.children[0]:void 0;if((o==="*"||o==="-")&&d&&(!d.children||!d.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(c=!0),dh(n)===o&&d){let f=-1;for(;++f<e.children.length;){const h=e.children[f];if(h&&h.type==="listItem"&&h.children&&h.children[0]&&h.children[0].type==="thematicBreak"){c=!0;break}}}}c&&(o=a),n.bulletCurrent=o;const u=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=s,i(),u}function $j(e){const t=e.options.listItemIndent||"one";if(t!=="tab"&&t!=="one"&&t!=="mixed")throw new Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function Mj(e,t,n,r){const i=$j(n);let s=n.bulletCurrent||rl(n);t&&t.type==="list"&&t.ordered&&(s=(typeof t.start=="number"&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+s);let o=s.length+1;(i==="tab"||i==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);const a=n.createTracker(r);a.move(s+" ".repeat(o-s.length)),a.shift(o);const c=n.enter("listItem"),u=n.indentLines(n.containerFlow(e,a.current()),d);return c(),u;function d(f,h,p){return h?(p?"":" ".repeat(o))+f:(p?s:s+" ".repeat(o-s.length))+f}}function Fj(e,t,n,r){const i=n.enter("paragraph"),s=n.enter("phrasing"),o=n.containerPhrasing(e,r);return s(),i(),o}const Lj=Bs(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function Bj(e,t,n,r){return(e.children.some(function(o){return Lj(o)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function Zj(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}fh.peek=Vj;function fh(e,t,n,r){const i=Zj(n),s=n.enter("strong"),o=n.createTracker(r),a=o.move(i+i);let c=o.move(n.containerPhrasing(e,{after:i,before:a,...o.current()}));const u=c.charCodeAt(0),d=hs(r.before.charCodeAt(r.before.length-1),u,i);d.inside&&(c=mi(u)+c.slice(1));const f=c.charCodeAt(c.length-1),h=hs(r.after.charCodeAt(0),f,i);h.inside&&(c=c.slice(0,-1)+mi(f));const p=o.move(i+i);return s(),n.attentionEncodeSurroundingInfo={after:h.outside,before:d.outside},a+c+p}function Vj(e,t,n){return n.options.strong||"*"}function Uj(e,t,n,r){return n.safe(e.value,r)}function Jj(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function Hj(e,t,n){const r=(dh(n)+(n.options.ruleSpaces?" ":"")).repeat(Jj(n));return n.options.ruleSpaces?r.slice(0,-1):r}const ph={blockquote:mj,break:Kc,code:wj,definition:Sj,emphasis:rh,hardBreak:Kc,heading:Cj,html:ih,image:sh,imageReference:oh,inlineCode:ah,link:ch,linkReference:uh,list:Rj,listItem:Mj,paragraph:Fj,root:Bj,strong:fh,text:Uj,thematicBreak:Hj};function Wj(){return{enter:{table:qj,tableData:Yc,tableHeader:Yc,tableRow:Kj},exit:{codeText:Yj,table:Gj,tableData:So,tableHeader:So,tableRow:So}}}function qj(e){const t=e._align;this.enter({type:"table",align:t.map(function(n){return n==="none"?null:n}),children:[]},e),this.data.inTable=!0}function Gj(e){this.exit(e),this.data.inTable=void 0}function Kj(e){this.enter({type:"tableRow",children:[]},e)}function So(e){this.exit(e)}function Yc(e){this.enter({type:"tableCell",children:[]},e)}function Yj(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,Xj));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function Xj(e,t){return t==="|"?t:e}function Qj(e){const t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,s=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
|
|
175
|
+
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:h,table:o,tableCell:c,tableRow:a}};function o(p,m,v,k){return u(d(p,v,k),p.align)}function a(p,m,v,k){const y=f(p,v,k),_=u([y]);return _.slice(0,_.indexOf(`
|
|
176
|
+
`))}function c(p,m,v,k){const y=v.enter("tableCell"),_=v.enter("phrasing"),x=v.containerPhrasing(p,{...k,before:s,after:s});return _(),y(),x}function u(p,m){return pj(p,{align:m,alignDelimiters:r,padding:n,stringLength:i})}function d(p,m,v){const k=p.children;let y=-1;const _=[],x=m.enter("table");for(;++y<k.length;)_[y]=f(k[y],m,v);return x(),_}function f(p,m,v){const k=p.children;let y=-1;const _=[],x=m.enter("tableRow");for(;++y<k.length;)_[y]=c(k[y],p,m,v);return x(),_}function h(p,m,v){let k=ph.inlineCode(p,m,v);return v.stack.includes("tableCell")&&(k=k.replace(/\|/g,"\\$&")),k}}function e_(){return{exit:{taskListCheckValueChecked:Xc,taskListCheckValueUnchecked:Xc,paragraph:n_}}}function t_(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:r_}}}function Xc(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function n_(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const i=t.children;let s=-1,o;for(;++s<i.length;){const a=i[s];if(a.type==="paragraph"){o=a;break}}o===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function r_(e,t,n,r){const i=e.children[0],s=typeof e.checked=="boolean"&&i&&i.type==="paragraph",o="["+(e.checked?"x":" ")+"] ",a=n.createTracker(r);s&&a.move(o);let c=ph.listItem(e,t,n,{...r,...a.current()});return s&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,u)),c;function u(d){return d+o}}function i_(){return[R1(),rj(),aj(),Wj(),e_()]}function s_(e){return{extensions:[$1(),ij(e),lj(),Qj(e),t_()]}}const o_={tokenize:f_,partial:!0},hh={tokenize:p_,partial:!0},mh={tokenize:h_,partial:!0},gh={tokenize:m_,partial:!0},a_={tokenize:g_,partial:!0},xh={name:"wwwAutolink",tokenize:u_,previous:bh},yh={name:"protocolAutolink",tokenize:d_,previous:vh},fn={name:"emailAutolink",tokenize:c_,previous:wh},rn={};function l_(){return{text:rn}}let Tn=48;for(;Tn<123;)rn[Tn]=fn,Tn++,Tn===58?Tn=65:Tn===91&&(Tn=97);rn[43]=fn;rn[45]=fn;rn[46]=fn;rn[95]=fn;rn[72]=[fn,yh];rn[104]=[fn,yh];rn[87]=[fn,xh];rn[119]=[fn,xh];function c_(e,t,n){const r=this;let i,s;return o;function o(f){return!ia(f)||!wh.call(r,r.previous)||il(r.events)?n(f):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),a(f))}function a(f){return ia(f)?(e.consume(f),a):f===64?(e.consume(f),c):n(f)}function c(f){return f===46?e.check(a_,d,u)(f):f===45||f===95||ut(f)?(s=!0,e.consume(f),c):d(f)}function u(f){return e.consume(f),i=!0,c}function d(f){return s&&i&&xt(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(f)):n(f)}}function u_(e,t,n){const r=this;return i;function i(o){return o!==87&&o!==119||!bh.call(r,r.previous)||il(r.events)?n(o):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(o_,e.attempt(hh,e.attempt(mh,s),n),n)(o))}function s(o){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(o)}}function d_(e,t,n){const r=this;let i="",s=!1;return o;function o(f){return(f===72||f===104)&&vh.call(r,r.previous)&&!il(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),i+=String.fromCodePoint(f),e.consume(f),a):n(f)}function a(f){if(xt(f)&&i.length<5)return i+=String.fromCodePoint(f),e.consume(f),a;if(f===58){const h=i.toLowerCase();if(h==="http"||h==="https")return e.consume(f),c}return n(f)}function c(f){return f===47?(e.consume(f),s?u:(s=!0,c)):n(f)}function u(f){return f===null||ds(f)||Ze(f)||Bn(f)||Ms(f)?n(f):e.attempt(hh,e.attempt(mh,d),n)(f)}function d(f){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(f)}}function f_(e,t,n){let r=0;return i;function i(o){return(o===87||o===119)&&r<3?(r++,e.consume(o),i):o===46&&r===3?(e.consume(o),s):n(o)}function s(o){return o===null?n(o):t(o)}}function p_(e,t,n){let r,i,s;return o;function o(u){return u===46||u===95?e.check(gh,c,a)(u):u===null||Ze(u)||Bn(u)||u!==45&&Ms(u)?c(u):(s=!0,e.consume(u),o)}function a(u){return u===95?r=!0:(i=r,r=void 0),e.consume(u),o}function c(u){return i||r||!s?n(u):t(u)}}function h_(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?s(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(gh,t,s)(o):o===null||Ze(o)||Bn(o)?t(o):(e.consume(o),i)}function s(o){return o===41&&r++,e.consume(o),i}}function m_(e,t,n){return r;function r(a){return a===33||a===34||a===39||a===41||a===42||a===44||a===46||a===58||a===59||a===63||a===95||a===126?(e.consume(a),r):a===38?(e.consume(a),s):a===93?(e.consume(a),i):a===60||a===null||Ze(a)||Bn(a)?t(a):n(a)}function i(a){return a===null||a===40||a===91||Ze(a)||Bn(a)?t(a):r(a)}function s(a){return xt(a)?o(a):n(a)}function o(a){return a===59?(e.consume(a),r):xt(a)?(e.consume(a),o):n(a)}}function g_(e,t,n){return r;function r(s){return e.consume(s),i}function i(s){return ut(s)?n(s):t(s)}}function bh(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Ze(e)}function vh(e){return!xt(e)}function wh(e){return!(e===47||ia(e))}function ia(e){return e===43||e===45||e===46||e===95||ut(e)}function il(e){let t=e.length,n=!1;for(;t--;){const r=e[t][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const x_={tokenize:__,partial:!0};function y_(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:k_,continuation:{tokenize:S_},exit:j_}},text:{91:{name:"gfmFootnoteCall",tokenize:w_},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:b_,resolveTo:v_}}}}function b_(e,t,n){const r=this;let i=r.events.length;const s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o;for(;i--;){const c=r.events[i][1];if(c.type==="labelImage"){o=c;break}if(c.type==="gfmFootnoteCall"||c.type==="labelLink"||c.type==="label"||c.type==="image"||c.type==="link")break}return a;function a(c){if(!o||!o._balanced)return n(c);const u=Wt(r.sliceSerialize({start:o.end,end:r.now()}));return u.codePointAt(0)!==94||!s.includes(u.slice(1))?n(c):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(c),e.exit("gfmFootnoteCallLabelMarker"),t(c))}}function v_(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const s={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:"chunkString",contentType:"string",start:Object.assign({},s.start),end:Object.assign({},s.end)},a=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",i,t],["exit",i,t],["enter",s,t],["enter",o,t],["exit",o,t],["exit",s,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...a),e}function w_(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s=0,o;return a;function a(f){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(f),e.exit("gfmFootnoteCallLabelMarker"),c}function c(f){return f!==94?n(f):(e.enter("gfmFootnoteCallMarker"),e.consume(f),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",u)}function u(f){if(s>999||f===93&&!o||f===null||f===91||Ze(f))return n(f);if(f===93){e.exit("chunkString");const h=e.exit("gfmFootnoteCallString");return i.includes(Wt(r.sliceSerialize(h)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(f),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(f)}return Ze(f)||(o=!0),s++,e.consume(f),f===92?d:u}function d(f){return f===91||f===92||f===93?(e.consume(f),s++,u):u(f)}}function k_(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s,o=0,a;return c;function c(m){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),u}function u(m){return m===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",d):n(m)}function d(m){if(o>999||m===93&&!a||m===null||m===91||Ze(m))return n(m);if(m===93){e.exit("chunkString");const v=e.exit("gfmFootnoteDefinitionLabelString");return s=Wt(r.sliceSerialize(v)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),h}return Ze(m)||(a=!0),o++,e.consume(m),m===92?f:d}function f(m){return m===91||m===92||m===93?(e.consume(m),o++,d):d(m)}function h(m){return m===58?(e.enter("definitionMarker"),e.consume(m),e.exit("definitionMarker"),i.includes(s)||i.push(s),Pe(e,p,"gfmFootnoteDefinitionWhitespace")):n(m)}function p(m){return t(m)}}function S_(e,t,n){return e.check(Ti,t,e.attempt(x_,t,n))}function j_(e){e.exit("gfmFootnoteDefinition")}function __(e,t,n){const r=this;return Pe(e,i,"gfmFootnoteDefinitionIndent",5);function i(s){const o=r.events[r.events.length-1];return o&&o[1].type==="gfmFootnoteDefinitionIndent"&&o[2].sliceSerialize(o[1],!0).length===4?t(s):n(s)}}function N_(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:s,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(o,a){let c=-1;for(;++c<o.length;)if(o[c][0]==="enter"&&o[c][1].type==="strikethroughSequenceTemporary"&&o[c][1]._close){let u=c;for(;u--;)if(o[u][0]==="exit"&&o[u][1].type==="strikethroughSequenceTemporary"&&o[u][1]._open&&o[c][1].end.offset-o[c][1].start.offset===o[u][1].end.offset-o[u][1].start.offset){o[c][1].type="strikethroughSequence",o[u][1].type="strikethroughSequence";const d={type:"strikethrough",start:Object.assign({},o[u][1].start),end:Object.assign({},o[c][1].end)},f={type:"strikethroughText",start:Object.assign({},o[u][1].end),end:Object.assign({},o[c][1].start)},h=[["enter",d,a],["enter",o[u][1],a],["exit",o[u][1],a],["enter",f,a]],p=a.parser.constructs.insideSpan.null;p&&At(h,h.length,0,Fs(p,o.slice(u+1,c),a)),At(h,h.length,0,[["exit",f,a],["enter",o[c][1],a],["exit",o[c][1],a],["exit",d,a]]),At(o,u-1,c-u+3,h),c=u+h.length-2;break}}for(c=-1;++c<o.length;)o[c][1].type==="strikethroughSequenceTemporary"&&(o[c][1].type="data");return o}function s(o,a,c){const u=this.previous,d=this.events;let f=0;return h;function h(m){return u===126&&d[d.length-1][1].type!=="characterEscape"?c(m):(o.enter("strikethroughSequenceTemporary"),p(m))}function p(m){const v=wr(u);if(m===126)return f>1?c(m):(o.consume(m),f++,p);if(f<2&&!n)return c(m);const k=o.exit("strikethroughSequenceTemporary"),y=wr(m);return k._open=!y||y===2&&!!v,k._close=!v||v===2&&!!y,a(m)}}}class C_{constructor(){this.map=[]}add(t,n,r){E_(this,t,n,r)}consume(t){if(this.map.sort(function(s,o){return s[0]-o[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let i=r.pop();for(;i;){for(const s of i)t.push(s);i=r.pop()}this.map.length=0}}function E_(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function T_(e,t){let n=!1;const r=[];for(;t<e.length;){const i=e[t];if(n){if(i[0]==="enter")i[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(i[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const s=r.length-1;r[s]=r[s]==="left"?"center":"right"}}else if(i[1].type==="tableDelimiterRow")break}else i[0]==="enter"&&i[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return r}function I_(){return{flow:{null:{name:"table",tokenize:A_,resolveAll:z_}}}}function A_(e,t,n){const r=this;let i=0,s=0,o;return a;function a(N){let R=r.events.length-1;for(;R>-1;){const $=r.events[R][1].type;if($==="lineEnding"||$==="linePrefix")R--;else break}const T=R>-1?r.events[R][1].type:null,F=T==="tableHead"||T==="tableRow"?w:c;return F===w&&r.parser.lazy[r.now().line]?n(N):F(N)}function c(N){return e.enter("tableHead"),e.enter("tableRow"),u(N)}function u(N){return N===124||(o=!0,s+=1),d(N)}function d(N){return N===null?n(N):be(N)?s>1?(s=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(N),e.exit("lineEnding"),p):n(N):Ie(N)?Pe(e,d,"whitespace")(N):(s+=1,o&&(o=!1,i+=1),N===124?(e.enter("tableCellDivider"),e.consume(N),e.exit("tableCellDivider"),o=!0,d):(e.enter("data"),f(N)))}function f(N){return N===null||N===124||Ze(N)?(e.exit("data"),d(N)):(e.consume(N),N===92?h:f)}function h(N){return N===92||N===124?(e.consume(N),f):f(N)}function p(N){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(N):(e.enter("tableDelimiterRow"),o=!1,Ie(N)?Pe(e,m,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(N):m(N))}function m(N){return N===45||N===58?k(N):N===124?(o=!0,e.enter("tableCellDivider"),e.consume(N),e.exit("tableCellDivider"),v):E(N)}function v(N){return Ie(N)?Pe(e,k,"whitespace")(N):k(N)}function k(N){return N===58?(s+=1,o=!0,e.enter("tableDelimiterMarker"),e.consume(N),e.exit("tableDelimiterMarker"),y):N===45?(s+=1,y(N)):N===null||be(N)?A(N):E(N)}function y(N){return N===45?(e.enter("tableDelimiterFiller"),_(N)):E(N)}function _(N){return N===45?(e.consume(N),_):N===58?(o=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(N),e.exit("tableDelimiterMarker"),x):(e.exit("tableDelimiterFiller"),x(N))}function x(N){return Ie(N)?Pe(e,A,"whitespace")(N):A(N)}function A(N){return N===124?m(N):N===null||be(N)?!o||i!==s?E(N):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(N)):E(N)}function E(N){return n(N)}function w(N){return e.enter("tableRow"),S(N)}function S(N){return N===124?(e.enter("tableCellDivider"),e.consume(N),e.exit("tableCellDivider"),S):N===null||be(N)?(e.exit("tableRow"),t(N)):Ie(N)?Pe(e,S,"whitespace")(N):(e.enter("data"),O(N))}function O(N){return N===null||N===124||Ze(N)?(e.exit("data"),S(N)):(e.consume(N),N===92?B:O)}function B(N){return N===92||N===124?(e.consume(N),O):O(N)}}function z_(e,t){let n=-1,r=!0,i=0,s=[0,0,0,0],o=[0,0,0,0],a=!1,c=0,u,d,f;const h=new C_;for(;++n<e.length;){const p=e[n],m=p[1];p[0]==="enter"?m.type==="tableHead"?(a=!1,c!==0&&(Qc(h,t,c,u,d),d=void 0,c=0),u={type:"table",start:Object.assign({},m.start),end:Object.assign({},m.end)},h.add(n,0,[["enter",u,t]])):m.type==="tableRow"||m.type==="tableDelimiterRow"?(r=!0,f=void 0,s=[0,0,0,0],o=[0,n+1,0,0],a&&(a=!1,d={type:"tableBody",start:Object.assign({},m.start),end:Object.assign({},m.end)},h.add(n,0,[["enter",d,t]])),i=m.type==="tableDelimiterRow"?2:d?3:1):i&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")?(r=!1,o[2]===0&&(s[1]!==0&&(o[0]=o[1],f=Bi(h,t,s,i,void 0,f),s=[0,0,0,0]),o[2]=n)):m.type==="tableCellDivider"&&(r?r=!1:(s[1]!==0&&(o[0]=o[1],f=Bi(h,t,s,i,void 0,f)),s=o,o=[s[1],n,0,0])):m.type==="tableHead"?(a=!0,c=n):m.type==="tableRow"||m.type==="tableDelimiterRow"?(c=n,s[1]!==0?(o[0]=o[1],f=Bi(h,t,s,i,n,f)):o[1]!==0&&(f=Bi(h,t,o,i,n,f)),i=0):i&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")&&(o[3]=n)}for(c!==0&&Qc(h,t,c,u,d),h.consume(t.events),n=-1;++n<t.events.length;){const p=t.events[n];p[0]==="enter"&&p[1].type==="table"&&(p[1]._align=T_(t.events,n))}return e}function Bi(e,t,n,r,i,s){const o=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",a="tableContent";n[0]!==0&&(s.end=Object.assign({},nr(t.events,n[0])),e.add(n[0],0,[["exit",s,t]]));const c=nr(t.events,n[1]);if(s={type:o,start:Object.assign({},c),end:Object.assign({},c)},e.add(n[1],0,[["enter",s,t]]),n[2]!==0){const u=nr(t.events,n[2]),d=nr(t.events,n[3]),f={type:a,start:Object.assign({},u),end:Object.assign({},d)};if(e.add(n[2],0,[["enter",f,t]]),r!==2){const h=t.events[n[2]],p=t.events[n[3]];if(h[1].end=Object.assign({},p[1].end),h[1].type="chunkText",h[1].contentType="text",n[3]>n[2]+1){const m=n[2]+1,v=n[3]-n[2]-1;e.add(m,v,[])}}e.add(n[3]+1,0,[["exit",f,t]])}return i!==void 0&&(s.end=Object.assign({},nr(t.events,i)),e.add(i,0,[["exit",s,t]]),s=void 0),s}function Qc(e,t,n,r,i){const s=[],o=nr(t.events,n);i&&(i.end=Object.assign({},o),s.push(["exit",i,t])),r.end=Object.assign({},o),s.push(["exit",r,t]),e.add(n+1,0,s)}function nr(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const O_={name:"tasklistCheck",tokenize:D_};function P_(){return{text:{91:O_}}}function D_(e,t,n){const r=this;return i;function i(c){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(c):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(c),e.exit("taskListCheckMarker"),s)}function s(c){return Ze(c)?(e.enter("taskListCheckValueUnchecked"),e.consume(c),e.exit("taskListCheckValueUnchecked"),o):c===88||c===120?(e.enter("taskListCheckValueChecked"),e.consume(c),e.exit("taskListCheckValueChecked"),o):n(c)}function o(c){return c===93?(e.enter("taskListCheckMarker"),e.consume(c),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),a):n(c)}function a(c){return be(c)?t(c):Ie(c)?e.check({tokenize:R_},t,n)(c):n(c)}}function R_(e,t,n){return Pe(e,r,"whitespace");function r(i){return i===null?n(i):t(i)}}function $_(e){return zp([l_(),y_(),N_(e),I_(),P_()])}const M_={};function F_(e){const t=this,n=e||M_,r=t.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),s=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),o=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push($_(n)),s.push(i_()),o.push(s_(n))}var kh="vercel.ai.error",L_=Symbol.for(kh),eu,tu,nn=class Sh extends(tu=Error,eu=L_,tu){constructor({name:t,message:n,cause:r}){super(n),this[eu]=!0,this.name=t,this.cause=r}static isInstance(t){return Sh.hasMarker(t,kh)}static hasMarker(t,n){const r=Symbol.for(n);return t!=null&&typeof t=="object"&&r in t&&typeof t[r]=="boolean"&&t[r]===!0}};function jh(e){return e==null?"unknown error":typeof e=="string"?e:e instanceof Error?e.message:JSON.stringify(e)}var _h="AI_InvalidArgumentError",Nh=`vercel.ai.error.${_h}`,B_=Symbol.for(Nh),nu,ru,Z_=class extends(ru=nn,nu=B_,ru){constructor({message:e,cause:t,argument:n}){super({name:_h,message:e,cause:t}),this[nu]=!0,this.argument=n}static isInstance(e){return nn.hasMarker(e,Nh)}},Ch="AI_JSONParseError",Eh=`vercel.ai.error.${Ch}`,V_=Symbol.for(Eh),iu,su,ou=class extends(su=nn,iu=V_,su){constructor({text:e,cause:t}){super({name:Ch,message:`JSON parsing failed: Text: ${e}.
|
|
177
|
+
Error message: ${jh(t)}`,cause:t}),this[iu]=!0,this.text=e}static isInstance(e){return nn.hasMarker(e,Eh)}},Th="AI_TypeValidationError",Ih=`vercel.ai.error.${Th}`,U_=Symbol.for(Ih),au,lu,kr=class sa extends(lu=nn,au=U_,lu){constructor({value:t,cause:n,context:r}){let i="Type validation failed";if(r!=null&&r.field&&(i+=` for ${r.field}`),r!=null&&r.entityName||r!=null&&r.entityId){i+=" (";const s=[];r.entityName&&s.push(r.entityName),r.entityId&&s.push(`id: "${r.entityId}"`),i+=s.join(", "),i+=")"}super({name:Th,message:`${i}: Value: ${JSON.stringify(t)}.
|
|
178
|
+
Error message: ${jh(n)}`,cause:n}),this[au]=!0,this.value=t,this.context=r}static isInstance(t){return nn.hasMarker(t,Ih)}static wrap({value:t,cause:n,context:r}){var i,s,o;return sa.isInstance(n)&&n.value===t&&((i=n.context)==null?void 0:i.field)===(r==null?void 0:r.field)&&((s=n.context)==null?void 0:s.entityName)===(r==null?void 0:r.entityName)&&((o=n.context)==null?void 0:o.entityId)===(r==null?void 0:r.entityId)?n:new sa({value:t,cause:n,context:r})}};function q(e,t,n){function r(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:o,traits:new Set},enumerable:!1}),a._zod.traits.has(e))return;a._zod.traits.add(e),t(a,c);const u=o.prototype,d=Object.keys(u);for(let f=0;f<d.length;f++){const h=d[f];h in a||(a[h]=u[h].bind(a))}}const i=(n==null?void 0:n.Parent)??Object;class s extends i{}Object.defineProperty(s,"name",{value:e});function o(a){var c;const u=n!=null&&n.Parent?new s:this;r(u,a),(c=u._zod).deferred??(c.deferred=[]);for(const d of u._zod.deferred)d();return u}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:a=>{var c,u;return n!=null&&n.Parent&&a instanceof n.Parent?!0:(u=(c=a==null?void 0:a._zod)==null?void 0:c.traits)==null?void 0:u.has(e)}}),Object.defineProperty(o,"name",{value:e}),o}class mr extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Ah extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const zh={};function Sn(e){return zh}function Oh(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,i])=>t.indexOf(+r)===-1).map(([r,i])=>i)}function oa(e,t){return typeof t=="bigint"?t.toString():t}function Vs(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function sl(e){return e==null}function ol(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function J_(e,t){const n=(e.toString().split(".")[1]||"").length,r=t.toString();let i=(r.split(".")[1]||"").length;if(i===0&&/\d?e-\d?/.test(r)){const c=r.match(/\d?e-(\d?)/);c!=null&&c[1]&&(i=Number.parseInt(c[1]))}const s=n>i?n:i,o=Number.parseInt(e.toFixed(s).replace(".","")),a=Number.parseInt(t.toFixed(s).replace(".",""));return o%a/10**s}const cu=Symbol("evaluating");function ze(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==cu)return r===void 0&&(r=cu,r=n()),r},set(i){Object.defineProperty(e,t,{value:i})},configurable:!0})}function Un(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Nn(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function uu(e){return JSON.stringify(e)}function H_(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Ph="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function gi(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const W_=Vs(()=>{var e;if(typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)!=null&&e.includes("Cloudflare")))return!1;try{const t=Function;return new t(""),!0}catch{return!1}});function Sr(e){if(gi(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(gi(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Dh(e){return Sr(e)?{...e}:Array.isArray(e)?[...e]:e}const q_=new Set(["string","number","symbol"]);function jr(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Cn(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n!=null&&n.parent)&&(r._zod.parent=e),r}function he(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if((t==null?void 0:t.message)!==void 0){if((t==null?void 0:t.error)!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function G_(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const K_={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Y_(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const s=Nn(e._zod.def,{get shape(){const o={};for(const a in t){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&(o[a]=n.shape[a])}return Un(this,"shape",o),o},checks:[]});return Cn(e,s)}function X_(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const s=Nn(e._zod.def,{get shape(){const o={...e._zod.def.shape};for(const a in t){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&delete o[a]}return Un(this,"shape",o),o},checks:[]});return Cn(e,s)}function Q_(e,t){if(!Sr(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const s=e._zod.def.shape;for(const o in t)if(Object.getOwnPropertyDescriptor(s,o)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const i=Nn(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t};return Un(this,"shape",s),s}});return Cn(e,i)}function eN(e,t){if(!Sr(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=Nn(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return Un(this,"shape",r),r}});return Cn(e,n)}function tN(e,t){const n=Nn(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return Un(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:[]});return Cn(e,n)}function nN(e,t,n){const i=t._zod.def.checks;if(i&&i.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const o=Nn(t._zod.def,{get shape(){const a=t._zod.def.shape,c={...a};if(n)for(const u in n){if(!(u in a))throw new Error(`Unrecognized key: "${u}"`);n[u]&&(c[u]=e?new e({type:"optional",innerType:a[u]}):a[u])}else for(const u in a)c[u]=e?new e({type:"optional",innerType:a[u]}):a[u];return Un(this,"shape",c),c},checks:[]});return Cn(t,o)}function rN(e,t,n){const r=Nn(t._zod.def,{get shape(){const i=t._zod.def.shape,s={...i};if(n)for(const o in n){if(!(o in s))throw new Error(`Unrecognized key: "${o}"`);n[o]&&(s[o]=new e({type:"nonoptional",innerType:i[o]}))}else for(const o in i)s[o]=new e({type:"nonoptional",innerType:i[o]});return Un(this,"shape",s),s}});return Cn(t,r)}function or(e,t=0){var n;if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(((n=e.issues[r])==null?void 0:n.continue)!==!0)return!0;return!1}function ar(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function Zi(e){return typeof e=="string"?e:e==null?void 0:e.message}function jn(e,t,n){var i,s,o,a,c,u;const r={...e,path:e.path??[]};if(!e.message){const d=Zi((o=(s=(i=e.inst)==null?void 0:i._zod.def)==null?void 0:s.error)==null?void 0:o.call(s,e))??Zi((a=t==null?void 0:t.error)==null?void 0:a.call(t,e))??Zi((c=n.customError)==null?void 0:c.call(n,e))??Zi((u=n.localeError)==null?void 0:u.call(n,e))??"Invalid input";r.message=d}return delete r.inst,delete r.continue,t!=null&&t.reportInput||delete r.input,r}function al(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function xi(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}const Rh=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,oa,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},$h=q("$ZodError",Rh),Mh=q("$ZodError",Rh,{Parent:Error});function iN(e,t=n=>n.message){const n={},r=[];for(const i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function sN(e,t=n=>n.message){const n={_errors:[]},r=i=>{for(const s of i.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(o=>r({issues:o}));else if(s.code==="invalid_key")r({issues:s.issues});else if(s.code==="invalid_element")r({issues:s.issues});else if(s.path.length===0)n._errors.push(t(s));else{let o=n,a=0;for(;a<s.path.length;){const c=s.path[a];a===s.path.length-1?(o[c]=o[c]||{_errors:[]},o[c]._errors.push(t(s))):o[c]=o[c]||{_errors:[]},o=o[c],a++}}};return r(e),n}const ll=e=>(t,n,r,i)=>{const s=r?Object.assign(r,{async:!1}):{async:!1},o=t._zod.run({value:n,issues:[]},s);if(o instanceof Promise)throw new mr;if(o.issues.length){const a=new((i==null?void 0:i.Err)??e)(o.issues.map(c=>jn(c,s,Sn())));throw Ph(a,i==null?void 0:i.callee),a}return o.value},cl=e=>async(t,n,r,i)=>{const s=r?Object.assign(r,{async:!0}):{async:!0};let o=t._zod.run({value:n,issues:[]},s);if(o instanceof Promise&&(o=await o),o.issues.length){const a=new((i==null?void 0:i.Err)??e)(o.issues.map(c=>jn(c,s,Sn())));throw Ph(a,i==null?void 0:i.callee),a}return o.value},Us=e=>(t,n,r)=>{const i=r?{...r,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw new mr;return s.issues.length?{success:!1,error:new(e??$h)(s.issues.map(o=>jn(o,i,Sn())))}:{success:!0,data:s.value}},oN=Us(Mh),Js=e=>async(t,n,r)=>{const i=r?Object.assign(r,{async:!0}):{async:!0};let s=t._zod.run({value:n,issues:[]},i);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(o=>jn(o,i,Sn())))}:{success:!0,data:s.value}},aN=Js(Mh),lN=e=>(t,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return ll(e)(t,n,i)},cN=e=>(t,n,r)=>ll(e)(t,n,r),uN=e=>async(t,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return cl(e)(t,n,i)},dN=e=>async(t,n,r)=>cl(e)(t,n,r),fN=e=>(t,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Us(e)(t,n,i)},pN=e=>(t,n,r)=>Us(e)(t,n,r),hN=e=>async(t,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Js(e)(t,n,i)},mN=e=>async(t,n,r)=>Js(e)(t,n,r),gN=/^[cC][^\s-]{8,}$/,xN=/^[0-9a-z]+$/,yN=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,bN=/^[0-9a-vA-V]{20}$/,vN=/^[A-Za-z0-9]{27}$/,wN=/^[a-zA-Z0-9_-]{21}$/,kN=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,SN=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,du=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,jN=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,_N="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function NN(){return new RegExp(_N,"u")}const CN=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,EN=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,TN=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,IN=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,AN=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Fh=/^[A-Za-z0-9_-]*$/,zN=/^\+[1-9]\d{6,14}$/,Lh="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",ON=new RegExp(`^${Lh}$`);function Bh(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function PN(e){return new RegExp(`^${Bh(e)}$`)}function DN(e){const t=Bh({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${t}(?:${n.join("|")})`;return new RegExp(`^${Lh}T(?:${r})$`)}const RN=e=>{const t=e?`[\\s\\S]{${(e==null?void 0:e.minimum)??0},${(e==null?void 0:e.maximum)??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},$N=/^-?\d+$/,Zh=/^-?\d+(?:\.\d+)?$/,MN=/^(?:true|false)$/i,FN=/^null$/i,LN=/^[^A-Z]*$/,BN=/^[^a-z]*$/,Nt=q("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Vh={number:"number",bigint:"bigint",object:"date"},Uh=q("$ZodCheckLessThan",(e,t)=>{Nt.init(e,t);const n=Vh[typeof t.value];e._zod.onattach.push(r=>{const i=r._zod.bag,s=(t.inclusive?i.maximum:i.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<s&&(t.inclusive?i.maximum=t.value:i.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Jh=q("$ZodCheckGreaterThan",(e,t)=>{Nt.init(e,t);const n=Vh[typeof t.value];e._zod.onattach.push(r=>{const i=r._zod.bag,s=(t.inclusive?i.minimum:i.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>s&&(t.inclusive?i.minimum=t.value:i.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ZN=q("$ZodCheckMultipleOf",(e,t)=>{Nt.init(e,t),e._zod.onattach.push(n=>{var r;(r=n._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):J_(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),VN=q("$ZodCheckNumberFormat",(e,t)=>{var o;Nt.init(e,t),t.format=t.format||"float64";const n=(o=t.format)==null?void 0:o.includes("int"),r=n?"int":"number",[i,s]=K_[t.format];e._zod.onattach.push(a=>{const c=a._zod.bag;c.format=t.format,c.minimum=i,c.maximum=s,n&&(c.pattern=$N)}),e._zod.check=a=>{const c=a.value;if(n){if(!Number.isInteger(c)){a.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:c,inst:e});return}if(!Number.isSafeInteger(c)){c>0?a.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}):a.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}c<i&&a.issues.push({origin:"number",input:c,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort}),c>s&&a.issues.push({origin:"number",input:c,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}}),UN=q("$ZodCheckMaxLength",(e,t)=>{var n;Nt.init(e,t),(n=e._zod.def).when??(n.when=r=>{const i=r.value;return!sl(i)&&i.length!==void 0}),e._zod.onattach.push(r=>{const i=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<i&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{const i=r.value;if(i.length<=t.maximum)return;const o=al(i);r.issues.push({origin:o,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),JN=q("$ZodCheckMinLength",(e,t)=>{var n;Nt.init(e,t),(n=e._zod.def).when??(n.when=r=>{const i=r.value;return!sl(i)&&i.length!==void 0}),e._zod.onattach.push(r=>{const i=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>i&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{const i=r.value;if(i.length>=t.minimum)return;const o=al(i);r.issues.push({origin:o,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),HN=q("$ZodCheckLengthEquals",(e,t)=>{var n;Nt.init(e,t),(n=e._zod.def).when??(n.when=r=>{const i=r.value;return!sl(i)&&i.length!==void 0}),e._zod.onattach.push(r=>{const i=r._zod.bag;i.minimum=t.length,i.maximum=t.length,i.length=t.length}),e._zod.check=r=>{const i=r.value,s=i.length;if(s===t.length)return;const o=al(i),a=s>t.length;r.issues.push({origin:o,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),Hs=q("$ZodCheckStringFormat",(e,t)=>{var n,r;Nt.init(e,t),e._zod.onattach.push(i=>{const s=i._zod.bag;s.format=t.format,t.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=i=>{t.pattern.lastIndex=0,!t.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:t.format,input:i.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),WN=q("$ZodCheckRegex",(e,t)=>{Hs.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),qN=q("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=LN),Hs.init(e,t)}),GN=q("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=BN),Hs.init(e,t)}),KN=q("$ZodCheckIncludes",(e,t)=>{Nt.init(e,t);const n=jr(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(i=>{const s=i._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),e._zod.check=i=>{i.value.includes(t.includes,t.position)||i.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:i.value,inst:e,continue:!t.abort})}}),YN=q("$ZodCheckStartsWith",(e,t)=>{Nt.init(e,t);const n=new RegExp(`^${jr(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),XN=q("$ZodCheckEndsWith",(e,t)=>{Nt.init(e,t);const n=new RegExp(`.*${jr(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),QN=q("$ZodCheckOverwrite",(e,t)=>{Nt.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class eC{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const r=t.split(`
|
|
179
|
+
`).filter(o=>o),i=Math.min(...r.map(o=>o.length-o.trimStart().length)),s=r.map(o=>o.slice(i)).map(o=>" ".repeat(this.indent*2)+o);for(const o of s)this.content.push(o)}compile(){const t=Function,n=this==null?void 0:this.args,i=[...((this==null?void 0:this.content)??[""]).map(s=>` ${s}`)];return new t(...n,i.join(`
|
|
180
|
+
`))}}const tC={major:4,minor:3,patch:6},qe=q("$ZodType",(e,t)=>{var i;var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=tC;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const s of r)for(const o of s._zod.onattach)o(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),(i=e._zod.deferred)==null||i.push(()=>{e._zod.run=e._zod.parse});else{const s=(a,c,u)=>{let d=or(a),f;for(const h of c){if(h._zod.def.when){if(!h._zod.def.when(a))continue}else if(d)continue;const p=a.issues.length,m=h._zod.check(a);if(m instanceof Promise&&(u==null?void 0:u.async)===!1)throw new mr;if(f||m instanceof Promise)f=(f??Promise.resolve()).then(async()=>{await m,a.issues.length!==p&&(d||(d=or(a,p)))});else{if(a.issues.length===p)continue;d||(d=or(a,p))}}return f?f.then(()=>a):a},o=(a,c,u)=>{if(or(a))return a.aborted=!0,a;const d=s(c,r,u);if(d instanceof Promise){if(u.async===!1)throw new mr;return d.then(f=>e._zod.parse(f,u))}return e._zod.parse(d,u)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){const d=e._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});return d instanceof Promise?d.then(f=>o(f,a,c)):o(d,a,c)}const u=e._zod.parse(a,c);if(u instanceof Promise){if(c.async===!1)throw new mr;return u.then(d=>s(d,r,c))}return s(u,r,c)}}ze(e,"~standard",()=>({validate:s=>{var o;try{const a=oN(e,s);return a.success?{value:a.data}:{issues:(o=a.error)==null?void 0:o.issues}}catch{return aN(e,s).then(c=>{var u;return c.success?{value:c.data}:{issues:(u=c.error)==null?void 0:u.issues}})}},vendor:"zod",version:1}))}),ul=q("$ZodString",(e,t)=>{var n;qe.init(e,t),e._zod.pattern=[...((n=e==null?void 0:e._zod.bag)==null?void 0:n.patterns)??[]].pop()??RN(e._zod.bag),e._zod.parse=(r,i)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),Ke=q("$ZodStringFormat",(e,t)=>{Hs.init(e,t),ul.init(e,t)}),nC=q("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=SN),Ke.init(e,t)}),rC=q("$ZodUUID",(e,t)=>{if(t.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=du(r))}else t.pattern??(t.pattern=du());Ke.init(e,t)}),iC=q("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=jN),Ke.init(e,t)}),sC=q("$ZodURL",(e,t)=>{Ke.init(e,t),e._zod.check=n=>{try{const r=n.value.trim(),i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=i.href:n.value=r;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),oC=q("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=NN()),Ke.init(e,t)}),aC=q("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=wN),Ke.init(e,t)}),lC=q("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=gN),Ke.init(e,t)}),cC=q("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=xN),Ke.init(e,t)}),uC=q("$ZodULID",(e,t)=>{t.pattern??(t.pattern=yN),Ke.init(e,t)}),dC=q("$ZodXID",(e,t)=>{t.pattern??(t.pattern=bN),Ke.init(e,t)}),fC=q("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=vN),Ke.init(e,t)}),pC=q("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=DN(t)),Ke.init(e,t)}),hC=q("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=ON),Ke.init(e,t)}),mC=q("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=PN(t)),Ke.init(e,t)}),gC=q("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=kN),Ke.init(e,t)}),xC=q("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=CN),Ke.init(e,t),e._zod.bag.format="ipv4"}),yC=q("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=EN),Ke.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),bC=q("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=TN),Ke.init(e,t)}),vC=q("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=IN),Ke.init(e,t),e._zod.check=n=>{const r=n.value.split("/");try{if(r.length!==2)throw new Error;const[i,s]=r;if(!s)throw new Error;const o=Number(s);if(`${o}`!==s)throw new Error;if(o<0||o>128)throw new Error;new URL(`http://[${i}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function Hh(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const wC=q("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=AN),Ke.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{Hh(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function kC(e){if(!Fh.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return Hh(n)}const SC=q("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Fh),Ke.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{kC(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),jC=q("$ZodE164",(e,t)=>{t.pattern??(t.pattern=zN),Ke.init(e,t)});function _C(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[r]=n;if(!r)return!1;const i=JSON.parse(atob(r));return!("typ"in i&&(i==null?void 0:i.typ)!=="JWT"||!i.alg||t&&(!("alg"in i)||i.alg!==t))}catch{return!1}}const NC=q("$ZodJWT",(e,t)=>{Ke.init(e,t),e._zod.check=n=>{_C(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),Wh=q("$ZodNumber",(e,t)=>{qe.init(e,t),e._zod.pattern=e._zod.bag.pattern??Zh,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const i=n.value;if(typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i))return n;const s=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:i,inst:e,...s?{received:s}:{}}),n}}),CC=q("$ZodNumberFormat",(e,t)=>{VN.init(e,t),Wh.init(e,t)}),EC=q("$ZodBoolean",(e,t)=>{qe.init(e,t),e._zod.pattern=MN,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}const i=n.value;return typeof i=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:e}),n}}),TC=q("$ZodNull",(e,t)=>{qe.init(e,t),e._zod.pattern=FN,e._zod.values=new Set([null]),e._zod.parse=(n,r)=>{const i=n.value;return i===null||n.issues.push({expected:"null",code:"invalid_type",input:i,inst:e}),n}}),IC=q("$ZodUnknown",(e,t)=>{qe.init(e,t),e._zod.parse=n=>n}),AC=q("$ZodNever",(e,t)=>{qe.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function fu(e,t,n){e.issues.length&&t.issues.push(...ar(n,e.issues)),t.value[n]=e.value}const zC=q("$ZodArray",(e,t)=>{qe.init(e,t),e._zod.parse=(n,r)=>{const i=n.value;if(!Array.isArray(i))return n.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),n;n.value=Array(i.length);const s=[];for(let o=0;o<i.length;o++){const a=i[o],c=t.element._zod.run({value:a,issues:[]},r);c instanceof Promise?s.push(c.then(u=>fu(u,n,o))):fu(c,n,o)}return s.length?Promise.all(s).then(()=>n):n}});function ms(e,t,n,r,i){if(e.issues.length){if(i&&!(n in r))return;t.issues.push(...ar(n,e.issues))}e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function qh(e){var r,i,s,o;const t=Object.keys(e.shape);for(const a of t)if(!((o=(s=(i=(r=e.shape)==null?void 0:r[a])==null?void 0:i._zod)==null?void 0:s.traits)!=null&&o.has("$ZodType")))throw new Error(`Invalid element at key "${a}": expected a Zod schema`);const n=G_(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Gh(e,t,n,r,i,s){const o=[],a=i.keySet,c=i.catchall._zod,u=c.def.type,d=c.optout==="optional";for(const f in t){if(a.has(f))continue;if(u==="never"){o.push(f);continue}const h=c.run({value:t[f],issues:[]},r);h instanceof Promise?e.push(h.then(p=>ms(p,n,f,t,d))):ms(h,n,f,t,d)}return o.length&&n.issues.push({code:"unrecognized_keys",keys:o,input:t,inst:s}),e.length?Promise.all(e).then(()=>n):n}const OC=q("$ZodObject",(e,t)=>{qe.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape");if(!(n!=null&&n.get)){const a=t.shape;Object.defineProperty(t,"shape",{get:()=>{const c={...a};return Object.defineProperty(t,"shape",{value:c}),c}})}const r=Vs(()=>qh(t));ze(e._zod,"propValues",()=>{const a=t.shape,c={};for(const u in a){const d=a[u]._zod;if(d.values){c[u]??(c[u]=new Set);for(const f of d.values)c[u].add(f)}}return c});const i=gi,s=t.catchall;let o;e._zod.parse=(a,c)=>{o??(o=r.value);const u=a.value;if(!i(u))return a.issues.push({expected:"object",code:"invalid_type",input:u,inst:e}),a;a.value={};const d=[],f=o.shape;for(const h of o.keys){const p=f[h],m=p._zod.optout==="optional",v=p._zod.run({value:u[h],issues:[]},c);v instanceof Promise?d.push(v.then(k=>ms(k,a,h,u,m))):ms(v,a,h,u,m)}return s?Gh(d,u,a,c,r.value,e):d.length?Promise.all(d).then(()=>a):a}}),PC=q("$ZodObjectJIT",(e,t)=>{OC.init(e,t);const n=e._zod.parse,r=Vs(()=>qh(t)),i=h=>{var x;const p=new eC(["shape","payload","ctx"]),m=r.value,v=A=>{const E=uu(A);return`shape[${E}]._zod.run({ value: input[${E}], issues: [] }, ctx)`};p.write("const input = payload.value;");const k=Object.create(null);let y=0;for(const A of m.keys)k[A]=`key_${y++}`;p.write("const newResult = {};");for(const A of m.keys){const E=k[A],w=uu(A),S=h[A],O=((x=S==null?void 0:S._zod)==null?void 0:x.optout)==="optional";p.write(`const ${E} = ${v(A)};`),O?p.write(`
|
|
181
|
+
if (${E}.issues.length) {
|
|
182
|
+
if (${w} in input) {
|
|
183
|
+
payload.issues = payload.issues.concat(${E}.issues.map(iss => ({
|
|
184
|
+
...iss,
|
|
185
|
+
path: iss.path ? [${w}, ...iss.path] : [${w}]
|
|
186
|
+
})));
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
if (${E}.value === undefined) {
|
|
191
|
+
if (${w} in input) {
|
|
192
|
+
newResult[${w}] = undefined;
|
|
193
|
+
}
|
|
194
|
+
} else {
|
|
195
|
+
newResult[${w}] = ${E}.value;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
`):p.write(`
|
|
199
|
+
if (${E}.issues.length) {
|
|
200
|
+
payload.issues = payload.issues.concat(${E}.issues.map(iss => ({
|
|
201
|
+
...iss,
|
|
202
|
+
path: iss.path ? [${w}, ...iss.path] : [${w}]
|
|
203
|
+
})));
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
if (${E}.value === undefined) {
|
|
207
|
+
if (${w} in input) {
|
|
208
|
+
newResult[${w}] = undefined;
|
|
209
|
+
}
|
|
210
|
+
} else {
|
|
211
|
+
newResult[${w}] = ${E}.value;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
`)}p.write("payload.value = newResult;"),p.write("return payload;");const _=p.compile();return(A,E)=>_(h,A,E)};let s;const o=gi,a=!zh.jitless,u=a&&W_.value,d=t.catchall;let f;e._zod.parse=(h,p)=>{f??(f=r.value);const m=h.value;return o(m)?a&&u&&(p==null?void 0:p.async)===!1&&p.jitless!==!0?(s||(s=i(t.shape)),h=s(h,p),d?Gh([],m,h,p,f,e):h):n(h,p):(h.issues.push({expected:"object",code:"invalid_type",input:m,inst:e}),h)}});function pu(e,t,n,r){for(const s of e)if(s.issues.length===0)return t.value=s.value,t;const i=e.filter(s=>!or(s));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(s=>s.issues.map(o=>jn(o,r,Sn())))}),t)}const Kh=q("$ZodUnion",(e,t)=>{qe.init(e,t),ze(e._zod,"optin",()=>t.options.some(i=>i._zod.optin==="optional")?"optional":void 0),ze(e._zod,"optout",()=>t.options.some(i=>i._zod.optout==="optional")?"optional":void 0),ze(e._zod,"values",()=>{if(t.options.every(i=>i._zod.values))return new Set(t.options.flatMap(i=>Array.from(i._zod.values)))}),ze(e._zod,"pattern",()=>{if(t.options.every(i=>i._zod.pattern)){const i=t.options.map(s=>s._zod.pattern);return new RegExp(`^(${i.map(s=>ol(s.source)).join("|")})$`)}});const n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(i,s)=>{if(n)return r(i,s);let o=!1;const a=[];for(const c of t.options){const u=c._zod.run({value:i.value,issues:[]},s);if(u instanceof Promise)a.push(u),o=!0;else{if(u.issues.length===0)return u;a.push(u)}}return o?Promise.all(a).then(c=>pu(c,i,e,s)):pu(a,i,e,s)}}),DC=q("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Kh.init(e,t);const n=e._zod.parse;ze(e._zod,"propValues",()=>{const i={};for(const s of t.options){const o=s._zod.propValues;if(!o||Object.keys(o).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(const[a,c]of Object.entries(o)){i[a]||(i[a]=new Set);for(const u of c)i[a].add(u)}}return i});const r=Vs(()=>{var o;const i=t.options,s=new Map;for(const a of i){const c=(o=a._zod.propValues)==null?void 0:o[t.discriminator];if(!c||c.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(a)}"`);for(const u of c){if(s.has(u))throw new Error(`Duplicate discriminator value "${String(u)}"`);s.set(u,a)}}return s});e._zod.parse=(i,s)=>{const o=i.value;if(!gi(o))return i.issues.push({code:"invalid_type",expected:"object",input:o,inst:e}),i;const a=r.value.get(o==null?void 0:o[t.discriminator]);return a?a._zod.run(i,s):t.unionFallback?n(i,s):(i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:o,path:[t.discriminator],inst:e}),i)}}),RC=q("$ZodIntersection",(e,t)=>{qe.init(e,t),e._zod.parse=(n,r)=>{const i=n.value,s=t.left._zod.run({value:i,issues:[]},r),o=t.right._zod.run({value:i,issues:[]},r);return s instanceof Promise||o instanceof Promise?Promise.all([s,o]).then(([c,u])=>hu(n,c,u)):hu(n,s,o)}});function aa(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Sr(e)&&Sr(t)){const n=Object.keys(t),r=Object.keys(e).filter(s=>n.indexOf(s)!==-1),i={...e,...t};for(const s of r){const o=aa(e[s],t[s]);if(!o.valid)return{valid:!1,mergeErrorPath:[s,...o.mergeErrorPath]};i[s]=o.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const i=e[r],s=t[r],o=aa(i,s);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function hu(e,t,n){const r=new Map;let i;for(const a of t.issues)if(a.code==="unrecognized_keys"){i??(i=a);for(const c of a.keys)r.has(c)||r.set(c,{}),r.get(c).l=!0}else e.issues.push(a);for(const a of n.issues)if(a.code==="unrecognized_keys")for(const c of a.keys)r.has(c)||r.set(c,{}),r.get(c).r=!0;else e.issues.push(a);const s=[...r].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(s.length&&i&&e.issues.push({...i,keys:s}),or(e))return e;const o=aa(t.value,n.value);if(!o.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}const $C=q("$ZodRecord",(e,t)=>{qe.init(e,t),e._zod.parse=(n,r)=>{const i=n.value;if(!Sr(i))return n.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),n;const s=[],o=t.keyType._zod.values;if(o){n.value={};const a=new Set;for(const u of o)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){a.add(typeof u=="number"?u.toString():u);const d=t.valueType._zod.run({value:i[u],issues:[]},r);d instanceof Promise?s.push(d.then(f=>{f.issues.length&&n.issues.push(...ar(u,f.issues)),n.value[u]=f.value})):(d.issues.length&&n.issues.push(...ar(u,d.issues)),n.value[u]=d.value)}let c;for(const u in i)a.has(u)||(c=c??[],c.push(u));c&&c.length>0&&n.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:c})}else{n.value={};for(const a of Reflect.ownKeys(i)){if(a==="__proto__")continue;let c=t.keyType._zod.run({value:a,issues:[]},r);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&Zh.test(a)&&c.issues.length){const f=t.keyType._zod.run({value:Number(a),issues:[]},r);if(f instanceof Promise)throw new Error("Async schemas not supported in object keys currently");f.issues.length===0&&(c=f)}if(c.issues.length){t.mode==="loose"?n.value[a]=i[a]:n.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(f=>jn(f,r,Sn())),input:a,path:[a],inst:e});continue}const d=t.valueType._zod.run({value:i[a],issues:[]},r);d instanceof Promise?s.push(d.then(f=>{f.issues.length&&n.issues.push(...ar(a,f.issues)),n.value[c.value]=f.value})):(d.issues.length&&n.issues.push(...ar(a,d.issues)),n.value[c.value]=d.value)}}return s.length?Promise.all(s).then(()=>n):n}}),MC=q("$ZodEnum",(e,t)=>{qe.init(e,t);const n=Oh(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(i=>q_.has(typeof i)).map(i=>typeof i=="string"?jr(i):i.toString()).join("|")})$`),e._zod.parse=(i,s)=>{const o=i.value;return r.has(o)||i.issues.push({code:"invalid_value",values:n,input:o,inst:e}),i}}),FC=q("$ZodLiteral",(e,t)=>{if(qe.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(r=>typeof r=="string"?jr(r):r?jr(r.toString()):String(r)).join("|")})$`),e._zod.parse=(r,i)=>{const s=r.value;return n.has(s)||r.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),r}}),LC=q("$ZodTransform",(e,t)=>{qe.init(e,t),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Ah(e.constructor.name);const i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(o=>(n.value=o,n));if(i instanceof Promise)throw new mr;return n.value=i,n}});function mu(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const Yh=q("$ZodOptional",(e,t)=>{qe.init(e,t),e._zod.optin="optional",e._zod.optout="optional",ze(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),ze(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${ol(n.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(t.innerType._zod.optin==="optional"){const i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(s=>mu(s,n.value)):mu(i,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,r)}}),BC=q("$ZodExactOptional",(e,t)=>{Yh.init(e,t),ze(e._zod,"values",()=>t.innerType._zod.values),ze(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),ZC=q("$ZodNullable",(e,t)=>{qe.init(e,t),ze(e._zod,"optin",()=>t.innerType._zod.optin),ze(e._zod,"optout",()=>t.innerType._zod.optout),ze(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${ol(n.source)}|null)$`):void 0}),ze(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)}),VC=q("$ZodDefault",(e,t)=>{qe.init(e,t),e._zod.optin="optional",ze(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;const i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(s=>gu(s,t)):gu(i,t)}});function gu(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const UC=q("$ZodPrefault",(e,t)=>{qe.init(e,t),e._zod.optin="optional",ze(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,r))}),JC=q("$ZodNonOptional",(e,t)=>{qe.init(e,t),ze(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(r=>r!==void 0)):void 0}),e._zod.parse=(n,r)=>{const i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(s=>xu(s,e)):xu(i,e)}});function xu(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const HC=q("$ZodCatch",(e,t)=>{qe.init(e,t),ze(e._zod,"optin",()=>t.innerType._zod.optin),ze(e._zod,"optout",()=>t.innerType._zod.optout),ze(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(s=>(n.value=s.value,s.issues.length&&(n.value=t.catchValue({...n,error:{issues:s.issues.map(o=>jn(o,r,Sn()))},input:n.value}),n.issues=[]),n)):(n.value=i.value,i.issues.length&&(n.value=t.catchValue({...n,error:{issues:i.issues.map(s=>jn(s,r,Sn()))},input:n.value}),n.issues=[]),n)}}),WC=q("$ZodPipe",(e,t)=>{qe.init(e,t),ze(e._zod,"values",()=>t.in._zod.values),ze(e._zod,"optin",()=>t.in._zod.optin),ze(e._zod,"optout",()=>t.out._zod.optout),ze(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){const s=t.out._zod.run(n,r);return s instanceof Promise?s.then(o=>Vi(o,t.in,r)):Vi(s,t.in,r)}const i=t.in._zod.run(n,r);return i instanceof Promise?i.then(s=>Vi(s,t.out,r)):Vi(i,t.out,r)}});function Vi(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const qC=q("$ZodReadonly",(e,t)=>{qe.init(e,t),ze(e._zod,"propValues",()=>t.innerType._zod.propValues),ze(e._zod,"values",()=>t.innerType._zod.values),ze(e._zod,"optin",()=>{var n,r;return(r=(n=t.innerType)==null?void 0:n._zod)==null?void 0:r.optin}),ze(e._zod,"optout",()=>{var n,r;return(r=(n=t.innerType)==null?void 0:n._zod)==null?void 0:r.optout}),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(yu):yu(i)}});function yu(e){return e.value=Object.freeze(e.value),e}const GC=q("$ZodLazy",(e,t)=>{qe.init(e,t),ze(e._zod,"innerType",()=>t.getter()),ze(e._zod,"pattern",()=>{var n,r;return(r=(n=e._zod.innerType)==null?void 0:n._zod)==null?void 0:r.pattern}),ze(e._zod,"propValues",()=>{var n,r;return(r=(n=e._zod.innerType)==null?void 0:n._zod)==null?void 0:r.propValues}),ze(e._zod,"optin",()=>{var n,r;return((r=(n=e._zod.innerType)==null?void 0:n._zod)==null?void 0:r.optin)??void 0}),ze(e._zod,"optout",()=>{var n,r;return((r=(n=e._zod.innerType)==null?void 0:n._zod)==null?void 0:r.optout)??void 0}),e._zod.parse=(n,r)=>e._zod.innerType._zod.run(n,r)}),KC=q("$ZodCustom",(e,t)=>{Nt.init(e,t),qe.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(s=>bu(s,n,r,e));bu(i,n,r,e)}});function bu(e,t,n,r){if(!e){const i={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(i.params=r._zod.def.params),t.issues.push(xi(i))}}var vu;class YC{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const r=n[0];return this._map.set(t,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const r={...this.get(n)??{}};delete r.id;const i={...r,...this._map.get(t)};return Object.keys(i).length?i:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function XC(){return new YC}(vu=globalThis).__zod_globalRegistry??(vu.__zod_globalRegistry=XC());const qr=globalThis.__zod_globalRegistry;function QC(e,t){return new e({type:"string",...he(t)})}function eE(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...he(t)})}function wu(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...he(t)})}function tE(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...he(t)})}function nE(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...he(t)})}function rE(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...he(t)})}function iE(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...he(t)})}function sE(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...he(t)})}function oE(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...he(t)})}function aE(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...he(t)})}function lE(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...he(t)})}function cE(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...he(t)})}function uE(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...he(t)})}function dE(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...he(t)})}function fE(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...he(t)})}function pE(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...he(t)})}function hE(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...he(t)})}function mE(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...he(t)})}function gE(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...he(t)})}function xE(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...he(t)})}function yE(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...he(t)})}function bE(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...he(t)})}function vE(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...he(t)})}function wE(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...he(t)})}function kE(e,t){return new e({type:"string",format:"date",check:"string_format",...he(t)})}function SE(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...he(t)})}function jE(e,t){return new e({type:"string",format:"duration",check:"string_format",...he(t)})}function _E(e,t){return new e({type:"number",checks:[],...he(t)})}function NE(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...he(t)})}function CE(e,t){return new e({type:"boolean",...he(t)})}function EE(e,t){return new e({type:"null",...he(t)})}function TE(e){return new e({type:"unknown"})}function IE(e,t){return new e({type:"never",...he(t)})}function ku(e,t){return new Uh({check:"less_than",...he(t),value:e,inclusive:!1})}function jo(e,t){return new Uh({check:"less_than",...he(t),value:e,inclusive:!0})}function Su(e,t){return new Jh({check:"greater_than",...he(t),value:e,inclusive:!1})}function _o(e,t){return new Jh({check:"greater_than",...he(t),value:e,inclusive:!0})}function ju(e,t){return new ZN({check:"multiple_of",...he(t),value:e})}function Xh(e,t){return new UN({check:"max_length",...he(t),maximum:e})}function gs(e,t){return new JN({check:"min_length",...he(t),minimum:e})}function Qh(e,t){return new HN({check:"length_equals",...he(t),length:e})}function AE(e,t){return new WN({check:"string_format",format:"regex",...he(t),pattern:e})}function zE(e){return new qN({check:"string_format",format:"lowercase",...he(e)})}function OE(e){return new GN({check:"string_format",format:"uppercase",...he(e)})}function PE(e,t){return new KN({check:"string_format",format:"includes",...he(t),includes:e})}function DE(e,t){return new YN({check:"string_format",format:"starts_with",...he(t),prefix:e})}function RE(e,t){return new XN({check:"string_format",format:"ends_with",...he(t),suffix:e})}function Ar(e){return new QN({check:"overwrite",tx:e})}function $E(e){return Ar(t=>t.normalize(e))}function ME(){return Ar(e=>e.trim())}function FE(){return Ar(e=>e.toLowerCase())}function LE(){return Ar(e=>e.toUpperCase())}function BE(){return Ar(e=>H_(e))}function ZE(e,t,n){return new e({type:"array",element:t,...he(n)})}function VE(e,t,n){const r=he(n);return r.abort??(r.abort=!0),new e({type:"custom",check:"custom",fn:t,...r})}function UE(e,t,n){return new e({type:"custom",check:"custom",fn:t,...he(n)})}function JE(e){const t=HE(n=>(n.addIssue=r=>{if(typeof r=="string")n.issues.push(xi(r,n.value,t._zod.def));else{const i=r;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=n.value),i.inst??(i.inst=t),i.continue??(i.continue=!t._zod.def.abort),n.issues.push(xi(i))}},e(n.value,n)));return t}function HE(e,t){const n=new Nt({check:"custom",...he(t)});return n._zod.check=e,n}function xs(e){let t=(e==null?void 0:e.target)??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:(e==null?void 0:e.metadata)??qr,target:t,unrepresentable:(e==null?void 0:e.unrepresentable)??"throw",override:(e==null?void 0:e.override)??(()=>{}),io:(e==null?void 0:e.io)??"output",counter:0,seen:new Map,cycles:(e==null?void 0:e.cycles)??"ref",reused:(e==null?void 0:e.reused)??"inline",external:(e==null?void 0:e.external)??void 0}}function Ue(e,t,n={path:[],schemaPath:[]}){var d,f;var r;const i=e._zod.def,s=t.seen.get(e);if(s)return s.count++,n.schemaPath.includes(e)&&(s.cycle=n.path),s.schema;const o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);const a=(f=(d=e._zod).toJSONSchema)==null?void 0:f.call(d);if(a)o.schema=a;else{const h={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,h);else{const m=o.schema,v=t.processors[i.type];if(!v)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);v(e,t,m,h)}const p=e._zod.parent;p&&(o.ref||(o.ref=p),Ue(p,t,h),t.seen.get(p).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io==="input"&&pt(e)&&(delete o.schema.examples,delete o.schema.default),t.io==="input"&&o.schema._prefault&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function ys(e,t){var o,a,c,u;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const d of e.seen.entries()){const f=(o=e.metadataRegistry.get(d[0]))==null?void 0:o.id;if(f){const h=r.get(f);if(h&&h!==d[0])throw new Error(`Duplicate schema id "${f}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(f,d[0])}}const i=d=>{var v;const f=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const k=(v=e.external.registry.get(d[0]))==null?void 0:v.id,y=e.external.uri??(x=>x);if(k)return{ref:y(k)};const _=d[1].defId??d[1].schema.id??`schema${e.counter++}`;return d[1].defId=_,{defId:_,ref:`${y("__shared")}#/${f}/${_}`}}if(d[1]===n)return{ref:"#"};const p=`#/${f}/`,m=d[1].schema.id??`__schema${e.counter++}`;return{defId:m,ref:p+m}},s=d=>{if(d[1].schema.$ref)return;const f=d[1],{ref:h,defId:p}=i(d);f.def={...f.schema},p&&(f.defId=p);const m=f.schema;for(const v in m)delete m[v];m.$ref=h};if(e.cycles==="throw")for(const d of e.seen.entries()){const f=d[1];if(f.cycle)throw new Error(`Cycle detected: #/${(a=f.cycle)==null?void 0:a.join("/")}/<root>
|
|
215
|
+
|
|
216
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const d of e.seen.entries()){const f=d[1];if(t===d[0]){s(d);continue}if(e.external){const p=(c=e.external.registry.get(d[0]))==null?void 0:c.id;if(t!==d[0]&&p){s(d);continue}}if((u=e.metadataRegistry.get(d[0]))==null?void 0:u.id){s(d);continue}if(f.cycle){s(d);continue}if(f.count>1&&e.reused==="ref"){s(d);continue}}}function bs(e,t){var o,a,c;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=u=>{const d=e.seen.get(u);if(d.ref===null)return;const f=d.def??d.schema,h={...f},p=d.ref;if(d.ref=null,p){r(p);const v=e.seen.get(p),k=v.schema;if(k.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(f.allOf=f.allOf??[],f.allOf.push(k)):Object.assign(f,k),Object.assign(f,h),u._zod.parent===p)for(const _ in f)_==="$ref"||_==="allOf"||_ in h||delete f[_];if(k.$ref&&v.def)for(const _ in f)_==="$ref"||_==="allOf"||_ in v.def&&JSON.stringify(f[_])===JSON.stringify(v.def[_])&&delete f[_]}const m=u._zod.parent;if(m&&m!==p){r(m);const v=e.seen.get(m);if(v!=null&&v.schema.$ref&&(f.$ref=v.schema.$ref,v.def))for(const k in f)k==="$ref"||k==="allOf"||k in v.def&&JSON.stringify(f[k])===JSON.stringify(v.def[k])&&delete f[k]}e.override({zodSchema:u,jsonSchema:f,path:d.path??[]})};for(const u of[...e.seen.entries()].reverse())r(u[0]);const i={};if(e.target==="draft-2020-12"?i.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?i.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?i.$schema="http://json-schema.org/draft-04/schema#":e.target,(o=e.external)!=null&&o.uri){const u=(a=e.external.registry.get(t))==null?void 0:a.id;if(!u)throw new Error("Schema is missing an `id` property");i.$id=e.external.uri(u)}Object.assign(i,n.def??n.schema);const s=((c=e.external)==null?void 0:c.defs)??{};for(const u of e.seen.entries()){const d=u[1];d.def&&d.defId&&(s[d.defId]=d.def)}e.external||Object.keys(s).length>0&&(e.target==="draft-2020-12"?i.$defs=s:i.definitions=s);try{const u=JSON.parse(JSON.stringify(i));return Object.defineProperty(u,"~standard",{value:{...t["~standard"],jsonSchema:{input:vs(t,"input",e.processors),output:vs(t,"output",e.processors)}},enumerable:!1,writable:!1}),u}catch{throw new Error("Error converting schema to JSON.")}}function pt(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return pt(r.element,n);if(r.type==="set")return pt(r.valueType,n);if(r.type==="lazy")return pt(r.getter(),n);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return pt(r.innerType,n);if(r.type==="intersection")return pt(r.left,n)||pt(r.right,n);if(r.type==="record"||r.type==="map")return pt(r.keyType,n)||pt(r.valueType,n);if(r.type==="pipe")return pt(r.in,n)||pt(r.out,n);if(r.type==="object"){for(const i in r.shape)if(pt(r.shape[i],n))return!0;return!1}if(r.type==="union"){for(const i of r.options)if(pt(i,n))return!0;return!1}if(r.type==="tuple"){for(const i of r.items)if(pt(i,n))return!0;return!!(r.rest&&pt(r.rest,n))}return!1}const WE=(e,t={})=>n=>{const r=xs({...n,processors:t});return Ue(e,r),ys(r,e),bs(r,e)},vs=(e,t,n={})=>r=>{const{libraryOptions:i,target:s}=r??{},o=xs({...i??{},target:s,io:t,processors:n});return Ue(e,o),ys(o,e),bs(o,e)},qE={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},em=(e,t,n,r)=>{const i=n;i.type="string";const{minimum:s,maximum:o,format:a,patterns:c,contentEncoding:u}=e._zod.bag;if(typeof s=="number"&&(i.minLength=s),typeof o=="number"&&(i.maxLength=o),a&&(i.format=qE[a]??a,i.format===""&&delete i.format,a==="time"&&delete i.format),u&&(i.contentEncoding=u),c&&c.size>0){const d=[...c];d.length===1?i.pattern=d[0].source:d.length>1&&(i.allOf=[...d.map(f=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))])}},tm=(e,t,n,r)=>{const i=n,{minimum:s,maximum:o,format:a,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:d}=e._zod.bag;typeof a=="string"&&a.includes("int")?i.type="integer":i.type="number",typeof d=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(i.minimum=d,i.exclusiveMinimum=!0):i.exclusiveMinimum=d),typeof s=="number"&&(i.minimum=s,typeof d=="number"&&t.target!=="draft-04"&&(d>=s?delete i.minimum:delete i.exclusiveMinimum)),typeof u=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(i.maximum=u,i.exclusiveMaximum=!0):i.exclusiveMaximum=u),typeof o=="number"&&(i.maximum=o,typeof u=="number"&&t.target!=="draft-04"&&(u<=o?delete i.maximum:delete i.exclusiveMaximum)),typeof c=="number"&&(i.multipleOf=c)},nm=(e,t,n,r)=>{n.type="boolean"},GE=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema")},KE=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema")},rm=(e,t,n,r)=>{t.target==="openapi-3.0"?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"},YE=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},XE=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema")},im=(e,t,n,r)=>{n.not={}},QE=(e,t,n,r)=>{},sm=(e,t,n,r)=>{},eT=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},om=(e,t,n,r)=>{const i=e._zod.def,s=Oh(i.entries);s.every(o=>typeof o=="number")&&(n.type="number"),s.every(o=>typeof o=="string")&&(n.type="string"),n.enum=s},am=(e,t,n,r)=>{const i=e._zod.def,s=[];for(const o of i.values)if(o===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof o=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");s.push(Number(o))}else s.push(o);if(s.length!==0)if(s.length===1){const o=s[0];n.type=o===null?"null":typeof o,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[o]:n.const=o}else s.every(o=>typeof o=="number")&&(n.type="number"),s.every(o=>typeof o=="string")&&(n.type="string"),s.every(o=>typeof o=="boolean")&&(n.type="boolean"),s.every(o=>o===null)&&(n.type="null"),n.enum=s},tT=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema")},nT=(e,t,n,r)=>{const i=n,s=e._zod.pattern;if(!s)throw new Error("Pattern not found in template literal");i.type="string",i.pattern=s.source},rT=(e,t,n,r)=>{const i=n,s={type:"string",format:"binary",contentEncoding:"binary"},{minimum:o,maximum:a,mime:c}=e._zod.bag;o!==void 0&&(s.minLength=o),a!==void 0&&(s.maxLength=a),c?c.length===1?(s.contentMediaType=c[0],Object.assign(i,s)):(Object.assign(i,s),i.anyOf=c.map(u=>({contentMediaType:u}))):Object.assign(i,s)},iT=(e,t,n,r)=>{n.type="boolean"},lm=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},sT=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Function types cannot be represented in JSON Schema")},cm=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},oT=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema")},aT=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema")},um=(e,t,n,r)=>{const i=n,s=e._zod.def,{minimum:o,maximum:a}=e._zod.bag;typeof o=="number"&&(i.minItems=o),typeof a=="number"&&(i.maxItems=a),i.type="array",i.items=Ue(s.element,t,{...r,path:[...r.path,"items"]})},dm=(e,t,n,r)=>{var u;const i=n,s=e._zod.def;i.type="object",i.properties={};const o=s.shape;for(const d in o)i.properties[d]=Ue(o[d],t,{...r,path:[...r.path,"properties",d]});const a=new Set(Object.keys(o)),c=new Set([...a].filter(d=>{const f=s.shape[d]._zod;return t.io==="input"?f.optin===void 0:f.optout===void 0}));c.size>0&&(i.required=Array.from(c)),((u=s.catchall)==null?void 0:u._zod.def.type)==="never"?i.additionalProperties=!1:s.catchall?s.catchall&&(i.additionalProperties=Ue(s.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(i.additionalProperties=!1)},fm=(e,t,n,r)=>{const i=e._zod.def,s=i.inclusive===!1,o=i.options.map((a,c)=>Ue(a,t,{...r,path:[...r.path,s?"oneOf":"anyOf",c]}));s?n.oneOf=o:n.anyOf=o},pm=(e,t,n,r)=>{const i=e._zod.def,s=Ue(i.left,t,{...r,path:[...r.path,"allOf",0]}),o=Ue(i.right,t,{...r,path:[...r.path,"allOf",1]}),a=u=>"allOf"in u&&Object.keys(u).length===1,c=[...a(s)?s.allOf:[s],...a(o)?o.allOf:[o]];n.allOf=c},lT=(e,t,n,r)=>{const i=n,s=e._zod.def;i.type="array";const o=t.target==="draft-2020-12"?"prefixItems":"items",a=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",c=s.items.map((h,p)=>Ue(h,t,{...r,path:[...r.path,o,p]})),u=s.rest?Ue(s.rest,t,{...r,path:[...r.path,a,...t.target==="openapi-3.0"?[s.items.length]:[]]}):null;t.target==="draft-2020-12"?(i.prefixItems=c,u&&(i.items=u)):t.target==="openapi-3.0"?(i.items={anyOf:c},u&&i.items.anyOf.push(u),i.minItems=c.length,u||(i.maxItems=c.length)):(i.items=c,u&&(i.additionalItems=u));const{minimum:d,maximum:f}=e._zod.bag;typeof d=="number"&&(i.minItems=d),typeof f=="number"&&(i.maxItems=f)},hm=(e,t,n,r)=>{const i=n,s=e._zod.def;i.type="object";const o=s.keyType,a=o._zod.bag,c=a==null?void 0:a.patterns;if(s.mode==="loose"&&c&&c.size>0){const d=Ue(s.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});i.patternProperties={};for(const f of c)i.patternProperties[f.source]=d}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(i.propertyNames=Ue(s.keyType,t,{...r,path:[...r.path,"propertyNames"]})),i.additionalProperties=Ue(s.valueType,t,{...r,path:[...r.path,"additionalProperties"]});const u=o._zod.values;if(u){const d=[...u].filter(f=>typeof f=="string"||typeof f=="number");d.length>0&&(i.required=d)}},mm=(e,t,n,r)=>{const i=e._zod.def,s=Ue(i.innerType,t,r),o=t.seen.get(e);t.target==="openapi-3.0"?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[s,{type:"null"}]},gm=(e,t,n,r)=>{const i=e._zod.def;Ue(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType},xm=(e,t,n,r)=>{const i=e._zod.def;Ue(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},ym=(e,t,n,r)=>{const i=e._zod.def;Ue(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},bm=(e,t,n,r)=>{const i=e._zod.def;Ue(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=o},vm=(e,t,n,r)=>{const i=e._zod.def,s=t.io==="input"?i.in._zod.def.type==="transform"?i.out:i.in:i.out;Ue(s,t,r);const o=t.seen.get(e);o.ref=s},wm=(e,t,n,r)=>{const i=e._zod.def;Ue(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType,n.readOnly=!0},cT=(e,t,n,r)=>{const i=e._zod.def;Ue(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType},dl=(e,t,n,r)=>{const i=e._zod.def;Ue(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType},km=(e,t,n,r)=>{const i=e._zod.innerType;Ue(i,t,r);const s=t.seen.get(e);s.ref=i},_u={string:em,number:tm,boolean:nm,bigint:GE,symbol:KE,null:rm,undefined:YE,void:XE,never:im,any:QE,unknown:sm,date:eT,enum:om,literal:am,nan:tT,template_literal:nT,file:rT,success:iT,custom:lm,function:sT,transform:cm,map:oT,set:aT,array:um,object:dm,union:fm,intersection:pm,tuple:lT,record:hm,nullable:mm,nonoptional:gm,default:xm,prefault:ym,catch:bm,pipe:vm,readonly:wm,promise:cT,optional:dl,lazy:km};function uT(e,t){if("_idmap"in e){const r=e,i=xs({...t,processors:_u}),s={};for(const c of r._idmap.entries()){const[u,d]=c;Ue(d,i)}const o={},a={registry:r,uri:t==null?void 0:t.uri,defs:s};i.external=a;for(const c of r._idmap.entries()){const[u,d]=c;ys(i,d),o[u]=bs(i,d)}if(Object.keys(s).length>0){const c=i.target==="draft-2020-12"?"$defs":"definitions";o.__shared={[c]:s}}return{schemas:o}}const n=xs({...t,processors:_u});return Ue(e,n),ys(n,e),bs(n,e)}const dT=q("ZodISODateTime",(e,t)=>{pC.init(e,t),et.init(e,t)});function fT(e){return wE(dT,e)}const pT=q("ZodISODate",(e,t)=>{hC.init(e,t),et.init(e,t)});function hT(e){return kE(pT,e)}const mT=q("ZodISOTime",(e,t)=>{mC.init(e,t),et.init(e,t)});function gT(e){return SE(mT,e)}const xT=q("ZodISODuration",(e,t)=>{gC.init(e,t),et.init(e,t)});function yT(e){return jE(xT,e)}const bT=(e,t)=>{$h.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>sN(e,n)},flatten:{value:n=>iN(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,oa,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,oa,2)}},isEmpty:{get(){return e.issues.length===0}}})},Ft=q("ZodError",bT,{Parent:Error}),vT=ll(Ft),wT=cl(Ft),kT=Us(Ft),Sm=Js(Ft),ST=lN(Ft),jT=cN(Ft),_T=uN(Ft),NT=dN(Ft),CT=fN(Ft),ET=pN(Ft),TT=hN(Ft),IT=mN(Ft),Ge=q("ZodType",(e,t)=>(qe.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:vs(e,"input"),output:vs(e,"output")}}),e.toJSONSchema=WE(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(Nn(t,{checks:[...t.checks??[],...n.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0}),e.with=e.check,e.clone=(n,r)=>Cn(e,n,r),e.brand=()=>e,e.register=(n,r)=>(n.add(e,r),e),e.parse=(n,r)=>vT(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>kT(e,n,r),e.parseAsync=async(n,r)=>wT(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>Sm(e,n,r),e.spa=e.safeParseAsync,e.encode=(n,r)=>ST(e,n,r),e.decode=(n,r)=>jT(e,n,r),e.encodeAsync=async(n,r)=>_T(e,n,r),e.decodeAsync=async(n,r)=>NT(e,n,r),e.safeEncode=(n,r)=>CT(e,n,r),e.safeDecode=(n,r)=>ET(e,n,r),e.safeEncodeAsync=async(n,r)=>TT(e,n,r),e.safeDecodeAsync=async(n,r)=>IT(e,n,r),e.refine=(n,r)=>e.check(NI(n,r)),e.superRefine=n=>e.check(CI(n)),e.overwrite=n=>e.check(Ar(n)),e.optional=()=>Eu(e),e.exactOptional=()=>fI(e),e.nullable=()=>Tu(e),e.nullish=()=>Eu(Tu(e)),e.nonoptional=n=>yI(e,n),e.array=()=>zr(e),e.or=n=>yt([e,n]),e.and=n=>oI(e,n),e.transform=n=>Iu(e,uI(n)),e.default=n=>mI(e,n),e.prefault=n=>xI(e,n),e.catch=n=>vI(e,n),e.pipe=n=>Iu(e,n),e.readonly=()=>SI(e),e.describe=n=>{const r=e.clone();return qr.add(r,{description:n}),r},Object.defineProperty(e,"description",{get(){var n;return(n=qr.get(e))==null?void 0:n.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return qr.get(e);const r=e.clone();return qr.add(r,n[0]),r},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=n=>n(e),e)),jm=q("_ZodString",(e,t)=>{ul.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(r,i,s)=>em(e,r,i);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...r)=>e.check(AE(...r)),e.includes=(...r)=>e.check(PE(...r)),e.startsWith=(...r)=>e.check(DE(...r)),e.endsWith=(...r)=>e.check(RE(...r)),e.min=(...r)=>e.check(gs(...r)),e.max=(...r)=>e.check(Xh(...r)),e.length=(...r)=>e.check(Qh(...r)),e.nonempty=(...r)=>e.check(gs(1,...r)),e.lowercase=r=>e.check(zE(r)),e.uppercase=r=>e.check(OE(r)),e.trim=()=>e.check(ME()),e.normalize=(...r)=>e.check($E(...r)),e.toLowerCase=()=>e.check(FE()),e.toUpperCase=()=>e.check(LE()),e.slugify=()=>e.check(BE())}),AT=q("ZodString",(e,t)=>{ul.init(e,t),jm.init(e,t),e.email=n=>e.check(eE(zT,n)),e.url=n=>e.check(sE(OT,n)),e.jwt=n=>e.check(vE(qT,n)),e.emoji=n=>e.check(oE(PT,n)),e.guid=n=>e.check(wu(Nu,n)),e.uuid=n=>e.check(tE(Ui,n)),e.uuidv4=n=>e.check(nE(Ui,n)),e.uuidv6=n=>e.check(rE(Ui,n)),e.uuidv7=n=>e.check(iE(Ui,n)),e.nanoid=n=>e.check(aE(DT,n)),e.guid=n=>e.check(wu(Nu,n)),e.cuid=n=>e.check(lE(RT,n)),e.cuid2=n=>e.check(cE($T,n)),e.ulid=n=>e.check(uE(MT,n)),e.base64=n=>e.check(xE(JT,n)),e.base64url=n=>e.check(yE(HT,n)),e.xid=n=>e.check(dE(FT,n)),e.ksuid=n=>e.check(fE(LT,n)),e.ipv4=n=>e.check(pE(BT,n)),e.ipv6=n=>e.check(hE(ZT,n)),e.cidrv4=n=>e.check(mE(VT,n)),e.cidrv6=n=>e.check(gE(UT,n)),e.e164=n=>e.check(bE(WT,n)),e.datetime=n=>e.check(fT(n)),e.date=n=>e.check(hT(n)),e.time=n=>e.check(gT(n)),e.duration=n=>e.check(yT(n))});function le(e){return QC(AT,e)}const et=q("ZodStringFormat",(e,t)=>{Ke.init(e,t),jm.init(e,t)}),zT=q("ZodEmail",(e,t)=>{iC.init(e,t),et.init(e,t)}),Nu=q("ZodGUID",(e,t)=>{nC.init(e,t),et.init(e,t)}),Ui=q("ZodUUID",(e,t)=>{rC.init(e,t),et.init(e,t)}),OT=q("ZodURL",(e,t)=>{sC.init(e,t),et.init(e,t)}),PT=q("ZodEmoji",(e,t)=>{oC.init(e,t),et.init(e,t)}),DT=q("ZodNanoID",(e,t)=>{aC.init(e,t),et.init(e,t)}),RT=q("ZodCUID",(e,t)=>{lC.init(e,t),et.init(e,t)}),$T=q("ZodCUID2",(e,t)=>{cC.init(e,t),et.init(e,t)}),MT=q("ZodULID",(e,t)=>{uC.init(e,t),et.init(e,t)}),FT=q("ZodXID",(e,t)=>{dC.init(e,t),et.init(e,t)}),LT=q("ZodKSUID",(e,t)=>{fC.init(e,t),et.init(e,t)}),BT=q("ZodIPv4",(e,t)=>{xC.init(e,t),et.init(e,t)}),ZT=q("ZodIPv6",(e,t)=>{yC.init(e,t),et.init(e,t)}),VT=q("ZodCIDRv4",(e,t)=>{bC.init(e,t),et.init(e,t)}),UT=q("ZodCIDRv6",(e,t)=>{vC.init(e,t),et.init(e,t)}),JT=q("ZodBase64",(e,t)=>{wC.init(e,t),et.init(e,t)}),HT=q("ZodBase64URL",(e,t)=>{SC.init(e,t),et.init(e,t)}),WT=q("ZodE164",(e,t)=>{jC.init(e,t),et.init(e,t)}),qT=q("ZodJWT",(e,t)=>{NC.init(e,t),et.init(e,t)}),_m=q("ZodNumber",(e,t)=>{Wh.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(r,i,s)=>tm(e,r,i),e.gt=(r,i)=>e.check(Su(r,i)),e.gte=(r,i)=>e.check(_o(r,i)),e.min=(r,i)=>e.check(_o(r,i)),e.lt=(r,i)=>e.check(ku(r,i)),e.lte=(r,i)=>e.check(jo(r,i)),e.max=(r,i)=>e.check(jo(r,i)),e.int=r=>e.check(Cu(r)),e.safe=r=>e.check(Cu(r)),e.positive=r=>e.check(Su(0,r)),e.nonnegative=r=>e.check(_o(0,r)),e.negative=r=>e.check(ku(0,r)),e.nonpositive=r=>e.check(jo(0,r)),e.multipleOf=(r,i)=>e.check(ju(r,i)),e.step=(r,i)=>e.check(ju(r,i)),e.finite=()=>e;const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function GT(e){return _E(_m,e)}const KT=q("ZodNumberFormat",(e,t)=>{CC.init(e,t),_m.init(e,t)});function Cu(e){return NE(KT,e)}const YT=q("ZodBoolean",(e,t)=>{EC.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,r,i)=>nm(e,n,r)});function ht(e){return CE(YT,e)}const XT=q("ZodNull",(e,t)=>{TC.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,r,i)=>rm(e,n,r)});function QT(e){return EE(XT,e)}const eI=q("ZodUnknown",(e,t)=>{IC.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,r,i)=>sm()});function Xt(){return TE(eI)}const tI=q("ZodNever",(e,t)=>{AC.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,r,i)=>im(e,n,r)});function Nm(e){return IE(tI,e)}const nI=q("ZodArray",(e,t)=>{zC.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,r,i)=>um(e,n,r,i),e.element=t.element,e.min=(n,r)=>e.check(gs(n,r)),e.nonempty=n=>e.check(gs(1,n)),e.max=(n,r)=>e.check(Xh(n,r)),e.length=(n,r)=>e.check(Qh(n,r)),e.unwrap=()=>e.element});function zr(e,t){return ZE(nI,e,t)}const Cm=q("ZodObject",(e,t)=>{PC.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,r,i)=>dm(e,n,r,i),ze(e,"shape",()=>t.shape),e.keyof=()=>Tm(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Xt()}),e.loose=()=>e.clone({...e._zod.def,catchall:Xt()}),e.strict=()=>e.clone({...e._zod.def,catchall:Nm()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>Q_(e,n),e.safeExtend=n=>eN(e,n),e.merge=n=>tN(e,n),e.pick=n=>Y_(e,n),e.omit=n=>X_(e,n),e.partial=(...n)=>nN(Im,e,n[0]),e.required=(...n)=>rN(Am,e,n[0])});function Be(e,t){const n={type:"object",shape:e??{},...he(t)};return new Cm(n)}function He(e,t){return new Cm({type:"object",shape:e,catchall:Nm(),...he(t)})}const Em=q("ZodUnion",(e,t)=>{Kh.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,r,i)=>fm(e,n,r,i),e.options=t.options});function yt(e,t){return new Em({type:"union",options:e,...he(t)})}const rI=q("ZodDiscriminatedUnion",(e,t)=>{Em.init(e,t),DC.init(e,t)});function iI(e,t,n){return new rI({type:"union",options:t,discriminator:e,...he(n)})}const sI=q("ZodIntersection",(e,t)=>{RC.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,r,i)=>pm(e,n,r,i)});function oI(e,t){return new sI({type:"intersection",left:e,right:t})}const aI=q("ZodRecord",(e,t)=>{$C.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,r,i)=>hm(e,n,r,i),e.keyType=t.keyType,e.valueType=t.valueType});function yi(e,t,n){return new aI({type:"record",keyType:e,valueType:t,...he(n)})}const la=q("ZodEnum",(e,t)=>{MC.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(r,i,s)=>om(e,r,i),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(r,i)=>{const s={};for(const o of r)if(n.has(o))s[o]=t.entries[o];else throw new Error(`Key ${o} not found in enum`);return new la({...t,checks:[],...he(i),entries:s})},e.exclude=(r,i)=>{const s={...t.entries};for(const o of r)if(n.has(o))delete s[o];else throw new Error(`Key ${o} not found in enum`);return new la({...t,checks:[],...he(i),entries:s})}});function Tm(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new la({type:"enum",entries:n,...he(t)})}const lI=q("ZodLiteral",(e,t)=>{FC.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,r,i)=>am(e,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function ve(e,t){return new lI({type:"literal",values:Array.isArray(e)?e:[e],...he(t)})}const cI=q("ZodTransform",(e,t)=>{LC.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,r,i)=>cm(e,n),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Ah(e.constructor.name);n.addIssue=s=>{if(typeof s=="string")n.issues.push(xi(s,n.value,t));else{const o=s;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=n.value),o.inst??(o.inst=e),n.issues.push(xi(o))}};const i=t.transform(n.value,n);return i instanceof Promise?i.then(s=>(n.value=s,n)):(n.value=i,n)}});function uI(e){return new cI({type:"transform",transform:e})}const Im=q("ZodOptional",(e,t)=>{Yh.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,r,i)=>dl(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function Eu(e){return new Im({type:"optional",innerType:e})}const dI=q("ZodExactOptional",(e,t)=>{BC.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,r,i)=>dl(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function fI(e){return new dI({type:"optional",innerType:e})}const pI=q("ZodNullable",(e,t)=>{ZC.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,r,i)=>mm(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function Tu(e){return new pI({type:"nullable",innerType:e})}const hI=q("ZodDefault",(e,t)=>{VC.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,r,i)=>xm(e,n,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function mI(e,t){return new hI({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Dh(t)}})}const gI=q("ZodPrefault",(e,t)=>{UC.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ym(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function xI(e,t){return new gI({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Dh(t)}})}const Am=q("ZodNonOptional",(e,t)=>{JC.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,r,i)=>gm(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function yI(e,t){return new Am({type:"nonoptional",innerType:e,...he(t)})}const bI=q("ZodCatch",(e,t)=>{HC.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,r,i)=>bm(e,n,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function vI(e,t){return new bI({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const wI=q("ZodPipe",(e,t)=>{WC.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,r,i)=>vm(e,n,r,i),e.in=t.in,e.out=t.out});function Iu(e,t){return new wI({type:"pipe",in:e,out:t})}const kI=q("ZodReadonly",(e,t)=>{qC.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,r,i)=>wm(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function SI(e){return new kI({type:"readonly",innerType:e})}const jI=q("ZodLazy",(e,t)=>{GC.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,r,i)=>km(e,n,r,i),e.unwrap=()=>e._zod.def.getter()});function _I(e){return new jI({type:"lazy",getter:e})}const fl=q("ZodCustom",(e,t)=>{KC.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,r,i)=>lm(e,n)});function zm(e,t){return VE(fl,e??(()=>!0),t)}function NI(e,t={}){return UE(fl,e,t)}function CI(e){return JE(e)}function ws(e,t={}){const n=new fl({type:"custom",check:"custom",fn:r=>r instanceof e,abort:!0,...he(t)});return n._zod.bag.Class=e,n._zod.check=r=>{r.value instanceof e||r.issues.push({code:"invalid_type",expected:e.name,input:r.value,inst:n,path:[...n._zod.def.path??[]]})},n}var bi;(function(e){e.assertEqual=i=>{};function t(i){}e.assertIs=t;function n(i){throw new Error}e.assertNever=n,e.arrayToEnum=i=>{const s={};for(const o of i)s[o]=o;return s},e.getValidEnumValues=i=>{const s=e.objectKeys(i).filter(a=>typeof i[i[a]]!="number"),o={};for(const a of s)o[a]=i[a];return e.objectValues(o)},e.objectValues=i=>e.objectKeys(i).map(function(s){return i[s]}),e.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const s=[];for(const o in i)Object.prototype.hasOwnProperty.call(i,o)&&s.push(o);return s},e.find=(i,s)=>{for(const o of i)if(s(o))return o},e.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function r(i,s=" | "){return i.map(o=>typeof o=="string"?`'${o}'`:o).join(s)}e.joinValues=r,e.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(bi||(bi={}));var Au;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(Au||(Au={}));bi.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]);bi.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class ks extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=t}format(t){const n=t||function(s){return s.message},r={_errors:[]},i=s=>{for(const o of s.issues)if(o.code==="invalid_union")o.unionErrors.map(i);else if(o.code==="invalid_return_type")i(o.returnTypeError);else if(o.code==="invalid_arguments")i(o.argumentsError);else if(o.path.length===0)r._errors.push(n(o));else{let a=r,c=0;for(;c<o.path.length;){const u=o.path[c];c===o.path.length-1?(a[u]=a[u]||{_errors:[]},a[u]._errors.push(n(o))):a[u]=a[u]||{_errors:[]},a=a[u],c++}}};return i(this),r}static assert(t){if(!(t instanceof ks))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,bi.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=n=>n.message){const n=Object.create(null),r=[];for(const i of this.issues)if(i.path.length>0){const s=i.path[0];n[s]=n[s]||[],n[s].push(t(i))}else r.push(t(i));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}}ks.create=e=>new ks(e);var zu;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})(zu||(zu={}));var Se;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(Se||(Se={}));class Ou extends Error{constructor(t,n){super(t),this.name="ParseError",this.type=n.type,this.field=n.field,this.value=n.value,this.line=n.line}}function No(e){}function EI(e){if(typeof e=="function")throw new TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");const{onEvent:t=No,onError:n=No,onRetry:r=No,onComment:i}=e;let s="",o=!0,a,c="",u="";function d(v){const k=o?v.replace(/^\xEF\xBB\xBF/,""):v,[y,_]=TI(`${s}${k}`);for(const x of y)f(x);s=_,o=!1}function f(v){if(v===""){p();return}if(v.startsWith(":")){i&&i(v.slice(v.startsWith(": ")?2:1));return}const k=v.indexOf(":");if(k!==-1){const y=v.slice(0,k),_=v[k+1]===" "?2:1,x=v.slice(k+_);h(y,x,v);return}h(v,"",v)}function h(v,k,y){switch(v){case"event":u=k;break;case"data":c=`${c}${k}
|
|
217
|
+
`;break;case"id":a=k.includes("\0")?void 0:k;break;case"retry":/^\d+$/.test(k)?r(parseInt(k,10)):n(new Ou(`Invalid \`retry\` value: "${k}"`,{type:"invalid-retry",value:k,line:y}));break;default:n(new Ou(`Unknown field "${v.length>20?`${v.slice(0,20)}…`:v}"`,{type:"unknown-field",field:v,value:k,line:y}));break}}function p(){c.length>0&&t({id:a,event:u||void 0,data:c.endsWith(`
|
|
218
|
+
`)?c.slice(0,-1):c}),a=void 0,c="",u=""}function m(v={}){s&&v.consume&&f(s),o=!0,a=void 0,c="",u="",s=""}return{feed:d,reset:m}}function TI(e){const t=[];let n="",r=0;for(;r<e.length;){const i=e.indexOf("\r",r),s=e.indexOf(`
|
|
219
|
+
`,r);let o=-1;if(i!==-1&&s!==-1?o=Math.min(i,s):i!==-1?i===e.length-1?o=-1:o=i:s!==-1&&(o=s),o===-1){n=e.slice(r);break}else{const a=e.slice(r,o);t.push(a),r=o+1,e[r-1]==="\r"&&e[r]===`
|
|
220
|
+
`&&r++}}return[t,n]}class II extends TransformStream{constructor({onError:t,onRetry:n,onComment:r}={}){let i;super({start(s){i=EI({onEvent:o=>{s.enqueue(o)},onError(o){t==="terminate"?s.error(o):typeof t=="function"&&t(o)},onRetry:n,onComment:r})},transform(s){i.feed(s)}})}}var Ai=({prefix:e,size:t=16,alphabet:n="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",separator:r="-"}={})=>{const i=()=>{const s=n.length,o=new Array(t);for(let a=0;a<t;a++)o[a]=n[Math.random()*s|0];return o.join("")};if(e==null)return i;if(n.includes(r))throw new Z_({argument:"separator",message:`The separator "${r}" must not be part of the alphabet "${n}".`});return()=>`${e}${r}${i()}`},AI=Ai();function Yn(e){if(e==null)return{};const t={};if(e instanceof Headers)e.forEach((n,r)=>{t[r.toLowerCase()]=n});else{Array.isArray(e)||(e=Object.entries(e));for(const[n,r]of e)r!=null&&(t[n.toLowerCase()]=r)}return t}var zI=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,OI=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;function Pu(e){const t=JSON.parse(e);return t===null||typeof t!="object"||zI.test(e)===!1&&OI.test(e)===!1?t:PI(t)}function PI(e){let t=[e];for(;t.length;){const n=t;t=[];for(const r of n){if(Object.prototype.hasOwnProperty.call(r,"__proto__"))throw new SyntaxError("Object contains forbidden prototype property");if(Object.prototype.hasOwnProperty.call(r,"constructor")&&r.constructor!==null&&typeof r.constructor=="object"&&Object.prototype.hasOwnProperty.call(r.constructor,"prototype"))throw new SyntaxError("Object contains forbidden prototype property");for(const i in r){const s=r[i];s&&typeof s=="object"&&t.push(s)}}}return e}function DI(e){const{stackTraceLimit:t}=Error;try{Error.stackTraceLimit=0}catch{return Pu(e)}try{return Pu(e)}finally{Error.stackTraceLimit=t}}function pl(e){if(e.type==="object"||Array.isArray(e.type)&&e.type.includes("object")){e.additionalProperties=!1;const{properties:n}=e;if(n!=null)for(const r of Object.keys(n))n[r]=In(n[r])}e.items!=null&&(e.items=Array.isArray(e.items)?e.items.map(In):In(e.items)),e.anyOf!=null&&(e.anyOf=e.anyOf.map(In)),e.allOf!=null&&(e.allOf=e.allOf.map(In)),e.oneOf!=null&&(e.oneOf=e.oneOf.map(In));const{definitions:t}=e;if(t!=null)for(const n of Object.keys(t))t[n]=In(t[n]);return e}function In(e){return typeof e=="boolean"?e:pl(e)}var RI=Symbol("Let zodToJsonSchema decide on which parser to use"),Du={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",strictUnions:!1,definitions:{},errorMessages:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref"},$I=e=>typeof e=="string"?{...Du,name:e}:{...Du,...e};function zt(){return{}}function MI(e,t){var n,r,i;const s={type:"array"};return(n=e.type)!=null&&n._def&&((i=(r=e.type)==null?void 0:r._def)==null?void 0:i.typeName)!==Se.ZodAny&&(s.items=Fe(e.type._def,{...t,currentPath:[...t.currentPath,"items"]})),e.minLength&&(s.minItems=e.minLength.value),e.maxLength&&(s.maxItems=e.maxLength.value),e.exactLength&&(s.minItems=e.exactLength.value,s.maxItems=e.exactLength.value),s}function FI(e){const t={type:"integer",format:"int64"};if(!e.checks)return t;for(const n of e.checks)switch(n.kind){case"min":n.inclusive?t.minimum=n.value:t.exclusiveMinimum=n.value;break;case"max":n.inclusive?t.maximum=n.value:t.exclusiveMaximum=n.value;break;case"multipleOf":t.multipleOf=n.value;break}return t}function LI(){return{type:"boolean"}}function Om(e,t){return Fe(e.type._def,t)}var BI=(e,t)=>Fe(e.innerType._def,t);function Pm(e,t,n){const r=n??t.dateStrategy;if(Array.isArray(r))return{anyOf:r.map((i,s)=>Pm(e,t,i))};switch(r){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return ZI(e)}}var ZI=e=>{const t={type:"integer",format:"unix-time"};for(const n of e.checks)switch(n.kind){case"min":t.minimum=n.value;break;case"max":t.maximum=n.value;break}return t};function VI(e,t){return{...Fe(e.innerType._def,t),default:e.defaultValue()}}function UI(e,t){return t.effectStrategy==="input"?Fe(e.schema._def,t):zt()}function JI(e){return{type:"string",enum:Array.from(e.values)}}var HI=e=>"type"in e&&e.type==="string"?!1:"allOf"in e;function WI(e,t){const n=[Fe(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),Fe(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(i=>!!i),r=[];return n.forEach(i=>{if(HI(i))r.push(...i.allOf);else{let s=i;if("additionalProperties"in i&&i.additionalProperties===!1){const{additionalProperties:o,...a}=i;s=a}r.push(s)}}),r.length?{allOf:r}:void 0}function qI(e){const t=typeof e.value;return t!=="bigint"&&t!=="number"&&t!=="boolean"&&t!=="string"?{type:Array.isArray(e.value)?"array":"object"}:{type:t==="bigint"?"integer":t,const:e.value}}var Co=void 0,Bt={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(Co===void 0&&(Co=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Co),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function Dm(e,t){const n={type:"string"};if(e.checks)for(const r of e.checks)switch(r.kind){case"min":n.minLength=typeof n.minLength=="number"?Math.max(n.minLength,r.value):r.value;break;case"max":n.maxLength=typeof n.maxLength=="number"?Math.min(n.maxLength,r.value):r.value;break;case"email":switch(t.emailStrategy){case"format:email":Zt(n,"email",r.message,t);break;case"format:idn-email":Zt(n,"idn-email",r.message,t);break;case"pattern:zod":ft(n,Bt.email,r.message,t);break}break;case"url":Zt(n,"uri",r.message,t);break;case"uuid":Zt(n,"uuid",r.message,t);break;case"regex":ft(n,r.regex,r.message,t);break;case"cuid":ft(n,Bt.cuid,r.message,t);break;case"cuid2":ft(n,Bt.cuid2,r.message,t);break;case"startsWith":ft(n,RegExp(`^${Eo(r.value,t)}`),r.message,t);break;case"endsWith":ft(n,RegExp(`${Eo(r.value,t)}$`),r.message,t);break;case"datetime":Zt(n,"date-time",r.message,t);break;case"date":Zt(n,"date",r.message,t);break;case"time":Zt(n,"time",r.message,t);break;case"duration":Zt(n,"duration",r.message,t);break;case"length":n.minLength=typeof n.minLength=="number"?Math.max(n.minLength,r.value):r.value,n.maxLength=typeof n.maxLength=="number"?Math.min(n.maxLength,r.value):r.value;break;case"includes":{ft(n,RegExp(Eo(r.value,t)),r.message,t);break}case"ip":{r.version!=="v6"&&Zt(n,"ipv4",r.message,t),r.version!=="v4"&&Zt(n,"ipv6",r.message,t);break}case"base64url":ft(n,Bt.base64url,r.message,t);break;case"jwt":ft(n,Bt.jwt,r.message,t);break;case"cidr":{r.version!=="v6"&&ft(n,Bt.ipv4Cidr,r.message,t),r.version!=="v4"&&ft(n,Bt.ipv6Cidr,r.message,t);break}case"emoji":ft(n,Bt.emoji(),r.message,t);break;case"ulid":{ft(n,Bt.ulid,r.message,t);break}case"base64":{switch(t.base64Strategy){case"format:binary":{Zt(n,"binary",r.message,t);break}case"contentEncoding:base64":{n.contentEncoding="base64";break}case"pattern:zod":{ft(n,Bt.base64,r.message,t);break}}break}case"nanoid":ft(n,Bt.nanoid,r.message,t)}return n}function Eo(e,t){return t.patternStrategy==="escape"?KI(e):e}var GI=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function KI(e){let t="";for(let n=0;n<e.length;n++)GI.has(e[n])||(t+="\\"),t+=e[n];return t}function Zt(e,t,n,r){var i;e.format||(i=e.anyOf)!=null&&i.some(s=>s.format)?(e.anyOf||(e.anyOf=[]),e.format&&(e.anyOf.push({format:e.format}),delete e.format),e.anyOf.push({format:t,...n&&r.errorMessages&&{errorMessage:{format:n}}})):e.format=t}function ft(e,t,n,r){var i;e.pattern||(i=e.allOf)!=null&&i.some(s=>s.pattern)?(e.allOf||(e.allOf=[]),e.pattern&&(e.allOf.push({pattern:e.pattern}),delete e.pattern),e.allOf.push({pattern:Ru(t,r),...n&&r.errorMessages&&{errorMessage:{pattern:n}}})):e.pattern=Ru(t,r)}function Ru(e,t){var n;if(!t.applyRegexFlags||!e.flags)return e.source;const r={i:e.flags.includes("i"),m:e.flags.includes("m"),s:e.flags.includes("s")},i=r.i?e.source.toLowerCase():e.source;let s="",o=!1,a=!1,c=!1;for(let u=0;u<i.length;u++){if(o){s+=i[u],o=!1;continue}if(r.i){if(a){if(i[u].match(/[a-z]/)){c?(s+=i[u],s+=`${i[u-2]}-${i[u]}`.toUpperCase(),c=!1):i[u+1]==="-"&&((n=i[u+2])!=null&&n.match(/[a-z]/))?(s+=i[u],c=!0):s+=`${i[u]}${i[u].toUpperCase()}`;continue}}else if(i[u].match(/[a-z]/)){s+=`[${i[u]}${i[u].toUpperCase()}]`;continue}}if(r.m){if(i[u]==="^"){s+=`(^|(?<=[\r
|
|
221
|
+
]))`;continue}else if(i[u]==="$"){s+=`($|(?=[\r
|
|
222
|
+
]))`;continue}}if(r.s&&i[u]==="."){s+=a?`${i[u]}\r
|
|
223
|
+
`:`[${i[u]}\r
|
|
224
|
+
]`;continue}s+=i[u],i[u]==="\\"?o=!0:a&&i[u]==="]"?a=!1:!a&&i[u]==="["&&(a=!0)}try{new RegExp(s)}catch{return console.warn(`Could not convert regex pattern at ${t.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),e.source}return s}function Rm(e,t){var n,r,i,s,o,a;const c={type:"object",additionalProperties:(n=Fe(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]}))!=null?n:t.allowedAdditionalProperties};if(((r=e.keyType)==null?void 0:r._def.typeName)===Se.ZodString&&((i=e.keyType._def.checks)!=null&&i.length)){const{type:u,...d}=Dm(e.keyType._def,t);return{...c,propertyNames:d}}else{if(((s=e.keyType)==null?void 0:s._def.typeName)===Se.ZodEnum)return{...c,propertyNames:{enum:e.keyType._def.values}};if(((o=e.keyType)==null?void 0:o._def.typeName)===Se.ZodBranded&&e.keyType._def.type._def.typeName===Se.ZodString&&((a=e.keyType._def.type._def.checks)!=null&&a.length)){const{type:u,...d}=Om(e.keyType._def,t);return{...c,propertyNames:d}}}return c}function YI(e,t){if(t.mapStrategy==="record")return Rm(e,t);const n=Fe(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||zt(),r=Fe(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||zt();return{type:"array",maxItems:125,items:{type:"array",items:[n,r],minItems:2,maxItems:2}}}function XI(e){const t=e.values,r=Object.keys(e.values).filter(s=>typeof t[t[s]]!="number").map(s=>t[s]),i=Array.from(new Set(r.map(s=>typeof s)));return{type:i.length===1?i[0]==="string"?"string":"number":["string","number"],enum:r}}function QI(){return{not:zt()}}function eA(){return{type:"null"}}var ca={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function tA(e,t){const n=e.options instanceof Map?Array.from(e.options.values()):e.options;if(n.every(r=>r._def.typeName in ca&&(!r._def.checks||!r._def.checks.length))){const r=n.reduce((i,s)=>{const o=ca[s._def.typeName];return o&&!i.includes(o)?[...i,o]:i},[]);return{type:r.length>1?r:r[0]}}else if(n.every(r=>r._def.typeName==="ZodLiteral"&&!r.description)){const r=n.reduce((i,s)=>{const o=typeof s._def.value;switch(o){case"string":case"number":case"boolean":return[...i,o];case"bigint":return[...i,"integer"];case"object":if(s._def.value===null)return[...i,"null"];case"symbol":case"undefined":case"function":default:return i}},[]);if(r.length===n.length){const i=r.filter((s,o,a)=>a.indexOf(s)===o);return{type:i.length>1?i:i[0],enum:n.reduce((s,o)=>s.includes(o._def.value)?s:[...s,o._def.value],[])}}}else if(n.every(r=>r._def.typeName==="ZodEnum"))return{type:"string",enum:n.reduce((r,i)=>[...r,...i._def.values.filter(s=>!r.includes(s))],[])};return nA(e,t)}var nA=(e,t)=>{const n=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((r,i)=>Fe(r._def,{...t,currentPath:[...t.currentPath,"anyOf",`${i}`]})).filter(r=>!!r&&(!t.strictUnions||typeof r=="object"&&Object.keys(r).length>0));return n.length?{anyOf:n}:void 0};function rA(e,t){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return{type:[ca[e.innerType._def.typeName],"null"]};const n=Fe(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return n&&{anyOf:[n,{type:"null"}]}}function iA(e){const t={type:"number"};if(!e.checks)return t;for(const n of e.checks)switch(n.kind){case"int":t.type="integer";break;case"min":n.inclusive?t.minimum=n.value:t.exclusiveMinimum=n.value;break;case"max":n.inclusive?t.maximum=n.value:t.exclusiveMaximum=n.value;break;case"multipleOf":t.multipleOf=n.value;break}return t}function sA(e,t){const n={type:"object",properties:{}},r=[],i=e.shape();for(const o in i){let a=i[o];if(a===void 0||a._def===void 0)continue;const c=aA(a),u=Fe(a._def,{...t,currentPath:[...t.currentPath,"properties",o],propertyPath:[...t.currentPath,"properties",o]});u!==void 0&&(n.properties[o]=u,c||r.push(o))}r.length&&(n.required=r);const s=oA(e,t);return s!==void 0&&(n.additionalProperties=s),n}function oA(e,t){if(e.catchall._def.typeName!=="ZodNever")return Fe(e.catchall._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]});switch(e.unknownKeys){case"passthrough":return t.allowedAdditionalProperties;case"strict":return t.rejectedAdditionalProperties;case"strip":return t.removeAdditionalStrategy==="strict"?t.allowedAdditionalProperties:t.rejectedAdditionalProperties}}function aA(e){try{return e.isOptional()}catch{return!0}}var lA=(e,t)=>{var n;if(t.currentPath.toString()===((n=t.propertyPath)==null?void 0:n.toString()))return Fe(e.innerType._def,t);const r=Fe(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return r?{anyOf:[{not:zt()},r]}:zt()},cA=(e,t)=>{if(t.pipeStrategy==="input")return Fe(e.in._def,t);if(t.pipeStrategy==="output")return Fe(e.out._def,t);const n=Fe(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),r=Fe(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",n?"1":"0"]});return{allOf:[n,r].filter(i=>i!==void 0)}};function uA(e,t){return Fe(e.type._def,t)}function dA(e,t){const r={type:"array",uniqueItems:!0,items:Fe(e.valueType._def,{...t,currentPath:[...t.currentPath,"items"]})};return e.minSize&&(r.minItems=e.minSize.value),e.maxSize&&(r.maxItems=e.maxSize.value),r}function fA(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((n,r)=>Fe(n._def,{...t,currentPath:[...t.currentPath,"items",`${r}`]})).reduce((n,r)=>r===void 0?n:[...n,r],[]),additionalItems:Fe(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((n,r)=>Fe(n._def,{...t,currentPath:[...t.currentPath,"items",`${r}`]})).reduce((n,r)=>r===void 0?n:[...n,r],[])}}function pA(){return{not:zt()}}function hA(){return zt()}var mA=(e,t)=>Fe(e.innerType._def,t),gA=(e,t,n)=>{switch(t){case Se.ZodString:return Dm(e,n);case Se.ZodNumber:return iA(e);case Se.ZodObject:return sA(e,n);case Se.ZodBigInt:return FI(e);case Se.ZodBoolean:return LI();case Se.ZodDate:return Pm(e,n);case Se.ZodUndefined:return pA();case Se.ZodNull:return eA();case Se.ZodArray:return MI(e,n);case Se.ZodUnion:case Se.ZodDiscriminatedUnion:return tA(e,n);case Se.ZodIntersection:return WI(e,n);case Se.ZodTuple:return fA(e,n);case Se.ZodRecord:return Rm(e,n);case Se.ZodLiteral:return qI(e);case Se.ZodEnum:return JI(e);case Se.ZodNativeEnum:return XI(e);case Se.ZodNullable:return rA(e,n);case Se.ZodOptional:return lA(e,n);case Se.ZodMap:return YI(e,n);case Se.ZodSet:return dA(e,n);case Se.ZodLazy:return()=>e.getter()._def;case Se.ZodPromise:return uA(e,n);case Se.ZodNaN:case Se.ZodNever:return QI();case Se.ZodEffects:return UI(e,n);case Se.ZodAny:return zt();case Se.ZodUnknown:return hA();case Se.ZodDefault:return VI(e,n);case Se.ZodBranded:return Om(e,n);case Se.ZodReadonly:return mA(e,n);case Se.ZodCatch:return BI(e,n);case Se.ZodPipeline:return cA(e,n);case Se.ZodFunction:case Se.ZodVoid:case Se.ZodSymbol:return;default:return(r=>{})()}},xA=(e,t)=>{let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];n++);return[(e.length-n).toString(),...t.slice(n)].join("/")};function Fe(e,t,n=!1){var r;const i=t.seen.get(e);if(t.override){const c=(r=t.override)==null?void 0:r.call(t,e,t,i,n);if(c!==RI)return c}if(i&&!n){const c=yA(i,t);if(c!==void 0)return c}const s={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,s);const o=gA(e,e.typeName,t),a=typeof o=="function"?Fe(o(),t):o;if(a&&bA(e,t,a),t.postProcess){const c=t.postProcess(a,e,t);return s.jsonSchema=a,c}return s.jsonSchema=a,a}var yA=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:xA(t.currentPath,e.path)};case"none":case"seen":return e.path.length<t.currentPath.length&&e.path.every((n,r)=>t.currentPath[r]===n)?(console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),zt()):t.$refStrategy==="seen"?zt():void 0}},bA=(e,t,n)=>(e.description&&(n.description=e.description),n),vA=e=>{const t=$I(e),n=t.name!==void 0?[...t.basePath,t.definitionPath,t.name]:t.basePath;return{...t,currentPath:n,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([r,i])=>[i._def,{def:i._def,path:[...t.basePath,t.definitionPath,r],jsonSchema:void 0}]))}},wA=(e,t)=>{var n;const r=vA(t);let i=typeof t=="object"&&t.definitions?Object.entries(t.definitions).reduce((u,[d,f])=>{var h;return{...u,[d]:(h=Fe(f._def,{...r,currentPath:[...r.basePath,r.definitionPath,d]},!0))!=null?h:zt()}},{}):void 0;const s=typeof t=="string"?t:(t==null?void 0:t.nameStrategy)==="title"||t==null?void 0:t.name,o=(n=Fe(e._def,s===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,s]},!1))!=null?n:zt(),a=typeof t=="object"&&t.name!==void 0&&t.nameStrategy==="title"?t.name:void 0;a!==void 0&&(o.title=a);const c=s===void 0?i?{...o,[r.definitionPath]:i}:o:{$ref:[...r.$refStrategy==="relative"?[]:r.basePath,r.definitionPath,s].join("/"),[r.definitionPath]:{...i,[s]:o}};return c.$schema="http://json-schema.org/draft-07/schema#",c},ua=Symbol.for("vercel.ai.schema");function kA(e){let t;return()=>(t==null&&(t=e()),t)}function Ws(e,{validate:t}={}){return{[ua]:!0,_type:void 0,get jsonSchema(){return typeof e=="function"&&(e=e()),e},validate:t}}function SA(e){return typeof e=="object"&&e!==null&&ua in e&&e[ua]===!0&&"jsonSchema"in e&&"validate"in e}function hl(e){return e==null?Ws({properties:{},additionalProperties:!1}):SA(e)?e:"~standard"in e?e["~standard"].vendor==="zod"?$m(e):jA(e):e()}function jA(e){return Ws(()=>pl(e["~standard"].jsonSchema.input({target:"draft-07"})),{validate:async t=>{const n=await e["~standard"].validate(t);return"value"in n?{success:!0,value:n.value}:{success:!1,error:new kr({value:t,cause:n.issues})}}})}function _A(e,t){var n;const r=(n=void 0)!=null?n:!1;return Ws(()=>wA(e,{$refStrategy:r?"root":"none"}),{validate:async i=>{const s=await e.safeParseAsync(i);return s.success?{success:!0,value:s.data}:{success:!1,error:s.error}}})}function NA(e,t){var n;const r=(n=void 0)!=null?n:!1;return Ws(()=>pl(uT(e,{target:"draft-7",io:"input",reused:r?"ref":"inline"})),{validate:async i=>{const s=await Sm(e,i);return s.success?{success:!0,value:s.data}:{success:!1,error:s.error}}})}function CA(e){return"_zod"in e}function $m(e,t){return CA(e)?NA(e):_A(e)}async function $u({value:e,schema:t,context:n}){const r=await vi({value:e,schema:t,context:n});if(!r.success)throw kr.wrap({value:e,cause:r.error,context:n});return r.value}async function vi({value:e,schema:t,context:n}){const r=hl(t);try{if(r.validate==null)return{success:!0,value:e,rawValue:e};const i=await r.validate(e);return i.success?{success:!0,value:i.value,rawValue:e}:{success:!1,error:kr.wrap({value:e,cause:i.error,context:n}),rawValue:e}}catch(i){return{success:!1,error:kr.wrap({value:e,cause:i,context:n}),rawValue:e}}}async function Zn({text:e,schema:t}){try{const n=DI(e);return t==null?{success:!0,value:n,rawValue:n}:await vi({value:n,schema:t})}catch(n){return{success:!1,error:ou.isInstance(n)?n:new ou({text:e,cause:n}),rawValue:void 0}}}function EA({stream:e,schema:t}){return e.pipeThrough(new TextDecoderStream).pipeThrough(new II).pipeThrough(new TransformStream({async transform({data:n},r){n!=="[DONE]"&&r.enqueue(await Zn({text:n,schema:t}))}}))}async function gn(e){return typeof e=="function"&&(e=e()),Promise.resolve(e)}var TA=Object.defineProperty,IA=(e,t)=>{for(var n in t)TA(e,n,{get:t[n],enumerable:!0})},Mm="AI_NoObjectGeneratedError",Fm=`vercel.ai.error.${Mm}`,AA=Symbol.for(Fm),Lm,bn=class extends nn{constructor({message:e="No object generated.",cause:t,text:n,response:r,usage:i,finishReason:s}){super({name:Mm,message:e,cause:t}),this[Lm]=!0,this.text=n,this.response=r,this.usage=i,this.finishReason=s}static isInstance(e){return nn.hasMarker(e,Fm)}};Lm=AA;var Bm="AI_UIMessageStreamError",Zm=`vercel.ai.error.${Bm}`,zA=Symbol.for(Zm),Vm,Xn=class extends nn{constructor({chunkType:e,chunkId:t,message:n}){super({name:Bm,message:n}),this[Vm]=!0,this.chunkType=e,this.chunkId=t}static isInstance(e){return nn.hasMarker(e,Zm)}};Vm=zA;var Um=yt([le(),ws(Uint8Array),ws(ArrayBuffer),zm(e=>{var t,n;return(n=(t=globalThis.Buffer)==null?void 0:t.isBuffer(e))!=null?n:!1},{message:"Must be a Buffer"})]),wi=_I(()=>yt([QT(),le(),GT(),ht(),yi(le(),wi.optional()),zr(wi)])),Te=yi(le(),yi(le(),wi.optional())),Jm=Be({type:ve("text"),text:le(),providerOptions:Te.optional()}),OA=Be({type:ve("image"),image:yt([Um,ws(URL)]),mediaType:le().optional(),providerOptions:Te.optional()}),Hm=Be({type:ve("file"),data:yt([Um,ws(URL)]),filename:le().optional(),mediaType:le(),providerOptions:Te.optional()}),PA=Be({type:ve("reasoning"),text:le(),providerOptions:Te.optional()}),DA=Be({type:ve("tool-call"),toolCallId:le(),toolName:le(),input:Xt(),providerOptions:Te.optional(),providerExecuted:ht().optional()}),RA=iI("type",[Be({type:ve("text"),value:le(),providerOptions:Te.optional()}),Be({type:ve("json"),value:wi,providerOptions:Te.optional()}),Be({type:ve("execution-denied"),reason:le().optional(),providerOptions:Te.optional()}),Be({type:ve("error-text"),value:le(),providerOptions:Te.optional()}),Be({type:ve("error-json"),value:wi,providerOptions:Te.optional()}),Be({type:ve("content"),value:zr(yt([Be({type:ve("text"),text:le(),providerOptions:Te.optional()}),Be({type:ve("media"),data:le(),mediaType:le()}),Be({type:ve("file-data"),data:le(),mediaType:le(),filename:le().optional(),providerOptions:Te.optional()}),Be({type:ve("file-url"),url:le(),providerOptions:Te.optional()}),Be({type:ve("file-id"),fileId:yt([le(),yi(le(),le())]),providerOptions:Te.optional()}),Be({type:ve("image-data"),data:le(),mediaType:le(),providerOptions:Te.optional()}),Be({type:ve("image-url"),url:le(),providerOptions:Te.optional()}),Be({type:ve("image-file-id"),fileId:yt([le(),yi(le(),le())]),providerOptions:Te.optional()}),Be({type:ve("custom"),providerOptions:Te.optional()})]))})]),Wm=Be({type:ve("tool-result"),toolCallId:le(),toolName:le(),output:RA,providerOptions:Te.optional()}),$A=Be({type:ve("tool-approval-request"),approvalId:le(),toolCallId:le()}),MA=Be({type:ve("tool-approval-response"),approvalId:le(),approved:ht(),reason:le().optional()}),FA=Be({role:ve("system"),content:le(),providerOptions:Te.optional()}),LA=Be({role:ve("user"),content:yt([le(),zr(yt([Jm,OA,Hm]))]),providerOptions:Te.optional()}),BA=Be({role:ve("assistant"),content:yt([le(),zr(yt([Jm,Hm,PA,DA,Wm,$A]))]),providerOptions:Te.optional()}),ZA=Be({role:ve("tool"),content:zr(yt([Wm,MA])),providerOptions:Te.optional()});yt([FA,LA,BA,ZA]);function qm(e,t){if(e===void 0&&t===void 0)return;if(e===void 0)return t;if(t===void 0)return e;const n={...e};for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)){const i=t[r];if(i===void 0)continue;const s=r in e?e[r]:void 0,o=i!==null&&typeof i=="object"&&!Array.isArray(i)&&!(i instanceof Date)&&!(i instanceof RegExp),a=s!=null&&typeof s=="object"&&!Array.isArray(s)&&!(s instanceof Date)&&!(s instanceof RegExp);o&&a?n[r]=qm(s,i):n[r]=i}return n}var VA={};IA(VA,{array:()=>WA,choice:()=>qA,json:()=>GA,object:()=>HA,text:()=>JA});function UA(e){const t=["ROOT"];let n=-1,r=null;function i(c,u,d){switch(c){case'"':{n=u,t.pop(),t.push(d),t.push("INSIDE_STRING");break}case"f":case"t":case"n":{n=u,r=u,t.pop(),t.push(d),t.push("INSIDE_LITERAL");break}case"-":{t.pop(),t.push(d),t.push("INSIDE_NUMBER");break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{n=u,t.pop(),t.push(d),t.push("INSIDE_NUMBER");break}case"{":{n=u,t.pop(),t.push(d),t.push("INSIDE_OBJECT_START");break}case"[":{n=u,t.pop(),t.push(d),t.push("INSIDE_ARRAY_START");break}}}function s(c,u){switch(c){case",":{t.pop(),t.push("INSIDE_OBJECT_AFTER_COMMA");break}case"}":{n=u,t.pop();break}}}function o(c,u){switch(c){case",":{t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{n=u,t.pop();break}}}for(let c=0;c<e.length;c++){const u=e[c];switch(t[t.length-1]){case"ROOT":i(u,c,"FINISH");break;case"INSIDE_OBJECT_START":{switch(u){case'"':{t.pop(),t.push("INSIDE_OBJECT_KEY");break}case"}":{n=c,t.pop();break}}break}case"INSIDE_OBJECT_AFTER_COMMA":{switch(u){case'"':{t.pop(),t.push("INSIDE_OBJECT_KEY");break}}break}case"INSIDE_OBJECT_KEY":{switch(u){case'"':{t.pop(),t.push("INSIDE_OBJECT_AFTER_KEY");break}}break}case"INSIDE_OBJECT_AFTER_KEY":{switch(u){case":":{t.pop(),t.push("INSIDE_OBJECT_BEFORE_VALUE");break}}break}case"INSIDE_OBJECT_BEFORE_VALUE":{i(u,c,"INSIDE_OBJECT_AFTER_VALUE");break}case"INSIDE_OBJECT_AFTER_VALUE":{s(u,c);break}case"INSIDE_STRING":{switch(u){case'"':{t.pop(),n=c;break}case"\\":{t.push("INSIDE_STRING_ESCAPE");break}default:n=c}break}case"INSIDE_ARRAY_START":{switch(u){case"]":{n=c,t.pop();break}default:{n=c,i(u,c,"INSIDE_ARRAY_AFTER_VALUE");break}}break}case"INSIDE_ARRAY_AFTER_VALUE":{switch(u){case",":{t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{n=c,t.pop();break}default:{n=c;break}}break}case"INSIDE_ARRAY_AFTER_COMMA":{i(u,c,"INSIDE_ARRAY_AFTER_VALUE");break}case"INSIDE_STRING_ESCAPE":{t.pop(),n=c;break}case"INSIDE_NUMBER":{switch(u){case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{n=c;break}case"e":case"E":case"-":case".":break;case",":{t.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&o(u,c),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&s(u,c);break}case"}":{t.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&s(u,c);break}case"]":{t.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&o(u,c);break}default:{t.pop();break}}break}case"INSIDE_LITERAL":{const f=e.substring(r,c+1);!"false".startsWith(f)&&!"true".startsWith(f)&&!"null".startsWith(f)?(t.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"?s(u,c):t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&o(u,c)):n=c;break}}}let a=e.slice(0,n+1);for(let c=t.length-1;c>=0;c--)switch(t[c]){case"INSIDE_STRING":{a+='"';break}case"INSIDE_OBJECT_KEY":case"INSIDE_OBJECT_AFTER_KEY":case"INSIDE_OBJECT_AFTER_COMMA":case"INSIDE_OBJECT_START":case"INSIDE_OBJECT_BEFORE_VALUE":case"INSIDE_OBJECT_AFTER_VALUE":{a+="}";break}case"INSIDE_ARRAY_START":case"INSIDE_ARRAY_AFTER_COMMA":case"INSIDE_ARRAY_AFTER_VALUE":{a+="]";break}case"INSIDE_LITERAL":{const d=e.substring(r,e.length);"true".startsWith(d)?a+="true".slice(d.length):"false".startsWith(d)?a+="false".slice(d.length):"null".startsWith(d)&&(a+="null".slice(d.length))}}return a}async function zi(e){if(e===void 0)return{value:void 0,state:"undefined-input"};let t=await Zn({text:e});return t.success?{value:t.value,state:"successful-parse"}:(t=await Zn({text:UA(e)}),t.success?{value:t.value,state:"repaired-parse"}:{value:void 0,state:"failed-parse"})}var JA=()=>({name:"text",responseFormat:Promise.resolve({type:"text"}),async parseCompleteOutput({text:e}){return e},async parsePartialOutput({text:e}){return{partial:e}},createElementStreamTransform(){}}),HA=({schema:e,name:t,description:n})=>{const r=hl(e);return{name:"object",responseFormat:gn(r.jsonSchema).then(i=>({type:"json",schema:i,...t!=null&&{name:t},...n!=null&&{description:n}})),async parseCompleteOutput({text:i},s){const o=await Zn({text:i});if(!o.success)throw new bn({message:"No object generated: could not parse the response.",cause:o.error,text:i,response:s.response,usage:s.usage,finishReason:s.finishReason});const a=await vi({value:o.value,schema:r});if(!a.success)throw new bn({message:"No object generated: response did not match schema.",cause:a.error,text:i,response:s.response,usage:s.usage,finishReason:s.finishReason});return a.value},async parsePartialOutput({text:i}){const s=await zi(i);switch(s.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return{partial:s.value}}},createElementStreamTransform(){}}},WA=({element:e,name:t,description:n})=>{const r=hl(e);return{name:"array",responseFormat:gn(r.jsonSchema).then(i=>{const{$schema:s,...o}=i;return{type:"json",schema:{$schema:"http://json-schema.org/draft-07/schema#",type:"object",properties:{elements:{type:"array",items:o}},required:["elements"],additionalProperties:!1},...t!=null&&{name:t},...n!=null&&{description:n}}}),async parseCompleteOutput({text:i},s){const o=await Zn({text:i});if(!o.success)throw new bn({message:"No object generated: could not parse the response.",cause:o.error,text:i,response:s.response,usage:s.usage,finishReason:s.finishReason});const a=o.value;if(a==null||typeof a!="object"||!("elements"in a)||!Array.isArray(a.elements))throw new bn({message:"No object generated: response did not match schema.",cause:new kr({value:a,cause:"response must be an object with an elements array"}),text:i,response:s.response,usage:s.usage,finishReason:s.finishReason});for(const c of a.elements){const u=await vi({value:c,schema:r});if(!u.success)throw new bn({message:"No object generated: response did not match schema.",cause:u.error,text:i,response:s.response,usage:s.usage,finishReason:s.finishReason})}return a.elements},async parsePartialOutput({text:i}){const s=await zi(i);switch(s.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":{const o=s.value;if(o==null||typeof o!="object"||!("elements"in o)||!Array.isArray(o.elements))return;const a=s.state==="repaired-parse"&&o.elements.length>0?o.elements.slice(0,-1):o.elements,c=[];for(const u of a){const d=await vi({value:u,schema:r});d.success&&c.push(d.value)}return{partial:c}}}},createElementStreamTransform(){let i=0;return new TransformStream({transform({partialOutput:s},o){if(s!=null)for(;i<s.length;i++)o.enqueue(s[i])}})}}},qA=({options:e,name:t,description:n})=>({name:"choice",responseFormat:Promise.resolve({type:"json",schema:{$schema:"http://json-schema.org/draft-07/schema#",type:"object",properties:{result:{type:"string",enum:e}},required:["result"],additionalProperties:!1},...t!=null&&{name:t},...n!=null&&{description:n}}),async parseCompleteOutput({text:r},i){const s=await Zn({text:r});if(!s.success)throw new bn({message:"No object generated: could not parse the response.",cause:s.error,text:r,response:i.response,usage:i.usage,finishReason:i.finishReason});const o=s.value;if(o==null||typeof o!="object"||!("result"in o)||typeof o.result!="string"||!e.includes(o.result))throw new bn({message:"No object generated: response did not match schema.",cause:new kr({value:o,cause:"response must be an object that contains a choice value."}),text:r,response:i.response,usage:i.usage,finishReason:i.finishReason});return o.result},async parsePartialOutput({text:r}){const i=await zi(r);switch(i.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":{const s=i.value;if(s==null||typeof s!="object"||!("result"in s)||typeof s.result!="string")return;const o=e.filter(a=>a.startsWith(s.result));return i.state==="successful-parse"?o.includes(s.result)?{partial:s.result}:void 0:o.length===1?{partial:o[0]}:void 0}}},createElementStreamTransform(){}}),GA=({name:e,description:t}={})=>({name:"json",responseFormat:Promise.resolve({type:"json",...e!=null&&{name:e},...t!=null&&{description:t}}),async parseCompleteOutput({text:n},r){const i=await Zn({text:n});if(!i.success)throw new bn({message:"No object generated: could not parse the response.",cause:i.error,text:n,response:r.response,usage:r.usage,finishReason:r.finishReason});return i.value},async parsePartialOutput({text:n}){const r=await zi(n);switch(r.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return r.value===void 0?void 0:{partial:r.value}}},createElementStreamTransform(){}});Ai({prefix:"aitxt",size:24});(class extends TransformStream{constructor(){super({transform(e,t){t.enqueue(`data: ${JSON.stringify(e)}
|
|
225
|
+
|
|
226
|
+
`)},flush(e){e.enqueue(`data: [DONE]
|
|
227
|
+
|
|
228
|
+
`)}})}});var KA=kA(()=>$m(yt([He({type:ve("text-start"),id:le(),providerMetadata:Te.optional()}),He({type:ve("text-delta"),id:le(),delta:le(),providerMetadata:Te.optional()}),He({type:ve("text-end"),id:le(),providerMetadata:Te.optional()}),He({type:ve("error"),errorText:le()}),He({type:ve("tool-input-start"),toolCallId:le(),toolName:le(),providerExecuted:ht().optional(),providerMetadata:Te.optional(),dynamic:ht().optional(),title:le().optional()}),He({type:ve("tool-input-delta"),toolCallId:le(),inputTextDelta:le()}),He({type:ve("tool-input-available"),toolCallId:le(),toolName:le(),input:Xt(),providerExecuted:ht().optional(),providerMetadata:Te.optional(),dynamic:ht().optional(),title:le().optional()}),He({type:ve("tool-input-error"),toolCallId:le(),toolName:le(),input:Xt(),providerExecuted:ht().optional(),providerMetadata:Te.optional(),dynamic:ht().optional(),errorText:le(),title:le().optional()}),He({type:ve("tool-approval-request"),approvalId:le(),toolCallId:le()}),He({type:ve("tool-output-available"),toolCallId:le(),output:Xt(),providerExecuted:ht().optional(),providerMetadata:Te.optional(),dynamic:ht().optional(),preliminary:ht().optional()}),He({type:ve("tool-output-error"),toolCallId:le(),errorText:le(),providerExecuted:ht().optional(),providerMetadata:Te.optional(),dynamic:ht().optional()}),He({type:ve("tool-output-denied"),toolCallId:le()}),He({type:ve("reasoning-start"),id:le(),providerMetadata:Te.optional()}),He({type:ve("reasoning-delta"),id:le(),delta:le(),providerMetadata:Te.optional()}),He({type:ve("reasoning-end"),id:le(),providerMetadata:Te.optional()}),He({type:ve("source-url"),sourceId:le(),url:le(),title:le().optional(),providerMetadata:Te.optional()}),He({type:ve("source-document"),sourceId:le(),mediaType:le(),title:le(),filename:le().optional(),providerMetadata:Te.optional()}),He({type:ve("file"),url:le(),mediaType:le(),providerMetadata:Te.optional()}),He({type:zm(e=>typeof e=="string"&&e.startsWith("data-"),{message:'Type must start with "data-"'}),id:le().optional(),data:Xt(),transient:ht().optional()}),He({type:ve("start-step")}),He({type:ve("finish-step")}),He({type:ve("start"),messageId:le().optional(),messageMetadata:Xt().optional()}),He({type:ve("finish"),finishReason:Tm(["stop","length","content-filter","tool-calls","error","other"]).optional(),messageMetadata:Xt().optional()}),He({type:ve("abort"),reason:le().optional()}),He({type:ve("message-metadata"),messageMetadata:Xt()})])));function YA(e){return e.type.startsWith("data-")}function da(e){return e.type.startsWith("tool-")}function XA(e){return e.type==="dynamic-tool"}function Ss(e){return da(e)||XA(e)}function Mu(e){return e.type.split("-").slice(1).join("-")}function QA({lastMessage:e,messageId:t}){return{message:(e==null?void 0:e.role)==="assistant"?e:{id:t,metadata:void 0,role:"assistant",parts:[]},activeTextParts:{},activeReasoningParts:{},partialToolCalls:{}}}function ez({stream:e,messageMetadataSchema:t,dataPartSchemas:n,runUpdateMessageJob:r,onError:i,onToolCall:s,onData:o}){return e.pipeThrough(new TransformStream({async transform(a,c){await r(async({state:u,write:d})=>{var f,h,p,m;function v(x){const E=u.message.parts.filter(Ss).find(w=>w.toolCallId===x);if(E==null)throw new Xn({chunkType:"tool-invocation",chunkId:x,message:`No tool invocation found for tool call ID "${x}".`});return E}function k(x){var A;const E=u.message.parts.find(O=>da(O)&&O.toolCallId===x.toolCallId),w=x,S=E;if(E!=null){E.state=x.state,S.input=w.input,S.output=w.output,S.errorText=w.errorText,S.rawInput=w.rawInput,S.preliminary=w.preliminary,x.title!==void 0&&(S.title=x.title),S.providerExecuted=(A=w.providerExecuted)!=null?A:E.providerExecuted;const O=w.providerMetadata;if(O!=null)if(x.state==="output-available"||x.state==="output-error"){const B=E;B.resultProviderMetadata=O}else E.callProviderMetadata=O}else u.message.parts.push({type:`tool-${x.toolName}`,toolCallId:x.toolCallId,state:x.state,title:x.title,input:w.input,output:w.output,rawInput:w.rawInput,errorText:w.errorText,providerExecuted:w.providerExecuted,preliminary:w.preliminary,...w.providerMetadata!=null&&(x.state==="output-available"||x.state==="output-error")?{resultProviderMetadata:w.providerMetadata}:{},...w.providerMetadata!=null&&!(x.state==="output-available"||x.state==="output-error")?{callProviderMetadata:w.providerMetadata}:{}})}function y(x){var A,E;const w=u.message.parts.find(B=>B.type==="dynamic-tool"&&B.toolCallId===x.toolCallId),S=x,O=w;if(w!=null){w.state=x.state,O.toolName=x.toolName,O.input=S.input,O.output=S.output,O.errorText=S.errorText,O.rawInput=(A=S.rawInput)!=null?A:O.rawInput,O.preliminary=S.preliminary,x.title!==void 0&&(O.title=x.title),O.providerExecuted=(E=S.providerExecuted)!=null?E:w.providerExecuted;const B=S.providerMetadata;if(B!=null)if(x.state==="output-available"||x.state==="output-error"){const N=w;N.resultProviderMetadata=B}else w.callProviderMetadata=B}else u.message.parts.push({type:"dynamic-tool",toolName:x.toolName,toolCallId:x.toolCallId,state:x.state,input:S.input,output:S.output,errorText:S.errorText,preliminary:S.preliminary,providerExecuted:S.providerExecuted,title:x.title,...S.providerMetadata!=null&&(x.state==="output-available"||x.state==="output-error")?{resultProviderMetadata:S.providerMetadata}:{},...S.providerMetadata!=null&&!(x.state==="output-available"||x.state==="output-error")?{callProviderMetadata:S.providerMetadata}:{}})}async function _(x){if(x!=null){const A=u.message.metadata!=null?qm(u.message.metadata,x):x;t!=null&&await $u({value:A,schema:t,context:{field:"message.metadata",entityId:u.message.id}}),u.message.metadata=A}}switch(a.type){case"text-start":{const x={type:"text",text:"",providerMetadata:a.providerMetadata,state:"streaming"};u.activeTextParts[a.id]=x,u.message.parts.push(x),d();break}case"text-delta":{const x=u.activeTextParts[a.id];if(x==null)throw new Xn({chunkType:"text-delta",chunkId:a.id,message:`Received text-delta for missing text part with ID "${a.id}". Ensure a "text-start" chunk is sent before any "text-delta" chunks.`});x.text+=a.delta,x.providerMetadata=(f=a.providerMetadata)!=null?f:x.providerMetadata,d();break}case"text-end":{const x=u.activeTextParts[a.id];if(x==null)throw new Xn({chunkType:"text-end",chunkId:a.id,message:`Received text-end for missing text part with ID "${a.id}". Ensure a "text-start" chunk is sent before any "text-end" chunks.`});x.state="done",x.providerMetadata=(h=a.providerMetadata)!=null?h:x.providerMetadata,delete u.activeTextParts[a.id],d();break}case"reasoning-start":{const x={type:"reasoning",text:"",providerMetadata:a.providerMetadata,state:"streaming"};u.activeReasoningParts[a.id]=x,u.message.parts.push(x),d();break}case"reasoning-delta":{const x=u.activeReasoningParts[a.id];if(x==null)throw new Xn({chunkType:"reasoning-delta",chunkId:a.id,message:`Received reasoning-delta for missing reasoning part with ID "${a.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-delta" chunks.`});x.text+=a.delta,x.providerMetadata=(p=a.providerMetadata)!=null?p:x.providerMetadata,d();break}case"reasoning-end":{const x=u.activeReasoningParts[a.id];if(x==null)throw new Xn({chunkType:"reasoning-end",chunkId:a.id,message:`Received reasoning-end for missing reasoning part with ID "${a.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-end" chunks.`});x.providerMetadata=(m=a.providerMetadata)!=null?m:x.providerMetadata,x.state="done",delete u.activeReasoningParts[a.id],d();break}case"file":{u.message.parts.push({type:"file",mediaType:a.mediaType,url:a.url,...a.providerMetadata!=null?{providerMetadata:a.providerMetadata}:{}}),d();break}case"source-url":{u.message.parts.push({type:"source-url",sourceId:a.sourceId,url:a.url,title:a.title,providerMetadata:a.providerMetadata}),d();break}case"source-document":{u.message.parts.push({type:"source-document",sourceId:a.sourceId,mediaType:a.mediaType,title:a.title,filename:a.filename,providerMetadata:a.providerMetadata}),d();break}case"tool-input-start":{const x=u.message.parts.filter(da);u.partialToolCalls[a.toolCallId]={text:"",toolName:a.toolName,index:x.length,dynamic:a.dynamic,title:a.title},a.dynamic?y({toolCallId:a.toolCallId,toolName:a.toolName,state:"input-streaming",input:void 0,providerExecuted:a.providerExecuted,title:a.title,providerMetadata:a.providerMetadata}):k({toolCallId:a.toolCallId,toolName:a.toolName,state:"input-streaming",input:void 0,providerExecuted:a.providerExecuted,title:a.title,providerMetadata:a.providerMetadata}),d();break}case"tool-input-delta":{const x=u.partialToolCalls[a.toolCallId];if(x==null)throw new Xn({chunkType:"tool-input-delta",chunkId:a.toolCallId,message:`Received tool-input-delta for missing tool call with ID "${a.toolCallId}". Ensure a "tool-input-start" chunk is sent before any "tool-input-delta" chunks.`});x.text+=a.inputTextDelta;const{value:A}=await zi(x.text);x.dynamic?y({toolCallId:a.toolCallId,toolName:x.toolName,state:"input-streaming",input:A,title:x.title}):k({toolCallId:a.toolCallId,toolName:x.toolName,state:"input-streaming",input:A,title:x.title}),d();break}case"tool-input-available":{a.dynamic?y({toolCallId:a.toolCallId,toolName:a.toolName,state:"input-available",input:a.input,providerExecuted:a.providerExecuted,providerMetadata:a.providerMetadata,title:a.title}):k({toolCallId:a.toolCallId,toolName:a.toolName,state:"input-available",input:a.input,providerExecuted:a.providerExecuted,providerMetadata:a.providerMetadata,title:a.title}),d(),s&&!a.providerExecuted&&await s({toolCall:a});break}case"tool-input-error":{const x=u.message.parts.filter(Ss).find(E=>E.toolCallId===a.toolCallId);(x!=null?x.type==="dynamic-tool":!!a.dynamic)?y({toolCallId:a.toolCallId,toolName:a.toolName,state:"output-error",input:a.input,errorText:a.errorText,providerExecuted:a.providerExecuted,providerMetadata:a.providerMetadata}):k({toolCallId:a.toolCallId,toolName:a.toolName,state:"output-error",input:void 0,rawInput:a.input,errorText:a.errorText,providerExecuted:a.providerExecuted,providerMetadata:a.providerMetadata}),d();break}case"tool-approval-request":{const x=v(a.toolCallId);x.state="approval-requested",x.approval={id:a.approvalId},d();break}case"tool-output-denied":{const x=v(a.toolCallId);x.state="output-denied",d();break}case"tool-output-available":{const x=v(a.toolCallId);x.type==="dynamic-tool"?y({toolCallId:a.toolCallId,toolName:x.toolName,state:"output-available",input:x.input,output:a.output,preliminary:a.preliminary,providerExecuted:a.providerExecuted,providerMetadata:a.providerMetadata,title:x.title}):k({toolCallId:a.toolCallId,toolName:Mu(x),state:"output-available",input:x.input,output:a.output,providerExecuted:a.providerExecuted,preliminary:a.preliminary,providerMetadata:a.providerMetadata,title:x.title}),d();break}case"tool-output-error":{const x=v(a.toolCallId);x.type==="dynamic-tool"?y({toolCallId:a.toolCallId,toolName:x.toolName,state:"output-error",input:x.input,errorText:a.errorText,providerExecuted:a.providerExecuted,providerMetadata:a.providerMetadata,title:x.title}):k({toolCallId:a.toolCallId,toolName:Mu(x),state:"output-error",input:x.input,rawInput:x.rawInput,errorText:a.errorText,providerExecuted:a.providerExecuted,providerMetadata:a.providerMetadata,title:x.title}),d();break}case"start-step":{u.message.parts.push({type:"step-start"});break}case"finish-step":{u.activeTextParts={},u.activeReasoningParts={};break}case"start":{a.messageId!=null&&(u.message.id=a.messageId),await _(a.messageMetadata),(a.messageId!=null||a.messageMetadata!=null)&&d();break}case"finish":{a.finishReason!=null&&(u.finishReason=a.finishReason),await _(a.messageMetadata),a.messageMetadata!=null&&d();break}case"message-metadata":{await _(a.messageMetadata),a.messageMetadata!=null&&d();break}case"error":{i==null||i(new Error(a.errorText));break}default:if(YA(a)){if((n==null?void 0:n[a.type])!=null){const E=u.message.parts.findIndex(S=>"id"in S&&"data"in S&&S.id===a.id&&S.type===a.type),w=E>=0?E:u.message.parts.length;await $u({value:a.data,schema:n[a.type],context:{field:`message.parts[${w}].data`,entityName:a.type,entityId:a.id}})}const x=a;if(x.transient){o==null||o(x);break}const A=x.id!=null?u.message.parts.find(E=>x.type===E.type&&x.id===E.id):void 0;A!=null?A.data=x.data:u.message.parts.push(x),o==null||o(x),d()}}c.enqueue(a)})}}))}async function tz({stream:e,onError:t}){const n=e.getReader();try{for(;;){const{done:r}=await n.read();if(r)break}}catch(r){t==null||t(r)}finally{n.releaseLock()}}Ai({prefix:"aitxt",size:24});Ai({prefix:"aiobj",size:24});var nz=class{constructor(){this.queue=[],this.isProcessing=!1}async processQueue(){if(!this.isProcessing){for(this.isProcessing=!0;this.queue.length>0;)await this.queue[0](),this.queue.shift();this.isProcessing=!1}}async run(e){return new Promise((t,n)=>{this.queue.push(async()=>{try{await e(),t()}catch(r){n(r)}}),this.processQueue()})}};Ai({prefix:"aiobj",size:24});async function rz(e){if(e==null)return[];if(!globalThis.FileList||!(e instanceof globalThis.FileList))throw new Error("FileList is not supported in the current environment");return Promise.all(Array.from(e).map(async t=>{const{name:n,type:r}=t,i=await new Promise((s,o)=>{const a=new FileReader;a.onload=c=>{var u;s((u=c.target)==null?void 0:u.result)},a.onerror=c=>o(c),a.readAsDataURL(t)});return{type:"file",mediaType:r,filename:n,url:i}}))}var iz=class{constructor({api:e="/api/chat",credentials:t,headers:n,body:r,fetch:i,prepareSendMessagesRequest:s,prepareReconnectToStreamRequest:o}){this.api=e,this.credentials=t,this.headers=n,this.body=r,this.fetch=i,this.prepareSendMessagesRequest=s,this.prepareReconnectToStreamRequest=o}async sendMessages({abortSignal:e,...t}){var n,r,i,s,o;const a=await gn(this.body),c=await gn(this.headers),u=await gn(this.credentials),d={...Yn(c),...Yn(t.headers)},f=await((n=this.prepareSendMessagesRequest)==null?void 0:n.call(this,{api:this.api,id:t.chatId,messages:t.messages,body:{...a,...t.body},headers:d,credentials:u,requestMetadata:t.metadata,trigger:t.trigger,messageId:t.messageId})),h=(r=f==null?void 0:f.api)!=null?r:this.api,p=(f==null?void 0:f.headers)!==void 0?Yn(f.headers):d,m=(f==null?void 0:f.body)!==void 0?f.body:{...a,...t.body,id:t.chatId,messages:t.messages,trigger:t.trigger,messageId:t.messageId},v=(i=f==null?void 0:f.credentials)!=null?i:u,y=await((s=this.fetch)!=null?s:globalThis.fetch)(h,{method:"POST",headers:{"Content-Type":"application/json",...p},body:JSON.stringify(m),credentials:v,signal:e});if(!y.ok)throw new Error((o=await y.text())!=null?o:"Failed to fetch the chat response.");if(!y.body)throw new Error("The response body is empty.");return this.processResponseStream(y.body)}async reconnectToStream(e){var t,n,r,i,s;const o=await gn(this.body),a=await gn(this.headers),c=await gn(this.credentials),u={...Yn(a),...Yn(e.headers)},d=await((t=this.prepareReconnectToStreamRequest)==null?void 0:t.call(this,{api:this.api,id:e.chatId,body:{...o,...e.body},headers:u,credentials:c,requestMetadata:e.metadata})),f=(n=d==null?void 0:d.api)!=null?n:`${this.api}/${e.chatId}/stream`,h=(d==null?void 0:d.headers)!==void 0?Yn(d.headers):u,p=(r=d==null?void 0:d.credentials)!=null?r:c,v=await((i=this.fetch)!=null?i:globalThis.fetch)(f,{method:"GET",headers:h,credentials:p});if(v.status===204)return null;if(!v.ok)throw new Error((s=await v.text())!=null?s:"Failed to fetch the chat response.");if(!v.body)throw new Error("The response body is empty.");return this.processResponseStream(v.body)}},Gm=class extends iz{constructor(e={}){super(e)}processResponseStream(e){return EA({stream:e,schema:KA}).pipeThrough(new TransformStream({async transform(t,n){if(!t.success)throw t.error;n.enqueue(t.value)}}))}},sz=class{constructor({generateId:e=AI,id:t=e(),transport:n=new Gm,messageMetadataSchema:r,dataPartSchemas:i,state:s,onError:o,onToolCall:a,onFinish:c,onData:u,sendAutomaticallyWhen:d}){this.activeResponse=void 0,this.jobExecutor=new nz,this.sendMessage=async(f,h)=>{var p,m,v,k;if(f==null){await this.makeRequest({trigger:"submit-message",messageId:(p=this.lastMessage)==null?void 0:p.id,...h});return}let y;if("text"in f||"files"in f?y={parts:[...Array.isArray(f.files)?f.files:await rz(f.files),..."text"in f&&f.text!=null?[{type:"text",text:f.text}]:[]]}:y=f,f.messageId!=null){const _=this.state.messages.findIndex(x=>x.id===f.messageId);if(_===-1)throw new Error(`message with id ${f.messageId} not found`);if(this.state.messages[_].role!=="user")throw new Error(`message with id ${f.messageId} is not a user message`);this.state.messages=this.state.messages.slice(0,_+1),this.state.replaceMessage(_,{...y,id:f.messageId,role:(m=y.role)!=null?m:"user",metadata:f.metadata})}else this.state.pushMessage({...y,id:(v=y.id)!=null?v:this.generateId(),role:(k=y.role)!=null?k:"user",metadata:f.metadata});await this.makeRequest({trigger:"submit-message",messageId:f.messageId,...h})},this.regenerate=async({messageId:f,...h}={})=>{const p=f==null?this.state.messages.length-1:this.state.messages.findIndex(m=>m.id===f);if(p===-1)throw new Error(`message ${f} not found`);this.state.messages=this.state.messages.slice(0,this.messages[p].role==="assistant"?p:p+1),await this.makeRequest({trigger:"regenerate-message",messageId:f,...h})},this.resumeStream=async(f={})=>{await this.makeRequest({trigger:"resume-stream",...f})},this.clearError=()=>{this.status==="error"&&(this.state.error=void 0,this.setStatus({status:"ready"}))},this.addToolApprovalResponse=async({id:f,approved:h,reason:p,options:m})=>this.jobExecutor.run(async()=>{const v=this.state.messages,k=v[v.length-1],y=_=>Ss(_)&&_.state==="approval-requested"&&_.approval.id===f?{..._,state:"approval-responded",approval:{id:f,approved:h,reason:p}}:_;this.state.replaceMessage(v.length-1,{...k,parts:k.parts.map(y)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(y)),this.status!=="streaming"&&this.status!=="submitted"&&this.sendAutomaticallyWhen&&this.shouldSendAutomatically().then(_=>{var x;_&&this.makeRequest({trigger:"submit-message",messageId:(x=this.lastMessage)==null?void 0:x.id,...m})})}),this.addToolOutput=async({state:f="output-available",toolCallId:h,output:p,errorText:m,options:v})=>this.jobExecutor.run(async()=>{const k=this.state.messages,y=k[k.length-1],_=x=>Ss(x)&&x.toolCallId===h?{...x,state:f,output:p,errorText:m}:x;this.state.replaceMessage(k.length-1,{...y,parts:y.parts.map(_)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(_)),this.status!=="streaming"&&this.status!=="submitted"&&this.sendAutomaticallyWhen&&this.shouldSendAutomatically().then(x=>{var A;x&&this.makeRequest({trigger:"submit-message",messageId:(A=this.lastMessage)==null?void 0:A.id,...v})})}),this.addToolResult=this.addToolOutput,this.stop=async()=>{var f;this.status!=="streaming"&&this.status!=="submitted"||(f=this.activeResponse)!=null&&f.abortController&&this.activeResponse.abortController.abort()},this.id=t,this.transport=n,this.generateId=e,this.messageMetadataSchema=r,this.dataPartSchemas=i,this.state=s,this.onError=o,this.onToolCall=a,this.onFinish=c,this.onData=u,this.sendAutomaticallyWhen=d}get status(){return this.state.status}setStatus({status:e,error:t}){this.status!==e&&(this.state.status=e,this.state.error=t)}get error(){return this.state.error}get messages(){return this.state.messages}get lastMessage(){return this.state.messages[this.state.messages.length-1]}set messages(e){this.state.messages=e}async shouldSendAutomatically(){if(!this.sendAutomaticallyWhen)return!1;const e=this.sendAutomaticallyWhen({messages:this.state.messages});return e&&typeof e=="object"&&"then"in e?await e:e}async makeRequest({trigger:e,metadata:t,headers:n,body:r,messageId:i}){var s,o,a;let c;if(e==="resume-stream")try{const p=await this.transport.reconnectToStream({chatId:this.id,metadata:t,headers:n,body:r});if(p==null)return;c=p}catch(p){this.onError&&p instanceof Error&&this.onError(p),this.setStatus({status:"error",error:p});return}this.setStatus({status:"submitted",error:void 0});const u=this.lastMessage;let d=!1,f=!1,h=!1;try{const p={state:QA({lastMessage:this.state.snapshot(u),messageId:this.generateId()}),abortController:new AbortController};p.abortController.signal.addEventListener("abort",()=>{d=!0}),this.activeResponse=p;let m;e==="resume-stream"?m=c:m=await this.transport.sendMessages({chatId:this.id,messages:this.state.messages,abortSignal:p.abortController.signal,metadata:t,headers:n,body:r,trigger:e,messageId:i});const v=k=>this.jobExecutor.run(()=>k({state:p.state,write:()=>{var y;this.setStatus({status:"streaming"}),p.state.message.id===((y=this.lastMessage)==null?void 0:y.id)?this.state.replaceMessage(this.state.messages.length-1,p.state.message):this.state.pushMessage(p.state.message)}}));await tz({stream:ez({stream:m,onToolCall:this.onToolCall,onData:this.onData,messageMetadataSchema:this.messageMetadataSchema,dataPartSchemas:this.dataPartSchemas,runUpdateMessageJob:v,onError:k=>{throw k}}),onError:k=>{throw k}}),this.setStatus({status:"ready"})}catch(p){if(d||p.name==="AbortError")return d=!0,this.setStatus({status:"ready"}),null;h=!0,p instanceof TypeError&&(p.message.toLowerCase().includes("fetch")||p.message.toLowerCase().includes("network"))&&(f=!0),this.onError&&p instanceof Error&&this.onError(p),this.setStatus({status:"error",error:p})}finally{try{(o=this.onFinish)==null||o.call(this,{message:this.activeResponse.state.message,messages:this.state.messages,isAbort:d,isDisconnect:f,isError:h,finishReason:(s=this.activeResponse)==null?void 0:s.state.finishReason})}catch(p){console.error(p)}this.activeResponse=void 0}!h&&await this.shouldSendAutomatically()&&await this.makeRequest({trigger:"submit-message",messageId:(a=this.lastMessage)==null?void 0:a.id,metadata:t,headers:n,body:r})}},To,Fu;function oz(){if(Fu)return To;Fu=1;function e(t,n){if(typeof t!="function")throw new TypeError(`Expected the first argument to be a \`function\`, got \`${typeof t}\`.`);let r,i=0;return function(...o){clearTimeout(r);const a=Date.now(),c=a-i,u=n-c;u<=0?(i=a,t.apply(this,o)):r=setTimeout(()=>{i=Date.now(),t.apply(this,o)},u)}}return To=e,To}var az=oz();const lz=ga(az);var Km=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},We=(e,t,n)=>(Km(e,t,"read from private field"),n?n.call(e):t.get(e)),Kt=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},mn=(e,t,n,r)=>(Km(e,t,"write to private field"),t.set(e,n),n);function cz(e,t){return t!=null?lz(e,t):e}var Pt,Ki,Yi,Gr,Kr,Yr,rr,fa,pa,uz=class{constructor(e=[]){Kt(this,Pt,void 0),Kt(this,Ki,"ready"),Kt(this,Yi,void 0),Kt(this,Gr,new Set),Kt(this,Kr,new Set),Kt(this,Yr,new Set),this.pushMessage=t=>{mn(this,Pt,We(this,Pt).concat(t)),We(this,rr).call(this)},this.popMessage=()=>{mn(this,Pt,We(this,Pt).slice(0,-1)),We(this,rr).call(this)},this.replaceMessage=(t,n)=>{mn(this,Pt,[...We(this,Pt).slice(0,t),this.snapshot(n),...We(this,Pt).slice(t+1)]),We(this,rr).call(this)},this.snapshot=t=>structuredClone(t),this["~registerMessagesCallback"]=(t,n)=>{const r=n?cz(t,n):t;return We(this,Gr).add(r),()=>{We(this,Gr).delete(r)}},this["~registerStatusCallback"]=t=>(We(this,Kr).add(t),()=>{We(this,Kr).delete(t)}),this["~registerErrorCallback"]=t=>(We(this,Yr).add(t),()=>{We(this,Yr).delete(t)}),Kt(this,rr,()=>{We(this,Gr).forEach(t=>t())}),Kt(this,fa,()=>{We(this,Kr).forEach(t=>t())}),Kt(this,pa,()=>{We(this,Yr).forEach(t=>t())}),mn(this,Pt,e)}get status(){return We(this,Ki)}set status(e){mn(this,Ki,e),We(this,fa).call(this)}get error(){return We(this,Yi)}set error(e){mn(this,Yi,e),We(this,pa).call(this)}get messages(){return We(this,Pt)}set messages(e){mn(this,Pt,[...e]),We(this,rr).call(this)}};Pt=new WeakMap;Ki=new WeakMap;Yi=new WeakMap;Gr=new WeakMap;Kr=new WeakMap;Yr=new WeakMap;rr=new WeakMap;fa=new WeakMap;pa=new WeakMap;var ir,Lu=class extends sz{constructor({messages:e,...t}){const n=new uz(e);super({...t,state:n}),Kt(this,ir,void 0),this["~registerMessagesCallback"]=(r,i)=>We(this,ir)["~registerMessagesCallback"](r,i),this["~registerStatusCallback"]=r=>We(this,ir)["~registerStatusCallback"](r),this["~registerErrorCallback"]=r=>We(this,ir)["~registerErrorCallback"](r),mn(this,ir,n)}};ir=new WeakMap;function dz({experimental_throttle:e,resume:t=!1,...n}={}){const r=g.useRef("chat"in n?{}:{onToolCall:n.onToolCall,onData:n.onData,onFinish:n.onFinish,onError:n.onError,sendAutomaticallyWhen:n.sendAutomaticallyWhen});"chat"in n||(r.current={onToolCall:n.onToolCall,onData:n.onData,onFinish:n.onFinish,onError:n.onError,sendAutomaticallyWhen:n.sendAutomaticallyWhen});const i={...n,onToolCall:h=>{var p,m;return(m=(p=r.current).onToolCall)==null?void 0:m.call(p,h)},onData:h=>{var p,m;return(m=(p=r.current).onData)==null?void 0:m.call(p,h)},onFinish:h=>{var p,m;return(m=(p=r.current).onFinish)==null?void 0:m.call(p,h)},onError:h=>{var p,m;return(m=(p=r.current).onError)==null?void 0:m.call(p,h)},sendAutomaticallyWhen:h=>{var p,m,v;return(v=(m=(p=r.current).sendAutomaticallyWhen)==null?void 0:m.call(p,h))!=null?v:!1}},s=g.useRef("chat"in n?n.chat:new Lu(i));("chat"in n&&n.chat!==s.current||"id"in n&&s.current.id!==n.id)&&(s.current="chat"in n?n.chat:new Lu(i));const a=g.useCallback(h=>s.current["~registerMessagesCallback"](h,e),[e,s.current.id]),c=g.useSyncExternalStore(a,()=>s.current.messages,()=>s.current.messages),u=g.useSyncExternalStore(s.current["~registerStatusCallback"],()=>s.current.status,()=>s.current.status),d=g.useSyncExternalStore(s.current["~registerErrorCallback"],()=>s.current.error,()=>s.current.error),f=g.useCallback(h=>{typeof h=="function"&&(h=h(s.current.messages)),s.current.messages=h},[s]);return g.useEffect(()=>{t&&s.current.resumeStream()},[t,s]),{id:s.current.id,messages:c,setMessages:f,sendMessage:s.current.sendMessage,regenerate:s.current.regenerate,clearError:s.current.clearError,stop:s.current.stop,error:d,resumeStream:s.current.resumeStream,status:u,addToolResult:s.current.addToolOutput,addToolOutput:s.current.addToolOutput,addToolApprovalResponse:s.current.addToolApprovalResponse}}function fz(e,t){const n={...e};for(const[r,i]of Object.entries(t))i===null?delete n[r]:i&&typeof i=="object"&&(n[r]=i);return n}function Ym(e,t){const n=t==null?void 0:t.blocks;if(!n||typeof n!="object"||Array.isArray(n))return null;const r={...e,props:{...(e==null?void 0:e.props)??{}}};return r.props.blocks=fz(r.props.blocks||{},n),r}function Xm(e){let t=0;for(let n=0;n<e.length;n++)t=Math.imul(31,t)+e.charCodeAt(n)|0;return(t>>>0).toString(36)}function Qm(e,t,n){if(!(n!=null&&n.selectedText)){const i=pz(e,t);if(i)return i}if(n!=null&&n.selectedText){const i=n.selectedText,s=e.indexOf(i);if(s!==-1){const a=e.indexOf(i,s+1);let c;if(a===-1)c=s;else if(n.startLine&&n.startLine>0){const f=bz(e,n.startLine);c=vz(e,i,f)}else c=s;const u=e.slice(0,c),d=e.slice(c+i.length);return{original:e,modified:u+t+d}}if(n.startLine&&n.endLine){const a=xz(e,t,n.startLine,n.endLine);if(a)return a}const o=Bu(e,t);return o||{original:e,modified:t}}const r=Bu(e,t);return r||{original:e,modified:t}}function pz(e,t){let n;try{n=JSON.parse(t)}catch{return null}if(!n||typeof n!="object"||Array.isArray(n))return null;const r=n.name;if(typeof r!="string"||!r)return null;let i;try{i=JSON.parse(e)}catch{return null}const s=e.match(/\n(\s+)"/),o=s?s[1].length:2;if(!ha(i,r,n))return null;const a=JSON.stringify(i,null,o);return{original:e,modified:a}}function ha(e,t,n){if(Array.isArray(e)){for(let r=0;r<e.length;r++){const i=e[r];if(i&&typeof i=="object"&&!Array.isArray(i)&&i.name===t)return e[r]=n,!0;if(ha(i,t,n))return!0}return!1}if(e&&typeof e=="object"){for(const r of Object.values(e))if(ha(r,t,n))return!0}return!1}function Bu(e,t){try{const s=JSON.parse(t);if(s&&typeof s=="object"&&!Array.isArray(s))try{const o=JSON.parse(e);if(o&&typeof o=="object"&&!Array.isArray(o)){const a=Object.keys(s).sort().join(","),c=Object.keys(o).sort().join(",");if(a===c)return null}}catch{}}catch{}const n=hz(t);if(n.length===0)return null;let r=e,i=!1;for(const s of n){const o=mz(r,t,s);o&&(r=o,i=!0)}return i?{original:e,modified:r}:null}function hz(e){const t=[],n=e.split(`
|
|
229
|
+
`),r=n.find(s=>s.trim().length>0);if(!r)return t;const i=r.search(/\S/);for(const s of n){const o=s.search(/\S/);if(o<0||o!==i)continue;const a=s.match(/^\s*"([^"]+)"\s*:/);a&&t.push(a[1])}return[...new Set(t)]}function mz(e,t,n){const r=`"${n}"`,i=Zu(e,r);if(i.length===0)return null;const s=Zu(t,r);if(s.length===0)return null;const o=s[0],a=t.slice(o.start,o.end);let c=0;if(i.length>1){let d=-1;for(let f=0;f<i.length;f++){const h=e.slice(i[f].start,i[f].end),p=yz(h,a);p>d&&(d=p,c=f)}}const u=i[c];return e.slice(0,u.start)+a+e.slice(u.end)}function Zu(e,t){const n=[];let r=0;for(;;){const i=e.indexOf(t,r);if(i===-1)break;let s=i-1;for(;s>=0&&(e[s]===" "||e[s]===" ");)s--;const o=s<0?"":e[s];if(o!==""&&o!=="{"&&o!==","&&o!==`
|
|
230
|
+
`&&o!=="\r"){r=i+1;continue}const a=e.indexOf(":",i+t.length);if(a===-1){r=i+1;continue}const c=a+1,u=gz(e,c);if(u===-1){r=i+1;continue}n.push({start:i,end:u}),r=u}return n}function gz(e,t){for(;t<e.length&&/\s/.test(e[t]);)t++;if(t>=e.length)return-1;const n=e[t];if(n==='"'){let i=t+1;for(;i<e.length;){if(e[i]==="\\"){i+=2;continue}if(e[i]==='"')return i+1;i++}return-1}if(n==="["||n==="{"){const i=n,s=n==="["?"]":"}";let o=1,a=t+1,c=!1;for(;a<e.length&&o>0;){if(e[a]==="\\"&&c){a+=2;continue}e[a]==='"'&&(c=!c),c||(e[a]===i?o++:e[a]===s&&o--),a++}return o===0?a:-1}let r=t;for(;r<e.length&&/[^\s,\]}]/.test(e[r]);)r++;return r>t?r:-1}function xz(e,t,n,r){const i=e.split(`
|
|
231
|
+
`);if(n<1||r<n||n>i.length)return null;const s=i.slice(0,n-1).join(`
|
|
232
|
+
`),o=i.slice(r).join(`
|
|
233
|
+
`),a=s+(s?`
|
|
234
|
+
`:"")+t+(o?`
|
|
235
|
+
`:"")+o;return{original:e,modified:a}}function yz(e,t){if(e===t)return 1;if(!e.length||!t.length)return 0;const n=3,r=new Set;for(let o=0;o<=e.length-n;o++)r.add(e.slice(o,o+n));let i=0;for(let o=0;o<=t.length-n;o++)r.has(t.slice(o,o+n))&&i++;const s=Math.max(e.length-n+1,t.length-n+1);return s>0?i/s:0}function bz(e,t){let n=0;const r=e.split(`
|
|
236
|
+
`);for(let i=0;i<Math.min(t-1,r.length);i++)n+=r[i].length+1;return n}function vz(e,t,n){let r=-1,i=1/0,s=e.indexOf(t);for(;s!==-1;){const o=Math.abs(s-n);o<i&&(i=o,r=s),s=e.indexOf(t,s+1)}return r}function wz(e){const t=e[e.length-1][1];try{return JSON.parse(t),t}catch{}if(e.length>1){const n=e.map(r=>r[1]).join(`
|
|
237
|
+
`);try{return JSON.parse(n),n}catch{}}return null}function kz(e,t,n){if(n==="global")return null;try{const r=JSON.parse(e),i=JSON.parse(t);if(n==="slides"&&Array.isArray(i.children))r.children=i.children;else if(n==="blocks"){const s=Ym(r,i);return s?{original:e,modified:JSON.stringify(s,null,2)}:null}else return null;return{original:e,modified:JSON.stringify(r,null,2)}}catch{return null}}function Sz(){const e=De(J=>J.threads),t=De(J=>J.activeThreadId),n=De(J=>J.updateThreadMessages),r=De(J=>J.updateThreadTitle),i=De(J=>J.clearContext),s=De(J=>J.contextAttachments),o=De(J=>J.scope),a=De(J=>J.model),c=ke(J=>J.activeTab),u=ke(J=>J.documents),d=ke(J=>J.documentTypes),f=ke(J=>J.setPendingDiff),h=ke(J=>J.createDocument),p=ke(J=>J.openDocument),m=g.useRef(e);m.current=e;const v=g.useRef(c);v.current=c;const k=g.useRef(u);k.current=u;const y=g.useRef(d);y.current=d;const _=g.useRef(t);_.current=t;const x=c?t[c]:void 0,A=g.useRef(x);A.current=x;const E=g.useRef([]),w=g.useRef([]),S=g.useRef({}),O=g.useRef({}),[,B]=g.useState(0),N=g.useCallback(()=>B(J=>J+1),[]),R=g.useRef(null);R.current||(R.current=new Gm({api:"/api/ai/chat"}));const T=g.useCallback(()=>{const J=k.current.find(V=>V.name===v.current);return J?{name:J.name,text:J.text}:void 0},[]),F=g.useCallback(J=>S.current[J]||[],[]),$=dz({transport:R.current,onError:()=>{E.current.shift(),w.current.shift(),i()},onFinish:({messages:J})=>{var G,ne;const V=A.current;if(V){n(V,J);const Q=m.current[V];if(Q&&Q.title.startsWith("Chat ")){const oe=J.find(I=>I.role==="user");if(oe){const I=((G=oe.parts)==null?void 0:G.filter(re=>re.type==="text").map(re=>re.text).join(""))||"";if(I){const re=I.length>50?I.slice(0,50)+"...":I;r(V,re)}}}}const X=E.current.shift()||[],j=w.current.shift()||"global",ye=J.filter(Q=>Q.role==="user"),ce=ye[ye.length-1];ce!=null&&ce.id&&(S.current[ce.id]=X,O.current[ce.id]=j);const b=J.filter(Q=>Q.role==="assistant").pop();if(b){const oe=[...(((ne=b.parts)==null?void 0:ne.filter(I=>I.type==="text").map(I=>I.text).join(""))||"").matchAll(/```(?:json|jsonc)\s*\n([\s\S]*?)```/g)];if(oe.length>0){const I=wz(oe);if(I){const re=oe[oe.length-1][1],ae=v.current;if(ae){const H=k.current.find($e=>$e.name===ae),K=(H==null?void 0:H.text)||"",pe=X[0],fe=kz(K,I,j);!fe&&j!=="global"&&console.warn(`[chat] scopedMerge failed for scope="${j}", falling back to text merge`);const{original:Re,modified:Oe}=fe??Qm(K,I,pe);f(ae,Re,Oe,Xm(re.replace(/\n$/,"")))}else{const H=`ai-generated-${Date.now()}`;h(H,I),p(H)}}}}i()}});g.useEffect(()=>{const J=$.messages.filter(V=>V.role==="user");for(let V=J.length-1;V>=0;V--){const X=J[V].id;if(X in S.current)break;E.current.length>0&&(S.current[X]=E.current[0],O.current[X]=w.current[0]||"global",N());break}},[$.messages,N]);const Z=g.useCallback((J,V)=>{E.current.push([...s]),w.current.push(o),i();const X={text:J};V!=null&&V.length&&(X.files=V),$.sendMessage(X,{body:{format:at,context:s,activeDocument:T(),documentType:v.current&&y.current[v.current]||"application/json+report",scope:o,model:a}})},[$.sendMessage,s,T,i,o,a]),P=g.useCallback(J=>O.current[J],[]);return{messages:$.messages,sendMessage:Z,status:$.status,error:$.error,setMessages:$.setMessages,stop:$.stop,getMessageContext:F,getMessageScope:P}}const eg=g.createContext(null);function jz({children:e}){const t=Sz();return l.jsx(eg.Provider,{value:t,children:e})}function _z(){const e=g.useContext(eg);if(!e)throw new Error("useChatSessionContext must be used within ChatSessionProvider");return e}function Nz(e){try{const t=JSON.parse(e.selectedText);if(t!=null&&t.name)return t.name}catch{}return e.propertyKey?e.propertyKey:e.jsonPath?(e.jsonPath.split(".").pop()??e.jsonPath).replace(/\[\d+\]/g,""):"selection"}function Cz(e,t=50){const n=e.replace(/[\n\r]+/g," ").replace(/\s+/g," ").trim();return n.length>t?n.slice(0,t)+"…":n}function tg({context:e,onRemove:t,variant:n="default"}){var u;const r=Nz(e),i=((u=e.documentName)==null?void 0:u.replace(/\.json$/,""))??"",s=i?`${i} › ${r}`:r,o=Cz(e.selectedText),a=n==="sent",c=l.jsxs("div",{className:`group flex items-center gap-1.5 rounded-md border pl-2 ${t?"pr-1":"pr-2"} py-1 text-xs max-w-[280px] transition-colors ${a?"border-primary-foreground/20 bg-primary-foreground/10 hover:bg-primary-foreground/20":"border-primary/20 bg-primary/5 hover:bg-primary/10"}`,children:[l.jsx(Ax,{className:`h-3 w-3 shrink-0 ${a?"text-primary-foreground/60":"text-primary/60"}`}),l.jsx("span",{className:"truncate font-medium",children:s}),t&&l.jsx("button",{type:"button",onClick:t,className:"shrink-0 rounded-sm p-0.5 opacity-60 hover:opacity-100 hover:bg-muted transition-opacity cursor-pointer","aria-label":"Remove context",children:l.jsx(wn,{className:"h-3 w-3"})})]});return l.jsxs(Ye,{children:[l.jsx(Xe,{asChild:!0,children:c}),l.jsxs(Qe,{side:"top",className:"max-w-xs",children:[l.jsx("p",{className:"text-xs font-medium mb-0.5",children:s}),l.jsx("p",{className:"text-xs text-muted-foreground font-mono",children:o}),e.jsonPath&&l.jsx("p",{className:"text-[10px] text-muted-foreground/60 mt-1",children:e.jsonPath})]})]})}class Qn extends Error{constructor(t,n){super(`${t} at position ${n}`),this.position=n}}const ng=32,Ez=10,rg=9,ig=13,Tz=160,Iz=6158,Az=8192,zz=8203,Oz=8239,Pz=8287,Dz=12288,Rz=65279;function $z(e){return/^[0-9A-Fa-f]$/.test(e)}function An(e){return e>="0"&&e<="9"}function Mz(e){return e>=" "}function Ji(e){return`,:[]/{}()
|
|
238
|
+
+`.includes(e)}function Vu(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"||e==="_"||e==="$"}function Uu(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"||e==="_"||e==="$"||e>="0"&&e<="9"}const Ju=/^(http|https|ftp|mailto|file|data|irc):\/\/$/,Hu=/^[A-Za-z0-9-._~:/?#@!$&'()*+;=]$/;function Wu(e){return`,[]/{}
|
|
239
|
+
+`.includes(e)}function qu(e){return Xi(e)||Fz.test(e)}const Fz=/^[[{\w-]$/;function Lz(e){return e===`
|
|
240
|
+
`||e==="\r"||e===" "||e==="\b"||e==="\f"}function zn(e,t){const n=e.charCodeAt(t);return n===ng||n===Ez||n===rg||n===ig}function Bz(e,t){const n=e.charCodeAt(t);return n===ng||n===rg||n===ig}function Zz(e,t){const n=e.charCodeAt(t);return n===Tz||n===Iz||n>=Az&&n<=zz||n===Oz||n===Pz||n===Dz||n===Rz}function Xi(e){return sg(e)||ma(e)}function sg(e){return e==='"'||e==="“"||e==="”"}function Gu(e){return e==='"'}function ma(e){return e==="'"||e==="‘"||e==="’"||e==="`"||e==="´"}function Ku(e){return e==="'"}function Ur(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;const r=e.lastIndexOf(t);return r!==-1?e.substring(0,r)+(n?"":e.substring(r+1)):e}function Vt(e,t){let n=e.length;if(!zn(e,n-1))return e+t;for(;zn(e,n-1);)n--;return e.substring(0,n)+t+e.substring(n)}function Vz(e,t,n){return e.substring(0,t)+e.substring(t+n)}function Uz(e){return/[,\n][ \t\r]*$/.test(e)}const Jz={"\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t"},Hz={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:`
|
|
241
|
+
`,r:"\r",t:" "};function Yu(e){let t=0,n="";u(["```","[```","{```"]),s()||$(),u(["```","```]","```}"]);const i=f(",");for(i&&o(),qu(e[t])&&Uz(n)?(i||(n=Vt(n,",")),y()):i&&(n=Ur(n,","));e[t]==="}"||e[t]==="]";)t++,o();if(t>=e.length)return n;F();function s(){o();const V=v()||k()||_()||A()||E()||S(!1)||O();return o(),V}function o(){let V=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;const X=t;let j=a(V);do j=c(),j&&(j=a(V));while(j);return t>X}function a(V){const X=V?zn:Bz;let j="";for(;;)if(X(e,t))j+=e[t],t++;else if(Zz(e,t))j+=" ",t++;else break;return j.length>0?(n+=j,!0):!1}function c(){if(e[t]==="/"&&e[t+1]==="*"){for(;t<e.length&&!Wz(e,t);)t++;return t+=2,!0}if(e[t]==="/"&&e[t+1]==="/"){for(;t<e.length&&e[t]!==`
|
|
242
|
+
`;)t++;return!0}return!1}function u(V){if(d(V)){if(Vu(e[t]))for(;t<e.length&&Uu(e[t]);)t++;return o(),!0}return!1}function d(V){a(!0);for(const X of V){const j=t+X.length;if(e.slice(t,j)===X)return t=j,!0}return!1}function f(V){return e[t]===V?(n+=e[t],t++,!0):!1}function h(V){return e[t]===V?(t++,!0):!1}function p(){return h("\\")}function m(){return o(),e[t]==="."&&e[t+1]==="."&&e[t+2]==="."?(t+=3,o(),h(","),!0):!1}function v(){if(e[t]==="{"){n+="{",t++,o(),h(",")&&o();let V=!0;for(;t<e.length&&e[t]!=="}";){let X;if(V?(X=!0,V=!1):(X=f(","),X||(n=Vt(n,",")),o()),m(),!(_()||S(!0))){e[t]==="}"||e[t]==="{"||e[t]==="]"||e[t]==="["||e[t]===void 0?n=Ur(n,","):Z();break}o();const ye=f(":"),ce=t>=e.length;ye||(qu(e[t])||ce?n=Vt(n,":"):P()),s()||(ye||ce?n+="null":P())}return e[t]==="}"?(n+="}",t++):n=Vt(n,"}"),!0}return!1}function k(){if(e[t]==="["){n+="[",t++,o(),h(",")&&o();let V=!0;for(;t<e.length&&e[t]!=="]";)if(V?V=!1:f(",")||(n=Vt(n,",")),m(),!s()){n=Ur(n,",");break}return e[t]==="]"?(n+="]",t++):n=Vt(n,"]"),!0}return!1}function y(){let V=!0,X=!0;for(;X;)V?V=!1:f(",")||(n=Vt(n,",")),X=s();X||(n=Ur(n,",")),n=`[
|
|
243
|
+
${n}
|
|
244
|
+
]`}function _(){let V=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,X=arguments.length>1&&arguments[1]!==void 0?arguments[1]:-1,j=e[t]==="\\";if(j&&(t++,j=!0),Xi(e[t])){const ye=Gu(e[t])?Gu:Ku(e[t])?Ku:ma(e[t])?ma:sg,ce=t,b=n.length;let G='"';for(t++;;){if(t>=e.length){const ne=B(t-1);return!V&&Ji(e.charAt(ne))?(t=ce,n=n.substring(0,b),_(!0)):(G=Vt(G,'"'),n+=G,!0)}if(t===X)return G=Vt(G,'"'),n+=G,!0;if(ye(e[t])){const ne=t,Q=G.length;if(G+='"',t++,n+=G,o(!1),V||t>=e.length||Ji(e[t])||Xi(e[t])||An(e[t]))return x(),!0;const oe=B(ne-1),I=e.charAt(oe);if(I===",")return t=ce,n=n.substring(0,b),_(!1,oe);if(Ji(I))return t=ce,n=n.substring(0,b),_(!0);n=n.substring(0,b),t=ne+1,G=`${G.substring(0,Q)}\\${G.substring(Q)}`}else if(V&&Wu(e[t])){if(e[t-1]===":"&&Ju.test(e.substring(ce+1,t+2)))for(;t<e.length&&Hu.test(e[t]);)G+=e[t],t++;return G=Vt(G,'"'),n+=G,x(),!0}else if(e[t]==="\\"){const ne=e.charAt(t+1);if(Hz[ne]!==void 0)G+=e.slice(t,t+2),t+=2;else if(ne==="u"){let oe=2;for(;oe<6&&$z(e[t+oe]);)oe++;oe===6?(G+=e.slice(t,t+6),t+=6):t+oe>=e.length?t=e.length:J()}else G+=ne,t+=2}else{const ne=e.charAt(t);ne==='"'&&e[t-1]!=="\\"?(G+=`\\${ne}`,t++):Lz(ne)?(G+=Jz[ne],t++):(Mz(ne)||T(ne),G+=ne,t++)}j&&p()}}return!1}function x(){let V=!1;for(o();e[t]==="+";){V=!0,t++,o(),n=Ur(n,'"',!0);const X=n.length;_()?n=Vz(n,X,1):n=Vt(n,'"')}return V}function A(){const V=t;if(e[t]==="-"){if(t++,N())return R(V),!0;if(!An(e[t]))return t=V,!1}for(;An(e[t]);)t++;if(e[t]==="."){if(t++,N())return R(V),!0;if(!An(e[t]))return t=V,!1;for(;An(e[t]);)t++}if(e[t]==="e"||e[t]==="E"){if(t++,(e[t]==="-"||e[t]==="+")&&t++,N())return R(V),!0;if(!An(e[t]))return t=V,!1;for(;An(e[t]);)t++}if(!N())return t=V,!1;if(t>V){const X=e.slice(V,t),j=/^0\d/.test(X);return n+=j?`"${X}"`:X,!0}return!1}function E(){return w("true","true")||w("false","false")||w("null","null")||w("True","true")||w("False","false")||w("None","null")}function w(V,X){return e.slice(t,t+V.length)===V?(n+=X,t+=V.length,!0):!1}function S(V){const X=t;if(Vu(e[t])){for(;t<e.length&&Uu(e[t]);)t++;let j=t;for(;zn(e,j);)j++;if(e[j]==="(")return t=j+1,s(),e[t]===")"&&(t++,e[t]===";"&&t++),!0}for(;t<e.length&&!Wu(e[t])&&!Xi(e[t])&&(!V||e[t]!==":");)t++;if(e[t-1]===":"&&Ju.test(e.substring(X,t+2)))for(;t<e.length&&Hu.test(e[t]);)t++;if(t>X){for(;zn(e,t-1)&&t>0;)t--;const j=e.slice(X,t);return n+=j==="undefined"?"null":JSON.stringify(j),e[t]==='"'&&t++,!0}}function O(){if(e[t]==="/"){const V=t;for(t++;t<e.length&&(e[t]!=="/"||e[t-1]==="\\");)t++;return t++,n+=JSON.stringify(e.substring(V,t)),!0}}function B(V){let X=V;for(;X>0&&zn(e,X);)X--;return X}function N(){return t>=e.length||Ji(e[t])||zn(e,t)}function R(V){n+=`${e.slice(V,t)}0`}function T(V){throw new Qn(`Invalid character ${JSON.stringify(V)}`,t)}function F(){throw new Qn(`Unexpected character ${JSON.stringify(e[t])}`,t)}function $(){throw new Qn("Unexpected end of json string",e.length)}function Z(){throw new Qn("Object key expected",t)}function P(){throw new Qn("Colon expected",t)}function J(){const V=e.slice(t,t+6);throw new Qn(`Invalid unicode character "${V}"`,t)}}function Wz(e,t){return e[t]==="*"&&e[t+1]==="/"}function qz({json:e,context:t,scope:n}){const[r,i]=g.useState(!1),[s,o]=g.useState(null),a=g.useMemo(()=>{try{return JSON.parse(e),e}catch{}try{return Yu(e)}catch{}const y=`{${e}}`;try{return JSON.parse(y),y}catch{}try{return Yu(y)}catch{return null}},[e]),c=g.useMemo(()=>Xm(a||e),[a,e]),u=ke(y=>y.activeTab),d=ke(y=>y.documents),f=ke(y=>(y.acceptedApplyIds||[]).includes(c)),h=ke(y=>y.setPendingDiff),p=ke(y=>y.createDocument),m=ke(y=>y.openDocument),v=g.useCallback(()=>{if(a){o(null);try{if(u){const y=d.find(w=>w.name===u),_=(y==null?void 0:y.text)||"";if(n==="blocks")try{const w=Ym(JSON.parse(_),JSON.parse(a));if(w){const S=JSON.stringify(w,null,2);h(u,_,S,c);return}}catch{}const x=t==null?void 0:t[0],{original:A,modified:E}=Qm(_,a,x);h(u,A,E,c)}else{const y=`ai-generated-${Date.now()}`;p(y,a),m(y)}}catch(y){o(y instanceof Error?y.message:"Merge failed")}}},[a,u,d,h,p,m,t,n,c]),k=g.useCallback(async()=>{await navigator.clipboard.writeText(e),i(!0),setTimeout(()=>i(!1),1500)},[e]);return l.jsxs("div",{className:"flex flex-col gap-1 px-3 py-2 border-t",children:[l.jsxs("div",{className:"flex gap-1.5",children:[l.jsx(Ce,{variant:"secondary",size:"sm",onClick:v,disabled:f||!a,children:f?"Applied":a?"Apply to Editor":"Invalid JSON"}),l.jsx(Ce,{variant:"ghost",size:"sm",onClick:k,children:r?l.jsx(un,{className:"h-3.5 w-3.5"}):l.jsx(Es,{className:"h-3.5 w-3.5"})})]}),s&&l.jsx("p",{className:"text-xs text-destructive m-0",children:s})]})}function Gz({threads:e,activeThread:t,disabled:n,onSwitch:r,onCreate:i,onDelete:s,onRename:o}){const[a,c]=g.useState(null),[u,d]=g.useState(""),[f,h]=g.useState(null),p=g.useRef(null),m=(t==null?void 0:t.title)||"New Chat",v=m.length>24?m.slice(0,24)+"...":m;g.useEffect(()=>{a&&requestAnimationFrame(()=>{var S;return(S=p.current)==null?void 0:S.focus()})},[a]);const k=g.useCallback((S,O)=>{O.stopPropagation(),O.preventDefault(),c(S.id),d(S.title),h(null)},[]),y=g.useCallback(()=>{a&&u.trim()&&o(a,u.trim()),c(null),d("")},[a,u,o]),_=g.useCallback(()=>{c(null),d("")},[]),x=g.useCallback(S=>{S.stopPropagation(),S.key==="Enter"?(S.preventDefault(),y()):S.key==="Escape"&&(S.preventDefault(),_())},[y,_]),A=g.useCallback((S,O)=>{O.stopPropagation(),O.preventDefault(),h(S),c(null)},[]),E=g.useCallback(S=>{S.stopPropagation(),S.preventDefault(),f&&(s(f),h(null))},[f,s]),w=g.useCallback(S=>{S.stopPropagation(),S.preventDefault(),h(null)},[]);return l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsxs(_i,{onOpenChange:S=>{S||(c(null),h(null))},children:[l.jsx(Ni,{asChild:!0,disabled:n,children:l.jsxs("button",{className:"flex items-center gap-1 text-sm font-semibold tracking-tight hover:text-foreground/80 transition-colors max-w-[180px] cursor-pointer",children:[l.jsx("div",{className:"h-2 w-2 rounded-full bg-primary/70 shrink-0"}),l.jsx("span",{className:"truncate",children:v}),l.jsx(ki,{className:"h-3 w-3 shrink-0 opacity-60"})]})}),l.jsxs(Er,{align:"start",className:"w-64",children:[e.map(S=>{const O=a===S.id;return f===S.id?l.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 text-sm",children:[l.jsx("span",{className:"text-destructive text-xs flex-1 truncate",children:"Delete this thread?"}),l.jsx("button",{className:"shrink-0 text-destructive hover:text-destructive/80 transition-colors cursor-pointer",onClick:E,children:l.jsx(un,{className:"h-3.5 w-3.5"})}),l.jsx("button",{className:"shrink-0 text-muted-foreground hover:text-foreground transition-colors cursor-pointer",onClick:w,children:l.jsx(wn,{className:"h-3.5 w-3.5"})})]},S.id):O?l.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1",onClick:N=>N.stopPropagation(),onPointerDown:N=>N.stopPropagation(),children:[l.jsx("input",{ref:p,type:"text",value:u,onChange:N=>d(N.target.value),onKeyDown:x,onBlur:y,className:"flex-1 min-w-0 text-sm rounded-sm border border-border bg-background px-1.5 py-0.5 outline-none focus:ring-1 focus:ring-primary/40"}),l.jsx("button",{className:"shrink-0 text-primary hover:text-primary/80 transition-colors cursor-pointer",onMouseDown:N=>{N.preventDefault(),y()},children:l.jsx(un,{className:"h-3.5 w-3.5"})}),l.jsx("button",{className:"shrink-0 text-muted-foreground hover:text-foreground transition-colors cursor-pointer",onMouseDown:N=>{N.preventDefault(),_()},children:l.jsx(wn,{className:"h-3.5 w-3.5"})})]},S.id):l.jsxs($t,{onSelect:()=>r(S.id),className:`group ${S.id===(t==null?void 0:t.id)?"bg-accent":""}`,children:[l.jsx("span",{className:"truncate flex-1",children:S.title.length>30?S.title.slice(0,30)+"...":S.title}),l.jsxs("div",{className:"ml-auto shrink-0 flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[l.jsx("button",{className:"text-muted-foreground hover:text-foreground transition-colors p-0.5 cursor-pointer",onClick:N=>k(S,N),children:l.jsx(zx,{className:"h-3 w-3"})}),e.length>1&&l.jsx("button",{className:"text-muted-foreground hover:text-destructive transition-colors p-0.5 cursor-pointer",onClick:N=>A(S.id,N),children:l.jsx(va,{className:"h-3 w-3"})})]})]},S.id)}),l.jsx(Fn,{}),l.jsxs($t,{onSelect:S=>{S.preventDefault();const O=i();O&&(c(O),d(Ea()),h(null))},children:[l.jsx(Dt,{className:"h-3.5 w-3.5 mr-1.5"}),"New Chat"]})]})]}),l.jsx(Ce,{variant:"ghost",size:"icon",className:"h-6 w-6 text-muted-foreground hover:text-foreground",onClick:()=>i(),disabled:n,title:"New chat thread",children:l.jsx(Dt,{className:"h-3.5 w-3.5"})})]})}const og=new Set(["image/png","image/jpeg","image/gif","image/webp","application/pdf","text/plain","text/markdown","text/csv","text/html"]),Kz=Array.from(og).join(","),Yz=20*1024*1024,Xu=10;function Xz(e){return new Promise((t,n)=>{const r=new FileReader;r.onload=()=>t({type:"file",mediaType:e.type,filename:e.name,url:r.result}),r.onerror=n,r.readAsDataURL(e)})}function Qu(e){return Array.from(e).filter(t=>og.has(t.type)&&t.size<=Yz)}function ag(e){return e.startsWith("image/")}function ed(){var Y,ge,_e;const e=De(M=>M.contextAttachments),t=De(M=>M.addContext),n=De(M=>M.removeContext),r=De(M=>M.scope),i=De(M=>M.setScope),s=De(M=>M.model),o=De(M=>M.setModel),a=De(M=>M.openChat),c=De(M=>M.closeChat),u=De(M=>M.threads),d=De(M=>M.activeThreadId),f=De(M=>M.createThread),h=De(M=>M.deleteThread),p=De(M=>M.switchThread),m=De(M=>M.updateThreadMessages),v=De(M=>M.updateThreadTitle),k=De(M=>M.deleteThreadsForDocument),y=ke(M=>M.activeTab),_=ke(M=>M.documents),{messages:x,sendMessage:A,status:E,error:w,setMessages:S,stop:O,getMessageContext:B,getMessageScope:N}=_z(),[R,T]=g.useState(""),[F,$]=g.useState([]),[Z,P]=g.useState(!1),[J,V]=g.useState(!1),X=g.useRef(null),j=g.useRef(null),ye=g.useRef(null),ce=g.useCallback(async M=>{const D=Qu(M);if(D.length===0)return;const xe=await Promise.all(D.map(Xz));$(de=>{const Me=[...de,...xe];return Me.length>Xu?Me.slice(0,Xu):Me})},[]),b=g.useCallback(M=>{$(D=>D.filter((xe,de)=>de!==M))},[]),G=g.useCallback(M=>{var xe;const D=(xe=M.clipboardData)==null?void 0:xe.files;if(D&&D.length>0){const de=Qu(D);de.length>0&&(M.preventDefault(),ce(de))}},[ce]),ne=g.useCallback(M=>{var xe;M.preventDefault(),V(!1);const D=(xe=M.dataTransfer)==null?void 0:xe.files;D&&D.length>0&&ce(Array.from(D))},[ce]),Q=g.useCallback(M=>{M.preventDefault(),V(!0)},[]),oe=g.useCallback(()=>V(!1),[]),I=y?d[y]:void 0,re=I?u[I]:void 0,ae=g.useMemo(()=>y?Object.values(u).filter(M=>M.documentName===y).sort((M,D)=>D.updatedAt-M.updatedAt):[],[u,y]);g.useEffect(()=>{y&&ae.length===0&&f(y)},[y,ae.length,f]);const H=g.useRef(u);H.current=u,g.useEffect(()=>{const M=new Set(_.map(xe=>xe.name)),D=new Set;for(const xe of Object.values(H.current))!M.has(xe.documentName)&&xe.documentName!=="__migrated__"&&D.add(xe.documentName);for(const xe of D)k(xe)},[_,k]);const K=g.useRef(null);g.useEffect(()=>{K.current!==I&&(K.current=I,S((re==null?void 0:re.messages)??[]))},[I,re,S]),g.useEffect(()=>{var M;(M=X.current)==null||M.scrollIntoView({behavior:"smooth"})},[x,E]),g.useEffect(()=>{const M=D=>{var Me;const{documentName:xe,selection:de}=D.detail;t({...de,documentName:xe}),a(),(Me=j.current)==null||Me.focus()};return window.addEventListener("monaco-selection-to-ai",M),()=>window.removeEventListener("monaco-selection-to-ai",M)},[t,a]);const pe=E==="streaming",fe=E==="submitted"||pe,Re=g.useCallback(M=>{M.preventDefault(),!(!R.trim()&&F.length===0||fe)&&(A(R,F.length>0?F:void 0),T(""),$([]))},[R,F,fe,A]),Oe=g.useCallback(M=>{M.key==="Enter"&&!M.shiftKey&&(M.preventDefault(),Re(M))},[Re]),$e=g.useCallback(()=>{x.length!==0&&P(!0)},[x.length]),C=g.useCallback(()=>{P(!1),S([]),I&&(m(I,[]),v(I,Ea()))},[S,I,m,v]),[z,L]=g.useState(null),se=g.useCallback(M=>{L(M)},[]),ie=g.useCallback(()=>{var Me,Je;if(!z)return;const M=x.findIndex(it=>it.id===z);if(M===-1){L(null);return}const D=x[M],xe=new Set([M]);D.role==="user"&&((Me=x[M+1])==null?void 0:Me.role)==="assistant"?xe.add(M+1):D.role==="assistant"&&M>0&&((Je=x[M-1])==null?void 0:Je.role)==="user"&&xe.add(M-1);const de=x.filter((it,Lt)=>!xe.has(Lt));S(de),I&&m(I,de),L(null)},[z,x,S,I,m]),ee=g.useCallback(M=>{if(!fe){if(ae.length<=1){$e();return}h(M)}},[fe,ae.length,$e,h]),me=g.useCallback(()=>{if(!(!y||fe))return f(y)},[y,fe,f]),we=g.useCallback(M=>{fe||M===I||p(M)},[fe,I,p]),U=g.useCallback((M,D)=>{v(M,D)},[v]);return l.jsxs("div",{className:"flex flex-col h-full border-l bg-surface-chat",children:[l.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border/60 bg-surface-chat",children:[l.jsx(Gz,{threads:ae,activeThread:re,disabled:fe,onSwitch:we,onCreate:me,onDelete:ee,onRename:U}),l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx(Ce,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs text-muted-foreground hover:text-foreground",onClick:$e,disabled:fe||x.length===0,children:"Clear"}),l.jsx(Ce,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:c,title:"Close chat",children:l.jsx(wn,{className:"h-3.5 w-3.5"})})]})]}),l.jsx(ui,{className:"flex-1 min-h-0 [&_[data-radix-scroll-area-viewport]>div]:!block",children:l.jsxs("div",{className:"p-3 space-y-4 min-w-0",children:[x.length===0&&l.jsxs("div",{className:"flex flex-col items-center justify-center py-12 px-4",children:[l.jsx("div",{className:"rounded-xl bg-primary/10 p-3 mb-4",children:l.jsx(gl,{className:"h-5 w-5 text-primary"})}),l.jsx("p",{className:"text-sm font-medium text-foreground/80 mb-1",children:"JSON Assistant"}),l.jsx("p",{className:"text-xs text-muted-foreground text-center max-w-[200px] mb-4",children:"Generate, edit, and refine your JSON document definitions with AI."}),l.jsxs("div",{className:"flex items-center gap-1.5 rounded-md bg-muted/50 px-2.5 py-1.5",children:[l.jsx(di,{shortcut:"mod+k"}),l.jsx("span",{className:"text-xs text-muted-foreground",children:"to send a selection"})]})]}),x.map((M,D)=>{let xe;if(M.role==="user"){const Je=B(M.id);Je&&Je.length>0&&(xe=Je)}else if(M.role==="assistant"){for(let Je=D-1;Je>=0;Je--)if(x[Je].role==="user"){xe=B(x[Je].id);break}}const de=pe&&D===x.length-1&&M.role==="assistant",Me=M.role==="user"?N(M.id):void 0;return l.jsx(Qz,{msg:M,isStreaming:de,context:xe,scope:Me,onDelete:fe?void 0:se},M.id)}),fe&&((Y=x[x.length-1])==null?void 0:Y.role)!=="assistant"&&l.jsx("div",{className:"flex justify-start",children:l.jsx("div",{className:"rounded-lg px-3 py-2 bg-muted/60 border border-border/40",children:l.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[l.jsx(Jr,{className:"h-3.5 w-3.5 animate-spin text-primary"}),l.jsx("span",{children:"Thinking..."})]})})}),w&&!fe&&l.jsx("div",{className:"flex justify-start",children:l.jsx("div",{className:"rounded-lg px-3 py-2 bg-destructive/10 border border-destructive/30 text-destructive text-sm max-w-[90%]",children:w.message||"Something went wrong"})}),l.jsx("div",{ref:X})]})}),l.jsxs("div",{className:`border-t border-border/60 p-2.5 space-y-2 bg-surface-chat transition-colors ${J?"ring-2 ring-primary/40 bg-primary/5":""}`,onDrop:ne,onDragOver:Q,onDragLeave:oe,children:[e.length>0&&l.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.map((M,D)=>l.jsx(tg,{context:M,onRemove:()=>n(D)},D))}),l.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[l.jsx(nO,{model:s,setModel:o}),at==="pptx"&&y&&l.jsx(iO,{scope:r,setScope:i,docSize:((_e=(ge=_.find(M=>M.name===y))==null?void 0:ge.text)==null?void 0:_e.length)??0})]}),F.length>0&&l.jsx("div",{className:"flex flex-wrap gap-1.5",children:F.map((M,D)=>l.jsxs("div",{className:"relative group",children:[ag(M.mediaType)?l.jsx("img",{src:M.url,alt:M.filename||"attachment",className:"h-14 w-14 rounded-md object-cover border border-border/60"}):l.jsxs("div",{className:"h-14 px-2.5 flex items-center gap-1.5 rounded-md border border-border/60 bg-muted/60 max-w-[140px]",children:[l.jsx(Do,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),l.jsx("span",{className:"text-xs truncate text-muted-foreground",children:M.filename||"file"})]}),l.jsx("button",{type:"button",onClick:()=>b(D),className:"absolute -top-1.5 -right-1.5 rounded-full bg-destructive text-destructive-foreground p-0.5 opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",children:l.jsx(wn,{className:"h-3 w-3"})})]},D))}),l.jsxs("form",{onSubmit:Re,className:"flex items-end gap-2",children:[l.jsx("input",{ref:ye,type:"file",accept:Kz,multiple:!0,className:"hidden",onChange:M=>{M.target.files&&ce(Array.from(M.target.files)),M.target.value=""}}),l.jsx(Ce,{type:"button",variant:"ghost",size:"icon",className:"shrink-0 h-9 w-9 rounded-lg text-muted-foreground hover:text-foreground",onClick:()=>{var M;return(M=ye.current)==null?void 0:M.click()},title:"Attach file",children:l.jsx(Do,{className:"h-4 w-4"})}),l.jsx("textarea",{ref:j,value:R,onChange:M=>{T(M.target.value);const D=M.target;D.style.height="auto",D.style.height=`${Math.min(D.scrollHeight,128)}px`},onKeyDown:Oe,onPaste:G,placeholder:e.length>0?"Describe how to edit the selection...":r==="slides"?"Add, edit, or remove slides...":r==="blocks"?"Edit block definitions: layouts and slots...":"Ask AI to generate or edit JSON...",className:"flex-1 min-h-[36px] max-h-32 resize-none overflow-y-auto rounded-lg border border-border/60 bg-background px-3 py-1.5 text-sm placeholder:text-muted-foreground placeholder:whitespace-nowrap placeholder:overflow-hidden placeholder:text-ellipsis focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/30 focus-visible:border-primary/50 transition-shadow",rows:1}),fe?l.jsx(Ce,{type:"button",size:"icon",variant:"destructive",className:"shrink-0 h-9 w-9 rounded-lg",onClick:O,title:"Stop generating",children:l.jsx(Wd,{className:"h-4 w-4"})}):l.jsx(Ce,{type:"submit",size:"icon",disabled:!R.trim()&&F.length===0,className:"shrink-0 h-9 w-9 rounded-lg",children:l.jsx(gl,{className:"h-4 w-4"})})]})]}),l.jsx(ct,{open:Z,onOpenChange:P,children:l.jsxs(lt,{className:"max-w-sm",children:[l.jsxs(qt,{children:[l.jsx(Gt,{children:"Clear thread"}),l.jsx(dn,{children:"This will delete all messages in this thread. This action cannot be undone."})]}),l.jsxs(kn,{children:[l.jsx(wl,{asChild:!0,children:l.jsx(Ce,{variant:"ghost",size:"sm",children:"Cancel"})}),l.jsx(Ce,{variant:"destructive",size:"sm",onClick:C,children:"Clear"})]})]})}),l.jsx(ct,{open:z!==null,onOpenChange:M=>{M||L(null)},children:l.jsxs(lt,{className:"max-w-sm",children:[l.jsxs(qt,{children:[l.jsx(Gt,{children:"Delete message"}),l.jsx(dn,{children:"This will delete the message and its paired response. This action cannot be undone."})]}),l.jsxs(kn,{children:[l.jsx(wl,{asChild:!0,children:l.jsx(Ce,{variant:"ghost",size:"sm",children:"Cancel"})}),l.jsx(Ce,{variant:"destructive",size:"sm",onClick:ie,children:"Delete"})]})]})})]})}const Qz=g.memo(function({msg:t,isStreaming:n,context:r,scope:i,onDelete:s}){var c,u;const o=((c=t.parts)==null?void 0:c.filter(d=>d.type==="text").map(d=>d.text).join(""))||"",a=((u=t.parts)==null?void 0:u.filter(d=>d.type==="file"))||[];return l.jsx("div",{className:`group/msg flex ${t.role==="user"?"justify-end":"justify-start"}`,children:l.jsxs("div",{className:`rounded-lg px-3 py-2 max-w-[90%] overflow-hidden min-w-0 ${t.role==="user"?"bg-primary text-primary-foreground":"bg-muted/60 border border-border/40"}`,children:[t.role==="user"?l.jsxs("div",{children:[a.length>0&&l.jsx("div",{className:"flex flex-wrap gap-1 mb-1.5",children:a.map((d,f)=>ag(d.mediaType)?l.jsx("img",{src:d.url,alt:d.filename||"image",className:"h-20 max-w-[160px] rounded-sm object-cover"},f):l.jsxs("div",{className:"flex items-center gap-1.5 rounded-sm bg-primary-foreground/20 px-2 py-1",children:[l.jsx(Do,{className:"h-3 w-3 shrink-0"}),l.jsx("span",{className:"text-xs truncate max-w-[120px]",children:d.filename||"file"})]},f))}),r&&r.length>0&&l.jsx("div",{className:"flex flex-wrap gap-1 mb-1.5",children:r.map((d,f)=>l.jsx(tg,{context:d,variant:"sent"},f))}),o&&l.jsx("div",{className:"whitespace-pre-wrap text-sm break-words",children:o}),i&&i!=="global"&&l.jsx("span",{className:"text-[10px] text-primary-foreground/60 mt-0.5 block text-right",children:i})]}):l.jsx(eO,{text:o,isStreaming:n,context:r,scope:i}),s&&!n&&l.jsx("div",{className:"opacity-0 transition-opacity group-hover/msg:opacity-100 focus-within:opacity-100 mt-1",children:l.jsx("button",{type:"button","aria-label":"Delete message",onClick:()=>s(t.id),className:`p-0.5 rounded-sm cursor-pointer focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring ${t.role==="user"?"text-primary-foreground/50 hover:text-primary-foreground/80":"text-muted-foreground hover:text-destructive"}`,children:l.jsx(va,{className:"h-3 w-3"})})})]})})},(e,t)=>e.msg.id===t.msg.id&&e.msg===t.msg&&e.isStreaming===t.isStreaming&&e.scope===t.scope&&e.onDelete===t.onDelete&&e.context===t.context);function eO({text:e,isStreaming:t,context:n,scope:r}){return t?l.jsx("div",{className:"text-sm prose prose-sm dark:prose-invert break-words [&_pre]:overflow-x-auto [&_p]:my-1",children:l.jsx("pre",{className:"whitespace-pre-wrap font-sans text-sm m-0 p-0 bg-transparent border-none",children:e})}):l.jsx("div",{className:"text-sm prose prose-sm dark:prose-invert break-words [&_pre]:overflow-x-auto [&_p]:my-1 [&_ul]:my-1 [&_ol]:my-1 [&_li]:my-0.5 [&_h1]:text-base [&_h2]:text-sm [&_h3]:text-sm [&_h1]:my-2 [&_h2]:my-1.5 [&_h3]:my-1",children:l.jsx(N1,{remarkPlugins:[F_],components:{pre:({children:i})=>l.jsx(l.Fragment,{children:i}),code:({className:i,children:s})=>{const o=i==null?void 0:i.startsWith("language-"),a=(i==null?void 0:i.replace("language-",""))||"",c=String(s).replace(/\n$/,"");if(!o)return l.jsx("code",{className:"rounded-sm bg-muted px-1 py-0.5 text-xs font-mono",children:s});const u=a==="json"||a==="jsonc";return l.jsxs("div",{className:"my-2 rounded-lg border bg-card",children:[l.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 bg-muted/60 border-b text-xs text-muted-foreground",children:[l.jsx("span",{className:"font-mono",children:a||"code"}),!u&&l.jsx(sO,{text:c})]}),l.jsx("pre",{className:"p-3 text-xs font-mono overflow-x-auto max-h-80 overflow-y-auto m-0",children:l.jsx("code",{children:c})}),u&&l.jsx(qz,{json:c,context:n,scope:r})]})}},children:e})})}const tO=[{value:"opus",label:"Opus"},{value:"sonnet",label:"Sonnet"},{value:"haiku",label:"Haiku"}];function nO({model:e,setModel:t}){return l.jsxs(li,{value:e,onValueChange:n=>t(n),children:[l.jsx(xr,{className:"h-6 w-auto gap-1 border-none bg-muted/40 px-2 py-0 text-[10px] shadow-none focus:ring-0",children:l.jsx(ci,{})}),l.jsx(yr,{children:tO.map(n=>l.jsx(Mn,{value:n.value,className:"text-xs",children:n.label},n.value))})]})}const td={global:"AI sees and edits the entire document",slides:"AI sees and edits only slides — block definitions stay unchanged",blocks:"AI sees and edits only block definitions — slides stay unchanged"},rO=1e5;function iO({scope:e,setScope:t,docSize:n}){return l.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Scope"}),l.jsx("div",{className:"flex items-center bg-muted/40 rounded-md p-0.5 gap-px",children:Object.keys(td).map(r=>l.jsxs(Ye,{children:[l.jsx(Xe,{asChild:!0,children:l.jsx("button",{type:"button",onClick:()=>t(r),className:`px-2 py-0.5 rounded-sm text-[10px] cursor-pointer transition-colors ${e===r?"bg-background text-foreground font-medium shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:r})}),l.jsx(Qe,{side:"top",className:"text-xs max-w-[200px]",children:td[r]})]},r))})]}),e==="global"&&n>rO&&l.jsxs("div",{className:"text-[10px] text-warning flex items-center gap-1",children:[l.jsx(Kd,{className:"h-3 w-3 shrink-0"}),l.jsxs("span",{children:["Large doc — switch to"," ",l.jsx("button",{type:"button",onClick:()=>t("slides"),className:"underline cursor-pointer hover:text-warning/80",children:"slides"})," ","or"," ",l.jsx("button",{type:"button",onClick:()=>t("blocks"),className:"underline cursor-pointer hover:text-warning/80",children:"blocks"})]})]})]})}function sO({text:e}){const[t,n]=g.useState(!1),r=g.useCallback(async()=>{await navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),1500)},[e]);return l.jsx("button",{onClick:r,className:"text-xs text-muted-foreground hover:text-foreground transition-colors",children:t?"Copied!":"Copy"})}function oO({discoveryData:e}){const t=Of(),n=Ky(),r=De(N=>N.chatOpen),i=De(N=>N.toggleChat),[s,o]=g.useState(()=>{try{const N=localStorage.getItem("dev-env.sidebar-open");return n?!1:N?N==="true":!0}catch{return!n}}),[a,c]=g.useState(()=>{try{const N=localStorage.getItem("dev-env.preview-open");return N?N==="true":!0}catch{return!0}}),[u,d]=g.useState("editor"),[f,h]=g.useState(!1),p=150,[m,v]=g.useState(!s),[k,y]=g.useState(!1);g.useEffect(()=>{try{localStorage.setItem("dev-env.sidebar-open",String(s))}catch{}},[s]),g.useEffect(()=>{try{localStorage.setItem("dev-env.preview-open",String(a))}catch{}},[a]);const _=g.useRef(n);g.useEffect(()=>{n&&!_.current&&s&&(y(!0),o(!1),setTimeout(()=>{v(!0),y(!1)},p)),!n&&_.current&&!s&&(y(!0),o(!0),setTimeout(()=>{v(!1),y(!1)},p)),_.current=n},[n,s]);const x=g.useCallback(()=>{if(t){h(N=>!N);return}y(!0),o(N=>!N),setTimeout(()=>{v(N=>!N),y(!1)},p)},[t]),A=g.useCallback(()=>c(N=>!N),[]),E=g.useRef(i),w=g.useRef(x),S=g.useRef(A);g.useEffect(()=>{E.current=i}),g.useEffect(()=>{w.current=x}),g.useEffect(()=>{S.current=A}),g.useEffect(()=>{const N=R=>{(R.metaKey||R.ctrlKey)&&(R.code==="KeyB"&&!R.shiftKey&&(R.preventDefault(),w.current()),R.code==="KeyJ"&&R.shiftKey&&(R.preventDefault(),R.stopPropagation(),E.current()),R.code==="KeyP"&&R.shiftKey&&(R.preventDefault(),S.current()))};return window.addEventListener("keydown",N,!0),()=>window.removeEventListener("keydown",N,!0)},[]);const O=jz,B=[{key:"editor",icon:Po,label:"Editor"},{key:"preview",icon:Yd,label:"Preview"},{key:"chat",icon:Xd,label:"Chat"}];return t?l.jsx(O,{children:l.jsxs("div",{className:"flex flex-col h-full w-full overflow-hidden",children:[l.jsxs("div",{className:"flex items-center gap-1 px-2 py-1.5 border-b bg-sidebar shrink-0",children:[l.jsxs(If,{open:f,onOpenChange:h,children:[l.jsx(Jy,{asChild:!0,children:l.jsx(Ce,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0",children:l.jsx(Gd,{className:"h-4 w-4"})})}),l.jsx(Oa,{side:"left",className:"p-0 w-72",children:l.jsx(Ll,{discoveryData:e,onToggleSidebar:()=>h(!1),isCollapsed:!1})})]}),l.jsx("div",{className:"flex gap-0.5 flex-1 min-w-0",children:B.map(({key:N,icon:R,label:T})=>l.jsxs(Ce,{variant:u===N?"default":"ghost",size:"sm",className:"h-7 gap-1.5 text-xs flex-1",onClick:()=>d(N),children:[l.jsx(R,{className:"h-3.5 w-3.5"}),l.jsx("span",{className:"hidden xs:inline",children:T})]},N))})]}),u!=="chat"&&l.jsx(uc,{previewOpen:a,onTogglePreview:A}),l.jsxs("div",{className:"flex-1 min-h-0",children:[u==="editor"&&l.jsx("div",{className:"h-full bg-surface-editor",children:l.jsx(Bl,{})}),u==="preview"&&l.jsx("div",{className:"h-full bg-surface-preview",children:l.jsx(Zl,{})}),u==="chat"&&l.jsx(ed,{})]})]})}):l.jsx(O,{children:l.jsxs("div",{className:"flex h-full w-full overflow-hidden",children:[l.jsx("div",{className:W("shrink-0 overflow-hidden border-r bg-sidebar","transition-[width] duration-300 ease-[cubic-bezier(0.16,1,0.3,1)]",s?"w-64":"w-12"),children:l.jsx(Ll,{discoveryData:e,onToggleSidebar:x,isCollapsed:m,isAnimating:k})}),l.jsxs("div",{className:"flex-1 min-w-0 flex flex-col h-full",children:[l.jsx(uc,{previewOpen:a,onTogglePreview:A}),l.jsxs(Nv,{direction:"horizontal",autoSaveId:"layout-main",className:"flex-1 min-h-0",children:[l.jsx(io,{defaultSize:a?50:100,minSize:20,id:"editor",order:1,children:l.jsx("div",{className:"h-full bg-surface-editor",children:l.jsx(Bl,{})})}),a&&l.jsxs(l.Fragment,{children:[l.jsx(Xl,{withHandle:!0}),l.jsx(io,{defaultSize:50,minSize:20,id:"preview",order:2,children:l.jsx("div",{className:"h-full bg-surface-preview",children:l.jsx(Zl,{})})})]}),r&&l.jsxs(l.Fragment,{children:[l.jsx(Xl,{withHandle:!0}),l.jsx(io,{defaultSize:30,minSize:25,maxSize:50,id:"chat",order:3,children:l.jsx(ed,{})})]})]})]})]})})}function aO(){const[e,t]=g.useState(null),[n,r]=g.useState(!0),[i,s]=g.useState(null),o=g.useCallback(async()=>{r(!0),s(null);try{const a=await fetch("/api/discovery/all");if(!a.ok)throw new Error(`Discovery failed: ${a.statusText}`);const c=await a.json();if(!c.success)throw new Error(c.error||"Discovery failed");t({pluginAutoload:!0,...c.data})}catch(a){console.error("Discovery error:",a),s(a instanceof Error?a.message:"Failed to fetch discovered items"),t({plugins:[],documents:[],themes:[],pluginAutoload:!0})}finally{r(!1)}},[]);return g.useEffect(()=>{o()},[o]),{data:e,loading:n,error:i,refetch:o}}function lO(){const{data:e,loading:t,error:n}=aO(),r=Jt(s=>s.applyPluginsWithValidation),i=g.useMemo(()=>(e==null?void 0:e.plugins.map(s=>s.name))??[],[e]);return g.useEffect(()=>{if(!e)return;Jt.getState().selectedPlugins.size>0&&r()},[e,r]),t?l.jsx("div",{className:"flex items-center justify-center h-screen",children:l.jsxs("div",{className:"text-center",children:[l.jsx("div",{className:"text-lg font-medium",children:"Discovering project resources..."}),l.jsx("div",{className:"text-sm text-muted-foreground mt-2",children:"Searching for documents, themes, and plugins"})]})}):n?l.jsx("div",{className:"flex items-center justify-center h-screen",children:l.jsxs("div",{className:"text-center",children:[l.jsx("div",{className:"text-lg font-medium text-destructive",children:"Discovery failed"}),l.jsx("div",{className:"text-sm text-muted-foreground mt-2",children:n}),l.jsx("div",{className:"text-xs text-muted-foreground mt-4",children:"The playground will work with limited functionality."})]})}):l.jsx(xg,{children:l.jsx(yg,{children:l.jsx(bg,{children:l.jsx(vg,{children:l.jsx(wg,{children:l.jsx(kg,{diskPluginNames:i,children:l.jsx(jy,{children:l.jsx(Df,{children:l.jsx("section",{className:"flex h-screen w-full flex-col",children:l.jsx("div",{className:"grow overflow-hidden",children:l.jsx(oO,{discoveryData:e})})})})})})})})})})})}const yO=Object.freeze(Object.defineProperty({__proto__:null,HomePage:lO},Symbol.toStringTag,{value:"Module"}));export{Av as A,tn as B,_i as D,yO as H,br as I,Xr as L,Vv as P,Tv as Q,li as S,mp as T,xr as a,ci as b,yr as c,Mn as d,ui as e,Ni as f,Er as g,za as h,Fn as i,$t as j,Pa as k,ni as l,pr as m,Ro as n,gp as o,ti as p,ac as q,La as r,Tf as s,Mv as t,Ov as u,ct as v,lt as w,qt as x,Gt as y,xp as z};
|
|
245
|
+
//# sourceMappingURL=HomePage-BlzZ7qG4.js.map
|