@json-to-office/jto 1.6.0 → 1.7.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 +60 -19
- package/dist/cli.js.map +1 -1
- package/dist/client/assets/HomePage-fDrbL-5G.js +106 -0
- package/dist/client/assets/HomePage-fDrbL-5G.js.map +1 -0
- package/dist/client/assets/{JsonEditorPage-4LrF2fB9.js → JsonEditorPage-CRY9589Y.js} +3 -3
- package/dist/client/assets/{JsonEditorPage-4LrF2fB9.js.map → JsonEditorPage-CRY9589Y.js.map} +1 -1
- package/dist/client/assets/MonacoPluginProvider-n1_V7jsc.js +3 -0
- package/dist/client/assets/MonacoPluginProvider-n1_V7jsc.js.map +1 -0
- package/dist/client/assets/{editor-D-REaAU9.js → editor-Y9dek093.js} +2 -2
- package/dist/client/assets/{editor-D-REaAU9.js.map → editor-Y9dek093.js.map} +1 -1
- package/dist/client/assets/{editor-monaco-json-BgziSLMV.js → editor-monaco-json-oBxvTIvi.js} +2 -2
- package/dist/client/assets/{editor-monaco-json-BgziSLMV.js.map → editor-monaco-json-oBxvTIvi.js.map} +1 -1
- package/dist/client/assets/{editor-refs-store-vzLK2-Zo.js → editor-refs-store-BMwl0ejj.js} +2 -2
- package/dist/client/assets/{editor-refs-store-vzLK2-Zo.js.map → editor-refs-store-BMwl0ejj.js.map} +1 -1
- package/dist/client/assets/{index-B7bDnXoC.js → index-B4R-AAtI.js} +4 -4
- package/dist/client/assets/index-B4R-AAtI.js.map +1 -0
- package/dist/client/assets/preview-zCYkbgdR.js +2 -0
- package/dist/client/assets/preview-zCYkbgdR.js.map +1 -0
- package/dist/client/assets/{useQualityAnalysis-CowAaoA9.js → useQualityAnalysis-BFG1bJDp.js} +2 -2
- package/dist/client/assets/{useQualityAnalysis-CowAaoA9.js.map → useQualityAnalysis-BFG1bJDp.js.map} +1 -1
- package/dist/client/index.html +1 -1
- package/package.json +5 -5
- package/dist/client/assets/HomePage-CeUQIXch.js +0 -106
- package/dist/client/assets/HomePage-CeUQIXch.js.map +0 -1
- package/dist/client/assets/MonacoPluginProvider-Bx_V_FaE.js +0 -3
- package/dist/client/assets/MonacoPluginProvider-Bx_V_FaE.js.map +0 -1
- package/dist/client/assets/index-B7bDnXoC.js.map +0 -1
- package/dist/client/assets/preview-BGqIip90.js +0 -2
- package/dist/client/assets/preview-BGqIip90.js.map +0 -1
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/editor-Y9dek093.js","assets/react-vendor-BmQ2Ko_D.js","assets/editor-monaco-json-oBxvTIvi.js","assets/index-B4R-AAtI.js","assets/query-vendor--rhYD8mC.js","assets/radix-ui-DFNP5I4e.js","assets/ui-vendor-Bq4-oNFL.js","assets/monaco-editor-DJsdM0WK.js","assets/state-vendor-Cq67_JbF.js","assets/index-CrzIwHLS.css","assets/editor-refs-store-BMwl0ejj.js","assets/MonacoPluginProvider-n1_V7jsc.js","assets/useQualityAnalysis-BFG1bJDp.js","assets/preview-zCYkbgdR.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var Km=Object.defineProperty;var Xm=(e,t,n)=>t in e?Km(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Vs=(e,t,n)=>Xm(e,typeof t!="symbol"?t+"":t,n);import{r as x,j as u,c as je,R as Uc,g as uo}from"./react-vendor-BmQ2Ko_D.js";import{b as Jc,c as co,d as Hc,e as ys,f as bs,D as vs,O as ws,g as Qm,V as eg,G as tg,h as Wc,I as ng,i as rg,j as qc,k as ig,l as Gc,m as sg,n as ag,L as Yc,S as Kc,o as Xc,p as Qc,q as ed,r as kr,s as og,t as lg,u as ug,v as td,w as nd,x as rd,y as id,z as sd,B as ad,E as od,F as ld,H as ud,J as cg,K as dg,M as fg,N as cd,Q as dd,U as fd,W as pd,X as hd,Y as md,Z as gd,_ as xd,$ as yd,a0 as bd,a1 as pg,a2 as vd,a3 as hg,a4 as mg,a5 as wd,a6 as gg,a7 as xg,a8 as yg,a9 as bg,aa as kd,ab as Sd,ac as _d}from"./radix-ui-DFNP5I4e.js";import{c as G,u as Sr,S as gn,A as ei,T as _i,C as vg,E as wg,F as ht,a as kg,b as Sg,d as Ye,e as Ke,f as Xe,g as jd,_ as Nd,h as ji,i as _g,j as jg,k as Ng,l as Tr,s as Us,W as Ed,m as $i}from"./index-B4R-AAtI.js";import{X as yn,C as mi,a as an,b as Eg,d as gi,G as Cd,F as Cg,e as _r,f as Td,P as Tg,g as Ig,h as Id,E as Ad,B as _a,H as Ag,T as ja,L as Na,i as zg,j as Og,S as zd,I as Pg,k as Dg,l as Ea,m as Rg,n as Mg,o as $g,p as Fg,q as Lg,r as Bg,s as Zg,t as Vg,u as ks,v as Ug,M as Jg,w as nn,x as Od,y as Hg,z as Wg,A as Pd,D as qg,J as Gg,K as Yg,N as Kg,O as Xg,Q as Dd,R as Qg,U as Ca,V as fo,W as Rd,Y as ex,Z as Md,_ as Fr,$ as tx,a0 as nx,a1 as rx,a2 as il,a3 as Ta}from"./ui-vendor-Bq4-oNFL.js";import{B as Se,u as $d,d as sl}from"./editor-refs-store-BMwl0ejj.js";import{u as Ne,i as ix,a as Ia,b as rn,g as sx,c as Lt,T as Fd,d as Hi,e as Ld,S as ax,O as ox,f as lx,M as ux,D as cx}from"./MonacoPluginProvider-n1_V7jsc.js";import{u as po,a as dx,d as fx,p as px,b as hx,e as mx}from"./state-vendor-Cq67_JbF.js";import{b as gx}from"./query-vendor--rhYD8mC.js";const Ct=Jc,xx=Hc,al=co,Bd=x.forwardRef(({className:e,...t},n)=>u.jsx(ws,{ref:n,className:G("fixed inset-0 z-50 bg-black/50",e),...t}));Bd.displayName=ws.displayName;const kt=x.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(xx,{children:[u.jsx(Bd,{}),u.jsxs(ys,{ref:r,className:G("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,u.jsxs(co,{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:[u.jsx(yn,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));kt.displayName=ys.displayName;const Vt=({className:e,...t})=>u.jsx("div",{className:G("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Vt.displayName="DialogHeader";const bn=({className:e,...t})=>u.jsx("div",{className:G("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});bn.displayName="DialogFooter";const Ut=x.forwardRef(({className:e,...t},n)=>u.jsx(bs,{ref:n,className:G("text-lg leading-none font-semibold tracking-tight",e),...t}));Ut.displayName=bs.displayName;const on=x.forwardRef(({className:e,...t},n)=>u.jsx(vs,{ref:n,className:G("text-muted-foreground text-sm",e),...t}));on.displayName=vs.displayName;const ti=Qm,Zd=tg,ni=eg,fr=x.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Wc,{ref:r,className:G("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,u.jsx(ng,{asChild:!0,children:u.jsx(mi,{className:"h-4 w-4 shrink-0 opacity-50"})})]}));fr.displayName=Wc.displayName;const Vd=x.forwardRef(({className:e,...t},n)=>u.jsx(Kc,{ref:n,className:G("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(Eg,{className:"h-4 w-4"})}));Vd.displayName=Kc.displayName;const Ud=x.forwardRef(({className:e,...t},n)=>u.jsx(Xc,{ref:n,className:G("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(mi,{className:"h-4 w-4"})}));Ud.displayName=Xc.displayName;const pr=x.forwardRef(({className:e,children:t,position:n="popper",...r},i)=>u.jsx(rg,{children:u.jsxs(qc,{ref:i,className:G("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:[u.jsx(Vd,{}),u.jsx(ig,{className:G("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),u.jsx(Ud,{})]})}));pr.displayName=qc.displayName;const ho=x.forwardRef(({className:e,...t},n)=>u.jsx(Yc,{ref:n,className:G("px-2 py-1.5 text-sm font-semibold",e),...t}));ho.displayName=Yc.displayName;const Pn=x.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Gc,{ref:r,className:G("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:[u.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(sg,{children:u.jsx(an,{className:"h-4 w-4"})})}),u.jsx(ag,{children:t})]}));Pn.displayName=Gc.displayName;const yx=x.forwardRef(({className:e,...t},n)=>u.jsx(Qc,{ref:n,className:G("bg-muted -mx-1 my-1 h-px",e),...t}));yx.displayName=Qc.displayName;const hr=x.forwardRef(({className:e,type:t,...n},r)=>u.jsx("input",{type:t,className:G("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}));hr.displayName="Input";const bx=gi("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Wr=x.forwardRef(({className:e,...t},n)=>u.jsx(ed,{ref:n,className:G(bx(),e),...t}));Wr.displayName=ed.displayName;const vx=gi("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 Kt({className:e,variant:t,...n}){return u.jsx("div",{className:G(vx({variant:t}),e),...n})}const wx=({open:e,onOpenChange:t})=>{const{documents:n,documentTypes:r,activeTab:i,createDocument:s,openDocument:a}=Ne(po(I=>({documents:I.documents,documentTypes:I.documentTypes,activeTab:I.activeTab,createDocument:I.createDocument,openDocument:I.openDocument}))),{toast:o}=Sr(),l=x.useMemo(()=>n.filter(I=>r[I.name]!=="application/json+theme"),[n,r]),[c,f]=x.useState(""),[d,h]=x.useState(""),[p,g]=x.useState("playground"),[w,_]=x.useState(!1),[b,N]=x.useState(null),[m,O]=x.useState(null),[C,v]=x.useState(null),k=()=>{N(null),O(null),v(null)};x.useEffect(()=>{if(!e)return;N(null),O(null),v(null);const I=l.map(P=>P.name),T=I.includes(i)?i:I[0]??"";h(T),f(I.find(P=>P!==T)??"")},[e]);const $=async()=>{const I=l.find(P=>P.name===c),T=l.find(P=>P.name===d);if(!(!I||!T)){_(!0),N(null),O(null),v(null);try{const P=await fetch(ei.diff,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldDefinition:I.text,newDefinition:T.text,options:{author:p||"playground"}})}),A=await P.json();if(!P.ok||!A.success){const M=Array.isArray(A.errors)?`: ${A.errors.slice(0,3).map(V=>V.message||String(V)).join("; ")}`:"";throw new Error((A.error||`Diff failed (${P.status})`)+M)}O(A.data.summary),v(A.data.document)}catch(P){N(P instanceof Error?P.message:"Diff failed")}finally{_(!1)}}},H=()=>{if(!C)return;const I=new Set(n.map(A=>A.name));let T=`${d}-redline`,P=2;for(;I.has(T);)T=`${d}-redline-${P++}`;s(T,JSON.stringify(C,null,2)),a(T),o({title:`Redline created: ${T}`}),t(!1)},j=m?m.tracked.modified+m.tracked.inserted+m.tracked.deleted:0;return u.jsx(Ct,{open:e,onOpenChange:t,children:u.jsxs(kt,{className:"sm:max-w-[560px]",children:[u.jsxs(Vt,{children:[u.jsxs(Ut,{className:"flex items-center gap-2",children:[u.jsx(Cd,{className:"size-4"}),"Compare documents"]}),u.jsx(on,{children:"Diff two versions into a redline with native Word tracked changes (accept/reject in Word)."})]}),u.jsxs("div",{className:"grid gap-4 py-2",children:[u.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[u.jsxs("div",{className:"grid gap-1.5",children:[u.jsx(Wr,{htmlFor:"diff-base",children:"Base (old)"}),u.jsxs(ti,{value:c,onValueChange:I=>{f(I),k()},children:[u.jsx(fr,{id:"diff-base",children:u.jsx(ni,{placeholder:"Select document"})}),u.jsx(pr,{children:l.map(I=>u.jsx(Pn,{value:I.name,children:I.name},I.name))})]})]}),u.jsxs("div",{className:"grid gap-1.5",children:[u.jsx(Wr,{htmlFor:"diff-revised",children:"Revised (new)"}),u.jsxs(ti,{value:d,onValueChange:I=>{h(I),k()},children:[u.jsx(fr,{id:"diff-revised",children:u.jsx(ni,{placeholder:"Select document"})}),u.jsx(pr,{children:l.map(I=>u.jsx(Pn,{value:I.name,children:I.name},I.name))})]})]})]}),u.jsxs("div",{className:"grid gap-1.5",children:[u.jsx(Wr,{htmlFor:"diff-author",children:"Revision author"}),u.jsx(hr,{id:"diff-author",value:p,onChange:I=>{g(I.target.value),k()},placeholder:"playground"})]}),b&&u.jsx("p",{className:"text-sm text-destructive",role:"alert",children:b}),m&&u.jsxs("div",{className:"rounded-md border p-3 text-sm grid gap-2",children:[u.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[u.jsxs(Kt,{variant:"secondary",children:[m.tracked.inserted," inserted"]}),u.jsxs(Kt,{variant:"secondary",children:[m.tracked.deleted," deleted"]}),u.jsxs(Kt,{variant:"secondary",children:[m.tracked.modified," modified"]}),u.jsxs("span",{className:"text-muted-foreground text-xs",children:[m.unchangedBlocks," blocks unchanged"]})]}),j===0&&m.untracked.length===0&&u.jsx("p",{className:"text-muted-foreground",children:"The documents are identical."}),m.untracked.length>0&&u.jsxs("div",{className:"grid gap-1 max-h-32 overflow-y-auto",children:[u.jsxs("p",{className:"font-medium text-warning-bg-foreground",children:[m.untracked.length," change(s) not expressible as tracked changes:"]}),m.untracked.map((I,T)=>u.jsxs("p",{className:"text-xs text-muted-foreground",children:[I.path," [",I.component,"] ",I.detail]},T))]}),m.notes.map((I,T)=>u.jsxs("p",{className:"text-xs text-muted-foreground",children:["Note: ",I]},T))]})]}),u.jsx(bn,{children:m&&j+m.untracked.length>0?u.jsxs(Se,{onClick:H,children:[u.jsx(Cg,{className:"size-4 mr-1"}),"Open redline"]}):u.jsxs(Se,{onClick:$,disabled:w||!c||!d||c===d,children:[w&&u.jsx(gn,{className:"size-4 mr-1"}),"Compare"]})})]})})};var xi=e=>e.type==="checkbox",In=e=>e instanceof Date,ft=e=>e==null;const Jd=e=>typeof e=="object";var et=e=>!ft(e)&&!Array.isArray(e)&&Jd(e)&&!In(e),Hd=e=>et(e)&&e.target?xi(e.target)?e.target.checked:e.target.value:e,kx=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,Wd=(e,t)=>e.has(kx(t)),Sx=e=>{const t=e.constructor&&e.constructor.prototype;return et(t)&&t.hasOwnProperty("isPrototypeOf")},mo=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function yt(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(!(mo&&(e instanceof Blob||r))&&(n||et(e)))if(t=n?[]:{},!n&&!Sx(e))t=e;else for(const i in e)e.hasOwnProperty(i)&&(t[i]=yt(e[i]));else return e;return t}var Ss=e=>Array.isArray(e)?e.filter(Boolean):[],Qe=e=>e===void 0,le=(e,t,n)=>{if(!t||!et(e))return n;const r=Ss(t.split(/[,[\].]+?/)).reduce((i,s)=>ft(i)?i:i[s],e);return Qe(r)||r===e?Qe(e[t])?n:e[t]:r},zt=e=>typeof e=="boolean",go=e=>/^\w*$/.test(e),qd=e=>Ss(e.replace(/["|']|\]/g,"").split(/\.|\[/)),Me=(e,t,n)=>{let r=-1;const i=go(t)?[t]:qd(t),s=i.length,a=s-1;for(;++r<s;){const o=i[r];let l=n;if(r!==a){const c=e[o];l=et(c)||Array.isArray(c)?c:isNaN(+i[r+1])?{}:[]}if(o==="__proto__"||o==="constructor"||o==="prototype")return;e[o]=l,e=e[o]}return e};const Wi={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},Ft={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},tn={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},Gd=je.createContext(null),_s=()=>je.useContext(Gd),_x=e=>{const{children:t,...n}=e;return je.createElement(Gd.Provider,{value:n},t)};var Yd=(e,t,n,r=!0)=>{const i={defaultValues:t._defaultValues};for(const s in e)Object.defineProperty(i,s,{get:()=>{const a=s;return t._proxyFormState[a]!==Ft.all&&(t._proxyFormState[a]=!r||Ft.all),n&&(n[a]=!0),e[a]}});return i},bt=e=>et(e)&&!Object.keys(e).length,Kd=(e,t,n,r)=>{n(e);const{name:i,...s}=e;return bt(s)||Object.keys(s).length>=Object.keys(t).length||Object.keys(s).find(a=>t[a]===(!r||Ft.all))},qr=e=>Array.isArray(e)?e:[e],Xd=(e,t,n)=>!e||!t||e===t||qr(e).some(r=>r&&(n?r===t:r.startsWith(t)||t.startsWith(r)));function xo(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 jx(e){const t=_s(),{control:n=t.control,disabled:r,name:i,exact:s}=e||{},[a,o]=je.useState(n._formState),l=je.useRef(!0),c=je.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1}),f=je.useRef(i);return f.current=i,xo({disabled:r,next:d=>l.current&&Xd(f.current,d.name,s)&&Kd(d,c.current,n._updateFormState)&&o({...n._formState,...d}),subject:n._subjects.state}),je.useEffect(()=>(l.current=!0,c.current.isValid&&n._updateValid(!0),()=>{l.current=!1}),[n]),je.useMemo(()=>Yd(a,n,c.current,!1),[a,n])}var Yt=e=>typeof e=="string",Qd=(e,t,n,r,i)=>Yt(e)?(r&&t.watch.add(e),le(n,e,i)):Array.isArray(e)?e.map(s=>(r&&t.watch.add(s),le(n,s))):(r&&(t.watchAll=!0),n);function Nx(e){const t=_s(),{control:n=t.control,name:r,defaultValue:i,disabled:s,exact:a}=e||{},o=je.useRef(r);o.current=r,xo({disabled:s,subject:n._subjects.values,next:f=>{Xd(o.current,f.name,a)&&c(yt(Qd(o.current,n._names,f.values||n._formValues,!1,i)))}});const[l,c]=je.useState(n._getWatch(r,i));return je.useEffect(()=>n._removeUnmounted()),l}function Ex(e){const t=_s(),{name:n,disabled:r,control:i=t.control,shouldUnregister:s}=e,a=Wd(i._names.array,n),o=Nx({control:i,name:n,defaultValue:le(i._formValues,n,le(i._defaultValues,n,e.defaultValue)),exact:!0}),l=jx({control:i,name:n,exact:!0}),c=je.useRef(i.register(n,{...e.rules,value:o,...zt(e.disabled)?{disabled:e.disabled}:{}})),f=je.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!le(l.errors,n)},isDirty:{enumerable:!0,get:()=>!!le(l.dirtyFields,n)},isTouched:{enumerable:!0,get:()=>!!le(l.touchedFields,n)},isValidating:{enumerable:!0,get:()=>!!le(l.validatingFields,n)},error:{enumerable:!0,get:()=>le(l.errors,n)}}),[l,n]),d=je.useMemo(()=>({name:n,value:o,...zt(r)||l.disabled?{disabled:l.disabled||r}:{},onChange:h=>c.current.onChange({target:{value:Hd(h),name:n},type:Wi.CHANGE}),onBlur:()=>c.current.onBlur({target:{value:le(i._formValues,n),name:n},type:Wi.BLUR}),ref:h=>{const p=le(i._fields,n);p&&h&&(p._f.ref={focus:()=>h.focus(),select:()=>h.select(),setCustomValidity:g=>h.setCustomValidity(g),reportValidity:()=>h.reportValidity()})}}),[n,i._formValues,r,l.disabled,o,i._fields]);return je.useEffect(()=>{const h=i._options.shouldUnregister||s,p=(g,w)=>{const _=le(i._fields,g);_&&_._f&&(_._f.mount=w)};if(p(n,!0),h){const g=yt(le(i._options.defaultValues,n));Me(i._defaultValues,n,g),Qe(le(i._formValues,n))&&Me(i._formValues,n,g)}return!a&&i.register(n),()=>{(a?h&&!i._state.action:h)?i.unregister(n):p(n,!1)}},[n,i,a,s]),je.useEffect(()=>{i._updateDisabledField({disabled:r,fields:i._fields,name:n})},[r,n,i]),je.useMemo(()=>({field:d,formState:l,fieldState:f}),[d,l,f])}const Cx=e=>e.render(Ex(e));var Tx=(e,t,n,r,i)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:i||!0}}:{},ol=e=>({isOnSubmit:!e||e===Ft.onSubmit,isOnBlur:e===Ft.onBlur,isOnChange:e===Ft.onChange,isOnAll:e===Ft.all,isOnTouch:e===Ft.onTouched}),ll=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some(r=>e.startsWith(r)&&/^\.\w+/.test(e.slice(r.length))));const Gr=(e,t,n,r)=>{for(const i of n||Object.keys(e)){const s=le(e,i);if(s){const{_f:a,...o}=s;if(a){if(a.refs&&a.refs[0]&&t(a.refs[0],i)&&!r)return!0;if(a.ref&&t(a.ref,a.name)&&!r)return!0;if(Gr(o,t))break}else if(et(o)&&Gr(o,t))break}}};var Ix=(e,t,n)=>{const r=qr(le(e,n));return Me(r,"root",t[n]),Me(e,n,r),e},yo=e=>e.type==="file",Gt=e=>typeof e=="function",qi=e=>{if(!mo)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},Fi=e=>Yt(e),bo=e=>e.type==="radio",Gi=e=>e instanceof RegExp;const ul={value:!1,isValid:!1},cl={value:!0,isValid:!0};var ef=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&&!Qe(e[0].attributes.value)?Qe(e[0].value)||e[0].value===""?cl:{value:e[0].value,isValid:!0}:cl:ul}return ul};const dl={isValid:!1,value:null};var tf=e=>Array.isArray(e)?e.reduce((t,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:t,dl):dl;function fl(e,t,n="validate"){if(Fi(e)||Array.isArray(e)&&e.every(Fi)||zt(e)&&!e)return{type:n,message:Fi(e)?e:"",ref:t}}var Ln=e=>et(e)&&!Gi(e)?e:{value:e,message:""},pl=async(e,t,n,r,i,s)=>{const{ref:a,refs:o,required:l,maxLength:c,minLength:f,min:d,max:h,pattern:p,validate:g,name:w,valueAsNumber:_,mount:b}=e._f,N=le(n,w);if(!b||t.has(w))return{};const m=o?o[0]:a,O=T=>{i&&m.reportValidity&&(m.setCustomValidity(zt(T)?"":T||""),m.reportValidity())},C={},v=bo(a),k=xi(a),$=v||k,H=(_||yo(a))&&Qe(a.value)&&Qe(N)||qi(a)&&a.value===""||N===""||Array.isArray(N)&&!N.length,j=Tx.bind(null,w,r,C),I=(T,P,A,M=tn.maxLength,V=tn.minLength)=>{const U=T?P:A;C[w]={type:T?M:V,message:U,ref:a,...j(T?M:V,U)}};if(s?!Array.isArray(N)||!N.length:l&&(!$&&(H||ft(N))||zt(N)&&!N||k&&!ef(o).isValid||v&&!tf(o).isValid)){const{value:T,message:P}=Fi(l)?{value:!!l,message:l}:Ln(l);if(T&&(C[w]={type:tn.required,message:P,ref:m,...j(tn.required,P)},!r))return O(P),C}if(!H&&(!ft(d)||!ft(h))){let T,P;const A=Ln(h),M=Ln(d);if(!ft(N)&&!isNaN(N)){const V=a.valueAsNumber||N&&+N;ft(A.value)||(T=V>A.value),ft(M.value)||(P=V<M.value)}else{const V=a.valueAsDate||new Date(N),U=S=>new Date(new Date().toDateString()+" "+S),J=a.type=="time",ne=a.type=="week";Yt(A.value)&&N&&(T=J?U(N)>U(A.value):ne?N>A.value:V>new Date(A.value)),Yt(M.value)&&N&&(P=J?U(N)<U(M.value):ne?N<M.value:V<new Date(M.value))}if((T||P)&&(I(!!T,A.message,M.message,tn.max,tn.min),!r))return O(C[w].message),C}if((c||f)&&!H&&(Yt(N)||s&&Array.isArray(N))){const T=Ln(c),P=Ln(f),A=!ft(T.value)&&N.length>+T.value,M=!ft(P.value)&&N.length<+P.value;if((A||M)&&(I(A,T.message,P.message),!r))return O(C[w].message),C}if(p&&!H&&Yt(N)){const{value:T,message:P}=Ln(p);if(Gi(T)&&!N.match(T)&&(C[w]={type:tn.pattern,message:P,ref:a,...j(tn.pattern,P)},!r))return O(P),C}if(g){if(Gt(g)){const T=await g(N,n),P=fl(T,m);if(P&&(C[w]={...P,...j(tn.validate,P.message)},!r))return O(P.message),C}else if(et(g)){let T={};for(const P in g){if(!bt(T)&&!r)break;const A=fl(await g[P](N,n),m,P);A&&(T={...A,...j(P,A.message)},O(A.message),r&&(C[w]=T))}if(!bt(T)&&(C[w]={ref:m,...T},!r))return C}}return O(!0),C};function Ax(e,t){const n=t.slice(0,-1).length;let r=0;for(;r<n;)e=Qe(e)?r++:e[t[r++]];return e}function zx(e){for(const t in e)if(e.hasOwnProperty(t)&&!Qe(e[t]))return!1;return!0}function it(e,t){const n=Array.isArray(t)?t:go(t)?[t]:qd(t),r=n.length===1?e:Ax(e,n),i=n.length-1,s=n[i];return r&&delete r[s],i!==0&&(et(r)&&bt(r)||Array.isArray(r)&&zx(r))&&it(e,n.slice(0,-1)),e}var Js=()=>{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=[]}}},Aa=e=>ft(e)||!Jd(e);function hn(e,t){if(Aa(e)||Aa(t))return e===t;if(In(e)&&In(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 a=t[i];if(In(s)&&In(a)||et(s)&&et(a)||Array.isArray(s)&&Array.isArray(a)?!hn(s,a):s!==a)return!1}}return!0}var nf=e=>e.type==="select-multiple",Ox=e=>bo(e)||xi(e),Hs=e=>qi(e)&&e.isConnected,rf=e=>{for(const t in e)if(Gt(e[t]))return!0;return!1};function Yi(e,t={}){const n=Array.isArray(e);if(et(e)||n)for(const r in e)Array.isArray(e[r])||et(e[r])&&!rf(e[r])?(t[r]=Array.isArray(e[r])?[]:{},Yi(e[r],t[r])):ft(e[r])||(t[r]=!0);return t}function sf(e,t,n){const r=Array.isArray(e);if(et(e)||r)for(const i in e)Array.isArray(e[i])||et(e[i])&&!rf(e[i])?Qe(t)||Aa(n[i])?n[i]=Array.isArray(e[i])?Yi(e[i],[]):{...Yi(e[i])}:sf(e[i],ft(t)?{}:t[i],n[i]):n[i]=!hn(e[i],t[i]);return n}var Ir=(e,t)=>sf(e,t,Yi(t)),af=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>Qe(e)?e:t?e===""?NaN:e&&+e:n&&Yt(e)?new Date(e):r?r(e):e;function Ws(e){const t=e.ref;return yo(t)?t.files:bo(t)?tf(e.refs).value:nf(t)?[...t.selectedOptions].map(({value:n})=>n):xi(t)?ef(e.refs).value:af(Qe(t.value)?e.ref.value:t.value,e)}var Px=(e,t,n,r)=>{const i={};for(const s of e){const a=le(t,s);a&&Me(i,s,a._f)}return{criteriaMode:n,names:[...e],fields:i,shouldUseNativeValidation:r}},Ar=e=>Qe(e)?e:Gi(e)?e.source:et(e)?Gi(e.value)?e.value.source:e.value:e;const hl="AsyncFunction";var Dx=e=>!!e&&!!e.validate&&!!(Gt(e.validate)&&e.validate.constructor.name===hl||et(e.validate)&&Object.values(e.validate).find(t=>t.constructor.name===hl)),Rx=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function ml(e,t,n){const r=le(e,n);if(r||go(n))return{error:r,name:n};const i=n.split(".");for(;i.length;){const s=i.join("."),a=le(t,s),o=le(e,s);if(a&&!Array.isArray(a)&&n!==s)return{name:n};if(o&&o.type)return{name:s,error:o};i.pop()}return{name:n}}var Mx=(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,$x=(e,t)=>!Ss(le(e,t)).length&&it(e,t);const Fx={mode:Ft.onSubmit,reValidateMode:Ft.onChange,shouldFocusError:!0};function Lx(e={}){let t={...Fx,...e},n={submitCount:0,isDirty:!1,isLoading:Gt(t.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1},r={},i=et(t.defaultValues)||et(t.values)?yt(t.defaultValues||t.values)||{}:{},s=t.shouldUnregister?{}:yt(i),a={action:!1,mount:!1,watch:!1},o={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},l,c=0;const f={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},d={values:Js(),array:Js(),state:Js()},h=ol(t.mode),p=ol(t.reValidateMode),g=t.criteriaMode===Ft.all,w=E=>R=>{clearTimeout(c),c=setTimeout(E,R)},_=async E=>{if(!t.disabled&&(f.isValid||E)){const R=t.resolver?bt((await $()).errors):await j(r,!0);R!==n.isValid&&d.state.next({isValid:R})}},b=(E,R)=>{!t.disabled&&(f.isValidating||f.validatingFields)&&((E||Array.from(o.mount)).forEach(Z=>{Z&&(R?Me(n.validatingFields,Z,R):it(n.validatingFields,Z))}),d.state.next({validatingFields:n.validatingFields,isValidating:!bt(n.validatingFields)}))},N=(E,R=[],Z,se,z=!0,K=!0)=>{if(se&&Z&&!t.disabled){if(a.action=!0,K&&Array.isArray(le(r,E))){const te=Z(le(r,E),se.argA,se.argB);z&&Me(r,E,te)}if(K&&Array.isArray(le(n.errors,E))){const te=Z(le(n.errors,E),se.argA,se.argB);z&&Me(n.errors,E,te),$x(n.errors,E)}if(f.touchedFields&&K&&Array.isArray(le(n.touchedFields,E))){const te=Z(le(n.touchedFields,E),se.argA,se.argB);z&&Me(n.touchedFields,E,te)}f.dirtyFields&&(n.dirtyFields=Ir(i,s)),d.state.next({name:E,isDirty:T(E,R),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else Me(s,E,R)},m=(E,R)=>{Me(n.errors,E,R),d.state.next({errors:n.errors})},O=E=>{n.errors=E,d.state.next({errors:n.errors,isValid:!1})},C=(E,R,Z,se)=>{const z=le(r,E);if(z){const K=le(s,E,Qe(Z)?le(i,E):Z);Qe(K)||se&&se.defaultChecked||R?Me(s,E,R?K:Ws(z._f)):M(E,K),a.mount&&_()}},v=(E,R,Z,se,z)=>{let K=!1,te=!1;const xe={name:E};if(!t.disabled){const L=!!(le(r,E)&&le(r,E)._f&&le(r,E)._f.disabled);if(!Z||se){f.isDirty&&(te=n.isDirty,n.isDirty=xe.isDirty=T(),K=te!==xe.isDirty);const Q=L||hn(le(i,E),R);te=!!(!L&&le(n.dirtyFields,E)),Q||L?it(n.dirtyFields,E):Me(n.dirtyFields,E,!0),xe.dirtyFields=n.dirtyFields,K=K||f.dirtyFields&&te!==!Q}if(Z){const Q=le(n.touchedFields,E);Q||(Me(n.touchedFields,E,Z),xe.touchedFields=n.touchedFields,K=K||f.touchedFields&&Q!==Z)}K&&z&&d.state.next(xe)}return K?xe:{}},k=(E,R,Z,se)=>{const z=le(n.errors,E),K=f.isValid&&zt(R)&&n.isValid!==R;if(t.delayError&&Z?(l=w(()=>m(E,Z)),l(t.delayError)):(clearTimeout(c),l=null,Z?Me(n.errors,E,Z):it(n.errors,E)),(Z?!hn(z,Z):z)||!bt(se)||K){const te={...se,...K&&zt(R)?{isValid:R}:{},errors:n.errors,name:E};n={...n,...te},d.state.next(te)}},$=async E=>{b(E,!0);const R=await t.resolver(s,t.context,Px(E||o.mount,r,t.criteriaMode,t.shouldUseNativeValidation));return b(E),R},H=async E=>{const{errors:R}=await $(E);if(E)for(const Z of E){const se=le(R,Z);se?Me(n.errors,Z,se):it(n.errors,Z)}else n.errors=R;return R},j=async(E,R,Z={valid:!0})=>{for(const se in E){const z=E[se];if(z){const{_f:K,...te}=z;if(K){const xe=o.array.has(K.name),L=z._f&&Dx(z._f);L&&f.validatingFields&&b([se],!0);const Q=await pl(z,o.disabled,s,g,t.shouldUseNativeValidation&&!R,xe);if(L&&f.validatingFields&&b([se]),Q[K.name]&&(Z.valid=!1,R))break;!R&&(le(Q,K.name)?xe?Ix(n.errors,Q,K.name):Me(n.errors,K.name,Q[K.name]):it(n.errors,K.name))}!bt(te)&&await j(te,R,Z)}}return Z.valid},I=()=>{for(const E of o.unMount){const R=le(r,E);R&&(R._f.refs?R._f.refs.every(Z=>!Hs(Z)):!Hs(R._f.ref))&&Y(E)}o.unMount=new Set},T=(E,R)=>!t.disabled&&(E&&R&&Me(s,E,R),!hn(oe(),i)),P=(E,R,Z)=>Qd(E,o,{...a.mount?s:Qe(R)?i:Yt(E)?{[E]:R}:R},Z,R),A=E=>Ss(le(a.mount?s:i,E,t.shouldUnregister?le(i,E,[]):[])),M=(E,R,Z={})=>{const se=le(r,E);let z=R;if(se){const K=se._f;K&&(!K.disabled&&Me(s,E,af(R,K)),z=qi(K.ref)&&ft(R)?"":R,nf(K.ref)?[...K.ref.options].forEach(te=>te.selected=z.includes(te.value)):K.refs?xi(K.ref)?K.refs.length>1?K.refs.forEach(te=>(!te.defaultChecked||!te.disabled)&&(te.checked=Array.isArray(z)?!!z.find(xe=>xe===te.value):z===te.value)):K.refs[0]&&(K.refs[0].checked=!!z):K.refs.forEach(te=>te.checked=te.value===z):yo(K.ref)?K.ref.value="":(K.ref.value=z,K.ref.type||d.values.next({name:E,values:{...s}})))}(Z.shouldDirty||Z.shouldTouch)&&v(E,z,Z.shouldTouch,Z.shouldDirty,!0),Z.shouldValidate&&S(E)},V=(E,R,Z)=>{for(const se in R){const z=R[se],K=`${E}.${se}`,te=le(r,K);(o.array.has(E)||et(z)||te&&!te._f)&&!In(z)?V(K,z,Z):M(K,z,Z)}},U=(E,R,Z={})=>{const se=le(r,E),z=o.array.has(E),K=yt(R);Me(s,E,K),z?(d.array.next({name:E,values:{...s}}),(f.isDirty||f.dirtyFields)&&Z.shouldDirty&&d.state.next({name:E,dirtyFields:Ir(i,s),isDirty:T(E,K)})):se&&!se._f&&!ft(K)?V(E,K,Z):M(E,K,Z),ll(E,o)&&d.state.next({...n}),d.values.next({name:a.mount?E:void 0,values:{...s}})},J=async E=>{a.mount=!0;const R=E.target;let Z=R.name,se=!0;const z=le(r,Z),K=()=>R.type?Ws(z._f):Hd(E),te=xe=>{se=Number.isNaN(xe)||In(xe)&&isNaN(xe.getTime())||hn(xe,le(s,Z,xe))};if(z){let xe,L;const Q=K(),me=E.type===Wi.BLUR||E.type===Wi.FOCUS_OUT,ve=!Rx(z._f)&&!t.resolver&&!le(n.errors,Z)&&!z._f.deps||Mx(me,le(n.touchedFields,Z),n.isSubmitted,p,h),F=ll(Z,o,me);Me(s,Z,Q),me?(z._f.onBlur&&z._f.onBlur(E),l&&l(0)):z._f.onChange&&z._f.onChange(E);const ge=v(Z,Q,me,!1),Te=!bt(ge)||F;if(!me&&d.values.next({name:Z,type:E.type,values:{...s}}),ve)return f.isValid&&(t.mode==="onBlur"&&me?_():me||_()),Te&&d.state.next({name:Z,...F?{}:ge});if(!me&&F&&d.state.next({...n}),t.resolver){const{errors:Le}=await $([Z]);if(te(Q),se){const rt=ml(n.errors,r,Z),tt=ml(Le,r,rt.name||Z);xe=tt.error,Z=tt.name,L=bt(Le)}}else b([Z],!0),xe=(await pl(z,o.disabled,s,g,t.shouldUseNativeValidation))[Z],b([Z]),te(Q),se&&(xe?L=!1:f.isValid&&(L=await j(r,!0)));se&&(z._f.deps&&S(z._f.deps),k(Z,L,xe,ge))}},ne=(E,R)=>{if(le(n.errors,R)&&E.focus)return E.focus(),1},S=async(E,R={})=>{let Z,se;const z=qr(E);if(t.resolver){const K=await H(Qe(E)?E:z);Z=bt(K),se=E?!z.some(te=>le(K,te)):Z}else E?(se=(await Promise.all(z.map(async K=>{const te=le(r,K);return await j(te&&te._f?{[K]:te}:te)}))).every(Boolean),!(!se&&!n.isValid)&&_()):se=Z=await j(r);return d.state.next({...!Yt(E)||f.isValid&&Z!==n.isValid?{}:{name:E},...t.resolver||!E?{isValid:Z}:{},errors:n.errors}),R.shouldFocus&&!se&&Gr(r,ne,E?z:o.mount),se},oe=E=>{const R={...a.mount?s:i};return Qe(E)?R:Yt(E)?le(R,E):E.map(Z=>le(R,Z))},B=(E,R)=>({invalid:!!le((R||n).errors,E),isDirty:!!le((R||n).dirtyFields,E),error:le((R||n).errors,E),isValidating:!!le(n.validatingFields,E),isTouched:!!le((R||n).touchedFields,E)}),y=E=>{E&&qr(E).forEach(R=>it(n.errors,R)),d.state.next({errors:E?n.errors:{}})},q=(E,R,Z)=>{const se=(le(r,E,{_f:{}})._f||{}).ref,z=le(n.errors,E)||{},{ref:K,message:te,type:xe,...L}=z;Me(n.errors,E,{...L,...R,ref:se}),d.state.next({name:E,errors:n.errors,isValid:!1}),Z&&Z.shouldFocus&&se&&se.focus&&se.focus()},X=(E,R)=>Gt(E)?d.values.subscribe({next:Z=>E(P(void 0,R),Z)}):P(E,R,!0),Y=(E,R={})=>{for(const Z of E?qr(E):o.mount)o.mount.delete(Z),o.array.delete(Z),R.keepValue||(it(r,Z),it(s,Z)),!R.keepError&&it(n.errors,Z),!R.keepDirty&&it(n.dirtyFields,Z),!R.keepTouched&&it(n.touchedFields,Z),!R.keepIsValidating&&it(n.validatingFields,Z),!t.shouldUnregister&&!R.keepDefaultValue&&it(i,Z);d.values.next({values:{...s}}),d.state.next({...n,...R.keepDirty?{isDirty:T()}:{}}),!R.keepIsValid&&_()},ie=({disabled:E,name:R,field:Z,fields:se})=>{(zt(E)&&a.mount||E||o.disabled.has(R))&&(E?o.disabled.add(R):o.disabled.delete(R),v(R,Ws(Z?Z._f:le(se,R)._f),!1,!1,!0))},D=(E,R={})=>{let Z=le(r,E);const se=zt(R.disabled)||zt(t.disabled);return Me(r,E,{...Z||{},_f:{...Z&&Z._f?Z._f:{ref:{name:E}},name:E,mount:!0,...R}}),o.mount.add(E),Z?ie({field:Z,disabled:zt(R.disabled)?R.disabled:t.disabled,name:E}):C(E,!0,R.value),{...se?{disabled:R.disabled||t.disabled}:{},...t.progressive?{required:!!R.required,min:Ar(R.min),max:Ar(R.max),minLength:Ar(R.minLength),maxLength:Ar(R.maxLength),pattern:Ar(R.pattern)}:{},name:E,onChange:J,onBlur:J,ref:z=>{if(z){D(E,R),Z=le(r,E);const K=Qe(z.value)&&z.querySelectorAll&&z.querySelectorAll("input,select,textarea")[0]||z,te=Ox(K),xe=Z._f.refs||[];if(te?xe.find(L=>L===K):K===Z._f.ref)return;Me(r,E,{_f:{...Z._f,...te?{refs:[...xe.filter(Hs),K,...Array.isArray(le(i,E))?[{}]:[]],ref:{type:K.type,name:E}}:{ref:K}}}),C(E,!1,void 0,K)}else Z=le(r,E,{}),Z._f&&(Z._f.mount=!1),(t.shouldUnregister||R.shouldUnregister)&&!(Wd(o.array,E)&&a.action)&&o.unMount.add(E)}}},ue=()=>t.shouldFocusError&&Gr(r,ne,o.mount),he=E=>{zt(E)&&(d.state.next({disabled:E}),Gr(r,(R,Z)=>{const se=le(r,Z);se&&(R.disabled=se._f.disabled||E,Array.isArray(se._f.refs)&&se._f.refs.forEach(z=>{z.disabled=se._f.disabled||E}))},0,!1))},ce=(E,R)=>async Z=>{let se;Z&&(Z.preventDefault&&Z.preventDefault(),Z.persist&&Z.persist());let z=yt(s);if(o.disabled.size)for(const K of o.disabled)Me(z,K,void 0);if(d.state.next({isSubmitting:!0}),t.resolver){const{errors:K,values:te}=await $();n.errors=K,z=te}else await j(r);if(it(n.errors,"root"),bt(n.errors)){d.state.next({errors:{}});try{await E(z,Z)}catch(K){se=K}}else R&&await R({...n.errors},Z),ue(),setTimeout(ue);if(d.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:bt(n.errors)&&!se,submitCount:n.submitCount+1,errors:n.errors}),se)throw se},ee=(E,R={})=>{le(r,E)&&(Qe(R.defaultValue)?U(E,yt(le(i,E))):(U(E,R.defaultValue),Me(i,E,yt(R.defaultValue))),R.keepTouched||it(n.touchedFields,E),R.keepDirty||(it(n.dirtyFields,E),n.isDirty=R.defaultValue?T(E,yt(le(i,E))):T()),R.keepError||(it(n.errors,E),f.isValid&&_()),d.state.next({...n}))},de=(E,R={})=>{const Z=E?yt(E):i,se=yt(Z),z=bt(E),K=z?i:se;if(R.keepDefaultValues||(i=Z),!R.keepValues){if(R.keepDirtyValues){const te=new Set([...o.mount,...Object.keys(Ir(i,s))]);for(const xe of Array.from(te))le(n.dirtyFields,xe)?Me(K,xe,le(s,xe)):U(xe,le(K,xe))}else{if(mo&&Qe(E))for(const te of o.mount){const xe=le(r,te);if(xe&&xe._f){const L=Array.isArray(xe._f.refs)?xe._f.refs[0]:xe._f.ref;if(qi(L)){const Q=L.closest("form");if(Q){Q.reset();break}}}}r={}}s=t.shouldUnregister?R.keepDefaultValues?yt(i):{}:yt(K),d.array.next({values:{...K}}),d.values.next({values:{...K}})}o={mount:R.keepDirtyValues?o.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},a.mount=!f.isValid||!!R.keepIsValid||!!R.keepDirtyValues,a.watch=!!t.shouldUnregister,d.state.next({submitCount:R.keepSubmitCount?n.submitCount:0,isDirty:z?!1:R.keepDirty?n.isDirty:!!(R.keepDefaultValues&&!hn(E,i)),isSubmitted:R.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:z?{}:R.keepDirtyValues?R.keepDefaultValues&&s?Ir(i,s):n.dirtyFields:R.keepDefaultValues&&E?Ir(i,E):R.keepDirty?n.dirtyFields:{},touchedFields:R.keepTouched?n.touchedFields:{},errors:R.keepErrors?n.errors:{},isSubmitSuccessful:R.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1})},fe=(E,R)=>de(Gt(E)?E(s):E,R);return{control:{register:D,unregister:Y,getFieldState:B,handleSubmit:ce,setError:q,_executeSchema:$,_getWatch:P,_getDirty:T,_updateValid:_,_removeUnmounted:I,_updateFieldArray:N,_updateDisabledField:ie,_getFieldArray:A,_reset:de,_resetDefaultValues:()=>Gt(t.defaultValues)&&t.defaultValues().then(E=>{fe(E,t.resetOptions),d.state.next({isLoading:!1})}),_updateFormState:E=>{n={...n,...E}},_disableForm:he,_subjects:d,_proxyFormState:f,_setErrors:O,get _fields(){return r},get _formValues(){return s},get _state(){return a},set _state(E){a=E},get _defaultValues(){return i},get _names(){return o},set _names(E){o=E},get _formState(){return n},set _formState(E){n=E},get _options(){return t},set _options(E){t={...t,...E}}},trigger:S,register:D,handleSubmit:ce,watch:X,setValue:U,getValues:oe,reset:fe,resetField:ee,clearErrors:y,unregister:Y,setError:q,setFocus:(E,R={})=>{const Z=le(r,E),se=Z&&Z._f;if(se){const z=se.refs?se.refs[0]:se.ref;z.focus&&(z.focus(),R.shouldSelect&&Gt(z.select)&&z.select())}},getFieldState:B}}function Bx(e={}){const t=je.useRef(void 0),n=je.useRef(void 0),[r,i]=je.useState({isDirty:!1,isValidating:!1,isLoading:Gt(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,defaultValues:Gt(e.defaultValues)?void 0:e.defaultValues});t.current||(t.current={...Lx(e),formState:r});const s=t.current.control;return s._options=e,xo({subject:s._subjects.state,next:a=>{Kd(a,s._proxyFormState,s._updateFormState,!0)&&i({...s._formState})}}),je.useEffect(()=>s._disableForm(e.disabled),[s,e.disabled]),je.useEffect(()=>{if(s._proxyFormState.isDirty){const a=s._getDirty();a!==r.isDirty&&s._subjects.state.next({isDirty:a})}},[s,r.isDirty]),je.useEffect(()=>{e.values&&!hn(e.values,n.current)?(s._reset(e.values,s._options.resetOptions),n.current=e.values,i(a=>({...a}))):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=Yd(r,s),t.current}function Zx(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 Vx=_x,of=x.createContext({}),gl=({...e})=>u.jsx(of.Provider,{value:{name:e.name},children:u.jsx(Cx,{...e})}),js=()=>{const e=x.useContext(of),t=x.useContext(lf),{getFieldState:n,formState:r}=_s(),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}},lf=x.createContext({}),za=x.forwardRef(({className:e,...t},n)=>{const r=x.useId();return u.jsx(lf.Provider,{value:{id:r},children:u.jsx("div",{ref:n,className:G("space-y-2",e),...t})})});za.displayName="FormItem";const Oa=x.forwardRef(({className:e,...t},n)=>{const{error:r,formItemId:i}=js();return u.jsx(Wr,{ref:n,className:G(r&&"text-destructive",e),htmlFor:i,...t})});Oa.displayName="FormLabel";const Pa=x.forwardRef(({...e},t)=>{const{error:n,formItemId:r,formDescriptionId:i,formMessageId:s}=js();return u.jsx(kr,{ref:t,id:r,"aria-describedby":n?`${i} ${s}`:`${i}`,"aria-invalid":!!n,...e})});Pa.displayName="FormControl";const uf=x.forwardRef(({className:e,...t},n)=>{const{formDescriptionId:r}=js();return u.jsx("p",{ref:n,id:r,className:G("text-muted-foreground text-[0.8rem]",e),...t})});uf.displayName="FormDescription";const Da=x.forwardRef(({className:e,children:t,...n},r)=>{const{error:i,formMessageId:s}=js(),a=i?String(i==null?void 0:i.message):t;return a?u.jsx("p",{ref:r,id:s,className:G("text-destructive text-[0.8rem] font-medium",e),...n,children:a}):null});Da.displayName="FormMessage";function vo(){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 cf=()=>({chatOpen:!1,scope:"global",model:"opus",contextAttachments:[],threads:{},activeThreadId:{}}),Ux=(e=cf())=>dx()(fx(px((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,a)=>a!==r)})),clearContext:()=>t({contextAttachments:[]}),setScope:r=>t({scope:r}),setModel:r=>t({model:r}),createThread:r=>{const i=crypto.randomUUID(),s=Date.now(),a={id:i,documentName:r,title:vo(),messages:[],createdAt:s,updatedAt:s};return t(o=>({threads:{...o.threads,[i]:a},activeThreadId:{...o.activeThreadId,[r]:i}})),i},deleteThread:r=>{const i=n(),s=i.threads[r];if(!s)return;const a=Object.fromEntries(Object.entries(i.threads).filter(([c])=>c!==r)),o=s.documentName,l={...i.activeThreadId};if(l[o]===r){const c=Object.values(a).filter(f=>f.documentName===o);c.length>0?(c.sort((f,d)=>d.updatedAt-f.updatedAt),l[o]=c[0].id):delete l[o]}t({threads:a,activeThreadId:l})},switchThread:r=>{const s=n().threads[r];s&&t(a=>({activeThreadId:{...a.activeThreadId,[s.documentName]:r}}))},updateThreadMessages:(r,i)=>{t(s=>{const a=s.threads[r];return a?{threads:{...s.threads,[r]:{...a,messages:i,updatedAt:Date.now()}}}:s})},updateThreadTitle:(r,i)=>{t(s=>{const a=s.threads[r];return a?{threads:{...s.threads,[r]:{...a,title:i}}}:s})},deleteThreadsForDocument:r=>{t(i=>{const s={...i.threads},a={...i.activeThreadId};for(const[o,l]of Object.entries(s))l.documentName===r&&delete s[o];return delete a[r],{threads:s,activeThreadId:a}})},renameThreadsForDocument:(r,i)=>{t(s=>{const a={...s.threads},o={...s.activeThreadId};for(const[l,c]of Object.entries(a))c.documentName===r&&(a[l]={...c,documentName:i});return r in o&&(o[i]=o[r],delete o[r]),{threads:a,activeThreadId:o}})},clearChat:()=>{t(r=>({contextAttachments:[]}))}}),{name:"chat-storage",version:1,storage:hx(()=>ix),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 t}}))),df=x.createContext(void 0),Jx=({children:e})=>{const t=x.useRef(null);return t.current||(t.current=Ux(cf())),u.jsx(df.Provider,{value:t.current,children:e})},Pe=e=>{const t=x.useContext(df);if(!t)throw new Error("useChatStore must be used within ChatStoreProvider");return mx(t,e)};function Hx(e,t,n){return t.filter(r=>r.name!==n).every(r=>r.name!==e)}function Wx(e,t,n){const r={},i=[];e!=="delete"&&(r.name=_i.String({minLength:1,maxLength:120,pattern:"^[a-zA-Z0-9-_. ]+$",description:"Document name (e.g., my-report.docx.json or my-theme.theme.json)"}),i.push("name")),e==="create"&&(r.template=_i.Optional(_i.String({description:"Template selection"})));const s=_i.Object(r,{additionalProperties:!1,required:i.length>0?i:void 0});return{schema:s,validate:a=>{const o=[];if(!vg(s,a))for(const c of wg(s,a))o.push({path:c.path.replace(/^\//,""),message:c.message});const l=a;if(e!=="delete"&&l.name){const c=l.name.trim();c?(l.name=c,t(c)||o.push({path:"name",message:"Document with this name already exists"})):o.push({path:"name",message:"Name can't be empty"})}return e==="create"&&(n!=null&&n.length)&&l.template&&(n.some(c=>c.name===l.template)||o.push({path:"template",message:"You must select a valid template"})),{success:o.length===0,data:o.length===0?l:void 0,errors:o}}}}function qx(e,t,n){return e==="create"?{name:"",template:t}:e==="update"?{name:n}:{}}const Gx=e=>({create:{title:e?"New Theme":"New Document",description:e?"Create a new theme from scratch or based on discovered themes.":"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"}}),Bn="__empty__";function Yx({mode:e,shouldReset:t,postSubmit:n,selectedName:r,discoveredDocuments:i,discoveredThemes:s,isTheme:a}){const[o,l]=x.useState(!1),[c,f]=x.useState(null),[d,h]=x.useState("idle"),{toast:p}=Sr(),g=Gx(a),{documents:w,openTabs:_,createDocument:b,renameDocument:N,deleteDocument:m,openDocument:O,closeDocument:C}=Ne(oe=>oe),{updateTheme:v,removeTheme:k}=Ia(oe=>oe),$=Pe(oe=>oe.renameThreadsForDocument),H=Pe(oe=>oe.deleteThreadsForDocument),j=x.useMemo(()=>a?s||[]:i||[],[a,i,s]),I=x.useMemo(()=>{const oe={current:[],downstream:[]};return j.forEach(B=>{oe[B.location]&&oe[B.location].push(B)}),oe},[j]),T=x.useMemo(()=>j.map(oe=>({name:oe.name,type:"application/json",text:"",mtime:new Date,ctime:new Date,atime:new Date})),[j]),P=x.useMemo(()=>Wx(e,oe=>Hx(oe,w,r),T),[e,w,r,T]),A=P.schema,M=x.useMemo(()=>{const oe=new Map;return j.forEach(B=>oe.set(B.path,B)),oe},[j]),V=Bn,U=Bx({resolver:Zx(P.validate),defaultValues:qx(e,void 0,r)}),[J,ne]=x.useState(V);x.useEffect(()=>{if(J&&J!==Bn&&e==="create"){const oe=M.get(J);if(oe){f(null),h("loading");let B=!1;return fetch(`/api/discovery/${a?"themes":"documents"}/${encodeURIComponent(oe.name)}/content`).then(y=>{if(!y.ok)throw new Error(`Failed to fetch content: ${y.statusText}`);return y.text()}).then(y=>{if(B)return;const q=JSON.parse(y);f(JSON.stringify(q,null,2)),h("idle")}).catch(y=>{B||(console.error("Failed to copy template:",y),f(null),h("error"))}),()=>{B=!0}}}h("idle")},[J,e,M,a]),x.useEffect(()=>{t&&(U.reset(),f(null),h("idle"),ne(V))},[U,t]);const S=U.handleSubmit(async({name:oe,template:B})=>{l(!0);try{if(await new Promise(y=>setTimeout(y,200)),e==="create"){const y=J?M.get(J):j.find(ee=>ee.name===B);let q,X=oe;if(!!J&&J!==Bn&&c===null){p({title:d==="loading"?"Template still loading":`Could not copy ${(y==null?void 0:y.name)??"the selected template"}`,description:d==="loading"?"Wait for the template to finish loading, then try again.":"Pick another template, or create an empty one instead.",variant:"destructive"});return}if(a){const ee=X.replace(/\.(json|theme)$/i,"").toLowerCase().replace(/\s+/g,"-"),de=ht==="docx"?kg(ee):{name:ee,colors:{primary:"#2563EB",secondary:"#64748B",accent:"#F8FAFC",background:"#FFFFFF",text:"#334155"},fonts:{heading:"Calibri",body:"Calibri"},defaults:{fontSize:18,fontColor:"#334155"}};q=c||JSON.stringify(de,null,2);const fe=`.${ht}.theme.json`;X.endsWith(fe)||(X=X.replace(/\.(pptx|docx)\.theme\.json$/i,"").replace(/\.theme\.json$/i,"").replace(/\.json$/i,""),X+=fe)}else{const ee=y;q=c||JSON.stringify(ht==="docx"?{name:"docx",props:{theme:(ee==null?void 0:ee.theme)||"default",metadata:{title:(ee==null?void 0:ee.title)||X.replace(/\.(json|js)$/i,"")}},children:[{name:"section",props:{},children:[{name:"paragraph",props:{text:"Start writing your document content here..."}}]}]}:{name:"pptx",props:{title:(ee==null?void 0:ee.title)||X.replace(/\.(json|js)$/i,""),theme:(ee==null?void 0:ee.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 de=ht==="docx"?".docx.json":".pptx.json";!X.endsWith(de)&&!X.endsWith(".json")&&(X+=de)}const ie=X.match(/(\.(pptx|docx)(\.theme)?\.json|\.json)$/i),D=ie?ie[0]:"",ue=X.slice(0,X.length-D.length);let he=X,ce=1;for(;w.some(ee=>ee.name===he);)ce++,he=`${ue} (${ce})${D}`;X=he,b(X,q),O(X),a&&v(X,q)}else if(e==="update"){const y=r,q=oe,X=_.includes(y);X&&C(y),N(y,q),$(y,q),X&&O(q)}else if(e==="delete"){const y=r;C(y),m(y),H(y),a&&k(y)}n()}finally{l(!1)}});return u.jsx(Vx,{...U,children:u.jsxs("form",{onSubmit:S,children:[u.jsxs(Vt,{children:[u.jsx(Ut,{children:g[e].title}),u.jsx(on,{children:g[e].description})]}),u.jsxs("div",{className:"flex flex-col gap-4 py-4",children:[A.properties&&"name"in A.properties&&u.jsx(gl,{control:U.control,name:"name",render:({field:oe})=>u.jsxs(za,{children:[u.jsx(Oa,{children:"Name"}),u.jsx(Pa,{children:u.jsx(hr,{placeholder:"Enter a name or select a template below",autoComplete:"off",...oe})}),u.jsx(Da,{})]})}),e==="create"&&u.jsx(gl,{control:U.control,name:"template",render:({field:oe})=>u.jsxs(za,{children:[u.jsx(Oa,{children:a?"Base Theme":"Base Document"}),u.jsxs(ti,{onValueChange:B=>{if(B===Bn)oe.onChange(void 0),U.setValue("name",""),ne(Bn),f(null);else{const y=M.get(B);y&&(oe.onChange(y.name),U.setValue("name",y.name),ne(B))}},defaultValue:V,children:[u.jsx(Pa,{children:u.jsx(fr,{children:u.jsx(ni,{placeholder:`Select a discovered ${a?"theme":"document"}`})})}),u.jsxs(pr,{className:"max-h-[300px]",children:[u.jsxs(Pn,{value:Bn,children:["Empty ",a?"theme":"document"]}),Object.entries(I).map(([B,y])=>y.length===0?null:u.jsxs(Zd,{children:[u.jsx(ho,{children:B==="current"?"📁 Current Directory":"📦 Project"}),y.map(q=>{let X;return q.title&&q.title!==q.name?X=q.title:q.description&&(X=q.description.length>40?q.description.substring(0,40)+"...":q.description),u.jsx(Pn,{value:q.path,className:"pl-6",children:u.jsxs("span",{className:"flex flex-col",children:[u.jsx("span",{className:"font-medium",children:q.name}),X&&u.jsx("span",{className:"text-muted-foreground text-xs",children:X})]})},q.path)})]},B))]})]}),u.jsxs(uf,{children:["Start empty or select a discovered"," ",a?"theme":"document"," as a starting point"]}),u.jsx(Da,{})]})})]}),u.jsx(bn,{children:u.jsx(Se,{type:"submit",variant:g[e].buttonVariant,disabled:o,children:o?u.jsxs(u.Fragment,{children:[u.jsx(gn,{size:"sm",className:"mr-2"}),e==="create"?"Creating...":e==="update"?"Saving...":"Deleting..."]}):g[e].button})})]})})}const Ki=je.memo(Yx);function cn(e,t){return t?e.toLowerCase().includes(t.toLowerCase()):!0}function wo({text:e,query:t}){if(!t)return u.jsx(u.Fragment,{children:e});const n=e.toLowerCase().indexOf(t.toLowerCase());return n===-1?u.jsx(u.Fragment,{children:e}):u.jsxs(u.Fragment,{children:[e.slice(0,n),u.jsx("mark",{className:"bg-transparent p-0 font-semibold text-current",children:e.slice(n,n+t.length)}),e.slice(n+t.length)]})}function Ra({children:e,count:t,actions:n,className:r,open:i,onToggle:s}){const a=u.jsxs(u.Fragment,{children:[u.jsx(_r,{"aria-hidden":!0,className:G("size-3 shrink-0 transition-transform duration-150 ease-out",i&&"rotate-90")}),u.jsx("span",{className:"text-[11px] font-medium tracking-[0.08em] uppercase",children:e}),t!==void 0&&u.jsx("span",{className:"text-[11px] font-normal tabular-nums text-sidebar-foreground/65",children:t})]});return u.jsxs("div",{className:G("flex h-6 shrink-0 items-center gap-1.5 select-none",r),children:[u.jsx("button",{type:"button",onClick:s,"aria-expanded":i,className:G("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:a}),n&&u.jsx("div",{className:"flex shrink-0 items-center gap-0.5 pr-1",children:n})]})}const Ht=je.forwardRef(({className:e,...t},n)=>u.jsx("button",{ref:n,type:"button",className:G("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}));Ht.displayName="RailIconButton";function xl({tone:e,className:t}){return u.jsx("span",{"aria-hidden":!0,className:G("size-1.5 shrink-0 rounded-full",e==="preview"?"bg-data-blue":"bg-warning",t)})}function yl({icon:e,label:t,onClick:n,hint:r}){return n?u.jsxs("button",{type:"button",onClick:n,title:r,className:G("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:[u.jsx(e,{className:"size-3.5 shrink-0"}),u.jsx("span",{className:"truncate",children:t})]}):u.jsx("p",{className:"px-2 py-1 text-[12px] leading-tight text-sidebar-foreground/70",children:t})}const Kx=og,Xx=lg,Qx=x.forwardRef(({className:e,inset:t,children:n,...r},i)=>u.jsxs(id,{ref:i,className:G("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,u.jsx(_r,{className:"ml-auto h-4 w-4"})]}));Qx.displayName=id.displayName;const ey=x.forwardRef(({className:e,...t},n)=>u.jsx(sd,{ref:n,className:G("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}));ey.displayName=sd.displayName;const ff=x.forwardRef(({className:e,...t},n)=>u.jsx(ug,{children:u.jsx(td,{ref:n,className:G("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})}));ff.displayName=td.displayName;const pf=x.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(rd,{ref:r,className:G("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}));pf.displayName=rd.displayName;const ty=x.forwardRef(({className:e,children:t,checked:n,...r},i)=>u.jsxs(ad,{ref:i,className:G("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:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(od,{children:u.jsx(an,{className:"h-4 w-4"})})}),t]}));ty.displayName=ad.displayName;const ny=x.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(ld,{ref:r,className:G("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:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(od,{children:u.jsx(Td,{className:"h-4 w-4 fill-current"})})}),t]}));ny.displayName=ld.displayName;const ry=x.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(ud,{ref:r,className:G("text-foreground px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));ry.displayName=ud.displayName;const hf=x.forwardRef(({className:e,...t},n)=>u.jsx(nd,{ref:n,className:G("bg-border -mx-1 my-1 h-px",e),...t}));hf.displayName=nd.displayName;const mf=({className:e,...t})=>u.jsx("span",{className:G("text-muted-foreground ml-auto text-xs tracking-widest",e),...t});mf.displayName="ContextMenuShortcut";const Ns=cg,Es=dg,iy=x.forwardRef(({className:e,inset:t,children:n,...r},i)=>u.jsxs(hd,{ref:i,className:G("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,u.jsx(_r,{className:"ml-auto"})]}));iy.displayName=hd.displayName;const sy=x.forwardRef(({className:e,...t},n)=>u.jsx(md,{ref:n,className:G("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}));sy.displayName=md.displayName;const yi=x.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(fg,{children:u.jsx(cd,{ref:r,sideOffset:t,className:G("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})}));yi.displayName=cd.displayName;const $t=x.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(dd,{ref:r,className:G("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=dd.displayName;const ay=x.forwardRef(({className:e,children:t,checked:n,...r},i)=>u.jsxs(gd,{ref:i,className:G("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:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(xd,{children:u.jsx(an,{className:"h-4 w-4"})})}),t]}));ay.displayName=gd.displayName;const oy=x.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(yd,{ref:r,className:G("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:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(xd,{children:u.jsx(Td,{className:"h-2 w-2 fill-current"})})}),t]}));oy.displayName=yd.displayName;const ko=x.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(pd,{ref:r,className:G("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));ko.displayName=pd.displayName;const mr=x.forwardRef(({className:e,...t},n)=>u.jsx(fd,{ref:n,className:G("bg-muted -mx-1 my-1 h-px",e),...t}));mr.displayName=fd.displayName;const gf=({className:e,...t})=>u.jsx("span",{className:G("ml-auto text-xs tracking-widest opacity-60",e),...t});gf.displayName="DropdownMenuShortcut";const xf=x.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},i)=>u.jsx(bd,{ref:i,decorative:n,orientation:t,className:G("bg-border shrink-0",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));xf.displayName=bd.displayName;const yf=Jc,ly=pg,uy=Hc,bf=x.forwardRef(({className:e,...t},n)=>u.jsx(ws,{className:G("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}));bf.displayName=ws.displayName;const cy=gi("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"}}),So=x.forwardRef(({side:e="right",className:t,children:n,...r},i)=>u.jsxs(uy,{children:[u.jsx(bf,{}),u.jsxs(ys,{ref:i,className:G(cy({side:e}),t),...r,children:[u.jsxs(co,{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:[u.jsx(yn,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]}),n]})]}));So.displayName=ys.displayName;const dy=x.forwardRef(({className:e,...t},n)=>u.jsx(bs,{ref:n,className:G("text-foreground text-lg font-semibold",e),...t}));dy.displayName=bs.displayName;const fy=x.forwardRef(({className:e,...t},n)=>u.jsx(vs,{ref:n,className:G("text-muted-foreground text-sm",e),...t}));fy.displayName=vs.displayName;function Yr({className:e,...t}){return u.jsx("div",{className:G("bg-primary/10 animate-pulse rounded-md",e),...t})}const qs=768,Gs=1200;function vf(e){return typeof window<"u"?window.innerWidth<e:!1}function wf(){const[e,t]=x.useState(()=>vf(qs));return x.useEffect(()=>{const n=window.matchMedia(`(max-width: ${qs-1}px)`),r=()=>{t(window.innerWidth<qs)};return n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),e}function py(){const[e,t]=x.useState(()=>vf(Gs));return x.useEffect(()=>{const n=window.matchMedia(`(max-width: ${Gs-1}px)`),r=()=>{t(window.innerWidth<Gs)};return n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),e}const hy="sidebar_state",my=60*60*24*7,gy="16rem",xy="18rem",yy="3rem",by="b",kf=x.createContext(null);function Cs(){const e=x.useContext(kf);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}const Sf=x.forwardRef(({defaultOpen:e=!0,open:t,onOpenChange:n,className:r,style:i,children:s,...a},o)=>{const l=wf(),[c,f]=x.useState(!1),[d,h]=x.useState(e),p=t??d,g=x.useCallback(N=>{const m=typeof N=="function"?N(p):N;n?n(m):h(m),document.cookie=`${hy}=${m}; path=/; max-age=${my}`},[n,p]),w=x.useCallback(()=>l?f(N=>!N):g(N=>!N),[l,g,f]);x.useEffect(()=>{const N=O=>{var k;const C=O;if(!C)return!1;const v=(k=C.tagName)==null?void 0:k.toLowerCase();return v==="input"||v==="textarea"||v==="select"||C.isContentEditable?!0:!!(C.closest&&C.closest(".monaco-editor"))},m=O=>{const C=O.metaKey||O.ctrlKey,v=O.key.toLowerCase();if(C&&v===by){O.preventDefault(),w();return}C&&v==="s"&&!N(O.target)&&(O.preventDefault(),w())};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[w]);const _=p?"expanded":"collapsed",b=x.useMemo(()=>({state:_,open:p,setOpen:g,isMobile:l,openMobile:c,setOpenMobile:f,toggleSidebar:w}),[_,p,g,l,c,f,w]);return u.jsx(kf.Provider,{value:b,children:u.jsx(Sg,{delayDuration:0,children:u.jsx("div",{style:{"--sidebar-width":gy,"--sidebar-width-icon":yy,...i},className:G("group/sidebar-wrapper has-[[data-variant=inset]]:bg-sidebar flex min-h-svh w-full",r),ref:o,...a,children:s})})})});Sf.displayName="SidebarProvider";const _f=x.forwardRef(({side:e="left",variant:t="sidebar",collapsible:n="offcanvas",className:r,children:i,...s},a)=>{const{isMobile:o,state:l,openMobile:c,setOpenMobile:f}=Cs();return n==="none"?u.jsx("div",{className:G("bg-sidebar text-sidebar-foreground flex h-full w-[--sidebar-width] flex-col",r),ref:a,...s,children:i}):o?u.jsx(yf,{open:c,onOpenChange:f,...s,children:u.jsx(So,{"data-sidebar":"sidebar","data-mobile":"true",className:"bg-sidebar text-sidebar-foreground w-[--sidebar-width] p-0 [&>button]:hidden",style:{"--sidebar-width":xy},side:e,children:u.jsx("div",{className:"flex h-full w-full flex-col",children:i})})}):u.jsxs("div",{ref:a,className:"group peer text-sidebar-foreground hidden md:block","data-state":l,"data-collapsible":l==="collapsed"?n:"","data-variant":t,"data-side":e,children:[u.jsx("div",{className:G("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]")}),u.jsx("div",{className:G("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:u.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})})]})});_f.displayName="Sidebar";const vy=x.forwardRef(({className:e,onClick:t,...n},r)=>{const{toggleSidebar:i}=Cs();return u.jsxs(Se,{ref:r,"data-sidebar":"trigger",variant:"ghost",size:"icon",className:G("h-7 w-7",e),onClick:s=>{t==null||t(s),i()},...n,children:[u.jsx(Tg,{}),u.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});vy.displayName="SidebarTrigger";const wy=x.forwardRef(({className:e,...t},n)=>{const{toggleSidebar:r}=Cs();return u.jsx("button",{ref:n,"data-sidebar":"rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:r,title:"Toggle Sidebar",className:G("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})});wy.displayName="SidebarRail";const ky=x.forwardRef(({className:e,...t},n)=>u.jsx("main",{ref:n,className:G("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}));ky.displayName="SidebarInset";const Sy=x.forwardRef(({className:e,...t},n)=>u.jsx(hr,{ref:n,"data-sidebar":"input",className:G("bg-background focus-visible:ring-sidebar-ring h-8 w-full shadow-none focus-visible:ring-2",e),...t}));Sy.displayName="SidebarInput";const Ma=x.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,"data-sidebar":"header",className:G("flex flex-col gap-2 p-2",e),...t}));Ma.displayName="SidebarHeader";const jf=x.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,"data-sidebar":"footer",className:G("flex flex-col gap-2 p-2",e),...t}));jf.displayName="SidebarFooter";const _y=x.forwardRef(({className:e,...t},n)=>u.jsx(xf,{ref:n,"data-sidebar":"separator",className:G("bg-sidebar-border mx-2 w-auto",e),...t}));_y.displayName="SidebarSeparator";const $a=x.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,"data-sidebar":"content",className:G("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",e),...t}));$a.displayName="SidebarContent";const jy=x.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,"data-sidebar":"group",className:G("relative flex w-full min-w-0 flex-col p-2",e),...t}));jy.displayName="SidebarGroup";const Ny=x.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const i=t?kr:"div";return u.jsx(i,{ref:r,"data-sidebar":"group-label",className:G("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})});Ny.displayName="SidebarGroupLabel";const Ey=x.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const i=t?kr:"button";return u.jsx(i,{ref:r,"data-sidebar":"group-action",className:G("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})});Ey.displayName="SidebarGroupAction";const Cy=x.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,"data-sidebar":"group-content",className:G("w-full text-sm",e),...t}));Cy.displayName="SidebarGroupContent";const Lr=x.forwardRef(({className:e,...t},n)=>u.jsx("ul",{ref:n,"data-sidebar":"menu",className:G("flex w-full min-w-0 flex-col gap-1",e),...t}));Lr.displayName="SidebarMenu";const Nf=x.forwardRef(({className:e,...t},n)=>u.jsx("li",{ref:n,"data-sidebar":"menu-item",className:G("group/menu-item relative",e),...t}));Nf.displayName="SidebarMenuItem";const Ty=gi("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"}}),Ef=x.forwardRef(({asChild:e=!1,isActive:t=!1,variant:n="default",size:r="default",tooltip:i,className:s,...a},o)=>{const l=e?kr:"button",{isMobile:c,state:f}=Cs(),d=u.jsx(l,{ref:o,"data-sidebar":"menu-button","data-size":r,"data-active":t,className:G(Ty({variant:n,size:r}),s),...a});return i?(typeof i=="string"&&(i={children:i}),u.jsxs(Ye,{children:[u.jsx(Ke,{asChild:!0,children:d}),u.jsx(Xe,{side:"right",align:"center",hidden:f!=="collapsed"||c,...i})]})):d});Ef.displayName="SidebarMenuButton";const Cf=x.forwardRef(({className:e,asChild:t=!1,showOnHover:n=!1,...r},i)=>{const s=t?kr:"button";return u.jsx(s,{ref:i,"data-sidebar":"menu-action",className:G("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})});Cf.displayName="SidebarMenuAction";const Iy=x.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,"data-sidebar":"menu-badge",className:G("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}));Iy.displayName="SidebarMenuBadge";const Ay=x.forwardRef(({className:e,showIcon:t=!1,...n},r)=>{const i=x.useMemo(()=>`${Math.floor(Math.random()*40)+50}%`,[]);return u.jsxs("div",{ref:r,"data-sidebar":"menu-skeleton",className:G("flex h-8 items-center gap-2 rounded-md px-2",e),...n,children:[t&&u.jsx(Yr,{className:"size-4 rounded-md","data-sidebar":"menu-skeleton-icon"}),u.jsx(Yr,{className:"h-4 max-w-[--skeleton-width] flex-1","data-sidebar":"menu-skeleton-text",style:{"--skeleton-width":i}})]})});Ay.displayName="SidebarMenuSkeleton";const zy=x.forwardRef(({className:e,...t},n)=>u.jsx("ul",{ref:n,"data-sidebar":"menu-sub",className:G("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}));zy.displayName="SidebarMenuSub";const Oy=x.forwardRef(({...e},t)=>u.jsx("li",{ref:t,...e}));Oy.displayName="SidebarMenuSubItem";const Py=x.forwardRef(({asChild:e=!1,size:t="md",isActive:n,className:r,...i},s)=>{const a=e?kr:"a";return u.jsx(a,{ref:s,"data-sidebar":"menu-sub-button","data-size":t,"data-active":n,className:G("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})});Py.displayName="SidebarMenuSubButton";function Li(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 Dy=typeof window<"u"?navigator.userAgent.toUpperCase().indexOf("MAC")>=0:!1;function Ry({document:e,compact:t=!1,query:n=""}){const r=x.useRef(null),[i,s]=x.useState(!1),[a,o]=x.useState(!1),[l,c]=x.useState(!1),[f,d]=x.useState(!1),h=Ne(B=>B.openDocument),p=Ne(B=>B.documentTypes),g=Ne(B=>B.activeTab),w=rn(B=>B.name),_=rn(B=>B.text),b=rn(B=>B.isGenerating),m=(p[e.name]||"application/json+report")==="application/json+theme",O=g===e.name,[C,v]=x.useState(w),[k,$]=x.useState(_),H=100,j=0;x.useEffect(()=>{const B=setTimeout(()=>{w&&_?(v(w),$(_)):b||(v(""),$(""))},b?H:j);return()=>clearTimeout(B)},[w,_,b]);const I=C===e.name,T=B=>{var q;const y=new Set;try{const X=JSON.parse(B);(q=X.props)!=null&&q.theme&&y.add(X.props.theme),X.children&&Array.isArray(X.children)&&X.children.forEach(Y=>{var ie;Y.name==="docx"&&((ie=Y.props)!=null&&ie.theme)&&y.add(Y.props.theme)})}catch{}return y},P=x.useMemo(()=>{if(!m||!k)return!1;try{const B=JSON.parse(e.text),y=sx(B);if(y)return T(k).has(y)}catch{}return!1},[m,k,e.text]),A=x.useCallback(()=>{c(!1)},[]),M=x.useCallback(()=>{d(!1)},[]),V=O?null:I?"preview":P?"in-use":null,U=O?"Editing":I?"In preview":P?"Used by preview":null,J=x.useMemo(()=>[{key:"open",label:"Open",shortcut:Dy?"⌘⏎":"⌃⏎",run:()=>h(e.name)},{key:"download",label:"Download…",separatorBefore:!0,run:()=>Li(e.name,new Blob([e.text],{type:e.type}))},{key:"rename",label:"Rename…",shortcut:"⏎",separatorBefore:!0,run:()=>c(!0)},{key:"delete",label:"Delete",shortcut:"⌫",danger:!0,run:()=>d(!0)}],[e.name,e.text,e.type,h]),ne=m?Ig:Id,S=i||a,oe=u.jsxs(Ef,{size:"sm",ref:r,"aria-label":U?`${e.name} — ${U}`:e.name,className:G("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",S&&"bg-sidebar-accent/60 text-sidebar-foreground",O&&"bg-sidebar-accent text-sidebar-accent-foreground font-medium"),title:U?`${e.name} — ${U}`:e.name,onClick:()=>{h(e.name)},onKeyDown:B=>{var y;(B.ctrlKey||B.metaKey)&&B.key==="Enter"?(h(e.name),B.preventDefault()):B.key==="Enter"?(c(!0),B.preventDefault()):B.key==="Backspace"||B.key==="Delete"?(d(!0),B.preventDefault()):B.key==="Escape"&&((y=r.current)==null||y.blur(),B.preventDefault())},children:[O&&u.jsx("span",{"aria-hidden":!0,className:G("bg-primary absolute top-1 bottom-1 left-0 w-[2px] rounded-full",t&&"top-1.5 bottom-1.5")}),u.jsx(ne,{className:G("size-3.5 shrink-0",m?"text-accent2":"text-sidebar-foreground/60",O&&!m&&"text-sidebar-accent-foreground/70")}),!t&&u.jsx("span",{className:"flex-1 truncate",children:u.jsx(wo,{text:e.name,query:n})}),t&&V&&u.jsx(xl,{tone:V,className:"absolute top-1 right-1 size-1.5 ring-2 ring-[hsl(var(--sidebar))]"})]});return u.jsxs(Nf,{children:[u.jsxs(Kx,{onOpenChange:s,children:[u.jsx(Xx,{className:"block",children:t?u.jsxs(Ye,{children:[u.jsx(Ke,{asChild:!0,children:oe}),u.jsx(Xe,{side:"right",children:u.jsxs("div",{className:"text-xs",children:[u.jsx("div",{children:e.name}),u.jsx("div",{className:"opacity-70",children:U??(m?"Theme":"Document")})]})})]}):oe}),u.jsx(ff,{className:"w-44",children:J.map(B=>u.jsxs(je.Fragment,{children:[B.separatorBefore&&u.jsx(hf,{}),u.jsxs(pf,{onClick:B.run,className:G(B.danger&&"text-destructive focus:text-destructive"),children:[B.label,B.shortcut&&u.jsx(mf,{children:B.shortcut})]})]},B.key))})]}),!t&&u.jsxs(u.Fragment,{children:[V&&u.jsx(xl,{tone:V,className:G("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",a&&"opacity-0")}),u.jsxs(Ns,{onOpenChange:o,children:[u.jsx(Es,{asChild:!0,children:u.jsx(Cf,{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:u.jsx(Ad,{})})}),u.jsx(yi,{side:"right",align:"start",className:"w-44",children:J.map(B=>u.jsxs(je.Fragment,{children:[B.separatorBefore&&u.jsx(mr,{}),u.jsxs($t,{onClick:B.run,className:G(B.danger&&"text-destructive focus:text-destructive"),children:[B.label,B.shortcut&&u.jsx(gf,{children:B.shortcut})]})]},B.key))})]})]}),u.jsx(Ct,{open:l,onOpenChange:c,children:u.jsx(kt,{className:"sm:max-w-[425px]",onCloseAutoFocus:B=>{var y;B.preventDefault(),(y=r.current)==null||y.focus()},children:u.jsx(Ki,{mode:"update",shouldReset:!l,postSubmit:A,selectedName:e.name})})}),u.jsx(Ct,{open:f,onOpenChange:d,children:u.jsx(kt,{className:"sm:max-w-[425px]",onCloseAutoFocus:B=>{var y;B.preventDefault(),(y=r.current)==null||y.focus()},children:u.jsx(Ki,{mode:"delete",shouldReset:!f,postSubmit:M,selectedName:e.name})})})]})}const Ni=je.memo(Ry);function My(e,t=!1){const n=e.length;let r=0,i="",s=0,a=16,o=0,l=0,c=0,f=0,d=0;function h(m,O){let C=0,v=0;for(;C<m;){let k=e.charCodeAt(r);if(k>=48&&k<=57)v=v*16+k-48;else if(k>=65&&k<=70)v=v*16+k-65+10;else if(k>=97&&k<=102)v=v*16+k-97+10;else break;r++,C++}return C<m&&(v=-1),v}function p(m){r=m,i="",s=0,a=16,d=0}function g(){let m=r;if(e.charCodeAt(r)===48)r++;else for(r++;r<e.length&&Zn(e.charCodeAt(r));)r++;if(r<e.length&&e.charCodeAt(r)===46)if(r++,r<e.length&&Zn(e.charCodeAt(r)))for(r++;r<e.length&&Zn(e.charCodeAt(r));)r++;else return d=3,e.substring(m,r);let O=r;if(r<e.length&&(e.charCodeAt(r)===69||e.charCodeAt(r)===101))if(r++,(r<e.length&&e.charCodeAt(r)===43||e.charCodeAt(r)===45)&&r++,r<e.length&&Zn(e.charCodeAt(r))){for(r++;r<e.length&&Zn(e.charCodeAt(r));)r++;O=r}else d=3;return e.substring(m,O)}function w(){let m="",O=r;for(;;){if(r>=n){m+=e.substring(O,r),d=2;break}const C=e.charCodeAt(r);if(C===34){m+=e.substring(O,r),r++;break}if(C===92){if(m+=e.substring(O,r),r++,r>=n){d=2;break}switch(e.charCodeAt(r++)){case 34:m+='"';break;case 92:m+="\\";break;case 47:m+="/";break;case 98:m+="\b";break;case 102:m+="\f";break;case 110:m+=`
|
|
3
|
+
`;break;case 114:m+="\r";break;case 116:m+=" ";break;case 117:const k=h(4);k>=0?m+=String.fromCharCode(k):d=4;break;default:d=5}O=r;continue}if(C>=0&&C<=31)if(zr(C)){m+=e.substring(O,r),d=2;break}else d=6;r++}return m}function _(){if(i="",d=0,s=r,l=o,f=c,r>=n)return s=n,a=17;let m=e.charCodeAt(r);if(Ys(m)){do r++,i+=String.fromCharCode(m),m=e.charCodeAt(r);while(Ys(m));return a=15}if(zr(m))return r++,i+=String.fromCharCode(m),m===13&&e.charCodeAt(r)===10&&(r++,i+=`
|
|
4
|
+
`),o++,c=r,a=14;switch(m){case 123:return r++,a=1;case 125:return r++,a=2;case 91:return r++,a=3;case 93:return r++,a=4;case 58:return r++,a=6;case 44:return r++,a=5;case 34:return r++,i=w(),a=10;case 47:const O=r-1;if(e.charCodeAt(r+1)===47){for(r+=2;r<n&&!zr(e.charCodeAt(r));)r++;return i=e.substring(O,r),a=12}if(e.charCodeAt(r+1)===42){r+=2;const C=n-1;let v=!1;for(;r<C;){const k=e.charCodeAt(r);if(k===42&&e.charCodeAt(r+1)===47){r+=2,v=!0;break}r++,zr(k)&&(k===13&&e.charCodeAt(r)===10&&r++,o++,c=r)}return v||(r++,d=1),i=e.substring(O,r),a=13}return i+=String.fromCharCode(m),r++,a=16;case 45:if(i+=String.fromCharCode(m),r++,r===n||!Zn(e.charCodeAt(r)))return a=16;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return i+=g(),a=11;default:for(;r<n&&b(m);)r++,m=e.charCodeAt(r);if(s!==r){switch(i=e.substring(s,r),i){case"true":return a=8;case"false":return a=9;case"null":return a=7}return a=16}return i+=String.fromCharCode(m),r++,a=16}}function b(m){if(Ys(m)||zr(m))return!1;switch(m){case 125:case 93:case 123:case 91:case 34:case 58:case 44:case 47:return!1}return!0}function N(){let m;do m=_();while(m>=12&&m<=15);return m}return{setPosition:p,getPosition:()=>r,scan:t?N:_,getToken:()=>a,getTokenValue:()=>i,getTokenOffset:()=>s,getTokenLength:()=>r-s,getTokenStartLine:()=>l,getTokenStartCharacter:()=>s-f,getTokenError:()=>d}}function Ys(e){return e===32||e===9}function zr(e){return e===10||e===13}function Zn(e){return e>=48&&e<=57}var bl;(function(e){e[e.lineFeed=10]="lineFeed",e[e.carriageReturn=13]="carriageReturn",e[e.space=32]="space",e[e._0=48]="_0",e[e._1=49]="_1",e[e._2=50]="_2",e[e._3=51]="_3",e[e._4=52]="_4",e[e._5=53]="_5",e[e._6=54]="_6",e[e._7=55]="_7",e[e._8=56]="_8",e[e._9=57]="_9",e[e.a=97]="a",e[e.b=98]="b",e[e.c=99]="c",e[e.d=100]="d",e[e.e=101]="e",e[e.f=102]="f",e[e.g=103]="g",e[e.h=104]="h",e[e.i=105]="i",e[e.j=106]="j",e[e.k=107]="k",e[e.l=108]="l",e[e.m=109]="m",e[e.n=110]="n",e[e.o=111]="o",e[e.p=112]="p",e[e.q=113]="q",e[e.r=114]="r",e[e.s=115]="s",e[e.t=116]="t",e[e.u=117]="u",e[e.v=118]="v",e[e.w=119]="w",e[e.x=120]="x",e[e.y=121]="y",e[e.z=122]="z",e[e.A=65]="A",e[e.B=66]="B",e[e.C=67]="C",e[e.D=68]="D",e[e.E=69]="E",e[e.F=70]="F",e[e.G=71]="G",e[e.H=72]="H",e[e.I=73]="I",e[e.J=74]="J",e[e.K=75]="K",e[e.L=76]="L",e[e.M=77]="M",e[e.N=78]="N",e[e.O=79]="O",e[e.P=80]="P",e[e.Q=81]="Q",e[e.R=82]="R",e[e.S=83]="S",e[e.T=84]="T",e[e.U=85]="U",e[e.V=86]="V",e[e.W=87]="W",e[e.X=88]="X",e[e.Y=89]="Y",e[e.Z=90]="Z",e[e.asterisk=42]="asterisk",e[e.backslash=92]="backslash",e[e.closeBrace=125]="closeBrace",e[e.closeBracket=93]="closeBracket",e[e.colon=58]="colon",e[e.comma=44]="comma",e[e.dot=46]="dot",e[e.doubleQuote=34]="doubleQuote",e[e.minus=45]="minus",e[e.openBrace=123]="openBrace",e[e.openBracket=91]="openBracket",e[e.plus=43]="plus",e[e.slash=47]="slash",e[e.formFeed=12]="formFeed",e[e.tab=9]="tab"})(bl||(bl={}));new Array(20).fill(0).map((e,t)=>" ".repeat(t));const Vn=200;new Array(Vn).fill(0).map((e,t)=>`
|
|
5
|
+
`+" ".repeat(t)),new Array(Vn).fill(0).map((e,t)=>"\r"+" ".repeat(t)),new Array(Vn).fill(0).map((e,t)=>`\r
|
|
6
|
+
`+" ".repeat(t)),new Array(Vn).fill(0).map((e,t)=>`
|
|
7
|
+
`+" ".repeat(t)),new Array(Vn).fill(0).map((e,t)=>"\r"+" ".repeat(t)),new Array(Vn).fill(0).map((e,t)=>`\r
|
|
8
|
+
`+" ".repeat(t));var Xi;(function(e){e.DEFAULT={allowTrailingComma:!1}})(Xi||(Xi={}));function $y(e,t=[],n=Xi.DEFAULT){let r={type:"array",offset:-1,length:-1,children:[],parent:void 0};function i(l){r.type==="property"&&(r.length=l-r.offset,r=r.parent)}function s(l){return r.children.push(l),l}Ly(e,{onObjectBegin:l=>{r=s({type:"object",offset:l,length:-1,parent:r,children:[]})},onObjectProperty:(l,c,f)=>{r=s({type:"property",offset:c,length:-1,parent:r,children:[]}),r.children.push({type:"string",value:l,offset:c,length:f,parent:r})},onObjectEnd:(l,c)=>{i(l+c),r.length=l+c-r.offset,r=r.parent,i(l+c)},onArrayBegin:(l,c)=>{r=s({type:"array",offset:l,length:-1,parent:r,children:[]})},onArrayEnd:(l,c)=>{r.length=l+c-r.offset,r=r.parent,i(l+c)},onLiteralValue:(l,c,f)=>{s({type:By(l),offset:c,length:f,parent:r,value:l}),i(c+f)},onSeparator:(l,c,f)=>{r.type==="property"&&(l===":"?r.colonOffset=c:l===","&&i(c))},onError:(l,c,f)=>{t.push({error:l,offset:c,length:f})}},n);const o=r.children[0];return o&&delete o.parent,o}function Fy(e,t){if(!e)return;let n=e;for(let r of t)if(typeof r=="string"){if(n.type!=="object"||!Array.isArray(n.children))return;let i=!1;for(const s of n.children)if(Array.isArray(s.children)&&s.children[0].value===r&&s.children.length===2){n=s.children[1],i=!0;break}if(!i)return}else{const i=r;if(n.type!=="array"||i<0||!Array.isArray(n.children)||i>=n.children.length)return;n=n.children[i]}return n}function Ly(e,t,n=Xi.DEFAULT){const r=My(e,!1),i=[];let s=0;function a(A){return A?()=>s===0&&A(r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter()):()=>!0}function o(A){return A?M=>s===0&&A(M,r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter()):()=>!0}function l(A){return A?M=>s===0&&A(M,r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter(),()=>i.slice()):()=>!0}function c(A){return A?()=>{s>0?s++:A(r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter(),()=>i.slice())===!1&&(s=1)}:()=>!0}function f(A){return A?()=>{s>0&&s--,s===0&&A(r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter())}:()=>!0}const d=c(t.onObjectBegin),h=l(t.onObjectProperty),p=f(t.onObjectEnd),g=c(t.onArrayBegin),w=f(t.onArrayEnd),_=l(t.onLiteralValue),b=o(t.onSeparator),N=a(t.onComment),m=o(t.onError),O=n&&n.disallowComments,C=n&&n.allowTrailingComma;function v(){for(;;){const A=r.scan();switch(r.getTokenError()){case 4:k(14);break;case 5:k(15);break;case 3:k(13);break;case 1:O||k(11);break;case 2:k(12);break;case 6:k(16);break}switch(A){case 12:case 13:O?k(10):N();break;case 16:k(1);break;case 15:case 14:break;default:return A}}}function k(A,M=[],V=[]){if(m(A),M.length+V.length>0){let U=r.getToken();for(;U!==17;){if(M.indexOf(U)!==-1){v();break}else if(V.indexOf(U)!==-1)break;U=v()}}}function $(A){const M=r.getTokenValue();return A?_(M):(h(M),i.push(M)),v(),!0}function H(){switch(r.getToken()){case 11:const A=r.getTokenValue();let M=Number(A);isNaN(M)&&(k(2),M=0),_(M);break;case 7:_(null);break;case 8:_(!0);break;case 9:_(!1);break;default:return!1}return v(),!0}function j(){return r.getToken()!==10?(k(3,[],[2,5]),!1):($(!1),r.getToken()===6?(b(":"),v(),P()||k(4,[],[2,5])):k(5,[],[2,5]),i.pop(),!0)}function I(){d(),v();let A=!1;for(;r.getToken()!==2&&r.getToken()!==17;){if(r.getToken()===5){if(A||k(4,[],[]),b(","),v(),r.getToken()===2&&C)break}else A&&k(6,[],[]);j()||k(4,[],[2,5]),A=!0}return p(),r.getToken()!==2?k(7,[2],[]):v(),!0}function T(){g(),v();let A=!0,M=!1;for(;r.getToken()!==4&&r.getToken()!==17;){if(r.getToken()===5){if(M||k(4,[],[]),b(","),v(),r.getToken()===4&&C)break}else M&&k(6,[],[]);A?(i.push(0),A=!1):i[i.length-1]++,P()||k(4,[],[4,5]),M=!0}return w(),A||i.pop(),r.getToken()!==4?k(8,[4],[]):v(),!0}function P(){switch(r.getToken()){case 3:return T();case 1:return I();case 10:return $(!0);default:return H()}}return v(),r.getToken()===17?n.allowEmptyContent?!0:(k(4,[],[]),!1):P()?(r.getToken()!==17&&k(9,[],[]),!0):(k(4,[],[]),!1)}function By(e){switch(typeof e){case"boolean":return"boolean";case"number":return"number";case"string":return"string";case"object":{if(e){if(Array.isArray(e))return"array"}else return"null";return"object"}default:return"null"}}var vl;(function(e){e[e.None=0]="None",e[e.UnexpectedEndOfComment=1]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=2]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=3]="UnexpectedEndOfNumber",e[e.InvalidUnicode=4]="InvalidUnicode",e[e.InvalidEscapeCharacter=5]="InvalidEscapeCharacter",e[e.InvalidCharacter=6]="InvalidCharacter"})(vl||(vl={}));var wl;(function(e){e[e.OpenBraceToken=1]="OpenBraceToken",e[e.CloseBraceToken=2]="CloseBraceToken",e[e.OpenBracketToken=3]="OpenBracketToken",e[e.CloseBracketToken=4]="CloseBracketToken",e[e.CommaToken=5]="CommaToken",e[e.ColonToken=6]="ColonToken",e[e.NullKeyword=7]="NullKeyword",e[e.TrueKeyword=8]="TrueKeyword",e[e.FalseKeyword=9]="FalseKeyword",e[e.StringLiteral=10]="StringLiteral",e[e.NumericLiteral=11]="NumericLiteral",e[e.LineCommentTrivia=12]="LineCommentTrivia",e[e.BlockCommentTrivia=13]="BlockCommentTrivia",e[e.LineBreakTrivia=14]="LineBreakTrivia",e[e.Trivia=15]="Trivia",e[e.Unknown=16]="Unknown",e[e.EOF=17]="EOF"})(wl||(wl={}));const Zy=$y,Rz=Fy;var kl;(function(e){e[e.InvalidSymbol=1]="InvalidSymbol",e[e.InvalidNumberFormat=2]="InvalidNumberFormat",e[e.PropertyNameExpected=3]="PropertyNameExpected",e[e.ValueExpected=4]="ValueExpected",e[e.ColonExpected=5]="ColonExpected",e[e.CommaExpected=6]="CommaExpected",e[e.CloseBraceExpected=7]="CloseBraceExpected",e[e.CloseBracketExpected=8]="CloseBracketExpected",e[e.EndOfFileExpected=9]="EndOfFileExpected",e[e.InvalidCommentToken=10]="InvalidCommentToken",e[e.UnexpectedEndOfComment=11]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=12]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=13]="UnexpectedEndOfNumber",e[e.InvalidUnicode=14]="InvalidUnicode",e[e.InvalidEscapeCharacter=15]="InvalidEscapeCharacter",e[e.InvalidCharacter=16]="InvalidCharacter"})(kl||(kl={}));const Vy=60,Uy=/§jtoc:\d+§/g;function Ie(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 st(e){return(e==null?void 0:e.type)==="string"&&typeof e.value=="string"?e.value:void 0}function Fa(e){return(e==null?void 0:e.type)==="number"&&typeof e.value=="number"?e.value:void 0}function Et(e){return(e==null?void 0:e.type)==="array"&&e.children?e.children:[]}function vt(e,t=Vy,n=!1){const r=e.replace(Uy,"…"),i=n?r.replace(/\s*\n\s*/g," ").trim():r.split(`
|
|
9
|
+
`)[0].trim();return i.length>t?`${i.slice(0,t-1)}…`:i}function Jy(e){const t=Et(Ie(e,"columns"));if(t.length>0)return`${Math.max(0,...t.map(i=>Et(Ie(i,"cells")).length))}×${t.length}`;const n=Et(Ie(e,"rows"));if(n.length>0){const r=n[0],i=(r==null?void 0:r.type)==="array"?Et(r).length:Et(Ie(r,"cells")).length;return i>0?`${n.length}×${i}`:`${n.length} rows`}}function Hy(e){const t=st(Ie(e,"alt"));if(t)return vt(t);const n=st(Ie(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 vt(r,40)}return"image"}function Wy(e,t){var r;const n=st(Ie(t,"text"));switch(e){case"heading":{const i=Fa(Ie(t,"level"))??1;return{label:n?vt(n):"heading",detail:`H${i}`}}case"text":return{label:n?vt(n):"text",detail:st(Ie(t,"style"))};case"paragraph":return{label:n?vt(n):"paragraph"};case"chart":case"highcharts":{const i=st(Ie(t,"title"))??st(Ie(Ie(t,"options"),"title"));return{label:i?vt(i):e,detail:st(Ie(t,"type"))}}case"table":return{label:"table",detail:Jy(t)};case"image":return{label:Hy(t)};case"shape":return{label:st(Ie(t,"type"))??"shape"};case"list":{const i=Et(Ie(t,"items"));return{label:"list",detail:i.length>0?`${i.length} items`:void 0}}case"section":{const i=st(Ie(Ie(t,"meta"),"title"))??st(Ie(t,"title"));return{label:i?vt(i):"section"}}case"statistic":{const i=st(Ie(t,"value"))??((r=Fa(Ie(t,"value")))==null?void 0:r.toString()),s=st(Ie(t,"label"));return{label:vt(s??i??"statistic"),detail:i}}default:return{label:n?vt(n):e}}}function gr(e){if(e.type!=="object")return null;const t=st(Ie(e,"name"));return t?{name:t,props:Ie(e,"props"),childrenArr:Ie(e,"children")}:null}function qy(e){let t;for(const n of Et(e)){const r=gr(n);if(!r)continue;const i=st(Ie(r.props,"text"));if(i){if(r.name==="heading"||r.name==="text")return vt(i,48);r.name==="paragraph"&&t===void 0&&(t=vt(i,48))}}return t}function Qi(e,t,n){let{label:r,detail:i}=Wy(t.name,t.props);return r===t.name&&t.childrenArr&&(r=qy(t.childrenArr)??r),{id:"",kind:t.name,label:r,detail:i,start:e.offset,end:e.offset+e.length,children:Tf(t.childrenArr),reorder:n}}function Tf(e){if(!e||e.type!=="array")return[];const t=`arr@${e.offset}`,n=[];for(const r of Et(e)){const i=gr(r);i&&n.push(Qi(r,i,{groupId:t,sliceStart:r.offset,sliceEnd:r.offset+r.length}))}return n}function Gy(e){const t=Ie(e,"props"),n=st(Ie(Ie(t,"meta"),"title"));if(n)return vt(n,48,!0);let r;const i=(o,l)=>{l&&(!r||o<r.rank)&&(r={rank:o,text:l})},s=Ie(t,"placeholders");if((s==null?void 0:s.type)==="object"&&s.children)for(const o of s.children){if(o.type!=="property"||!o.children)continue;const[l,c]=o.children,f=typeof(l==null?void 0:l.value)=="string"?l.value:"",d=c?gr(c):null,h=d?st(Ie(d.props,"text")):void 0;i(f==="title"?0:f==="subtitle"||f.startsWith("heading")?1:2,h)}const a=(o,l)=>{const c=gr(o);if(c){if(c.name==="text"||c.name==="heading"){const f=st(Ie(c.props,"text"));if(f){const d=st(Ie(c.props,"style"))??"";i(d==="title"?0:d.startsWith("heading")?1:2,f)}}if(l<1)for(const f of Et(c.childrenArr))a(f,l+1)}};for(const o of Et(Ie(e,"children")))a(o,0);return r?vt(r.text,48,!0):void 0}function Yy(e){const t=Ie(e,"children");if(!t||t.type!=="array")return[];const n=`arr@${t.offset}`,r=[];let i=0;for(const s of Et(t)){const a=gr(s);if(!a)continue;const o={groupId:n,sliceStart:s.offset,sliceEnd:s.offset+s.length};a.name==="slide"?(i+=1,r.push({id:"",kind:"slide",label:Gy(s)??`Slide ${i}`,detail:`${i}`,start:s.offset,end:s.offset+s.length,children:Tf(a.childrenArr),reorder:o})):r.push(Qi(s,a,o))}return r}function Ky(e){const t=Ie(e,"children");if(!t||t.type!=="array")return[];const n=`arr@${t.offset}`,r=[],i=[];for(const a of Et(t)){const o=gr(a);if(!o)continue;const l={groupId:n,sliceStart:a.offset,sliceEnd:a.offset+a.length},c=()=>i.length?i[i.length-1].node.children:r;if(o.name==="heading"){const f=Fa(Ie(o.props,"level"))??1;for(;i.length&&i[i.length-1].level>=f;)i.pop();const d=Qi(a,o,l);c().push(d),i.push({level:f,node:d})}else c().push(Qi(a,o,l))}const s=a=>{a.children.forEach(s);const o=a.children[a.children.length-1];a.kind==="heading"&&o&&(a.end=Math.max(a.end,o.end),a.reorder&&o.reorder&&(a.reorder.sliceEnd=Math.max(a.reorder.sliceEnd,o.reorder.sliceEnd)))};return r.forEach(s),r}function Sl(e){switch(e.type){case"string":return vt(String(e.value??""),24);case"number":case"boolean":return String(e.value);case"array":return`${Et(e).length} items`;case"object":return;default:return}}function Xy(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 a=[];if(i.type==="object"&&i.children)for(const o of i.children){if(o.type!=="property"||!o.children)continue;const[l,c]=o.children,f=typeof(l==null?void 0:l.value)=="string"?l.value:void 0;!f||!c||a.push({id:"",kind:"key",label:f,detail:Sl(c),start:o.offset,end:o.offset+o.length,children:[]})}t.push({id:"",kind:"key",label:s,detail:a.length===0?Sl(i):void 0,start:n.offset,end:n.offset+n.length,children:a})}return t}function _l(e,t,n){if(!e.trim())return[];const r=Zy(e,[],{allowTrailingComma:!0});if(!r)return[];const i=n==="theme"?Xy(r):t==="pptx"?Yy(r):Ky(r);return If(i,""),i}function If(e,t){e.forEach((n,r)=>{n.id=t?`${t}.${r}`:`${r}`,If(n.children,n.id)})}function Af(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 Qy(e,t){const n=new Set;for(const r of t)for(const i of Af(e,r))n.add(i);return n}function eb(e,t,n,r){if(n===r||n<0||r<0||n>=t.length||r>=t.length)return null;const i=t.map(f=>f.reorder);if(i.some(f=>!f))return null;const s=i[0].groupId;if(i.some(f=>f.groupId!==s))return null;for(let f=1;f<i.length;f++)if(i[f].sliceStart<i[f-1].sliceEnd)return null;const a=i.map(f=>e.slice(f.sliceStart,f.sliceEnd)),o=[];for(let f=1;f<i.length;f++){const d=e.slice(i[f-1].sliceEnd,i[f].sliceStart);if((d.match(/,/g)??[]).length!==1)return null;o.push(d)}const l=a.map((f,d)=>d);l.splice(r,0,l.splice(n,1)[0]);let c="";return l.forEach((f,d)=>{c+=a[f],d<o.length&&(c+=o[d])}),{start:i[0].sliceStart,end:i[i.length-1].sliceEnd,text:c}}const tb={slide:$g,heading:Mg,text:ja,paragraph:Rg,chart:Ea,highcharts:Ea,table:Dg,image:Pg,shape:zd,list:Og,toc:zg,section:Na,columns:Na,"text-box":ja,statistic:Ag,key:_a};function nb(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 rb(e){const t=e.lastIndexOf(".");return t===-1?"":e.slice(0,t)}function ib(){const{activeTab:e,documentTypes:t}=Ne(po(k=>({activeTab:k.activeTab,documentTypes:k.documentTypes}))),n=Ne(k=>{var $;return k.activeTab?($=k.documents.find(H=>H.name===k.activeTab))==null?void 0:$.text:void 0}),r=$d(k=>e?k.editors.get(e)??null:null),i=e&&t[e]==="application/json+theme"?"theme":"document",[s,a]=x.useState([]),[o,l]=x.useState(null),[c,f]=x.useState(()=>new Set),[d,h]=x.useState(()=>new Set),[p,g]=x.useState(null),w=x.useRef(s);w.current=s;const _=x.useRef(null),b=x.useRef(null),N=x.useCallback(()=>{var H;if(!e){a([]);return}const k=((H=r==null?void 0:r.editor.getModel())==null?void 0:H.getValue())??n??"",$=_l(k,ht,i);if(a($),b.current!==e){b.current=e;const j=new Set;if(i==="document"&&ht==="docx")for(const I of $)I.kind==="heading"&&j.add(I.id);h(j),l(null)}},[e,r,n,i]);x.useEffect(()=>{N();const k=r==null?void 0:r.editor.getModel();if(!k)return;const $=sl(N,300),H=k.onDidChangeContent(()=>$());return()=>{$.cancel(),H.dispose()}},[N,r]),x.useEffect(()=>{if(!r)return;const{editor:k}=r,$=sl(()=>{const j=k.getModel(),I=k.getPosition();if(!j||!I)return;const T=j.getOffsetAt(I),P=Af(w.current,T);if(P.length===0){l(null);return}l(P[P.length-1]);const A=P.slice(0,-1);A.length&&h(M=>{if(A.every(U=>M.has(U)))return M;const V=new Set(M);for(const U of A)V.add(U);return V})},150),H=k.onDidChangeCursorPosition(()=>$());return()=>{$.cancel(),H.dispose()}},[r]),x.useEffect(()=>{if(!o||!_.current)return;const k=_.current.querySelector(`[data-oid="${CSS.escape(o)}"]`);k==null||k.scrollIntoView({block:"nearest"})},[o]),x.useEffect(()=>{if(!r){f(new Set);return}const{editor:k,monaco:$}=r,H=()=>{const I=k.getModel();if(!I)return;const T=$.editor.getModelMarkers({resource:I.uri}).filter(P=>P.severity===$.MarkerSeverity.Error).map(P=>I.getOffsetAt({lineNumber:P.startLineNumber,column:P.startColumn}));f(Qy(w.current,T))};H();const j=$.editor.onDidChangeMarkers(I=>{const T=k.getModel();T&&I.some(P=>P.toString()===T.uri.toString())&&H()});return()=>j.dispose()},[r,s]);const m=x.useCallback(k=>{h($=>{const H=new Set($);return H.has(k)?H.delete(k):H.add(k),H})},[]),O=x.useCallback(k=>{if(l(k.id),!r)return;const{editor:$,monaco:H}=r,j=$.getModel();if(!j)return;const I=j.getPositionAt(k.start),T=j.getPositionAt(k.end),P=new H.Range(I.lineNumber,I.column,T.lineNumber,T.column);$.revealRangeNearTopIfOutsideViewport(P,H.editor.ScrollType.Smooth),$.setPosition(I),$.focus();const A=$.deltaDecorations([],[{range:P,options:{className:"jto-outline-flash"}}]);window.setTimeout(()=>$.deltaDecorations(A,[]),700)},[r]),C=x.useCallback(k=>{var oe;if(!r||!k.overId)return;const{editor:$,monaco:H,collapse:j}=r,I=$.getModel();if(!I)return;const T=I.getValue(),P=_l(T,ht,i),A=k.parentId?((oe=nb(P,k.parentId))==null?void 0:oe.children)??[]:P,M=A.findIndex(B=>B.id===k.dragId),V=A.findIndex(B=>B.id===k.overId);if(M===-1||V===-1)return;let U=V+(k.overHalf==="after"?1:0);M<U&&(U-=1);const J=eb(T,A,M,U);if(!J)return;const ne=I.getPositionAt(J.start),S=I.getPositionAt(J.end);$.executeEdits("outline-reorder",[{range:new H.Range(ne.lineNumber,ne.column,S.lineNumber,S.column),text:J.text}]),j==null||j.resyncDecorations()},[r,i]),v=x.useMemo(()=>{const k=[],$=(H,j,I)=>{var A,M;const T=(M=(A=H[0])==null?void 0:A.reorder)==null?void 0:M.groupId,P=H.length>1&&T!==void 0&&H.every(V=>{var U;return((U=V.reorder)==null?void 0:U.groupId)===T});H.forEach(V=>{const U=tb[V.kind]??Fg,J=V.children.length>0,ne=d.has(V.id),S=o===V.id,oe=(p==null?void 0:p.overId)===V.id;k.push(u.jsxs("div",{"data-oid":V.id,role:"treeitem","aria-selected":S,"aria-expanded":J?ne:void 0,tabIndex:0,draggable:P,onClick:()=>O(V),onKeyDown:B=>{(B.key==="Enter"||B.key===" ")&&(B.preventDefault(),O(V)),B.key==="ArrowRight"&&J&&!ne&&m(V.id),B.key==="ArrowLeft"&&J&&ne&&m(V.id)},onDragStart:B=>{B.dataTransfer.setData("text/plain",V.id),B.dataTransfer.effectAllowed="move",g({dragId:V.id,parentId:I,overId:null,overHalf:"before"})},onDragOver:B=>{if(!p||p.dragId===V.id||rb(p.dragId)!==I)return;B.preventDefault(),B.dataTransfer.dropEffect="move";const y=B.currentTarget.getBoundingClientRect(),q=B.clientY<y.top+y.height/2?"before":"after";(p.overId!==V.id||p.overHalf!==q)&&g({...p,overId:V.id,overHalf:q})},onDrop:B=>{B.preventDefault(),p&&C({...p,overId:V.id,overHalf:p.overHalf}),g(null)},onDragEnd:()=>g(null),className:G("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",S&&"bg-sidebar-accent font-medium text-sidebar-foreground",oe&&(p==null?void 0:p.overHalf)==="before"&&"shadow-[inset_0_2px_0_hsl(var(--ring))]",oe&&(p==null?void 0:p.overHalf)==="after"&&"shadow-[inset_0_-2px_0_hsl(var(--ring))]"),style:{paddingLeft:4+j*12},children:[J?u.jsx("span",{role:"button","aria-label":ne?"Collapse":"Expand",onClick:B=>{B.stopPropagation(),m(V.id)},className:"flex size-3.5 shrink-0 items-center justify-center rounded-xs text-sidebar-foreground/55 hover:text-sidebar-foreground",children:u.jsx(_r,{className:G("size-3 transition-transform",ne&&"rotate-90")})}):u.jsx("span",{className:"size-3.5 shrink-0"}),V.kind==="slide"&&u.jsx("span",{className:"w-3 shrink-0 text-right text-[10px] tabular-nums text-sidebar-foreground/50",children:V.detail}),u.jsx(U,{className:"size-3.5 shrink-0 text-sidebar-foreground/55"}),u.jsx("span",{className:"min-w-0 flex-1 truncate",children:V.label}),V.kind!=="slide"&&V.detail&&u.jsx("span",{className:"shrink-0 text-[10px] text-sidebar-foreground/50",children:V.detail}),c.has(V.id)&&u.jsx("span",{"aria-label":"Contains validation errors",className:"bg-destructive size-1.5 shrink-0 rounded-full"})]},V.id)),J&&ne&&$(V.children,j+1,V.id)})};return $(s,0,""),k},[s,d,o,c,p,O,m,C]);return!e||s.length===0?null:u.jsx("li",{className:"list-none",children:u.jsx("div",{ref:_,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:v})})}const jl=x.memo(ib);async function sb(e,t){const n=JSON.stringify({name:e,props:t,children:[]},null,2);await navigator.clipboard.writeText(n)}const ri=x.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(vd,{ref:r,className:G("relative overflow-hidden",e),...n,children:[u.jsx(hg,{className:"h-full w-full rounded-[inherit]",children:t}),u.jsx(zf,{}),u.jsx(mg,{})]}));ri.displayName=vd.displayName;const zf=x.forwardRef(({className:e,orientation:t="vertical",...n},r)=>u.jsx(wd,{ref:r,orientation:t,className:G("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:u.jsx(gg,{className:"bg-border relative flex-1 rounded-full"})}));zf.displayName=wd.displayName;function Of({className:e,...t}){return u.jsx(xg,{"data-slot":"switch",className:G("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:u.jsx(yg,{"data-slot":"switch-thumb",className:G("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 ab=gi("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"}}),ir=x.forwardRef(({className:e,variant:t,...n},r)=>u.jsx("div",{ref:r,role:"alert",className:G(ab({variant:t}),e),...n}));ir.displayName="Alert";const ob=x.forwardRef(({className:e,...t},n)=>u.jsx("h5",{ref:n,className:G("mb-1 font-medium leading-none tracking-tight",e),...t}));ob.displayName="AlertTitle";const sr=x.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:G("text-sm [&_p]:leading-relaxed",e),...t}));sr.displayName="AlertDescription";const es=x.memo(({keyName:e,value:t,depth:n=0,isLast:r=!1})=>{const[i,s]=x.useState(n<2),a=t!==null&&typeof t=="object",o=Array.isArray(t),l=()=>s(!i),c=()=>t===null?u.jsx("span",{className:"text-muted-foreground",children:"null"}):t===void 0?u.jsx("span",{className:"text-muted-foreground",children:"undefined"}):typeof t=="boolean"?u.jsx("span",{className:"text-warning",children:String(t)}):typeof t=="number"?u.jsx("span",{className:"text-success",children:t}):typeof t=="string"?t.startsWith("http")?u.jsxs("span",{className:"text-data-blue",children:['"',t,'"']}):t.startsWith("#/")?u.jsxs("span",{className:"text-warning",children:['"',t,'"']}):u.jsxs("span",{className:"text-destructive",children:['"',t,'"']}):null,f=a?Object.keys(t).length:0;return u.jsxs("div",{className:G("text-sm",n>0&&"ml-4"),children:[u.jsxs("div",{className:"flex items-start hover:bg-muted/30 rounded-sm px-1 py-0.5",children:[a&&u.jsx("button",{onClick:l,className:"mr-1 hover:bg-muted rounded-sm p-0.5","aria-label":i?"Collapse":"Expand",children:i?u.jsx(mi,{className:"h-3 w-3"}):u.jsx(_r,{className:"h-3 w-3"})}),!a&&u.jsx("span",{className:"w-4"}),e&&u.jsxs(u.Fragment,{children:[u.jsxs("span",{className:"text-data-blue",children:['"',e,'"']}),u.jsx("span",{className:"mx-1",children:":"})]}),a?u.jsxs("span",{className:"text-muted-foreground",children:[o?"[":"{",!i&&u.jsxs("span",{className:"mx-1 text-xs",children:[f," ",o?"items":"properties"]}),!i&&(o?"]":"}")]}):c(),!a&&!r&&u.jsx("span",{className:"text-muted-foreground",children:","})]}),a&&i&&u.jsxs("div",{className:"ml-4",children:[o?t.map((d,h)=>u.jsx(es,{keyName:String(h),value:d,depth:n+1,isLast:h===t.length-1},h)):Object.entries(t).map(([d,h],p,g)=>u.jsx(es,{keyName:d,value:h,depth:n+1,isLast:p===g.length-1},d)),u.jsx("div",{className:"ml-4",children:u.jsxs("span",{className:"text-muted-foreground",children:[o?"]":"}",!r&&","]})})]})]})});es.displayName="JsonNode";const ts=x.memo(({schema:e,loading:t=!1,error:n,className:r})=>t?u.jsxs("div",{className:G("space-y-4",r),children:[u.jsx(Yr,{className:"h-8 w-64"}),u.jsx(Yr,{className:"h-4 w-full"}),u.jsx(Yr,{className:"h-64 w-full"})]}):n?u.jsx(ir,{variant:"destructive",className:r,children:u.jsx(sr,{children:n})}):e?u.jsx(ri,{className:G("h-full w-full rounded-md border bg-muted/10 p-4",r),children:u.jsx("div",{className:"font-mono text-xs",children:u.jsx(es,{value:e})})}):u.jsx(ir,{className:r,children:u.jsx(sr,{children:"No schema available"})}));ts.displayName="SchemaViewer";function lb({plugins:e,initialFocusedPlugin:t}){var m,O;const n=Lt(C=>C.togglePlugin),r=Lt(C=>C.isPluginSelected),i=Lt(C=>C.selectedPlugins),s=Lt(C=>C.isApplyingPlugins),[a,o]=x.useState(null),[l,c]=x.useState(null),[f,d]=x.useState("properties");x.useEffect(()=>{if(t){const C=e.find(v=>v.name===t);if(C){o(C);return}}e.length>0&&!a&&o(e[0])},[t,e]);const h=x.useMemo(()=>{const C={current:[],downstream:[],upstream:[]};return e.forEach(v=>{C[v.location]&&C[v.location].push(v)}),C},[e]),p=async(C,v)=>{a&&(await sb(a.name,C.props),c(v),setTimeout(()=>c(null),2e3))},g=C=>{switch(C){case"current":return"Current Directory";case"downstream":return"Project";case"upstream":return"Parent Directories";default:return C}},w=C=>{switch(C){case"current":return u.jsx(Jg,{className:"size-3"});case"downstream":return u.jsx(Ug,{className:"size-3"});case"upstream":return u.jsx(Id,{className:"size-3"});default:return null}},_=((m=a==null?void 0:a.schema)==null?void 0:m.properties)&&Object.keys(a.schema.properties).length>0,b=(O=a==null?void 0:a.schema)==null?void 0:O.jsonSchema,N=(a==null?void 0:a.examples)&&a.examples.length>0;return u.jsxs(u.Fragment,{children:[u.jsxs(Vt,{children:[u.jsxs(Ut,{className:"flex items-center gap-2",children:[u.jsx(Lg,{className:"size-5 text-warning"}),"Plugins",u.jsxs(Kt,{variant:"secondary",className:"font-normal",children:[i.size," active"]})]}),u.jsxs(on,{children:[e.length," plugin",e.length!==1?"s":""," discovered in your project"]})]}),u.jsxs("div",{className:"mt-3 flex gap-0 h-[600px] border rounded-lg overflow-hidden",children:[u.jsx("div",{className:"w-[240px] flex-none border-r bg-muted/30",children:u.jsx(ri,{className:"h-full",children:u.jsx("div",{className:"p-2 space-y-3",children:Object.entries(h).map(([C,v])=>v.length===0?null:u.jsxs("div",{children:[u.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1 text-[11px] font-medium text-muted-foreground uppercase tracking-wider",children:[w(C),g(C)]}),u.jsx("div",{className:"space-y-0.5",children:v.map(k=>{const $=r(k.name),H=(a==null?void 0:a.name)===k.name;return u.jsxs("button",{onClick:()=>o(k),className:G("w-full text-left px-2 py-1.5 rounded-md transition-colors cursor-pointer","flex items-center gap-2",H?"bg-accent text-accent-foreground":"hover:bg-accent/50 text-foreground"),children:[u.jsx("div",{className:G("size-1.5 rounded-full flex-none transition-colors",$?"bg-warning":"bg-muted-foreground/30")}),u.jsx("span",{className:"text-sm font-medium truncate flex-1",children:k.name})]},k.name)})})]},C))})})}),a?u.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[u.jsxs("div",{className:"flex-none px-5 py-4 border-b bg-background",children:[u.jsxs("div",{className:"flex items-start justify-between gap-3",children:[u.jsxs("div",{className:"min-w-0",children:[u.jsxs("div",{className:"flex items-center gap-2.5",children:[u.jsx("h3",{className:"text-base font-semibold truncate",children:a.name}),a.version&&u.jsxs(Kt,{variant:"outline",className:"font-mono text-[11px] flex-none",children:["v",a.version]})]}),a.description&&u.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:a.description})]}),u.jsxs("div",{className:"flex items-center gap-2 flex-none pt-0.5",children:[u.jsx("span",{className:"text-xs text-muted-foreground",children:r(a.name)?"On":"Off"}),u.jsx(Of,{checked:r(a.name),onCheckedChange:()=>n(a),disabled:s,"aria-label":`Toggle ${a.name}`})]})]}),u.jsxs("div",{className:"flex items-center gap-1.5 mt-2 text-xs text-muted-foreground",children:[w(a.location),u.jsx("span",{children:g(a.location)}),u.jsx("span",{className:"text-muted-foreground/60 mx-1",children:"/"}),u.jsx("span",{className:"font-mono truncate",children:a.relativePath})]})]}),u.jsxs("div",{className:"flex-none px-5 pt-3 pb-0 flex gap-1 border-b bg-background",children:[_&&u.jsx("button",{onClick:()=>d("properties"),className:G("px-3 py-1.5 text-sm font-medium rounded-t-md border-b-2 transition-colors cursor-pointer",f==="properties"?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),children:u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(_a,{className:"size-3.5"}),"Properties"]})}),b&&u.jsx("button",{onClick:()=>d("schema"),className:G("px-3 py-1.5 text-sm font-medium rounded-t-md border-b-2 transition-colors cursor-pointer",f==="schema"?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),children:u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(Bg,{className:"size-3.5"}),"Schema"]})}),N&&u.jsx("button",{onClick:()=>d("examples"),className:G("px-3 py-1.5 text-sm font-medium rounded-t-md border-b-2 transition-colors cursor-pointer",f==="examples"?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),children:u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(Zg,{className:"size-3.5"}),"Examples",u.jsx(Kt,{variant:"secondary",className:"text-[10px] px-1.5 py-0 h-4",children:a.examples.length})]})})]}),u.jsx(ri,{className:"flex-1",children:u.jsxs("div",{className:"p-5",children:[f==="properties"&&_&&u.jsx("div",{className:"space-y-1",children:Object.entries(a.schema.properties).map(([C,v])=>u.jsx(ub,{name:C,prop:v},C))}),f==="schema"&&b&&u.jsx(ts,{schema:a.schema.jsonSchema,loading:!1,className:"h-[420px]"}),f==="examples"&&N&&a.examples.map((C,v)=>u.jsxs("div",{className:G(v>0&&"mt-4 pt-4 border-t"),children:[u.jsxs("div",{className:"flex items-center justify-between mb-2",children:[u.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[C.title&&u.jsx("span",{className:"font-medium text-sm truncate",children:C.title}),!C.title&&u.jsxs("span",{className:"text-sm text-muted-foreground",children:["Example ",v+1]})]}),u.jsx(Se,{size:"sm",variant:"ghost",className:"h-7 px-2 text-xs flex-none",onClick:()=>p(C,v),children:l===v?u.jsxs(u.Fragment,{children:[u.jsx(Vg,{className:"size-3 mr-1 text-success"}),"Copied"]}):u.jsxs(u.Fragment,{children:[u.jsx(ks,{className:"size-3 mr-1"}),"Copy"]})})]}),C.description&&u.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:C.description}),u.jsx("pre",{className:"p-3 bg-muted rounded-md overflow-x-auto text-xs font-mono leading-relaxed",children:JSON.stringify(C.props,null,2)})]},v)),!_&&!b&&!N&&u.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[u.jsx(_a,{className:"size-10 mx-auto mb-3 opacity-20"}),u.jsx("p",{className:"text-sm",children:"No schema or examples available for this plugin"})]})]})})]}):u.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:u.jsx("p",{className:"text-sm",children:"Select a plugin to view details"})})]})]})}function ub({name:e,prop:t}){var a;const[n,r]=x.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 u.jsxs("div",{className:"rounded-md border",children:[u.jsxs("button",{onClick:()=>i&&r(!n),className:G("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?u.jsx(mi,{className:"size-3 text-muted-foreground flex-none"}):u.jsx(_r,{className:"size-3 text-muted-foreground flex-none"}):u.jsx("span",{className:"size-3 flex-none"}),u.jsx("span",{className:"font-mono font-medium text-xs",children:e}),u.jsx(Kt,{variant:"outline",className:"text-[10px] px-1.5 py-0 h-4 flex-none",children:s}),t.optional===!1&&u.jsx("span",{className:"text-[10px] text-destructive font-medium flex-none",children:"required"}),u.jsx("span",{className:"flex-1"}),t.default!==void 0&&u.jsxs("span",{className:"text-[10px] font-mono text-muted-foreground flex-none",children:["= ",JSON.stringify(t.default)]})]}),n&&i&&u.jsxs("div",{className:"px-3 pb-2 pt-0 ml-5 text-xs space-y-1 text-muted-foreground",children:[t.description&&u.jsx("p",{children:t.description}),t.enum&&u.jsxs("p",{children:[u.jsx("span",{className:"font-medium text-foreground",children:"Values: "}),t.enum.map((o,l)=>u.jsxs("span",{children:[l>0&&", ",u.jsx("code",{className:"bg-muted px-1 rounded-sm",children:JSON.stringify(o)})]},l))]}),((a=t.items)==null?void 0:a.type)&&u.jsxs("p",{children:[u.jsx("span",{className:"font-medium text-foreground",children:"Items: "}),t.items.type]})]})]})}const cb={current:"Current directory",downstream:"Project"};function Nl({location:e}){return u.jsx("li",{className:"list-none px-2 pt-2 pb-0.5 text-[10px] tracking-[0.08em] text-sidebar-foreground/65 uppercase",children:cb[e]??e})}function El({name:e,subtitle:t,query:n,onSelect:r}){return u.jsx("li",{className:"list-none",children:u.jsxs("button",{type:"button",onClick:r,title:t?`${e} — ${t}`:e,"aria-label":`Add ${e} to workspace`,className:G("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:[u.jsx("span",{className:"min-w-0 flex-1 truncate text-left",children:u.jsx(wo,{text:e,query:n})}),u.jsx(nn,{"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 db({plugins:e,query:t,open:n,onToggleSection:r,onShowPluginDetails:i,isPluginSelected:s,onTogglePlugin:a,isApplyingPlugins:o,selectedPluginCount:l}){return e.length===0?null:u.jsxs("section",{className:"border-sidebar-border/70 mt-3 border-t pt-2",children:[u.jsx(Ra,{open:n,onToggle:r,count:`${l}/${e.length}`,children:"Plugins"}),n&&u.jsx("div",{className:"flex flex-col gap-0.5",children:e.map(c=>{const f=s(c.name),d=`plugin-switch-${c.filePath||c.name}`;return u.jsxs("div",{title:c.description?`${c.name} — ${c.description}`:c.name,className:G("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:[u.jsx("label",{htmlFor:d,className:G("flex h-7 min-w-0 flex-1 cursor-pointer items-center text-[13px]",f?"text-sidebar-foreground":"text-sidebar-foreground/70"),children:u.jsx("span",{className:"truncate",children:u.jsx(wo,{text:c.name,query:t})})}),u.jsx(Ht,{"aria-label":`Details for ${c.name}`,onClick:h=>{h.stopPropagation(),i(c.name)},className:"opacity-0 group-hover/row:opacity-100 focus-visible:opacity-100",children:u.jsx(Od,{})}),u.jsx(Of,{id:d,checked:f,onCheckedChange:()=>a(c),disabled:o,className:"shrink-0","aria-label":`Toggle ${c.name} plugin`})]},c.filePath||c.name)})})]})}function Cl(e){return x.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 Pf({children:e,className:t}){return u.jsx("kbd",{"data-slot":"kbd",className:G("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","[[data-slot=tooltip-content]_&]:bg-primary-foreground/20 [[data-slot=tooltip-content]_&]:text-primary-foreground",t),children:e})}function fb({children:e,className:t}){return u.jsx("span",{className:G("inline-flex items-center gap-0.5",t),children:e})}const Ei=typeof navigator<"u"&&/Mac|iPod|iPhone|iPad/.test(navigator.platform);function ii({shortcut:e,className:t}){const r=e.split("+").map(i=>i.trim().toLowerCase()).map(i=>{switch(i){case"mod":return Ei?"⌘":"Ctrl";case"shift":return Ei?"⇧":"Shift";case"alt":return Ei?"⌥":"Alt";case"ctrl":return Ei?"⌃":"Ctrl";case"enter":return"↵";default:return i.toUpperCase()}});return u.jsx(fb,{className:t,children:r.map((i,s)=>u.jsx(Pf,{children:i},s))})}function pb({className:e}={}){const{theme:t,setTheme:n}=jd(),r=t==="system"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":t,i=x.useCallback(()=>{n(r==="dark"?"light":"dark")},[r,n]);return u.jsxs(Ye,{children:[u.jsx(Ke,{asChild:!0,children:u.jsxs(Se,{variant:"ghost",size:"icon",onClick:i,className:e,children:[u.jsx(Hg,{className:"hidden dark:block"}),u.jsx(Wg,{className:"block dark:hidden"}),u.jsx("span",{className:"sr-only",children:"Toggle theme"})]})}),u.jsx(Xe,{children:u.jsx("p",{children:"Toggle theme"})})]})}function hb({discoveryData:e,onToggleSidebar:t,isCollapsed:n=!1,isAnimating:r=!1}){const{documents:i,documentTypes:s,createDocument:a,openDocument:o,activeTab:l}=Ne(po(z=>({documents:z.documents,documentTypes:z.documentTypes,createDocument:z.createDocument,openDocument:z.openDocument,activeTab:z.activeTab}))),c=Ia(z=>z.updateTheme),f=Ia(z=>z.removeTheme),d=x.useContext(Fd),[h,p]=x.useState(!1),[g,w]=x.useState(!1),[_,b]=x.useState(!1),[N,m]=x.useState(null),O=Lt(z=>z.togglePlugin),C=Lt(z=>z.isPluginSelected),v=Lt(z=>z.selectedPlugins),k=Lt(z=>z.isApplyingPlugins),[$,H]=x.useState(!1),[j,I]=x.useState(new Set(["documents","themes"])),[T,P]=x.useState(""),A=x.useRef(null),{toast:M}=Sr(),V=i.filter(z=>s[z.name]!=="application/json+theme"),U=i.filter(z=>s[z.name]==="application/json+theme"),J=x.useCallback(()=>{p(!1)},[]),ne=x.useCallback(()=>{w(!1)},[]),S=x.useRef(new Map);x.useEffect(()=>{const z=S.current,K=new Map;U.forEach(te=>{K.set(te.name,te.text),z.get(te.name)!==te.text&&c(te.name,te.text)}),z.forEach((te,xe)=>{K.has(xe)||f(xe)}),S.current=K},[U,c,f]);const oe=x.useRef(!1);x.useEffect(()=>{if(oe.current||!d)return;oe.current=!0;const z=new Set(U.map(te=>te.name));Object.keys(d.getState().customThemes).forEach(te=>{z.has(te)||f(te)})},[U,f,d]);const B=x.useCallback(z=>{I(K=>{const te=new Set(K);return te.has(z)?te.delete(z):te.add(z),te})},[]),{resolvedTheme:y}=jd(),q=y==="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",X=x.useCallback(async(z,K)=>{if(i.some(te=>te.name===z)){o(z);return}try{const te=await fetch(`/api/discovery/${K?"themes":"documents"}/${encodeURIComponent(z)}/content`);if(!te.ok)throw new Error(te.statusText);const xe=await te.text(),L=JSON.parse(xe);a(z,JSON.stringify(L,null,2),{templateSource:z}),o(z),M({title:`Added ${K?"theme":"document"}: ${z}`})}catch{M({title:"Failed to load",description:`Could not load ${z}`,variant:"destructive"})}},[i,a,o,M]);x.useEffect(()=>{if(n)return;const z=K=>{var L,Q,me,ve,F;if(K.key!=="/"||K.metaKey||K.ctrlKey||K.altKey)return;const te=K.target,xe=(L=te==null?void 0:te.tagName)==null?void 0:L.toLowerCase();xe==="input"||xe==="textarea"||xe==="select"||te!=null&&te.isContentEditable||(Q=te==null?void 0:te.closest)!=null&&Q.call(te,".monaco-editor")||(me=A.current)!=null&&me.closest('[aria-hidden="true"], [inert]')||(K.preventDefault(),(ve=A.current)==null||ve.focus(),(F=A.current)==null||F.select())};return window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)},[n]);const Y=T.trim(),ie=x.useMemo(()=>new Set(i.map(z=>z.name)),[i]),D=x.useMemo(()=>V.filter(z=>cn(z.name,Y)),[V,Y]),ue=x.useMemo(()=>U.filter(z=>cn(z.name,Y)),[U,Y]),he=x.useMemo(()=>((e==null?void 0:e.documents)??[]).filter(z=>!ie.has(z.name)&&(cn(z.name,Y)||cn(z.title??"",Y))),[e,Y,ie]),ce=x.useMemo(()=>((e==null?void 0:e.themes)??[]).filter(z=>!ie.has(z.name)&&(cn(z.name,Y)||cn(z.description??"",Y))),[e,Y,ie]),ee=Cl(he),de=Cl(ce),fe=x.useMemo(()=>((e==null?void 0:e.plugins)??[]).filter(z=>cn(z.name,Y)||cn(z.description??"",Y)),[e,Y]),Re=z=>Y.length>0||j.has(z),Oe=Re("documents"),We=Re("themes"),E=D.length+he.length,R=ue.length+ce.length,Z=Y.length>0&&D.length===0&&ue.length===0&&he.length===0&&ce.length===0&&fe.length===0,se=G("transition-opacity duration-150 ease-out",r?"opacity-0":"opacity-100");return u.jsxs(u.Fragment,{children:[u.jsxs(_f,{collapsible:"none",style:{"--sidebar-width":n?"3rem":"16rem"},children:[n?u.jsxs(u.Fragment,{children:[u.jsx(Ma,{className:G("gap-0 p-1.5",se),children:u.jsxs(Ye,{children:[u.jsx(Ke,{asChild:!0,children:u.jsx(Ht,{className:"mx-auto size-7","aria-label":"Expand sidebar","aria-expanded":!1,onClick:t,children:u.jsx(Pd,{})})}),u.jsxs(Xe,{side:"right",className:"flex items-center gap-2",children:[u.jsx("span",{children:"Expand sidebar"}),u.jsx(ii,{shortcut:"mod+b"})]})]})}),u.jsxs($a,{className:G("gap-2 px-1 py-1",se),children:[u.jsxs(Lr,{className:"items-center gap-0.5",children:[V.map(z=>u.jsx(Ni,{document:z,compact:!0},z.name)),u.jsxs(Ye,{children:[u.jsx(Ke,{asChild:!0,children:u.jsx(Ht,{className:"size-7","aria-label":"New document",onClick:()=>p(!0),children:u.jsx(nn,{})})}),u.jsx(Xe,{side:"right",children:"New document"})]})]}),u.jsx("div",{className:"bg-sidebar-border/70 mx-auto h-px w-6"}),u.jsxs(Lr,{className:"items-center gap-0.5",children:[U.map(z=>u.jsx(Ni,{document:z,compact:!0},z.name)),u.jsxs(Ye,{children:[u.jsx(Ke,{asChild:!0,children:u.jsx(Ht,{className:"size-7","aria-label":"New theme",onClick:()=>w(!0),children:u.jsx(nn,{})})}),u.jsx(Xe,{side:"right",children:"New theme"})]})]})]})]}):u.jsxs(u.Fragment,{children:[u.jsxs(Ma,{className:G("gap-0 p-2",se),children:[u.jsxs("div",{className:"flex h-7 items-center justify-between gap-1",children:[u.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:u.jsx("img",{src:q,alt:"Wiseair",className:"h-[18px] w-auto max-w-[110px] shrink-0"})}),u.jsxs(Ye,{children:[u.jsx(Ke,{asChild:!0,children:u.jsx(Ht,{"aria-label":"Collapse sidebar","aria-expanded":!0,onClick:t,children:u.jsx(qg,{})})}),u.jsxs(Xe,{side:"right",className:"flex items-center gap-2",children:[u.jsx("span",{children:"Collapse sidebar"}),u.jsx(ii,{shortcut:"mod+b"})]})]})]}),u.jsxs("div",{className:"relative mt-2",children:[u.jsx(Gg,{"aria-hidden":!0,className:"pointer-events-none absolute top-1/2 left-2 size-3.5 -translate-y-1/2 text-sidebar-foreground/40"}),u.jsx("input",{ref:A,type:"text",value:T,spellCheck:!1,autoComplete:"off",placeholder:"Filter files…","aria-label":"Filter documents, themes and plugins",onChange:z=>P(z.target.value),onKeyDown:z=>{z.key==="Escape"&&(z.preventDefault(),P(""),z.currentTarget.blur())},className:G("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")}),Y?u.jsx(Ht,{"aria-label":"Clear filter",onClick:()=>{var z;P(""),(z=A.current)==null||z.focus()},className:"absolute top-1/2 right-1 -translate-y-1/2",children:u.jsx(yn,{})}):u.jsx(Pf,{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:"/"})]})]}),u.jsx($a,{className:G("gap-0 px-2 pb-2",se),children:Z?u.jsxs("div",{className:"px-1 py-6 text-center",children:[u.jsxs("p",{className:"text-[13px] text-sidebar-foreground/70",children:["No files match “",Y,"”"]}),u.jsx("button",{type:"button",onClick:()=>{var z;P(""),(z=A.current)==null||z.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"})]}):u.jsxs(u.Fragment,{children:[(E>0||!Y)&&u.jsxs("section",{children:[u.jsx(Ra,{open:Oe,onToggle:()=>B("documents"),count:E||void 0,actions:u.jsxs(u.Fragment,{children:[ht==="docx"&&u.jsxs(Ye,{children:[u.jsx(Ke,{asChild:!0,children:u.jsx(Ht,{"aria-label":"Compare documents",disabled:V.length<2,onClick:()=>H(!0),children:u.jsx(Cd,{})})}),u.jsx(Xe,{side:"bottom",children:V.length<2?"Compare needs two documents":"Compare documents (redline)"})]}),u.jsxs(Ye,{children:[u.jsx(Ke,{asChild:!0,children:u.jsx(Ht,{"aria-label":"New document",onClick:()=>p(!0),children:u.jsx(nn,{})})}),u.jsx(Xe,{side:"bottom",children:"New document"})]})]}),children:"Documents"}),Oe&&u.jsxs(Lr,{className:"gap-0.5",children:[D.map(z=>u.jsxs(x.Fragment,{children:[u.jsx(Ni,{document:z,query:Y}),!Y&&l===z.name&&u.jsx(jl,{})]},z.name)),ee.map(([z,K])=>u.jsxs(x.Fragment,{children:[ee.length>1&&u.jsx(Nl,{location:z}),K.map(te=>u.jsx(El,{name:te.name,subtitle:te.title,query:Y,onSelect:()=>X(te.name,!1)},te.path||te.name))]},z)),E===0&&u.jsx("li",{className:"list-none",children:u.jsx(yl,{icon:nn,label:"New document",onClick:()=>p(!0)})})]})]}),(R>0||!Y)&&u.jsxs("section",{className:"mt-3",children:[u.jsx(Ra,{open:We,onToggle:()=>B("themes"),count:R||void 0,actions:u.jsxs(Ye,{children:[u.jsx(Ke,{asChild:!0,children:u.jsx(Ht,{"aria-label":"New theme",onClick:()=>w(!0),children:u.jsx(nn,{})})}),u.jsx(Xe,{side:"bottom",children:"New theme"})]}),children:"Themes"}),We&&u.jsxs(Lr,{className:"gap-0.5",children:[ue.map(z=>u.jsxs(x.Fragment,{children:[u.jsx(Ni,{document:z,query:Y}),!Y&&l===z.name&&u.jsx(jl,{})]},z.name)),de.map(([z,K])=>u.jsxs(x.Fragment,{children:[de.length>1&&u.jsx(Nl,{location:z}),K.map(te=>u.jsx(El,{name:te.name,subtitle:te.description,query:Y,onSelect:()=>X(te.name,!0)},te.path||te.name))]},z)),R===0&&u.jsx("li",{className:"list-none",children:u.jsx(yl,{icon:nn,label:"New theme",onClick:()=>w(!0)})})]})]}),u.jsx(db,{plugins:fe,query:Y,open:Re("plugins"),onToggleSection:()=>B("plugins"),onShowPluginDetails:z=>{m(z),b(!0)},isPluginSelected:C,onTogglePlugin:O,isApplyingPlugins:k,selectedPluginCount:v.size})]})})]}),u.jsx(jf,{className:G("border-sidebar-border/70 gap-0 border-t p-1.5",se),children:u.jsx("div",{className:G("flex items-center",n?"justify-center":"justify-start"),children:u.jsx(pb,{className:"size-7 rounded-sm text-sidebar-foreground/70 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground [&_svg]:size-3.5"})})})]}),u.jsx(Ct,{open:h,onOpenChange:p,children:u.jsx(kt,{className:"sm:max-w-[525px]",children:u.jsx(Ki,{mode:"create",shouldReset:!h,postSubmit:J,discoveredDocuments:(e==null?void 0:e.documents)||[]})})}),u.jsx(Ct,{open:g,onOpenChange:w,children:u.jsx(kt,{className:"sm:max-w-[525px]",children:u.jsx(Ki,{mode:"create",shouldReset:!g,postSubmit:ne,discoveredThemes:(e==null?void 0:e.themes)||[],isTheme:!0})})}),u.jsx(Ct,{open:_,onOpenChange:z=>{b(z),z||m(null)},children:u.jsx(kt,{className:"max-h-[85vh] overflow-hidden sm:max-w-5xl",children:u.jsx(lb,{plugins:(e==null?void 0:e.plugins)||[],initialFocusedPlugin:N})})}),u.jsx(wx,{open:$,onOpenChange:H})]})}const Tl=x.memo(hb),mb=x.lazy(()=>Nd(()=>import("./editor-Y9dek093.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12])).then(e=>({default:e.Editor})));function Il(){return u.jsx(x.Suspense,{fallback:u.jsx("div",{className:"flex items-center justify-center h-full",children:u.jsxs("div",{className:"text-center",children:[u.jsx(gn,{className:"w-8 h-8 mx-auto mb-2"}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading editor..."})]})}),children:u.jsx(mb,{})})}const gb=x.lazy(()=>Nd(()=>import("./preview-zCYkbgdR.js"),__vite__mapDeps([13,1,3,4,5,6,7,8,9,10,12,11])).then(e=>({default:e.Preview})));function Al(){return u.jsx(x.Suspense,{fallback:u.jsx("div",{className:"flex items-center justify-center h-full",children:u.jsxs("div",{className:"text-center",children:[u.jsx(gn,{className:"w-8 h-8 mx-auto mb-2"}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading preview..."})]})}),children:u.jsx(gb,{})})}const{createElement:xr,createContext:xb,forwardRef:Df,useCallback:gt,useContext:Rf,useEffect:zn,useImperativeHandle:Mf,useLayoutEffect:yb,useMemo:bb,useRef:wt,useState:ar}=Uc,zl=Uc[`useId${Math.random()}`.slice(0,5)],vb=yb,Ts=xb(null);Ts.displayName="PanelGroupContext";const On=vb,wb=typeof zl=="function"?zl:()=>null;let kb=0;function _o(e=null){const t=wb(),n=wt(e||t||null);return n.current===null&&(n.current=""+kb++),e??n.current}function $f({children:e,className:t="",collapsedSize:n,collapsible:r,defaultSize:i,forwardedRef:s,id:a,maxSize:o,minSize:l,onCollapse:c,onExpand:f,onResize:d,order:h,style:p,tagName:g="div",...w}){const _=Rf(Ts);if(_===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:b,expandPanel:N,getPanelSize:m,getPanelStyle:O,groupId:C,isPanelCollapsed:v,reevaluatePanelConstraints:k,registerPanel:$,resizePanel:H,unregisterPanel:j}=_,I=_o(a),T=wt({callbacks:{onCollapse:c,onExpand:f,onResize:d},constraints:{collapsedSize:n,collapsible:r,defaultSize:i,maxSize:o,minSize:l},id:I,idIsFromProps:a!==void 0,order:h});wt({didLogMissingDefaultSizeWarning:!1}),On(()=>{const{callbacks:A,constraints:M}=T.current,V={...M};T.current.id=I,T.current.idIsFromProps=a!==void 0,T.current.order=h,A.onCollapse=c,A.onExpand=f,A.onResize=d,M.collapsedSize=n,M.collapsible=r,M.defaultSize=i,M.maxSize=o,M.minSize=l,(V.collapsedSize!==M.collapsedSize||V.collapsible!==M.collapsible||V.maxSize!==M.maxSize||V.minSize!==M.minSize)&&k(T.current,V)}),On(()=>{const A=T.current;return $(A),()=>{j(A)}},[h,I,$,j]),Mf(s,()=>({collapse:()=>{b(T.current)},expand:A=>{N(T.current,A)},getId(){return I},getSize(){return m(T.current)},isCollapsed(){return v(T.current)},isExpanded(){return!v(T.current)},resize:A=>{H(T.current,A)}}),[b,N,m,v,I,H]);const P=O(T.current,i);return xr(g,{...w,children:e,className:t,id:a,style:{...P,...p},"data-panel":"","data-panel-collapsible":r||void 0,"data-panel-group-id":C,"data-panel-id":I,"data-panel-size":parseFloat(""+P.flexGrow).toFixed(1)})}const Ff=Df((e,t)=>xr($f,{...e,forwardedRef:t}));$f.displayName="Panel";Ff.displayName="forwardRef(Panel)";let La=null,An=null;function Sb(e,t){if(t){const n=(t&Uf)!==0,r=(t&Jf)!==0,i=(t&Hf)!==0,s=(t&Wf)!==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 _b(){An!==null&&(document.head.removeChild(An),La=null,An=null)}function Ks(e,t){const n=Sb(e,t);La!==n&&(La=n,An===null&&(An=document.createElement("style"),document.head.appendChild(An)),An.innerHTML=`*{cursor: ${n}!important;}`)}function Lf(e){return e.type==="keydown"}function Bf(e){return e.type.startsWith("pointer")}function Zf(e){return e.type.startsWith("mouse")}function Is(e){if(Bf(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(Zf(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function jb(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function Nb(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 Eb(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:Dl(e),b:Dl(t)};let r;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),r=e;_e(r,"Stacking order can only be calculated for elements with a common ancestor");const i={a:Pl(Ol(n.a)),b:Pl(Ol(n.b))};if(i.a===i.b){const s=r.childNodes,a={a:n.a.at(-1),b:n.b.at(-1)};let o=s.length;for(;o--;){const l=s[o];if(l===a.a)return 1;if(l===a.b)return-1}}return Math.sign(i.a-i.b)}const Cb=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function Tb(e){var t;const n=getComputedStyle((t=Vf(e))!==null&&t!==void 0?t:e).display;return n==="flex"||n==="inline-flex"}function Ib(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||Tb(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"||Cb.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function Ol(e){let t=e.length;for(;t--;){const n=e[t];if(_e(n,"Missing node"),Ib(n))return n}return null}function Pl(e){return e&&Number(getComputedStyle(e).zIndex)||0}function Dl(e){const t=[];for(;e;)t.push(e),e=Vf(e);return t}function Vf(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}const Uf=1,Jf=2,Hf=4,Wf=8,Ab=jb()==="coarse";let Bt=[],or=!1,mn=new Map,As=new Map;const si=new Set;function zb(e,t,n,r,i){var s;const{ownerDocument:a}=t,o={direction:n,element:t,hitAreaMargins:r,setResizeHandlerState:i},l=(s=mn.get(a))!==null&&s!==void 0?s:0;return mn.set(a,l+1),si.add(o),ns(),function(){var f;As.delete(e),si.delete(o);const d=(f=mn.get(a))!==null&&f!==void 0?f:1;if(mn.set(a,d-1),ns(),d===1&&mn.delete(a),Bt.includes(o)){const h=Bt.indexOf(o);h>=0&&Bt.splice(h,1),No(),i("up",!0,null)}}}function Rl(e){const{target:t}=e,{x:n,y:r}=Is(e);or=!0,jo({target:t,x:n,y:r}),ns(),Bt.length>0&&(rs("down",e),e.preventDefault(),e.stopPropagation())}function Or(e){const{x:t,y:n}=Is(e);if(or&&e.buttons===0&&(or=!1,rs("up",e)),!or){const{target:r}=e;jo({target:r,x:t,y:n})}rs("move",e),No(),Bt.length>0&&e.preventDefault()}function Un(e){const{target:t}=e,{x:n,y:r}=Is(e);As.clear(),or=!1,Bt.length>0&&e.preventDefault(),rs("up",e),jo({target:t,x:n,y:r}),No(),ns()}function jo({target:e,x:t,y:n}){Bt.splice(0);let r=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(r=e),si.forEach(i=>{const{element:s,hitAreaMargins:a}=i,o=s.getBoundingClientRect(),{bottom:l,left:c,right:f,top:d}=o,h=Ab?a.coarse:a.fine;if(t>=c-h&&t<=f+h&&n>=d-h&&n<=l+h){if(r!==null&&document.contains(r)&&s!==r&&!s.contains(r)&&!r.contains(s)&&Eb(r,s)>0){let g=r,w=!1;for(;g&&!g.contains(s);){if(Nb(g.getBoundingClientRect(),o)){w=!0;break}g=g.parentElement}if(w)return}Bt.push(i)}})}function Xs(e,t){As.set(e,t)}function No(){let e=!1,t=!1;Bt.forEach(r=>{const{direction:i}=r;i==="horizontal"?e=!0:t=!0});let n=0;As.forEach(r=>{n|=r}),e&&t?Ks("intersection",n):e?Ks("horizontal",n):t?Ks("vertical",n):_b()}function ns(){mn.forEach((e,t)=>{const{body:n}=t;n.removeEventListener("contextmenu",Un),n.removeEventListener("pointerdown",Rl),n.removeEventListener("pointerleave",Or),n.removeEventListener("pointermove",Or)}),window.removeEventListener("pointerup",Un),window.removeEventListener("pointercancel",Un),si.size>0&&(or?(Bt.length>0&&mn.forEach((e,t)=>{const{body:n}=t;e>0&&(n.addEventListener("contextmenu",Un),n.addEventListener("pointerleave",Or),n.addEventListener("pointermove",Or))}),window.addEventListener("pointerup",Un),window.addEventListener("pointercancel",Un)):mn.forEach((e,t)=>{const{body:n}=t;e>0&&(n.addEventListener("pointerdown",Rl,{capture:!0}),n.addEventListener("pointermove",Or))}))}function rs(e,t){si.forEach(n=>{const{setResizeHandlerState:r}=n,i=Bt.includes(n);r(e,i,t)})}function Ob(){const[e,t]=ar(0);return gt(()=>t(n=>n+1),[])}function _e(e,t){if(!e)throw console.error(t),Error(t)}const Eo=10;function Dn(e,t,n=Eo){return e.toFixed(n)===t.toFixed(n)?0:e>t?1:-1}function sn(e,t,n=Eo){return Dn(e,t,n)===0}function Nt(e,t,n){return Dn(e,t,n)===0}function Pb(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(!Nt(i,s,n))return!1}return!0}function tr({panelConstraints:e,panelIndex:t,size:n}){const r=e[t];_e(r!=null,`Panel constraints not found for index ${t}`);let{collapsedSize:i=0,collapsible:s,maxSize:a=100,minSize:o=0}=r;if(Dn(n,o)<0)if(s){const l=(i+o)/2;Dn(n,l)<0?n=i:n=o}else n=o;return n=Math.min(a,n),n=parseFloat(n.toFixed(Eo)),n}function Br({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:s}){if(Nt(e,0))return t;const a=[...t],[o,l]=r;_e(o!=null,"Invalid first pivot index"),_e(l!=null,"Invalid second pivot index");let c=0;if(s==="keyboard"){{const d=e<0?l:o,h=n[d];_e(h,`Panel constraints not found for index ${d}`);const{collapsedSize:p=0,collapsible:g,minSize:w=0}=h;if(g){const _=t[d];if(_e(_!=null,`Previous layout not found for panel index ${d}`),Nt(_,p)){const b=w-_;Dn(b,Math.abs(e))>0&&(e=e<0?0-b:b)}}}{const d=e<0?o:l,h=n[d];_e(h,`No panel constraints found for index ${d}`);const{collapsedSize:p=0,collapsible:g,minSize:w=0}=h;if(g){const _=t[d];if(_e(_!=null,`Previous layout not found for panel index ${d}`),Nt(_,w)){const b=_-p;Dn(b,Math.abs(e))>0&&(e=e<0?0-b:b)}}}}{const d=e<0?1:-1;let h=e<0?l:o,p=0;for(;;){const w=t[h];_e(w!=null,`Previous layout not found for panel index ${h}`);const b=tr({panelConstraints:n,panelIndex:h,size:100})-w;if(p+=b,h+=d,h<0||h>=n.length)break}const g=Math.min(Math.abs(e),Math.abs(p));e=e<0?0-g:g}{let h=e<0?o:l;for(;h>=0&&h<n.length;){const p=Math.abs(e)-Math.abs(c),g=t[h];_e(g!=null,`Previous layout not found for panel index ${h}`);const w=g-p,_=tr({panelConstraints:n,panelIndex:h,size:w});if(!Nt(g,_)&&(c+=g-_,a[h]=_,c.toPrecision(3).localeCompare(Math.abs(e).toPrecision(3),void 0,{numeric:!0})>=0))break;e<0?h--:h++}}if(Pb(i,a))return i;{const d=e<0?l:o,h=t[d];_e(h!=null,`Previous layout not found for panel index ${d}`);const p=h+c,g=tr({panelConstraints:n,panelIndex:d,size:p});if(a[d]=g,!Nt(g,p)){let w=p-g,b=e<0?l:o;for(;b>=0&&b<n.length;){const N=a[b];_e(N!=null,`Previous layout not found for panel index ${b}`);const m=N+w,O=tr({panelConstraints:n,panelIndex:b,size:m});if(Nt(N,O)||(w-=O-N,a[b]=O),Nt(w,0))break;e>0?b--:b++}}}const f=a.reduce((d,h)=>h+d,0);return Nt(f,100)?a:i}function Db({layout:e,panelsArray:t,pivotIndices:n}){let r=0,i=100,s=0,a=0;const o=n[0];_e(o!=null,"No pivot index found"),t.forEach((d,h)=>{const{constraints:p}=d,{maxSize:g=100,minSize:w=0}=p;h===o?(r=w,i=g):(s+=w,a+=g)});const l=Math.min(i,100-s),c=Math.max(r,100-a),f=e[o];return{valueMax:l,valueMin:c,valueNow:f}}function ai(e,t=document){return Array.from(t.querySelectorAll(`[data-panel-resize-handle-id][data-panel-group-id="${e}"]`))}function qf(e,t,n=document){const i=ai(e,n).findIndex(s=>s.getAttribute("data-panel-resize-handle-id")===t);return i??null}function Gf(e,t,n){const r=qf(e,t,n);return r!=null?[r,r+1]:[-1,-1]}function Yf(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 zs(e,t=document){const n=t.querySelector(`[data-panel-resize-handle-id="${e}"]`);return n||null}function Rb(e,t,n,r=document){var i,s,a,o;const l=zs(t,r),c=ai(e,r),f=l?c.indexOf(l):-1,d=(i=(s=n[f])===null||s===void 0?void 0:s.id)!==null&&i!==void 0?i:null,h=(a=(o=n[f+1])===null||o===void 0?void 0:o.id)!==null&&a!==void 0?a:null;return[d,h]}function Mb({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:r,panelDataArray:i,panelGroupElement:s,setLayout:a}){wt({didWarnAboutMissingResizeHandle:!1}),On(()=>{if(!s)return;const o=ai(n,s);for(let l=0;l<i.length-1;l++){const{valueMax:c,valueMin:f,valueNow:d}=Db({layout:r,panelsArray:i,pivotIndices:[l,l+1]}),h=o[l];if(h!=null){const p=i[l];_e(p,`No panel data found for index "${l}"`),h.setAttribute("aria-controls",p.id),h.setAttribute("aria-valuemax",""+Math.round(c)),h.setAttribute("aria-valuemin",""+Math.round(f)),h.setAttribute("aria-valuenow",d!=null?""+Math.round(d):"")}}return()=>{o.forEach((l,c)=>{l.removeAttribute("aria-controls"),l.removeAttribute("aria-valuemax"),l.removeAttribute("aria-valuemin"),l.removeAttribute("aria-valuenow")})}},[n,r,i,s]),zn(()=>{if(!s)return;const o=t.current;_e(o,"Eager values not found");const{panelDataArray:l}=o,c=Yf(n,s);_e(c!=null,`No group found for id "${n}"`);const f=ai(n,s);_e(f,`No resize handles found for group id "${n}"`);const d=f.map(h=>{const p=h.getAttribute("data-panel-resize-handle-id");_e(p,"Resize handle element has no handle id attribute");const[g,w]=Rb(n,p,l,s);if(g==null||w==null)return()=>{};const _=b=>{if(!b.defaultPrevented)switch(b.key){case"Enter":{b.preventDefault();const N=l.findIndex(m=>m.id===g);if(N>=0){const m=l[N];_e(m,`No panel data found for index ${N}`);const O=r[N],{collapsedSize:C=0,collapsible:v,minSize:k=0}=m.constraints;if(O!=null&&v){const $=Br({delta:Nt(O,C)?k-C:C-O,initialLayout:r,panelConstraints:l.map(H=>H.constraints),pivotIndices:Gf(n,p,s),prevLayout:r,trigger:"keyboard"});r!==$&&a($)}}break}}};return h.addEventListener("keydown",_),()=>{h.removeEventListener("keydown",_)}});return()=>{d.forEach(h=>h())}},[s,e,t,n,r,i,a])}function Ml(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 Kf(e,t){const n=e==="horizontal",{x:r,y:i}=Is(t);return n?r:i}function $b(e,t,n,r,i){const s=n==="horizontal",a=zs(t,i);_e(a,`No resize handle element found for id "${t}"`);const o=a.getAttribute("data-panel-group-id");_e(o,"Resize handle element has no group id attribute");let{initialCursorPosition:l}=r;const c=Kf(n,e),f=Yf(o,i);_e(f,`No group element found for id "${o}"`);const d=f.getBoundingClientRect(),h=s?d.width:d.height;return(c-l)/h*100}function Fb(e,t,n,r,i,s){if(Lf(e)){const a=n==="horizontal";let o=0;e.shiftKey?o=100:i!=null?o=i:o=10;let l=0;switch(e.key){case"ArrowDown":l=a?0:o;break;case"ArrowLeft":l=a?-o:0;break;case"ArrowRight":l=a?o:0;break;case"ArrowUp":l=a?0:-o;break;case"End":l=100;break;case"Home":l=-100;break}return l}else return r==null?0:$b(e,t,n,r,s)}function Lb({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 a=n[s];_e(a,`Panel constraints not found for index ${s}`);const{defaultSize:o}=a;o!=null&&(r++,t[s]=o,i-=o)}for(let s=0;s<e.length;s++){const a=n[s];_e(a,`Panel constraints not found for index ${s}`);const{defaultSize:o}=a;if(o!=null)continue;const l=e.length-r,c=i/l;r++,t[s]=c,i-=c}return t}function Jn(e,t,n){t.forEach((r,i)=>{const s=e[i];_e(s,`Panel data not found for index ${i}`);const{callbacks:a,constraints:o,id:l}=s,{collapsedSize:c=0,collapsible:f}=o,d=n[l];if(d==null||r!==d){n[l]=r;const{onCollapse:h,onExpand:p,onResize:g}=a;g&&g(r,d),f&&(h||p)&&(p&&(d==null||sn(d,c))&&!sn(r,c)&&p(),h&&(d==null||!sn(d,c))&&sn(r,c)&&h())}})}function Ci(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 Bb({defaultSize:e,dragState:t,layout:n,panelData:r,panelIndex:i,precision:s=3}){const a=n[i];let o;return a==null?o=e!=null?e.toPrecision(s):"1":r.length===1?o="1":o=a.toPrecision(s),{flexBasis:0,flexGrow:o,flexShrink:1,overflow:"hidden",pointerEvents:t!==null?"none":void 0}}function Zb(e,t=10){let n=null;return(...i)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...i)},t)}}function $l(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 Xf(e){return`react-resizable-panels:${e}`}function Qf(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 ep(e,t){try{const n=Xf(e),r=t.getItem(n);if(r){const i=JSON.parse(r);if(typeof i=="object"&&i!=null)return i}}catch{}return null}function Vb(e,t,n){var r,i;const s=(r=ep(e,n))!==null&&r!==void 0?r:{},a=Qf(t);return(i=s[a])!==null&&i!==void 0?i:null}function Ub(e,t,n,r,i){var s;const a=Xf(e),o=Qf(t),l=(s=ep(e,i))!==null&&s!==void 0?s:{};l[o]={expandToSizes:Object.fromEntries(n.entries()),layout:r};try{i.setItem(a,JSON.stringify(l))}catch(c){console.error(c)}}function Fl({layout:e,panelConstraints:t}){const n=[...e],r=n.reduce((s,a)=>s+a,0);if(n.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${n.map(s=>`${s}%`).join(", ")}`);if(!Nt(r,100)&&n.length>0)for(let s=0;s<t.length;s++){const a=n[s];_e(a!=null,`No layout data found for index ${s}`);const o=100/r*a;n[s]=o}let i=0;for(let s=0;s<t.length;s++){const a=n[s];_e(a!=null,`No layout data found for index ${s}`);const o=tr({panelConstraints:t,panelIndex:s,size:a});a!=o&&(i+=a-o,n[s]=o)}if(!Nt(i,0))for(let s=0;s<t.length;s++){const a=n[s];_e(a!=null,`No layout data found for index ${s}`);const o=a+i,l=tr({panelConstraints:t,panelIndex:s,size:o});if(a!==l&&(i-=l-a,n[s]=l,Nt(i,0)))break}return n}const Jb=100,Zr={getItem:e=>($l(Zr),Zr.getItem(e)),setItem:(e,t)=>{$l(Zr),Zr.setItem(e,t)}},Ll={};function tp({autoSaveId:e=null,children:t,className:n="",direction:r,forwardedRef:i,id:s=null,onLayout:a=null,keyboardResizeBy:o=null,storage:l=Zr,style:c,tagName:f="div",...d}){const h=_o(s),p=wt(null),[g,w]=ar(null),[_,b]=ar([]),N=Ob(),m=wt({}),O=wt(new Map),C=wt(0),v=wt({autoSaveId:e,direction:r,dragState:g,id:h,keyboardResizeBy:o,onLayout:a,storage:l}),k=wt({layout:_,panelDataArray:[],panelDataArrayChanged:!1});wt({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),Mf(i,()=>({getId:()=>v.current.id,getLayout:()=>{const{layout:y}=k.current;return y},setLayout:y=>{const{onLayout:q}=v.current,{layout:X,panelDataArray:Y}=k.current,ie=Fl({layout:y,panelConstraints:Y.map(D=>D.constraints)});Ml(X,ie)||(b(ie),k.current.layout=ie,q&&q(ie),Jn(Y,ie,m.current))}}),[]),On(()=>{v.current.autoSaveId=e,v.current.direction=r,v.current.dragState=g,v.current.id=h,v.current.onLayout=a,v.current.storage=l}),Mb({committedValuesRef:v,eagerValuesRef:k,groupId:h,layout:_,panelDataArray:k.current.panelDataArray,setLayout:b,panelGroupElement:p.current}),zn(()=>{const{panelDataArray:y}=k.current;if(e){if(_.length===0||_.length!==y.length)return;let q=Ll[e];q==null&&(q=Zb(Ub,Jb),Ll[e]=q);const X=[...y],Y=new Map(O.current);q(e,X,Y,_,l)}},[e,_,l]),zn(()=>{});const $=gt(y=>{const{onLayout:q}=v.current,{layout:X,panelDataArray:Y}=k.current;if(y.constraints.collapsible){const ie=Y.map(ce=>ce.constraints),{collapsedSize:D=0,panelSize:ue,pivotIndices:he}=jn(Y,y,X);if(_e(ue!=null,`Panel size not found for panel "${y.id}"`),!sn(ue,D)){O.current.set(y.id,ue);const ee=Kn(Y,y)===Y.length-1?ue-D:D-ue,de=Br({delta:ee,initialLayout:X,panelConstraints:ie,pivotIndices:he,prevLayout:X,trigger:"imperative-api"});Ci(X,de)||(b(de),k.current.layout=de,q&&q(de),Jn(Y,de,m.current))}}},[]),H=gt((y,q)=>{const{onLayout:X}=v.current,{layout:Y,panelDataArray:ie}=k.current;if(y.constraints.collapsible){const D=ie.map(fe=>fe.constraints),{collapsedSize:ue=0,panelSize:he=0,minSize:ce=0,pivotIndices:ee}=jn(ie,y,Y),de=q??ce;if(sn(he,ue)){const fe=O.current.get(y.id),Re=fe!=null&&fe>=de?fe:de,We=Kn(ie,y)===ie.length-1?he-Re:Re-he,E=Br({delta:We,initialLayout:Y,panelConstraints:D,pivotIndices:ee,prevLayout:Y,trigger:"imperative-api"});Ci(Y,E)||(b(E),k.current.layout=E,X&&X(E),Jn(ie,E,m.current))}}},[]),j=gt(y=>{const{layout:q,panelDataArray:X}=k.current,{panelSize:Y}=jn(X,y,q);return _e(Y!=null,`Panel size not found for panel "${y.id}"`),Y},[]),I=gt((y,q)=>{const{panelDataArray:X}=k.current,Y=Kn(X,y);return Bb({defaultSize:q,dragState:g,layout:_,panelData:X,panelIndex:Y})},[g,_]),T=gt(y=>{const{layout:q,panelDataArray:X}=k.current,{collapsedSize:Y=0,collapsible:ie,panelSize:D}=jn(X,y,q);return _e(D!=null,`Panel size not found for panel "${y.id}"`),ie===!0&&sn(D,Y)},[]),P=gt(y=>{const{layout:q,panelDataArray:X}=k.current,{collapsedSize:Y=0,collapsible:ie,panelSize:D}=jn(X,y,q);return _e(D!=null,`Panel size not found for panel "${y.id}"`),!ie||Dn(D,Y)>0},[]),A=gt(y=>{const{panelDataArray:q}=k.current;q.push(y),q.sort((X,Y)=>{const ie=X.order,D=Y.order;return ie==null&&D==null?0:ie==null?-1:D==null?1:ie-D}),k.current.panelDataArrayChanged=!0,N()},[N]);On(()=>{if(k.current.panelDataArrayChanged){k.current.panelDataArrayChanged=!1;const{autoSaveId:y,onLayout:q,storage:X}=v.current,{layout:Y,panelDataArray:ie}=k.current;let D=null;if(y){const he=Vb(y,ie,X);he&&(O.current=new Map(Object.entries(he.expandToSizes)),D=he.layout)}D==null&&(D=Lb({panelDataArray:ie}));const ue=Fl({layout:D,panelConstraints:ie.map(he=>he.constraints)});Ml(Y,ue)||(b(ue),k.current.layout=ue,q&&q(ue),Jn(ie,ue,m.current))}}),On(()=>{const y=k.current;return()=>{y.layout=[]}},[]);const M=gt(y=>{let q=!1;const X=p.current;return X&&window.getComputedStyle(X,null).getPropertyValue("direction")==="rtl"&&(q=!0),function(ie){ie.preventDefault();const D=p.current;if(!D)return()=>null;const{direction:ue,dragState:he,id:ce,keyboardResizeBy:ee,onLayout:de}=v.current,{layout:fe,panelDataArray:Re}=k.current,{initialLayout:Oe}=he??{},We=Gf(ce,y,D);let E=Fb(ie,y,ue,he,ee,D);const R=ue==="horizontal";R&&q&&(E=-E);const Z=Re.map(K=>K.constraints),se=Br({delta:E,initialLayout:Oe??fe,panelConstraints:Z,pivotIndices:We,prevLayout:fe,trigger:Lf(ie)?"keyboard":"mouse-or-touch"}),z=!Ci(fe,se);(Bf(ie)||Zf(ie))&&C.current!=E&&(C.current=E,!z&&E!==0?R?Xs(y,E<0?Uf:Jf):Xs(y,E<0?Hf:Wf):Xs(y,0)),z&&(b(se),k.current.layout=se,de&&de(se),Jn(Re,se,m.current))}},[]),V=gt((y,q)=>{const{onLayout:X}=v.current,{layout:Y,panelDataArray:ie}=k.current,D=ie.map(fe=>fe.constraints),{panelSize:ue,pivotIndices:he}=jn(ie,y,Y);_e(ue!=null,`Panel size not found for panel "${y.id}"`);const ee=Kn(ie,y)===ie.length-1?ue-q:q-ue,de=Br({delta:ee,initialLayout:Y,panelConstraints:D,pivotIndices:he,prevLayout:Y,trigger:"imperative-api"});Ci(Y,de)||(b(de),k.current.layout=de,X&&X(de),Jn(ie,de,m.current))},[]),U=gt((y,q)=>{const{layout:X,panelDataArray:Y}=k.current,{collapsedSize:ie=0,collapsible:D}=q,{collapsedSize:ue=0,collapsible:he,maxSize:ce=100,minSize:ee=0}=y.constraints,{panelSize:de}=jn(Y,y,X);de!=null&&(D&&he&&sn(de,ie)?sn(ie,ue)||V(y,ue):de<ee?V(y,ee):de>ce&&V(y,ce))},[V]),J=gt((y,q)=>{const{direction:X}=v.current,{layout:Y}=k.current;if(!p.current)return;const ie=zs(y,p.current);_e(ie,`Drag handle element not found for id "${y}"`);const D=Kf(X,q);w({dragHandleId:y,dragHandleRect:ie.getBoundingClientRect(),initialCursorPosition:D,initialLayout:Y})},[]),ne=gt(()=>{w(null)},[]),S=gt(y=>{const{panelDataArray:q}=k.current,X=Kn(q,y);X>=0&&(q.splice(X,1),delete m.current[y.id],k.current.panelDataArrayChanged=!0,N())},[N]),oe=bb(()=>({collapsePanel:$,direction:r,dragState:g,expandPanel:H,getPanelSize:j,getPanelStyle:I,groupId:h,isPanelCollapsed:T,isPanelExpanded:P,reevaluatePanelConstraints:U,registerPanel:A,registerResizeHandle:M,resizePanel:V,startDragging:J,stopDragging:ne,unregisterPanel:S,panelGroupElement:p.current}),[$,g,r,H,j,I,h,T,P,U,A,M,V,J,ne,S]),B={display:"flex",flexDirection:r==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return xr(Ts.Provider,{value:oe},xr(f,{...d,children:t,className:n,id:s,ref:p,style:{...B,...c},"data-panel-group":"","data-panel-group-direction":r,"data-panel-group-id":h}))}const np=Df((e,t)=>xr(tp,{...e,forwardedRef:t}));tp.displayName="PanelGroup";np.displayName="forwardRef(PanelGroup)";function Kn(e,t){return e.findIndex(n=>n===t||n.id===t.id)}function jn(e,t,n){const r=Kn(e,t),s=r===e.length-1?[r-1,r]:[r,r+1],a=n[r];return{...t.constraints,panelSize:a,pivotIndices:s}}function Hb({disabled:e,handleId:t,resizeHandler:n,panelGroupElement:r}){zn(()=>{if(e||n==null||r==null)return;const i=zs(t,r);if(i==null)return;const s=a=>{if(!a.defaultPrevented)switch(a.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{a.preventDefault(),n(a);break}case"F6":{a.preventDefault();const o=i.getAttribute("data-panel-group-id");_e(o,`No group element found for id "${o}"`);const l=ai(o,r),c=qf(o,t,r);_e(c!==null,`No resize element found for id "${t}"`);const f=a.shiftKey?c>0?c-1:l.length-1:c+1<l.length?c+1:0;l[f].focus();break}}};return i.addEventListener("keydown",s),()=>{i.removeEventListener("keydown",s)}},[r,e,t,n])}function rp({children:e=null,className:t="",disabled:n=!1,hitAreaMargins:r,id:i,onBlur:s,onDragging:a,onFocus:o,style:l={},tabIndex:c=0,tagName:f="div",...d}){var h,p;const g=wt(null),w=wt({onDragging:a});zn(()=>{w.current.onDragging=a});const _=Rf(Ts);if(_===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:b,groupId:N,registerResizeHandle:m,startDragging:O,stopDragging:C,panelGroupElement:v}=_,k=_o(i),[$,H]=ar("inactive"),[j,I]=ar(!1),[T,P]=ar(null),A=wt({state:$});On(()=>{A.current.state=$}),zn(()=>{if(n)P(null);else{const J=m(k);P(()=>J)}},[n,k,m]);const M=(h=r==null?void 0:r.coarse)!==null&&h!==void 0?h:15,V=(p=r==null?void 0:r.fine)!==null&&p!==void 0?p:5;return zn(()=>{if(n||T==null)return;const J=g.current;return _e(J,"Element ref not attached"),zb(k,J,b,{coarse:M,fine:V},(S,oe,B)=>{if(oe)switch(S){case"down":{H("drag"),_e(B,'Expected event to be defined for "down" action'),O(k,B);const{onDragging:y}=w.current;y&&y(!0);break}case"move":{const{state:y}=A.current;y!=="drag"&&H("hover"),_e(B,'Expected event to be defined for "move" action'),T(B);break}case"up":{H("hover"),C();const{onDragging:y}=w.current;y&&y(!1);break}}else H("inactive")})},[M,b,n,V,m,k,T,O,C]),Hb({disabled:n,handleId:k,resizeHandler:T,panelGroupElement:v}),xr(f,{...d,children:e,className:t,id:i,onBlur:()=>{I(!1),s==null||s()},onFocus:()=>{I(!0),o==null||o()},ref:g,role:"separator",style:{...{touchAction:"none",userSelect:"none"},...l},tabIndex:c,"data-panel-group-direction":b,"data-panel-group-id":N,"data-resize-handle":"","data-resize-handle-active":$==="drag"?"pointer":j?"keyboard":void 0,"data-resize-handle-state":$,"data-panel-resize-handle-enabled":!n,"data-panel-resize-handle-id":k})}rp.displayName="PanelResizeHandle";const Wb=({className:e,...t})=>u.jsx(np,{className:G("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...t}),Qs=Ff,Bl=({withHandle:e,className:t,...n})=>u.jsx(rp,{className:G("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&&u.jsx("div",{className:"bg-border z-10 flex h-4 w-3 items-center justify-center rounded-sm border",children:u.jsx(Yg,{className:"h-2.5 w-2.5"})})}),ip=x.forwardRef(({className:e,...t},n)=>u.jsx("textarea",{className:G("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}));ip.displayName="Textarea";class qb{constructor(t){Vs(this,"client");this.client=gx.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 Gb=new qb;class Yb extends Error{constructor(n,r){super(n);Vs(this,"quality");this.name="QualityGateFailedError",this.quality=r}}function Kb(e,t){return e??t}function Xb(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 Qb(e){if(Xb(e.headers.get("content-type")))try{return await e.json()}catch{return}}function Zl(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 ev(){const e=x.useRef(null),t=Hi(s=>s.generationBackend),n=Ld(),r=x.useCallback(async(s,a,o,l,c)=>{e.current&&e.current.abort();const f=new AbortController;e.current=f;const d=Kb(c==null?void 0:c.renderer,t);try{l==null||l("parsing","Validating JSON structure...");let h;try{h=JSON.parse(a)}catch(H){throw new Error(`Invalid JSON: ${H instanceof Error?H.message:"Unknown parse error"}`)}l==null||l("building",`Building ${ji.toLowerCase()} structure...`);const p={jsonDefinition:h,options:{...c,sourceName:n(s),...d?{renderer:d}:{}}};p.customThemes=o??{},l==null||l("rendering",`Generating ${ht.toUpperCase()} content...`);const g={"Content-Type":"application/json"};c!=null&&c.bypassCache&&(g["X-Bypass-Cache"]="true");const w=await fetch(ei.generate,{method:"POST",headers:g,body:JSON.stringify(p),signal:f.signal}),_=await Qb(w);if(w.status===400&&(_==null?void 0:_.code)==="QUALITY_GATE_FAILED")throw new Yb(Zl(w,_),_.quality);if(!w.ok||!(_!=null&&_.success))throw new Error(Zl(w,_));const{data:b,cache:N,warnings:m}=_,O=N.status==="HIT"?"HIT":N.status==="MISS"?"MISS":"UNKNOWN",C=O==="HIT"?`Served from cache (Hit rate: ${N.hitRate})`:`Generated fresh ${ji.toLowerCase()}`;l==null||l("finalizing",C);const v=globalThis.atob(b.document),k=new Uint8Array(v.length);for(let H=0;H<v.length;H++)k[H]=v.charCodeAt(H);const $=new Blob([k],{type:b.contentType});if($.size===0)throw new Error(`Received empty ${ji.toLowerCase()} from API`);return{name:s,text:a,blob:$,...d?{renderer:d}:{},filename:b.filename,fileId:b.fileId,cacheStatus:O,cacheHitRate:N.hitRate,warnings:m}}catch(h){throw h instanceof Error&&h.name==="AbortError"?new Error(`${ji} generation was cancelled`):h}finally{e.current===f&&(e.current=null)}},[t,n]),i=x.useCallback(()=>{e.current&&(e.current.abort(),e.current=null)},[]);return{generatePresentation:r,generateDocument:r,cancelGeneration:i}}const Bi={ids:[],default:null};let Vl;function tv(){return Vl??(Vl=(async()=>{var e;try{const t=await fetch(ei.renderers);if(!t.ok)return Bi;const n=await t.json();return!(n!=null&&n.success)||!Array.isArray((e=n.data)==null?void 0:e.ids)?Bi:n.data}catch{return Bi}})()),Vl}function nv(){const[e,t]=x.useState(Bi);return x.useEffect(()=>{let n=!1;return tv().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 a of i){let o=a.message;if(a.context&&Object.keys(a.context).length>0){const l=Object.entries(a.context).map(([c,f])=>`${c}: ${JSON.stringify(f)}`).join(", ");o+=` (${l})`}s.push(o)}t.push({name:"list",props:{items:s,spacing:{after:120}}})}return{name:"docx",props:{metadata:{title:"Generation Warnings"},theme:"minimal"},children:t}}function iv({open:e,onClose:t,nonSafeFonts:n,onChoose:r}){const[i,s]=je.useState("custom");je.useEffect(()=>{e&&s("custom")},[e]);const a=n.length===1?n[0]:n.slice(0,3).join(", ")+(n.length>3?` +${n.length-3} more`:""),o=[{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 u.jsx(Ct,{open:e,onOpenChange:l=>!l&&t(),children:u.jsxs(kt,{className:"max-w-md",children:[u.jsxs(Vt,{children:[u.jsx(Ut,{children:"Non-safe fonts in this document"}),u.jsxs(on,{children:[a," ",n.length===1?"is":"are"," not in the built-in safe list. Choose how to export."]})]}),u.jsx("div",{className:"grid gap-2 py-2",children:o.map(l=>{const c=i===l.value;return u.jsxs("button",{type:"button",onClick:()=>s(l.value),className:`text-left rounded-md border px-3 py-2 transition-colors ${c?"border-primary bg-primary/5":"border-border hover:bg-muted/40"}`,children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("span",{className:`h-3.5 w-3.5 rounded-full border flex items-center justify-center ${c?"border-primary":"border-muted-foreground/50"}`,children:c&&u.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-primary"})}),u.jsx("span",{className:"text-sm font-medium",children:l.title})]}),u.jsx("p",{className:"mt-1 text-xs text-muted-foreground pl-6",children:l.desc})]},l.value)})}),u.jsxs(bn,{children:[u.jsx(Se,{variant:"outline",size:"sm",onClick:t,children:"Cancel"}),u.jsx(Se,{size:"sm",onClick:()=>{r(i),t()},children:"Download"})]})]})})}function ea(){return u.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 Ul(){return u.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 sv({name:e,blob:t,onManualRender:n,isGenerating:r,isRendering:i,onShowCacheMetrics:s,onShowSchemas:a,onShowFonts:o,documentText:l,editorDocumentText:c,editorDocumentName:f,warnings:d,onToggleChat:h,chatOpen:p,onTogglePreview:g,previewOpen:w}){const[_,b]=x.useState(!1),[N,m]=x.useState(!1),[O,C]=x.useState(!1),[v,k]=x.useState(!1),[$,H]=x.useState(!1),[j,I]=x.useState(null),{toast:T}=Sr(),P=Ld(),{generateDocument:A}=ev(),M=x.useContext(Fd),V=nv(),U=Hi(ee=>ee.generationBackend),J=Hi(ee=>ee.setSettings),ne=U??V.default??void 0,S=x.useCallback(()=>{const ee={},{customThemes:de}=M.getState();return Object.values(de).forEach(fe=>{fe.valid&&fe.parsed&&(ee[fe.name]=fe.parsed)}),ee},[M]),oe=je.useMemo(()=>{if(!l)return[];try{const ee=JSON.parse(l);return[...(ht==="pptx"?_g:jg)(ee)].filter(fe=>!Ng(fe))}catch{return[]}},[l]),[B,y]=x.useState(!1),q=x.useCallback(async()=>{if(t){b(!0);try{await new Promise(ee=>setTimeout(ee,100)),Li(`${e}${Tr}`,t)}finally{setTimeout(()=>b(!1),500)}}},[t,e]),X=x.useCallback(async()=>{if(t){if(oe.length===0){await q();return}y(!0)}},[t,oe.length,q]),Y=x.useCallback(async ee=>{var de;if(l){b(!0);try{const fe=await A(e,l,S(),void 0,{bypassCache:!0,fonts:{mode:ee}});if(fe.blob.size===0)T({title:"Export failed",description:"The server returned an empty document.",variant:"destructive"});else{Li(`${e}${Tr}`,fe.blob);const Re=(de=fe.warnings)==null?void 0:de.find(Oe=>{var We,E;return((We=Oe.context)==null?void 0:We.code)==="FONT_MODE_SUBSTITUTED"||((E=Oe.context)==null?void 0:E.code)==="FONT_MODE_CUSTOM"});Re&&T({title:ee==="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(()=>b(!1),500)}}},[l,e,A,T,S]),ie=x.useCallback(async()=>{if(!(!d||d.length===0)){m(!0);try{const ee=rv(d);if(!ee){T({title:"No warnings",description:"There are no warnings to download.",variant:"destructive"});return}const de=await A("warnings",JSON.stringify(ee,null,2),{});de&&typeof de=="object"&&"blob"in de&&de.blob&&(Li(`${e}-warnings${Tr}`,de.blob),T({title:"Warnings downloaded",description:`Downloaded warnings document with ${d.length} warning(s).`}))}catch(ee){console.error("Failed to generate warnings document:",ee),T({title:"Download failed",description:ee instanceof Error?ee.message:"Failed to generate warnings document",variant:"destructive"})}finally{setTimeout(()=>m(!1),500)}}},[d,e,A,T]),D=x.useCallback(async()=>{C(!0);try{await Gb.delete(`/${ht}/cache`),window.dispatchEvent(new CustomEvent("cache:cleared")),T({title:"Cache Cleared",description:"All active caches have been successfully cleared.",variant:"default"})}catch(ee){console.error("Failed to clear cache:",ee),T({title:"Cache Clear Failed",description:"Failed to clear caches. Please try again.",variant:"destructive"})}finally{C(!1)}},[T]),ue=c??l,he=x.useCallback(()=>{var fe,Re;if(!ue){T({title:"No document available",description:"Please select a document to copy standard components",variant:"destructive"});return}try{JSON.parse(ue)}catch{T({title:"Document is not valid JSON",description:"Fix the JSON errors in the editor, then copy again",variant:"destructive"});return}H(!0);const ee=(async()=>{const Oe=await fetch(`/api/${ht}/standard-components`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonDefinition:ue,customThemes:S(),options:{sourceName:P(f??e)}})});if(!Oe.ok){let E=`Request failed with status ${Oe.status}`;try{const R=await Oe.json(),Z=R.error??R.message;typeof Z=="string"&&Z&&(E=Z)}catch{}throw new Error(E)}const We=await Oe.json();return JSON.stringify(We.data,null,2)})();let de;typeof ClipboardItem<"u"&&((fe=navigator.clipboard)!=null&&fe.write)?de=navigator.clipboard.write([new ClipboardItem({"text/plain":ee.then(Oe=>new Blob([Oe],{type:"text/plain"}))})]):(Re=navigator.clipboard)!=null&&Re.writeText?de=ee.then(Oe=>navigator.clipboard.writeText(Oe)):de=Promise.reject(new Error("Clipboard is not available in this context")),(async()=>{try{await de,T({title:"Copied to clipboard",description:"Standard components JSON has been copied"})}catch(Oe){let We=null;try{We=await ee}catch(E){console.error("Error fetching standard components:",E),T({title:"Failed to get standard components",description:E instanceof Error?E.message:"Request failed",variant:"destructive"});return}console.error("Clipboard write failed:",Oe),I(We)}finally{H(!1)}})()},[ue,e,f,P,S,T]),ce=x.useCallback(async()=>{if(j!=null)try{await navigator.clipboard.writeText(j),T({title:"Copied to clipboard",description:"Standard components JSON has been copied"}),I(null)}catch{T({title:"Clipboard unavailable",description:"Select the JSON in the dialog and copy it manually",variant:"destructive"})}},[j,T]);return u.jsxs(u.Fragment,{children:[u.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:[u.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[u.jsx("p",{className:"text-foreground text-sm font-semibold tracking-tight truncate flex-1 min-w-0",children:e}),u.jsxs(Ye,{children:[u.jsx(Ke,{asChild:!0,children:u.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:u.jsx(Od,{className:"h-3.5 w-3.5 text-muted-foreground"})})}),u.jsx(Xe,{className:"max-w-sm",children:u.jsxs("p",{className:"text-sm",children:["Preview converts the file to a PDF with LibreOffice. Download the ",Tr," to verify fidelity."]})})]})]}),u.jsxs("div",{className:"flex flex-row items-center gap-x-1 shrink-0",children:[u.jsxs(Ye,{children:[u.jsx(Ke,{asChild:!0,children:u.jsxs(Se,{variant:"default",size:"sm",className:"gap-1.5 h-7 px-2.5",onClick:n,"aria-label":"Render preview",disabled:r||i||w===!1,children:[i?u.jsx(gn,{size:"sm"}):u.jsx(Kg,{className:"h-3.5 w-3.5"}),u.jsx("span",{className:"text-xs font-medium hidden sm:inline",children:"Run"})]})}),u.jsx(Xe,{children:u.jsx("p",{children:w===!1?"Open preview to run":i?"Rendering preview...":"Render preview"})})]}),u.jsx("div",{className:"w-px h-4 bg-border/60 mx-1"}),u.jsxs(Ye,{children:[u.jsx(Ke,{asChild:!0,children:u.jsxs(Se,{variant:"outline",size:"sm",className:"gap-1.5 h-7 px-2.5",disabled:!t||_||r,onClick:X,children:[_?u.jsx(gn,{size:"sm"}):u.jsx(Xg,{className:"h-3.5 w-3.5"}),u.jsx("span",{className:"text-xs font-medium hidden sm:inline",children:"Download"})]})}),u.jsx(Xe,{children:u.jsxs("p",{children:["Download ",Tr]})})]}),d&&d.length>0&&u.jsxs(Ye,{children:[u.jsx(Ke,{asChild:!0,children:u.jsx(Se,{variant:"outline",size:"icon",className:"h-7 w-7 border-transparent bg-warning/10 text-warning hover:bg-warning/20",disabled:N||r,onClick:ie,children:N?u.jsx(gn,{size:"sm"}):u.jsx(Dd,{className:"h-3.5 w-3.5"})})}),u.jsx(Xe,{children:u.jsxs("p",{children:["Download warnings (",d.length,")"]})})]}),V.ids.length>1&&u.jsxs(ti,{value:ne,onValueChange:ee=>J({generationBackend:ee}),children:[u.jsxs(Ye,{children:[u.jsx(Ke,{asChild:!0,children:u.jsxs(fr,{"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:[u.jsx(Na,{className:"h-3.5 w-3.5 shrink-0 opacity-60"}),u.jsxs(ni,{placeholder:"Renderer",children:[u.jsx("span",{className:"font-medium",children:ne}),ne!==V.default&&u.jsx(ea,{})]})]})}),u.jsx(Xe,{children:u.jsxs("p",{children:["Renderer that writes the ",ht.toUpperCase()," file. A non-default one may refuse a document it cannot express."]})})]}),u.jsx(pr,{className:"min-w-[var(--radix-select-trigger-width)] text-sidebar-foreground",children:u.jsxs(Zd,{children:[u.jsx(ho,{className:"px-2 py-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Renderer"}),V.ids.map(ee=>u.jsx(Pn,{value:ee,className:"text-xs",children:u.jsxs("span",{className:"flex items-center gap-1.5 whitespace-nowrap",children:[u.jsx("span",{className:"font-medium",children:ee}),ee===V.default?u.jsx(Ul,{}):u.jsx(ea,{})]})},ee))]})})]}),u.jsx("div",{className:"w-px h-4 bg-border/60 mx-1"}),u.jsxs(Ns,{children:[u.jsxs(Ye,{children:[u.jsx(Ke,{asChild:!0,children:u.jsx(Es,{asChild:!0,children:u.jsx(Se,{variant:"ghost",size:"icon",className:"h-7 w-7",children:u.jsx(Ad,{className:"h-3.5 w-3.5"})})})}),u.jsx(Xe,{children:u.jsx("p",{children:"More actions"})})]}),u.jsxs(yi,{align:"end",className:"w-52",children:[a&&u.jsxs($t,{onClick:a,children:[u.jsx(Qg,{className:"h-4 w-4 mr-2"}),"View JSON Schemas"]}),o&&u.jsxs($t,{onClick:o,children:[u.jsx(ja,{className:"h-4 w-4 mr-2"}),"Browse fonts"]}),s&&u.jsxs($t,{onClick:s,children:[u.jsx(Ea,{className:"h-4 w-4 mr-2"}),"View cache metrics"]}),ue?u.jsxs($t,{onClick:he,disabled:$,children:[u.jsx(Ca,{className:"h-4 w-4 mr-2"}),$?"Copying...":"Copy standard components"]}):u.jsxs(Ye,{children:[u.jsx(Ke,{asChild:!0,children:u.jsx("span",{className:"block",children:u.jsxs($t,{disabled:!0,children:[u.jsx(Ca,{className:"h-4 w-4 mr-2"}),"Copy standard components"]})})}),u.jsx(Xe,{side:"left",children:u.jsx("p",{children:"No document selected — open or select a document first"})})]}),u.jsx(mr,{}),u.jsxs($t,{onClick:()=>k(!0),disabled:O,className:"text-destructive focus:text-destructive",children:[u.jsx(fo,{className:"h-4 w-4 mr-2"}),O?"Clearing...":"Clear all caches"]}),V.ids.length>1&&u.jsxs(u.Fragment,{children:[u.jsx(mr,{className:"lg:hidden"}),u.jsx(ko,{className:"lg:hidden px-2 py-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Renderer"}),V.ids.map(ee=>u.jsxs($t,{className:"lg:hidden gap-1.5",onClick:()=>J({generationBackend:ee}),children:[u.jsx(an,{className:`h-3.5 w-3.5 shrink-0 ${ne===ee?"opacity-100":"opacity-0"}`}),u.jsx("span",{className:"font-medium",children:ee}),ee===V.default?u.jsx(Ul,{}):u.jsx(ea,{})]},ee))]})]})]}),g&&u.jsxs(Ye,{children:[u.jsx(Ke,{asChild:!0,children:u.jsx(Se,{variant:w?"default":"ghost",size:"icon",className:"h-7 w-7",onClick:g,children:w?u.jsx(Rd,{className:"h-3.5 w-3.5"}):u.jsx(ex,{className:"h-3.5 w-3.5"})})}),u.jsx(Xe,{children:u.jsxs("span",{className:"flex items-center gap-1.5",children:[w?"Hide":"Show"," Preview"," ",u.jsx(ii,{shortcut:"mod+shift+p"})]})})]}),h&&u.jsxs(Ye,{children:[u.jsx(Ke,{asChild:!0,children:u.jsx(Se,{variant:p?"default":"ghost",size:"icon",className:"h-7 w-7",onClick:h,children:u.jsx(Md,{className:"h-3.5 w-3.5"})})}),u.jsx(Xe,{children:u.jsxs("span",{className:"flex items-center gap-1.5",children:[p?"Close":"Open"," AI Chat"," ",u.jsx(ii,{shortcut:"mod+shift+j"})]})})]})]})]}),u.jsx(iv,{open:B,onClose:()=>y(!1),nonSafeFonts:oe,onChoose:Y}),u.jsx(Ct,{open:j!=null,onOpenChange:ee=>{ee||I(null)},children:u.jsxs(kt,{className:"max-w-lg",children:[u.jsxs(Vt,{children:[u.jsx(Ut,{children:"Standard components"}),u.jsx(on,{children:"The browser blocked the automatic clipboard write. Copy the JSON from here instead."})]}),u.jsx(ip,{readOnly:!0,value:j??"",className:"h-64 font-mono text-xs",onFocus:ee=>ee.currentTarget.select()}),u.jsxs(bn,{children:[u.jsx(Se,{variant:"outline",size:"sm",onClick:()=>I(null),children:"Close"}),u.jsx(Se,{size:"sm",onClick:ce,children:"Copy to clipboard"})]})]})}),u.jsx(Ct,{open:v,onOpenChange:k,children:u.jsxs(kt,{className:"max-w-sm",children:[u.jsxs(Vt,{children:[u.jsx(Ut,{children:"Clear all caches?"}),u.jsx(on,{children:"This will clear the document, component, and rasterized-visual caches. Next generation will be uncached."})]}),u.jsxs(bn,{children:[u.jsx(Se,{variant:"outline",size:"sm",onClick:()=>k(!1),children:"Cancel"}),u.jsx(Se,{variant:"destructive",size:"sm",disabled:O,onClick:async()=>{await D(),k(!1)},children:O?u.jsx(gn,{size:"sm"}):"Clear"})]})]})})]})}const av=je.memo(sv),sp=bg,Co=x.forwardRef(({className:e,...t},n)=>u.jsx(kd,{ref:n,className:G("bg-muted text-muted-foreground inline-flex h-9 items-center justify-center rounded-sm p-1",e),...t}));Co.displayName=kd.displayName;const lr=x.forwardRef(({className:e,...t},n)=>u.jsx(Sd,{ref:n,className:G("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}));lr.displayName=Sd.displayName;const ur=x.forwardRef(({className:e,...t},n)=>u.jsx(_d,{ref:n,className:G("ring-offset-background focus-visible:ring-ring mt-2 focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none",e),...t}));ur.displayName=_d.displayName;async function ov(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 lv(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 uv(e){const t=lv(e);return ov(t)}const cv=({open:e,onOpenChange:t,defaultTab:n="document"})=>{const[r,i]=x.useState(n),[s,a]=x.useState(null),[o,l]=x.useState(null),[c,f]=x.useState(!1),[d,h]=x.useState(!1),[p,g]=x.useState(null),[w,_]=x.useState(null),[b,N]=x.useState(!1),{toast:m}=Sr(),O=Lt(P=>P.selectedPlugins),C=Array.from(O);x.useEffect(()=>{n&&i(n)},[n]);const v=x.useCallback(async()=>{f(!0),g(null);try{const P=await Us.fetchDocumentSchema(C);a(P)}catch(P){const A=P instanceof Error?P.message:"Failed to load document schema";g(A),m({variant:"destructive",title:"Error loading schema",description:A})}finally{f(!1)}},[C,m]),k=x.useCallback(async()=>{if(!o){h(!0),_(null);try{const P=await Us.fetchThemeSchema();l(P)}catch(P){const A=P instanceof Error?P.message:"Failed to load theme schema";_(A),m({variant:"destructive",title:"Error loading schema",description:A})}finally{h(!1)}}},[o,m]),[$,H]=x.useState([]);x.useEffect(()=>{e||(a(null),g(null))},[e]),x.useEffect(()=>{if(!e)return;const P=C.length!==$.length||C.some((A,M)=>A!==$[M]);r==="document"?(!s||P)&&(P&&(Us.clearPluginSchemaCache(),H([...C])),c||v()):r==="theme"&&!o&&!d&&k()},[r,e,s,o,c,d,C,$,v,k]);const j=C.length,I=r==="document"?s:o,T=async()=>{if(I)try{await uv(I)&&(N(!0),m({title:"Schema copied",description:"The JSON schema has been copied to your clipboard"}),setTimeout(()=>N(!1),2e3))}catch(P){console.error("Copy failed:",P)}};return u.jsx(Ct,{open:e,onOpenChange:t,children:u.jsxs(kt,{className:"max-w-4xl max-h-[90vh] overflow-hidden flex flex-col",children:[u.jsx(Vt,{children:u.jsx(Ut,{children:"Schema Viewer"})}),u.jsxs(sp,{value:r,onValueChange:P=>i(P),className:"flex-1 overflow-hidden flex flex-col",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs(Co,{children:[u.jsxs(lr,{value:"document",className:"flex items-center gap-1",children:["Document",j>0&&u.jsxs(Kt,{variant:"secondary",className:"ml-1 text-xs px-1 py-0",children:["+",j]})]}),u.jsx(lr,{value:"theme",children:"Theme"})]}),u.jsx("div",{className:"ml-auto",children:u.jsx(Se,{variant:"ghost",size:"icon",onClick:T,disabled:b||!I,"aria-label":"Copy schema",children:b?u.jsx(an,{className:"h-4 w-4"}):u.jsx(ks,{className:"h-4 w-4"})})})]}),u.jsxs("div",{className:"flex-1 overflow-auto mt-4",children:[u.jsx(ur,{value:"document",className:"h-full",children:u.jsx(ts,{schema:s,loading:c,error:p||void 0})}),u.jsx(ur,{value:"theme",className:"h-full",children:u.jsx(ts,{schema:o,loading:d,error:w||void 0})})]})]})]})})};function To(e,t){var r;const n=$d.getState().getEditor(e);return(r=n==null?void 0:n.flushPendingSave)==null||r.call(n),n?n.toStorageValue(n.editor.getValue()):t}function ap(e,t,n){if(t.length===0)return n;const r=Jl(e,t[0]);let i=r;for(let s=0;s<t.length-1;s++){const a=t[s],o=t[s+1],l=i[a],c=Jl(l,o);i[a]=c,i=c}return i[t[t.length-1]]=n,r}function Jl(e,t){return typeof t=="number"?Array.isArray(e)?[...e]:[]:e&&typeof e=="object"&&!Array.isArray(e)?{...e}:{}}const Hl=2*1024*1024,Wl=12*1024*1024;function dv(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 fv(e){let n="";for(let r=0;r<e.length;r+=32768)n+=String.fromCharCode(...e.subarray(r,r+32768));return btoa(n)}function is(e){return e>=1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:`${Math.round(e/1024)} KB`}function pv(e,t){if(t.length===0)return{ok:!1,message:`"${e}" is empty.`};if(t.length>Hl)return{ok:!1,message:`"${e}" is ${is(t.length)}. The limit is ${is(Hl)} per font, because the bytes travel inside the document JSON.`};const n=dv(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:fv(t)}}const hv=new Set(["italic","oblique"]);function mv(e){const t=e.replace(/\.[^.]+$/,""),n=t.split(/[-_\s]+/).filter(Boolean),r=new Map;for(const[a,o]of Object.entries(Ed))r.set(o.toLowerCase(),Number(a));let i=400,s=!1;for(;n.length>1;){const a=n[n.length-1].toLowerCase();if(hv.has(a)){s=!0,n.pop();continue}const o=r.get(a);if(o!==void 0){i=o,n.pop();continue}break}return{family:n.join(" ")||t,weight:i,italic:s}}function gv(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 xv(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 yv(e,t,n,r){const i=((e==null?void 0:e.sources)??[]).filter(o=>{const l=xv(o);return l?!n.some(c=>c.weight===l.weight&&c.italic===l.italic):!0}),s=n.map(o=>({kind:"data",data:o.data,weight:o.weight,italic:o.italic})),a=r??(e==null?void 0:e.category);return{id:(e==null?void 0:e.id)??t,family:t,...a?{category:a}:{},sources:[...i,...s]}}function bv(e,t){let n=Array.isArray(e)?[...e]:[];for(const r of t){const i=r.sources.filter(a=>a.kind==="data").map(a=>({data:a.data,weight:a.weight??400,italic:a.italic??!1}));if(i.length===0)continue;const s=n.find(a=>{var o;return((o=a==null?void 0:a.family)==null?void 0:o.toLowerCase())===r.family.toLowerCase()});n=gv(n,yv(s,r.family,i,r.category))}return n}function vv(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 wv(e){const t=new TextEncoder().encode(e).length;return t<=Wl?null:`Adding this font would push the document to ${is(t)}, past the ${is(Wl)} limit. Remove a font from props.fontRegistry, or use fewer weights.`}const ql=new Set,kv=(e,t,n)=>`${e.toLowerCase()}|${t}|${n?"i":"r"}`;function Sv(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 _v(e,t,n,r){const i=kv(e,n,r);if(!ql.has(i))try{if(typeof FontFace>"u"||!(document!=null&&document.fonts))return;const s=Sv(t),a=new FontFace(e,s.buffer,{weight:String(n),style:r?"italic":"normal"});await a.load(),document.fonts.add(a),ql.add(i)}catch{}}const jv={safe:[],google:[]};function Gl(e,t){var f;const n=`gf-${e.replace(/\s+/g,"-")}`,r=document.getElementById(n),i=new Set(t&&t.length>0?t:[400,700]),s=new Set(((f=r==null?void 0:r.dataset.weights)==null?void 0:f.split(",").map(Number).filter(d=>!Number.isNaN(d)))??[]),a=new Set([...s,...i]);if(r&&a.size===s.size)return;const o=[...a].sort((d,h)=>d-h).join(";"),l=`https://fonts.googleapis.com/css2?family=${encodeURIComponent(e)}:wght@${o}&display=swap`,c=r??document.createElement("link");r||(c.id=n,c.rel="stylesheet",document.head.appendChild(c)),c.href=l,c.dataset.weights=[...a].sort((d,h)=>d-h).join(",")}function Nv(){const e=Ne(i=>i.activeTab),t=Ne(i=>i.documents),n=Ne(i=>i.documentTypes),r=Ne(i=>i.saveDocument);return x.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(c=>c.name===e);if(!s)return{ok:!1,error:"Active theme not found"};const a=To(e,s.text);let o;try{o=JSON.parse(a)}catch(c){return{ok:!1,error:`Active theme is not valid JSON: ${c.message}`}}const l=i(o);return r(e,JSON.stringify(l,null,2)),{ok:!0,name:e}},[e,t,n,r])}function Ev(){const e=Ne(r=>r.activeTab),t=Ne(r=>r.documents),n=Ne(r=>r.saveDocument);return x.useCallback((r,i)=>{if(!e)return{ok:!1,error:"No active file"};const s=t.find(c=>c.name===e);if(!s)return{ok:!1,error:"Active document not found"};const a=To(e,s.text);let o;try{o=JSON.parse(a)}catch(c){return{ok:!1,error:`Active document is not valid JSON: ${c.message}`}}const l=ap(o,r,i);return n(e,JSON.stringify(l,null,2)),{ok:!0,name:e}},[e,t,n])}function Cv(){const e=Ne(i=>i.activeTab),t=Ne(i=>i.documents),n=Ne(i=>i.documentTypes),r=Ne(i=>i.saveDocument);return x.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 a=To(e,s.text);let o;try{o=JSON.parse(a)}catch(p){return{ok:!1,error:`Active document is not valid JSON: ${p.message}`}}const l=bv((h=o==null?void 0:o.props)==null?void 0:h.fontRegistry,i),c=ap(o,["props","fontRegistry"],l),f=JSON.stringify(c,null,2),d=wv(f);return d?{ok:!1,error:d}:(r(e,f),{ok:!0,name:e})},[e,t,n,r])}function Tv(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 Yl(e){return e.map((t,n)=>typeof t=="number"?`[${t}]`:n===0?t:`.${t}`).join("")}const Iv=({open:e,onOpenChange:t})=>{const n=$i(D=>D.open),r=$i(D=>D.contextual),i=$i(D=>D.close),s=e??n,a=r,o=x.useCallback(D=>{t&&t(D),D||i()},[t,i]),[l,c]=x.useState(jv),[f,d]=x.useState(!1),[h,p]=x.useState(""),[g,w]=x.useState("safe"),[_,b]=x.useState(null),[N,m]=x.useState(null),[O,C]=x.useState(!1),[v,k]=x.useState(!1),[$,H]=x.useState(""),[j,I]=x.useState([]),T=x.useRef(null),{toast:P}=Sr(),A=Nv(),M=Ev(),V=Cv(),U=Ne(D=>D.activeTab),J=Ne(D=>D.documentTypes),ne=U&&J[U]==="application/json+theme",S=!!a||ne;x.useEffect(()=>{s&&(l.safe.length>0||l.google.length>0||(d(!0),fetch(ei.fonts.catalog).then(D=>D.json()).then(D=>c(D)).catch(D=>{P({variant:"destructive",title:"Font catalog unavailable",description:D.message})}).finally(()=>d(!1))))},[s,l,P]),x.useEffect(()=>{if(!(g!=="google"||l.google.length===0))for(const D of l.google)Gl(D.family,D.weights)},[g,l]);const oe=x.useMemo(()=>l.safe.filter(D=>D.toLowerCase().includes(h.toLowerCase())),[l.safe,h]),B=x.useMemo(()=>l.google.filter(D=>D.family.toLowerCase().includes(h.toLowerCase())),[l.google,h]),y=x.useCallback(async D=>{try{await navigator.clipboard.writeText(D),m(D),setTimeout(()=>m(null),1500)}catch{P({variant:"destructive",title:"Copy failed",description:"Your browser blocked clipboard write."})}},[P]),q=x.useCallback(async(D,ue,he)=>{b(D);try{const ce=A(ee=>(Tv(ee,he,D),ee));if(!ce.ok){P({variant:"destructive",title:"Could not insert font",description:ce.error});return}P({title:"Font inserted",description:`${D} set as ${he} font in "${ce.name}".`})}finally{b(null)}},[A,P]),X=x.useCallback(async D=>{if(a){b(D);try{const ue=M(a.jsonPath,D);if(!ue.ok){P({variant:"destructive",title:"Could not insert font",description:ue.error});return}P({title:"Font inserted",description:`${D} set at ${Yl(a.jsonPath)}.`}),o(!1)}finally{b(null)}}},[a,M,P,o]),Y=x.useCallback(async D=>{if(!(!D||D.length===0)){C(!0);try{const ue=[];for(const ce of Array.from(D)){const ee=new Uint8Array(await ce.arrayBuffer()),de=pv(ce.name,ee);if(!de.ok){P({variant:"destructive",title:"Font rejected",description:de.message});continue}ue.push({identity:mv(ce.name),base64:de.base64})}if(ue.length===0)return;const he=V(ue.map(({identity:ce,base64:ee})=>({id:ce.family,family:ce.family,sources:[{kind:"data",data:ee,weight:ce.weight,italic:ce.italic}]})));if(!he.ok){P({variant:"destructive",title:"Could not register font",description:he.error});return}for(const{identity:ce,base64:ee}of ue)_v(ce.family,ee,ce.weight,ce.italic),P({title:`Added ${ce.family}`,description:`Registered at weight ${ce.weight}${ce.italic?" italic":""} in props.fontRegistry. Reference it as "${ce.family}".`})}catch(ue){P({variant:"destructive",title:"Upload failed",description:ue.message})}finally{C(!1),T.current&&(T.current.value="")}}},[V,P]),ie=x.useCallback(async()=>{var ue,he;const D=$.trim();if(D){k(!0),I([]);try{const ce=await fetch(ei.fonts.materialize,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({family:D,weights:[400,700],italics:!1})});if(ce.status===429)throw new Error("Too many font fetches — the playground allows 20 every 15 minutes. Try again shortly.");if(!ce.ok){const Oe=await ce.json().catch(()=>({}));throw new Error(Oe.error??`Materialize failed (${ce.status})`)}const ee=await ce.json();I(ee.warnings??[]);const de=(ue=l.google.find(Oe=>Oe.family.toLowerCase()===ee.family.toLowerCase()))==null?void 0:ue.category,fe=vv(ee,de);if(!fe){P({variant:"destructive",title:"Nothing to embed",description:((he=ee.warnings)==null?void 0:he.join(" · "))||`Google Fonts has no family named "${D}".`});return}const Re=V([fe]);if(!Re.ok){P({variant:"destructive",title:"Could not register font",description:Re.error});return}Gl(ee.family,[400,700]),P({title:`Added ${ee.family}`,description:`Embedded ${fe.sources.length} weight(s) in props.fontRegistry.`})}catch(ce){P({variant:"destructive",title:"Google Fonts fetch failed",description:ce.message})}finally{k(!1)}}},[$,l.google,V,P]);return u.jsx(Ct,{open:s,onOpenChange:o,children:u.jsxs(kt,{className:"max-w-4xl max-h-[90vh] overflow-hidden flex flex-col",children:[u.jsx(Vt,{children:u.jsx(Ut,{children:a?`Font for ${Yl(a.jsonPath)}`:"Fonts"})}),!a&&!ne&&g!=="custom"&&u.jsx(ir,{children:u.jsxs(sr,{children:["Fonts are registered on themes. Open a ",u.jsx("code",{children:".theme.json"})," ","file to apply a font — the buttons below are disabled until you do."]})}),u.jsxs(sp,{value:g,onValueChange:D=>w(D),className:"flex-1 overflow-hidden flex flex-col",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs(Co,{children:[u.jsxs(lr,{value:"safe",children:["Safe",u.jsx(Kt,{variant:"secondary",className:"ml-1 text-xs px-1 py-0",children:l.safe.length})]}),u.jsxs(lr,{value:"google",children:["Google",u.jsx(Kt,{variant:"secondary",className:"ml-1 text-xs px-1 py-0",children:l.google.length})]}),u.jsx(lr,{value:"custom",children:"Custom"})]}),u.jsx(hr,{type:"search",placeholder:"Search fonts...",value:h,onChange:D=>p(D.target.value),className:"ml-auto max-w-xs"})]}),u.jsxs("div",{className:"flex-1 overflow-auto mt-4 pr-2",children:[u.jsx(ur,{value:"safe",className:"m-0",children:f&&oe.length===0?u.jsxs("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:[u.jsx(Fr,{className:"animate-spin mr-2"})," Loading catalog..."]}):u.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:oe.map(D=>u.jsx(Kl,{family:D,meta:u.jsx("span",{className:"text-xs",children:"Installed with Office"}),previewStyle:{fontFamily:`"${D}", sans-serif`},onCopy:()=>y(D),copied:N===D,contextual:!!a,onUseThis:()=>X(D),onInsertHeading:()=>q(D,"safe","heading"),onInsertBody:()=>q(D,"safe","body"),applying:_===D,disabled:!S},D))})}),u.jsx(ur,{value:"google",className:"m-0",children:f&&B.length===0?u.jsxs("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:[u.jsx(Fr,{className:"animate-spin mr-2"})," Loading catalog..."]}):u.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:B.map(D=>u.jsx(Kl,{family:D.family,meta:u.jsxs("span",{className:"text-xs",children:[D.category," · ",D.weights.length," weights"]}),previewStyle:{fontFamily:`"${D.family}", sans-serif`},onCopy:()=>y(D.family),copied:N===D.family,contextual:!!a,onUseThis:()=>X(D.family),onInsertHeading:()=>q(D.family,"google","heading"),onInsertBody:()=>q(D.family,"google","body"),applying:_===D.family,disabled:!S,extraAction:u.jsx(zv,{family:D.family,weights:D.weights,hasItalic:D.hasItalic})},D.family))})}),u.jsx(ur,{value:"custom",className:"m-0 flex flex-col gap-6",children:ne?u.jsx(ir,{children:u.jsxs(sr,{children:["Custom fonts are stored on the document (",u.jsx("code",{children:"props.fontRegistry"}),"), because the bytes travel with the JSON. Open a document tab to add one."]})}):u.jsxs(u.Fragment,{children:[u.jsxs("section",{className:"flex flex-col gap-2",children:[u.jsx("h3",{className:"text-sm font-medium",children:"Upload a font file"}),u.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."," ",u.jsx("code",{children:"Geist-SemiBold.ttf"}),")."]}),u.jsxs("div",{onDragOver:D=>D.preventDefault(),onDrop:D=>{D.preventDefault(),Y(D.dataTransfer.files)},className:"rounded-md border border-dashed p-6 text-center",children:[u.jsx("input",{ref:T,type:"file",accept:".ttf,.otf,font/ttf,font/otf",multiple:!0,className:"hidden",onChange:D=>void Y(D.target.files)}),u.jsxs(Se,{variant:"secondary",disabled:O,onClick:()=>{var D;return(D=T.current)==null?void 0:D.click()},children:[O?u.jsx(Fr,{className:"animate-spin mr-2 h-4 w-4"}):u.jsx(tx,{className:"mr-2 h-4 w-4"}),"Choose font files"]}),u.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:"or drop them here"})]})]}),u.jsxs("section",{className:"flex flex-col gap-2",children:[u.jsx("h3",{className:"text-sm font-medium",children:"Embed any Google font"}),u.jsxs("p",{className:"text-xs text-muted-foreground",children:["Not limited to the ",l.google.length," curated families — type any Google Fonts family name and its regular and bold weights are fetched and embedded."]}),u.jsxs("div",{className:"flex gap-2",children:[u.jsx(hr,{placeholder:"e.g. Geist",value:$,onChange:D=>H(D.target.value),onKeyDown:D=>{D.key==="Enter"&&ie()}}),u.jsxs(Se,{onClick:()=>void ie(),disabled:v||$.trim()==="",children:[v&&u.jsx(Fr,{className:"animate-spin mr-2 h-4 w-4"}),"Embed"]})]}),j.length>0&&u.jsx(ir,{children:u.jsx(sr,{className:"text-xs",children:j.join(" · ")})})]})]})})]})]})]})})},Av="The quick brown fox jumps over the lazy dog",zv=({family:e,weights:t,hasItalic:n})=>{const r=x.useMemo(()=>[...t].sort((i,s)=>i-s),[t]);return u.jsxs(Ns,{children:[u.jsx(Es,{asChild:!0,children:u.jsx(Se,{size:"sm",variant:"ghost","aria-label":"Show variants",children:"Variants"})}),u.jsxs(yi,{align:"end",className:"min-w-[260px]",children:[u.jsxs(ko,{className:"text-xs text-muted-foreground",children:[r.length," weight",r.length===1?"":"s",n?" · italic available":""]}),u.jsx(mr,{}),r.map(i=>{const s=Ed[i]??String(i);return u.jsxs("div",{className:"flex flex-col gap-0.5 px-2 py-1.5",children:[u.jsx("span",{className:"truncate",style:{fontFamily:`"${e}", sans-serif`,fontWeight:i},children:s}),u.jsxs("span",{className:"text-xs text-muted-foreground font-mono",children:["fontWeight: ",i]})]},i)})]})]})},Kl=({family:e,meta:t,previewStyle:n,onCopy:r,copied:i,contextual:s,onUseThis:a,onInsertHeading:o,onInsertBody:l,applying:c,disabled:f,extraAction:d})=>u.jsxs("div",{className:"border rounded-md p-3 flex flex-col gap-2 bg-card",children:[u.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[u.jsx("div",{className:"font-medium truncate",children:e}),u.jsx("div",{className:"text-muted-foreground",children:t})]}),u.jsx("div",{className:"text-lg truncate",style:n,"aria-hidden":!0,children:Av}),u.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[s?u.jsx(Se,{size:"sm",onClick:a,disabled:c||f,"aria-label":`Use ${e} at the target path`,children:"Use this font"}):u.jsxs(u.Fragment,{children:[u.jsx(Se,{size:"sm",variant:"secondary",onClick:o,disabled:c||f,"aria-label":`Set ${e} as heading font`,children:"Set heading"}),u.jsx(Se,{size:"sm",variant:"secondary",onClick:l,disabled:c||f,"aria-label":`Set ${e} as body font`,children:"Set body"})]}),d,u.jsx(Se,{size:"sm",variant:"ghost",className:"ml-auto",onClick:r,"aria-label":`Copy ${e}`,children:i?u.jsx(an,{className:"h-4 w-4"}):u.jsx(ks,{className:"h-4 w-4"})})]})]});function Xl({previewOpen:e,onTogglePreview:t}){const n=rn(v=>v.name||""),r=rn(v=>v.blob),i=rn(v=>v.isGenerating),s=rn(v=>v.text),a=rn(v=>v.warnings),o=rn(v=>v.isRendering),l=Hi(v=>v.useGlobalPreviewHeader??!0),c=Ne(v=>v.activeTab),f=Ne(v=>v.documentTypes),d=c&&f[c]==="application/json+theme"?"theme":"document",h=Ne(v=>{var k;return v.activeTab&&v.documentTypes[v.activeTab]!=="application/json+theme"?(k=v.documents.find($=>$.name===v.activeTab))==null?void 0:k.text:void 0}),p=Ne(v=>v.activeTab&&v.documentTypes[v.activeTab]!=="application/json+theme"?v.activeTab:void 0),g=Pe(v=>v.chatOpen),w=Pe(v=>v.toggleChat),[_,b]=je.useState(!1),N=$i(v=>v.openFor);if(!l)return null;const m=x.useCallback(()=>{window.dispatchEvent(new CustomEvent("preview:manualRender"))},[]),O=x.useCallback(()=>{window.dispatchEvent(new CustomEvent("preview:showCacheMetrics"))},[]),C=(n==null?void 0:n.trim())||"Preview";return u.jsxs("div",{className:"sticky top-0 z-20",children:[u.jsx(av,{name:C,blob:r,onManualRender:m,isGenerating:i,isRendering:!!o,onShowCacheMetrics:O,onShowSchemas:()=>b(!0),onShowFonts:()=>N(),documentText:s,editorDocumentText:h,editorDocumentName:p,warnings:a,onToggleChat:w,chatOpen:g,onTogglePreview:t,previewOpen:e}),u.jsx(cv,{open:_,onOpenChange:b,defaultTab:d==="theme"?"theme":"document"}),u.jsx(Iv,{})]})}function Ov(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const Pv=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Dv=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Rv={};function Ql(e,t){return(Rv.jsx?Dv:Pv).test(e)}const Mv=/[ \t\n\f\r]/g;function $v(e){return typeof e=="object"?e.type==="text"?eu(e.value):!1:eu(e)}function eu(e){return e.replace(Mv,"")===""}class bi{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}bi.prototype.normal={};bi.prototype.property={};bi.prototype.space=void 0;function op(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new bi(n,r,t)}function Ba(e){return e.toLowerCase()}class St{constructor(t,n){this.attribute=n,this.property=t}}St.prototype.attribute="";St.prototype.booleanish=!1;St.prototype.boolean=!1;St.prototype.commaOrSpaceSeparated=!1;St.prototype.commaSeparated=!1;St.prototype.defined=!1;St.prototype.mustUseProperty=!1;St.prototype.number=!1;St.prototype.overloadedBoolean=!1;St.prototype.property="";St.prototype.spaceSeparated=!1;St.prototype.space=void 0;let Fv=0;const ke=$n(),nt=$n(),Za=$n(),re=$n(),Be=$n(),cr=$n(),jt=$n();function $n(){return 2**++Fv}const Va=Object.freeze(Object.defineProperty({__proto__:null,boolean:ke,booleanish:nt,commaOrSpaceSeparated:jt,commaSeparated:cr,number:re,overloadedBoolean:Za,spaceSeparated:Be},Symbol.toStringTag,{value:"Module"})),ta=Object.keys(Va);class Io extends St{constructor(t,n,r,i){let s=-1;if(super(t,n),tu(this,"space",i),typeof r=="number")for(;++s<ta.length;){const a=ta[s];tu(this,ta[s],(r&Va[a])===Va[a])}}}Io.prototype.defined=!0;function tu(e,t,n){n&&(e[t]=n)}function jr(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const s=new Io(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[Ba(r)]=r,n[Ba(s.attribute)]=r}return new bi(t,n,e.space)}const lp=jr({properties:{ariaActiveDescendant:null,ariaAtomic:nt,ariaAutoComplete:null,ariaBusy:nt,ariaChecked:nt,ariaColCount:re,ariaColIndex:re,ariaColSpan:re,ariaControls:Be,ariaCurrent:null,ariaDescribedBy:Be,ariaDetails:null,ariaDisabled:nt,ariaDropEffect:Be,ariaErrorMessage:null,ariaExpanded:nt,ariaFlowTo:Be,ariaGrabbed:nt,ariaHasPopup:null,ariaHidden:nt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Be,ariaLevel:re,ariaLive:null,ariaModal:nt,ariaMultiLine:nt,ariaMultiSelectable:nt,ariaOrientation:null,ariaOwns:Be,ariaPlaceholder:null,ariaPosInSet:re,ariaPressed:nt,ariaReadOnly:nt,ariaRelevant:null,ariaRequired:nt,ariaRoleDescription:Be,ariaRowCount:re,ariaRowIndex:re,ariaRowSpan:re,ariaSelected:nt,ariaSetSize:re,ariaSort:null,ariaValueMax:re,ariaValueMin:re,ariaValueNow:re,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function up(e,t){return t in e?e[t]:t}function cp(e,t){return up(e,t.toLowerCase())}const Lv=jr({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:cr,acceptCharset:Be,accessKey:Be,action:null,allow:null,allowFullScreen:ke,allowPaymentRequest:ke,allowUserMedia:ke,alt:null,as:null,async:ke,autoCapitalize:null,autoComplete:Be,autoFocus:ke,autoPlay:ke,blocking:Be,capture:null,charSet:null,checked:ke,cite:null,className:Be,cols:re,colSpan:null,content:null,contentEditable:nt,controls:ke,controlsList:Be,coords:re|cr,crossOrigin:null,data:null,dateTime:null,decoding:null,default:ke,defer:ke,dir:null,dirName:null,disabled:ke,download:Za,draggable:nt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:ke,formTarget:null,headers:Be,height:re,hidden:Za,high:re,href:null,hrefLang:null,htmlFor:Be,httpEquiv:Be,id:null,imageSizes:null,imageSrcSet:null,inert:ke,inputMode:null,integrity:null,is:null,isMap:ke,itemId:null,itemProp:Be,itemRef:Be,itemScope:ke,itemType:Be,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:ke,low:re,manifest:null,max:null,maxLength:re,media:null,method:null,min:null,minLength:re,multiple:ke,muted:ke,name:null,nonce:null,noModule:ke,noValidate:ke,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:ke,optimum:re,pattern:null,ping:Be,placeholder:null,playsInline:ke,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:ke,referrerPolicy:null,rel:Be,required:ke,reversed:ke,rows:re,rowSpan:re,sandbox:Be,scope:null,scoped:ke,seamless:ke,selected:ke,shadowRootClonable:ke,shadowRootDelegatesFocus:ke,shadowRootMode:null,shape:null,size:re,sizes:null,slot:null,span:re,spellCheck:nt,src:null,srcDoc:null,srcLang:null,srcSet:null,start:re,step:null,style:null,tabIndex:re,target:null,title:null,translate:null,type:null,typeMustMatch:ke,useMap:null,value:nt,width:re,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Be,axis:null,background:null,bgColor:null,border:re,borderColor:null,bottomMargin:re,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:ke,declare:ke,event:null,face:null,frame:null,frameBorder:null,hSpace:re,leftMargin:re,link:null,longDesc:null,lowSrc:null,marginHeight:re,marginWidth:re,noResize:ke,noHref:ke,noShade:ke,noWrap:ke,object:null,profile:null,prompt:null,rev:null,rightMargin:re,rules:null,scheme:null,scrolling:nt,standby:null,summary:null,text:null,topMargin:re,valueType:null,version:null,vAlign:null,vLink:null,vSpace:re,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:ke,disableRemotePlayback:ke,prefix:null,property:null,results:re,security:null,unselectable:null},space:"html",transform:cp}),Bv=jr({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:jt,accentHeight:re,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:re,amplitude:re,arabicForm:null,ascent:re,attributeName:null,attributeType:null,azimuth:re,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:re,by:null,calcMode:null,capHeight:re,className:Be,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:re,diffuseConstant:re,direction:null,display:null,dur:null,divisor:re,dominantBaseline:null,download:ke,dx:null,dy:null,edgeMode:null,editable:null,elevation:re,enableBackground:null,end:null,event:null,exponent:re,externalResourcesRequired:null,fill:null,fillOpacity:re,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:cr,g2:cr,glyphName:cr,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:re,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:re,horizOriginX:re,horizOriginY:re,id:null,ideographic:re,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:re,k:re,k1:re,k2:re,k3:re,k4:re,kernelMatrix:jt,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:re,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:re,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:re,overlineThickness:re,paintOrder:null,panose1:null,path:null,pathLength:re,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Be,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:re,pointsAtY:re,pointsAtZ:re,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:jt,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:jt,rev:jt,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:jt,requiredFeatures:jt,requiredFonts:jt,requiredFormats:jt,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:re,specularExponent:re,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:re,strikethroughThickness:re,string:null,stroke:null,strokeDashArray:jt,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:re,strokeOpacity:re,strokeWidth:null,style:null,surfaceScale:re,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:jt,tabIndex:re,tableValues:null,target:null,targetX:re,targetY:re,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:jt,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:re,underlineThickness:re,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:re,values:null,vAlphabetic:re,vMathematical:re,vectorEffect:null,vHanging:re,vIdeographic:re,version:null,vertAdvY:re,vertOriginX:re,vertOriginY:re,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:re,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:up}),dp=jr({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()}}),fp=jr({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:cp}),pp=jr({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),Zv={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"},Vv=/[A-Z]/g,nu=/-[a-z]/g,Uv=/^data[-\w.:]+$/i;function Jv(e,t){const n=Ba(t);let r=t,i=St;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&Uv.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(nu,Wv);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!nu.test(s)){let a=s.replace(Vv,Hv);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}i=Io}return new i(r,t)}function Hv(e){return"-"+e.toLowerCase()}function Wv(e){return e.charAt(1).toUpperCase()}const qv=op([lp,Lv,dp,fp,pp],"html"),Ao=op([lp,Bv,dp,fp,pp],"svg");function Gv(e){return e.join(" ").trim()}var Hn={},na,ru;function Yv(){if(ru)return na;ru=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,a=/^[;\s]*/,o=/^\s+|\s+$/g,l=`
|
|
10
|
+
`,c="/",f="*",d="",h="comment",p="declaration";function g(_,b){if(typeof _!="string")throw new TypeError("First argument must be a string");if(!_)return[];b=b||{};var N=1,m=1;function O(A){var M=A.match(t);M&&(N+=M.length);var V=A.lastIndexOf(l);m=~V?A.length-V:m+A.length}function C(){var A={line:N,column:m};return function(M){return M.position=new v(A),H(),M}}function v(A){this.start=A,this.end={line:N,column:m},this.source=b.source}v.prototype.content=_;function k(A){var M=new Error(b.source+":"+N+":"+m+": "+A);if(M.reason=A,M.filename=b.source,M.line=N,M.column=m,M.source=_,!b.silent)throw M}function $(A){var M=A.exec(_);if(M){var V=M[0];return O(V),_=_.slice(V.length),M}}function H(){$(n)}function j(A){var M;for(A=A||[];M=I();)M!==!1&&A.push(M);return A}function I(){var A=C();if(!(c!=_.charAt(0)||f!=_.charAt(1))){for(var M=2;d!=_.charAt(M)&&(f!=_.charAt(M)||c!=_.charAt(M+1));)++M;if(M+=2,d===_.charAt(M-1))return k("End of comment missing");var V=_.slice(2,M-2);return m+=2,O(V),_=_.slice(M),m+=2,A({type:h,comment:V})}}function T(){var A=C(),M=$(r);if(M){if(I(),!$(i))return k("property missing ':'");var V=$(s),U=A({type:p,property:w(M[0].replace(e,d)),value:V?w(V[0].replace(e,d)):d});return $(a),U}}function P(){var A=[];j(A);for(var M;M=T();)M!==!1&&(A.push(M),j(A));return A}return H(),P()}function w(_){return _?_.replace(o,d):d}return na=g,na}var iu;function Kv(){if(iu)return Hn;iu=1;var e=Hn&&Hn.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Hn,"__esModule",{value:!0}),Hn.default=n;const t=e(Yv());function n(r,i){let s=null;if(!r||typeof r!="string")return s;const a=(0,t.default)(r),o=typeof i=="function";return a.forEach(l=>{if(l.type!=="declaration")return;const{property:c,value:f}=l;o?i(c,f,l):f&&(s=s||{},s[c]=f)}),s}return Hn}var Pr={},su;function Xv(){if(su)return Pr;su=1,Object.defineProperty(Pr,"__esModule",{value:!0}),Pr.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,i=/^-(ms)-/,s=function(c){return!c||n.test(c)||e.test(c)},a=function(c,f){return f.toUpperCase()},o=function(c,f){return"".concat(f,"-")},l=function(c,f){return f===void 0&&(f={}),s(c)?c:(c=c.toLowerCase(),f.reactCompat?c=c.replace(i,o):c=c.replace(r,o),c.replace(t,a))};return Pr.camelCase=l,Pr}var Dr,au;function Qv(){if(au)return Dr;au=1;var e=Dr&&Dr.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},t=e(Kv()),n=Xv();function r(i,s){var a={};return!i||typeof i!="string"||(0,t.default)(i,function(o,l){o&&l&&(a[(0,n.camelCase)(o,s)]=l)}),a}return r.default=r,Dr=r,Dr}var ew=Qv();const tw=uo(ew),hp=mp("end"),zo=mp("start");function mp(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 nw(e){const t=zo(e),n=hp(e);if(t&&n)return{start:t,end:n}}function Kr(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?ou(e.position):"start"in e||"end"in e?ou(e):"line"in e||"column"in e?Ua(e):""}function Ua(e){return lu(e&&e.line)+":"+lu(e&&e.column)}function ou(e){return Ua(e&&e.start)+"-"+Ua(e&&e.end)}function lu(e){return e&&typeof e=="number"?e:1}class lt extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",s={},a=!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&&(a=!0,i=t.message,s.cause=t),!s.ruleId&&!s.source&&typeof r=="string"){const l=r.indexOf(":");l===-1?s.ruleId=r:(s.source=r.slice(0,l),s.ruleId=r.slice(l+1))}if(!s.place&&s.ancestors&&s.ancestors){const l=s.ancestors[s.ancestors.length-1];l&&(s.place=l.position)}const o=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=o?o.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=o?o.line:void 0,this.name=Kr(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=a&&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}}lt.prototype.file="";lt.prototype.name="";lt.prototype.reason="";lt.prototype.message="";lt.prototype.stack="";lt.prototype.column=void 0;lt.prototype.line=void 0;lt.prototype.ancestors=void 0;lt.prototype.cause=void 0;lt.prototype.fatal=void 0;lt.prototype.place=void 0;lt.prototype.ruleId=void 0;lt.prototype.source=void 0;const Oo={}.hasOwnProperty,rw=new Map,iw=/[A-Z]/g,sw=new Set(["table","tbody","thead","tfoot","tr"]),aw=new Set(["td","th"]),gp="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function ow(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=mw(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=hw(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"?Ao:qv,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},s=xp(i,e,void 0);return s&&typeof s!="string"?s:i.create(e,i.Fragment,{children:s||void 0},void 0)}function xp(e,t,n){if(t.type==="element")return lw(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return uw(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return dw(e,t,n);if(t.type==="mdxjsEsm")return cw(e,t);if(t.type==="root")return fw(e,t,n);if(t.type==="text")return pw(e,t)}function lw(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=Ao,e.schema=i),e.ancestors.push(t);const s=bp(e,t.tagName,!1),a=gw(e,t);let o=Do(e,t);return sw.has(t.tagName)&&(o=o.filter(function(l){return typeof l=="string"?!$v(l):!0})),yp(e,a,s,t),Po(a,o),e.ancestors.pop(),e.schema=r,e.create(t,s,a,n)}function uw(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)}oi(e,t.position)}function cw(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);oi(e,t.position)}function dw(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=Ao,e.schema=i),e.ancestors.push(t);const s=t.name===null?e.Fragment:bp(e,t.name,!0),a=xw(e,t),o=Do(e,t);return yp(e,a,s,t),Po(a,o),e.ancestors.pop(),e.schema=r,e.create(t,s,a,n)}function fw(e,t,n){const r={};return Po(r,Do(e,t)),e.create(t,e.Fragment,r,n)}function pw(e,t){return t.value}function yp(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Po(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function hw(e,t,n){return r;function r(i,s,a,o){const c=Array.isArray(a.children)?n:t;return o?c(s,a,o):c(s,a)}}function mw(e,t){return n;function n(r,i,s,a){const o=Array.isArray(s.children),l=zo(r);return t(i,s,a,o,{columnNumber:l?l.column-1:void 0,fileName:e,lineNumber:l?l.line:void 0},void 0)}}function gw(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&Oo.call(t.properties,i)){const s=yw(e,i,t.properties[i]);if(s){const[a,o]=s;e.tableCellAlignToStyle&&a==="align"&&typeof o=="string"&&aw.has(t.tagName)?r=o:n[a]=o}}if(r){const s=n.style||(n.style={});s[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function xw(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 a=s.expression;a.type;const o=a.properties[0];o.type,Object.assign(n,e.evaluater.evaluateExpression(o.argument))}else oi(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 o=r.value.data.estree.body[0];o.type,s=e.evaluater.evaluateExpression(o.expression)}else oi(e,t.position);else s=r.value===null?!0:r.value;n[i]=s}return n}function Do(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:rw;for(;++r<t.children.length;){const s=t.children[r];let a;if(e.passKeys){const l=s.type==="element"?s.tagName:s.type==="mdxJsxFlowElement"||s.type==="mdxJsxTextElement"?s.name:void 0;if(l){const c=i.get(l)||0;a=l+"-"+c,i.set(l,c+1)}}const o=xp(e,s,a);o!==void 0&&n.push(o)}return n}function yw(e,t,n){const r=Jv(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?Ov(n):Gv(n)),r.property==="style"){let i=typeof n=="object"?n:bw(e,String(n));return e.stylePropertyNameCase==="css"&&(i=vw(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&r.space?Zv[r.property]||r.property:r.attribute,n]}}function bw(e,t){try{return tw(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,i=new lt("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=gp+"#cannot-parse-style-attribute",i}}function bp(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const i=t.split(".");let s=-1,a;for(;++s<i.length;){const o=Ql(i[s])?{type:"Identifier",name:i[s]}:{type:"Literal",value:i[s]};a=a?{type:"MemberExpression",object:a,property:o,computed:!!(s&&o.type==="Literal"),optional:!1}:o}r=a}else r=Ql(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const i=r.value;return Oo.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(r);oi(e)}function oi(e,t){const n=new lt("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=gp+"#cannot-handle-mdx-estrees-without-createevaluater",n}function vw(e){const t={};let n;for(n in e)Oo.call(e,n)&&(t[ww(n)]=e[n]);return t}function ww(e){let t=e.replace(iw,kw);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function kw(e){return"-"+e.toLowerCase()}const ra={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"]},Sw={};function Ro(e,t){const n=Sw,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return vp(e,r,i)}function vp(e,t,n){if(_w(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 uu(e.children,t,n)}return Array.isArray(e)?uu(e,t,n):""}function uu(e,t,n){const r=[];let i=-1;for(;++i<e.length;)r[i]=vp(e[i],t,n);return r.join("")}function _w(e){return!!(e&&typeof e=="object")}const cu=document.createElement("i");function Mo(e){const t="&"+e+";";cu.innerHTML=t;const n=cu.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function Tt(e,t,n,r){const i=e.length;let s=0,a;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)a=Array.from(r),a.unshift(t,n),e.splice(...a);else for(n&&e.splice(t,n);s<r.length;)a=r.slice(s,s+1e4),a.unshift(t,0),e.splice(...a),s+=1e4,t+=1e4}function Ot(e,t){return e.length>0?(Tt(e,e.length,0,t),e):t}const du={}.hasOwnProperty;function wp(e){const t={};let n=-1;for(;++n<e.length;)jw(t,e[n]);return t}function jw(e,t){let n;for(n in t){const i=(du.call(e,n)?e[n]:void 0)||(e[n]={}),s=t[n];let a;if(s)for(a in s){du.call(i,a)||(i[a]=[]);const o=s[a];Nw(i[a],Array.isArray(o)?o:o?[o]:[])}}}function Nw(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);Tt(e,0,0,r)}function kp(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 Zt(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const pt=kn(/[A-Za-z]/),ot=kn(/[\dA-Za-z]/),Ew=kn(/[#-'*+\--9=?A-Z^-~]/);function ss(e){return e!==null&&(e<32||e===127)}const Ja=kn(/\d/),Cw=kn(/[\dA-Fa-f]/),Tw=kn(/[!-/:-@[-`{-~]/);function ye(e){return e!==null&&e<-2}function Fe(e){return e!==null&&(e<0||e===32)}function Ce(e){return e===-2||e===-1||e===32}const Os=kn(new RegExp("\\p{P}|\\p{S}","u")),Rn=kn(/\s/);function kn(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Nr(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const s=e.charCodeAt(n);let a="";if(s===37&&ot(e.charCodeAt(n+1))&&ot(e.charCodeAt(n+2)))i=2;else if(s<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(s))||(a=String.fromCharCode(s));else if(s>55295&&s<57344){const o=e.charCodeAt(n+1);s<56320&&o>56319&&o<57344?(a=String.fromCharCode(s,o),i=1):a="�"}else a=String.fromCharCode(s);a&&(t.push(e.slice(r,n),encodeURIComponent(a)),r=n+i+1,a=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function ze(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let s=0;return a;function a(l){return Ce(l)?(e.enter(n),o(l)):t(l)}function o(l){return Ce(l)&&s++<i?(e.consume(l),o):(e.exit(n),t(l))}}const Iw={tokenize:Aw};function Aw(e){const t=e.attempt(this.parser.constructs.contentInitial,r,i);let n;return t;function r(o){if(o===null){e.consume(o);return}return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),ze(e,t,"linePrefix")}function i(o){return e.enter("paragraph"),s(o)}function s(o){const l=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=l),n=l,a(o)}function a(o){if(o===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(o);return}return ye(o)?(e.consume(o),e.exit("chunkText"),s):(e.consume(o),a)}}const zw={tokenize:Ow},fu={tokenize:Pw};function Ow(e){const t=this,n=[];let r=0,i,s,a;return o;function o(m){if(r<n.length){const O=n[r];return t.containerState=O[1],e.attempt(O[0].continuation,l,c)(m)}return c(m)}function l(m){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&N();const O=t.events.length;let C=O,v;for(;C--;)if(t.events[C][0]==="exit"&&t.events[C][1].type==="chunkFlow"){v=t.events[C][1].end;break}b(r);let k=O;for(;k<t.events.length;)t.events[k][1].end={...v},k++;return Tt(t.events,C+1,0,t.events.slice(O)),t.events.length=k,c(m)}return o(m)}function c(m){if(r===n.length){if(!i)return h(m);if(i.currentConstruct&&i.currentConstruct.concrete)return g(m);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(fu,f,d)(m)}function f(m){return i&&N(),b(r),h(m)}function d(m){return t.parser.lazy[t.now().line]=r!==n.length,a=t.now().offset,g(m)}function h(m){return t.containerState={},e.attempt(fu,p,g)(m)}function p(m){return r++,n.push([t.currentConstruct,t.containerState]),h(m)}function g(m){if(m===null){i&&N(),b(0),e.consume(m);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:s}),w(m)}function w(m){if(m===null){_(e.exit("chunkFlow"),!0),b(0),e.consume(m);return}return ye(m)?(e.consume(m),_(e.exit("chunkFlow")),r=0,t.interrupt=void 0,o):(e.consume(m),w)}function _(m,O){const C=t.sliceStream(m);if(O&&C.push(null),m.previous=s,s&&(s.next=m),s=m,i.defineSkip(m.start),i.write(C),t.parser.lazy[m.start.line]){let v=i.events.length;for(;v--;)if(i.events[v][1].start.offset<a&&(!i.events[v][1].end||i.events[v][1].end.offset>a))return;const k=t.events.length;let $=k,H,j;for(;$--;)if(t.events[$][0]==="exit"&&t.events[$][1].type==="chunkFlow"){if(H){j=t.events[$][1].end;break}H=!0}for(b(r),v=k;v<t.events.length;)t.events[v][1].end={...j},v++;Tt(t.events,$+1,0,t.events.slice(k)),t.events.length=v}}function b(m){let O=n.length;for(;O-- >m;){const C=n[O];t.containerState=C[1],C[0].exit.call(t,e)}n.length=m}function N(){i.write([null]),s=void 0,i=void 0,t.containerState._closeFlow=void 0}}function Pw(e,t,n){return ze(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function yr(e){if(e===null||Fe(e)||Rn(e))return 1;if(Os(e))return 2}function Ps(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 Ha={name:"attention",resolveAll:Dw,tokenize:Rw};function Dw(e,t){let n=-1,r,i,s,a,o,l,c,f;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;l=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 d={...e[r][1].end},h={...e[n][1].start};pu(d,-l),pu(h,l),a={type:l>1?"strongSequence":"emphasisSequence",start:d,end:{...e[r][1].end}},o={type:l>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:h},s={type:l>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:l>1?"strong":"emphasis",start:{...a.start},end:{...o.end}},e[r][1].end={...a.start},e[n][1].start={...o.end},c=[],e[r][1].end.offset-e[r][1].start.offset&&(c=Ot(c,[["enter",e[r][1],t],["exit",e[r][1],t]])),c=Ot(c,[["enter",i,t],["enter",a,t],["exit",a,t],["enter",s,t]]),c=Ot(c,Ps(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),c=Ot(c,[["exit",s,t],["enter",o,t],["exit",o,t],["exit",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(f=2,c=Ot(c,[["enter",e[n][1],t],["exit",e[n][1],t]])):f=0,Tt(e,r-1,n-r+3,c),n=r+c.length-f-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function Rw(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=yr(r);let s;return a;function a(l){return s=l,e.enter("attentionSequence"),o(l)}function o(l){if(l===s)return e.consume(l),o;const c=e.exit("attentionSequence"),f=yr(l),d=!f||f===2&&i||n.includes(l),h=!i||i===2&&f||n.includes(r);return c._open=!!(s===42?d:d&&(i||!h)),c._close=!!(s===42?h:h&&(f||!d)),t(l)}}function pu(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const Mw={name:"autolink",tokenize:$w};function $w(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 pt(p)?(e.consume(p),a):p===64?n(p):c(p)}function a(p){return p===43||p===45||p===46||ot(p)?(r=1,o(p)):c(p)}function o(p){return p===58?(e.consume(p),r=0,l):(p===43||p===45||p===46||ot(p))&&r++<32?(e.consume(p),o):(r=0,c(p))}function l(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||ss(p)?n(p):(e.consume(p),l)}function c(p){return p===64?(e.consume(p),f):Ew(p)?(e.consume(p),c):n(p)}function f(p){return ot(p)?d(p):n(p)}function d(p){return p===46?(e.consume(p),r=0,f):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||ot(p))&&r++<63){const g=p===45?h:d;return e.consume(p),g}return n(p)}}const vi={partial:!0,tokenize:Fw};function Fw(e,t,n){return r;function r(s){return Ce(s)?ze(e,i,"linePrefix")(s):i(s)}function i(s){return s===null||ye(s)?t(s):n(s)}}const Sp={continuation:{tokenize:Bw},exit:Zw,name:"blockQuote",tokenize:Lw};function Lw(e,t,n){const r=this;return i;function i(a){if(a===62){const o=r.containerState;return o.open||(e.enter("blockQuote",{_container:!0}),o.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(a),e.exit("blockQuoteMarker"),s}return n(a)}function s(a){return Ce(a)?(e.enter("blockQuotePrefixWhitespace"),e.consume(a),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(a))}}function Bw(e,t,n){const r=this;return i;function i(a){return Ce(a)?ze(e,s,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a):s(a)}function s(a){return e.attempt(Sp,t,n)(a)}}function Zw(e){e.exit("blockQuote")}const _p={name:"characterEscape",tokenize:Vw};function Vw(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 Tw(s)?(e.enter("characterEscapeValue"),e.consume(s),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(s)}}const jp={name:"characterReference",tokenize:Uw};function Uw(e,t,n){const r=this;let i=0,s,a;return o;function o(d){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(d),e.exit("characterReferenceMarker"),l}function l(d){return d===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(d),e.exit("characterReferenceMarkerNumeric"),c):(e.enter("characterReferenceValue"),s=31,a=ot,f(d))}function c(d){return d===88||d===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(d),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),s=6,a=Cw,f):(e.enter("characterReferenceValue"),s=7,a=Ja,f(d))}function f(d){if(d===59&&i){const h=e.exit("characterReferenceValue");return a===ot&&!Mo(r.sliceSerialize(h))?n(d):(e.enter("characterReferenceMarker"),e.consume(d),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return a(d)&&i++<s?(e.consume(d),f):n(d)}}const hu={partial:!0,tokenize:Hw},mu={concrete:!0,name:"codeFenced",tokenize:Jw};function Jw(e,t,n){const r=this,i={partial:!0,tokenize:C};let s=0,a=0,o;return l;function l(v){return c(v)}function c(v){const k=r.events[r.events.length-1];return s=k&&k[1].type==="linePrefix"?k[2].sliceSerialize(k[1],!0).length:0,o=v,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),f(v)}function f(v){return v===o?(a++,e.consume(v),f):a<3?n(v):(e.exit("codeFencedFenceSequence"),Ce(v)?ze(e,d,"whitespace")(v):d(v))}function d(v){return v===null||ye(v)?(e.exit("codeFencedFence"),r.interrupt?t(v):e.check(hu,w,O)(v)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),h(v))}function h(v){return v===null||ye(v)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),d(v)):Ce(v)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),ze(e,p,"whitespace")(v)):v===96&&v===o?n(v):(e.consume(v),h)}function p(v){return v===null||ye(v)?d(v):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),g(v))}function g(v){return v===null||ye(v)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),d(v)):v===96&&v===o?n(v):(e.consume(v),g)}function w(v){return e.attempt(i,O,_)(v)}function _(v){return e.enter("lineEnding"),e.consume(v),e.exit("lineEnding"),b}function b(v){return s>0&&Ce(v)?ze(e,N,"linePrefix",s+1)(v):N(v)}function N(v){return v===null||ye(v)?e.check(hu,w,O)(v):(e.enter("codeFlowValue"),m(v))}function m(v){return v===null||ye(v)?(e.exit("codeFlowValue"),N(v)):(e.consume(v),m)}function O(v){return e.exit("codeFenced"),t(v)}function C(v,k,$){let H=0;return j;function j(M){return v.enter("lineEnding"),v.consume(M),v.exit("lineEnding"),I}function I(M){return v.enter("codeFencedFence"),Ce(M)?ze(v,T,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(M):T(M)}function T(M){return M===o?(v.enter("codeFencedFenceSequence"),P(M)):$(M)}function P(M){return M===o?(H++,v.consume(M),P):H>=a?(v.exit("codeFencedFenceSequence"),Ce(M)?ze(v,A,"whitespace")(M):A(M)):$(M)}function A(M){return M===null||ye(M)?(v.exit("codeFencedFence"),k(M)):$(M)}}}function Hw(e,t,n){const r=this;return i;function i(a){return a===null?n(a):(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),s)}function s(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}const ia={name:"codeIndented",tokenize:qw},Ww={partial:!0,tokenize:Gw};function qw(e,t,n){const r=this;return i;function i(c){return e.enter("codeIndented"),ze(e,s,"linePrefix",5)(c)}function s(c){const f=r.events[r.events.length-1];return f&&f[1].type==="linePrefix"&&f[2].sliceSerialize(f[1],!0).length>=4?a(c):n(c)}function a(c){return c===null?l(c):ye(c)?e.attempt(Ww,a,l)(c):(e.enter("codeFlowValue"),o(c))}function o(c){return c===null||ye(c)?(e.exit("codeFlowValue"),a(c)):(e.consume(c),o)}function l(c){return e.exit("codeIndented"),t(c)}}function Gw(e,t,n){const r=this;return i;function i(a){return r.parser.lazy[r.now().line]?n(a):ye(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),i):ze(e,s,"linePrefix",5)(a)}function s(a){const o=r.events[r.events.length-1];return o&&o[1].type==="linePrefix"&&o[2].sliceSerialize(o[1],!0).length>=4?t(a):ye(a)?i(a):n(a)}}const Yw={name:"codeText",previous:Xw,resolve:Kw,tokenize:Qw};function Kw(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 Xw(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function Qw(e,t,n){let r=0,i,s;return a;function a(d){return e.enter("codeText"),e.enter("codeTextSequence"),o(d)}function o(d){return d===96?(e.consume(d),r++,o):(e.exit("codeTextSequence"),l(d))}function l(d){return d===null?n(d):d===32?(e.enter("space"),e.consume(d),e.exit("space"),l):d===96?(s=e.enter("codeTextSequence"),i=0,f(d)):ye(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),l):(e.enter("codeTextData"),c(d))}function c(d){return d===null||d===32||d===96||ye(d)?(e.exit("codeTextData"),l(d)):(e.consume(d),c)}function f(d){return d===96?(e.consume(d),i++,f):i===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(d)):(s.type="codeTextData",c(d))}}class e0{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&&Rr(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),Rr(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Rr(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);Rr(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Rr(this.left,n.reverse())}}}function Rr(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 Np(e){const t={};let n=-1,r,i,s,a,o,l,c;const f=new e0(e);for(;++n<f.length;){for(;n in t;)n=t[n];if(r=f.get(n),n&&r[1].type==="chunkFlow"&&f.get(n-1)[1].type==="listItemPrefix"&&(l=r[1]._tokenizer.events,s=0,s<l.length&&l[s][1].type==="lineEndingBlank"&&(s+=2),s<l.length&&l[s][1].type==="content"))for(;++s<l.length&&l[s][1].type!=="content";)l[s][1].type==="chunkText"&&(l[s][1]._isInFirstContentOfListItem=!0,s++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,t0(f,n)),n=t[n],c=!0);else if(r[1]._container){for(s=n,i=void 0;s--;)if(a=f.get(s),a[1].type==="lineEnding"||a[1].type==="lineEndingBlank")a[0]==="enter"&&(i&&(f.get(i)[1].type="lineEndingBlank"),a[1].type="lineEnding",i=s);else if(!(a[1].type==="linePrefix"||a[1].type==="listItemIndent"))break;i&&(r[1].end={...f.get(i)[1].start},o=f.slice(i,n),o.unshift(r),f.splice(i,n-i+1,o))}}return Tt(e,0,Number.POSITIVE_INFINITY,f.slice(0)),!c}function t0(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const s=[];let a=n._tokenizer;a||(a=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(a._contentTypeTextTrailing=!0));const o=a.events,l=[],c={};let f,d,h=-1,p=n,g=0,w=0;const _=[w];for(;p;){for(;e.get(++i)[1]!==p;);s.push(i),p._tokenizer||(f=r.sliceStream(p),p.next||f.push(null),d&&a.defineSkip(p.start),p._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=!0),a.write(f),p._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++h<o.length;)o[h][0]==="exit"&&o[h-1][0]==="enter"&&o[h][1].type===o[h-1][1].type&&o[h][1].start.line!==o[h][1].end.line&&(w=h+1,_.push(w),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(a.events=[],p?(p._tokenizer=void 0,p.previous=void 0):_.pop(),h=_.length;h--;){const b=o.slice(_[h],_[h+1]),N=s.pop();l.push([N,N+b.length-1]),e.splice(N,2,b)}for(l.reverse(),h=-1;++h<l.length;)c[g+l[h][0]]=g+l[h][1],g+=l[h][1]-l[h][0]-1;return c}const n0={resolve:i0,tokenize:s0},r0={partial:!0,tokenize:a0};function i0(e){return Np(e),e}function s0(e,t){let n;return r;function r(o){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),i(o)}function i(o){return o===null?s(o):ye(o)?e.check(r0,a,s)(o):(e.consume(o),i)}function s(o){return e.exit("chunkContent"),e.exit("content"),t(o)}function a(o){return e.consume(o),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,i}}function a0(e,t,n){const r=this;return i;function i(a){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),ze(e,s,"linePrefix")}function s(a){if(a===null||ye(a))return n(a);const o=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&o&&o[1].type==="linePrefix"&&o[2].sliceSerialize(o[1],!0).length>=4?t(a):e.interrupt(r.parser.constructs.flow,n,t)(a)}}function Ep(e,t,n,r,i,s,a,o,l){const c=l||Number.POSITIVE_INFINITY;let f=0;return d;function d(b){return b===60?(e.enter(r),e.enter(i),e.enter(s),e.consume(b),e.exit(s),h):b===null||b===32||b===41||ss(b)?n(b):(e.enter(r),e.enter(a),e.enter(o),e.enter("chunkString",{contentType:"string"}),w(b))}function h(b){return b===62?(e.enter(s),e.consume(b),e.exit(s),e.exit(i),e.exit(r),t):(e.enter(o),e.enter("chunkString",{contentType:"string"}),p(b))}function p(b){return b===62?(e.exit("chunkString"),e.exit(o),h(b)):b===null||b===60||ye(b)?n(b):(e.consume(b),b===92?g:p)}function g(b){return b===60||b===62||b===92?(e.consume(b),p):p(b)}function w(b){return!f&&(b===null||b===41||Fe(b))?(e.exit("chunkString"),e.exit(o),e.exit(a),e.exit(r),t(b)):f<c&&b===40?(e.consume(b),f++,w):b===41?(e.consume(b),f--,w):b===null||b===32||b===40||ss(b)?n(b):(e.consume(b),b===92?_:w)}function _(b){return b===40||b===41||b===92?(e.consume(b),w):w(b)}}function Cp(e,t,n,r,i,s){const a=this;let o=0,l;return c;function c(p){return e.enter(r),e.enter(i),e.consume(p),e.exit(i),e.enter(s),f}function f(p){return o>999||p===null||p===91||p===93&&!l||p===94&&!o&&"_hiddenFootnoteSupport"in a.parser.constructs?n(p):p===93?(e.exit(s),e.enter(i),e.consume(p),e.exit(i),e.exit(r),t):ye(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),f):(e.enter("chunkString",{contentType:"string"}),d(p))}function d(p){return p===null||p===91||p===93||ye(p)||o++>999?(e.exit("chunkString"),f(p)):(e.consume(p),l||(l=!Ce(p)),p===92?h:d)}function h(p){return p===91||p===92||p===93?(e.consume(p),o++,d):d(p)}}function Tp(e,t,n,r,i,s){let a;return o;function o(h){return h===34||h===39||h===40?(e.enter(r),e.enter(i),e.consume(h),e.exit(i),a=h===40?41:h,l):n(h)}function l(h){return h===a?(e.enter(i),e.consume(h),e.exit(i),e.exit(r),t):(e.enter(s),c(h))}function c(h){return h===a?(e.exit(s),l(a)):h===null?n(h):ye(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),ze(e,c,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),f(h))}function f(h){return h===a||h===null||ye(h)?(e.exit("chunkString"),c(h)):(e.consume(h),h===92?d:f)}function d(h){return h===a||h===92?(e.consume(h),f):f(h)}}function Xr(e,t){let n;return r;function r(i){return ye(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):Ce(i)?ze(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const o0={name:"definition",tokenize:u0},l0={partial:!0,tokenize:c0};function u0(e,t,n){const r=this;let i;return s;function s(p){return e.enter("definition"),a(p)}function a(p){return Cp.call(r,e,o,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(p)}function o(p){return i=Zt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),p===58?(e.enter("definitionMarker"),e.consume(p),e.exit("definitionMarker"),l):n(p)}function l(p){return Fe(p)?Xr(e,c)(p):c(p)}function c(p){return Ep(e,f,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(p)}function f(p){return e.attempt(l0,d,d)(p)}function d(p){return Ce(p)?ze(e,h,"whitespace")(p):h(p)}function h(p){return p===null||ye(p)?(e.exit("definition"),r.parser.defined.push(i),t(p)):n(p)}}function c0(e,t,n){return r;function r(o){return Fe(o)?Xr(e,i)(o):n(o)}function i(o){return Tp(e,s,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(o)}function s(o){return Ce(o)?ze(e,a,"whitespace")(o):a(o)}function a(o){return o===null||ye(o)?t(o):n(o)}}const d0={name:"hardBreakEscape",tokenize:f0};function f0(e,t,n){return r;function r(s){return e.enter("hardBreakEscape"),e.consume(s),i}function i(s){return ye(s)?(e.exit("hardBreakEscape"),t(s)):n(s)}}const p0={name:"headingAtx",resolve:h0,tokenize:m0};function h0(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"},Tt(e,r,n-r+1,[["enter",i,t],["enter",s,t],["exit",s,t],["exit",i,t]])),e}function m0(e,t,n){let r=0;return i;function i(f){return e.enter("atxHeading"),s(f)}function s(f){return e.enter("atxHeadingSequence"),a(f)}function a(f){return f===35&&r++<6?(e.consume(f),a):f===null||Fe(f)?(e.exit("atxHeadingSequence"),o(f)):n(f)}function o(f){return f===35?(e.enter("atxHeadingSequence"),l(f)):f===null||ye(f)?(e.exit("atxHeading"),t(f)):Ce(f)?ze(e,o,"whitespace")(f):(e.enter("atxHeadingText"),c(f))}function l(f){return f===35?(e.consume(f),l):(e.exit("atxHeadingSequence"),o(f))}function c(f){return f===null||f===35||Fe(f)?(e.exit("atxHeadingText"),o(f)):(e.consume(f),c)}}const g0=["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"],gu=["pre","script","style","textarea"],x0={concrete:!0,name:"htmlFlow",resolveTo:v0,tokenize:w0},y0={partial:!0,tokenize:S0},b0={partial:!0,tokenize:k0};function v0(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 w0(e,t,n){const r=this;let i,s,a,o,l;return c;function c(y){return f(y)}function f(y){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(y),d}function d(y){return y===33?(e.consume(y),h):y===47?(e.consume(y),s=!0,w):y===63?(e.consume(y),i=3,r.interrupt?t:S):pt(y)?(e.consume(y),a=String.fromCharCode(y),_):n(y)}function h(y){return y===45?(e.consume(y),i=2,p):y===91?(e.consume(y),i=5,o=0,g):pt(y)?(e.consume(y),i=4,r.interrupt?t:S):n(y)}function p(y){return y===45?(e.consume(y),r.interrupt?t:S):n(y)}function g(y){const q="CDATA[";return y===q.charCodeAt(o++)?(e.consume(y),o===q.length?r.interrupt?t:T:g):n(y)}function w(y){return pt(y)?(e.consume(y),a=String.fromCharCode(y),_):n(y)}function _(y){if(y===null||y===47||y===62||Fe(y)){const q=y===47,X=a.toLowerCase();return!q&&!s&&gu.includes(X)?(i=1,r.interrupt?t(y):T(y)):g0.includes(a.toLowerCase())?(i=6,q?(e.consume(y),b):r.interrupt?t(y):T(y)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(y):s?N(y):m(y))}return y===45||ot(y)?(e.consume(y),a+=String.fromCharCode(y),_):n(y)}function b(y){return y===62?(e.consume(y),r.interrupt?t:T):n(y)}function N(y){return Ce(y)?(e.consume(y),N):j(y)}function m(y){return y===47?(e.consume(y),j):y===58||y===95||pt(y)?(e.consume(y),O):Ce(y)?(e.consume(y),m):j(y)}function O(y){return y===45||y===46||y===58||y===95||ot(y)?(e.consume(y),O):C(y)}function C(y){return y===61?(e.consume(y),v):Ce(y)?(e.consume(y),C):m(y)}function v(y){return y===null||y===60||y===61||y===62||y===96?n(y):y===34||y===39?(e.consume(y),l=y,k):Ce(y)?(e.consume(y),v):$(y)}function k(y){return y===l?(e.consume(y),l=null,H):y===null||ye(y)?n(y):(e.consume(y),k)}function $(y){return y===null||y===34||y===39||y===47||y===60||y===61||y===62||y===96||Fe(y)?C(y):(e.consume(y),$)}function H(y){return y===47||y===62||Ce(y)?m(y):n(y)}function j(y){return y===62?(e.consume(y),I):n(y)}function I(y){return y===null||ye(y)?T(y):Ce(y)?(e.consume(y),I):n(y)}function T(y){return y===45&&i===2?(e.consume(y),V):y===60&&i===1?(e.consume(y),U):y===62&&i===4?(e.consume(y),oe):y===63&&i===3?(e.consume(y),S):y===93&&i===5?(e.consume(y),ne):ye(y)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(y0,B,P)(y)):y===null||ye(y)?(e.exit("htmlFlowData"),P(y)):(e.consume(y),T)}function P(y){return e.check(b0,A,B)(y)}function A(y){return e.enter("lineEnding"),e.consume(y),e.exit("lineEnding"),M}function M(y){return y===null||ye(y)?P(y):(e.enter("htmlFlowData"),T(y))}function V(y){return y===45?(e.consume(y),S):T(y)}function U(y){return y===47?(e.consume(y),a="",J):T(y)}function J(y){if(y===62){const q=a.toLowerCase();return gu.includes(q)?(e.consume(y),oe):T(y)}return pt(y)&&a.length<8?(e.consume(y),a+=String.fromCharCode(y),J):T(y)}function ne(y){return y===93?(e.consume(y),S):T(y)}function S(y){return y===62?(e.consume(y),oe):y===45&&i===2?(e.consume(y),S):T(y)}function oe(y){return y===null||ye(y)?(e.exit("htmlFlowData"),B(y)):(e.consume(y),oe)}function B(y){return e.exit("htmlFlow"),t(y)}}function k0(e,t,n){const r=this;return i;function i(a){return ye(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),s):n(a)}function s(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}function S0(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(vi,t,n)}}const _0={name:"htmlText",tokenize:j0};function j0(e,t,n){const r=this;let i,s,a;return o;function o(S){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(S),l}function l(S){return S===33?(e.consume(S),c):S===47?(e.consume(S),C):S===63?(e.consume(S),m):pt(S)?(e.consume(S),$):n(S)}function c(S){return S===45?(e.consume(S),f):S===91?(e.consume(S),s=0,g):pt(S)?(e.consume(S),N):n(S)}function f(S){return S===45?(e.consume(S),p):n(S)}function d(S){return S===null?n(S):S===45?(e.consume(S),h):ye(S)?(a=d,U(S)):(e.consume(S),d)}function h(S){return S===45?(e.consume(S),p):d(S)}function p(S){return S===62?V(S):S===45?h(S):d(S)}function g(S){const oe="CDATA[";return S===oe.charCodeAt(s++)?(e.consume(S),s===oe.length?w:g):n(S)}function w(S){return S===null?n(S):S===93?(e.consume(S),_):ye(S)?(a=w,U(S)):(e.consume(S),w)}function _(S){return S===93?(e.consume(S),b):w(S)}function b(S){return S===62?V(S):S===93?(e.consume(S),b):w(S)}function N(S){return S===null||S===62?V(S):ye(S)?(a=N,U(S)):(e.consume(S),N)}function m(S){return S===null?n(S):S===63?(e.consume(S),O):ye(S)?(a=m,U(S)):(e.consume(S),m)}function O(S){return S===62?V(S):m(S)}function C(S){return pt(S)?(e.consume(S),v):n(S)}function v(S){return S===45||ot(S)?(e.consume(S),v):k(S)}function k(S){return ye(S)?(a=k,U(S)):Ce(S)?(e.consume(S),k):V(S)}function $(S){return S===45||ot(S)?(e.consume(S),$):S===47||S===62||Fe(S)?H(S):n(S)}function H(S){return S===47?(e.consume(S),V):S===58||S===95||pt(S)?(e.consume(S),j):ye(S)?(a=H,U(S)):Ce(S)?(e.consume(S),H):V(S)}function j(S){return S===45||S===46||S===58||S===95||ot(S)?(e.consume(S),j):I(S)}function I(S){return S===61?(e.consume(S),T):ye(S)?(a=I,U(S)):Ce(S)?(e.consume(S),I):H(S)}function T(S){return S===null||S===60||S===61||S===62||S===96?n(S):S===34||S===39?(e.consume(S),i=S,P):ye(S)?(a=T,U(S)):Ce(S)?(e.consume(S),T):(e.consume(S),A)}function P(S){return S===i?(e.consume(S),i=void 0,M):S===null?n(S):ye(S)?(a=P,U(S)):(e.consume(S),P)}function A(S){return S===null||S===34||S===39||S===60||S===61||S===96?n(S):S===47||S===62||Fe(S)?H(S):(e.consume(S),A)}function M(S){return S===47||S===62||Fe(S)?H(S):n(S)}function V(S){return S===62?(e.consume(S),e.exit("htmlTextData"),e.exit("htmlText"),t):n(S)}function U(S){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(S),e.exit("lineEnding"),J}function J(S){return Ce(S)?ze(e,ne,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(S):ne(S)}function ne(S){return e.enter("htmlTextData"),a(S)}}const $o={name:"labelEnd",resolveAll:T0,resolveTo:I0,tokenize:A0},N0={tokenize:z0},E0={tokenize:O0},C0={tokenize:P0};function T0(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&&Tt(e,0,e.length,n),e}function I0(e,t){let n=e.length,r=0,i,s,a,o;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(a){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"&&(a=n);const l={type:e[s][1].type==="labelLink"?"link":"image",start:{...e[s][1].start},end:{...e[e.length-1][1].end}},c={type:"label",start:{...e[s][1].start},end:{...e[a][1].end}},f={type:"labelText",start:{...e[s+r+2][1].end},end:{...e[a-2][1].start}};return o=[["enter",l,t],["enter",c,t]],o=Ot(o,e.slice(s+1,s+r+3)),o=Ot(o,[["enter",f,t]]),o=Ot(o,Ps(t.parser.constructs.insideSpan.null,e.slice(s+r+4,a-3),t)),o=Ot(o,[["exit",f,t],e[a-2],e[a-1],["exit",c,t]]),o=Ot(o,e.slice(a+1)),o=Ot(o,[["exit",l,t]]),Tt(e,s,e.length,o),e}function A0(e,t,n){const r=this;let i=r.events.length,s,a;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 o;function o(h){return s?s._inactive?d(h):(a=r.parser.defined.includes(Zt(r.sliceSerialize({start:s.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(h),e.exit("labelMarker"),e.exit("labelEnd"),l):n(h)}function l(h){return h===40?e.attempt(N0,f,a?f:d)(h):h===91?e.attempt(E0,f,a?c:d)(h):a?f(h):d(h)}function c(h){return e.attempt(C0,f,d)(h)}function f(h){return t(h)}function d(h){return s._balanced=!0,n(h)}}function z0(e,t,n){return r;function r(d){return e.enter("resource"),e.enter("resourceMarker"),e.consume(d),e.exit("resourceMarker"),i}function i(d){return Fe(d)?Xr(e,s)(d):s(d)}function s(d){return d===41?f(d):Ep(e,a,o,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(d)}function a(d){return Fe(d)?Xr(e,l)(d):f(d)}function o(d){return n(d)}function l(d){return d===34||d===39||d===40?Tp(e,c,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(d):f(d)}function c(d){return Fe(d)?Xr(e,f)(d):f(d)}function f(d){return d===41?(e.enter("resourceMarker"),e.consume(d),e.exit("resourceMarker"),e.exit("resource"),t):n(d)}}function O0(e,t,n){const r=this;return i;function i(o){return Cp.call(r,e,s,a,"reference","referenceMarker","referenceString")(o)}function s(o){return r.parser.defined.includes(Zt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(o):n(o)}function a(o){return n(o)}}function P0(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 D0={name:"labelStartImage",resolveAll:$o.resolveAll,tokenize:R0};function R0(e,t,n){const r=this;return i;function i(o){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(o),e.exit("labelImageMarker"),s}function s(o){return o===91?(e.enter("labelMarker"),e.consume(o),e.exit("labelMarker"),e.exit("labelImage"),a):n(o)}function a(o){return o===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(o):t(o)}}const M0={name:"labelStartLink",resolveAll:$o.resolveAll,tokenize:$0};function $0(e,t,n){const r=this;return i;function i(a){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelLink"),s}function s(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):t(a)}}const sa={name:"lineEnding",tokenize:F0};function F0(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),ze(e,t,"linePrefix")}}const Zi={name:"thematicBreak",tokenize:L0};function L0(e,t,n){let r=0,i;return s;function s(c){return e.enter("thematicBreak"),a(c)}function a(c){return i=c,o(c)}function o(c){return c===i?(e.enter("thematicBreakSequence"),l(c)):r>=3&&(c===null||ye(c))?(e.exit("thematicBreak"),t(c)):n(c)}function l(c){return c===i?(e.consume(c),r++,l):(e.exit("thematicBreakSequence"),Ce(c)?ze(e,o,"whitespace")(c):o(c))}}const xt={continuation:{tokenize:U0},exit:H0,name:"list",tokenize:V0},B0={partial:!0,tokenize:W0},Z0={partial:!0,tokenize:J0};function V0(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,a=0;return o;function o(p){const g=r.containerState.type||(p===42||p===43||p===45?"listUnordered":"listOrdered");if(g==="listUnordered"?!r.containerState.marker||p===r.containerState.marker:Ja(p)){if(r.containerState.type||(r.containerState.type=g,e.enter(g,{_container:!0})),g==="listUnordered")return e.enter("listItemPrefix"),p===42||p===45?e.check(Zi,n,c)(p):c(p);if(!r.interrupt||p===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),l(p)}return n(p)}function l(p){return Ja(p)&&++a<10?(e.consume(p),l):(!r.interrupt||a<2)&&(r.containerState.marker?p===r.containerState.marker:p===41||p===46)?(e.exit("listItemValue"),c(p)):n(p)}function c(p){return e.enter("listItemMarker"),e.consume(p),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||p,e.check(vi,r.interrupt?n:f,e.attempt(B0,h,d))}function f(p){return r.containerState.initialBlankLine=!0,s++,h(p)}function d(p){return Ce(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 U0(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(vi,i,s);function i(o){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,ze(e,t,"listItemIndent",r.containerState.size+1)(o)}function s(o){return r.containerState.furtherBlankLines||!Ce(o)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,a(o)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(Z0,t,a)(o))}function a(o){return r.containerState._closeFlow=!0,r.interrupt=void 0,ze(e,e.attempt(xt,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o)}}function J0(e,t,n){const r=this;return ze(e,i,"listItemIndent",r.containerState.size+1);function i(s){const a=r.events[r.events.length-1];return a&&a[1].type==="listItemIndent"&&a[2].sliceSerialize(a[1],!0).length===r.containerState.size?t(s):n(s)}}function H0(e){e.exit(this.containerState.type)}function W0(e,t,n){const r=this;return ze(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(s){const a=r.events[r.events.length-1];return!Ce(s)&&a&&a[1].type==="listItemPrefixWhitespace"?t(s):n(s)}}const xu={name:"setextUnderline",resolveTo:q0,tokenize:G0};function q0(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 a={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",a,t]),e.splice(s+1,0,["exit",e[r][1],t]),e[r][1].end={...e[s][1].end}):e[r][1]=a,e.push(["exit",a,t]),e}function G0(e,t,n){const r=this;let i;return s;function s(c){let f=r.events.length,d;for(;f--;)if(r.events[f][1].type!=="lineEnding"&&r.events[f][1].type!=="linePrefix"&&r.events[f][1].type!=="content"){d=r.events[f][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||d)?(e.enter("setextHeadingLine"),i=c,a(c)):n(c)}function a(c){return e.enter("setextHeadingLineSequence"),o(c)}function o(c){return c===i?(e.consume(c),o):(e.exit("setextHeadingLineSequence"),Ce(c)?ze(e,l,"lineSuffix")(c):l(c))}function l(c){return c===null||ye(c)?(e.exit("setextHeadingLine"),t(c)):n(c)}}const Y0={tokenize:K0};function K0(e){const t=this,n=e.attempt(vi,r,e.attempt(this.parser.constructs.flowInitial,i,ze(e,e.attempt(this.parser.constructs.flow,i,e.attempt(n0,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 X0={resolveAll:Ap()},Q0=Ip("string"),ek=Ip("text");function Ip(e){return{resolveAll:Ap(e==="text"?tk:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],s=n.attempt(i,a,o);return a;function a(f){return c(f)?s(f):o(f)}function o(f){if(f===null){n.consume(f);return}return n.enter("data"),n.consume(f),l}function l(f){return c(f)?(n.exit("data"),s(f)):(n.consume(f),l)}function c(f){if(f===null)return!0;const d=i[f];let h=-1;if(d)for(;++h<d.length;){const p=d[h];if(!p.previous||p.previous.call(r,r.previous))return!0}return!1}}}function Ap(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 tk(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,a=-1,o=0,l;for(;s--;){const c=i[s];if(typeof c=="string"){for(a=c.length;c.charCodeAt(a-1)===32;)o++,a--;if(a)break;a=-1}else if(c===-2)l=!0,o++;else if(c!==-1){s++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(o=0),o){const c={type:n===e.length||l||o<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:s?a:r.start._bufferIndex+a,_index:r.start._index+s,line:r.end.line,column:r.end.column-o,offset:r.end.offset-o},end:{...r.end}};r.end={...c.start},r.start.offset===r.end.offset?Object.assign(r,c):(e.splice(n,0,["enter",c,t],["exit",c,t]),n+=2)}n++}return e}const nk={42:xt,43:xt,45:xt,48:xt,49:xt,50:xt,51:xt,52:xt,53:xt,54:xt,55:xt,56:xt,57:xt,62:Sp},rk={91:o0},ik={[-2]:ia,[-1]:ia,32:ia},sk={35:p0,42:Zi,45:[xu,Zi],60:x0,61:xu,95:Zi,96:mu,126:mu},ak={38:jp,92:_p},ok={[-5]:sa,[-4]:sa,[-3]:sa,33:D0,38:jp,42:Ha,60:[Mw,_0],91:M0,92:[d0,_p],93:$o,95:Ha,96:Yw},lk={null:[Ha,X0]},uk={null:[42,95]},ck={null:[]},dk=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:uk,contentInitial:rk,disable:ck,document:nk,flow:sk,flowInitial:ik,insideSpan:lk,string:ak,text:ok},Symbol.toStringTag,{value:"Module"}));function fk(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 a=[],o=[];const l={attempt:k(C),check:k(v),consume:N,enter:m,exit:O,interrupt:k(v,{interrupt:!0})},c={code:null,containerState:{},defineSkip:w,events:[],now:g,parser:e,previous:null,sliceSerialize:h,sliceStream:p,write:d};let f=t.tokenize.call(c,l);return t.resolveAll&&s.push(t),c;function d(I){return a=Ot(a,I),_(),a[a.length-1]!==null?[]:($(t,0),c.events=Ps(s,c.events,c),c.events)}function h(I,T){return hk(p(I),T)}function p(I){return pk(a,I)}function g(){const{_bufferIndex:I,_index:T,line:P,column:A,offset:M}=r;return{_bufferIndex:I,_index:T,line:P,column:A,offset:M}}function w(I){i[I.line]=I.column,j()}function _(){let I;for(;r._index<a.length;){const T=a[r._index];if(typeof T=="string")for(I=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===I&&r._bufferIndex<T.length;)b(T.charCodeAt(r._bufferIndex));else b(T)}}function b(I){f=f(I)}function N(I){ye(I)?(r.line++,r.column=1,r.offset+=I===-3?2:1,j()):I!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===a[r._index].length&&(r._bufferIndex=-1,r._index++)),c.previous=I}function m(I,T){const P=T||{};return P.type=I,P.start=g(),c.events.push(["enter",P,c]),o.push(P),P}function O(I){const T=o.pop();return T.end=g(),c.events.push(["exit",T,c]),T}function C(I,T){$(I,T.from)}function v(I,T){T.restore()}function k(I,T){return P;function P(A,M,V){let U,J,ne,S;return Array.isArray(A)?B(A):"tokenize"in A?B([A]):oe(A);function oe(Y){return ie;function ie(D){const ue=D!==null&&Y[D],he=D!==null&&Y.null,ce=[...Array.isArray(ue)?ue:ue?[ue]:[],...Array.isArray(he)?he:he?[he]:[]];return B(ce)(D)}}function B(Y){return U=Y,J=0,Y.length===0?V:y(Y[J])}function y(Y){return ie;function ie(D){return S=H(),ne=Y,Y.partial||(c.currentConstruct=Y),Y.name&&c.parser.constructs.disable.null.includes(Y.name)?X():Y.tokenize.call(T?Object.assign(Object.create(c),T):c,l,q,X)(D)}}function q(Y){return I(ne,S),M}function X(Y){return S.restore(),++J<U.length?y(U[J]):V}}}function $(I,T){I.resolveAll&&!s.includes(I)&&s.push(I),I.resolve&&Tt(c.events,T,c.events.length-T,I.resolve(c.events.slice(T),c)),I.resolveTo&&(c.events=I.resolveTo(c.events,c))}function H(){const I=g(),T=c.previous,P=c.currentConstruct,A=c.events.length,M=Array.from(o);return{from:A,restore:V};function V(){r=I,c.previous=T,c.currentConstruct=P,c.events.length=A,o=M,j()}}function j(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function pk(e,t){const n=t.start._index,r=t.start._bufferIndex,i=t.end._index,s=t.end._bufferIndex;let a;if(n===i)a=[e[n].slice(r,s)];else{if(a=e.slice(n,i),r>-1){const o=a[0];typeof o=="string"?a[0]=o.slice(r):a.shift()}s>0&&a.push(e[i].slice(0,s))}return a}function hk(e,t){let n=-1;const r=[];let i;for(;++n<e.length;){const s=e[n];let a;if(typeof s=="string")a=s;else switch(s){case-5:{a="\r";break}case-4:{a=`
|
|
11
|
+
`;break}case-3:{a=`\r
|
|
12
|
+
`;break}case-2:{a=t?" ":" ";break}case-1:{if(!t&&i)continue;a=" ";break}default:a=String.fromCharCode(s)}i=s===-2,r.push(a)}return r.join("")}function mk(e){const r={constructs:wp([dk,...(e||{}).extensions||[]]),content:i(Iw),defined:[],document:i(zw),flow:i(Y0),lazy:{},string:i(Q0),text:i(ek)};return r;function i(s){return a;function a(o){return fk(r,s,o)}}}function gk(e){for(;!Np(e););return e}const yu=/[\0\t\n\r]/g;function xk(){let e=1,t="",n=!0,r;return i;function i(s,a,o){const l=[];let c,f,d,h,p;for(s=t+(typeof s=="string"?s.toString():new TextDecoder(a||void 0).decode(s)),d=0,t="",n&&(s.charCodeAt(0)===65279&&d++,n=void 0);d<s.length;){if(yu.lastIndex=d,c=yu.exec(s),h=c&&c.index!==void 0?c.index:s.length,p=s.charCodeAt(h),!c){t=s.slice(d);break}if(p===10&&d===h&&r)l.push(-3),r=void 0;else switch(r&&(l.push(-5),r=void 0),d<h&&(l.push(s.slice(d,h)),e+=h-d),p){case 0:{l.push(65533),e++;break}case 9:{for(f=Math.ceil(e/4)*4,l.push(-2);e++<f;)l.push(-1);break}case 10:{l.push(-4),e=1;break}default:r=!0,e=1}d=h+1}return o&&(r&&l.push(-5),t&&l.push(t),l.push(null)),l}}const yk=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function bk(e){return e.replace(yk,vk)}function vk(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),s=i===120||i===88;return kp(n.slice(s?2:1),s?16:10)}return Mo(n)||e}const zp={}.hasOwnProperty;function wk(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),kk(n)(gk(mk(n).document().write(xk()(e,t,!0))))}function kk(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(R),autolinkProtocol:H,autolinkEmail:H,atxHeading:s(Re),blockQuote:s(he),characterEscape:H,characterReference:H,codeFenced:s(ce),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:s(ce,a),codeText:s(ee,a),codeTextData:H,data:H,codeFlowValue:H,definition:s(de),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:s(fe),hardBreakEscape:s(Oe),hardBreakTrailing:s(Oe),htmlFlow:s(We,a),htmlFlowData:H,htmlText:s(We,a),htmlTextData:H,image:s(E),label:a,link:s(R),listItem:s(se),listItemValue:h,listOrdered:s(Z,d),listUnordered:s(Z),paragraph:s(z),reference:y,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:s(Re),strong:s(K),thematicBreak:s(xe)},exit:{atxHeading:l(),atxHeadingSequence:C,autolink:l(),autolinkEmail:ue,autolinkProtocol:D,blockQuote:l(),characterEscapeValue:j,characterReferenceMarkerHexadecimal:X,characterReferenceMarkerNumeric:X,characterReferenceValue:Y,characterReference:ie,codeFenced:l(_),codeFencedFence:w,codeFencedFenceInfo:p,codeFencedFenceMeta:g,codeFlowValue:j,codeIndented:l(b),codeText:l(M),codeTextData:j,data:j,definition:l(),definitionDestinationString:O,definitionLabelString:N,definitionTitleString:m,emphasis:l(),hardBreakEscape:l(T),hardBreakTrailing:l(T),htmlFlow:l(P),htmlFlowData:j,htmlText:l(A),htmlTextData:j,image:l(U),label:ne,labelText:J,lineEnding:I,link:l(V),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:q,resourceDestinationString:S,resourceTitleString:oe,resource:B,setextHeading:l($),setextHeadingLineSequence:k,setextHeadingText:v,strong:l(),thematicBreak:l()}};Op(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(L){let Q={type:"root",children:[]};const me={stack:[Q],tokenStack:[],config:t,enter:o,exit:c,buffer:a,resume:f,data:n},ve=[];let F=-1;for(;++F<L.length;)if(L[F][1].type==="listOrdered"||L[F][1].type==="listUnordered")if(L[F][0]==="enter")ve.push(F);else{const ge=ve.pop();F=i(L,ge,F)}for(F=-1;++F<L.length;){const ge=t[L[F][0]];zp.call(ge,L[F][1].type)&&ge[L[F][1].type].call(Object.assign({sliceSerialize:L[F][2].sliceSerialize},me),L[F][1])}if(me.tokenStack.length>0){const ge=me.tokenStack[me.tokenStack.length-1];(ge[1]||bu).call(me,void 0,ge[0])}for(Q.position={start:dn(L.length>0?L[0][1].start:{line:1,column:1,offset:0}),end:dn(L.length>0?L[L.length-2][1].end:{line:1,column:1,offset:0})},F=-1;++F<t.transforms.length;)Q=t.transforms[F](Q)||Q;return Q}function i(L,Q,me){let ve=Q-1,F=-1,ge=!1,Te,Le,rt,tt;for(;++ve<=me;){const at=L[ve];switch(at[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{at[0]==="enter"?F++:F--,tt=void 0;break}case"lineEndingBlank":{at[0]==="enter"&&(Te&&!tt&&!F&&!rt&&(rt=ve),tt=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:tt=void 0}if(!F&&at[0]==="enter"&&at[1].type==="listItemPrefix"||F===-1&&at[0]==="exit"&&(at[1].type==="listUnordered"||at[1].type==="listOrdered")){if(Te){let un=ve;for(Le=void 0;un--;){const en=L[un];if(en[1].type==="lineEnding"||en[1].type==="lineEndingBlank"){if(en[0]==="exit")continue;Le&&(L[Le][1].type="lineEndingBlank",ge=!0),en[1].type="lineEnding",Le=un}else if(!(en[1].type==="linePrefix"||en[1].type==="blockQuotePrefix"||en[1].type==="blockQuotePrefixWhitespace"||en[1].type==="blockQuoteMarker"||en[1].type==="listItemIndent"))break}rt&&(!Le||rt<Le)&&(Te._spread=!0),Te.end=Object.assign({},Le?L[Le][1].start:at[1].end),L.splice(Le||ve,0,["exit",Te,at[2]]),ve++,me++}if(at[1].type==="listItemPrefix"){const un={type:"listItem",_spread:!1,start:Object.assign({},at[1].start),end:void 0};Te=un,L.splice(ve,0,["enter",un,at[2]]),ve++,me++,rt=void 0,tt=!0}}}return L[Q][1]._spread=ge,me}function s(L,Q){return me;function me(ve){o.call(this,L(ve),ve),Q&&Q.call(this,ve)}}function a(){this.stack.push({type:"fragment",children:[]})}function o(L,Q,me){this.stack[this.stack.length-1].children.push(L),this.stack.push(L),this.tokenStack.push([Q,me||void 0]),L.position={start:dn(Q.start),end:void 0}}function l(L){return Q;function Q(me){L&&L.call(this,me),c.call(this,me)}}function c(L,Q){const me=this.stack.pop(),ve=this.tokenStack.pop();if(ve)ve[0].type!==L.type&&(Q?Q.call(this,L,ve[0]):(ve[1]||bu).call(this,L,ve[0]));else throw new Error("Cannot close `"+L.type+"` ("+Kr({start:L.start,end:L.end})+"): it’s not open");me.position.end=dn(L.end)}function f(){return Ro(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function h(L){if(this.data.expectingFirstListItemValue){const Q=this.stack[this.stack.length-2];Q.start=Number.parseInt(this.sliceSerialize(L),10),this.data.expectingFirstListItemValue=void 0}}function p(){const L=this.resume(),Q=this.stack[this.stack.length-1];Q.lang=L}function g(){const L=this.resume(),Q=this.stack[this.stack.length-1];Q.meta=L}function w(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function _(){const L=this.resume(),Q=this.stack[this.stack.length-1];Q.value=L.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function b(){const L=this.resume(),Q=this.stack[this.stack.length-1];Q.value=L.replace(/(\r?\n|\r)$/g,"")}function N(L){const Q=this.resume(),me=this.stack[this.stack.length-1];me.label=Q,me.identifier=Zt(this.sliceSerialize(L)).toLowerCase()}function m(){const L=this.resume(),Q=this.stack[this.stack.length-1];Q.title=L}function O(){const L=this.resume(),Q=this.stack[this.stack.length-1];Q.url=L}function C(L){const Q=this.stack[this.stack.length-1];if(!Q.depth){const me=this.sliceSerialize(L).length;Q.depth=me}}function v(){this.data.setextHeadingSlurpLineEnding=!0}function k(L){const Q=this.stack[this.stack.length-1];Q.depth=this.sliceSerialize(L).codePointAt(0)===61?1:2}function $(){this.data.setextHeadingSlurpLineEnding=void 0}function H(L){const me=this.stack[this.stack.length-1].children;let ve=me[me.length-1];(!ve||ve.type!=="text")&&(ve=te(),ve.position={start:dn(L.start),end:void 0},me.push(ve)),this.stack.push(ve)}function j(L){const Q=this.stack.pop();Q.value+=this.sliceSerialize(L),Q.position.end=dn(L.end)}function I(L){const Q=this.stack[this.stack.length-1];if(this.data.atHardBreak){const me=Q.children[Q.children.length-1];me.position.end=dn(L.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(Q.type)&&(H.call(this,L),j.call(this,L))}function T(){this.data.atHardBreak=!0}function P(){const L=this.resume(),Q=this.stack[this.stack.length-1];Q.value=L}function A(){const L=this.resume(),Q=this.stack[this.stack.length-1];Q.value=L}function M(){const L=this.resume(),Q=this.stack[this.stack.length-1];Q.value=L}function V(){const L=this.stack[this.stack.length-1];if(this.data.inReference){const Q=this.data.referenceType||"shortcut";L.type+="Reference",L.referenceType=Q,delete L.url,delete L.title}else delete L.identifier,delete L.label;this.data.referenceType=void 0}function U(){const L=this.stack[this.stack.length-1];if(this.data.inReference){const Q=this.data.referenceType||"shortcut";L.type+="Reference",L.referenceType=Q,delete L.url,delete L.title}else delete L.identifier,delete L.label;this.data.referenceType=void 0}function J(L){const Q=this.sliceSerialize(L),me=this.stack[this.stack.length-2];me.label=bk(Q),me.identifier=Zt(Q).toLowerCase()}function ne(){const L=this.stack[this.stack.length-1],Q=this.resume(),me=this.stack[this.stack.length-1];if(this.data.inReference=!0,me.type==="link"){const ve=L.children;me.children=ve}else me.alt=Q}function S(){const L=this.resume(),Q=this.stack[this.stack.length-1];Q.url=L}function oe(){const L=this.resume(),Q=this.stack[this.stack.length-1];Q.title=L}function B(){this.data.inReference=void 0}function y(){this.data.referenceType="collapsed"}function q(L){const Q=this.resume(),me=this.stack[this.stack.length-1];me.label=Q,me.identifier=Zt(this.sliceSerialize(L)).toLowerCase(),this.data.referenceType="full"}function X(L){this.data.characterReferenceType=L.type}function Y(L){const Q=this.sliceSerialize(L),me=this.data.characterReferenceType;let ve;me?(ve=kp(Q,me==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):ve=Mo(Q);const F=this.stack[this.stack.length-1];F.value+=ve}function ie(L){const Q=this.stack.pop();Q.position.end=dn(L.end)}function D(L){j.call(this,L);const Q=this.stack[this.stack.length-1];Q.url=this.sliceSerialize(L)}function ue(L){j.call(this,L);const Q=this.stack[this.stack.length-1];Q.url="mailto:"+this.sliceSerialize(L)}function he(){return{type:"blockquote",children:[]}}function ce(){return{type:"code",lang:null,meta:null,value:""}}function ee(){return{type:"inlineCode",value:""}}function de(){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 We(){return{type:"html",value:""}}function E(){return{type:"image",title:null,url:"",alt:null}}function R(){return{type:"link",title:null,url:"",children:[]}}function Z(L){return{type:"list",ordered:L.type==="listOrdered",start:null,spread:L._spread,children:[]}}function se(L){return{type:"listItem",spread:L._spread,checked:null,children:[]}}function z(){return{type:"paragraph",children:[]}}function K(){return{type:"strong",children:[]}}function te(){return{type:"text",value:""}}function xe(){return{type:"thematicBreak"}}}function dn(e){return{line:e.line,column:e.column,offset:e.offset}}function Op(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?Op(e,r):Sk(e,r)}}function Sk(e,t){let n;for(n in t)if(zp.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 bu(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+Kr({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Kr({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+Kr({start:t.start,end:t.end})+") is still open")}function _k(e){const t=this;t.parser=n;function n(r){return wk(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function jk(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 Nk(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
|
|
13
|
+
`}]}function Ek(e,t){const n=t.value?t.value+`
|
|
14
|
+
`:"",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 Ck(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Tk(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Ik(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),i=Nr(r.toLowerCase()),s=e.footnoteOrder.indexOf(r);let a,o=e.footnoteCounts.get(r);o===void 0?(o=0,e.footnoteOrder.push(r),a=e.footnoteOrder.length):a=s+1,o+=1,e.footnoteCounts.set(r,o);const l={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+i,id:n+"fnref-"+i+(o>1?"-"+o:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(a)}]};e.patch(t,l);const c={type:"element",tagName:"sup",properties:{},children:[l]};return e.patch(t,c),e.applyData(t,c)}function Ak(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 zk(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function Pp(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 a=i[i.length-1];return a&&a.type==="text"?a.value+=r:i.push({type:"text",value:r}),i}function Ok(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Pp(e,t);const i={src:Nr(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 Pk(e,t){const n={src:Nr(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 Dk(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 Rk(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Pp(e,t);const i={href:Nr(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 Mk(e,t){const n={href:Nr(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 $k(e,t,n){const r=e.all(t),i=n?Fk(n):Dp(t),s={},a=[];if(typeof t.checked=="boolean"){const f=r[0];let d;f&&f.type==="element"&&f.tagName==="p"?d=f:(d={type:"element",tagName:"p",properties:{},children:[]},r.unshift(d)),d.children.length>0&&d.children.unshift({type:"text",value:" "}),d.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),s.className=["task-list-item"]}let o=-1;for(;++o<r.length;){const f=r[o];(i||o!==0||f.type!=="element"||f.tagName!=="p")&&a.push({type:"text",value:`
|
|
15
|
+
`}),f.type==="element"&&f.tagName==="p"&&!i?a.push(...f.children):a.push(f)}const l=r[r.length-1];l&&(i||l.type!=="element"||l.tagName!=="p")&&a.push({type:"text",value:`
|
|
16
|
+
`});const c={type:"element",tagName:"li",properties:s,children:a};return e.patch(t,c),e.applyData(t,c)}function Fk(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=Dp(n[r])}return t}function Dp(e){const t=e.spread;return t??e.children.length>1}function Lk(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 a=r[i];if(a.type==="element"&&a.tagName==="li"&&a.properties&&Array.isArray(a.properties.className)&&a.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 Bk(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Zk(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function Vk(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Uk(e,t){const n=e.all(t),r=n.shift(),i=[];if(r){const a={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],a),i.push(a)}if(n.length>0){const a={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},o=zo(t.children[1]),l=hp(t.children[t.children.length-1]);o&&l&&(a.position={start:o,end:l}),i.push(a)}const s={type:"element",tagName:"table",properties:{},children:e.wrap(i,!0)};return e.patch(t,s),e.applyData(t,s)}function Jk(e,t,n){const r=n?n.children:void 0,s=(r?r.indexOf(t):1)===0?"th":"td",a=n&&n.type==="table"?n.align:void 0,o=a?a.length:t.children.length;let l=-1;const c=[];for(;++l<o;){const d=t.children[l],h={},p=a?a[l]:void 0;p&&(h.align=p);let g={type:"element",tagName:s,properties:h,children:[]};d&&(g.children=e.all(d),e.patch(d,g),g=e.applyData(d,g)),c.push(g)}const f={type:"element",tagName:"tr",properties:{},children:e.wrap(c,!0)};return e.patch(t,f),e.applyData(t,f)}function Hk(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const vu=9,wu=32;function Wk(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),i=0;const s=[];for(;r;)s.push(ku(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return s.push(ku(t.slice(i),i>0,!1)),s.join("")}function ku(e,t,n){let r=0,i=e.length;if(t){let s=e.codePointAt(r);for(;s===vu||s===wu;)r++,s=e.codePointAt(r)}if(n){let s=e.codePointAt(i-1);for(;s===vu||s===wu;)i--,s=e.codePointAt(i-1)}return i>r?e.slice(r,i):""}function qk(e,t){const n={type:"text",value:Wk(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function Gk(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const Yk={blockquote:jk,break:Nk,code:Ek,delete:Ck,emphasis:Tk,footnoteReference:Ik,heading:Ak,html:zk,imageReference:Ok,image:Pk,inlineCode:Dk,linkReference:Rk,link:Mk,listItem:$k,list:Lk,paragraph:Bk,root:Zk,strong:Vk,table:Uk,tableCell:Hk,tableRow:Jk,text:qk,thematicBreak:Gk,toml:Ti,yaml:Ti,definition:Ti,footnoteDefinition:Ti};function Ti(){}const Rp=-1,Ds=0,Qr=1,as=2,Fo=3,Lo=4,Bo=5,Zo=6,Mp=7,$p=8,Su=typeof self=="object"?self:globalThis,Kk=(e,t)=>{const n=(i,s)=>(e.set(s,i),i),r=i=>{if(e.has(i))return e.get(i);const[s,a]=t[i];switch(s){case Ds:case Rp:return n(a,i);case Qr:{const o=n([],i);for(const l of a)o.push(r(l));return o}case as:{const o=n({},i);for(const[l,c]of a)o[r(l)]=r(c);return o}case Fo:return n(new Date(a),i);case Lo:{const{source:o,flags:l}=a;return n(new RegExp(o,l),i)}case Bo:{const o=n(new Map,i);for(const[l,c]of a)o.set(r(l),r(c));return o}case Zo:{const o=n(new Set,i);for(const l of a)o.add(r(l));return o}case Mp:{const{name:o,message:l}=a;return n(new Su[o](l),i)}case $p:return n(BigInt(a),i);case"BigInt":return n(Object(BigInt(a)),i);case"ArrayBuffer":return n(new Uint8Array(a).buffer,a);case"DataView":{const{buffer:o}=new Uint8Array(a);return n(new DataView(o),a)}}return n(new Su[s](a),i)};return r},_u=e=>Kk(new Map,e)(0),Wn="",{toString:Xk}={},{keys:Qk}=Object,Mr=e=>{const t=typeof e;if(t!=="object"||!e)return[Ds,t];const n=Xk.call(e).slice(8,-1);switch(n){case"Array":return[Qr,Wn];case"Object":return[as,Wn];case"Date":return[Fo,Wn];case"RegExp":return[Lo,Wn];case"Map":return[Bo,Wn];case"Set":return[Zo,Wn];case"DataView":return[Qr,n]}return n.includes("Array")?[Qr,n]:n.includes("Error")?[Mp,n]:[as,n]},Ii=([e,t])=>e===Ds&&(t==="function"||t==="symbol"),e1=(e,t,n,r)=>{const i=(a,o)=>{const l=r.push(a)-1;return n.set(o,l),l},s=a=>{if(n.has(a))return n.get(a);let[o,l]=Mr(a);switch(o){case Ds:{let f=a;switch(l){case"bigint":o=$p,f=a.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+l);f=null;break;case"undefined":return i([Rp],a)}return i([o,f],a)}case Qr:{if(l){let h=a;return l==="DataView"?h=new Uint8Array(a.buffer):l==="ArrayBuffer"&&(h=new Uint8Array(a)),i([l,[...h]],a)}const f=[],d=i([o,f],a);for(const h of a)f.push(s(h));return d}case as:{if(l)switch(l){case"BigInt":return i([l,a.toString()],a);case"Boolean":case"Number":case"String":return i([l,a.valueOf()],a)}if(t&&"toJSON"in a)return s(a.toJSON());const f=[],d=i([o,f],a);for(const h of Qk(a))(e||!Ii(Mr(a[h])))&&f.push([s(h),s(a[h])]);return d}case Fo:return i([o,a.toISOString()],a);case Lo:{const{source:f,flags:d}=a;return i([o,{source:f,flags:d}],a)}case Bo:{const f=[],d=i([o,f],a);for(const[h,p]of a)(e||!(Ii(Mr(h))||Ii(Mr(p))))&&f.push([s(h),s(p)]);return d}case Zo:{const f=[],d=i([o,f],a);for(const h of a)(e||!Ii(Mr(h)))&&f.push(s(h));return d}}const{message:c}=a;return i([o,{name:l,message:c}],a)};return s},ju=(e,{json:t,lossy:n}={})=>{const r=[];return e1(!(t||n),!!t,new Map,r)(e),r},os=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?_u(ju(e,t)):structuredClone(e):(e,t)=>_u(ju(e,t));function t1(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 n1(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function r1(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||t1,r=e.options.footnoteBackLabel||n1,i=e.options.footnoteLabel||"Footnotes",s=e.options.footnoteLabelTagName||"h2",a=e.options.footnoteLabelProperties||{className:["sr-only"]},o=[];let l=-1;for(;++l<e.footnoteOrder.length;){const c=e.footnoteById.get(e.footnoteOrder[l]);if(!c)continue;const f=e.all(c),d=String(c.identifier).toUpperCase(),h=Nr(d.toLowerCase());let p=0;const g=[],w=e.footnoteCounts.get(d);for(;w!==void 0&&++p<=w;){g.length>0&&g.push({type:"text",value:" "});let N=typeof n=="string"?n:n(l,p);typeof N=="string"&&(N={type:"text",value:N}),g.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+h+(p>1?"-"+p:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(l,p),className:["data-footnote-backref"]},children:Array.isArray(N)?N:[N]})}const _=f[f.length-1];if(_&&_.type==="element"&&_.tagName==="p"){const N=_.children[_.children.length-1];N&&N.type==="text"?N.value+=" ":_.children.push({type:"text",value:" "}),_.children.push(...g)}else f.push(...g);const b={type:"element",tagName:"li",properties:{id:t+"fn-"+h},children:e.wrap(f,!0)};e.patch(c,b),o.push(b)}if(o.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:s,properties:{...os(a),id:"footnote-label"},children:[{type:"text",value:i}]},{type:"text",value:`
|
|
17
|
+
`},{type:"element",tagName:"ol",properties:{},children:e.wrap(o,!0)},{type:"text",value:`
|
|
18
|
+
`}]}}const Rs=function(e){if(e==null)return o1;if(typeof e=="function")return Ms(e);if(typeof e=="object")return Array.isArray(e)?i1(e):s1(e);if(typeof e=="string")return a1(e);throw new Error("Expected function, string, or object as test")};function i1(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=Rs(e[n]);return Ms(r);function r(...i){let s=-1;for(;++s<t.length;)if(t[s].apply(this,i))return!0;return!1}}function s1(e){const t=e;return Ms(n);function n(r){const i=r;let s;for(s in e)if(i[s]!==t[s])return!1;return!0}}function a1(e){return Ms(t);function t(n){return n&&n.type===e}}function Ms(e){return t;function t(n,r,i){return!!(l1(n)&&e.call(this,n,typeof r=="number"?r:void 0,i||void 0))}}function o1(){return!0}function l1(e){return e!==null&&typeof e=="object"&&"type"in e}const Fp=[],u1=!0,Wa=!1,c1="skip";function Lp(e,t,n,r){let i;typeof t=="function"&&typeof n!="function"?(r=n,n=t):i=t;const s=Rs(i),a=r?-1:1;o(e,void 0,[])();function o(l,c,f){const d=l&&typeof l=="object"?l:{};if(typeof d.type=="string"){const p=typeof d.tagName=="string"?d.tagName:typeof d.name=="string"?d.name:void 0;Object.defineProperty(h,"name",{value:"node ("+(l.type+(p?"<"+p+">":""))+")"})}return h;function h(){let p=Fp,g,w,_;if((!t||s(l,c,f[f.length-1]||void 0))&&(p=d1(n(l,f)),p[0]===Wa))return p;if("children"in l&&l.children){const b=l;if(b.children&&p[0]!==c1)for(w=(r?b.children.length:-1)+a,_=f.concat(b);w>-1&&w<b.children.length;){const N=b.children[w];if(g=o(N,w,_)(),g[0]===Wa)return g;w=typeof g[1]=="number"?g[1]:w+a}}return p}}}function d1(e){return Array.isArray(e)?e:typeof e=="number"?[u1,e]:e==null?Fp:[e]}function Vo(e,t,n,r){let i,s,a;typeof t=="function"&&typeof n!="function"?(s=void 0,a=t,i=n):(s=t,a=n,i=r),Lp(e,s,o,i);function o(l,c){const f=c[c.length-1],d=f?f.children.indexOf(l):void 0;return a(l,d,f)}}const qa={}.hasOwnProperty,f1={};function p1(e,t){const n=t||f1,r=new Map,i=new Map,s=new Map,a={...Yk,...n.handlers},o={all:c,applyData:m1,definitionById:r,footnoteById:i,footnoteCounts:s,footnoteOrder:[],handlers:a,one:l,options:n,patch:h1,wrap:x1};return Vo(e,function(f){if(f.type==="definition"||f.type==="footnoteDefinition"){const d=f.type==="definition"?r:i,h=String(f.identifier).toUpperCase();d.has(h)||d.set(h,f)}}),o;function l(f,d){const h=f.type,p=o.handlers[h];if(qa.call(o.handlers,h)&&p)return p(o,f,d);if(o.options.passThrough&&o.options.passThrough.includes(h)){if("children"in f){const{children:w,..._}=f,b=os(_);return b.children=o.all(f),b}return os(f)}return(o.options.unknownHandler||g1)(o,f,d)}function c(f){const d=[];if("children"in f){const h=f.children;let p=-1;for(;++p<h.length;){const g=o.one(h[p],f);if(g){if(p&&h[p-1].type==="break"&&(!Array.isArray(g)&&g.type==="text"&&(g.value=Nu(g.value)),!Array.isArray(g)&&g.type==="element")){const w=g.children[0];w&&w.type==="text"&&(w.value=Nu(w.value))}Array.isArray(g)?d.push(...g):d.push(g)}}}return d}}function h1(e,t){e.position&&(t.position=nw(e))}function m1(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 a="children"in n?n.children:[n];n={type:"element",tagName:r,properties:{},children:a}}n.type==="element"&&s&&Object.assign(n.properties,os(s)),"children"in n&&n.children&&i!==null&&i!==void 0&&(n.children=i)}return n}function g1(e,t){const n=t.data||{},r="value"in t&&!(qa.call(n,"hProperties")||qa.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 x1(e,t){const n=[];let r=-1;for(t&&n.push({type:"text",value:`
|
|
19
|
+
`});++r<e.length;)r&&n.push({type:"text",value:`
|
|
20
|
+
`}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:`
|
|
21
|
+
`}),n}function Nu(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function Eu(e,t){const n=p1(e,t),r=n.one(e,void 0),i=r1(n),s=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return i&&s.children.push({type:"text",value:`
|
|
22
|
+
`},i),s}function y1(e,t){return e&&"run"in e?async function(n,r){const i=Eu(n,{file:r,...t});await e.run(i,r)}:function(n,r){return Eu(n,{file:r,...e||t})}}function Cu(e){if(e)throw e}var aa,Tu;function b1(){if(Tu)return aa;Tu=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=function(c){return typeof Array.isArray=="function"?Array.isArray(c):t.call(c)==="[object Array]"},s=function(c){if(!c||t.call(c)!=="[object Object]")return!1;var f=e.call(c,"constructor"),d=c.constructor&&c.constructor.prototype&&e.call(c.constructor.prototype,"isPrototypeOf");if(c.constructor&&!f&&!d)return!1;var h;for(h in c);return typeof h>"u"||e.call(c,h)},a=function(c,f){n&&f.name==="__proto__"?n(c,f.name,{enumerable:!0,configurable:!0,value:f.newValue,writable:!0}):c[f.name]=f.newValue},o=function(c,f){if(f==="__proto__")if(e.call(c,f)){if(r)return r(c,f).value}else return;return c[f]};return aa=function l(){var c,f,d,h,p,g,w=arguments[0],_=1,b=arguments.length,N=!1;for(typeof w=="boolean"&&(N=w,w=arguments[1]||{},_=2),(w==null||typeof w!="object"&&typeof w!="function")&&(w={});_<b;++_)if(c=arguments[_],c!=null)for(f in c)d=o(w,f),h=o(c,f),w!==h&&(N&&h&&(s(h)||(p=i(h)))?(p?(p=!1,g=d&&i(d)?d:[]):g=d&&s(d)?d:{},a(w,{name:f,newValue:l(N,g,h)})):typeof h<"u"&&a(w,{name:f,newValue:h}));return w},aa}var v1=b1();const oa=uo(v1);function Ga(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 w1(){const e=[],t={run:n,use:r};return t;function n(...i){let s=-1;const a=i.pop();if(typeof a!="function")throw new TypeError("Expected function as last argument, not "+a);o(null,...i);function o(l,...c){const f=e[++s];let d=-1;if(l){a(l);return}for(;++d<i.length;)(c[d]===null||c[d]===void 0)&&(c[d]=i[d]);i=c,f?k1(f,o)(...c):a(null,...c)}}function r(i){if(typeof i!="function")throw new TypeError("Expected `middelware` to be a function, not "+i);return e.push(i),t}}function k1(e,t){let n;return r;function r(...a){const o=e.length>a.length;let l;o&&a.push(i);try{l=e.apply(this,a)}catch(c){const f=c;if(o&&n)throw f;return i(f)}o||(l&&l.then&&typeof l.then=="function"?l.then(s,i):l instanceof Error?i(l):s(l))}function i(a,...o){n||(n=!0,t(a,...o))}function s(a){i(null,a)}}const Wt={basename:S1,dirname:_1,extname:j1,join:N1,sep:"/"};function S1(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');wi(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 a=-1,o=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(s){n=i+1;break}}else a<0&&(s=!0,a=i+1),o>-1&&(e.codePointAt(i)===t.codePointAt(o--)?o<0&&(r=i):(o=-1,r=a));return n===r?r=a:r<0&&(r=e.length),e.slice(n,r)}function _1(e){if(wi(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 j1(e){wi(e);let t=e.length,n=-1,r=0,i=-1,s=0,a;for(;t--;){const o=e.codePointAt(t);if(o===47){if(a){r=t+1;break}continue}n<0&&(a=!0,n=t+1),o===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 N1(...e){let t=-1,n;for(;++t<e.length;)wi(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":E1(n)}function E1(e){wi(e);const t=e.codePointAt(0)===47;let n=C1(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function C1(e,t){let n="",r=0,i=-1,s=0,a=-1,o,l;for(;++a<=e.length;){if(a<e.length)o=e.codePointAt(a);else{if(o===47)break;o=47}if(o===47){if(!(i===a-1||s===1))if(i!==a-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(l=n.lastIndexOf("/"),l!==n.length-1){l<0?(n="",r=0):(n=n.slice(0,l),r=n.length-1-n.lastIndexOf("/")),i=a,s=0;continue}}else if(n.length>0){n="",r=0,i=a,s=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(i+1,a):n=e.slice(i+1,a),r=a-i-1;i=a,s=0}else o===46&&s>-1?s++:s=-1}return n}function wi(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const T1={cwd:I1};function I1(){return"/"}function Ya(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function A1(e){if(typeof e=="string")e=new URL(e);else if(!Ya(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 z1(e)}function z1(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 la=["history","path","basename","stem","extname","dirname"];class Bp{constructor(t){let n;t?Ya(t)?n={path:t}:typeof t=="string"||O1(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":T1.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<la.length;){const s=la[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)la.includes(i)||(this[i]=n[i])}get basename(){return typeof this.path=="string"?Wt.basename(this.path):void 0}set basename(t){ca(t,"basename"),ua(t,"basename"),this.path=Wt.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Wt.dirname(this.path):void 0}set dirname(t){Iu(this.basename,"dirname"),this.path=Wt.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Wt.extname(this.path):void 0}set extname(t){if(ua(t,"extname"),Iu(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=Wt.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){Ya(t)&&(t=A1(t)),ca(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Wt.basename(this.path,this.extname):void 0}set stem(t){ca(t,"stem"),ua(t,"stem"),this.path=Wt.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 lt(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 ua(e,t){if(e&&e.includes(Wt.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Wt.sep+"`")}function ca(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function Iu(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function O1(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const P1=function(e){const r=this.constructor.prototype,i=r[e],s=function(){return i.apply(s,arguments)};return Object.setPrototypeOf(s,r),s},D1={}.hasOwnProperty;class Uo extends P1{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=w1()}copy(){const t=new Uo;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(oa(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(pa("data",this.frozen),this.namespace[t]=n,this):D1.call(this.namespace,t)&&this.namespace[t]||void 0:t?(pa("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=Ai(t),r=this.parser||this.Parser;return da("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),da("process",this.parser||this.Parser),fa("process",this.compiler||this.Compiler),n?i(void 0,n):new Promise(i);function i(s,a){const o=Ai(t),l=r.parse(o);r.run(l,o,function(f,d,h){if(f||!d||!h)return c(f);const p=d,g=r.stringify(p,h);$1(g)?h.value=g:h.result=g,c(f,h)});function c(f,d){f||!d?a(f):s?s(d):n(void 0,d)}}}processSync(t){let n=!1,r;return this.freeze(),da("processSync",this.parser||this.Parser),fa("processSync",this.compiler||this.Compiler),this.process(t,i),zu("processSync","process",n),r;function i(s,a){n=!0,Cu(s),r=a}}run(t,n,r){Au(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(a,o){const l=Ai(n);i.run(t,l,c);function c(f,d,h){const p=d||t;f?o(f):a?a(p):r(void 0,p,h)}}}runSync(t,n){let r=!1,i;return this.run(t,n,s),zu("runSync","run",r),i;function s(a,o){Cu(a),i=o,r=!0}}stringify(t,n){this.freeze();const r=Ai(n),i=this.compiler||this.Compiler;return fa("stringify",i),Au(t),i(t,r)}use(t,...n){const r=this.attachers,i=this.namespace;if(pa("use",this.frozen),t!=null)if(typeof t=="function")l(t,n);else if(typeof t=="object")Array.isArray(t)?o(t):a(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function s(c){if(typeof c=="function")l(c,[]);else if(typeof c=="object")if(Array.isArray(c)){const[f,...d]=c;l(f,d)}else a(c);else throw new TypeError("Expected usable value, not `"+c+"`")}function a(c){if(!("plugins"in c)&&!("settings"in c))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");o(c.plugins),c.settings&&(i.settings=oa(!0,i.settings,c.settings))}function o(c){let f=-1;if(c!=null)if(Array.isArray(c))for(;++f<c.length;){const d=c[f];s(d)}else throw new TypeError("Expected a list of plugins, not `"+c+"`")}function l(c,f){let d=-1,h=-1;for(;++d<r.length;)if(r[d][0]===c){h=d;break}if(h===-1)r.push([c,...f]);else if(f.length>0){let[p,...g]=f;const w=r[h][1];Ga(w)&&Ga(p)&&(p=oa(!0,w,p)),r[h]=[c,p,...g]}}}}const R1=new Uo().freeze();function da(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function fa(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function pa(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 Au(e){if(!Ga(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function zu(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Ai(e){return M1(e)?e:new Bp(e)}function M1(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function $1(e){return typeof e=="string"||F1(e)}function F1(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const L1="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",Ou=[],Pu={allowDangerousHtml:!0},B1=/^(https?|ircs?|mailto|xmpp)$/i,Z1=[{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 V1(e){const t=U1(e),n=J1(e);return H1(t.runSync(t.parse(n),n),e)}function U1(e){const t=e.rehypePlugins||Ou,n=e.remarkPlugins||Ou,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...Pu}:Pu;return R1().use(_k).use(n).use(y1,r).use(t)}function J1(e){const t=e.children||"",n=new Bp;return typeof t=="string"&&(n.value=t),n}function H1(e,t){const n=t.allowedElements,r=t.allowElement,i=t.components,s=t.disallowedElements,a=t.skipHtml,o=t.unwrapDisallowed,l=t.urlTransform||W1;for(const f of Z1)Object.hasOwn(t,f.from)&&(""+f.from+(f.to?"use `"+f.to+"` instead":"remove it")+L1+f.id,void 0);return Vo(e,c),ow(e,{Fragment:u.Fragment,components:i,ignoreInvalidStyle:!0,jsx:u.jsx,jsxs:u.jsxs,passKeys:!0,passNode:!0});function c(f,d,h){if(f.type==="raw"&&h&&typeof d=="number")return a?h.children.splice(d,1):h.children[d]={type:"text",value:f.value},d;if(f.type==="element"){let p;for(p in ra)if(Object.hasOwn(ra,p)&&Object.hasOwn(f.properties,p)){const g=f.properties[p],w=ra[p];(w===null||w.includes(f.tagName))&&(f.properties[p]=l(String(g||""),p,f))}}if(f.type==="element"){let p=n?!n.includes(f.tagName):s?s.includes(f.tagName):!1;if(!p&&r&&typeof d=="number"&&(p=!r(f,d,h)),p&&h&&typeof d=="number")return o&&f.children?h.children.splice(d,1,...f.children):h.children.splice(d,1),d}}}function W1(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||B1.test(e.slice(0,t))?e:""}function Du(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 q1(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function G1(e,t,n){const i=Rs((n||{}).ignore||[]),s=Y1(t);let a=-1;for(;++a<s.length;)Lp(e,"text",o);function o(c,f){let d=-1,h;for(;++d<f.length;){const p=f[d],g=h?h.children:void 0;if(i(p,g?g.indexOf(p):void 0,h))return;h=p}if(h)return l(c,f)}function l(c,f){const d=f[f.length-1],h=s[a][0],p=s[a][1];let g=0;const _=d.children.indexOf(c);let b=!1,N=[];h.lastIndex=0;let m=h.exec(c.value);for(;m;){const O=m.index,C={index:m.index,input:m.input,stack:[...f,c]};let v=p(...m,C);if(typeof v=="string"&&(v=v.length>0?{type:"text",value:v}:void 0),v===!1?h.lastIndex=O+1:(g!==O&&N.push({type:"text",value:c.value.slice(g,O)}),Array.isArray(v)?N.push(...v):v&&N.push(v),g=O+m[0].length,b=!0),!h.global)break;m=h.exec(c.value)}return b?(g<c.value.length&&N.push({type:"text",value:c.value.slice(g)}),d.children.splice(_,1,...N)):N=[c],_+N.length}}function Y1(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([K1(i[0]),X1(i[1])])}return t}function K1(e){return typeof e=="string"?new RegExp(q1(e),"g"):e}function X1(e){return typeof e=="function"?e:function(){return e}}const ha="phrasing",ma=["autolink","link","image","label"];function Q1(){return{transforms:[aS],enter:{literalAutolink:tS,literalAutolinkEmail:ga,literalAutolinkHttp:ga,literalAutolinkWww:ga},exit:{literalAutolink:sS,literalAutolinkEmail:iS,literalAutolinkHttp:nS,literalAutolinkWww:rS}}}function eS(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:ha,notInConstruct:ma},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:ha,notInConstruct:ma},{character:":",before:"[ps]",after:"\\/",inConstruct:ha,notInConstruct:ma}]}}function tS(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function ga(e){this.config.enter.autolinkProtocol.call(this,e)}function nS(e){this.config.exit.autolinkProtocol.call(this,e)}function rS(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 iS(e){this.config.exit.autolinkEmail.call(this,e)}function sS(e){this.exit(e)}function aS(e){G1(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,oS],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),lS]],{ignore:["link","linkReference"]})}function oS(e,t,n,r,i){let s="";if(!Zp(i)||(/^w/i.test(t)&&(n=t+n,t="",s="http://"),!uS(n)))return!1;const a=cS(n+r);if(!a[0])return!1;const o={type:"link",title:null,url:s+t+a[0],children:[{type:"text",value:t+a[0]}]};return a[1]?[o,{type:"text",value:a[1]}]:o}function lS(e,t,n,r){return!Zp(r,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function uS(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 cS(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=Du(e,"(");let s=Du(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 Zp(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||Rn(n)||Os(n))&&(!t||n!==47)}Vp.peek=bS;function dS(){this.buffer()}function fS(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function pS(){this.buffer()}function hS(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function mS(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Zt(this.sliceSerialize(e)).toLowerCase(),n.label=t}function gS(e){this.exit(e)}function xS(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Zt(this.sliceSerialize(e)).toLowerCase(),n.label=t}function yS(e){this.exit(e)}function bS(){return"["}function Vp(e,t,n,r){const i=n.createTracker(r);let s=i.move("[^");const a=n.enter("footnoteReference"),o=n.enter("reference");return s+=i.move(n.safe(n.associationId(e),{after:"]",before:s})),o(),a(),s+=i.move("]"),s}function vS(){return{enter:{gfmFootnoteCallString:dS,gfmFootnoteCall:fS,gfmFootnoteDefinitionLabelString:pS,gfmFootnoteDefinition:hS},exit:{gfmFootnoteCallString:mS,gfmFootnoteCall:gS,gfmFootnoteDefinitionLabelString:xS,gfmFootnoteDefinition:yS}}}function wS(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:Vp},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(r,i,s,a){const o=s.createTracker(a);let l=o.move("[^");const c=s.enter("footnoteDefinition"),f=s.enter("label");return l+=o.move(s.safe(s.associationId(r),{before:l,after:"]"})),f(),l+=o.move("]:"),r.children&&r.children.length>0&&(o.shift(4),l+=o.move((t?`
|
|
23
|
+
`:" ")+s.indentLines(s.containerFlow(r,o.current()),t?Up:kS))),c(),l}}function kS(e,t,n){return t===0?e:Up(e,t,n)}function Up(e,t,n){return(n?"":" ")+e}const SS=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];Jp.peek=CS;function _S(){return{canContainEols:["delete"],enter:{strikethrough:NS},exit:{strikethrough:ES}}}function jS(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:SS}],handlers:{delete:Jp}}}function NS(e){this.enter({type:"delete",children:[]},e)}function ES(e){this.exit(e)}function Jp(e,t,n,r){const i=n.createTracker(r),s=n.enter("strikethrough");let a=i.move("~~");return a+=n.containerPhrasing(e,{...i.current(),before:a,after:"~"}),a+=i.move("~~"),s(),a}function CS(){return"~"}function TS(e){return e.length}function IS(e,t){const n=t||{},r=(n.align||[]).concat(),i=n.stringLength||TS,s=[],a=[],o=[],l=[];let c=0,f=-1;for(;++f<e.length;){const w=[],_=[];let b=-1;for(e[f].length>c&&(c=e[f].length);++b<e[f].length;){const N=AS(e[f][b]);if(n.alignDelimiters!==!1){const m=i(N);_[b]=m,(l[b]===void 0||m>l[b])&&(l[b]=m)}w.push(N)}a[f]=w,o[f]=_}let d=-1;if(typeof r=="object"&&"length"in r)for(;++d<c;)s[d]=Ru(r[d]);else{const w=Ru(r);for(;++d<c;)s[d]=w}d=-1;const h=[],p=[];for(;++d<c;){const w=s[d];let _="",b="";w===99?(_=":",b=":"):w===108?_=":":w===114&&(b=":");let N=n.alignDelimiters===!1?1:Math.max(1,l[d]-_.length-b.length);const m=_+"-".repeat(N)+b;n.alignDelimiters!==!1&&(N=_.length+N+b.length,N>l[d]&&(l[d]=N),p[d]=N),h[d]=m}a.splice(1,0,h),o.splice(1,0,p),f=-1;const g=[];for(;++f<a.length;){const w=a[f],_=o[f];d=-1;const b=[];for(;++d<c;){const N=w[d]||"";let m="",O="";if(n.alignDelimiters!==!1){const C=l[d]-(_[d]||0),v=s[d];v===114?m=" ".repeat(C):v===99?C%2?(m=" ".repeat(C/2+.5),O=" ".repeat(C/2-.5)):(m=" ".repeat(C/2),O=m):O=" ".repeat(C)}n.delimiterStart!==!1&&!d&&b.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&N==="")&&(n.delimiterStart!==!1||d)&&b.push(" "),n.alignDelimiters!==!1&&b.push(m),b.push(N),n.alignDelimiters!==!1&&b.push(O),n.padding!==!1&&b.push(" "),(n.delimiterEnd!==!1||d!==c-1)&&b.push("|")}g.push(n.delimiterEnd===!1?b.join("").replace(/ +$/,""):b.join(""))}return g.join(`
|
|
24
|
+
`)}function AS(e){return e==null?"":String(e)}function Ru(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 zS(e,t,n,r){const i=n.enter("blockquote"),s=n.createTracker(r);s.move("> "),s.shift(2);const a=n.indentLines(n.containerFlow(e,s.current()),OS);return i(),a}function OS(e,t,n){return">"+(n?"":" ")+e}function PS(e,t){return Mu(e,t.inConstruct,!0)&&!Mu(e,t.notInConstruct,!1)}function Mu(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 $u(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
|
|
25
|
+
`&&PS(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?"":" ";return`\\
|
|
26
|
+
`}function DS(e,t){const n=String(e);let r=n.indexOf(t),i=r,s=0,a=0;if(typeof t!="string")throw new TypeError("Expected substring");for(;r!==-1;)r===i?++s>a&&(a=s):s=1,i=r+t.length,r=n.indexOf(t,i);return a}function RS(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 MS(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 $S(e,t,n,r){const i=MS(n),s=e.value||"",a=i==="`"?"GraveAccent":"Tilde";if(RS(e,n)){const d=n.enter("codeIndented"),h=n.indentLines(s,FS);return d(),h}const o=n.createTracker(r),l=i.repeat(Math.max(DS(s,i)+1,3)),c=n.enter("codeFenced");let f=o.move(l);if(e.lang){const d=n.enter(`codeFencedLang${a}`);f+=o.move(n.safe(e.lang,{before:f,after:" ",encode:["`"],...o.current()})),d()}if(e.lang&&e.meta){const d=n.enter(`codeFencedMeta${a}`);f+=o.move(" "),f+=o.move(n.safe(e.meta,{before:f,after:`
|
|
27
|
+
`,encode:["`"],...o.current()})),d()}return f+=o.move(`
|
|
28
|
+
`),s&&(f+=o.move(s+`
|
|
29
|
+
`)),f+=o.move(l),c(),f}function FS(e,t,n){return(n?"":" ")+e}function Jo(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 LS(e,t,n,r){const i=Jo(n),s=i==='"'?"Quote":"Apostrophe",a=n.enter("definition");let o=n.enter("label");const l=n.createTracker(r);let c=l.move("[");return c+=l.move(n.safe(n.associationId(e),{before:c,after:"]",...l.current()})),c+=l.move("]: "),o(),!e.url||/[\0- \u007F]/.test(e.url)?(o=n.enter("destinationLiteral"),c+=l.move("<"),c+=l.move(n.safe(e.url,{before:c,after:">",...l.current()})),c+=l.move(">")):(o=n.enter("destinationRaw"),c+=l.move(n.safe(e.url,{before:c,after:e.title?" ":`
|
|
30
|
+
`,...l.current()}))),o(),e.title&&(o=n.enter(`title${s}`),c+=l.move(" "+i),c+=l.move(n.safe(e.title,{before:c,after:i,...l.current()})),c+=l.move(i),o()),a(),c}function BS(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 li(e){return"&#x"+e.toString(16).toUpperCase()+";"}function ls(e,t,n){const r=yr(e),i=yr(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}}Hp.peek=ZS;function Hp(e,t,n,r){const i=BS(n),s=n.enter("emphasis"),a=n.createTracker(r),o=a.move(i);let l=a.move(n.containerPhrasing(e,{after:i,before:o,...a.current()}));const c=l.charCodeAt(0),f=ls(r.before.charCodeAt(r.before.length-1),c,i);f.inside&&(l=li(c)+l.slice(1));const d=l.charCodeAt(l.length-1),h=ls(r.after.charCodeAt(0),d,i);h.inside&&(l=l.slice(0,-1)+li(d));const p=a.move(i);return s(),n.attentionEncodeSurroundingInfo={after:h.outside,before:f.outside},o+l+p}function ZS(e,t,n){return n.options.emphasis||"*"}function VS(e,t){let n=!1;return Vo(e,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return n=!0,Wa}),!!((!e.depth||e.depth<3)&&Ro(e)&&(t.options.setext||n))}function US(e,t,n,r){const i=Math.max(Math.min(6,e.depth||1),1),s=n.createTracker(r);if(VS(e,n)){const f=n.enter("headingSetext"),d=n.enter("phrasing"),h=n.containerPhrasing(e,{...s.current(),before:`
|
|
31
|
+
`,after:`
|
|
32
|
+
`});return d(),f(),h+`
|
|
33
|
+
`+(i===1?"=":"-").repeat(h.length-(Math.max(h.lastIndexOf("\r"),h.lastIndexOf(`
|
|
34
|
+
`))+1))}const a="#".repeat(i),o=n.enter("headingAtx"),l=n.enter("phrasing");s.move(a+" ");let c=n.containerPhrasing(e,{before:"# ",after:`
|
|
35
|
+
`,...s.current()});return/^[\t ]/.test(c)&&(c=li(c.charCodeAt(0))+c.slice(1)),c=c?a+" "+c:a,n.options.closeAtx&&(c+=" "+a),l(),o(),c}Wp.peek=JS;function Wp(e){return e.value||""}function JS(){return"<"}qp.peek=HS;function qp(e,t,n,r){const i=Jo(n),s=i==='"'?"Quote":"Apostrophe",a=n.enter("image");let o=n.enter("label");const l=n.createTracker(r);let c=l.move("![");return c+=l.move(n.safe(e.alt,{before:c,after:"]",...l.current()})),c+=l.move("]("),o(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(o=n.enter("destinationLiteral"),c+=l.move("<"),c+=l.move(n.safe(e.url,{before:c,after:">",...l.current()})),c+=l.move(">")):(o=n.enter("destinationRaw"),c+=l.move(n.safe(e.url,{before:c,after:e.title?" ":")",...l.current()}))),o(),e.title&&(o=n.enter(`title${s}`),c+=l.move(" "+i),c+=l.move(n.safe(e.title,{before:c,after:i,...l.current()})),c+=l.move(i),o()),c+=l.move(")"),a(),c}function HS(){return"!"}Gp.peek=WS;function Gp(e,t,n,r){const i=e.referenceType,s=n.enter("imageReference");let a=n.enter("label");const o=n.createTracker(r);let l=o.move("![");const c=n.safe(e.alt,{before:l,after:"]",...o.current()});l+=o.move(c+"]["),a();const f=n.stack;n.stack=[],a=n.enter("reference");const d=n.safe(n.associationId(e),{before:l,after:"]",...o.current()});return a(),n.stack=f,s(),i==="full"||!c||c!==d?l+=o.move(d+"]"):i==="shortcut"?l=l.slice(0,-1):l+=o.move("]"),l}function WS(){return"!"}Yp.peek=qS;function Yp(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 a=n.unsafe[s],o=n.compilePattern(a);let l;if(a.atBreak)for(;l=o.exec(r);){let c=l.index;r.charCodeAt(c)===10&&r.charCodeAt(c-1)===13&&c--,r=r.slice(0,c)+" "+r.slice(l.index+1)}}return i+r+i}function qS(){return"`"}function Kp(e,t){const n=Ro(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))}Xp.peek=GS;function Xp(e,t,n,r){const i=Jo(n),s=i==='"'?"Quote":"Apostrophe",a=n.createTracker(r);let o,l;if(Kp(e,n)){const f=n.stack;n.stack=[],o=n.enter("autolink");let d=a.move("<");return d+=a.move(n.containerPhrasing(e,{before:d,after:">",...a.current()})),d+=a.move(">"),o(),n.stack=f,d}o=n.enter("link"),l=n.enter("label");let c=a.move("[");return c+=a.move(n.containerPhrasing(e,{before:c,after:"](",...a.current()})),c+=a.move("]("),l(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(l=n.enter("destinationLiteral"),c+=a.move("<"),c+=a.move(n.safe(e.url,{before:c,after:">",...a.current()})),c+=a.move(">")):(l=n.enter("destinationRaw"),c+=a.move(n.safe(e.url,{before:c,after:e.title?" ":")",...a.current()}))),l(),e.title&&(l=n.enter(`title${s}`),c+=a.move(" "+i),c+=a.move(n.safe(e.title,{before:c,after:i,...a.current()})),c+=a.move(i),l()),c+=a.move(")"),o(),c}function GS(e,t,n){return Kp(e,n)?"<":"["}Qp.peek=YS;function Qp(e,t,n,r){const i=e.referenceType,s=n.enter("linkReference");let a=n.enter("label");const o=n.createTracker(r);let l=o.move("[");const c=n.containerPhrasing(e,{before:l,after:"]",...o.current()});l+=o.move(c+"]["),a();const f=n.stack;n.stack=[],a=n.enter("reference");const d=n.safe(n.associationId(e),{before:l,after:"]",...o.current()});return a(),n.stack=f,s(),i==="full"||!c||c!==d?l+=o.move(d+"]"):i==="shortcut"?l=l.slice(0,-1):l+=o.move("]"),l}function YS(){return"["}function Ho(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 KS(e){const t=Ho(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 XS(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 eh(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 QS(e,t,n,r){const i=n.enter("list"),s=n.bulletCurrent;let a=e.ordered?XS(n):Ho(n);const o=e.ordered?a==="."?")":".":KS(n);let l=t&&n.bulletLastUsed?a===n.bulletLastUsed:!1;if(!e.ordered){const f=e.children?e.children[0]:void 0;if((a==="*"||a==="-")&&f&&(!f.children||!f.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&&(l=!0),eh(n)===a&&f){let d=-1;for(;++d<e.children.length;){const h=e.children[d];if(h&&h.type==="listItem"&&h.children&&h.children[0]&&h.children[0].type==="thematicBreak"){l=!0;break}}}}l&&(a=o),n.bulletCurrent=a;const c=n.containerFlow(e,r);return n.bulletLastUsed=a,n.bulletCurrent=s,i(),c}function e_(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 t_(e,t,n,r){const i=e_(n);let s=n.bulletCurrent||Ho(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 a=s.length+1;(i==="tab"||i==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(a=Math.ceil(a/4)*4);const o=n.createTracker(r);o.move(s+" ".repeat(a-s.length)),o.shift(a);const l=n.enter("listItem"),c=n.indentLines(n.containerFlow(e,o.current()),f);return l(),c;function f(d,h,p){return h?(p?"":" ".repeat(a))+d:(p?s:s+" ".repeat(a-s.length))+d}}function n_(e,t,n,r){const i=n.enter("paragraph"),s=n.enter("phrasing"),a=n.containerPhrasing(e,r);return s(),i(),a}const r_=Rs(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function i_(e,t,n,r){return(e.children.some(function(a){return r_(a)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function s_(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}th.peek=a_;function th(e,t,n,r){const i=s_(n),s=n.enter("strong"),a=n.createTracker(r),o=a.move(i+i);let l=a.move(n.containerPhrasing(e,{after:i,before:o,...a.current()}));const c=l.charCodeAt(0),f=ls(r.before.charCodeAt(r.before.length-1),c,i);f.inside&&(l=li(c)+l.slice(1));const d=l.charCodeAt(l.length-1),h=ls(r.after.charCodeAt(0),d,i);h.inside&&(l=l.slice(0,-1)+li(d));const p=a.move(i+i);return s(),n.attentionEncodeSurroundingInfo={after:h.outside,before:f.outside},o+l+p}function a_(e,t,n){return n.options.strong||"*"}function o_(e,t,n,r){return n.safe(e.value,r)}function l_(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 u_(e,t,n){const r=(eh(n)+(n.options.ruleSpaces?" ":"")).repeat(l_(n));return n.options.ruleSpaces?r.slice(0,-1):r}const nh={blockquote:zS,break:$u,code:$S,definition:LS,emphasis:Hp,hardBreak:$u,heading:US,html:Wp,image:qp,imageReference:Gp,inlineCode:Yp,link:Xp,linkReference:Qp,list:QS,listItem:t_,paragraph:n_,root:i_,strong:th,text:o_,thematicBreak:u_};function c_(){return{enter:{table:d_,tableData:Fu,tableHeader:Fu,tableRow:p_},exit:{codeText:h_,table:f_,tableData:xa,tableHeader:xa,tableRow:xa}}}function d_(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 f_(e){this.exit(e),this.data.inTable=void 0}function p_(e){this.enter({type:"tableRow",children:[]},e)}function xa(e){this.exit(e)}function Fu(e){this.enter({type:"tableCell",children:[]},e)}function h_(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,m_));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function m_(e,t){return t==="|"?t:e}function g_(e){const t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,s=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
|
|
36
|
+
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:h,table:a,tableCell:l,tableRow:o}};function a(p,g,w,_){return c(f(p,w,_),p.align)}function o(p,g,w,_){const b=d(p,w,_),N=c([b]);return N.slice(0,N.indexOf(`
|
|
37
|
+
`))}function l(p,g,w,_){const b=w.enter("tableCell"),N=w.enter("phrasing"),m=w.containerPhrasing(p,{..._,before:s,after:s});return N(),b(),m}function c(p,g){return IS(p,{align:g,alignDelimiters:r,padding:n,stringLength:i})}function f(p,g,w){const _=p.children;let b=-1;const N=[],m=g.enter("table");for(;++b<_.length;)N[b]=d(_[b],g,w);return m(),N}function d(p,g,w){const _=p.children;let b=-1;const N=[],m=g.enter("tableRow");for(;++b<_.length;)N[b]=l(_[b],p,g,w);return m(),N}function h(p,g,w){let _=nh.inlineCode(p,g,w);return w.stack.includes("tableCell")&&(_=_.replace(/\|/g,"\\$&")),_}}function x_(){return{exit:{taskListCheckValueChecked:Lu,taskListCheckValueUnchecked:Lu,paragraph:b_}}}function y_(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:v_}}}function Lu(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function b_(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,a;for(;++s<i.length;){const o=i[s];if(o.type==="paragraph"){a=o;break}}a===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 v_(e,t,n,r){const i=e.children[0],s=typeof e.checked=="boolean"&&i&&i.type==="paragraph",a="["+(e.checked?"x":" ")+"] ",o=n.createTracker(r);s&&o.move(a);let l=nh.listItem(e,t,n,{...r,...o.current()});return s&&(l=l.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,c)),l;function c(f){return f+a}}function w_(){return[Q1(),vS(),_S(),c_(),x_()]}function k_(e){return{extensions:[eS(),wS(e),jS(),g_(e),y_()]}}const S_={tokenize:T_,partial:!0},rh={tokenize:I_,partial:!0},ih={tokenize:A_,partial:!0},sh={tokenize:z_,partial:!0},__={tokenize:O_,partial:!0},ah={name:"wwwAutolink",tokenize:E_,previous:lh},oh={name:"protocolAutolink",tokenize:C_,previous:uh},ln={name:"emailAutolink",tokenize:N_,previous:ch},Qt={};function j_(){return{text:Qt}}let Nn=48;for(;Nn<123;)Qt[Nn]=ln,Nn++,Nn===58?Nn=65:Nn===91&&(Nn=97);Qt[43]=ln;Qt[45]=ln;Qt[46]=ln;Qt[95]=ln;Qt[72]=[ln,oh];Qt[104]=[ln,oh];Qt[87]=[ln,ah];Qt[119]=[ln,ah];function N_(e,t,n){const r=this;let i,s;return a;function a(d){return!Ka(d)||!ch.call(r,r.previous)||Wo(r.events)?n(d):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),o(d))}function o(d){return Ka(d)?(e.consume(d),o):d===64?(e.consume(d),l):n(d)}function l(d){return d===46?e.check(__,f,c)(d):d===45||d===95||ot(d)?(s=!0,e.consume(d),l):f(d)}function c(d){return e.consume(d),i=!0,l}function f(d){return s&&i&&pt(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(d)):n(d)}}function E_(e,t,n){const r=this;return i;function i(a){return a!==87&&a!==119||!lh.call(r,r.previous)||Wo(r.events)?n(a):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(S_,e.attempt(rh,e.attempt(ih,s),n),n)(a))}function s(a){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(a)}}function C_(e,t,n){const r=this;let i="",s=!1;return a;function a(d){return(d===72||d===104)&&uh.call(r,r.previous)&&!Wo(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),i+=String.fromCodePoint(d),e.consume(d),o):n(d)}function o(d){if(pt(d)&&i.length<5)return i+=String.fromCodePoint(d),e.consume(d),o;if(d===58){const h=i.toLowerCase();if(h==="http"||h==="https")return e.consume(d),l}return n(d)}function l(d){return d===47?(e.consume(d),s?c:(s=!0,l)):n(d)}function c(d){return d===null||ss(d)||Fe(d)||Rn(d)||Os(d)?n(d):e.attempt(rh,e.attempt(ih,f),n)(d)}function f(d){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(d)}}function T_(e,t,n){let r=0;return i;function i(a){return(a===87||a===119)&&r<3?(r++,e.consume(a),i):a===46&&r===3?(e.consume(a),s):n(a)}function s(a){return a===null?n(a):t(a)}}function I_(e,t,n){let r,i,s;return a;function a(c){return c===46||c===95?e.check(sh,l,o)(c):c===null||Fe(c)||Rn(c)||c!==45&&Os(c)?l(c):(s=!0,e.consume(c),a)}function o(c){return c===95?r=!0:(i=r,r=void 0),e.consume(c),a}function l(c){return i||r||!s?n(c):t(c)}}function A_(e,t){let n=0,r=0;return i;function i(a){return a===40?(n++,e.consume(a),i):a===41&&r<n?s(a):a===33||a===34||a===38||a===39||a===41||a===42||a===44||a===46||a===58||a===59||a===60||a===63||a===93||a===95||a===126?e.check(sh,t,s)(a):a===null||Fe(a)||Rn(a)?t(a):(e.consume(a),i)}function s(a){return a===41&&r++,e.consume(a),i}}function z_(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),s):o===93?(e.consume(o),i):o===60||o===null||Fe(o)||Rn(o)?t(o):n(o)}function i(o){return o===null||o===40||o===91||Fe(o)||Rn(o)?t(o):r(o)}function s(o){return pt(o)?a(o):n(o)}function a(o){return o===59?(e.consume(o),r):pt(o)?(e.consume(o),a):n(o)}}function O_(e,t,n){return r;function r(s){return e.consume(s),i}function i(s){return ot(s)?n(s):t(s)}}function lh(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Fe(e)}function uh(e){return!pt(e)}function ch(e){return!(e===47||Ka(e))}function Ka(e){return e===43||e===45||e===46||e===95||ot(e)}function Wo(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 P_={tokenize:Z_,partial:!0};function D_(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:F_,continuation:{tokenize:L_},exit:B_}},text:{91:{name:"gfmFootnoteCall",tokenize:$_},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:R_,resolveTo:M_}}}}function R_(e,t,n){const r=this;let i=r.events.length;const s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a;for(;i--;){const l=r.events[i][1];if(l.type==="labelImage"){a=l;break}if(l.type==="gfmFootnoteCall"||l.type==="labelLink"||l.type==="label"||l.type==="image"||l.type==="link")break}return o;function o(l){if(!a||!a._balanced)return n(l);const c=Zt(r.sliceSerialize({start:a.end,end:r.now()}));return c.codePointAt(0)!==94||!s.includes(c.slice(1))?n(l):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(l),e.exit("gfmFootnoteCallLabelMarker"),t(l))}}function M_(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)},a={type:"chunkString",contentType:"string",start:Object.assign({},s.start),end:Object.assign({},s.end)},o=[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",a,t],["exit",a,t],["exit",s,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...o),e}function $_(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s=0,a;return o;function o(d){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),l}function l(d){return d!==94?n(d):(e.enter("gfmFootnoteCallMarker"),e.consume(d),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",c)}function c(d){if(s>999||d===93&&!a||d===null||d===91||Fe(d))return n(d);if(d===93){e.exit("chunkString");const h=e.exit("gfmFootnoteCallString");return i.includes(Zt(r.sliceSerialize(h)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(d)}return Fe(d)||(a=!0),s++,e.consume(d),d===92?f:c}function f(d){return d===91||d===92||d===93?(e.consume(d),s++,c):c(d)}}function F_(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s,a=0,o;return l;function l(g){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(g),e.exit("gfmFootnoteDefinitionLabelMarker"),c}function c(g){return g===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(g),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",f):n(g)}function f(g){if(a>999||g===93&&!o||g===null||g===91||Fe(g))return n(g);if(g===93){e.exit("chunkString");const w=e.exit("gfmFootnoteDefinitionLabelString");return s=Zt(r.sliceSerialize(w)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(g),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),h}return Fe(g)||(o=!0),a++,e.consume(g),g===92?d:f}function d(g){return g===91||g===92||g===93?(e.consume(g),a++,f):f(g)}function h(g){return g===58?(e.enter("definitionMarker"),e.consume(g),e.exit("definitionMarker"),i.includes(s)||i.push(s),ze(e,p,"gfmFootnoteDefinitionWhitespace")):n(g)}function p(g){return t(g)}}function L_(e,t,n){return e.check(vi,t,e.attempt(P_,t,n))}function B_(e){e.exit("gfmFootnoteDefinition")}function Z_(e,t,n){const r=this;return ze(e,i,"gfmFootnoteDefinitionIndent",5);function i(s){const a=r.events[r.events.length-1];return a&&a[1].type==="gfmFootnoteDefinitionIndent"&&a[2].sliceSerialize(a[1],!0).length===4?t(s):n(s)}}function V_(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(a,o){let l=-1;for(;++l<a.length;)if(a[l][0]==="enter"&&a[l][1].type==="strikethroughSequenceTemporary"&&a[l][1]._close){let c=l;for(;c--;)if(a[c][0]==="exit"&&a[c][1].type==="strikethroughSequenceTemporary"&&a[c][1]._open&&a[l][1].end.offset-a[l][1].start.offset===a[c][1].end.offset-a[c][1].start.offset){a[l][1].type="strikethroughSequence",a[c][1].type="strikethroughSequence";const f={type:"strikethrough",start:Object.assign({},a[c][1].start),end:Object.assign({},a[l][1].end)},d={type:"strikethroughText",start:Object.assign({},a[c][1].end),end:Object.assign({},a[l][1].start)},h=[["enter",f,o],["enter",a[c][1],o],["exit",a[c][1],o],["enter",d,o]],p=o.parser.constructs.insideSpan.null;p&&Tt(h,h.length,0,Ps(p,a.slice(c+1,l),o)),Tt(h,h.length,0,[["exit",d,o],["enter",a[l][1],o],["exit",a[l][1],o],["exit",f,o]]),Tt(a,c-1,l-c+3,h),l=c+h.length-2;break}}for(l=-1;++l<a.length;)a[l][1].type==="strikethroughSequenceTemporary"&&(a[l][1].type="data");return a}function s(a,o,l){const c=this.previous,f=this.events;let d=0;return h;function h(g){return c===126&&f[f.length-1][1].type!=="characterEscape"?l(g):(a.enter("strikethroughSequenceTemporary"),p(g))}function p(g){const w=yr(c);if(g===126)return d>1?l(g):(a.consume(g),d++,p);if(d<2&&!n)return l(g);const _=a.exit("strikethroughSequenceTemporary"),b=yr(g);return _._open=!b||b===2&&!!w,_._close=!w||w===2&&!!b,o(g)}}}class U_{constructor(){this.map=[]}add(t,n,r){J_(this,t,n,r)}consume(t){if(this.map.sort(function(s,a){return s[0]-a[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 J_(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 H_(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 W_(){return{flow:{null:{name:"table",tokenize:q_,resolveAll:G_}}}}function q_(e,t,n){const r=this;let i=0,s=0,a;return o;function o(j){let I=r.events.length-1;for(;I>-1;){const A=r.events[I][1].type;if(A==="lineEnding"||A==="linePrefix")I--;else break}const T=I>-1?r.events[I][1].type:null,P=T==="tableHead"||T==="tableRow"?v:l;return P===v&&r.parser.lazy[r.now().line]?n(j):P(j)}function l(j){return e.enter("tableHead"),e.enter("tableRow"),c(j)}function c(j){return j===124||(a=!0,s+=1),f(j)}function f(j){return j===null?n(j):ye(j)?s>1?(s=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(j),e.exit("lineEnding"),p):n(j):Ce(j)?ze(e,f,"whitespace")(j):(s+=1,a&&(a=!1,i+=1),j===124?(e.enter("tableCellDivider"),e.consume(j),e.exit("tableCellDivider"),a=!0,f):(e.enter("data"),d(j)))}function d(j){return j===null||j===124||Fe(j)?(e.exit("data"),f(j)):(e.consume(j),j===92?h:d)}function h(j){return j===92||j===124?(e.consume(j),d):d(j)}function p(j){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(j):(e.enter("tableDelimiterRow"),a=!1,Ce(j)?ze(e,g,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(j):g(j))}function g(j){return j===45||j===58?_(j):j===124?(a=!0,e.enter("tableCellDivider"),e.consume(j),e.exit("tableCellDivider"),w):C(j)}function w(j){return Ce(j)?ze(e,_,"whitespace")(j):_(j)}function _(j){return j===58?(s+=1,a=!0,e.enter("tableDelimiterMarker"),e.consume(j),e.exit("tableDelimiterMarker"),b):j===45?(s+=1,b(j)):j===null||ye(j)?O(j):C(j)}function b(j){return j===45?(e.enter("tableDelimiterFiller"),N(j)):C(j)}function N(j){return j===45?(e.consume(j),N):j===58?(a=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(j),e.exit("tableDelimiterMarker"),m):(e.exit("tableDelimiterFiller"),m(j))}function m(j){return Ce(j)?ze(e,O,"whitespace")(j):O(j)}function O(j){return j===124?g(j):j===null||ye(j)?!a||i!==s?C(j):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(j)):C(j)}function C(j){return n(j)}function v(j){return e.enter("tableRow"),k(j)}function k(j){return j===124?(e.enter("tableCellDivider"),e.consume(j),e.exit("tableCellDivider"),k):j===null||ye(j)?(e.exit("tableRow"),t(j)):Ce(j)?ze(e,k,"whitespace")(j):(e.enter("data"),$(j))}function $(j){return j===null||j===124||Fe(j)?(e.exit("data"),k(j)):(e.consume(j),j===92?H:$)}function H(j){return j===92||j===124?(e.consume(j),$):$(j)}}function G_(e,t){let n=-1,r=!0,i=0,s=[0,0,0,0],a=[0,0,0,0],o=!1,l=0,c,f,d;const h=new U_;for(;++n<e.length;){const p=e[n],g=p[1];p[0]==="enter"?g.type==="tableHead"?(o=!1,l!==0&&(Bu(h,t,l,c,f),f=void 0,l=0),c={type:"table",start:Object.assign({},g.start),end:Object.assign({},g.end)},h.add(n,0,[["enter",c,t]])):g.type==="tableRow"||g.type==="tableDelimiterRow"?(r=!0,d=void 0,s=[0,0,0,0],a=[0,n+1,0,0],o&&(o=!1,f={type:"tableBody",start:Object.assign({},g.start),end:Object.assign({},g.end)},h.add(n,0,[["enter",f,t]])),i=g.type==="tableDelimiterRow"?2:f?3:1):i&&(g.type==="data"||g.type==="tableDelimiterMarker"||g.type==="tableDelimiterFiller")?(r=!1,a[2]===0&&(s[1]!==0&&(a[0]=a[1],d=zi(h,t,s,i,void 0,d),s=[0,0,0,0]),a[2]=n)):g.type==="tableCellDivider"&&(r?r=!1:(s[1]!==0&&(a[0]=a[1],d=zi(h,t,s,i,void 0,d)),s=a,a=[s[1],n,0,0])):g.type==="tableHead"?(o=!0,l=n):g.type==="tableRow"||g.type==="tableDelimiterRow"?(l=n,s[1]!==0?(a[0]=a[1],d=zi(h,t,s,i,n,d)):a[1]!==0&&(d=zi(h,t,a,i,n,d)),i=0):i&&(g.type==="data"||g.type==="tableDelimiterMarker"||g.type==="tableDelimiterFiller")&&(a[3]=n)}for(l!==0&&Bu(h,t,l,c,f),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=H_(t.events,n))}return e}function zi(e,t,n,r,i,s){const a=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",o="tableContent";n[0]!==0&&(s.end=Object.assign({},Xn(t.events,n[0])),e.add(n[0],0,[["exit",s,t]]));const l=Xn(t.events,n[1]);if(s={type:a,start:Object.assign({},l),end:Object.assign({},l)},e.add(n[1],0,[["enter",s,t]]),n[2]!==0){const c=Xn(t.events,n[2]),f=Xn(t.events,n[3]),d={type:o,start:Object.assign({},c),end:Object.assign({},f)};if(e.add(n[2],0,[["enter",d,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 g=n[2]+1,w=n[3]-n[2]-1;e.add(g,w,[])}}e.add(n[3]+1,0,[["exit",d,t]])}return i!==void 0&&(s.end=Object.assign({},Xn(t.events,i)),e.add(i,0,[["exit",s,t]]),s=void 0),s}function Bu(e,t,n,r,i){const s=[],a=Xn(t.events,n);i&&(i.end=Object.assign({},a),s.push(["exit",i,t])),r.end=Object.assign({},a),s.push(["exit",r,t]),e.add(n+1,0,s)}function Xn(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const Y_={name:"tasklistCheck",tokenize:X_};function K_(){return{text:{91:Y_}}}function X_(e,t,n){const r=this;return i;function i(l){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(l):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),s)}function s(l){return Fe(l)?(e.enter("taskListCheckValueUnchecked"),e.consume(l),e.exit("taskListCheckValueUnchecked"),a):l===88||l===120?(e.enter("taskListCheckValueChecked"),e.consume(l),e.exit("taskListCheckValueChecked"),a):n(l)}function a(l){return l===93?(e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),o):n(l)}function o(l){return ye(l)?t(l):Ce(l)?e.check({tokenize:Q_},t,n)(l):n(l)}}function Q_(e,t,n){return ze(e,r,"whitespace");function r(i){return i===null?n(i):t(i)}}function ej(e){return wp([j_(),D_(),V_(e),W_(),K_()])}const tj={};function nj(e){const t=this,n=e||tj,r=t.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),s=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),a=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(ej(n)),s.push(w_()),a.push(k_(n))}var dh="vercel.ai.error",rj=Symbol.for(dh),Zu,Vu,Xt=class fh extends(Vu=Error,Zu=rj,Vu){constructor({name:t,message:n,cause:r}){super(n),this[Zu]=!0,this.name=t,this.cause=r}static isInstance(t){return fh.hasMarker(t,dh)}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 ph(e){return e==null?"unknown error":typeof e=="string"?e:e instanceof Error?e.message:JSON.stringify(e)}var hh="AI_InvalidArgumentError",mh=`vercel.ai.error.${hh}`,ij=Symbol.for(mh),Uu,Ju,sj=class extends(Ju=Xt,Uu=ij,Ju){constructor({message:e,cause:t,argument:n}){super({name:hh,message:e,cause:t}),this[Uu]=!0,this.argument=n}static isInstance(e){return Xt.hasMarker(e,mh)}},gh="AI_JSONParseError",xh=`vercel.ai.error.${gh}`,aj=Symbol.for(xh),Hu,Wu,qu=class extends(Wu=Xt,Hu=aj,Wu){constructor({text:e,cause:t}){super({name:gh,message:`JSON parsing failed: Text: ${e}.
|
|
38
|
+
Error message: ${ph(t)}`,cause:t}),this[Hu]=!0,this.text=e}static isInstance(e){return Xt.hasMarker(e,xh)}},yh="AI_TypeValidationError",bh=`vercel.ai.error.${yh}`,oj=Symbol.for(bh),Gu,Yu,br=class Xa extends(Yu=Xt,Gu=oj,Yu){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:yh,message:`${i}: Value: ${JSON.stringify(t)}.
|
|
39
|
+
Error message: ${ph(n)}`,cause:n}),this[Gu]=!0,this.value=t,this.context=r}static isInstance(t){return Xt.hasMarker(t,bh)}static wrap({value:t,cause:n,context:r}){var i,s,a;return Xa.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)&&((a=n.context)==null?void 0:a.entityId)===(r==null?void 0:r.entityId)?n:new Xa({value:t,cause:n,context:r})}};function W(e,t,n){function r(o,l){if(o._zod||Object.defineProperty(o,"_zod",{value:{def:l,constr:a,traits:new Set},enumerable:!1}),o._zod.traits.has(e))return;o._zod.traits.add(e),t(o,l);const c=a.prototype,f=Object.keys(c);for(let d=0;d<f.length;d++){const h=f[d];h in o||(o[h]=c[h].bind(o))}}const i=(n==null?void 0:n.Parent)??Object;class s extends i{}Object.defineProperty(s,"name",{value:e});function a(o){var l;const c=n!=null&&n.Parent?new s:this;r(c,o),(l=c._zod).deferred??(l.deferred=[]);for(const f of c._zod.deferred)f();return c}return Object.defineProperty(a,"init",{value:r}),Object.defineProperty(a,Symbol.hasInstance,{value:o=>{var l,c;return n!=null&&n.Parent&&o instanceof n.Parent?!0:(c=(l=o==null?void 0:o._zod)==null?void 0:l.traits)==null?void 0:c.has(e)}}),Object.defineProperty(a,"name",{value:e}),a}class dr extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class vh extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const wh={};function vn(e){return wh}function kh(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 Qa(e,t){return typeof t=="bigint"?t.toString():t}function $s(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function qo(e){return e==null}function Go(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function lj(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 l=r.match(/\d?e-(\d?)/);l!=null&&l[1]&&(i=Number.parseInt(l[1]))}const s=n>i?n:i,a=Number.parseInt(e.toFixed(s).replace(".","")),o=Number.parseInt(t.toFixed(s).replace(".",""));return a%o/10**s}const Ku=Symbol("evaluating");function Ae(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Ku)return r===void 0&&(r=Ku,r=n()),r},set(i){Object.defineProperty(e,t,{value:i})},configurable:!0})}function Fn(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Sn(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function Xu(e){return JSON.stringify(e)}function uj(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Sh="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function ui(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const cj=$s(()=>{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 vr(e){if(ui(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(ui(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function _h(e){return vr(e)?{...e}:Array.isArray(e)?[...e]:e}const dj=new Set(["string","number","symbol"]);function wr(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function _n(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 pe(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 fj(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const pj={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 hj(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=Sn(e._zod.def,{get shape(){const a={};for(const o in t){if(!(o in n.shape))throw new Error(`Unrecognized key: "${o}"`);t[o]&&(a[o]=n.shape[o])}return Fn(this,"shape",a),a},checks:[]});return _n(e,s)}function mj(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=Sn(e._zod.def,{get shape(){const a={...e._zod.def.shape};for(const o in t){if(!(o in n.shape))throw new Error(`Unrecognized key: "${o}"`);t[o]&&delete a[o]}return Fn(this,"shape",a),a},checks:[]});return _n(e,s)}function gj(e,t){if(!vr(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 a in t)if(Object.getOwnPropertyDescriptor(s,a)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const i=Sn(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t};return Fn(this,"shape",s),s}});return _n(e,i)}function xj(e,t){if(!vr(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=Sn(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return Fn(this,"shape",r),r}});return _n(e,n)}function yj(e,t){const n=Sn(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return Fn(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:[]});return _n(e,n)}function bj(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 a=Sn(t._zod.def,{get shape(){const o=t._zod.def.shape,l={...o};if(n)for(const c in n){if(!(c in o))throw new Error(`Unrecognized key: "${c}"`);n[c]&&(l[c]=e?new e({type:"optional",innerType:o[c]}):o[c])}else for(const c in o)l[c]=e?new e({type:"optional",innerType:o[c]}):o[c];return Fn(this,"shape",l),l},checks:[]});return _n(t,a)}function vj(e,t,n){const r=Sn(t._zod.def,{get shape(){const i=t._zod.def.shape,s={...i};if(n)for(const a in n){if(!(a in s))throw new Error(`Unrecognized key: "${a}"`);n[a]&&(s[a]=new e({type:"nonoptional",innerType:i[a]}))}else for(const a in i)s[a]=new e({type:"nonoptional",innerType:i[a]});return Fn(this,"shape",s),s}});return _n(t,r)}function nr(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 rr(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function Oi(e){return typeof e=="string"?e:e==null?void 0:e.message}function wn(e,t,n){var i,s,a,o,l,c;const r={...e,path:e.path??[]};if(!e.message){const f=Oi((a=(s=(i=e.inst)==null?void 0:i._zod.def)==null?void 0:s.error)==null?void 0:a.call(s,e))??Oi((o=t==null?void 0:t.error)==null?void 0:o.call(t,e))??Oi((l=n.customError)==null?void 0:l.call(n,e))??Oi((c=n.localeError)==null?void 0:c.call(n,e))??"Invalid input";r.message=f}return delete r.inst,delete r.continue,t!=null&&t.reportInput||delete r.input,r}function Yo(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function ci(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}const jh=(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,Qa,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Nh=W("$ZodError",jh),Eh=W("$ZodError",jh,{Parent:Error});function wj(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 kj(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(a=>r({issues:a}));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 a=n,o=0;for(;o<s.path.length;){const l=s.path[o];o===s.path.length-1?(a[l]=a[l]||{_errors:[]},a[l]._errors.push(t(s))):a[l]=a[l]||{_errors:[]},a=a[l],o++}}};return r(e),n}const Ko=e=>(t,n,r,i)=>{const s=r?Object.assign(r,{async:!1}):{async:!1},a=t._zod.run({value:n,issues:[]},s);if(a instanceof Promise)throw new dr;if(a.issues.length){const o=new((i==null?void 0:i.Err)??e)(a.issues.map(l=>wn(l,s,vn())));throw Sh(o,i==null?void 0:i.callee),o}return a.value},Xo=e=>async(t,n,r,i)=>{const s=r?Object.assign(r,{async:!0}):{async:!0};let a=t._zod.run({value:n,issues:[]},s);if(a instanceof Promise&&(a=await a),a.issues.length){const o=new((i==null?void 0:i.Err)??e)(a.issues.map(l=>wn(l,s,vn())));throw Sh(o,i==null?void 0:i.callee),o}return a.value},Fs=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 dr;return s.issues.length?{success:!1,error:new(e??Nh)(s.issues.map(a=>wn(a,i,vn())))}:{success:!0,data:s.value}},Sj=Fs(Eh),Ls=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(a=>wn(a,i,vn())))}:{success:!0,data:s.value}},_j=Ls(Eh),jj=e=>(t,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Ko(e)(t,n,i)},Nj=e=>(t,n,r)=>Ko(e)(t,n,r),Ej=e=>async(t,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Xo(e)(t,n,i)},Cj=e=>async(t,n,r)=>Xo(e)(t,n,r),Tj=e=>(t,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Fs(e)(t,n,i)},Ij=e=>(t,n,r)=>Fs(e)(t,n,r),Aj=e=>async(t,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Ls(e)(t,n,i)},zj=e=>async(t,n,r)=>Ls(e)(t,n,r),Oj=/^[cC][^\s-]{8,}$/,Pj=/^[0-9a-z]+$/,Dj=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Rj=/^[0-9a-vA-V]{20}$/,Mj=/^[A-Za-z0-9]{27}$/,$j=/^[a-zA-Z0-9_-]{21}$/,Fj=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Lj=/^([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})$/,Qu=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)$/,Bj=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Zj="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Vj(){return new RegExp(Zj,"u")}const Uj=/^(?:(?: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])$/,Jj=/^(([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}|:))$/,Hj=/^((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])$/,Wj=/^(([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])$/,qj=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Ch=/^[A-Za-z0-9_-]*$/,Gj=/^\+[1-9]\d{6,14}$/,Th="(?:(?:\\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])))",Yj=new RegExp(`^${Th}$`);function Ih(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 Kj(e){return new RegExp(`^${Ih(e)}$`)}function Xj(e){const t=Ih({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(`^${Th}T(?:${r})$`)}const Qj=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}$`)},eN=/^-?\d+$/,Ah=/^-?\d+(?:\.\d+)?$/,tN=/^(?:true|false)$/i,nN=/^null$/i,rN=/^[^A-Z]*$/,iN=/^[^a-z]*$/,_t=W("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),zh={number:"number",bigint:"bigint",object:"date"},Oh=W("$ZodCheckLessThan",(e,t)=>{_t.init(e,t);const n=zh[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})}}),Ph=W("$ZodCheckGreaterThan",(e,t)=>{_t.init(e,t);const n=zh[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})}}),sN=W("$ZodCheckMultipleOf",(e,t)=>{_t.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):lj(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})}}),aN=W("$ZodCheckNumberFormat",(e,t)=>{var a;_t.init(e,t),t.format=t.format||"float64";const n=(a=t.format)==null?void 0:a.includes("int"),r=n?"int":"number",[i,s]=pj[t.format];e._zod.onattach.push(o=>{const l=o._zod.bag;l.format=t.format,l.minimum=i,l.maximum=s,n&&(l.pattern=eN)}),e._zod.check=o=>{const l=o.value;if(n){if(!Number.isInteger(l)){o.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:l,inst:e});return}if(!Number.isSafeInteger(l)){l>0?o.issues.push({input:l,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}):o.issues.push({input:l,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}}l<i&&o.issues.push({origin:"number",input:l,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort}),l>s&&o.issues.push({origin:"number",input:l,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}}),oN=W("$ZodCheckMaxLength",(e,t)=>{var n;_t.init(e,t),(n=e._zod.def).when??(n.when=r=>{const i=r.value;return!qo(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 a=Yo(i);r.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),lN=W("$ZodCheckMinLength",(e,t)=>{var n;_t.init(e,t),(n=e._zod.def).when??(n.when=r=>{const i=r.value;return!qo(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 a=Yo(i);r.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),uN=W("$ZodCheckLengthEquals",(e,t)=>{var n;_t.init(e,t),(n=e._zod.def).when??(n.when=r=>{const i=r.value;return!qo(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 a=Yo(i),o=s>t.length;r.issues.push({origin:a,...o?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),Bs=W("$ZodCheckStringFormat",(e,t)=>{var n,r;_t.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=()=>{})}),cN=W("$ZodCheckRegex",(e,t)=>{Bs.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})}}),dN=W("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=rN),Bs.init(e,t)}),fN=W("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=iN),Bs.init(e,t)}),pN=W("$ZodCheckIncludes",(e,t)=>{_t.init(e,t);const n=wr(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})}}),hN=W("$ZodCheckStartsWith",(e,t)=>{_t.init(e,t);const n=new RegExp(`^${wr(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})}}),mN=W("$ZodCheckEndsWith",(e,t)=>{_t.init(e,t);const n=new RegExp(`.*${wr(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})}}),gN=W("$ZodCheckOverwrite",(e,t)=>{_t.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class xN{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(`
|
|
40
|
+
`).filter(a=>a),i=Math.min(...r.map(a=>a.length-a.trimStart().length)),s=r.map(a=>a.slice(i)).map(a=>" ".repeat(this.indent*2)+a);for(const a of s)this.content.push(a)}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(`
|
|
41
|
+
`))}}const yN={major:4,minor:3,patch:6},Je=W("$ZodType",(e,t)=>{var i;var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=yN;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const s of r)for(const a of s._zod.onattach)a(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=(o,l,c)=>{let f=nr(o),d;for(const h of l){if(h._zod.def.when){if(!h._zod.def.when(o))continue}else if(f)continue;const p=o.issues.length,g=h._zod.check(o);if(g instanceof Promise&&(c==null?void 0:c.async)===!1)throw new dr;if(d||g instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await g,o.issues.length!==p&&(f||(f=nr(o,p)))});else{if(o.issues.length===p)continue;f||(f=nr(o,p))}}return d?d.then(()=>o):o},a=(o,l,c)=>{if(nr(o))return o.aborted=!0,o;const f=s(l,r,c);if(f instanceof Promise){if(c.async===!1)throw new dr;return f.then(d=>e._zod.parse(d,c))}return e._zod.parse(f,c)};e._zod.run=(o,l)=>{if(l.skipChecks)return e._zod.parse(o,l);if(l.direction==="backward"){const f=e._zod.parse({value:o.value,issues:[]},{...l,skipChecks:!0});return f instanceof Promise?f.then(d=>a(d,o,l)):a(f,o,l)}const c=e._zod.parse(o,l);if(c instanceof Promise){if(l.async===!1)throw new dr;return c.then(f=>s(f,r,l))}return s(c,r,l)}}Ae(e,"~standard",()=>({validate:s=>{var a;try{const o=Sj(e,s);return o.success?{value:o.data}:{issues:(a=o.error)==null?void 0:a.issues}}catch{return _j(e,s).then(l=>{var c;return l.success?{value:l.data}:{issues:(c=l.error)==null?void 0:c.issues}})}},vendor:"zod",version:1}))}),Qo=W("$ZodString",(e,t)=>{var n;Je.init(e,t),e._zod.pattern=[...((n=e==null?void 0:e._zod.bag)==null?void 0:n.patterns)??[]].pop()??Qj(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}}),qe=W("$ZodStringFormat",(e,t)=>{Bs.init(e,t),Qo.init(e,t)}),bN=W("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Lj),qe.init(e,t)}),vN=W("$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=Qu(r))}else t.pattern??(t.pattern=Qu());qe.init(e,t)}),wN=W("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Bj),qe.init(e,t)}),kN=W("$ZodURL",(e,t)=>{qe.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})}}}),SN=W("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Vj()),qe.init(e,t)}),_N=W("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=$j),qe.init(e,t)}),jN=W("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Oj),qe.init(e,t)}),NN=W("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Pj),qe.init(e,t)}),EN=W("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Dj),qe.init(e,t)}),CN=W("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Rj),qe.init(e,t)}),TN=W("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Mj),qe.init(e,t)}),IN=W("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Xj(t)),qe.init(e,t)}),AN=W("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Yj),qe.init(e,t)}),zN=W("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Kj(t)),qe.init(e,t)}),ON=W("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Fj),qe.init(e,t)}),PN=W("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Uj),qe.init(e,t),e._zod.bag.format="ipv4"}),DN=W("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Jj),qe.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})}}}),RN=W("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Hj),qe.init(e,t)}),MN=W("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Wj),qe.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 a=Number(s);if(`${a}`!==s)throw new Error;if(a<0||a>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 Dh(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const $N=W("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=qj),qe.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{Dh(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function FN(e){if(!Ch.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return Dh(n)}const LN=W("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Ch),qe.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{FN(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),BN=W("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Gj),qe.init(e,t)});function ZN(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 VN=W("$ZodJWT",(e,t)=>{qe.init(e,t),e._zod.check=n=>{ZN(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),Rh=W("$ZodNumber",(e,t)=>{Je.init(e,t),e._zod.pattern=e._zod.bag.pattern??Ah,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}}),UN=W("$ZodNumberFormat",(e,t)=>{aN.init(e,t),Rh.init(e,t)}),JN=W("$ZodBoolean",(e,t)=>{Je.init(e,t),e._zod.pattern=tN,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}}),HN=W("$ZodNull",(e,t)=>{Je.init(e,t),e._zod.pattern=nN,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}}),WN=W("$ZodUnknown",(e,t)=>{Je.init(e,t),e._zod.parse=n=>n}),qN=W("$ZodNever",(e,t)=>{Je.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function ec(e,t,n){e.issues.length&&t.issues.push(...rr(n,e.issues)),t.value[n]=e.value}const GN=W("$ZodArray",(e,t)=>{Je.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 a=0;a<i.length;a++){const o=i[a],l=t.element._zod.run({value:o,issues:[]},r);l instanceof Promise?s.push(l.then(c=>ec(c,n,a))):ec(l,n,a)}return s.length?Promise.all(s).then(()=>n):n}});function us(e,t,n,r,i){if(e.issues.length){if(i&&!(n in r))return;t.issues.push(...rr(n,e.issues))}e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function Mh(e){var r,i,s,a;const t=Object.keys(e.shape);for(const o of t)if(!((a=(s=(i=(r=e.shape)==null?void 0:r[o])==null?void 0:i._zod)==null?void 0:s.traits)!=null&&a.has("$ZodType")))throw new Error(`Invalid element at key "${o}": expected a Zod schema`);const n=fj(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function $h(e,t,n,r,i,s){const a=[],o=i.keySet,l=i.catchall._zod,c=l.def.type,f=l.optout==="optional";for(const d in t){if(o.has(d))continue;if(c==="never"){a.push(d);continue}const h=l.run({value:t[d],issues:[]},r);h instanceof Promise?e.push(h.then(p=>us(p,n,d,t,f))):us(h,n,d,t,f)}return a.length&&n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:s}),e.length?Promise.all(e).then(()=>n):n}const YN=W("$ZodObject",(e,t)=>{Je.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape");if(!(n!=null&&n.get)){const o=t.shape;Object.defineProperty(t,"shape",{get:()=>{const l={...o};return Object.defineProperty(t,"shape",{value:l}),l}})}const r=$s(()=>Mh(t));Ae(e._zod,"propValues",()=>{const o=t.shape,l={};for(const c in o){const f=o[c]._zod;if(f.values){l[c]??(l[c]=new Set);for(const d of f.values)l[c].add(d)}}return l});const i=ui,s=t.catchall;let a;e._zod.parse=(o,l)=>{a??(a=r.value);const c=o.value;if(!i(c))return o.issues.push({expected:"object",code:"invalid_type",input:c,inst:e}),o;o.value={};const f=[],d=a.shape;for(const h of a.keys){const p=d[h],g=p._zod.optout==="optional",w=p._zod.run({value:c[h],issues:[]},l);w instanceof Promise?f.push(w.then(_=>us(_,o,h,c,g))):us(w,o,h,c,g)}return s?$h(f,c,o,l,r.value,e):f.length?Promise.all(f).then(()=>o):o}}),KN=W("$ZodObjectJIT",(e,t)=>{YN.init(e,t);const n=e._zod.parse,r=$s(()=>Mh(t)),i=h=>{var m;const p=new xN(["shape","payload","ctx"]),g=r.value,w=O=>{const C=Xu(O);return`shape[${C}]._zod.run({ value: input[${C}], issues: [] }, ctx)`};p.write("const input = payload.value;");const _=Object.create(null);let b=0;for(const O of g.keys)_[O]=`key_${b++}`;p.write("const newResult = {};");for(const O of g.keys){const C=_[O],v=Xu(O),k=h[O],$=((m=k==null?void 0:k._zod)==null?void 0:m.optout)==="optional";p.write(`const ${C} = ${w(O)};`),$?p.write(`
|
|
42
|
+
if (${C}.issues.length) {
|
|
43
|
+
if (${v} in input) {
|
|
44
|
+
payload.issues = payload.issues.concat(${C}.issues.map(iss => ({
|
|
45
|
+
...iss,
|
|
46
|
+
path: iss.path ? [${v}, ...iss.path] : [${v}]
|
|
47
|
+
})));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (${C}.value === undefined) {
|
|
52
|
+
if (${v} in input) {
|
|
53
|
+
newResult[${v}] = undefined;
|
|
54
|
+
}
|
|
55
|
+
} else {
|
|
56
|
+
newResult[${v}] = ${C}.value;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
`):p.write(`
|
|
60
|
+
if (${C}.issues.length) {
|
|
61
|
+
payload.issues = payload.issues.concat(${C}.issues.map(iss => ({
|
|
62
|
+
...iss,
|
|
63
|
+
path: iss.path ? [${v}, ...iss.path] : [${v}]
|
|
64
|
+
})));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (${C}.value === undefined) {
|
|
68
|
+
if (${v} in input) {
|
|
69
|
+
newResult[${v}] = undefined;
|
|
70
|
+
}
|
|
71
|
+
} else {
|
|
72
|
+
newResult[${v}] = ${C}.value;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
`)}p.write("payload.value = newResult;"),p.write("return payload;");const N=p.compile();return(O,C)=>N(h,O,C)};let s;const a=ui,o=!wh.jitless,c=o&&cj.value,f=t.catchall;let d;e._zod.parse=(h,p)=>{d??(d=r.value);const g=h.value;return a(g)?o&&c&&(p==null?void 0:p.async)===!1&&p.jitless!==!0?(s||(s=i(t.shape)),h=s(h,p),f?$h([],g,h,p,d,e):h):n(h,p):(h.issues.push({expected:"object",code:"invalid_type",input:g,inst:e}),h)}});function tc(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=>!nr(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(a=>wn(a,r,vn())))}),t)}const Fh=W("$ZodUnion",(e,t)=>{Je.init(e,t),Ae(e._zod,"optin",()=>t.options.some(i=>i._zod.optin==="optional")?"optional":void 0),Ae(e._zod,"optout",()=>t.options.some(i=>i._zod.optout==="optional")?"optional":void 0),Ae(e._zod,"values",()=>{if(t.options.every(i=>i._zod.values))return new Set(t.options.flatMap(i=>Array.from(i._zod.values)))}),Ae(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=>Go(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 a=!1;const o=[];for(const l of t.options){const c=l._zod.run({value:i.value,issues:[]},s);if(c instanceof Promise)o.push(c),a=!0;else{if(c.issues.length===0)return c;o.push(c)}}return a?Promise.all(o).then(l=>tc(l,i,e,s)):tc(o,i,e,s)}}),XN=W("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Fh.init(e,t);const n=e._zod.parse;Ae(e._zod,"propValues",()=>{const i={};for(const s of t.options){const a=s._zod.propValues;if(!a||Object.keys(a).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(const[o,l]of Object.entries(a)){i[o]||(i[o]=new Set);for(const c of l)i[o].add(c)}}return i});const r=$s(()=>{var a;const i=t.options,s=new Map;for(const o of i){const l=(a=o._zod.propValues)==null?void 0:a[t.discriminator];if(!l||l.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(o)}"`);for(const c of l){if(s.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);s.set(c,o)}}return s});e._zod.parse=(i,s)=>{const a=i.value;if(!ui(a))return i.issues.push({code:"invalid_type",expected:"object",input:a,inst:e}),i;const o=r.value.get(a==null?void 0:a[t.discriminator]);return o?o._zod.run(i,s):t.unionFallback?n(i,s):(i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:a,path:[t.discriminator],inst:e}),i)}}),QN=W("$ZodIntersection",(e,t)=>{Je.init(e,t),e._zod.parse=(n,r)=>{const i=n.value,s=t.left._zod.run({value:i,issues:[]},r),a=t.right._zod.run({value:i,issues:[]},r);return s instanceof Promise||a instanceof Promise?Promise.all([s,a]).then(([l,c])=>nc(n,l,c)):nc(n,s,a)}});function eo(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(vr(e)&&vr(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 a=eo(e[s],t[s]);if(!a.valid)return{valid:!1,mergeErrorPath:[s,...a.mergeErrorPath]};i[s]=a.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],a=eo(i,s);if(!a.valid)return{valid:!1,mergeErrorPath:[r,...a.mergeErrorPath]};n.push(a.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function nc(e,t,n){const r=new Map;let i;for(const o of t.issues)if(o.code==="unrecognized_keys"){i??(i=o);for(const l of o.keys)r.has(l)||r.set(l,{}),r.get(l).l=!0}else e.issues.push(o);for(const o of n.issues)if(o.code==="unrecognized_keys")for(const l of o.keys)r.has(l)||r.set(l,{}),r.get(l).r=!0;else e.issues.push(o);const s=[...r].filter(([,o])=>o.l&&o.r).map(([o])=>o);if(s.length&&i&&e.issues.push({...i,keys:s}),nr(e))return e;const a=eo(t.value,n.value);if(!a.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(a.mergeErrorPath)}`);return e.value=a.data,e}const eE=W("$ZodRecord",(e,t)=>{Je.init(e,t),e._zod.parse=(n,r)=>{const i=n.value;if(!vr(i))return n.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),n;const s=[],a=t.keyType._zod.values;if(a){n.value={};const o=new Set;for(const c of a)if(typeof c=="string"||typeof c=="number"||typeof c=="symbol"){o.add(typeof c=="number"?c.toString():c);const f=t.valueType._zod.run({value:i[c],issues:[]},r);f instanceof Promise?s.push(f.then(d=>{d.issues.length&&n.issues.push(...rr(c,d.issues)),n.value[c]=d.value})):(f.issues.length&&n.issues.push(...rr(c,f.issues)),n.value[c]=f.value)}let l;for(const c in i)o.has(c)||(l=l??[],l.push(c));l&&l.length>0&&n.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:l})}else{n.value={};for(const o of Reflect.ownKeys(i)){if(o==="__proto__")continue;let l=t.keyType._zod.run({value:o,issues:[]},r);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof o=="string"&&Ah.test(o)&&l.issues.length){const d=t.keyType._zod.run({value:Number(o),issues:[]},r);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");d.issues.length===0&&(l=d)}if(l.issues.length){t.mode==="loose"?n.value[o]=i[o]:n.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(d=>wn(d,r,vn())),input:o,path:[o],inst:e});continue}const f=t.valueType._zod.run({value:i[o],issues:[]},r);f instanceof Promise?s.push(f.then(d=>{d.issues.length&&n.issues.push(...rr(o,d.issues)),n.value[l.value]=d.value})):(f.issues.length&&n.issues.push(...rr(o,f.issues)),n.value[l.value]=f.value)}}return s.length?Promise.all(s).then(()=>n):n}}),tE=W("$ZodEnum",(e,t)=>{Je.init(e,t);const n=kh(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(i=>dj.has(typeof i)).map(i=>typeof i=="string"?wr(i):i.toString()).join("|")})$`),e._zod.parse=(i,s)=>{const a=i.value;return r.has(a)||i.issues.push({code:"invalid_value",values:n,input:a,inst:e}),i}}),nE=W("$ZodLiteral",(e,t)=>{if(Je.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"?wr(r):r?wr(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}}),rE=W("$ZodTransform",(e,t)=>{Je.init(e,t),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new vh(e.constructor.name);const i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(a=>(n.value=a,n));if(i instanceof Promise)throw new dr;return n.value=i,n}});function rc(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const Lh=W("$ZodOptional",(e,t)=>{Je.init(e,t),e._zod.optin="optional",e._zod.optout="optional",Ae(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Ae(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Go(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=>rc(s,n.value)):rc(i,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,r)}}),iE=W("$ZodExactOptional",(e,t)=>{Lh.init(e,t),Ae(e._zod,"values",()=>t.innerType._zod.values),Ae(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),sE=W("$ZodNullable",(e,t)=>{Je.init(e,t),Ae(e._zod,"optin",()=>t.innerType._zod.optin),Ae(e._zod,"optout",()=>t.innerType._zod.optout),Ae(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Go(n.source)}|null)$`):void 0}),Ae(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)}),aE=W("$ZodDefault",(e,t)=>{Je.init(e,t),e._zod.optin="optional",Ae(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=>ic(s,t)):ic(i,t)}});function ic(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const oE=W("$ZodPrefault",(e,t)=>{Je.init(e,t),e._zod.optin="optional",Ae(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))}),lE=W("$ZodNonOptional",(e,t)=>{Je.init(e,t),Ae(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=>sc(s,e)):sc(i,e)}});function sc(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 uE=W("$ZodCatch",(e,t)=>{Je.init(e,t),Ae(e._zod,"optin",()=>t.innerType._zod.optin),Ae(e._zod,"optout",()=>t.innerType._zod.optout),Ae(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(a=>wn(a,r,vn()))},input:n.value}),n.issues=[]),n)):(n.value=i.value,i.issues.length&&(n.value=t.catchValue({...n,error:{issues:i.issues.map(s=>wn(s,r,vn()))},input:n.value}),n.issues=[]),n)}}),cE=W("$ZodPipe",(e,t)=>{Je.init(e,t),Ae(e._zod,"values",()=>t.in._zod.values),Ae(e._zod,"optin",()=>t.in._zod.optin),Ae(e._zod,"optout",()=>t.out._zod.optout),Ae(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(a=>Pi(a,t.in,r)):Pi(s,t.in,r)}const i=t.in._zod.run(n,r);return i instanceof Promise?i.then(s=>Pi(s,t.out,r)):Pi(i,t.out,r)}});function Pi(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const dE=W("$ZodReadonly",(e,t)=>{Je.init(e,t),Ae(e._zod,"propValues",()=>t.innerType._zod.propValues),Ae(e._zod,"values",()=>t.innerType._zod.values),Ae(e._zod,"optin",()=>{var n,r;return(r=(n=t.innerType)==null?void 0:n._zod)==null?void 0:r.optin}),Ae(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(ac):ac(i)}});function ac(e){return e.value=Object.freeze(e.value),e}const fE=W("$ZodLazy",(e,t)=>{Je.init(e,t),Ae(e._zod,"innerType",()=>t.getter()),Ae(e._zod,"pattern",()=>{var n,r;return(r=(n=e._zod.innerType)==null?void 0:n._zod)==null?void 0:r.pattern}),Ae(e._zod,"propValues",()=>{var n,r;return(r=(n=e._zod.innerType)==null?void 0:n._zod)==null?void 0:r.propValues}),Ae(e._zod,"optin",()=>{var n,r;return((r=(n=e._zod.innerType)==null?void 0:n._zod)==null?void 0:r.optin)??void 0}),Ae(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)}),pE=W("$ZodCustom",(e,t)=>{_t.init(e,t),Je.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=>oc(s,n,r,e));oc(i,n,r,e)}});function oc(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(ci(i))}}var lc;class hE{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 mE(){return new hE}(lc=globalThis).__zod_globalRegistry??(lc.__zod_globalRegistry=mE());const Vr=globalThis.__zod_globalRegistry;function gE(e,t){return new e({type:"string",...pe(t)})}function xE(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...pe(t)})}function uc(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...pe(t)})}function yE(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...pe(t)})}function bE(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...pe(t)})}function vE(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...pe(t)})}function wE(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...pe(t)})}function kE(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...pe(t)})}function SE(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...pe(t)})}function _E(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...pe(t)})}function jE(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...pe(t)})}function NE(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...pe(t)})}function EE(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...pe(t)})}function CE(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...pe(t)})}function TE(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...pe(t)})}function IE(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...pe(t)})}function AE(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...pe(t)})}function zE(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...pe(t)})}function OE(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...pe(t)})}function PE(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...pe(t)})}function DE(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...pe(t)})}function RE(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...pe(t)})}function ME(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...pe(t)})}function $E(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...pe(t)})}function FE(e,t){return new e({type:"string",format:"date",check:"string_format",...pe(t)})}function LE(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...pe(t)})}function BE(e,t){return new e({type:"string",format:"duration",check:"string_format",...pe(t)})}function ZE(e,t){return new e({type:"number",checks:[],...pe(t)})}function VE(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...pe(t)})}function UE(e,t){return new e({type:"boolean",...pe(t)})}function JE(e,t){return new e({type:"null",...pe(t)})}function HE(e){return new e({type:"unknown"})}function WE(e,t){return new e({type:"never",...pe(t)})}function cc(e,t){return new Oh({check:"less_than",...pe(t),value:e,inclusive:!1})}function ya(e,t){return new Oh({check:"less_than",...pe(t),value:e,inclusive:!0})}function dc(e,t){return new Ph({check:"greater_than",...pe(t),value:e,inclusive:!1})}function ba(e,t){return new Ph({check:"greater_than",...pe(t),value:e,inclusive:!0})}function fc(e,t){return new sN({check:"multiple_of",...pe(t),value:e})}function Bh(e,t){return new oN({check:"max_length",...pe(t),maximum:e})}function cs(e,t){return new lN({check:"min_length",...pe(t),minimum:e})}function Zh(e,t){return new uN({check:"length_equals",...pe(t),length:e})}function qE(e,t){return new cN({check:"string_format",format:"regex",...pe(t),pattern:e})}function GE(e){return new dN({check:"string_format",format:"lowercase",...pe(e)})}function YE(e){return new fN({check:"string_format",format:"uppercase",...pe(e)})}function KE(e,t){return new pN({check:"string_format",format:"includes",...pe(t),includes:e})}function XE(e,t){return new hN({check:"string_format",format:"starts_with",...pe(t),prefix:e})}function QE(e,t){return new mN({check:"string_format",format:"ends_with",...pe(t),suffix:e})}function Er(e){return new gN({check:"overwrite",tx:e})}function eC(e){return Er(t=>t.normalize(e))}function tC(){return Er(e=>e.trim())}function nC(){return Er(e=>e.toLowerCase())}function rC(){return Er(e=>e.toUpperCase())}function iC(){return Er(e=>uj(e))}function sC(e,t,n){return new e({type:"array",element:t,...pe(n)})}function aC(e,t,n){const r=pe(n);return r.abort??(r.abort=!0),new e({type:"custom",check:"custom",fn:t,...r})}function oC(e,t,n){return new e({type:"custom",check:"custom",fn:t,...pe(n)})}function lC(e){const t=uC(n=>(n.addIssue=r=>{if(typeof r=="string")n.issues.push(ci(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(ci(i))}},e(n.value,n)));return t}function uC(e,t){const n=new _t({check:"custom",...pe(t)});return n._zod.check=e,n}function ds(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)??Vr,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 Ze(e,t,n={path:[],schemaPath:[]}){var f,d;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 a={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,a);const o=(d=(f=e._zod).toJSONSchema)==null?void 0:d.call(f);if(o)a.schema=o;else{const h={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,a.schema,h);else{const g=a.schema,w=t.processors[i.type];if(!w)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);w(e,t,g,h)}const p=e._zod.parent;p&&(a.ref||(a.ref=p),Ze(p,t,h),t.seen.get(p).isParent=!0)}const l=t.metadataRegistry.get(e);return l&&Object.assign(a.schema,l),t.io==="input"&&ct(e)&&(delete a.schema.examples,delete a.schema.default),t.io==="input"&&a.schema._prefault&&((r=a.schema).default??(r.default=a.schema._prefault)),delete a.schema._prefault,t.seen.get(e).schema}function fs(e,t){var a,o,l,c;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 f of e.seen.entries()){const d=(a=e.metadataRegistry.get(f[0]))==null?void 0:a.id;if(d){const h=r.get(d);if(h&&h!==f[0])throw new Error(`Duplicate schema id "${d}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(d,f[0])}}const i=f=>{var w;const d=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const _=(w=e.external.registry.get(f[0]))==null?void 0:w.id,b=e.external.uri??(m=>m);if(_)return{ref:b(_)};const N=f[1].defId??f[1].schema.id??`schema${e.counter++}`;return f[1].defId=N,{defId:N,ref:`${b("__shared")}#/${d}/${N}`}}if(f[1]===n)return{ref:"#"};const p=`#/${d}/`,g=f[1].schema.id??`__schema${e.counter++}`;return{defId:g,ref:p+g}},s=f=>{if(f[1].schema.$ref)return;const d=f[1],{ref:h,defId:p}=i(f);d.def={...d.schema},p&&(d.defId=p);const g=d.schema;for(const w in g)delete g[w];g.$ref=h};if(e.cycles==="throw")for(const f of e.seen.entries()){const d=f[1];if(d.cycle)throw new Error(`Cycle detected: #/${(o=d.cycle)==null?void 0:o.join("/")}/<root>
|
|
76
|
+
|
|
77
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const f of e.seen.entries()){const d=f[1];if(t===f[0]){s(f);continue}if(e.external){const p=(l=e.external.registry.get(f[0]))==null?void 0:l.id;if(t!==f[0]&&p){s(f);continue}}if((c=e.metadataRegistry.get(f[0]))==null?void 0:c.id){s(f);continue}if(d.cycle){s(f);continue}if(d.count>1&&e.reused==="ref"){s(f);continue}}}function ps(e,t){var a,o,l;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=c=>{const f=e.seen.get(c);if(f.ref===null)return;const d=f.def??f.schema,h={...d},p=f.ref;if(f.ref=null,p){r(p);const w=e.seen.get(p),_=w.schema;if(_.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(d.allOf=d.allOf??[],d.allOf.push(_)):Object.assign(d,_),Object.assign(d,h),c._zod.parent===p)for(const N in d)N==="$ref"||N==="allOf"||N in h||delete d[N];if(_.$ref&&w.def)for(const N in d)N==="$ref"||N==="allOf"||N in w.def&&JSON.stringify(d[N])===JSON.stringify(w.def[N])&&delete d[N]}const g=c._zod.parent;if(g&&g!==p){r(g);const w=e.seen.get(g);if(w!=null&&w.schema.$ref&&(d.$ref=w.schema.$ref,w.def))for(const _ in d)_==="$ref"||_==="allOf"||_ in w.def&&JSON.stringify(d[_])===JSON.stringify(w.def[_])&&delete d[_]}e.override({zodSchema:c,jsonSchema:d,path:f.path??[]})};for(const c of[...e.seen.entries()].reverse())r(c[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,(a=e.external)!=null&&a.uri){const c=(o=e.external.registry.get(t))==null?void 0:o.id;if(!c)throw new Error("Schema is missing an `id` property");i.$id=e.external.uri(c)}Object.assign(i,n.def??n.schema);const s=((l=e.external)==null?void 0:l.defs)??{};for(const c of e.seen.entries()){const f=c[1];f.def&&f.defId&&(s[f.defId]=f.def)}e.external||Object.keys(s).length>0&&(e.target==="draft-2020-12"?i.$defs=s:i.definitions=s);try{const c=JSON.parse(JSON.stringify(i));return Object.defineProperty(c,"~standard",{value:{...t["~standard"],jsonSchema:{input:hs(t,"input",e.processors),output:hs(t,"output",e.processors)}},enumerable:!1,writable:!1}),c}catch{throw new Error("Error converting schema to JSON.")}}function ct(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 ct(r.element,n);if(r.type==="set")return ct(r.valueType,n);if(r.type==="lazy")return ct(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 ct(r.innerType,n);if(r.type==="intersection")return ct(r.left,n)||ct(r.right,n);if(r.type==="record"||r.type==="map")return ct(r.keyType,n)||ct(r.valueType,n);if(r.type==="pipe")return ct(r.in,n)||ct(r.out,n);if(r.type==="object"){for(const i in r.shape)if(ct(r.shape[i],n))return!0;return!1}if(r.type==="union"){for(const i of r.options)if(ct(i,n))return!0;return!1}if(r.type==="tuple"){for(const i of r.items)if(ct(i,n))return!0;return!!(r.rest&&ct(r.rest,n))}return!1}const cC=(e,t={})=>n=>{const r=ds({...n,processors:t});return Ze(e,r),fs(r,e),ps(r,e)},hs=(e,t,n={})=>r=>{const{libraryOptions:i,target:s}=r??{},a=ds({...i??{},target:s,io:t,processors:n});return Ze(e,a),fs(a,e),ps(a,e)},dC={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Vh=(e,t,n,r)=>{const i=n;i.type="string";const{minimum:s,maximum:a,format:o,patterns:l,contentEncoding:c}=e._zod.bag;if(typeof s=="number"&&(i.minLength=s),typeof a=="number"&&(i.maxLength=a),o&&(i.format=dC[o]??o,i.format===""&&delete i.format,o==="time"&&delete i.format),c&&(i.contentEncoding=c),l&&l.size>0){const f=[...l];f.length===1?i.pattern=f[0].source:f.length>1&&(i.allOf=[...f.map(d=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:d.source}))])}},Uh=(e,t,n,r)=>{const i=n,{minimum:s,maximum:a,format:o,multipleOf:l,exclusiveMaximum:c,exclusiveMinimum:f}=e._zod.bag;typeof o=="string"&&o.includes("int")?i.type="integer":i.type="number",typeof f=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(i.minimum=f,i.exclusiveMinimum=!0):i.exclusiveMinimum=f),typeof s=="number"&&(i.minimum=s,typeof f=="number"&&t.target!=="draft-04"&&(f>=s?delete i.minimum:delete i.exclusiveMinimum)),typeof c=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(i.maximum=c,i.exclusiveMaximum=!0):i.exclusiveMaximum=c),typeof a=="number"&&(i.maximum=a,typeof c=="number"&&t.target!=="draft-04"&&(c<=a?delete i.maximum:delete i.exclusiveMaximum)),typeof l=="number"&&(i.multipleOf=l)},Jh=(e,t,n,r)=>{n.type="boolean"},fC=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema")},pC=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema")},Hh=(e,t,n,r)=>{t.target==="openapi-3.0"?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"},hC=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},mC=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema")},Wh=(e,t,n,r)=>{n.not={}},gC=(e,t,n,r)=>{},qh=(e,t,n,r)=>{},xC=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},Gh=(e,t,n,r)=>{const i=e._zod.def,s=kh(i.entries);s.every(a=>typeof a=="number")&&(n.type="number"),s.every(a=>typeof a=="string")&&(n.type="string"),n.enum=s},Yh=(e,t,n,r)=>{const i=e._zod.def,s=[];for(const a of i.values)if(a===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof a=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");s.push(Number(a))}else s.push(a);if(s.length!==0)if(s.length===1){const a=s[0];n.type=a===null?"null":typeof a,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[a]:n.const=a}else s.every(a=>typeof a=="number")&&(n.type="number"),s.every(a=>typeof a=="string")&&(n.type="string"),s.every(a=>typeof a=="boolean")&&(n.type="boolean"),s.every(a=>a===null)&&(n.type="null"),n.enum=s},yC=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema")},bC=(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},vC=(e,t,n,r)=>{const i=n,s={type:"string",format:"binary",contentEncoding:"binary"},{minimum:a,maximum:o,mime:l}=e._zod.bag;a!==void 0&&(s.minLength=a),o!==void 0&&(s.maxLength=o),l?l.length===1?(s.contentMediaType=l[0],Object.assign(i,s)):(Object.assign(i,s),i.anyOf=l.map(c=>({contentMediaType:c}))):Object.assign(i,s)},wC=(e,t,n,r)=>{n.type="boolean"},Kh=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},kC=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Function types cannot be represented in JSON Schema")},Xh=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},SC=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema")},_C=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema")},Qh=(e,t,n,r)=>{const i=n,s=e._zod.def,{minimum:a,maximum:o}=e._zod.bag;typeof a=="number"&&(i.minItems=a),typeof o=="number"&&(i.maxItems=o),i.type="array",i.items=Ze(s.element,t,{...r,path:[...r.path,"items"]})},em=(e,t,n,r)=>{var c;const i=n,s=e._zod.def;i.type="object",i.properties={};const a=s.shape;for(const f in a)i.properties[f]=Ze(a[f],t,{...r,path:[...r.path,"properties",f]});const o=new Set(Object.keys(a)),l=new Set([...o].filter(f=>{const d=s.shape[f]._zod;return t.io==="input"?d.optin===void 0:d.optout===void 0}));l.size>0&&(i.required=Array.from(l)),((c=s.catchall)==null?void 0:c._zod.def.type)==="never"?i.additionalProperties=!1:s.catchall?s.catchall&&(i.additionalProperties=Ze(s.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(i.additionalProperties=!1)},tm=(e,t,n,r)=>{const i=e._zod.def,s=i.inclusive===!1,a=i.options.map((o,l)=>Ze(o,t,{...r,path:[...r.path,s?"oneOf":"anyOf",l]}));s?n.oneOf=a:n.anyOf=a},nm=(e,t,n,r)=>{const i=e._zod.def,s=Ze(i.left,t,{...r,path:[...r.path,"allOf",0]}),a=Ze(i.right,t,{...r,path:[...r.path,"allOf",1]}),o=c=>"allOf"in c&&Object.keys(c).length===1,l=[...o(s)?s.allOf:[s],...o(a)?a.allOf:[a]];n.allOf=l},jC=(e,t,n,r)=>{const i=n,s=e._zod.def;i.type="array";const a=t.target==="draft-2020-12"?"prefixItems":"items",o=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",l=s.items.map((h,p)=>Ze(h,t,{...r,path:[...r.path,a,p]})),c=s.rest?Ze(s.rest,t,{...r,path:[...r.path,o,...t.target==="openapi-3.0"?[s.items.length]:[]]}):null;t.target==="draft-2020-12"?(i.prefixItems=l,c&&(i.items=c)):t.target==="openapi-3.0"?(i.items={anyOf:l},c&&i.items.anyOf.push(c),i.minItems=l.length,c||(i.maxItems=l.length)):(i.items=l,c&&(i.additionalItems=c));const{minimum:f,maximum:d}=e._zod.bag;typeof f=="number"&&(i.minItems=f),typeof d=="number"&&(i.maxItems=d)},rm=(e,t,n,r)=>{const i=n,s=e._zod.def;i.type="object";const a=s.keyType,o=a._zod.bag,l=o==null?void 0:o.patterns;if(s.mode==="loose"&&l&&l.size>0){const f=Ze(s.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});i.patternProperties={};for(const d of l)i.patternProperties[d.source]=f}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(i.propertyNames=Ze(s.keyType,t,{...r,path:[...r.path,"propertyNames"]})),i.additionalProperties=Ze(s.valueType,t,{...r,path:[...r.path,"additionalProperties"]});const c=a._zod.values;if(c){const f=[...c].filter(d=>typeof d=="string"||typeof d=="number");f.length>0&&(i.required=f)}},im=(e,t,n,r)=>{const i=e._zod.def,s=Ze(i.innerType,t,r),a=t.seen.get(e);t.target==="openapi-3.0"?(a.ref=i.innerType,n.nullable=!0):n.anyOf=[s,{type:"null"}]},sm=(e,t,n,r)=>{const i=e._zod.def;Ze(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType},am=(e,t,n,r)=>{const i=e._zod.def;Ze(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},om=(e,t,n,r)=>{const i=e._zod.def;Ze(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)))},lm=(e,t,n,r)=>{const i=e._zod.def;Ze(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType;let a;try{a=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=a},um=(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;Ze(s,t,r);const a=t.seen.get(e);a.ref=s},cm=(e,t,n,r)=>{const i=e._zod.def;Ze(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType,n.readOnly=!0},NC=(e,t,n,r)=>{const i=e._zod.def;Ze(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType},el=(e,t,n,r)=>{const i=e._zod.def;Ze(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType},dm=(e,t,n,r)=>{const i=e._zod.innerType;Ze(i,t,r);const s=t.seen.get(e);s.ref=i},pc={string:Vh,number:Uh,boolean:Jh,bigint:fC,symbol:pC,null:Hh,undefined:hC,void:mC,never:Wh,any:gC,unknown:qh,date:xC,enum:Gh,literal:Yh,nan:yC,template_literal:bC,file:vC,success:wC,custom:Kh,function:kC,transform:Xh,map:SC,set:_C,array:Qh,object:em,union:tm,intersection:nm,tuple:jC,record:rm,nullable:im,nonoptional:sm,default:am,prefault:om,catch:lm,pipe:um,readonly:cm,promise:NC,optional:el,lazy:dm};function EC(e,t){if("_idmap"in e){const r=e,i=ds({...t,processors:pc}),s={};for(const l of r._idmap.entries()){const[c,f]=l;Ze(f,i)}const a={},o={registry:r,uri:t==null?void 0:t.uri,defs:s};i.external=o;for(const l of r._idmap.entries()){const[c,f]=l;fs(i,f),a[c]=ps(i,f)}if(Object.keys(s).length>0){const l=i.target==="draft-2020-12"?"$defs":"definitions";a.__shared={[l]:s}}return{schemas:a}}const n=ds({...t,processors:pc});return Ze(e,n),fs(n,e),ps(n,e)}const CC=W("ZodISODateTime",(e,t)=>{IN.init(e,t),Ge.init(e,t)});function TC(e){return $E(CC,e)}const IC=W("ZodISODate",(e,t)=>{AN.init(e,t),Ge.init(e,t)});function AC(e){return FE(IC,e)}const zC=W("ZodISOTime",(e,t)=>{zN.init(e,t),Ge.init(e,t)});function OC(e){return LE(zC,e)}const PC=W("ZodISODuration",(e,t)=>{ON.init(e,t),Ge.init(e,t)});function DC(e){return BE(PC,e)}const RC=(e,t)=>{Nh.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>kj(e,n)},flatten:{value:n=>wj(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,Qa,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,Qa,2)}},isEmpty:{get(){return e.issues.length===0}}})},Pt=W("ZodError",RC,{Parent:Error}),MC=Ko(Pt),$C=Xo(Pt),FC=Fs(Pt),fm=Ls(Pt),LC=jj(Pt),BC=Nj(Pt),ZC=Ej(Pt),VC=Cj(Pt),UC=Tj(Pt),JC=Ij(Pt),HC=Aj(Pt),WC=zj(Pt),He=W("ZodType",(e,t)=>(Je.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:hs(e,"input"),output:hs(e,"output")}}),e.toJSONSchema=cC(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(Sn(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)=>_n(e,n,r),e.brand=()=>e,e.register=(n,r)=>(n.add(e,r),e),e.parse=(n,r)=>MC(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>FC(e,n,r),e.parseAsync=async(n,r)=>$C(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>fm(e,n,r),e.spa=e.safeParseAsync,e.encode=(n,r)=>LC(e,n,r),e.decode=(n,r)=>BC(e,n,r),e.encodeAsync=async(n,r)=>ZC(e,n,r),e.decodeAsync=async(n,r)=>VC(e,n,r),e.safeEncode=(n,r)=>UC(e,n,r),e.safeDecode=(n,r)=>JC(e,n,r),e.safeEncodeAsync=async(n,r)=>HC(e,n,r),e.safeDecodeAsync=async(n,r)=>WC(e,n,r),e.refine=(n,r)=>e.check(VT(n,r)),e.superRefine=n=>e.check(UT(n)),e.overwrite=n=>e.check(Er(n)),e.optional=()=>gc(e),e.exactOptional=()=>TT(e),e.nullable=()=>xc(e),e.nullish=()=>gc(xc(e)),e.nonoptional=n=>DT(e,n),e.array=()=>Cr(e),e.or=n=>mt([e,n]),e.and=n=>ST(e,n),e.transform=n=>yc(e,ET(n)),e.default=n=>zT(e,n),e.prefault=n=>PT(e,n),e.catch=n=>MT(e,n),e.pipe=n=>yc(e,n),e.readonly=()=>LT(e),e.describe=n=>{const r=e.clone();return Vr.add(r,{description:n}),r},Object.defineProperty(e,"description",{get(){var n;return(n=Vr.get(e))==null?void 0:n.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return Vr.get(e);const r=e.clone();return Vr.add(r,n[0]),r},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=n=>n(e),e)),pm=W("_ZodString",(e,t)=>{Qo.init(e,t),He.init(e,t),e._zod.processJSONSchema=(r,i,s)=>Vh(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(qE(...r)),e.includes=(...r)=>e.check(KE(...r)),e.startsWith=(...r)=>e.check(XE(...r)),e.endsWith=(...r)=>e.check(QE(...r)),e.min=(...r)=>e.check(cs(...r)),e.max=(...r)=>e.check(Bh(...r)),e.length=(...r)=>e.check(Zh(...r)),e.nonempty=(...r)=>e.check(cs(1,...r)),e.lowercase=r=>e.check(GE(r)),e.uppercase=r=>e.check(YE(r)),e.trim=()=>e.check(tC()),e.normalize=(...r)=>e.check(eC(...r)),e.toLowerCase=()=>e.check(nC()),e.toUpperCase=()=>e.check(rC()),e.slugify=()=>e.check(iC())}),qC=W("ZodString",(e,t)=>{Qo.init(e,t),pm.init(e,t),e.email=n=>e.check(xE(GC,n)),e.url=n=>e.check(kE(YC,n)),e.jwt=n=>e.check(ME(dT,n)),e.emoji=n=>e.check(SE(KC,n)),e.guid=n=>e.check(uc(hc,n)),e.uuid=n=>e.check(yE(Di,n)),e.uuidv4=n=>e.check(bE(Di,n)),e.uuidv6=n=>e.check(vE(Di,n)),e.uuidv7=n=>e.check(wE(Di,n)),e.nanoid=n=>e.check(_E(XC,n)),e.guid=n=>e.check(uc(hc,n)),e.cuid=n=>e.check(jE(QC,n)),e.cuid2=n=>e.check(NE(eT,n)),e.ulid=n=>e.check(EE(tT,n)),e.base64=n=>e.check(PE(lT,n)),e.base64url=n=>e.check(DE(uT,n)),e.xid=n=>e.check(CE(nT,n)),e.ksuid=n=>e.check(TE(rT,n)),e.ipv4=n=>e.check(IE(iT,n)),e.ipv6=n=>e.check(AE(sT,n)),e.cidrv4=n=>e.check(zE(aT,n)),e.cidrv6=n=>e.check(OE(oT,n)),e.e164=n=>e.check(RE(cT,n)),e.datetime=n=>e.check(TC(n)),e.date=n=>e.check(AC(n)),e.time=n=>e.check(OC(n)),e.duration=n=>e.check(DC(n))});function ae(e){return gE(qC,e)}const Ge=W("ZodStringFormat",(e,t)=>{qe.init(e,t),pm.init(e,t)}),GC=W("ZodEmail",(e,t)=>{wN.init(e,t),Ge.init(e,t)}),hc=W("ZodGUID",(e,t)=>{bN.init(e,t),Ge.init(e,t)}),Di=W("ZodUUID",(e,t)=>{vN.init(e,t),Ge.init(e,t)}),YC=W("ZodURL",(e,t)=>{kN.init(e,t),Ge.init(e,t)}),KC=W("ZodEmoji",(e,t)=>{SN.init(e,t),Ge.init(e,t)}),XC=W("ZodNanoID",(e,t)=>{_N.init(e,t),Ge.init(e,t)}),QC=W("ZodCUID",(e,t)=>{jN.init(e,t),Ge.init(e,t)}),eT=W("ZodCUID2",(e,t)=>{NN.init(e,t),Ge.init(e,t)}),tT=W("ZodULID",(e,t)=>{EN.init(e,t),Ge.init(e,t)}),nT=W("ZodXID",(e,t)=>{CN.init(e,t),Ge.init(e,t)}),rT=W("ZodKSUID",(e,t)=>{TN.init(e,t),Ge.init(e,t)}),iT=W("ZodIPv4",(e,t)=>{PN.init(e,t),Ge.init(e,t)}),sT=W("ZodIPv6",(e,t)=>{DN.init(e,t),Ge.init(e,t)}),aT=W("ZodCIDRv4",(e,t)=>{RN.init(e,t),Ge.init(e,t)}),oT=W("ZodCIDRv6",(e,t)=>{MN.init(e,t),Ge.init(e,t)}),lT=W("ZodBase64",(e,t)=>{$N.init(e,t),Ge.init(e,t)}),uT=W("ZodBase64URL",(e,t)=>{LN.init(e,t),Ge.init(e,t)}),cT=W("ZodE164",(e,t)=>{BN.init(e,t),Ge.init(e,t)}),dT=W("ZodJWT",(e,t)=>{VN.init(e,t),Ge.init(e,t)}),hm=W("ZodNumber",(e,t)=>{Rh.init(e,t),He.init(e,t),e._zod.processJSONSchema=(r,i,s)=>Uh(e,r,i),e.gt=(r,i)=>e.check(dc(r,i)),e.gte=(r,i)=>e.check(ba(r,i)),e.min=(r,i)=>e.check(ba(r,i)),e.lt=(r,i)=>e.check(cc(r,i)),e.lte=(r,i)=>e.check(ya(r,i)),e.max=(r,i)=>e.check(ya(r,i)),e.int=r=>e.check(mc(r)),e.safe=r=>e.check(mc(r)),e.positive=r=>e.check(dc(0,r)),e.nonnegative=r=>e.check(ba(0,r)),e.negative=r=>e.check(cc(0,r)),e.nonpositive=r=>e.check(ya(0,r)),e.multipleOf=(r,i)=>e.check(fc(r,i)),e.step=(r,i)=>e.check(fc(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 fT(e){return ZE(hm,e)}const pT=W("ZodNumberFormat",(e,t)=>{UN.init(e,t),hm.init(e,t)});function mc(e){return VE(pT,e)}const hT=W("ZodBoolean",(e,t)=>{JN.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Jh(e,n,r)});function dt(e){return UE(hT,e)}const mT=W("ZodNull",(e,t)=>{HN.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Hh(e,n,r)});function gT(e){return JE(mT,e)}const xT=W("ZodUnknown",(e,t)=>{WN.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>qh()});function qt(){return HE(xT)}const yT=W("ZodNever",(e,t)=>{qN.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Wh(e,n,r)});function mm(e){return WE(yT,e)}const bT=W("ZodArray",(e,t)=>{GN.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Qh(e,n,r,i),e.element=t.element,e.min=(n,r)=>e.check(cs(n,r)),e.nonempty=n=>e.check(cs(1,n)),e.max=(n,r)=>e.check(Bh(n,r)),e.length=(n,r)=>e.check(Zh(n,r)),e.unwrap=()=>e.element});function Cr(e,t){return sC(bT,e,t)}const gm=W("ZodObject",(e,t)=>{KN.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>em(e,n,r,i),Ae(e,"shape",()=>t.shape),e.keyof=()=>ym(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:qt()}),e.loose=()=>e.clone({...e._zod.def,catchall:qt()}),e.strict=()=>e.clone({...e._zod.def,catchall:mm()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>gj(e,n),e.safeExtend=n=>xj(e,n),e.merge=n=>yj(e,n),e.pick=n=>hj(e,n),e.omit=n=>mj(e,n),e.partial=(...n)=>bj(bm,e,n[0]),e.required=(...n)=>vj(vm,e,n[0])});function $e(e,t){const n={type:"object",shape:e??{},...pe(t)};return new gm(n)}function Ve(e,t){return new gm({type:"object",shape:e,catchall:mm(),...pe(t)})}const xm=W("ZodUnion",(e,t)=>{Fh.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>tm(e,n,r,i),e.options=t.options});function mt(e,t){return new xm({type:"union",options:e,...pe(t)})}const vT=W("ZodDiscriminatedUnion",(e,t)=>{xm.init(e,t),XN.init(e,t)});function wT(e,t,n){return new vT({type:"union",options:t,discriminator:e,...pe(n)})}const kT=W("ZodIntersection",(e,t)=>{QN.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>nm(e,n,r,i)});function ST(e,t){return new kT({type:"intersection",left:e,right:t})}const _T=W("ZodRecord",(e,t)=>{eE.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>rm(e,n,r,i),e.keyType=t.keyType,e.valueType=t.valueType});function di(e,t,n){return new _T({type:"record",keyType:e,valueType:t,...pe(n)})}const to=W("ZodEnum",(e,t)=>{tE.init(e,t),He.init(e,t),e._zod.processJSONSchema=(r,i,s)=>Gh(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 a of r)if(n.has(a))s[a]=t.entries[a];else throw new Error(`Key ${a} not found in enum`);return new to({...t,checks:[],...pe(i),entries:s})},e.exclude=(r,i)=>{const s={...t.entries};for(const a of r)if(n.has(a))delete s[a];else throw new Error(`Key ${a} not found in enum`);return new to({...t,checks:[],...pe(i),entries:s})}});function ym(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new to({type:"enum",entries:n,...pe(t)})}const jT=W("ZodLiteral",(e,t)=>{nE.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Yh(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 be(e,t){return new jT({type:"literal",values:Array.isArray(e)?e:[e],...pe(t)})}const NT=W("ZodTransform",(e,t)=>{rE.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Xh(e,n),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new vh(e.constructor.name);n.addIssue=s=>{if(typeof s=="string")n.issues.push(ci(s,n.value,t));else{const a=s;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),a.input??(a.input=n.value),a.inst??(a.inst=e),n.issues.push(ci(a))}};const i=t.transform(n.value,n);return i instanceof Promise?i.then(s=>(n.value=s,n)):(n.value=i,n)}});function ET(e){return new NT({type:"transform",transform:e})}const bm=W("ZodOptional",(e,t)=>{Lh.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>el(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function gc(e){return new bm({type:"optional",innerType:e})}const CT=W("ZodExactOptional",(e,t)=>{iE.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>el(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function TT(e){return new CT({type:"optional",innerType:e})}const IT=W("ZodNullable",(e,t)=>{sE.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>im(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function xc(e){return new IT({type:"nullable",innerType:e})}const AT=W("ZodDefault",(e,t)=>{aE.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>am(e,n,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function zT(e,t){return new AT({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():_h(t)}})}const OT=W("ZodPrefault",(e,t)=>{oE.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>om(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function PT(e,t){return new OT({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():_h(t)}})}const vm=W("ZodNonOptional",(e,t)=>{lE.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>sm(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function DT(e,t){return new vm({type:"nonoptional",innerType:e,...pe(t)})}const RT=W("ZodCatch",(e,t)=>{uE.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>lm(e,n,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function MT(e,t){return new RT({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const $T=W("ZodPipe",(e,t)=>{cE.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>um(e,n,r,i),e.in=t.in,e.out=t.out});function yc(e,t){return new $T({type:"pipe",in:e,out:t})}const FT=W("ZodReadonly",(e,t)=>{dE.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>cm(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function LT(e){return new FT({type:"readonly",innerType:e})}const BT=W("ZodLazy",(e,t)=>{fE.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>dm(e,n,r,i),e.unwrap=()=>e._zod.def.getter()});function ZT(e){return new BT({type:"lazy",getter:e})}const tl=W("ZodCustom",(e,t)=>{pE.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Kh(e,n)});function wm(e,t){return aC(tl,e??(()=>!0),t)}function VT(e,t={}){return oC(tl,e,t)}function UT(e){return lC(e)}function ms(e,t={}){const n=new tl({type:"custom",check:"custom",fn:r=>r instanceof e,abort:!0,...pe(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 fi;(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 a of i)s[a]=a;return s},e.getValidEnumValues=i=>{const s=e.objectKeys(i).filter(o=>typeof i[i[o]]!="number"),a={};for(const o of s)a[o]=i[o];return e.objectValues(a)},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 a in i)Object.prototype.hasOwnProperty.call(i,a)&&s.push(a);return s},e.find=(i,s)=>{for(const a of i)if(s(a))return a},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(a=>typeof a=="string"?`'${a}'`:a).join(s)}e.joinValues=r,e.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(fi||(fi={}));var bc;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(bc||(bc={}));fi.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]);fi.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 gs 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 a of s.issues)if(a.code==="invalid_union")a.unionErrors.map(i);else if(a.code==="invalid_return_type")i(a.returnTypeError);else if(a.code==="invalid_arguments")i(a.argumentsError);else if(a.path.length===0)r._errors.push(n(a));else{let o=r,l=0;for(;l<a.path.length;){const c=a.path[l];l===a.path.length-1?(o[c]=o[c]||{_errors:[]},o[c]._errors.push(n(a))):o[c]=o[c]||{_errors:[]},o=o[c],l++}}};return i(this),r}static assert(t){if(!(t instanceof gs))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,fi.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()}}gs.create=e=>new gs(e);var vc;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})(vc||(vc={}));var we;(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"})(we||(we={}));class wc 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 va(e){}function JT(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=va,onError:n=va,onRetry:r=va,onComment:i}=e;let s="",a=!0,o,l="",c="";function f(w){const _=a?w.replace(/^\xEF\xBB\xBF/,""):w,[b,N]=HT(`${s}${_}`);for(const m of b)d(m);s=N,a=!1}function d(w){if(w===""){p();return}if(w.startsWith(":")){i&&i(w.slice(w.startsWith(": ")?2:1));return}const _=w.indexOf(":");if(_!==-1){const b=w.slice(0,_),N=w[_+1]===" "?2:1,m=w.slice(_+N);h(b,m,w);return}h(w,"",w)}function h(w,_,b){switch(w){case"event":c=_;break;case"data":l=`${l}${_}
|
|
78
|
+
`;break;case"id":o=_.includes("\0")?void 0:_;break;case"retry":/^\d+$/.test(_)?r(parseInt(_,10)):n(new wc(`Invalid \`retry\` value: "${_}"`,{type:"invalid-retry",value:_,line:b}));break;default:n(new wc(`Unknown field "${w.length>20?`${w.slice(0,20)}…`:w}"`,{type:"unknown-field",field:w,value:_,line:b}));break}}function p(){l.length>0&&t({id:o,event:c||void 0,data:l.endsWith(`
|
|
79
|
+
`)?l.slice(0,-1):l}),o=void 0,l="",c=""}function g(w={}){s&&w.consume&&d(s),a=!0,o=void 0,l="",c="",s=""}return{feed:f,reset:g}}function HT(e){const t=[];let n="",r=0;for(;r<e.length;){const i=e.indexOf("\r",r),s=e.indexOf(`
|
|
80
|
+
`,r);let a=-1;if(i!==-1&&s!==-1?a=Math.min(i,s):i!==-1?i===e.length-1?a=-1:a=i:s!==-1&&(a=s),a===-1){n=e.slice(r);break}else{const o=e.slice(r,a);t.push(o),r=a+1,e[r-1]==="\r"&&e[r]===`
|
|
81
|
+
`&&r++}}return[t,n]}class WT extends TransformStream{constructor({onError:t,onRetry:n,onComment:r}={}){let i;super({start(s){i=JT({onEvent:a=>{s.enqueue(a)},onError(a){t==="terminate"?s.error(a):typeof t=="function"&&t(a)},onRetry:n,onComment:r})},transform(s){i.feed(s)}})}}var ki=({prefix:e,size:t=16,alphabet:n="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",separator:r="-"}={})=>{const i=()=>{const s=n.length,a=new Array(t);for(let o=0;o<t;o++)a[o]=n[Math.random()*s|0];return a.join("")};if(e==null)return i;if(n.includes(r))throw new sj({argument:"separator",message:`The separator "${r}" must not be part of the alphabet "${n}".`});return()=>`${e}${r}${i()}`},qT=ki();function qn(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 GT=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,YT=/"(?: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 kc(e){const t=JSON.parse(e);return t===null||typeof t!="object"||GT.test(e)===!1&&YT.test(e)===!1?t:KT(t)}function KT(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 XT(e){const{stackTraceLimit:t}=Error;try{Error.stackTraceLimit=0}catch{return kc(e)}try{return kc(e)}finally{Error.stackTraceLimit=t}}function nl(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]=En(n[r])}e.items!=null&&(e.items=Array.isArray(e.items)?e.items.map(En):En(e.items)),e.anyOf!=null&&(e.anyOf=e.anyOf.map(En)),e.allOf!=null&&(e.allOf=e.allOf.map(En)),e.oneOf!=null&&(e.oneOf=e.oneOf.map(En));const{definitions:t}=e;if(t!=null)for(const n of Object.keys(t))t[n]=En(t[n]);return e}function En(e){return typeof e=="boolean"?e:nl(e)}var QT=Symbol("Let zodToJsonSchema decide on which parser to use"),Sc={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"},eI=e=>typeof e=="string"?{...Sc,name:e}:{...Sc,...e};function It(){return{}}function tI(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)!==we.ZodAny&&(s.items=De(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 nI(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 rI(){return{type:"boolean"}}function km(e,t){return De(e.type._def,t)}var iI=(e,t)=>De(e.innerType._def,t);function Sm(e,t,n){const r=n??t.dateStrategy;if(Array.isArray(r))return{anyOf:r.map((i,s)=>Sm(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 sI(e)}}var sI=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 aI(e,t){return{...De(e.innerType._def,t),default:e.defaultValue()}}function oI(e,t){return t.effectStrategy==="input"?De(e.schema._def,t):It()}function lI(e){return{type:"string",enum:Array.from(e.values)}}var uI=e=>"type"in e&&e.type==="string"?!1:"allOf"in e;function cI(e,t){const n=[De(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),De(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(i=>!!i),r=[];return n.forEach(i=>{if(uI(i))r.push(...i.allOf);else{let s=i;if("additionalProperties"in i&&i.additionalProperties===!1){const{additionalProperties:a,...o}=i;s=o}r.push(s)}}),r.length?{allOf:r}:void 0}function dI(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 wa=void 0,Dt={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:()=>(wa===void 0&&(wa=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),wa),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 _m(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":Rt(n,"email",r.message,t);break;case"format:idn-email":Rt(n,"idn-email",r.message,t);break;case"pattern:zod":ut(n,Dt.email,r.message,t);break}break;case"url":Rt(n,"uri",r.message,t);break;case"uuid":Rt(n,"uuid",r.message,t);break;case"regex":ut(n,r.regex,r.message,t);break;case"cuid":ut(n,Dt.cuid,r.message,t);break;case"cuid2":ut(n,Dt.cuid2,r.message,t);break;case"startsWith":ut(n,RegExp(`^${ka(r.value,t)}`),r.message,t);break;case"endsWith":ut(n,RegExp(`${ka(r.value,t)}$`),r.message,t);break;case"datetime":Rt(n,"date-time",r.message,t);break;case"date":Rt(n,"date",r.message,t);break;case"time":Rt(n,"time",r.message,t);break;case"duration":Rt(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":{ut(n,RegExp(ka(r.value,t)),r.message,t);break}case"ip":{r.version!=="v6"&&Rt(n,"ipv4",r.message,t),r.version!=="v4"&&Rt(n,"ipv6",r.message,t);break}case"base64url":ut(n,Dt.base64url,r.message,t);break;case"jwt":ut(n,Dt.jwt,r.message,t);break;case"cidr":{r.version!=="v6"&&ut(n,Dt.ipv4Cidr,r.message,t),r.version!=="v4"&&ut(n,Dt.ipv6Cidr,r.message,t);break}case"emoji":ut(n,Dt.emoji(),r.message,t);break;case"ulid":{ut(n,Dt.ulid,r.message,t);break}case"base64":{switch(t.base64Strategy){case"format:binary":{Rt(n,"binary",r.message,t);break}case"contentEncoding:base64":{n.contentEncoding="base64";break}case"pattern:zod":{ut(n,Dt.base64,r.message,t);break}}break}case"nanoid":ut(n,Dt.nanoid,r.message,t)}return n}function ka(e,t){return t.patternStrategy==="escape"?pI(e):e}var fI=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function pI(e){let t="";for(let n=0;n<e.length;n++)fI.has(e[n])||(t+="\\"),t+=e[n];return t}function Rt(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 ut(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:_c(t,r),...n&&r.errorMessages&&{errorMessage:{pattern:n}}})):e.pattern=_c(t,r)}function _c(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="",a=!1,o=!1,l=!1;for(let c=0;c<i.length;c++){if(a){s+=i[c],a=!1;continue}if(r.i){if(o){if(i[c].match(/[a-z]/)){l?(s+=i[c],s+=`${i[c-2]}-${i[c]}`.toUpperCase(),l=!1):i[c+1]==="-"&&((n=i[c+2])!=null&&n.match(/[a-z]/))?(s+=i[c],l=!0):s+=`${i[c]}${i[c].toUpperCase()}`;continue}}else if(i[c].match(/[a-z]/)){s+=`[${i[c]}${i[c].toUpperCase()}]`;continue}}if(r.m){if(i[c]==="^"){s+=`(^|(?<=[\r
|
|
82
|
+
]))`;continue}else if(i[c]==="$"){s+=`($|(?=[\r
|
|
83
|
+
]))`;continue}}if(r.s&&i[c]==="."){s+=o?`${i[c]}\r
|
|
84
|
+
`:`[${i[c]}\r
|
|
85
|
+
]`;continue}s+=i[c],i[c]==="\\"?a=!0:o&&i[c]==="]"?o=!1:!o&&i[c]==="["&&(o=!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 jm(e,t){var n,r,i,s,a,o;const l={type:"object",additionalProperties:(n=De(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]}))!=null?n:t.allowedAdditionalProperties};if(((r=e.keyType)==null?void 0:r._def.typeName)===we.ZodString&&((i=e.keyType._def.checks)!=null&&i.length)){const{type:c,...f}=_m(e.keyType._def,t);return{...l,propertyNames:f}}else{if(((s=e.keyType)==null?void 0:s._def.typeName)===we.ZodEnum)return{...l,propertyNames:{enum:e.keyType._def.values}};if(((a=e.keyType)==null?void 0:a._def.typeName)===we.ZodBranded&&e.keyType._def.type._def.typeName===we.ZodString&&((o=e.keyType._def.type._def.checks)!=null&&o.length)){const{type:c,...f}=km(e.keyType._def,t);return{...l,propertyNames:f}}}return l}function hI(e,t){if(t.mapStrategy==="record")return jm(e,t);const n=De(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||It(),r=De(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||It();return{type:"array",maxItems:125,items:{type:"array",items:[n,r],minItems:2,maxItems:2}}}function mI(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 gI(){return{not:It()}}function xI(){return{type:"null"}}var no={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function yI(e,t){const n=e.options instanceof Map?Array.from(e.options.values()):e.options;if(n.every(r=>r._def.typeName in no&&(!r._def.checks||!r._def.checks.length))){const r=n.reduce((i,s)=>{const a=no[s._def.typeName];return a&&!i.includes(a)?[...i,a]: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 a=typeof s._def.value;switch(a){case"string":case"number":case"boolean":return[...i,a];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,a,o)=>o.indexOf(s)===a);return{type:i.length>1?i:i[0],enum:n.reduce((s,a)=>s.includes(a._def.value)?s:[...s,a._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 bI(e,t)}var bI=(e,t)=>{const n=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((r,i)=>De(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 vI(e,t){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return{type:[no[e.innerType._def.typeName],"null"]};const n=De(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return n&&{anyOf:[n,{type:"null"}]}}function wI(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 kI(e,t){const n={type:"object",properties:{}},r=[],i=e.shape();for(const a in i){let o=i[a];if(o===void 0||o._def===void 0)continue;const l=_I(o),c=De(o._def,{...t,currentPath:[...t.currentPath,"properties",a],propertyPath:[...t.currentPath,"properties",a]});c!==void 0&&(n.properties[a]=c,l||r.push(a))}r.length&&(n.required=r);const s=SI(e,t);return s!==void 0&&(n.additionalProperties=s),n}function SI(e,t){if(e.catchall._def.typeName!=="ZodNever")return De(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 _I(e){try{return e.isOptional()}catch{return!0}}var jI=(e,t)=>{var n;if(t.currentPath.toString()===((n=t.propertyPath)==null?void 0:n.toString()))return De(e.innerType._def,t);const r=De(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return r?{anyOf:[{not:It()},r]}:It()},NI=(e,t)=>{if(t.pipeStrategy==="input")return De(e.in._def,t);if(t.pipeStrategy==="output")return De(e.out._def,t);const n=De(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),r=De(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",n?"1":"0"]});return{allOf:[n,r].filter(i=>i!==void 0)}};function EI(e,t){return De(e.type._def,t)}function CI(e,t){const r={type:"array",uniqueItems:!0,items:De(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 TI(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((n,r)=>De(n._def,{...t,currentPath:[...t.currentPath,"items",`${r}`]})).reduce((n,r)=>r===void 0?n:[...n,r],[]),additionalItems:De(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((n,r)=>De(n._def,{...t,currentPath:[...t.currentPath,"items",`${r}`]})).reduce((n,r)=>r===void 0?n:[...n,r],[])}}function II(){return{not:It()}}function AI(){return It()}var zI=(e,t)=>De(e.innerType._def,t),OI=(e,t,n)=>{switch(t){case we.ZodString:return _m(e,n);case we.ZodNumber:return wI(e);case we.ZodObject:return kI(e,n);case we.ZodBigInt:return nI(e);case we.ZodBoolean:return rI();case we.ZodDate:return Sm(e,n);case we.ZodUndefined:return II();case we.ZodNull:return xI();case we.ZodArray:return tI(e,n);case we.ZodUnion:case we.ZodDiscriminatedUnion:return yI(e,n);case we.ZodIntersection:return cI(e,n);case we.ZodTuple:return TI(e,n);case we.ZodRecord:return jm(e,n);case we.ZodLiteral:return dI(e);case we.ZodEnum:return lI(e);case we.ZodNativeEnum:return mI(e);case we.ZodNullable:return vI(e,n);case we.ZodOptional:return jI(e,n);case we.ZodMap:return hI(e,n);case we.ZodSet:return CI(e,n);case we.ZodLazy:return()=>e.getter()._def;case we.ZodPromise:return EI(e,n);case we.ZodNaN:case we.ZodNever:return gI();case we.ZodEffects:return oI(e,n);case we.ZodAny:return It();case we.ZodUnknown:return AI();case we.ZodDefault:return aI(e,n);case we.ZodBranded:return km(e,n);case we.ZodReadonly:return zI(e,n);case we.ZodCatch:return iI(e,n);case we.ZodPipeline:return NI(e,n);case we.ZodFunction:case we.ZodVoid:case we.ZodSymbol:return;default:return(r=>{})()}},PI=(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 De(e,t,n=!1){var r;const i=t.seen.get(e);if(t.override){const l=(r=t.override)==null?void 0:r.call(t,e,t,i,n);if(l!==QT)return l}if(i&&!n){const l=DI(i,t);if(l!==void 0)return l}const s={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,s);const a=OI(e,e.typeName,t),o=typeof a=="function"?De(a(),t):a;if(o&&RI(e,t,o),t.postProcess){const l=t.postProcess(o,e,t);return s.jsonSchema=o,l}return s.jsonSchema=o,o}var DI=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:PI(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`),It()):t.$refStrategy==="seen"?It():void 0}},RI=(e,t,n)=>(e.description&&(n.description=e.description),n),MI=e=>{const t=eI(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}]))}},$I=(e,t)=>{var n;const r=MI(t);let i=typeof t=="object"&&t.definitions?Object.entries(t.definitions).reduce((c,[f,d])=>{var h;return{...c,[f]:(h=De(d._def,{...r,currentPath:[...r.basePath,r.definitionPath,f]},!0))!=null?h:It()}},{}):void 0;const s=typeof t=="string"?t:(t==null?void 0:t.nameStrategy)==="title"||t==null?void 0:t.name,a=(n=De(e._def,s===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,s]},!1))!=null?n:It(),o=typeof t=="object"&&t.name!==void 0&&t.nameStrategy==="title"?t.name:void 0;o!==void 0&&(a.title=o);const l=s===void 0?i?{...a,[r.definitionPath]:i}:a:{$ref:[...r.$refStrategy==="relative"?[]:r.basePath,r.definitionPath,s].join("/"),[r.definitionPath]:{...i,[s]:a}};return l.$schema="http://json-schema.org/draft-07/schema#",l},ro=Symbol.for("vercel.ai.schema");function FI(e){let t;return()=>(t==null&&(t=e()),t)}function Zs(e,{validate:t}={}){return{[ro]:!0,_type:void 0,get jsonSchema(){return typeof e=="function"&&(e=e()),e},validate:t}}function LI(e){return typeof e=="object"&&e!==null&&ro in e&&e[ro]===!0&&"jsonSchema"in e&&"validate"in e}function rl(e){return e==null?Zs({properties:{},additionalProperties:!1}):LI(e)?e:"~standard"in e?e["~standard"].vendor==="zod"?Nm(e):BI(e):e()}function BI(e){return Zs(()=>nl(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 br({value:t,cause:n.issues})}}})}function ZI(e,t){var n;const r=(n=void 0)!=null?n:!1;return Zs(()=>$I(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 VI(e,t){var n;const r=(n=void 0)!=null?n:!1;return Zs(()=>nl(EC(e,{target:"draft-7",io:"input",reused:r?"ref":"inline"})),{validate:async i=>{const s=await fm(e,i);return s.success?{success:!0,value:s.data}:{success:!1,error:s.error}}})}function UI(e){return"_zod"in e}function Nm(e,t){return UI(e)?VI(e):ZI(e)}async function jc({value:e,schema:t,context:n}){const r=await pi({value:e,schema:t,context:n});if(!r.success)throw br.wrap({value:e,cause:r.error,context:n});return r.value}async function pi({value:e,schema:t,context:n}){const r=rl(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:br.wrap({value:e,cause:i.error,context:n}),rawValue:e}}catch(i){return{success:!1,error:br.wrap({value:e,cause:i,context:n}),rawValue:e}}}async function Mn({text:e,schema:t}){try{const n=XT(e);return t==null?{success:!0,value:n,rawValue:n}:await pi({value:n,schema:t})}catch(n){return{success:!1,error:qu.isInstance(n)?n:new qu({text:e,cause:n}),rawValue:void 0}}}function JI({stream:e,schema:t}){return e.pipeThrough(new TextDecoderStream).pipeThrough(new WT).pipeThrough(new TransformStream({async transform({data:n},r){n!=="[DONE]"&&r.enqueue(await Mn({text:n,schema:t}))}}))}async function pn(e){return typeof e=="function"&&(e=e()),Promise.resolve(e)}var HI=Object.defineProperty,WI=(e,t)=>{for(var n in t)HI(e,n,{get:t[n],enumerable:!0})},Em="AI_NoObjectGeneratedError",Cm=`vercel.ai.error.${Em}`,qI=Symbol.for(Cm),Tm,xn=class extends Xt{constructor({message:e="No object generated.",cause:t,text:n,response:r,usage:i,finishReason:s}){super({name:Em,message:e,cause:t}),this[Tm]=!0,this.text=n,this.response=r,this.usage=i,this.finishReason=s}static isInstance(e){return Xt.hasMarker(e,Cm)}};Tm=qI;var Im="AI_UIMessageStreamError",Am=`vercel.ai.error.${Im}`,GI=Symbol.for(Am),zm,Gn=class extends Xt{constructor({chunkType:e,chunkId:t,message:n}){super({name:Im,message:n}),this[zm]=!0,this.chunkType=e,this.chunkId=t}static isInstance(e){return Xt.hasMarker(e,Am)}};zm=GI;var Om=mt([ae(),ms(Uint8Array),ms(ArrayBuffer),wm(e=>{var t,n;return(n=(t=globalThis.Buffer)==null?void 0:t.isBuffer(e))!=null?n:!1},{message:"Must be a Buffer"})]),hi=ZT(()=>mt([gT(),ae(),fT(),dt(),di(ae(),hi.optional()),Cr(hi)])),Ee=di(ae(),di(ae(),hi.optional())),Pm=$e({type:be("text"),text:ae(),providerOptions:Ee.optional()}),YI=$e({type:be("image"),image:mt([Om,ms(URL)]),mediaType:ae().optional(),providerOptions:Ee.optional()}),Dm=$e({type:be("file"),data:mt([Om,ms(URL)]),filename:ae().optional(),mediaType:ae(),providerOptions:Ee.optional()}),KI=$e({type:be("reasoning"),text:ae(),providerOptions:Ee.optional()}),XI=$e({type:be("tool-call"),toolCallId:ae(),toolName:ae(),input:qt(),providerOptions:Ee.optional(),providerExecuted:dt().optional()}),QI=wT("type",[$e({type:be("text"),value:ae(),providerOptions:Ee.optional()}),$e({type:be("json"),value:hi,providerOptions:Ee.optional()}),$e({type:be("execution-denied"),reason:ae().optional(),providerOptions:Ee.optional()}),$e({type:be("error-text"),value:ae(),providerOptions:Ee.optional()}),$e({type:be("error-json"),value:hi,providerOptions:Ee.optional()}),$e({type:be("content"),value:Cr(mt([$e({type:be("text"),text:ae(),providerOptions:Ee.optional()}),$e({type:be("media"),data:ae(),mediaType:ae()}),$e({type:be("file-data"),data:ae(),mediaType:ae(),filename:ae().optional(),providerOptions:Ee.optional()}),$e({type:be("file-url"),url:ae(),providerOptions:Ee.optional()}),$e({type:be("file-id"),fileId:mt([ae(),di(ae(),ae())]),providerOptions:Ee.optional()}),$e({type:be("image-data"),data:ae(),mediaType:ae(),providerOptions:Ee.optional()}),$e({type:be("image-url"),url:ae(),providerOptions:Ee.optional()}),$e({type:be("image-file-id"),fileId:mt([ae(),di(ae(),ae())]),providerOptions:Ee.optional()}),$e({type:be("custom"),providerOptions:Ee.optional()})]))})]),Rm=$e({type:be("tool-result"),toolCallId:ae(),toolName:ae(),output:QI,providerOptions:Ee.optional()}),eA=$e({type:be("tool-approval-request"),approvalId:ae(),toolCallId:ae()}),tA=$e({type:be("tool-approval-response"),approvalId:ae(),approved:dt(),reason:ae().optional()}),nA=$e({role:be("system"),content:ae(),providerOptions:Ee.optional()}),rA=$e({role:be("user"),content:mt([ae(),Cr(mt([Pm,YI,Dm]))]),providerOptions:Ee.optional()}),iA=$e({role:be("assistant"),content:mt([ae(),Cr(mt([Pm,Dm,KI,XI,Rm,eA]))]),providerOptions:Ee.optional()}),sA=$e({role:be("tool"),content:Cr(mt([Rm,tA])),providerOptions:Ee.optional()});mt([nA,rA,iA,sA]);function Mm(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,a=i!==null&&typeof i=="object"&&!Array.isArray(i)&&!(i instanceof Date)&&!(i instanceof RegExp),o=s!=null&&typeof s=="object"&&!Array.isArray(s)&&!(s instanceof Date)&&!(s instanceof RegExp);a&&o?n[r]=Mm(s,i):n[r]=i}return n}var aA={};WI(aA,{array:()=>cA,choice:()=>dA,json:()=>fA,object:()=>uA,text:()=>lA});function oA(e){const t=["ROOT"];let n=-1,r=null;function i(l,c,f){switch(l){case'"':{n=c,t.pop(),t.push(f),t.push("INSIDE_STRING");break}case"f":case"t":case"n":{n=c,r=c,t.pop(),t.push(f),t.push("INSIDE_LITERAL");break}case"-":{t.pop(),t.push(f),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=c,t.pop(),t.push(f),t.push("INSIDE_NUMBER");break}case"{":{n=c,t.pop(),t.push(f),t.push("INSIDE_OBJECT_START");break}case"[":{n=c,t.pop(),t.push(f),t.push("INSIDE_ARRAY_START");break}}}function s(l,c){switch(l){case",":{t.pop(),t.push("INSIDE_OBJECT_AFTER_COMMA");break}case"}":{n=c,t.pop();break}}}function a(l,c){switch(l){case",":{t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{n=c,t.pop();break}}}for(let l=0;l<e.length;l++){const c=e[l];switch(t[t.length-1]){case"ROOT":i(c,l,"FINISH");break;case"INSIDE_OBJECT_START":{switch(c){case'"':{t.pop(),t.push("INSIDE_OBJECT_KEY");break}case"}":{n=l,t.pop();break}}break}case"INSIDE_OBJECT_AFTER_COMMA":{switch(c){case'"':{t.pop(),t.push("INSIDE_OBJECT_KEY");break}}break}case"INSIDE_OBJECT_KEY":{switch(c){case'"':{t.pop(),t.push("INSIDE_OBJECT_AFTER_KEY");break}}break}case"INSIDE_OBJECT_AFTER_KEY":{switch(c){case":":{t.pop(),t.push("INSIDE_OBJECT_BEFORE_VALUE");break}}break}case"INSIDE_OBJECT_BEFORE_VALUE":{i(c,l,"INSIDE_OBJECT_AFTER_VALUE");break}case"INSIDE_OBJECT_AFTER_VALUE":{s(c,l);break}case"INSIDE_STRING":{switch(c){case'"':{t.pop(),n=l;break}case"\\":{t.push("INSIDE_STRING_ESCAPE");break}default:n=l}break}case"INSIDE_ARRAY_START":{switch(c){case"]":{n=l,t.pop();break}default:{n=l,i(c,l,"INSIDE_ARRAY_AFTER_VALUE");break}}break}case"INSIDE_ARRAY_AFTER_VALUE":{switch(c){case",":{t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{n=l,t.pop();break}default:{n=l;break}}break}case"INSIDE_ARRAY_AFTER_COMMA":{i(c,l,"INSIDE_ARRAY_AFTER_VALUE");break}case"INSIDE_STRING_ESCAPE":{t.pop(),n=l;break}case"INSIDE_NUMBER":{switch(c){case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{n=l;break}case"e":case"E":case"-":case".":break;case",":{t.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&a(c,l),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&s(c,l);break}case"}":{t.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&s(c,l);break}case"]":{t.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&a(c,l);break}default:{t.pop();break}}break}case"INSIDE_LITERAL":{const d=e.substring(r,l+1);!"false".startsWith(d)&&!"true".startsWith(d)&&!"null".startsWith(d)?(t.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"?s(c,l):t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&a(c,l)):n=l;break}}}let o=e.slice(0,n+1);for(let l=t.length-1;l>=0;l--)switch(t[l]){case"INSIDE_STRING":{o+='"';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":{o+="}";break}case"INSIDE_ARRAY_START":case"INSIDE_ARRAY_AFTER_COMMA":case"INSIDE_ARRAY_AFTER_VALUE":{o+="]";break}case"INSIDE_LITERAL":{const f=e.substring(r,e.length);"true".startsWith(f)?o+="true".slice(f.length):"false".startsWith(f)?o+="false".slice(f.length):"null".startsWith(f)&&(o+="null".slice(f.length))}}return o}async function Si(e){if(e===void 0)return{value:void 0,state:"undefined-input"};let t=await Mn({text:e});return t.success?{value:t.value,state:"successful-parse"}:(t=await Mn({text:oA(e)}),t.success?{value:t.value,state:"repaired-parse"}:{value:void 0,state:"failed-parse"})}var lA=()=>({name:"text",responseFormat:Promise.resolve({type:"text"}),async parseCompleteOutput({text:e}){return e},async parsePartialOutput({text:e}){return{partial:e}},createElementStreamTransform(){}}),uA=({schema:e,name:t,description:n})=>{const r=rl(e);return{name:"object",responseFormat:pn(r.jsonSchema).then(i=>({type:"json",schema:i,...t!=null&&{name:t},...n!=null&&{description:n}})),async parseCompleteOutput({text:i},s){const a=await Mn({text:i});if(!a.success)throw new xn({message:"No object generated: could not parse the response.",cause:a.error,text:i,response:s.response,usage:s.usage,finishReason:s.finishReason});const o=await pi({value:a.value,schema:r});if(!o.success)throw new xn({message:"No object generated: response did not match schema.",cause:o.error,text:i,response:s.response,usage:s.usage,finishReason:s.finishReason});return o.value},async parsePartialOutput({text:i}){const s=await Si(i);switch(s.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return{partial:s.value}}},createElementStreamTransform(){}}},cA=({element:e,name:t,description:n})=>{const r=rl(e);return{name:"array",responseFormat:pn(r.jsonSchema).then(i=>{const{$schema:s,...a}=i;return{type:"json",schema:{$schema:"http://json-schema.org/draft-07/schema#",type:"object",properties:{elements:{type:"array",items:a}},required:["elements"],additionalProperties:!1},...t!=null&&{name:t},...n!=null&&{description:n}}}),async parseCompleteOutput({text:i},s){const a=await Mn({text:i});if(!a.success)throw new xn({message:"No object generated: could not parse the response.",cause:a.error,text:i,response:s.response,usage:s.usage,finishReason:s.finishReason});const o=a.value;if(o==null||typeof o!="object"||!("elements"in o)||!Array.isArray(o.elements))throw new xn({message:"No object generated: response did not match schema.",cause:new br({value:o,cause:"response must be an object with an elements array"}),text:i,response:s.response,usage:s.usage,finishReason:s.finishReason});for(const l of o.elements){const c=await pi({value:l,schema:r});if(!c.success)throw new xn({message:"No object generated: response did not match schema.",cause:c.error,text:i,response:s.response,usage:s.usage,finishReason:s.finishReason})}return o.elements},async parsePartialOutput({text:i}){const s=await Si(i);switch(s.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":{const a=s.value;if(a==null||typeof a!="object"||!("elements"in a)||!Array.isArray(a.elements))return;const o=s.state==="repaired-parse"&&a.elements.length>0?a.elements.slice(0,-1):a.elements,l=[];for(const c of o){const f=await pi({value:c,schema:r});f.success&&l.push(f.value)}return{partial:l}}}},createElementStreamTransform(){let i=0;return new TransformStream({transform({partialOutput:s},a){if(s!=null)for(;i<s.length;i++)a.enqueue(s[i])}})}}},dA=({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 Mn({text:r});if(!s.success)throw new xn({message:"No object generated: could not parse the response.",cause:s.error,text:r,response:i.response,usage:i.usage,finishReason:i.finishReason});const a=s.value;if(a==null||typeof a!="object"||!("result"in a)||typeof a.result!="string"||!e.includes(a.result))throw new xn({message:"No object generated: response did not match schema.",cause:new br({value:a,cause:"response must be an object that contains a choice value."}),text:r,response:i.response,usage:i.usage,finishReason:i.finishReason});return a.result},async parsePartialOutput({text:r}){const i=await Si(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 a=e.filter(o=>o.startsWith(s.result));return i.state==="successful-parse"?a.includes(s.result)?{partial:s.result}:void 0:a.length===1?{partial:a[0]}:void 0}}},createElementStreamTransform(){}}),fA=({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 Mn({text:n});if(!i.success)throw new xn({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 Si(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(){}});ki({prefix:"aitxt",size:24});(class extends TransformStream{constructor(){super({transform(e,t){t.enqueue(`data: ${JSON.stringify(e)}
|
|
86
|
+
|
|
87
|
+
`)},flush(e){e.enqueue(`data: [DONE]
|
|
88
|
+
|
|
89
|
+
`)}})}});var pA=FI(()=>Nm(mt([Ve({type:be("text-start"),id:ae(),providerMetadata:Ee.optional()}),Ve({type:be("text-delta"),id:ae(),delta:ae(),providerMetadata:Ee.optional()}),Ve({type:be("text-end"),id:ae(),providerMetadata:Ee.optional()}),Ve({type:be("error"),errorText:ae()}),Ve({type:be("tool-input-start"),toolCallId:ae(),toolName:ae(),providerExecuted:dt().optional(),providerMetadata:Ee.optional(),dynamic:dt().optional(),title:ae().optional()}),Ve({type:be("tool-input-delta"),toolCallId:ae(),inputTextDelta:ae()}),Ve({type:be("tool-input-available"),toolCallId:ae(),toolName:ae(),input:qt(),providerExecuted:dt().optional(),providerMetadata:Ee.optional(),dynamic:dt().optional(),title:ae().optional()}),Ve({type:be("tool-input-error"),toolCallId:ae(),toolName:ae(),input:qt(),providerExecuted:dt().optional(),providerMetadata:Ee.optional(),dynamic:dt().optional(),errorText:ae(),title:ae().optional()}),Ve({type:be("tool-approval-request"),approvalId:ae(),toolCallId:ae()}),Ve({type:be("tool-output-available"),toolCallId:ae(),output:qt(),providerExecuted:dt().optional(),providerMetadata:Ee.optional(),dynamic:dt().optional(),preliminary:dt().optional()}),Ve({type:be("tool-output-error"),toolCallId:ae(),errorText:ae(),providerExecuted:dt().optional(),providerMetadata:Ee.optional(),dynamic:dt().optional()}),Ve({type:be("tool-output-denied"),toolCallId:ae()}),Ve({type:be("reasoning-start"),id:ae(),providerMetadata:Ee.optional()}),Ve({type:be("reasoning-delta"),id:ae(),delta:ae(),providerMetadata:Ee.optional()}),Ve({type:be("reasoning-end"),id:ae(),providerMetadata:Ee.optional()}),Ve({type:be("source-url"),sourceId:ae(),url:ae(),title:ae().optional(),providerMetadata:Ee.optional()}),Ve({type:be("source-document"),sourceId:ae(),mediaType:ae(),title:ae(),filename:ae().optional(),providerMetadata:Ee.optional()}),Ve({type:be("file"),url:ae(),mediaType:ae(),providerMetadata:Ee.optional()}),Ve({type:wm(e=>typeof e=="string"&&e.startsWith("data-"),{message:'Type must start with "data-"'}),id:ae().optional(),data:qt(),transient:dt().optional()}),Ve({type:be("start-step")}),Ve({type:be("finish-step")}),Ve({type:be("start"),messageId:ae().optional(),messageMetadata:qt().optional()}),Ve({type:be("finish"),finishReason:ym(["stop","length","content-filter","tool-calls","error","other"]).optional(),messageMetadata:qt().optional()}),Ve({type:be("abort"),reason:ae().optional()}),Ve({type:be("message-metadata"),messageMetadata:qt()})])));function hA(e){return e.type.startsWith("data-")}function io(e){return e.type.startsWith("tool-")}function mA(e){return e.type==="dynamic-tool"}function xs(e){return io(e)||mA(e)}function Nc(e){return e.type.split("-").slice(1).join("-")}function gA({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 xA({stream:e,messageMetadataSchema:t,dataPartSchemas:n,runUpdateMessageJob:r,onError:i,onToolCall:s,onData:a}){return e.pipeThrough(new TransformStream({async transform(o,l){await r(async({state:c,write:f})=>{var d,h,p,g;function w(m){const C=c.message.parts.filter(xs).find(v=>v.toolCallId===m);if(C==null)throw new Gn({chunkType:"tool-invocation",chunkId:m,message:`No tool invocation found for tool call ID "${m}".`});return C}function _(m){var O;const C=c.message.parts.find($=>io($)&&$.toolCallId===m.toolCallId),v=m,k=C;if(C!=null){C.state=m.state,k.input=v.input,k.output=v.output,k.errorText=v.errorText,k.rawInput=v.rawInput,k.preliminary=v.preliminary,m.title!==void 0&&(k.title=m.title),k.providerExecuted=(O=v.providerExecuted)!=null?O:C.providerExecuted;const $=v.providerMetadata;if($!=null)if(m.state==="output-available"||m.state==="output-error"){const H=C;H.resultProviderMetadata=$}else C.callProviderMetadata=$}else c.message.parts.push({type:`tool-${m.toolName}`,toolCallId:m.toolCallId,state:m.state,title:m.title,input:v.input,output:v.output,rawInput:v.rawInput,errorText:v.errorText,providerExecuted:v.providerExecuted,preliminary:v.preliminary,...v.providerMetadata!=null&&(m.state==="output-available"||m.state==="output-error")?{resultProviderMetadata:v.providerMetadata}:{},...v.providerMetadata!=null&&!(m.state==="output-available"||m.state==="output-error")?{callProviderMetadata:v.providerMetadata}:{}})}function b(m){var O,C;const v=c.message.parts.find(H=>H.type==="dynamic-tool"&&H.toolCallId===m.toolCallId),k=m,$=v;if(v!=null){v.state=m.state,$.toolName=m.toolName,$.input=k.input,$.output=k.output,$.errorText=k.errorText,$.rawInput=(O=k.rawInput)!=null?O:$.rawInput,$.preliminary=k.preliminary,m.title!==void 0&&($.title=m.title),$.providerExecuted=(C=k.providerExecuted)!=null?C:v.providerExecuted;const H=k.providerMetadata;if(H!=null)if(m.state==="output-available"||m.state==="output-error"){const j=v;j.resultProviderMetadata=H}else v.callProviderMetadata=H}else c.message.parts.push({type:"dynamic-tool",toolName:m.toolName,toolCallId:m.toolCallId,state:m.state,input:k.input,output:k.output,errorText:k.errorText,preliminary:k.preliminary,providerExecuted:k.providerExecuted,title:m.title,...k.providerMetadata!=null&&(m.state==="output-available"||m.state==="output-error")?{resultProviderMetadata:k.providerMetadata}:{},...k.providerMetadata!=null&&!(m.state==="output-available"||m.state==="output-error")?{callProviderMetadata:k.providerMetadata}:{}})}async function N(m){if(m!=null){const O=c.message.metadata!=null?Mm(c.message.metadata,m):m;t!=null&&await jc({value:O,schema:t,context:{field:"message.metadata",entityId:c.message.id}}),c.message.metadata=O}}switch(o.type){case"text-start":{const m={type:"text",text:"",providerMetadata:o.providerMetadata,state:"streaming"};c.activeTextParts[o.id]=m,c.message.parts.push(m),f();break}case"text-delta":{const m=c.activeTextParts[o.id];if(m==null)throw new Gn({chunkType:"text-delta",chunkId:o.id,message:`Received text-delta for missing text part with ID "${o.id}". Ensure a "text-start" chunk is sent before any "text-delta" chunks.`});m.text+=o.delta,m.providerMetadata=(d=o.providerMetadata)!=null?d:m.providerMetadata,f();break}case"text-end":{const m=c.activeTextParts[o.id];if(m==null)throw new Gn({chunkType:"text-end",chunkId:o.id,message:`Received text-end for missing text part with ID "${o.id}". Ensure a "text-start" chunk is sent before any "text-end" chunks.`});m.state="done",m.providerMetadata=(h=o.providerMetadata)!=null?h:m.providerMetadata,delete c.activeTextParts[o.id],f();break}case"reasoning-start":{const m={type:"reasoning",text:"",providerMetadata:o.providerMetadata,state:"streaming"};c.activeReasoningParts[o.id]=m,c.message.parts.push(m),f();break}case"reasoning-delta":{const m=c.activeReasoningParts[o.id];if(m==null)throw new Gn({chunkType:"reasoning-delta",chunkId:o.id,message:`Received reasoning-delta for missing reasoning part with ID "${o.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-delta" chunks.`});m.text+=o.delta,m.providerMetadata=(p=o.providerMetadata)!=null?p:m.providerMetadata,f();break}case"reasoning-end":{const m=c.activeReasoningParts[o.id];if(m==null)throw new Gn({chunkType:"reasoning-end",chunkId:o.id,message:`Received reasoning-end for missing reasoning part with ID "${o.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-end" chunks.`});m.providerMetadata=(g=o.providerMetadata)!=null?g:m.providerMetadata,m.state="done",delete c.activeReasoningParts[o.id],f();break}case"file":{c.message.parts.push({type:"file",mediaType:o.mediaType,url:o.url,...o.providerMetadata!=null?{providerMetadata:o.providerMetadata}:{}}),f();break}case"source-url":{c.message.parts.push({type:"source-url",sourceId:o.sourceId,url:o.url,title:o.title,providerMetadata:o.providerMetadata}),f();break}case"source-document":{c.message.parts.push({type:"source-document",sourceId:o.sourceId,mediaType:o.mediaType,title:o.title,filename:o.filename,providerMetadata:o.providerMetadata}),f();break}case"tool-input-start":{const m=c.message.parts.filter(io);c.partialToolCalls[o.toolCallId]={text:"",toolName:o.toolName,index:m.length,dynamic:o.dynamic,title:o.title},o.dynamic?b({toolCallId:o.toolCallId,toolName:o.toolName,state:"input-streaming",input:void 0,providerExecuted:o.providerExecuted,title:o.title,providerMetadata:o.providerMetadata}):_({toolCallId:o.toolCallId,toolName:o.toolName,state:"input-streaming",input:void 0,providerExecuted:o.providerExecuted,title:o.title,providerMetadata:o.providerMetadata}),f();break}case"tool-input-delta":{const m=c.partialToolCalls[o.toolCallId];if(m==null)throw new Gn({chunkType:"tool-input-delta",chunkId:o.toolCallId,message:`Received tool-input-delta for missing tool call with ID "${o.toolCallId}". Ensure a "tool-input-start" chunk is sent before any "tool-input-delta" chunks.`});m.text+=o.inputTextDelta;const{value:O}=await Si(m.text);m.dynamic?b({toolCallId:o.toolCallId,toolName:m.toolName,state:"input-streaming",input:O,title:m.title}):_({toolCallId:o.toolCallId,toolName:m.toolName,state:"input-streaming",input:O,title:m.title}),f();break}case"tool-input-available":{o.dynamic?b({toolCallId:o.toolCallId,toolName:o.toolName,state:"input-available",input:o.input,providerExecuted:o.providerExecuted,providerMetadata:o.providerMetadata,title:o.title}):_({toolCallId:o.toolCallId,toolName:o.toolName,state:"input-available",input:o.input,providerExecuted:o.providerExecuted,providerMetadata:o.providerMetadata,title:o.title}),f(),s&&!o.providerExecuted&&await s({toolCall:o});break}case"tool-input-error":{const m=c.message.parts.filter(xs).find(C=>C.toolCallId===o.toolCallId);(m!=null?m.type==="dynamic-tool":!!o.dynamic)?b({toolCallId:o.toolCallId,toolName:o.toolName,state:"output-error",input:o.input,errorText:o.errorText,providerExecuted:o.providerExecuted,providerMetadata:o.providerMetadata}):_({toolCallId:o.toolCallId,toolName:o.toolName,state:"output-error",input:void 0,rawInput:o.input,errorText:o.errorText,providerExecuted:o.providerExecuted,providerMetadata:o.providerMetadata}),f();break}case"tool-approval-request":{const m=w(o.toolCallId);m.state="approval-requested",m.approval={id:o.approvalId},f();break}case"tool-output-denied":{const m=w(o.toolCallId);m.state="output-denied",f();break}case"tool-output-available":{const m=w(o.toolCallId);m.type==="dynamic-tool"?b({toolCallId:o.toolCallId,toolName:m.toolName,state:"output-available",input:m.input,output:o.output,preliminary:o.preliminary,providerExecuted:o.providerExecuted,providerMetadata:o.providerMetadata,title:m.title}):_({toolCallId:o.toolCallId,toolName:Nc(m),state:"output-available",input:m.input,output:o.output,providerExecuted:o.providerExecuted,preliminary:o.preliminary,providerMetadata:o.providerMetadata,title:m.title}),f();break}case"tool-output-error":{const m=w(o.toolCallId);m.type==="dynamic-tool"?b({toolCallId:o.toolCallId,toolName:m.toolName,state:"output-error",input:m.input,errorText:o.errorText,providerExecuted:o.providerExecuted,providerMetadata:o.providerMetadata,title:m.title}):_({toolCallId:o.toolCallId,toolName:Nc(m),state:"output-error",input:m.input,rawInput:m.rawInput,errorText:o.errorText,providerExecuted:o.providerExecuted,providerMetadata:o.providerMetadata,title:m.title}),f();break}case"start-step":{c.message.parts.push({type:"step-start"});break}case"finish-step":{c.activeTextParts={},c.activeReasoningParts={};break}case"start":{o.messageId!=null&&(c.message.id=o.messageId),await N(o.messageMetadata),(o.messageId!=null||o.messageMetadata!=null)&&f();break}case"finish":{o.finishReason!=null&&(c.finishReason=o.finishReason),await N(o.messageMetadata),o.messageMetadata!=null&&f();break}case"message-metadata":{await N(o.messageMetadata),o.messageMetadata!=null&&f();break}case"error":{i==null||i(new Error(o.errorText));break}default:if(hA(o)){if((n==null?void 0:n[o.type])!=null){const C=c.message.parts.findIndex(k=>"id"in k&&"data"in k&&k.id===o.id&&k.type===o.type),v=C>=0?C:c.message.parts.length;await jc({value:o.data,schema:n[o.type],context:{field:`message.parts[${v}].data`,entityName:o.type,entityId:o.id}})}const m=o;if(m.transient){a==null||a(m);break}const O=m.id!=null?c.message.parts.find(C=>m.type===C.type&&m.id===C.id):void 0;O!=null?O.data=m.data:c.message.parts.push(m),a==null||a(m),f()}}l.enqueue(o)})}}))}async function yA({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()}}ki({prefix:"aitxt",size:24});ki({prefix:"aiobj",size:24});var bA=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()})}};ki({prefix:"aiobj",size:24});async function vA(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,a)=>{const o=new FileReader;o.onload=l=>{var c;s((c=l.target)==null?void 0:c.result)},o.onerror=l=>a(l),o.readAsDataURL(t)});return{type:"file",mediaType:r,filename:n,url:i}}))}var wA=class{constructor({api:e="/api/chat",credentials:t,headers:n,body:r,fetch:i,prepareSendMessagesRequest:s,prepareReconnectToStreamRequest:a}){this.api=e,this.credentials=t,this.headers=n,this.body=r,this.fetch=i,this.prepareSendMessagesRequest=s,this.prepareReconnectToStreamRequest=a}async sendMessages({abortSignal:e,...t}){var n,r,i,s,a;const o=await pn(this.body),l=await pn(this.headers),c=await pn(this.credentials),f={...qn(l),...qn(t.headers)},d=await((n=this.prepareSendMessagesRequest)==null?void 0:n.call(this,{api:this.api,id:t.chatId,messages:t.messages,body:{...o,...t.body},headers:f,credentials:c,requestMetadata:t.metadata,trigger:t.trigger,messageId:t.messageId})),h=(r=d==null?void 0:d.api)!=null?r:this.api,p=(d==null?void 0:d.headers)!==void 0?qn(d.headers):f,g=(d==null?void 0:d.body)!==void 0?d.body:{...o,...t.body,id:t.chatId,messages:t.messages,trigger:t.trigger,messageId:t.messageId},w=(i=d==null?void 0:d.credentials)!=null?i:c,b=await((s=this.fetch)!=null?s:globalThis.fetch)(h,{method:"POST",headers:{"Content-Type":"application/json",...p},body:JSON.stringify(g),credentials:w,signal:e});if(!b.ok)throw new Error((a=await b.text())!=null?a:"Failed to fetch the chat response.");if(!b.body)throw new Error("The response body is empty.");return this.processResponseStream(b.body)}async reconnectToStream(e){var t,n,r,i,s;const a=await pn(this.body),o=await pn(this.headers),l=await pn(this.credentials),c={...qn(o),...qn(e.headers)},f=await((t=this.prepareReconnectToStreamRequest)==null?void 0:t.call(this,{api:this.api,id:e.chatId,body:{...a,...e.body},headers:c,credentials:l,requestMetadata:e.metadata})),d=(n=f==null?void 0:f.api)!=null?n:`${this.api}/${e.chatId}/stream`,h=(f==null?void 0:f.headers)!==void 0?qn(f.headers):c,p=(r=f==null?void 0:f.credentials)!=null?r:l,w=await((i=this.fetch)!=null?i:globalThis.fetch)(d,{method:"GET",headers:h,credentials:p});if(w.status===204)return null;if(!w.ok)throw new Error((s=await w.text())!=null?s:"Failed to fetch the chat response.");if(!w.body)throw new Error("The response body is empty.");return this.processResponseStream(w.body)}},$m=class extends wA{constructor(e={}){super(e)}processResponseStream(e){return JI({stream:e,schema:pA}).pipeThrough(new TransformStream({async transform(t,n){if(!t.success)throw t.error;n.enqueue(t.value)}}))}},kA=class{constructor({generateId:e=qT,id:t=e(),transport:n=new $m,messageMetadataSchema:r,dataPartSchemas:i,state:s,onError:a,onToolCall:o,onFinish:l,onData:c,sendAutomaticallyWhen:f}){this.activeResponse=void 0,this.jobExecutor=new bA,this.sendMessage=async(d,h)=>{var p,g,w,_;if(d==null){await this.makeRequest({trigger:"submit-message",messageId:(p=this.lastMessage)==null?void 0:p.id,...h});return}let b;if("text"in d||"files"in d?b={parts:[...Array.isArray(d.files)?d.files:await vA(d.files),..."text"in d&&d.text!=null?[{type:"text",text:d.text}]:[]]}:b=d,d.messageId!=null){const N=this.state.messages.findIndex(m=>m.id===d.messageId);if(N===-1)throw new Error(`message with id ${d.messageId} not found`);if(this.state.messages[N].role!=="user")throw new Error(`message with id ${d.messageId} is not a user message`);this.state.messages=this.state.messages.slice(0,N+1),this.state.replaceMessage(N,{...b,id:d.messageId,role:(g=b.role)!=null?g:"user",metadata:d.metadata})}else this.state.pushMessage({...b,id:(w=b.id)!=null?w:this.generateId(),role:(_=b.role)!=null?_:"user",metadata:d.metadata});await this.makeRequest({trigger:"submit-message",messageId:d.messageId,...h})},this.regenerate=async({messageId:d,...h}={})=>{const p=d==null?this.state.messages.length-1:this.state.messages.findIndex(g=>g.id===d);if(p===-1)throw new Error(`message ${d} 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:d,...h})},this.resumeStream=async(d={})=>{await this.makeRequest({trigger:"resume-stream",...d})},this.clearError=()=>{this.status==="error"&&(this.state.error=void 0,this.setStatus({status:"ready"}))},this.addToolApprovalResponse=async({id:d,approved:h,reason:p,options:g})=>this.jobExecutor.run(async()=>{const w=this.state.messages,_=w[w.length-1],b=N=>xs(N)&&N.state==="approval-requested"&&N.approval.id===d?{...N,state:"approval-responded",approval:{id:d,approved:h,reason:p}}:N;this.state.replaceMessage(w.length-1,{..._,parts:_.parts.map(b)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(b)),this.status!=="streaming"&&this.status!=="submitted"&&this.sendAutomaticallyWhen&&this.shouldSendAutomatically().then(N=>{var m;N&&this.makeRequest({trigger:"submit-message",messageId:(m=this.lastMessage)==null?void 0:m.id,...g})})}),this.addToolOutput=async({state:d="output-available",toolCallId:h,output:p,errorText:g,options:w})=>this.jobExecutor.run(async()=>{const _=this.state.messages,b=_[_.length-1],N=m=>xs(m)&&m.toolCallId===h?{...m,state:d,output:p,errorText:g}:m;this.state.replaceMessage(_.length-1,{...b,parts:b.parts.map(N)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(N)),this.status!=="streaming"&&this.status!=="submitted"&&this.sendAutomaticallyWhen&&this.shouldSendAutomatically().then(m=>{var O;m&&this.makeRequest({trigger:"submit-message",messageId:(O=this.lastMessage)==null?void 0:O.id,...w})})}),this.addToolResult=this.addToolOutput,this.stop=async()=>{var d;this.status!=="streaming"&&this.status!=="submitted"||(d=this.activeResponse)!=null&&d.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=a,this.onToolCall=o,this.onFinish=l,this.onData=c,this.sendAutomaticallyWhen=f}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,a,o;let l;if(e==="resume-stream")try{const p=await this.transport.reconnectToStream({chatId:this.id,metadata:t,headers:n,body:r});if(p==null)return;l=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 c=this.lastMessage;let f=!1,d=!1,h=!1;try{const p={state:gA({lastMessage:this.state.snapshot(c),messageId:this.generateId()}),abortController:new AbortController};p.abortController.signal.addEventListener("abort",()=>{f=!0}),this.activeResponse=p;let g;e==="resume-stream"?g=l:g=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 w=_=>this.jobExecutor.run(()=>_({state:p.state,write:()=>{var b;this.setStatus({status:"streaming"}),p.state.message.id===((b=this.lastMessage)==null?void 0:b.id)?this.state.replaceMessage(this.state.messages.length-1,p.state.message):this.state.pushMessage(p.state.message)}}));await yA({stream:xA({stream:g,onToolCall:this.onToolCall,onData:this.onData,messageMetadataSchema:this.messageMetadataSchema,dataPartSchemas:this.dataPartSchemas,runUpdateMessageJob:w,onError:_=>{throw _}}),onError:_=>{throw _}}),this.setStatus({status:"ready"})}catch(p){if(f||p.name==="AbortError")return f=!0,this.setStatus({status:"ready"}),null;h=!0,p instanceof TypeError&&(p.message.toLowerCase().includes("fetch")||p.message.toLowerCase().includes("network"))&&(d=!0),this.onError&&p instanceof Error&&this.onError(p),this.setStatus({status:"error",error:p})}finally{try{(a=this.onFinish)==null||a.call(this,{message:this.activeResponse.state.message,messages:this.state.messages,isAbort:f,isDisconnect:d,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:(o=this.lastMessage)==null?void 0:o.id,metadata:t,headers:n,body:r})}},Sa,Ec;function SA(){if(Ec)return Sa;Ec=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(...a){clearTimeout(r);const o=Date.now(),l=o-i,c=n-l;c<=0?(i=o,t.apply(this,a)):r=setTimeout(()=>{i=Date.now(),t.apply(this,a)},c)}}return Sa=e,Sa}var _A=SA();const jA=uo(_A);var Fm=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},Ue=(e,t,n)=>(Fm(e,t,"read from private field"),n?n.call(e):t.get(e)),Jt=(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)},fn=(e,t,n,r)=>(Fm(e,t,"write to private field"),t.set(e,n),n);function NA(e,t){return t!=null?jA(e,t):e}var At,Vi,Ui,Ur,Jr,Hr,Qn,so,ao,EA=class{constructor(e=[]){Jt(this,At,void 0),Jt(this,Vi,"ready"),Jt(this,Ui,void 0),Jt(this,Ur,new Set),Jt(this,Jr,new Set),Jt(this,Hr,new Set),this.pushMessage=t=>{fn(this,At,Ue(this,At).concat(t)),Ue(this,Qn).call(this)},this.popMessage=()=>{fn(this,At,Ue(this,At).slice(0,-1)),Ue(this,Qn).call(this)},this.replaceMessage=(t,n)=>{fn(this,At,[...Ue(this,At).slice(0,t),this.snapshot(n),...Ue(this,At).slice(t+1)]),Ue(this,Qn).call(this)},this.snapshot=t=>structuredClone(t),this["~registerMessagesCallback"]=(t,n)=>{const r=n?NA(t,n):t;return Ue(this,Ur).add(r),()=>{Ue(this,Ur).delete(r)}},this["~registerStatusCallback"]=t=>(Ue(this,Jr).add(t),()=>{Ue(this,Jr).delete(t)}),this["~registerErrorCallback"]=t=>(Ue(this,Hr).add(t),()=>{Ue(this,Hr).delete(t)}),Jt(this,Qn,()=>{Ue(this,Ur).forEach(t=>t())}),Jt(this,so,()=>{Ue(this,Jr).forEach(t=>t())}),Jt(this,ao,()=>{Ue(this,Hr).forEach(t=>t())}),fn(this,At,e)}get status(){return Ue(this,Vi)}set status(e){fn(this,Vi,e),Ue(this,so).call(this)}get error(){return Ue(this,Ui)}set error(e){fn(this,Ui,e),Ue(this,ao).call(this)}get messages(){return Ue(this,At)}set messages(e){fn(this,At,[...e]),Ue(this,Qn).call(this)}};At=new WeakMap;Vi=new WeakMap;Ui=new WeakMap;Ur=new WeakMap;Jr=new WeakMap;Hr=new WeakMap;Qn=new WeakMap;so=new WeakMap;ao=new WeakMap;var er,Cc=class extends kA{constructor({messages:e,...t}){const n=new EA(e);super({...t,state:n}),Jt(this,er,void 0),this["~registerMessagesCallback"]=(r,i)=>Ue(this,er)["~registerMessagesCallback"](r,i),this["~registerStatusCallback"]=r=>Ue(this,er)["~registerStatusCallback"](r),this["~registerErrorCallback"]=r=>Ue(this,er)["~registerErrorCallback"](r),fn(this,er,n)}};er=new WeakMap;function CA({experimental_throttle:e,resume:t=!1,...n}={}){const r=x.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,g;return(g=(p=r.current).onToolCall)==null?void 0:g.call(p,h)},onData:h=>{var p,g;return(g=(p=r.current).onData)==null?void 0:g.call(p,h)},onFinish:h=>{var p,g;return(g=(p=r.current).onFinish)==null?void 0:g.call(p,h)},onError:h=>{var p,g;return(g=(p=r.current).onError)==null?void 0:g.call(p,h)},sendAutomaticallyWhen:h=>{var p,g,w;return(w=(g=(p=r.current).sendAutomaticallyWhen)==null?void 0:g.call(p,h))!=null?w:!1}},s=x.useRef("chat"in n?n.chat:new Cc(i));("chat"in n&&n.chat!==s.current||"id"in n&&s.current.id!==n.id)&&(s.current="chat"in n?n.chat:new Cc(i));const o=x.useCallback(h=>s.current["~registerMessagesCallback"](h,e),[e,s.current.id]),l=x.useSyncExternalStore(o,()=>s.current.messages,()=>s.current.messages),c=x.useSyncExternalStore(s.current["~registerStatusCallback"],()=>s.current.status,()=>s.current.status),f=x.useSyncExternalStore(s.current["~registerErrorCallback"],()=>s.current.error,()=>s.current.error),d=x.useCallback(h=>{typeof h=="function"&&(h=h(s.current.messages)),s.current.messages=h},[s]);return x.useEffect(()=>{t&&s.current.resumeStream()},[t,s]),{id:s.current.id,messages:l,setMessages:d,sendMessage:s.current.sendMessage,regenerate:s.current.regenerate,clearError:s.current.clearError,stop:s.current.stop,error:f,resumeStream:s.current.resumeStream,status:c,addToolResult:s.current.addToolOutput,addToolOutput:s.current.addToolOutput,addToolApprovalResponse:s.current.addToolApprovalResponse}}function Lm(e,t){const n=[...e];for(const r of t){if(!r||typeof r.name!="string")continue;const i=n.findIndex(s=>s.name===r.name);r._delete?i!==-1&&n.splice(i,1):i!==-1?n[i]=r:n.push(r)}return n}function Bm(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 Zm(e,t,n){if(!(n!=null&&n.selectedText)){const i=TA(e,t);if(i)return i}if(n!=null&&n.selectedText){const i=n.selectedText,s=e.indexOf(i);if(s!==-1){const o=e.indexOf(i,s+1);let l;if(o===-1)l=s;else if(n.startLine&&n.startLine>0){const d=DA(e,n.startLine);l=RA(e,i,d)}else l=s;const c=e.slice(0,l),f=e.slice(l+i.length);return{original:e,modified:c+t+f}}if(n.startLine&&n.endLine){const o=OA(e,t,n.startLine,n.endLine);if(o)return o}const a=Tc(e,t);return a||{original:e,modified:t}}const r=Tc(e,t);return r||{original:e,modified:t}}function TA(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+)"/),a=s?s[1].length:2;if(!oo(i,r,n))return null;const o=JSON.stringify(i,null,a);return{original:e,modified:o}}function oo(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(oo(i,t,n))return!0}return!1}if(e&&typeof e=="object"){for(const r of Object.values(e))if(oo(r,t,n))return!0}return!1}function Tc(e,t){try{const s=JSON.parse(t);if(s&&typeof s=="object"&&!Array.isArray(s))try{const a=JSON.parse(e);if(a&&typeof a=="object"&&!Array.isArray(a)){const o=Object.keys(s).sort().join(","),l=Object.keys(a).sort().join(",");if(o===l)return null}}catch{}}catch{}const n=IA(t);if(n.length===0)return null;let r=e,i=!1;for(const s of n){const a=AA(r,t,s);a&&(r=a,i=!0)}return i?{original:e,modified:r}:null}function IA(e){const t=[],n=e.split(`
|
|
90
|
+
`),r=n.find(s=>s.trim().length>0);if(!r)return t;const i=r.search(/\S/);for(const s of n){const a=s.search(/\S/);if(a<0||a!==i)continue;const o=s.match(/^\s*"([^"]+)"\s*:/);o&&t.push(o[1])}return[...new Set(t)]}function AA(e,t,n){const r=`"${n}"`,i=Ic(e,r);if(i.length===0)return null;const s=Ic(t,r);if(s.length===0)return null;const a=s[0],o=t.slice(a.start,a.end);let l=0;if(i.length>1){let f=-1;for(let d=0;d<i.length;d++){const h=e.slice(i[d].start,i[d].end),p=PA(h,o);p>f&&(f=p,l=d)}}const c=i[l];return e.slice(0,c.start)+o+e.slice(c.end)}function Ic(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 a=s<0?"":e[s];if(a!==""&&a!=="{"&&a!==","&&a!==`
|
|
91
|
+
`&&a!=="\r"){r=i+1;continue}const o=e.indexOf(":",i+t.length);if(o===-1){r=i+1;continue}const l=o+1,c=zA(e,l);if(c===-1){r=i+1;continue}n.push({start:i,end:c}),r=c}return n}function zA(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 a=1,o=t+1,l=!1;for(;o<e.length&&a>0;){if(e[o]==="\\"&&l){o+=2;continue}e[o]==='"'&&(l=!l),l||(e[o]===i?a++:e[o]===s&&a--),o++}return a===0?o:-1}let r=t;for(;r<e.length&&/[^\s,\]}]/.test(e[r]);)r++;return r>t?r:-1}function OA(e,t,n,r){const i=e.split(`
|
|
92
|
+
`);if(n<1||r<n||n>i.length)return null;const s=i.slice(0,n-1).join(`
|
|
93
|
+
`),a=i.slice(r).join(`
|
|
94
|
+
`),o=s+(s?`
|
|
95
|
+
`:"")+t+(a?`
|
|
96
|
+
`:"")+a;return{original:e,modified:o}}function PA(e,t){if(e===t)return 1;if(!e.length||!t.length)return 0;const n=3,r=new Set;for(let a=0;a<=e.length-n;a++)r.add(e.slice(a,a+n));let i=0;for(let a=0;a<=t.length-n;a++)r.has(t.slice(a,a+n))&&i++;const s=Math.max(e.length-n+1,t.length-n+1);return s>0?i/s:0}function DA(e,t){let n=0;const r=e.split(`
|
|
97
|
+
`);for(let i=0;i<Math.min(t-1,r.length);i++)n+=r[i].length+1;return n}function RA(e,t,n){let r=-1,i=1/0,s=e.indexOf(t);for(;s!==-1;){const a=Math.abs(s-n);a<i&&(i=a,r=s),s=e.indexOf(t,s+1)}return r}function MA(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(`
|
|
98
|
+
`);try{return JSON.parse(n),n}catch{}}return null}function $A(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==="templates"&&Array.isArray(i.templates))r.props||(r.props={}),r.props.templates=Lm(r.props.templates||[],i.templates);else return null;return{original:e,modified:JSON.stringify(r,null,2)}}catch{return null}}function FA(){const e=Pe(U=>U.threads),t=Pe(U=>U.activeThreadId),n=Pe(U=>U.updateThreadMessages),r=Pe(U=>U.updateThreadTitle),i=Pe(U=>U.clearContext),s=Pe(U=>U.contextAttachments),a=Pe(U=>U.scope),o=Pe(U=>U.model),l=Ne(U=>U.activeTab),c=Ne(U=>U.documents),f=Ne(U=>U.documentTypes),d=Ne(U=>U.setPendingDiff),h=Ne(U=>U.createDocument),p=Ne(U=>U.openDocument),g=x.useRef(e);g.current=e;const w=x.useRef(l);w.current=l;const _=x.useRef(c);_.current=c;const b=x.useRef(f);b.current=f;const N=x.useRef(t);N.current=t;const m=l?t[l]:void 0,O=x.useRef(m);O.current=m;const C=x.useRef([]),v=x.useRef([]),k=x.useRef({}),$=x.useRef({}),[,H]=x.useState(0),j=x.useCallback(()=>H(U=>U+1),[]),I=x.useRef(null);I.current||(I.current=new $m({api:"/api/ai/chat"}));const T=x.useCallback(()=>{const U=_.current.find(J=>J.name===w.current);return U?{name:U.name,text:U.text}:void 0},[]),P=x.useCallback(U=>k.current[U]||[],[]),A=CA({transport:I.current,onError:()=>{C.current.shift(),v.current.shift(),i()},onFinish:({messages:U})=>{var q,X;const J=O.current;if(J){n(J,U);const Y=g.current[J];if(Y&&Y.title.startsWith("Chat ")){const ie=U.find(D=>D.role==="user");if(ie){const D=((q=ie.parts)==null?void 0:q.filter(ue=>ue.type==="text").map(ue=>ue.text).join(""))||"";if(D){const ue=D.length>50?D.slice(0,50)+"...":D;r(J,ue)}}}}const ne=C.current.shift()||[],S=v.current.shift()||"global",oe=U.filter(Y=>Y.role==="user"),B=oe[oe.length-1];B!=null&&B.id&&(k.current[B.id]=ne,$.current[B.id]=S);const y=U.filter(Y=>Y.role==="assistant").pop();if(y){const ie=[...(((X=y.parts)==null?void 0:X.filter(D=>D.type==="text").map(D=>D.text).join(""))||"").matchAll(/```(?:json|jsonc)\s*\n([\s\S]*?)```/g)];if(ie.length>0){const D=MA(ie);if(D){const ue=ie[ie.length-1][1],he=w.current;if(he){const ce=_.current.find(We=>We.name===he),ee=(ce==null?void 0:ce.text)||"",de=ne[0],fe=$A(ee,D,S);!fe&&S!=="global"&&console.warn(`[chat] scopedMerge failed for scope="${S}", falling back to text merge`);const{original:Re,modified:Oe}=fe??Zm(ee,D,de);d(he,Re,Oe,Bm(ue.replace(/\n$/,"")))}else{const ce=`ai-generated-${Date.now()}`;h(ce,D),p(ce)}}}}i()}});x.useEffect(()=>{const U=A.messages.filter(J=>J.role==="user");for(let J=U.length-1;J>=0;J--){const ne=U[J].id;if(ne in k.current)break;C.current.length>0&&(k.current[ne]=C.current[0],$.current[ne]=v.current[0]||"global",j());break}},[A.messages,j]);const M=x.useCallback((U,J)=>{C.current.push([...s]),v.current.push(a),i();const ne={text:U};J!=null&&J.length&&(ne.files=J),A.sendMessage(ne,{body:{format:ht,context:s,activeDocument:T(),documentType:w.current&&b.current[w.current]||"application/json+report",scope:a,model:o}})},[A.sendMessage,s,T,i,a,o]),V=x.useCallback(U=>$.current[U],[]);return{messages:A.messages,sendMessage:M,status:A.status,error:A.error,setMessages:A.setMessages,stop:A.stop,getMessageContext:P,getMessageScope:V}}const Vm=x.createContext(null);function LA({children:e}){const t=FA();return u.jsx(Vm.Provider,{value:t,children:e})}function BA(){const e=x.useContext(Vm);if(!e)throw new Error("useChatSessionContext must be used within ChatSessionProvider");return e}function ZA(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 VA(e,t=50){const n=e.replace(/[\n\r]+/g," ").replace(/\s+/g," ").trim();return n.length>t?n.slice(0,t)+"…":n}function Um({context:e,onRemove:t,variant:n="default"}){var c;const r=ZA(e),i=((c=e.documentName)==null?void 0:c.replace(/\.json$/,""))??"",s=i?`${i} › ${r}`:r,a=VA(e.selectedText),o=n==="sent",l=u.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 ${o?"border-primary-foreground/20 bg-primary-foreground/10 hover:bg-primary-foreground/20":"border-primary/20 bg-primary/5 hover:bg-primary/10"}`,children:[u.jsx(nx,{className:`h-3 w-3 shrink-0 ${o?"text-primary-foreground/60":"text-primary/60"}`}),u.jsx("span",{className:"truncate font-medium",children:s}),t&&u.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:u.jsx(yn,{className:"h-3 w-3"})})]});return u.jsxs(Ye,{children:[u.jsx(Ke,{asChild:!0,children:l}),u.jsxs(Xe,{side:"top",className:"max-w-xs",children:[u.jsx("p",{className:"text-xs font-medium mb-0.5",children:s}),u.jsx("p",{className:"text-xs text-muted-foreground font-mono",children:a}),e.jsonPath&&u.jsx("p",{className:"text-[10px] text-muted-foreground/60 mt-1",children:e.jsonPath})]})]})}class Yn extends Error{constructor(t,n){super(`${t} at position ${n}`),this.position=n}}const Jm=32,UA=10,Hm=9,Wm=13,JA=160,HA=6158,WA=8192,qA=8203,GA=8239,YA=8287,KA=12288,XA=65279;function QA(e){return/^[0-9A-Fa-f]$/.test(e)}function Cn(e){return e>="0"&&e<="9"}function ez(e){return e>=" "}function Ri(e){return`,:[]/{}()
|
|
99
|
+
+`.includes(e)}function Ac(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"||e==="_"||e==="$"}function zc(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"||e==="_"||e==="$"||e>="0"&&e<="9"}const Oc=/^(http|https|ftp|mailto|file|data|irc):\/\/$/,Pc=/^[A-Za-z0-9-._~:/?#@!$&'()*+;=]$/;function Dc(e){return`,[]/{}
|
|
100
|
+
+`.includes(e)}function Rc(e){return Ji(e)||tz.test(e)}const tz=/^[[{\w-]$/;function nz(e){return e===`
|
|
101
|
+
`||e==="\r"||e===" "||e==="\b"||e==="\f"}function Tn(e,t){const n=e.charCodeAt(t);return n===Jm||n===UA||n===Hm||n===Wm}function rz(e,t){const n=e.charCodeAt(t);return n===Jm||n===Hm||n===Wm}function iz(e,t){const n=e.charCodeAt(t);return n===JA||n===HA||n>=WA&&n<=qA||n===GA||n===YA||n===KA||n===XA}function Ji(e){return qm(e)||lo(e)}function qm(e){return e==='"'||e==="“"||e==="”"}function Mc(e){return e==='"'}function lo(e){return e==="'"||e==="‘"||e==="’"||e==="`"||e==="´"}function $c(e){return e==="'"}function $r(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 Mt(e,t){let n=e.length;if(!Tn(e,n-1))return e+t;for(;Tn(e,n-1);)n--;return e.substring(0,n)+t+e.substring(n)}function sz(e,t,n){return e.substring(0,t)+e.substring(t+n)}function az(e){return/[,\n][ \t\r]*$/.test(e)}const oz={"\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t"},lz={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:`
|
|
102
|
+
`,r:"\r",t:" "};function Fc(e){let t=0,n="";c(["```","[```","{```"]),s()||A(),c(["```","```]","```}"]);const i=d(",");for(i&&a(),Rc(e[t])&&az(n)?(i||(n=Mt(n,",")),b()):i&&(n=$r(n,","));e[t]==="}"||e[t]==="]";)t++,a();if(t>=e.length)return n;P();function s(){a();const J=w()||_()||N()||O()||C()||k(!1)||$();return a(),J}function a(){let J=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;const ne=t;let S=o(J);do S=l(),S&&(S=o(J));while(S);return t>ne}function o(J){const ne=J?Tn:rz;let S="";for(;;)if(ne(e,t))S+=e[t],t++;else if(iz(e,t))S+=" ",t++;else break;return S.length>0?(n+=S,!0):!1}function l(){if(e[t]==="/"&&e[t+1]==="*"){for(;t<e.length&&!uz(e,t);)t++;return t+=2,!0}if(e[t]==="/"&&e[t+1]==="/"){for(;t<e.length&&e[t]!==`
|
|
103
|
+
`;)t++;return!0}return!1}function c(J){if(f(J)){if(Ac(e[t]))for(;t<e.length&&zc(e[t]);)t++;return a(),!0}return!1}function f(J){o(!0);for(const ne of J){const S=t+ne.length;if(e.slice(t,S)===ne)return t=S,!0}return!1}function d(J){return e[t]===J?(n+=e[t],t++,!0):!1}function h(J){return e[t]===J?(t++,!0):!1}function p(){return h("\\")}function g(){return a(),e[t]==="."&&e[t+1]==="."&&e[t+2]==="."?(t+=3,a(),h(","),!0):!1}function w(){if(e[t]==="{"){n+="{",t++,a(),h(",")&&a();let J=!0;for(;t<e.length&&e[t]!=="}";){let ne;if(J?(ne=!0,J=!1):(ne=d(","),ne||(n=Mt(n,",")),a()),g(),!(N()||k(!0))){e[t]==="}"||e[t]==="{"||e[t]==="]"||e[t]==="["||e[t]===void 0?n=$r(n,","):M();break}a();const oe=d(":"),B=t>=e.length;oe||(Rc(e[t])||B?n=Mt(n,":"):V()),s()||(oe||B?n+="null":V())}return e[t]==="}"?(n+="}",t++):n=Mt(n,"}"),!0}return!1}function _(){if(e[t]==="["){n+="[",t++,a(),h(",")&&a();let J=!0;for(;t<e.length&&e[t]!=="]";)if(J?J=!1:d(",")||(n=Mt(n,",")),g(),!s()){n=$r(n,",");break}return e[t]==="]"?(n+="]",t++):n=Mt(n,"]"),!0}return!1}function b(){let J=!0,ne=!0;for(;ne;)J?J=!1:d(",")||(n=Mt(n,",")),ne=s();ne||(n=$r(n,",")),n=`[
|
|
104
|
+
${n}
|
|
105
|
+
]`}function N(){let J=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,ne=arguments.length>1&&arguments[1]!==void 0?arguments[1]:-1,S=e[t]==="\\";if(S&&(t++,S=!0),Ji(e[t])){const oe=Mc(e[t])?Mc:$c(e[t])?$c:lo(e[t])?lo:qm,B=t,y=n.length;let q='"';for(t++;;){if(t>=e.length){const X=H(t-1);return!J&&Ri(e.charAt(X))?(t=B,n=n.substring(0,y),N(!0)):(q=Mt(q,'"'),n+=q,!0)}if(t===ne)return q=Mt(q,'"'),n+=q,!0;if(oe(e[t])){const X=t,Y=q.length;if(q+='"',t++,n+=q,a(!1),J||t>=e.length||Ri(e[t])||Ji(e[t])||Cn(e[t]))return m(),!0;const ie=H(X-1),D=e.charAt(ie);if(D===",")return t=B,n=n.substring(0,y),N(!1,ie);if(Ri(D))return t=B,n=n.substring(0,y),N(!0);n=n.substring(0,y),t=X+1,q=`${q.substring(0,Y)}\\${q.substring(Y)}`}else if(J&&Dc(e[t])){if(e[t-1]===":"&&Oc.test(e.substring(B+1,t+2)))for(;t<e.length&&Pc.test(e[t]);)q+=e[t],t++;return q=Mt(q,'"'),n+=q,m(),!0}else if(e[t]==="\\"){const X=e.charAt(t+1);if(lz[X]!==void 0)q+=e.slice(t,t+2),t+=2;else if(X==="u"){let ie=2;for(;ie<6&&QA(e[t+ie]);)ie++;ie===6?(q+=e.slice(t,t+6),t+=6):t+ie>=e.length?t=e.length:U()}else q+=X,t+=2}else{const X=e.charAt(t);X==='"'&&e[t-1]!=="\\"?(q+=`\\${X}`,t++):nz(X)?(q+=oz[X],t++):(ez(X)||T(X),q+=X,t++)}S&&p()}}return!1}function m(){let J=!1;for(a();e[t]==="+";){J=!0,t++,a(),n=$r(n,'"',!0);const ne=n.length;N()?n=sz(n,ne,1):n=Mt(n,'"')}return J}function O(){const J=t;if(e[t]==="-"){if(t++,j())return I(J),!0;if(!Cn(e[t]))return t=J,!1}for(;Cn(e[t]);)t++;if(e[t]==="."){if(t++,j())return I(J),!0;if(!Cn(e[t]))return t=J,!1;for(;Cn(e[t]);)t++}if(e[t]==="e"||e[t]==="E"){if(t++,(e[t]==="-"||e[t]==="+")&&t++,j())return I(J),!0;if(!Cn(e[t]))return t=J,!1;for(;Cn(e[t]);)t++}if(!j())return t=J,!1;if(t>J){const ne=e.slice(J,t),S=/^0\d/.test(ne);return n+=S?`"${ne}"`:ne,!0}return!1}function C(){return v("true","true")||v("false","false")||v("null","null")||v("True","true")||v("False","false")||v("None","null")}function v(J,ne){return e.slice(t,t+J.length)===J?(n+=ne,t+=J.length,!0):!1}function k(J){const ne=t;if(Ac(e[t])){for(;t<e.length&&zc(e[t]);)t++;let S=t;for(;Tn(e,S);)S++;if(e[S]==="(")return t=S+1,s(),e[t]===")"&&(t++,e[t]===";"&&t++),!0}for(;t<e.length&&!Dc(e[t])&&!Ji(e[t])&&(!J||e[t]!==":");)t++;if(e[t-1]===":"&&Oc.test(e.substring(ne,t+2)))for(;t<e.length&&Pc.test(e[t]);)t++;if(t>ne){for(;Tn(e,t-1)&&t>0;)t--;const S=e.slice(ne,t);return n+=S==="undefined"?"null":JSON.stringify(S),e[t]==='"'&&t++,!0}}function $(){if(e[t]==="/"){const J=t;for(t++;t<e.length&&(e[t]!=="/"||e[t-1]==="\\");)t++;return t++,n+=JSON.stringify(e.substring(J,t)),!0}}function H(J){let ne=J;for(;ne>0&&Tn(e,ne);)ne--;return ne}function j(){return t>=e.length||Ri(e[t])||Tn(e,t)}function I(J){n+=`${e.slice(J,t)}0`}function T(J){throw new Yn(`Invalid character ${JSON.stringify(J)}`,t)}function P(){throw new Yn(`Unexpected character ${JSON.stringify(e[t])}`,t)}function A(){throw new Yn("Unexpected end of json string",e.length)}function M(){throw new Yn("Object key expected",t)}function V(){throw new Yn("Colon expected",t)}function U(){const J=e.slice(t,t+6);throw new Yn(`Invalid unicode character "${J}"`,t)}}function uz(e,t){return e[t]==="*"&&e[t+1]==="/"}function cz({json:e,context:t,scope:n}){const[r,i]=x.useState(!1),[s,a]=x.useState(null),o=x.useMemo(()=>{try{return JSON.parse(e),e}catch{}try{return Fc(e)}catch{}const b=`{${e}}`;try{return JSON.parse(b),b}catch{}try{return Fc(b)}catch{return null}},[e]),l=x.useMemo(()=>Bm(o||e),[o,e]),c=Ne(b=>b.activeTab),f=Ne(b=>b.documents),d=Ne(b=>(b.acceptedApplyIds||[]).includes(l)),h=Ne(b=>b.setPendingDiff),p=Ne(b=>b.createDocument),g=Ne(b=>b.openDocument),w=x.useCallback(()=>{if(o){a(null);try{if(c){const b=f.find(v=>v.name===c),N=(b==null?void 0:b.text)||"";if(n==="templates")try{const v=JSON.parse(N),k=JSON.parse(o);if(Array.isArray(k.templates)){v.props||(v.props={}),v.props.templates=Lm(v.props.templates||[],k.templates);const $=JSON.stringify(v,null,2);h(c,N,$,l);return}}catch{}const m=t==null?void 0:t[0],{original:O,modified:C}=Zm(N,o,m);h(c,O,C,l)}else{const b=`ai-generated-${Date.now()}`;p(b,o),g(b)}}catch(b){a(b instanceof Error?b.message:"Merge failed")}}},[o,c,f,h,p,g,t,n,l]),_=x.useCallback(async()=>{await navigator.clipboard.writeText(e),i(!0),setTimeout(()=>i(!1),1500)},[e]);return u.jsxs("div",{className:"flex flex-col gap-1 px-3 py-2 border-t",children:[u.jsxs("div",{className:"flex gap-1.5",children:[u.jsx(Se,{variant:"secondary",size:"sm",onClick:w,disabled:d||!o,children:d?"Applied":o?"Apply to Editor":"Invalid JSON"}),u.jsx(Se,{variant:"ghost",size:"sm",onClick:_,children:r?u.jsx(an,{className:"h-3.5 w-3.5"}):u.jsx(ks,{className:"h-3.5 w-3.5"})})]}),s&&u.jsx("p",{className:"text-xs text-destructive m-0",children:s})]})}function dz({threads:e,activeThread:t,disabled:n,onSwitch:r,onCreate:i,onDelete:s,onRename:a}){const[o,l]=x.useState(null),[c,f]=x.useState(""),[d,h]=x.useState(null),p=x.useRef(null),g=(t==null?void 0:t.title)||"New Chat",w=g.length>24?g.slice(0,24)+"...":g;x.useEffect(()=>{o&&requestAnimationFrame(()=>{var k;return(k=p.current)==null?void 0:k.focus()})},[o]);const _=x.useCallback((k,$)=>{$.stopPropagation(),$.preventDefault(),l(k.id),f(k.title),h(null)},[]),b=x.useCallback(()=>{o&&c.trim()&&a(o,c.trim()),l(null),f("")},[o,c,a]),N=x.useCallback(()=>{l(null),f("")},[]),m=x.useCallback(k=>{k.stopPropagation(),k.key==="Enter"?(k.preventDefault(),b()):k.key==="Escape"&&(k.preventDefault(),N())},[b,N]),O=x.useCallback((k,$)=>{$.stopPropagation(),$.preventDefault(),h(k),l(null)},[]),C=x.useCallback(k=>{k.stopPropagation(),k.preventDefault(),d&&(s(d),h(null))},[d,s]),v=x.useCallback(k=>{k.stopPropagation(),k.preventDefault(),h(null)},[]);return u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsxs(Ns,{onOpenChange:k=>{k||(l(null),h(null))},children:[u.jsx(Es,{asChild:!0,disabled:n,children:u.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:[u.jsx("div",{className:"h-2 w-2 rounded-full bg-primary/70 shrink-0"}),u.jsx("span",{className:"truncate",children:w}),u.jsx(mi,{className:"h-3 w-3 shrink-0 opacity-60"})]})}),u.jsxs(yi,{align:"start",className:"w-64",children:[e.map(k=>{const $=o===k.id;return d===k.id?u.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 text-sm",children:[u.jsx("span",{className:"text-destructive text-xs flex-1 truncate",children:"Delete this thread?"}),u.jsx("button",{className:"shrink-0 text-destructive hover:text-destructive/80 transition-colors cursor-pointer",onClick:C,children:u.jsx(an,{className:"h-3.5 w-3.5"})}),u.jsx("button",{className:"shrink-0 text-muted-foreground hover:text-foreground transition-colors cursor-pointer",onClick:v,children:u.jsx(yn,{className:"h-3.5 w-3.5"})})]},k.id):$?u.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1",onClick:j=>j.stopPropagation(),onPointerDown:j=>j.stopPropagation(),children:[u.jsx("input",{ref:p,type:"text",value:c,onChange:j=>f(j.target.value),onKeyDown:m,onBlur:b,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"}),u.jsx("button",{className:"shrink-0 text-primary hover:text-primary/80 transition-colors cursor-pointer",onMouseDown:j=>{j.preventDefault(),b()},children:u.jsx(an,{className:"h-3.5 w-3.5"})}),u.jsx("button",{className:"shrink-0 text-muted-foreground hover:text-foreground transition-colors cursor-pointer",onMouseDown:j=>{j.preventDefault(),N()},children:u.jsx(yn,{className:"h-3.5 w-3.5"})})]},k.id):u.jsxs($t,{onSelect:()=>r(k.id),className:`group ${k.id===(t==null?void 0:t.id)?"bg-accent":""}`,children:[u.jsx("span",{className:"truncate flex-1",children:k.title.length>30?k.title.slice(0,30)+"...":k.title}),u.jsxs("div",{className:"ml-auto shrink-0 flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[u.jsx("button",{className:"text-muted-foreground hover:text-foreground transition-colors p-0.5 cursor-pointer",onClick:j=>_(k,j),children:u.jsx(rx,{className:"h-3 w-3"})}),e.length>1&&u.jsx("button",{className:"text-muted-foreground hover:text-destructive transition-colors p-0.5 cursor-pointer",onClick:j=>O(k.id,j),children:u.jsx(fo,{className:"h-3 w-3"})})]})]},k.id)}),u.jsx(mr,{}),u.jsxs($t,{onSelect:k=>{k.preventDefault();const $=i();$&&(l($),f(vo()),h(null))},children:[u.jsx(nn,{className:"h-3.5 w-3.5 mr-1.5"}),"New Chat"]})]})]}),u.jsx(Se,{variant:"ghost",size:"icon",className:"h-6 w-6 text-muted-foreground hover:text-foreground",onClick:()=>i(),disabled:n,title:"New chat thread",children:u.jsx(nn,{className:"h-3.5 w-3.5"})})]})}const Gm=new Set(["image/png","image/jpeg","image/gif","image/webp","application/pdf","text/plain","text/markdown","text/csv","text/html"]),fz=Array.from(Gm).join(","),pz=20*1024*1024,Lc=10;function hz(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 Bc(e){return Array.from(e).filter(t=>Gm.has(t.type)&&t.size<=pz)}function Ym(e){return e.startsWith("image/")}function Zc(){var Q,me,ve;const e=Pe(F=>F.contextAttachments),t=Pe(F=>F.addContext),n=Pe(F=>F.removeContext),r=Pe(F=>F.scope),i=Pe(F=>F.setScope),s=Pe(F=>F.model),a=Pe(F=>F.setModel),o=Pe(F=>F.openChat),l=Pe(F=>F.closeChat),c=Pe(F=>F.threads),f=Pe(F=>F.activeThreadId),d=Pe(F=>F.createThread),h=Pe(F=>F.deleteThread),p=Pe(F=>F.switchThread),g=Pe(F=>F.updateThreadMessages),w=Pe(F=>F.updateThreadTitle),_=Pe(F=>F.deleteThreadsForDocument),b=Ne(F=>F.activeTab),N=Ne(F=>F.documents),{messages:m,sendMessage:O,status:C,error:v,setMessages:k,stop:$,getMessageContext:H,getMessageScope:j}=BA(),[I,T]=x.useState(""),[P,A]=x.useState([]),[M,V]=x.useState(!1),[U,J]=x.useState(!1),ne=x.useRef(null),S=x.useRef(null),oe=x.useRef(null),B=x.useCallback(async F=>{const ge=Bc(F);if(ge.length===0)return;const Te=await Promise.all(ge.map(hz));A(Le=>{const rt=[...Le,...Te];return rt.length>Lc?rt.slice(0,Lc):rt})},[]),y=x.useCallback(F=>{A(ge=>ge.filter((Te,Le)=>Le!==F))},[]),q=x.useCallback(F=>{var Te;const ge=(Te=F.clipboardData)==null?void 0:Te.files;if(ge&&ge.length>0){const Le=Bc(ge);Le.length>0&&(F.preventDefault(),B(Le))}},[B]),X=x.useCallback(F=>{var Te;F.preventDefault(),J(!1);const ge=(Te=F.dataTransfer)==null?void 0:Te.files;ge&&ge.length>0&&B(Array.from(ge))},[B]),Y=x.useCallback(F=>{F.preventDefault(),J(!0)},[]),ie=x.useCallback(()=>J(!1),[]),D=b?f[b]:void 0,ue=D?c[D]:void 0,he=x.useMemo(()=>b?Object.values(c).filter(F=>F.documentName===b).sort((F,ge)=>ge.updatedAt-F.updatedAt):[],[c,b]);x.useEffect(()=>{b&&he.length===0&&d(b)},[b,he.length,d]);const ce=x.useRef(c);ce.current=c,x.useEffect(()=>{const F=new Set(N.map(Te=>Te.name)),ge=new Set;for(const Te of Object.values(ce.current))!F.has(Te.documentName)&&Te.documentName!=="__migrated__"&&ge.add(Te.documentName);for(const Te of ge)_(Te)},[N,_]);const ee=x.useRef(null);x.useEffect(()=>{ee.current!==D&&(ee.current=D,k((ue==null?void 0:ue.messages)??[]))},[D,ue,k]),x.useEffect(()=>{var F;(F=ne.current)==null||F.scrollIntoView({behavior:"smooth"})},[m,C]),x.useEffect(()=>{const F=ge=>{var rt;const{documentName:Te,selection:Le}=ge.detail;t({...Le,documentName:Te}),o(),(rt=S.current)==null||rt.focus()};return window.addEventListener("monaco-selection-to-ai",F),()=>window.removeEventListener("monaco-selection-to-ai",F)},[t,o]);const de=C==="streaming",fe=C==="submitted"||de,Re=x.useCallback(F=>{F.preventDefault(),!(!I.trim()&&P.length===0||fe)&&(O(I,P.length>0?P:void 0),T(""),A([]))},[I,P,fe,O]),Oe=x.useCallback(F=>{F.key==="Enter"&&!F.shiftKey&&(F.preventDefault(),Re(F))},[Re]),We=x.useCallback(()=>{m.length!==0&&V(!0)},[m.length]),E=x.useCallback(()=>{V(!1),k([]),D&&(g(D,[]),w(D,vo()))},[k,D,g,w]),[R,Z]=x.useState(null),se=x.useCallback(F=>{Z(F)},[]),z=x.useCallback(()=>{var rt,tt;if(!R)return;const F=m.findIndex(at=>at.id===R);if(F===-1){Z(null);return}const ge=m[F],Te=new Set([F]);ge.role==="user"&&((rt=m[F+1])==null?void 0:rt.role)==="assistant"?Te.add(F+1):ge.role==="assistant"&&F>0&&((tt=m[F-1])==null?void 0:tt.role)==="user"&&Te.add(F-1);const Le=m.filter((at,un)=>!Te.has(un));k(Le),D&&g(D,Le),Z(null)},[R,m,k,D,g]),K=x.useCallback(F=>{if(!fe){if(he.length<=1){We();return}h(F)}},[fe,he.length,We,h]),te=x.useCallback(()=>{if(!(!b||fe))return d(b)},[b,fe,d]),xe=x.useCallback(F=>{fe||F===D||p(F)},[fe,D,p]),L=x.useCallback((F,ge)=>{w(F,ge)},[w]);return u.jsxs("div",{className:"flex flex-col h-full border-l bg-surface-chat",children:[u.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border/60 bg-surface-chat",children:[u.jsx(dz,{threads:he,activeThread:ue,disabled:fe,onSwitch:xe,onCreate:te,onDelete:K,onRename:L}),u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsx(Se,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs text-muted-foreground hover:text-foreground",onClick:We,disabled:fe||m.length===0,children:"Clear"}),u.jsx(Se,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:l,title:"Close chat",children:u.jsx(yn,{className:"h-3.5 w-3.5"})})]})]}),u.jsx(ri,{className:"flex-1 min-h-0 [&_[data-radix-scroll-area-viewport]>div]:!block",children:u.jsxs("div",{className:"p-3 space-y-4 min-w-0",children:[m.length===0&&u.jsxs("div",{className:"flex flex-col items-center justify-center py-12 px-4",children:[u.jsx("div",{className:"rounded-xl bg-primary/10 p-3 mb-4",children:u.jsx(il,{className:"h-5 w-5 text-primary"})}),u.jsx("p",{className:"text-sm font-medium text-foreground/80 mb-1",children:"JSON Assistant"}),u.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."}),u.jsxs("div",{className:"flex items-center gap-1.5 rounded-md bg-muted/50 px-2.5 py-1.5",children:[u.jsx(ii,{shortcut:"mod+k"}),u.jsx("span",{className:"text-xs text-muted-foreground",children:"to send a selection"})]})]}),m.map((F,ge)=>{let Te;if(F.role==="user"){const tt=H(F.id);tt&&tt.length>0&&(Te=tt)}else if(F.role==="assistant"){for(let tt=ge-1;tt>=0;tt--)if(m[tt].role==="user"){Te=H(m[tt].id);break}}const Le=de&&ge===m.length-1&&F.role==="assistant",rt=F.role==="user"?j(F.id):void 0;return u.jsx(mz,{msg:F,isStreaming:Le,context:Te,scope:rt,onDelete:fe?void 0:se},F.id)}),fe&&((Q=m[m.length-1])==null?void 0:Q.role)!=="assistant"&&u.jsx("div",{className:"flex justify-start",children:u.jsx("div",{className:"rounded-lg px-3 py-2 bg-muted/60 border border-border/40",children:u.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(Fr,{className:"h-3.5 w-3.5 animate-spin text-primary"}),u.jsx("span",{children:"Thinking..."})]})})}),v&&!fe&&u.jsx("div",{className:"flex justify-start",children:u.jsx("div",{className:"rounded-lg px-3 py-2 bg-destructive/10 border border-destructive/30 text-destructive text-sm max-w-[90%]",children:v.message||"Something went wrong"})}),u.jsx("div",{ref:ne})]})}),u.jsxs("div",{className:`border-t border-border/60 p-2.5 space-y-2 bg-surface-chat transition-colors ${U?"ring-2 ring-primary/40 bg-primary/5":""}`,onDrop:X,onDragOver:Y,onDragLeave:ie,children:[e.length>0&&u.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.map((F,ge)=>u.jsx(Um,{context:F,onRemove:()=>n(ge)},ge))}),u.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[u.jsx(yz,{model:s,setModel:a}),ht==="pptx"&&b&&u.jsx(vz,{scope:r,setScope:i,docSize:((ve=(me=N.find(F=>F.name===b))==null?void 0:me.text)==null?void 0:ve.length)??0})]}),P.length>0&&u.jsx("div",{className:"flex flex-wrap gap-1.5",children:P.map((F,ge)=>u.jsxs("div",{className:"relative group",children:[Ym(F.mediaType)?u.jsx("img",{src:F.url,alt:F.filename||"attachment",className:"h-14 w-14 rounded-md object-cover border border-border/60"}):u.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:[u.jsx(Ta,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),u.jsx("span",{className:"text-xs truncate text-muted-foreground",children:F.filename||"file"})]}),u.jsx("button",{type:"button",onClick:()=>y(ge),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:u.jsx(yn,{className:"h-3 w-3"})})]},ge))}),u.jsxs("form",{onSubmit:Re,className:"flex items-end gap-2",children:[u.jsx("input",{ref:oe,type:"file",accept:fz,multiple:!0,className:"hidden",onChange:F=>{F.target.files&&B(Array.from(F.target.files)),F.target.value=""}}),u.jsx(Se,{type:"button",variant:"ghost",size:"icon",className:"shrink-0 h-9 w-9 rounded-lg text-muted-foreground hover:text-foreground",onClick:()=>{var F;return(F=oe.current)==null?void 0:F.click()},title:"Attach file",children:u.jsx(Ta,{className:"h-4 w-4"})}),u.jsx("textarea",{ref:S,value:I,onChange:F=>{T(F.target.value);const ge=F.target;ge.style.height="auto",ge.style.height=`${Math.min(ge.scrollHeight,128)}px`},onKeyDown:Oe,onPaste:q,placeholder:e.length>0?"Describe how to edit the selection...":r==="slides"?"Add, edit, or remove slides...":r==="templates"?"Edit template layouts and placeholders...":"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?u.jsx(Se,{type:"button",size:"icon",variant:"destructive",className:"shrink-0 h-9 w-9 rounded-lg",onClick:$,title:"Stop generating",children:u.jsx(zd,{className:"h-4 w-4"})}):u.jsx(Se,{type:"submit",size:"icon",disabled:!I.trim()&&P.length===0,className:"shrink-0 h-9 w-9 rounded-lg",children:u.jsx(il,{className:"h-4 w-4"})})]})]}),u.jsx(Ct,{open:M,onOpenChange:V,children:u.jsxs(kt,{className:"max-w-sm",children:[u.jsxs(Vt,{children:[u.jsx(Ut,{children:"Clear thread"}),u.jsx(on,{children:"This will delete all messages in this thread. This action cannot be undone."})]}),u.jsxs(bn,{children:[u.jsx(al,{asChild:!0,children:u.jsx(Se,{variant:"ghost",size:"sm",children:"Cancel"})}),u.jsx(Se,{variant:"destructive",size:"sm",onClick:E,children:"Clear"})]})]})}),u.jsx(Ct,{open:R!==null,onOpenChange:F=>{F||Z(null)},children:u.jsxs(kt,{className:"max-w-sm",children:[u.jsxs(Vt,{children:[u.jsx(Ut,{children:"Delete message"}),u.jsx(on,{children:"This will delete the message and its paired response. This action cannot be undone."})]}),u.jsxs(bn,{children:[u.jsx(al,{asChild:!0,children:u.jsx(Se,{variant:"ghost",size:"sm",children:"Cancel"})}),u.jsx(Se,{variant:"destructive",size:"sm",onClick:z,children:"Delete"})]})]})})]})}const mz=x.memo(function({msg:t,isStreaming:n,context:r,scope:i,onDelete:s}){var l,c;const a=((l=t.parts)==null?void 0:l.filter(f=>f.type==="text").map(f=>f.text).join(""))||"",o=((c=t.parts)==null?void 0:c.filter(f=>f.type==="file"))||[];return u.jsx("div",{className:`group/msg flex ${t.role==="user"?"justify-end":"justify-start"}`,children:u.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"?u.jsxs("div",{children:[o.length>0&&u.jsx("div",{className:"flex flex-wrap gap-1 mb-1.5",children:o.map((f,d)=>Ym(f.mediaType)?u.jsx("img",{src:f.url,alt:f.filename||"image",className:"h-20 max-w-[160px] rounded-sm object-cover"},d):u.jsxs("div",{className:"flex items-center gap-1.5 rounded-sm bg-primary-foreground/20 px-2 py-1",children:[u.jsx(Ta,{className:"h-3 w-3 shrink-0"}),u.jsx("span",{className:"text-xs truncate max-w-[120px]",children:f.filename||"file"})]},d))}),r&&r.length>0&&u.jsx("div",{className:"flex flex-wrap gap-1 mb-1.5",children:r.map((f,d)=>u.jsx(Um,{context:f,variant:"sent"},d))}),a&&u.jsx("div",{className:"whitespace-pre-wrap text-sm break-words",children:a}),i&&i!=="global"&&u.jsx("span",{className:"text-[10px] text-primary-foreground/60 mt-0.5 block text-right",children:i})]}):u.jsx(gz,{text:a,isStreaming:n,context:r,scope:i}),s&&!n&&u.jsx("div",{className:"opacity-0 transition-opacity group-hover/msg:opacity-100 focus-within:opacity-100 mt-1",children:u.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:u.jsx(fo,{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 gz({text:e,isStreaming:t,context:n,scope:r}){return t?u.jsx("div",{className:"text-sm prose prose-sm dark:prose-invert break-words [&_pre]:overflow-x-auto [&_p]:my-1",children:u.jsx("pre",{className:"whitespace-pre-wrap font-sans text-sm m-0 p-0 bg-transparent border-none",children:e})}):u.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:u.jsx(V1,{remarkPlugins:[nj],components:{pre:({children:i})=>u.jsx(u.Fragment,{children:i}),code:({className:i,children:s})=>{const a=i==null?void 0:i.startsWith("language-"),o=(i==null?void 0:i.replace("language-",""))||"",l=String(s).replace(/\n$/,"");if(!a)return u.jsx("code",{className:"rounded-sm bg-muted px-1 py-0.5 text-xs font-mono",children:s});const c=o==="json"||o==="jsonc";return u.jsxs("div",{className:"my-2 rounded-lg border bg-card",children:[u.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 bg-muted/60 border-b text-xs text-muted-foreground",children:[u.jsx("span",{className:"font-mono",children:o||"code"}),!c&&u.jsx(wz,{text:l})]}),u.jsx("pre",{className:"p-3 text-xs font-mono overflow-x-auto max-h-80 overflow-y-auto m-0",children:u.jsx("code",{children:l})}),c&&u.jsx(cz,{json:l,context:n,scope:r})]})}},children:e})})}const xz=[{value:"opus",label:"Opus"},{value:"sonnet",label:"Sonnet"},{value:"haiku",label:"Haiku"}];function yz({model:e,setModel:t}){return u.jsxs(ti,{value:e,onValueChange:n=>t(n),children:[u.jsx(fr,{className:"h-6 w-auto gap-1 border-none bg-muted/40 px-2 py-0 text-[10px] shadow-none focus:ring-0",children:u.jsx(ni,{})}),u.jsx(pr,{children:xz.map(n=>u.jsx(Pn,{value:n.value,className:"text-xs",children:n.label},n.value))})]})}const Vc={global:"AI sees and edits the entire document",slides:"AI sees and edits only slides — templates stay unchanged",templates:"AI sees and edits only template layouts — slides stay unchanged"},bz=1e5;function vz({scope:e,setScope:t,docSize:n}){return u.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Scope"}),u.jsx("div",{className:"flex items-center bg-muted/40 rounded-md p-0.5 gap-px",children:Object.keys(Vc).map(r=>u.jsxs(Ye,{children:[u.jsx(Ke,{asChild:!0,children:u.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})}),u.jsx(Xe,{side:"top",className:"text-xs max-w-[200px]",children:Vc[r]})]},r))})]}),e==="global"&&n>bz&&u.jsxs("div",{className:"text-[10px] text-warning flex items-center gap-1",children:[u.jsx(Dd,{className:"h-3 w-3 shrink-0"}),u.jsxs("span",{children:["Large doc — switch to"," ",u.jsx("button",{type:"button",onClick:()=>t("slides"),className:"underline cursor-pointer hover:text-warning/80",children:"slides"})," ","or"," ",u.jsx("button",{type:"button",onClick:()=>t("templates"),className:"underline cursor-pointer hover:text-warning/80",children:"templates"})]})]})]})}function wz({text:e}){const[t,n]=x.useState(!1),r=x.useCallback(async()=>{await navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),1500)},[e]);return u.jsx("button",{onClick:r,className:"text-xs text-muted-foreground hover:text-foreground transition-colors",children:t?"Copied!":"Copy"})}function kz({discoveryData:e}){const t=wf(),n=py(),r=Pe(j=>j.chatOpen),i=Pe(j=>j.toggleChat),[s,a]=x.useState(()=>{try{const j=localStorage.getItem("dev-env.sidebar-open");return n?!1:j?j==="true":!0}catch{return!n}}),[o,l]=x.useState(()=>{try{const j=localStorage.getItem("dev-env.preview-open");return j?j==="true":!0}catch{return!0}}),[c,f]=x.useState("editor"),[d,h]=x.useState(!1),p=150,[g,w]=x.useState(!s),[_,b]=x.useState(!1);x.useEffect(()=>{try{localStorage.setItem("dev-env.sidebar-open",String(s))}catch{}},[s]),x.useEffect(()=>{try{localStorage.setItem("dev-env.preview-open",String(o))}catch{}},[o]);const N=x.useRef(n);x.useEffect(()=>{n&&!N.current&&s&&(b(!0),a(!1),setTimeout(()=>{w(!0),b(!1)},p)),!n&&N.current&&!s&&(b(!0),a(!0),setTimeout(()=>{w(!1),b(!1)},p)),N.current=n},[n,s]);const m=x.useCallback(()=>{if(t){h(j=>!j);return}b(!0),a(j=>!j),setTimeout(()=>{w(j=>!j),b(!1)},p)},[t]),O=x.useCallback(()=>l(j=>!j),[]),C=x.useRef(i),v=x.useRef(m),k=x.useRef(O);x.useEffect(()=>{C.current=i}),x.useEffect(()=>{v.current=m}),x.useEffect(()=>{k.current=O}),x.useEffect(()=>{const j=I=>{(I.metaKey||I.ctrlKey)&&(I.code==="KeyB"&&!I.shiftKey&&(I.preventDefault(),v.current()),I.code==="KeyJ"&&I.shiftKey&&(I.preventDefault(),I.stopPropagation(),C.current()),I.code==="KeyP"&&I.shiftKey&&(I.preventDefault(),k.current()))};return window.addEventListener("keydown",j,!0),()=>window.removeEventListener("keydown",j,!0)},[]);const $=LA,H=[{key:"editor",icon:Ca,label:"Editor"},{key:"preview",icon:Rd,label:"Preview"},{key:"chat",icon:Md,label:"Chat"}];return t?u.jsx($,{children:u.jsxs("div",{className:"flex flex-col h-full w-full overflow-hidden",children:[u.jsxs("div",{className:"flex items-center gap-1 px-2 py-1.5 border-b bg-sidebar shrink-0",children:[u.jsxs(yf,{open:d,onOpenChange:h,children:[u.jsx(ly,{asChild:!0,children:u.jsx(Se,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0",children:u.jsx(Pd,{className:"h-4 w-4"})})}),u.jsx(So,{side:"left",className:"p-0 w-72",children:u.jsx(Tl,{discoveryData:e,onToggleSidebar:()=>h(!1),isCollapsed:!1})})]}),u.jsx("div",{className:"flex gap-0.5 flex-1 min-w-0",children:H.map(({key:j,icon:I,label:T})=>u.jsxs(Se,{variant:c===j?"default":"ghost",size:"sm",className:"h-7 gap-1.5 text-xs flex-1",onClick:()=>f(j),children:[u.jsx(I,{className:"h-3.5 w-3.5"}),u.jsx("span",{className:"hidden xs:inline",children:T})]},j))})]}),c!=="chat"&&u.jsx(Xl,{previewOpen:o,onTogglePreview:O}),u.jsxs("div",{className:"flex-1 min-h-0",children:[c==="editor"&&u.jsx("div",{className:"h-full bg-surface-editor",children:u.jsx(Il,{})}),c==="preview"&&u.jsx("div",{className:"h-full bg-surface-preview",children:u.jsx(Al,{})}),c==="chat"&&u.jsx(Zc,{})]})]})}):u.jsx($,{children:u.jsxs("div",{className:"flex h-full w-full overflow-hidden",children:[u.jsx("div",{className:G("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:u.jsx(Tl,{discoveryData:e,onToggleSidebar:m,isCollapsed:g,isAnimating:_})}),u.jsxs("div",{className:"flex-1 min-w-0 flex flex-col h-full",children:[u.jsx(Xl,{previewOpen:o,onTogglePreview:O}),u.jsxs(Wb,{direction:"horizontal",autoSaveId:"layout-main",className:"flex-1 min-h-0",children:[u.jsx(Qs,{defaultSize:o?50:100,minSize:20,id:"editor",order:1,children:u.jsx("div",{className:"h-full bg-surface-editor",children:u.jsx(Il,{})})}),o&&u.jsxs(u.Fragment,{children:[u.jsx(Bl,{withHandle:!0}),u.jsx(Qs,{defaultSize:50,minSize:20,id:"preview",order:2,children:u.jsx("div",{className:"h-full bg-surface-preview",children:u.jsx(Al,{})})})]}),r&&u.jsxs(u.Fragment,{children:[u.jsx(Bl,{withHandle:!0}),u.jsx(Qs,{defaultSize:30,minSize:25,maxSize:50,id:"chat",order:3,children:u.jsx(Zc,{})})]})]})]})]})})}function Sz(){const[e,t]=x.useState(null),[n,r]=x.useState(!0),[i,s]=x.useState(null),a=x.useCallback(async()=>{r(!0),s(null);try{const o=await fetch("/api/discovery/all");if(!o.ok)throw new Error(`Discovery failed: ${o.statusText}`);const l=await o.json();if(!l.success)throw new Error(l.error||"Discovery failed");t(l.data)}catch(o){console.error("Discovery error:",o),s(o instanceof Error?o.message:"Failed to fetch discovered items"),t({plugins:[],documents:[],themes:[]})}finally{r(!1)}},[]);return x.useEffect(()=>{a()},[a]),{data:e,loading:n,error:i,refetch:a}}let Mi=null;async function _z(){const e=await fetch("/api/discovery/load-plugins",{method:"POST"});if(!e.ok)throw new Error(`Failed to load plugins: ${e.statusText}`);const t=await e.json();if(!t.success)throw new Error(t.error||"Failed to load plugins");return t.data.loaded}function jz(){const[e,t]=x.useState(!1),[n,r]=x.useState(null),[i,s]=x.useState(0);return{loadPlugins:x.useCallback(async()=>{t(!0),r(null);try{Mi||(Mi=_z().finally(()=>{Mi=null}));const o=await Mi;return s(o),!0}catch(o){return console.error("Plugin loading error:",o),r(o instanceof Error?o.message:"Failed to load plugins"),!1}finally{t(!1)}},[]),loading:e,error:n,loadedCount:i}}function Nz(){const{data:e,loading:t,error:n}=Sz(),{loadPlugins:r}=jz(),i=Lt(s=>s.applyPluginsWithValidation);return x.useEffect(()=>{e&&e.plugins.length>0&&r().then(s=>{if(s){console.log("Plugins loaded successfully");const a=Lt.getState().selectedPlugins;a.size>0&&(console.log("Auto-applying persisted plugin selections:",Array.from(a)),i())}})},[e,r,i]),t?u.jsx("div",{className:"flex items-center justify-center h-screen",children:u.jsxs("div",{className:"text-center",children:[u.jsx("div",{className:"text-lg font-medium",children:"Discovering project resources..."}),u.jsx("div",{className:"text-sm text-muted-foreground mt-2",children:"Searching for documents, themes, and plugins"})]})}):n?u.jsx("div",{className:"flex items-center justify-center h-screen",children:u.jsxs("div",{className:"text-center",children:[u.jsx("div",{className:"text-lg font-medium text-destructive",children:"Discovery failed"}),u.jsx("div",{className:"text-sm text-muted-foreground mt-2",children:n}),u.jsx("div",{className:"text-xs text-muted-foreground mt-4",children:"The playground will work with limited functionality."})]})}):u.jsx(ax,{children:u.jsx(ox,{children:u.jsx(lx,{children:u.jsx(ux,{children:u.jsx(cx,{children:u.jsx(Jx,{children:u.jsx(Sf,{children:u.jsx("section",{className:"flex h-screen w-full flex-col",children:u.jsx("div",{className:"grow overflow-hidden",children:u.jsx(kz,{discoveryData:e})})})})})})})})})})}const Mz=Object.freeze(Object.defineProperty({__proto__:null,HomePage:Nz},Symbol.toStringTag,{value:"Module"}));export{Kt as B,Ct as D,Mz as H,Wr as L,av as P,Yb as Q,Yr as S,ur as T,sp as a,ti as b,fr as c,ni as d,pr as e,Pn as f,Rz as g,xf as h,kt as i,Vt as j,Ut as k,Xb as l,Zy as p,ev as u};
|
|
106
|
+
//# sourceMappingURL=HomePage-fDrbL-5G.js.map
|