@json-to-office/jto 0.22.0 → 0.24.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 +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/client/assets/HomePage-C3rGwXmP.js +99 -0
- package/dist/client/assets/HomePage-C3rGwXmP.js.map +1 -0
- package/dist/client/assets/{JsonEditorPage-Bclb98Ti.js → JsonEditorPage-Bdilserz.js} +3 -3
- package/dist/client/assets/{JsonEditorPage-Bclb98Ti.js.map → JsonEditorPage-Bdilserz.js.map} +1 -1
- package/dist/client/assets/{MonacoPluginProvider-BbjmAGrJ.js → MonacoPluginProvider-C-bX2Lh9.js} +3 -3
- package/dist/client/assets/{MonacoPluginProvider-BbjmAGrJ.js.map → MonacoPluginProvider-C-bX2Lh9.js.map} +1 -1
- package/dist/client/assets/button-CD_S_eWG.js +2 -0
- package/dist/client/assets/button-CD_S_eWG.js.map +1 -0
- package/dist/client/assets/editor-DjQ1HvFx.js +9 -0
- package/dist/client/assets/editor-DjQ1HvFx.js.map +1 -0
- package/dist/client/assets/editor-monaco-json-CKdq0BCO.js +24 -0
- package/dist/client/assets/editor-monaco-json-CKdq0BCO.js.map +1 -0
- package/dist/client/assets/index-BdmImuIf.css +1 -0
- package/dist/client/assets/index-DASNz01y.js +5 -0
- package/dist/client/assets/index-DASNz01y.js.map +1 -0
- package/dist/client/assets/preview-B9UKky-W.js +3 -0
- package/dist/client/assets/preview-B9UKky-W.js.map +1 -0
- package/dist/client/assets/{radix-ui-BQBCrmlJ.js → radix-ui-Bq-7y_Sq.js} +6 -6
- package/dist/client/assets/{radix-ui-BQBCrmlJ.js.map → radix-ui-Bq-7y_Sq.js.map} +1 -1
- package/dist/client/assets/{ui-vendor-HKNXoiLD.js → ui-vendor-Nd4Lg2re.js} +46 -56
- package/dist/client/assets/ui-vendor-Nd4Lg2re.js.map +1 -0
- package/dist/client/index.html +6 -5
- package/package.json +7 -6
- package/dist/client/assets/HomePage-BW2AGCC2.js +0 -99
- package/dist/client/assets/HomePage-BW2AGCC2.js.map +0 -1
- package/dist/client/assets/button-CSrOcD5F.js +0 -2
- package/dist/client/assets/button-CSrOcD5F.js.map +0 -1
- package/dist/client/assets/editor-CGjdiUtd.js +0 -9
- package/dist/client/assets/editor-CGjdiUtd.js.map +0 -1
- package/dist/client/assets/editor-monaco-json-Bw2M2Xcf.js +0 -24
- package/dist/client/assets/editor-monaco-json-Bw2M2Xcf.js.map +0 -1
- package/dist/client/assets/index-Auo5vP51.css +0 -1
- package/dist/client/assets/index-Bn9d6cEh.js +0 -5
- package/dist/client/assets/index-Bn9d6cEh.js.map +0 -1
- package/dist/client/assets/preview-C51sEB99.js +0 -3
- package/dist/client/assets/preview-C51sEB99.js.map +0 -1
- package/dist/client/assets/ui-vendor-HKNXoiLD.js.map +0 -1
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/editor-DjQ1HvFx.js","assets/react-vendor-CTFDOf2G.js","assets/editor-monaco-json-CKdq0BCO.js","assets/index-DASNz01y.js","assets/query-vendor-Df8-oete.js","assets/radix-ui-Bq-7y_Sq.js","assets/ui-vendor-Nd4Lg2re.js","assets/monaco-editor-BcgxPCqT.js","assets/state-vendor-ByFYl9bq.js","assets/index-BdmImuIf.css","assets/MonacoPluginProvider-C-bX2Lh9.js","assets/button-CD_S_eWG.js","assets/preview-B9UKky-W.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var um=Object.defineProperty;var cm=(e,t,n)=>t in e?um(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Po=(e,t,n)=>cm(e,typeof t!="symbol"?t+"":t,n);import{r as b,j as u,c as _e,R as lc,g as Za}from"./react-vendor-CTFDOf2G.js";import{b as uc,c as Ba,d as cc,e as rs,f as is,D as ss,O as as,g as dm,V as fm,h as dc,I as pm,i as hm,j as fc,k as mm,l as pc,m as gm,n as xm,G as ym,S as hc,o as mc,L as gc,p as xc,q as yc,r as dr,s as bm,t as vm,u as wm,v as bc,w as vc,x as wc,y as kc,z as Sc,B as _c,E as jc,F as Cc,H as Nc,J as km,K as Sm,M as _m,N as Ec,Q as Ic,U as Tc,W as zc,X as Ac,Y as Pc,Z as Oc,_ as Dc,$ as Rc,a0 as Mc,a1 as jm,a2 as $c,a3 as Cm,a4 as Nm,a5 as Fc,a6 as Em,a7 as Im,a8 as Tm,a9 as zm,aa as Am,ab as Pm,ac as Om,ad as Lc,ae as Zc,af as Bc}from"./radix-ui-Bq-7y_Sq.js";import{c as H,u as fr,S as en,A as Vc,T as fi,C as Dm,E as Rm,F as yt,a as Mm,b as $m,d as qe,e as Ge,f as Ke,g as Uc,_ as Jc,h as pi,i as Fm,j as Lm,k as Zm,l as xr,s as Es,m as Ci,W as Bm}from"./index-DASNz01y.js";import{X as fn,C as ti,a as pn,b as Vm,d as ni,G as Hc,F as Um,e as ri,f as Wc,P as Jm,g as Hm,h as qc,E as Gc,S as Wm,B as Oo,i as qm,j as Gm,k as Km,l as os,m as Ym,M as Xm,I as Kc,n as Xt,o as Qm,p as eg,q as Yc,r as tg,s as ng,t as rg,u as ig,R as sg,v as ag,T as Xc,w as og,x as lg,y as ug,z as Qc,A as Va,D as ed,H as cg,J as td,L as la,K as dg,N as fg,O as Do,Q as ua,U as pg}from"./ui-vendor-Nd4Lg2re.js";import{B as Ee}from"./button-CD_S_eWG.js";import{u as Oe,i as hg,a as ca,b as Qt,g as mg,c as Dt,T as nd,d as hi,S as gg,O as xg,e as yg,M as bg,D as vg}from"./MonacoPluginProvider-C-bX2Lh9.js";import{u as rd,a as wg,d as kg,p as Sg,b as _g,e as jg}from"./state-vendor-ByFYl9bq.js";import{b as Cg}from"./query-vendor-Df8-oete.js";const It=uc,Ng=cc,Ro=Ba,id=b.forwardRef(({className:e,...t},n)=>u.jsx(as,{ref:n,className:H("fixed inset-0 z-50 bg-black/50",e),...t}));id.displayName=as.displayName;const St=b.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Ng,{children:[u.jsx(id,{}),u.jsxs(rs,{ref:r,className:H("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(Ba,{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(fn,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));St.displayName=rs.displayName;const Ht=({className:e,...t})=>u.jsx("div",{className:H("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Ht.displayName="DialogHeader";const In=({className:e,...t})=>u.jsx("div",{className:H("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});In.displayName="DialogFooter";const Wt=b.forwardRef(({className:e,...t},n)=>u.jsx(is,{ref:n,className:H("text-lg leading-none font-semibold tracking-tight",e),...t}));Wt.displayName=is.displayName;const hn=b.forwardRef(({className:e,...t},n)=>u.jsx(ss,{ref:n,className:H("text-muted-foreground text-sm",e),...t}));hn.displayName=ss.displayName;const Fr=dm,Eg=ym,Lr=fm,rr=b.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(dc,{ref:r,className:H("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(pm,{asChild:!0,children:u.jsx(ti,{className:"h-4 w-4 shrink-0 opacity-50"})})]}));rr.displayName=dc.displayName;const sd=b.forwardRef(({className:e,...t},n)=>u.jsx(hc,{ref:n,className:H("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(Vm,{className:"h-4 w-4"})}));sd.displayName=hc.displayName;const ad=b.forwardRef(({className:e,...t},n)=>u.jsx(mc,{ref:n,className:H("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(ti,{className:"h-4 w-4"})}));ad.displayName=mc.displayName;const ir=b.forwardRef(({className:e,children:t,position:n="popper",...r},i)=>u.jsx(hm,{children:u.jsxs(fc,{ref:i,className:H("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(sd,{}),u.jsx(mm,{className:H("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),u.jsx(ad,{})]})}));ir.displayName=fc.displayName;const od=b.forwardRef(({className:e,...t},n)=>u.jsx(gc,{ref:n,className:H("px-2 py-1.5 text-sm font-semibold",e),...t}));od.displayName=gc.displayName;const Tn=b.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(pc,{ref:r,className:H("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(gm,{children:u.jsx(pn,{className:"h-4 w-4"})})}),u.jsx(xm,{children:t})]}));Tn.displayName=pc.displayName;const Ig=b.forwardRef(({className:e,...t},n)=>u.jsx(xc,{ref:n,className:H("bg-muted -mx-1 my-1 h-px",e),...t}));Ig.displayName=xc.displayName;const ii=b.forwardRef(({className:e,type:t,...n},r)=>u.jsx("input",{type:t,className:H("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}));ii.displayName="Input";const Tg=ni("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Xn=b.forwardRef(({className:e,...t},n)=>u.jsx(yc,{ref:n,className:H(Tg(),e),...t}));Xn.displayName=yc.displayName;const zg=ni("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 Jt({className:e,variant:t,...n}){return u.jsx("div",{className:H(zg({variant:t}),e),...n})}const Ag=({open:e,onOpenChange:t})=>{const{documents:n,documentTypes:r,activeTab:i,createDocument:s,openDocument:a}=Oe(rd(T=>({documents:T.documents,documentTypes:T.documentTypes,activeTab:T.activeTab,createDocument:T.createDocument,openDocument:T.openDocument}))),{toast:o}=fr(),l=b.useMemo(()=>n.filter(T=>r[T.name]!=="application/json+theme"),[n,r]),[c,f]=b.useState(""),[d,p]=b.useState(""),[h,g]=b.useState("playground"),[v,S]=b.useState(!1),[x,_]=b.useState(null),[m,I]=b.useState(null),[E,w]=b.useState(null),N=()=>{_(null),I(null),w(null)};b.useEffect(()=>{if(!e)return;_(null),I(null),w(null);const T=l.map(F=>F.name),A=T.includes(i)?i:T[0]??"";p(A),f(T.find(F=>F!==A)??"")},[e]);const O=async()=>{const T=l.find(F=>F.name===c),A=l.find(F=>F.name===d);if(!(!T||!A)){S(!0),_(null),I(null),w(null);try{const F=await fetch(Vc.diff,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldDefinition:T.text,newDefinition:A.text,options:{author:h||"playground"}})}),R=await F.json();if(!F.ok||!R.success){const L=Array.isArray(R.errors)?`: ${R.errors.slice(0,3).map(P=>P.message||String(P)).join("; ")}`:"";throw new Error((R.error||`Diff failed (${F.status})`)+L)}I(R.data.summary),w(R.data.document)}catch(F){_(F instanceof Error?F.message:"Diff failed")}finally{S(!1)}}},K=()=>{if(!E)return;const T=new Set(n.map(R=>R.name));let A=`${d}-redline`,F=2;for(;T.has(A);)A=`${d}-redline-${F++}`;s(A,JSON.stringify(E,null,2)),a(A),o({title:`Redline created: ${A}`}),t(!1)},C=m?m.tracked.modified+m.tracked.inserted+m.tracked.deleted:0;return u.jsx(It,{open:e,onOpenChange:t,children:u.jsxs(St,{className:"sm:max-w-[560px]",children:[u.jsxs(Ht,{children:[u.jsxs(Wt,{className:"flex items-center gap-2",children:[u.jsx(Hc,{className:"size-4"}),"Compare documents"]}),u.jsx(hn,{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(Xn,{htmlFor:"diff-base",children:"Base (old)"}),u.jsxs(Fr,{value:c,onValueChange:T=>{f(T),N()},children:[u.jsx(rr,{id:"diff-base",children:u.jsx(Lr,{placeholder:"Select document"})}),u.jsx(ir,{children:l.map(T=>u.jsx(Tn,{value:T.name,children:T.name},T.name))})]})]}),u.jsxs("div",{className:"grid gap-1.5",children:[u.jsx(Xn,{htmlFor:"diff-revised",children:"Revised (new)"}),u.jsxs(Fr,{value:d,onValueChange:T=>{p(T),N()},children:[u.jsx(rr,{id:"diff-revised",children:u.jsx(Lr,{placeholder:"Select document"})}),u.jsx(ir,{children:l.map(T=>u.jsx(Tn,{value:T.name,children:T.name},T.name))})]})]})]}),u.jsxs("div",{className:"grid gap-1.5",children:[u.jsx(Xn,{htmlFor:"diff-author",children:"Revision author"}),u.jsx(ii,{id:"diff-author",value:h,onChange:T=>{g(T.target.value),N()},placeholder:"playground"})]}),x&&u.jsx("p",{className:"text-sm text-destructive",role:"alert",children:x}),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(Jt,{variant:"secondary",children:[m.tracked.inserted," inserted"]}),u.jsxs(Jt,{variant:"secondary",children:[m.tracked.deleted," deleted"]}),u.jsxs(Jt,{variant:"secondary",children:[m.tracked.modified," modified"]}),u.jsxs("span",{className:"text-muted-foreground text-xs",children:[m.unchangedBlocks," blocks unchanged"]})]}),C===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((T,A)=>u.jsxs("p",{className:"text-xs text-muted-foreground",children:[T.path," [",T.component,"] ",T.detail]},A))]}),m.notes.map((T,A)=>u.jsxs("p",{className:"text-xs text-muted-foreground",children:["Note: ",T]},A))]})]}),u.jsx(In,{children:m&&C+m.untracked.length>0?u.jsxs(Ee,{onClick:K,children:[u.jsx(Um,{className:"size-4 mr-1"}),"Open redline"]}):u.jsxs(Ee,{onClick:O,disabled:v||!c||!d||c===d,children:[v&&u.jsx(en,{className:"size-4 mr-1"}),"Compare"]})})]})})};var si=e=>e.type==="checkbox",jn=e=>e instanceof Date,ct=e=>e==null;const ld=e=>typeof e=="object";var Qe=e=>!ct(e)&&!Array.isArray(e)&&ld(e)&&!jn(e),ud=e=>Qe(e)&&e.target?si(e.target)?e.target.checked:e.target.value:e,Pg=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,cd=(e,t)=>e.has(Pg(t)),Og=e=>{const t=e.constructor&&e.constructor.prototype;return Qe(t)&&t.hasOwnProperty("isPrototypeOf")},Ua=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function mt(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(!(Ua&&(e instanceof Blob||r))&&(n||Qe(e)))if(t=n?[]:{},!n&&!Og(e))t=e;else for(const i in e)e.hasOwnProperty(i)&&(t[i]=mt(e[i]));else return e;return t}var ls=e=>Array.isArray(e)?e.filter(Boolean):[],Xe=e=>e===void 0,oe=(e,t,n)=>{if(!t||!Qe(e))return n;const r=ls(t.split(/[,[\].]+?/)).reduce((i,s)=>ct(i)?i:i[s],e);return Xe(r)||r===e?Xe(e[t])?n:e[t]:r},Nt=e=>typeof e=="boolean",Ja=e=>/^\w*$/.test(e),dd=e=>ls(e.replace(/["|']|\]/g,"").split(/\.|\[/)),Me=(e,t,n)=>{let r=-1;const i=Ja(t)?[t]:dd(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=Qe(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 Pi={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},Ot={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},Yt={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},fd=_e.createContext(null),us=()=>_e.useContext(fd),Dg=e=>{const{children:t,...n}=e;return _e.createElement(fd.Provider,{value:n},t)};var pd=(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]!==Ot.all&&(t._proxyFormState[a]=!r||Ot.all),n&&(n[a]=!0),e[a]}});return i},gt=e=>Qe(e)&&!Object.keys(e).length,hd=(e,t,n,r)=>{n(e);const{name:i,...s}=e;return gt(s)||Object.keys(s).length>=Object.keys(t).length||Object.keys(s).find(a=>t[a]===(!r||Ot.all))},Pr=e=>Array.isArray(e)?e:[e],md=(e,t,n)=>!e||!t||e===t||Pr(e).some(r=>r&&(n?r===t:r.startsWith(t)||t.startsWith(r)));function Ha(e){const t=_e.useRef(e);t.current=e,_e.useEffect(()=>{const n=!e.disabled&&t.current.subject&&t.current.subject.subscribe({next:t.current.next});return()=>{n&&n.unsubscribe()}},[e.disabled])}function Rg(e){const t=us(),{control:n=t.control,disabled:r,name:i,exact:s}=e||{},[a,o]=_e.useState(n._formState),l=_e.useRef(!0),c=_e.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1}),f=_e.useRef(i);return f.current=i,Ha({disabled:r,next:d=>l.current&&md(f.current,d.name,s)&&hd(d,c.current,n._updateFormState)&&o({...n._formState,...d}),subject:n._subjects.state}),_e.useEffect(()=>(l.current=!0,c.current.isValid&&n._updateValid(!0),()=>{l.current=!1}),[n]),_e.useMemo(()=>pd(a,n,c.current,!1),[a,n])}var Ut=e=>typeof e=="string",gd=(e,t,n,r,i)=>Ut(e)?(r&&t.watch.add(e),oe(n,e,i)):Array.isArray(e)?e.map(s=>(r&&t.watch.add(s),oe(n,s))):(r&&(t.watchAll=!0),n);function Mg(e){const t=us(),{control:n=t.control,name:r,defaultValue:i,disabled:s,exact:a}=e||{},o=_e.useRef(r);o.current=r,Ha({disabled:s,subject:n._subjects.values,next:f=>{md(o.current,f.name,a)&&c(mt(gd(o.current,n._names,f.values||n._formValues,!1,i)))}});const[l,c]=_e.useState(n._getWatch(r,i));return _e.useEffect(()=>n._removeUnmounted()),l}function $g(e){const t=us(),{name:n,disabled:r,control:i=t.control,shouldUnregister:s}=e,a=cd(i._names.array,n),o=Mg({control:i,name:n,defaultValue:oe(i._formValues,n,oe(i._defaultValues,n,e.defaultValue)),exact:!0}),l=Rg({control:i,name:n,exact:!0}),c=_e.useRef(i.register(n,{...e.rules,value:o,...Nt(e.disabled)?{disabled:e.disabled}:{}})),f=_e.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!oe(l.errors,n)},isDirty:{enumerable:!0,get:()=>!!oe(l.dirtyFields,n)},isTouched:{enumerable:!0,get:()=>!!oe(l.touchedFields,n)},isValidating:{enumerable:!0,get:()=>!!oe(l.validatingFields,n)},error:{enumerable:!0,get:()=>oe(l.errors,n)}}),[l,n]),d=_e.useMemo(()=>({name:n,value:o,...Nt(r)||l.disabled?{disabled:l.disabled||r}:{},onChange:p=>c.current.onChange({target:{value:ud(p),name:n},type:Pi.CHANGE}),onBlur:()=>c.current.onBlur({target:{value:oe(i._formValues,n),name:n},type:Pi.BLUR}),ref:p=>{const h=oe(i._fields,n);h&&p&&(h._f.ref={focus:()=>p.focus(),select:()=>p.select(),setCustomValidity:g=>p.setCustomValidity(g),reportValidity:()=>p.reportValidity()})}}),[n,i._formValues,r,l.disabled,o,i._fields]);return _e.useEffect(()=>{const p=i._options.shouldUnregister||s,h=(g,v)=>{const S=oe(i._fields,g);S&&S._f&&(S._f.mount=v)};if(h(n,!0),p){const g=mt(oe(i._options.defaultValues,n));Me(i._defaultValues,n,g),Xe(oe(i._formValues,n))&&Me(i._formValues,n,g)}return!a&&i.register(n),()=>{(a?p&&!i._state.action:p)?i.unregister(n):h(n,!1)}},[n,i,a,s]),_e.useEffect(()=>{i._updateDisabledField({disabled:r,fields:i._fields,name:n})},[r,n,i]),_e.useMemo(()=>({field:d,formState:l,fieldState:f}),[d,l,f])}const Fg=e=>e.render($g(e));var Lg=(e,t,n,r,i)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:i||!0}}:{},Mo=e=>({isOnSubmit:!e||e===Ot.onSubmit,isOnBlur:e===Ot.onBlur,isOnChange:e===Ot.onChange,isOnAll:e===Ot.all,isOnTouch:e===Ot.onTouched}),$o=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some(r=>e.startsWith(r)&&/^\.\w+/.test(e.slice(r.length))));const Or=(e,t,n,r)=>{for(const i of n||Object.keys(e)){const s=oe(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(Or(o,t))break}else if(Qe(o)&&Or(o,t))break}}};var Zg=(e,t,n)=>{const r=Pr(oe(e,n));return Me(r,"root",t[n]),Me(e,n,r),e},Wa=e=>e.type==="file",Vt=e=>typeof e=="function",Oi=e=>{if(!Ua)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},Ni=e=>Ut(e),qa=e=>e.type==="radio",Di=e=>e instanceof RegExp;const Fo={value:!1,isValid:!1},Lo={value:!0,isValid:!0};var xd=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&&!Xe(e[0].attributes.value)?Xe(e[0].value)||e[0].value===""?Lo:{value:e[0].value,isValid:!0}:Lo:Fo}return Fo};const Zo={isValid:!1,value:null};var yd=e=>Array.isArray(e)?e.reduce((t,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:t,Zo):Zo;function Bo(e,t,n="validate"){if(Ni(e)||Array.isArray(e)&&e.every(Ni)||Nt(e)&&!e)return{type:n,message:Ni(e)?e:"",ref:t}}var Rn=e=>Qe(e)&&!Di(e)?e:{value:e,message:""},Vo=async(e,t,n,r,i,s)=>{const{ref:a,refs:o,required:l,maxLength:c,minLength:f,min:d,max:p,pattern:h,validate:g,name:v,valueAsNumber:S,mount:x}=e._f,_=oe(n,v);if(!x||t.has(v))return{};const m=o?o[0]:a,I=A=>{i&&m.reportValidity&&(m.setCustomValidity(Nt(A)?"":A||""),m.reportValidity())},E={},w=qa(a),N=si(a),O=w||N,K=(S||Wa(a))&&Xe(a.value)&&Xe(_)||Oi(a)&&a.value===""||_===""||Array.isArray(_)&&!_.length,C=Lg.bind(null,v,r,E),T=(A,F,R,L=Yt.maxLength,P=Yt.minLength)=>{const V=A?F:R;E[v]={type:A?L:P,message:V,ref:a,...C(A?L:P,V)}};if(s?!Array.isArray(_)||!_.length:l&&(!O&&(K||ct(_))||Nt(_)&&!_||N&&!xd(o).isValid||w&&!yd(o).isValid)){const{value:A,message:F}=Ni(l)?{value:!!l,message:l}:Rn(l);if(A&&(E[v]={type:Yt.required,message:F,ref:m,...C(Yt.required,F)},!r))return I(F),E}if(!K&&(!ct(d)||!ct(p))){let A,F;const R=Rn(p),L=Rn(d);if(!ct(_)&&!isNaN(_)){const P=a.valueAsNumber||_&&+_;ct(R.value)||(A=P>R.value),ct(L.value)||(F=P<L.value)}else{const P=a.valueAsDate||new Date(_),V=k=>new Date(new Date().toDateString()+" "+k),U=a.type=="time",se=a.type=="week";Ut(R.value)&&_&&(A=U?V(_)>V(R.value):se?_>R.value:P>new Date(R.value)),Ut(L.value)&&_&&(F=U?V(_)<V(L.value):se?_<L.value:P<new Date(L.value))}if((A||F)&&(T(!!A,R.message,L.message,Yt.max,Yt.min),!r))return I(E[v].message),E}if((c||f)&&!K&&(Ut(_)||s&&Array.isArray(_))){const A=Rn(c),F=Rn(f),R=!ct(A.value)&&_.length>+A.value,L=!ct(F.value)&&_.length<+F.value;if((R||L)&&(T(R,A.message,F.message),!r))return I(E[v].message),E}if(h&&!K&&Ut(_)){const{value:A,message:F}=Rn(h);if(Di(A)&&!_.match(A)&&(E[v]={type:Yt.pattern,message:F,ref:a,...C(Yt.pattern,F)},!r))return I(F),E}if(g){if(Vt(g)){const A=await g(_,n),F=Bo(A,m);if(F&&(E[v]={...F,...C(Yt.validate,F.message)},!r))return I(F.message),E}else if(Qe(g)){let A={};for(const F in g){if(!gt(A)&&!r)break;const R=Bo(await g[F](_,n),m,F);R&&(A={...R,...C(F,R.message)},I(R.message),r&&(E[v]=A))}if(!gt(A)&&(E[v]={ref:m,...A},!r))return E}}return I(!0),E};function Bg(e,t){const n=t.slice(0,-1).length;let r=0;for(;r<n;)e=Xe(e)?r++:e[t[r++]];return e}function Vg(e){for(const t in e)if(e.hasOwnProperty(t)&&!Xe(e[t]))return!1;return!0}function rt(e,t){const n=Array.isArray(t)?t:Ja(t)?[t]:dd(t),r=n.length===1?e:Bg(e,n),i=n.length-1,s=n[i];return r&&delete r[s],i!==0&&(Qe(r)&>(r)||Array.isArray(r)&&Vg(r))&&rt(e,n.slice(0,-1)),e}var Is=()=>{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=[]}}},da=e=>ct(e)||!ld(e);function un(e,t){if(da(e)||da(t))return e===t;if(jn(e)&&jn(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(jn(s)&&jn(a)||Qe(s)&&Qe(a)||Array.isArray(s)&&Array.isArray(a)?!un(s,a):s!==a)return!1}}return!0}var bd=e=>e.type==="select-multiple",Ug=e=>qa(e)||si(e),Ts=e=>Oi(e)&&e.isConnected,vd=e=>{for(const t in e)if(Vt(e[t]))return!0;return!1};function Ri(e,t={}){const n=Array.isArray(e);if(Qe(e)||n)for(const r in e)Array.isArray(e[r])||Qe(e[r])&&!vd(e[r])?(t[r]=Array.isArray(e[r])?[]:{},Ri(e[r],t[r])):ct(e[r])||(t[r]=!0);return t}function wd(e,t,n){const r=Array.isArray(e);if(Qe(e)||r)for(const i in e)Array.isArray(e[i])||Qe(e[i])&&!vd(e[i])?Xe(t)||da(n[i])?n[i]=Array.isArray(e[i])?Ri(e[i],[]):{...Ri(e[i])}:wd(e[i],ct(t)?{}:t[i],n[i]):n[i]=!un(e[i],t[i]);return n}var yr=(e,t)=>wd(e,t,Ri(t)),kd=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>Xe(e)?e:t?e===""?NaN:e&&+e:n&&Ut(e)?new Date(e):r?r(e):e;function zs(e){const t=e.ref;return Wa(t)?t.files:qa(t)?yd(e.refs).value:bd(t)?[...t.selectedOptions].map(({value:n})=>n):si(t)?xd(e.refs).value:kd(Xe(t.value)?e.ref.value:t.value,e)}var Jg=(e,t,n,r)=>{const i={};for(const s of e){const a=oe(t,s);a&&Me(i,s,a._f)}return{criteriaMode:n,names:[...e],fields:i,shouldUseNativeValidation:r}},br=e=>Xe(e)?e:Di(e)?e.source:Qe(e)?Di(e.value)?e.value.source:e.value:e;const Uo="AsyncFunction";var Hg=e=>!!e&&!!e.validate&&!!(Vt(e.validate)&&e.validate.constructor.name===Uo||Qe(e.validate)&&Object.values(e.validate).find(t=>t.constructor.name===Uo)),Wg=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function Jo(e,t,n){const r=oe(e,n);if(r||Ja(n))return{error:r,name:n};const i=n.split(".");for(;i.length;){const s=i.join("."),a=oe(t,s),o=oe(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 qg=(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,Gg=(e,t)=>!ls(oe(e,t)).length&&rt(e,t);const Kg={mode:Ot.onSubmit,reValidateMode:Ot.onChange,shouldFocusError:!0};function Yg(e={}){let t={...Kg,...e},n={submitCount:0,isDirty:!1,isLoading:Vt(t.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1},r={},i=Qe(t.defaultValues)||Qe(t.values)?mt(t.defaultValues||t.values)||{}:{},s=t.shouldUnregister?{}:mt(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:Is(),array:Is(),state:Is()},p=Mo(t.mode),h=Mo(t.reValidateMode),g=t.criteriaMode===Ot.all,v=j=>z=>{clearTimeout(c),c=setTimeout(j,z)},S=async j=>{if(!t.disabled&&(f.isValid||j)){const z=t.resolver?gt((await O()).errors):await C(r,!0);z!==n.isValid&&d.state.next({isValid:z})}},x=(j,z)=>{!t.disabled&&(f.isValidating||f.validatingFields)&&((j||Array.from(o.mount)).forEach(M=>{M&&(z?Me(n.validatingFields,M,z):rt(n.validatingFields,M))}),d.state.next({validatingFields:n.validatingFields,isValidating:!gt(n.validatingFields)}))},_=(j,z=[],M,re,ee=!0,Q=!0)=>{if(re&&M&&!t.disabled){if(a.action=!0,Q&&Array.isArray(oe(r,j))){const pe=M(oe(r,j),re.argA,re.argB);ee&&Me(r,j,pe)}if(Q&&Array.isArray(oe(n.errors,j))){const pe=M(oe(n.errors,j),re.argA,re.argB);ee&&Me(n.errors,j,pe),Gg(n.errors,j)}if(f.touchedFields&&Q&&Array.isArray(oe(n.touchedFields,j))){const pe=M(oe(n.touchedFields,j),re.argA,re.argB);ee&&Me(n.touchedFields,j,pe)}f.dirtyFields&&(n.dirtyFields=yr(i,s)),d.state.next({name:j,isDirty:A(j,z),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else Me(s,j,z)},m=(j,z)=>{Me(n.errors,j,z),d.state.next({errors:n.errors})},I=j=>{n.errors=j,d.state.next({errors:n.errors,isValid:!1})},E=(j,z,M,re)=>{const ee=oe(r,j);if(ee){const Q=oe(s,j,Xe(M)?oe(i,j):M);Xe(Q)||re&&re.defaultChecked||z?Me(s,j,z?Q:zs(ee._f)):L(j,Q),a.mount&&S()}},w=(j,z,M,re,ee)=>{let Q=!1,pe=!1;const we={name:j};if(!t.disabled){const $=!!(oe(r,j)&&oe(r,j)._f&&oe(r,j)._f.disabled);if(!M||re){f.isDirty&&(pe=n.isDirty,n.isDirty=we.isDirty=A(),Q=pe!==we.isDirty);const G=$||un(oe(i,j),z);pe=!!(!$&&oe(n.dirtyFields,j)),G||$?rt(n.dirtyFields,j):Me(n.dirtyFields,j,!0),we.dirtyFields=n.dirtyFields,Q=Q||f.dirtyFields&&pe!==!G}if(M){const G=oe(n.touchedFields,j);G||(Me(n.touchedFields,j,M),we.touchedFields=n.touchedFields,Q=Q||f.touchedFields&&G!==M)}Q&&ee&&d.state.next(we)}return Q?we:{}},N=(j,z,M,re)=>{const ee=oe(n.errors,j),Q=f.isValid&&Nt(z)&&n.isValid!==z;if(t.delayError&&M?(l=v(()=>m(j,M)),l(t.delayError)):(clearTimeout(c),l=null,M?Me(n.errors,j,M):rt(n.errors,j)),(M?!un(ee,M):ee)||!gt(re)||Q){const pe={...re,...Q&&Nt(z)?{isValid:z}:{},errors:n.errors,name:j};n={...n,...pe},d.state.next(pe)}},O=async j=>{x(j,!0);const z=await t.resolver(s,t.context,Jg(j||o.mount,r,t.criteriaMode,t.shouldUseNativeValidation));return x(j),z},K=async j=>{const{errors:z}=await O(j);if(j)for(const M of j){const re=oe(z,M);re?Me(n.errors,M,re):rt(n.errors,M)}else n.errors=z;return z},C=async(j,z,M={valid:!0})=>{for(const re in j){const ee=j[re];if(ee){const{_f:Q,...pe}=ee;if(Q){const we=o.array.has(Q.name),$=ee._f&&Hg(ee._f);$&&f.validatingFields&&x([re],!0);const G=await Vo(ee,o.disabled,s,g,t.shouldUseNativeValidation&&!z,we);if($&&f.validatingFields&&x([re]),G[Q.name]&&(M.valid=!1,z))break;!z&&(oe(G,Q.name)?we?Zg(n.errors,G,Q.name):Me(n.errors,Q.name,G[Q.name]):rt(n.errors,Q.name))}!gt(pe)&&await C(pe,z,M)}}return M.valid},T=()=>{for(const j of o.unMount){const z=oe(r,j);z&&(z._f.refs?z._f.refs.every(M=>!Ts(M)):!Ts(z._f.ref))&&ie(j)}o.unMount=new Set},A=(j,z)=>!t.disabled&&(j&&z&&Me(s,j,z),!un(le(),i)),F=(j,z,M)=>gd(j,o,{...a.mount?s:Xe(z)?i:Ut(j)?{[j]:z}:z},M,z),R=j=>ls(oe(a.mount?s:i,j,t.shouldUnregister?oe(i,j,[]):[])),L=(j,z,M={})=>{const re=oe(r,j);let ee=z;if(re){const Q=re._f;Q&&(!Q.disabled&&Me(s,j,kd(z,Q)),ee=Oi(Q.ref)&&ct(z)?"":z,bd(Q.ref)?[...Q.ref.options].forEach(pe=>pe.selected=ee.includes(pe.value)):Q.refs?si(Q.ref)?Q.refs.length>1?Q.refs.forEach(pe=>(!pe.defaultChecked||!pe.disabled)&&(pe.checked=Array.isArray(ee)?!!ee.find(we=>we===pe.value):ee===pe.value)):Q.refs[0]&&(Q.refs[0].checked=!!ee):Q.refs.forEach(pe=>pe.checked=pe.value===ee):Wa(Q.ref)?Q.ref.value="":(Q.ref.value=ee,Q.ref.type||d.values.next({name:j,values:{...s}})))}(M.shouldDirty||M.shouldTouch)&&w(j,ee,M.shouldTouch,M.shouldDirty,!0),M.shouldValidate&&k(j)},P=(j,z,M)=>{for(const re in z){const ee=z[re],Q=`${j}.${re}`,pe=oe(r,Q);(o.array.has(j)||Qe(ee)||pe&&!pe._f)&&!jn(ee)?P(Q,ee,M):L(Q,ee,M)}},V=(j,z,M={})=>{const re=oe(r,j),ee=o.array.has(j),Q=mt(z);Me(s,j,Q),ee?(d.array.next({name:j,values:{...s}}),(f.isDirty||f.dirtyFields)&&M.shouldDirty&&d.state.next({name:j,dirtyFields:yr(i,s),isDirty:A(j,Q)})):re&&!re._f&&!ct(Q)?P(j,Q,M):L(j,Q,M),$o(j,o)&&d.state.next({...n}),d.values.next({name:a.mount?j:void 0,values:{...s}})},U=async j=>{a.mount=!0;const z=j.target;let M=z.name,re=!0;const ee=oe(r,M),Q=()=>z.type?zs(ee._f):ud(j),pe=we=>{re=Number.isNaN(we)||jn(we)&&isNaN(we.getTime())||un(we,oe(s,M,we))};if(ee){let we,$;const G=Q(),he=j.type===Pi.BLUR||j.type===Pi.FOCUS_OUT,je=!Wg(ee._f)&&!t.resolver&&!oe(n.errors,M)&&!ee._f.deps||qg(he,oe(n.touchedFields,M),n.isSubmitted,h,p),D=$o(M,o,he);Me(s,M,G),he?(ee._f.onBlur&&ee._f.onBlur(j),l&&l(0)):ee._f.onChange&&ee._f.onChange(j);const ge=w(M,G,he,!1),Te=!gt(ge)||D;if(!he&&d.values.next({name:M,type:j.type,values:{...s}}),je)return f.isValid&&(t.mode==="onBlur"&&he?S():he||S()),Te&&d.state.next({name:M,...D?{}:ge});if(!he&&D&&d.state.next({...n}),t.resolver){const{errors:Le}=await O([M]);if(pe(G),re){const nt=Jo(n.errors,r,M),et=Jo(Le,r,nt.name||M);we=et.error,M=et.name,$=gt(Le)}}else x([M],!0),we=(await Vo(ee,o.disabled,s,g,t.shouldUseNativeValidation))[M],x([M]),pe(G),re&&(we?$=!1:f.isValid&&($=await C(r,!0)));re&&(ee._f.deps&&k(ee._f.deps),N(M,$,we,ge))}},se=(j,z)=>{if(oe(n.errors,z)&&j.focus)return j.focus(),1},k=async(j,z={})=>{let M,re;const ee=Pr(j);if(t.resolver){const Q=await K(Xe(j)?j:ee);M=gt(Q),re=j?!ee.some(pe=>oe(Q,pe)):M}else j?(re=(await Promise.all(ee.map(async Q=>{const pe=oe(r,Q);return await C(pe&&pe._f?{[Q]:pe}:pe)}))).every(Boolean),!(!re&&!n.isValid)&&S()):re=M=await C(r);return d.state.next({...!Ut(j)||f.isValid&&M!==n.isValid?{}:{name:j},...t.resolver||!j?{isValid:M}:{},errors:n.errors}),z.shouldFocus&&!re&&Or(r,se,j?ee:o.mount),re},le=j=>{const z={...a.mount?s:i};return Xe(j)?z:Ut(j)?oe(z,j):j.map(M=>oe(z,M))},q=(j,z)=>({invalid:!!oe((z||n).errors,j),isDirty:!!oe((z||n).dirtyFields,j),error:oe((z||n).errors,j),isValidating:!!oe(n.validatingFields,j),isTouched:!!oe((z||n).touchedFields,j)}),y=j=>{j&&Pr(j).forEach(z=>rt(n.errors,z)),d.state.next({errors:j?n.errors:{}})},W=(j,z,M)=>{const re=(oe(r,j,{_f:{}})._f||{}).ref,ee=oe(n.errors,j)||{},{ref:Q,message:pe,type:we,...$}=ee;Me(n.errors,j,{...$,...z,ref:re}),d.state.next({name:j,errors:n.errors,isValid:!1}),M&&M.shouldFocus&&re&&re.focus&&re.focus()},B=(j,z)=>Vt(j)?d.values.subscribe({next:M=>j(F(void 0,z),M)}):F(j,z,!0),ie=(j,z={})=>{for(const M of j?Pr(j):o.mount)o.mount.delete(M),o.array.delete(M),z.keepValue||(rt(r,M),rt(s,M)),!z.keepError&&rt(n.errors,M),!z.keepDirty&&rt(n.dirtyFields,M),!z.keepTouched&&rt(n.touchedFields,M),!z.keepIsValidating&&rt(n.validatingFields,M),!t.shouldUnregister&&!z.keepDefaultValue&&rt(i,M);d.values.next({values:{...s}}),d.state.next({...n,...z.keepDirty?{isDirty:A()}:{}}),!z.keepIsValid&&S()},te=({disabled:j,name:z,field:M,fields:re})=>{(Nt(j)&&a.mount||j||o.disabled.has(z))&&(j?o.disabled.add(z):o.disabled.delete(z),w(z,zs(M?M._f:oe(re,z)._f),!1,!1,!0))},X=(j,z={})=>{let M=oe(r,j);const re=Nt(z.disabled)||Nt(t.disabled);return Me(r,j,{...M||{},_f:{...M&&M._f?M._f:{ref:{name:j}},name:j,mount:!0,...z}}),o.mount.add(j),M?te({field:M,disabled:Nt(z.disabled)?z.disabled:t.disabled,name:j}):E(j,!0,z.value),{...re?{disabled:z.disabled||t.disabled}:{},...t.progressive?{required:!!z.required,min:br(z.min),max:br(z.max),minLength:br(z.minLength),maxLength:br(z.maxLength),pattern:br(z.pattern)}:{},name:j,onChange:U,onBlur:U,ref:ee=>{if(ee){X(j,z),M=oe(r,j);const Q=Xe(ee.value)&&ee.querySelectorAll&&ee.querySelectorAll("input,select,textarea")[0]||ee,pe=Ug(Q),we=M._f.refs||[];if(pe?we.find($=>$===Q):Q===M._f.ref)return;Me(r,j,{_f:{...M._f,...pe?{refs:[...we.filter(Ts),Q,...Array.isArray(oe(i,j))?[{}]:[]],ref:{type:Q.type,name:j}}:{ref:Q}}}),E(j,!1,void 0,Q)}else M=oe(r,j,{}),M._f&&(M._f.mount=!1),(t.shouldUnregister||z.shouldUnregister)&&!(cd(o.array,j)&&a.action)&&o.unMount.add(j)}}},fe=()=>t.shouldFocusError&&Or(r,se,o.mount),be=j=>{Nt(j)&&(d.state.next({disabled:j}),Or(r,(z,M)=>{const re=oe(r,M);re&&(z.disabled=re._f.disabled||j,Array.isArray(re._f.refs)&&re._f.refs.forEach(ee=>{ee.disabled=re._f.disabled||j}))},0,!1))},ne=(j,z)=>async M=>{let re;M&&(M.preventDefault&&M.preventDefault(),M.persist&&M.persist());let ee=mt(s);if(o.disabled.size)for(const Q of o.disabled)Me(ee,Q,void 0);if(d.state.next({isSubmitting:!0}),t.resolver){const{errors:Q,values:pe}=await O();n.errors=Q,ee=pe}else await C(r);if(rt(n.errors,"root"),gt(n.errors)){d.state.next({errors:{}});try{await j(ee,M)}catch(Q){re=Q}}else z&&await z({...n.errors},M),fe(),setTimeout(fe);if(d.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:gt(n.errors)&&!re,submitCount:n.submitCount+1,errors:n.errors}),re)throw re},de=(j,z={})=>{oe(r,j)&&(Xe(z.defaultValue)?V(j,mt(oe(i,j))):(V(j,z.defaultValue),Me(i,j,mt(z.defaultValue))),z.keepTouched||rt(n.touchedFields,j),z.keepDirty||(rt(n.dirtyFields,j),n.isDirty=z.defaultValue?A(j,mt(oe(i,j))):A()),z.keepError||(rt(n.errors,j),f.isValid&&S()),d.state.next({...n}))},ue=(j,z={})=>{const M=j?mt(j):i,re=mt(M),ee=gt(j),Q=ee?i:re;if(z.keepDefaultValues||(i=M),!z.keepValues){if(z.keepDirtyValues){const pe=new Set([...o.mount,...Object.keys(yr(i,s))]);for(const we of Array.from(pe))oe(n.dirtyFields,we)?Me(Q,we,oe(s,we)):V(we,oe(Q,we))}else{if(Ua&&Xe(j))for(const pe of o.mount){const we=oe(r,pe);if(we&&we._f){const $=Array.isArray(we._f.refs)?we._f.refs[0]:we._f.ref;if(Oi($)){const G=$.closest("form");if(G){G.reset();break}}}}r={}}s=t.shouldUnregister?z.keepDefaultValues?mt(i):{}:mt(Q),d.array.next({values:{...Q}}),d.values.next({values:{...Q}})}o={mount:z.keepDirtyValues?o.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},a.mount=!f.isValid||!!z.keepIsValid||!!z.keepDirtyValues,a.watch=!!t.shouldUnregister,d.state.next({submitCount:z.keepSubmitCount?n.submitCount:0,isDirty:ee?!1:z.keepDirty?n.isDirty:!!(z.keepDefaultValues&&!un(j,i)),isSubmitted:z.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:ee?{}:z.keepDirtyValues?z.keepDefaultValues&&s?yr(i,s):n.dirtyFields:z.keepDefaultValues&&j?yr(i,j):z.keepDirty?n.dirtyFields:{},touchedFields:z.keepTouched?n.touchedFields:{},errors:z.keepErrors?n.errors:{},isSubmitSuccessful:z.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1})},Z=(j,z)=>ue(Vt(j)?j(s):j,z);return{control:{register:X,unregister:ie,getFieldState:q,handleSubmit:ne,setError:W,_executeSchema:O,_getWatch:F,_getDirty:A,_updateValid:S,_removeUnmounted:T,_updateFieldArray:_,_updateDisabledField:te,_getFieldArray:R,_reset:ue,_resetDefaultValues:()=>Vt(t.defaultValues)&&t.defaultValues().then(j=>{Z(j,t.resetOptions),d.state.next({isLoading:!1})}),_updateFormState:j=>{n={...n,...j}},_disableForm:be,_subjects:d,_proxyFormState:f,_setErrors:I,get _fields(){return r},get _formValues(){return s},get _state(){return a},set _state(j){a=j},get _defaultValues(){return i},get _names(){return o},set _names(j){o=j},get _formState(){return n},set _formState(j){n=j},get _options(){return t},set _options(j){t={...t,...j}}},trigger:k,register:X,handleSubmit:ne,watch:B,setValue:V,getValues:le,reset:Z,resetField:de,clearErrors:y,unregister:ie,setError:W,setFocus:(j,z={})=>{const M=oe(r,j),re=M&&M._f;if(re){const ee=re.refs?re.refs[0]:re.ref;ee.focus&&(ee.focus(),z.shouldSelect&&Vt(ee.select)&&ee.select())}},getFieldState:q}}function Xg(e={}){const t=_e.useRef(void 0),n=_e.useRef(void 0),[r,i]=_e.useState({isDirty:!1,isValidating:!1,isLoading:Vt(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,defaultValues:Vt(e.defaultValues)?void 0:e.defaultValues});t.current||(t.current={...Yg(e),formState:r});const s=t.current.control;return s._options=e,Ha({subject:s._subjects.state,next:a=>{hd(a,s._proxyFormState,s._updateFormState,!0)&&i({...s._formState})}}),_e.useEffect(()=>s._disableForm(e.disabled),[s,e.disabled]),_e.useEffect(()=>{if(s._proxyFormState.isDirty){const a=s._getDirty();a!==r.isDirty&&s._subjects.state.next({isDirty:a})}},[s,r.isDirty]),_e.useEffect(()=>{e.values&&!un(e.values,n.current)?(s._reset(e.values,s._options.resetOptions),n.current=e.values,i(a=>({...a}))):s._resetDefaultValues()},[e.values,s]),_e.useEffect(()=>{e.errors&&s._setErrors(e.errors)},[e.errors,s]),_e.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()}),_e.useEffect(()=>{e.shouldUnregister&&s._subjects.values.next({values:s._getWatch()})},[e.shouldUnregister,s]),t.current.formState=pd(r,s),t.current}function Qg(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 ex=Dg,Sd=b.createContext({}),Ho=({...e})=>u.jsx(Sd.Provider,{value:{name:e.name},children:u.jsx(Fg,{...e})}),cs=()=>{const e=b.useContext(Sd),t=b.useContext(_d),{getFieldState:n,formState:r}=us(),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}},_d=b.createContext({}),fa=b.forwardRef(({className:e,...t},n)=>{const r=b.useId();return u.jsx(_d.Provider,{value:{id:r},children:u.jsx("div",{ref:n,className:H("space-y-2",e),...t})})});fa.displayName="FormItem";const pa=b.forwardRef(({className:e,...t},n)=>{const{error:r,formItemId:i}=cs();return u.jsx(Xn,{ref:n,className:H(r&&"text-destructive",e),htmlFor:i,...t})});pa.displayName="FormLabel";const ha=b.forwardRef(({...e},t)=>{const{error:n,formItemId:r,formDescriptionId:i,formMessageId:s}=cs();return u.jsx(dr,{ref:t,id:r,"aria-describedby":n?`${i} ${s}`:`${i}`,"aria-invalid":!!n,...e})});ha.displayName="FormControl";const jd=b.forwardRef(({className:e,...t},n)=>{const{formDescriptionId:r}=cs();return u.jsx("p",{ref:n,id:r,className:H("text-muted-foreground text-[0.8rem]",e),...t})});jd.displayName="FormDescription";const ma=b.forwardRef(({className:e,children:t,...n},r)=>{const{error:i,formMessageId:s}=cs(),a=i?String(i==null?void 0:i.message):t;return a?u.jsx("p",{ref:r,id:s,className:H("text-destructive text-[0.8rem] font-medium",e),...n,children:a}):null});ma.displayName="FormMessage";function Ga(){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 Cd=()=>({chatOpen:!1,scope:"global",model:"opus",contextAttachments:[],threads:{},activeThreadId:{}}),tx=(e=Cd())=>wg()(kg(Sg((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:Ga(),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:_g(()=>hg),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}}))),Nd=b.createContext(void 0),nx=({children:e})=>{const t=b.useRef(null);return t.current||(t.current=tx(Cd())),u.jsx(Nd.Provider,{value:t.current,children:e})},Pe=e=>{const t=b.useContext(Nd);if(!t)throw new Error("useChatStore must be used within ChatStoreProvider");return jg(t,e)};function rx(e,t,n){return t.filter(r=>r.name!==n).every(r=>r.name!==e)}function ix(e,t,n){const r={},i=[];e!=="delete"&&(r.name=fi.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=fi.Optional(fi.String({description:"Template selection"})));const s=fi.Object(r,{additionalProperties:!1,required:i.length>0?i:void 0});return{schema:s,validate:a=>{const o=[];if(!Dm(s,a))for(const c of Rm(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 sx(e,t,n){return e==="create"?{name:"",template:t}:e==="update"?{name:n}:{}}const ax=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"}}),Mn="__empty__";function ox({mode:e,shouldReset:t,postSubmit:n,selectedName:r,discoveredDocuments:i,discoveredThemes:s,isTheme:a}){const[o,l]=b.useState(!1),[c,f]=b.useState(null),[d,p]=b.useState("idle"),{toast:h}=fr(),g=ax(a),{documents:v,openTabs:S,createDocument:x,renameDocument:_,deleteDocument:m,openDocument:I,closeDocument:E}=Oe(le=>le),{updateTheme:w,removeTheme:N}=ca(le=>le),O=Pe(le=>le.renameThreadsForDocument),K=Pe(le=>le.deleteThreadsForDocument),C=b.useMemo(()=>a?s||[]:i||[],[a,i,s]),T=b.useMemo(()=>{const le={current:[],downstream:[]};return C.forEach(q=>{le[q.location]&&le[q.location].push(q)}),le},[C]),A=b.useMemo(()=>C.map(le=>({name:le.name,type:"application/json",text:"",mtime:new Date,ctime:new Date,atime:new Date})),[C]),F=b.useMemo(()=>ix(e,le=>rx(le,v,r),A),[e,v,r,A]),R=F.schema,L=b.useMemo(()=>{const le=new Map;return C.forEach(q=>le.set(q.path,q)),le},[C]),P=Mn,V=Xg({resolver:Qg(F.validate),defaultValues:sx(e,void 0,r)}),[U,se]=b.useState(P);b.useEffect(()=>{if(U&&U!==Mn&&e==="create"){const le=L.get(U);if(le){f(null),p("loading");let q=!1;return fetch(`/api/discovery/${a?"themes":"documents"}/${encodeURIComponent(le.name)}/content`).then(y=>{if(!y.ok)throw new Error(`Failed to fetch content: ${y.statusText}`);return y.text()}).then(y=>{if(q)return;const W=JSON.parse(y);f(JSON.stringify(W,null,2)),p("idle")}).catch(y=>{q||(console.error("Failed to copy template:",y),f(null),p("error"))}),()=>{q=!0}}}p("idle")},[U,e,L,a]),b.useEffect(()=>{t&&(V.reset(),f(null),p("idle"),se(P))},[V,t]);const k=V.handleSubmit(async({name:le,template:q})=>{l(!0);try{if(await new Promise(y=>setTimeout(y,200)),e==="create"){const y=U?L.get(U):C.find(de=>de.name===q);let W,B=le;if(!!U&&U!==Mn&&c===null){h({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 de=B.replace(/\.(json|theme)$/i,"").toLowerCase().replace(/\s+/g,"-"),ue=yt==="docx"?Mm(de):{name:de,colors:{primary:"#2563EB",secondary:"#64748B",accent:"#F8FAFC",background:"#FFFFFF",text:"#334155"},fonts:{heading:"Calibri",body:"Calibri"},defaults:{fontSize:18,fontColor:"#334155"}};W=c||JSON.stringify(ue,null,2);const Z=`.${yt}.theme.json`;B.endsWith(Z)||(B=B.replace(/\.(pptx|docx)\.theme\.json$/i,"").replace(/\.theme\.json$/i,"").replace(/\.json$/i,""),B+=Z)}else{const de=y;W=c||JSON.stringify(yt==="docx"?{name:"docx",props:{theme:(de==null?void 0:de.theme)||"default",metadata:{title:(de==null?void 0:de.title)||B.replace(/\.(json|js)$/i,"")}},children:[{name:"section",props:{},children:[{name:"paragraph",props:{text:"Start writing your document content here..."}}]}]}:{name:"pptx",props:{title:(de==null?void 0:de.title)||B.replace(/\.(json|js)$/i,""),theme:(de==null?void 0:de.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 ue=yt==="docx"?".docx.json":".pptx.json";!B.endsWith(ue)&&!B.endsWith(".json")&&(B+=ue)}const te=B.match(/(\.(pptx|docx)(\.theme)?\.json|\.json)$/i),X=te?te[0]:"",fe=B.slice(0,B.length-X.length);let be=B,ne=1;for(;v.some(de=>de.name===be);)ne++,be=`${fe} (${ne})${X}`;B=be,x(B,W),I(B),a&&w(B,W)}else if(e==="update"){const y=r,W=le,B=S.includes(y);B&&E(y),_(y,W),O(y,W),B&&I(W)}else if(e==="delete"){const y=r;E(y),m(y),K(y),a&&N(y)}n()}finally{l(!1)}});return u.jsx(ex,{...V,children:u.jsxs("form",{onSubmit:k,children:[u.jsxs(Ht,{children:[u.jsx(Wt,{children:g[e].title}),u.jsx(hn,{children:g[e].description})]}),u.jsxs("div",{className:"flex flex-col gap-4 py-4",children:[R.properties&&"name"in R.properties&&u.jsx(Ho,{control:V.control,name:"name",render:({field:le})=>u.jsxs(fa,{children:[u.jsx(pa,{children:"Name"}),u.jsx(ha,{children:u.jsx(ii,{placeholder:"Enter a name or select a template below",autoComplete:"off",...le})}),u.jsx(ma,{})]})}),e==="create"&&u.jsx(Ho,{control:V.control,name:"template",render:({field:le})=>u.jsxs(fa,{children:[u.jsx(pa,{children:a?"Base Theme":"Base Document"}),u.jsxs(Fr,{onValueChange:q=>{if(q===Mn)le.onChange(void 0),V.setValue("name",""),se(Mn),f(null);else{const y=L.get(q);y&&(le.onChange(y.name),V.setValue("name",y.name),se(q))}},defaultValue:P,children:[u.jsx(ha,{children:u.jsx(rr,{children:u.jsx(Lr,{placeholder:`Select a discovered ${a?"theme":"document"}`})})}),u.jsxs(ir,{className:"max-h-[300px]",children:[u.jsxs(Tn,{value:Mn,children:["Empty ",a?"theme":"document"]}),Object.entries(T).map(([q,y])=>y.length===0?null:u.jsxs(Eg,{children:[u.jsx(od,{children:q==="current"?"📁 Current Directory":"📦 Project"}),y.map(W=>{let B;return W.title&&W.title!==W.name?B=W.title:W.description&&(B=W.description.length>40?W.description.substring(0,40)+"...":W.description),u.jsx(Tn,{value:W.path,className:"pl-6",children:u.jsxs("span",{className:"flex flex-col",children:[u.jsx("span",{className:"font-medium",children:W.name}),B&&u.jsx("span",{className:"text-muted-foreground text-xs",children:B})]})},W.path)})]},q))]})]}),u.jsxs(jd,{children:["Start empty or select a discovered"," ",a?"theme":"document"," as a starting point"]}),u.jsx(ma,{})]})})]}),u.jsx(In,{children:u.jsx(Ee,{type:"submit",variant:g[e].buttonVariant,disabled:o,children:o?u.jsxs(u.Fragment,{children:[u.jsx(en,{size:"sm",className:"mr-2"}),e==="create"?"Creating...":e==="update"?"Saving...":"Deleting..."]}):g[e].button})})]})})}const Mi=_e.memo(ox);function sn(e,t){return t?e.toLowerCase().includes(t.toLowerCase()):!0}function Ka({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 Wo({children:e,count:t,actions:n,className:r}){return u.jsxs("div",{className:H("flex h-6 shrink-0 items-center gap-1.5 px-1 select-none",r),children:[u.jsx("span",{className:"text-[11px] font-medium tracking-[0.08em] text-sidebar-foreground/70 uppercase",children:e}),t!==void 0&&u.jsx("span",{className:"text-[11px] font-normal tabular-nums text-sidebar-foreground/65",children:t}),n&&u.jsx("div",{className:"ml-auto flex items-center gap-0.5",children:n})]})}const Ft=_e.forwardRef(({className:e,...t},n)=>u.jsx("button",{ref:n,type:"button",className:H("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}));Ft.displayName="RailIconButton";function qo({tone:e,className:t}){return u.jsx("span",{"aria-hidden":!0,className:H("size-1.5 shrink-0 rounded-full",e==="preview"?"bg-data-blue":"bg-warning",t)})}function Go({icon:e,label:t,onClick:n,hint:r}){return n?u.jsxs("button",{type:"button",onClick:n,title:r,className:H("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 lx=bm,ux=vm,cx=b.forwardRef(({className:e,inset:t,children:n,...r},i)=>u.jsxs(kc,{ref:i,className:H("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(ri,{className:"ml-auto h-4 w-4"})]}));cx.displayName=kc.displayName;const dx=b.forwardRef(({className:e,...t},n)=>u.jsx(Sc,{ref:n,className:H("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}));dx.displayName=Sc.displayName;const Ed=b.forwardRef(({className:e,...t},n)=>u.jsx(wm,{children:u.jsx(bc,{ref:n,className:H("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})}));Ed.displayName=bc.displayName;const Id=b.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(wc,{ref:r,className:H("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}));Id.displayName=wc.displayName;const fx=b.forwardRef(({className:e,children:t,checked:n,...r},i)=>u.jsxs(_c,{ref:i,className:H("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(jc,{children:u.jsx(pn,{className:"h-4 w-4"})})}),t]}));fx.displayName=_c.displayName;const px=b.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Cc,{ref:r,className:H("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(jc,{children:u.jsx(Wc,{className:"h-4 w-4 fill-current"})})}),t]}));px.displayName=Cc.displayName;const hx=b.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Nc,{ref:r,className:H("text-foreground px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));hx.displayName=Nc.displayName;const Td=b.forwardRef(({className:e,...t},n)=>u.jsx(vc,{ref:n,className:H("bg-border -mx-1 my-1 h-px",e),...t}));Td.displayName=vc.displayName;const zd=({className:e,...t})=>u.jsx("span",{className:H("text-muted-foreground ml-auto text-xs tracking-widest",e),...t});zd.displayName="ContextMenuShortcut";const ds=km,fs=Sm,mx=b.forwardRef(({className:e,inset:t,children:n,...r},i)=>u.jsxs(Ac,{ref:i,className:H("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(ri,{className:"ml-auto"})]}));mx.displayName=Ac.displayName;const gx=b.forwardRef(({className:e,...t},n)=>u.jsx(Pc,{ref:n,className:H("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}));gx.displayName=Pc.displayName;const ai=b.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(_m,{children:u.jsx(Ec,{ref:r,sideOffset:t,className:H("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})}));ai.displayName=Ec.displayName;const Bt=b.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Ic,{ref:r,className:H("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}));Bt.displayName=Ic.displayName;const xx=b.forwardRef(({className:e,children:t,checked:n,...r},i)=>u.jsxs(Oc,{ref:i,className:H("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(Dc,{children:u.jsx(pn,{className:"h-4 w-4"})})}),t]}));xx.displayName=Oc.displayName;const yx=b.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Rc,{ref:r,className:H("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(Dc,{children:u.jsx(Wc,{className:"h-2 w-2 fill-current"})})}),t]}));yx.displayName=Rc.displayName;const Ad=b.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(zc,{ref:r,className:H("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));Ad.displayName=zc.displayName;const sr=b.forwardRef(({className:e,...t},n)=>u.jsx(Tc,{ref:n,className:H("bg-muted -mx-1 my-1 h-px",e),...t}));sr.displayName=Tc.displayName;const Pd=({className:e,...t})=>u.jsx("span",{className:H("ml-auto text-xs tracking-widest opacity-60",e),...t});Pd.displayName="DropdownMenuShortcut";const Od=b.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},i)=>u.jsx(Mc,{ref:i,decorative:n,orientation:t,className:H("bg-border shrink-0",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));Od.displayName=Mc.displayName;const Dd=uc,bx=jm,vx=cc,Rd=b.forwardRef(({className:e,...t},n)=>u.jsx(as,{className:H("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}));Rd.displayName=as.displayName;const wx=ni("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"}}),Ya=b.forwardRef(({side:e="right",className:t,children:n,...r},i)=>u.jsxs(vx,{children:[u.jsx(Rd,{}),u.jsxs(rs,{ref:i,className:H(wx({side:e}),t),...r,children:[u.jsxs(Ba,{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(fn,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]}),n]})]}));Ya.displayName=rs.displayName;const kx=b.forwardRef(({className:e,...t},n)=>u.jsx(is,{ref:n,className:H("text-foreground text-lg font-semibold",e),...t}));kx.displayName=is.displayName;const Sx=b.forwardRef(({className:e,...t},n)=>u.jsx(ss,{ref:n,className:H("text-muted-foreground text-sm",e),...t}));Sx.displayName=ss.displayName;function Dr({className:e,...t}){return u.jsx("div",{className:H("bg-primary/10 animate-pulse rounded-md",e),...t})}const As=768,Ps=1200;function Md(e){return typeof window<"u"?window.innerWidth<e:!1}function $d(){const[e,t]=b.useState(()=>Md(As));return b.useEffect(()=>{const n=window.matchMedia(`(max-width: ${As-1}px)`),r=()=>{t(window.innerWidth<As)};return n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),e}function _x(){const[e,t]=b.useState(()=>Md(Ps));return b.useEffect(()=>{const n=window.matchMedia(`(max-width: ${Ps-1}px)`),r=()=>{t(window.innerWidth<Ps)};return n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),e}const jx="sidebar_state",Cx=60*60*24*7,Nx="16rem",Ex="18rem",Ix="3rem",Tx="b",Fd=b.createContext(null);function ps(){const e=b.useContext(Fd);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}const Ld=b.forwardRef(({defaultOpen:e=!0,open:t,onOpenChange:n,className:r,style:i,children:s,...a},o)=>{const l=$d(),[c,f]=b.useState(!1),[d,p]=b.useState(e),h=t??d,g=b.useCallback(_=>{const m=typeof _=="function"?_(h):_;n?n(m):p(m),document.cookie=`${jx}=${m}; path=/; max-age=${Cx}`},[n,h]),v=b.useCallback(()=>l?f(_=>!_):g(_=>!_),[l,g,f]);b.useEffect(()=>{const _=I=>{var N;const E=I;if(!E)return!1;const w=(N=E.tagName)==null?void 0:N.toLowerCase();return w==="input"||w==="textarea"||w==="select"||E.isContentEditable?!0:!!(E.closest&&E.closest(".monaco-editor"))},m=I=>{const E=I.metaKey||I.ctrlKey,w=I.key.toLowerCase();if(E&&w===Tx){I.preventDefault(),v();return}E&&w==="s"&&!_(I.target)&&(I.preventDefault(),v())};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[v]);const S=h?"expanded":"collapsed",x=b.useMemo(()=>({state:S,open:h,setOpen:g,isMobile:l,openMobile:c,setOpenMobile:f,toggleSidebar:v}),[S,h,g,l,c,f,v]);return u.jsx(Fd.Provider,{value:x,children:u.jsx($m,{delayDuration:0,children:u.jsx("div",{style:{"--sidebar-width":Nx,"--sidebar-width-icon":Ix,...i},className:H("group/sidebar-wrapper has-[[data-variant=inset]]:bg-sidebar flex min-h-svh w-full",r),ref:o,...a,children:s})})})});Ld.displayName="SidebarProvider";const Zd=b.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}=ps();return n==="none"?u.jsx("div",{className:H("bg-sidebar text-sidebar-foreground flex h-full w-[--sidebar-width] flex-col",r),ref:a,...s,children:i}):o?u.jsx(Dd,{open:c,onOpenChange:f,...s,children:u.jsx(Ya,{"data-sidebar":"sidebar","data-mobile":"true",className:"bg-sidebar text-sidebar-foreground w-[--sidebar-width] p-0 [&>button]:hidden",style:{"--sidebar-width":Ex},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:H("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:H("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})})]})});Zd.displayName="Sidebar";const zx=b.forwardRef(({className:e,onClick:t,...n},r)=>{const{toggleSidebar:i}=ps();return u.jsxs(Ee,{ref:r,"data-sidebar":"trigger",variant:"ghost",size:"icon",className:H("h-7 w-7",e),onClick:s=>{t==null||t(s),i()},...n,children:[u.jsx(Jm,{}),u.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});zx.displayName="SidebarTrigger";const Ax=b.forwardRef(({className:e,...t},n)=>{const{toggleSidebar:r}=ps();return u.jsx("button",{ref:n,"data-sidebar":"rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:r,title:"Toggle Sidebar",className:H("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})});Ax.displayName="SidebarRail";const Px=b.forwardRef(({className:e,...t},n)=>u.jsx("main",{ref:n,className:H("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}));Px.displayName="SidebarInset";const Ox=b.forwardRef(({className:e,...t},n)=>u.jsx(ii,{ref:n,"data-sidebar":"input",className:H("bg-background focus-visible:ring-sidebar-ring h-8 w-full shadow-none focus-visible:ring-2",e),...t}));Ox.displayName="SidebarInput";const ga=b.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,"data-sidebar":"header",className:H("flex flex-col gap-2 p-2",e),...t}));ga.displayName="SidebarHeader";const Bd=b.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,"data-sidebar":"footer",className:H("flex flex-col gap-2 p-2",e),...t}));Bd.displayName="SidebarFooter";const Dx=b.forwardRef(({className:e,...t},n)=>u.jsx(Od,{ref:n,"data-sidebar":"separator",className:H("bg-sidebar-border mx-2 w-auto",e),...t}));Dx.displayName="SidebarSeparator";const xa=b.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,"data-sidebar":"content",className:H("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",e),...t}));xa.displayName="SidebarContent";const Rx=b.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,"data-sidebar":"group",className:H("relative flex w-full min-w-0 flex-col p-2",e),...t}));Rx.displayName="SidebarGroup";const Mx=b.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const i=t?dr:"div";return u.jsx(i,{ref:r,"data-sidebar":"group-label",className:H("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})});Mx.displayName="SidebarGroupLabel";const $x=b.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const i=t?dr:"button";return u.jsx(i,{ref:r,"data-sidebar":"group-action",className:H("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})});$x.displayName="SidebarGroupAction";const Fx=b.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,"data-sidebar":"group-content",className:H("w-full text-sm",e),...t}));Fx.displayName="SidebarGroupContent";const Cr=b.forwardRef(({className:e,...t},n)=>u.jsx("ul",{ref:n,"data-sidebar":"menu",className:H("flex w-full min-w-0 flex-col gap-1",e),...t}));Cr.displayName="SidebarMenu";const Vd=b.forwardRef(({className:e,...t},n)=>u.jsx("li",{ref:n,"data-sidebar":"menu-item",className:H("group/menu-item relative",e),...t}));Vd.displayName="SidebarMenuItem";const Lx=ni("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"}}),Ud=b.forwardRef(({asChild:e=!1,isActive:t=!1,variant:n="default",size:r="default",tooltip:i,className:s,...a},o)=>{const l=e?dr:"button",{isMobile:c,state:f}=ps(),d=u.jsx(l,{ref:o,"data-sidebar":"menu-button","data-size":r,"data-active":t,className:H(Lx({variant:n,size:r}),s),...a});return i?(typeof i=="string"&&(i={children:i}),u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:d}),u.jsx(Ke,{side:"right",align:"center",hidden:f!=="collapsed"||c,...i})]})):d});Ud.displayName="SidebarMenuButton";const Jd=b.forwardRef(({className:e,asChild:t=!1,showOnHover:n=!1,...r},i)=>{const s=t?dr:"button";return u.jsx(s,{ref:i,"data-sidebar":"menu-action",className:H("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})});Jd.displayName="SidebarMenuAction";const Zx=b.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,"data-sidebar":"menu-badge",className:H("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}));Zx.displayName="SidebarMenuBadge";const Bx=b.forwardRef(({className:e,showIcon:t=!1,...n},r)=>{const i=b.useMemo(()=>`${Math.floor(Math.random()*40)+50}%`,[]);return u.jsxs("div",{ref:r,"data-sidebar":"menu-skeleton",className:H("flex h-8 items-center gap-2 rounded-md px-2",e),...n,children:[t&&u.jsx(Dr,{className:"size-4 rounded-md","data-sidebar":"menu-skeleton-icon"}),u.jsx(Dr,{className:"h-4 max-w-[--skeleton-width] flex-1","data-sidebar":"menu-skeleton-text",style:{"--skeleton-width":i}})]})});Bx.displayName="SidebarMenuSkeleton";const Vx=b.forwardRef(({className:e,...t},n)=>u.jsx("ul",{ref:n,"data-sidebar":"menu-sub",className:H("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}));Vx.displayName="SidebarMenuSub";const Ux=b.forwardRef(({...e},t)=>u.jsx("li",{ref:t,...e}));Ux.displayName="SidebarMenuSubItem";const Jx=b.forwardRef(({asChild:e=!1,size:t="md",isActive:n,className:r,...i},s)=>{const a=e?dr:"a";return u.jsx(a,{ref:s,"data-sidebar":"menu-sub-button","data-size":t,"data-active":n,className:H("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})});Jx.displayName="SidebarMenuSubButton";function Ei(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 Hx=typeof window<"u"?navigator.userAgent.toUpperCase().indexOf("MAC")>=0:!1;function Wx({document:e,compact:t=!1,query:n=""}){const r=b.useRef(null),[i,s]=b.useState(!1),[a,o]=b.useState(!1),[l,c]=b.useState(!1),[f,d]=b.useState(!1),p=Oe(q=>q.openDocument),h=Oe(q=>q.documentTypes),g=Oe(q=>q.activeTab),v=Qt(q=>q.name),S=Qt(q=>q.text),x=Qt(q=>q.isGenerating),m=(h[e.name]||"application/json+report")==="application/json+theme",I=g===e.name,[E,w]=b.useState(v),[N,O]=b.useState(S),K=100,C=0;b.useEffect(()=>{const q=setTimeout(()=>{v&&S?(w(v),O(S)):x||(w(""),O(""))},x?K:C);return()=>clearTimeout(q)},[v,S,x]);const T=E===e.name,A=q=>{var W;const y=new Set;try{const B=JSON.parse(q);(W=B.props)!=null&&W.theme&&y.add(B.props.theme),B.children&&Array.isArray(B.children)&&B.children.forEach(ie=>{var te;ie.name==="docx"&&((te=ie.props)!=null&&te.theme)&&y.add(ie.props.theme)})}catch{}return y},F=b.useMemo(()=>{if(!m||!N)return!1;try{const q=JSON.parse(e.text),y=mg(q);if(y)return A(N).has(y)}catch{}return!1},[m,N,e.text]),R=b.useCallback(()=>{c(!1)},[]),L=b.useCallback(()=>{d(!1)},[]),P=I?null:T?"preview":F?"in-use":null,V=I?"Editing":T?"In preview":F?"Used by preview":null,U=b.useMemo(()=>[{key:"open",label:"Open",shortcut:Hx?"⌘⏎":"⌃⏎",run:()=>p(e.name)},{key:"download",label:"Download…",separatorBefore:!0,run:()=>Ei(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,p]),se=m?Hm:qc,k=i||a,le=u.jsxs(Ud,{size:"sm",ref:r,"aria-label":V?`${e.name} — ${V}`:e.name,className:H("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",k&&"bg-sidebar-accent/60 text-sidebar-foreground",I&&"bg-sidebar-accent text-sidebar-accent-foreground font-medium"),title:V?`${e.name} — ${V}`:e.name,onClick:()=>{p(e.name)},onKeyDown:q=>{var y;(q.ctrlKey||q.metaKey)&&q.key==="Enter"?(p(e.name),q.preventDefault()):q.key==="Enter"?(c(!0),q.preventDefault()):q.key==="Backspace"||q.key==="Delete"?(d(!0),q.preventDefault()):q.key==="Escape"&&((y=r.current)==null||y.blur(),q.preventDefault())},children:[I&&u.jsx("span",{"aria-hidden":!0,className:H("bg-primary absolute top-1 bottom-1 left-0 w-[2px] rounded-full",t&&"top-1.5 bottom-1.5")}),u.jsx(se,{className:H("size-3.5 shrink-0",m?"text-accent2":"text-sidebar-foreground/60",I&&!m&&"text-sidebar-accent-foreground/70")}),!t&&u.jsx("span",{className:"flex-1 truncate",children:u.jsx(Ka,{text:e.name,query:n})}),t&&P&&u.jsx(qo,{tone:P,className:"absolute top-1 right-1 size-1.5 ring-2 ring-[hsl(var(--sidebar))]"})]});return u.jsxs(Vd,{children:[u.jsxs(lx,{onOpenChange:s,children:[u.jsx(ux,{className:"block",children:t?u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:le}),u.jsx(Ke,{side:"right",children:u.jsxs("div",{className:"text-xs",children:[u.jsx("div",{children:e.name}),u.jsx("div",{className:"opacity-70",children:V??(m?"Theme":"Document")})]})})]}):le}),u.jsx(Ed,{className:"w-44",children:U.map(q=>u.jsxs(_e.Fragment,{children:[q.separatorBefore&&u.jsx(Td,{}),u.jsxs(Id,{onClick:q.run,className:H(q.danger&&"text-destructive focus:text-destructive"),children:[q.label,q.shortcut&&u.jsx(zd,{children:q.shortcut})]})]},q.key))})]}),!t&&u.jsxs(u.Fragment,{children:[P&&u.jsx(qo,{tone:P,className:H("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(ds,{onOpenChange:o,children:[u.jsx(fs,{asChild:!0,children:u.jsx(Jd,{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(Gc,{})})}),u.jsx(ai,{side:"right",align:"start",className:"w-44",children:U.map(q=>u.jsxs(_e.Fragment,{children:[q.separatorBefore&&u.jsx(sr,{}),u.jsxs(Bt,{onClick:q.run,className:H(q.danger&&"text-destructive focus:text-destructive"),children:[q.label,q.shortcut&&u.jsx(Pd,{children:q.shortcut})]})]},q.key))})]})]}),u.jsx(It,{open:l,onOpenChange:c,children:u.jsx(St,{className:"sm:max-w-[425px]",onCloseAutoFocus:q=>{var y;q.preventDefault(),(y=r.current)==null||y.focus()},children:u.jsx(Mi,{mode:"update",shouldReset:!l,postSubmit:R,selectedName:e.name})})}),u.jsx(It,{open:f,onOpenChange:d,children:u.jsx(St,{className:"sm:max-w-[425px]",onCloseAutoFocus:q=>{var y;q.preventDefault(),(y=r.current)==null||y.focus()},children:u.jsx(Mi,{mode:"delete",shouldReset:!f,postSubmit:L,selectedName:e.name})})})]})}const mi=_e.memo(Wx);async function qx(e,t){const n=JSON.stringify({name:e,props:t,children:[]},null,2);await navigator.clipboard.writeText(n)}const Zr=b.forwardRef(({className:e,children:t,...n},r)=>u.jsxs($c,{ref:r,className:H("relative overflow-hidden",e),...n,children:[u.jsx(Cm,{className:"h-full w-full rounded-[inherit]",children:t}),u.jsx(Hd,{}),u.jsx(Nm,{})]}));Zr.displayName=$c.displayName;const Hd=b.forwardRef(({className:e,orientation:t="vertical",...n},r)=>u.jsx(Fc,{ref:r,orientation:t,className:H("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(Em,{className:"bg-border relative flex-1 rounded-full"})}));Hd.displayName=Fc.displayName;function Xa({className:e,...t}){return u.jsx(Im,{"data-slot":"switch",className:H("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(Tm,{"data-slot":"switch-thumb",className:H("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 Gx=ni("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"}}),$i=b.forwardRef(({className:e,variant:t,...n},r)=>u.jsx("div",{ref:r,role:"alert",className:H(Gx({variant:t}),e),...n}));$i.displayName="Alert";const Kx=b.forwardRef(({className:e,...t},n)=>u.jsx("h5",{ref:n,className:H("mb-1 font-medium leading-none tracking-tight",e),...t}));Kx.displayName="AlertTitle";const Fi=b.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:H("text-sm [&_p]:leading-relaxed",e),...t}));Fi.displayName="AlertDescription";const Li=b.memo(({keyName:e,value:t,depth:n=0,isLast:r=!1})=>{const[i,s]=b.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:H("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(ti,{className:"h-3 w-3"}):u.jsx(ri,{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,p)=>u.jsx(Li,{keyName:String(p),value:d,depth:n+1,isLast:p===t.length-1},p)):Object.entries(t).map(([d,p],h,g)=>u.jsx(Li,{keyName:d,value:p,depth:n+1,isLast:h===g.length-1},d)),u.jsx("div",{className:"ml-4",children:u.jsxs("span",{className:"text-muted-foreground",children:[o?"]":"}",!r&&","]})})]})]})});Li.displayName="JsonNode";const Zi=b.memo(({schema:e,loading:t=!1,error:n,className:r})=>t?u.jsxs("div",{className:H("space-y-4",r),children:[u.jsx(Dr,{className:"h-8 w-64"}),u.jsx(Dr,{className:"h-4 w-full"}),u.jsx(Dr,{className:"h-64 w-full"})]}):n?u.jsx($i,{variant:"destructive",className:r,children:u.jsx(Fi,{children:n})}):e?u.jsx(Zr,{className:H("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(Li,{value:e})})}):u.jsx($i,{className:r,children:u.jsx(Fi,{children:"No schema available"})}));Zi.displayName="SchemaViewer";function Yx({plugins:e,initialFocusedPlugin:t}){var m,I;const n=Dt(E=>E.togglePlugin),r=Dt(E=>E.isPluginSelected),i=Dt(E=>E.selectedPlugins),s=Dt(E=>E.isApplyingPlugins),[a,o]=b.useState(null),[l,c]=b.useState(null),[f,d]=b.useState("properties");b.useEffect(()=>{if(t){const E=e.find(w=>w.name===t);if(E){o(E);return}}e.length>0&&!a&&o(e[0])},[t,e]);const p=b.useMemo(()=>{const E={current:[],downstream:[],upstream:[]};return e.forEach(w=>{E[w.location]&&E[w.location].push(w)}),E},[e]),h=async(E,w)=>{a&&(await qx(a.name,E.props),c(w),setTimeout(()=>c(null),2e3))},g=E=>{switch(E){case"current":return"Current Directory";case"downstream":return"Project";case"upstream":return"Parent Directories";default:return E}},v=E=>{switch(E){case"current":return u.jsx(Xm,{className:"size-3"});case"downstream":return u.jsx(Ym,{className:"size-3"});case"upstream":return u.jsx(qc,{className:"size-3"});default:return null}},S=((m=a==null?void 0:a.schema)==null?void 0:m.properties)&&Object.keys(a.schema.properties).length>0,x=(I=a==null?void 0:a.schema)==null?void 0:I.jsonSchema,_=(a==null?void 0:a.examples)&&a.examples.length>0;return u.jsxs(u.Fragment,{children:[u.jsxs(Ht,{children:[u.jsxs(Wt,{className:"flex items-center gap-2",children:[u.jsx(Wm,{className:"size-5 text-warning"}),"Plugins",u.jsxs(Jt,{variant:"secondary",className:"font-normal",children:[i.size," active"]})]}),u.jsxs(hn,{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(Zr,{className:"h-full",children:u.jsx("div",{className:"p-2 space-y-3",children:Object.entries(p).map(([E,w])=>w.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:[v(E),g(E)]}),u.jsx("div",{className:"space-y-0.5",children:w.map(N=>{const O=r(N.name),K=(a==null?void 0:a.name)===N.name;return u.jsxs("button",{onClick:()=>o(N),className:H("w-full text-left px-2 py-1.5 rounded-md transition-colors cursor-pointer","flex items-center gap-2",K?"bg-accent text-accent-foreground":"hover:bg-accent/50 text-foreground"),children:[u.jsx("div",{className:H("size-1.5 rounded-full flex-none transition-colors",O?"bg-warning":"bg-muted-foreground/30")}),u.jsx("span",{className:"text-sm font-medium truncate flex-1",children:N.name})]},N.name)})})]},E))})})}),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(Jt,{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(Xa,{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:[v(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:[S&&u.jsx("button",{onClick:()=>d("properties"),className:H("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(Oo,{className:"size-3.5"}),"Properties"]})}),x&&u.jsx("button",{onClick:()=>d("schema"),className:H("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(qm,{className:"size-3.5"}),"Schema"]})}),_&&u.jsx("button",{onClick:()=>d("examples"),className:H("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(Gm,{className:"size-3.5"}),"Examples",u.jsx(Jt,{variant:"secondary",className:"text-[10px] px-1.5 py-0 h-4",children:a.examples.length})]})})]}),u.jsx(Zr,{className:"flex-1",children:u.jsxs("div",{className:"p-5",children:[f==="properties"&&S&&u.jsx("div",{className:"space-y-1",children:Object.entries(a.schema.properties).map(([E,w])=>u.jsx(Xx,{name:E,prop:w},E))}),f==="schema"&&x&&u.jsx(Zi,{schema:a.schema.jsonSchema,loading:!1,className:"h-[420px]"}),f==="examples"&&_&&a.examples.map((E,w)=>u.jsxs("div",{className:H(w>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:[E.title&&u.jsx("span",{className:"font-medium text-sm truncate",children:E.title}),!E.title&&u.jsxs("span",{className:"text-sm text-muted-foreground",children:["Example ",w+1]})]}),u.jsx(Ee,{size:"sm",variant:"ghost",className:"h-7 px-2 text-xs flex-none",onClick:()=>h(E,w),children:l===w?u.jsxs(u.Fragment,{children:[u.jsx(Km,{className:"size-3 mr-1 text-success"}),"Copied"]}):u.jsxs(u.Fragment,{children:[u.jsx(os,{className:"size-3 mr-1"}),"Copy"]})})]}),E.description&&u.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:E.description}),u.jsx("pre",{className:"p-3 bg-muted rounded-md overflow-x-auto text-xs font-mono leading-relaxed",children:JSON.stringify(E.props,null,2)})]},w)),!S&&!x&&!_&&u.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[u.jsx(Oo,{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 Xx({name:e,prop:t}){var a;const[n,r]=b.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:H("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(ti,{className:"size-3 text-muted-foreground flex-none"}):u.jsx(ri,{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(Jt,{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 Qx=zm,ey=Am,ty=Pm,ny={current:"Current directory",downstream:"Project"};function Os({id:e,label:t,count:n,open:r,onToggle:i,children:s}){return u.jsxs(Qx,{open:r,children:[u.jsxs(ey,{onClick:()=>i(e),className:H("flex h-7 w-full 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:[u.jsx(ri,{className:H("size-3 shrink-0 transition-transform duration-150 ease-out",r&&"rotate-90")}),u.jsx("span",{className:"text-[11px] font-medium tracking-[0.08em] uppercase",children:t}),u.jsx("span",{className:"ml-auto text-[11px] font-normal tabular-nums text-sidebar-foreground/65",children:n})]}),u.jsx(ty,{children:u.jsx("div",{className:"border-sidebar-border/70 mt-0.5 ml-[13px] border-l pl-1",children:s})})]})}function Ko({location:e}){return u.jsx("div",{className:"px-2 pt-2 pb-0.5 text-[10px] tracking-[0.08em] text-sidebar-foreground/65 uppercase",children:ny[e]??e})}function Yo({name:e,subtitle:t,added:n,query:r,onSelect:i}){return u.jsxs("button",{type:"button",onClick:i,title:t?`${e} — ${t}`:e,"aria-label":n?`Open ${e}`:`Add ${e} to workspace`,className:H("group/row flex h-7 w-full cursor-pointer items-center gap-2 rounded-sm px-2","text-[13px] transition-colors","hover:bg-sidebar-accent/60 hover:text-sidebar-foreground","focus-visible:ring-sidebar-ring focus-visible:ring-1 focus-visible:outline-none","text-sidebar-foreground/70"),children:[u.jsx("span",{className:"truncate",children:u.jsx(Ka,{text:e,query:r})}),n?u.jsx("span",{className:"ml-auto shrink-0 text-[10px] tracking-[0.06em] text-sidebar-foreground/65 uppercase",children:"Open"}):u.jsx(Xt,{"aria-hidden":!0,className:"ml-auto 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 ry({documents:e,themes:t,plugins:n,openNames:r,query:i,expandedGroups:s,onToggleGroup:a,onQuickAdd:o,onShowPluginDetails:l,isPluginSelected:c,onTogglePlugin:f,isApplyingPlugins:d,selectedPluginCount:p}){const h=x=>i?!0:s.has(x),g=b.useMemo(()=>Xo(e),[e]),v=b.useMemo(()=>Xo(t),[t]);return e.length>0||t.length>0||n.length>0?u.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.length>0&&u.jsx(Os,{id:"library-documents",label:"Project documents",count:e.length,open:h("library-documents"),onToggle:a,children:g.map(([x,_])=>u.jsxs(_e.Fragment,{children:[g.length>1&&u.jsx(Ko,{location:x}),_.map(m=>u.jsx(Yo,{name:m.name,subtitle:m.title,added:r.has(m.name),query:i,onSelect:()=>o(m.name,!1)},m.path||m.name))]},x))}),t.length>0&&u.jsx(Os,{id:"library-themes",label:"Project themes",count:t.length,open:h("library-themes"),onToggle:a,children:v.map(([x,_])=>u.jsxs(_e.Fragment,{children:[v.length>1&&u.jsx(Ko,{location:x}),_.map(m=>u.jsx(Yo,{name:m.name,subtitle:m.description,added:r.has(m.name),query:i,onSelect:()=>o(m.name,!0)},m.path||m.name))]},x))}),n.length>0&&u.jsx(Os,{id:"library-plugins",label:"Plugins",count:`${p}/${n.length}`,open:h("library-plugins"),onToggle:a,children:n.map(x=>{const _=c(x.name),m=`plugin-switch-${x.filePath||x.name}`;return u.jsxs("div",{title:x.description?`${x.name} — ${x.description}`:x.name,className:H("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:m,className:H("flex h-7 min-w-0 flex-1 cursor-pointer items-center text-[13px]",_?"text-sidebar-foreground":"text-sidebar-foreground/70"),children:u.jsx("span",{className:"truncate",children:u.jsx(Ka,{text:x.name,query:i})})}),u.jsx(Ft,{"aria-label":`Details for ${x.name}`,onClick:I=>{I.stopPropagation(),l(x.name)},className:"opacity-0 group-hover/row:opacity-100 focus-visible:opacity-100",children:u.jsx(Kc,{})}),u.jsx(Xa,{id:m,checked:_,onCheckedChange:()=>f(x),disabled:d,className:"shrink-0","aria-label":`Toggle ${x.name} plugin`})]},x.filePath||x.name)})})]}):null}function Xo(e){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))}function Wd({children:e,className:t}){return u.jsx("kbd",{"data-slot":"kbd",className:H("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 iy({children:e,className:t}){return u.jsx("span",{className:H("inline-flex items-center gap-0.5",t),children:e})}const gi=typeof navigator<"u"&&/Mac|iPod|iPhone|iPad/.test(navigator.platform);function Br({shortcut:e,className:t}){const r=e.split("+").map(i=>i.trim().toLowerCase()).map(i=>{switch(i){case"mod":return gi?"⌘":"Ctrl";case"shift":return gi?"⇧":"Shift";case"alt":return gi?"⌥":"Alt";case"ctrl":return gi?"⌃":"Ctrl";case"enter":return"↵";default:return i.toUpperCase()}});return u.jsx(iy,{className:t,children:r.map((i,s)=>u.jsx(Wd,{children:i},s))})}function sy({className:e}={}){const{theme:t,setTheme:n}=Uc(),r=t==="system"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":t,i=b.useCallback(()=>{n(r==="dark"?"light":"dark")},[r,n]);return u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsxs(Ee,{variant:"ghost",size:"icon",onClick:i,className:e,children:[u.jsx(Qm,{className:"hidden dark:block"}),u.jsx(eg,{className:"block dark:hidden"}),u.jsx("span",{className:"sr-only",children:"Toggle theme"})]})}),u.jsx(Ke,{children:u.jsx("p",{children:"Toggle theme"})})]})}function ay({discoveryData:e,onToggleSidebar:t,isCollapsed:n=!1,isAnimating:r=!1}){const{documents:i,documentTypes:s,createDocument:a,openDocument:o}=Oe(rd(Z=>({documents:Z.documents,documentTypes:Z.documentTypes,createDocument:Z.createDocument,openDocument:Z.openDocument}))),l=ca(Z=>Z.updateTheme),c=ca(Z=>Z.removeTheme),f=b.useContext(nd),[d,p]=b.useState(!1),[h,g]=b.useState(!1),[v,S]=b.useState(!1),[x,_]=b.useState(null),m=Dt(Z=>Z.togglePlugin),I=Dt(Z=>Z.isPluginSelected),E=Dt(Z=>Z.selectedPlugins),w=Dt(Z=>Z.isApplyingPlugins),[N,O]=b.useState(!1),[K,C]=b.useState(new Set(["library-documents"])),[T,A]=b.useState(""),F=b.useRef(null),{toast:R}=fr(),L=i.filter(Z=>s[Z.name]!=="application/json+theme"),P=i.filter(Z=>s[Z.name]==="application/json+theme"),V=b.useCallback(()=>{p(!1)},[]),U=b.useCallback(()=>{g(!1)},[]),se=b.useRef(new Map);b.useEffect(()=>{const Z=se.current,ke=new Map;P.forEach(me=>{ke.set(me.name,me.text),Z.get(me.name)!==me.text&&l(me.name,me.text)}),Z.forEach((me,De)=>{ke.has(De)||c(De)}),se.current=ke},[P,l,c]);const k=b.useRef(!1);b.useEffect(()=>{if(k.current||!f)return;k.current=!0;const Z=new Set(P.map(me=>me.name));Object.keys(f.getState().customThemes).forEach(me=>{Z.has(me)||c(me)})},[P,c,f]);const le=b.useCallback(Z=>{C(ke=>{const me=new Set(ke);return me.has(Z)?me.delete(Z):me.add(Z),me})},[]),{resolvedTheme:q}=Uc(),y=q==="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",W=b.useCallback(async(Z,ke)=>{if(i.some(me=>me.name===Z)){o(Z);return}try{const me=await fetch(`/api/discovery/${ke?"themes":"documents"}/${encodeURIComponent(Z)}/content`);if(!me.ok)throw new Error(me.statusText);const De=await me.text(),j=JSON.parse(De);a(Z,JSON.stringify(j,null,2)),o(Z),R({title:`Added ${ke?"theme":"document"}: ${Z}`})}catch{R({title:"Failed to load",description:`Could not load ${Z}`,variant:"destructive"})}},[i,a,o,R]);b.useEffect(()=>{if(n)return;const Z=ke=>{var j,z,M,re,ee;if(ke.key!=="/"||ke.metaKey||ke.ctrlKey||ke.altKey)return;const me=ke.target,De=(j=me==null?void 0:me.tagName)==null?void 0:j.toLowerCase();De==="input"||De==="textarea"||De==="select"||me!=null&&me.isContentEditable||(z=me==null?void 0:me.closest)!=null&&z.call(me,".monaco-editor")||(M=F.current)!=null&&M.closest('[aria-hidden="true"], [inert]')||(ke.preventDefault(),(re=F.current)==null||re.focus(),(ee=F.current)==null||ee.select())};return window.addEventListener("keydown",Z),()=>window.removeEventListener("keydown",Z)},[n]);const B=T.trim(),ie=b.useMemo(()=>new Set(i.map(Z=>Z.name)),[i]),te=b.useMemo(()=>L.filter(Z=>sn(Z.name,B)),[L,B]),X=b.useMemo(()=>P.filter(Z=>sn(Z.name,B)),[P,B]),fe=b.useMemo(()=>((e==null?void 0:e.documents)??[]).filter(Z=>sn(Z.name,B)||sn(Z.title??"",B)),[e,B]),be=b.useMemo(()=>((e==null?void 0:e.themes)??[]).filter(Z=>sn(Z.name,B)||sn(Z.description??"",B)),[e,B]),ne=b.useMemo(()=>((e==null?void 0:e.plugins)??[]).filter(Z=>sn(Z.name,B)||sn(Z.description??"",B)),[e,B]),de=B.length>0&&te.length===0&&X.length===0&&fe.length===0&&be.length===0&&ne.length===0,ue=H("transition-opacity duration-150 ease-out",r?"opacity-0":"opacity-100");return u.jsxs(u.Fragment,{children:[u.jsxs(Zd,{collapsible:"none",style:{"--sidebar-width":n?"3rem":"16rem"},children:[n?u.jsxs(u.Fragment,{children:[u.jsx(ga,{className:H("gap-0 p-1.5",ue),children:u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsx(Ft,{className:"mx-auto size-7","aria-label":"Expand sidebar","aria-expanded":!1,onClick:t,children:u.jsx(Yc,{})})}),u.jsxs(Ke,{side:"right",className:"flex items-center gap-2",children:[u.jsx("span",{children:"Expand sidebar"}),u.jsx(Br,{shortcut:"mod+b"})]})]})}),u.jsxs(xa,{className:H("gap-2 px-1 py-1",ue),children:[u.jsxs(Cr,{className:"items-center gap-0.5",children:[L.map(Z=>u.jsx(mi,{document:Z,compact:!0},Z.name)),u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsx(Ft,{className:"size-7","aria-label":"New document",onClick:()=>p(!0),children:u.jsx(Xt,{})})}),u.jsx(Ke,{side:"right",children:"New document"})]})]}),u.jsx("div",{className:"bg-sidebar-border/70 mx-auto h-px w-6"}),u.jsxs(Cr,{className:"items-center gap-0.5",children:[P.map(Z=>u.jsx(mi,{document:Z,compact:!0},Z.name)),u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsx(Ft,{className:"size-7","aria-label":"New theme",onClick:()=>g(!0),children:u.jsx(Xt,{})})}),u.jsx(Ke,{side:"right",children:"New theme"})]})]})]})]}):u.jsxs(u.Fragment,{children:[u.jsxs(ga,{className:H("gap-0 p-2",ue),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:y,alt:"Wiseair",className:"h-[18px] w-auto max-w-[110px] shrink-0"})}),u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsx(Ft,{"aria-label":"Collapse sidebar","aria-expanded":!0,onClick:t,children:u.jsx(tg,{})})}),u.jsxs(Ke,{side:"right",className:"flex items-center gap-2",children:[u.jsx("span",{children:"Collapse sidebar"}),u.jsx(Br,{shortcut:"mod+b"})]})]})]}),u.jsxs("div",{className:"relative mt-2",children:[u.jsx(ng,{"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:F,type:"text",value:T,spellCheck:!1,autoComplete:"off",placeholder:"Filter files…","aria-label":"Filter documents, themes and plugins",onChange:Z=>A(Z.target.value),onKeyDown:Z=>{Z.key==="Escape"&&(Z.preventDefault(),A(""),Z.currentTarget.blur())},className:H("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")}),B?u.jsx(Ft,{"aria-label":"Clear filter",onClick:()=>{var Z;A(""),(Z=F.current)==null||Z.focus()},className:"absolute top-1/2 right-1 -translate-y-1/2",children:u.jsx(fn,{})}):u.jsx(Wd,{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(xa,{className:H("gap-0 px-2 pb-2",ue),children:de?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 “",B,"”"]}),u.jsx("button",{type:"button",onClick:()=>{var Z;A(""),(Z=F.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:[(te.length>0||!B)&&u.jsxs("section",{children:[u.jsx(Wo,{count:(B?te.length:L.length)||void 0,actions:u.jsxs(u.Fragment,{children:[yt==="docx"&&u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsx(Ft,{"aria-label":"Compare documents",disabled:L.length<2,onClick:()=>O(!0),children:u.jsx(Hc,{})})}),u.jsx(Ke,{side:"bottom",children:L.length<2?"Compare needs two documents":"Compare documents (redline)"})]}),u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsx(Ft,{"aria-label":"New document",onClick:()=>p(!0),children:u.jsx(Xt,{})})}),u.jsx(Ke,{side:"bottom",children:"New document"})]})]}),children:"Documents"}),u.jsx(Cr,{className:"gap-0.5",children:te.length>0?te.map(Z=>u.jsx(mi,{document:Z,query:B},Z.name)):u.jsx(Go,{icon:Xt,label:"New document",onClick:()=>p(!0)})})]}),(X.length>0||!B)&&u.jsxs("section",{className:"mt-3",children:[u.jsx(Wo,{count:(B?X.length:P.length)||void 0,actions:u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsx(Ft,{"aria-label":"New theme",onClick:()=>g(!0),children:u.jsx(Xt,{})})}),u.jsx(Ke,{side:"bottom",children:"New theme"})]}),children:"Themes"}),u.jsx(Cr,{className:"gap-0.5",children:X.length>0?X.map(Z=>u.jsx(mi,{document:Z,query:B},Z.name)):u.jsx(Go,{icon:Xt,label:"New theme",onClick:()=>g(!0)})})]}),(fe.length>0||be.length>0||ne.length>0)&&u.jsx("div",{className:"border-sidebar-border/70 mt-3 border-t pt-2",children:u.jsx(ry,{documents:fe,themes:be,plugins:ne,openNames:ie,query:B,expandedGroups:K,onToggleGroup:le,onQuickAdd:W,onShowPluginDetails:Z=>{_(Z),S(!0)},isPluginSelected:I,onTogglePlugin:m,isApplyingPlugins:w,selectedPluginCount:E.size})})]})})]}),u.jsx(Bd,{className:H("border-sidebar-border/70 gap-0 border-t p-1.5",ue),children:u.jsx("div",{className:H("flex items-center",n?"justify-center":"justify-start"),children:u.jsx(sy,{className:"size-7 rounded-sm text-sidebar-foreground/70 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground [&_svg]:size-3.5"})})})]}),u.jsx(It,{open:d,onOpenChange:p,children:u.jsx(St,{className:"sm:max-w-[525px]",children:u.jsx(Mi,{mode:"create",shouldReset:!d,postSubmit:V,discoveredDocuments:(e==null?void 0:e.documents)||[]})})}),u.jsx(It,{open:h,onOpenChange:g,children:u.jsx(St,{className:"sm:max-w-[525px]",children:u.jsx(Mi,{mode:"create",shouldReset:!h,postSubmit:U,discoveredThemes:(e==null?void 0:e.themes)||[],isTheme:!0})})}),u.jsx(It,{open:v,onOpenChange:Z=>{S(Z),Z||_(null)},children:u.jsx(St,{className:"max-h-[85vh] overflow-hidden sm:max-w-5xl",children:u.jsx(Yx,{plugins:(e==null?void 0:e.plugins)||[],initialFocusedPlugin:x})})}),u.jsx(Ag,{open:N,onOpenChange:O})]})}const Qo=b.memo(ay),oy=b.lazy(()=>Jc(()=>import("./editor-DjQ1HvFx.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11])).then(e=>({default:e.Editor})));function el(){return u.jsx(b.Suspense,{fallback:u.jsx("div",{className:"flex items-center justify-center h-full",children:u.jsxs("div",{className:"text-center",children:[u.jsx(en,{className:"w-8 h-8 mx-auto mb-2"}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading editor..."})]})}),children:u.jsx(oy,{})})}const ly=b.lazy(()=>Jc(()=>import("./preview-B9UKky-W.js"),__vite__mapDeps([12,1,3,4,5,6,7,8,9,10,11])).then(e=>({default:e.Preview})));function tl(){return u.jsx(b.Suspense,{fallback:u.jsx("div",{className:"flex items-center justify-center h-full",children:u.jsxs("div",{className:"text-center",children:[u.jsx(en,{className:"w-8 h-8 mx-auto mb-2"}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading preview..."})]})}),children:u.jsx(ly,{})})}const{createElement:ar,createContext:uy,forwardRef:qd,useCallback:pt,useContext:Gd,useEffect:Nn,useImperativeHandle:Kd,useLayoutEffect:cy,useMemo:dy,useRef:xt,useState:Qn}=lc,nl=lc[`useId${Math.random()}`.slice(0,5)],fy=cy,hs=uy(null);hs.displayName="PanelGroupContext";const En=fy,py=typeof nl=="function"?nl:()=>null;let hy=0;function Qa(e=null){const t=py(),n=xt(e||t||null);return n.current===null&&(n.current=""+hy++),e??n.current}function Yd({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:p,style:h,tagName:g="div",...v}){const S=Gd(hs);if(S===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:x,expandPanel:_,getPanelSize:m,getPanelStyle:I,groupId:E,isPanelCollapsed:w,reevaluatePanelConstraints:N,registerPanel:O,resizePanel:K,unregisterPanel:C}=S,T=Qa(a),A=xt({callbacks:{onCollapse:c,onExpand:f,onResize:d},constraints:{collapsedSize:n,collapsible:r,defaultSize:i,maxSize:o,minSize:l},id:T,idIsFromProps:a!==void 0,order:p});xt({didLogMissingDefaultSizeWarning:!1}),En(()=>{const{callbacks:R,constraints:L}=A.current,P={...L};A.current.id=T,A.current.idIsFromProps=a!==void 0,A.current.order=p,R.onCollapse=c,R.onExpand=f,R.onResize=d,L.collapsedSize=n,L.collapsible=r,L.defaultSize=i,L.maxSize=o,L.minSize=l,(P.collapsedSize!==L.collapsedSize||P.collapsible!==L.collapsible||P.maxSize!==L.maxSize||P.minSize!==L.minSize)&&N(A.current,P)}),En(()=>{const R=A.current;return O(R),()=>{C(R)}},[p,T,O,C]),Kd(s,()=>({collapse:()=>{x(A.current)},expand:R=>{_(A.current,R)},getId(){return T},getSize(){return m(A.current)},isCollapsed(){return w(A.current)},isExpanded(){return!w(A.current)},resize:R=>{K(A.current,R)}}),[x,_,m,w,T,K]);const F=I(A.current,i);return ar(g,{...v,children:e,className:t,id:a,style:{...F,...h},"data-panel":"","data-panel-collapsible":r||void 0,"data-panel-group-id":E,"data-panel-id":T,"data-panel-size":parseFloat(""+F.flexGrow).toFixed(1)})}const Xd=qd((e,t)=>ar(Yd,{...e,forwardedRef:t}));Yd.displayName="Panel";Xd.displayName="forwardRef(Panel)";let ya=null,Cn=null;function my(e,t){if(t){const n=(t&rf)!==0,r=(t&sf)!==0,i=(t&af)!==0,s=(t&of)!==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 gy(){Cn!==null&&(document.head.removeChild(Cn),ya=null,Cn=null)}function Ds(e,t){const n=my(e,t);ya!==n&&(ya=n,Cn===null&&(Cn=document.createElement("style"),document.head.appendChild(Cn)),Cn.innerHTML=`*{cursor: ${n}!important;}`)}function Qd(e){return e.type==="keydown"}function ef(e){return e.type.startsWith("pointer")}function tf(e){return e.type.startsWith("mouse")}function ms(e){if(ef(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(tf(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function xy(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function yy(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 by(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:sl(e),b:sl(t)};let r;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),r=e;Ce(r,"Stacking order can only be calculated for elements with a common ancestor");const i={a:il(rl(n.a)),b:il(rl(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 vy=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function wy(e){var t;const n=getComputedStyle((t=nf(e))!==null&&t!==void 0?t:e).display;return n==="flex"||n==="inline-flex"}function ky(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||wy(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"||vy.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function rl(e){let t=e.length;for(;t--;){const n=e[t];if(Ce(n,"Missing node"),ky(n))return n}return null}function il(e){return e&&Number(getComputedStyle(e).zIndex)||0}function sl(e){const t=[];for(;e;)t.push(e),e=nf(e);return t}function nf(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}const rf=1,sf=2,af=4,of=8,Sy=xy()==="coarse";let Rt=[],er=!1,cn=new Map,gs=new Map;const Vr=new Set;function _y(e,t,n,r,i){var s;const{ownerDocument:a}=t,o={direction:n,element:t,hitAreaMargins:r,setResizeHandlerState:i},l=(s=cn.get(a))!==null&&s!==void 0?s:0;return cn.set(a,l+1),Vr.add(o),Bi(),function(){var f;gs.delete(e),Vr.delete(o);const d=(f=cn.get(a))!==null&&f!==void 0?f:1;if(cn.set(a,d-1),Bi(),d===1&&cn.delete(a),Rt.includes(o)){const p=Rt.indexOf(o);p>=0&&Rt.splice(p,1),to(),i("up",!0,null)}}}function al(e){const{target:t}=e,{x:n,y:r}=ms(e);er=!0,eo({target:t,x:n,y:r}),Bi(),Rt.length>0&&(Vi("down",e),e.preventDefault(),e.stopPropagation())}function vr(e){const{x:t,y:n}=ms(e);if(er&&e.buttons===0&&(er=!1,Vi("up",e)),!er){const{target:r}=e;eo({target:r,x:t,y:n})}Vi("move",e),to(),Rt.length>0&&e.preventDefault()}function $n(e){const{target:t}=e,{x:n,y:r}=ms(e);gs.clear(),er=!1,Rt.length>0&&e.preventDefault(),Vi("up",e),eo({target:t,x:n,y:r}),to(),Bi()}function eo({target:e,x:t,y:n}){Rt.splice(0);let r=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(r=e),Vr.forEach(i=>{const{element:s,hitAreaMargins:a}=i,o=s.getBoundingClientRect(),{bottom:l,left:c,right:f,top:d}=o,p=Sy?a.coarse:a.fine;if(t>=c-p&&t<=f+p&&n>=d-p&&n<=l+p){if(r!==null&&document.contains(r)&&s!==r&&!s.contains(r)&&!r.contains(s)&&by(r,s)>0){let g=r,v=!1;for(;g&&!g.contains(s);){if(yy(g.getBoundingClientRect(),o)){v=!0;break}g=g.parentElement}if(v)return}Rt.push(i)}})}function Rs(e,t){gs.set(e,t)}function to(){let e=!1,t=!1;Rt.forEach(r=>{const{direction:i}=r;i==="horizontal"?e=!0:t=!0});let n=0;gs.forEach(r=>{n|=r}),e&&t?Ds("intersection",n):e?Ds("horizontal",n):t?Ds("vertical",n):gy()}function Bi(){cn.forEach((e,t)=>{const{body:n}=t;n.removeEventListener("contextmenu",$n),n.removeEventListener("pointerdown",al),n.removeEventListener("pointerleave",vr),n.removeEventListener("pointermove",vr)}),window.removeEventListener("pointerup",$n),window.removeEventListener("pointercancel",$n),Vr.size>0&&(er?(Rt.length>0&&cn.forEach((e,t)=>{const{body:n}=t;e>0&&(n.addEventListener("contextmenu",$n),n.addEventListener("pointerleave",vr),n.addEventListener("pointermove",vr))}),window.addEventListener("pointerup",$n),window.addEventListener("pointercancel",$n)):cn.forEach((e,t)=>{const{body:n}=t;e>0&&(n.addEventListener("pointerdown",al,{capture:!0}),n.addEventListener("pointermove",vr))}))}function Vi(e,t){Vr.forEach(n=>{const{setResizeHandlerState:r}=n,i=Rt.includes(n);r(e,i,t)})}function jy(){const[e,t]=Qn(0);return pt(()=>t(n=>n+1),[])}function Ce(e,t){if(!e)throw console.error(t),Error(t)}const no=10;function zn(e,t,n=no){return e.toFixed(n)===t.toFixed(n)?0:e>t?1:-1}function tn(e,t,n=no){return zn(e,t,n)===0}function kt(e,t,n){return zn(e,t,n)===0}function Cy(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(!kt(i,s,n))return!1}return!0}function Gn({panelConstraints:e,panelIndex:t,size:n}){const r=e[t];Ce(r!=null,`Panel constraints not found for index ${t}`);let{collapsedSize:i=0,collapsible:s,maxSize:a=100,minSize:o=0}=r;if(zn(n,o)<0)if(s){const l=(i+o)/2;zn(n,l)<0?n=i:n=o}else n=o;return n=Math.min(a,n),n=parseFloat(n.toFixed(no)),n}function Nr({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:s}){if(kt(e,0))return t;const a=[...t],[o,l]=r;Ce(o!=null,"Invalid first pivot index"),Ce(l!=null,"Invalid second pivot index");let c=0;if(s==="keyboard"){{const d=e<0?l:o,p=n[d];Ce(p,`Panel constraints not found for index ${d}`);const{collapsedSize:h=0,collapsible:g,minSize:v=0}=p;if(g){const S=t[d];if(Ce(S!=null,`Previous layout not found for panel index ${d}`),kt(S,h)){const x=v-S;zn(x,Math.abs(e))>0&&(e=e<0?0-x:x)}}}{const d=e<0?o:l,p=n[d];Ce(p,`No panel constraints found for index ${d}`);const{collapsedSize:h=0,collapsible:g,minSize:v=0}=p;if(g){const S=t[d];if(Ce(S!=null,`Previous layout not found for panel index ${d}`),kt(S,v)){const x=S-h;zn(x,Math.abs(e))>0&&(e=e<0?0-x:x)}}}}{const d=e<0?1:-1;let p=e<0?l:o,h=0;for(;;){const v=t[p];Ce(v!=null,`Previous layout not found for panel index ${p}`);const x=Gn({panelConstraints:n,panelIndex:p,size:100})-v;if(h+=x,p+=d,p<0||p>=n.length)break}const g=Math.min(Math.abs(e),Math.abs(h));e=e<0?0-g:g}{let p=e<0?o:l;for(;p>=0&&p<n.length;){const h=Math.abs(e)-Math.abs(c),g=t[p];Ce(g!=null,`Previous layout not found for panel index ${p}`);const v=g-h,S=Gn({panelConstraints:n,panelIndex:p,size:v});if(!kt(g,S)&&(c+=g-S,a[p]=S,c.toPrecision(3).localeCompare(Math.abs(e).toPrecision(3),void 0,{numeric:!0})>=0))break;e<0?p--:p++}}if(Cy(i,a))return i;{const d=e<0?l:o,p=t[d];Ce(p!=null,`Previous layout not found for panel index ${d}`);const h=p+c,g=Gn({panelConstraints:n,panelIndex:d,size:h});if(a[d]=g,!kt(g,h)){let v=h-g,x=e<0?l:o;for(;x>=0&&x<n.length;){const _=a[x];Ce(_!=null,`Previous layout not found for panel index ${x}`);const m=_+v,I=Gn({panelConstraints:n,panelIndex:x,size:m});if(kt(_,I)||(v-=I-_,a[x]=I),kt(v,0))break;e>0?x--:x++}}}const f=a.reduce((d,p)=>p+d,0);return kt(f,100)?a:i}function Ny({layout:e,panelsArray:t,pivotIndices:n}){let r=0,i=100,s=0,a=0;const o=n[0];Ce(o!=null,"No pivot index found"),t.forEach((d,p)=>{const{constraints:h}=d,{maxSize:g=100,minSize:v=0}=h;p===o?(r=v,i=g):(s+=v,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 Ur(e,t=document){return Array.from(t.querySelectorAll(`[data-panel-resize-handle-id][data-panel-group-id="${e}"]`))}function lf(e,t,n=document){const i=Ur(e,n).findIndex(s=>s.getAttribute("data-panel-resize-handle-id")===t);return i??null}function uf(e,t,n){const r=lf(e,t,n);return r!=null?[r,r+1]:[-1,-1]}function cf(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 xs(e,t=document){const n=t.querySelector(`[data-panel-resize-handle-id="${e}"]`);return n||null}function Ey(e,t,n,r=document){var i,s,a,o;const l=xs(t,r),c=Ur(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,p=(a=(o=n[f+1])===null||o===void 0?void 0:o.id)!==null&&a!==void 0?a:null;return[d,p]}function Iy({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:r,panelDataArray:i,panelGroupElement:s,setLayout:a}){xt({didWarnAboutMissingResizeHandle:!1}),En(()=>{if(!s)return;const o=Ur(n,s);for(let l=0;l<i.length-1;l++){const{valueMax:c,valueMin:f,valueNow:d}=Ny({layout:r,panelsArray:i,pivotIndices:[l,l+1]}),p=o[l];if(p!=null){const h=i[l];Ce(h,`No panel data found for index "${l}"`),p.setAttribute("aria-controls",h.id),p.setAttribute("aria-valuemax",""+Math.round(c)),p.setAttribute("aria-valuemin",""+Math.round(f)),p.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]),Nn(()=>{if(!s)return;const o=t.current;Ce(o,"Eager values not found");const{panelDataArray:l}=o,c=cf(n,s);Ce(c!=null,`No group found for id "${n}"`);const f=Ur(n,s);Ce(f,`No resize handles found for group id "${n}"`);const d=f.map(p=>{const h=p.getAttribute("data-panel-resize-handle-id");Ce(h,"Resize handle element has no handle id attribute");const[g,v]=Ey(n,h,l,s);if(g==null||v==null)return()=>{};const S=x=>{if(!x.defaultPrevented)switch(x.key){case"Enter":{x.preventDefault();const _=l.findIndex(m=>m.id===g);if(_>=0){const m=l[_];Ce(m,`No panel data found for index ${_}`);const I=r[_],{collapsedSize:E=0,collapsible:w,minSize:N=0}=m.constraints;if(I!=null&&w){const O=Nr({delta:kt(I,E)?N-E:E-I,initialLayout:r,panelConstraints:l.map(K=>K.constraints),pivotIndices:uf(n,h,s),prevLayout:r,trigger:"keyboard"});r!==O&&a(O)}}break}}};return p.addEventListener("keydown",S),()=>{p.removeEventListener("keydown",S)}});return()=>{d.forEach(p=>p())}},[s,e,t,n,r,i,a])}function ol(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 df(e,t){const n=e==="horizontal",{x:r,y:i}=ms(t);return n?r:i}function Ty(e,t,n,r,i){const s=n==="horizontal",a=xs(t,i);Ce(a,`No resize handle element found for id "${t}"`);const o=a.getAttribute("data-panel-group-id");Ce(o,"Resize handle element has no group id attribute");let{initialCursorPosition:l}=r;const c=df(n,e),f=cf(o,i);Ce(f,`No group element found for id "${o}"`);const d=f.getBoundingClientRect(),p=s?d.width:d.height;return(c-l)/p*100}function zy(e,t,n,r,i,s){if(Qd(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:Ty(e,t,n,r,s)}function Ay({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];Ce(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];Ce(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 Fn(e,t,n){t.forEach((r,i)=>{const s=e[i];Ce(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:p,onExpand:h,onResize:g}=a;g&&g(r,d),f&&(p||h)&&(h&&(d==null||tn(d,c))&&!tn(r,c)&&h(),p&&(d==null||!tn(d,c))&&tn(r,c)&&p())}})}function xi(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 Py({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 Oy(e,t=10){let n=null;return(...i)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...i)},t)}}function ll(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 ff(e){return`react-resizable-panels:${e}`}function pf(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 hf(e,t){try{const n=ff(e),r=t.getItem(n);if(r){const i=JSON.parse(r);if(typeof i=="object"&&i!=null)return i}}catch{}return null}function Dy(e,t,n){var r,i;const s=(r=hf(e,n))!==null&&r!==void 0?r:{},a=pf(t);return(i=s[a])!==null&&i!==void 0?i:null}function Ry(e,t,n,r,i){var s;const a=ff(e),o=pf(t),l=(s=hf(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 ul({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(!kt(r,100)&&n.length>0)for(let s=0;s<t.length;s++){const a=n[s];Ce(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];Ce(a!=null,`No layout data found for index ${s}`);const o=Gn({panelConstraints:t,panelIndex:s,size:a});a!=o&&(i+=a-o,n[s]=o)}if(!kt(i,0))for(let s=0;s<t.length;s++){const a=n[s];Ce(a!=null,`No layout data found for index ${s}`);const o=a+i,l=Gn({panelConstraints:t,panelIndex:s,size:o});if(a!==l&&(i-=l-a,n[s]=l,kt(i,0)))break}return n}const My=100,Er={getItem:e=>(ll(Er),Er.getItem(e)),setItem:(e,t)=>{ll(Er),Er.setItem(e,t)}},cl={};function mf({autoSaveId:e=null,children:t,className:n="",direction:r,forwardedRef:i,id:s=null,onLayout:a=null,keyboardResizeBy:o=null,storage:l=Er,style:c,tagName:f="div",...d}){const p=Qa(s),h=xt(null),[g,v]=Qn(null),[S,x]=Qn([]),_=jy(),m=xt({}),I=xt(new Map),E=xt(0),w=xt({autoSaveId:e,direction:r,dragState:g,id:p,keyboardResizeBy:o,onLayout:a,storage:l}),N=xt({layout:S,panelDataArray:[],panelDataArrayChanged:!1});xt({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),Kd(i,()=>({getId:()=>w.current.id,getLayout:()=>{const{layout:y}=N.current;return y},setLayout:y=>{const{onLayout:W}=w.current,{layout:B,panelDataArray:ie}=N.current,te=ul({layout:y,panelConstraints:ie.map(X=>X.constraints)});ol(B,te)||(x(te),N.current.layout=te,W&&W(te),Fn(ie,te,m.current))}}),[]),En(()=>{w.current.autoSaveId=e,w.current.direction=r,w.current.dragState=g,w.current.id=p,w.current.onLayout=a,w.current.storage=l}),Iy({committedValuesRef:w,eagerValuesRef:N,groupId:p,layout:S,panelDataArray:N.current.panelDataArray,setLayout:x,panelGroupElement:h.current}),Nn(()=>{const{panelDataArray:y}=N.current;if(e){if(S.length===0||S.length!==y.length)return;let W=cl[e];W==null&&(W=Oy(Ry,My),cl[e]=W);const B=[...y],ie=new Map(I.current);W(e,B,ie,S,l)}},[e,S,l]),Nn(()=>{});const O=pt(y=>{const{onLayout:W}=w.current,{layout:B,panelDataArray:ie}=N.current;if(y.constraints.collapsible){const te=ie.map(ne=>ne.constraints),{collapsedSize:X=0,panelSize:fe,pivotIndices:be}=vn(ie,y,B);if(Ce(fe!=null,`Panel size not found for panel "${y.id}"`),!tn(fe,X)){I.current.set(y.id,fe);const de=Jn(ie,y)===ie.length-1?fe-X:X-fe,ue=Nr({delta:de,initialLayout:B,panelConstraints:te,pivotIndices:be,prevLayout:B,trigger:"imperative-api"});xi(B,ue)||(x(ue),N.current.layout=ue,W&&W(ue),Fn(ie,ue,m.current))}}},[]),K=pt((y,W)=>{const{onLayout:B}=w.current,{layout:ie,panelDataArray:te}=N.current;if(y.constraints.collapsible){const X=te.map(Z=>Z.constraints),{collapsedSize:fe=0,panelSize:be=0,minSize:ne=0,pivotIndices:de}=vn(te,y,ie),ue=W??ne;if(tn(be,fe)){const Z=I.current.get(y.id),ke=Z!=null&&Z>=ue?Z:ue,De=Jn(te,y)===te.length-1?be-ke:ke-be,j=Nr({delta:De,initialLayout:ie,panelConstraints:X,pivotIndices:de,prevLayout:ie,trigger:"imperative-api"});xi(ie,j)||(x(j),N.current.layout=j,B&&B(j),Fn(te,j,m.current))}}},[]),C=pt(y=>{const{layout:W,panelDataArray:B}=N.current,{panelSize:ie}=vn(B,y,W);return Ce(ie!=null,`Panel size not found for panel "${y.id}"`),ie},[]),T=pt((y,W)=>{const{panelDataArray:B}=N.current,ie=Jn(B,y);return Py({defaultSize:W,dragState:g,layout:S,panelData:B,panelIndex:ie})},[g,S]),A=pt(y=>{const{layout:W,panelDataArray:B}=N.current,{collapsedSize:ie=0,collapsible:te,panelSize:X}=vn(B,y,W);return Ce(X!=null,`Panel size not found for panel "${y.id}"`),te===!0&&tn(X,ie)},[]),F=pt(y=>{const{layout:W,panelDataArray:B}=N.current,{collapsedSize:ie=0,collapsible:te,panelSize:X}=vn(B,y,W);return Ce(X!=null,`Panel size not found for panel "${y.id}"`),!te||zn(X,ie)>0},[]),R=pt(y=>{const{panelDataArray:W}=N.current;W.push(y),W.sort((B,ie)=>{const te=B.order,X=ie.order;return te==null&&X==null?0:te==null?-1:X==null?1:te-X}),N.current.panelDataArrayChanged=!0,_()},[_]);En(()=>{if(N.current.panelDataArrayChanged){N.current.panelDataArrayChanged=!1;const{autoSaveId:y,onLayout:W,storage:B}=w.current,{layout:ie,panelDataArray:te}=N.current;let X=null;if(y){const be=Dy(y,te,B);be&&(I.current=new Map(Object.entries(be.expandToSizes)),X=be.layout)}X==null&&(X=Ay({panelDataArray:te}));const fe=ul({layout:X,panelConstraints:te.map(be=>be.constraints)});ol(ie,fe)||(x(fe),N.current.layout=fe,W&&W(fe),Fn(te,fe,m.current))}}),En(()=>{const y=N.current;return()=>{y.layout=[]}},[]);const L=pt(y=>{let W=!1;const B=h.current;return B&&window.getComputedStyle(B,null).getPropertyValue("direction")==="rtl"&&(W=!0),function(te){te.preventDefault();const X=h.current;if(!X)return()=>null;const{direction:fe,dragState:be,id:ne,keyboardResizeBy:de,onLayout:ue}=w.current,{layout:Z,panelDataArray:ke}=N.current,{initialLayout:me}=be??{},De=uf(ne,y,X);let j=zy(te,y,fe,be,de,X);const z=fe==="horizontal";z&&W&&(j=-j);const M=ke.map(Q=>Q.constraints),re=Nr({delta:j,initialLayout:me??Z,panelConstraints:M,pivotIndices:De,prevLayout:Z,trigger:Qd(te)?"keyboard":"mouse-or-touch"}),ee=!xi(Z,re);(ef(te)||tf(te))&&E.current!=j&&(E.current=j,!ee&&j!==0?z?Rs(y,j<0?rf:sf):Rs(y,j<0?af:of):Rs(y,0)),ee&&(x(re),N.current.layout=re,ue&&ue(re),Fn(ke,re,m.current))}},[]),P=pt((y,W)=>{const{onLayout:B}=w.current,{layout:ie,panelDataArray:te}=N.current,X=te.map(Z=>Z.constraints),{panelSize:fe,pivotIndices:be}=vn(te,y,ie);Ce(fe!=null,`Panel size not found for panel "${y.id}"`);const de=Jn(te,y)===te.length-1?fe-W:W-fe,ue=Nr({delta:de,initialLayout:ie,panelConstraints:X,pivotIndices:be,prevLayout:ie,trigger:"imperative-api"});xi(ie,ue)||(x(ue),N.current.layout=ue,B&&B(ue),Fn(te,ue,m.current))},[]),V=pt((y,W)=>{const{layout:B,panelDataArray:ie}=N.current,{collapsedSize:te=0,collapsible:X}=W,{collapsedSize:fe=0,collapsible:be,maxSize:ne=100,minSize:de=0}=y.constraints,{panelSize:ue}=vn(ie,y,B);ue!=null&&(X&&be&&tn(ue,te)?tn(te,fe)||P(y,fe):ue<de?P(y,de):ue>ne&&P(y,ne))},[P]),U=pt((y,W)=>{const{direction:B}=w.current,{layout:ie}=N.current;if(!h.current)return;const te=xs(y,h.current);Ce(te,`Drag handle element not found for id "${y}"`);const X=df(B,W);v({dragHandleId:y,dragHandleRect:te.getBoundingClientRect(),initialCursorPosition:X,initialLayout:ie})},[]),se=pt(()=>{v(null)},[]),k=pt(y=>{const{panelDataArray:W}=N.current,B=Jn(W,y);B>=0&&(W.splice(B,1),delete m.current[y.id],N.current.panelDataArrayChanged=!0,_())},[_]),le=dy(()=>({collapsePanel:O,direction:r,dragState:g,expandPanel:K,getPanelSize:C,getPanelStyle:T,groupId:p,isPanelCollapsed:A,isPanelExpanded:F,reevaluatePanelConstraints:V,registerPanel:R,registerResizeHandle:L,resizePanel:P,startDragging:U,stopDragging:se,unregisterPanel:k,panelGroupElement:h.current}),[O,g,r,K,C,T,p,A,F,V,R,L,P,U,se,k]),q={display:"flex",flexDirection:r==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return ar(hs.Provider,{value:le},ar(f,{...d,children:t,className:n,id:s,ref:h,style:{...q,...c},"data-panel-group":"","data-panel-group-direction":r,"data-panel-group-id":p}))}const gf=qd((e,t)=>ar(mf,{...e,forwardedRef:t}));mf.displayName="PanelGroup";gf.displayName="forwardRef(PanelGroup)";function Jn(e,t){return e.findIndex(n=>n===t||n.id===t.id)}function vn(e,t,n){const r=Jn(e,t),s=r===e.length-1?[r-1,r]:[r,r+1],a=n[r];return{...t.constraints,panelSize:a,pivotIndices:s}}function $y({disabled:e,handleId:t,resizeHandler:n,panelGroupElement:r}){Nn(()=>{if(e||n==null||r==null)return;const i=xs(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");Ce(o,`No group element found for id "${o}"`);const l=Ur(o,r),c=lf(o,t,r);Ce(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 xf({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 p,h;const g=xt(null),v=xt({onDragging:a});Nn(()=>{v.current.onDragging=a});const S=Gd(hs);if(S===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:x,groupId:_,registerResizeHandle:m,startDragging:I,stopDragging:E,panelGroupElement:w}=S,N=Qa(i),[O,K]=Qn("inactive"),[C,T]=Qn(!1),[A,F]=Qn(null),R=xt({state:O});En(()=>{R.current.state=O}),Nn(()=>{if(n)F(null);else{const U=m(N);F(()=>U)}},[n,N,m]);const L=(p=r==null?void 0:r.coarse)!==null&&p!==void 0?p:15,P=(h=r==null?void 0:r.fine)!==null&&h!==void 0?h:5;return Nn(()=>{if(n||A==null)return;const U=g.current;return Ce(U,"Element ref not attached"),_y(N,U,x,{coarse:L,fine:P},(k,le,q)=>{if(le)switch(k){case"down":{K("drag"),Ce(q,'Expected event to be defined for "down" action'),I(N,q);const{onDragging:y}=v.current;y&&y(!0);break}case"move":{const{state:y}=R.current;y!=="drag"&&K("hover"),Ce(q,'Expected event to be defined for "move" action'),A(q);break}case"up":{K("hover"),E();const{onDragging:y}=v.current;y&&y(!1);break}}else K("inactive")})},[L,x,n,P,m,N,A,I,E]),$y({disabled:n,handleId:N,resizeHandler:A,panelGroupElement:w}),ar(f,{...d,children:e,className:t,id:i,onBlur:()=>{T(!1),s==null||s()},onFocus:()=>{T(!0),o==null||o()},ref:g,role:"separator",style:{...{touchAction:"none",userSelect:"none"},...l},tabIndex:c,"data-panel-group-direction":x,"data-panel-group-id":_,"data-resize-handle":"","data-resize-handle-active":O==="drag"?"pointer":C?"keyboard":void 0,"data-resize-handle-state":O,"data-panel-resize-handle-enabled":!n,"data-panel-resize-handle-id":N})}xf.displayName="PanelResizeHandle";const Fy=({className:e,...t})=>u.jsx(gf,{className:H("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...t}),Ms=Xd,dl=({withHandle:e,className:t,...n})=>u.jsx(xf,{className:H("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(rg,{className:"h-2.5 w-2.5"})})});class Ly{constructor(t){Po(this,"client");this.client=Cg.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 Zy=new Ly;function By(){const e=b.useRef(null),t=b.useCallback(async(r,i,s,a,o)=>{e.current&&e.current.abort();const l=new AbortController;e.current=l;try{a==null||a("parsing","Validating JSON structure...");let c;try{c=JSON.parse(i)}catch(w){throw new Error(`Invalid JSON: ${w instanceof Error?w.message:"Unknown parse error"}`)}a==null||a("building",`Building ${pi.toLowerCase()} structure...`);const f={jsonDefinition:c,options:o||{}};f.customThemes=s??{},a==null||a("rendering",`Generating ${yt.toUpperCase()} content...`);const d={"Content-Type":"application/json"};o!=null&&o.bypassCache&&(d["X-Bypass-Cache"]="true");const p=await fetch(Vc.generate,{method:"POST",headers:d,body:JSON.stringify(f),signal:l.signal}),h=await p.json();if(!p.ok||!h.success){const w=h.error||h.message||`API request failed with status: ${p.status}`;throw new Error(w)}const{data:g,cache:v,warnings:S}=h,x=v.status==="HIT"?"HIT":v.status==="MISS"?"MISS":"UNKNOWN",_=x==="HIT"?`Served from cache (Hit rate: ${v.hitRate})`:`Generated fresh ${pi.toLowerCase()}`;a==null||a("finalizing",_);const m=globalThis.atob(g.document),I=new Uint8Array(m.length);for(let w=0;w<m.length;w++)I[w]=m.charCodeAt(w);const E=new Blob([I],{type:g.contentType});if(E.size===0)throw new Error(`Received empty ${pi.toLowerCase()} from API`);return{name:r,text:i,blob:E,filename:g.filename,fileId:g.fileId,cacheStatus:x,cacheHitRate:v.hitRate,warnings:S}}catch(c){throw c instanceof Error&&c.name==="AbortError"?new Error(`${pi} generation was cancelled`):c}finally{e.current===l&&(e.current=null)}},[]),n=b.useCallback(()=>{e.current&&(e.current.abort(),e.current=null)},[]);return{generatePresentation:t,generateDocument:t,cancelGeneration:n}}function Vy(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 Uy({open:e,onClose:t,nonSafeFonts:n,onChoose:r}){const[i,s]=_e.useState("custom");_e.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(It,{open:e,onOpenChange:l=>!l&&t(),children:u.jsxs(St,{className:"max-w-md",children:[u.jsxs(Ht,{children:[u.jsx(Wt,{children:"Non-safe fonts in this document"}),u.jsxs(hn,{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(In,{children:[u.jsx(Ee,{variant:"outline",size:"sm",onClick:t,children:"Cancel"}),u.jsx(Ee,{size:"sm",onClick:()=>{r(i),t()},children:"Download"})]})]})})}const fl=yt==="docx"?["docxjs","LibreOffice"]:["LibreOffice"],$s={docxjs:["⚡","(Fast) works in the browser — lower fidelity"],LibreOffice:["🖨️","(High fidelity) converts to PDF locally with LibreOffice"]};function Jy({name:e,blob:t,displayReloadButton:n,iframeRef:r,autoReload:i,onToggleAutoReload:s,onManualRender:a,isGenerating:o,isRendering:l,onShowCacheMetrics:c,onShowSchemas:f,onShowFonts:d,documentText:p,warnings:h,renderingLibrary:g,setRenderingLibrary:v,onToggleChat:S,chatOpen:x,onTogglePreview:_,previewOpen:m}){const I=g!=="docxjs",[E,w]=b.useState(!1),[N,O]=b.useState(!1),[K,C]=b.useState(!1),[T,A]=b.useState(!1),[F,R]=b.useState(!1),[L,P]=b.useState(!1),{toast:V}=fr(),{generateDocument:U}=By(),se=b.useContext(nd),k=b.useCallback(()=>{const ne={},{customThemes:de}=se.getState();return Object.values(de).forEach(ue=>{ue.valid&&ue.parsed&&(ne[ue.name]=ue.parsed)}),ne},[se]),le=_e.useMemo(()=>{if(!p)return[];try{const ne=JSON.parse(p);return[...(yt==="pptx"?Fm:Lm)(ne)].filter(ue=>!Zm(ue))}catch{return[]}},[p]),[q,y]=b.useState(!1),W=b.useCallback(async()=>{if(t){w(!0);try{await new Promise(ne=>setTimeout(ne,100)),Ei(`${e}${xr}`,t)}finally{setTimeout(()=>w(!1),500)}}},[t,e]),B=b.useCallback(async()=>{if(t){if(le.length===0){await W();return}y(!0)}},[t,le.length,W]),ie=b.useCallback(async ne=>{var de;if(p){w(!0);try{const ue=await U(e,p,k(),void 0,{bypassCache:!0,fonts:{mode:ne}});if(ue.blob.size===0)V({title:"Export failed",description:"The server returned an empty document.",variant:"destructive"});else{Ei(`${e}${xr}`,ue.blob);const Z=(de=ue.warnings)==null?void 0:de.find(ke=>{var me,De;return((me=ke.context)==null?void 0:me.code)==="FONT_MODE_SUBSTITUTED"||((De=ke.context)==null?void 0:De.code)==="FONT_MODE_CUSTOM"});Z&&V({title:ne==="substitute"?"Fonts substituted":"Non-safe fonts kept",description:Z.message})}}catch(ue){V({title:"Export failed",description:ue instanceof Error?ue.message:String(ue),variant:"destructive"})}finally{setTimeout(()=>w(!1),500)}}},[p,e,U,V,k]),te=b.useCallback(async()=>{if(!(!h||h.length===0)){O(!0);try{const ne=Vy(h);if(!ne){V({title:"No warnings",description:"There are no warnings to download.",variant:"destructive"});return}const de=await U("warnings",JSON.stringify(ne,null,2),{});de&&typeof de=="object"&&"blob"in de&&de.blob&&(Ei(`${e}-warnings${xr}`,de.blob),V({title:"Warnings downloaded",description:`Downloaded warnings document with ${h.length} warning(s).`}))}catch(ne){console.error("Failed to generate warnings document:",ne),V({title:"Download failed",description:ne instanceof Error?ne.message:"Failed to generate warnings document",variant:"destructive"})}finally{setTimeout(()=>O(!1),500)}}},[h,e,U,V]),X=b.useCallback(async()=>{const ne=r==null?void 0:r.current;if(ne!=null&&ne.src){C(!0);try{await new Promise(ue=>{let Z=null,ke=!1;const me=()=>{Z&&(clearTimeout(Z),Z=null),ne.removeEventListener("load",j),ne.removeEventListener("error",z)},De=()=>{ke||(ke=!0,me(),ue())},j=()=>De(),z=()=>De();ne.addEventListener("load",j),ne.addEventListener("error",z),Z=setTimeout(()=>{console.warn("Iframe reload timed out after 5 seconds"),De()},5e3);const M=ne.src,re=M.includes("?")?"&":"?",ee=Date.now();ne.src=`${M}${re}_reload=${ee}`})}catch(de){console.error("Iframe reload failed:",de)}finally{C(!1)}}},[r]),fe=b.useCallback(async()=>{A(!0);try{await Zy.delete(`/${yt}/cache`),window.dispatchEvent(new CustomEvent("cache:cleared")),V({title:"Cache Cleared",description:"All caches (document and component) have been successfully cleared.",variant:"default"})}catch(ne){console.error("Failed to clear cache:",ne),V({title:"Cache Clear Failed",description:"Failed to clear caches. Please try again.",variant:"destructive"})}finally{A(!1)}},[V]),be=b.useCallback(async()=>{if(!p){V({title:"No document available",description:"Please select a document to copy standard components",variant:"destructive"});return}P(!0);try{const ne=await fetch(`/api/${yt}/standard-components`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonDefinition:p})});if(!ne.ok){let Z=`Request failed with status ${ne.status}`;try{const ke=await ne.json();ke.message&&(Z=ke.message)}catch{}V({title:"Failed to get standard components",description:Z,variant:"destructive"});return}const de=await ne.json(),ue=JSON.stringify(de.data,null,2);await navigator.clipboard.writeText(ue),V({title:"Copied to clipboard",description:"Standard components JSON has been copied"})}catch(ne){console.error("Error copying standard components:",ne),V({title:"Error",description:ne instanceof Error?ne.message:"Failed to copy standard components",variant:"destructive"})}finally{P(!1)}},[p,V]);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(qe,{children:[u.jsx(Ge,{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(Kc,{className:"h-3.5 w-3.5 text-muted-foreground"})})}),u.jsx(Ke,{className:"max-w-sm",children:u.jsxs("p",{className:"text-sm",children:["Preview uses"," ",yt==="docx"?"docx-preview":"LibreOffice PDF conversion",". Download the ",xr," to verify fidelity."]})})]})]}),u.jsxs("div",{className:"flex flex-row items-center gap-x-1 shrink-0",children:[(!i||I)&&u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsxs(Ee,{variant:"default",size:"sm",className:"gap-1.5 h-7 px-2.5",onClick:a,"aria-label":"Render preview",disabled:o||l||m===!1,children:[l?u.jsx(en,{size:"sm"}):u.jsx(ig,{className:"h-3.5 w-3.5"}),u.jsx("span",{className:"text-xs font-medium hidden sm:inline",children:"Run"})]})}),u.jsx(Ke,{children:u.jsx("p",{children:m===!1?"Open preview to run":l?"Rendering preview...":"Render preview"})})]}),yt==="docx"&&u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsxs("div",{className:"flex items-center gap-1.5 cursor-help ml-2 mr-1",children:[u.jsx(Xn,{className:"text-xs text-muted-foreground hidden sm:inline",children:"Auto"}),u.jsx(Xa,{checked:i,onCheckedChange:s,disabled:I})]})}),u.jsx(Ke,{children:u.jsx("p",{children:I?"Auto-reload is not available for Office, Docs, and LibreOffice renderers":`${i?"Disable":"Enable"} automatic preview reload on content changes`})})]}),n&&i&&u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsx(Ee,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:X,disabled:K||o||l,children:K?u.jsx(en,{size:"sm"}):u.jsx(sg,{className:"h-3.5 w-3.5"})})}),u.jsx(Ke,{children:u.jsx("p",{children:K?"Reloading...":"Reload"})})]}),u.jsx("div",{className:"w-px h-4 bg-border/60 mx-1"}),u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsxs(Ee,{variant:"outline",size:"sm",className:"gap-1.5 h-7 px-2.5",disabled:!t||E||o,onClick:B,children:[E?u.jsx(en,{size:"sm"}):u.jsx(ag,{className:"h-3.5 w-3.5"}),u.jsx("span",{className:"text-xs font-medium hidden sm:inline",children:"Download"})]})}),u.jsx(Ke,{children:u.jsxs("p",{children:["Download ",xr]})})]}),h&&h.length>0&&u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsx(Ee,{variant:"outline",size:"icon",className:"h-7 w-7 border-transparent bg-warning/10 text-warning hover:bg-warning/20",disabled:N||o,onClick:te,children:N?u.jsx(en,{size:"sm"}):u.jsx(Xc,{className:"h-3.5 w-3.5"})})}),u.jsx(Ke,{children:u.jsxs("p",{children:["Download warnings (",h.length,")"]})})]}),g&&v&&u.jsxs(Fr,{value:g,onValueChange:v,children:[u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsx(rr,{className:"w-[140px] h-7 text-xs hidden lg:flex",children:u.jsx(Lr,{placeholder:"Renderer"})})}),u.jsx(Ke,{children:u.jsx("p",{children:"Select the rendering library"})})]}),u.jsx(ir,{className:"text-sidebar-foreground",children:fl.map(ne=>u.jsxs(Tn,{value:ne,children:[u.jsxs(qe,{children:[u.jsx(Ge,{tabIndex:-1,children:$s[ne][0]}),u.jsx(Ke,{children:$s[ne][1]})]})," ",ne]},ne))})]}),u.jsx("div",{className:"w-px h-4 bg-border/60 mx-1"}),u.jsxs(ds,{children:[u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsx(fs,{asChild:!0,children:u.jsx(Ee,{variant:"ghost",size:"icon",className:"h-7 w-7",children:u.jsx(Gc,{className:"h-3.5 w-3.5"})})})}),u.jsx(Ke,{children:u.jsx("p",{children:"More actions"})})]}),u.jsxs(ai,{align:"end",className:"w-52",children:[f&&u.jsxs(Bt,{onClick:f,children:[u.jsx(og,{className:"h-4 w-4 mr-2"}),"View JSON Schemas"]}),d&&u.jsxs(Bt,{onClick:d,children:[u.jsx(lg,{className:"h-4 w-4 mr-2"}),"Browse fonts"]}),c&&u.jsxs(Bt,{onClick:c,children:[u.jsx(ug,{className:"h-4 w-4 mr-2"}),"View cache metrics"]}),u.jsxs(Bt,{onClick:be,disabled:!p||L,children:[u.jsx(Qc,{className:"h-4 w-4 mr-2"}),L?"Copying...":"Copy standard components"]}),u.jsx(sr,{}),u.jsxs(Bt,{onClick:()=>R(!0),disabled:T,className:"text-destructive focus:text-destructive",children:[u.jsx(Va,{className:"h-4 w-4 mr-2"}),T?"Clearing...":"Clear all caches"]}),g&&v&&u.jsxs(u.Fragment,{children:[u.jsx(sr,{className:"lg:hidden"}),fl.map(ne=>u.jsxs(Bt,{className:"lg:hidden",onClick:()=>v(ne),children:[u.jsx("span",{className:"mr-2",children:g===ne?"●":"○"}),$s[ne][0]," ",ne]},ne))]})]})]}),_&&u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsx(Ee,{variant:m?"default":"ghost",size:"icon",className:"h-7 w-7",onClick:_,children:m?u.jsx(ed,{className:"h-3.5 w-3.5"}):u.jsx(cg,{className:"h-3.5 w-3.5"})})}),u.jsx(Ke,{children:u.jsxs("span",{className:"flex items-center gap-1.5",children:[m?"Hide":"Show"," Preview"," ",u.jsx(Br,{shortcut:"mod+shift+p"})]})})]}),S&&u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsx(Ee,{variant:x?"default":"ghost",size:"icon",className:"h-7 w-7",onClick:S,children:u.jsx(td,{className:"h-3.5 w-3.5"})})}),u.jsx(Ke,{children:u.jsxs("span",{className:"flex items-center gap-1.5",children:[x?"Close":"Open"," AI Chat"," ",u.jsx(Br,{shortcut:"mod+shift+j"})]})})]})]})]}),u.jsx(Uy,{open:q,onClose:()=>y(!1),nonSafeFonts:le,onChoose:ie}),u.jsx(It,{open:F,onOpenChange:R,children:u.jsxs(St,{className:"max-w-sm",children:[u.jsxs(Ht,{children:[u.jsx(Wt,{children:"Clear all caches?"}),u.jsx(hn,{children:"This will clear document and component caches. Next generation will be uncached."})]}),u.jsxs(In,{children:[u.jsx(Ee,{variant:"outline",size:"sm",onClick:()=>R(!1),children:"Cancel"}),u.jsx(Ee,{variant:"destructive",size:"sm",disabled:T,onClick:async()=>{await fe(),R(!1)},children:T?u.jsx(en,{size:"sm"}):"Clear"})]})]})})]})}const Hy=_e.memo(Jy),yf=Om,ro=b.forwardRef(({className:e,...t},n)=>u.jsx(Lc,{ref:n,className:H("bg-muted text-muted-foreground inline-flex h-9 items-center justify-center rounded-sm p-1",e),...t}));ro.displayName=Lc.displayName;const Jr=b.forwardRef(({className:e,...t},n)=>u.jsx(Zc,{ref:n,className:H("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}));Jr.displayName=Zc.displayName;const Hr=b.forwardRef(({className:e,...t},n)=>u.jsx(Bc,{ref:n,className:H("ring-offset-background focus-visible:ring-ring mt-2 focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none",e),...t}));Hr.displayName=Bc.displayName;async function Wy(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 qy(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 Gy(e){const t=qy(e);return Wy(t)}const Ky=({open:e,onOpenChange:t,defaultTab:n="document"})=>{const[r,i]=b.useState(n),[s,a]=b.useState(null),[o,l]=b.useState(null),[c,f]=b.useState(!1),[d,p]=b.useState(!1),[h,g]=b.useState(null),[v,S]=b.useState(null),[x,_]=b.useState(!1),{toast:m}=fr(),I=Dt(F=>F.selectedPlugins),E=Array.from(I);b.useEffect(()=>{n&&i(n)},[n]);const w=b.useCallback(async()=>{f(!0),g(null);try{const F=await Es.fetchDocumentSchema(E);a(F)}catch(F){const R=F instanceof Error?F.message:"Failed to load document schema";g(R),m({variant:"destructive",title:"Error loading schema",description:R})}finally{f(!1)}},[E,m]),N=b.useCallback(async()=>{if(!o){p(!0),S(null);try{const F=await Es.fetchThemeSchema();l(F)}catch(F){const R=F instanceof Error?F.message:"Failed to load theme schema";S(R),m({variant:"destructive",title:"Error loading schema",description:R})}finally{p(!1)}}},[o,m]),[O,K]=b.useState([]);b.useEffect(()=>{e||(a(null),g(null))},[e]),b.useEffect(()=>{if(!e)return;const F=E.length!==O.length||E.some((R,L)=>R!==O[L]);r==="document"?(!s||F)&&(F&&(Es.clearPluginSchemaCache(),K([...E])),c||w()):r==="theme"&&!o&&!d&&N()},[r,e,s,o,c,d,E,O,w,N]);const C=E.length,T=r==="document"?s:o,A=async()=>{if(T)try{await Gy(T)&&(_(!0),m({title:"Schema copied",description:"The JSON schema has been copied to your clipboard"}),setTimeout(()=>_(!1),2e3))}catch(F){console.error("Copy failed:",F)}};return u.jsx(It,{open:e,onOpenChange:t,children:u.jsxs(St,{className:"max-w-4xl max-h-[90vh] overflow-hidden flex flex-col",children:[u.jsx(Ht,{children:u.jsx(Wt,{children:"Schema Viewer"})}),u.jsxs(yf,{value:r,onValueChange:F=>i(F),className:"flex-1 overflow-hidden flex flex-col",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs(ro,{children:[u.jsxs(Jr,{value:"document",className:"flex items-center gap-1",children:["Document",C>0&&u.jsxs(Jt,{variant:"secondary",className:"ml-1 text-xs px-1 py-0",children:["+",C]})]}),u.jsx(Jr,{value:"theme",children:"Theme"})]}),u.jsx("div",{className:"ml-auto",children:u.jsx(Ee,{variant:"ghost",size:"icon",onClick:A,disabled:x||!T,"aria-label":"Copy schema",children:x?u.jsx(pn,{className:"h-4 w-4"}):u.jsx(os,{className:"h-4 w-4"})})})]}),u.jsxs("div",{className:"flex-1 overflow-auto mt-4",children:[u.jsx(Hr,{value:"document",className:"h-full",children:u.jsx(Zi,{schema:s,loading:c,error:h||void 0})}),u.jsx(Hr,{value:"theme",className:"h-full",children:u.jsx(Zi,{schema:o,loading:d,error:v||void 0})})]})]})]})})};function Yy(e,t,n){if(t.length===0)return n;const r=pl(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=pl(l,o);i[a]=c,i=c}return i[t[t.length-1]]=n,r}function pl(e,t){return typeof t=="number"?Array.isArray(e)?[...e]:[]:e&&typeof e=="object"&&!Array.isArray(e)?{...e}:{}}const Xy={safe:[],google:[]};function Qy(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,p)=>d-p).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,p)=>d-p).join(",")}function eb(){const e=Oe(i=>i.activeTab),t=Oe(i=>i.documents),n=Oe(i=>i.documentTypes),r=Oe(i=>i.saveDocument);return b.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(l=>l.name===e);if(!s)return{ok:!1,error:"Active theme not found"};let a;try{a=JSON.parse(s.text)}catch(l){return{ok:!1,error:`Active theme is not valid JSON: ${l.message}`}}const o=i(a);return r(e,JSON.stringify(o,null,2)),{ok:!0,name:e}},[e,t,n,r])}function tb(){const e=Oe(r=>r.activeTab),t=Oe(r=>r.documents),n=Oe(r=>r.saveDocument);return b.useCallback((r,i)=>{if(!e)return{ok:!1,error:"No active file"};const s=t.find(l=>l.name===e);if(!s)return{ok:!1,error:"Active document not found"};let a;try{a=JSON.parse(s.text)}catch(l){return{ok:!1,error:`Active document is not valid JSON: ${l.message}`}}const o=Yy(a,r,i);return n(e,JSON.stringify(o,null,2)),{ok:!0,name:e}},[e,t,n])}function nb(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 hl(e){return e.map((t,n)=>typeof t=="number"?`[${t}]`:n===0?t:`.${t}`).join("")}const rb=({open:e,onOpenChange:t})=>{const n=Ci(P=>P.open),r=Ci(P=>P.contextual),i=Ci(P=>P.close),s=e??n,a=r,o=b.useCallback(P=>{t&&t(P),P||i()},[t,i]),[l,c]=b.useState(Xy),[f,d]=b.useState(!1),[p,h]=b.useState(""),[g,v]=b.useState("safe"),[S,x]=b.useState(null),[_,m]=b.useState(null),{toast:I}=fr(),E=eb(),w=tb(),N=Oe(P=>P.activeTab),O=Oe(P=>P.documentTypes),K=N&&O[N]==="application/json+theme",C=!!a||K;b.useEffect(()=>{s&&(l.safe.length>0||l.google.length>0||(d(!0),fetch("/api/fonts/catalog").then(P=>P.json()).then(P=>c(P)).catch(P=>{I({variant:"destructive",title:"Font catalog unavailable",description:P.message})}).finally(()=>d(!1))))},[s,l,I]),b.useEffect(()=>{if(!(g!=="google"||l.google.length===0))for(const P of l.google)Qy(P.family,P.weights)},[g,l]);const T=b.useMemo(()=>l.safe.filter(P=>P.toLowerCase().includes(p.toLowerCase())),[l.safe,p]),A=b.useMemo(()=>l.google.filter(P=>P.family.toLowerCase().includes(p.toLowerCase())),[l.google,p]),F=b.useCallback(async P=>{try{await navigator.clipboard.writeText(P),m(P),setTimeout(()=>m(null),1500)}catch{I({variant:"destructive",title:"Copy failed",description:"Your browser blocked clipboard write."})}},[I]),R=b.useCallback(async(P,V,U)=>{x(P);try{const se=E(k=>(nb(k,U,P),k));if(!se.ok){I({variant:"destructive",title:"Could not insert font",description:se.error});return}I({title:"Font inserted",description:`${P} set as ${U} font in "${se.name}".`})}finally{x(null)}},[E,I]),L=b.useCallback(async P=>{if(a){x(P);try{const V=w(a.jsonPath,P);if(!V.ok){I({variant:"destructive",title:"Could not insert font",description:V.error});return}I({title:"Font inserted",description:`${P} set at ${hl(a.jsonPath)}.`}),o(!1)}finally{x(null)}}},[a,w,I,o]);return u.jsx(It,{open:s,onOpenChange:o,children:u.jsxs(St,{className:"max-w-4xl max-h-[90vh] overflow-hidden flex flex-col",children:[u.jsx(Ht,{children:u.jsx(Wt,{children:a?`Font for ${hl(a.jsonPath)}`:"Fonts"})}),!a&&!K&&u.jsx($i,{children:u.jsxs(Fi,{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(yf,{value:g,onValueChange:P=>v(P),className:"flex-1 overflow-hidden flex flex-col",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs(ro,{children:[u.jsxs(Jr,{value:"safe",children:["Safe",u.jsx(Jt,{variant:"secondary",className:"ml-1 text-xs px-1 py-0",children:l.safe.length})]}),u.jsxs(Jr,{value:"google",children:["Google",u.jsx(Jt,{variant:"secondary",className:"ml-1 text-xs px-1 py-0",children:l.google.length})]})]}),u.jsx(ii,{type:"search",placeholder:"Search fonts...",value:p,onChange:P=>h(P.target.value),className:"ml-auto max-w-xs"})]}),u.jsxs("div",{className:"flex-1 overflow-auto mt-4 pr-2",children:[u.jsx(Hr,{value:"safe",className:"m-0",children:f&&T.length===0?u.jsxs("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:[u.jsx(la,{className:"animate-spin mr-2"})," Loading catalog..."]}):u.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:T.map(P=>u.jsx(ml,{family:P,meta:u.jsx("span",{className:"text-xs",children:"Installed with Office"}),previewStyle:{fontFamily:`"${P}", sans-serif`},onCopy:()=>F(P),copied:_===P,contextual:!!a,onUseThis:()=>L(P),onInsertHeading:()=>R(P,"safe","heading"),onInsertBody:()=>R(P,"safe","body"),applying:S===P,disabled:!C},P))})}),u.jsx(Hr,{value:"google",className:"m-0",children:f&&A.length===0?u.jsxs("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:[u.jsx(la,{className:"animate-spin mr-2"})," Loading catalog..."]}):u.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:A.map(P=>u.jsx(ml,{family:P.family,meta:u.jsxs("span",{className:"text-xs",children:[P.category," · ",P.weights.length," weights"]}),previewStyle:{fontFamily:`"${P.family}", sans-serif`},onCopy:()=>F(P.family),copied:_===P.family,contextual:!!a,onUseThis:()=>L(P.family),onInsertHeading:()=>R(P.family,"google","heading"),onInsertBody:()=>R(P.family,"google","body"),applying:S===P.family,disabled:!C,extraAction:u.jsx(sb,{family:P.family,weights:P.weights,hasItalic:P.hasItalic})},P.family))})})]})]})]})})},ib="The quick brown fox jumps over the lazy dog",sb=({family:e,weights:t,hasItalic:n})=>{const r=b.useMemo(()=>[...t].sort((i,s)=>i-s),[t]);return u.jsxs(ds,{children:[u.jsx(fs,{asChild:!0,children:u.jsx(Ee,{size:"sm",variant:"ghost","aria-label":"Show variants",children:"Variants"})}),u.jsxs(ai,{align:"end",className:"min-w-[260px]",children:[u.jsxs(Ad,{className:"text-xs text-muted-foreground",children:[r.length," weight",r.length===1?"":"s",n?" · italic available":""]}),u.jsx(sr,{}),r.map(i=>{const s=Bm[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)})]})]})},ml=({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:ib}),u.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[s?u.jsx(Ee,{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(Ee,{size:"sm",variant:"secondary",onClick:o,disabled:c||f,"aria-label":`Set ${e} as heading font`,children:"Set heading"}),u.jsx(Ee,{size:"sm",variant:"secondary",onClick:l,disabled:c||f,"aria-label":`Set ${e} as body font`,children:"Set body"})]}),d,u.jsx(Ee,{size:"sm",variant:"ghost",className:"ml-auto",onClick:r,"aria-label":`Copy ${e}`,children:i?u.jsx(pn,{className:"h-4 w-4"}):u.jsx(os,{className:"h-4 w-4"})})]})]});function gl({previewOpen:e,onTogglePreview:t}){const n=Qt(O=>O.name||""),r=Qt(O=>O.blob),i=Qt(O=>O.isGenerating),s=Qt(O=>O.text),a=Qt(O=>O.warnings),o=Qt(O=>O.isRendering),l=hi(O=>O.autoReload),c=hi(O=>O.renderingLibrary),f=hi(O=>O.setSettings),d=hi(O=>O.useGlobalPreviewHeader??!0),p=Oe(O=>O.activeTab),h=Oe(O=>O.documentTypes),g=p&&h[p]==="application/json+theme"?"theme":"document",v=Pe(O=>O.chatOpen),S=Pe(O=>O.toggleChat),[x,_]=_e.useState(!1),m=Ci(O=>O.openFor);if(!d)return null;const I=b.useCallback(()=>f({saveDocumentDebounceWait:2e3,autoReload:!l}),[l,f]),E=b.useCallback(()=>{window.dispatchEvent(new CustomEvent("preview:manualRender"))},[]),w=b.useCallback(()=>{window.dispatchEvent(new CustomEvent("preview:showCacheMetrics"))},[]),N=(n==null?void 0:n.trim())||"Preview";return u.jsxs("div",{className:"sticky top-0 z-20",children:[u.jsx(Hy,{name:N,blob:r,displayReloadButton:!1,autoReload:l,onToggleAutoReload:I,onManualRender:E,isGenerating:i,isRendering:!!o,onShowCacheMetrics:w,onShowSchemas:()=>_(!0),onShowFonts:()=>m(),documentText:s,warnings:a,renderingLibrary:c,setRenderingLibrary:O=>f({renderingLibrary:O}),onToggleChat:S,chatOpen:v,onTogglePreview:t,previewOpen:e}),u.jsx(Ky,{open:x,onOpenChange:_,defaultTab:g==="theme"?"theme":"document"}),u.jsx(rb,{})]})}function ab(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const ob=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,lb=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,ub={};function xl(e,t){return(ub.jsx?lb:ob).test(e)}const cb=/[ \t\n\f\r]/g;function db(e){return typeof e=="object"?e.type==="text"?yl(e.value):!1:yl(e)}function yl(e){return e.replace(cb,"")===""}class oi{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}oi.prototype.normal={};oi.prototype.property={};oi.prototype.space=void 0;function bf(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new oi(n,r,t)}function ba(e){return e.toLowerCase()}class bt{constructor(t,n){this.attribute=n,this.property=t}}bt.prototype.attribute="";bt.prototype.booleanish=!1;bt.prototype.boolean=!1;bt.prototype.commaOrSpaceSeparated=!1;bt.prototype.commaSeparated=!1;bt.prototype.defined=!1;bt.prototype.mustUseProperty=!1;bt.prototype.number=!1;bt.prototype.overloadedBoolean=!1;bt.prototype.property="";bt.prototype.spaceSeparated=!1;bt.prototype.space=void 0;let fb=0;const Se=On(),tt=On(),va=On(),Y=On(),Ze=On(),tr=On(),wt=On();function On(){return 2**++fb}const wa=Object.freeze(Object.defineProperty({__proto__:null,boolean:Se,booleanish:tt,commaOrSpaceSeparated:wt,commaSeparated:tr,number:Y,overloadedBoolean:va,spaceSeparated:Ze},Symbol.toStringTag,{value:"Module"})),Fs=Object.keys(wa);class io extends bt{constructor(t,n,r,i){let s=-1;if(super(t,n),bl(this,"space",i),typeof r=="number")for(;++s<Fs.length;){const a=Fs[s];bl(this,Fs[s],(r&wa[a])===wa[a])}}}io.prototype.defined=!0;function bl(e,t,n){n&&(e[t]=n)}function pr(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 oi(t,n,e.space)}const vf=pr({properties:{ariaActiveDescendant:null,ariaAtomic:tt,ariaAutoComplete:null,ariaBusy:tt,ariaChecked:tt,ariaColCount:Y,ariaColIndex:Y,ariaColSpan:Y,ariaControls:Ze,ariaCurrent:null,ariaDescribedBy:Ze,ariaDetails:null,ariaDisabled:tt,ariaDropEffect:Ze,ariaErrorMessage:null,ariaExpanded:tt,ariaFlowTo:Ze,ariaGrabbed:tt,ariaHasPopup:null,ariaHidden:tt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Ze,ariaLevel:Y,ariaLive:null,ariaModal:tt,ariaMultiLine:tt,ariaMultiSelectable:tt,ariaOrientation:null,ariaOwns:Ze,ariaPlaceholder:null,ariaPosInSet:Y,ariaPressed:tt,ariaReadOnly:tt,ariaRelevant:null,ariaRequired:tt,ariaRoleDescription:Ze,ariaRowCount:Y,ariaRowIndex:Y,ariaRowSpan:Y,ariaSelected:tt,ariaSetSize:Y,ariaSort:null,ariaValueMax:Y,ariaValueMin:Y,ariaValueNow:Y,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function wf(e,t){return t in e?e[t]:t}function kf(e,t){return wf(e,t.toLowerCase())}const pb=pr({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:tr,acceptCharset:Ze,accessKey:Ze,action:null,allow:null,allowFullScreen:Se,allowPaymentRequest:Se,allowUserMedia:Se,alt:null,as:null,async:Se,autoCapitalize:null,autoComplete:Ze,autoFocus:Se,autoPlay:Se,blocking:Ze,capture:null,charSet:null,checked:Se,cite:null,className:Ze,cols:Y,colSpan:null,content:null,contentEditable:tt,controls:Se,controlsList:Ze,coords:Y|tr,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Se,defer:Se,dir:null,dirName:null,disabled:Se,download:va,draggable:tt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Se,formTarget:null,headers:Ze,height:Y,hidden:va,high:Y,href:null,hrefLang:null,htmlFor:Ze,httpEquiv:Ze,id:null,imageSizes:null,imageSrcSet:null,inert:Se,inputMode:null,integrity:null,is:null,isMap:Se,itemId:null,itemProp:Ze,itemRef:Ze,itemScope:Se,itemType:Ze,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Se,low:Y,manifest:null,max:null,maxLength:Y,media:null,method:null,min:null,minLength:Y,multiple:Se,muted:Se,name:null,nonce:null,noModule:Se,noValidate:Se,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:Se,optimum:Y,pattern:null,ping:Ze,placeholder:null,playsInline:Se,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Se,referrerPolicy:null,rel:Ze,required:Se,reversed:Se,rows:Y,rowSpan:Y,sandbox:Ze,scope:null,scoped:Se,seamless:Se,selected:Se,shadowRootClonable:Se,shadowRootDelegatesFocus:Se,shadowRootMode:null,shape:null,size:Y,sizes:null,slot:null,span:Y,spellCheck:tt,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Y,step:null,style:null,tabIndex:Y,target:null,title:null,translate:null,type:null,typeMustMatch:Se,useMap:null,value:tt,width:Y,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Ze,axis:null,background:null,bgColor:null,border:Y,borderColor:null,bottomMargin:Y,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Se,declare:Se,event:null,face:null,frame:null,frameBorder:null,hSpace:Y,leftMargin:Y,link:null,longDesc:null,lowSrc:null,marginHeight:Y,marginWidth:Y,noResize:Se,noHref:Se,noShade:Se,noWrap:Se,object:null,profile:null,prompt:null,rev:null,rightMargin:Y,rules:null,scheme:null,scrolling:tt,standby:null,summary:null,text:null,topMargin:Y,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Y,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Se,disableRemotePlayback:Se,prefix:null,property:null,results:Y,security:null,unselectable:null},space:"html",transform:kf}),hb=pr({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:wt,accentHeight:Y,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Y,amplitude:Y,arabicForm:null,ascent:Y,attributeName:null,attributeType:null,azimuth:Y,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Y,by:null,calcMode:null,capHeight:Y,className:Ze,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:Y,diffuseConstant:Y,direction:null,display:null,dur:null,divisor:Y,dominantBaseline:null,download:Se,dx:null,dy:null,edgeMode:null,editable:null,elevation:Y,enableBackground:null,end:null,event:null,exponent:Y,externalResourcesRequired:null,fill:null,fillOpacity:Y,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:tr,g2:tr,glyphName:tr,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Y,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Y,horizOriginX:Y,horizOriginY:Y,id:null,ideographic:Y,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Y,k:Y,k1:Y,k2:Y,k3:Y,k4:Y,kernelMatrix:wt,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Y,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:Y,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:Y,overlineThickness:Y,paintOrder:null,panose1:null,path:null,pathLength:Y,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Ze,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Y,pointsAtY:Y,pointsAtZ:Y,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:wt,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:wt,rev:wt,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:wt,requiredFeatures:wt,requiredFonts:wt,requiredFormats:wt,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:Y,specularExponent:Y,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Y,strikethroughThickness:Y,string:null,stroke:null,strokeDashArray:wt,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Y,strokeOpacity:Y,strokeWidth:null,style:null,surfaceScale:Y,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:wt,tabIndex:Y,tableValues:null,target:null,targetX:Y,targetY:Y,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:wt,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Y,underlineThickness:Y,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Y,values:null,vAlphabetic:Y,vMathematical:Y,vectorEffect:null,vHanging:Y,vIdeographic:Y,version:null,vertAdvY:Y,vertOriginX:Y,vertOriginY:Y,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Y,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:wf}),Sf=pr({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()}}),_f=pr({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:kf}),jf=pr({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),mb={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"},gb=/[A-Z]/g,vl=/-[a-z]/g,xb=/^data[-\w.:]+$/i;function yb(e,t){const n=ba(t);let r=t,i=bt;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&xb.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(vl,vb);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!vl.test(s)){let a=s.replace(gb,bb);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}i=io}return new i(r,t)}function bb(e){return"-"+e.toLowerCase()}function vb(e){return e.charAt(1).toUpperCase()}const wb=bf([vf,pb,Sf,_f,jf],"html"),so=bf([vf,hb,Sf,_f,jf],"svg");function kb(e){return e.join(" ").trim()}var Ln={},Ls,wl;function Sb(){if(wl)return Ls;wl=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=`
|
|
3
|
+
`,c="/",f="*",d="",p="comment",h="declaration";function g(S,x){if(typeof S!="string")throw new TypeError("First argument must be a string");if(!S)return[];x=x||{};var _=1,m=1;function I(R){var L=R.match(t);L&&(_+=L.length);var P=R.lastIndexOf(l);m=~P?R.length-P:m+R.length}function E(){var R={line:_,column:m};return function(L){return L.position=new w(R),K(),L}}function w(R){this.start=R,this.end={line:_,column:m},this.source=x.source}w.prototype.content=S;function N(R){var L=new Error(x.source+":"+_+":"+m+": "+R);if(L.reason=R,L.filename=x.source,L.line=_,L.column=m,L.source=S,!x.silent)throw L}function O(R){var L=R.exec(S);if(L){var P=L[0];return I(P),S=S.slice(P.length),L}}function K(){O(n)}function C(R){var L;for(R=R||[];L=T();)L!==!1&&R.push(L);return R}function T(){var R=E();if(!(c!=S.charAt(0)||f!=S.charAt(1))){for(var L=2;d!=S.charAt(L)&&(f!=S.charAt(L)||c!=S.charAt(L+1));)++L;if(L+=2,d===S.charAt(L-1))return N("End of comment missing");var P=S.slice(2,L-2);return m+=2,I(P),S=S.slice(L),m+=2,R({type:p,comment:P})}}function A(){var R=E(),L=O(r);if(L){if(T(),!O(i))return N("property missing ':'");var P=O(s),V=R({type:h,property:v(L[0].replace(e,d)),value:P?v(P[0].replace(e,d)):d});return O(a),V}}function F(){var R=[];C(R);for(var L;L=A();)L!==!1&&(R.push(L),C(R));return R}return K(),F()}function v(S){return S?S.replace(o,d):d}return Ls=g,Ls}var kl;function _b(){if(kl)return Ln;kl=1;var e=Ln&&Ln.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Ln,"__esModule",{value:!0}),Ln.default=n;const t=e(Sb());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 Ln}var wr={},Sl;function jb(){if(Sl)return wr;Sl=1,Object.defineProperty(wr,"__esModule",{value:!0}),wr.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 wr.camelCase=l,wr}var kr,_l;function Cb(){if(_l)return kr;_l=1;var e=kr&&kr.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},t=e(_b()),n=jb();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,kr=r,kr}var Nb=Cb();const Eb=Za(Nb),Cf=Nf("end"),ao=Nf("start");function Nf(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 Ib(e){const t=ao(e),n=Cf(e);if(t&&n)return{start:t,end:n}}function Rr(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?jl(e.position):"start"in e||"end"in e?jl(e):"line"in e||"column"in e?ka(e):""}function ka(e){return Cl(e&&e.line)+":"+Cl(e&&e.column)}function jl(e){return ka(e&&e.start)+"-"+ka(e&&e.end)}function Cl(e){return e&&typeof e=="number"?e:1}class at 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=Rr(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}}at.prototype.file="";at.prototype.name="";at.prototype.reason="";at.prototype.message="";at.prototype.stack="";at.prototype.column=void 0;at.prototype.line=void 0;at.prototype.ancestors=void 0;at.prototype.cause=void 0;at.prototype.fatal=void 0;at.prototype.place=void 0;at.prototype.ruleId=void 0;at.prototype.source=void 0;const oo={}.hasOwnProperty,Tb=new Map,zb=/[A-Z]/g,Ab=new Set(["table","tbody","thead","tfoot","tr"]),Pb=new Set(["td","th"]),Ef="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Ob(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=Bb(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=Zb(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"?so:wb,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},s=If(i,e,void 0);return s&&typeof s!="string"?s:i.create(e,i.Fragment,{children:s||void 0},void 0)}function If(e,t,n){if(t.type==="element")return Db(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return Rb(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return $b(e,t,n);if(t.type==="mdxjsEsm")return Mb(e,t);if(t.type==="root")return Fb(e,t,n);if(t.type==="text")return Lb(e,t)}function Db(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=so,e.schema=i),e.ancestors.push(t);const s=zf(e,t.tagName,!1),a=Vb(e,t);let o=uo(e,t);return Ab.has(t.tagName)&&(o=o.filter(function(l){return typeof l=="string"?!db(l):!0})),Tf(e,a,s,t),lo(a,o),e.ancestors.pop(),e.schema=r,e.create(t,s,a,n)}function Rb(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)}Wr(e,t.position)}function Mb(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Wr(e,t.position)}function $b(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=so,e.schema=i),e.ancestors.push(t);const s=t.name===null?e.Fragment:zf(e,t.name,!0),a=Ub(e,t),o=uo(e,t);return Tf(e,a,s,t),lo(a,o),e.ancestors.pop(),e.schema=r,e.create(t,s,a,n)}function Fb(e,t,n){const r={};return lo(r,uo(e,t)),e.create(t,e.Fragment,r,n)}function Lb(e,t){return t.value}function Tf(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function lo(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function Zb(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 Bb(e,t){return n;function n(r,i,s,a){const o=Array.isArray(s.children),l=ao(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 Vb(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&oo.call(t.properties,i)){const s=Jb(e,i,t.properties[i]);if(s){const[a,o]=s;e.tableCellAlignToStyle&&a==="align"&&typeof o=="string"&&Pb.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 Ub(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 Wr(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 Wr(e,t.position);else s=r.value===null?!0:r.value;n[i]=s}return n}function uo(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:Tb;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=If(e,s,a);o!==void 0&&n.push(o)}return n}function Jb(e,t,n){const r=yb(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?ab(n):kb(n)),r.property==="style"){let i=typeof n=="object"?n:Hb(e,String(n));return e.stylePropertyNameCase==="css"&&(i=Wb(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&r.space?mb[r.property]||r.property:r.attribute,n]}}function Hb(e,t){try{return Eb(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,i=new at("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=Ef+"#cannot-parse-style-attribute",i}}function zf(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=xl(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=xl(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);Wr(e)}function Wr(e,t){const n=new at("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=Ef+"#cannot-handle-mdx-estrees-without-createevaluater",n}function Wb(e){const t={};let n;for(n in e)oo.call(e,n)&&(t[qb(n)]=e[n]);return t}function qb(e){let t=e.replace(zb,Gb);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function Gb(e){return"-"+e.toLowerCase()}const Zs={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"]},Kb={};function co(e,t){const n=Kb,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return Af(e,r,i)}function Af(e,t,n){if(Yb(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 Nl(e.children,t,n)}return Array.isArray(e)?Nl(e,t,n):""}function Nl(e,t,n){const r=[];let i=-1;for(;++i<e.length;)r[i]=Af(e[i],t,n);return r.join("")}function Yb(e){return!!(e&&typeof e=="object")}const El=document.createElement("i");function fo(e){const t="&"+e+";";El.innerHTML=t;const n=El.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function _t(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 Et(e,t){return e.length>0?(_t(e,e.length,0,t),e):t}const Il={}.hasOwnProperty;function Pf(e){const t={};let n=-1;for(;++n<e.length;)Xb(t,e[n]);return t}function Xb(e,t){let n;for(n in t){const i=(Il.call(e,n)?e[n]:void 0)||(e[n]={}),s=t[n];let a;if(s)for(a in s){Il.call(i,a)||(i[a]=[]);const o=s[a];Qb(i[a],Array.isArray(o)?o:o?[o]:[])}}}function Qb(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);_t(e,0,0,r)}function Of(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 Mt(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const dt=xn(/[A-Za-z]/),st=xn(/[\dA-Za-z]/),ev=xn(/[#-'*+\--9=?A-Z^-~]/);function Ui(e){return e!==null&&(e<32||e===127)}const Sa=xn(/\d/),tv=xn(/[\dA-Fa-f]/),nv=xn(/[!-/:-@[-`{-~]/);function xe(e){return e!==null&&e<-2}function Fe(e){return e!==null&&(e<0||e===32)}function Ie(e){return e===-2||e===-1||e===32}const ys=xn(new RegExp("\\p{P}|\\p{S}","u")),An=xn(/\s/);function xn(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function hr(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const s=e.charCodeAt(n);let a="";if(s===37&&st(e.charCodeAt(n+1))&&st(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 Ae(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let s=0;return a;function a(l){return Ie(l)?(e.enter(n),o(l)):t(l)}function o(l){return Ie(l)&&s++<i?(e.consume(l),o):(e.exit(n),t(l))}}const rv={tokenize:iv};function iv(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"),Ae(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 xe(o)?(e.consume(o),e.exit("chunkText"),s):(e.consume(o),a)}}const sv={tokenize:av},Tl={tokenize:ov};function av(e){const t=this,n=[];let r=0,i,s,a;return o;function o(m){if(r<n.length){const I=n[r];return t.containerState=I[1],e.attempt(I[0].continuation,l,c)(m)}return c(m)}function l(m){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&_();const I=t.events.length;let E=I,w;for(;E--;)if(t.events[E][0]==="exit"&&t.events[E][1].type==="chunkFlow"){w=t.events[E][1].end;break}x(r);let N=I;for(;N<t.events.length;)t.events[N][1].end={...w},N++;return _t(t.events,E+1,0,t.events.slice(I)),t.events.length=N,c(m)}return o(m)}function c(m){if(r===n.length){if(!i)return p(m);if(i.currentConstruct&&i.currentConstruct.concrete)return g(m);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Tl,f,d)(m)}function f(m){return i&&_(),x(r),p(m)}function d(m){return t.parser.lazy[t.now().line]=r!==n.length,a=t.now().offset,g(m)}function p(m){return t.containerState={},e.attempt(Tl,h,g)(m)}function h(m){return r++,n.push([t.currentConstruct,t.containerState]),p(m)}function g(m){if(m===null){i&&_(),x(0),e.consume(m);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:s}),v(m)}function v(m){if(m===null){S(e.exit("chunkFlow"),!0),x(0),e.consume(m);return}return xe(m)?(e.consume(m),S(e.exit("chunkFlow")),r=0,t.interrupt=void 0,o):(e.consume(m),v)}function S(m,I){const E=t.sliceStream(m);if(I&&E.push(null),m.previous=s,s&&(s.next=m),s=m,i.defineSkip(m.start),i.write(E),t.parser.lazy[m.start.line]){let w=i.events.length;for(;w--;)if(i.events[w][1].start.offset<a&&(!i.events[w][1].end||i.events[w][1].end.offset>a))return;const N=t.events.length;let O=N,K,C;for(;O--;)if(t.events[O][0]==="exit"&&t.events[O][1].type==="chunkFlow"){if(K){C=t.events[O][1].end;break}K=!0}for(x(r),w=N;w<t.events.length;)t.events[w][1].end={...C},w++;_t(t.events,O+1,0,t.events.slice(N)),t.events.length=w}}function x(m){let I=n.length;for(;I-- >m;){const E=n[I];t.containerState=E[1],E[0].exit.call(t,e)}n.length=m}function _(){i.write([null]),s=void 0,i=void 0,t.containerState._closeFlow=void 0}}function ov(e,t,n){return Ae(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function or(e){if(e===null||Fe(e)||An(e))return 1;if(ys(e))return 2}function bs(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 _a={name:"attention",resolveAll:lv,tokenize:uv};function lv(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},p={...e[n][1].start};zl(d,-l),zl(p,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:p},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=Et(c,[["enter",e[r][1],t],["exit",e[r][1],t]])),c=Et(c,[["enter",i,t],["enter",a,t],["exit",a,t],["enter",s,t]]),c=Et(c,bs(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),c=Et(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=Et(c,[["enter",e[n][1],t],["exit",e[n][1],t]])):f=0,_t(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 uv(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=or(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=or(l),d=!f||f===2&&i||n.includes(l),p=!i||i===2&&f||n.includes(r);return c._open=!!(s===42?d:d&&(i||!p)),c._close=!!(s===42?p:p&&(f||!d)),t(l)}}function zl(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const cv={name:"autolink",tokenize:dv};function dv(e,t,n){let r=0;return i;function i(h){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),s}function s(h){return dt(h)?(e.consume(h),a):h===64?n(h):c(h)}function a(h){return h===43||h===45||h===46||st(h)?(r=1,o(h)):c(h)}function o(h){return h===58?(e.consume(h),r=0,l):(h===43||h===45||h===46||st(h))&&r++<32?(e.consume(h),o):(r=0,c(h))}function l(h){return h===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.exit("autolink"),t):h===null||h===32||h===60||Ui(h)?n(h):(e.consume(h),l)}function c(h){return h===64?(e.consume(h),f):ev(h)?(e.consume(h),c):n(h)}function f(h){return st(h)?d(h):n(h)}function d(h){return h===46?(e.consume(h),r=0,f):h===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.exit("autolink"),t):p(h)}function p(h){if((h===45||st(h))&&r++<63){const g=h===45?p:d;return e.consume(h),g}return n(h)}}const li={partial:!0,tokenize:fv};function fv(e,t,n){return r;function r(s){return Ie(s)?Ae(e,i,"linePrefix")(s):i(s)}function i(s){return s===null||xe(s)?t(s):n(s)}}const Df={continuation:{tokenize:hv},exit:mv,name:"blockQuote",tokenize:pv};function pv(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 Ie(a)?(e.enter("blockQuotePrefixWhitespace"),e.consume(a),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(a))}}function hv(e,t,n){const r=this;return i;function i(a){return Ie(a)?Ae(e,s,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a):s(a)}function s(a){return e.attempt(Df,t,n)(a)}}function mv(e){e.exit("blockQuote")}const Rf={name:"characterEscape",tokenize:gv};function gv(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 nv(s)?(e.enter("characterEscapeValue"),e.consume(s),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(s)}}const Mf={name:"characterReference",tokenize:xv};function xv(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=st,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=tv,f):(e.enter("characterReferenceValue"),s=7,a=Sa,f(d))}function f(d){if(d===59&&i){const p=e.exit("characterReferenceValue");return a===st&&!fo(r.sliceSerialize(p))?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 Al={partial:!0,tokenize:bv},Pl={concrete:!0,name:"codeFenced",tokenize:yv};function yv(e,t,n){const r=this,i={partial:!0,tokenize:E};let s=0,a=0,o;return l;function l(w){return c(w)}function c(w){const N=r.events[r.events.length-1];return s=N&&N[1].type==="linePrefix"?N[2].sliceSerialize(N[1],!0).length:0,o=w,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),f(w)}function f(w){return w===o?(a++,e.consume(w),f):a<3?n(w):(e.exit("codeFencedFenceSequence"),Ie(w)?Ae(e,d,"whitespace")(w):d(w))}function d(w){return w===null||xe(w)?(e.exit("codeFencedFence"),r.interrupt?t(w):e.check(Al,v,I)(w)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),p(w))}function p(w){return w===null||xe(w)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),d(w)):Ie(w)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Ae(e,h,"whitespace")(w)):w===96&&w===o?n(w):(e.consume(w),p)}function h(w){return w===null||xe(w)?d(w):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),g(w))}function g(w){return w===null||xe(w)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),d(w)):w===96&&w===o?n(w):(e.consume(w),g)}function v(w){return e.attempt(i,I,S)(w)}function S(w){return e.enter("lineEnding"),e.consume(w),e.exit("lineEnding"),x}function x(w){return s>0&&Ie(w)?Ae(e,_,"linePrefix",s+1)(w):_(w)}function _(w){return w===null||xe(w)?e.check(Al,v,I)(w):(e.enter("codeFlowValue"),m(w))}function m(w){return w===null||xe(w)?(e.exit("codeFlowValue"),_(w)):(e.consume(w),m)}function I(w){return e.exit("codeFenced"),t(w)}function E(w,N,O){let K=0;return C;function C(L){return w.enter("lineEnding"),w.consume(L),w.exit("lineEnding"),T}function T(L){return w.enter("codeFencedFence"),Ie(L)?Ae(w,A,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(L):A(L)}function A(L){return L===o?(w.enter("codeFencedFenceSequence"),F(L)):O(L)}function F(L){return L===o?(K++,w.consume(L),F):K>=a?(w.exit("codeFencedFenceSequence"),Ie(L)?Ae(w,R,"whitespace")(L):R(L)):O(L)}function R(L){return L===null||xe(L)?(w.exit("codeFencedFence"),N(L)):O(L)}}}function bv(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 Bs={name:"codeIndented",tokenize:wv},vv={partial:!0,tokenize:kv};function wv(e,t,n){const r=this;return i;function i(c){return e.enter("codeIndented"),Ae(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):xe(c)?e.attempt(vv,a,l)(c):(e.enter("codeFlowValue"),o(c))}function o(c){return c===null||xe(c)?(e.exit("codeFlowValue"),a(c)):(e.consume(c),o)}function l(c){return e.exit("codeIndented"),t(c)}}function kv(e,t,n){const r=this;return i;function i(a){return r.parser.lazy[r.now().line]?n(a):xe(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),i):Ae(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):xe(a)?i(a):n(a)}}const Sv={name:"codeText",previous:jv,resolve:_v,tokenize:Cv};function _v(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 jv(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function Cv(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)):xe(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||xe(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 Nv{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&&Sr(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),Sr(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Sr(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);Sr(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Sr(this.left,n.reverse())}}}function Sr(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 $f(e){const t={};let n=-1,r,i,s,a,o,l,c;const f=new Nv(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,Ev(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 _t(e,0,Number.POSITIVE_INFINITY,f.slice(0)),!c}function Ev(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,p=-1,h=n,g=0,v=0;const S=[v];for(;h;){for(;e.get(++i)[1]!==h;);s.push(i),h._tokenizer||(f=r.sliceStream(h),h.next||f.push(null),d&&a.defineSkip(h.start),h._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=!0),a.write(f),h._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=void 0)),d=h,h=h.next}for(h=n;++p<o.length;)o[p][0]==="exit"&&o[p-1][0]==="enter"&&o[p][1].type===o[p-1][1].type&&o[p][1].start.line!==o[p][1].end.line&&(v=p+1,S.push(v),h._tokenizer=void 0,h.previous=void 0,h=h.next);for(a.events=[],h?(h._tokenizer=void 0,h.previous=void 0):S.pop(),p=S.length;p--;){const x=o.slice(S[p],S[p+1]),_=s.pop();l.push([_,_+x.length-1]),e.splice(_,2,x)}for(l.reverse(),p=-1;++p<l.length;)c[g+l[p][0]]=g+l[p][1],g+=l[p][1]-l[p][0]-1;return c}const Iv={resolve:zv,tokenize:Av},Tv={partial:!0,tokenize:Pv};function zv(e){return $f(e),e}function Av(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):xe(o)?e.check(Tv,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 Pv(e,t,n){const r=this;return i;function i(a){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),Ae(e,s,"linePrefix")}function s(a){if(a===null||xe(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 Ff(e,t,n,r,i,s,a,o,l){const c=l||Number.POSITIVE_INFINITY;let f=0;return d;function d(x){return x===60?(e.enter(r),e.enter(i),e.enter(s),e.consume(x),e.exit(s),p):x===null||x===32||x===41||Ui(x)?n(x):(e.enter(r),e.enter(a),e.enter(o),e.enter("chunkString",{contentType:"string"}),v(x))}function p(x){return x===62?(e.enter(s),e.consume(x),e.exit(s),e.exit(i),e.exit(r),t):(e.enter(o),e.enter("chunkString",{contentType:"string"}),h(x))}function h(x){return x===62?(e.exit("chunkString"),e.exit(o),p(x)):x===null||x===60||xe(x)?n(x):(e.consume(x),x===92?g:h)}function g(x){return x===60||x===62||x===92?(e.consume(x),h):h(x)}function v(x){return!f&&(x===null||x===41||Fe(x))?(e.exit("chunkString"),e.exit(o),e.exit(a),e.exit(r),t(x)):f<c&&x===40?(e.consume(x),f++,v):x===41?(e.consume(x),f--,v):x===null||x===32||x===40||Ui(x)?n(x):(e.consume(x),x===92?S:v)}function S(x){return x===40||x===41||x===92?(e.consume(x),v):v(x)}}function Lf(e,t,n,r,i,s){const a=this;let o=0,l;return c;function c(h){return e.enter(r),e.enter(i),e.consume(h),e.exit(i),e.enter(s),f}function f(h){return o>999||h===null||h===91||h===93&&!l||h===94&&!o&&"_hiddenFootnoteSupport"in a.parser.constructs?n(h):h===93?(e.exit(s),e.enter(i),e.consume(h),e.exit(i),e.exit(r),t):xe(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),f):(e.enter("chunkString",{contentType:"string"}),d(h))}function d(h){return h===null||h===91||h===93||xe(h)||o++>999?(e.exit("chunkString"),f(h)):(e.consume(h),l||(l=!Ie(h)),h===92?p:d)}function p(h){return h===91||h===92||h===93?(e.consume(h),o++,d):d(h)}}function Zf(e,t,n,r,i,s){let a;return o;function o(p){return p===34||p===39||p===40?(e.enter(r),e.enter(i),e.consume(p),e.exit(i),a=p===40?41:p,l):n(p)}function l(p){return p===a?(e.enter(i),e.consume(p),e.exit(i),e.exit(r),t):(e.enter(s),c(p))}function c(p){return p===a?(e.exit(s),l(a)):p===null?n(p):xe(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),Ae(e,c,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),f(p))}function f(p){return p===a||p===null||xe(p)?(e.exit("chunkString"),c(p)):(e.consume(p),p===92?d:f)}function d(p){return p===a||p===92?(e.consume(p),f):f(p)}}function Mr(e,t){let n;return r;function r(i){return xe(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):Ie(i)?Ae(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const Ov={name:"definition",tokenize:Rv},Dv={partial:!0,tokenize:Mv};function Rv(e,t,n){const r=this;let i;return s;function s(h){return e.enter("definition"),a(h)}function a(h){return Lf.call(r,e,o,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(h)}function o(h){return i=Mt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),h===58?(e.enter("definitionMarker"),e.consume(h),e.exit("definitionMarker"),l):n(h)}function l(h){return Fe(h)?Mr(e,c)(h):c(h)}function c(h){return Ff(e,f,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(h)}function f(h){return e.attempt(Dv,d,d)(h)}function d(h){return Ie(h)?Ae(e,p,"whitespace")(h):p(h)}function p(h){return h===null||xe(h)?(e.exit("definition"),r.parser.defined.push(i),t(h)):n(h)}}function Mv(e,t,n){return r;function r(o){return Fe(o)?Mr(e,i)(o):n(o)}function i(o){return Zf(e,s,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(o)}function s(o){return Ie(o)?Ae(e,a,"whitespace")(o):a(o)}function a(o){return o===null||xe(o)?t(o):n(o)}}const $v={name:"hardBreakEscape",tokenize:Fv};function Fv(e,t,n){return r;function r(s){return e.enter("hardBreakEscape"),e.consume(s),i}function i(s){return xe(s)?(e.exit("hardBreakEscape"),t(s)):n(s)}}const Lv={name:"headingAtx",resolve:Zv,tokenize:Bv};function Zv(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"},_t(e,r,n-r+1,[["enter",i,t],["enter",s,t],["exit",s,t],["exit",i,t]])),e}function Bv(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||xe(f)?(e.exit("atxHeading"),t(f)):Ie(f)?Ae(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 Vv=["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"],Ol=["pre","script","style","textarea"],Uv={concrete:!0,name:"htmlFlow",resolveTo:Wv,tokenize:qv},Jv={partial:!0,tokenize:Kv},Hv={partial:!0,tokenize:Gv};function Wv(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 qv(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),p):y===47?(e.consume(y),s=!0,v):y===63?(e.consume(y),i=3,r.interrupt?t:k):dt(y)?(e.consume(y),a=String.fromCharCode(y),S):n(y)}function p(y){return y===45?(e.consume(y),i=2,h):y===91?(e.consume(y),i=5,o=0,g):dt(y)?(e.consume(y),i=4,r.interrupt?t:k):n(y)}function h(y){return y===45?(e.consume(y),r.interrupt?t:k):n(y)}function g(y){const W="CDATA[";return y===W.charCodeAt(o++)?(e.consume(y),o===W.length?r.interrupt?t:A:g):n(y)}function v(y){return dt(y)?(e.consume(y),a=String.fromCharCode(y),S):n(y)}function S(y){if(y===null||y===47||y===62||Fe(y)){const W=y===47,B=a.toLowerCase();return!W&&!s&&Ol.includes(B)?(i=1,r.interrupt?t(y):A(y)):Vv.includes(a.toLowerCase())?(i=6,W?(e.consume(y),x):r.interrupt?t(y):A(y)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(y):s?_(y):m(y))}return y===45||st(y)?(e.consume(y),a+=String.fromCharCode(y),S):n(y)}function x(y){return y===62?(e.consume(y),r.interrupt?t:A):n(y)}function _(y){return Ie(y)?(e.consume(y),_):C(y)}function m(y){return y===47?(e.consume(y),C):y===58||y===95||dt(y)?(e.consume(y),I):Ie(y)?(e.consume(y),m):C(y)}function I(y){return y===45||y===46||y===58||y===95||st(y)?(e.consume(y),I):E(y)}function E(y){return y===61?(e.consume(y),w):Ie(y)?(e.consume(y),E):m(y)}function w(y){return y===null||y===60||y===61||y===62||y===96?n(y):y===34||y===39?(e.consume(y),l=y,N):Ie(y)?(e.consume(y),w):O(y)}function N(y){return y===l?(e.consume(y),l=null,K):y===null||xe(y)?n(y):(e.consume(y),N)}function O(y){return y===null||y===34||y===39||y===47||y===60||y===61||y===62||y===96||Fe(y)?E(y):(e.consume(y),O)}function K(y){return y===47||y===62||Ie(y)?m(y):n(y)}function C(y){return y===62?(e.consume(y),T):n(y)}function T(y){return y===null||xe(y)?A(y):Ie(y)?(e.consume(y),T):n(y)}function A(y){return y===45&&i===2?(e.consume(y),P):y===60&&i===1?(e.consume(y),V):y===62&&i===4?(e.consume(y),le):y===63&&i===3?(e.consume(y),k):y===93&&i===5?(e.consume(y),se):xe(y)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(Jv,q,F)(y)):y===null||xe(y)?(e.exit("htmlFlowData"),F(y)):(e.consume(y),A)}function F(y){return e.check(Hv,R,q)(y)}function R(y){return e.enter("lineEnding"),e.consume(y),e.exit("lineEnding"),L}function L(y){return y===null||xe(y)?F(y):(e.enter("htmlFlowData"),A(y))}function P(y){return y===45?(e.consume(y),k):A(y)}function V(y){return y===47?(e.consume(y),a="",U):A(y)}function U(y){if(y===62){const W=a.toLowerCase();return Ol.includes(W)?(e.consume(y),le):A(y)}return dt(y)&&a.length<8?(e.consume(y),a+=String.fromCharCode(y),U):A(y)}function se(y){return y===93?(e.consume(y),k):A(y)}function k(y){return y===62?(e.consume(y),le):y===45&&i===2?(e.consume(y),k):A(y)}function le(y){return y===null||xe(y)?(e.exit("htmlFlowData"),q(y)):(e.consume(y),le)}function q(y){return e.exit("htmlFlow"),t(y)}}function Gv(e,t,n){const r=this;return i;function i(a){return xe(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 Kv(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(li,t,n)}}const Yv={name:"htmlText",tokenize:Xv};function Xv(e,t,n){const r=this;let i,s,a;return o;function o(k){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(k),l}function l(k){return k===33?(e.consume(k),c):k===47?(e.consume(k),E):k===63?(e.consume(k),m):dt(k)?(e.consume(k),O):n(k)}function c(k){return k===45?(e.consume(k),f):k===91?(e.consume(k),s=0,g):dt(k)?(e.consume(k),_):n(k)}function f(k){return k===45?(e.consume(k),h):n(k)}function d(k){return k===null?n(k):k===45?(e.consume(k),p):xe(k)?(a=d,V(k)):(e.consume(k),d)}function p(k){return k===45?(e.consume(k),h):d(k)}function h(k){return k===62?P(k):k===45?p(k):d(k)}function g(k){const le="CDATA[";return k===le.charCodeAt(s++)?(e.consume(k),s===le.length?v:g):n(k)}function v(k){return k===null?n(k):k===93?(e.consume(k),S):xe(k)?(a=v,V(k)):(e.consume(k),v)}function S(k){return k===93?(e.consume(k),x):v(k)}function x(k){return k===62?P(k):k===93?(e.consume(k),x):v(k)}function _(k){return k===null||k===62?P(k):xe(k)?(a=_,V(k)):(e.consume(k),_)}function m(k){return k===null?n(k):k===63?(e.consume(k),I):xe(k)?(a=m,V(k)):(e.consume(k),m)}function I(k){return k===62?P(k):m(k)}function E(k){return dt(k)?(e.consume(k),w):n(k)}function w(k){return k===45||st(k)?(e.consume(k),w):N(k)}function N(k){return xe(k)?(a=N,V(k)):Ie(k)?(e.consume(k),N):P(k)}function O(k){return k===45||st(k)?(e.consume(k),O):k===47||k===62||Fe(k)?K(k):n(k)}function K(k){return k===47?(e.consume(k),P):k===58||k===95||dt(k)?(e.consume(k),C):xe(k)?(a=K,V(k)):Ie(k)?(e.consume(k),K):P(k)}function C(k){return k===45||k===46||k===58||k===95||st(k)?(e.consume(k),C):T(k)}function T(k){return k===61?(e.consume(k),A):xe(k)?(a=T,V(k)):Ie(k)?(e.consume(k),T):K(k)}function A(k){return k===null||k===60||k===61||k===62||k===96?n(k):k===34||k===39?(e.consume(k),i=k,F):xe(k)?(a=A,V(k)):Ie(k)?(e.consume(k),A):(e.consume(k),R)}function F(k){return k===i?(e.consume(k),i=void 0,L):k===null?n(k):xe(k)?(a=F,V(k)):(e.consume(k),F)}function R(k){return k===null||k===34||k===39||k===60||k===61||k===96?n(k):k===47||k===62||Fe(k)?K(k):(e.consume(k),R)}function L(k){return k===47||k===62||Fe(k)?K(k):n(k)}function P(k){return k===62?(e.consume(k),e.exit("htmlTextData"),e.exit("htmlText"),t):n(k)}function V(k){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(k),e.exit("lineEnding"),U}function U(k){return Ie(k)?Ae(e,se,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(k):se(k)}function se(k){return e.enter("htmlTextData"),a(k)}}const po={name:"labelEnd",resolveAll:nw,resolveTo:rw,tokenize:iw},Qv={tokenize:sw},ew={tokenize:aw},tw={tokenize:ow};function nw(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&&_t(e,0,e.length,n),e}function rw(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=Et(o,e.slice(s+1,s+r+3)),o=Et(o,[["enter",f,t]]),o=Et(o,bs(t.parser.constructs.insideSpan.null,e.slice(s+r+4,a-3),t)),o=Et(o,[["exit",f,t],e[a-2],e[a-1],["exit",c,t]]),o=Et(o,e.slice(a+1)),o=Et(o,[["exit",l,t]]),_t(e,s,e.length,o),e}function iw(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(p){return s?s._inactive?d(p):(a=r.parser.defined.includes(Mt(r.sliceSerialize({start:s.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(p),e.exit("labelMarker"),e.exit("labelEnd"),l):n(p)}function l(p){return p===40?e.attempt(Qv,f,a?f:d)(p):p===91?e.attempt(ew,f,a?c:d)(p):a?f(p):d(p)}function c(p){return e.attempt(tw,f,d)(p)}function f(p){return t(p)}function d(p){return s._balanced=!0,n(p)}}function sw(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)?Mr(e,s)(d):s(d)}function s(d){return d===41?f(d):Ff(e,a,o,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(d)}function a(d){return Fe(d)?Mr(e,l)(d):f(d)}function o(d){return n(d)}function l(d){return d===34||d===39||d===40?Zf(e,c,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(d):f(d)}function c(d){return Fe(d)?Mr(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 aw(e,t,n){const r=this;return i;function i(o){return Lf.call(r,e,s,a,"reference","referenceMarker","referenceString")(o)}function s(o){return r.parser.defined.includes(Mt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(o):n(o)}function a(o){return n(o)}}function ow(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 lw={name:"labelStartImage",resolveAll:po.resolveAll,tokenize:uw};function uw(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 cw={name:"labelStartLink",resolveAll:po.resolveAll,tokenize:dw};function dw(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 Vs={name:"lineEnding",tokenize:fw};function fw(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),Ae(e,t,"linePrefix")}}const Ii={name:"thematicBreak",tokenize:pw};function pw(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||xe(c))?(e.exit("thematicBreak"),t(c)):n(c)}function l(c){return c===i?(e.consume(c),r++,l):(e.exit("thematicBreakSequence"),Ie(c)?Ae(e,o,"whitespace")(c):o(c))}}const ht={continuation:{tokenize:xw},exit:bw,name:"list",tokenize:gw},hw={partial:!0,tokenize:vw},mw={partial:!0,tokenize:yw};function gw(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(h){const g=r.containerState.type||(h===42||h===43||h===45?"listUnordered":"listOrdered");if(g==="listUnordered"?!r.containerState.marker||h===r.containerState.marker:Sa(h)){if(r.containerState.type||(r.containerState.type=g,e.enter(g,{_container:!0})),g==="listUnordered")return e.enter("listItemPrefix"),h===42||h===45?e.check(Ii,n,c)(h):c(h);if(!r.interrupt||h===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),l(h)}return n(h)}function l(h){return Sa(h)&&++a<10?(e.consume(h),l):(!r.interrupt||a<2)&&(r.containerState.marker?h===r.containerState.marker:h===41||h===46)?(e.exit("listItemValue"),c(h)):n(h)}function c(h){return e.enter("listItemMarker"),e.consume(h),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||h,e.check(li,r.interrupt?n:f,e.attempt(hw,p,d))}function f(h){return r.containerState.initialBlankLine=!0,s++,p(h)}function d(h){return Ie(h)?(e.enter("listItemPrefixWhitespace"),e.consume(h),e.exit("listItemPrefixWhitespace"),p):n(h)}function p(h){return r.containerState.size=s+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(h)}}function xw(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(li,i,s);function i(o){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Ae(e,t,"listItemIndent",r.containerState.size+1)(o)}function s(o){return r.containerState.furtherBlankLines||!Ie(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(mw,t,a)(o))}function a(o){return r.containerState._closeFlow=!0,r.interrupt=void 0,Ae(e,e.attempt(ht,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o)}}function yw(e,t,n){const r=this;return Ae(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 bw(e){e.exit(this.containerState.type)}function vw(e,t,n){const r=this;return Ae(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!Ie(s)&&a&&a[1].type==="listItemPrefixWhitespace"?t(s):n(s)}}const Dl={name:"setextUnderline",resolveTo:ww,tokenize:kw};function ww(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 kw(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"),Ie(c)?Ae(e,l,"lineSuffix")(c):l(c))}function l(c){return c===null||xe(c)?(e.exit("setextHeadingLine"),t(c)):n(c)}}const Sw={tokenize:_w};function _w(e){const t=this,n=e.attempt(li,r,e.attempt(this.parser.constructs.flowInitial,i,Ae(e,e.attempt(this.parser.constructs.flow,i,e.attempt(Iv,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 jw={resolveAll:Vf()},Cw=Bf("string"),Nw=Bf("text");function Bf(e){return{resolveAll:Vf(e==="text"?Ew: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 p=-1;if(d)for(;++p<d.length;){const h=d[p];if(!h.previous||h.previous.call(r,r.previous))return!0}return!1}}}function Vf(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 Ew(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 Iw={42:ht,43:ht,45:ht,48:ht,49:ht,50:ht,51:ht,52:ht,53:ht,54:ht,55:ht,56:ht,57:ht,62:Df},Tw={91:Ov},zw={[-2]:Bs,[-1]:Bs,32:Bs},Aw={35:Lv,42:Ii,45:[Dl,Ii],60:Uv,61:Dl,95:Ii,96:Pl,126:Pl},Pw={38:Mf,92:Rf},Ow={[-5]:Vs,[-4]:Vs,[-3]:Vs,33:lw,38:Mf,42:_a,60:[cv,Yv],91:cw,92:[$v,Rf],93:po,95:_a,96:Sv},Dw={null:[_a,jw]},Rw={null:[42,95]},Mw={null:[]},$w=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:Rw,contentInitial:Tw,disable:Mw,document:Iw,flow:Aw,flowInitial:zw,insideSpan:Dw,string:Pw,text:Ow},Symbol.toStringTag,{value:"Module"}));function Fw(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:N(E),check:N(w),consume:_,enter:m,exit:I,interrupt:N(w,{interrupt:!0})},c={code:null,containerState:{},defineSkip:v,events:[],now:g,parser:e,previous:null,sliceSerialize:p,sliceStream:h,write:d};let f=t.tokenize.call(c,l);return t.resolveAll&&s.push(t),c;function d(T){return a=Et(a,T),S(),a[a.length-1]!==null?[]:(O(t,0),c.events=bs(s,c.events,c),c.events)}function p(T,A){return Zw(h(T),A)}function h(T){return Lw(a,T)}function g(){const{_bufferIndex:T,_index:A,line:F,column:R,offset:L}=r;return{_bufferIndex:T,_index:A,line:F,column:R,offset:L}}function v(T){i[T.line]=T.column,C()}function S(){let T;for(;r._index<a.length;){const A=a[r._index];if(typeof A=="string")for(T=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===T&&r._bufferIndex<A.length;)x(A.charCodeAt(r._bufferIndex));else x(A)}}function x(T){f=f(T)}function _(T){xe(T)?(r.line++,r.column=1,r.offset+=T===-3?2:1,C()):T!==-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=T}function m(T,A){const F=A||{};return F.type=T,F.start=g(),c.events.push(["enter",F,c]),o.push(F),F}function I(T){const A=o.pop();return A.end=g(),c.events.push(["exit",A,c]),A}function E(T,A){O(T,A.from)}function w(T,A){A.restore()}function N(T,A){return F;function F(R,L,P){let V,U,se,k;return Array.isArray(R)?q(R):"tokenize"in R?q([R]):le(R);function le(ie){return te;function te(X){const fe=X!==null&&ie[X],be=X!==null&&ie.null,ne=[...Array.isArray(fe)?fe:fe?[fe]:[],...Array.isArray(be)?be:be?[be]:[]];return q(ne)(X)}}function q(ie){return V=ie,U=0,ie.length===0?P:y(ie[U])}function y(ie){return te;function te(X){return k=K(),se=ie,ie.partial||(c.currentConstruct=ie),ie.name&&c.parser.constructs.disable.null.includes(ie.name)?B():ie.tokenize.call(A?Object.assign(Object.create(c),A):c,l,W,B)(X)}}function W(ie){return T(se,k),L}function B(ie){return k.restore(),++U<V.length?y(V[U]):P}}}function O(T,A){T.resolveAll&&!s.includes(T)&&s.push(T),T.resolve&&_t(c.events,A,c.events.length-A,T.resolve(c.events.slice(A),c)),T.resolveTo&&(c.events=T.resolveTo(c.events,c))}function K(){const T=g(),A=c.previous,F=c.currentConstruct,R=c.events.length,L=Array.from(o);return{from:R,restore:P};function P(){r=T,c.previous=A,c.currentConstruct=F,c.events.length=R,o=L,C()}}function C(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function Lw(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 Zw(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=`
|
|
4
|
+
`;break}case-3:{a=`\r
|
|
5
|
+
`;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 Bw(e){const r={constructs:Pf([$w,...(e||{}).extensions||[]]),content:i(rv),defined:[],document:i(sv),flow:i(Sw),lazy:{},string:i(Cw),text:i(Nw)};return r;function i(s){return a;function a(o){return Fw(r,s,o)}}}function Vw(e){for(;!$f(e););return e}const Rl=/[\0\t\n\r]/g;function Uw(){let e=1,t="",n=!0,r;return i;function i(s,a,o){const l=[];let c,f,d,p,h;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(Rl.lastIndex=d,c=Rl.exec(s),p=c&&c.index!==void 0?c.index:s.length,h=s.charCodeAt(p),!c){t=s.slice(d);break}if(h===10&&d===p&&r)l.push(-3),r=void 0;else switch(r&&(l.push(-5),r=void 0),d<p&&(l.push(s.slice(d,p)),e+=p-d),h){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=p+1}return o&&(r&&l.push(-5),t&&l.push(t),l.push(null)),l}}const Jw=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Hw(e){return e.replace(Jw,Ww)}function Ww(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),s=i===120||i===88;return Of(n.slice(s?2:1),s?16:10)}return fo(n)||e}const Uf={}.hasOwnProperty;function qw(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),Gw(n)(Vw(Bw(n).document().write(Uw()(e,t,!0))))}function Gw(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(z),autolinkProtocol:K,autolinkEmail:K,atxHeading:s(ke),blockQuote:s(be),characterEscape:K,characterReference:K,codeFenced:s(ne),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:s(ne,a),codeText:s(de,a),codeTextData:K,data:K,codeFlowValue:K,definition:s(ue),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:s(Z),hardBreakEscape:s(me),hardBreakTrailing:s(me),htmlFlow:s(De,a),htmlFlowData:K,htmlText:s(De,a),htmlTextData:K,image:s(j),label:a,link:s(z),listItem:s(re),listItemValue:p,listOrdered:s(M,d),listUnordered:s(M),paragraph:s(ee),reference:y,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:s(ke),strong:s(Q),thematicBreak:s(we)},exit:{atxHeading:l(),atxHeadingSequence:E,autolink:l(),autolinkEmail:fe,autolinkProtocol:X,blockQuote:l(),characterEscapeValue:C,characterReferenceMarkerHexadecimal:B,characterReferenceMarkerNumeric:B,characterReferenceValue:ie,characterReference:te,codeFenced:l(S),codeFencedFence:v,codeFencedFenceInfo:h,codeFencedFenceMeta:g,codeFlowValue:C,codeIndented:l(x),codeText:l(L),codeTextData:C,data:C,definition:l(),definitionDestinationString:I,definitionLabelString:_,definitionTitleString:m,emphasis:l(),hardBreakEscape:l(A),hardBreakTrailing:l(A),htmlFlow:l(F),htmlFlowData:C,htmlText:l(R),htmlTextData:C,image:l(V),label:se,labelText:U,lineEnding:T,link:l(P),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:W,resourceDestinationString:k,resourceTitleString:le,resource:q,setextHeading:l(O),setextHeadingLineSequence:N,setextHeadingText:w,strong:l(),thematicBreak:l()}};Jf(t,(e||{}).mdastExtensions||[]);const n={};return r;function r($){let G={type:"root",children:[]};const he={stack:[G],tokenStack:[],config:t,enter:o,exit:c,buffer:a,resume:f,data:n},je=[];let D=-1;for(;++D<$.length;)if($[D][1].type==="listOrdered"||$[D][1].type==="listUnordered")if($[D][0]==="enter")je.push(D);else{const ge=je.pop();D=i($,ge,D)}for(D=-1;++D<$.length;){const ge=t[$[D][0]];Uf.call(ge,$[D][1].type)&&ge[$[D][1].type].call(Object.assign({sliceSerialize:$[D][2].sliceSerialize},he),$[D][1])}if(he.tokenStack.length>0){const ge=he.tokenStack[he.tokenStack.length-1];(ge[1]||Ml).call(he,void 0,ge[0])}for(G.position={start:an($.length>0?$[0][1].start:{line:1,column:1,offset:0}),end:an($.length>0?$[$.length-2][1].end:{line:1,column:1,offset:0})},D=-1;++D<t.transforms.length;)G=t.transforms[D](G)||G;return G}function i($,G,he){let je=G-1,D=-1,ge=!1,Te,Le,nt,et;for(;++je<=he;){const it=$[je];switch(it[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{it[0]==="enter"?D++:D--,et=void 0;break}case"lineEndingBlank":{it[0]==="enter"&&(Te&&!et&&!D&&!nt&&(nt=je),et=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:et=void 0}if(!D&&it[0]==="enter"&&it[1].type==="listItemPrefix"||D===-1&&it[0]==="exit"&&(it[1].type==="listUnordered"||it[1].type==="listOrdered")){if(Te){let rn=je;for(Le=void 0;rn--;){const Kt=$[rn];if(Kt[1].type==="lineEnding"||Kt[1].type==="lineEndingBlank"){if(Kt[0]==="exit")continue;Le&&($[Le][1].type="lineEndingBlank",ge=!0),Kt[1].type="lineEnding",Le=rn}else if(!(Kt[1].type==="linePrefix"||Kt[1].type==="blockQuotePrefix"||Kt[1].type==="blockQuotePrefixWhitespace"||Kt[1].type==="blockQuoteMarker"||Kt[1].type==="listItemIndent"))break}nt&&(!Le||nt<Le)&&(Te._spread=!0),Te.end=Object.assign({},Le?$[Le][1].start:it[1].end),$.splice(Le||je,0,["exit",Te,it[2]]),je++,he++}if(it[1].type==="listItemPrefix"){const rn={type:"listItem",_spread:!1,start:Object.assign({},it[1].start),end:void 0};Te=rn,$.splice(je,0,["enter",rn,it[2]]),je++,he++,nt=void 0,et=!0}}}return $[G][1]._spread=ge,he}function s($,G){return he;function he(je){o.call(this,$(je),je),G&&G.call(this,je)}}function a(){this.stack.push({type:"fragment",children:[]})}function o($,G,he){this.stack[this.stack.length-1].children.push($),this.stack.push($),this.tokenStack.push([G,he||void 0]),$.position={start:an(G.start),end:void 0}}function l($){return G;function G(he){$&&$.call(this,he),c.call(this,he)}}function c($,G){const he=this.stack.pop(),je=this.tokenStack.pop();if(je)je[0].type!==$.type&&(G?G.call(this,$,je[0]):(je[1]||Ml).call(this,$,je[0]));else throw new Error("Cannot close `"+$.type+"` ("+Rr({start:$.start,end:$.end})+"): it’s not open");he.position.end=an($.end)}function f(){return co(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function p($){if(this.data.expectingFirstListItemValue){const G=this.stack[this.stack.length-2];G.start=Number.parseInt(this.sliceSerialize($),10),this.data.expectingFirstListItemValue=void 0}}function h(){const $=this.resume(),G=this.stack[this.stack.length-1];G.lang=$}function g(){const $=this.resume(),G=this.stack[this.stack.length-1];G.meta=$}function v(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function S(){const $=this.resume(),G=this.stack[this.stack.length-1];G.value=$.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function x(){const $=this.resume(),G=this.stack[this.stack.length-1];G.value=$.replace(/(\r?\n|\r)$/g,"")}function _($){const G=this.resume(),he=this.stack[this.stack.length-1];he.label=G,he.identifier=Mt(this.sliceSerialize($)).toLowerCase()}function m(){const $=this.resume(),G=this.stack[this.stack.length-1];G.title=$}function I(){const $=this.resume(),G=this.stack[this.stack.length-1];G.url=$}function E($){const G=this.stack[this.stack.length-1];if(!G.depth){const he=this.sliceSerialize($).length;G.depth=he}}function w(){this.data.setextHeadingSlurpLineEnding=!0}function N($){const G=this.stack[this.stack.length-1];G.depth=this.sliceSerialize($).codePointAt(0)===61?1:2}function O(){this.data.setextHeadingSlurpLineEnding=void 0}function K($){const he=this.stack[this.stack.length-1].children;let je=he[he.length-1];(!je||je.type!=="text")&&(je=pe(),je.position={start:an($.start),end:void 0},he.push(je)),this.stack.push(je)}function C($){const G=this.stack.pop();G.value+=this.sliceSerialize($),G.position.end=an($.end)}function T($){const G=this.stack[this.stack.length-1];if(this.data.atHardBreak){const he=G.children[G.children.length-1];he.position.end=an($.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(G.type)&&(K.call(this,$),C.call(this,$))}function A(){this.data.atHardBreak=!0}function F(){const $=this.resume(),G=this.stack[this.stack.length-1];G.value=$}function R(){const $=this.resume(),G=this.stack[this.stack.length-1];G.value=$}function L(){const $=this.resume(),G=this.stack[this.stack.length-1];G.value=$}function P(){const $=this.stack[this.stack.length-1];if(this.data.inReference){const G=this.data.referenceType||"shortcut";$.type+="Reference",$.referenceType=G,delete $.url,delete $.title}else delete $.identifier,delete $.label;this.data.referenceType=void 0}function V(){const $=this.stack[this.stack.length-1];if(this.data.inReference){const G=this.data.referenceType||"shortcut";$.type+="Reference",$.referenceType=G,delete $.url,delete $.title}else delete $.identifier,delete $.label;this.data.referenceType=void 0}function U($){const G=this.sliceSerialize($),he=this.stack[this.stack.length-2];he.label=Hw(G),he.identifier=Mt(G).toLowerCase()}function se(){const $=this.stack[this.stack.length-1],G=this.resume(),he=this.stack[this.stack.length-1];if(this.data.inReference=!0,he.type==="link"){const je=$.children;he.children=je}else he.alt=G}function k(){const $=this.resume(),G=this.stack[this.stack.length-1];G.url=$}function le(){const $=this.resume(),G=this.stack[this.stack.length-1];G.title=$}function q(){this.data.inReference=void 0}function y(){this.data.referenceType="collapsed"}function W($){const G=this.resume(),he=this.stack[this.stack.length-1];he.label=G,he.identifier=Mt(this.sliceSerialize($)).toLowerCase(),this.data.referenceType="full"}function B($){this.data.characterReferenceType=$.type}function ie($){const G=this.sliceSerialize($),he=this.data.characterReferenceType;let je;he?(je=Of(G,he==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):je=fo(G);const D=this.stack[this.stack.length-1];D.value+=je}function te($){const G=this.stack.pop();G.position.end=an($.end)}function X($){C.call(this,$);const G=this.stack[this.stack.length-1];G.url=this.sliceSerialize($)}function fe($){C.call(this,$);const G=this.stack[this.stack.length-1];G.url="mailto:"+this.sliceSerialize($)}function be(){return{type:"blockquote",children:[]}}function ne(){return{type:"code",lang:null,meta:null,value:""}}function de(){return{type:"inlineCode",value:""}}function ue(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Z(){return{type:"emphasis",children:[]}}function ke(){return{type:"heading",depth:0,children:[]}}function me(){return{type:"break"}}function De(){return{type:"html",value:""}}function j(){return{type:"image",title:null,url:"",alt:null}}function z(){return{type:"link",title:null,url:"",children:[]}}function M($){return{type:"list",ordered:$.type==="listOrdered",start:null,spread:$._spread,children:[]}}function re($){return{type:"listItem",spread:$._spread,checked:null,children:[]}}function ee(){return{type:"paragraph",children:[]}}function Q(){return{type:"strong",children:[]}}function pe(){return{type:"text",value:""}}function we(){return{type:"thematicBreak"}}}function an(e){return{line:e.line,column:e.column,offset:e.offset}}function Jf(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?Jf(e,r):Kw(e,r)}}function Kw(e,t){let n;for(n in t)if(Uf.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 Ml(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+Rr({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Rr({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+Rr({start:t.start,end:t.end})+") is still open")}function Yw(e){const t=this;t.parser=n;function n(r){return qw(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function Xw(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 Qw(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
|
|
6
|
+
`}]}function e0(e,t){const n=t.value?t.value+`
|
|
7
|
+
`:"",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 t0(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function n0(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function r0(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),i=hr(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 i0(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 s0(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function Hf(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 a0(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Hf(e,t);const i={src:hr(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 o0(e,t){const n={src:hr(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 l0(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 u0(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Hf(e,t);const i={href:hr(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 c0(e,t){const n={href:hr(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 d0(e,t,n){const r=e.all(t),i=n?f0(n):Wf(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:`
|
|
8
|
+
`}),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:`
|
|
9
|
+
`});const c={type:"element",tagName:"li",properties:s,children:a};return e.patch(t,c),e.applyData(t,c)}function f0(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=Wf(n[r])}return t}function Wf(e){const t=e.spread;return t??e.children.length>1}function p0(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 h0(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function m0(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function g0(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function x0(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=ao(t.children[1]),l=Cf(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 y0(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],p={},h=a?a[l]:void 0;h&&(p.align=h);let g={type:"element",tagName:s,properties:p,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 b0(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const $l=9,Fl=32;function v0(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),i=0;const s=[];for(;r;)s.push(Ll(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return s.push(Ll(t.slice(i),i>0,!1)),s.join("")}function Ll(e,t,n){let r=0,i=e.length;if(t){let s=e.codePointAt(r);for(;s===$l||s===Fl;)r++,s=e.codePointAt(r)}if(n){let s=e.codePointAt(i-1);for(;s===$l||s===Fl;)i--,s=e.codePointAt(i-1)}return i>r?e.slice(r,i):""}function w0(e,t){const n={type:"text",value:v0(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function k0(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const S0={blockquote:Xw,break:Qw,code:e0,delete:t0,emphasis:n0,footnoteReference:r0,heading:i0,html:s0,imageReference:a0,image:o0,inlineCode:l0,linkReference:u0,link:c0,listItem:d0,list:p0,paragraph:h0,root:m0,strong:g0,table:x0,tableCell:b0,tableRow:y0,text:w0,thematicBreak:k0,toml:yi,yaml:yi,definition:yi,footnoteDefinition:yi};function yi(){}const qf=-1,vs=0,$r=1,Ji=2,ho=3,mo=4,go=5,xo=6,Gf=7,Kf=8,Zl=typeof self=="object"?self:globalThis,_0=(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 vs:case qf:return n(a,i);case $r:{const o=n([],i);for(const l of a)o.push(r(l));return o}case Ji:{const o=n({},i);for(const[l,c]of a)o[r(l)]=r(c);return o}case ho:return n(new Date(a),i);case mo:{const{source:o,flags:l}=a;return n(new RegExp(o,l),i)}case go:{const o=n(new Map,i);for(const[l,c]of a)o.set(r(l),r(c));return o}case xo:{const o=n(new Set,i);for(const l of a)o.add(r(l));return o}case Gf:{const{name:o,message:l}=a;return n(new Zl[o](l),i)}case Kf: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 Zl[s](a),i)};return r},Bl=e=>_0(new Map,e)(0),Zn="",{toString:j0}={},{keys:C0}=Object,_r=e=>{const t=typeof e;if(t!=="object"||!e)return[vs,t];const n=j0.call(e).slice(8,-1);switch(n){case"Array":return[$r,Zn];case"Object":return[Ji,Zn];case"Date":return[ho,Zn];case"RegExp":return[mo,Zn];case"Map":return[go,Zn];case"Set":return[xo,Zn];case"DataView":return[$r,n]}return n.includes("Array")?[$r,n]:n.includes("Error")?[Gf,n]:[Ji,n]},bi=([e,t])=>e===vs&&(t==="function"||t==="symbol"),N0=(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]=_r(a);switch(o){case vs:{let f=a;switch(l){case"bigint":o=Kf,f=a.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+l);f=null;break;case"undefined":return i([qf],a)}return i([o,f],a)}case $r:{if(l){let p=a;return l==="DataView"?p=new Uint8Array(a.buffer):l==="ArrayBuffer"&&(p=new Uint8Array(a)),i([l,[...p]],a)}const f=[],d=i([o,f],a);for(const p of a)f.push(s(p));return d}case Ji:{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 p of C0(a))(e||!bi(_r(a[p])))&&f.push([s(p),s(a[p])]);return d}case ho:return i([o,a.toISOString()],a);case mo:{const{source:f,flags:d}=a;return i([o,{source:f,flags:d}],a)}case go:{const f=[],d=i([o,f],a);for(const[p,h]of a)(e||!(bi(_r(p))||bi(_r(h))))&&f.push([s(p),s(h)]);return d}case xo:{const f=[],d=i([o,f],a);for(const p of a)(e||!bi(_r(p)))&&f.push(s(p));return d}}const{message:c}=a;return i([o,{name:l,message:c}],a)};return s},Vl=(e,{json:t,lossy:n}={})=>{const r=[];return N0(!(t||n),!!t,new Map,r)(e),r},Hi=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?Bl(Vl(e,t)):structuredClone(e):(e,t)=>Bl(Vl(e,t));function E0(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 I0(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function T0(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||E0,r=e.options.footnoteBackLabel||I0,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(),p=hr(d.toLowerCase());let h=0;const g=[],v=e.footnoteCounts.get(d);for(;v!==void 0&&++h<=v;){g.length>0&&g.push({type:"text",value:" "});let _=typeof n=="string"?n:n(l,h);typeof _=="string"&&(_={type:"text",value:_}),g.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+p+(h>1?"-"+h:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(l,h),className:["data-footnote-backref"]},children:Array.isArray(_)?_:[_]})}const S=f[f.length-1];if(S&&S.type==="element"&&S.tagName==="p"){const _=S.children[S.children.length-1];_&&_.type==="text"?_.value+=" ":S.children.push({type:"text",value:" "}),S.children.push(...g)}else f.push(...g);const x={type:"element",tagName:"li",properties:{id:t+"fn-"+p},children:e.wrap(f,!0)};e.patch(c,x),o.push(x)}if(o.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:s,properties:{...Hi(a),id:"footnote-label"},children:[{type:"text",value:i}]},{type:"text",value:`
|
|
10
|
+
`},{type:"element",tagName:"ol",properties:{},children:e.wrap(o,!0)},{type:"text",value:`
|
|
11
|
+
`}]}}const ws=function(e){if(e==null)return O0;if(typeof e=="function")return ks(e);if(typeof e=="object")return Array.isArray(e)?z0(e):A0(e);if(typeof e=="string")return P0(e);throw new Error("Expected function, string, or object as test")};function z0(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=ws(e[n]);return ks(r);function r(...i){let s=-1;for(;++s<t.length;)if(t[s].apply(this,i))return!0;return!1}}function A0(e){const t=e;return ks(n);function n(r){const i=r;let s;for(s in e)if(i[s]!==t[s])return!1;return!0}}function P0(e){return ks(t);function t(n){return n&&n.type===e}}function ks(e){return t;function t(n,r,i){return!!(D0(n)&&e.call(this,n,typeof r=="number"?r:void 0,i||void 0))}}function O0(){return!0}function D0(e){return e!==null&&typeof e=="object"&&"type"in e}const Yf=[],R0=!0,ja=!1,M0="skip";function Xf(e,t,n,r){let i;typeof t=="function"&&typeof n!="function"?(r=n,n=t):i=t;const s=ws(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 h=typeof d.tagName=="string"?d.tagName:typeof d.name=="string"?d.name:void 0;Object.defineProperty(p,"name",{value:"node ("+(l.type+(h?"<"+h+">":""))+")"})}return p;function p(){let h=Yf,g,v,S;if((!t||s(l,c,f[f.length-1]||void 0))&&(h=$0(n(l,f)),h[0]===ja))return h;if("children"in l&&l.children){const x=l;if(x.children&&h[0]!==M0)for(v=(r?x.children.length:-1)+a,S=f.concat(x);v>-1&&v<x.children.length;){const _=x.children[v];if(g=o(_,v,S)(),g[0]===ja)return g;v=typeof g[1]=="number"?g[1]:v+a}}return h}}}function $0(e){return Array.isArray(e)?e:typeof e=="number"?[R0,e]:e==null?Yf:[e]}function yo(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),Xf(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 Ca={}.hasOwnProperty,F0={};function L0(e,t){const n=t||F0,r=new Map,i=new Map,s=new Map,a={...S0,...n.handlers},o={all:c,applyData:B0,definitionById:r,footnoteById:i,footnoteCounts:s,footnoteOrder:[],handlers:a,one:l,options:n,patch:Z0,wrap:U0};return yo(e,function(f){if(f.type==="definition"||f.type==="footnoteDefinition"){const d=f.type==="definition"?r:i,p=String(f.identifier).toUpperCase();d.has(p)||d.set(p,f)}}),o;function l(f,d){const p=f.type,h=o.handlers[p];if(Ca.call(o.handlers,p)&&h)return h(o,f,d);if(o.options.passThrough&&o.options.passThrough.includes(p)){if("children"in f){const{children:v,...S}=f,x=Hi(S);return x.children=o.all(f),x}return Hi(f)}return(o.options.unknownHandler||V0)(o,f,d)}function c(f){const d=[];if("children"in f){const p=f.children;let h=-1;for(;++h<p.length;){const g=o.one(p[h],f);if(g){if(h&&p[h-1].type==="break"&&(!Array.isArray(g)&&g.type==="text"&&(g.value=Ul(g.value)),!Array.isArray(g)&&g.type==="element")){const v=g.children[0];v&&v.type==="text"&&(v.value=Ul(v.value))}Array.isArray(g)?d.push(...g):d.push(g)}}}return d}}function Z0(e,t){e.position&&(t.position=Ib(e))}function B0(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,Hi(s)),"children"in n&&n.children&&i!==null&&i!==void 0&&(n.children=i)}return n}function V0(e,t){const n=t.data||{},r="value"in t&&!(Ca.call(n,"hProperties")||Ca.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 U0(e,t){const n=[];let r=-1;for(t&&n.push({type:"text",value:`
|
|
12
|
+
`});++r<e.length;)r&&n.push({type:"text",value:`
|
|
13
|
+
`}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:`
|
|
14
|
+
`}),n}function Ul(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function Jl(e,t){const n=L0(e,t),r=n.one(e,void 0),i=T0(n),s=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return i&&s.children.push({type:"text",value:`
|
|
15
|
+
`},i),s}function J0(e,t){return e&&"run"in e?async function(n,r){const i=Jl(n,{file:r,...t});await e.run(i,r)}:function(n,r){return Jl(n,{file:r,...e||t})}}function Hl(e){if(e)throw e}var Us,Wl;function H0(){if(Wl)return Us;Wl=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 p;for(p in c);return typeof p>"u"||e.call(c,p)},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 Us=function l(){var c,f,d,p,h,g,v=arguments[0],S=1,x=arguments.length,_=!1;for(typeof v=="boolean"&&(_=v,v=arguments[1]||{},S=2),(v==null||typeof v!="object"&&typeof v!="function")&&(v={});S<x;++S)if(c=arguments[S],c!=null)for(f in c)d=o(v,f),p=o(c,f),v!==p&&(_&&p&&(s(p)||(h=i(p)))?(h?(h=!1,g=d&&i(d)?d:[]):g=d&&s(d)?d:{},a(v,{name:f,newValue:l(_,g,p)})):typeof p<"u"&&a(v,{name:f,newValue:p}));return v},Us}var W0=H0();const Js=Za(W0);function Na(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function q0(){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?G0(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 G0(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 Lt={basename:K0,dirname:Y0,extname:X0,join:Q0,sep:"/"};function K0(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');ui(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 Y0(e){if(ui(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 X0(e){ui(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 Q0(...e){let t=-1,n;for(;++t<e.length;)ui(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":ek(n)}function ek(e){ui(e);const t=e.codePointAt(0)===47;let n=tk(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function tk(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 ui(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const nk={cwd:rk};function rk(){return"/"}function Ea(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function ik(e){if(typeof e=="string")e=new URL(e);else if(!Ea(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 sk(e)}function sk(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 Hs=["history","path","basename","stem","extname","dirname"];class Qf{constructor(t){let n;t?Ea(t)?n={path:t}:typeof t=="string"||ak(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":nk.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<Hs.length;){const s=Hs[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)Hs.includes(i)||(this[i]=n[i])}get basename(){return typeof this.path=="string"?Lt.basename(this.path):void 0}set basename(t){qs(t,"basename"),Ws(t,"basename"),this.path=Lt.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Lt.dirname(this.path):void 0}set dirname(t){ql(this.basename,"dirname"),this.path=Lt.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Lt.extname(this.path):void 0}set extname(t){if(Ws(t,"extname"),ql(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=Lt.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){Ea(t)&&(t=ik(t)),qs(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Lt.basename(this.path,this.extname):void 0}set stem(t){qs(t,"stem"),Ws(t,"stem"),this.path=Lt.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 at(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 Ws(e,t){if(e&&e.includes(Lt.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Lt.sep+"`")}function qs(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function ql(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function ak(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const ok=function(e){const r=this.constructor.prototype,i=r[e],s=function(){return i.apply(s,arguments)};return Object.setPrototypeOf(s,r),s},lk={}.hasOwnProperty;class bo extends ok{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=q0()}copy(){const t=new bo;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(Js(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(Ys("data",this.frozen),this.namespace[t]=n,this):lk.call(this.namespace,t)&&this.namespace[t]||void 0:t?(Ys("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=vi(t),r=this.parser||this.Parser;return Gs("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),Gs("process",this.parser||this.Parser),Ks("process",this.compiler||this.Compiler),n?i(void 0,n):new Promise(i);function i(s,a){const o=vi(t),l=r.parse(o);r.run(l,o,function(f,d,p){if(f||!d||!p)return c(f);const h=d,g=r.stringify(h,p);dk(g)?p.value=g:p.result=g,c(f,p)});function c(f,d){f||!d?a(f):s?s(d):n(void 0,d)}}}processSync(t){let n=!1,r;return this.freeze(),Gs("processSync",this.parser||this.Parser),Ks("processSync",this.compiler||this.Compiler),this.process(t,i),Kl("processSync","process",n),r;function i(s,a){n=!0,Hl(s),r=a}}run(t,n,r){Gl(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=vi(n);i.run(t,l,c);function c(f,d,p){const h=d||t;f?o(f):a?a(h):r(void 0,h,p)}}}runSync(t,n){let r=!1,i;return this.run(t,n,s),Kl("runSync","run",r),i;function s(a,o){Hl(a),i=o,r=!0}}stringify(t,n){this.freeze();const r=vi(n),i=this.compiler||this.Compiler;return Ks("stringify",i),Gl(t),i(t,r)}use(t,...n){const r=this.attachers,i=this.namespace;if(Ys("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=Js(!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,p=-1;for(;++d<r.length;)if(r[d][0]===c){p=d;break}if(p===-1)r.push([c,...f]);else if(f.length>0){let[h,...g]=f;const v=r[p][1];Na(v)&&Na(h)&&(h=Js(!0,v,h)),r[p]=[c,h,...g]}}}}const uk=new bo().freeze();function Gs(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Ks(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Ys(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 Gl(e){if(!Na(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function Kl(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function vi(e){return ck(e)?e:new Qf(e)}function ck(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function dk(e){return typeof e=="string"||fk(e)}function fk(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const pk="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",Yl=[],Xl={allowDangerousHtml:!0},hk=/^(https?|ircs?|mailto|xmpp)$/i,mk=[{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 gk(e){const t=xk(e),n=yk(e);return bk(t.runSync(t.parse(n),n),e)}function xk(e){const t=e.rehypePlugins||Yl,n=e.remarkPlugins||Yl,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...Xl}:Xl;return uk().use(Yw).use(n).use(J0,r).use(t)}function yk(e){const t=e.children||"",n=new Qf;return typeof t=="string"&&(n.value=t),n}function bk(e,t){const n=t.allowedElements,r=t.allowElement,i=t.components,s=t.disallowedElements,a=t.skipHtml,o=t.unwrapDisallowed,l=t.urlTransform||vk;for(const f of mk)Object.hasOwn(t,f.from)&&(""+f.from+(f.to?"use `"+f.to+"` instead":"remove it")+pk+f.id,void 0);return yo(e,c),Ob(e,{Fragment:u.Fragment,components:i,ignoreInvalidStyle:!0,jsx:u.jsx,jsxs:u.jsxs,passKeys:!0,passNode:!0});function c(f,d,p){if(f.type==="raw"&&p&&typeof d=="number")return a?p.children.splice(d,1):p.children[d]={type:"text",value:f.value},d;if(f.type==="element"){let h;for(h in Zs)if(Object.hasOwn(Zs,h)&&Object.hasOwn(f.properties,h)){const g=f.properties[h],v=Zs[h];(v===null||v.includes(f.tagName))&&(f.properties[h]=l(String(g||""),h,f))}}if(f.type==="element"){let h=n?!n.includes(f.tagName):s?s.includes(f.tagName):!1;if(!h&&r&&typeof d=="number"&&(h=!r(f,d,p)),h&&p&&typeof d=="number")return o&&f.children?p.children.splice(d,1,...f.children):p.children.splice(d,1),d}}}function vk(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||hk.test(e.slice(0,t))?e:""}function Ql(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 wk(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function kk(e,t,n){const i=ws((n||{}).ignore||[]),s=Sk(t);let a=-1;for(;++a<s.length;)Xf(e,"text",o);function o(c,f){let d=-1,p;for(;++d<f.length;){const h=f[d],g=p?p.children:void 0;if(i(h,g?g.indexOf(h):void 0,p))return;p=h}if(p)return l(c,f)}function l(c,f){const d=f[f.length-1],p=s[a][0],h=s[a][1];let g=0;const S=d.children.indexOf(c);let x=!1,_=[];p.lastIndex=0;let m=p.exec(c.value);for(;m;){const I=m.index,E={index:m.index,input:m.input,stack:[...f,c]};let w=h(...m,E);if(typeof w=="string"&&(w=w.length>0?{type:"text",value:w}:void 0),w===!1?p.lastIndex=I+1:(g!==I&&_.push({type:"text",value:c.value.slice(g,I)}),Array.isArray(w)?_.push(...w):w&&_.push(w),g=I+m[0].length,x=!0),!p.global)break;m=p.exec(c.value)}return x?(g<c.value.length&&_.push({type:"text",value:c.value.slice(g)}),d.children.splice(S,1,..._)):_=[c],S+_.length}}function Sk(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([_k(i[0]),jk(i[1])])}return t}function _k(e){return typeof e=="string"?new RegExp(wk(e),"g"):e}function jk(e){return typeof e=="function"?e:function(){return e}}const Xs="phrasing",Qs=["autolink","link","image","label"];function Ck(){return{transforms:[Pk],enter:{literalAutolink:Ek,literalAutolinkEmail:ea,literalAutolinkHttp:ea,literalAutolinkWww:ea},exit:{literalAutolink:Ak,literalAutolinkEmail:zk,literalAutolinkHttp:Ik,literalAutolinkWww:Tk}}}function Nk(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:Xs,notInConstruct:Qs},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:Xs,notInConstruct:Qs},{character:":",before:"[ps]",after:"\\/",inConstruct:Xs,notInConstruct:Qs}]}}function Ek(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function ea(e){this.config.enter.autolinkProtocol.call(this,e)}function Ik(e){this.config.exit.autolinkProtocol.call(this,e)}function Tk(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 zk(e){this.config.exit.autolinkEmail.call(this,e)}function Ak(e){this.exit(e)}function Pk(e){kk(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,Ok],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),Dk]],{ignore:["link","linkReference"]})}function Ok(e,t,n,r,i){let s="";if(!ep(i)||(/^w/i.test(t)&&(n=t+n,t="",s="http://"),!Rk(n)))return!1;const a=Mk(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 Dk(e,t,n,r){return!ep(r,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function Rk(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 Mk(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=Ql(e,"(");let s=Ql(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 ep(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||An(n)||ys(n))&&(!t||n!==47)}tp.peek=Hk;function $k(){this.buffer()}function Fk(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function Lk(){this.buffer()}function Zk(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function Bk(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Mt(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Vk(e){this.exit(e)}function Uk(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Mt(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Jk(e){this.exit(e)}function Hk(){return"["}function tp(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 Wk(){return{enter:{gfmFootnoteCallString:$k,gfmFootnoteCall:Fk,gfmFootnoteDefinitionLabelString:Lk,gfmFootnoteDefinition:Zk},exit:{gfmFootnoteCallString:Bk,gfmFootnoteCall:Vk,gfmFootnoteDefinitionLabelString:Uk,gfmFootnoteDefinition:Jk}}}function qk(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:tp},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?`
|
|
16
|
+
`:" ")+s.indentLines(s.containerFlow(r,o.current()),t?np:Gk))),c(),l}}function Gk(e,t,n){return t===0?e:np(e,t,n)}function np(e,t,n){return(n?"":" ")+e}const Kk=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];rp.peek=tS;function Yk(){return{canContainEols:["delete"],enter:{strikethrough:Qk},exit:{strikethrough:eS}}}function Xk(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:Kk}],handlers:{delete:rp}}}function Qk(e){this.enter({type:"delete",children:[]},e)}function eS(e){this.exit(e)}function rp(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 tS(){return"~"}function nS(e){return e.length}function rS(e,t){const n=t||{},r=(n.align||[]).concat(),i=n.stringLength||nS,s=[],a=[],o=[],l=[];let c=0,f=-1;for(;++f<e.length;){const v=[],S=[];let x=-1;for(e[f].length>c&&(c=e[f].length);++x<e[f].length;){const _=iS(e[f][x]);if(n.alignDelimiters!==!1){const m=i(_);S[x]=m,(l[x]===void 0||m>l[x])&&(l[x]=m)}v.push(_)}a[f]=v,o[f]=S}let d=-1;if(typeof r=="object"&&"length"in r)for(;++d<c;)s[d]=eu(r[d]);else{const v=eu(r);for(;++d<c;)s[d]=v}d=-1;const p=[],h=[];for(;++d<c;){const v=s[d];let S="",x="";v===99?(S=":",x=":"):v===108?S=":":v===114&&(x=":");let _=n.alignDelimiters===!1?1:Math.max(1,l[d]-S.length-x.length);const m=S+"-".repeat(_)+x;n.alignDelimiters!==!1&&(_=S.length+_+x.length,_>l[d]&&(l[d]=_),h[d]=_),p[d]=m}a.splice(1,0,p),o.splice(1,0,h),f=-1;const g=[];for(;++f<a.length;){const v=a[f],S=o[f];d=-1;const x=[];for(;++d<c;){const _=v[d]||"";let m="",I="";if(n.alignDelimiters!==!1){const E=l[d]-(S[d]||0),w=s[d];w===114?m=" ".repeat(E):w===99?E%2?(m=" ".repeat(E/2+.5),I=" ".repeat(E/2-.5)):(m=" ".repeat(E/2),I=m):I=" ".repeat(E)}n.delimiterStart!==!1&&!d&&x.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&_==="")&&(n.delimiterStart!==!1||d)&&x.push(" "),n.alignDelimiters!==!1&&x.push(m),x.push(_),n.alignDelimiters!==!1&&x.push(I),n.padding!==!1&&x.push(" "),(n.delimiterEnd!==!1||d!==c-1)&&x.push("|")}g.push(n.delimiterEnd===!1?x.join("").replace(/ +$/,""):x.join(""))}return g.join(`
|
|
17
|
+
`)}function iS(e){return e==null?"":String(e)}function eu(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 sS(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()),aS);return i(),a}function aS(e,t,n){return">"+(n?"":" ")+e}function oS(e,t){return tu(e,t.inConstruct,!0)&&!tu(e,t.notInConstruct,!1)}function tu(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 nu(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
|
|
18
|
+
`&&oS(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?"":" ";return`\\
|
|
19
|
+
`}function lS(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 uS(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 cS(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 dS(e,t,n,r){const i=cS(n),s=e.value||"",a=i==="`"?"GraveAccent":"Tilde";if(uS(e,n)){const d=n.enter("codeIndented"),p=n.indentLines(s,fS);return d(),p}const o=n.createTracker(r),l=i.repeat(Math.max(lS(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:`
|
|
20
|
+
`,encode:["`"],...o.current()})),d()}return f+=o.move(`
|
|
21
|
+
`),s&&(f+=o.move(s+`
|
|
22
|
+
`)),f+=o.move(l),c(),f}function fS(e,t,n){return(n?"":" ")+e}function vo(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 pS(e,t,n,r){const i=vo(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?" ":`
|
|
23
|
+
`,...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 hS(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 qr(e){return"&#x"+e.toString(16).toUpperCase()+";"}function Wi(e,t,n){const r=or(e),i=or(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}}ip.peek=mS;function ip(e,t,n,r){const i=hS(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=Wi(r.before.charCodeAt(r.before.length-1),c,i);f.inside&&(l=qr(c)+l.slice(1));const d=l.charCodeAt(l.length-1),p=Wi(r.after.charCodeAt(0),d,i);p.inside&&(l=l.slice(0,-1)+qr(d));const h=a.move(i);return s(),n.attentionEncodeSurroundingInfo={after:p.outside,before:f.outside},o+l+h}function mS(e,t,n){return n.options.emphasis||"*"}function gS(e,t){let n=!1;return yo(e,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return n=!0,ja}),!!((!e.depth||e.depth<3)&&co(e)&&(t.options.setext||n))}function xS(e,t,n,r){const i=Math.max(Math.min(6,e.depth||1),1),s=n.createTracker(r);if(gS(e,n)){const f=n.enter("headingSetext"),d=n.enter("phrasing"),p=n.containerPhrasing(e,{...s.current(),before:`
|
|
24
|
+
`,after:`
|
|
25
|
+
`});return d(),f(),p+`
|
|
26
|
+
`+(i===1?"=":"-").repeat(p.length-(Math.max(p.lastIndexOf("\r"),p.lastIndexOf(`
|
|
27
|
+
`))+1))}const a="#".repeat(i),o=n.enter("headingAtx"),l=n.enter("phrasing");s.move(a+" ");let c=n.containerPhrasing(e,{before:"# ",after:`
|
|
28
|
+
`,...s.current()});return/^[\t ]/.test(c)&&(c=qr(c.charCodeAt(0))+c.slice(1)),c=c?a+" "+c:a,n.options.closeAtx&&(c+=" "+a),l(),o(),c}sp.peek=yS;function sp(e){return e.value||""}function yS(){return"<"}ap.peek=bS;function ap(e,t,n,r){const i=vo(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 bS(){return"!"}op.peek=vS;function op(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 vS(){return"!"}lp.peek=wS;function lp(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 wS(){return"`"}function up(e,t){const n=co(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))}cp.peek=kS;function cp(e,t,n,r){const i=vo(n),s=i==='"'?"Quote":"Apostrophe",a=n.createTracker(r);let o,l;if(up(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 kS(e,t,n){return up(e,n)?"<":"["}dp.peek=SS;function dp(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 SS(){return"["}function wo(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 _S(e){const t=wo(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 jS(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 fp(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 CS(e,t,n,r){const i=n.enter("list"),s=n.bulletCurrent;let a=e.ordered?jS(n):wo(n);const o=e.ordered?a==="."?")":".":_S(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),fp(n)===a&&f){let d=-1;for(;++d<e.children.length;){const p=e.children[d];if(p&&p.type==="listItem"&&p.children&&p.children[0]&&p.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 NS(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 ES(e,t,n,r){const i=NS(n);let s=n.bulletCurrent||wo(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,p,h){return p?(h?"":" ".repeat(a))+d:(h?s:s+" ".repeat(a-s.length))+d}}function IS(e,t,n,r){const i=n.enter("paragraph"),s=n.enter("phrasing"),a=n.containerPhrasing(e,r);return s(),i(),a}const TS=ws(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function zS(e,t,n,r){return(e.children.some(function(a){return TS(a)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function AS(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}pp.peek=PS;function pp(e,t,n,r){const i=AS(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=Wi(r.before.charCodeAt(r.before.length-1),c,i);f.inside&&(l=qr(c)+l.slice(1));const d=l.charCodeAt(l.length-1),p=Wi(r.after.charCodeAt(0),d,i);p.inside&&(l=l.slice(0,-1)+qr(d));const h=a.move(i+i);return s(),n.attentionEncodeSurroundingInfo={after:p.outside,before:f.outside},o+l+h}function PS(e,t,n){return n.options.strong||"*"}function OS(e,t,n,r){return n.safe(e.value,r)}function DS(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 RS(e,t,n){const r=(fp(n)+(n.options.ruleSpaces?" ":"")).repeat(DS(n));return n.options.ruleSpaces?r.slice(0,-1):r}const hp={blockquote:sS,break:nu,code:dS,definition:pS,emphasis:ip,hardBreak:nu,heading:xS,html:sp,image:ap,imageReference:op,inlineCode:lp,link:cp,linkReference:dp,list:CS,listItem:ES,paragraph:IS,root:zS,strong:pp,text:OS,thematicBreak:RS};function MS(){return{enter:{table:$S,tableData:ru,tableHeader:ru,tableRow:LS},exit:{codeText:ZS,table:FS,tableData:ta,tableHeader:ta,tableRow:ta}}}function $S(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 FS(e){this.exit(e),this.data.inTable=void 0}function LS(e){this.enter({type:"tableRow",children:[]},e)}function ta(e){this.exit(e)}function ru(e){this.enter({type:"tableCell",children:[]},e)}function ZS(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,BS));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function BS(e,t){return t==="|"?t:e}function VS(e){const t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,s=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
|
|
29
|
+
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:p,table:a,tableCell:l,tableRow:o}};function a(h,g,v,S){return c(f(h,v,S),h.align)}function o(h,g,v,S){const x=d(h,v,S),_=c([x]);return _.slice(0,_.indexOf(`
|
|
30
|
+
`))}function l(h,g,v,S){const x=v.enter("tableCell"),_=v.enter("phrasing"),m=v.containerPhrasing(h,{...S,before:s,after:s});return _(),x(),m}function c(h,g){return rS(h,{align:g,alignDelimiters:r,padding:n,stringLength:i})}function f(h,g,v){const S=h.children;let x=-1;const _=[],m=g.enter("table");for(;++x<S.length;)_[x]=d(S[x],g,v);return m(),_}function d(h,g,v){const S=h.children;let x=-1;const _=[],m=g.enter("tableRow");for(;++x<S.length;)_[x]=l(S[x],h,g,v);return m(),_}function p(h,g,v){let S=hp.inlineCode(h,g,v);return v.stack.includes("tableCell")&&(S=S.replace(/\|/g,"\\$&")),S}}function US(){return{exit:{taskListCheckValueChecked:iu,taskListCheckValueUnchecked:iu,paragraph:HS}}}function JS(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:WS}}}function iu(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function HS(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 WS(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=hp.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 qS(){return[Ck(),Wk(),Yk(),MS(),US()]}function GS(e){return{extensions:[Nk(),qk(e),Xk(),VS(e),JS()]}}const KS={tokenize:n1,partial:!0},mp={tokenize:r1,partial:!0},gp={tokenize:i1,partial:!0},xp={tokenize:s1,partial:!0},YS={tokenize:a1,partial:!0},yp={name:"wwwAutolink",tokenize:e1,previous:vp},bp={name:"protocolAutolink",tokenize:t1,previous:wp},nn={name:"emailAutolink",tokenize:QS,previous:kp},Gt={};function XS(){return{text:Gt}}let wn=48;for(;wn<123;)Gt[wn]=nn,wn++,wn===58?wn=65:wn===91&&(wn=97);Gt[43]=nn;Gt[45]=nn;Gt[46]=nn;Gt[95]=nn;Gt[72]=[nn,bp];Gt[104]=[nn,bp];Gt[87]=[nn,yp];Gt[119]=[nn,yp];function QS(e,t,n){const r=this;let i,s;return a;function a(d){return!Ia(d)||!kp.call(r,r.previous)||ko(r.events)?n(d):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),o(d))}function o(d){return Ia(d)?(e.consume(d),o):d===64?(e.consume(d),l):n(d)}function l(d){return d===46?e.check(YS,f,c)(d):d===45||d===95||st(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&&dt(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(d)):n(d)}}function e1(e,t,n){const r=this;return i;function i(a){return a!==87&&a!==119||!vp.call(r,r.previous)||ko(r.events)?n(a):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(KS,e.attempt(mp,e.attempt(gp,s),n),n)(a))}function s(a){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(a)}}function t1(e,t,n){const r=this;let i="",s=!1;return a;function a(d){return(d===72||d===104)&&wp.call(r,r.previous)&&!ko(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),i+=String.fromCodePoint(d),e.consume(d),o):n(d)}function o(d){if(dt(d)&&i.length<5)return i+=String.fromCodePoint(d),e.consume(d),o;if(d===58){const p=i.toLowerCase();if(p==="http"||p==="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||Ui(d)||Fe(d)||An(d)||ys(d)?n(d):e.attempt(mp,e.attempt(gp,f),n)(d)}function f(d){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(d)}}function n1(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 r1(e,t,n){let r,i,s;return a;function a(c){return c===46||c===95?e.check(xp,l,o)(c):c===null||Fe(c)||An(c)||c!==45&&ys(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 i1(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(xp,t,s)(a):a===null||Fe(a)||An(a)?t(a):(e.consume(a),i)}function s(a){return a===41&&r++,e.consume(a),i}}function s1(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)||An(o)?t(o):n(o)}function i(o){return o===null||o===40||o===91||Fe(o)||An(o)?t(o):r(o)}function s(o){return dt(o)?a(o):n(o)}function a(o){return o===59?(e.consume(o),r):dt(o)?(e.consume(o),a):n(o)}}function a1(e,t,n){return r;function r(s){return e.consume(s),i}function i(s){return st(s)?n(s):t(s)}}function vp(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Fe(e)}function wp(e){return!dt(e)}function kp(e){return!(e===47||Ia(e))}function Ia(e){return e===43||e===45||e===46||e===95||st(e)}function ko(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 o1={tokenize:m1,partial:!0};function l1(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:f1,continuation:{tokenize:p1},exit:h1}},text:{91:{name:"gfmFootnoteCall",tokenize:d1},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:u1,resolveTo:c1}}}}function u1(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=Mt(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 c1(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 d1(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 p=e.exit("gfmFootnoteCallString");return i.includes(Mt(r.sliceSerialize(p)))?(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 f1(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 v=e.exit("gfmFootnoteDefinitionLabelString");return s=Mt(r.sliceSerialize(v)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(g),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),p}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 p(g){return g===58?(e.enter("definitionMarker"),e.consume(g),e.exit("definitionMarker"),i.includes(s)||i.push(s),Ae(e,h,"gfmFootnoteDefinitionWhitespace")):n(g)}function h(g){return t(g)}}function p1(e,t,n){return e.check(li,t,e.attempt(o1,t,n))}function h1(e){e.exit("gfmFootnoteDefinition")}function m1(e,t,n){const r=this;return Ae(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 g1(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)},p=[["enter",f,o],["enter",a[c][1],o],["exit",a[c][1],o],["enter",d,o]],h=o.parser.constructs.insideSpan.null;h&&_t(p,p.length,0,bs(h,a.slice(c+1,l),o)),_t(p,p.length,0,[["exit",d,o],["enter",a[l][1],o],["exit",a[l][1],o],["exit",f,o]]),_t(a,c-1,l-c+3,p),l=c+p.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 p;function p(g){return c===126&&f[f.length-1][1].type!=="characterEscape"?l(g):(a.enter("strikethroughSequenceTemporary"),h(g))}function h(g){const v=or(c);if(g===126)return d>1?l(g):(a.consume(g),d++,h);if(d<2&&!n)return l(g);const S=a.exit("strikethroughSequenceTemporary"),x=or(g);return S._open=!x||x===2&&!!v,S._close=!v||v===2&&!!x,o(g)}}}class x1{constructor(){this.map=[]}add(t,n,r){y1(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 y1(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 b1(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 v1(){return{flow:{null:{name:"table",tokenize:w1,resolveAll:k1}}}}function w1(e,t,n){const r=this;let i=0,s=0,a;return o;function o(C){let T=r.events.length-1;for(;T>-1;){const R=r.events[T][1].type;if(R==="lineEnding"||R==="linePrefix")T--;else break}const A=T>-1?r.events[T][1].type:null,F=A==="tableHead"||A==="tableRow"?w:l;return F===w&&r.parser.lazy[r.now().line]?n(C):F(C)}function l(C){return e.enter("tableHead"),e.enter("tableRow"),c(C)}function c(C){return C===124||(a=!0,s+=1),f(C)}function f(C){return C===null?n(C):xe(C)?s>1?(s=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(C),e.exit("lineEnding"),h):n(C):Ie(C)?Ae(e,f,"whitespace")(C):(s+=1,a&&(a=!1,i+=1),C===124?(e.enter("tableCellDivider"),e.consume(C),e.exit("tableCellDivider"),a=!0,f):(e.enter("data"),d(C)))}function d(C){return C===null||C===124||Fe(C)?(e.exit("data"),f(C)):(e.consume(C),C===92?p:d)}function p(C){return C===92||C===124?(e.consume(C),d):d(C)}function h(C){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(C):(e.enter("tableDelimiterRow"),a=!1,Ie(C)?Ae(e,g,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(C):g(C))}function g(C){return C===45||C===58?S(C):C===124?(a=!0,e.enter("tableCellDivider"),e.consume(C),e.exit("tableCellDivider"),v):E(C)}function v(C){return Ie(C)?Ae(e,S,"whitespace")(C):S(C)}function S(C){return C===58?(s+=1,a=!0,e.enter("tableDelimiterMarker"),e.consume(C),e.exit("tableDelimiterMarker"),x):C===45?(s+=1,x(C)):C===null||xe(C)?I(C):E(C)}function x(C){return C===45?(e.enter("tableDelimiterFiller"),_(C)):E(C)}function _(C){return C===45?(e.consume(C),_):C===58?(a=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(C),e.exit("tableDelimiterMarker"),m):(e.exit("tableDelimiterFiller"),m(C))}function m(C){return Ie(C)?Ae(e,I,"whitespace")(C):I(C)}function I(C){return C===124?g(C):C===null||xe(C)?!a||i!==s?E(C):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(C)):E(C)}function E(C){return n(C)}function w(C){return e.enter("tableRow"),N(C)}function N(C){return C===124?(e.enter("tableCellDivider"),e.consume(C),e.exit("tableCellDivider"),N):C===null||xe(C)?(e.exit("tableRow"),t(C)):Ie(C)?Ae(e,N,"whitespace")(C):(e.enter("data"),O(C))}function O(C){return C===null||C===124||Fe(C)?(e.exit("data"),N(C)):(e.consume(C),C===92?K:O)}function K(C){return C===92||C===124?(e.consume(C),O):O(C)}}function k1(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 p=new x1;for(;++n<e.length;){const h=e[n],g=h[1];h[0]==="enter"?g.type==="tableHead"?(o=!1,l!==0&&(su(p,t,l,c,f),f=void 0,l=0),c={type:"table",start:Object.assign({},g.start),end:Object.assign({},g.end)},p.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)},p.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=wi(p,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=wi(p,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=wi(p,t,s,i,n,d)):a[1]!==0&&(d=wi(p,t,a,i,n,d)),i=0):i&&(g.type==="data"||g.type==="tableDelimiterMarker"||g.type==="tableDelimiterFiller")&&(a[3]=n)}for(l!==0&&su(p,t,l,c,f),p.consume(t.events),n=-1;++n<t.events.length;){const h=t.events[n];h[0]==="enter"&&h[1].type==="table"&&(h[1]._align=b1(t.events,n))}return e}function wi(e,t,n,r,i,s){const a=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",o="tableContent";n[0]!==0&&(s.end=Object.assign({},Hn(t.events,n[0])),e.add(n[0],0,[["exit",s,t]]));const l=Hn(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=Hn(t.events,n[2]),f=Hn(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 p=t.events[n[2]],h=t.events[n[3]];if(p[1].end=Object.assign({},h[1].end),p[1].type="chunkText",p[1].contentType="text",n[3]>n[2]+1){const g=n[2]+1,v=n[3]-n[2]-1;e.add(g,v,[])}}e.add(n[3]+1,0,[["exit",d,t]])}return i!==void 0&&(s.end=Object.assign({},Hn(t.events,i)),e.add(i,0,[["exit",s,t]]),s=void 0),s}function su(e,t,n,r,i){const s=[],a=Hn(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 Hn(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const S1={name:"tasklistCheck",tokenize:j1};function _1(){return{text:{91:S1}}}function j1(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 xe(l)?t(l):Ie(l)?e.check({tokenize:C1},t,n)(l):n(l)}}function C1(e,t,n){return Ae(e,r,"whitespace");function r(i){return i===null?n(i):t(i)}}function N1(e){return Pf([XS(),l1(),g1(e),v1(),_1()])}const E1={};function I1(e){const t=this,n=e||E1,r=t.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),s=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),a=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(N1(n)),s.push(qS()),a.push(GS(n))}var Sp="vercel.ai.error",T1=Symbol.for(Sp),au,ou,qt=class _p extends(ou=Error,au=T1,ou){constructor({name:t,message:n,cause:r}){super(n),this[au]=!0,this.name=t,this.cause=r}static isInstance(t){return _p.hasMarker(t,Sp)}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 jp(e){return e==null?"unknown error":typeof e=="string"?e:e instanceof Error?e.message:JSON.stringify(e)}var Cp="AI_InvalidArgumentError",Np=`vercel.ai.error.${Cp}`,z1=Symbol.for(Np),lu,uu,A1=class extends(uu=qt,lu=z1,uu){constructor({message:e,cause:t,argument:n}){super({name:Cp,message:e,cause:t}),this[lu]=!0,this.argument=n}static isInstance(e){return qt.hasMarker(e,Np)}},Ep="AI_JSONParseError",Ip=`vercel.ai.error.${Ep}`,P1=Symbol.for(Ip),cu,du,fu=class extends(du=qt,cu=P1,du){constructor({text:e,cause:t}){super({name:Ep,message:`JSON parsing failed: Text: ${e}.
|
|
31
|
+
Error message: ${jp(t)}`,cause:t}),this[cu]=!0,this.text=e}static isInstance(e){return qt.hasMarker(e,Ip)}},Tp="AI_TypeValidationError",zp=`vercel.ai.error.${Tp}`,O1=Symbol.for(zp),pu,hu,lr=class Ta extends(hu=qt,pu=O1,hu){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:Tp,message:`${i}: Value: ${JSON.stringify(t)}.
|
|
32
|
+
Error message: ${jp(n)}`,cause:n}),this[pu]=!0,this.value=t,this.context=r}static isInstance(t){return qt.hasMarker(t,zp)}static wrap({value:t,cause:n,context:r}){var i,s,a;return Ta.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 Ta({value:t,cause:n,context:r})}};function J(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 p=f[d];p in o||(o[p]=c[p].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 nr extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Ap extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const Pp={};function mn(e){return Pp}function Op(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 za(e,t){return typeof t=="bigint"?t.toString():t}function Ss(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function So(e){return e==null}function _o(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function D1(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 mu=Symbol("evaluating");function ze(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==mu)return r===void 0&&(r=mu,r=n()),r},set(i){Object.defineProperty(e,t,{value:i})},configurable:!0})}function Dn(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function yn(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function gu(e){return JSON.stringify(e)}function R1(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Dp="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Gr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const M1=Ss(()=>{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 ur(e){if(Gr(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(Gr(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Rp(e){return ur(e)?{...e}:Array.isArray(e)?[...e]:e}const $1=new Set(["string","number","symbol"]);function cr(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function bn(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 ce(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 F1(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const L1={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 Z1(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=yn(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 Dn(this,"shape",a),a},checks:[]});return bn(e,s)}function B1(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=yn(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 Dn(this,"shape",a),a},checks:[]});return bn(e,s)}function V1(e,t){if(!ur(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=yn(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t};return Dn(this,"shape",s),s}});return bn(e,i)}function U1(e,t){if(!ur(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=yn(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return Dn(this,"shape",r),r}});return bn(e,n)}function J1(e,t){const n=yn(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return Dn(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:[]});return bn(e,n)}function H1(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=yn(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 Dn(this,"shape",l),l},checks:[]});return bn(t,a)}function W1(e,t,n){const r=yn(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 Dn(this,"shape",s),s}});return bn(t,r)}function Kn(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 Yn(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function ki(e){return typeof e=="string"?e:e==null?void 0:e.message}function gn(e,t,n){var i,s,a,o,l,c;const r={...e,path:e.path??[]};if(!e.message){const f=ki((a=(s=(i=e.inst)==null?void 0:i._zod.def)==null?void 0:s.error)==null?void 0:a.call(s,e))??ki((o=t==null?void 0:t.error)==null?void 0:o.call(t,e))??ki((l=n.customError)==null?void 0:l.call(n,e))??ki((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 jo(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Kr(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}const Mp=(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,za,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},$p=J("$ZodError",Mp),Fp=J("$ZodError",Mp,{Parent:Error});function q1(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 G1(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 Co=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 nr;if(a.issues.length){const o=new((i==null?void 0:i.Err)??e)(a.issues.map(l=>gn(l,s,mn())));throw Dp(o,i==null?void 0:i.callee),o}return a.value},No=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=>gn(l,s,mn())));throw Dp(o,i==null?void 0:i.callee),o}return a.value},_s=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 nr;return s.issues.length?{success:!1,error:new(e??$p)(s.issues.map(a=>gn(a,i,mn())))}:{success:!0,data:s.value}},K1=_s(Fp),js=e=>async(t,n,r)=>{const i=r?Object.assign(r,{async:!0}):{async:!0};let s=t._zod.run({value:n,issues:[]},i);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(a=>gn(a,i,mn())))}:{success:!0,data:s.value}},Y1=js(Fp),X1=e=>(t,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Co(e)(t,n,i)},Q1=e=>(t,n,r)=>Co(e)(t,n,r),e_=e=>async(t,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return No(e)(t,n,i)},t_=e=>async(t,n,r)=>No(e)(t,n,r),n_=e=>(t,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return _s(e)(t,n,i)},r_=e=>(t,n,r)=>_s(e)(t,n,r),i_=e=>async(t,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return js(e)(t,n,i)},s_=e=>async(t,n,r)=>js(e)(t,n,r),a_=/^[cC][^\s-]{8,}$/,o_=/^[0-9a-z]+$/,l_=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,u_=/^[0-9a-vA-V]{20}$/,c_=/^[A-Za-z0-9]{27}$/,d_=/^[a-zA-Z0-9_-]{21}$/,f_=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,p_=/^([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})$/,xu=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)$/,h_=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,m_="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function g_(){return new RegExp(m_,"u")}const x_=/^(?:(?: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])$/,y_=/^(([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}|:))$/,b_=/^((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])$/,v_=/^(([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])$/,w_=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Lp=/^[A-Za-z0-9_-]*$/,k_=/^\+[1-9]\d{6,14}$/,Zp="(?:(?:\\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])))",S_=new RegExp(`^${Zp}$`);function Bp(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 __(e){return new RegExp(`^${Bp(e)}$`)}function j_(e){const t=Bp({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(`^${Zp}T(?:${r})$`)}const C_=e=>{const t=e?`[\\s\\S]{${(e==null?void 0:e.minimum)??0},${(e==null?void 0:e.maximum)??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},N_=/^-?\d+$/,Vp=/^-?\d+(?:\.\d+)?$/,E_=/^(?:true|false)$/i,I_=/^null$/i,T_=/^[^A-Z]*$/,z_=/^[^a-z]*$/,vt=J("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Up={number:"number",bigint:"bigint",object:"date"},Jp=J("$ZodCheckLessThan",(e,t)=>{vt.init(e,t);const n=Up[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})}}),Hp=J("$ZodCheckGreaterThan",(e,t)=>{vt.init(e,t);const n=Up[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})}}),A_=J("$ZodCheckMultipleOf",(e,t)=>{vt.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):D1(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})}}),P_=J("$ZodCheckNumberFormat",(e,t)=>{var a;vt.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]=L1[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=N_)}),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})}}),O_=J("$ZodCheckMaxLength",(e,t)=>{var n;vt.init(e,t),(n=e._zod.def).when??(n.when=r=>{const i=r.value;return!So(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=jo(i);r.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),D_=J("$ZodCheckMinLength",(e,t)=>{var n;vt.init(e,t),(n=e._zod.def).when??(n.when=r=>{const i=r.value;return!So(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=jo(i);r.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),R_=J("$ZodCheckLengthEquals",(e,t)=>{var n;vt.init(e,t),(n=e._zod.def).when??(n.when=r=>{const i=r.value;return!So(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=jo(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})}}),Cs=J("$ZodCheckStringFormat",(e,t)=>{var n,r;vt.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=()=>{})}),M_=J("$ZodCheckRegex",(e,t)=>{Cs.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})}}),$_=J("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=T_),Cs.init(e,t)}),F_=J("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=z_),Cs.init(e,t)}),L_=J("$ZodCheckIncludes",(e,t)=>{vt.init(e,t);const n=cr(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})}}),Z_=J("$ZodCheckStartsWith",(e,t)=>{vt.init(e,t);const n=new RegExp(`^${cr(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})}}),B_=J("$ZodCheckEndsWith",(e,t)=>{vt.init(e,t);const n=new RegExp(`.*${cr(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})}}),V_=J("$ZodCheckOverwrite",(e,t)=>{vt.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class U_{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(`
|
|
33
|
+
`).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(`
|
|
34
|
+
`))}}const J_={major:4,minor:3,patch:6},Je=J("$ZodType",(e,t)=>{var i;var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=J_;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=Kn(o),d;for(const p of l){if(p._zod.def.when){if(!p._zod.def.when(o))continue}else if(f)continue;const h=o.issues.length,g=p._zod.check(o);if(g instanceof Promise&&(c==null?void 0:c.async)===!1)throw new nr;if(d||g instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await g,o.issues.length!==h&&(f||(f=Kn(o,h)))});else{if(o.issues.length===h)continue;f||(f=Kn(o,h))}}return d?d.then(()=>o):o},a=(o,l,c)=>{if(Kn(o))return o.aborted=!0,o;const f=s(l,r,c);if(f instanceof Promise){if(c.async===!1)throw new nr;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 nr;return c.then(f=>s(f,r,l))}return s(c,r,l)}}ze(e,"~standard",()=>({validate:s=>{var a;try{const o=K1(e,s);return o.success?{value:o.data}:{issues:(a=o.error)==null?void 0:a.issues}}catch{return Y1(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}))}),Eo=J("$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()??C_(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}}),We=J("$ZodStringFormat",(e,t)=>{Cs.init(e,t),Eo.init(e,t)}),H_=J("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=p_),We.init(e,t)}),W_=J("$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=xu(r))}else t.pattern??(t.pattern=xu());We.init(e,t)}),q_=J("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=h_),We.init(e,t)}),G_=J("$ZodURL",(e,t)=>{We.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})}}}),K_=J("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=g_()),We.init(e,t)}),Y_=J("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=d_),We.init(e,t)}),X_=J("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=a_),We.init(e,t)}),Q_=J("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=o_),We.init(e,t)}),ej=J("$ZodULID",(e,t)=>{t.pattern??(t.pattern=l_),We.init(e,t)}),tj=J("$ZodXID",(e,t)=>{t.pattern??(t.pattern=u_),We.init(e,t)}),nj=J("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=c_),We.init(e,t)}),rj=J("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=j_(t)),We.init(e,t)}),ij=J("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=S_),We.init(e,t)}),sj=J("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=__(t)),We.init(e,t)}),aj=J("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=f_),We.init(e,t)}),oj=J("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=x_),We.init(e,t),e._zod.bag.format="ipv4"}),lj=J("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=y_),We.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})}}}),uj=J("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=b_),We.init(e,t)}),cj=J("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=v_),We.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 Wp(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const dj=J("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=w_),We.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{Wp(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function fj(e){if(!Lp.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return Wp(n)}const pj=J("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Lp),We.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{fj(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),hj=J("$ZodE164",(e,t)=>{t.pattern??(t.pattern=k_),We.init(e,t)});function mj(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 gj=J("$ZodJWT",(e,t)=>{We.init(e,t),e._zod.check=n=>{mj(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),qp=J("$ZodNumber",(e,t)=>{Je.init(e,t),e._zod.pattern=e._zod.bag.pattern??Vp,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}}),xj=J("$ZodNumberFormat",(e,t)=>{P_.init(e,t),qp.init(e,t)}),yj=J("$ZodBoolean",(e,t)=>{Je.init(e,t),e._zod.pattern=E_,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}}),bj=J("$ZodNull",(e,t)=>{Je.init(e,t),e._zod.pattern=I_,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}}),vj=J("$ZodUnknown",(e,t)=>{Je.init(e,t),e._zod.parse=n=>n}),wj=J("$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 yu(e,t,n){e.issues.length&&t.issues.push(...Yn(n,e.issues)),t.value[n]=e.value}const kj=J("$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=>yu(c,n,a))):yu(l,n,a)}return s.length?Promise.all(s).then(()=>n):n}});function qi(e,t,n,r,i){if(e.issues.length){if(i&&!(n in r))return;t.issues.push(...Yn(n,e.issues))}e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function Gp(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=F1(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Kp(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 p=l.run({value:t[d],issues:[]},r);p instanceof Promise?e.push(p.then(h=>qi(h,n,d,t,f))):qi(p,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 Sj=J("$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=Ss(()=>Gp(t));ze(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=Gr,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 p of a.keys){const h=d[p],g=h._zod.optout==="optional",v=h._zod.run({value:c[p],issues:[]},l);v instanceof Promise?f.push(v.then(S=>qi(S,o,p,c,g))):qi(v,o,p,c,g)}return s?Kp(f,c,o,l,r.value,e):f.length?Promise.all(f).then(()=>o):o}}),_j=J("$ZodObjectJIT",(e,t)=>{Sj.init(e,t);const n=e._zod.parse,r=Ss(()=>Gp(t)),i=p=>{var m;const h=new U_(["shape","payload","ctx"]),g=r.value,v=I=>{const E=gu(I);return`shape[${E}]._zod.run({ value: input[${E}], issues: [] }, ctx)`};h.write("const input = payload.value;");const S=Object.create(null);let x=0;for(const I of g.keys)S[I]=`key_${x++}`;h.write("const newResult = {};");for(const I of g.keys){const E=S[I],w=gu(I),N=p[I],O=((m=N==null?void 0:N._zod)==null?void 0:m.optout)==="optional";h.write(`const ${E} = ${v(I)};`),O?h.write(`
|
|
35
|
+
if (${E}.issues.length) {
|
|
36
|
+
if (${w} in input) {
|
|
37
|
+
payload.issues = payload.issues.concat(${E}.issues.map(iss => ({
|
|
38
|
+
...iss,
|
|
39
|
+
path: iss.path ? [${w}, ...iss.path] : [${w}]
|
|
40
|
+
})));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (${E}.value === undefined) {
|
|
45
|
+
if (${w} in input) {
|
|
46
|
+
newResult[${w}] = undefined;
|
|
47
|
+
}
|
|
48
|
+
} else {
|
|
49
|
+
newResult[${w}] = ${E}.value;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
`):h.write(`
|
|
53
|
+
if (${E}.issues.length) {
|
|
54
|
+
payload.issues = payload.issues.concat(${E}.issues.map(iss => ({
|
|
55
|
+
...iss,
|
|
56
|
+
path: iss.path ? [${w}, ...iss.path] : [${w}]
|
|
57
|
+
})));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (${E}.value === undefined) {
|
|
61
|
+
if (${w} in input) {
|
|
62
|
+
newResult[${w}] = undefined;
|
|
63
|
+
}
|
|
64
|
+
} else {
|
|
65
|
+
newResult[${w}] = ${E}.value;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
`)}h.write("payload.value = newResult;"),h.write("return payload;");const _=h.compile();return(I,E)=>_(p,I,E)};let s;const a=Gr,o=!Pp.jitless,c=o&&M1.value,f=t.catchall;let d;e._zod.parse=(p,h)=>{d??(d=r.value);const g=p.value;return a(g)?o&&c&&(h==null?void 0:h.async)===!1&&h.jitless!==!0?(s||(s=i(t.shape)),p=s(p,h),f?Kp([],g,p,h,d,e):p):n(p,h):(p.issues.push({expected:"object",code:"invalid_type",input:g,inst:e}),p)}});function bu(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=>!Kn(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=>gn(a,r,mn())))}),t)}const Yp=J("$ZodUnion",(e,t)=>{Je.init(e,t),ze(e._zod,"optin",()=>t.options.some(i=>i._zod.optin==="optional")?"optional":void 0),ze(e._zod,"optout",()=>t.options.some(i=>i._zod.optout==="optional")?"optional":void 0),ze(e._zod,"values",()=>{if(t.options.every(i=>i._zod.values))return new Set(t.options.flatMap(i=>Array.from(i._zod.values)))}),ze(e._zod,"pattern",()=>{if(t.options.every(i=>i._zod.pattern)){const i=t.options.map(s=>s._zod.pattern);return new RegExp(`^(${i.map(s=>_o(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=>bu(l,i,e,s)):bu(o,i,e,s)}}),jj=J("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Yp.init(e,t);const n=e._zod.parse;ze(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=Ss(()=>{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(!Gr(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)}}),Cj=J("$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])=>vu(n,l,c)):vu(n,s,a)}});function Aa(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(ur(e)&&ur(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=Aa(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=Aa(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 vu(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}),Kn(e))return e;const a=Aa(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 Nj=J("$ZodRecord",(e,t)=>{Je.init(e,t),e._zod.parse=(n,r)=>{const i=n.value;if(!ur(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(...Yn(c,d.issues)),n.value[c]=d.value})):(f.issues.length&&n.issues.push(...Yn(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"&&Vp.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=>gn(d,r,mn())),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(...Yn(o,d.issues)),n.value[l.value]=d.value})):(f.issues.length&&n.issues.push(...Yn(o,f.issues)),n.value[l.value]=f.value)}}return s.length?Promise.all(s).then(()=>n):n}}),Ej=J("$ZodEnum",(e,t)=>{Je.init(e,t);const n=Op(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(i=>$1.has(typeof i)).map(i=>typeof i=="string"?cr(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}}),Ij=J("$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"?cr(r):r?cr(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}}),Tj=J("$ZodTransform",(e,t)=>{Je.init(e,t),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Ap(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 nr;return n.value=i,n}});function wu(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const Xp=J("$ZodOptional",(e,t)=>{Je.init(e,t),e._zod.optin="optional",e._zod.optout="optional",ze(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),ze(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${_o(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=>wu(s,n.value)):wu(i,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,r)}}),zj=J("$ZodExactOptional",(e,t)=>{Xp.init(e,t),ze(e._zod,"values",()=>t.innerType._zod.values),ze(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),Aj=J("$ZodNullable",(e,t)=>{Je.init(e,t),ze(e._zod,"optin",()=>t.innerType._zod.optin),ze(e._zod,"optout",()=>t.innerType._zod.optout),ze(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${_o(n.source)}|null)$`):void 0}),ze(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)}),Pj=J("$ZodDefault",(e,t)=>{Je.init(e,t),e._zod.optin="optional",ze(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;const i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(s=>ku(s,t)):ku(i,t)}});function ku(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Oj=J("$ZodPrefault",(e,t)=>{Je.init(e,t),e._zod.optin="optional",ze(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,r))}),Dj=J("$ZodNonOptional",(e,t)=>{Je.init(e,t),ze(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(r=>r!==void 0)):void 0}),e._zod.parse=(n,r)=>{const i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(s=>Su(s,e)):Su(i,e)}});function Su(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 Rj=J("$ZodCatch",(e,t)=>{Je.init(e,t),ze(e._zod,"optin",()=>t.innerType._zod.optin),ze(e._zod,"optout",()=>t.innerType._zod.optout),ze(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(s=>(n.value=s.value,s.issues.length&&(n.value=t.catchValue({...n,error:{issues:s.issues.map(a=>gn(a,r,mn()))},input:n.value}),n.issues=[]),n)):(n.value=i.value,i.issues.length&&(n.value=t.catchValue({...n,error:{issues:i.issues.map(s=>gn(s,r,mn()))},input:n.value}),n.issues=[]),n)}}),Mj=J("$ZodPipe",(e,t)=>{Je.init(e,t),ze(e._zod,"values",()=>t.in._zod.values),ze(e._zod,"optin",()=>t.in._zod.optin),ze(e._zod,"optout",()=>t.out._zod.optout),ze(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){const s=t.out._zod.run(n,r);return s instanceof Promise?s.then(a=>Si(a,t.in,r)):Si(s,t.in,r)}const i=t.in._zod.run(n,r);return i instanceof Promise?i.then(s=>Si(s,t.out,r)):Si(i,t.out,r)}});function Si(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const $j=J("$ZodReadonly",(e,t)=>{Je.init(e,t),ze(e._zod,"propValues",()=>t.innerType._zod.propValues),ze(e._zod,"values",()=>t.innerType._zod.values),ze(e._zod,"optin",()=>{var n,r;return(r=(n=t.innerType)==null?void 0:n._zod)==null?void 0:r.optin}),ze(e._zod,"optout",()=>{var n,r;return(r=(n=t.innerType)==null?void 0:n._zod)==null?void 0:r.optout}),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(_u):_u(i)}});function _u(e){return e.value=Object.freeze(e.value),e}const Fj=J("$ZodLazy",(e,t)=>{Je.init(e,t),ze(e._zod,"innerType",()=>t.getter()),ze(e._zod,"pattern",()=>{var n,r;return(r=(n=e._zod.innerType)==null?void 0:n._zod)==null?void 0:r.pattern}),ze(e._zod,"propValues",()=>{var n,r;return(r=(n=e._zod.innerType)==null?void 0:n._zod)==null?void 0:r.propValues}),ze(e._zod,"optin",()=>{var n,r;return((r=(n=e._zod.innerType)==null?void 0:n._zod)==null?void 0:r.optin)??void 0}),ze(e._zod,"optout",()=>{var n,r;return((r=(n=e._zod.innerType)==null?void 0:n._zod)==null?void 0:r.optout)??void 0}),e._zod.parse=(n,r)=>e._zod.innerType._zod.run(n,r)}),Lj=J("$ZodCustom",(e,t)=>{vt.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=>ju(s,n,r,e));ju(i,n,r,e)}});function ju(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(Kr(i))}}var Cu;class Zj{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 Bj(){return new Zj}(Cu=globalThis).__zod_globalRegistry??(Cu.__zod_globalRegistry=Bj());const Ir=globalThis.__zod_globalRegistry;function Vj(e,t){return new e({type:"string",...ce(t)})}function Uj(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...ce(t)})}function Nu(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...ce(t)})}function Jj(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...ce(t)})}function Hj(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...ce(t)})}function Wj(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...ce(t)})}function qj(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...ce(t)})}function Gj(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...ce(t)})}function Kj(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...ce(t)})}function Yj(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...ce(t)})}function Xj(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...ce(t)})}function Qj(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...ce(t)})}function eC(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...ce(t)})}function tC(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...ce(t)})}function nC(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...ce(t)})}function rC(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...ce(t)})}function iC(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...ce(t)})}function sC(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...ce(t)})}function aC(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...ce(t)})}function oC(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...ce(t)})}function lC(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...ce(t)})}function uC(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...ce(t)})}function cC(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...ce(t)})}function dC(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...ce(t)})}function fC(e,t){return new e({type:"string",format:"date",check:"string_format",...ce(t)})}function pC(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...ce(t)})}function hC(e,t){return new e({type:"string",format:"duration",check:"string_format",...ce(t)})}function mC(e,t){return new e({type:"number",checks:[],...ce(t)})}function gC(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...ce(t)})}function xC(e,t){return new e({type:"boolean",...ce(t)})}function yC(e,t){return new e({type:"null",...ce(t)})}function bC(e){return new e({type:"unknown"})}function vC(e,t){return new e({type:"never",...ce(t)})}function Eu(e,t){return new Jp({check:"less_than",...ce(t),value:e,inclusive:!1})}function na(e,t){return new Jp({check:"less_than",...ce(t),value:e,inclusive:!0})}function Iu(e,t){return new Hp({check:"greater_than",...ce(t),value:e,inclusive:!1})}function ra(e,t){return new Hp({check:"greater_than",...ce(t),value:e,inclusive:!0})}function Tu(e,t){return new A_({check:"multiple_of",...ce(t),value:e})}function Qp(e,t){return new O_({check:"max_length",...ce(t),maximum:e})}function Gi(e,t){return new D_({check:"min_length",...ce(t),minimum:e})}function eh(e,t){return new R_({check:"length_equals",...ce(t),length:e})}function wC(e,t){return new M_({check:"string_format",format:"regex",...ce(t),pattern:e})}function kC(e){return new $_({check:"string_format",format:"lowercase",...ce(e)})}function SC(e){return new F_({check:"string_format",format:"uppercase",...ce(e)})}function _C(e,t){return new L_({check:"string_format",format:"includes",...ce(t),includes:e})}function jC(e,t){return new Z_({check:"string_format",format:"starts_with",...ce(t),prefix:e})}function CC(e,t){return new B_({check:"string_format",format:"ends_with",...ce(t),suffix:e})}function mr(e){return new V_({check:"overwrite",tx:e})}function NC(e){return mr(t=>t.normalize(e))}function EC(){return mr(e=>e.trim())}function IC(){return mr(e=>e.toLowerCase())}function TC(){return mr(e=>e.toUpperCase())}function zC(){return mr(e=>R1(e))}function AC(e,t,n){return new e({type:"array",element:t,...ce(n)})}function PC(e,t,n){const r=ce(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,...ce(n)})}function DC(e){const t=RC(n=>(n.addIssue=r=>{if(typeof r=="string")n.issues.push(Kr(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(Kr(i))}},e(n.value,n)));return t}function RC(e,t){const n=new vt({check:"custom",...ce(t)});return n._zod.check=e,n}function Ki(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)??Ir,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 Be(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 p={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,a.schema,p);else{const g=a.schema,v=t.processors[i.type];if(!v)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);v(e,t,g,p)}const h=e._zod.parent;h&&(a.ref||(a.ref=h),Be(h,t,p),t.seen.get(h).isParent=!0)}const l=t.metadataRegistry.get(e);return l&&Object.assign(a.schema,l),t.io==="input"&<(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 Yi(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 p=r.get(d);if(p&&p!==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 v;const d=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const S=(v=e.external.registry.get(f[0]))==null?void 0:v.id,x=e.external.uri??(m=>m);if(S)return{ref:x(S)};const _=f[1].defId??f[1].schema.id??`schema${e.counter++}`;return f[1].defId=_,{defId:_,ref:`${x("__shared")}#/${d}/${_}`}}if(f[1]===n)return{ref:"#"};const h=`#/${d}/`,g=f[1].schema.id??`__schema${e.counter++}`;return{defId:g,ref:h+g}},s=f=>{if(f[1].schema.$ref)return;const d=f[1],{ref:p,defId:h}=i(f);d.def={...d.schema},h&&(d.defId=h);const g=d.schema;for(const v in g)delete g[v];g.$ref=p};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>
|
|
69
|
+
|
|
70
|
+
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 h=(l=e.external.registry.get(f[0]))==null?void 0:l.id;if(t!==f[0]&&h){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 Xi(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,p={...d},h=f.ref;if(f.ref=null,h){r(h);const v=e.seen.get(h),S=v.schema;if(S.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(d.allOf=d.allOf??[],d.allOf.push(S)):Object.assign(d,S),Object.assign(d,p),c._zod.parent===h)for(const _ in d)_==="$ref"||_==="allOf"||_ in p||delete d[_];if(S.$ref&&v.def)for(const _ in d)_==="$ref"||_==="allOf"||_ in v.def&&JSON.stringify(d[_])===JSON.stringify(v.def[_])&&delete d[_]}const g=c._zod.parent;if(g&&g!==h){r(g);const v=e.seen.get(g);if(v!=null&&v.schema.$ref&&(d.$ref=v.schema.$ref,v.def))for(const S in d)S==="$ref"||S==="allOf"||S in v.def&&JSON.stringify(d[S])===JSON.stringify(v.def[S])&&delete d[S]}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:Qi(t,"input",e.processors),output:Qi(t,"output",e.processors)}},enumerable:!1,writable:!1}),c}catch{throw new Error("Error converting schema to JSON.")}}function lt(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 lt(r.element,n);if(r.type==="set")return lt(r.valueType,n);if(r.type==="lazy")return lt(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 lt(r.innerType,n);if(r.type==="intersection")return lt(r.left,n)||lt(r.right,n);if(r.type==="record"||r.type==="map")return lt(r.keyType,n)||lt(r.valueType,n);if(r.type==="pipe")return lt(r.in,n)||lt(r.out,n);if(r.type==="object"){for(const i in r.shape)if(lt(r.shape[i],n))return!0;return!1}if(r.type==="union"){for(const i of r.options)if(lt(i,n))return!0;return!1}if(r.type==="tuple"){for(const i of r.items)if(lt(i,n))return!0;return!!(r.rest&<(r.rest,n))}return!1}const MC=(e,t={})=>n=>{const r=Ki({...n,processors:t});return Be(e,r),Yi(r,e),Xi(r,e)},Qi=(e,t,n={})=>r=>{const{libraryOptions:i,target:s}=r??{},a=Ki({...i??{},target:s,io:t,processors:n});return Be(e,a),Yi(a,e),Xi(a,e)},$C={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},th=(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=$C[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}))])}},nh=(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)},rh=(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")},LC=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema")},ih=(e,t,n,r)=>{t.target==="openapi-3.0"?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"},ZC=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},BC=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema")},sh=(e,t,n,r)=>{n.not={}},VC=(e,t,n,r)=>{},ah=(e,t,n,r)=>{},UC=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},oh=(e,t,n,r)=>{const i=e._zod.def,s=Op(i.entries);s.every(a=>typeof a=="number")&&(n.type="number"),s.every(a=>typeof a=="string")&&(n.type="string"),n.enum=s},lh=(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},JC=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema")},HC=(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},WC=(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)},qC=(e,t,n,r)=>{n.type="boolean"},uh=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},GC=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Function types cannot be represented in JSON Schema")},ch=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},KC=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema")},YC=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema")},dh=(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=Be(s.element,t,{...r,path:[...r.path,"items"]})},fh=(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]=Be(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=Be(s.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(i.additionalProperties=!1)},ph=(e,t,n,r)=>{const i=e._zod.def,s=i.inclusive===!1,a=i.options.map((o,l)=>Be(o,t,{...r,path:[...r.path,s?"oneOf":"anyOf",l]}));s?n.oneOf=a:n.anyOf=a},hh=(e,t,n,r)=>{const i=e._zod.def,s=Be(i.left,t,{...r,path:[...r.path,"allOf",0]}),a=Be(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},XC=(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((p,h)=>Be(p,t,{...r,path:[...r.path,a,h]})),c=s.rest?Be(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)},mh=(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=Be(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=Be(s.keyType,t,{...r,path:[...r.path,"propertyNames"]})),i.additionalProperties=Be(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)}},gh=(e,t,n,r)=>{const i=e._zod.def,s=Be(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"}]},xh=(e,t,n,r)=>{const i=e._zod.def;Be(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType},yh=(e,t,n,r)=>{const i=e._zod.def;Be(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},bh=(e,t,n,r)=>{const i=e._zod.def;Be(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)))},vh=(e,t,n,r)=>{const i=e._zod.def;Be(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},wh=(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;Be(s,t,r);const a=t.seen.get(e);a.ref=s},kh=(e,t,n,r)=>{const i=e._zod.def;Be(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType,n.readOnly=!0},QC=(e,t,n,r)=>{const i=e._zod.def;Be(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType},Io=(e,t,n,r)=>{const i=e._zod.def;Be(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType},Sh=(e,t,n,r)=>{const i=e._zod.innerType;Be(i,t,r);const s=t.seen.get(e);s.ref=i},zu={string:th,number:nh,boolean:rh,bigint:FC,symbol:LC,null:ih,undefined:ZC,void:BC,never:sh,any:VC,unknown:ah,date:UC,enum:oh,literal:lh,nan:JC,template_literal:HC,file:WC,success:qC,custom:uh,function:GC,transform:ch,map:KC,set:YC,array:dh,object:fh,union:ph,intersection:hh,tuple:XC,record:mh,nullable:gh,nonoptional:xh,default:yh,prefault:bh,catch:vh,pipe:wh,readonly:kh,promise:QC,optional:Io,lazy:Sh};function eN(e,t){if("_idmap"in e){const r=e,i=Ki({...t,processors:zu}),s={};for(const l of r._idmap.entries()){const[c,f]=l;Be(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;Yi(i,f),a[c]=Xi(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=Ki({...t,processors:zu});return Be(e,n),Yi(n,e),Xi(n,e)}const tN=J("ZodISODateTime",(e,t)=>{rj.init(e,t),Ye.init(e,t)});function nN(e){return dC(tN,e)}const rN=J("ZodISODate",(e,t)=>{ij.init(e,t),Ye.init(e,t)});function iN(e){return fC(rN,e)}const sN=J("ZodISOTime",(e,t)=>{sj.init(e,t),Ye.init(e,t)});function aN(e){return pC(sN,e)}const oN=J("ZodISODuration",(e,t)=>{aj.init(e,t),Ye.init(e,t)});function lN(e){return hC(oN,e)}const uN=(e,t)=>{$p.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>G1(e,n)},flatten:{value:n=>q1(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,za,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,za,2)}},isEmpty:{get(){return e.issues.length===0}}})},Tt=J("ZodError",uN,{Parent:Error}),cN=Co(Tt),dN=No(Tt),fN=_s(Tt),_h=js(Tt),pN=X1(Tt),hN=Q1(Tt),mN=e_(Tt),gN=t_(Tt),xN=n_(Tt),yN=r_(Tt),bN=i_(Tt),vN=s_(Tt),He=J("ZodType",(e,t)=>(Je.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Qi(e,"input"),output:Qi(e,"output")}}),e.toJSONSchema=MC(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(yn(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)=>bn(e,n,r),e.brand=()=>e,e.register=(n,r)=>(n.add(e,r),e),e.parse=(n,r)=>cN(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>fN(e,n,r),e.parseAsync=async(n,r)=>dN(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>_h(e,n,r),e.spa=e.safeParseAsync,e.encode=(n,r)=>pN(e,n,r),e.decode=(n,r)=>hN(e,n,r),e.encodeAsync=async(n,r)=>mN(e,n,r),e.decodeAsync=async(n,r)=>gN(e,n,r),e.safeEncode=(n,r)=>xN(e,n,r),e.safeDecode=(n,r)=>yN(e,n,r),e.safeEncodeAsync=async(n,r)=>bN(e,n,r),e.safeDecodeAsync=async(n,r)=>vN(e,n,r),e.refine=(n,r)=>e.check(gE(n,r)),e.superRefine=n=>e.check(xE(n)),e.overwrite=n=>e.check(mr(n)),e.optional=()=>Ou(e),e.exactOptional=()=>nE(e),e.nullable=()=>Du(e),e.nullish=()=>Ou(Du(e)),e.nonoptional=n=>lE(e,n),e.array=()=>gr(e),e.or=n=>ft([e,n]),e.and=n=>KN(e,n),e.transform=n=>Ru(e,eE(n)),e.default=n=>sE(e,n),e.prefault=n=>oE(e,n),e.catch=n=>cE(e,n),e.pipe=n=>Ru(e,n),e.readonly=()=>pE(e),e.describe=n=>{const r=e.clone();return Ir.add(r,{description:n}),r},Object.defineProperty(e,"description",{get(){var n;return(n=Ir.get(e))==null?void 0:n.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return Ir.get(e);const r=e.clone();return Ir.add(r,n[0]),r},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=n=>n(e),e)),jh=J("_ZodString",(e,t)=>{Eo.init(e,t),He.init(e,t),e._zod.processJSONSchema=(r,i,s)=>th(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(wC(...r)),e.includes=(...r)=>e.check(_C(...r)),e.startsWith=(...r)=>e.check(jC(...r)),e.endsWith=(...r)=>e.check(CC(...r)),e.min=(...r)=>e.check(Gi(...r)),e.max=(...r)=>e.check(Qp(...r)),e.length=(...r)=>e.check(eh(...r)),e.nonempty=(...r)=>e.check(Gi(1,...r)),e.lowercase=r=>e.check(kC(r)),e.uppercase=r=>e.check(SC(r)),e.trim=()=>e.check(EC()),e.normalize=(...r)=>e.check(NC(...r)),e.toLowerCase=()=>e.check(IC()),e.toUpperCase=()=>e.check(TC()),e.slugify=()=>e.check(zC())}),wN=J("ZodString",(e,t)=>{Eo.init(e,t),jh.init(e,t),e.email=n=>e.check(Uj(kN,n)),e.url=n=>e.check(Gj(SN,n)),e.jwt=n=>e.check(cC($N,n)),e.emoji=n=>e.check(Kj(_N,n)),e.guid=n=>e.check(Nu(Au,n)),e.uuid=n=>e.check(Jj(_i,n)),e.uuidv4=n=>e.check(Hj(_i,n)),e.uuidv6=n=>e.check(Wj(_i,n)),e.uuidv7=n=>e.check(qj(_i,n)),e.nanoid=n=>e.check(Yj(jN,n)),e.guid=n=>e.check(Nu(Au,n)),e.cuid=n=>e.check(Xj(CN,n)),e.cuid2=n=>e.check(Qj(NN,n)),e.ulid=n=>e.check(eC(EN,n)),e.base64=n=>e.check(oC(DN,n)),e.base64url=n=>e.check(lC(RN,n)),e.xid=n=>e.check(tC(IN,n)),e.ksuid=n=>e.check(nC(TN,n)),e.ipv4=n=>e.check(rC(zN,n)),e.ipv6=n=>e.check(iC(AN,n)),e.cidrv4=n=>e.check(sC(PN,n)),e.cidrv6=n=>e.check(aC(ON,n)),e.e164=n=>e.check(uC(MN,n)),e.datetime=n=>e.check(nN(n)),e.date=n=>e.check(iN(n)),e.time=n=>e.check(aN(n)),e.duration=n=>e.check(lN(n))});function ae(e){return Vj(wN,e)}const Ye=J("ZodStringFormat",(e,t)=>{We.init(e,t),jh.init(e,t)}),kN=J("ZodEmail",(e,t)=>{q_.init(e,t),Ye.init(e,t)}),Au=J("ZodGUID",(e,t)=>{H_.init(e,t),Ye.init(e,t)}),_i=J("ZodUUID",(e,t)=>{W_.init(e,t),Ye.init(e,t)}),SN=J("ZodURL",(e,t)=>{G_.init(e,t),Ye.init(e,t)}),_N=J("ZodEmoji",(e,t)=>{K_.init(e,t),Ye.init(e,t)}),jN=J("ZodNanoID",(e,t)=>{Y_.init(e,t),Ye.init(e,t)}),CN=J("ZodCUID",(e,t)=>{X_.init(e,t),Ye.init(e,t)}),NN=J("ZodCUID2",(e,t)=>{Q_.init(e,t),Ye.init(e,t)}),EN=J("ZodULID",(e,t)=>{ej.init(e,t),Ye.init(e,t)}),IN=J("ZodXID",(e,t)=>{tj.init(e,t),Ye.init(e,t)}),TN=J("ZodKSUID",(e,t)=>{nj.init(e,t),Ye.init(e,t)}),zN=J("ZodIPv4",(e,t)=>{oj.init(e,t),Ye.init(e,t)}),AN=J("ZodIPv6",(e,t)=>{lj.init(e,t),Ye.init(e,t)}),PN=J("ZodCIDRv4",(e,t)=>{uj.init(e,t),Ye.init(e,t)}),ON=J("ZodCIDRv6",(e,t)=>{cj.init(e,t),Ye.init(e,t)}),DN=J("ZodBase64",(e,t)=>{dj.init(e,t),Ye.init(e,t)}),RN=J("ZodBase64URL",(e,t)=>{pj.init(e,t),Ye.init(e,t)}),MN=J("ZodE164",(e,t)=>{hj.init(e,t),Ye.init(e,t)}),$N=J("ZodJWT",(e,t)=>{gj.init(e,t),Ye.init(e,t)}),Ch=J("ZodNumber",(e,t)=>{qp.init(e,t),He.init(e,t),e._zod.processJSONSchema=(r,i,s)=>nh(e,r,i),e.gt=(r,i)=>e.check(Iu(r,i)),e.gte=(r,i)=>e.check(ra(r,i)),e.min=(r,i)=>e.check(ra(r,i)),e.lt=(r,i)=>e.check(Eu(r,i)),e.lte=(r,i)=>e.check(na(r,i)),e.max=(r,i)=>e.check(na(r,i)),e.int=r=>e.check(Pu(r)),e.safe=r=>e.check(Pu(r)),e.positive=r=>e.check(Iu(0,r)),e.nonnegative=r=>e.check(ra(0,r)),e.negative=r=>e.check(Eu(0,r)),e.nonpositive=r=>e.check(na(0,r)),e.multipleOf=(r,i)=>e.check(Tu(r,i)),e.step=(r,i)=>e.check(Tu(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 FN(e){return mC(Ch,e)}const LN=J("ZodNumberFormat",(e,t)=>{xj.init(e,t),Ch.init(e,t)});function Pu(e){return gC(LN,e)}const ZN=J("ZodBoolean",(e,t)=>{yj.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>rh(e,n,r)});function ut(e){return xC(ZN,e)}const BN=J("ZodNull",(e,t)=>{bj.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ih(e,n,r)});function VN(e){return yC(BN,e)}const UN=J("ZodUnknown",(e,t)=>{vj.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ah()});function Zt(){return bC(UN)}const JN=J("ZodNever",(e,t)=>{wj.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>sh(e,n,r)});function Nh(e){return vC(JN,e)}const HN=J("ZodArray",(e,t)=>{kj.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>dh(e,n,r,i),e.element=t.element,e.min=(n,r)=>e.check(Gi(n,r)),e.nonempty=n=>e.check(Gi(1,n)),e.max=(n,r)=>e.check(Qp(n,r)),e.length=(n,r)=>e.check(eh(n,r)),e.unwrap=()=>e.element});function gr(e,t){return AC(HN,e,t)}const Eh=J("ZodObject",(e,t)=>{_j.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>fh(e,n,r,i),ze(e,"shape",()=>t.shape),e.keyof=()=>Th(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Zt()}),e.loose=()=>e.clone({...e._zod.def,catchall:Zt()}),e.strict=()=>e.clone({...e._zod.def,catchall:Nh()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>V1(e,n),e.safeExtend=n=>U1(e,n),e.merge=n=>J1(e,n),e.pick=n=>Z1(e,n),e.omit=n=>B1(e,n),e.partial=(...n)=>H1(zh,e,n[0]),e.required=(...n)=>W1(Ah,e,n[0])});function $e(e,t){const n={type:"object",shape:e??{},...ce(t)};return new Eh(n)}function Ve(e,t){return new Eh({type:"object",shape:e,catchall:Nh(),...ce(t)})}const Ih=J("ZodUnion",(e,t)=>{Yp.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ph(e,n,r,i),e.options=t.options});function ft(e,t){return new Ih({type:"union",options:e,...ce(t)})}const WN=J("ZodDiscriminatedUnion",(e,t)=>{Ih.init(e,t),jj.init(e,t)});function qN(e,t,n){return new WN({type:"union",options:t,discriminator:e,...ce(n)})}const GN=J("ZodIntersection",(e,t)=>{Cj.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>hh(e,n,r,i)});function KN(e,t){return new GN({type:"intersection",left:e,right:t})}const YN=J("ZodRecord",(e,t)=>{Nj.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>mh(e,n,r,i),e.keyType=t.keyType,e.valueType=t.valueType});function Yr(e,t,n){return new YN({type:"record",keyType:e,valueType:t,...ce(n)})}const Pa=J("ZodEnum",(e,t)=>{Ej.init(e,t),He.init(e,t),e._zod.processJSONSchema=(r,i,s)=>oh(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 Pa({...t,checks:[],...ce(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 Pa({...t,checks:[],...ce(i),entries:s})}});function Th(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new Pa({type:"enum",entries:n,...ce(t)})}const XN=J("ZodLiteral",(e,t)=>{Ij.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>lh(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 ye(e,t){return new XN({type:"literal",values:Array.isArray(e)?e:[e],...ce(t)})}const QN=J("ZodTransform",(e,t)=>{Tj.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ch(e,n),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Ap(e.constructor.name);n.addIssue=s=>{if(typeof s=="string")n.issues.push(Kr(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(Kr(a))}};const i=t.transform(n.value,n);return i instanceof Promise?i.then(s=>(n.value=s,n)):(n.value=i,n)}});function eE(e){return new QN({type:"transform",transform:e})}const zh=J("ZodOptional",(e,t)=>{Xp.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Io(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function Ou(e){return new zh({type:"optional",innerType:e})}const tE=J("ZodExactOptional",(e,t)=>{zj.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Io(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function nE(e){return new tE({type:"optional",innerType:e})}const rE=J("ZodNullable",(e,t)=>{Aj.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>gh(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function Du(e){return new rE({type:"nullable",innerType:e})}const iE=J("ZodDefault",(e,t)=>{Pj.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>yh(e,n,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function sE(e,t){return new iE({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Rp(t)}})}const aE=J("ZodPrefault",(e,t)=>{Oj.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>bh(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function oE(e,t){return new aE({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Rp(t)}})}const Ah=J("ZodNonOptional",(e,t)=>{Dj.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>xh(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function lE(e,t){return new Ah({type:"nonoptional",innerType:e,...ce(t)})}const uE=J("ZodCatch",(e,t)=>{Rj.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>vh(e,n,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function cE(e,t){return new uE({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const dE=J("ZodPipe",(e,t)=>{Mj.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>wh(e,n,r,i),e.in=t.in,e.out=t.out});function Ru(e,t){return new dE({type:"pipe",in:e,out:t})}const fE=J("ZodReadonly",(e,t)=>{$j.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>kh(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function pE(e){return new fE({type:"readonly",innerType:e})}const hE=J("ZodLazy",(e,t)=>{Fj.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Sh(e,n,r,i),e.unwrap=()=>e._zod.def.getter()});function mE(e){return new hE({type:"lazy",getter:e})}const To=J("ZodCustom",(e,t)=>{Lj.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>uh(e,n)});function Ph(e,t){return PC(To,e??(()=>!0),t)}function gE(e,t={}){return OC(To,e,t)}function xE(e){return DC(e)}function es(e,t={}){const n=new To({type:"custom",check:"custom",fn:r=>r instanceof e,abort:!0,...ce(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 Xr;(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})(Xr||(Xr={}));var Mu;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(Mu||(Mu={}));Xr.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]);Xr.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 ts 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 ts))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Xr.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()}}ts.create=e=>new ts(e);var $u;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})($u||($u={}));var ve;(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"})(ve||(ve={}));class Fu 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 ia(e){}function yE(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=ia,onError:n=ia,onRetry:r=ia,onComment:i}=e;let s="",a=!0,o,l="",c="";function f(v){const S=a?v.replace(/^\xEF\xBB\xBF/,""):v,[x,_]=bE(`${s}${S}`);for(const m of x)d(m);s=_,a=!1}function d(v){if(v===""){h();return}if(v.startsWith(":")){i&&i(v.slice(v.startsWith(": ")?2:1));return}const S=v.indexOf(":");if(S!==-1){const x=v.slice(0,S),_=v[S+1]===" "?2:1,m=v.slice(S+_);p(x,m,v);return}p(v,"",v)}function p(v,S,x){switch(v){case"event":c=S;break;case"data":l=`${l}${S}
|
|
71
|
+
`;break;case"id":o=S.includes("\0")?void 0:S;break;case"retry":/^\d+$/.test(S)?r(parseInt(S,10)):n(new Fu(`Invalid \`retry\` value: "${S}"`,{type:"invalid-retry",value:S,line:x}));break;default:n(new Fu(`Unknown field "${v.length>20?`${v.slice(0,20)}…`:v}"`,{type:"unknown-field",field:v,value:S,line:x}));break}}function h(){l.length>0&&t({id:o,event:c||void 0,data:l.endsWith(`
|
|
72
|
+
`)?l.slice(0,-1):l}),o=void 0,l="",c=""}function g(v={}){s&&v.consume&&d(s),a=!0,o=void 0,l="",c="",s=""}return{feed:f,reset:g}}function bE(e){const t=[];let n="",r=0;for(;r<e.length;){const i=e.indexOf("\r",r),s=e.indexOf(`
|
|
73
|
+
`,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]===`
|
|
74
|
+
`&&r++}}return[t,n]}class vE extends TransformStream{constructor({onError:t,onRetry:n,onComment:r}={}){let i;super({start(s){i=yE({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 ci=({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 A1({argument:"separator",message:`The separator "${r}" must not be part of the alphabet "${n}".`});return()=>`${e}${r}${i()}`},wE=ci();function Bn(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 kE=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,SE=/"(?: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 Lu(e){const t=JSON.parse(e);return t===null||typeof t!="object"||kE.test(e)===!1&&SE.test(e)===!1?t:_E(t)}function _E(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 jE(e){const{stackTraceLimit:t}=Error;try{Error.stackTraceLimit=0}catch{return Lu(e)}try{return Lu(e)}finally{Error.stackTraceLimit=t}}function zo(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]=kn(n[r])}e.items!=null&&(e.items=Array.isArray(e.items)?e.items.map(kn):kn(e.items)),e.anyOf!=null&&(e.anyOf=e.anyOf.map(kn)),e.allOf!=null&&(e.allOf=e.allOf.map(kn)),e.oneOf!=null&&(e.oneOf=e.oneOf.map(kn));const{definitions:t}=e;if(t!=null)for(const n of Object.keys(t))t[n]=kn(t[n]);return e}function kn(e){return typeof e=="boolean"?e:zo(e)}var CE=Symbol("Let zodToJsonSchema decide on which parser to use"),Zu={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"},NE=e=>typeof e=="string"?{...Zu,name:e}:{...Zu,...e};function jt(){return{}}function EE(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)!==ve.ZodAny&&(s.items=Re(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 IE(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 TE(){return{type:"boolean"}}function Oh(e,t){return Re(e.type._def,t)}var zE=(e,t)=>Re(e.innerType._def,t);function Dh(e,t,n){const r=n??t.dateStrategy;if(Array.isArray(r))return{anyOf:r.map((i,s)=>Dh(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 AE(e)}}var AE=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 PE(e,t){return{...Re(e.innerType._def,t),default:e.defaultValue()}}function OE(e,t){return t.effectStrategy==="input"?Re(e.schema._def,t):jt()}function DE(e){return{type:"string",enum:Array.from(e.values)}}var RE=e=>"type"in e&&e.type==="string"?!1:"allOf"in e;function ME(e,t){const n=[Re(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),Re(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(i=>!!i),r=[];return n.forEach(i=>{if(RE(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 $E(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 sa=void 0,zt={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:()=>(sa===void 0&&(sa=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),sa),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 Rh(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":At(n,"email",r.message,t);break;case"format:idn-email":At(n,"idn-email",r.message,t);break;case"pattern:zod":ot(n,zt.email,r.message,t);break}break;case"url":At(n,"uri",r.message,t);break;case"uuid":At(n,"uuid",r.message,t);break;case"regex":ot(n,r.regex,r.message,t);break;case"cuid":ot(n,zt.cuid,r.message,t);break;case"cuid2":ot(n,zt.cuid2,r.message,t);break;case"startsWith":ot(n,RegExp(`^${aa(r.value,t)}`),r.message,t);break;case"endsWith":ot(n,RegExp(`${aa(r.value,t)}$`),r.message,t);break;case"datetime":At(n,"date-time",r.message,t);break;case"date":At(n,"date",r.message,t);break;case"time":At(n,"time",r.message,t);break;case"duration":At(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":{ot(n,RegExp(aa(r.value,t)),r.message,t);break}case"ip":{r.version!=="v6"&&At(n,"ipv4",r.message,t),r.version!=="v4"&&At(n,"ipv6",r.message,t);break}case"base64url":ot(n,zt.base64url,r.message,t);break;case"jwt":ot(n,zt.jwt,r.message,t);break;case"cidr":{r.version!=="v6"&&ot(n,zt.ipv4Cidr,r.message,t),r.version!=="v4"&&ot(n,zt.ipv6Cidr,r.message,t);break}case"emoji":ot(n,zt.emoji(),r.message,t);break;case"ulid":{ot(n,zt.ulid,r.message,t);break}case"base64":{switch(t.base64Strategy){case"format:binary":{At(n,"binary",r.message,t);break}case"contentEncoding:base64":{n.contentEncoding="base64";break}case"pattern:zod":{ot(n,zt.base64,r.message,t);break}}break}case"nanoid":ot(n,zt.nanoid,r.message,t)}return n}function aa(e,t){return t.patternStrategy==="escape"?LE(e):e}var FE=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function LE(e){let t="";for(let n=0;n<e.length;n++)FE.has(e[n])||(t+="\\"),t+=e[n];return t}function At(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 ot(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:Bu(t,r),...n&&r.errorMessages&&{errorMessage:{pattern:n}}})):e.pattern=Bu(t,r)}function Bu(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
|
|
75
|
+
]))`;continue}else if(i[c]==="$"){s+=`($|(?=[\r
|
|
76
|
+
]))`;continue}}if(r.s&&i[c]==="."){s+=o?`${i[c]}\r
|
|
77
|
+
`:`[${i[c]}\r
|
|
78
|
+
]`;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 Mh(e,t){var n,r,i,s,a,o;const l={type:"object",additionalProperties:(n=Re(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]}))!=null?n:t.allowedAdditionalProperties};if(((r=e.keyType)==null?void 0:r._def.typeName)===ve.ZodString&&((i=e.keyType._def.checks)!=null&&i.length)){const{type:c,...f}=Rh(e.keyType._def,t);return{...l,propertyNames:f}}else{if(((s=e.keyType)==null?void 0:s._def.typeName)===ve.ZodEnum)return{...l,propertyNames:{enum:e.keyType._def.values}};if(((a=e.keyType)==null?void 0:a._def.typeName)===ve.ZodBranded&&e.keyType._def.type._def.typeName===ve.ZodString&&((o=e.keyType._def.type._def.checks)!=null&&o.length)){const{type:c,...f}=Oh(e.keyType._def,t);return{...l,propertyNames:f}}}return l}function ZE(e,t){if(t.mapStrategy==="record")return Mh(e,t);const n=Re(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||jt(),r=Re(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||jt();return{type:"array",maxItems:125,items:{type:"array",items:[n,r],minItems:2,maxItems:2}}}function BE(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 VE(){return{not:jt()}}function UE(){return{type:"null"}}var Oa={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function JE(e,t){const n=e.options instanceof Map?Array.from(e.options.values()):e.options;if(n.every(r=>r._def.typeName in Oa&&(!r._def.checks||!r._def.checks.length))){const r=n.reduce((i,s)=>{const a=Oa[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 HE(e,t)}var HE=(e,t)=>{const n=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((r,i)=>Re(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 WE(e,t){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return{type:[Oa[e.innerType._def.typeName],"null"]};const n=Re(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return n&&{anyOf:[n,{type:"null"}]}}function qE(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 GE(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=YE(o),c=Re(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=KE(e,t);return s!==void 0&&(n.additionalProperties=s),n}function KE(e,t){if(e.catchall._def.typeName!=="ZodNever")return Re(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 YE(e){try{return e.isOptional()}catch{return!0}}var XE=(e,t)=>{var n;if(t.currentPath.toString()===((n=t.propertyPath)==null?void 0:n.toString()))return Re(e.innerType._def,t);const r=Re(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return r?{anyOf:[{not:jt()},r]}:jt()},QE=(e,t)=>{if(t.pipeStrategy==="input")return Re(e.in._def,t);if(t.pipeStrategy==="output")return Re(e.out._def,t);const n=Re(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),r=Re(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 Re(e.type._def,t)}function tI(e,t){const r={type:"array",uniqueItems:!0,items:Re(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 nI(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((n,r)=>Re(n._def,{...t,currentPath:[...t.currentPath,"items",`${r}`]})).reduce((n,r)=>r===void 0?n:[...n,r],[]),additionalItems:Re(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((n,r)=>Re(n._def,{...t,currentPath:[...t.currentPath,"items",`${r}`]})).reduce((n,r)=>r===void 0?n:[...n,r],[])}}function rI(){return{not:jt()}}function iI(){return jt()}var sI=(e,t)=>Re(e.innerType._def,t),aI=(e,t,n)=>{switch(t){case ve.ZodString:return Rh(e,n);case ve.ZodNumber:return qE(e);case ve.ZodObject:return GE(e,n);case ve.ZodBigInt:return IE(e);case ve.ZodBoolean:return TE();case ve.ZodDate:return Dh(e,n);case ve.ZodUndefined:return rI();case ve.ZodNull:return UE();case ve.ZodArray:return EE(e,n);case ve.ZodUnion:case ve.ZodDiscriminatedUnion:return JE(e,n);case ve.ZodIntersection:return ME(e,n);case ve.ZodTuple:return nI(e,n);case ve.ZodRecord:return Mh(e,n);case ve.ZodLiteral:return $E(e);case ve.ZodEnum:return DE(e);case ve.ZodNativeEnum:return BE(e);case ve.ZodNullable:return WE(e,n);case ve.ZodOptional:return XE(e,n);case ve.ZodMap:return ZE(e,n);case ve.ZodSet:return tI(e,n);case ve.ZodLazy:return()=>e.getter()._def;case ve.ZodPromise:return eI(e,n);case ve.ZodNaN:case ve.ZodNever:return VE();case ve.ZodEffects:return OE(e,n);case ve.ZodAny:return jt();case ve.ZodUnknown:return iI();case ve.ZodDefault:return PE(e,n);case ve.ZodBranded:return Oh(e,n);case ve.ZodReadonly:return sI(e,n);case ve.ZodCatch:return zE(e,n);case ve.ZodPipeline:return QE(e,n);case ve.ZodFunction:case ve.ZodVoid:case ve.ZodSymbol:return;default:return(r=>{})()}},oI=(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 Re(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!==CE)return l}if(i&&!n){const l=lI(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=aI(e,e.typeName,t),o=typeof a=="function"?Re(a(),t):a;if(o&&uI(e,t,o),t.postProcess){const l=t.postProcess(o,e,t);return s.jsonSchema=o,l}return s.jsonSchema=o,o}var lI=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:oI(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`),jt()):t.$refStrategy==="seen"?jt():void 0}},uI=(e,t,n)=>(e.description&&(n.description=e.description),n),cI=e=>{const t=NE(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}]))}},dI=(e,t)=>{var n;const r=cI(t);let i=typeof t=="object"&&t.definitions?Object.entries(t.definitions).reduce((c,[f,d])=>{var p;return{...c,[f]:(p=Re(d._def,{...r,currentPath:[...r.basePath,r.definitionPath,f]},!0))!=null?p:jt()}},{}):void 0;const s=typeof t=="string"?t:(t==null?void 0:t.nameStrategy)==="title"||t==null?void 0:t.name,a=(n=Re(e._def,s===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,s]},!1))!=null?n:jt(),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},Da=Symbol.for("vercel.ai.schema");function fI(e){let t;return()=>(t==null&&(t=e()),t)}function Ns(e,{validate:t}={}){return{[Da]:!0,_type:void 0,get jsonSchema(){return typeof e=="function"&&(e=e()),e},validate:t}}function pI(e){return typeof e=="object"&&e!==null&&Da in e&&e[Da]===!0&&"jsonSchema"in e&&"validate"in e}function Ao(e){return e==null?Ns({properties:{},additionalProperties:!1}):pI(e)?e:"~standard"in e?e["~standard"].vendor==="zod"?$h(e):hI(e):e()}function hI(e){return Ns(()=>zo(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 lr({value:t,cause:n.issues})}}})}function mI(e,t){var n;const r=(n=void 0)!=null?n:!1;return Ns(()=>dI(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 gI(e,t){var n;const r=(n=void 0)!=null?n:!1;return Ns(()=>zo(eN(e,{target:"draft-7",io:"input",reused:r?"ref":"inline"})),{validate:async i=>{const s=await _h(e,i);return s.success?{success:!0,value:s.data}:{success:!1,error:s.error}}})}function xI(e){return"_zod"in e}function $h(e,t){return xI(e)?gI(e):mI(e)}async function Vu({value:e,schema:t,context:n}){const r=await Qr({value:e,schema:t,context:n});if(!r.success)throw lr.wrap({value:e,cause:r.error,context:n});return r.value}async function Qr({value:e,schema:t,context:n}){const r=Ao(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:lr.wrap({value:e,cause:i.error,context:n}),rawValue:e}}catch(i){return{success:!1,error:lr.wrap({value:e,cause:i,context:n}),rawValue:e}}}async function Pn({text:e,schema:t}){try{const n=jE(e);return t==null?{success:!0,value:n,rawValue:n}:await Qr({value:n,schema:t})}catch(n){return{success:!1,error:fu.isInstance(n)?n:new fu({text:e,cause:n}),rawValue:void 0}}}function yI({stream:e,schema:t}){return e.pipeThrough(new TextDecoderStream).pipeThrough(new vE).pipeThrough(new TransformStream({async transform({data:n},r){n!=="[DONE]"&&r.enqueue(await Pn({text:n,schema:t}))}}))}async function ln(e){return typeof e=="function"&&(e=e()),Promise.resolve(e)}var bI=Object.defineProperty,vI=(e,t)=>{for(var n in t)bI(e,n,{get:t[n],enumerable:!0})},Fh="AI_NoObjectGeneratedError",Lh=`vercel.ai.error.${Fh}`,wI=Symbol.for(Lh),Zh,dn=class extends qt{constructor({message:e="No object generated.",cause:t,text:n,response:r,usage:i,finishReason:s}){super({name:Fh,message:e,cause:t}),this[Zh]=!0,this.text=n,this.response=r,this.usage=i,this.finishReason=s}static isInstance(e){return qt.hasMarker(e,Lh)}};Zh=wI;var Bh="AI_UIMessageStreamError",Vh=`vercel.ai.error.${Bh}`,kI=Symbol.for(Vh),Uh,Vn=class extends qt{constructor({chunkType:e,chunkId:t,message:n}){super({name:Bh,message:n}),this[Uh]=!0,this.chunkType=e,this.chunkId=t}static isInstance(e){return qt.hasMarker(e,Vh)}};Uh=kI;var Jh=ft([ae(),es(Uint8Array),es(ArrayBuffer),Ph(e=>{var t,n;return(n=(t=globalThis.Buffer)==null?void 0:t.isBuffer(e))!=null?n:!1},{message:"Must be a Buffer"})]),ei=mE(()=>ft([VN(),ae(),FN(),ut(),Yr(ae(),ei.optional()),gr(ei)])),Ne=Yr(ae(),Yr(ae(),ei.optional())),Hh=$e({type:ye("text"),text:ae(),providerOptions:Ne.optional()}),SI=$e({type:ye("image"),image:ft([Jh,es(URL)]),mediaType:ae().optional(),providerOptions:Ne.optional()}),Wh=$e({type:ye("file"),data:ft([Jh,es(URL)]),filename:ae().optional(),mediaType:ae(),providerOptions:Ne.optional()}),_I=$e({type:ye("reasoning"),text:ae(),providerOptions:Ne.optional()}),jI=$e({type:ye("tool-call"),toolCallId:ae(),toolName:ae(),input:Zt(),providerOptions:Ne.optional(),providerExecuted:ut().optional()}),CI=qN("type",[$e({type:ye("text"),value:ae(),providerOptions:Ne.optional()}),$e({type:ye("json"),value:ei,providerOptions:Ne.optional()}),$e({type:ye("execution-denied"),reason:ae().optional(),providerOptions:Ne.optional()}),$e({type:ye("error-text"),value:ae(),providerOptions:Ne.optional()}),$e({type:ye("error-json"),value:ei,providerOptions:Ne.optional()}),$e({type:ye("content"),value:gr(ft([$e({type:ye("text"),text:ae(),providerOptions:Ne.optional()}),$e({type:ye("media"),data:ae(),mediaType:ae()}),$e({type:ye("file-data"),data:ae(),mediaType:ae(),filename:ae().optional(),providerOptions:Ne.optional()}),$e({type:ye("file-url"),url:ae(),providerOptions:Ne.optional()}),$e({type:ye("file-id"),fileId:ft([ae(),Yr(ae(),ae())]),providerOptions:Ne.optional()}),$e({type:ye("image-data"),data:ae(),mediaType:ae(),providerOptions:Ne.optional()}),$e({type:ye("image-url"),url:ae(),providerOptions:Ne.optional()}),$e({type:ye("image-file-id"),fileId:ft([ae(),Yr(ae(),ae())]),providerOptions:Ne.optional()}),$e({type:ye("custom"),providerOptions:Ne.optional()})]))})]),qh=$e({type:ye("tool-result"),toolCallId:ae(),toolName:ae(),output:CI,providerOptions:Ne.optional()}),NI=$e({type:ye("tool-approval-request"),approvalId:ae(),toolCallId:ae()}),EI=$e({type:ye("tool-approval-response"),approvalId:ae(),approved:ut(),reason:ae().optional()}),II=$e({role:ye("system"),content:ae(),providerOptions:Ne.optional()}),TI=$e({role:ye("user"),content:ft([ae(),gr(ft([Hh,SI,Wh]))]),providerOptions:Ne.optional()}),zI=$e({role:ye("assistant"),content:ft([ae(),gr(ft([Hh,Wh,_I,jI,qh,NI]))]),providerOptions:Ne.optional()}),AI=$e({role:ye("tool"),content:gr(ft([qh,EI])),providerOptions:Ne.optional()});ft([II,TI,zI,AI]);function Gh(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]=Gh(s,i):n[r]=i}return n}var PI={};vI(PI,{array:()=>MI,choice:()=>$I,json:()=>FI,object:()=>RI,text:()=>DI});function OI(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 di(e){if(e===void 0)return{value:void 0,state:"undefined-input"};let t=await Pn({text:e});return t.success?{value:t.value,state:"successful-parse"}:(t=await Pn({text:OI(e)}),t.success?{value:t.value,state:"repaired-parse"}:{value:void 0,state:"failed-parse"})}var DI=()=>({name:"text",responseFormat:Promise.resolve({type:"text"}),async parseCompleteOutput({text:e}){return e},async parsePartialOutput({text:e}){return{partial:e}},createElementStreamTransform(){}}),RI=({schema:e,name:t,description:n})=>{const r=Ao(e);return{name:"object",responseFormat:ln(r.jsonSchema).then(i=>({type:"json",schema:i,...t!=null&&{name:t},...n!=null&&{description:n}})),async parseCompleteOutput({text:i},s){const a=await Pn({text:i});if(!a.success)throw new dn({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 Qr({value:a.value,schema:r});if(!o.success)throw new dn({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 di(i);switch(s.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return{partial:s.value}}},createElementStreamTransform(){}}},MI=({element:e,name:t,description:n})=>{const r=Ao(e);return{name:"array",responseFormat:ln(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 Pn({text:i});if(!a.success)throw new dn({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 dn({message:"No object generated: response did not match schema.",cause:new lr({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 Qr({value:l,schema:r});if(!c.success)throw new dn({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 di(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 Qr({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])}})}}},$I=({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 Pn({text:r});if(!s.success)throw new dn({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 dn({message:"No object generated: response did not match schema.",cause:new lr({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 di(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(){}}),FI=({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 Pn({text:n});if(!i.success)throw new dn({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 di(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(){}});ci({prefix:"aitxt",size:24});(class extends TransformStream{constructor(){super({transform(e,t){t.enqueue(`data: ${JSON.stringify(e)}
|
|
79
|
+
|
|
80
|
+
`)},flush(e){e.enqueue(`data: [DONE]
|
|
81
|
+
|
|
82
|
+
`)}})}});var LI=fI(()=>$h(ft([Ve({type:ye("text-start"),id:ae(),providerMetadata:Ne.optional()}),Ve({type:ye("text-delta"),id:ae(),delta:ae(),providerMetadata:Ne.optional()}),Ve({type:ye("text-end"),id:ae(),providerMetadata:Ne.optional()}),Ve({type:ye("error"),errorText:ae()}),Ve({type:ye("tool-input-start"),toolCallId:ae(),toolName:ae(),providerExecuted:ut().optional(),providerMetadata:Ne.optional(),dynamic:ut().optional(),title:ae().optional()}),Ve({type:ye("tool-input-delta"),toolCallId:ae(),inputTextDelta:ae()}),Ve({type:ye("tool-input-available"),toolCallId:ae(),toolName:ae(),input:Zt(),providerExecuted:ut().optional(),providerMetadata:Ne.optional(),dynamic:ut().optional(),title:ae().optional()}),Ve({type:ye("tool-input-error"),toolCallId:ae(),toolName:ae(),input:Zt(),providerExecuted:ut().optional(),providerMetadata:Ne.optional(),dynamic:ut().optional(),errorText:ae(),title:ae().optional()}),Ve({type:ye("tool-approval-request"),approvalId:ae(),toolCallId:ae()}),Ve({type:ye("tool-output-available"),toolCallId:ae(),output:Zt(),providerExecuted:ut().optional(),providerMetadata:Ne.optional(),dynamic:ut().optional(),preliminary:ut().optional()}),Ve({type:ye("tool-output-error"),toolCallId:ae(),errorText:ae(),providerExecuted:ut().optional(),providerMetadata:Ne.optional(),dynamic:ut().optional()}),Ve({type:ye("tool-output-denied"),toolCallId:ae()}),Ve({type:ye("reasoning-start"),id:ae(),providerMetadata:Ne.optional()}),Ve({type:ye("reasoning-delta"),id:ae(),delta:ae(),providerMetadata:Ne.optional()}),Ve({type:ye("reasoning-end"),id:ae(),providerMetadata:Ne.optional()}),Ve({type:ye("source-url"),sourceId:ae(),url:ae(),title:ae().optional(),providerMetadata:Ne.optional()}),Ve({type:ye("source-document"),sourceId:ae(),mediaType:ae(),title:ae(),filename:ae().optional(),providerMetadata:Ne.optional()}),Ve({type:ye("file"),url:ae(),mediaType:ae(),providerMetadata:Ne.optional()}),Ve({type:Ph(e=>typeof e=="string"&&e.startsWith("data-"),{message:'Type must start with "data-"'}),id:ae().optional(),data:Zt(),transient:ut().optional()}),Ve({type:ye("start-step")}),Ve({type:ye("finish-step")}),Ve({type:ye("start"),messageId:ae().optional(),messageMetadata:Zt().optional()}),Ve({type:ye("finish"),finishReason:Th(["stop","length","content-filter","tool-calls","error","other"]).optional(),messageMetadata:Zt().optional()}),Ve({type:ye("abort"),reason:ae().optional()}),Ve({type:ye("message-metadata"),messageMetadata:Zt()})])));function ZI(e){return e.type.startsWith("data-")}function Ra(e){return e.type.startsWith("tool-")}function BI(e){return e.type==="dynamic-tool"}function ns(e){return Ra(e)||BI(e)}function Uu(e){return e.type.split("-").slice(1).join("-")}function VI({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 UI({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,p,h,g;function v(m){const E=c.message.parts.filter(ns).find(w=>w.toolCallId===m);if(E==null)throw new Vn({chunkType:"tool-invocation",chunkId:m,message:`No tool invocation found for tool call ID "${m}".`});return E}function S(m){var I;const E=c.message.parts.find(O=>Ra(O)&&O.toolCallId===m.toolCallId),w=m,N=E;if(E!=null){E.state=m.state,N.input=w.input,N.output=w.output,N.errorText=w.errorText,N.rawInput=w.rawInput,N.preliminary=w.preliminary,m.title!==void 0&&(N.title=m.title),N.providerExecuted=(I=w.providerExecuted)!=null?I:E.providerExecuted;const O=w.providerMetadata;if(O!=null)if(m.state==="output-available"||m.state==="output-error"){const K=E;K.resultProviderMetadata=O}else E.callProviderMetadata=O}else c.message.parts.push({type:`tool-${m.toolName}`,toolCallId:m.toolCallId,state:m.state,title:m.title,input:w.input,output:w.output,rawInput:w.rawInput,errorText:w.errorText,providerExecuted:w.providerExecuted,preliminary:w.preliminary,...w.providerMetadata!=null&&(m.state==="output-available"||m.state==="output-error")?{resultProviderMetadata:w.providerMetadata}:{},...w.providerMetadata!=null&&!(m.state==="output-available"||m.state==="output-error")?{callProviderMetadata:w.providerMetadata}:{}})}function x(m){var I,E;const w=c.message.parts.find(K=>K.type==="dynamic-tool"&&K.toolCallId===m.toolCallId),N=m,O=w;if(w!=null){w.state=m.state,O.toolName=m.toolName,O.input=N.input,O.output=N.output,O.errorText=N.errorText,O.rawInput=(I=N.rawInput)!=null?I:O.rawInput,O.preliminary=N.preliminary,m.title!==void 0&&(O.title=m.title),O.providerExecuted=(E=N.providerExecuted)!=null?E:w.providerExecuted;const K=N.providerMetadata;if(K!=null)if(m.state==="output-available"||m.state==="output-error"){const C=w;C.resultProviderMetadata=K}else w.callProviderMetadata=K}else c.message.parts.push({type:"dynamic-tool",toolName:m.toolName,toolCallId:m.toolCallId,state:m.state,input:N.input,output:N.output,errorText:N.errorText,preliminary:N.preliminary,providerExecuted:N.providerExecuted,title:m.title,...N.providerMetadata!=null&&(m.state==="output-available"||m.state==="output-error")?{resultProviderMetadata:N.providerMetadata}:{},...N.providerMetadata!=null&&!(m.state==="output-available"||m.state==="output-error")?{callProviderMetadata:N.providerMetadata}:{}})}async function _(m){if(m!=null){const I=c.message.metadata!=null?Gh(c.message.metadata,m):m;t!=null&&await Vu({value:I,schema:t,context:{field:"message.metadata",entityId:c.message.id}}),c.message.metadata=I}}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 Vn({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 Vn({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=(p=o.providerMetadata)!=null?p: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 Vn({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=(h=o.providerMetadata)!=null?h:m.providerMetadata,f();break}case"reasoning-end":{const m=c.activeReasoningParts[o.id];if(m==null)throw new Vn({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(Ra);c.partialToolCalls[o.toolCallId]={text:"",toolName:o.toolName,index:m.length,dynamic:o.dynamic,title:o.title},o.dynamic?x({toolCallId:o.toolCallId,toolName:o.toolName,state:"input-streaming",input:void 0,providerExecuted:o.providerExecuted,title:o.title,providerMetadata:o.providerMetadata}):S({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 Vn({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:I}=await di(m.text);m.dynamic?x({toolCallId:o.toolCallId,toolName:m.toolName,state:"input-streaming",input:I,title:m.title}):S({toolCallId:o.toolCallId,toolName:m.toolName,state:"input-streaming",input:I,title:m.title}),f();break}case"tool-input-available":{o.dynamic?x({toolCallId:o.toolCallId,toolName:o.toolName,state:"input-available",input:o.input,providerExecuted:o.providerExecuted,providerMetadata:o.providerMetadata,title:o.title}):S({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(ns).find(E=>E.toolCallId===o.toolCallId);(m!=null?m.type==="dynamic-tool":!!o.dynamic)?x({toolCallId:o.toolCallId,toolName:o.toolName,state:"output-error",input:o.input,errorText:o.errorText,providerExecuted:o.providerExecuted,providerMetadata:o.providerMetadata}):S({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=v(o.toolCallId);m.state="approval-requested",m.approval={id:o.approvalId},f();break}case"tool-output-denied":{const m=v(o.toolCallId);m.state="output-denied",f();break}case"tool-output-available":{const m=v(o.toolCallId);m.type==="dynamic-tool"?x({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}):S({toolCallId:o.toolCallId,toolName:Uu(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=v(o.toolCallId);m.type==="dynamic-tool"?x({toolCallId:o.toolCallId,toolName:m.toolName,state:"output-error",input:m.input,errorText:o.errorText,providerExecuted:o.providerExecuted,providerMetadata:o.providerMetadata,title:m.title}):S({toolCallId:o.toolCallId,toolName:Uu(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 _(o.messageMetadata),(o.messageId!=null||o.messageMetadata!=null)&&f();break}case"finish":{o.finishReason!=null&&(c.finishReason=o.finishReason),await _(o.messageMetadata),o.messageMetadata!=null&&f();break}case"message-metadata":{await _(o.messageMetadata),o.messageMetadata!=null&&f();break}case"error":{i==null||i(new Error(o.errorText));break}default:if(ZI(o)){if((n==null?void 0:n[o.type])!=null){const E=c.message.parts.findIndex(N=>"id"in N&&"data"in N&&N.id===o.id&&N.type===o.type),w=E>=0?E:c.message.parts.length;await Vu({value:o.data,schema:n[o.type],context:{field:`message.parts[${w}].data`,entityName:o.type,entityId:o.id}})}const m=o;if(m.transient){a==null||a(m);break}const I=m.id!=null?c.message.parts.find(E=>m.type===E.type&&m.id===E.id):void 0;I!=null?I.data=m.data:c.message.parts.push(m),a==null||a(m),f()}}l.enqueue(o)})}}))}async function JI({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()}}ci({prefix:"aitxt",size:24});ci({prefix:"aiobj",size:24});var HI=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()})}};ci({prefix:"aiobj",size:24});async function WI(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 qI=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 ln(this.body),l=await ln(this.headers),c=await ln(this.credentials),f={...Bn(l),...Bn(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})),p=(r=d==null?void 0:d.api)!=null?r:this.api,h=(d==null?void 0:d.headers)!==void 0?Bn(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},v=(i=d==null?void 0:d.credentials)!=null?i:c,x=await((s=this.fetch)!=null?s:globalThis.fetch)(p,{method:"POST",headers:{"Content-Type":"application/json",...h},body:JSON.stringify(g),credentials:v,signal:e});if(!x.ok)throw new Error((a=await x.text())!=null?a:"Failed to fetch the chat response.");if(!x.body)throw new Error("The response body is empty.");return this.processResponseStream(x.body)}async reconnectToStream(e){var t,n,r,i,s;const a=await ln(this.body),o=await ln(this.headers),l=await ln(this.credentials),c={...Bn(o),...Bn(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`,p=(f==null?void 0:f.headers)!==void 0?Bn(f.headers):c,h=(r=f==null?void 0:f.credentials)!=null?r:l,v=await((i=this.fetch)!=null?i:globalThis.fetch)(d,{method:"GET",headers:p,credentials:h});if(v.status===204)return null;if(!v.ok)throw new Error((s=await v.text())!=null?s:"Failed to fetch the chat response.");if(!v.body)throw new Error("The response body is empty.");return this.processResponseStream(v.body)}},Kh=class extends qI{constructor(e={}){super(e)}processResponseStream(e){return yI({stream:e,schema:LI}).pipeThrough(new TransformStream({async transform(t,n){if(!t.success)throw t.error;n.enqueue(t.value)}}))}},GI=class{constructor({generateId:e=wE,id:t=e(),transport:n=new Kh,messageMetadataSchema:r,dataPartSchemas:i,state:s,onError:a,onToolCall:o,onFinish:l,onData:c,sendAutomaticallyWhen:f}){this.activeResponse=void 0,this.jobExecutor=new HI,this.sendMessage=async(d,p)=>{var h,g,v,S;if(d==null){await this.makeRequest({trigger:"submit-message",messageId:(h=this.lastMessage)==null?void 0:h.id,...p});return}let x;if("text"in d||"files"in d?x={parts:[...Array.isArray(d.files)?d.files:await WI(d.files),..."text"in d&&d.text!=null?[{type:"text",text:d.text}]:[]]}:x=d,d.messageId!=null){const _=this.state.messages.findIndex(m=>m.id===d.messageId);if(_===-1)throw new Error(`message with id ${d.messageId} not found`);if(this.state.messages[_].role!=="user")throw new Error(`message with id ${d.messageId} is not a user message`);this.state.messages=this.state.messages.slice(0,_+1),this.state.replaceMessage(_,{...x,id:d.messageId,role:(g=x.role)!=null?g:"user",metadata:d.metadata})}else this.state.pushMessage({...x,id:(v=x.id)!=null?v:this.generateId(),role:(S=x.role)!=null?S:"user",metadata:d.metadata});await this.makeRequest({trigger:"submit-message",messageId:d.messageId,...p})},this.regenerate=async({messageId:d,...p}={})=>{const h=d==null?this.state.messages.length-1:this.state.messages.findIndex(g=>g.id===d);if(h===-1)throw new Error(`message ${d} not found`);this.state.messages=this.state.messages.slice(0,this.messages[h].role==="assistant"?h:h+1),await this.makeRequest({trigger:"regenerate-message",messageId:d,...p})},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:p,reason:h,options:g})=>this.jobExecutor.run(async()=>{const v=this.state.messages,S=v[v.length-1],x=_=>ns(_)&&_.state==="approval-requested"&&_.approval.id===d?{..._,state:"approval-responded",approval:{id:d,approved:p,reason:h}}:_;this.state.replaceMessage(v.length-1,{...S,parts:S.parts.map(x)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(x)),this.status!=="streaming"&&this.status!=="submitted"&&this.sendAutomaticallyWhen&&this.shouldSendAutomatically().then(_=>{var m;_&&this.makeRequest({trigger:"submit-message",messageId:(m=this.lastMessage)==null?void 0:m.id,...g})})}),this.addToolOutput=async({state:d="output-available",toolCallId:p,output:h,errorText:g,options:v})=>this.jobExecutor.run(async()=>{const S=this.state.messages,x=S[S.length-1],_=m=>ns(m)&&m.toolCallId===p?{...m,state:d,output:h,errorText:g}:m;this.state.replaceMessage(S.length-1,{...x,parts:x.parts.map(_)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(_)),this.status!=="streaming"&&this.status!=="submitted"&&this.sendAutomaticallyWhen&&this.shouldSendAutomatically().then(m=>{var I;m&&this.makeRequest({trigger:"submit-message",messageId:(I=this.lastMessage)==null?void 0:I.id,...v})})}),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 h=await this.transport.reconnectToStream({chatId:this.id,metadata:t,headers:n,body:r});if(h==null)return;l=h}catch(h){this.onError&&h instanceof Error&&this.onError(h),this.setStatus({status:"error",error:h});return}this.setStatus({status:"submitted",error:void 0});const c=this.lastMessage;let f=!1,d=!1,p=!1;try{const h={state:VI({lastMessage:this.state.snapshot(c),messageId:this.generateId()}),abortController:new AbortController};h.abortController.signal.addEventListener("abort",()=>{f=!0}),this.activeResponse=h;let g;e==="resume-stream"?g=l:g=await this.transport.sendMessages({chatId:this.id,messages:this.state.messages,abortSignal:h.abortController.signal,metadata:t,headers:n,body:r,trigger:e,messageId:i});const v=S=>this.jobExecutor.run(()=>S({state:h.state,write:()=>{var x;this.setStatus({status:"streaming"}),h.state.message.id===((x=this.lastMessage)==null?void 0:x.id)?this.state.replaceMessage(this.state.messages.length-1,h.state.message):this.state.pushMessage(h.state.message)}}));await JI({stream:UI({stream:g,onToolCall:this.onToolCall,onData:this.onData,messageMetadataSchema:this.messageMetadataSchema,dataPartSchemas:this.dataPartSchemas,runUpdateMessageJob:v,onError:S=>{throw S}}),onError:S=>{throw S}}),this.setStatus({status:"ready"})}catch(h){if(f||h.name==="AbortError")return f=!0,this.setStatus({status:"ready"}),null;p=!0,h instanceof TypeError&&(h.message.toLowerCase().includes("fetch")||h.message.toLowerCase().includes("network"))&&(d=!0),this.onError&&h instanceof Error&&this.onError(h),this.setStatus({status:"error",error:h})}finally{try{(a=this.onFinish)==null||a.call(this,{message:this.activeResponse.state.message,messages:this.state.messages,isAbort:f,isDisconnect:d,isError:p,finishReason:(s=this.activeResponse)==null?void 0:s.state.finishReason})}catch(h){console.error(h)}this.activeResponse=void 0}!p&&await this.shouldSendAutomatically()&&await this.makeRequest({trigger:"submit-message",messageId:(o=this.lastMessage)==null?void 0:o.id,metadata:t,headers:n,body:r})}},oa,Ju;function KI(){if(Ju)return oa;Ju=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 oa=e,oa}var YI=KI();const XI=Za(YI);var Yh=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},Ue=(e,t,n)=>(Yh(e,t,"read from private field"),n?n.call(e):t.get(e)),$t=(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)},on=(e,t,n,r)=>(Yh(e,t,"write to private field"),t.set(e,n),n);function QI(e,t){return t!=null?XI(e,t):e}var Ct,Ti,zi,Tr,zr,Ar,Wn,Ma,$a,eT=class{constructor(e=[]){$t(this,Ct,void 0),$t(this,Ti,"ready"),$t(this,zi,void 0),$t(this,Tr,new Set),$t(this,zr,new Set),$t(this,Ar,new Set),this.pushMessage=t=>{on(this,Ct,Ue(this,Ct).concat(t)),Ue(this,Wn).call(this)},this.popMessage=()=>{on(this,Ct,Ue(this,Ct).slice(0,-1)),Ue(this,Wn).call(this)},this.replaceMessage=(t,n)=>{on(this,Ct,[...Ue(this,Ct).slice(0,t),this.snapshot(n),...Ue(this,Ct).slice(t+1)]),Ue(this,Wn).call(this)},this.snapshot=t=>structuredClone(t),this["~registerMessagesCallback"]=(t,n)=>{const r=n?QI(t,n):t;return Ue(this,Tr).add(r),()=>{Ue(this,Tr).delete(r)}},this["~registerStatusCallback"]=t=>(Ue(this,zr).add(t),()=>{Ue(this,zr).delete(t)}),this["~registerErrorCallback"]=t=>(Ue(this,Ar).add(t),()=>{Ue(this,Ar).delete(t)}),$t(this,Wn,()=>{Ue(this,Tr).forEach(t=>t())}),$t(this,Ma,()=>{Ue(this,zr).forEach(t=>t())}),$t(this,$a,()=>{Ue(this,Ar).forEach(t=>t())}),on(this,Ct,e)}get status(){return Ue(this,Ti)}set status(e){on(this,Ti,e),Ue(this,Ma).call(this)}get error(){return Ue(this,zi)}set error(e){on(this,zi,e),Ue(this,$a).call(this)}get messages(){return Ue(this,Ct)}set messages(e){on(this,Ct,[...e]),Ue(this,Wn).call(this)}};Ct=new WeakMap;Ti=new WeakMap;zi=new WeakMap;Tr=new WeakMap;zr=new WeakMap;Ar=new WeakMap;Wn=new WeakMap;Ma=new WeakMap;$a=new WeakMap;var qn,Hu=class extends GI{constructor({messages:e,...t}){const n=new eT(e);super({...t,state:n}),$t(this,qn,void 0),this["~registerMessagesCallback"]=(r,i)=>Ue(this,qn)["~registerMessagesCallback"](r,i),this["~registerStatusCallback"]=r=>Ue(this,qn)["~registerStatusCallback"](r),this["~registerErrorCallback"]=r=>Ue(this,qn)["~registerErrorCallback"](r),on(this,qn,n)}};qn=new WeakMap;function tT({experimental_throttle:e,resume:t=!1,...n}={}){const r=b.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:p=>{var h,g;return(g=(h=r.current).onToolCall)==null?void 0:g.call(h,p)},onData:p=>{var h,g;return(g=(h=r.current).onData)==null?void 0:g.call(h,p)},onFinish:p=>{var h,g;return(g=(h=r.current).onFinish)==null?void 0:g.call(h,p)},onError:p=>{var h,g;return(g=(h=r.current).onError)==null?void 0:g.call(h,p)},sendAutomaticallyWhen:p=>{var h,g,v;return(v=(g=(h=r.current).sendAutomaticallyWhen)==null?void 0:g.call(h,p))!=null?v:!1}},s=b.useRef("chat"in n?n.chat:new Hu(i));("chat"in n&&n.chat!==s.current||"id"in n&&s.current.id!==n.id)&&(s.current="chat"in n?n.chat:new Hu(i));const o=b.useCallback(p=>s.current["~registerMessagesCallback"](p,e),[e,s.current.id]),l=b.useSyncExternalStore(o,()=>s.current.messages,()=>s.current.messages),c=b.useSyncExternalStore(s.current["~registerStatusCallback"],()=>s.current.status,()=>s.current.status),f=b.useSyncExternalStore(s.current["~registerErrorCallback"],()=>s.current.error,()=>s.current.error),d=b.useCallback(p=>{typeof p=="function"&&(p=p(s.current.messages)),s.current.messages=p},[s]);return b.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 Xh(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 Qh(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 em(e,t,n){if(!(n!=null&&n.selectedText)){const i=nT(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=lT(e,n.startLine);l=uT(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=aT(e,t,n.startLine,n.endLine);if(o)return o}const a=Wu(e,t);return a||{original:e,modified:t}}const r=Wu(e,t);return r||{original:e,modified:t}}function nT(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(!Fa(i,r,n))return null;const o=JSON.stringify(i,null,a);return{original:e,modified:o}}function Fa(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(Fa(i,t,n))return!0}return!1}if(e&&typeof e=="object"){for(const r of Object.values(e))if(Fa(r,t,n))return!0}return!1}function Wu(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=rT(t);if(n.length===0)return null;let r=e,i=!1;for(const s of n){const a=iT(r,t,s);a&&(r=a,i=!0)}return i?{original:e,modified:r}:null}function rT(e){const t=[],n=e.split(`
|
|
83
|
+
`),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 iT(e,t,n){const r=`"${n}"`,i=qu(e,r);if(i.length===0)return null;const s=qu(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 p=e.slice(i[d].start,i[d].end),h=oT(p,o);h>f&&(f=h,l=d)}}const c=i[l];return e.slice(0,c.start)+o+e.slice(c.end)}function qu(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!==`
|
|
84
|
+
`&&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=sT(e,l);if(c===-1){r=i+1;continue}n.push({start:i,end:c}),r=c}return n}function sT(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 aT(e,t,n,r){const i=e.split(`
|
|
85
|
+
`);if(n<1||r<n||n>i.length)return null;const s=i.slice(0,n-1).join(`
|
|
86
|
+
`),a=i.slice(r).join(`
|
|
87
|
+
`),o=s+(s?`
|
|
88
|
+
`:"")+t+(a?`
|
|
89
|
+
`:"")+a;return{original:e,modified:o}}function oT(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 lT(e,t){let n=0;const r=e.split(`
|
|
90
|
+
`);for(let i=0;i<Math.min(t-1,r.length);i++)n+=r[i].length+1;return n}function uT(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 cT(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(`
|
|
91
|
+
`);try{return JSON.parse(n),n}catch{}}return null}function dT(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=Xh(r.props.templates||[],i.templates);else return null;return{original:e,modified:JSON.stringify(r,null,2)}}catch{return null}}function fT(){const e=Pe(V=>V.threads),t=Pe(V=>V.activeThreadId),n=Pe(V=>V.updateThreadMessages),r=Pe(V=>V.updateThreadTitle),i=Pe(V=>V.clearContext),s=Pe(V=>V.contextAttachments),a=Pe(V=>V.scope),o=Pe(V=>V.model),l=Oe(V=>V.activeTab),c=Oe(V=>V.documents),f=Oe(V=>V.documentTypes),d=Oe(V=>V.setPendingDiff),p=Oe(V=>V.createDocument),h=Oe(V=>V.openDocument),g=b.useRef(e);g.current=e;const v=b.useRef(l);v.current=l;const S=b.useRef(c);S.current=c;const x=b.useRef(f);x.current=f;const _=b.useRef(t);_.current=t;const m=l?t[l]:void 0,I=b.useRef(m);I.current=m;const E=b.useRef([]),w=b.useRef([]),N=b.useRef({}),O=b.useRef({}),[,K]=b.useState(0),C=b.useCallback(()=>K(V=>V+1),[]),T=b.useRef(null);T.current||(T.current=new Kh({api:"/api/ai/chat"}));const A=b.useCallback(()=>{const V=S.current.find(U=>U.name===v.current);return V?{name:V.name,text:V.text}:void 0},[]),F=b.useCallback(V=>N.current[V]||[],[]),R=tT({transport:T.current,onError:()=>{E.current.shift(),w.current.shift(),i()},onFinish:({messages:V})=>{var W,B;const U=I.current;if(U){n(U,V);const ie=g.current[U];if(ie&&ie.title.startsWith("Chat ")){const te=V.find(X=>X.role==="user");if(te){const X=((W=te.parts)==null?void 0:W.filter(fe=>fe.type==="text").map(fe=>fe.text).join(""))||"";if(X){const fe=X.length>50?X.slice(0,50)+"...":X;r(U,fe)}}}}const se=E.current.shift()||[],k=w.current.shift()||"global",le=V.filter(ie=>ie.role==="user"),q=le[le.length-1];q!=null&&q.id&&(N.current[q.id]=se,O.current[q.id]=k);const y=V.filter(ie=>ie.role==="assistant").pop();if(y){const te=[...(((B=y.parts)==null?void 0:B.filter(X=>X.type==="text").map(X=>X.text).join(""))||"").matchAll(/```(?:json|jsonc)\s*\n([\s\S]*?)```/g)];if(te.length>0){const X=cT(te);if(X){const fe=te[te.length-1][1],be=v.current;if(be){const ne=S.current.find(De=>De.name===be),de=(ne==null?void 0:ne.text)||"",ue=se[0],Z=dT(de,X,k);!Z&&k!=="global"&&console.warn(`[chat] scopedMerge failed for scope="${k}", falling back to text merge`);const{original:ke,modified:me}=Z??em(de,X,ue);d(be,ke,me,Qh(fe.replace(/\n$/,"")))}else{const ne=`ai-generated-${Date.now()}`;p(ne,X),h(ne)}}}}i()}});b.useEffect(()=>{const V=R.messages.filter(U=>U.role==="user");for(let U=V.length-1;U>=0;U--){const se=V[U].id;if(se in N.current)break;E.current.length>0&&(N.current[se]=E.current[0],O.current[se]=w.current[0]||"global",C());break}},[R.messages,C]);const L=b.useCallback((V,U)=>{E.current.push([...s]),w.current.push(a),i();const se={text:V};U!=null&&U.length&&(se.files=U),R.sendMessage(se,{body:{format:yt,context:s,activeDocument:A(),documentType:v.current&&x.current[v.current]||"application/json+report",scope:a,model:o}})},[R.sendMessage,s,A,i,a,o]),P=b.useCallback(V=>O.current[V],[]);return{messages:R.messages,sendMessage:L,status:R.status,error:R.error,setMessages:R.setMessages,stop:R.stop,getMessageContext:F,getMessageScope:P}}const tm=b.createContext(null);function pT({children:e}){const t=fT();return u.jsx(tm.Provider,{value:t,children:e})}function hT(){const e=b.useContext(tm);if(!e)throw new Error("useChatSessionContext must be used within ChatSessionProvider");return e}function mT(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 gT(e,t=50){const n=e.replace(/[\n\r]+/g," ").replace(/\s+/g," ").trim();return n.length>t?n.slice(0,t)+"…":n}function nm({context:e,onRemove:t,variant:n="default"}){var c;const r=mT(e),i=((c=e.documentName)==null?void 0:c.replace(/\.json$/,""))??"",s=i?`${i} › ${r}`:r,a=gT(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(dg,{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(fn,{className:"h-3 w-3"})})]});return u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:l}),u.jsxs(Ke,{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 Un extends Error{constructor(t,n){super(`${t} at position ${n}`),this.position=n}}const rm=32,xT=10,im=9,sm=13,yT=160,bT=6158,vT=8192,wT=8203,kT=8239,ST=8287,_T=12288,jT=65279;function CT(e){return/^[0-9A-Fa-f]$/.test(e)}function Sn(e){return e>="0"&&e<="9"}function NT(e){return e>=" "}function ji(e){return`,:[]/{}()
|
|
92
|
+
+`.includes(e)}function Gu(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"||e==="_"||e==="$"}function Ku(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"||e==="_"||e==="$"||e>="0"&&e<="9"}const Yu=/^(http|https|ftp|mailto|file|data|irc):\/\/$/,Xu=/^[A-Za-z0-9-._~:/?#@!$&'()*+;=]$/;function Qu(e){return`,[]/{}
|
|
93
|
+
+`.includes(e)}function ec(e){return Ai(e)||ET.test(e)}const ET=/^[[{\w-]$/;function IT(e){return e===`
|
|
94
|
+
`||e==="\r"||e===" "||e==="\b"||e==="\f"}function _n(e,t){const n=e.charCodeAt(t);return n===rm||n===xT||n===im||n===sm}function TT(e,t){const n=e.charCodeAt(t);return n===rm||n===im||n===sm}function zT(e,t){const n=e.charCodeAt(t);return n===yT||n===bT||n>=vT&&n<=wT||n===kT||n===ST||n===_T||n===jT}function Ai(e){return am(e)||La(e)}function am(e){return e==='"'||e==="“"||e==="”"}function tc(e){return e==='"'}function La(e){return e==="'"||e==="‘"||e==="’"||e==="`"||e==="´"}function nc(e){return e==="'"}function jr(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 Pt(e,t){let n=e.length;if(!_n(e,n-1))return e+t;for(;_n(e,n-1);)n--;return e.substring(0,n)+t+e.substring(n)}function AT(e,t,n){return e.substring(0,t)+e.substring(t+n)}function PT(e){return/[,\n][ \t\r]*$/.test(e)}const OT={"\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t"},DT={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:`
|
|
95
|
+
`,r:"\r",t:" "};function rc(e){let t=0,n="";c(["```","[```","{```"]),s()||R(),c(["```","```]","```}"]);const i=d(",");for(i&&a(),ec(e[t])&&PT(n)?(i||(n=Pt(n,",")),x()):i&&(n=jr(n,","));e[t]==="}"||e[t]==="]";)t++,a();if(t>=e.length)return n;F();function s(){a();const U=v()||S()||_()||I()||E()||N(!1)||O();return a(),U}function a(){let U=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;const se=t;let k=o(U);do k=l(),k&&(k=o(U));while(k);return t>se}function o(U){const se=U?_n:TT;let k="";for(;;)if(se(e,t))k+=e[t],t++;else if(zT(e,t))k+=" ",t++;else break;return k.length>0?(n+=k,!0):!1}function l(){if(e[t]==="/"&&e[t+1]==="*"){for(;t<e.length&&!RT(e,t);)t++;return t+=2,!0}if(e[t]==="/"&&e[t+1]==="/"){for(;t<e.length&&e[t]!==`
|
|
96
|
+
`;)t++;return!0}return!1}function c(U){if(f(U)){if(Gu(e[t]))for(;t<e.length&&Ku(e[t]);)t++;return a(),!0}return!1}function f(U){o(!0);for(const se of U){const k=t+se.length;if(e.slice(t,k)===se)return t=k,!0}return!1}function d(U){return e[t]===U?(n+=e[t],t++,!0):!1}function p(U){return e[t]===U?(t++,!0):!1}function h(){return p("\\")}function g(){return a(),e[t]==="."&&e[t+1]==="."&&e[t+2]==="."?(t+=3,a(),p(","),!0):!1}function v(){if(e[t]==="{"){n+="{",t++,a(),p(",")&&a();let U=!0;for(;t<e.length&&e[t]!=="}";){let se;if(U?(se=!0,U=!1):(se=d(","),se||(n=Pt(n,",")),a()),g(),!(_()||N(!0))){e[t]==="}"||e[t]==="{"||e[t]==="]"||e[t]==="["||e[t]===void 0?n=jr(n,","):L();break}a();const le=d(":"),q=t>=e.length;le||(ec(e[t])||q?n=Pt(n,":"):P()),s()||(le||q?n+="null":P())}return e[t]==="}"?(n+="}",t++):n=Pt(n,"}"),!0}return!1}function S(){if(e[t]==="["){n+="[",t++,a(),p(",")&&a();let U=!0;for(;t<e.length&&e[t]!=="]";)if(U?U=!1:d(",")||(n=Pt(n,",")),g(),!s()){n=jr(n,",");break}return e[t]==="]"?(n+="]",t++):n=Pt(n,"]"),!0}return!1}function x(){let U=!0,se=!0;for(;se;)U?U=!1:d(",")||(n=Pt(n,",")),se=s();se||(n=jr(n,",")),n=`[
|
|
97
|
+
${n}
|
|
98
|
+
]`}function _(){let U=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,se=arguments.length>1&&arguments[1]!==void 0?arguments[1]:-1,k=e[t]==="\\";if(k&&(t++,k=!0),Ai(e[t])){const le=tc(e[t])?tc:nc(e[t])?nc:La(e[t])?La:am,q=t,y=n.length;let W='"';for(t++;;){if(t>=e.length){const B=K(t-1);return!U&&ji(e.charAt(B))?(t=q,n=n.substring(0,y),_(!0)):(W=Pt(W,'"'),n+=W,!0)}if(t===se)return W=Pt(W,'"'),n+=W,!0;if(le(e[t])){const B=t,ie=W.length;if(W+='"',t++,n+=W,a(!1),U||t>=e.length||ji(e[t])||Ai(e[t])||Sn(e[t]))return m(),!0;const te=K(B-1),X=e.charAt(te);if(X===",")return t=q,n=n.substring(0,y),_(!1,te);if(ji(X))return t=q,n=n.substring(0,y),_(!0);n=n.substring(0,y),t=B+1,W=`${W.substring(0,ie)}\\${W.substring(ie)}`}else if(U&&Qu(e[t])){if(e[t-1]===":"&&Yu.test(e.substring(q+1,t+2)))for(;t<e.length&&Xu.test(e[t]);)W+=e[t],t++;return W=Pt(W,'"'),n+=W,m(),!0}else if(e[t]==="\\"){const B=e.charAt(t+1);if(DT[B]!==void 0)W+=e.slice(t,t+2),t+=2;else if(B==="u"){let te=2;for(;te<6&&CT(e[t+te]);)te++;te===6?(W+=e.slice(t,t+6),t+=6):t+te>=e.length?t=e.length:V()}else W+=B,t+=2}else{const B=e.charAt(t);B==='"'&&e[t-1]!=="\\"?(W+=`\\${B}`,t++):IT(B)?(W+=OT[B],t++):(NT(B)||A(B),W+=B,t++)}k&&h()}}return!1}function m(){let U=!1;for(a();e[t]==="+";){U=!0,t++,a(),n=jr(n,'"',!0);const se=n.length;_()?n=AT(n,se,1):n=Pt(n,'"')}return U}function I(){const U=t;if(e[t]==="-"){if(t++,C())return T(U),!0;if(!Sn(e[t]))return t=U,!1}for(;Sn(e[t]);)t++;if(e[t]==="."){if(t++,C())return T(U),!0;if(!Sn(e[t]))return t=U,!1;for(;Sn(e[t]);)t++}if(e[t]==="e"||e[t]==="E"){if(t++,(e[t]==="-"||e[t]==="+")&&t++,C())return T(U),!0;if(!Sn(e[t]))return t=U,!1;for(;Sn(e[t]);)t++}if(!C())return t=U,!1;if(t>U){const se=e.slice(U,t),k=/^0\d/.test(se);return n+=k?`"${se}"`:se,!0}return!1}function E(){return w("true","true")||w("false","false")||w("null","null")||w("True","true")||w("False","false")||w("None","null")}function w(U,se){return e.slice(t,t+U.length)===U?(n+=se,t+=U.length,!0):!1}function N(U){const se=t;if(Gu(e[t])){for(;t<e.length&&Ku(e[t]);)t++;let k=t;for(;_n(e,k);)k++;if(e[k]==="(")return t=k+1,s(),e[t]===")"&&(t++,e[t]===";"&&t++),!0}for(;t<e.length&&!Qu(e[t])&&!Ai(e[t])&&(!U||e[t]!==":");)t++;if(e[t-1]===":"&&Yu.test(e.substring(se,t+2)))for(;t<e.length&&Xu.test(e[t]);)t++;if(t>se){for(;_n(e,t-1)&&t>0;)t--;const k=e.slice(se,t);return n+=k==="undefined"?"null":JSON.stringify(k),e[t]==='"'&&t++,!0}}function O(){if(e[t]==="/"){const U=t;for(t++;t<e.length&&(e[t]!=="/"||e[t-1]==="\\");)t++;return t++,n+=JSON.stringify(e.substring(U,t)),!0}}function K(U){let se=U;for(;se>0&&_n(e,se);)se--;return se}function C(){return t>=e.length||ji(e[t])||_n(e,t)}function T(U){n+=`${e.slice(U,t)}0`}function A(U){throw new Un(`Invalid character ${JSON.stringify(U)}`,t)}function F(){throw new Un(`Unexpected character ${JSON.stringify(e[t])}`,t)}function R(){throw new Un("Unexpected end of json string",e.length)}function L(){throw new Un("Object key expected",t)}function P(){throw new Un("Colon expected",t)}function V(){const U=e.slice(t,t+6);throw new Un(`Invalid unicode character "${U}"`,t)}}function RT(e,t){return e[t]==="*"&&e[t+1]==="/"}function MT({json:e,context:t,scope:n}){const[r,i]=b.useState(!1),[s,a]=b.useState(null),o=b.useMemo(()=>{try{return JSON.parse(e),e}catch{}try{return rc(e)}catch{}const x=`{${e}}`;try{return JSON.parse(x),x}catch{}try{return rc(x)}catch{return null}},[e]),l=b.useMemo(()=>Qh(o||e),[o,e]),c=Oe(x=>x.activeTab),f=Oe(x=>x.documents),d=Oe(x=>(x.acceptedApplyIds||[]).includes(l)),p=Oe(x=>x.setPendingDiff),h=Oe(x=>x.createDocument),g=Oe(x=>x.openDocument),v=b.useCallback(()=>{if(o){a(null);try{if(c){const x=f.find(w=>w.name===c),_=(x==null?void 0:x.text)||"";if(n==="templates")try{const w=JSON.parse(_),N=JSON.parse(o);if(Array.isArray(N.templates)){w.props||(w.props={}),w.props.templates=Xh(w.props.templates||[],N.templates);const O=JSON.stringify(w,null,2);p(c,_,O,l);return}}catch{}const m=t==null?void 0:t[0],{original:I,modified:E}=em(_,o,m);p(c,I,E,l)}else{const x=`ai-generated-${Date.now()}`;h(x,o),g(x)}}catch(x){a(x instanceof Error?x.message:"Merge failed")}}},[o,c,f,p,h,g,t,n,l]),S=b.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(Ee,{variant:"secondary",size:"sm",onClick:v,disabled:d||!o,children:d?"Applied":o?"Apply to Editor":"Invalid JSON"}),u.jsx(Ee,{variant:"ghost",size:"sm",onClick:S,children:r?u.jsx(pn,{className:"h-3.5 w-3.5"}):u.jsx(os,{className:"h-3.5 w-3.5"})})]}),s&&u.jsx("p",{className:"text-xs text-destructive m-0",children:s})]})}function $T({threads:e,activeThread:t,disabled:n,onSwitch:r,onCreate:i,onDelete:s,onRename:a}){const[o,l]=b.useState(null),[c,f]=b.useState(""),[d,p]=b.useState(null),h=b.useRef(null),g=(t==null?void 0:t.title)||"New Chat",v=g.length>24?g.slice(0,24)+"...":g;b.useEffect(()=>{o&&requestAnimationFrame(()=>{var N;return(N=h.current)==null?void 0:N.focus()})},[o]);const S=b.useCallback((N,O)=>{O.stopPropagation(),O.preventDefault(),l(N.id),f(N.title),p(null)},[]),x=b.useCallback(()=>{o&&c.trim()&&a(o,c.trim()),l(null),f("")},[o,c,a]),_=b.useCallback(()=>{l(null),f("")},[]),m=b.useCallback(N=>{N.stopPropagation(),N.key==="Enter"?(N.preventDefault(),x()):N.key==="Escape"&&(N.preventDefault(),_())},[x,_]),I=b.useCallback((N,O)=>{O.stopPropagation(),O.preventDefault(),p(N),l(null)},[]),E=b.useCallback(N=>{N.stopPropagation(),N.preventDefault(),d&&(s(d),p(null))},[d,s]),w=b.useCallback(N=>{N.stopPropagation(),N.preventDefault(),p(null)},[]);return u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsxs(ds,{onOpenChange:N=>{N||(l(null),p(null))},children:[u.jsx(fs,{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:v}),u.jsx(ti,{className:"h-3 w-3 shrink-0 opacity-60"})]})}),u.jsxs(ai,{align:"start",className:"w-64",children:[e.map(N=>{const O=o===N.id;return d===N.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:E,children:u.jsx(pn,{className:"h-3.5 w-3.5"})}),u.jsx("button",{className:"shrink-0 text-muted-foreground hover:text-foreground transition-colors cursor-pointer",onClick:w,children:u.jsx(fn,{className:"h-3.5 w-3.5"})})]},N.id):O?u.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1",onClick:C=>C.stopPropagation(),onPointerDown:C=>C.stopPropagation(),children:[u.jsx("input",{ref:h,type:"text",value:c,onChange:C=>f(C.target.value),onKeyDown:m,onBlur:x,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:C=>{C.preventDefault(),x()},children:u.jsx(pn,{className:"h-3.5 w-3.5"})}),u.jsx("button",{className:"shrink-0 text-muted-foreground hover:text-foreground transition-colors cursor-pointer",onMouseDown:C=>{C.preventDefault(),_()},children:u.jsx(fn,{className:"h-3.5 w-3.5"})})]},N.id):u.jsxs(Bt,{onSelect:()=>r(N.id),className:`group ${N.id===(t==null?void 0:t.id)?"bg-accent":""}`,children:[u.jsx("span",{className:"truncate flex-1",children:N.title.length>30?N.title.slice(0,30)+"...":N.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:C=>S(N,C),children:u.jsx(fg,{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:C=>I(N.id,C),children:u.jsx(Va,{className:"h-3 w-3"})})]})]},N.id)}),u.jsx(sr,{}),u.jsxs(Bt,{onSelect:N=>{N.preventDefault();const O=i();O&&(l(O),f(Ga()),p(null))},children:[u.jsx(Xt,{className:"h-3.5 w-3.5 mr-1.5"}),"New Chat"]})]})]}),u.jsx(Ee,{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(Xt,{className:"h-3.5 w-3.5"})})]})}const om=new Set(["image/png","image/jpeg","image/gif","image/webp","application/pdf","text/plain","text/markdown","text/csv","text/html"]),FT=Array.from(om).join(","),LT=20*1024*1024,ic=10;function ZT(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 sc(e){return Array.from(e).filter(t=>om.has(t.type)&&t.size<=LT)}function lm(e){return e.startsWith("image/")}function ac(){var G,he,je;const e=Pe(D=>D.contextAttachments),t=Pe(D=>D.addContext),n=Pe(D=>D.removeContext),r=Pe(D=>D.scope),i=Pe(D=>D.setScope),s=Pe(D=>D.model),a=Pe(D=>D.setModel),o=Pe(D=>D.openChat),l=Pe(D=>D.closeChat),c=Pe(D=>D.threads),f=Pe(D=>D.activeThreadId),d=Pe(D=>D.createThread),p=Pe(D=>D.deleteThread),h=Pe(D=>D.switchThread),g=Pe(D=>D.updateThreadMessages),v=Pe(D=>D.updateThreadTitle),S=Pe(D=>D.deleteThreadsForDocument),x=Oe(D=>D.activeTab),_=Oe(D=>D.documents),{messages:m,sendMessage:I,status:E,error:w,setMessages:N,stop:O,getMessageContext:K,getMessageScope:C}=hT(),[T,A]=b.useState(""),[F,R]=b.useState([]),[L,P]=b.useState(!1),[V,U]=b.useState(!1),se=b.useRef(null),k=b.useRef(null),le=b.useRef(null),q=b.useCallback(async D=>{const ge=sc(D);if(ge.length===0)return;const Te=await Promise.all(ge.map(ZT));R(Le=>{const nt=[...Le,...Te];return nt.length>ic?nt.slice(0,ic):nt})},[]),y=b.useCallback(D=>{R(ge=>ge.filter((Te,Le)=>Le!==D))},[]),W=b.useCallback(D=>{var Te;const ge=(Te=D.clipboardData)==null?void 0:Te.files;if(ge&&ge.length>0){const Le=sc(ge);Le.length>0&&(D.preventDefault(),q(Le))}},[q]),B=b.useCallback(D=>{var Te;D.preventDefault(),U(!1);const ge=(Te=D.dataTransfer)==null?void 0:Te.files;ge&&ge.length>0&&q(Array.from(ge))},[q]),ie=b.useCallback(D=>{D.preventDefault(),U(!0)},[]),te=b.useCallback(()=>U(!1),[]),X=x?f[x]:void 0,fe=X?c[X]:void 0,be=b.useMemo(()=>x?Object.values(c).filter(D=>D.documentName===x).sort((D,ge)=>ge.updatedAt-D.updatedAt):[],[c,x]);b.useEffect(()=>{x&&be.length===0&&d(x)},[x,be.length,d]);const ne=b.useRef(c);ne.current=c,b.useEffect(()=>{const D=new Set(_.map(Te=>Te.name)),ge=new Set;for(const Te of Object.values(ne.current))!D.has(Te.documentName)&&Te.documentName!=="__migrated__"&&ge.add(Te.documentName);for(const Te of ge)S(Te)},[_,S]);const de=b.useRef(null);b.useEffect(()=>{de.current!==X&&(de.current=X,N((fe==null?void 0:fe.messages)??[]))},[X,fe,N]),b.useEffect(()=>{var D;(D=se.current)==null||D.scrollIntoView({behavior:"smooth"})},[m,E]),b.useEffect(()=>{const D=ge=>{var nt;const{documentName:Te,selection:Le}=ge.detail;t({...Le,documentName:Te}),o(),(nt=k.current)==null||nt.focus()};return window.addEventListener("monaco-selection-to-ai",D),()=>window.removeEventListener("monaco-selection-to-ai",D)},[t,o]);const ue=E==="streaming",Z=E==="submitted"||ue,ke=b.useCallback(D=>{D.preventDefault(),!(!T.trim()&&F.length===0||Z)&&(I(T,F.length>0?F:void 0),A(""),R([]))},[T,F,Z,I]),me=b.useCallback(D=>{D.key==="Enter"&&!D.shiftKey&&(D.preventDefault(),ke(D))},[ke]),De=b.useCallback(()=>{m.length!==0&&P(!0)},[m.length]),j=b.useCallback(()=>{P(!1),N([]),X&&(g(X,[]),v(X,Ga()))},[N,X,g,v]),[z,M]=b.useState(null),re=b.useCallback(D=>{M(D)},[]),ee=b.useCallback(()=>{var nt,et;if(!z)return;const D=m.findIndex(it=>it.id===z);if(D===-1){M(null);return}const ge=m[D],Te=new Set([D]);ge.role==="user"&&((nt=m[D+1])==null?void 0:nt.role)==="assistant"?Te.add(D+1):ge.role==="assistant"&&D>0&&((et=m[D-1])==null?void 0:et.role)==="user"&&Te.add(D-1);const Le=m.filter((it,rn)=>!Te.has(rn));N(Le),X&&g(X,Le),M(null)},[z,m,N,X,g]),Q=b.useCallback(D=>{if(!Z){if(be.length<=1){De();return}p(D)}},[Z,be.length,De,p]),pe=b.useCallback(()=>{if(!(!x||Z))return d(x)},[x,Z,d]),we=b.useCallback(D=>{Z||D===X||h(D)},[Z,X,h]),$=b.useCallback((D,ge)=>{v(D,ge)},[v]);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($T,{threads:be,activeThread:fe,disabled:Z,onSwitch:we,onCreate:pe,onDelete:Q,onRename:$}),u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsx(Ee,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs text-muted-foreground hover:text-foreground",onClick:De,disabled:Z||m.length===0,children:"Clear"}),u.jsx(Ee,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:l,title:"Close chat",children:u.jsx(fn,{className:"h-3.5 w-3.5"})})]})]}),u.jsx(Zr,{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(Do,{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(Br,{shortcut:"mod+k"}),u.jsx("span",{className:"text-xs text-muted-foreground",children:"to send a selection"})]})]}),m.map((D,ge)=>{let Te;if(D.role==="user"){const et=K(D.id);et&&et.length>0&&(Te=et)}else if(D.role==="assistant"){for(let et=ge-1;et>=0;et--)if(m[et].role==="user"){Te=K(m[et].id);break}}const Le=ue&&ge===m.length-1&&D.role==="assistant",nt=D.role==="user"?C(D.id):void 0;return u.jsx(BT,{msg:D,isStreaming:Le,context:Te,scope:nt,onDelete:Z?void 0:re},D.id)}),Z&&((G=m[m.length-1])==null?void 0:G.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(la,{className:"h-3.5 w-3.5 animate-spin text-primary"}),u.jsx("span",{children:"Thinking..."})]})})}),w&&!Z&&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:w.message||"Something went wrong"})}),u.jsx("div",{ref:se})]})}),u.jsxs("div",{className:`border-t border-border/60 p-2.5 space-y-2 bg-surface-chat transition-colors ${V?"ring-2 ring-primary/40 bg-primary/5":""}`,onDrop:B,onDragOver:ie,onDragLeave:te,children:[e.length>0&&u.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.map((D,ge)=>u.jsx(nm,{context:D,onRemove:()=>n(ge)},ge))}),u.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[u.jsx(JT,{model:s,setModel:a}),yt==="pptx"&&x&&u.jsx(WT,{scope:r,setScope:i,docSize:((je=(he=_.find(D=>D.name===x))==null?void 0:he.text)==null?void 0:je.length)??0})]}),F.length>0&&u.jsx("div",{className:"flex flex-wrap gap-1.5",children:F.map((D,ge)=>u.jsxs("div",{className:"relative group",children:[lm(D.mediaType)?u.jsx("img",{src:D.url,alt:D.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(ua,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),u.jsx("span",{className:"text-xs truncate text-muted-foreground",children:D.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(fn,{className:"h-3 w-3"})})]},ge))}),u.jsxs("form",{onSubmit:ke,className:"flex items-end gap-2",children:[u.jsx("input",{ref:le,type:"file",accept:FT,multiple:!0,className:"hidden",onChange:D=>{D.target.files&&q(Array.from(D.target.files)),D.target.value=""}}),u.jsx(Ee,{type:"button",variant:"ghost",size:"icon",className:"shrink-0 h-9 w-9 rounded-lg text-muted-foreground hover:text-foreground",onClick:()=>{var D;return(D=le.current)==null?void 0:D.click()},title:"Attach file",children:u.jsx(ua,{className:"h-4 w-4"})}),u.jsx("textarea",{ref:k,value:T,onChange:D=>{A(D.target.value);const ge=D.target;ge.style.height="auto",ge.style.height=`${Math.min(ge.scrollHeight,128)}px`},onKeyDown:me,onPaste:W,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}),Z?u.jsx(Ee,{type:"button",size:"icon",variant:"destructive",className:"shrink-0 h-9 w-9 rounded-lg",onClick:O,title:"Stop generating",children:u.jsx(pg,{className:"h-4 w-4"})}):u.jsx(Ee,{type:"submit",size:"icon",disabled:!T.trim()&&F.length===0,className:"shrink-0 h-9 w-9 rounded-lg",children:u.jsx(Do,{className:"h-4 w-4"})})]})]}),u.jsx(It,{open:L,onOpenChange:P,children:u.jsxs(St,{className:"max-w-sm",children:[u.jsxs(Ht,{children:[u.jsx(Wt,{children:"Clear thread"}),u.jsx(hn,{children:"This will delete all messages in this thread. This action cannot be undone."})]}),u.jsxs(In,{children:[u.jsx(Ro,{asChild:!0,children:u.jsx(Ee,{variant:"ghost",size:"sm",children:"Cancel"})}),u.jsx(Ee,{variant:"destructive",size:"sm",onClick:j,children:"Clear"})]})]})}),u.jsx(It,{open:z!==null,onOpenChange:D=>{D||M(null)},children:u.jsxs(St,{className:"max-w-sm",children:[u.jsxs(Ht,{children:[u.jsx(Wt,{children:"Delete message"}),u.jsx(hn,{children:"This will delete the message and its paired response. This action cannot be undone."})]}),u.jsxs(In,{children:[u.jsx(Ro,{asChild:!0,children:u.jsx(Ee,{variant:"ghost",size:"sm",children:"Cancel"})}),u.jsx(Ee,{variant:"destructive",size:"sm",onClick:ee,children:"Delete"})]})]})})]})}const BT=b.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)=>lm(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(ua,{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(nm,{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(VT,{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(Va,{className:"h-3 w-3"})})})]})})},(e,t)=>e.msg.id===t.msg.id&&e.msg===t.msg&&e.isStreaming===t.isStreaming&&e.scope===t.scope&&e.onDelete===t.onDelete&&e.context===t.context);function VT({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(gk,{remarkPlugins:[I1],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(qT,{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(MT,{json:l,context:n,scope:r})]})}},children:e})})}const UT=[{value:"opus",label:"Opus"},{value:"sonnet",label:"Sonnet"},{value:"haiku",label:"Haiku"}];function JT({model:e,setModel:t}){return u.jsxs(Fr,{value:e,onValueChange:n=>t(n),children:[u.jsx(rr,{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(Lr,{})}),u.jsx(ir,{children:UT.map(n=>u.jsx(Tn,{value:n.value,className:"text-xs",children:n.label},n.value))})]})}const oc={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"},HT=1e5;function WT({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(oc).map(r=>u.jsxs(qe,{children:[u.jsx(Ge,{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(Ke,{side:"top",className:"text-xs max-w-[200px]",children:oc[r]})]},r))})]}),e==="global"&&n>HT&&u.jsxs("div",{className:"text-[10px] text-warning flex items-center gap-1",children:[u.jsx(Xc,{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 qT({text:e}){const[t,n]=b.useState(!1),r=b.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 GT({discoveryData:e}){const t=$d(),n=_x(),r=Pe(C=>C.chatOpen),i=Pe(C=>C.toggleChat),[s,a]=b.useState(()=>{try{const C=localStorage.getItem("dev-env.sidebar-open");return n?!1:C?C==="true":!0}catch{return!n}}),[o,l]=b.useState(()=>{try{const C=localStorage.getItem("dev-env.preview-open");return C?C==="true":!0}catch{return!0}}),[c,f]=b.useState("editor"),[d,p]=b.useState(!1),h=150,[g,v]=b.useState(!s),[S,x]=b.useState(!1);b.useEffect(()=>{try{localStorage.setItem("dev-env.sidebar-open",String(s))}catch{}},[s]),b.useEffect(()=>{try{localStorage.setItem("dev-env.preview-open",String(o))}catch{}},[o]);const _=b.useRef(n);b.useEffect(()=>{n&&!_.current&&s&&(x(!0),a(!1),setTimeout(()=>{v(!0),x(!1)},h)),!n&&_.current&&!s&&(x(!0),a(!0),setTimeout(()=>{v(!1),x(!1)},h)),_.current=n},[n,s]);const m=b.useCallback(()=>{if(t){p(C=>!C);return}x(!0),a(C=>!C),setTimeout(()=>{v(C=>!C),x(!1)},h)},[t]),I=b.useCallback(()=>l(C=>!C),[]),E=b.useRef(i),w=b.useRef(m),N=b.useRef(I);b.useEffect(()=>{E.current=i}),b.useEffect(()=>{w.current=m}),b.useEffect(()=>{N.current=I}),b.useEffect(()=>{const C=T=>{(T.metaKey||T.ctrlKey)&&(T.code==="KeyB"&&!T.shiftKey&&(T.preventDefault(),w.current()),T.code==="KeyJ"&&T.shiftKey&&(T.preventDefault(),T.stopPropagation(),E.current()),T.code==="KeyP"&&T.shiftKey&&(T.preventDefault(),N.current()))};return window.addEventListener("keydown",C,!0),()=>window.removeEventListener("keydown",C,!0)},[]);const O=pT,K=[{key:"editor",icon:Qc,label:"Editor"},{key:"preview",icon:ed,label:"Preview"},{key:"chat",icon:td,label:"Chat"}];return t?u.jsx(O,{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(Dd,{open:d,onOpenChange:p,children:[u.jsx(bx,{asChild:!0,children:u.jsx(Ee,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0",children:u.jsx(Yc,{className:"h-4 w-4"})})}),u.jsx(Ya,{side:"left",className:"p-0 w-72",children:u.jsx(Qo,{discoveryData:e,onToggleSidebar:()=>p(!1),isCollapsed:!1})})]}),u.jsx("div",{className:"flex gap-0.5 flex-1 min-w-0",children:K.map(({key:C,icon:T,label:A})=>u.jsxs(Ee,{variant:c===C?"default":"ghost",size:"sm",className:"h-7 gap-1.5 text-xs flex-1",onClick:()=>f(C),children:[u.jsx(T,{className:"h-3.5 w-3.5"}),u.jsx("span",{className:"hidden xs:inline",children:A})]},C))})]}),c!=="chat"&&u.jsx(gl,{previewOpen:o,onTogglePreview:I}),u.jsxs("div",{className:"flex-1 min-h-0",children:[c==="editor"&&u.jsx("div",{className:"h-full bg-surface-editor",children:u.jsx(el,{})}),c==="preview"&&u.jsx("div",{className:"h-full bg-surface-preview",children:u.jsx(tl,{})}),c==="chat"&&u.jsx(ac,{})]})]})}):u.jsx(O,{children:u.jsxs("div",{className:"flex h-full w-full overflow-hidden",children:[u.jsx("div",{className:H("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(Qo,{discoveryData:e,onToggleSidebar:m,isCollapsed:g,isAnimating:S})}),u.jsxs("div",{className:"flex-1 min-w-0 flex flex-col h-full",children:[u.jsx(gl,{previewOpen:o,onTogglePreview:I}),u.jsxs(Fy,{direction:"horizontal",autoSaveId:"layout-main",className:"flex-1 min-h-0",children:[u.jsx(Ms,{defaultSize:o?50:100,minSize:20,id:"editor",order:1,children:u.jsx("div",{className:"h-full bg-surface-editor",children:u.jsx(el,{})})}),o&&u.jsxs(u.Fragment,{children:[u.jsx(dl,{withHandle:!0}),u.jsx(Ms,{defaultSize:50,minSize:20,id:"preview",order:2,children:u.jsx("div",{className:"h-full bg-surface-preview",children:u.jsx(tl,{})})})]}),r&&u.jsxs(u.Fragment,{children:[u.jsx(dl,{withHandle:!0}),u.jsx(Ms,{defaultSize:30,minSize:25,maxSize:50,id:"chat",order:3,children:u.jsx(ac,{})})]})]})]})]})})}function KT(){const[e,t]=b.useState(null),[n,r]=b.useState(!0),[i,s]=b.useState(null),a=b.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 b.useEffect(()=>{a()},[a]),{data:e,loading:n,error:i,refetch:a}}function YT(){const[e,t]=b.useState(!1),[n,r]=b.useState(null),[i,s]=b.useState(0);return{loadPlugins:b.useCallback(async()=>{t(!0),r(null);try{const o=await fetch("/api/discovery/load-plugins",{method:"POST"});if(!o.ok)throw new Error(`Failed to load plugins: ${o.statusText}`);const l=await o.json();if(!l.success)throw new Error(l.error||"Failed to load plugins");return s(l.data.loaded),!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 XT(){const{data:e,loading:t,error:n}=KT(),{loadPlugins:r}=YT(),i=Dt(s=>s.applyPluginsWithValidation);return b.useEffect(()=>{e&&e.plugins.length>0&&r().then(s=>{if(s){console.log("Plugins loaded successfully");const a=Dt.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(gg,{children:u.jsx(xg,{children:u.jsx(yg,{children:u.jsx(bg,{children:u.jsx(vg,{children:u.jsx(nx,{children:u.jsx(Ld,{children:u.jsx("section",{className:"flex h-screen w-full flex-col",children:u.jsx("div",{className:"grow overflow-hidden",children:u.jsx(GT,{discoveryData:e})})})})})})})})})})}const lz=Object.freeze(Object.defineProperty({__proto__:null,HomePage:XT},Symbol.toStringTag,{value:"Module"}));export{Jt as B,It as D,lz as H,Hy as P,Dr as S,Hr as T,yf as a,Od as b,St as c,Ht as d,Wt as e,By as u};
|
|
99
|
+
//# sourceMappingURL=HomePage-C3rGwXmP.js.map
|