@json-to-office/jto 0.28.1 → 0.30.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.
Files changed (27) hide show
  1. package/dist/cli.js +167 -40
  2. package/dist/cli.js.map +1 -1
  3. package/dist/client/assets/HomePage-DdoBbkci.js +99 -0
  4. package/dist/client/assets/HomePage-DdoBbkci.js.map +1 -0
  5. package/dist/client/assets/{JsonEditorPage-CzMTUrNe.js → JsonEditorPage-DzwrMvnL.js} +3 -3
  6. package/dist/client/assets/{JsonEditorPage-CzMTUrNe.js.map → JsonEditorPage-DzwrMvnL.js.map} +1 -1
  7. package/dist/client/assets/{MonacoPluginProvider-CmMAmp3u.js → MonacoPluginProvider-YJNcGGax.js} +3 -3
  8. package/dist/client/assets/{MonacoPluginProvider-CmMAmp3u.js.map → MonacoPluginProvider-YJNcGGax.js.map} +1 -1
  9. package/dist/client/assets/{button-BEg2__r6.js → button-D-eAs5li.js} +2 -2
  10. package/dist/client/assets/{button-BEg2__r6.js.map → button-D-eAs5li.js.map} +1 -1
  11. package/dist/client/assets/{editor-DPs_adn-.js → editor-3sZ4Fpsu.js} +2 -2
  12. package/dist/client/assets/{editor-DPs_adn-.js.map → editor-3sZ4Fpsu.js.map} +1 -1
  13. package/dist/client/assets/{editor-monaco-json-xnoKHnLp.js → editor-monaco-json-Cm5QFfZ9.js} +2 -2
  14. package/dist/client/assets/{editor-monaco-json-xnoKHnLp.js.map → editor-monaco-json-Cm5QFfZ9.js.map} +1 -1
  15. package/dist/client/assets/{index-DgKS-gEZ.js → index-Cfi2fdyV.js} +3 -3
  16. package/dist/client/assets/{index-DgKS-gEZ.js.map → index-Cfi2fdyV.js.map} +1 -1
  17. package/dist/client/assets/preview-CC4_sT2f.js +3 -0
  18. package/dist/client/assets/preview-CC4_sT2f.js.map +1 -0
  19. package/dist/client/index.html +1 -1
  20. package/dist/render-server.d.ts +2 -1
  21. package/dist/render-server.js +149 -36
  22. package/dist/render-server.js.map +1 -1
  23. package/package.json +7 -7
  24. package/dist/client/assets/HomePage-g8gOpx6G.js +0 -99
  25. package/dist/client/assets/HomePage-g8gOpx6G.js.map +0 -1
  26. package/dist/client/assets/preview-RxIHvUjz.js +0 -3
  27. package/dist/client/assets/preview-RxIHvUjz.js.map +0 -1
@@ -0,0 +1,99 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/editor-3sZ4Fpsu.js","assets/react-vendor-CTFDOf2G.js","assets/editor-monaco-json-Cm5QFfZ9.js","assets/index-Cfi2fdyV.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-YJNcGGax.js","assets/button-D-eAs5li.js","assets/preview-CC4_sT2f.js"])))=>i.map(i=>d[i]);
2
+ var cm=Object.defineProperty;var dm=(e,t,n)=>t in e?cm(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Oo=(e,t,n)=>dm(e,typeof t!="symbol"?t+"":t,n);import{r as b,j as l,c as Se,R as uc,g as Ba}from"./react-vendor-CTFDOf2G.js";import{b as cc,c as Va,d as dc,e as rs,f as is,D as ss,O as as,g as fm,V as pm,h as fc,I as hm,i as mm,j as pc,k as gm,l as hc,m as xm,n as ym,G as bm,S as mc,o as gc,L as xc,p as yc,q as bc,r as dr,s as vm,t as wm,u as km,v as vc,w as wc,x as kc,y as Sc,z as _c,B as jc,E as Cc,F as Nc,H as Ec,J as Sm,K as _m,M as jm,N as Ic,Q as Tc,U as zc,W as Ac,X as Pc,Y as Oc,Z as Dc,_ as Rc,$ as Mc,a0 as $c,a1 as Cm,a2 as Fc,a3 as Nm,a4 as Em,a5 as Lc,a6 as Im,a7 as Tm,a8 as zm,a9 as Am,aa as Pm,ab as Om,ac as Dm,ad as Zc,ae as Bc,af as Vc}from"./radix-ui-Bq-7y_Sq.js";import{c as H,u as fr,S as en,A as Uc,T as fi,C as Rm,E as Mm,F as yt,a as $m,b as Fm,d as We,e as qe,f as Ge,g as Jc,_ as Hc,h as pi,i as Lm,j as Zm,k as Bm,l as xr,s as Es,m as Ci,W as Vm}from"./index-Cfi2fdyV.js";import{X as pn,C as ti,a as hn,b as Um,d as ni,G as Wc,F as Jm,e as ri,f as qc,P as Hm,g as Wm,h as Gc,E as Kc,S as qm,B as Do,i as Gm,j as Km,k as Ym,l as os,m as Xm,M as Qm,I as Yc,n as Xt,o as eg,p as tg,q as Xc,r as ng,s as rg,t as ig,u as sg,R as ag,v as og,T as Qc,w as lg,x as ug,y as cg,z as la,A as Ua,D as ed,H as dg,J as td,L as ua,K as fg,N as pg,O as Ro,Q as ca,U as hg}from"./ui-vendor-Nd4Lg2re.js";import{B as Ce}from"./button-D-eAs5li.js";import{u as Oe,i as mg,a as da,b as Qt,g as gg,c as Rt,T as nd,d as hi,S as xg,O as yg,e as bg,M as vg,D as wg}from"./MonacoPluginProvider-YJNcGGax.js";import{u as rd,a as kg,d as Sg,p as _g,b as jg,e as Cg}from"./state-vendor-ByFYl9bq.js";import{b as Ng}from"./query-vendor-Df8-oete.js";const _t=cc,Eg=dc,Mo=Va,id=b.forwardRef(({className:e,...t},n)=>l.jsx(as,{ref:n,className:H("fixed inset-0 z-50 bg-black/50",e),...t}));id.displayName=as.displayName;const bt=b.forwardRef(({className:e,children:t,...n},r)=>l.jsxs(Eg,{children:[l.jsx(id,{}),l.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,l.jsxs(Va,{className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 cursor-pointer rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-none disabled:pointer-events-none",children:[l.jsx(pn,{className:"h-4 w-4"}),l.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));bt.displayName=rs.displayName;const Ft=({className:e,...t})=>l.jsx("div",{className:H("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Ft.displayName="DialogHeader";const mn=({className:e,...t})=>l.jsx("div",{className:H("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});mn.displayName="DialogFooter";const Lt=b.forwardRef(({className:e,...t},n)=>l.jsx(is,{ref:n,className:H("text-lg leading-none font-semibold tracking-tight",e),...t}));Lt.displayName=is.displayName;const nn=b.forwardRef(({className:e,...t},n)=>l.jsx(ss,{ref:n,className:H("text-muted-foreground text-sm",e),...t}));nn.displayName=ss.displayName;const Fr=fm,Ig=bm,Lr=pm,rr=b.forwardRef(({className:e,children:t,...n},r)=>l.jsxs(fc,{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,l.jsx(hm,{asChild:!0,children:l.jsx(ti,{className:"h-4 w-4 shrink-0 opacity-50"})})]}));rr.displayName=fc.displayName;const sd=b.forwardRef(({className:e,...t},n)=>l.jsx(mc,{ref:n,className:H("flex cursor-default items-center justify-center py-1",e),...t,children:l.jsx(Um,{className:"h-4 w-4"})}));sd.displayName=mc.displayName;const ad=b.forwardRef(({className:e,...t},n)=>l.jsx(gc,{ref:n,className:H("flex cursor-default items-center justify-center py-1",e),...t,children:l.jsx(ti,{className:"h-4 w-4"})}));ad.displayName=gc.displayName;const ir=b.forwardRef(({className:e,children:t,position:n="popper",...r},i)=>l.jsx(mm,{children:l.jsxs(pc,{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:[l.jsx(sd,{}),l.jsx(gm,{className:H("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),l.jsx(ad,{})]})}));ir.displayName=pc.displayName;const od=b.forwardRef(({className:e,...t},n)=>l.jsx(xc,{ref:n,className:H("px-2 py-1.5 text-sm font-semibold",e),...t}));od.displayName=xc.displayName;const Tn=b.forwardRef(({className:e,children:t,...n},r)=>l.jsxs(hc,{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:[l.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:l.jsx(xm,{children:l.jsx(hn,{className:"h-4 w-4"})})}),l.jsx(ym,{children:t})]}));Tn.displayName=hc.displayName;const Tg=b.forwardRef(({className:e,...t},n)=>l.jsx(yc,{ref:n,className:H("bg-muted -mx-1 my-1 h-px",e),...t}));Tg.displayName=yc.displayName;const ii=b.forwardRef(({className:e,type:t,...n},r)=>l.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 zg=ni("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Xn=b.forwardRef(({className:e,...t},n)=>l.jsx(bc,{ref:n,className:H(zg(),e),...t}));Xn.displayName=bc.displayName;const Ag=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 Wt({className:e,variant:t,...n}){return l.jsx("div",{className:H(Ag({variant:t}),e),...n})}const Pg=({open:e,onOpenChange:t})=>{const{documents:n,documentTypes:r,activeTab:i,createDocument:s,openDocument:a}=Oe(rd(z=>({documents:z.documents,documentTypes:z.documentTypes,activeTab:z.activeTab,createDocument:z.createDocument,openDocument:z.openDocument}))),{toast:o}=fr(),u=b.useMemo(()=>n.filter(z=>r[z.name]!=="application/json+theme"),[n,r]),[c,f]=b.useState(""),[d,p]=b.useState(""),[h,m]=b.useState("playground"),[v,S]=b.useState(!1),[x,j]=b.useState(null),[g,I]=b.useState(null),[E,k]=b.useState(null),N=()=>{j(null),I(null),k(null)};b.useEffect(()=>{if(!e)return;j(null),I(null),k(null);const z=u.map(M=>M.name),A=z.includes(i)?i:z[0]??"";p(A),f(z.find(M=>M!==A)??"")},[e]);const J=async()=>{const z=u.find(M=>M.name===c),A=u.find(M=>M.name===d);if(!(!z||!A)){S(!0),j(null),I(null),k(null);try{const M=await fetch(Uc.diff,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldDefinition:z.text,newDefinition:A.text,options:{author:h||"playground"}})}),$=await M.json();if(!M.ok||!$.success){const F=Array.isArray($.errors)?`: ${$.errors.slice(0,3).map(P=>P.message||String(P)).join("; ")}`:"";throw new Error(($.error||`Diff failed (${M.status})`)+F)}I($.data.summary),k($.data.document)}catch(M){j(M instanceof Error?M.message:"Diff failed")}finally{S(!1)}}},L=()=>{if(!E)return;const z=new Set(n.map($=>$.name));let A=`${d}-redline`,M=2;for(;z.has(A);)A=`${d}-redline-${M++}`;s(A,JSON.stringify(E,null,2)),a(A),o({title:`Redline created: ${A}`}),t(!1)},C=g?g.tracked.modified+g.tracked.inserted+g.tracked.deleted:0;return l.jsx(_t,{open:e,onOpenChange:t,children:l.jsxs(bt,{className:"sm:max-w-[560px]",children:[l.jsxs(Ft,{children:[l.jsxs(Lt,{className:"flex items-center gap-2",children:[l.jsx(Wc,{className:"size-4"}),"Compare documents"]}),l.jsx(nn,{children:"Diff two versions into a redline with native Word tracked changes (accept/reject in Word)."})]}),l.jsxs("div",{className:"grid gap-4 py-2",children:[l.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[l.jsxs("div",{className:"grid gap-1.5",children:[l.jsx(Xn,{htmlFor:"diff-base",children:"Base (old)"}),l.jsxs(Fr,{value:c,onValueChange:z=>{f(z),N()},children:[l.jsx(rr,{id:"diff-base",children:l.jsx(Lr,{placeholder:"Select document"})}),l.jsx(ir,{children:u.map(z=>l.jsx(Tn,{value:z.name,children:z.name},z.name))})]})]}),l.jsxs("div",{className:"grid gap-1.5",children:[l.jsx(Xn,{htmlFor:"diff-revised",children:"Revised (new)"}),l.jsxs(Fr,{value:d,onValueChange:z=>{p(z),N()},children:[l.jsx(rr,{id:"diff-revised",children:l.jsx(Lr,{placeholder:"Select document"})}),l.jsx(ir,{children:u.map(z=>l.jsx(Tn,{value:z.name,children:z.name},z.name))})]})]})]}),l.jsxs("div",{className:"grid gap-1.5",children:[l.jsx(Xn,{htmlFor:"diff-author",children:"Revision author"}),l.jsx(ii,{id:"diff-author",value:h,onChange:z=>{m(z.target.value),N()},placeholder:"playground"})]}),x&&l.jsx("p",{className:"text-sm text-destructive",role:"alert",children:x}),g&&l.jsxs("div",{className:"rounded-md border p-3 text-sm grid gap-2",children:[l.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[l.jsxs(Wt,{variant:"secondary",children:[g.tracked.inserted," inserted"]}),l.jsxs(Wt,{variant:"secondary",children:[g.tracked.deleted," deleted"]}),l.jsxs(Wt,{variant:"secondary",children:[g.tracked.modified," modified"]}),l.jsxs("span",{className:"text-muted-foreground text-xs",children:[g.unchangedBlocks," blocks unchanged"]})]}),C===0&&g.untracked.length===0&&l.jsx("p",{className:"text-muted-foreground",children:"The documents are identical."}),g.untracked.length>0&&l.jsxs("div",{className:"grid gap-1 max-h-32 overflow-y-auto",children:[l.jsxs("p",{className:"font-medium text-warning-bg-foreground",children:[g.untracked.length," change(s) not expressible as tracked changes:"]}),g.untracked.map((z,A)=>l.jsxs("p",{className:"text-xs text-muted-foreground",children:[z.path," [",z.component,"] ",z.detail]},A))]}),g.notes.map((z,A)=>l.jsxs("p",{className:"text-xs text-muted-foreground",children:["Note: ",z]},A))]})]}),l.jsx(mn,{children:g&&C+g.untracked.length>0?l.jsxs(Ce,{onClick:L,children:[l.jsx(Jm,{className:"size-4 mr-1"}),"Open redline"]}):l.jsxs(Ce,{onClick:J,disabled:v||!c||!d||c===d,children:[v&&l.jsx(en,{className:"size-4 mr-1"}),"Compare"]})})]})})};var si=e=>e.type==="checkbox",Cn=e=>e instanceof Date,ct=e=>e==null;const ld=e=>typeof e=="object";var Qe=e=>!ct(e)&&!Array.isArray(e)&&ld(e)&&!Cn(e),ud=e=>Qe(e)&&e.target?si(e.target)?e.target.checked:e.target.value:e,Og=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,cd=(e,t)=>e.has(Og(t)),Dg=e=>{const t=e.constructor&&e.constructor.prototype;return Qe(t)&&t.hasOwnProperty("isPrototypeOf")},Ja=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(!(Ja&&(e instanceof Blob||r))&&(n||Qe(e)))if(t=n?[]:{},!n&&!Dg(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},Et=e=>typeof e=="boolean",Ha=e=>/^\w*$/.test(e),dd=e=>ls(e.replace(/["|']|\]/g,"").split(/\.|\[/)),Me=(e,t,n)=>{let r=-1;const i=Ha(t)?[t]:dd(t),s=i.length,a=s-1;for(;++r<s;){const o=i[r];let u=n;if(r!==a){const c=e[o];u=Qe(c)||Array.isArray(c)?c:isNaN(+i[r+1])?{}:[]}if(o==="__proto__"||o==="constructor"||o==="prototype")return;e[o]=u,e=e[o]}return e};const Pi={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},Dt={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=Se.createContext(null),us=()=>Se.useContext(fd),Rg=e=>{const{children:t,...n}=e;return Se.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]!==Dt.all&&(t._proxyFormState[a]=!r||Dt.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||Dt.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 Wa(e){const t=Se.useRef(e);t.current=e,Se.useEffect(()=>{const n=!e.disabled&&t.current.subject&&t.current.subject.subscribe({next:t.current.next});return()=>{n&&n.unsubscribe()}},[e.disabled])}function Mg(e){const t=us(),{control:n=t.control,disabled:r,name:i,exact:s}=e||{},[a,o]=Se.useState(n._formState),u=Se.useRef(!0),c=Se.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1}),f=Se.useRef(i);return f.current=i,Wa({disabled:r,next:d=>u.current&&md(f.current,d.name,s)&&hd(d,c.current,n._updateFormState)&&o({...n._formState,...d}),subject:n._subjects.state}),Se.useEffect(()=>(u.current=!0,c.current.isValid&&n._updateValid(!0),()=>{u.current=!1}),[n]),Se.useMemo(()=>pd(a,n,c.current,!1),[a,n])}var Ht=e=>typeof e=="string",gd=(e,t,n,r,i)=>Ht(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 $g(e){const t=us(),{control:n=t.control,name:r,defaultValue:i,disabled:s,exact:a}=e||{},o=Se.useRef(r);o.current=r,Wa({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[u,c]=Se.useState(n._getWatch(r,i));return Se.useEffect(()=>n._removeUnmounted()),u}function Fg(e){const t=us(),{name:n,disabled:r,control:i=t.control,shouldUnregister:s}=e,a=cd(i._names.array,n),o=$g({control:i,name:n,defaultValue:oe(i._formValues,n,oe(i._defaultValues,n,e.defaultValue)),exact:!0}),u=Mg({control:i,name:n,exact:!0}),c=Se.useRef(i.register(n,{...e.rules,value:o,...Et(e.disabled)?{disabled:e.disabled}:{}})),f=Se.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!oe(u.errors,n)},isDirty:{enumerable:!0,get:()=>!!oe(u.dirtyFields,n)},isTouched:{enumerable:!0,get:()=>!!oe(u.touchedFields,n)},isValidating:{enumerable:!0,get:()=>!!oe(u.validatingFields,n)},error:{enumerable:!0,get:()=>oe(u.errors,n)}}),[u,n]),d=Se.useMemo(()=>({name:n,value:o,...Et(r)||u.disabled?{disabled:u.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:m=>p.setCustomValidity(m),reportValidity:()=>p.reportValidity()})}}),[n,i._formValues,r,u.disabled,o,i._fields]);return Se.useEffect(()=>{const p=i._options.shouldUnregister||s,h=(m,v)=>{const S=oe(i._fields,m);S&&S._f&&(S._f.mount=v)};if(h(n,!0),p){const m=mt(oe(i._options.defaultValues,n));Me(i._defaultValues,n,m),Xe(oe(i._formValues,n))&&Me(i._formValues,n,m)}return!a&&i.register(n),()=>{(a?p&&!i._state.action:p)?i.unregister(n):h(n,!1)}},[n,i,a,s]),Se.useEffect(()=>{i._updateDisabledField({disabled:r,fields:i._fields,name:n})},[r,n,i]),Se.useMemo(()=>({field:d,formState:u,fieldState:f}),[d,u,f])}const Lg=e=>e.render(Fg(e));var Zg=(e,t,n,r,i)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:i||!0}}:{},$o=e=>({isOnSubmit:!e||e===Dt.onSubmit,isOnBlur:e===Dt.onBlur,isOnChange:e===Dt.onChange,isOnAll:e===Dt.all,isOnTouch:e===Dt.onTouched}),Fo=(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 Bg=(e,t,n)=>{const r=Pr(oe(e,n));return Me(r,"root",t[n]),Me(e,n,r),e},qa=e=>e.type==="file",Jt=e=>typeof e=="function",Oi=e=>{if(!Ja)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},Ni=e=>Ht(e),Ga=e=>e.type==="radio",Di=e=>e instanceof RegExp;const Lo={value:!1,isValid:!1},Zo={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===""?Zo:{value:e[0].value,isValid:!0}:Zo:Lo}return Lo};const Bo={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,Bo):Bo;function Vo(e,t,n="validate"){if(Ni(e)||Array.isArray(e)&&e.every(Ni)||Et(e)&&!e)return{type:n,message:Ni(e)?e:"",ref:t}}var Rn=e=>Qe(e)&&!Di(e)?e:{value:e,message:""},Uo=async(e,t,n,r,i,s)=>{const{ref:a,refs:o,required:u,maxLength:c,minLength:f,min:d,max:p,pattern:h,validate:m,name:v,valueAsNumber:S,mount:x}=e._f,j=oe(n,v);if(!x||t.has(v))return{};const g=o?o[0]:a,I=A=>{i&&g.reportValidity&&(g.setCustomValidity(Et(A)?"":A||""),g.reportValidity())},E={},k=Ga(a),N=si(a),J=k||N,L=(S||qa(a))&&Xe(a.value)&&Xe(j)||Oi(a)&&a.value===""||j===""||Array.isArray(j)&&!j.length,C=Zg.bind(null,v,r,E),z=(A,M,$,F=Yt.maxLength,P=Yt.minLength)=>{const G=A?M:$;E[v]={type:A?F:P,message:G,ref:a,...C(A?F:P,G)}};if(s?!Array.isArray(j)||!j.length:u&&(!J&&(L||ct(j))||Et(j)&&!j||N&&!xd(o).isValid||k&&!yd(o).isValid)){const{value:A,message:M}=Ni(u)?{value:!!u,message:u}:Rn(u);if(A&&(E[v]={type:Yt.required,message:M,ref:g,...C(Yt.required,M)},!r))return I(M),E}if(!L&&(!ct(d)||!ct(p))){let A,M;const $=Rn(p),F=Rn(d);if(!ct(j)&&!isNaN(j)){const P=a.valueAsNumber||j&&+j;ct($.value)||(A=P>$.value),ct(F.value)||(M=P<F.value)}else{const P=a.valueAsDate||new Date(j),G=w=>new Date(new Date().toDateString()+" "+w),B=a.type=="time",ie=a.type=="week";Ht($.value)&&j&&(A=B?G(j)>G($.value):ie?j>$.value:P>new Date($.value)),Ht(F.value)&&j&&(M=B?G(j)<G(F.value):ie?j<F.value:P<new Date(F.value))}if((A||M)&&(z(!!A,$.message,F.message,Yt.max,Yt.min),!r))return I(E[v].message),E}if((c||f)&&!L&&(Ht(j)||s&&Array.isArray(j))){const A=Rn(c),M=Rn(f),$=!ct(A.value)&&j.length>+A.value,F=!ct(M.value)&&j.length<+M.value;if(($||F)&&(z($,A.message,M.message),!r))return I(E[v].message),E}if(h&&!L&&Ht(j)){const{value:A,message:M}=Rn(h);if(Di(A)&&!j.match(A)&&(E[v]={type:Yt.pattern,message:M,ref:a,...C(Yt.pattern,M)},!r))return I(M),E}if(m){if(Jt(m)){const A=await m(j,n),M=Vo(A,g);if(M&&(E[v]={...M,...C(Yt.validate,M.message)},!r))return I(M.message),E}else if(Qe(m)){let A={};for(const M in m){if(!gt(A)&&!r)break;const $=Vo(await m[M](j,n),g,M);$&&(A={...$,...C(M,$.message)},I($.message),r&&(E[v]=A))}if(!gt(A)&&(E[v]={ref:g,...A},!r))return E}}return I(!0),E};function Vg(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 Ug(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:Ha(t)?[t]:dd(t),r=n.length===1?e:Vg(e,n),i=n.length-1,s=n[i];return r&&delete r[s],i!==0&&(Qe(r)&&gt(r)||Array.isArray(r)&&Ug(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=[]}}},fa=e=>ct(e)||!ld(e);function cn(e,t){if(fa(e)||fa(t))return e===t;if(Cn(e)&&Cn(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(Cn(s)&&Cn(a)||Qe(s)&&Qe(a)||Array.isArray(s)&&Array.isArray(a)?!cn(s,a):s!==a)return!1}}return!0}var bd=e=>e.type==="select-multiple",Jg=e=>Ga(e)||si(e),Ts=e=>Oi(e)&&e.isConnected,vd=e=>{for(const t in e)if(Jt(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)||fa(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]=!cn(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&&Ht(e)?new Date(e):r?r(e):e;function zs(e){const t=e.ref;return qa(t)?t.files:Ga(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 Hg=(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 Jo="AsyncFunction";var Wg=e=>!!e&&!!e.validate&&!!(Jt(e.validate)&&e.validate.constructor.name===Jo||Qe(e.validate)&&Object.values(e.validate).find(t=>t.constructor.name===Jo)),qg=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function Ho(e,t,n){const r=oe(e,n);if(r||Ha(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 Gg=(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,Kg=(e,t)=>!ls(oe(e,t)).length&&rt(e,t);const Yg={mode:Dt.onSubmit,reValidateMode:Dt.onChange,shouldFocusError:!0};function Xg(e={}){let t={...Yg,...e},n={submitCount:0,isDirty:!1,isLoading:Jt(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},u,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=$o(t.mode),h=$o(t.reValidateMode),m=t.criteriaMode===Dt.all,v=_=>T=>{clearTimeout(c),c=setTimeout(_,T)},S=async _=>{if(!t.disabled&&(f.isValid||_)){const T=t.resolver?gt((await J()).errors):await C(r,!0);T!==n.isValid&&d.state.next({isValid:T})}},x=(_,T)=>{!t.disabled&&(f.isValidating||f.validatingFields)&&((_||Array.from(o.mount)).forEach(O=>{O&&(T?Me(n.validatingFields,O,T):rt(n.validatingFields,O))}),d.state.next({validatingFields:n.validatingFields,isValidating:!gt(n.validatingFields)}))},j=(_,T=[],O,ee,Y=!0,Q=!0)=>{if(ee&&O&&!t.disabled){if(a.action=!0,Q&&Array.isArray(oe(r,_))){const ce=O(oe(r,_),ee.argA,ee.argB);Y&&Me(r,_,ce)}if(Q&&Array.isArray(oe(n.errors,_))){const ce=O(oe(n.errors,_),ee.argA,ee.argB);Y&&Me(n.errors,_,ce),Kg(n.errors,_)}if(f.touchedFields&&Q&&Array.isArray(oe(n.touchedFields,_))){const ce=O(oe(n.touchedFields,_),ee.argA,ee.argB);Y&&Me(n.touchedFields,_,ce)}f.dirtyFields&&(n.dirtyFields=yr(i,s)),d.state.next({name:_,isDirty:A(_,T),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else Me(s,_,T)},g=(_,T)=>{Me(n.errors,_,T),d.state.next({errors:n.errors})},I=_=>{n.errors=_,d.state.next({errors:n.errors,isValid:!1})},E=(_,T,O,ee)=>{const Y=oe(r,_);if(Y){const Q=oe(s,_,Xe(O)?oe(i,_):O);Xe(Q)||ee&&ee.defaultChecked||T?Me(s,_,T?Q:zs(Y._f)):F(_,Q),a.mount&&S()}},k=(_,T,O,ee,Y)=>{let Q=!1,ce=!1;const ye={name:_};if(!t.disabled){const R=!!(oe(r,_)&&oe(r,_)._f&&oe(r,_)._f.disabled);if(!O||ee){f.isDirty&&(ce=n.isDirty,n.isDirty=ye.isDirty=A(),Q=ce!==ye.isDirty);const K=R||cn(oe(i,_),T);ce=!!(!R&&oe(n.dirtyFields,_)),K||R?rt(n.dirtyFields,_):Me(n.dirtyFields,_,!0),ye.dirtyFields=n.dirtyFields,Q=Q||f.dirtyFields&&ce!==!K}if(O){const K=oe(n.touchedFields,_);K||(Me(n.touchedFields,_,O),ye.touchedFields=n.touchedFields,Q=Q||f.touchedFields&&K!==O)}Q&&Y&&d.state.next(ye)}return Q?ye:{}},N=(_,T,O,ee)=>{const Y=oe(n.errors,_),Q=f.isValid&&Et(T)&&n.isValid!==T;if(t.delayError&&O?(u=v(()=>g(_,O)),u(t.delayError)):(clearTimeout(c),u=null,O?Me(n.errors,_,O):rt(n.errors,_)),(O?!cn(Y,O):Y)||!gt(ee)||Q){const ce={...ee,...Q&&Et(T)?{isValid:T}:{},errors:n.errors,name:_};n={...n,...ce},d.state.next(ce)}},J=async _=>{x(_,!0);const T=await t.resolver(s,t.context,Hg(_||o.mount,r,t.criteriaMode,t.shouldUseNativeValidation));return x(_),T},L=async _=>{const{errors:T}=await J(_);if(_)for(const O of _){const ee=oe(T,O);ee?Me(n.errors,O,ee):rt(n.errors,O)}else n.errors=T;return T},C=async(_,T,O={valid:!0})=>{for(const ee in _){const Y=_[ee];if(Y){const{_f:Q,...ce}=Y;if(Q){const ye=o.array.has(Q.name),R=Y._f&&Wg(Y._f);R&&f.validatingFields&&x([ee],!0);const K=await Uo(Y,o.disabled,s,m,t.shouldUseNativeValidation&&!T,ye);if(R&&f.validatingFields&&x([ee]),K[Q.name]&&(O.valid=!1,T))break;!T&&(oe(K,Q.name)?ye?Bg(n.errors,K,Q.name):Me(n.errors,Q.name,K[Q.name]):rt(n.errors,Q.name))}!gt(ce)&&await C(ce,T,O)}}return O.valid},z=()=>{for(const _ of o.unMount){const T=oe(r,_);T&&(T._f.refs?T._f.refs.every(O=>!Ts(O)):!Ts(T._f.ref))&&se(_)}o.unMount=new Set},A=(_,T)=>!t.disabled&&(_&&T&&Me(s,_,T),!cn(le(),i)),M=(_,T,O)=>gd(_,o,{...a.mount?s:Xe(T)?i:Ht(_)?{[_]:T}:T},O,T),$=_=>ls(oe(a.mount?s:i,_,t.shouldUnregister?oe(i,_,[]):[])),F=(_,T,O={})=>{const ee=oe(r,_);let Y=T;if(ee){const Q=ee._f;Q&&(!Q.disabled&&Me(s,_,kd(T,Q)),Y=Oi(Q.ref)&&ct(T)?"":T,bd(Q.ref)?[...Q.ref.options].forEach(ce=>ce.selected=Y.includes(ce.value)):Q.refs?si(Q.ref)?Q.refs.length>1?Q.refs.forEach(ce=>(!ce.defaultChecked||!ce.disabled)&&(ce.checked=Array.isArray(Y)?!!Y.find(ye=>ye===ce.value):Y===ce.value)):Q.refs[0]&&(Q.refs[0].checked=!!Y):Q.refs.forEach(ce=>ce.checked=ce.value===Y):qa(Q.ref)?Q.ref.value="":(Q.ref.value=Y,Q.ref.type||d.values.next({name:_,values:{...s}})))}(O.shouldDirty||O.shouldTouch)&&k(_,Y,O.shouldTouch,O.shouldDirty,!0),O.shouldValidate&&w(_)},P=(_,T,O)=>{for(const ee in T){const Y=T[ee],Q=`${_}.${ee}`,ce=oe(r,Q);(o.array.has(_)||Qe(Y)||ce&&!ce._f)&&!Cn(Y)?P(Q,Y,O):F(Q,Y,O)}},G=(_,T,O={})=>{const ee=oe(r,_),Y=o.array.has(_),Q=mt(T);Me(s,_,Q),Y?(d.array.next({name:_,values:{...s}}),(f.isDirty||f.dirtyFields)&&O.shouldDirty&&d.state.next({name:_,dirtyFields:yr(i,s),isDirty:A(_,Q)})):ee&&!ee._f&&!ct(Q)?P(_,Q,O):F(_,Q,O),Fo(_,o)&&d.state.next({...n}),d.values.next({name:a.mount?_:void 0,values:{...s}})},B=async _=>{a.mount=!0;const T=_.target;let O=T.name,ee=!0;const Y=oe(r,O),Q=()=>T.type?zs(Y._f):ud(_),ce=ye=>{ee=Number.isNaN(ye)||Cn(ye)&&isNaN(ye.getTime())||cn(ye,oe(s,O,ye))};if(Y){let ye,R;const K=Q(),fe=_.type===Pi.BLUR||_.type===Pi.FOCUS_OUT,_e=!qg(Y._f)&&!t.resolver&&!oe(n.errors,O)&&!Y._f.deps||Gg(fe,oe(n.touchedFields,O),n.isSubmitted,h,p),D=Fo(O,o,fe);Me(s,O,K),fe?(Y._f.onBlur&&Y._f.onBlur(_),u&&u(0)):Y._f.onChange&&Y._f.onChange(_);const pe=k(O,K,fe,!1),Te=!gt(pe)||D;if(!fe&&d.values.next({name:O,type:_.type,values:{...s}}),_e)return f.isValid&&(t.mode==="onBlur"&&fe?S():fe||S()),Te&&d.state.next({name:O,...D?{}:pe});if(!fe&&D&&d.state.next({...n}),t.resolver){const{errors:Le}=await J([O]);if(ce(K),ee){const nt=Ho(n.errors,r,O),et=Ho(Le,r,nt.name||O);ye=et.error,O=et.name,R=gt(Le)}}else x([O],!0),ye=(await Uo(Y,o.disabled,s,m,t.shouldUseNativeValidation))[O],x([O]),ce(K),ee&&(ye?R=!1:f.isValid&&(R=await C(r,!0)));ee&&(Y._f.deps&&w(Y._f.deps),N(O,R,ye,pe))}},ie=(_,T)=>{if(oe(n.errors,T)&&_.focus)return _.focus(),1},w=async(_,T={})=>{let O,ee;const Y=Pr(_);if(t.resolver){const Q=await L(Xe(_)?_:Y);O=gt(Q),ee=_?!Y.some(ce=>oe(Q,ce)):O}else _?(ee=(await Promise.all(Y.map(async Q=>{const ce=oe(r,Q);return await C(ce&&ce._f?{[Q]:ce}:ce)}))).every(Boolean),!(!ee&&!n.isValid)&&S()):ee=O=await C(r);return d.state.next({...!Ht(_)||f.isValid&&O!==n.isValid?{}:{name:_},...t.resolver||!_?{isValid:O}:{},errors:n.errors}),T.shouldFocus&&!ee&&Or(r,ie,_?Y:o.mount),ee},le=_=>{const T={...a.mount?s:i};return Xe(_)?T:Ht(_)?oe(T,_):_.map(O=>oe(T,O))},q=(_,T)=>({invalid:!!oe((T||n).errors,_),isDirty:!!oe((T||n).dirtyFields,_),error:oe((T||n).errors,_),isValidating:!!oe(n.validatingFields,_),isTouched:!!oe((T||n).touchedFields,_)}),y=_=>{_&&Pr(_).forEach(T=>rt(n.errors,T)),d.state.next({errors:_?n.errors:{}})},W=(_,T,O)=>{const ee=(oe(r,_,{_f:{}})._f||{}).ref,Y=oe(n.errors,_)||{},{ref:Q,message:ce,type:ye,...R}=Y;Me(n.errors,_,{...R,...T,ref:ee}),d.state.next({name:_,errors:n.errors,isValid:!1}),O&&O.shouldFocus&&ee&&ee.focus&&ee.focus()},Z=(_,T)=>Jt(_)?d.values.subscribe({next:O=>_(M(void 0,T),O)}):M(_,T,!0),se=(_,T={})=>{for(const O of _?Pr(_):o.mount)o.mount.delete(O),o.array.delete(O),T.keepValue||(rt(r,O),rt(s,O)),!T.keepError&&rt(n.errors,O),!T.keepDirty&&rt(n.dirtyFields,O),!T.keepTouched&&rt(n.touchedFields,O),!T.keepIsValidating&&rt(n.validatingFields,O),!t.shouldUnregister&&!T.keepDefaultValue&&rt(i,O);d.values.next({values:{...s}}),d.state.next({...n,...T.keepDirty?{isDirty:A()}:{}}),!T.keepIsValid&&S()},re=({disabled:_,name:T,field:O,fields:ee})=>{(Et(_)&&a.mount||_||o.disabled.has(T))&&(_?o.disabled.add(T):o.disabled.delete(T),k(T,zs(O?O._f:oe(ee,T)._f),!1,!1,!0))},ne=(_,T={})=>{let O=oe(r,_);const ee=Et(T.disabled)||Et(t.disabled);return Me(r,_,{...O||{},_f:{...O&&O._f?O._f:{ref:{name:_}},name:_,mount:!0,...T}}),o.mount.add(_),O?re({field:O,disabled:Et(T.disabled)?T.disabled:t.disabled,name:_}):E(_,!0,T.value),{...ee?{disabled:T.disabled||t.disabled}:{},...t.progressive?{required:!!T.required,min:br(T.min),max:br(T.max),minLength:br(T.minLength),maxLength:br(T.maxLength),pattern:br(T.pattern)}:{},name:_,onChange:B,onBlur:B,ref:Y=>{if(Y){ne(_,T),O=oe(r,_);const Q=Xe(Y.value)&&Y.querySelectorAll&&Y.querySelectorAll("input,select,textarea")[0]||Y,ce=Jg(Q),ye=O._f.refs||[];if(ce?ye.find(R=>R===Q):Q===O._f.ref)return;Me(r,_,{_f:{...O._f,...ce?{refs:[...ye.filter(Ts),Q,...Array.isArray(oe(i,_))?[{}]:[]],ref:{type:Q.type,name:_}}:{ref:Q}}}),E(_,!1,void 0,Q)}else O=oe(r,_,{}),O._f&&(O._f.mount=!1),(t.shouldUnregister||T.shouldUnregister)&&!(cd(o.array,_)&&a.action)&&o.unMount.add(_)}}},de=()=>t.shouldFocusError&&Or(r,ie,o.mount),ge=_=>{Et(_)&&(d.state.next({disabled:_}),Or(r,(T,O)=>{const ee=oe(r,O);ee&&(T.disabled=ee._f.disabled||_,Array.isArray(ee._f.refs)&&ee._f.refs.forEach(Y=>{Y.disabled=ee._f.disabled||_}))},0,!1))},Ne=(_,T)=>async O=>{let ee;O&&(O.preventDefault&&O.preventDefault(),O.persist&&O.persist());let Y=mt(s);if(o.disabled.size)for(const Q of o.disabled)Me(Y,Q,void 0);if(d.state.next({isSubmitting:!0}),t.resolver){const{errors:Q,values:ce}=await J();n.errors=Q,Y=ce}else await C(r);if(rt(n.errors,"root"),gt(n.errors)){d.state.next({errors:{}});try{await _(Y,O)}catch(Q){ee=Q}}else T&&await T({...n.errors},O),de(),setTimeout(de);if(d.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:gt(n.errors)&&!ee,submitCount:n.submitCount+1,errors:n.errors}),ee)throw ee},be=(_,T={})=>{oe(r,_)&&(Xe(T.defaultValue)?G(_,mt(oe(i,_))):(G(_,T.defaultValue),Me(i,_,mt(T.defaultValue))),T.keepTouched||rt(n.touchedFields,_),T.keepDirty||(rt(n.dirtyFields,_),n.isDirty=T.defaultValue?A(_,mt(oe(i,_))):A()),T.keepError||(rt(n.errors,_),f.isValid&&S()),d.state.next({...n}))},xe=(_,T={})=>{const O=_?mt(_):i,ee=mt(O),Y=gt(_),Q=Y?i:ee;if(T.keepDefaultValues||(i=O),!T.keepValues){if(T.keepDirtyValues){const ce=new Set([...o.mount,...Object.keys(yr(i,s))]);for(const ye of Array.from(ce))oe(n.dirtyFields,ye)?Me(Q,ye,oe(s,ye)):G(ye,oe(Q,ye))}else{if(Ja&&Xe(_))for(const ce of o.mount){const ye=oe(r,ce);if(ye&&ye._f){const R=Array.isArray(ye._f.refs)?ye._f.refs[0]:ye._f.ref;if(Oi(R)){const K=R.closest("form");if(K){K.reset();break}}}}r={}}s=t.shouldUnregister?T.keepDefaultValues?mt(i):{}:mt(Q),d.array.next({values:{...Q}}),d.values.next({values:{...Q}})}o={mount:T.keepDirtyValues?o.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},a.mount=!f.isValid||!!T.keepIsValid||!!T.keepDirtyValues,a.watch=!!t.shouldUnregister,d.state.next({submitCount:T.keepSubmitCount?n.submitCount:0,isDirty:Y?!1:T.keepDirty?n.isDirty:!!(T.keepDefaultValues&&!cn(_,i)),isSubmitted:T.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:Y?{}:T.keepDirtyValues?T.keepDefaultValues&&s?yr(i,s):n.dirtyFields:T.keepDefaultValues&&_?yr(i,_):T.keepDirty?n.dirtyFields:{},touchedFields:T.keepTouched?n.touchedFields:{},errors:T.keepErrors?n.errors:{},isSubmitSuccessful:T.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1})},U=(_,T)=>xe(Jt(_)?_(s):_,T);return{control:{register:ne,unregister:se,getFieldState:q,handleSubmit:Ne,setError:W,_executeSchema:J,_getWatch:M,_getDirty:A,_updateValid:S,_removeUnmounted:z,_updateFieldArray:j,_updateDisabledField:re,_getFieldArray:$,_reset:xe,_resetDefaultValues:()=>Jt(t.defaultValues)&&t.defaultValues().then(_=>{U(_,t.resetOptions),d.state.next({isLoading:!1})}),_updateFormState:_=>{n={...n,..._}},_disableForm:ge,_subjects:d,_proxyFormState:f,_setErrors:I,get _fields(){return r},get _formValues(){return s},get _state(){return a},set _state(_){a=_},get _defaultValues(){return i},get _names(){return o},set _names(_){o=_},get _formState(){return n},set _formState(_){n=_},get _options(){return t},set _options(_){t={...t,..._}}},trigger:w,register:ne,handleSubmit:Ne,watch:Z,setValue:G,getValues:le,reset:U,resetField:be,clearErrors:y,unregister:se,setError:W,setFocus:(_,T={})=>{const O=oe(r,_),ee=O&&O._f;if(ee){const Y=ee.refs?ee.refs[0]:ee.ref;Y.focus&&(Y.focus(),T.shouldSelect&&Jt(Y.select)&&Y.select())}},getFieldState:q}}function Qg(e={}){const t=Se.useRef(void 0),n=Se.useRef(void 0),[r,i]=Se.useState({isDirty:!1,isValidating:!1,isLoading:Jt(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,defaultValues:Jt(e.defaultValues)?void 0:e.defaultValues});t.current||(t.current={...Xg(e),formState:r});const s=t.current.control;return s._options=e,Wa({subject:s._subjects.state,next:a=>{hd(a,s._proxyFormState,s._updateFormState,!0)&&i({...s._formState})}}),Se.useEffect(()=>s._disableForm(e.disabled),[s,e.disabled]),Se.useEffect(()=>{if(s._proxyFormState.isDirty){const a=s._getDirty();a!==r.isDirty&&s._subjects.state.next({isDirty:a})}},[s,r.isDirty]),Se.useEffect(()=>{e.values&&!cn(e.values,n.current)?(s._reset(e.values,s._options.resetOptions),n.current=e.values,i(a=>({...a}))):s._resetDefaultValues()},[e.values,s]),Se.useEffect(()=>{e.errors&&s._setErrors(e.errors)},[e.errors,s]),Se.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()}),Se.useEffect(()=>{e.shouldUnregister&&s._subjects.values.next({values:s._getWatch()})},[e.shouldUnregister,s]),t.current.formState=pd(r,s),t.current}function ex(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 tx=Rg,Sd=b.createContext({}),Wo=({...e})=>l.jsx(Sd.Provider,{value:{name:e.name},children:l.jsx(Lg,{...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({}),pa=b.forwardRef(({className:e,...t},n)=>{const r=b.useId();return l.jsx(_d.Provider,{value:{id:r},children:l.jsx("div",{ref:n,className:H("space-y-2",e),...t})})});pa.displayName="FormItem";const ha=b.forwardRef(({className:e,...t},n)=>{const{error:r,formItemId:i}=cs();return l.jsx(Xn,{ref:n,className:H(r&&"text-destructive",e),htmlFor:i,...t})});ha.displayName="FormLabel";const ma=b.forwardRef(({...e},t)=>{const{error:n,formItemId:r,formDescriptionId:i,formMessageId:s}=cs();return l.jsx(dr,{ref:t,id:r,"aria-describedby":n?`${i} ${s}`:`${i}`,"aria-invalid":!!n,...e})});ma.displayName="FormControl";const jd=b.forwardRef(({className:e,...t},n)=>{const{formDescriptionId:r}=cs();return l.jsx("p",{ref:n,id:r,className:H("text-muted-foreground text-[0.8rem]",e),...t})});jd.displayName="FormDescription";const ga=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?l.jsx("p",{ref:r,id:s,className:H("text-destructive text-[0.8rem] font-medium",e),...n,children:a}):null});ga.displayName="FormMessage";function Ka(){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:{}}),nx=(e=Cd())=>kg()(Sg(_g((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:Ka(),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,u={...i.activeThreadId};if(u[o]===r){const c=Object.values(a).filter(f=>f.documentName===o);c.length>0?(c.sort((f,d)=>d.updatedAt-f.updatedAt),u[o]=c[0].id):delete u[o]}t({threads:a,activeThreadId:u})},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,u]of Object.entries(s))u.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[u,c]of Object.entries(a))c.documentName===r&&(a[u]={...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:jg(()=>mg),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),rx=({children:e})=>{const t=b.useRef(null);return t.current||(t.current=nx(Cd())),l.jsx(Nd.Provider,{value:t.current,children:e})},De=e=>{const t=b.useContext(Nd);if(!t)throw new Error("useChatStore must be used within ChatStoreProvider");return Cg(t,e)};function ix(e,t,n){return t.filter(r=>r.name!==n).every(r=>r.name!==e)}function sx(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(!Rm(s,a))for(const c of Mm(s,a))o.push({path:c.path.replace(/^\//,""),message:c.message});const u=a;if(e!=="delete"&&u.name){const c=u.name.trim();c?(u.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)&&u.template&&(n.some(c=>c.name===u.template)||o.push({path:"template",message:"You must select a valid template"})),{success:o.length===0,data:o.length===0?u:void 0,errors:o}}}}function ax(e,t,n){return e==="create"?{name:"",template:t}:e==="update"?{name:n}:{}}const ox=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 lx({mode:e,shouldReset:t,postSubmit:n,selectedName:r,discoveredDocuments:i,discoveredThemes:s,isTheme:a}){const[o,u]=b.useState(!1),[c,f]=b.useState(null),[d,p]=b.useState("idle"),{toast:h}=fr(),m=ox(a),{documents:v,openTabs:S,createDocument:x,renameDocument:j,deleteDocument:g,openDocument:I,closeDocument:E}=Oe(le=>le),{updateTheme:k,removeTheme:N}=da(le=>le),J=De(le=>le.renameThreadsForDocument),L=De(le=>le.deleteThreadsForDocument),C=b.useMemo(()=>a?s||[]:i||[],[a,i,s]),z=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]),M=b.useMemo(()=>sx(e,le=>ix(le,v,r),A),[e,v,r,A]),$=M.schema,F=b.useMemo(()=>{const le=new Map;return C.forEach(q=>le.set(q.path,q)),le},[C]),P=Mn,G=Qg({resolver:ex(M.validate),defaultValues:ax(e,void 0,r)}),[B,ie]=b.useState(P);b.useEffect(()=>{if(B&&B!==Mn&&e==="create"){const le=F.get(B);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")},[B,e,F,a]),b.useEffect(()=>{t&&(G.reset(),f(null),p("idle"),ie(P))},[G,t]);const w=G.handleSubmit(async({name:le,template:q})=>{u(!0);try{if(await new Promise(y=>setTimeout(y,200)),e==="create"){const y=B?F.get(B):C.find(be=>be.name===q);let W,Z=le;if(!!B&&B!==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 be=Z.replace(/\.(json|theme)$/i,"").toLowerCase().replace(/\s+/g,"-"),xe=yt==="docx"?$m(be):{name:be,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(xe,null,2);const U=`.${yt}.theme.json`;Z.endsWith(U)||(Z=Z.replace(/\.(pptx|docx)\.theme\.json$/i,"").replace(/\.theme\.json$/i,"").replace(/\.json$/i,""),Z+=U)}else{const be=y;W=c||JSON.stringify(yt==="docx"?{name:"docx",props:{theme:(be==null?void 0:be.theme)||"default",metadata:{title:(be==null?void 0:be.title)||Z.replace(/\.(json|js)$/i,"")}},children:[{name:"section",props:{},children:[{name:"paragraph",props:{text:"Start writing your document content here..."}}]}]}:{name:"pptx",props:{title:(be==null?void 0:be.title)||Z.replace(/\.(json|js)$/i,""),theme:(be==null?void 0:be.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 xe=yt==="docx"?".docx.json":".pptx.json";!Z.endsWith(xe)&&!Z.endsWith(".json")&&(Z+=xe)}const re=Z.match(/(\.(pptx|docx)(\.theme)?\.json|\.json)$/i),ne=re?re[0]:"",de=Z.slice(0,Z.length-ne.length);let ge=Z,Ne=1;for(;v.some(be=>be.name===ge);)Ne++,ge=`${de} (${Ne})${ne}`;Z=ge,x(Z,W),I(Z),a&&k(Z,W)}else if(e==="update"){const y=r,W=le,Z=S.includes(y);Z&&E(y),j(y,W),J(y,W),Z&&I(W)}else if(e==="delete"){const y=r;E(y),g(y),L(y),a&&N(y)}n()}finally{u(!1)}});return l.jsx(tx,{...G,children:l.jsxs("form",{onSubmit:w,children:[l.jsxs(Ft,{children:[l.jsx(Lt,{children:m[e].title}),l.jsx(nn,{children:m[e].description})]}),l.jsxs("div",{className:"flex flex-col gap-4 py-4",children:[$.properties&&"name"in $.properties&&l.jsx(Wo,{control:G.control,name:"name",render:({field:le})=>l.jsxs(pa,{children:[l.jsx(ha,{children:"Name"}),l.jsx(ma,{children:l.jsx(ii,{placeholder:"Enter a name or select a template below",autoComplete:"off",...le})}),l.jsx(ga,{})]})}),e==="create"&&l.jsx(Wo,{control:G.control,name:"template",render:({field:le})=>l.jsxs(pa,{children:[l.jsx(ha,{children:a?"Base Theme":"Base Document"}),l.jsxs(Fr,{onValueChange:q=>{if(q===Mn)le.onChange(void 0),G.setValue("name",""),ie(Mn),f(null);else{const y=F.get(q);y&&(le.onChange(y.name),G.setValue("name",y.name),ie(q))}},defaultValue:P,children:[l.jsx(ma,{children:l.jsx(rr,{children:l.jsx(Lr,{placeholder:`Select a discovered ${a?"theme":"document"}`})})}),l.jsxs(ir,{className:"max-h-[300px]",children:[l.jsxs(Tn,{value:Mn,children:["Empty ",a?"theme":"document"]}),Object.entries(z).map(([q,y])=>y.length===0?null:l.jsxs(Ig,{children:[l.jsx(od,{children:q==="current"?"📁 Current Directory":"📦 Project"}),y.map(W=>{let Z;return W.title&&W.title!==W.name?Z=W.title:W.description&&(Z=W.description.length>40?W.description.substring(0,40)+"...":W.description),l.jsx(Tn,{value:W.path,className:"pl-6",children:l.jsxs("span",{className:"flex flex-col",children:[l.jsx("span",{className:"font-medium",children:W.name}),Z&&l.jsx("span",{className:"text-muted-foreground text-xs",children:Z})]})},W.path)})]},q))]})]}),l.jsxs(jd,{children:["Start empty or select a discovered"," ",a?"theme":"document"," as a starting point"]}),l.jsx(ga,{})]})})]}),l.jsx(mn,{children:l.jsx(Ce,{type:"submit",variant:m[e].buttonVariant,disabled:o,children:o?l.jsxs(l.Fragment,{children:[l.jsx(en,{size:"sm",className:"mr-2"}),e==="create"?"Creating...":e==="update"?"Saving...":"Deleting..."]}):m[e].button})})]})})}const Mi=Se.memo(lx);function an(e,t){return t?e.toLowerCase().includes(t.toLowerCase()):!0}function Ya({text:e,query:t}){if(!t)return l.jsx(l.Fragment,{children:e});const n=e.toLowerCase().indexOf(t.toLowerCase());return n===-1?l.jsx(l.Fragment,{children:e}):l.jsxs(l.Fragment,{children:[e.slice(0,n),l.jsx("mark",{className:"bg-transparent p-0 font-semibold text-current",children:e.slice(n,n+t.length)}),e.slice(n+t.length)]})}function qo({children:e,count:t,actions:n,className:r}){return l.jsxs("div",{className:H("flex h-6 shrink-0 items-center gap-1.5 px-1 select-none",r),children:[l.jsx("span",{className:"text-[11px] font-medium tracking-[0.08em] text-sidebar-foreground/70 uppercase",children:e}),t!==void 0&&l.jsx("span",{className:"text-[11px] font-normal tabular-nums text-sidebar-foreground/65",children:t}),n&&l.jsx("div",{className:"ml-auto flex items-center gap-0.5",children:n})]})}const Bt=Se.forwardRef(({className:e,...t},n)=>l.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}));Bt.displayName="RailIconButton";function Go({tone:e,className:t}){return l.jsx("span",{"aria-hidden":!0,className:H("size-1.5 shrink-0 rounded-full",e==="preview"?"bg-data-blue":"bg-warning",t)})}function Ko({icon:e,label:t,onClick:n,hint:r}){return n?l.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:[l.jsx(e,{className:"size-3.5 shrink-0"}),l.jsx("span",{className:"truncate",children:t})]}):l.jsx("p",{className:"px-2 py-1 text-[12px] leading-tight text-sidebar-foreground/70",children:t})}const ux=vm,cx=wm,dx=b.forwardRef(({className:e,inset:t,children:n,...r},i)=>l.jsxs(Sc,{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,l.jsx(ri,{className:"ml-auto h-4 w-4"})]}));dx.displayName=Sc.displayName;const fx=b.forwardRef(({className:e,...t},n)=>l.jsx(_c,{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}));fx.displayName=_c.displayName;const Ed=b.forwardRef(({className:e,...t},n)=>l.jsx(km,{children:l.jsx(vc,{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=vc.displayName;const Id=b.forwardRef(({className:e,inset:t,...n},r)=>l.jsx(kc,{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=kc.displayName;const px=b.forwardRef(({className:e,children:t,checked:n,...r},i)=>l.jsxs(jc,{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:[l.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:l.jsx(Cc,{children:l.jsx(hn,{className:"h-4 w-4"})})}),t]}));px.displayName=jc.displayName;const hx=b.forwardRef(({className:e,children:t,...n},r)=>l.jsxs(Nc,{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:[l.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:l.jsx(Cc,{children:l.jsx(qc,{className:"h-4 w-4 fill-current"})})}),t]}));hx.displayName=Nc.displayName;const mx=b.forwardRef(({className:e,inset:t,...n},r)=>l.jsx(Ec,{ref:r,className:H("text-foreground px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));mx.displayName=Ec.displayName;const Td=b.forwardRef(({className:e,...t},n)=>l.jsx(wc,{ref:n,className:H("bg-border -mx-1 my-1 h-px",e),...t}));Td.displayName=wc.displayName;const zd=({className:e,...t})=>l.jsx("span",{className:H("text-muted-foreground ml-auto text-xs tracking-widest",e),...t});zd.displayName="ContextMenuShortcut";const ds=Sm,fs=_m,gx=b.forwardRef(({className:e,inset:t,children:n,...r},i)=>l.jsxs(Pc,{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,l.jsx(ri,{className:"ml-auto"})]}));gx.displayName=Pc.displayName;const xx=b.forwardRef(({className:e,...t},n)=>l.jsx(Oc,{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}));xx.displayName=Oc.displayName;const ai=b.forwardRef(({className:e,sideOffset:t=4,...n},r)=>l.jsx(jm,{children:l.jsx(Ic,{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=Ic.displayName;const Ot=b.forwardRef(({className:e,inset:t,...n},r)=>l.jsx(Tc,{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}));Ot.displayName=Tc.displayName;const yx=b.forwardRef(({className:e,children:t,checked:n,...r},i)=>l.jsxs(Dc,{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:[l.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:l.jsx(Rc,{children:l.jsx(hn,{className:"h-4 w-4"})})}),t]}));yx.displayName=Dc.displayName;const bx=b.forwardRef(({className:e,children:t,...n},r)=>l.jsxs(Mc,{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:[l.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:l.jsx(Rc,{children:l.jsx(qc,{className:"h-2 w-2 fill-current"})})}),t]}));bx.displayName=Mc.displayName;const Ad=b.forwardRef(({className:e,inset:t,...n},r)=>l.jsx(Ac,{ref:r,className:H("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));Ad.displayName=Ac.displayName;const sr=b.forwardRef(({className:e,...t},n)=>l.jsx(zc,{ref:n,className:H("bg-muted -mx-1 my-1 h-px",e),...t}));sr.displayName=zc.displayName;const Pd=({className:e,...t})=>l.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)=>l.jsx($c,{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=$c.displayName;const Dd=cc,vx=Cm,wx=dc,Rd=b.forwardRef(({className:e,...t},n)=>l.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 kx=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"}}),Xa=b.forwardRef(({side:e="right",className:t,children:n,...r},i)=>l.jsxs(wx,{children:[l.jsx(Rd,{}),l.jsxs(rs,{ref:i,className:H(kx({side:e}),t),...r,children:[l.jsxs(Va,{className:"ring-offset-background focus:ring-ring data-[state=open]:bg-secondary absolute top-4 right-4 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-none disabled:pointer-events-none",children:[l.jsx(pn,{className:"h-4 w-4"}),l.jsx("span",{className:"sr-only",children:"Close"})]}),n]})]}));Xa.displayName=rs.displayName;const Sx=b.forwardRef(({className:e,...t},n)=>l.jsx(is,{ref:n,className:H("text-foreground text-lg font-semibold",e),...t}));Sx.displayName=is.displayName;const _x=b.forwardRef(({className:e,...t},n)=>l.jsx(ss,{ref:n,className:H("text-muted-foreground text-sm",e),...t}));_x.displayName=ss.displayName;function Dr({className:e,...t}){return l.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 jx(){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 Cx="sidebar_state",Nx=60*60*24*7,Ex="16rem",Ix="18rem",Tx="3rem",zx="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 u=$d(),[c,f]=b.useState(!1),[d,p]=b.useState(e),h=t??d,m=b.useCallback(j=>{const g=typeof j=="function"?j(h):j;n?n(g):p(g),document.cookie=`${Cx}=${g}; path=/; max-age=${Nx}`},[n,h]),v=b.useCallback(()=>u?f(j=>!j):m(j=>!j),[u,m,f]);b.useEffect(()=>{const j=I=>{var N;const E=I;if(!E)return!1;const k=(N=E.tagName)==null?void 0:N.toLowerCase();return k==="input"||k==="textarea"||k==="select"||E.isContentEditable?!0:!!(E.closest&&E.closest(".monaco-editor"))},g=I=>{const E=I.metaKey||I.ctrlKey,k=I.key.toLowerCase();if(E&&k===zx){I.preventDefault(),v();return}E&&k==="s"&&!j(I.target)&&(I.preventDefault(),v())};return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[v]);const S=h?"expanded":"collapsed",x=b.useMemo(()=>({state:S,open:h,setOpen:m,isMobile:u,openMobile:c,setOpenMobile:f,toggleSidebar:v}),[S,h,m,u,c,f,v]);return l.jsx(Fd.Provider,{value:x,children:l.jsx(Fm,{delayDuration:0,children:l.jsx("div",{style:{"--sidebar-width":Ex,"--sidebar-width-icon":Tx,...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:u,openMobile:c,setOpenMobile:f}=ps();return n==="none"?l.jsx("div",{className:H("bg-sidebar text-sidebar-foreground flex h-full w-[--sidebar-width] flex-col",r),ref:a,...s,children:i}):o?l.jsx(Dd,{open:c,onOpenChange:f,...s,children:l.jsx(Xa,{"data-sidebar":"sidebar","data-mobile":"true",className:"bg-sidebar text-sidebar-foreground w-[--sidebar-width] p-0 [&>button]:hidden",style:{"--sidebar-width":Ix},side:e,children:l.jsx("div",{className:"flex h-full w-full flex-col",children:i})})}):l.jsxs("div",{ref:a,className:"group peer text-sidebar-foreground hidden md:block","data-state":u,"data-collapsible":u==="collapsed"?n:"","data-variant":t,"data-side":e,children:[l.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]")}),l.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:l.jsx("div",{"data-sidebar":"sidebar",className:"bg-sidebar group-data-[variant=floating]:border-sidebar-border flex h-full w-full flex-col group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:shadow",children:i})})]})});Zd.displayName="Sidebar";const Ax=b.forwardRef(({className:e,onClick:t,...n},r)=>{const{toggleSidebar:i}=ps();return l.jsxs(Ce,{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:[l.jsx(Hm,{}),l.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});Ax.displayName="SidebarTrigger";const Px=b.forwardRef(({className:e,...t},n)=>{const{toggleSidebar:r}=ps();return l.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})});Px.displayName="SidebarRail";const Ox=b.forwardRef(({className:e,...t},n)=>l.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}));Ox.displayName="SidebarInset";const Dx=b.forwardRef(({className:e,...t},n)=>l.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}));Dx.displayName="SidebarInput";const xa=b.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,"data-sidebar":"header",className:H("flex flex-col gap-2 p-2",e),...t}));xa.displayName="SidebarHeader";const Bd=b.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,"data-sidebar":"footer",className:H("flex flex-col gap-2 p-2",e),...t}));Bd.displayName="SidebarFooter";const Rx=b.forwardRef(({className:e,...t},n)=>l.jsx(Od,{ref:n,"data-sidebar":"separator",className:H("bg-sidebar-border mx-2 w-auto",e),...t}));Rx.displayName="SidebarSeparator";const ya=b.forwardRef(({className:e,...t},n)=>l.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}));ya.displayName="SidebarContent";const Mx=b.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,"data-sidebar":"group",className:H("relative flex w-full min-w-0 flex-col p-2",e),...t}));Mx.displayName="SidebarGroup";const $x=b.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const i=t?dr:"div";return l.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})});$x.displayName="SidebarGroupLabel";const Fx=b.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const i=t?dr:"button";return l.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})});Fx.displayName="SidebarGroupAction";const Lx=b.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,"data-sidebar":"group-content",className:H("w-full text-sm",e),...t}));Lx.displayName="SidebarGroupContent";const Cr=b.forwardRef(({className:e,...t},n)=>l.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)=>l.jsx("li",{ref:n,"data-sidebar":"menu-item",className:H("group/menu-item relative",e),...t}));Vd.displayName="SidebarMenuItem";const Zx=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 u=e?dr:"button",{isMobile:c,state:f}=ps(),d=l.jsx(u,{ref:o,"data-sidebar":"menu-button","data-size":r,"data-active":t,className:H(Zx({variant:n,size:r}),s),...a});return i?(typeof i=="string"&&(i={children:i}),l.jsxs(We,{children:[l.jsx(qe,{asChild:!0,children:d}),l.jsx(Ge,{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 l.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 Bx=b.forwardRef(({className:e,...t},n)=>l.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}));Bx.displayName="SidebarMenuBadge";const Vx=b.forwardRef(({className:e,showIcon:t=!1,...n},r)=>{const i=b.useMemo(()=>`${Math.floor(Math.random()*40)+50}%`,[]);return l.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&&l.jsx(Dr,{className:"size-4 rounded-md","data-sidebar":"menu-skeleton-icon"}),l.jsx(Dr,{className:"h-4 max-w-[--skeleton-width] flex-1","data-sidebar":"menu-skeleton-text",style:{"--skeleton-width":i}})]})});Vx.displayName="SidebarMenuSkeleton";const Ux=b.forwardRef(({className:e,...t},n)=>l.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}));Ux.displayName="SidebarMenuSub";const Jx=b.forwardRef(({...e},t)=>l.jsx("li",{ref:t,...e}));Jx.displayName="SidebarMenuSubItem";const Hx=b.forwardRef(({asChild:e=!1,size:t="md",isActive:n,className:r,...i},s)=>{const a=e?dr:"a";return l.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})});Hx.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 Wx=typeof window<"u"?navigator.userAgent.toUpperCase().indexOf("MAC")>=0:!1;function qx({document:e,compact:t=!1,query:n=""}){const r=b.useRef(null),[i,s]=b.useState(!1),[a,o]=b.useState(!1),[u,c]=b.useState(!1),[f,d]=b.useState(!1),p=Oe(q=>q.openDocument),h=Oe(q=>q.documentTypes),m=Oe(q=>q.activeTab),v=Qt(q=>q.name),S=Qt(q=>q.text),x=Qt(q=>q.isGenerating),g=(h[e.name]||"application/json+report")==="application/json+theme",I=m===e.name,[E,k]=b.useState(v),[N,J]=b.useState(S),L=100,C=0;b.useEffect(()=>{const q=setTimeout(()=>{v&&S?(k(v),J(S)):x||(k(""),J(""))},x?L:C);return()=>clearTimeout(q)},[v,S,x]);const z=E===e.name,A=q=>{var W;const y=new Set;try{const Z=JSON.parse(q);(W=Z.props)!=null&&W.theme&&y.add(Z.props.theme),Z.children&&Array.isArray(Z.children)&&Z.children.forEach(se=>{var re;se.name==="docx"&&((re=se.props)!=null&&re.theme)&&y.add(se.props.theme)})}catch{}return y},M=b.useMemo(()=>{if(!g||!N)return!1;try{const q=JSON.parse(e.text),y=gg(q);if(y)return A(N).has(y)}catch{}return!1},[g,N,e.text]),$=b.useCallback(()=>{c(!1)},[]),F=b.useCallback(()=>{d(!1)},[]),P=I?null:z?"preview":M?"in-use":null,G=I?"Editing":z?"In preview":M?"Used by preview":null,B=b.useMemo(()=>[{key:"open",label:"Open",shortcut:Wx?"⌘⏎":"⌃⏎",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]),ie=g?Wm:Gc,w=i||a,le=l.jsxs(Ud,{size:"sm",ref:r,"aria-label":G?`${e.name} — ${G}`: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",w&&"bg-sidebar-accent/60 text-sidebar-foreground",I&&"bg-sidebar-accent text-sidebar-accent-foreground font-medium"),title:G?`${e.name} — ${G}`: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&&l.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")}),l.jsx(ie,{className:H("size-3.5 shrink-0",g?"text-accent2":"text-sidebar-foreground/60",I&&!g&&"text-sidebar-accent-foreground/70")}),!t&&l.jsx("span",{className:"flex-1 truncate",children:l.jsx(Ya,{text:e.name,query:n})}),t&&P&&l.jsx(Go,{tone:P,className:"absolute top-1 right-1 size-1.5 ring-2 ring-[hsl(var(--sidebar))]"})]});return l.jsxs(Vd,{children:[l.jsxs(ux,{onOpenChange:s,children:[l.jsx(cx,{className:"block",children:t?l.jsxs(We,{children:[l.jsx(qe,{asChild:!0,children:le}),l.jsx(Ge,{side:"right",children:l.jsxs("div",{className:"text-xs",children:[l.jsx("div",{children:e.name}),l.jsx("div",{className:"opacity-70",children:G??(g?"Theme":"Document")})]})})]}):le}),l.jsx(Ed,{className:"w-44",children:B.map(q=>l.jsxs(Se.Fragment,{children:[q.separatorBefore&&l.jsx(Td,{}),l.jsxs(Id,{onClick:q.run,className:H(q.danger&&"text-destructive focus:text-destructive"),children:[q.label,q.shortcut&&l.jsx(zd,{children:q.shortcut})]})]},q.key))})]}),!t&&l.jsxs(l.Fragment,{children:[P&&l.jsx(Go,{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")}),l.jsxs(ds,{onOpenChange:o,children:[l.jsx(fs,{asChild:!0,children:l.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:l.jsx(Kc,{})})}),l.jsx(ai,{side:"right",align:"start",className:"w-44",children:B.map(q=>l.jsxs(Se.Fragment,{children:[q.separatorBefore&&l.jsx(sr,{}),l.jsxs(Ot,{onClick:q.run,className:H(q.danger&&"text-destructive focus:text-destructive"),children:[q.label,q.shortcut&&l.jsx(Pd,{children:q.shortcut})]})]},q.key))})]})]}),l.jsx(_t,{open:u,onOpenChange:c,children:l.jsx(bt,{className:"sm:max-w-[425px]",onCloseAutoFocus:q=>{var y;q.preventDefault(),(y=r.current)==null||y.focus()},children:l.jsx(Mi,{mode:"update",shouldReset:!u,postSubmit:$,selectedName:e.name})})}),l.jsx(_t,{open:f,onOpenChange:d,children:l.jsx(bt,{className:"sm:max-w-[425px]",onCloseAutoFocus:q=>{var y;q.preventDefault(),(y=r.current)==null||y.focus()},children:l.jsx(Mi,{mode:"delete",shouldReset:!f,postSubmit:F,selectedName:e.name})})})]})}const mi=Se.memo(qx);async function Gx(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)=>l.jsxs(Fc,{ref:r,className:H("relative overflow-hidden",e),...n,children:[l.jsx(Nm,{className:"h-full w-full rounded-[inherit]",children:t}),l.jsx(Hd,{}),l.jsx(Em,{})]}));Zr.displayName=Fc.displayName;const Hd=b.forwardRef(({className:e,orientation:t="vertical",...n},r)=>l.jsx(Lc,{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:l.jsx(Im,{className:"bg-border relative flex-1 rounded-full"})}));Hd.displayName=Lc.displayName;function Qa({className:e,...t}){return l.jsx(Tm,{"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:l.jsx(zm,{"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 Kx=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)=>l.jsx("div",{ref:r,role:"alert",className:H(Kx({variant:t}),e),...n}));$i.displayName="Alert";const Yx=b.forwardRef(({className:e,...t},n)=>l.jsx("h5",{ref:n,className:H("mb-1 font-medium leading-none tracking-tight",e),...t}));Yx.displayName="AlertTitle";const Fi=b.forwardRef(({className:e,...t},n)=>l.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),u=()=>s(!i),c=()=>t===null?l.jsx("span",{className:"text-muted-foreground",children:"null"}):t===void 0?l.jsx("span",{className:"text-muted-foreground",children:"undefined"}):typeof t=="boolean"?l.jsx("span",{className:"text-warning",children:String(t)}):typeof t=="number"?l.jsx("span",{className:"text-success",children:t}):typeof t=="string"?t.startsWith("http")?l.jsxs("span",{className:"text-data-blue",children:['"',t,'"']}):t.startsWith("#/")?l.jsxs("span",{className:"text-warning",children:['"',t,'"']}):l.jsxs("span",{className:"text-destructive",children:['"',t,'"']}):null,f=a?Object.keys(t).length:0;return l.jsxs("div",{className:H("text-sm",n>0&&"ml-4"),children:[l.jsxs("div",{className:"flex items-start hover:bg-muted/30 rounded-sm px-1 py-0.5",children:[a&&l.jsx("button",{onClick:u,className:"mr-1 hover:bg-muted rounded-sm p-0.5","aria-label":i?"Collapse":"Expand",children:i?l.jsx(ti,{className:"h-3 w-3"}):l.jsx(ri,{className:"h-3 w-3"})}),!a&&l.jsx("span",{className:"w-4"}),e&&l.jsxs(l.Fragment,{children:[l.jsxs("span",{className:"text-data-blue",children:['"',e,'"']}),l.jsx("span",{className:"mx-1",children:":"})]}),a?l.jsxs("span",{className:"text-muted-foreground",children:[o?"[":"{",!i&&l.jsxs("span",{className:"mx-1 text-xs",children:[f," ",o?"items":"properties"]}),!i&&(o?"]":"}")]}):c(),!a&&!r&&l.jsx("span",{className:"text-muted-foreground",children:","})]}),a&&i&&l.jsxs("div",{className:"ml-4",children:[o?t.map((d,p)=>l.jsx(Li,{keyName:String(p),value:d,depth:n+1,isLast:p===t.length-1},p)):Object.entries(t).map(([d,p],h,m)=>l.jsx(Li,{keyName:d,value:p,depth:n+1,isLast:h===m.length-1},d)),l.jsx("div",{className:"ml-4",children:l.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?l.jsxs("div",{className:H("space-y-4",r),children:[l.jsx(Dr,{className:"h-8 w-64"}),l.jsx(Dr,{className:"h-4 w-full"}),l.jsx(Dr,{className:"h-64 w-full"})]}):n?l.jsx($i,{variant:"destructive",className:r,children:l.jsx(Fi,{children:n})}):e?l.jsx(Zr,{className:H("h-full w-full rounded-md border bg-muted/10 p-4",r),children:l.jsx("div",{className:"font-mono text-xs",children:l.jsx(Li,{value:e})})}):l.jsx($i,{className:r,children:l.jsx(Fi,{children:"No schema available"})}));Zi.displayName="SchemaViewer";function Xx({plugins:e,initialFocusedPlugin:t}){var g,I;const n=Rt(E=>E.togglePlugin),r=Rt(E=>E.isPluginSelected),i=Rt(E=>E.selectedPlugins),s=Rt(E=>E.isApplyingPlugins),[a,o]=b.useState(null),[u,c]=b.useState(null),[f,d]=b.useState("properties");b.useEffect(()=>{if(t){const E=e.find(k=>k.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(k=>{E[k.location]&&E[k.location].push(k)}),E},[e]),h=async(E,k)=>{a&&(await Gx(a.name,E.props),c(k),setTimeout(()=>c(null),2e3))},m=E=>{switch(E){case"current":return"Current Directory";case"downstream":return"Project";case"upstream":return"Parent Directories";default:return E}},v=E=>{switch(E){case"current":return l.jsx(Qm,{className:"size-3"});case"downstream":return l.jsx(Xm,{className:"size-3"});case"upstream":return l.jsx(Gc,{className:"size-3"});default:return null}},S=((g=a==null?void 0:a.schema)==null?void 0:g.properties)&&Object.keys(a.schema.properties).length>0,x=(I=a==null?void 0:a.schema)==null?void 0:I.jsonSchema,j=(a==null?void 0:a.examples)&&a.examples.length>0;return l.jsxs(l.Fragment,{children:[l.jsxs(Ft,{children:[l.jsxs(Lt,{className:"flex items-center gap-2",children:[l.jsx(qm,{className:"size-5 text-warning"}),"Plugins",l.jsxs(Wt,{variant:"secondary",className:"font-normal",children:[i.size," active"]})]}),l.jsxs(nn,{children:[e.length," plugin",e.length!==1?"s":""," discovered in your project"]})]}),l.jsxs("div",{className:"mt-3 flex gap-0 h-[600px] border rounded-lg overflow-hidden",children:[l.jsx("div",{className:"w-[240px] flex-none border-r bg-muted/30",children:l.jsx(Zr,{className:"h-full",children:l.jsx("div",{className:"p-2 space-y-3",children:Object.entries(p).map(([E,k])=>k.length===0?null:l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1 text-[11px] font-medium text-muted-foreground uppercase tracking-wider",children:[v(E),m(E)]}),l.jsx("div",{className:"space-y-0.5",children:k.map(N=>{const J=r(N.name),L=(a==null?void 0:a.name)===N.name;return l.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",L?"bg-accent text-accent-foreground":"hover:bg-accent/50 text-foreground"),children:[l.jsx("div",{className:H("size-1.5 rounded-full flex-none transition-colors",J?"bg-warning":"bg-muted-foreground/30")}),l.jsx("span",{className:"text-sm font-medium truncate flex-1",children:N.name})]},N.name)})})]},E))})})}),a?l.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[l.jsxs("div",{className:"flex-none px-5 py-4 border-b bg-background",children:[l.jsxs("div",{className:"flex items-start justify-between gap-3",children:[l.jsxs("div",{className:"min-w-0",children:[l.jsxs("div",{className:"flex items-center gap-2.5",children:[l.jsx("h3",{className:"text-base font-semibold truncate",children:a.name}),a.version&&l.jsxs(Wt,{variant:"outline",className:"font-mono text-[11px] flex-none",children:["v",a.version]})]}),a.description&&l.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:a.description})]}),l.jsxs("div",{className:"flex items-center gap-2 flex-none pt-0.5",children:[l.jsx("span",{className:"text-xs text-muted-foreground",children:r(a.name)?"On":"Off"}),l.jsx(Qa,{checked:r(a.name),onCheckedChange:()=>n(a),disabled:s,"aria-label":`Toggle ${a.name}`})]})]}),l.jsxs("div",{className:"flex items-center gap-1.5 mt-2 text-xs text-muted-foreground",children:[v(a.location),l.jsx("span",{children:m(a.location)}),l.jsx("span",{className:"text-muted-foreground/60 mx-1",children:"/"}),l.jsx("span",{className:"font-mono truncate",children:a.relativePath})]})]}),l.jsxs("div",{className:"flex-none px-5 pt-3 pb-0 flex gap-1 border-b bg-background",children:[S&&l.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:l.jsxs("span",{className:"flex items-center gap-1.5",children:[l.jsx(Do,{className:"size-3.5"}),"Properties"]})}),x&&l.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:l.jsxs("span",{className:"flex items-center gap-1.5",children:[l.jsx(Gm,{className:"size-3.5"}),"Schema"]})}),j&&l.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:l.jsxs("span",{className:"flex items-center gap-1.5",children:[l.jsx(Km,{className:"size-3.5"}),"Examples",l.jsx(Wt,{variant:"secondary",className:"text-[10px] px-1.5 py-0 h-4",children:a.examples.length})]})})]}),l.jsx(Zr,{className:"flex-1",children:l.jsxs("div",{className:"p-5",children:[f==="properties"&&S&&l.jsx("div",{className:"space-y-1",children:Object.entries(a.schema.properties).map(([E,k])=>l.jsx(Qx,{name:E,prop:k},E))}),f==="schema"&&x&&l.jsx(Zi,{schema:a.schema.jsonSchema,loading:!1,className:"h-[420px]"}),f==="examples"&&j&&a.examples.map((E,k)=>l.jsxs("div",{className:H(k>0&&"mt-4 pt-4 border-t"),children:[l.jsxs("div",{className:"flex items-center justify-between mb-2",children:[l.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[E.title&&l.jsx("span",{className:"font-medium text-sm truncate",children:E.title}),!E.title&&l.jsxs("span",{className:"text-sm text-muted-foreground",children:["Example ",k+1]})]}),l.jsx(Ce,{size:"sm",variant:"ghost",className:"h-7 px-2 text-xs flex-none",onClick:()=>h(E,k),children:u===k?l.jsxs(l.Fragment,{children:[l.jsx(Ym,{className:"size-3 mr-1 text-success"}),"Copied"]}):l.jsxs(l.Fragment,{children:[l.jsx(os,{className:"size-3 mr-1"}),"Copy"]})})]}),E.description&&l.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:E.description}),l.jsx("pre",{className:"p-3 bg-muted rounded-md overflow-x-auto text-xs font-mono leading-relaxed",children:JSON.stringify(E.props,null,2)})]},k)),!S&&!x&&!j&&l.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[l.jsx(Do,{className:"size-10 mx-auto mb-3 opacity-20"}),l.jsx("p",{className:"text-sm",children:"No schema or examples available for this plugin"})]})]})})]}):l.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:l.jsx("p",{className:"text-sm",children:"Select a plugin to view details"})})]})]})}function Qx({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 l.jsxs("div",{className:"rounded-md border",children:[l.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?l.jsx(ti,{className:"size-3 text-muted-foreground flex-none"}):l.jsx(ri,{className:"size-3 text-muted-foreground flex-none"}):l.jsx("span",{className:"size-3 flex-none"}),l.jsx("span",{className:"font-mono font-medium text-xs",children:e}),l.jsx(Wt,{variant:"outline",className:"text-[10px] px-1.5 py-0 h-4 flex-none",children:s}),t.optional===!1&&l.jsx("span",{className:"text-[10px] text-destructive font-medium flex-none",children:"required"}),l.jsx("span",{className:"flex-1"}),t.default!==void 0&&l.jsxs("span",{className:"text-[10px] font-mono text-muted-foreground flex-none",children:["= ",JSON.stringify(t.default)]})]}),n&&i&&l.jsxs("div",{className:"px-3 pb-2 pt-0 ml-5 text-xs space-y-1 text-muted-foreground",children:[t.description&&l.jsx("p",{children:t.description}),t.enum&&l.jsxs("p",{children:[l.jsx("span",{className:"font-medium text-foreground",children:"Values: "}),t.enum.map((o,u)=>l.jsxs("span",{children:[u>0&&", ",l.jsx("code",{className:"bg-muted px-1 rounded-sm",children:JSON.stringify(o)})]},u))]}),((a=t.items)==null?void 0:a.type)&&l.jsxs("p",{children:[l.jsx("span",{className:"font-medium text-foreground",children:"Items: "}),t.items.type]})]})]})}const ey=Am,ty=Pm,ny=Om,ry={current:"Current directory",downstream:"Project"};function Os({id:e,label:t,count:n,open:r,onToggle:i,children:s}){return l.jsxs(ey,{open:r,children:[l.jsxs(ty,{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:[l.jsx(ri,{className:H("size-3 shrink-0 transition-transform duration-150 ease-out",r&&"rotate-90")}),l.jsx("span",{className:"text-[11px] font-medium tracking-[0.08em] uppercase",children:t}),l.jsx("span",{className:"ml-auto text-[11px] font-normal tabular-nums text-sidebar-foreground/65",children:n})]}),l.jsx(ny,{children:l.jsx("div",{className:"border-sidebar-border/70 mt-0.5 ml-[13px] border-l pl-1",children:s})})]})}function Yo({location:e}){return l.jsx("div",{className:"px-2 pt-2 pb-0.5 text-[10px] tracking-[0.08em] text-sidebar-foreground/65 uppercase",children:ry[e]??e})}function Xo({name:e,subtitle:t,added:n,query:r,onSelect:i}){return l.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:[l.jsx("span",{className:"truncate",children:l.jsx(Ya,{text:e,query:r})}),n?l.jsx("span",{className:"ml-auto shrink-0 text-[10px] tracking-[0.06em] text-sidebar-foreground/65 uppercase",children:"Open"}):l.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 iy({documents:e,themes:t,plugins:n,openNames:r,query:i,expandedGroups:s,onToggleGroup:a,onQuickAdd:o,onShowPluginDetails:u,isPluginSelected:c,onTogglePlugin:f,isApplyingPlugins:d,selectedPluginCount:p}){const h=x=>i?!0:s.has(x),m=b.useMemo(()=>Qo(e),[e]),v=b.useMemo(()=>Qo(t),[t]);return e.length>0||t.length>0||n.length>0?l.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.length>0&&l.jsx(Os,{id:"library-documents",label:"Project documents",count:e.length,open:h("library-documents"),onToggle:a,children:m.map(([x,j])=>l.jsxs(Se.Fragment,{children:[m.length>1&&l.jsx(Yo,{location:x}),j.map(g=>l.jsx(Xo,{name:g.name,subtitle:g.title,added:r.has(g.name),query:i,onSelect:()=>o(g.name,!1)},g.path||g.name))]},x))}),t.length>0&&l.jsx(Os,{id:"library-themes",label:"Project themes",count:t.length,open:h("library-themes"),onToggle:a,children:v.map(([x,j])=>l.jsxs(Se.Fragment,{children:[v.length>1&&l.jsx(Yo,{location:x}),j.map(g=>l.jsx(Xo,{name:g.name,subtitle:g.description,added:r.has(g.name),query:i,onSelect:()=>o(g.name,!0)},g.path||g.name))]},x))}),n.length>0&&l.jsx(Os,{id:"library-plugins",label:"Plugins",count:`${p}/${n.length}`,open:h("library-plugins"),onToggle:a,children:n.map(x=>{const j=c(x.name),g=`plugin-switch-${x.filePath||x.name}`;return l.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:[l.jsx("label",{htmlFor:g,className:H("flex h-7 min-w-0 flex-1 cursor-pointer items-center text-[13px]",j?"text-sidebar-foreground":"text-sidebar-foreground/70"),children:l.jsx("span",{className:"truncate",children:l.jsx(Ya,{text:x.name,query:i})})}),l.jsx(Bt,{"aria-label":`Details for ${x.name}`,onClick:I=>{I.stopPropagation(),u(x.name)},className:"opacity-0 group-hover/row:opacity-100 focus-visible:opacity-100",children:l.jsx(Yc,{})}),l.jsx(Qa,{id:g,checked:j,onCheckedChange:()=>f(x),disabled:d,className:"shrink-0","aria-label":`Toggle ${x.name} plugin`})]},x.filePath||x.name)})})]}):null}function Qo(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 l.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 sy({children:e,className:t}){return l.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 l.jsx(sy,{className:t,children:r.map((i,s)=>l.jsx(Wd,{children:i},s))})}function ay({className:e}={}){const{theme:t,setTheme:n}=Jc(),r=t==="system"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":t,i=b.useCallback(()=>{n(r==="dark"?"light":"dark")},[r,n]);return l.jsxs(We,{children:[l.jsx(qe,{asChild:!0,children:l.jsxs(Ce,{variant:"ghost",size:"icon",onClick:i,className:e,children:[l.jsx(eg,{className:"hidden dark:block"}),l.jsx(tg,{className:"block dark:hidden"}),l.jsx("span",{className:"sr-only",children:"Toggle theme"})]})}),l.jsx(Ge,{children:l.jsx("p",{children:"Toggle theme"})})]})}function oy({discoveryData:e,onToggleSidebar:t,isCollapsed:n=!1,isAnimating:r=!1}){const{documents:i,documentTypes:s,createDocument:a,openDocument:o}=Oe(rd(U=>({documents:U.documents,documentTypes:U.documentTypes,createDocument:U.createDocument,openDocument:U.openDocument}))),u=da(U=>U.updateTheme),c=da(U=>U.removeTheme),f=b.useContext(nd),[d,p]=b.useState(!1),[h,m]=b.useState(!1),[v,S]=b.useState(!1),[x,j]=b.useState(null),g=Rt(U=>U.togglePlugin),I=Rt(U=>U.isPluginSelected),E=Rt(U=>U.selectedPlugins),k=Rt(U=>U.isApplyingPlugins),[N,J]=b.useState(!1),[L,C]=b.useState(new Set(["library-documents"])),[z,A]=b.useState(""),M=b.useRef(null),{toast:$}=fr(),F=i.filter(U=>s[U.name]!=="application/json+theme"),P=i.filter(U=>s[U.name]==="application/json+theme"),G=b.useCallback(()=>{p(!1)},[]),B=b.useCallback(()=>{m(!1)},[]),ie=b.useRef(new Map);b.useEffect(()=>{const U=ie.current,Ae=new Map;P.forEach(X=>{Ae.set(X.name,X.text),U.get(X.name)!==X.text&&u(X.name,X.text)}),U.forEach((X,ve)=>{Ae.has(ve)||c(ve)}),ie.current=Ae},[P,u,c]);const w=b.useRef(!1);b.useEffect(()=>{if(w.current||!f)return;w.current=!0;const U=new Set(P.map(X=>X.name));Object.keys(f.getState().customThemes).forEach(X=>{U.has(X)||c(X)})},[P,c,f]);const le=b.useCallback(U=>{C(Ae=>{const X=new Set(Ae);return X.has(U)?X.delete(U):X.add(U),X})},[]),{resolvedTheme:q}=Jc(),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(U,Ae)=>{if(i.some(X=>X.name===U)){o(U);return}try{const X=await fetch(`/api/discovery/${Ae?"themes":"documents"}/${encodeURIComponent(U)}/content`);if(!X.ok)throw new Error(X.statusText);const ve=await X.text(),_=JSON.parse(ve);a(U,JSON.stringify(_,null,2)),o(U),$({title:`Added ${Ae?"theme":"document"}: ${U}`})}catch{$({title:"Failed to load",description:`Could not load ${U}`,variant:"destructive"})}},[i,a,o,$]);b.useEffect(()=>{if(n)return;const U=Ae=>{var _,T,O,ee,Y;if(Ae.key!=="/"||Ae.metaKey||Ae.ctrlKey||Ae.altKey)return;const X=Ae.target,ve=(_=X==null?void 0:X.tagName)==null?void 0:_.toLowerCase();ve==="input"||ve==="textarea"||ve==="select"||X!=null&&X.isContentEditable||(T=X==null?void 0:X.closest)!=null&&T.call(X,".monaco-editor")||(O=M.current)!=null&&O.closest('[aria-hidden="true"], [inert]')||(Ae.preventDefault(),(ee=M.current)==null||ee.focus(),(Y=M.current)==null||Y.select())};return window.addEventListener("keydown",U),()=>window.removeEventListener("keydown",U)},[n]);const Z=z.trim(),se=b.useMemo(()=>new Set(i.map(U=>U.name)),[i]),re=b.useMemo(()=>F.filter(U=>an(U.name,Z)),[F,Z]),ne=b.useMemo(()=>P.filter(U=>an(U.name,Z)),[P,Z]),de=b.useMemo(()=>((e==null?void 0:e.documents)??[]).filter(U=>an(U.name,Z)||an(U.title??"",Z)),[e,Z]),ge=b.useMemo(()=>((e==null?void 0:e.themes)??[]).filter(U=>an(U.name,Z)||an(U.description??"",Z)),[e,Z]),Ne=b.useMemo(()=>((e==null?void 0:e.plugins)??[]).filter(U=>an(U.name,Z)||an(U.description??"",Z)),[e,Z]),be=Z.length>0&&re.length===0&&ne.length===0&&de.length===0&&ge.length===0&&Ne.length===0,xe=H("transition-opacity duration-150 ease-out",r?"opacity-0":"opacity-100");return l.jsxs(l.Fragment,{children:[l.jsxs(Zd,{collapsible:"none",style:{"--sidebar-width":n?"3rem":"16rem"},children:[n?l.jsxs(l.Fragment,{children:[l.jsx(xa,{className:H("gap-0 p-1.5",xe),children:l.jsxs(We,{children:[l.jsx(qe,{asChild:!0,children:l.jsx(Bt,{className:"mx-auto size-7","aria-label":"Expand sidebar","aria-expanded":!1,onClick:t,children:l.jsx(Xc,{})})}),l.jsxs(Ge,{side:"right",className:"flex items-center gap-2",children:[l.jsx("span",{children:"Expand sidebar"}),l.jsx(Br,{shortcut:"mod+b"})]})]})}),l.jsxs(ya,{className:H("gap-2 px-1 py-1",xe),children:[l.jsxs(Cr,{className:"items-center gap-0.5",children:[F.map(U=>l.jsx(mi,{document:U,compact:!0},U.name)),l.jsxs(We,{children:[l.jsx(qe,{asChild:!0,children:l.jsx(Bt,{className:"size-7","aria-label":"New document",onClick:()=>p(!0),children:l.jsx(Xt,{})})}),l.jsx(Ge,{side:"right",children:"New document"})]})]}),l.jsx("div",{className:"bg-sidebar-border/70 mx-auto h-px w-6"}),l.jsxs(Cr,{className:"items-center gap-0.5",children:[P.map(U=>l.jsx(mi,{document:U,compact:!0},U.name)),l.jsxs(We,{children:[l.jsx(qe,{asChild:!0,children:l.jsx(Bt,{className:"size-7","aria-label":"New theme",onClick:()=>m(!0),children:l.jsx(Xt,{})})}),l.jsx(Ge,{side:"right",children:"New theme"})]})]})]})]}):l.jsxs(l.Fragment,{children:[l.jsxs(xa,{className:H("gap-0 p-2",xe),children:[l.jsxs("div",{className:"flex h-7 items-center justify-between gap-1",children:[l.jsx("a",{href:"/","aria-label":"JSON to Office home",className:"focus-visible:ring-sidebar-ring flex items-center rounded-sm pl-1 focus-visible:ring-1 focus-visible:outline-none",children:l.jsx("img",{src:y,alt:"Wiseair",className:"h-[18px] w-auto max-w-[110px] shrink-0"})}),l.jsxs(We,{children:[l.jsx(qe,{asChild:!0,children:l.jsx(Bt,{"aria-label":"Collapse sidebar","aria-expanded":!0,onClick:t,children:l.jsx(ng,{})})}),l.jsxs(Ge,{side:"right",className:"flex items-center gap-2",children:[l.jsx("span",{children:"Collapse sidebar"}),l.jsx(Br,{shortcut:"mod+b"})]})]})]}),l.jsxs("div",{className:"relative mt-2",children:[l.jsx(rg,{"aria-hidden":!0,className:"pointer-events-none absolute top-1/2 left-2 size-3.5 -translate-y-1/2 text-sidebar-foreground/40"}),l.jsx("input",{ref:M,type:"text",value:z,spellCheck:!1,autoComplete:"off",placeholder:"Filter files…","aria-label":"Filter documents, themes and plugins",onChange:U=>A(U.target.value),onKeyDown:U=>{U.key==="Escape"&&(U.preventDefault(),A(""),U.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")}),Z?l.jsx(Bt,{"aria-label":"Clear filter",onClick:()=>{var U;A(""),(U=M.current)==null||U.focus()},className:"absolute top-1/2 right-1 -translate-y-1/2",children:l.jsx(pn,{})}):l.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:"/"})]})]}),l.jsx(ya,{className:H("gap-0 px-2 pb-2",xe),children:be?l.jsxs("div",{className:"px-1 py-6 text-center",children:[l.jsxs("p",{className:"text-[13px] text-sidebar-foreground/70",children:["No files match “",Z,"”"]}),l.jsx("button",{type:"button",onClick:()=>{var U;A(""),(U=M.current)==null||U.focus()},className:"text-sidebar-foreground/70 hover:text-sidebar-foreground focus-visible:ring-sidebar-ring mt-1 cursor-pointer rounded-sm text-[12px] underline-offset-2 hover:underline focus-visible:ring-1 focus-visible:outline-none",children:"Clear filter"})]}):l.jsxs(l.Fragment,{children:[(re.length>0||!Z)&&l.jsxs("section",{children:[l.jsx(qo,{count:(Z?re.length:F.length)||void 0,actions:l.jsxs(l.Fragment,{children:[yt==="docx"&&l.jsxs(We,{children:[l.jsx(qe,{asChild:!0,children:l.jsx(Bt,{"aria-label":"Compare documents",disabled:F.length<2,onClick:()=>J(!0),children:l.jsx(Wc,{})})}),l.jsx(Ge,{side:"bottom",children:F.length<2?"Compare needs two documents":"Compare documents (redline)"})]}),l.jsxs(We,{children:[l.jsx(qe,{asChild:!0,children:l.jsx(Bt,{"aria-label":"New document",onClick:()=>p(!0),children:l.jsx(Xt,{})})}),l.jsx(Ge,{side:"bottom",children:"New document"})]})]}),children:"Documents"}),l.jsx(Cr,{className:"gap-0.5",children:re.length>0?re.map(U=>l.jsx(mi,{document:U,query:Z},U.name)):l.jsx(Ko,{icon:Xt,label:"New document",onClick:()=>p(!0)})})]}),(ne.length>0||!Z)&&l.jsxs("section",{className:"mt-3",children:[l.jsx(qo,{count:(Z?ne.length:P.length)||void 0,actions:l.jsxs(We,{children:[l.jsx(qe,{asChild:!0,children:l.jsx(Bt,{"aria-label":"New theme",onClick:()=>m(!0),children:l.jsx(Xt,{})})}),l.jsx(Ge,{side:"bottom",children:"New theme"})]}),children:"Themes"}),l.jsx(Cr,{className:"gap-0.5",children:ne.length>0?ne.map(U=>l.jsx(mi,{document:U,query:Z},U.name)):l.jsx(Ko,{icon:Xt,label:"New theme",onClick:()=>m(!0)})})]}),(de.length>0||ge.length>0||Ne.length>0)&&l.jsx("div",{className:"border-sidebar-border/70 mt-3 border-t pt-2",children:l.jsx(iy,{documents:de,themes:ge,plugins:Ne,openNames:se,query:Z,expandedGroups:L,onToggleGroup:le,onQuickAdd:W,onShowPluginDetails:U=>{j(U),S(!0)},isPluginSelected:I,onTogglePlugin:g,isApplyingPlugins:k,selectedPluginCount:E.size})})]})})]}),l.jsx(Bd,{className:H("border-sidebar-border/70 gap-0 border-t p-1.5",xe),children:l.jsx("div",{className:H("flex items-center",n?"justify-center":"justify-start"),children:l.jsx(ay,{className:"size-7 rounded-sm text-sidebar-foreground/70 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground [&_svg]:size-3.5"})})})]}),l.jsx(_t,{open:d,onOpenChange:p,children:l.jsx(bt,{className:"sm:max-w-[525px]",children:l.jsx(Mi,{mode:"create",shouldReset:!d,postSubmit:G,discoveredDocuments:(e==null?void 0:e.documents)||[]})})}),l.jsx(_t,{open:h,onOpenChange:m,children:l.jsx(bt,{className:"sm:max-w-[525px]",children:l.jsx(Mi,{mode:"create",shouldReset:!h,postSubmit:B,discoveredThemes:(e==null?void 0:e.themes)||[],isTheme:!0})})}),l.jsx(_t,{open:v,onOpenChange:U=>{S(U),U||j(null)},children:l.jsx(bt,{className:"max-h-[85vh] overflow-hidden sm:max-w-5xl",children:l.jsx(Xx,{plugins:(e==null?void 0:e.plugins)||[],initialFocusedPlugin:x})})}),l.jsx(Pg,{open:N,onOpenChange:J})]})}const el=b.memo(oy),ly=b.lazy(()=>Hc(()=>import("./editor-3sZ4Fpsu.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11])).then(e=>({default:e.Editor})));function tl(){return l.jsx(b.Suspense,{fallback:l.jsx("div",{className:"flex items-center justify-center h-full",children:l.jsxs("div",{className:"text-center",children:[l.jsx(en,{className:"w-8 h-8 mx-auto mb-2"}),l.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading editor..."})]})}),children:l.jsx(ly,{})})}const uy=b.lazy(()=>Hc(()=>import("./preview-CC4_sT2f.js"),__vite__mapDeps([12,1,3,4,5,6,7,8,9,10,11])).then(e=>({default:e.Preview})));function nl(){return l.jsx(b.Suspense,{fallback:l.jsx("div",{className:"flex items-center justify-center h-full",children:l.jsxs("div",{className:"text-center",children:[l.jsx(en,{className:"w-8 h-8 mx-auto mb-2"}),l.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading preview..."})]})}),children:l.jsx(uy,{})})}const{createElement:ar,createContext:cy,forwardRef:qd,useCallback:pt,useContext:Gd,useEffect:En,useImperativeHandle:Kd,useLayoutEffect:dy,useMemo:fy,useRef:xt,useState:Qn}=uc,rl=uc[`useId${Math.random()}`.slice(0,5)],py=dy,hs=cy(null);hs.displayName="PanelGroupContext";const In=py,hy=typeof rl=="function"?rl:()=>null;let my=0;function eo(e=null){const t=hy(),n=xt(e||t||null);return n.current===null&&(n.current=""+my++),e??n.current}function Yd({children:e,className:t="",collapsedSize:n,collapsible:r,defaultSize:i,forwardedRef:s,id:a,maxSize:o,minSize:u,onCollapse:c,onExpand:f,onResize:d,order:p,style:h,tagName:m="div",...v}){const S=Gd(hs);if(S===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:x,expandPanel:j,getPanelSize:g,getPanelStyle:I,groupId:E,isPanelCollapsed:k,reevaluatePanelConstraints:N,registerPanel:J,resizePanel:L,unregisterPanel:C}=S,z=eo(a),A=xt({callbacks:{onCollapse:c,onExpand:f,onResize:d},constraints:{collapsedSize:n,collapsible:r,defaultSize:i,maxSize:o,minSize:u},id:z,idIsFromProps:a!==void 0,order:p});xt({didLogMissingDefaultSizeWarning:!1}),In(()=>{const{callbacks:$,constraints:F}=A.current,P={...F};A.current.id=z,A.current.idIsFromProps=a!==void 0,A.current.order=p,$.onCollapse=c,$.onExpand=f,$.onResize=d,F.collapsedSize=n,F.collapsible=r,F.defaultSize=i,F.maxSize=o,F.minSize=u,(P.collapsedSize!==F.collapsedSize||P.collapsible!==F.collapsible||P.maxSize!==F.maxSize||P.minSize!==F.minSize)&&N(A.current,P)}),In(()=>{const $=A.current;return J($),()=>{C($)}},[p,z,J,C]),Kd(s,()=>({collapse:()=>{x(A.current)},expand:$=>{j(A.current,$)},getId(){return z},getSize(){return g(A.current)},isCollapsed(){return k(A.current)},isExpanded(){return!k(A.current)},resize:$=>{L(A.current,$)}}),[x,j,g,k,z,L]);const M=I(A.current,i);return ar(m,{...v,children:e,className:t,id:a,style:{...M,...h},"data-panel":"","data-panel-collapsible":r||void 0,"data-panel-group-id":E,"data-panel-id":z,"data-panel-size":parseFloat(""+M.flexGrow).toFixed(1)})}const Xd=qd((e,t)=>ar(Yd,{...e,forwardedRef:t}));Yd.displayName="Panel";Xd.displayName="forwardRef(Panel)";let ba=null,Nn=null;function gy(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 xy(){Nn!==null&&(document.head.removeChild(Nn),ba=null,Nn=null)}function Ds(e,t){const n=gy(e,t);ba!==n&&(ba=n,Nn===null&&(Nn=document.createElement("style"),document.head.appendChild(Nn)),Nn.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 yy(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function by(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 vy(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:al(e),b:al(t)};let r;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),r=e;je(r,"Stacking order can only be calculated for elements with a common ancestor");const i={a:sl(il(n.a)),b:sl(il(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 u=s[o];if(u===a.a)return 1;if(u===a.b)return-1}}return Math.sign(i.a-i.b)}const wy=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function ky(e){var t;const n=getComputedStyle((t=nf(e))!==null&&t!==void 0?t:e).display;return n==="flex"||n==="inline-flex"}function Sy(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||ky(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"||wy.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function il(e){let t=e.length;for(;t--;){const n=e[t];if(je(n,"Missing node"),Sy(n))return n}return null}function sl(e){return e&&Number(getComputedStyle(e).zIndex)||0}function al(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,_y=yy()==="coarse";let Mt=[],er=!1,dn=new Map,gs=new Map;const Vr=new Set;function jy(e,t,n,r,i){var s;const{ownerDocument:a}=t,o={direction:n,element:t,hitAreaMargins:r,setResizeHandlerState:i},u=(s=dn.get(a))!==null&&s!==void 0?s:0;return dn.set(a,u+1),Vr.add(o),Bi(),function(){var f;gs.delete(e),Vr.delete(o);const d=(f=dn.get(a))!==null&&f!==void 0?f:1;if(dn.set(a,d-1),Bi(),d===1&&dn.delete(a),Mt.includes(o)){const p=Mt.indexOf(o);p>=0&&Mt.splice(p,1),no(),i("up",!0,null)}}}function ol(e){const{target:t}=e,{x:n,y:r}=ms(e);er=!0,to({target:t,x:n,y:r}),Bi(),Mt.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;to({target:r,x:t,y:n})}Vi("move",e),no(),Mt.length>0&&e.preventDefault()}function $n(e){const{target:t}=e,{x:n,y:r}=ms(e);gs.clear(),er=!1,Mt.length>0&&e.preventDefault(),Vi("up",e),to({target:t,x:n,y:r}),no(),Bi()}function to({target:e,x:t,y:n}){Mt.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:u,left:c,right:f,top:d}=o,p=_y?a.coarse:a.fine;if(t>=c-p&&t<=f+p&&n>=d-p&&n<=u+p){if(r!==null&&document.contains(r)&&s!==r&&!s.contains(r)&&!r.contains(s)&&vy(r,s)>0){let m=r,v=!1;for(;m&&!m.contains(s);){if(by(m.getBoundingClientRect(),o)){v=!0;break}m=m.parentElement}if(v)return}Mt.push(i)}})}function Rs(e,t){gs.set(e,t)}function no(){let e=!1,t=!1;Mt.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):xy()}function Bi(){dn.forEach((e,t)=>{const{body:n}=t;n.removeEventListener("contextmenu",$n),n.removeEventListener("pointerdown",ol),n.removeEventListener("pointerleave",vr),n.removeEventListener("pointermove",vr)}),window.removeEventListener("pointerup",$n),window.removeEventListener("pointercancel",$n),Vr.size>0&&(er?(Mt.length>0&&dn.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)):dn.forEach((e,t)=>{const{body:n}=t;e>0&&(n.addEventListener("pointerdown",ol,{capture:!0}),n.addEventListener("pointermove",vr))}))}function Vi(e,t){Vr.forEach(n=>{const{setResizeHandlerState:r}=n,i=Mt.includes(n);r(e,i,t)})}function Cy(){const[e,t]=Qn(0);return pt(()=>t(n=>n+1),[])}function je(e,t){if(!e)throw console.error(t),Error(t)}const ro=10;function zn(e,t,n=ro){return e.toFixed(n)===t.toFixed(n)?0:e>t?1:-1}function tn(e,t,n=ro){return zn(e,t,n)===0}function St(e,t,n){return zn(e,t,n)===0}function Ny(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(!St(i,s,n))return!1}return!0}function Gn({panelConstraints:e,panelIndex:t,size:n}){const r=e[t];je(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 u=(i+o)/2;zn(n,u)<0?n=i:n=o}else n=o;return n=Math.min(a,n),n=parseFloat(n.toFixed(ro)),n}function Nr({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:s}){if(St(e,0))return t;const a=[...t],[o,u]=r;je(o!=null,"Invalid first pivot index"),je(u!=null,"Invalid second pivot index");let c=0;if(s==="keyboard"){{const d=e<0?u:o,p=n[d];je(p,`Panel constraints not found for index ${d}`);const{collapsedSize:h=0,collapsible:m,minSize:v=0}=p;if(m){const S=t[d];if(je(S!=null,`Previous layout not found for panel index ${d}`),St(S,h)){const x=v-S;zn(x,Math.abs(e))>0&&(e=e<0?0-x:x)}}}{const d=e<0?o:u,p=n[d];je(p,`No panel constraints found for index ${d}`);const{collapsedSize:h=0,collapsible:m,minSize:v=0}=p;if(m){const S=t[d];if(je(S!=null,`Previous layout not found for panel index ${d}`),St(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?u:o,h=0;for(;;){const v=t[p];je(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 m=Math.min(Math.abs(e),Math.abs(h));e=e<0?0-m:m}{let p=e<0?o:u;for(;p>=0&&p<n.length;){const h=Math.abs(e)-Math.abs(c),m=t[p];je(m!=null,`Previous layout not found for panel index ${p}`);const v=m-h,S=Gn({panelConstraints:n,panelIndex:p,size:v});if(!St(m,S)&&(c+=m-S,a[p]=S,c.toPrecision(3).localeCompare(Math.abs(e).toPrecision(3),void 0,{numeric:!0})>=0))break;e<0?p--:p++}}if(Ny(i,a))return i;{const d=e<0?u:o,p=t[d];je(p!=null,`Previous layout not found for panel index ${d}`);const h=p+c,m=Gn({panelConstraints:n,panelIndex:d,size:h});if(a[d]=m,!St(m,h)){let v=h-m,x=e<0?u:o;for(;x>=0&&x<n.length;){const j=a[x];je(j!=null,`Previous layout not found for panel index ${x}`);const g=j+v,I=Gn({panelConstraints:n,panelIndex:x,size:g});if(St(j,I)||(v-=I-j,a[x]=I),St(v,0))break;e>0?x--:x++}}}const f=a.reduce((d,p)=>p+d,0);return St(f,100)?a:i}function Ey({layout:e,panelsArray:t,pivotIndices:n}){let r=0,i=100,s=0,a=0;const o=n[0];je(o!=null,"No pivot index found"),t.forEach((d,p)=>{const{constraints:h}=d,{maxSize:m=100,minSize:v=0}=h;p===o?(r=v,i=m):(s+=v,a+=m)});const u=Math.min(i,100-s),c=Math.max(r,100-a),f=e[o];return{valueMax:u,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 Iy(e,t,n,r=document){var i,s,a,o;const u=xs(t,r),c=Ur(e,r),f=u?c.indexOf(u):-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 Ty({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:r,panelDataArray:i,panelGroupElement:s,setLayout:a}){xt({didWarnAboutMissingResizeHandle:!1}),In(()=>{if(!s)return;const o=Ur(n,s);for(let u=0;u<i.length-1;u++){const{valueMax:c,valueMin:f,valueNow:d}=Ey({layout:r,panelsArray:i,pivotIndices:[u,u+1]}),p=o[u];if(p!=null){const h=i[u];je(h,`No panel data found for index "${u}"`),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((u,c)=>{u.removeAttribute("aria-controls"),u.removeAttribute("aria-valuemax"),u.removeAttribute("aria-valuemin"),u.removeAttribute("aria-valuenow")})}},[n,r,i,s]),En(()=>{if(!s)return;const o=t.current;je(o,"Eager values not found");const{panelDataArray:u}=o,c=cf(n,s);je(c!=null,`No group found for id "${n}"`);const f=Ur(n,s);je(f,`No resize handles found for group id "${n}"`);const d=f.map(p=>{const h=p.getAttribute("data-panel-resize-handle-id");je(h,"Resize handle element has no handle id attribute");const[m,v]=Iy(n,h,u,s);if(m==null||v==null)return()=>{};const S=x=>{if(!x.defaultPrevented)switch(x.key){case"Enter":{x.preventDefault();const j=u.findIndex(g=>g.id===m);if(j>=0){const g=u[j];je(g,`No panel data found for index ${j}`);const I=r[j],{collapsedSize:E=0,collapsible:k,minSize:N=0}=g.constraints;if(I!=null&&k){const J=Nr({delta:St(I,E)?N-E:E-I,initialLayout:r,panelConstraints:u.map(L=>L.constraints),pivotIndices:uf(n,h,s),prevLayout:r,trigger:"keyboard"});r!==J&&a(J)}}break}}};return p.addEventListener("keydown",S),()=>{p.removeEventListener("keydown",S)}});return()=>{d.forEach(p=>p())}},[s,e,t,n,r,i,a])}function ll(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 zy(e,t,n,r,i){const s=n==="horizontal",a=xs(t,i);je(a,`No resize handle element found for id "${t}"`);const o=a.getAttribute("data-panel-group-id");je(o,"Resize handle element has no group id attribute");let{initialCursorPosition:u}=r;const c=df(n,e),f=cf(o,i);je(f,`No group element found for id "${o}"`);const d=f.getBoundingClientRect(),p=s?d.width:d.height;return(c-u)/p*100}function Ay(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 u=0;switch(e.key){case"ArrowDown":u=a?0:o;break;case"ArrowLeft":u=a?-o:0;break;case"ArrowRight":u=a?o:0;break;case"ArrowUp":u=a?0:-o;break;case"End":u=100;break;case"Home":u=-100;break}return u}else return r==null?0:zy(e,t,n,r,s)}function Py({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];je(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];je(a,`Panel constraints not found for index ${s}`);const{defaultSize:o}=a;if(o!=null)continue;const u=e.length-r,c=i/u;r++,t[s]=c,i-=c}return t}function Fn(e,t,n){t.forEach((r,i)=>{const s=e[i];je(s,`Panel data not found for index ${i}`);const{callbacks:a,constraints:o,id:u}=s,{collapsedSize:c=0,collapsible:f}=o,d=n[u];if(d==null||r!==d){n[u]=r;const{onCollapse:p,onExpand:h,onResize:m}=a;m&&m(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 Oy({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 Dy(e,t=10){let n=null;return(...i)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...i)},t)}}function ul(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 Ry(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 My(e,t,n,r,i){var s;const a=ff(e),o=pf(t),u=(s=hf(e,i))!==null&&s!==void 0?s:{};u[o]={expandToSizes:Object.fromEntries(n.entries()),layout:r};try{i.setItem(a,JSON.stringify(u))}catch(c){console.error(c)}}function cl({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(!St(r,100)&&n.length>0)for(let s=0;s<t.length;s++){const a=n[s];je(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];je(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(!St(i,0))for(let s=0;s<t.length;s++){const a=n[s];je(a!=null,`No layout data found for index ${s}`);const o=a+i,u=Gn({panelConstraints:t,panelIndex:s,size:o});if(a!==u&&(i-=u-a,n[s]=u,St(i,0)))break}return n}const $y=100,Er={getItem:e=>(ul(Er),Er.getItem(e)),setItem:(e,t)=>{ul(Er),Er.setItem(e,t)}},dl={};function mf({autoSaveId:e=null,children:t,className:n="",direction:r,forwardedRef:i,id:s=null,onLayout:a=null,keyboardResizeBy:o=null,storage:u=Er,style:c,tagName:f="div",...d}){const p=eo(s),h=xt(null),[m,v]=Qn(null),[S,x]=Qn([]),j=Cy(),g=xt({}),I=xt(new Map),E=xt(0),k=xt({autoSaveId:e,direction:r,dragState:m,id:p,keyboardResizeBy:o,onLayout:a,storage:u}),N=xt({layout:S,panelDataArray:[],panelDataArrayChanged:!1});xt({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),Kd(i,()=>({getId:()=>k.current.id,getLayout:()=>{const{layout:y}=N.current;return y},setLayout:y=>{const{onLayout:W}=k.current,{layout:Z,panelDataArray:se}=N.current,re=cl({layout:y,panelConstraints:se.map(ne=>ne.constraints)});ll(Z,re)||(x(re),N.current.layout=re,W&&W(re),Fn(se,re,g.current))}}),[]),In(()=>{k.current.autoSaveId=e,k.current.direction=r,k.current.dragState=m,k.current.id=p,k.current.onLayout=a,k.current.storage=u}),Ty({committedValuesRef:k,eagerValuesRef:N,groupId:p,layout:S,panelDataArray:N.current.panelDataArray,setLayout:x,panelGroupElement:h.current}),En(()=>{const{panelDataArray:y}=N.current;if(e){if(S.length===0||S.length!==y.length)return;let W=dl[e];W==null&&(W=Dy(My,$y),dl[e]=W);const Z=[...y],se=new Map(I.current);W(e,Z,se,S,u)}},[e,S,u]),En(()=>{});const J=pt(y=>{const{onLayout:W}=k.current,{layout:Z,panelDataArray:se}=N.current;if(y.constraints.collapsible){const re=se.map(Ne=>Ne.constraints),{collapsedSize:ne=0,panelSize:de,pivotIndices:ge}=wn(se,y,Z);if(je(de!=null,`Panel size not found for panel "${y.id}"`),!tn(de,ne)){I.current.set(y.id,de);const be=Jn(se,y)===se.length-1?de-ne:ne-de,xe=Nr({delta:be,initialLayout:Z,panelConstraints:re,pivotIndices:ge,prevLayout:Z,trigger:"imperative-api"});xi(Z,xe)||(x(xe),N.current.layout=xe,W&&W(xe),Fn(se,xe,g.current))}}},[]),L=pt((y,W)=>{const{onLayout:Z}=k.current,{layout:se,panelDataArray:re}=N.current;if(y.constraints.collapsible){const ne=re.map(U=>U.constraints),{collapsedSize:de=0,panelSize:ge=0,minSize:Ne=0,pivotIndices:be}=wn(re,y,se),xe=W??Ne;if(tn(ge,de)){const U=I.current.get(y.id),Ae=U!=null&&U>=xe?U:xe,ve=Jn(re,y)===re.length-1?ge-Ae:Ae-ge,_=Nr({delta:ve,initialLayout:se,panelConstraints:ne,pivotIndices:be,prevLayout:se,trigger:"imperative-api"});xi(se,_)||(x(_),N.current.layout=_,Z&&Z(_),Fn(re,_,g.current))}}},[]),C=pt(y=>{const{layout:W,panelDataArray:Z}=N.current,{panelSize:se}=wn(Z,y,W);return je(se!=null,`Panel size not found for panel "${y.id}"`),se},[]),z=pt((y,W)=>{const{panelDataArray:Z}=N.current,se=Jn(Z,y);return Oy({defaultSize:W,dragState:m,layout:S,panelData:Z,panelIndex:se})},[m,S]),A=pt(y=>{const{layout:W,panelDataArray:Z}=N.current,{collapsedSize:se=0,collapsible:re,panelSize:ne}=wn(Z,y,W);return je(ne!=null,`Panel size not found for panel "${y.id}"`),re===!0&&tn(ne,se)},[]),M=pt(y=>{const{layout:W,panelDataArray:Z}=N.current,{collapsedSize:se=0,collapsible:re,panelSize:ne}=wn(Z,y,W);return je(ne!=null,`Panel size not found for panel "${y.id}"`),!re||zn(ne,se)>0},[]),$=pt(y=>{const{panelDataArray:W}=N.current;W.push(y),W.sort((Z,se)=>{const re=Z.order,ne=se.order;return re==null&&ne==null?0:re==null?-1:ne==null?1:re-ne}),N.current.panelDataArrayChanged=!0,j()},[j]);In(()=>{if(N.current.panelDataArrayChanged){N.current.panelDataArrayChanged=!1;const{autoSaveId:y,onLayout:W,storage:Z}=k.current,{layout:se,panelDataArray:re}=N.current;let ne=null;if(y){const ge=Ry(y,re,Z);ge&&(I.current=new Map(Object.entries(ge.expandToSizes)),ne=ge.layout)}ne==null&&(ne=Py({panelDataArray:re}));const de=cl({layout:ne,panelConstraints:re.map(ge=>ge.constraints)});ll(se,de)||(x(de),N.current.layout=de,W&&W(de),Fn(re,de,g.current))}}),In(()=>{const y=N.current;return()=>{y.layout=[]}},[]);const F=pt(y=>{let W=!1;const Z=h.current;return Z&&window.getComputedStyle(Z,null).getPropertyValue("direction")==="rtl"&&(W=!0),function(re){re.preventDefault();const ne=h.current;if(!ne)return()=>null;const{direction:de,dragState:ge,id:Ne,keyboardResizeBy:be,onLayout:xe}=k.current,{layout:U,panelDataArray:Ae}=N.current,{initialLayout:X}=ge??{},ve=uf(Ne,y,ne);let _=Ay(re,y,de,ge,be,ne);const T=de==="horizontal";T&&W&&(_=-_);const O=Ae.map(Q=>Q.constraints),ee=Nr({delta:_,initialLayout:X??U,panelConstraints:O,pivotIndices:ve,prevLayout:U,trigger:Qd(re)?"keyboard":"mouse-or-touch"}),Y=!xi(U,ee);(ef(re)||tf(re))&&E.current!=_&&(E.current=_,!Y&&_!==0?T?Rs(y,_<0?rf:sf):Rs(y,_<0?af:of):Rs(y,0)),Y&&(x(ee),N.current.layout=ee,xe&&xe(ee),Fn(Ae,ee,g.current))}},[]),P=pt((y,W)=>{const{onLayout:Z}=k.current,{layout:se,panelDataArray:re}=N.current,ne=re.map(U=>U.constraints),{panelSize:de,pivotIndices:ge}=wn(re,y,se);je(de!=null,`Panel size not found for panel "${y.id}"`);const be=Jn(re,y)===re.length-1?de-W:W-de,xe=Nr({delta:be,initialLayout:se,panelConstraints:ne,pivotIndices:ge,prevLayout:se,trigger:"imperative-api"});xi(se,xe)||(x(xe),N.current.layout=xe,Z&&Z(xe),Fn(re,xe,g.current))},[]),G=pt((y,W)=>{const{layout:Z,panelDataArray:se}=N.current,{collapsedSize:re=0,collapsible:ne}=W,{collapsedSize:de=0,collapsible:ge,maxSize:Ne=100,minSize:be=0}=y.constraints,{panelSize:xe}=wn(se,y,Z);xe!=null&&(ne&&ge&&tn(xe,re)?tn(re,de)||P(y,de):xe<be?P(y,be):xe>Ne&&P(y,Ne))},[P]),B=pt((y,W)=>{const{direction:Z}=k.current,{layout:se}=N.current;if(!h.current)return;const re=xs(y,h.current);je(re,`Drag handle element not found for id "${y}"`);const ne=df(Z,W);v({dragHandleId:y,dragHandleRect:re.getBoundingClientRect(),initialCursorPosition:ne,initialLayout:se})},[]),ie=pt(()=>{v(null)},[]),w=pt(y=>{const{panelDataArray:W}=N.current,Z=Jn(W,y);Z>=0&&(W.splice(Z,1),delete g.current[y.id],N.current.panelDataArrayChanged=!0,j())},[j]),le=fy(()=>({collapsePanel:J,direction:r,dragState:m,expandPanel:L,getPanelSize:C,getPanelStyle:z,groupId:p,isPanelCollapsed:A,isPanelExpanded:M,reevaluatePanelConstraints:G,registerPanel:$,registerResizeHandle:F,resizePanel:P,startDragging:B,stopDragging:ie,unregisterPanel:w,panelGroupElement:h.current}),[J,m,r,L,C,z,p,A,M,G,$,F,P,B,ie,w]),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 wn(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 Fy({disabled:e,handleId:t,resizeHandler:n,panelGroupElement:r}){En(()=>{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");je(o,`No group element found for id "${o}"`);const u=Ur(o,r),c=lf(o,t,r);je(c!==null,`No resize element found for id "${t}"`);const f=a.shiftKey?c>0?c-1:u.length-1:c+1<u.length?c+1:0;u[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:u={},tabIndex:c=0,tagName:f="div",...d}){var p,h;const m=xt(null),v=xt({onDragging:a});En(()=>{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:j,registerResizeHandle:g,startDragging:I,stopDragging:E,panelGroupElement:k}=S,N=eo(i),[J,L]=Qn("inactive"),[C,z]=Qn(!1),[A,M]=Qn(null),$=xt({state:J});In(()=>{$.current.state=J}),En(()=>{if(n)M(null);else{const B=g(N);M(()=>B)}},[n,N,g]);const F=(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 En(()=>{if(n||A==null)return;const B=m.current;return je(B,"Element ref not attached"),jy(N,B,x,{coarse:F,fine:P},(w,le,q)=>{if(le)switch(w){case"down":{L("drag"),je(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}=$.current;y!=="drag"&&L("hover"),je(q,'Expected event to be defined for "move" action'),A(q);break}case"up":{L("hover"),E();const{onDragging:y}=v.current;y&&y(!1);break}}else L("inactive")})},[F,x,n,P,g,N,A,I,E]),Fy({disabled:n,handleId:N,resizeHandler:A,panelGroupElement:k}),ar(f,{...d,children:e,className:t,id:i,onBlur:()=>{z(!1),s==null||s()},onFocus:()=>{z(!0),o==null||o()},ref:m,role:"separator",style:{...{touchAction:"none",userSelect:"none"},...u},tabIndex:c,"data-panel-group-direction":x,"data-panel-group-id":j,"data-resize-handle":"","data-resize-handle-active":J==="drag"?"pointer":C?"keyboard":void 0,"data-resize-handle-state":J,"data-panel-resize-handle-enabled":!n,"data-panel-resize-handle-id":N})}xf.displayName="PanelResizeHandle";const Ly=({className:e,...t})=>l.jsx(gf,{className:H("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...t}),Ms=Xd,fl=({withHandle:e,className:t,...n})=>l.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&&l.jsx("div",{className:"bg-border z-10 flex h-4 w-3 items-center justify-center rounded-sm border",children:l.jsx(ig,{className:"h-2.5 w-2.5"})})}),yf=b.forwardRef(({className:e,...t},n)=>l.jsx("textarea",{className:H("flex min-h-[80px] w-full rounded-sm border border-input bg-background px-3 py-2 text-sm shadow-xs","placeholder:text-muted-foreground","focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring","disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...t}));yf.displayName="Textarea";class Zy{constructor(t){Oo(this,"client");this.client=Ng.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 By=new Zy;function Vy(){const e=b.useRef(null),t=b.useCallback(async(r,i,s,a,o)=>{e.current&&e.current.abort();const u=new AbortController;e.current=u;try{a==null||a("parsing","Validating JSON structure...");let c;try{c=JSON.parse(i)}catch(k){throw new Error(`Invalid JSON: ${k instanceof Error?k.message:"Unknown parse error"}`)}a==null||a("building",`Building ${pi.toLowerCase()} structure...`);const f={jsonDefinition:c,options:{...o,sourceName:r}};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(Uc.generate,{method:"POST",headers:d,body:JSON.stringify(f),signal:u.signal}),h=await p.json();if(!p.ok||!h.success){const k=h.error||h.message||`API request failed with status: ${p.status}`;throw new Error(k)}const{data:m,cache:v,warnings:S}=h,x=v.status==="HIT"?"HIT":v.status==="MISS"?"MISS":"UNKNOWN",j=x==="HIT"?`Served from cache (Hit rate: ${v.hitRate})`:`Generated fresh ${pi.toLowerCase()}`;a==null||a("finalizing",j);const g=globalThis.atob(m.document),I=new Uint8Array(g.length);for(let k=0;k<g.length;k++)I[k]=g.charCodeAt(k);const E=new Blob([I],{type:m.contentType});if(E.size===0)throw new Error(`Received empty ${pi.toLowerCase()} from API`);return{name:r,text:i,blob:E,filename:m.filename,fileId:m.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===u&&(e.current=null)}},[]),n=b.useCallback(()=>{e.current&&(e.current.abort(),e.current=null)},[]);return{generatePresentation:t,generateDocument:t,cancelGeneration:n}}function Uy(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 u=Object.entries(a.context).map(([c,f])=>`${c}: ${JSON.stringify(f)}`).join(", ");o+=` (${u})`}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 Jy({open:e,onClose:t,nonSafeFonts:n,onChoose:r}){const[i,s]=Se.useState("custom");Se.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 l.jsx(_t,{open:e,onOpenChange:u=>!u&&t(),children:l.jsxs(bt,{className:"max-w-md",children:[l.jsxs(Ft,{children:[l.jsx(Lt,{children:"Non-safe fonts in this document"}),l.jsxs(nn,{children:[a," ",n.length===1?"is":"are"," not in the built-in safe list. Choose how to export."]})]}),l.jsx("div",{className:"grid gap-2 py-2",children:o.map(u=>{const c=i===u.value;return l.jsxs("button",{type:"button",onClick:()=>s(u.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:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:`h-3.5 w-3.5 rounded-full border flex items-center justify-center ${c?"border-primary":"border-muted-foreground/50"}`,children:c&&l.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-primary"})}),l.jsx("span",{className:"text-sm font-medium",children:u.title})]}),l.jsx("p",{className:"mt-1 text-xs text-muted-foreground pl-6",children:u.desc})]},u.value)})}),l.jsxs(mn,{children:[l.jsx(Ce,{variant:"outline",size:"sm",onClick:t,children:"Cancel"}),l.jsx(Ce,{size:"sm",onClick:()=>{r(i),t()},children:"Download"})]})]})})}const pl=yt==="docx"?["docxjs","LibreOffice"]:["LibreOffice"],$s={docxjs:["⚡","(Fast) works in the browser — lower fidelity"],LibreOffice:["🖨️","(High fidelity) converts to PDF locally with LibreOffice"]};function Hy({name:e,blob:t,displayReloadButton:n,iframeRef:r,autoReload:i,onToggleAutoReload:s,onManualRender:a,isGenerating:o,isRendering:u,onShowCacheMetrics:c,onShowSchemas:f,onShowFonts:d,documentText:p,editorDocumentText:h,warnings:m,renderingLibrary:v,setRenderingLibrary:S,onToggleChat:x,chatOpen:j,onTogglePreview:g,previewOpen:I}){const E=v!=="docxjs",[k,N]=b.useState(!1),[J,L]=b.useState(!1),[C,z]=b.useState(!1),[A,M]=b.useState(!1),[$,F]=b.useState(!1),[P,G]=b.useState(!1),[B,ie]=b.useState(null),{toast:w}=fr(),{generateDocument:le}=Vy(),q=b.useContext(nd),y=b.useCallback(()=>{const X={},{customThemes:ve}=q.getState();return Object.values(ve).forEach(_=>{_.valid&&_.parsed&&(X[_.name]=_.parsed)}),X},[q]),W=Se.useMemo(()=>{if(!p)return[];try{const X=JSON.parse(p);return[...(yt==="pptx"?Lm:Zm)(X)].filter(_=>!Bm(_))}catch{return[]}},[p]),[Z,se]=b.useState(!1),re=b.useCallback(async()=>{if(t){N(!0);try{await new Promise(X=>setTimeout(X,100)),Ei(`${e}${xr}`,t)}finally{setTimeout(()=>N(!1),500)}}},[t,e]),ne=b.useCallback(async()=>{if(t){if(W.length===0){await re();return}se(!0)}},[t,W.length,re]),de=b.useCallback(async X=>{var ve;if(p){N(!0);try{const _=await le(e,p,y(),void 0,{bypassCache:!0,fonts:{mode:X}});if(_.blob.size===0)w({title:"Export failed",description:"The server returned an empty document.",variant:"destructive"});else{Ei(`${e}${xr}`,_.blob);const T=(ve=_.warnings)==null?void 0:ve.find(O=>{var ee,Y;return((ee=O.context)==null?void 0:ee.code)==="FONT_MODE_SUBSTITUTED"||((Y=O.context)==null?void 0:Y.code)==="FONT_MODE_CUSTOM"});T&&w({title:X==="substitute"?"Fonts substituted":"Non-safe fonts kept",description:T.message})}}catch(_){w({title:"Export failed",description:_ instanceof Error?_.message:String(_),variant:"destructive"})}finally{setTimeout(()=>N(!1),500)}}},[p,e,le,w,y]),ge=b.useCallback(async()=>{if(!(!m||m.length===0)){L(!0);try{const X=Uy(m);if(!X){w({title:"No warnings",description:"There are no warnings to download.",variant:"destructive"});return}const ve=await le("warnings",JSON.stringify(X,null,2),{});ve&&typeof ve=="object"&&"blob"in ve&&ve.blob&&(Ei(`${e}-warnings${xr}`,ve.blob),w({title:"Warnings downloaded",description:`Downloaded warnings document with ${m.length} warning(s).`}))}catch(X){console.error("Failed to generate warnings document:",X),w({title:"Download failed",description:X instanceof Error?X.message:"Failed to generate warnings document",variant:"destructive"})}finally{setTimeout(()=>L(!1),500)}}},[m,e,le,w]),Ne=b.useCallback(async()=>{const X=r==null?void 0:r.current;if(X!=null&&X.src){z(!0);try{await new Promise(_=>{let T=null,O=!1;const ee=()=>{T&&(clearTimeout(T),T=null),X.removeEventListener("load",Q),X.removeEventListener("error",ce)},Y=()=>{O||(O=!0,ee(),_())},Q=()=>Y(),ce=()=>Y();X.addEventListener("load",Q),X.addEventListener("error",ce),T=setTimeout(()=>{console.warn("Iframe reload timed out after 5 seconds"),Y()},5e3);const ye=X.src,R=ye.includes("?")?"&":"?",K=Date.now();X.src=`${ye}${R}_reload=${K}`})}catch(ve){console.error("Iframe reload failed:",ve)}finally{z(!1)}}},[r]),be=b.useCallback(async()=>{M(!0);try{await By.delete(`/${yt}/cache`),window.dispatchEvent(new CustomEvent("cache:cleared")),w({title:"Cache Cleared",description:"All caches (document and component) have been successfully cleared.",variant:"default"})}catch(X){console.error("Failed to clear cache:",X),w({title:"Cache Clear Failed",description:"Failed to clear caches. Please try again.",variant:"destructive"})}finally{M(!1)}},[w]),xe=h??p,U=b.useCallback(()=>{var _,T;if(!xe){w({title:"No document available",description:"Please select a document to copy standard components",variant:"destructive"});return}try{JSON.parse(xe)}catch{w({title:"Document is not valid JSON",description:"Fix the JSON errors in the editor, then copy again",variant:"destructive"});return}G(!0);const X=(async()=>{const O=await fetch(`/api/${yt}/standard-components`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonDefinition:xe})});if(!O.ok){let Y=`Request failed with status ${O.status}`;try{const Q=await O.json();Q.message&&(Y=Q.message)}catch{}throw new Error(Y)}const ee=await O.json();return JSON.stringify(ee.data,null,2)})();let ve;typeof ClipboardItem<"u"&&((_=navigator.clipboard)!=null&&_.write)?ve=navigator.clipboard.write([new ClipboardItem({"text/plain":X.then(O=>new Blob([O],{type:"text/plain"}))})]):(T=navigator.clipboard)!=null&&T.writeText?ve=X.then(O=>navigator.clipboard.writeText(O)):ve=Promise.reject(new Error("Clipboard is not available in this context")),(async()=>{try{await ve,w({title:"Copied to clipboard",description:"Standard components JSON has been copied"})}catch(O){let ee=null;try{ee=await X}catch(Y){console.error("Error fetching standard components:",Y),w({title:"Failed to get standard components",description:Y instanceof Error?Y.message:"Request failed",variant:"destructive"});return}console.error("Clipboard write failed:",O),ie(ee)}finally{G(!1)}})()},[xe,w]),Ae=b.useCallback(async()=>{if(B!=null)try{await navigator.clipboard.writeText(B),w({title:"Copied to clipboard",description:"Standard components JSON has been copied"}),ie(null)}catch{w({title:"Clipboard unavailable",description:"Select the JSON in the dialog and copy it manually",variant:"destructive"})}},[B,w]);return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"bg-sidebar border-b flex flex-row flex-nowrap items-center justify-between gap-x-2 px-3 py-1.5",children:[l.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[l.jsx("p",{className:"text-foreground text-sm font-semibold tracking-tight truncate flex-1 min-w-0",children:e}),l.jsxs(We,{children:[l.jsx(qe,{asChild:!0,children:l.jsx("button",{type:"button","aria-label":"Preview disclaimer",className:"cursor-help inline-flex items-center justify-center h-6 w-6 rounded-sm hover:bg-muted/60 shrink-0",children:l.jsx(Yc,{className:"h-3.5 w-3.5 text-muted-foreground"})})}),l.jsx(Ge,{className:"max-w-sm",children:l.jsxs("p",{className:"text-sm",children:["Preview uses"," ",yt==="docx"?"docx-preview":"LibreOffice PDF conversion",". Download the ",xr," to verify fidelity."]})})]})]}),l.jsxs("div",{className:"flex flex-row items-center gap-x-1 shrink-0",children:[(!i||E)&&l.jsxs(We,{children:[l.jsx(qe,{asChild:!0,children:l.jsxs(Ce,{variant:"default",size:"sm",className:"gap-1.5 h-7 px-2.5",onClick:a,"aria-label":"Render preview",disabled:o||u||I===!1,children:[u?l.jsx(en,{size:"sm"}):l.jsx(sg,{className:"h-3.5 w-3.5"}),l.jsx("span",{className:"text-xs font-medium hidden sm:inline",children:"Run"})]})}),l.jsx(Ge,{children:l.jsx("p",{children:I===!1?"Open preview to run":u?"Rendering preview...":"Render preview"})})]}),yt==="docx"&&l.jsxs(We,{children:[l.jsx(qe,{asChild:!0,children:l.jsxs("div",{className:"flex items-center gap-1.5 cursor-help ml-2 mr-1",children:[l.jsx(Xn,{className:"text-xs text-muted-foreground hidden sm:inline",children:"Auto"}),l.jsx(Qa,{checked:i,onCheckedChange:s,disabled:E})]})}),l.jsx(Ge,{children:l.jsx("p",{children:E?"Auto-reload is not available for Office, Docs, and LibreOffice renderers":`${i?"Disable":"Enable"} automatic preview reload on content changes`})})]}),n&&i&&l.jsxs(We,{children:[l.jsx(qe,{asChild:!0,children:l.jsx(Ce,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:Ne,disabled:C||o||u,children:C?l.jsx(en,{size:"sm"}):l.jsx(ag,{className:"h-3.5 w-3.5"})})}),l.jsx(Ge,{children:l.jsx("p",{children:C?"Reloading...":"Reload"})})]}),l.jsx("div",{className:"w-px h-4 bg-border/60 mx-1"}),l.jsxs(We,{children:[l.jsx(qe,{asChild:!0,children:l.jsxs(Ce,{variant:"outline",size:"sm",className:"gap-1.5 h-7 px-2.5",disabled:!t||k||o,onClick:ne,children:[k?l.jsx(en,{size:"sm"}):l.jsx(og,{className:"h-3.5 w-3.5"}),l.jsx("span",{className:"text-xs font-medium hidden sm:inline",children:"Download"})]})}),l.jsx(Ge,{children:l.jsxs("p",{children:["Download ",xr]})})]}),m&&m.length>0&&l.jsxs(We,{children:[l.jsx(qe,{asChild:!0,children:l.jsx(Ce,{variant:"outline",size:"icon",className:"h-7 w-7 border-transparent bg-warning/10 text-warning hover:bg-warning/20",disabled:J||o,onClick:ge,children:J?l.jsx(en,{size:"sm"}):l.jsx(Qc,{className:"h-3.5 w-3.5"})})}),l.jsx(Ge,{children:l.jsxs("p",{children:["Download warnings (",m.length,")"]})})]}),v&&S&&l.jsxs(Fr,{value:v,onValueChange:S,children:[l.jsxs(We,{children:[l.jsx(qe,{asChild:!0,children:l.jsx(rr,{className:"w-[140px] h-7 text-xs hidden lg:flex",children:l.jsx(Lr,{placeholder:"Renderer"})})}),l.jsx(Ge,{children:l.jsx("p",{children:"Select the rendering library"})})]}),l.jsx(ir,{className:"text-sidebar-foreground",children:pl.map(X=>l.jsxs(Tn,{value:X,children:[l.jsxs(We,{children:[l.jsx(qe,{tabIndex:-1,children:$s[X][0]}),l.jsx(Ge,{children:$s[X][1]})]})," ",X]},X))})]}),l.jsx("div",{className:"w-px h-4 bg-border/60 mx-1"}),l.jsxs(ds,{children:[l.jsxs(We,{children:[l.jsx(qe,{asChild:!0,children:l.jsx(fs,{asChild:!0,children:l.jsx(Ce,{variant:"ghost",size:"icon",className:"h-7 w-7",children:l.jsx(Kc,{className:"h-3.5 w-3.5"})})})}),l.jsx(Ge,{children:l.jsx("p",{children:"More actions"})})]}),l.jsxs(ai,{align:"end",className:"w-52",children:[f&&l.jsxs(Ot,{onClick:f,children:[l.jsx(lg,{className:"h-4 w-4 mr-2"}),"View JSON Schemas"]}),d&&l.jsxs(Ot,{onClick:d,children:[l.jsx(ug,{className:"h-4 w-4 mr-2"}),"Browse fonts"]}),c&&l.jsxs(Ot,{onClick:c,children:[l.jsx(cg,{className:"h-4 w-4 mr-2"}),"View cache metrics"]}),xe?l.jsxs(Ot,{onClick:U,disabled:P,children:[l.jsx(la,{className:"h-4 w-4 mr-2"}),P?"Copying...":"Copy standard components"]}):l.jsxs(We,{children:[l.jsx(qe,{asChild:!0,children:l.jsx("span",{className:"block",children:l.jsxs(Ot,{disabled:!0,children:[l.jsx(la,{className:"h-4 w-4 mr-2"}),"Copy standard components"]})})}),l.jsx(Ge,{side:"left",children:l.jsx("p",{children:"No document selected — open or select a document first"})})]}),l.jsx(sr,{}),l.jsxs(Ot,{onClick:()=>F(!0),disabled:A,className:"text-destructive focus:text-destructive",children:[l.jsx(Ua,{className:"h-4 w-4 mr-2"}),A?"Clearing...":"Clear all caches"]}),v&&S&&l.jsxs(l.Fragment,{children:[l.jsx(sr,{className:"lg:hidden"}),pl.map(X=>l.jsxs(Ot,{className:"lg:hidden",onClick:()=>S(X),children:[l.jsx("span",{className:"mr-2",children:v===X?"●":"○"}),$s[X][0]," ",X]},X))]})]})]}),g&&l.jsxs(We,{children:[l.jsx(qe,{asChild:!0,children:l.jsx(Ce,{variant:I?"default":"ghost",size:"icon",className:"h-7 w-7",onClick:g,children:I?l.jsx(ed,{className:"h-3.5 w-3.5"}):l.jsx(dg,{className:"h-3.5 w-3.5"})})}),l.jsx(Ge,{children:l.jsxs("span",{className:"flex items-center gap-1.5",children:[I?"Hide":"Show"," Preview"," ",l.jsx(Br,{shortcut:"mod+shift+p"})]})})]}),x&&l.jsxs(We,{children:[l.jsx(qe,{asChild:!0,children:l.jsx(Ce,{variant:j?"default":"ghost",size:"icon",className:"h-7 w-7",onClick:x,children:l.jsx(td,{className:"h-3.5 w-3.5"})})}),l.jsx(Ge,{children:l.jsxs("span",{className:"flex items-center gap-1.5",children:[j?"Close":"Open"," AI Chat"," ",l.jsx(Br,{shortcut:"mod+shift+j"})]})})]})]})]}),l.jsx(Jy,{open:Z,onClose:()=>se(!1),nonSafeFonts:W,onChoose:de}),l.jsx(_t,{open:B!=null,onOpenChange:X=>{X||ie(null)},children:l.jsxs(bt,{className:"max-w-lg",children:[l.jsxs(Ft,{children:[l.jsx(Lt,{children:"Standard components"}),l.jsx(nn,{children:"The browser blocked the automatic clipboard write. Copy the JSON from here instead."})]}),l.jsx(yf,{readOnly:!0,value:B??"",className:"h-64 font-mono text-xs",onFocus:X=>X.currentTarget.select()}),l.jsxs(mn,{children:[l.jsx(Ce,{variant:"outline",size:"sm",onClick:()=>ie(null),children:"Close"}),l.jsx(Ce,{size:"sm",onClick:Ae,children:"Copy to clipboard"})]})]})}),l.jsx(_t,{open:$,onOpenChange:F,children:l.jsxs(bt,{className:"max-w-sm",children:[l.jsxs(Ft,{children:[l.jsx(Lt,{children:"Clear all caches?"}),l.jsx(nn,{children:"This will clear document and component caches. Next generation will be uncached."})]}),l.jsxs(mn,{children:[l.jsx(Ce,{variant:"outline",size:"sm",onClick:()=>F(!1),children:"Cancel"}),l.jsx(Ce,{variant:"destructive",size:"sm",disabled:A,onClick:async()=>{await be(),F(!1)},children:A?l.jsx(en,{size:"sm"}):"Clear"})]})]})})]})}const Wy=Se.memo(Hy),bf=Dm,io=b.forwardRef(({className:e,...t},n)=>l.jsx(Zc,{ref:n,className:H("bg-muted text-muted-foreground inline-flex h-9 items-center justify-center rounded-sm p-1",e),...t}));io.displayName=Zc.displayName;const Jr=b.forwardRef(({className:e,...t},n)=>l.jsx(Bc,{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=Bc.displayName;const Hr=b.forwardRef(({className:e,...t},n)=>l.jsx(Vc,{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=Vc.displayName;async function qy(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 Gy(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 Ky(e){const t=Gy(e);return qy(t)}const Yy=({open:e,onOpenChange:t,defaultTab:n="document"})=>{const[r,i]=b.useState(n),[s,a]=b.useState(null),[o,u]=b.useState(null),[c,f]=b.useState(!1),[d,p]=b.useState(!1),[h,m]=b.useState(null),[v,S]=b.useState(null),[x,j]=b.useState(!1),{toast:g}=fr(),I=Rt(M=>M.selectedPlugins),E=Array.from(I);b.useEffect(()=>{n&&i(n)},[n]);const k=b.useCallback(async()=>{f(!0),m(null);try{const M=await Es.fetchDocumentSchema(E);a(M)}catch(M){const $=M instanceof Error?M.message:"Failed to load document schema";m($),g({variant:"destructive",title:"Error loading schema",description:$})}finally{f(!1)}},[E,g]),N=b.useCallback(async()=>{if(!o){p(!0),S(null);try{const M=await Es.fetchThemeSchema();u(M)}catch(M){const $=M instanceof Error?M.message:"Failed to load theme schema";S($),g({variant:"destructive",title:"Error loading schema",description:$})}finally{p(!1)}}},[o,g]),[J,L]=b.useState([]);b.useEffect(()=>{e||(a(null),m(null))},[e]),b.useEffect(()=>{if(!e)return;const M=E.length!==J.length||E.some(($,F)=>$!==J[F]);r==="document"?(!s||M)&&(M&&(Es.clearPluginSchemaCache(),L([...E])),c||k()):r==="theme"&&!o&&!d&&N()},[r,e,s,o,c,d,E,J,k,N]);const C=E.length,z=r==="document"?s:o,A=async()=>{if(z)try{await Ky(z)&&(j(!0),g({title:"Schema copied",description:"The JSON schema has been copied to your clipboard"}),setTimeout(()=>j(!1),2e3))}catch(M){console.error("Copy failed:",M)}};return l.jsx(_t,{open:e,onOpenChange:t,children:l.jsxs(bt,{className:"max-w-4xl max-h-[90vh] overflow-hidden flex flex-col",children:[l.jsx(Ft,{children:l.jsx(Lt,{children:"Schema Viewer"})}),l.jsxs(bf,{value:r,onValueChange:M=>i(M),className:"flex-1 overflow-hidden flex flex-col",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs(io,{children:[l.jsxs(Jr,{value:"document",className:"flex items-center gap-1",children:["Document",C>0&&l.jsxs(Wt,{variant:"secondary",className:"ml-1 text-xs px-1 py-0",children:["+",C]})]}),l.jsx(Jr,{value:"theme",children:"Theme"})]}),l.jsx("div",{className:"ml-auto",children:l.jsx(Ce,{variant:"ghost",size:"icon",onClick:A,disabled:x||!z,"aria-label":"Copy schema",children:x?l.jsx(hn,{className:"h-4 w-4"}):l.jsx(os,{className:"h-4 w-4"})})})]}),l.jsxs("div",{className:"flex-1 overflow-auto mt-4",children:[l.jsx(Hr,{value:"document",className:"h-full",children:l.jsx(Zi,{schema:s,loading:c,error:h||void 0})}),l.jsx(Hr,{value:"theme",className:"h-full",children:l.jsx(Zi,{schema:o,loading:d,error:v||void 0})})]})]})]})})};function Xy(e,t,n){if(t.length===0)return n;const r=hl(e,t[0]);let i=r;for(let s=0;s<t.length-1;s++){const a=t[s],o=t[s+1],u=i[a],c=hl(u,o);i[a]=c,i=c}return i[t[t.length-1]]=n,r}function hl(e,t){return typeof t=="number"?Array.isArray(e)?[...e]:[]:e&&typeof e=="object"&&!Array.isArray(e)?{...e}:{}}const Qy={safe:[],google:[]};function eb(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(";"),u=`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=u,c.dataset.weights=[...a].sort((d,p)=>d-p).join(",")}function tb(){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(u=>u.name===e);if(!s)return{ok:!1,error:"Active theme not found"};let a;try{a=JSON.parse(s.text)}catch(u){return{ok:!1,error:`Active theme is not valid JSON: ${u.message}`}}const o=i(a);return r(e,JSON.stringify(o,null,2)),{ok:!0,name:e}},[e,t,n,r])}function nb(){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(u=>u.name===e);if(!s)return{ok:!1,error:"Active document not found"};let a;try{a=JSON.parse(s.text)}catch(u){return{ok:!1,error:`Active document is not valid JSON: ${u.message}`}}const o=Xy(a,r,i);return n(e,JSON.stringify(o,null,2)),{ok:!0,name:e}},[e,t,n])}function rb(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 ml(e){return e.map((t,n)=>typeof t=="number"?`[${t}]`:n===0?t:`.${t}`).join("")}const ib=({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]),[u,c]=b.useState(Qy),[f,d]=b.useState(!1),[p,h]=b.useState(""),[m,v]=b.useState("safe"),[S,x]=b.useState(null),[j,g]=b.useState(null),{toast:I}=fr(),E=tb(),k=nb(),N=Oe(P=>P.activeTab),J=Oe(P=>P.documentTypes),L=N&&J[N]==="application/json+theme",C=!!a||L;b.useEffect(()=>{s&&(u.safe.length>0||u.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,u,I]),b.useEffect(()=>{if(!(m!=="google"||u.google.length===0))for(const P of u.google)eb(P.family,P.weights)},[m,u]);const z=b.useMemo(()=>u.safe.filter(P=>P.toLowerCase().includes(p.toLowerCase())),[u.safe,p]),A=b.useMemo(()=>u.google.filter(P=>P.family.toLowerCase().includes(p.toLowerCase())),[u.google,p]),M=b.useCallback(async P=>{try{await navigator.clipboard.writeText(P),g(P),setTimeout(()=>g(null),1500)}catch{I({variant:"destructive",title:"Copy failed",description:"Your browser blocked clipboard write."})}},[I]),$=b.useCallback(async(P,G,B)=>{x(P);try{const ie=E(w=>(rb(w,B,P),w));if(!ie.ok){I({variant:"destructive",title:"Could not insert font",description:ie.error});return}I({title:"Font inserted",description:`${P} set as ${B} font in "${ie.name}".`})}finally{x(null)}},[E,I]),F=b.useCallback(async P=>{if(a){x(P);try{const G=k(a.jsonPath,P);if(!G.ok){I({variant:"destructive",title:"Could not insert font",description:G.error});return}I({title:"Font inserted",description:`${P} set at ${ml(a.jsonPath)}.`}),o(!1)}finally{x(null)}}},[a,k,I,o]);return l.jsx(_t,{open:s,onOpenChange:o,children:l.jsxs(bt,{className:"max-w-4xl max-h-[90vh] overflow-hidden flex flex-col",children:[l.jsx(Ft,{children:l.jsx(Lt,{children:a?`Font for ${ml(a.jsonPath)}`:"Fonts"})}),!a&&!L&&l.jsx($i,{children:l.jsxs(Fi,{children:["Fonts are registered on themes. Open a ",l.jsx("code",{children:".theme.json"})," ","file to apply a font — the buttons below are disabled until you do."]})}),l.jsxs(bf,{value:m,onValueChange:P=>v(P),className:"flex-1 overflow-hidden flex flex-col",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs(io,{children:[l.jsxs(Jr,{value:"safe",children:["Safe",l.jsx(Wt,{variant:"secondary",className:"ml-1 text-xs px-1 py-0",children:u.safe.length})]}),l.jsxs(Jr,{value:"google",children:["Google",l.jsx(Wt,{variant:"secondary",className:"ml-1 text-xs px-1 py-0",children:u.google.length})]})]}),l.jsx(ii,{type:"search",placeholder:"Search fonts...",value:p,onChange:P=>h(P.target.value),className:"ml-auto max-w-xs"})]}),l.jsxs("div",{className:"flex-1 overflow-auto mt-4 pr-2",children:[l.jsx(Hr,{value:"safe",className:"m-0",children:f&&z.length===0?l.jsxs("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:[l.jsx(ua,{className:"animate-spin mr-2"})," Loading catalog..."]}):l.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:z.map(P=>l.jsx(gl,{family:P,meta:l.jsx("span",{className:"text-xs",children:"Installed with Office"}),previewStyle:{fontFamily:`"${P}", sans-serif`},onCopy:()=>M(P),copied:j===P,contextual:!!a,onUseThis:()=>F(P),onInsertHeading:()=>$(P,"safe","heading"),onInsertBody:()=>$(P,"safe","body"),applying:S===P,disabled:!C},P))})}),l.jsx(Hr,{value:"google",className:"m-0",children:f&&A.length===0?l.jsxs("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:[l.jsx(ua,{className:"animate-spin mr-2"})," Loading catalog..."]}):l.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:A.map(P=>l.jsx(gl,{family:P.family,meta:l.jsxs("span",{className:"text-xs",children:[P.category," · ",P.weights.length," weights"]}),previewStyle:{fontFamily:`"${P.family}", sans-serif`},onCopy:()=>M(P.family),copied:j===P.family,contextual:!!a,onUseThis:()=>F(P.family),onInsertHeading:()=>$(P.family,"google","heading"),onInsertBody:()=>$(P.family,"google","body"),applying:S===P.family,disabled:!C,extraAction:l.jsx(ab,{family:P.family,weights:P.weights,hasItalic:P.hasItalic})},P.family))})})]})]})]})})},sb="The quick brown fox jumps over the lazy dog",ab=({family:e,weights:t,hasItalic:n})=>{const r=b.useMemo(()=>[...t].sort((i,s)=>i-s),[t]);return l.jsxs(ds,{children:[l.jsx(fs,{asChild:!0,children:l.jsx(Ce,{size:"sm",variant:"ghost","aria-label":"Show variants",children:"Variants"})}),l.jsxs(ai,{align:"end",className:"min-w-[260px]",children:[l.jsxs(Ad,{className:"text-xs text-muted-foreground",children:[r.length," weight",r.length===1?"":"s",n?" · italic available":""]}),l.jsx(sr,{}),r.map(i=>{const s=Vm[i]??String(i);return l.jsxs("div",{className:"flex flex-col gap-0.5 px-2 py-1.5",children:[l.jsx("span",{className:"truncate",style:{fontFamily:`"${e}", sans-serif`,fontWeight:i},children:s}),l.jsxs("span",{className:"text-xs text-muted-foreground font-mono",children:["fontWeight: ",i]})]},i)})]})]})},gl=({family:e,meta:t,previewStyle:n,onCopy:r,copied:i,contextual:s,onUseThis:a,onInsertHeading:o,onInsertBody:u,applying:c,disabled:f,extraAction:d})=>l.jsxs("div",{className:"border rounded-md p-3 flex flex-col gap-2 bg-card",children:[l.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[l.jsx("div",{className:"font-medium truncate",children:e}),l.jsx("div",{className:"text-muted-foreground",children:t})]}),l.jsx("div",{className:"text-lg truncate",style:n,"aria-hidden":!0,children:sb}),l.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[s?l.jsx(Ce,{size:"sm",onClick:a,disabled:c||f,"aria-label":`Use ${e} at the target path`,children:"Use this font"}):l.jsxs(l.Fragment,{children:[l.jsx(Ce,{size:"sm",variant:"secondary",onClick:o,disabled:c||f,"aria-label":`Set ${e} as heading font`,children:"Set heading"}),l.jsx(Ce,{size:"sm",variant:"secondary",onClick:u,disabled:c||f,"aria-label":`Set ${e} as body font`,children:"Set body"})]}),d,l.jsx(Ce,{size:"sm",variant:"ghost",className:"ml-auto",onClick:r,"aria-label":`Copy ${e}`,children:i?l.jsx(hn,{className:"h-4 w-4"}):l.jsx(os,{className:"h-4 w-4"})})]})]});function xl({previewOpen:e,onTogglePreview:t}){const n=Qt(L=>L.name||""),r=Qt(L=>L.blob),i=Qt(L=>L.isGenerating),s=Qt(L=>L.text),a=Qt(L=>L.warnings),o=Qt(L=>L.isRendering),u=hi(L=>L.autoReload),c=hi(L=>L.renderingLibrary),f=hi(L=>L.setSettings),d=hi(L=>L.useGlobalPreviewHeader??!0),p=Oe(L=>L.activeTab),h=Oe(L=>L.documentTypes),m=p&&h[p]==="application/json+theme"?"theme":"document",v=Oe(L=>{var C;return L.activeTab&&L.documentTypes[L.activeTab]!=="application/json+theme"?(C=L.documents.find(z=>z.name===L.activeTab))==null?void 0:C.text:void 0}),S=De(L=>L.chatOpen),x=De(L=>L.toggleChat),[j,g]=Se.useState(!1),I=Ci(L=>L.openFor);if(!d)return null;const E=b.useCallback(()=>f({saveDocumentDebounceWait:2e3,autoReload:!u}),[u,f]),k=b.useCallback(()=>{window.dispatchEvent(new CustomEvent("preview:manualRender"))},[]),N=b.useCallback(()=>{window.dispatchEvent(new CustomEvent("preview:showCacheMetrics"))},[]),J=(n==null?void 0:n.trim())||"Preview";return l.jsxs("div",{className:"sticky top-0 z-20",children:[l.jsx(Wy,{name:J,blob:r,displayReloadButton:!1,autoReload:u,onToggleAutoReload:E,onManualRender:k,isGenerating:i,isRendering:!!o,onShowCacheMetrics:N,onShowSchemas:()=>g(!0),onShowFonts:()=>I(),documentText:s,editorDocumentText:v,warnings:a,renderingLibrary:c,setRenderingLibrary:L=>f({renderingLibrary:L}),onToggleChat:x,chatOpen:S,onTogglePreview:t,previewOpen:e}),l.jsx(Yy,{open:j,onOpenChange:g,defaultTab:m==="theme"?"theme":"document"}),l.jsx(ib,{})]})}function ob(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const lb=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,ub=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,cb={};function yl(e,t){return(cb.jsx?ub:lb).test(e)}const db=/[ \t\n\f\r]/g;function fb(e){return typeof e=="object"?e.type==="text"?bl(e.value):!1:bl(e)}function bl(e){return e.replace(db,"")===""}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 vf(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 va(e){return e.toLowerCase()}class vt{constructor(t,n){this.attribute=n,this.property=t}}vt.prototype.attribute="";vt.prototype.booleanish=!1;vt.prototype.boolean=!1;vt.prototype.commaOrSpaceSeparated=!1;vt.prototype.commaSeparated=!1;vt.prototype.defined=!1;vt.prototype.mustUseProperty=!1;vt.prototype.number=!1;vt.prototype.overloadedBoolean=!1;vt.prototype.property="";vt.prototype.spaceSeparated=!1;vt.prototype.space=void 0;let pb=0;const ke=On(),tt=On(),wa=On(),te=On(),Ze=On(),tr=On(),kt=On();function On(){return 2**++pb}const ka=Object.freeze(Object.defineProperty({__proto__:null,boolean:ke,booleanish:tt,commaOrSpaceSeparated:kt,commaSeparated:tr,number:te,overloadedBoolean:wa,spaceSeparated:Ze},Symbol.toStringTag,{value:"Module"})),Fs=Object.keys(ka);class so extends vt{constructor(t,n,r,i){let s=-1;if(super(t,n),vl(this,"space",i),typeof r=="number")for(;++s<Fs.length;){const a=Fs[s];vl(this,Fs[s],(r&ka[a])===ka[a])}}}so.prototype.defined=!0;function vl(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 so(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[va(r)]=r,n[va(s.attribute)]=r}return new oi(t,n,e.space)}const wf=pr({properties:{ariaActiveDescendant:null,ariaAtomic:tt,ariaAutoComplete:null,ariaBusy:tt,ariaChecked:tt,ariaColCount:te,ariaColIndex:te,ariaColSpan:te,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:te,ariaLive:null,ariaModal:tt,ariaMultiLine:tt,ariaMultiSelectable:tt,ariaOrientation:null,ariaOwns:Ze,ariaPlaceholder:null,ariaPosInSet:te,ariaPressed:tt,ariaReadOnly:tt,ariaRelevant:null,ariaRequired:tt,ariaRoleDescription:Ze,ariaRowCount:te,ariaRowIndex:te,ariaRowSpan:te,ariaSelected:tt,ariaSetSize:te,ariaSort:null,ariaValueMax:te,ariaValueMin:te,ariaValueNow:te,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function kf(e,t){return t in e?e[t]:t}function Sf(e,t){return kf(e,t.toLowerCase())}const hb=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:ke,allowPaymentRequest:ke,allowUserMedia:ke,alt:null,as:null,async:ke,autoCapitalize:null,autoComplete:Ze,autoFocus:ke,autoPlay:ke,blocking:Ze,capture:null,charSet:null,checked:ke,cite:null,className:Ze,cols:te,colSpan:null,content:null,contentEditable:tt,controls:ke,controlsList:Ze,coords:te|tr,crossOrigin:null,data:null,dateTime:null,decoding:null,default:ke,defer:ke,dir:null,dirName:null,disabled:ke,download:wa,draggable:tt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:ke,formTarget:null,headers:Ze,height:te,hidden:wa,high:te,href:null,hrefLang:null,htmlFor:Ze,httpEquiv:Ze,id:null,imageSizes:null,imageSrcSet:null,inert:ke,inputMode:null,integrity:null,is:null,isMap:ke,itemId:null,itemProp:Ze,itemRef:Ze,itemScope:ke,itemType:Ze,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:ke,low:te,manifest:null,max:null,maxLength:te,media:null,method:null,min:null,minLength:te,multiple:ke,muted:ke,name:null,nonce:null,noModule:ke,noValidate:ke,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:ke,optimum:te,pattern:null,ping:Ze,placeholder:null,playsInline:ke,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:ke,referrerPolicy:null,rel:Ze,required:ke,reversed:ke,rows:te,rowSpan:te,sandbox:Ze,scope:null,scoped:ke,seamless:ke,selected:ke,shadowRootClonable:ke,shadowRootDelegatesFocus:ke,shadowRootMode:null,shape:null,size:te,sizes:null,slot:null,span:te,spellCheck:tt,src:null,srcDoc:null,srcLang:null,srcSet:null,start:te,step:null,style:null,tabIndex:te,target:null,title:null,translate:null,type:null,typeMustMatch:ke,useMap:null,value:tt,width:te,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Ze,axis:null,background:null,bgColor:null,border:te,borderColor:null,bottomMargin:te,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:ke,declare:ke,event:null,face:null,frame:null,frameBorder:null,hSpace:te,leftMargin:te,link:null,longDesc:null,lowSrc:null,marginHeight:te,marginWidth:te,noResize:ke,noHref:ke,noShade:ke,noWrap:ke,object:null,profile:null,prompt:null,rev:null,rightMargin:te,rules:null,scheme:null,scrolling:tt,standby:null,summary:null,text:null,topMargin:te,valueType:null,version:null,vAlign:null,vLink:null,vSpace:te,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:ke,disableRemotePlayback:ke,prefix:null,property:null,results:te,security:null,unselectable:null},space:"html",transform:Sf}),mb=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:kt,accentHeight:te,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:te,amplitude:te,arabicForm:null,ascent:te,attributeName:null,attributeType:null,azimuth:te,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:te,by:null,calcMode:null,capHeight:te,className: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:te,diffuseConstant:te,direction:null,display:null,dur:null,divisor:te,dominantBaseline:null,download:ke,dx:null,dy:null,edgeMode:null,editable:null,elevation:te,enableBackground:null,end:null,event:null,exponent:te,externalResourcesRequired:null,fill:null,fillOpacity:te,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:tr,g2:tr,glyphName:tr,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:te,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:te,horizOriginX:te,horizOriginY:te,id:null,ideographic:te,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:te,k:te,k1:te,k2:te,k3:te,k4:te,kernelMatrix:kt,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:te,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:te,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:te,overlineThickness:te,paintOrder:null,panose1:null,path:null,pathLength:te,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Ze,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:te,pointsAtY:te,pointsAtZ:te,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:kt,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:kt,rev:kt,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:kt,requiredFeatures:kt,requiredFonts:kt,requiredFormats:kt,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:te,specularExponent:te,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:te,strikethroughThickness:te,string:null,stroke:null,strokeDashArray:kt,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:te,strokeOpacity:te,strokeWidth:null,style:null,surfaceScale:te,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:kt,tabIndex:te,tableValues:null,target:null,targetX:te,targetY:te,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:kt,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:te,underlineThickness:te,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:te,values:null,vAlphabetic:te,vMathematical:te,vectorEffect:null,vHanging:te,vIdeographic:te,version:null,vertAdvY:te,vertOriginX:te,vertOriginY:te,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:te,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:kf}),_f=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()}}),jf=pr({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Sf}),Cf=pr({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),gb={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"},xb=/[A-Z]/g,wl=/-[a-z]/g,yb=/^data[-\w.:]+$/i;function bb(e,t){const n=va(t);let r=t,i=vt;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&yb.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(wl,wb);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!wl.test(s)){let a=s.replace(xb,vb);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}i=so}return new i(r,t)}function vb(e){return"-"+e.toLowerCase()}function wb(e){return e.charAt(1).toUpperCase()}const kb=vf([wf,hb,_f,jf,Cf],"html"),ao=vf([wf,mb,_f,jf,Cf],"svg");function Sb(e){return e.join(" ").trim()}var Ln={},Ls,kl;function _b(){if(kl)return Ls;kl=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,a=/^[;\s]*/,o=/^\s+|\s+$/g,u=`
3
+ `,c="/",f="*",d="",p="comment",h="declaration";function m(S,x){if(typeof S!="string")throw new TypeError("First argument must be a string");if(!S)return[];x=x||{};var j=1,g=1;function I($){var F=$.match(t);F&&(j+=F.length);var P=$.lastIndexOf(u);g=~P?$.length-P:g+$.length}function E(){var $={line:j,column:g};return function(F){return F.position=new k($),L(),F}}function k($){this.start=$,this.end={line:j,column:g},this.source=x.source}k.prototype.content=S;function N($){var F=new Error(x.source+":"+j+":"+g+": "+$);if(F.reason=$,F.filename=x.source,F.line=j,F.column=g,F.source=S,!x.silent)throw F}function J($){var F=$.exec(S);if(F){var P=F[0];return I(P),S=S.slice(P.length),F}}function L(){J(n)}function C($){var F;for($=$||[];F=z();)F!==!1&&$.push(F);return $}function z(){var $=E();if(!(c!=S.charAt(0)||f!=S.charAt(1))){for(var F=2;d!=S.charAt(F)&&(f!=S.charAt(F)||c!=S.charAt(F+1));)++F;if(F+=2,d===S.charAt(F-1))return N("End of comment missing");var P=S.slice(2,F-2);return g+=2,I(P),S=S.slice(F),g+=2,$({type:p,comment:P})}}function A(){var $=E(),F=J(r);if(F){if(z(),!J(i))return N("property missing ':'");var P=J(s),G=$({type:h,property:v(F[0].replace(e,d)),value:P?v(P[0].replace(e,d)):d});return J(a),G}}function M(){var $=[];C($);for(var F;F=A();)F!==!1&&($.push(F),C($));return $}return L(),M()}function v(S){return S?S.replace(o,d):d}return Ls=m,Ls}var Sl;function jb(){if(Sl)return Ln;Sl=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(_b());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(u=>{if(u.type!=="declaration")return;const{property:c,value:f}=u;o?i(c,f,u):f&&(s=s||{},s[c]=f)}),s}return Ln}var wr={},_l;function Cb(){if(_l)return wr;_l=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,"-")},u=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=u,wr}var kr,jl;function Nb(){if(jl)return kr;jl=1;var e=kr&&kr.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},t=e(jb()),n=Cb();function r(i,s){var a={};return!i||typeof i!="string"||(0,t.default)(i,function(o,u){o&&u&&(a[(0,n.camelCase)(o,s)]=u)}),a}return r.default=r,kr=r,kr}var Eb=Nb();const Ib=Ba(Eb),Nf=Ef("end"),oo=Ef("start");function Ef(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 Tb(e){const t=oo(e),n=Nf(e);if(t&&n)return{start:t,end:n}}function Rr(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?Cl(e.position):"start"in e||"end"in e?Cl(e):"line"in e||"column"in e?Sa(e):""}function Sa(e){return Nl(e&&e.line)+":"+Nl(e&&e.column)}function Cl(e){return Sa(e&&e.start)+"-"+Sa(e&&e.end)}function Nl(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 u=r.indexOf(":");u===-1?s.ruleId=r:(s.source=r.slice(0,u),s.ruleId=r.slice(u+1))}if(!s.place&&s.ancestors&&s.ancestors){const u=s.ancestors[s.ancestors.length-1];u&&(s.place=u.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 lo={}.hasOwnProperty,zb=new Map,Ab=/[A-Z]/g,Pb=new Set(["table","tbody","thead","tfoot","tr"]),Ob=new Set(["td","th"]),If="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Db(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=Vb(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=Bb(n,t.jsx,t.jsxs)}const i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?ao:kb,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},s=Tf(i,e,void 0);return s&&typeof s!="string"?s:i.create(e,i.Fragment,{children:s||void 0},void 0)}function Tf(e,t,n){if(t.type==="element")return Rb(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return Mb(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return Fb(e,t,n);if(t.type==="mdxjsEsm")return $b(e,t);if(t.type==="root")return Lb(e,t,n);if(t.type==="text")return Zb(e,t)}function Rb(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=ao,e.schema=i),e.ancestors.push(t);const s=Af(e,t.tagName,!1),a=Ub(e,t);let o=co(e,t);return Pb.has(t.tagName)&&(o=o.filter(function(u){return typeof u=="string"?!fb(u):!0})),zf(e,a,s,t),uo(a,o),e.ancestors.pop(),e.schema=r,e.create(t,s,a,n)}function Mb(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 $b(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Wr(e,t.position)}function Fb(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=ao,e.schema=i),e.ancestors.push(t);const s=t.name===null?e.Fragment:Af(e,t.name,!0),a=Jb(e,t),o=co(e,t);return zf(e,a,s,t),uo(a,o),e.ancestors.pop(),e.schema=r,e.create(t,s,a,n)}function Lb(e,t,n){const r={};return uo(r,co(e,t)),e.create(t,e.Fragment,r,n)}function Zb(e,t){return t.value}function zf(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function uo(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function Bb(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 Vb(e,t){return n;function n(r,i,s,a){const o=Array.isArray(s.children),u=oo(r);return t(i,s,a,o,{columnNumber:u?u.column-1:void 0,fileName:e,lineNumber:u?u.line:void 0},void 0)}}function Ub(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&lo.call(t.properties,i)){const s=Hb(e,i,t.properties[i]);if(s){const[a,o]=s;e.tableCellAlignToStyle&&a==="align"&&typeof o=="string"&&Ob.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 Jb(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 co(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:zb;for(;++r<t.children.length;){const s=t.children[r];let a;if(e.passKeys){const u=s.type==="element"?s.tagName:s.type==="mdxJsxFlowElement"||s.type==="mdxJsxTextElement"?s.name:void 0;if(u){const c=i.get(u)||0;a=u+"-"+c,i.set(u,c+1)}}const o=Tf(e,s,a);o!==void 0&&n.push(o)}return n}function Hb(e,t,n){const r=bb(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?ob(n):Sb(n)),r.property==="style"){let i=typeof n=="object"?n:Wb(e,String(n));return e.stylePropertyNameCase==="css"&&(i=qb(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&r.space?gb[r.property]||r.property:r.attribute,n]}}function Wb(e,t){try{return Ib(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=If+"#cannot-parse-style-attribute",i}}function Af(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=yl(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=yl(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const i=r.value;return lo.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=If+"#cannot-handle-mdx-estrees-without-createevaluater",n}function qb(e){const t={};let n;for(n in e)lo.call(e,n)&&(t[Gb(n)]=e[n]);return t}function Gb(e){let t=e.replace(Ab,Kb);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function Kb(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"]},Yb={};function fo(e,t){const n=Yb,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return Pf(e,r,i)}function Pf(e,t,n){if(Xb(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 El(e.children,t,n)}return Array.isArray(e)?El(e,t,n):""}function El(e,t,n){const r=[];let i=-1;for(;++i<e.length;)r[i]=Pf(e[i],t,n);return r.join("")}function Xb(e){return!!(e&&typeof e=="object")}const Il=document.createElement("i");function po(e){const t="&"+e+";";Il.innerHTML=t;const n=Il.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function jt(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 It(e,t){return e.length>0?(jt(e,e.length,0,t),e):t}const Tl={}.hasOwnProperty;function Of(e){const t={};let n=-1;for(;++n<e.length;)Qb(t,e[n]);return t}function Qb(e,t){let n;for(n in t){const i=(Tl.call(e,n)?e[n]:void 0)||(e[n]={}),s=t[n];let a;if(s)for(a in s){Tl.call(i,a)||(i[a]=[]);const o=s[a];ev(i[a],Array.isArray(o)?o:o?[o]:[])}}}function ev(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);jt(e,0,0,r)}function Df(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 $t(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const dt=yn(/[A-Za-z]/),st=yn(/[\dA-Za-z]/),tv=yn(/[#-'*+\--9=?A-Z^-~]/);function Ui(e){return e!==null&&(e<32||e===127)}const _a=yn(/\d/),nv=yn(/[\dA-Fa-f]/),rv=yn(/[!-/:-@[-`{-~]/);function he(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=yn(new RegExp("\\p{P}|\\p{S}","u")),An=yn(/\s/);function yn(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 Pe(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let s=0;return a;function a(u){return Ie(u)?(e.enter(n),o(u)):t(u)}function o(u){return Ie(u)&&s++<i?(e.consume(u),o):(e.exit(n),t(u))}}const iv={tokenize:sv};function sv(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"),Pe(e,t,"linePrefix")}function i(o){return e.enter("paragraph"),s(o)}function s(o){const u=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=u),n=u,a(o)}function a(o){if(o===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(o);return}return he(o)?(e.consume(o),e.exit("chunkText"),s):(e.consume(o),a)}}const av={tokenize:ov},zl={tokenize:lv};function ov(e){const t=this,n=[];let r=0,i,s,a;return o;function o(g){if(r<n.length){const I=n[r];return t.containerState=I[1],e.attempt(I[0].continuation,u,c)(g)}return c(g)}function u(g){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&j();const I=t.events.length;let E=I,k;for(;E--;)if(t.events[E][0]==="exit"&&t.events[E][1].type==="chunkFlow"){k=t.events[E][1].end;break}x(r);let N=I;for(;N<t.events.length;)t.events[N][1].end={...k},N++;return jt(t.events,E+1,0,t.events.slice(I)),t.events.length=N,c(g)}return o(g)}function c(g){if(r===n.length){if(!i)return p(g);if(i.currentConstruct&&i.currentConstruct.concrete)return m(g);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(zl,f,d)(g)}function f(g){return i&&j(),x(r),p(g)}function d(g){return t.parser.lazy[t.now().line]=r!==n.length,a=t.now().offset,m(g)}function p(g){return t.containerState={},e.attempt(zl,h,m)(g)}function h(g){return r++,n.push([t.currentConstruct,t.containerState]),p(g)}function m(g){if(g===null){i&&j(),x(0),e.consume(g);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:s}),v(g)}function v(g){if(g===null){S(e.exit("chunkFlow"),!0),x(0),e.consume(g);return}return he(g)?(e.consume(g),S(e.exit("chunkFlow")),r=0,t.interrupt=void 0,o):(e.consume(g),v)}function S(g,I){const E=t.sliceStream(g);if(I&&E.push(null),g.previous=s,s&&(s.next=g),s=g,i.defineSkip(g.start),i.write(E),t.parser.lazy[g.start.line]){let k=i.events.length;for(;k--;)if(i.events[k][1].start.offset<a&&(!i.events[k][1].end||i.events[k][1].end.offset>a))return;const N=t.events.length;let J=N,L,C;for(;J--;)if(t.events[J][0]==="exit"&&t.events[J][1].type==="chunkFlow"){if(L){C=t.events[J][1].end;break}L=!0}for(x(r),k=N;k<t.events.length;)t.events[k][1].end={...C},k++;jt(t.events,J+1,0,t.events.slice(N)),t.events.length=k}}function x(g){let I=n.length;for(;I-- >g;){const E=n[I];t.containerState=E[1],E[0].exit.call(t,e)}n.length=g}function j(){i.write([null]),s=void 0,i=void 0,t.containerState._closeFlow=void 0}}function lv(e,t,n){return Pe(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function 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 ja={name:"attention",resolveAll:uv,tokenize:cv};function uv(e,t){let n=-1,r,i,s,a,o,u,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;u=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};Al(d,-u),Al(p,u),a={type:u>1?"strongSequence":"emphasisSequence",start:d,end:{...e[r][1].end}},o={type:u>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:p},s={type:u>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:u>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=It(c,[["enter",e[r][1],t],["exit",e[r][1],t]])),c=It(c,[["enter",i,t],["enter",a,t],["exit",a,t],["enter",s,t]]),c=It(c,bs(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),c=It(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=It(c,[["enter",e[n][1],t],["exit",e[n][1],t]])):f=0,jt(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 cv(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=or(r);let s;return a;function a(u){return s=u,e.enter("attentionSequence"),o(u)}function o(u){if(u===s)return e.consume(u),o;const c=e.exit("attentionSequence"),f=or(u),d=!f||f===2&&i||n.includes(u),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(u)}}function Al(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const dv={name:"autolink",tokenize:fv};function fv(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,u):(h===43||h===45||h===46||st(h))&&r++<32?(e.consume(h),o):(r=0,c(h))}function u(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),u)}function c(h){return h===64?(e.consume(h),f):tv(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 m=h===45?p:d;return e.consume(h),m}return n(h)}}const li={partial:!0,tokenize:pv};function pv(e,t,n){return r;function r(s){return Ie(s)?Pe(e,i,"linePrefix")(s):i(s)}function i(s){return s===null||he(s)?t(s):n(s)}}const Rf={continuation:{tokenize:mv},exit:gv,name:"blockQuote",tokenize:hv};function hv(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 mv(e,t,n){const r=this;return i;function i(a){return Ie(a)?Pe(e,s,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a):s(a)}function s(a){return e.attempt(Rf,t,n)(a)}}function gv(e){e.exit("blockQuote")}const Mf={name:"characterEscape",tokenize:xv};function xv(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 rv(s)?(e.enter("characterEscapeValue"),e.consume(s),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(s)}}const $f={name:"characterReference",tokenize:yv};function yv(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"),u}function u(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=nv,f):(e.enter("characterReferenceValue"),s=7,a=_a,f(d))}function f(d){if(d===59&&i){const p=e.exit("characterReferenceValue");return a===st&&!po(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 Pl={partial:!0,tokenize:vv},Ol={concrete:!0,name:"codeFenced",tokenize:bv};function bv(e,t,n){const r=this,i={partial:!0,tokenize:E};let s=0,a=0,o;return u;function u(k){return c(k)}function c(k){const N=r.events[r.events.length-1];return s=N&&N[1].type==="linePrefix"?N[2].sliceSerialize(N[1],!0).length:0,o=k,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),f(k)}function f(k){return k===o?(a++,e.consume(k),f):a<3?n(k):(e.exit("codeFencedFenceSequence"),Ie(k)?Pe(e,d,"whitespace")(k):d(k))}function d(k){return k===null||he(k)?(e.exit("codeFencedFence"),r.interrupt?t(k):e.check(Pl,v,I)(k)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),p(k))}function p(k){return k===null||he(k)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),d(k)):Ie(k)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Pe(e,h,"whitespace")(k)):k===96&&k===o?n(k):(e.consume(k),p)}function h(k){return k===null||he(k)?d(k):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),m(k))}function m(k){return k===null||he(k)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),d(k)):k===96&&k===o?n(k):(e.consume(k),m)}function v(k){return e.attempt(i,I,S)(k)}function S(k){return e.enter("lineEnding"),e.consume(k),e.exit("lineEnding"),x}function x(k){return s>0&&Ie(k)?Pe(e,j,"linePrefix",s+1)(k):j(k)}function j(k){return k===null||he(k)?e.check(Pl,v,I)(k):(e.enter("codeFlowValue"),g(k))}function g(k){return k===null||he(k)?(e.exit("codeFlowValue"),j(k)):(e.consume(k),g)}function I(k){return e.exit("codeFenced"),t(k)}function E(k,N,J){let L=0;return C;function C(F){return k.enter("lineEnding"),k.consume(F),k.exit("lineEnding"),z}function z(F){return k.enter("codeFencedFence"),Ie(F)?Pe(k,A,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(F):A(F)}function A(F){return F===o?(k.enter("codeFencedFenceSequence"),M(F)):J(F)}function M(F){return F===o?(L++,k.consume(F),M):L>=a?(k.exit("codeFencedFenceSequence"),Ie(F)?Pe(k,$,"whitespace")(F):$(F)):J(F)}function $(F){return F===null||he(F)?(k.exit("codeFencedFence"),N(F)):J(F)}}}function vv(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:kv},wv={partial:!0,tokenize:Sv};function kv(e,t,n){const r=this;return i;function i(c){return e.enter("codeIndented"),Pe(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?u(c):he(c)?e.attempt(wv,a,u)(c):(e.enter("codeFlowValue"),o(c))}function o(c){return c===null||he(c)?(e.exit("codeFlowValue"),a(c)):(e.consume(c),o)}function u(c){return e.exit("codeIndented"),t(c)}}function Sv(e,t,n){const r=this;return i;function i(a){return r.parser.lazy[r.now().line]?n(a):he(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),i):Pe(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):he(a)?i(a):n(a)}}const _v={name:"codeText",previous:Cv,resolve:jv,tokenize:Nv};function jv(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 Cv(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function Nv(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"),u(d))}function u(d){return d===null?n(d):d===32?(e.enter("space"),e.consume(d),e.exit("space"),u):d===96?(s=e.enter("codeTextSequence"),i=0,f(d)):he(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),u):(e.enter("codeTextData"),c(d))}function c(d){return d===null||d===32||d===96||he(d)?(e.exit("codeTextData"),u(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 Ev{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 Ff(e){const t={};let n=-1,r,i,s,a,o,u,c;const f=new Ev(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"&&(u=r[1]._tokenizer.events,s=0,s<u.length&&u[s][1].type==="lineEndingBlank"&&(s+=2),s<u.length&&u[s][1].type==="content"))for(;++s<u.length&&u[s][1].type!=="content";)u[s][1].type==="chunkText"&&(u[s][1]._isInFirstContentOfListItem=!0,s++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,Iv(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 jt(e,0,Number.POSITIVE_INFINITY,f.slice(0)),!c}function Iv(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,u=[],c={};let f,d,p=-1,h=n,m=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]),j=s.pop();u.push([j,j+x.length-1]),e.splice(j,2,x)}for(u.reverse(),p=-1;++p<u.length;)c[m+u[p][0]]=m+u[p][1],m+=u[p][1]-u[p][0]-1;return c}const Tv={resolve:Av,tokenize:Pv},zv={partial:!0,tokenize:Ov};function Av(e){return Ff(e),e}function Pv(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):he(o)?e.check(zv,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 Ov(e,t,n){const r=this;return i;function i(a){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),Pe(e,s,"linePrefix")}function s(a){if(a===null||he(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 Lf(e,t,n,r,i,s,a,o,u){const c=u||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||he(x)?n(x):(e.consume(x),x===92?m:h)}function m(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 Zf(e,t,n,r,i,s){const a=this;let o=0,u;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&&!u||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):he(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||he(h)||o++>999?(e.exit("chunkString"),f(h)):(e.consume(h),u||(u=!Ie(h)),h===92?p:d)}function p(h){return h===91||h===92||h===93?(e.consume(h),o++,d):d(h)}}function Bf(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,u):n(p)}function u(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),u(a)):p===null?n(p):he(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),Pe(e,c,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),f(p))}function f(p){return p===a||p===null||he(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 he(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):Ie(i)?Pe(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const Dv={name:"definition",tokenize:Mv},Rv={partial:!0,tokenize:$v};function Mv(e,t,n){const r=this;let i;return s;function s(h){return e.enter("definition"),a(h)}function a(h){return Zf.call(r,e,o,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(h)}function o(h){return i=$t(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),h===58?(e.enter("definitionMarker"),e.consume(h),e.exit("definitionMarker"),u):n(h)}function u(h){return Fe(h)?Mr(e,c)(h):c(h)}function c(h){return Lf(e,f,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(h)}function f(h){return e.attempt(Rv,d,d)(h)}function d(h){return Ie(h)?Pe(e,p,"whitespace")(h):p(h)}function p(h){return h===null||he(h)?(e.exit("definition"),r.parser.defined.push(i),t(h)):n(h)}}function $v(e,t,n){return r;function r(o){return Fe(o)?Mr(e,i)(o):n(o)}function i(o){return Bf(e,s,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(o)}function s(o){return Ie(o)?Pe(e,a,"whitespace")(o):a(o)}function a(o){return o===null||he(o)?t(o):n(o)}}const Fv={name:"hardBreakEscape",tokenize:Lv};function Lv(e,t,n){return r;function r(s){return e.enter("hardBreakEscape"),e.consume(s),i}function i(s){return he(s)?(e.exit("hardBreakEscape"),t(s)):n(s)}}const Zv={name:"headingAtx",resolve:Bv,tokenize:Vv};function Bv(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"},jt(e,r,n-r+1,[["enter",i,t],["enter",s,t],["exit",s,t],["exit",i,t]])),e}function Vv(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"),u(f)):f===null||he(f)?(e.exit("atxHeading"),t(f)):Ie(f)?Pe(e,o,"whitespace")(f):(e.enter("atxHeadingText"),c(f))}function u(f){return f===35?(e.consume(f),u):(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 Uv=["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"],Dl=["pre","script","style","textarea"],Jv={concrete:!0,name:"htmlFlow",resolveTo:qv,tokenize:Gv},Hv={partial:!0,tokenize:Yv},Wv={partial:!0,tokenize:Kv};function qv(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 Gv(e,t,n){const r=this;let i,s,a,o,u;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:w):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,m):dt(y)?(e.consume(y),i=4,r.interrupt?t:w):n(y)}function h(y){return y===45?(e.consume(y),r.interrupt?t:w):n(y)}function m(y){const W="CDATA[";return y===W.charCodeAt(o++)?(e.consume(y),o===W.length?r.interrupt?t:A:m):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,Z=a.toLowerCase();return!W&&!s&&Dl.includes(Z)?(i=1,r.interrupt?t(y):A(y)):Uv.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?j(y):g(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 j(y){return Ie(y)?(e.consume(y),j):C(y)}function g(y){return y===47?(e.consume(y),C):y===58||y===95||dt(y)?(e.consume(y),I):Ie(y)?(e.consume(y),g):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),k):Ie(y)?(e.consume(y),E):g(y)}function k(y){return y===null||y===60||y===61||y===62||y===96?n(y):y===34||y===39?(e.consume(y),u=y,N):Ie(y)?(e.consume(y),k):J(y)}function N(y){return y===u?(e.consume(y),u=null,L):y===null||he(y)?n(y):(e.consume(y),N)}function J(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),J)}function L(y){return y===47||y===62||Ie(y)?g(y):n(y)}function C(y){return y===62?(e.consume(y),z):n(y)}function z(y){return y===null||he(y)?A(y):Ie(y)?(e.consume(y),z):n(y)}function A(y){return y===45&&i===2?(e.consume(y),P):y===60&&i===1?(e.consume(y),G):y===62&&i===4?(e.consume(y),le):y===63&&i===3?(e.consume(y),w):y===93&&i===5?(e.consume(y),ie):he(y)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(Hv,q,M)(y)):y===null||he(y)?(e.exit("htmlFlowData"),M(y)):(e.consume(y),A)}function M(y){return e.check(Wv,$,q)(y)}function $(y){return e.enter("lineEnding"),e.consume(y),e.exit("lineEnding"),F}function F(y){return y===null||he(y)?M(y):(e.enter("htmlFlowData"),A(y))}function P(y){return y===45?(e.consume(y),w):A(y)}function G(y){return y===47?(e.consume(y),a="",B):A(y)}function B(y){if(y===62){const W=a.toLowerCase();return Dl.includes(W)?(e.consume(y),le):A(y)}return dt(y)&&a.length<8?(e.consume(y),a+=String.fromCharCode(y),B):A(y)}function ie(y){return y===93?(e.consume(y),w):A(y)}function w(y){return y===62?(e.consume(y),le):y===45&&i===2?(e.consume(y),w):A(y)}function le(y){return y===null||he(y)?(e.exit("htmlFlowData"),q(y)):(e.consume(y),le)}function q(y){return e.exit("htmlFlow"),t(y)}}function Kv(e,t,n){const r=this;return i;function i(a){return he(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 Yv(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(li,t,n)}}const Xv={name:"htmlText",tokenize:Qv};function Qv(e,t,n){const r=this;let i,s,a;return o;function o(w){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(w),u}function u(w){return w===33?(e.consume(w),c):w===47?(e.consume(w),E):w===63?(e.consume(w),g):dt(w)?(e.consume(w),J):n(w)}function c(w){return w===45?(e.consume(w),f):w===91?(e.consume(w),s=0,m):dt(w)?(e.consume(w),j):n(w)}function f(w){return w===45?(e.consume(w),h):n(w)}function d(w){return w===null?n(w):w===45?(e.consume(w),p):he(w)?(a=d,G(w)):(e.consume(w),d)}function p(w){return w===45?(e.consume(w),h):d(w)}function h(w){return w===62?P(w):w===45?p(w):d(w)}function m(w){const le="CDATA[";return w===le.charCodeAt(s++)?(e.consume(w),s===le.length?v:m):n(w)}function v(w){return w===null?n(w):w===93?(e.consume(w),S):he(w)?(a=v,G(w)):(e.consume(w),v)}function S(w){return w===93?(e.consume(w),x):v(w)}function x(w){return w===62?P(w):w===93?(e.consume(w),x):v(w)}function j(w){return w===null||w===62?P(w):he(w)?(a=j,G(w)):(e.consume(w),j)}function g(w){return w===null?n(w):w===63?(e.consume(w),I):he(w)?(a=g,G(w)):(e.consume(w),g)}function I(w){return w===62?P(w):g(w)}function E(w){return dt(w)?(e.consume(w),k):n(w)}function k(w){return w===45||st(w)?(e.consume(w),k):N(w)}function N(w){return he(w)?(a=N,G(w)):Ie(w)?(e.consume(w),N):P(w)}function J(w){return w===45||st(w)?(e.consume(w),J):w===47||w===62||Fe(w)?L(w):n(w)}function L(w){return w===47?(e.consume(w),P):w===58||w===95||dt(w)?(e.consume(w),C):he(w)?(a=L,G(w)):Ie(w)?(e.consume(w),L):P(w)}function C(w){return w===45||w===46||w===58||w===95||st(w)?(e.consume(w),C):z(w)}function z(w){return w===61?(e.consume(w),A):he(w)?(a=z,G(w)):Ie(w)?(e.consume(w),z):L(w)}function A(w){return w===null||w===60||w===61||w===62||w===96?n(w):w===34||w===39?(e.consume(w),i=w,M):he(w)?(a=A,G(w)):Ie(w)?(e.consume(w),A):(e.consume(w),$)}function M(w){return w===i?(e.consume(w),i=void 0,F):w===null?n(w):he(w)?(a=M,G(w)):(e.consume(w),M)}function $(w){return w===null||w===34||w===39||w===60||w===61||w===96?n(w):w===47||w===62||Fe(w)?L(w):(e.consume(w),$)}function F(w){return w===47||w===62||Fe(w)?L(w):n(w)}function P(w){return w===62?(e.consume(w),e.exit("htmlTextData"),e.exit("htmlText"),t):n(w)}function G(w){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(w),e.exit("lineEnding"),B}function B(w){return Ie(w)?Pe(e,ie,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(w):ie(w)}function ie(w){return e.enter("htmlTextData"),a(w)}}const ho={name:"labelEnd",resolveAll:rw,resolveTo:iw,tokenize:sw},ew={tokenize:aw},tw={tokenize:ow},nw={tokenize:lw};function rw(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&&jt(e,0,e.length,n),e}function iw(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 u={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",u,t],["enter",c,t]],o=It(o,e.slice(s+1,s+r+3)),o=It(o,[["enter",f,t]]),o=It(o,bs(t.parser.constructs.insideSpan.null,e.slice(s+r+4,a-3),t)),o=It(o,[["exit",f,t],e[a-2],e[a-1],["exit",c,t]]),o=It(o,e.slice(a+1)),o=It(o,[["exit",u,t]]),jt(e,s,e.length,o),e}function sw(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($t(r.sliceSerialize({start:s.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(p),e.exit("labelMarker"),e.exit("labelEnd"),u):n(p)}function u(p){return p===40?e.attempt(ew,f,a?f:d)(p):p===91?e.attempt(tw,f,a?c:d)(p):a?f(p):d(p)}function c(p){return e.attempt(nw,f,d)(p)}function f(p){return t(p)}function d(p){return s._balanced=!0,n(p)}}function aw(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):Lf(e,a,o,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(d)}function a(d){return Fe(d)?Mr(e,u)(d):f(d)}function o(d){return n(d)}function u(d){return d===34||d===39||d===40?Bf(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 ow(e,t,n){const r=this;return i;function i(o){return Zf.call(r,e,s,a,"reference","referenceMarker","referenceString")(o)}function s(o){return r.parser.defined.includes($t(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(o):n(o)}function a(o){return n(o)}}function lw(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 uw={name:"labelStartImage",resolveAll:ho.resolveAll,tokenize:cw};function cw(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 dw={name:"labelStartLink",resolveAll:ho.resolveAll,tokenize:fw};function fw(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:pw};function pw(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),Pe(e,t,"linePrefix")}}const Ii={name:"thematicBreak",tokenize:hw};function hw(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"),u(c)):r>=3&&(c===null||he(c))?(e.exit("thematicBreak"),t(c)):n(c)}function u(c){return c===i?(e.consume(c),r++,u):(e.exit("thematicBreakSequence"),Ie(c)?Pe(e,o,"whitespace")(c):o(c))}}const ht={continuation:{tokenize:yw},exit:vw,name:"list",tokenize:xw},mw={partial:!0,tokenize:ww},gw={partial:!0,tokenize:bw};function xw(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 m=r.containerState.type||(h===42||h===43||h===45?"listUnordered":"listOrdered");if(m==="listUnordered"?!r.containerState.marker||h===r.containerState.marker:_a(h)){if(r.containerState.type||(r.containerState.type=m,e.enter(m,{_container:!0})),m==="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"),u(h)}return n(h)}function u(h){return _a(h)&&++a<10?(e.consume(h),u):(!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(mw,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 yw(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,Pe(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(gw,t,a)(o))}function a(o){return r.containerState._closeFlow=!0,r.interrupt=void 0,Pe(e,e.attempt(ht,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o)}}function bw(e,t,n){const r=this;return Pe(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 vw(e){e.exit(this.containerState.type)}function ww(e,t,n){const r=this;return Pe(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(s){const a=r.events[r.events.length-1];return!Ie(s)&&a&&a[1].type==="listItemPrefixWhitespace"?t(s):n(s)}}const Rl={name:"setextUnderline",resolveTo:kw,tokenize:Sw};function kw(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 Sw(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)?Pe(e,u,"lineSuffix")(c):u(c))}function u(c){return c===null||he(c)?(e.exit("setextHeadingLine"),t(c)):n(c)}}const _w={tokenize:jw};function jw(e){const t=this,n=e.attempt(li,r,e.attempt(this.parser.constructs.flowInitial,i,Pe(e,e.attempt(this.parser.constructs.flow,i,e.attempt(Tv,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 Cw={resolveAll:Uf()},Nw=Vf("string"),Ew=Vf("text");function Vf(e){return{resolveAll:Uf(e==="text"?Iw: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),u}function u(f){return c(f)?(n.exit("data"),s(f)):(n.consume(f),u)}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 Uf(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 Iw(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,u;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)u=!0,o++;else if(c!==-1){s++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(o=0),o){const c={type:n===e.length||u||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 Tw={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:Rf},zw={91:Dv},Aw={[-2]:Bs,[-1]:Bs,32:Bs},Pw={35:Zv,42:Ii,45:[Rl,Ii],60:Jv,61:Rl,95:Ii,96:Ol,126:Ol},Ow={38:$f,92:Mf},Dw={[-5]:Vs,[-4]:Vs,[-3]:Vs,33:uw,38:$f,42:ja,60:[dv,Xv],91:dw,92:[Fv,Mf],93:ho,95:ja,96:_v},Rw={null:[ja,Cw]},Mw={null:[42,95]},$w={null:[]},Fw=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:Mw,contentInitial:zw,disable:$w,document:Tw,flow:Pw,flowInitial:Aw,insideSpan:Rw,string:Ow,text:Dw},Symbol.toStringTag,{value:"Module"}));function Lw(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 u={attempt:N(E),check:N(k),consume:j,enter:g,exit:I,interrupt:N(k,{interrupt:!0})},c={code:null,containerState:{},defineSkip:v,events:[],now:m,parser:e,previous:null,sliceSerialize:p,sliceStream:h,write:d};let f=t.tokenize.call(c,u);return t.resolveAll&&s.push(t),c;function d(z){return a=It(a,z),S(),a[a.length-1]!==null?[]:(J(t,0),c.events=bs(s,c.events,c),c.events)}function p(z,A){return Bw(h(z),A)}function h(z){return Zw(a,z)}function m(){const{_bufferIndex:z,_index:A,line:M,column:$,offset:F}=r;return{_bufferIndex:z,_index:A,line:M,column:$,offset:F}}function v(z){i[z.line]=z.column,C()}function S(){let z;for(;r._index<a.length;){const A=a[r._index];if(typeof A=="string")for(z=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===z&&r._bufferIndex<A.length;)x(A.charCodeAt(r._bufferIndex));else x(A)}}function x(z){f=f(z)}function j(z){he(z)?(r.line++,r.column=1,r.offset+=z===-3?2:1,C()):z!==-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=z}function g(z,A){const M=A||{};return M.type=z,M.start=m(),c.events.push(["enter",M,c]),o.push(M),M}function I(z){const A=o.pop();return A.end=m(),c.events.push(["exit",A,c]),A}function E(z,A){J(z,A.from)}function k(z,A){A.restore()}function N(z,A){return M;function M($,F,P){let G,B,ie,w;return Array.isArray($)?q($):"tokenize"in $?q([$]):le($);function le(se){return re;function re(ne){const de=ne!==null&&se[ne],ge=ne!==null&&se.null,Ne=[...Array.isArray(de)?de:de?[de]:[],...Array.isArray(ge)?ge:ge?[ge]:[]];return q(Ne)(ne)}}function q(se){return G=se,B=0,se.length===0?P:y(se[B])}function y(se){return re;function re(ne){return w=L(),ie=se,se.partial||(c.currentConstruct=se),se.name&&c.parser.constructs.disable.null.includes(se.name)?Z():se.tokenize.call(A?Object.assign(Object.create(c),A):c,u,W,Z)(ne)}}function W(se){return z(ie,w),F}function Z(se){return w.restore(),++B<G.length?y(G[B]):P}}}function J(z,A){z.resolveAll&&!s.includes(z)&&s.push(z),z.resolve&&jt(c.events,A,c.events.length-A,z.resolve(c.events.slice(A),c)),z.resolveTo&&(c.events=z.resolveTo(c.events,c))}function L(){const z=m(),A=c.previous,M=c.currentConstruct,$=c.events.length,F=Array.from(o);return{from:$,restore:P};function P(){r=z,c.previous=A,c.currentConstruct=M,c.events.length=$,o=F,C()}}function C(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function Zw(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 Bw(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 Vw(e){const r={constructs:Of([Fw,...(e||{}).extensions||[]]),content:i(iv),defined:[],document:i(av),flow:i(_w),lazy:{},string:i(Nw),text:i(Ew)};return r;function i(s){return a;function a(o){return Lw(r,s,o)}}}function Uw(e){for(;!Ff(e););return e}const Ml=/[\0\t\n\r]/g;function Jw(){let e=1,t="",n=!0,r;return i;function i(s,a,o){const u=[];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(Ml.lastIndex=d,c=Ml.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)u.push(-3),r=void 0;else switch(r&&(u.push(-5),r=void 0),d<p&&(u.push(s.slice(d,p)),e+=p-d),h){case 0:{u.push(65533),e++;break}case 9:{for(f=Math.ceil(e/4)*4,u.push(-2);e++<f;)u.push(-1);break}case 10:{u.push(-4),e=1;break}default:r=!0,e=1}d=p+1}return o&&(r&&u.push(-5),t&&u.push(t),u.push(null)),u}}const Hw=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Ww(e){return e.replace(Hw,qw)}function qw(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),s=i===120||i===88;return Df(n.slice(s?2:1),s?16:10)}return po(n)||e}const Jf={}.hasOwnProperty;function Gw(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),Kw(n)(Uw(Vw(n).document().write(Jw()(e,t,!0))))}function Kw(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(T),autolinkProtocol:L,autolinkEmail:L,atxHeading:s(Ae),blockQuote:s(ge),characterEscape:L,characterReference:L,codeFenced:s(Ne),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:s(Ne,a),codeText:s(be,a),codeTextData:L,data:L,codeFlowValue:L,definition:s(xe),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:s(U),hardBreakEscape:s(X),hardBreakTrailing:s(X),htmlFlow:s(ve,a),htmlFlowData:L,htmlText:s(ve,a),htmlTextData:L,image:s(_),label:a,link:s(T),listItem:s(ee),listItemValue:p,listOrdered:s(O,d),listUnordered:s(O),paragraph:s(Y),reference:y,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:s(Ae),strong:s(Q),thematicBreak:s(ye)},exit:{atxHeading:u(),atxHeadingSequence:E,autolink:u(),autolinkEmail:de,autolinkProtocol:ne,blockQuote:u(),characterEscapeValue:C,characterReferenceMarkerHexadecimal:Z,characterReferenceMarkerNumeric:Z,characterReferenceValue:se,characterReference:re,codeFenced:u(S),codeFencedFence:v,codeFencedFenceInfo:h,codeFencedFenceMeta:m,codeFlowValue:C,codeIndented:u(x),codeText:u(F),codeTextData:C,data:C,definition:u(),definitionDestinationString:I,definitionLabelString:j,definitionTitleString:g,emphasis:u(),hardBreakEscape:u(A),hardBreakTrailing:u(A),htmlFlow:u(M),htmlFlowData:C,htmlText:u($),htmlTextData:C,image:u(G),label:ie,labelText:B,lineEnding:z,link:u(P),listItem:u(),listOrdered:u(),listUnordered:u(),paragraph:u(),referenceString:W,resourceDestinationString:w,resourceTitleString:le,resource:q,setextHeading:u(J),setextHeadingLineSequence:N,setextHeadingText:k,strong:u(),thematicBreak:u()}};Hf(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(R){let K={type:"root",children:[]};const fe={stack:[K],tokenStack:[],config:t,enter:o,exit:c,buffer:a,resume:f,data:n},_e=[];let D=-1;for(;++D<R.length;)if(R[D][1].type==="listOrdered"||R[D][1].type==="listUnordered")if(R[D][0]==="enter")_e.push(D);else{const pe=_e.pop();D=i(R,pe,D)}for(D=-1;++D<R.length;){const pe=t[R[D][0]];Jf.call(pe,R[D][1].type)&&pe[R[D][1].type].call(Object.assign({sliceSerialize:R[D][2].sliceSerialize},fe),R[D][1])}if(fe.tokenStack.length>0){const pe=fe.tokenStack[fe.tokenStack.length-1];(pe[1]||$l).call(fe,void 0,pe[0])}for(K.position={start:on(R.length>0?R[0][1].start:{line:1,column:1,offset:0}),end:on(R.length>0?R[R.length-2][1].end:{line:1,column:1,offset:0})},D=-1;++D<t.transforms.length;)K=t.transforms[D](K)||K;return K}function i(R,K,fe){let _e=K-1,D=-1,pe=!1,Te,Le,nt,et;for(;++_e<=fe;){const it=R[_e];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=_e),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 sn=_e;for(Le=void 0;sn--;){const Kt=R[sn];if(Kt[1].type==="lineEnding"||Kt[1].type==="lineEndingBlank"){if(Kt[0]==="exit")continue;Le&&(R[Le][1].type="lineEndingBlank",pe=!0),Kt[1].type="lineEnding",Le=sn}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?R[Le][1].start:it[1].end),R.splice(Le||_e,0,["exit",Te,it[2]]),_e++,fe++}if(it[1].type==="listItemPrefix"){const sn={type:"listItem",_spread:!1,start:Object.assign({},it[1].start),end:void 0};Te=sn,R.splice(_e,0,["enter",sn,it[2]]),_e++,fe++,nt=void 0,et=!0}}}return R[K][1]._spread=pe,fe}function s(R,K){return fe;function fe(_e){o.call(this,R(_e),_e),K&&K.call(this,_e)}}function a(){this.stack.push({type:"fragment",children:[]})}function o(R,K,fe){this.stack[this.stack.length-1].children.push(R),this.stack.push(R),this.tokenStack.push([K,fe||void 0]),R.position={start:on(K.start),end:void 0}}function u(R){return K;function K(fe){R&&R.call(this,fe),c.call(this,fe)}}function c(R,K){const fe=this.stack.pop(),_e=this.tokenStack.pop();if(_e)_e[0].type!==R.type&&(K?K.call(this,R,_e[0]):(_e[1]||$l).call(this,R,_e[0]));else throw new Error("Cannot close `"+R.type+"` ("+Rr({start:R.start,end:R.end})+"): it’s not open");fe.position.end=on(R.end)}function f(){return fo(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function p(R){if(this.data.expectingFirstListItemValue){const K=this.stack[this.stack.length-2];K.start=Number.parseInt(this.sliceSerialize(R),10),this.data.expectingFirstListItemValue=void 0}}function h(){const R=this.resume(),K=this.stack[this.stack.length-1];K.lang=R}function m(){const R=this.resume(),K=this.stack[this.stack.length-1];K.meta=R}function v(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function S(){const R=this.resume(),K=this.stack[this.stack.length-1];K.value=R.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function x(){const R=this.resume(),K=this.stack[this.stack.length-1];K.value=R.replace(/(\r?\n|\r)$/g,"")}function j(R){const K=this.resume(),fe=this.stack[this.stack.length-1];fe.label=K,fe.identifier=$t(this.sliceSerialize(R)).toLowerCase()}function g(){const R=this.resume(),K=this.stack[this.stack.length-1];K.title=R}function I(){const R=this.resume(),K=this.stack[this.stack.length-1];K.url=R}function E(R){const K=this.stack[this.stack.length-1];if(!K.depth){const fe=this.sliceSerialize(R).length;K.depth=fe}}function k(){this.data.setextHeadingSlurpLineEnding=!0}function N(R){const K=this.stack[this.stack.length-1];K.depth=this.sliceSerialize(R).codePointAt(0)===61?1:2}function J(){this.data.setextHeadingSlurpLineEnding=void 0}function L(R){const fe=this.stack[this.stack.length-1].children;let _e=fe[fe.length-1];(!_e||_e.type!=="text")&&(_e=ce(),_e.position={start:on(R.start),end:void 0},fe.push(_e)),this.stack.push(_e)}function C(R){const K=this.stack.pop();K.value+=this.sliceSerialize(R),K.position.end=on(R.end)}function z(R){const K=this.stack[this.stack.length-1];if(this.data.atHardBreak){const fe=K.children[K.children.length-1];fe.position.end=on(R.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(K.type)&&(L.call(this,R),C.call(this,R))}function A(){this.data.atHardBreak=!0}function M(){const R=this.resume(),K=this.stack[this.stack.length-1];K.value=R}function $(){const R=this.resume(),K=this.stack[this.stack.length-1];K.value=R}function F(){const R=this.resume(),K=this.stack[this.stack.length-1];K.value=R}function P(){const R=this.stack[this.stack.length-1];if(this.data.inReference){const K=this.data.referenceType||"shortcut";R.type+="Reference",R.referenceType=K,delete R.url,delete R.title}else delete R.identifier,delete R.label;this.data.referenceType=void 0}function G(){const R=this.stack[this.stack.length-1];if(this.data.inReference){const K=this.data.referenceType||"shortcut";R.type+="Reference",R.referenceType=K,delete R.url,delete R.title}else delete R.identifier,delete R.label;this.data.referenceType=void 0}function B(R){const K=this.sliceSerialize(R),fe=this.stack[this.stack.length-2];fe.label=Ww(K),fe.identifier=$t(K).toLowerCase()}function ie(){const R=this.stack[this.stack.length-1],K=this.resume(),fe=this.stack[this.stack.length-1];if(this.data.inReference=!0,fe.type==="link"){const _e=R.children;fe.children=_e}else fe.alt=K}function w(){const R=this.resume(),K=this.stack[this.stack.length-1];K.url=R}function le(){const R=this.resume(),K=this.stack[this.stack.length-1];K.title=R}function q(){this.data.inReference=void 0}function y(){this.data.referenceType="collapsed"}function W(R){const K=this.resume(),fe=this.stack[this.stack.length-1];fe.label=K,fe.identifier=$t(this.sliceSerialize(R)).toLowerCase(),this.data.referenceType="full"}function Z(R){this.data.characterReferenceType=R.type}function se(R){const K=this.sliceSerialize(R),fe=this.data.characterReferenceType;let _e;fe?(_e=Df(K,fe==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):_e=po(K);const D=this.stack[this.stack.length-1];D.value+=_e}function re(R){const K=this.stack.pop();K.position.end=on(R.end)}function ne(R){C.call(this,R);const K=this.stack[this.stack.length-1];K.url=this.sliceSerialize(R)}function de(R){C.call(this,R);const K=this.stack[this.stack.length-1];K.url="mailto:"+this.sliceSerialize(R)}function ge(){return{type:"blockquote",children:[]}}function Ne(){return{type:"code",lang:null,meta:null,value:""}}function be(){return{type:"inlineCode",value:""}}function xe(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function U(){return{type:"emphasis",children:[]}}function Ae(){return{type:"heading",depth:0,children:[]}}function X(){return{type:"break"}}function ve(){return{type:"html",value:""}}function _(){return{type:"image",title:null,url:"",alt:null}}function T(){return{type:"link",title:null,url:"",children:[]}}function O(R){return{type:"list",ordered:R.type==="listOrdered",start:null,spread:R._spread,children:[]}}function ee(R){return{type:"listItem",spread:R._spread,checked:null,children:[]}}function Y(){return{type:"paragraph",children:[]}}function Q(){return{type:"strong",children:[]}}function ce(){return{type:"text",value:""}}function ye(){return{type:"thematicBreak"}}}function on(e){return{line:e.line,column:e.column,offset:e.offset}}function Hf(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?Hf(e,r):Yw(e,r)}}function Yw(e,t){let n;for(n in t)if(Jf.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 $l(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 Xw(e){const t=this;t.parser=n;function n(r){return Gw(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function Qw(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 e0(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
6
+ `}]}function t0(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 n0(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function r0(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function i0(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 u={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,u);const c={type:"element",tagName:"sup",properties:{},children:[u]};return e.patch(t,c),e.applyData(t,c)}function s0(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 a0(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function Wf(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 o0(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Wf(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 l0(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 u0(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 c0(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Wf(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 d0(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 f0(e,t,n){const r=e.all(t),i=n?p0(n):qf(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 u=r[r.length-1];u&&(i||u.type!=="element"||u.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 p0(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=qf(n[r])}return t}function qf(e){const t=e.spread;return t??e.children.length>1}function h0(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 m0(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function g0(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function x0(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function y0(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=oo(t.children[1]),u=Nf(t.children[t.children.length-1]);o&&u&&(a.position={start:o,end:u}),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 b0(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 u=-1;const c=[];for(;++u<o;){const d=t.children[u],p={},h=a?a[u]:void 0;h&&(p.align=h);let m={type:"element",tagName:s,properties:p,children:[]};d&&(m.children=e.all(d),e.patch(d,m),m=e.applyData(d,m)),c.push(m)}const f={type:"element",tagName:"tr",properties:{},children:e.wrap(c,!0)};return e.patch(t,f),e.applyData(t,f)}function v0(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const Fl=9,Ll=32;function w0(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),i=0;const s=[];for(;r;)s.push(Zl(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return s.push(Zl(t.slice(i),i>0,!1)),s.join("")}function Zl(e,t,n){let r=0,i=e.length;if(t){let s=e.codePointAt(r);for(;s===Fl||s===Ll;)r++,s=e.codePointAt(r)}if(n){let s=e.codePointAt(i-1);for(;s===Fl||s===Ll;)i--,s=e.codePointAt(i-1)}return i>r?e.slice(r,i):""}function k0(e,t){const n={type:"text",value:w0(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function S0(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const _0={blockquote:Qw,break:e0,code:t0,delete:n0,emphasis:r0,footnoteReference:i0,heading:s0,html:a0,imageReference:o0,image:l0,inlineCode:u0,linkReference:c0,link:d0,listItem:f0,list:h0,paragraph:m0,root:g0,strong:x0,table:y0,tableCell:v0,tableRow:b0,text:k0,thematicBreak:S0,toml:yi,yaml:yi,definition:yi,footnoteDefinition:yi};function yi(){}const Gf=-1,vs=0,$r=1,Ji=2,mo=3,go=4,xo=5,yo=6,Kf=7,Yf=8,Bl=typeof self=="object"?self:globalThis,j0=(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 Gf:return n(a,i);case $r:{const o=n([],i);for(const u of a)o.push(r(u));return o}case Ji:{const o=n({},i);for(const[u,c]of a)o[r(u)]=r(c);return o}case mo:return n(new Date(a),i);case go:{const{source:o,flags:u}=a;return n(new RegExp(o,u),i)}case xo:{const o=n(new Map,i);for(const[u,c]of a)o.set(r(u),r(c));return o}case yo:{const o=n(new Set,i);for(const u of a)o.add(r(u));return o}case Kf:{const{name:o,message:u}=a;return n(new Bl[o](u),i)}case Yf: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 Bl[s](a),i)};return r},Vl=e=>j0(new Map,e)(0),Zn="",{toString:C0}={},{keys:N0}=Object,_r=e=>{const t=typeof e;if(t!=="object"||!e)return[vs,t];const n=C0.call(e).slice(8,-1);switch(n){case"Array":return[$r,Zn];case"Object":return[Ji,Zn];case"Date":return[mo,Zn];case"RegExp":return[go,Zn];case"Map":return[xo,Zn];case"Set":return[yo,Zn];case"DataView":return[$r,n]}return n.includes("Array")?[$r,n]:n.includes("Error")?[Kf,n]:[Ji,n]},bi=([e,t])=>e===vs&&(t==="function"||t==="symbol"),E0=(e,t,n,r)=>{const i=(a,o)=>{const u=r.push(a)-1;return n.set(o,u),u},s=a=>{if(n.has(a))return n.get(a);let[o,u]=_r(a);switch(o){case vs:{let f=a;switch(u){case"bigint":o=Yf,f=a.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+u);f=null;break;case"undefined":return i([Gf],a)}return i([o,f],a)}case $r:{if(u){let p=a;return u==="DataView"?p=new Uint8Array(a.buffer):u==="ArrayBuffer"&&(p=new Uint8Array(a)),i([u,[...p]],a)}const f=[],d=i([o,f],a);for(const p of a)f.push(s(p));return d}case Ji:{if(u)switch(u){case"BigInt":return i([u,a.toString()],a);case"Boolean":case"Number":case"String":return i([u,a.valueOf()],a)}if(t&&"toJSON"in a)return s(a.toJSON());const f=[],d=i([o,f],a);for(const p of N0(a))(e||!bi(_r(a[p])))&&f.push([s(p),s(a[p])]);return d}case mo:return i([o,a.toISOString()],a);case go:{const{source:f,flags:d}=a;return i([o,{source:f,flags:d}],a)}case xo:{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 yo:{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:u,message:c}],a)};return s},Ul=(e,{json:t,lossy:n}={})=>{const r=[];return E0(!(t||n),!!t,new Map,r)(e),r},Hi=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?Vl(Ul(e,t)):structuredClone(e):(e,t)=>Vl(Ul(e,t));function I0(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 T0(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function z0(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||I0,r=e.options.footnoteBackLabel||T0,i=e.options.footnoteLabel||"Footnotes",s=e.options.footnoteLabelTagName||"h2",a=e.options.footnoteLabelProperties||{className:["sr-only"]},o=[];let u=-1;for(;++u<e.footnoteOrder.length;){const c=e.footnoteById.get(e.footnoteOrder[u]);if(!c)continue;const f=e.all(c),d=String(c.identifier).toUpperCase(),p=hr(d.toLowerCase());let h=0;const m=[],v=e.footnoteCounts.get(d);for(;v!==void 0&&++h<=v;){m.length>0&&m.push({type:"text",value:" "});let j=typeof n=="string"?n:n(u,h);typeof j=="string"&&(j={type:"text",value:j}),m.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+p+(h>1?"-"+h:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(u,h),className:["data-footnote-backref"]},children:Array.isArray(j)?j:[j]})}const S=f[f.length-1];if(S&&S.type==="element"&&S.tagName==="p"){const j=S.children[S.children.length-1];j&&j.type==="text"?j.value+=" ":S.children.push({type:"text",value:" "}),S.children.push(...m)}else f.push(...m);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 D0;if(typeof e=="function")return ks(e);if(typeof e=="object")return Array.isArray(e)?A0(e):P0(e);if(typeof e=="string")return O0(e);throw new Error("Expected function, string, or object as test")};function A0(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 P0(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 O0(e){return ks(t);function t(n){return n&&n.type===e}}function ks(e){return t;function t(n,r,i){return!!(R0(n)&&e.call(this,n,typeof r=="number"?r:void 0,i||void 0))}}function D0(){return!0}function R0(e){return e!==null&&typeof e=="object"&&"type"in e}const Xf=[],M0=!0,Ca=!1,$0="skip";function Qf(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(u,c,f){const d=u&&typeof u=="object"?u:{};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 ("+(u.type+(h?"<"+h+">":""))+")"})}return p;function p(){let h=Xf,m,v,S;if((!t||s(u,c,f[f.length-1]||void 0))&&(h=F0(n(u,f)),h[0]===Ca))return h;if("children"in u&&u.children){const x=u;if(x.children&&h[0]!==$0)for(v=(r?x.children.length:-1)+a,S=f.concat(x);v>-1&&v<x.children.length;){const j=x.children[v];if(m=o(j,v,S)(),m[0]===Ca)return m;v=typeof m[1]=="number"?m[1]:v+a}}return h}}}function F0(e){return Array.isArray(e)?e:typeof e=="number"?[M0,e]:e==null?Xf:[e]}function bo(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),Qf(e,s,o,i);function o(u,c){const f=c[c.length-1],d=f?f.children.indexOf(u):void 0;return a(u,d,f)}}const Na={}.hasOwnProperty,L0={};function Z0(e,t){const n=t||L0,r=new Map,i=new Map,s=new Map,a={..._0,...n.handlers},o={all:c,applyData:V0,definitionById:r,footnoteById:i,footnoteCounts:s,footnoteOrder:[],handlers:a,one:u,options:n,patch:B0,wrap:J0};return bo(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 u(f,d){const p=f.type,h=o.handlers[p];if(Na.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||U0)(o,f,d)}function c(f){const d=[];if("children"in f){const p=f.children;let h=-1;for(;++h<p.length;){const m=o.one(p[h],f);if(m){if(h&&p[h-1].type==="break"&&(!Array.isArray(m)&&m.type==="text"&&(m.value=Jl(m.value)),!Array.isArray(m)&&m.type==="element")){const v=m.children[0];v&&v.type==="text"&&(v.value=Jl(v.value))}Array.isArray(m)?d.push(...m):d.push(m)}}}return d}}function B0(e,t){e.position&&(t.position=Tb(e))}function V0(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 U0(e,t){const n=t.data||{},r="value"in t&&!(Na.call(n,"hProperties")||Na.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 J0(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 Jl(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function Hl(e,t){const n=Z0(e,t),r=n.one(e,void 0),i=z0(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 H0(e,t){return e&&"run"in e?async function(n,r){const i=Hl(n,{file:r,...t});await e.run(i,r)}:function(n,r){return Hl(n,{file:r,...e||t})}}function Wl(e){if(e)throw e}var Us,ql;function W0(){if(ql)return Us;ql=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 u(){var c,f,d,p,h,m,v=arguments[0],S=1,x=arguments.length,j=!1;for(typeof v=="boolean"&&(j=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&&(j&&p&&(s(p)||(h=i(p)))?(h?(h=!1,m=d&&i(d)?d:[]):m=d&&s(d)?d:{},a(v,{name:f,newValue:u(j,m,p)})):typeof p<"u"&&a(v,{name:f,newValue:p}));return v},Us}var q0=W0();const Js=Ba(q0);function Ea(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 G0(){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(u,...c){const f=e[++s];let d=-1;if(u){a(u);return}for(;++d<i.length;)(c[d]===null||c[d]===void 0)&&(c[d]=i[d]);i=c,f?K0(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 K0(e,t){let n;return r;function r(...a){const o=e.length>a.length;let u;o&&a.push(i);try{u=e.apply(this,a)}catch(c){const f=c;if(o&&n)throw f;return i(f)}o||(u&&u.then&&typeof u.then=="function"?u.then(s,i):u instanceof Error?i(u):s(u))}function i(a,...o){n||(n=!0,t(a,...o))}function s(a){i(null,a)}}const Vt={basename:Y0,dirname:X0,extname:Q0,join:ek,sep:"/"};function Y0(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 X0(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 Q0(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 ek(...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?".":tk(n)}function tk(e){ui(e);const t=e.codePointAt(0)===47;let n=nk(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function nk(e,t){let n="",r=0,i=-1,s=0,a=-1,o,u;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(u=n.lastIndexOf("/"),u!==n.length-1){u<0?(n="",r=0):(n=n.slice(0,u),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 rk={cwd:ik};function ik(){return"/"}function Ia(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function sk(e){if(typeof e=="string")e=new URL(e);else if(!Ia(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 ak(e)}function ak(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 ep{constructor(t){let n;t?Ia(t)?n={path:t}:typeof t=="string"||ok(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":rk.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"?Vt.basename(this.path):void 0}set basename(t){qs(t,"basename"),Ws(t,"basename"),this.path=Vt.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Vt.dirname(this.path):void 0}set dirname(t){Gl(this.basename,"dirname"),this.path=Vt.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Vt.extname(this.path):void 0}set extname(t){if(Ws(t,"extname"),Gl(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=Vt.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){Ia(t)&&(t=sk(t)),qs(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Vt.basename(this.path,this.extname):void 0}set stem(t){qs(t,"stem"),Ws(t,"stem"),this.path=Vt.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(Vt.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Vt.sep+"`")}function qs(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function Gl(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function ok(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const lk=function(e){const r=this.constructor.prototype,i=r[e],s=function(){return i.apply(s,arguments)};return Object.setPrototypeOf(s,r),s},uk={}.hasOwnProperty;class vo extends lk{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=G0()}copy(){const t=new vo;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):uk.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),u=r.parse(o);r.run(u,o,function(f,d,p){if(f||!d||!p)return c(f);const h=d,m=r.stringify(h,p);fk(m)?p.value=m:p.result=m,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),Yl("processSync","process",n),r;function i(s,a){n=!0,Wl(s),r=a}}run(t,n,r){Kl(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 u=vi(n);i.run(t,u,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),Yl("runSync","run",r),i;function s(a,o){Wl(a),i=o,r=!0}}stringify(t,n){this.freeze();const r=vi(n),i=this.compiler||this.Compiler;return Ks("stringify",i),Kl(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")u(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")u(c,[]);else if(typeof c=="object")if(Array.isArray(c)){const[f,...d]=c;u(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 u(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,...m]=f;const v=r[p][1];Ea(v)&&Ea(h)&&(h=Js(!0,v,h)),r[p]=[c,h,...m]}}}}const ck=new vo().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 Kl(e){if(!Ea(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function Yl(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function vi(e){return dk(e)?e:new ep(e)}function dk(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function fk(e){return typeof e=="string"||pk(e)}function pk(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const hk="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",Xl=[],Ql={allowDangerousHtml:!0},mk=/^(https?|ircs?|mailto|xmpp)$/i,gk=[{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 xk(e){const t=yk(e),n=bk(e);return vk(t.runSync(t.parse(n),n),e)}function yk(e){const t=e.rehypePlugins||Xl,n=e.remarkPlugins||Xl,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...Ql}:Ql;return ck().use(Xw).use(n).use(H0,r).use(t)}function bk(e){const t=e.children||"",n=new ep;return typeof t=="string"&&(n.value=t),n}function vk(e,t){const n=t.allowedElements,r=t.allowElement,i=t.components,s=t.disallowedElements,a=t.skipHtml,o=t.unwrapDisallowed,u=t.urlTransform||wk;for(const f of gk)Object.hasOwn(t,f.from)&&(""+f.from+(f.to?"use `"+f.to+"` instead":"remove it")+hk+f.id,void 0);return bo(e,c),Db(e,{Fragment:l.Fragment,components:i,ignoreInvalidStyle:!0,jsx:l.jsx,jsxs:l.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 m=f.properties[h],v=Zs[h];(v===null||v.includes(f.tagName))&&(f.properties[h]=u(String(m||""),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 wk(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||mk.test(e.slice(0,t))?e:""}function eu(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 kk(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function Sk(e,t,n){const i=ws((n||{}).ignore||[]),s=_k(t);let a=-1;for(;++a<s.length;)Qf(e,"text",o);function o(c,f){let d=-1,p;for(;++d<f.length;){const h=f[d],m=p?p.children:void 0;if(i(h,m?m.indexOf(h):void 0,p))return;p=h}if(p)return u(c,f)}function u(c,f){const d=f[f.length-1],p=s[a][0],h=s[a][1];let m=0;const S=d.children.indexOf(c);let x=!1,j=[];p.lastIndex=0;let g=p.exec(c.value);for(;g;){const I=g.index,E={index:g.index,input:g.input,stack:[...f,c]};let k=h(...g,E);if(typeof k=="string"&&(k=k.length>0?{type:"text",value:k}:void 0),k===!1?p.lastIndex=I+1:(m!==I&&j.push({type:"text",value:c.value.slice(m,I)}),Array.isArray(k)?j.push(...k):k&&j.push(k),m=I+g[0].length,x=!0),!p.global)break;g=p.exec(c.value)}return x?(m<c.value.length&&j.push({type:"text",value:c.value.slice(m)}),d.children.splice(S,1,...j)):j=[c],S+j.length}}function _k(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([jk(i[0]),Ck(i[1])])}return t}function jk(e){return typeof e=="string"?new RegExp(kk(e),"g"):e}function Ck(e){return typeof e=="function"?e:function(){return e}}const Xs="phrasing",Qs=["autolink","link","image","label"];function Nk(){return{transforms:[Ok],enter:{literalAutolink:Ik,literalAutolinkEmail:ea,literalAutolinkHttp:ea,literalAutolinkWww:ea},exit:{literalAutolink:Pk,literalAutolinkEmail:Ak,literalAutolinkHttp:Tk,literalAutolinkWww:zk}}}function Ek(){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 Ik(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function ea(e){this.config.enter.autolinkProtocol.call(this,e)}function Tk(e){this.config.exit.autolinkProtocol.call(this,e)}function zk(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 Ak(e){this.config.exit.autolinkEmail.call(this,e)}function Pk(e){this.exit(e)}function Ok(e){Sk(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,Dk],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),Rk]],{ignore:["link","linkReference"]})}function Dk(e,t,n,r,i){let s="";if(!tp(i)||(/^w/i.test(t)&&(n=t+n,t="",s="http://"),!Mk(n)))return!1;const a=$k(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 Rk(e,t,n,r){return!tp(r,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function Mk(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 $k(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=eu(e,"(");let s=eu(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 tp(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||An(n)||ys(n))&&(!t||n!==47)}np.peek=Wk;function Fk(){this.buffer()}function Lk(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function Zk(){this.buffer()}function Bk(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function Vk(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=$t(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Uk(e){this.exit(e)}function Jk(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=$t(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Hk(e){this.exit(e)}function Wk(){return"["}function np(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 qk(){return{enter:{gfmFootnoteCallString:Fk,gfmFootnoteCall:Lk,gfmFootnoteDefinitionLabelString:Zk,gfmFootnoteDefinition:Bk},exit:{gfmFootnoteCallString:Vk,gfmFootnoteCall:Uk,gfmFootnoteDefinitionLabelString:Jk,gfmFootnoteDefinition:Hk}}}function Gk(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:np},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(r,i,s,a){const o=s.createTracker(a);let u=o.move("[^");const c=s.enter("footnoteDefinition"),f=s.enter("label");return u+=o.move(s.safe(s.associationId(r),{before:u,after:"]"})),f(),u+=o.move("]:"),r.children&&r.children.length>0&&(o.shift(4),u+=o.move((t?`
16
+ `:" ")+s.indentLines(s.containerFlow(r,o.current()),t?rp:Kk))),c(),u}}function Kk(e,t,n){return t===0?e:rp(e,t,n)}function rp(e,t,n){return(n?"":" ")+e}const Yk=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];ip.peek=nS;function Xk(){return{canContainEols:["delete"],enter:{strikethrough:eS},exit:{strikethrough:tS}}}function Qk(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:Yk}],handlers:{delete:ip}}}function eS(e){this.enter({type:"delete",children:[]},e)}function tS(e){this.exit(e)}function ip(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 nS(){return"~"}function rS(e){return e.length}function iS(e,t){const n=t||{},r=(n.align||[]).concat(),i=n.stringLength||rS,s=[],a=[],o=[],u=[];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 j=sS(e[f][x]);if(n.alignDelimiters!==!1){const g=i(j);S[x]=g,(u[x]===void 0||g>u[x])&&(u[x]=g)}v.push(j)}a[f]=v,o[f]=S}let d=-1;if(typeof r=="object"&&"length"in r)for(;++d<c;)s[d]=tu(r[d]);else{const v=tu(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 j=n.alignDelimiters===!1?1:Math.max(1,u[d]-S.length-x.length);const g=S+"-".repeat(j)+x;n.alignDelimiters!==!1&&(j=S.length+j+x.length,j>u[d]&&(u[d]=j),h[d]=j),p[d]=g}a.splice(1,0,p),o.splice(1,0,h),f=-1;const m=[];for(;++f<a.length;){const v=a[f],S=o[f];d=-1;const x=[];for(;++d<c;){const j=v[d]||"";let g="",I="";if(n.alignDelimiters!==!1){const E=u[d]-(S[d]||0),k=s[d];k===114?g=" ".repeat(E):k===99?E%2?(g=" ".repeat(E/2+.5),I=" ".repeat(E/2-.5)):(g=" ".repeat(E/2),I=g):I=" ".repeat(E)}n.delimiterStart!==!1&&!d&&x.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&j==="")&&(n.delimiterStart!==!1||d)&&x.push(" "),n.alignDelimiters!==!1&&x.push(g),x.push(j),n.alignDelimiters!==!1&&x.push(I),n.padding!==!1&&x.push(" "),(n.delimiterEnd!==!1||d!==c-1)&&x.push("|")}m.push(n.delimiterEnd===!1?x.join("").replace(/ +$/,""):x.join(""))}return m.join(`
17
+ `)}function sS(e){return e==null?"":String(e)}function tu(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 aS(e,t,n,r){const i=n.enter("blockquote"),s=n.createTracker(r);s.move("> "),s.shift(2);const a=n.indentLines(n.containerFlow(e,s.current()),oS);return i(),a}function oS(e,t,n){return">"+(n?"":" ")+e}function lS(e,t){return nu(e,t.inConstruct,!0)&&!nu(e,t.notInConstruct,!1)}function nu(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 ru(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
18
+ `&&lS(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?"":" ";return`\\
19
+ `}function uS(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 cS(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 dS(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 fS(e,t,n,r){const i=dS(n),s=e.value||"",a=i==="`"?"GraveAccent":"Tilde";if(cS(e,n)){const d=n.enter("codeIndented"),p=n.indentLines(s,pS);return d(),p}const o=n.createTracker(r),u=i.repeat(Math.max(uS(s,i)+1,3)),c=n.enter("codeFenced");let f=o.move(u);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(u),c(),f}function pS(e,t,n){return(n?"":" ")+e}function wo(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 hS(e,t,n,r){const i=wo(n),s=i==='"'?"Quote":"Apostrophe",a=n.enter("definition");let o=n.enter("label");const u=n.createTracker(r);let c=u.move("[");return c+=u.move(n.safe(n.associationId(e),{before:c,after:"]",...u.current()})),c+=u.move("]: "),o(),!e.url||/[\0- \u007F]/.test(e.url)?(o=n.enter("destinationLiteral"),c+=u.move("<"),c+=u.move(n.safe(e.url,{before:c,after:">",...u.current()})),c+=u.move(">")):(o=n.enter("destinationRaw"),c+=u.move(n.safe(e.url,{before:c,after:e.title?" ":`
23
+ `,...u.current()}))),o(),e.title&&(o=n.enter(`title${s}`),c+=u.move(" "+i),c+=u.move(n.safe(e.title,{before:c,after:i,...u.current()})),c+=u.move(i),o()),a(),c}function mS(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}}sp.peek=gS;function sp(e,t,n,r){const i=mS(n),s=n.enter("emphasis"),a=n.createTracker(r),o=a.move(i);let u=a.move(n.containerPhrasing(e,{after:i,before:o,...a.current()}));const c=u.charCodeAt(0),f=Wi(r.before.charCodeAt(r.before.length-1),c,i);f.inside&&(u=qr(c)+u.slice(1));const d=u.charCodeAt(u.length-1),p=Wi(r.after.charCodeAt(0),d,i);p.inside&&(u=u.slice(0,-1)+qr(d));const h=a.move(i);return s(),n.attentionEncodeSurroundingInfo={after:p.outside,before:f.outside},o+u+h}function gS(e,t,n){return n.options.emphasis||"*"}function xS(e,t){let n=!1;return bo(e,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return n=!0,Ca}),!!((!e.depth||e.depth<3)&&fo(e)&&(t.options.setext||n))}function yS(e,t,n,r){const i=Math.max(Math.min(6,e.depth||1),1),s=n.createTracker(r);if(xS(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"),u=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),u(),o(),c}ap.peek=bS;function ap(e){return e.value||""}function bS(){return"<"}op.peek=vS;function op(e,t,n,r){const i=wo(n),s=i==='"'?"Quote":"Apostrophe",a=n.enter("image");let o=n.enter("label");const u=n.createTracker(r);let c=u.move("![");return c+=u.move(n.safe(e.alt,{before:c,after:"]",...u.current()})),c+=u.move("]("),o(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(o=n.enter("destinationLiteral"),c+=u.move("<"),c+=u.move(n.safe(e.url,{before:c,after:">",...u.current()})),c+=u.move(">")):(o=n.enter("destinationRaw"),c+=u.move(n.safe(e.url,{before:c,after:e.title?" ":")",...u.current()}))),o(),e.title&&(o=n.enter(`title${s}`),c+=u.move(" "+i),c+=u.move(n.safe(e.title,{before:c,after:i,...u.current()})),c+=u.move(i),o()),c+=u.move(")"),a(),c}function vS(){return"!"}lp.peek=wS;function lp(e,t,n,r){const i=e.referenceType,s=n.enter("imageReference");let a=n.enter("label");const o=n.createTracker(r);let u=o.move("![");const c=n.safe(e.alt,{before:u,after:"]",...o.current()});u+=o.move(c+"]["),a();const f=n.stack;n.stack=[],a=n.enter("reference");const d=n.safe(n.associationId(e),{before:u,after:"]",...o.current()});return a(),n.stack=f,s(),i==="full"||!c||c!==d?u+=o.move(d+"]"):i==="shortcut"?u=u.slice(0,-1):u+=o.move("]"),u}function wS(){return"!"}up.peek=kS;function up(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 u;if(a.atBreak)for(;u=o.exec(r);){let c=u.index;r.charCodeAt(c)===10&&r.charCodeAt(c-1)===13&&c--,r=r.slice(0,c)+" "+r.slice(u.index+1)}}return i+r+i}function kS(){return"`"}function cp(e,t){const n=fo(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))}dp.peek=SS;function dp(e,t,n,r){const i=wo(n),s=i==='"'?"Quote":"Apostrophe",a=n.createTracker(r);let o,u;if(cp(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"),u=n.enter("label");let c=a.move("[");return c+=a.move(n.containerPhrasing(e,{before:c,after:"](",...a.current()})),c+=a.move("]("),u(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(u=n.enter("destinationLiteral"),c+=a.move("<"),c+=a.move(n.safe(e.url,{before:c,after:">",...a.current()})),c+=a.move(">")):(u=n.enter("destinationRaw"),c+=a.move(n.safe(e.url,{before:c,after:e.title?" ":")",...a.current()}))),u(),e.title&&(u=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),u()),c+=a.move(")"),o(),c}function SS(e,t,n){return cp(e,n)?"<":"["}fp.peek=_S;function fp(e,t,n,r){const i=e.referenceType,s=n.enter("linkReference");let a=n.enter("label");const o=n.createTracker(r);let u=o.move("[");const c=n.containerPhrasing(e,{before:u,after:"]",...o.current()});u+=o.move(c+"]["),a();const f=n.stack;n.stack=[],a=n.enter("reference");const d=n.safe(n.associationId(e),{before:u,after:"]",...o.current()});return a(),n.stack=f,s(),i==="full"||!c||c!==d?u+=o.move(d+"]"):i==="shortcut"?u=u.slice(0,-1):u+=o.move("]"),u}function _S(){return"["}function ko(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 jS(e){const t=ko(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 CS(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 pp(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 NS(e,t,n,r){const i=n.enter("list"),s=n.bulletCurrent;let a=e.ordered?CS(n):ko(n);const o=e.ordered?a==="."?")":".":jS(n);let u=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&&(u=!0),pp(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"){u=!0;break}}}}u&&(a=o),n.bulletCurrent=a;const c=n.containerFlow(e,r);return n.bulletLastUsed=a,n.bulletCurrent=s,i(),c}function ES(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 IS(e,t,n,r){const i=ES(n);let s=n.bulletCurrent||ko(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 u=n.enter("listItem"),c=n.indentLines(n.containerFlow(e,o.current()),f);return u(),c;function f(d,p,h){return p?(h?"":" ".repeat(a))+d:(h?s:s+" ".repeat(a-s.length))+d}}function TS(e,t,n,r){const i=n.enter("paragraph"),s=n.enter("phrasing"),a=n.containerPhrasing(e,r);return s(),i(),a}const zS=ws(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function AS(e,t,n,r){return(e.children.some(function(a){return zS(a)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function PS(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}hp.peek=OS;function hp(e,t,n,r){const i=PS(n),s=n.enter("strong"),a=n.createTracker(r),o=a.move(i+i);let u=a.move(n.containerPhrasing(e,{after:i,before:o,...a.current()}));const c=u.charCodeAt(0),f=Wi(r.before.charCodeAt(r.before.length-1),c,i);f.inside&&(u=qr(c)+u.slice(1));const d=u.charCodeAt(u.length-1),p=Wi(r.after.charCodeAt(0),d,i);p.inside&&(u=u.slice(0,-1)+qr(d));const h=a.move(i+i);return s(),n.attentionEncodeSurroundingInfo={after:p.outside,before:f.outside},o+u+h}function OS(e,t,n){return n.options.strong||"*"}function DS(e,t,n,r){return n.safe(e.value,r)}function RS(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 MS(e,t,n){const r=(pp(n)+(n.options.ruleSpaces?" ":"")).repeat(RS(n));return n.options.ruleSpaces?r.slice(0,-1):r}const mp={blockquote:aS,break:ru,code:fS,definition:hS,emphasis:sp,hardBreak:ru,heading:yS,html:ap,image:op,imageReference:lp,inlineCode:up,link:dp,linkReference:fp,list:NS,listItem:IS,paragraph:TS,root:AS,strong:hp,text:DS,thematicBreak:MS};function $S(){return{enter:{table:FS,tableData:iu,tableHeader:iu,tableRow:ZS},exit:{codeText:BS,table:LS,tableData:ta,tableHeader:ta,tableRow:ta}}}function FS(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 LS(e){this.exit(e),this.data.inTable=void 0}function ZS(e){this.enter({type:"tableRow",children:[]},e)}function ta(e){this.exit(e)}function iu(e){this.enter({type:"tableCell",children:[]},e)}function BS(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,VS));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function VS(e,t){return t==="|"?t:e}function US(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:u,tableRow:o}};function a(h,m,v,S){return c(f(h,v,S),h.align)}function o(h,m,v,S){const x=d(h,v,S),j=c([x]);return j.slice(0,j.indexOf(`
30
+ `))}function u(h,m,v,S){const x=v.enter("tableCell"),j=v.enter("phrasing"),g=v.containerPhrasing(h,{...S,before:s,after:s});return j(),x(),g}function c(h,m){return iS(h,{align:m,alignDelimiters:r,padding:n,stringLength:i})}function f(h,m,v){const S=h.children;let x=-1;const j=[],g=m.enter("table");for(;++x<S.length;)j[x]=d(S[x],m,v);return g(),j}function d(h,m,v){const S=h.children;let x=-1;const j=[],g=m.enter("tableRow");for(;++x<S.length;)j[x]=u(S[x],h,m,v);return g(),j}function p(h,m,v){let S=mp.inlineCode(h,m,v);return v.stack.includes("tableCell")&&(S=S.replace(/\|/g,"\\$&")),S}}function JS(){return{exit:{taskListCheckValueChecked:su,taskListCheckValueUnchecked:su,paragraph:WS}}}function HS(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:qS}}}function su(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function WS(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 qS(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 u=mp.listItem(e,t,n,{...r,...o.current()});return s&&(u=u.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,c)),u;function c(f){return f+a}}function GS(){return[Nk(),qk(),Xk(),$S(),JS()]}function KS(e){return{extensions:[Ek(),Gk(e),Qk(),US(e),HS()]}}const YS={tokenize:r1,partial:!0},gp={tokenize:i1,partial:!0},xp={tokenize:s1,partial:!0},yp={tokenize:a1,partial:!0},XS={tokenize:o1,partial:!0},bp={name:"wwwAutolink",tokenize:t1,previous:wp},vp={name:"protocolAutolink",tokenize:n1,previous:kp},rn={name:"emailAutolink",tokenize:e1,previous:Sp},Gt={};function QS(){return{text:Gt}}let kn=48;for(;kn<123;)Gt[kn]=rn,kn++,kn===58?kn=65:kn===91&&(kn=97);Gt[43]=rn;Gt[45]=rn;Gt[46]=rn;Gt[95]=rn;Gt[72]=[rn,vp];Gt[104]=[rn,vp];Gt[87]=[rn,bp];Gt[119]=[rn,bp];function e1(e,t,n){const r=this;let i,s;return a;function a(d){return!Ta(d)||!Sp.call(r,r.previous)||So(r.events)?n(d):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),o(d))}function o(d){return Ta(d)?(e.consume(d),o):d===64?(e.consume(d),u):n(d)}function u(d){return d===46?e.check(XS,f,c)(d):d===45||d===95||st(d)?(s=!0,e.consume(d),u):f(d)}function c(d){return e.consume(d),i=!0,u}function f(d){return s&&i&&dt(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(d)):n(d)}}function t1(e,t,n){const r=this;return i;function i(a){return a!==87&&a!==119||!wp.call(r,r.previous)||So(r.events)?n(a):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(YS,e.attempt(gp,e.attempt(xp,s),n),n)(a))}function s(a){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(a)}}function n1(e,t,n){const r=this;let i="",s=!1;return a;function a(d){return(d===72||d===104)&&kp.call(r,r.previous)&&!So(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),u}return n(d)}function u(d){return d===47?(e.consume(d),s?c:(s=!0,u)):n(d)}function c(d){return d===null||Ui(d)||Fe(d)||An(d)||ys(d)?n(d):e.attempt(gp,e.attempt(xp,f),n)(d)}function f(d){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(d)}}function r1(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 i1(e,t,n){let r,i,s;return a;function a(c){return c===46||c===95?e.check(yp,u,o)(c):c===null||Fe(c)||An(c)||c!==45&&ys(c)?u(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 u(c){return i||r||!s?n(c):t(c)}}function s1(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(yp,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 a1(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 o1(e,t,n){return r;function r(s){return e.consume(s),i}function i(s){return st(s)?n(s):t(s)}}function wp(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Fe(e)}function kp(e){return!dt(e)}function Sp(e){return!(e===47||Ta(e))}function Ta(e){return e===43||e===45||e===46||e===95||st(e)}function So(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 l1={tokenize:g1,partial:!0};function u1(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:p1,continuation:{tokenize:h1},exit:m1}},text:{91:{name:"gfmFootnoteCall",tokenize:f1},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:c1,resolveTo:d1}}}}function c1(e,t,n){const r=this;let i=r.events.length;const s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a;for(;i--;){const u=r.events[i][1];if(u.type==="labelImage"){a=u;break}if(u.type==="gfmFootnoteCall"||u.type==="labelLink"||u.type==="label"||u.type==="image"||u.type==="link")break}return o;function o(u){if(!a||!a._balanced)return n(u);const c=$t(r.sliceSerialize({start:a.end,end:r.now()}));return c.codePointAt(0)!==94||!s.includes(c.slice(1))?n(u):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(u),e.exit("gfmFootnoteCallLabelMarker"),t(u))}}function d1(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 f1(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"),u}function u(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($t(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 p1(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s,a=0,o;return u;function u(m){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),c}function c(m){return m===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",f):n(m)}function f(m){if(a>999||m===93&&!o||m===null||m===91||Fe(m))return n(m);if(m===93){e.exit("chunkString");const v=e.exit("gfmFootnoteDefinitionLabelString");return s=$t(r.sliceSerialize(v)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),p}return Fe(m)||(o=!0),a++,e.consume(m),m===92?d:f}function d(m){return m===91||m===92||m===93?(e.consume(m),a++,f):f(m)}function p(m){return m===58?(e.enter("definitionMarker"),e.consume(m),e.exit("definitionMarker"),i.includes(s)||i.push(s),Pe(e,h,"gfmFootnoteDefinitionWhitespace")):n(m)}function h(m){return t(m)}}function h1(e,t,n){return e.check(li,t,e.attempt(l1,t,n))}function m1(e){e.exit("gfmFootnoteDefinition")}function g1(e,t,n){const r=this;return Pe(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 x1(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 u=-1;for(;++u<a.length;)if(a[u][0]==="enter"&&a[u][1].type==="strikethroughSequenceTemporary"&&a[u][1]._close){let c=u;for(;c--;)if(a[c][0]==="exit"&&a[c][1].type==="strikethroughSequenceTemporary"&&a[c][1]._open&&a[u][1].end.offset-a[u][1].start.offset===a[c][1].end.offset-a[c][1].start.offset){a[u][1].type="strikethroughSequence",a[c][1].type="strikethroughSequence";const f={type:"strikethrough",start:Object.assign({},a[c][1].start),end:Object.assign({},a[u][1].end)},d={type:"strikethroughText",start:Object.assign({},a[c][1].end),end:Object.assign({},a[u][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&&jt(p,p.length,0,bs(h,a.slice(c+1,u),o)),jt(p,p.length,0,[["exit",d,o],["enter",a[u][1],o],["exit",a[u][1],o],["exit",f,o]]),jt(a,c-1,u-c+3,p),u=c+p.length-2;break}}for(u=-1;++u<a.length;)a[u][1].type==="strikethroughSequenceTemporary"&&(a[u][1].type="data");return a}function s(a,o,u){const c=this.previous,f=this.events;let d=0;return p;function p(m){return c===126&&f[f.length-1][1].type!=="characterEscape"?u(m):(a.enter("strikethroughSequenceTemporary"),h(m))}function h(m){const v=or(c);if(m===126)return d>1?u(m):(a.consume(m),d++,h);if(d<2&&!n)return u(m);const S=a.exit("strikethroughSequenceTemporary"),x=or(m);return S._open=!x||x===2&&!!v,S._close=!v||v===2&&!!x,o(m)}}}class y1{constructor(){this.map=[]}add(t,n,r){b1(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 b1(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 v1(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 w1(){return{flow:{null:{name:"table",tokenize:k1,resolveAll:S1}}}}function k1(e,t,n){const r=this;let i=0,s=0,a;return o;function o(C){let z=r.events.length-1;for(;z>-1;){const $=r.events[z][1].type;if($==="lineEnding"||$==="linePrefix")z--;else break}const A=z>-1?r.events[z][1].type:null,M=A==="tableHead"||A==="tableRow"?k:u;return M===k&&r.parser.lazy[r.now().line]?n(C):M(C)}function u(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):he(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)?Pe(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)?Pe(e,m,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(C):m(C))}function m(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)?Pe(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||he(C)?I(C):E(C)}function x(C){return C===45?(e.enter("tableDelimiterFiller"),j(C)):E(C)}function j(C){return C===45?(e.consume(C),j):C===58?(a=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(C),e.exit("tableDelimiterMarker"),g):(e.exit("tableDelimiterFiller"),g(C))}function g(C){return Ie(C)?Pe(e,I,"whitespace")(C):I(C)}function I(C){return C===124?m(C):C===null||he(C)?!a||i!==s?E(C):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(C)):E(C)}function E(C){return n(C)}function k(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||he(C)?(e.exit("tableRow"),t(C)):Ie(C)?Pe(e,N,"whitespace")(C):(e.enter("data"),J(C))}function J(C){return C===null||C===124||Fe(C)?(e.exit("data"),N(C)):(e.consume(C),C===92?L:J)}function L(C){return C===92||C===124?(e.consume(C),J):J(C)}}function S1(e,t){let n=-1,r=!0,i=0,s=[0,0,0,0],a=[0,0,0,0],o=!1,u=0,c,f,d;const p=new y1;for(;++n<e.length;){const h=e[n],m=h[1];h[0]==="enter"?m.type==="tableHead"?(o=!1,u!==0&&(au(p,t,u,c,f),f=void 0,u=0),c={type:"table",start:Object.assign({},m.start),end:Object.assign({},m.end)},p.add(n,0,[["enter",c,t]])):m.type==="tableRow"||m.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({},m.start),end:Object.assign({},m.end)},p.add(n,0,[["enter",f,t]])),i=m.type==="tableDelimiterRow"?2:f?3:1):i&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.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)):m.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])):m.type==="tableHead"?(o=!0,u=n):m.type==="tableRow"||m.type==="tableDelimiterRow"?(u=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&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")&&(a[3]=n)}for(u!==0&&au(p,t,u,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=v1(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 u=Hn(t.events,n[1]);if(s={type:a,start:Object.assign({},u),end:Object.assign({},u)},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 m=n[2]+1,v=n[3]-n[2]-1;e.add(m,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 au(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 _1={name:"tasklistCheck",tokenize:C1};function j1(){return{text:{91:_1}}}function C1(e,t,n){const r=this;return i;function i(u){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(u):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(u),e.exit("taskListCheckMarker"),s)}function s(u){return Fe(u)?(e.enter("taskListCheckValueUnchecked"),e.consume(u),e.exit("taskListCheckValueUnchecked"),a):u===88||u===120?(e.enter("taskListCheckValueChecked"),e.consume(u),e.exit("taskListCheckValueChecked"),a):n(u)}function a(u){return u===93?(e.enter("taskListCheckMarker"),e.consume(u),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),o):n(u)}function o(u){return he(u)?t(u):Ie(u)?e.check({tokenize:N1},t,n)(u):n(u)}}function N1(e,t,n){return Pe(e,r,"whitespace");function r(i){return i===null?n(i):t(i)}}function E1(e){return Of([QS(),u1(),x1(e),w1(),j1()])}const I1={};function T1(e){const t=this,n=e||I1,r=t.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),s=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),a=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(E1(n)),s.push(GS()),a.push(KS(n))}var _p="vercel.ai.error",z1=Symbol.for(_p),ou,lu,qt=class jp extends(lu=Error,ou=z1,lu){constructor({name:t,message:n,cause:r}){super(n),this[ou]=!0,this.name=t,this.cause=r}static isInstance(t){return jp.hasMarker(t,_p)}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 Cp(e){return e==null?"unknown error":typeof e=="string"?e:e instanceof Error?e.message:JSON.stringify(e)}var Np="AI_InvalidArgumentError",Ep=`vercel.ai.error.${Np}`,A1=Symbol.for(Ep),uu,cu,P1=class extends(cu=qt,uu=A1,cu){constructor({message:e,cause:t,argument:n}){super({name:Np,message:e,cause:t}),this[uu]=!0,this.argument=n}static isInstance(e){return qt.hasMarker(e,Ep)}},Ip="AI_JSONParseError",Tp=`vercel.ai.error.${Ip}`,O1=Symbol.for(Tp),du,fu,pu=class extends(fu=qt,du=O1,fu){constructor({text:e,cause:t}){super({name:Ip,message:`JSON parsing failed: Text: ${e}.
31
+ Error message: ${Cp(t)}`,cause:t}),this[du]=!0,this.text=e}static isInstance(e){return qt.hasMarker(e,Tp)}},zp="AI_TypeValidationError",Ap=`vercel.ai.error.${zp}`,D1=Symbol.for(Ap),hu,mu,lr=class za extends(mu=qt,hu=D1,mu){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:zp,message:`${i}: Value: ${JSON.stringify(t)}.
32
+ Error message: ${Cp(n)}`,cause:n}),this[hu]=!0,this.value=t,this.context=r}static isInstance(t){return qt.hasMarker(t,Ap)}static wrap({value:t,cause:n,context:r}){var i,s,a;return za.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 za({value:t,cause:n,context:r})}};function V(e,t,n){function r(o,u){if(o._zod||Object.defineProperty(o,"_zod",{value:{def:u,constr:a,traits:new Set},enumerable:!1}),o._zod.traits.has(e))return;o._zod.traits.add(e),t(o,u);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 u;const c=n!=null&&n.Parent?new s:this;r(c,o),(u=c._zod).deferred??(u.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 u,c;return n!=null&&n.Parent&&o instanceof n.Parent?!0:(c=(u=o==null?void 0:o._zod)==null?void 0:u.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 Pp extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const Op={};function gn(e){return Op}function Dp(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 Aa(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 _o(e){return e==null}function jo(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function R1(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 u=r.match(/\d?e-(\d?)/);u!=null&&u[1]&&(i=Number.parseInt(u[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 gu=Symbol("evaluating");function ze(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==gu)return r===void 0&&(r=gu,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 bn(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function xu(e){return JSON.stringify(e)}function M1(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Rp="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Gr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const $1=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 Mp(e){return ur(e)?{...e}:Array.isArray(e)?[...e]:e}const F1=new Set(["string","number","symbol"]);function cr(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function vn(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 ue(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 L1(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const Z1={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 B1(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=bn(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 vn(e,s)}function V1(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=bn(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 vn(e,s)}function U1(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=bn(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t};return Dn(this,"shape",s),s}});return vn(e,i)}function J1(e,t){if(!ur(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=bn(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return Dn(this,"shape",r),r}});return vn(e,n)}function H1(e,t){const n=bn(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 vn(e,n)}function W1(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=bn(t._zod.def,{get shape(){const o=t._zod.def.shape,u={...o};if(n)for(const c in n){if(!(c in o))throw new Error(`Unrecognized key: "${c}"`);n[c]&&(u[c]=e?new e({type:"optional",innerType:o[c]}):o[c])}else for(const c in o)u[c]=e?new e({type:"optional",innerType:o[c]}):o[c];return Dn(this,"shape",u),u},checks:[]});return vn(t,a)}function q1(e,t,n){const r=bn(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 vn(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 xn(e,t,n){var i,s,a,o,u,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((u=n.customError)==null?void 0:u.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 Co(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 $p=(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,Aa,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Fp=V("$ZodError",$p),Lp=V("$ZodError",$p,{Parent:Error});function G1(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 K1(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 u=s.path[o];o===s.path.length-1?(a[u]=a[u]||{_errors:[]},a[u]._errors.push(t(s))):a[u]=a[u]||{_errors:[]},a=a[u],o++}}};return r(e),n}const No=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(u=>xn(u,s,gn())));throw Rp(o,i==null?void 0:i.callee),o}return a.value},Eo=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(u=>xn(u,s,gn())));throw Rp(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??Fp)(s.issues.map(a=>xn(a,i,gn())))}:{success:!0,data:s.value}},Y1=_s(Lp),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=>xn(a,i,gn())))}:{success:!0,data:s.value}},X1=js(Lp),Q1=e=>(t,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return No(e)(t,n,i)},e_=e=>(t,n,r)=>No(e)(t,n,r),t_=e=>async(t,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Eo(e)(t,n,i)},n_=e=>async(t,n,r)=>Eo(e)(t,n,r),r_=e=>(t,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return _s(e)(t,n,i)},i_=e=>(t,n,r)=>_s(e)(t,n,r),s_=e=>async(t,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return js(e)(t,n,i)},a_=e=>async(t,n,r)=>js(e)(t,n,r),o_=/^[cC][^\s-]{8,}$/,l_=/^[0-9a-z]+$/,u_=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,c_=/^[0-9a-vA-V]{20}$/,d_=/^[A-Za-z0-9]{27}$/,f_=/^[a-zA-Z0-9_-]{21}$/,p_=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,h_=/^([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})$/,yu=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)$/,m_=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,g_="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function x_(){return new RegExp(g_,"u")}const y_=/^(?:(?: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])$/,b_=/^(([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}|:))$/,v_=/^((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])$/,w_=/^(([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])$/,k_=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Zp=/^[A-Za-z0-9_-]*$/,S_=/^\+[1-9]\d{6,14}$/,Bp="(?:(?:\\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])))",__=new RegExp(`^${Bp}$`);function Vp(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 j_(e){return new RegExp(`^${Vp(e)}$`)}function C_(e){const t=Vp({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(`^${Bp}T(?:${r})$`)}const N_=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}$`)},E_=/^-?\d+$/,Up=/^-?\d+(?:\.\d+)?$/,I_=/^(?:true|false)$/i,T_=/^null$/i,z_=/^[^A-Z]*$/,A_=/^[^a-z]*$/,wt=V("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Jp={number:"number",bigint:"bigint",object:"date"},Hp=V("$ZodCheckLessThan",(e,t)=>{wt.init(e,t);const n=Jp[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})}}),Wp=V("$ZodCheckGreaterThan",(e,t)=>{wt.init(e,t);const n=Jp[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})}}),P_=V("$ZodCheckMultipleOf",(e,t)=>{wt.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):R1(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})}}),O_=V("$ZodCheckNumberFormat",(e,t)=>{var a;wt.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]=Z1[t.format];e._zod.onattach.push(o=>{const u=o._zod.bag;u.format=t.format,u.minimum=i,u.maximum=s,n&&(u.pattern=E_)}),e._zod.check=o=>{const u=o.value;if(n){if(!Number.isInteger(u)){o.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:u,inst:e});return}if(!Number.isSafeInteger(u)){u>0?o.issues.push({input:u,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:u,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}}u<i&&o.issues.push({origin:"number",input:u,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort}),u>s&&o.issues.push({origin:"number",input:u,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}}),D_=V("$ZodCheckMaxLength",(e,t)=>{var n;wt.init(e,t),(n=e._zod.def).when??(n.when=r=>{const i=r.value;return!_o(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=Co(i);r.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),R_=V("$ZodCheckMinLength",(e,t)=>{var n;wt.init(e,t),(n=e._zod.def).when??(n.when=r=>{const i=r.value;return!_o(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=Co(i);r.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),M_=V("$ZodCheckLengthEquals",(e,t)=>{var n;wt.init(e,t),(n=e._zod.def).when??(n.when=r=>{const i=r.value;return!_o(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=Co(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=V("$ZodCheckStringFormat",(e,t)=>{var n,r;wt.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=()=>{})}),$_=V("$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})}}),F_=V("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=z_),Cs.init(e,t)}),L_=V("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=A_),Cs.init(e,t)}),Z_=V("$ZodCheckIncludes",(e,t)=>{wt.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})}}),B_=V("$ZodCheckStartsWith",(e,t)=>{wt.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})}}),V_=V("$ZodCheckEndsWith",(e,t)=>{wt.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})}}),U_=V("$ZodCheckOverwrite",(e,t)=>{wt.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class J_{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 H_={major:4,minor:3,patch:6},Je=V("$ZodType",(e,t)=>{var i;var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=H_;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,u,c)=>{let f=Kn(o),d;for(const p of u){if(p._zod.def.when){if(!p._zod.def.when(o))continue}else if(f)continue;const h=o.issues.length,m=p._zod.check(o);if(m instanceof Promise&&(c==null?void 0:c.async)===!1)throw new nr;if(d||m instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await m,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,u,c)=>{if(Kn(o))return o.aborted=!0,o;const f=s(u,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,u)=>{if(u.skipChecks)return e._zod.parse(o,u);if(u.direction==="backward"){const f=e._zod.parse({value:o.value,issues:[]},{...u,skipChecks:!0});return f instanceof Promise?f.then(d=>a(d,o,u)):a(f,o,u)}const c=e._zod.parse(o,u);if(c instanceof Promise){if(u.async===!1)throw new nr;return c.then(f=>s(f,r,u))}return s(c,r,u)}}ze(e,"~standard",()=>({validate:s=>{var a;try{const o=Y1(e,s);return o.success?{value:o.data}:{issues:(a=o.error)==null?void 0:a.issues}}catch{return X1(e,s).then(u=>{var c;return u.success?{value:u.data}:{issues:(c=u.error)==null?void 0:c.issues}})}},vendor:"zod",version:1}))}),Io=V("$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()??N_(e._zod.bag),e._zod.parse=(r,i)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),Ke=V("$ZodStringFormat",(e,t)=>{Cs.init(e,t),Io.init(e,t)}),W_=V("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=h_),Ke.init(e,t)}),q_=V("$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=yu(r))}else t.pattern??(t.pattern=yu());Ke.init(e,t)}),G_=V("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=m_),Ke.init(e,t)}),K_=V("$ZodURL",(e,t)=>{Ke.init(e,t),e._zod.check=n=>{try{const r=n.value.trim(),i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=i.href:n.value=r;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),Y_=V("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=x_()),Ke.init(e,t)}),X_=V("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=f_),Ke.init(e,t)}),Q_=V("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=o_),Ke.init(e,t)}),ej=V("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=l_),Ke.init(e,t)}),tj=V("$ZodULID",(e,t)=>{t.pattern??(t.pattern=u_),Ke.init(e,t)}),nj=V("$ZodXID",(e,t)=>{t.pattern??(t.pattern=c_),Ke.init(e,t)}),rj=V("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=d_),Ke.init(e,t)}),ij=V("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=C_(t)),Ke.init(e,t)}),sj=V("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=__),Ke.init(e,t)}),aj=V("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=j_(t)),Ke.init(e,t)}),oj=V("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=p_),Ke.init(e,t)}),lj=V("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=y_),Ke.init(e,t),e._zod.bag.format="ipv4"}),uj=V("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=b_),Ke.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),cj=V("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=v_),Ke.init(e,t)}),dj=V("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=w_),Ke.init(e,t),e._zod.check=n=>{const r=n.value.split("/");try{if(r.length!==2)throw new Error;const[i,s]=r;if(!s)throw new Error;const 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 qp(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const fj=V("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=k_),Ke.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{qp(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function pj(e){if(!Zp.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return qp(n)}const hj=V("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Zp),Ke.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{pj(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),mj=V("$ZodE164",(e,t)=>{t.pattern??(t.pattern=S_),Ke.init(e,t)});function gj(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 xj=V("$ZodJWT",(e,t)=>{Ke.init(e,t),e._zod.check=n=>{gj(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),Gp=V("$ZodNumber",(e,t)=>{Je.init(e,t),e._zod.pattern=e._zod.bag.pattern??Up,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}}),yj=V("$ZodNumberFormat",(e,t)=>{O_.init(e,t),Gp.init(e,t)}),bj=V("$ZodBoolean",(e,t)=>{Je.init(e,t),e._zod.pattern=I_,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}}),vj=V("$ZodNull",(e,t)=>{Je.init(e,t),e._zod.pattern=T_,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}}),wj=V("$ZodUnknown",(e,t)=>{Je.init(e,t),e._zod.parse=n=>n}),kj=V("$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 bu(e,t,n){e.issues.length&&t.issues.push(...Yn(n,e.issues)),t.value[n]=e.value}const Sj=V("$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],u=t.element._zod.run({value:o,issues:[]},r);u instanceof Promise?s.push(u.then(c=>bu(c,n,a))):bu(u,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 Kp(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=L1(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Yp(e,t,n,r,i,s){const a=[],o=i.keySet,u=i.catchall._zod,c=u.def.type,f=u.optout==="optional";for(const d in t){if(o.has(d))continue;if(c==="never"){a.push(d);continue}const p=u.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 _j=V("$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 u={...o};return Object.defineProperty(t,"shape",{value:u}),u}})}const r=Ss(()=>Kp(t));ze(e._zod,"propValues",()=>{const o=t.shape,u={};for(const c in o){const f=o[c]._zod;if(f.values){u[c]??(u[c]=new Set);for(const d of f.values)u[c].add(d)}}return u});const i=Gr,s=t.catchall;let a;e._zod.parse=(o,u)=>{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],m=h._zod.optout==="optional",v=h._zod.run({value:c[p],issues:[]},u);v instanceof Promise?f.push(v.then(S=>qi(S,o,p,c,m))):qi(v,o,p,c,m)}return s?Yp(f,c,o,u,r.value,e):f.length?Promise.all(f).then(()=>o):o}}),jj=V("$ZodObjectJIT",(e,t)=>{_j.init(e,t);const n=e._zod.parse,r=Ss(()=>Kp(t)),i=p=>{var g;const h=new J_(["shape","payload","ctx"]),m=r.value,v=I=>{const E=xu(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 m.keys)S[I]=`key_${x++}`;h.write("const newResult = {};");for(const I of m.keys){const E=S[I],k=xu(I),N=p[I],J=((g=N==null?void 0:N._zod)==null?void 0:g.optout)==="optional";h.write(`const ${E} = ${v(I)};`),J?h.write(`
35
+ if (${E}.issues.length) {
36
+ if (${k} in input) {
37
+ payload.issues = payload.issues.concat(${E}.issues.map(iss => ({
38
+ ...iss,
39
+ path: iss.path ? [${k}, ...iss.path] : [${k}]
40
+ })));
41
+ }
42
+ }
43
+
44
+ if (${E}.value === undefined) {
45
+ if (${k} in input) {
46
+ newResult[${k}] = undefined;
47
+ }
48
+ } else {
49
+ newResult[${k}] = ${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 ? [${k}, ...iss.path] : [${k}]
57
+ })));
58
+ }
59
+
60
+ if (${E}.value === undefined) {
61
+ if (${k} in input) {
62
+ newResult[${k}] = undefined;
63
+ }
64
+ } else {
65
+ newResult[${k}] = ${E}.value;
66
+ }
67
+
68
+ `)}h.write("payload.value = newResult;"),h.write("return payload;");const j=h.compile();return(I,E)=>j(p,I,E)};let s;const a=Gr,o=!Op.jitless,c=o&&$1.value,f=t.catchall;let d;e._zod.parse=(p,h)=>{d??(d=r.value);const m=p.value;return a(m)?o&&c&&(h==null?void 0:h.async)===!1&&h.jitless!==!0?(s||(s=i(t.shape)),p=s(p,h),f?Yp([],m,p,h,d,e):p):n(p,h):(p.issues.push({expected:"object",code:"invalid_type",input:m,inst:e}),p)}});function vu(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=>xn(a,r,gn())))}),t)}const Xp=V("$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=>jo(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 u of t.options){const c=u._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(u=>vu(u,i,e,s)):vu(o,i,e,s)}}),Cj=V("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Xp.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,u]of Object.entries(a)){i[o]||(i[o]=new Set);for(const c of u)i[o].add(c)}}return i});const r=Ss(()=>{var a;const i=t.options,s=new Map;for(const o of i){const u=(a=o._zod.propValues)==null?void 0:a[t.discriminator];if(!u||u.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(o)}"`);for(const c of u){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)}}),Nj=V("$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(([u,c])=>wu(n,u,c)):wu(n,s,a)}});function Pa(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=Pa(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=Pa(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 wu(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 u of o.keys)r.has(u)||r.set(u,{}),r.get(u).l=!0}else e.issues.push(o);for(const o of n.issues)if(o.code==="unrecognized_keys")for(const u of o.keys)r.has(u)||r.set(u,{}),r.get(u).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=Pa(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 Ej=V("$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 u;for(const c in i)o.has(c)||(u=u??[],u.push(c));u&&u.length>0&&n.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:u})}else{n.value={};for(const o of Reflect.ownKeys(i)){if(o==="__proto__")continue;let u=t.keyType._zod.run({value:o,issues:[]},r);if(u instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof o=="string"&&Up.test(o)&&u.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&&(u=d)}if(u.issues.length){t.mode==="loose"?n.value[o]=i[o]:n.issues.push({code:"invalid_key",origin:"record",issues:u.issues.map(d=>xn(d,r,gn())),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[u.value]=d.value})):(f.issues.length&&n.issues.push(...Yn(o,f.issues)),n.value[u.value]=f.value)}}return s.length?Promise.all(s).then(()=>n):n}}),Ij=V("$ZodEnum",(e,t)=>{Je.init(e,t);const n=Dp(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(i=>F1.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}}),Tj=V("$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}}),zj=V("$ZodTransform",(e,t)=>{Je.init(e,t),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Pp(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 ku(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const Qp=V("$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(`^(${jo(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=>ku(s,n.value)):ku(i,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,r)}}),Aj=V("$ZodExactOptional",(e,t)=>{Qp.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)}),Pj=V("$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(`^(${jo(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)}),Oj=V("$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=>Su(s,t)):Su(i,t)}});function Su(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Dj=V("$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))}),Rj=V("$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=>_u(s,e)):_u(i,e)}});function _u(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 Mj=V("$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=>xn(a,r,gn()))},input:n.value}),n.issues=[]),n)):(n.value=i.value,i.issues.length&&(n.value=t.catchValue({...n,error:{issues:i.issues.map(s=>xn(s,r,gn()))},input:n.value}),n.issues=[]),n)}}),$j=V("$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 Fj=V("$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(ju):ju(i)}});function ju(e){return e.value=Object.freeze(e.value),e}const Lj=V("$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)}),Zj=V("$ZodCustom",(e,t)=>{wt.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=>Cu(s,n,r,e));Cu(i,n,r,e)}});function Cu(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 Nu;class Bj{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 Vj(){return new Bj}(Nu=globalThis).__zod_globalRegistry??(Nu.__zod_globalRegistry=Vj());const Ir=globalThis.__zod_globalRegistry;function Uj(e,t){return new e({type:"string",...ue(t)})}function Jj(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...ue(t)})}function Eu(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...ue(t)})}function Hj(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...ue(t)})}function Wj(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...ue(t)})}function qj(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...ue(t)})}function Gj(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...ue(t)})}function Kj(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...ue(t)})}function Yj(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...ue(t)})}function Xj(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...ue(t)})}function Qj(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...ue(t)})}function eC(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...ue(t)})}function tC(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...ue(t)})}function nC(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...ue(t)})}function rC(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...ue(t)})}function iC(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...ue(t)})}function sC(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...ue(t)})}function aC(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...ue(t)})}function oC(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...ue(t)})}function lC(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...ue(t)})}function uC(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...ue(t)})}function cC(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...ue(t)})}function dC(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...ue(t)})}function fC(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...ue(t)})}function pC(e,t){return new e({type:"string",format:"date",check:"string_format",...ue(t)})}function hC(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...ue(t)})}function mC(e,t){return new e({type:"string",format:"duration",check:"string_format",...ue(t)})}function gC(e,t){return new e({type:"number",checks:[],...ue(t)})}function xC(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...ue(t)})}function yC(e,t){return new e({type:"boolean",...ue(t)})}function bC(e,t){return new e({type:"null",...ue(t)})}function vC(e){return new e({type:"unknown"})}function wC(e,t){return new e({type:"never",...ue(t)})}function Iu(e,t){return new Hp({check:"less_than",...ue(t),value:e,inclusive:!1})}function na(e,t){return new Hp({check:"less_than",...ue(t),value:e,inclusive:!0})}function Tu(e,t){return new Wp({check:"greater_than",...ue(t),value:e,inclusive:!1})}function ra(e,t){return new Wp({check:"greater_than",...ue(t),value:e,inclusive:!0})}function zu(e,t){return new P_({check:"multiple_of",...ue(t),value:e})}function eh(e,t){return new D_({check:"max_length",...ue(t),maximum:e})}function Gi(e,t){return new R_({check:"min_length",...ue(t),minimum:e})}function th(e,t){return new M_({check:"length_equals",...ue(t),length:e})}function kC(e,t){return new $_({check:"string_format",format:"regex",...ue(t),pattern:e})}function SC(e){return new F_({check:"string_format",format:"lowercase",...ue(e)})}function _C(e){return new L_({check:"string_format",format:"uppercase",...ue(e)})}function jC(e,t){return new Z_({check:"string_format",format:"includes",...ue(t),includes:e})}function CC(e,t){return new B_({check:"string_format",format:"starts_with",...ue(t),prefix:e})}function NC(e,t){return new V_({check:"string_format",format:"ends_with",...ue(t),suffix:e})}function mr(e){return new U_({check:"overwrite",tx:e})}function EC(e){return mr(t=>t.normalize(e))}function IC(){return mr(e=>e.trim())}function TC(){return mr(e=>e.toLowerCase())}function zC(){return mr(e=>e.toUpperCase())}function AC(){return mr(e=>M1(e))}function PC(e,t,n){return new e({type:"array",element:t,...ue(n)})}function OC(e,t,n){const r=ue(n);return r.abort??(r.abort=!0),new e({type:"custom",check:"custom",fn:t,...r})}function DC(e,t,n){return new e({type:"custom",check:"custom",fn:t,...ue(n)})}function RC(e){const t=MC(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 MC(e,t){const n=new wt({check:"custom",...ue(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 m=a.schema,v=t.processors[i.type];if(!v)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);v(e,t,m,p)}const h=e._zod.parent;h&&(a.ref||(a.ref=h),Be(h,t,p),t.seen.get(h).isParent=!0)}const u=t.metadataRegistry.get(e);return u&&Object.assign(a.schema,u),t.io==="input"&&lt(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,u,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??(g=>g);if(S)return{ref:x(S)};const j=f[1].defId??f[1].schema.id??`schema${e.counter++}`;return f[1].defId=j,{defId:j,ref:`${x("__shared")}#/${d}/${j}`}}if(f[1]===n)return{ref:"#"};const h=`#/${d}/`,m=f[1].schema.id??`__schema${e.counter++}`;return{defId:m,ref:h+m}},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 m=d.schema;for(const v in m)delete m[v];m.$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=(u=e.external.registry.get(f[0]))==null?void 0:u.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,u;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 j in d)j==="$ref"||j==="allOf"||j in p||delete d[j];if(S.$ref&&v.def)for(const j in d)j==="$ref"||j==="allOf"||j in v.def&&JSON.stringify(d[j])===JSON.stringify(v.def[j])&&delete d[j]}const m=c._zod.parent;if(m&&m!==h){r(m);const v=e.seen.get(m);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=((u=e.external)==null?void 0:u.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&&lt(r.rest,n))}return!1}const $C=(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)},FC={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},nh=(e,t,n,r)=>{const i=n;i.type="string";const{minimum:s,maximum:a,format:o,patterns:u,contentEncoding:c}=e._zod.bag;if(typeof s=="number"&&(i.minLength=s),typeof a=="number"&&(i.maxLength=a),o&&(i.format=FC[o]??o,i.format===""&&delete i.format,o==="time"&&delete i.format),c&&(i.contentEncoding=c),u&&u.size>0){const f=[...u];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}))])}},rh=(e,t,n,r)=>{const i=n,{minimum:s,maximum:a,format:o,multipleOf:u,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 u=="number"&&(i.multipleOf=u)},ih=(e,t,n,r)=>{n.type="boolean"},LC=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema")},ZC=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema")},sh=(e,t,n,r)=>{t.target==="openapi-3.0"?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"},BC=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},VC=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema")},ah=(e,t,n,r)=>{n.not={}},UC=(e,t,n,r)=>{},oh=(e,t,n,r)=>{},JC=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},lh=(e,t,n,r)=>{const i=e._zod.def,s=Dp(i.entries);s.every(a=>typeof a=="number")&&(n.type="number"),s.every(a=>typeof a=="string")&&(n.type="string"),n.enum=s},uh=(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},HC=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema")},WC=(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},qC=(e,t,n,r)=>{const i=n,s={type:"string",format:"binary",contentEncoding:"binary"},{minimum:a,maximum:o,mime:u}=e._zod.bag;a!==void 0&&(s.minLength=a),o!==void 0&&(s.maxLength=o),u?u.length===1?(s.contentMediaType=u[0],Object.assign(i,s)):(Object.assign(i,s),i.anyOf=u.map(c=>({contentMediaType:c}))):Object.assign(i,s)},GC=(e,t,n,r)=>{n.type="boolean"},ch=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},KC=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Function types cannot be represented in JSON Schema")},dh=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},YC=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema")},XC=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema")},fh=(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"]})},ph=(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)),u=new Set([...o].filter(f=>{const d=s.shape[f]._zod;return t.io==="input"?d.optin===void 0:d.optout===void 0}));u.size>0&&(i.required=Array.from(u)),((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)},hh=(e,t,n,r)=>{const i=e._zod.def,s=i.inclusive===!1,a=i.options.map((o,u)=>Be(o,t,{...r,path:[...r.path,s?"oneOf":"anyOf",u]}));s?n.oneOf=a:n.anyOf=a},mh=(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,u=[...o(s)?s.allOf:[s],...o(a)?a.allOf:[a]];n.allOf=u},QC=(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",u=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=u,c&&(i.items=c)):t.target==="openapi-3.0"?(i.items={anyOf:u},c&&i.items.anyOf.push(c),i.minItems=u.length,c||(i.maxItems=u.length)):(i.items=u,c&&(i.additionalItems=c));const{minimum:f,maximum:d}=e._zod.bag;typeof f=="number"&&(i.minItems=f),typeof d=="number"&&(i.maxItems=d)},gh=(e,t,n,r)=>{const i=n,s=e._zod.def;i.type="object";const a=s.keyType,o=a._zod.bag,u=o==null?void 0:o.patterns;if(s.mode==="loose"&&u&&u.size>0){const f=Be(s.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});i.patternProperties={};for(const d of u)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)}},xh=(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"}]},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},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,n.default=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,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},wh=(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},kh=(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},Sh=(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},eN=(e,t,n,r)=>{const i=e._zod.def;Be(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType},To=(e,t,n,r)=>{const i=e._zod.def;Be(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType},_h=(e,t,n,r)=>{const i=e._zod.innerType;Be(i,t,r);const s=t.seen.get(e);s.ref=i},Au={string:nh,number:rh,boolean:ih,bigint:LC,symbol:ZC,null:sh,undefined:BC,void:VC,never:ah,any:UC,unknown:oh,date:JC,enum:lh,literal:uh,nan:HC,template_literal:WC,file:qC,success:GC,custom:ch,function:KC,transform:dh,map:YC,set:XC,array:fh,object:ph,union:hh,intersection:mh,tuple:QC,record:gh,nullable:xh,nonoptional:yh,default:bh,prefault:vh,catch:wh,pipe:kh,readonly:Sh,promise:eN,optional:To,lazy:_h};function tN(e,t){if("_idmap"in e){const r=e,i=Ki({...t,processors:Au}),s={};for(const u of r._idmap.entries()){const[c,f]=u;Be(f,i)}const a={},o={registry:r,uri:t==null?void 0:t.uri,defs:s};i.external=o;for(const u of r._idmap.entries()){const[c,f]=u;Yi(i,f),a[c]=Xi(i,f)}if(Object.keys(s).length>0){const u=i.target==="draft-2020-12"?"$defs":"definitions";a.__shared={[u]:s}}return{schemas:a}}const n=Ki({...t,processors:Au});return Be(e,n),Yi(n,e),Xi(n,e)}const nN=V("ZodISODateTime",(e,t)=>{ij.init(e,t),Ye.init(e,t)});function rN(e){return fC(nN,e)}const iN=V("ZodISODate",(e,t)=>{sj.init(e,t),Ye.init(e,t)});function sN(e){return pC(iN,e)}const aN=V("ZodISOTime",(e,t)=>{aj.init(e,t),Ye.init(e,t)});function oN(e){return hC(aN,e)}const lN=V("ZodISODuration",(e,t)=>{oj.init(e,t),Ye.init(e,t)});function uN(e){return mC(lN,e)}const cN=(e,t)=>{Fp.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>K1(e,n)},flatten:{value:n=>G1(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,Aa,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,Aa,2)}},isEmpty:{get(){return e.issues.length===0}}})},Tt=V("ZodError",cN,{Parent:Error}),dN=No(Tt),fN=Eo(Tt),pN=_s(Tt),jh=js(Tt),hN=Q1(Tt),mN=e_(Tt),gN=t_(Tt),xN=n_(Tt),yN=r_(Tt),bN=i_(Tt),vN=s_(Tt),wN=a_(Tt),He=V("ZodType",(e,t)=>(Je.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Qi(e,"input"),output:Qi(e,"output")}}),e.toJSONSchema=$C(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(bn(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)=>vn(e,n,r),e.brand=()=>e,e.register=(n,r)=>(n.add(e,r),e),e.parse=(n,r)=>dN(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>pN(e,n,r),e.parseAsync=async(n,r)=>fN(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>jh(e,n,r),e.spa=e.safeParseAsync,e.encode=(n,r)=>hN(e,n,r),e.decode=(n,r)=>mN(e,n,r),e.encodeAsync=async(n,r)=>gN(e,n,r),e.decodeAsync=async(n,r)=>xN(e,n,r),e.safeEncode=(n,r)=>yN(e,n,r),e.safeDecode=(n,r)=>bN(e,n,r),e.safeEncodeAsync=async(n,r)=>vN(e,n,r),e.safeDecodeAsync=async(n,r)=>wN(e,n,r),e.refine=(n,r)=>e.check(xE(n,r)),e.superRefine=n=>e.check(yE(n)),e.overwrite=n=>e.check(mr(n)),e.optional=()=>Du(e),e.exactOptional=()=>rE(e),e.nullable=()=>Ru(e),e.nullish=()=>Du(Ru(e)),e.nonoptional=n=>uE(e,n),e.array=()=>gr(e),e.or=n=>ft([e,n]),e.and=n=>YN(e,n),e.transform=n=>Mu(e,tE(n)),e.default=n=>aE(e,n),e.prefault=n=>lE(e,n),e.catch=n=>dE(e,n),e.pipe=n=>Mu(e,n),e.readonly=()=>hE(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)),Ch=V("_ZodString",(e,t)=>{Io.init(e,t),He.init(e,t),e._zod.processJSONSchema=(r,i,s)=>nh(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(kC(...r)),e.includes=(...r)=>e.check(jC(...r)),e.startsWith=(...r)=>e.check(CC(...r)),e.endsWith=(...r)=>e.check(NC(...r)),e.min=(...r)=>e.check(Gi(...r)),e.max=(...r)=>e.check(eh(...r)),e.length=(...r)=>e.check(th(...r)),e.nonempty=(...r)=>e.check(Gi(1,...r)),e.lowercase=r=>e.check(SC(r)),e.uppercase=r=>e.check(_C(r)),e.trim=()=>e.check(IC()),e.normalize=(...r)=>e.check(EC(...r)),e.toLowerCase=()=>e.check(TC()),e.toUpperCase=()=>e.check(zC()),e.slugify=()=>e.check(AC())}),kN=V("ZodString",(e,t)=>{Io.init(e,t),Ch.init(e,t),e.email=n=>e.check(Jj(SN,n)),e.url=n=>e.check(Kj(_N,n)),e.jwt=n=>e.check(dC(FN,n)),e.emoji=n=>e.check(Yj(jN,n)),e.guid=n=>e.check(Eu(Pu,n)),e.uuid=n=>e.check(Hj(_i,n)),e.uuidv4=n=>e.check(Wj(_i,n)),e.uuidv6=n=>e.check(qj(_i,n)),e.uuidv7=n=>e.check(Gj(_i,n)),e.nanoid=n=>e.check(Xj(CN,n)),e.guid=n=>e.check(Eu(Pu,n)),e.cuid=n=>e.check(Qj(NN,n)),e.cuid2=n=>e.check(eC(EN,n)),e.ulid=n=>e.check(tC(IN,n)),e.base64=n=>e.check(lC(RN,n)),e.base64url=n=>e.check(uC(MN,n)),e.xid=n=>e.check(nC(TN,n)),e.ksuid=n=>e.check(rC(zN,n)),e.ipv4=n=>e.check(iC(AN,n)),e.ipv6=n=>e.check(sC(PN,n)),e.cidrv4=n=>e.check(aC(ON,n)),e.cidrv6=n=>e.check(oC(DN,n)),e.e164=n=>e.check(cC($N,n)),e.datetime=n=>e.check(rN(n)),e.date=n=>e.check(sN(n)),e.time=n=>e.check(oN(n)),e.duration=n=>e.check(uN(n))});function ae(e){return Uj(kN,e)}const Ye=V("ZodStringFormat",(e,t)=>{Ke.init(e,t),Ch.init(e,t)}),SN=V("ZodEmail",(e,t)=>{G_.init(e,t),Ye.init(e,t)}),Pu=V("ZodGUID",(e,t)=>{W_.init(e,t),Ye.init(e,t)}),_i=V("ZodUUID",(e,t)=>{q_.init(e,t),Ye.init(e,t)}),_N=V("ZodURL",(e,t)=>{K_.init(e,t),Ye.init(e,t)}),jN=V("ZodEmoji",(e,t)=>{Y_.init(e,t),Ye.init(e,t)}),CN=V("ZodNanoID",(e,t)=>{X_.init(e,t),Ye.init(e,t)}),NN=V("ZodCUID",(e,t)=>{Q_.init(e,t),Ye.init(e,t)}),EN=V("ZodCUID2",(e,t)=>{ej.init(e,t),Ye.init(e,t)}),IN=V("ZodULID",(e,t)=>{tj.init(e,t),Ye.init(e,t)}),TN=V("ZodXID",(e,t)=>{nj.init(e,t),Ye.init(e,t)}),zN=V("ZodKSUID",(e,t)=>{rj.init(e,t),Ye.init(e,t)}),AN=V("ZodIPv4",(e,t)=>{lj.init(e,t),Ye.init(e,t)}),PN=V("ZodIPv6",(e,t)=>{uj.init(e,t),Ye.init(e,t)}),ON=V("ZodCIDRv4",(e,t)=>{cj.init(e,t),Ye.init(e,t)}),DN=V("ZodCIDRv6",(e,t)=>{dj.init(e,t),Ye.init(e,t)}),RN=V("ZodBase64",(e,t)=>{fj.init(e,t),Ye.init(e,t)}),MN=V("ZodBase64URL",(e,t)=>{hj.init(e,t),Ye.init(e,t)}),$N=V("ZodE164",(e,t)=>{mj.init(e,t),Ye.init(e,t)}),FN=V("ZodJWT",(e,t)=>{xj.init(e,t),Ye.init(e,t)}),Nh=V("ZodNumber",(e,t)=>{Gp.init(e,t),He.init(e,t),e._zod.processJSONSchema=(r,i,s)=>rh(e,r,i),e.gt=(r,i)=>e.check(Tu(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(Iu(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(Ou(r)),e.safe=r=>e.check(Ou(r)),e.positive=r=>e.check(Tu(0,r)),e.nonnegative=r=>e.check(ra(0,r)),e.negative=r=>e.check(Iu(0,r)),e.nonpositive=r=>e.check(na(0,r)),e.multipleOf=(r,i)=>e.check(zu(r,i)),e.step=(r,i)=>e.check(zu(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 LN(e){return gC(Nh,e)}const ZN=V("ZodNumberFormat",(e,t)=>{yj.init(e,t),Nh.init(e,t)});function Ou(e){return xC(ZN,e)}const BN=V("ZodBoolean",(e,t)=>{bj.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ih(e,n,r)});function ut(e){return yC(BN,e)}const VN=V("ZodNull",(e,t)=>{vj.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>sh(e,n,r)});function UN(e){return bC(VN,e)}const JN=V("ZodUnknown",(e,t)=>{wj.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>oh()});function Ut(){return vC(JN)}const HN=V("ZodNever",(e,t)=>{kj.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ah(e,n,r)});function Eh(e){return wC(HN,e)}const WN=V("ZodArray",(e,t)=>{Sj.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>fh(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(eh(n,r)),e.length=(n,r)=>e.check(th(n,r)),e.unwrap=()=>e.element});function gr(e,t){return PC(WN,e,t)}const Ih=V("ZodObject",(e,t)=>{jj.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ph(e,n,r,i),ze(e,"shape",()=>t.shape),e.keyof=()=>zh(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Ut()}),e.loose=()=>e.clone({...e._zod.def,catchall:Ut()}),e.strict=()=>e.clone({...e._zod.def,catchall:Eh()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>U1(e,n),e.safeExtend=n=>J1(e,n),e.merge=n=>H1(e,n),e.pick=n=>B1(e,n),e.omit=n=>V1(e,n),e.partial=(...n)=>W1(Ah,e,n[0]),e.required=(...n)=>q1(Ph,e,n[0])});function $e(e,t){const n={type:"object",shape:e??{},...ue(t)};return new Ih(n)}function Ve(e,t){return new Ih({type:"object",shape:e,catchall:Eh(),...ue(t)})}const Th=V("ZodUnion",(e,t)=>{Xp.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>hh(e,n,r,i),e.options=t.options});function ft(e,t){return new Th({type:"union",options:e,...ue(t)})}const qN=V("ZodDiscriminatedUnion",(e,t)=>{Th.init(e,t),Cj.init(e,t)});function GN(e,t,n){return new qN({type:"union",options:t,discriminator:e,...ue(n)})}const KN=V("ZodIntersection",(e,t)=>{Nj.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>mh(e,n,r,i)});function YN(e,t){return new KN({type:"intersection",left:e,right:t})}const XN=V("ZodRecord",(e,t)=>{Ej.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>gh(e,n,r,i),e.keyType=t.keyType,e.valueType=t.valueType});function Yr(e,t,n){return new XN({type:"record",keyType:e,valueType:t,...ue(n)})}const Oa=V("ZodEnum",(e,t)=>{Ij.init(e,t),He.init(e,t),e._zod.processJSONSchema=(r,i,s)=>lh(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 Oa({...t,checks:[],...ue(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 Oa({...t,checks:[],...ue(i),entries:s})}});function zh(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new Oa({type:"enum",entries:n,...ue(t)})}const QN=V("ZodLiteral",(e,t)=>{Tj.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>uh(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 me(e,t){return new QN({type:"literal",values:Array.isArray(e)?e:[e],...ue(t)})}const eE=V("ZodTransform",(e,t)=>{zj.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>dh(e,n),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Pp(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 tE(e){return new eE({type:"transform",transform:e})}const Ah=V("ZodOptional",(e,t)=>{Qp.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>To(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function Du(e){return new Ah({type:"optional",innerType:e})}const nE=V("ZodExactOptional",(e,t)=>{Aj.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>To(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function rE(e){return new nE({type:"optional",innerType:e})}const iE=V("ZodNullable",(e,t)=>{Pj.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 Ru(e){return new iE({type:"nullable",innerType:e})}const sE=V("ZodDefault",(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,e.removeDefault=e.unwrap});function aE(e,t){return new sE({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Mp(t)}})}const oE=V("ZodPrefault",(e,t)=>{Dj.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>vh(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function lE(e,t){return new oE({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Mp(t)}})}const Ph=V("ZodNonOptional",(e,t)=>{Rj.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>yh(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function uE(e,t){return new Ph({type:"nonoptional",innerType:e,...ue(t)})}const cE=V("ZodCatch",(e,t)=>{Mj.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>wh(e,n,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function dE(e,t){return new cE({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const fE=V("ZodPipe",(e,t)=>{$j.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>kh(e,n,r,i),e.in=t.in,e.out=t.out});function Mu(e,t){return new fE({type:"pipe",in:e,out:t})}const pE=V("ZodReadonly",(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.innerType});function hE(e){return new pE({type:"readonly",innerType:e})}const mE=V("ZodLazy",(e,t)=>{Lj.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>_h(e,n,r,i),e.unwrap=()=>e._zod.def.getter()});function gE(e){return new mE({type:"lazy",getter:e})}const zo=V("ZodCustom",(e,t)=>{Zj.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ch(e,n)});function Oh(e,t){return OC(zo,e??(()=>!0),t)}function xE(e,t={}){return DC(zo,e,t)}function yE(e){return RC(e)}function es(e,t={}){const n=new zo({type:"custom",check:"custom",fn:r=>r instanceof e,abort:!0,...ue(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 $u;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})($u||($u={}));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,u=0;for(;u<a.path.length;){const c=a.path[u];u===a.path.length-1?(o[c]=o[c]||{_errors:[]},o[c]._errors.push(n(a))):o[c]=o[c]||{_errors:[]},o=o[c],u++}}};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 Fu;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})(Fu||(Fu={}));var we;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(we||(we={}));class Lu 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 bE(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,u="",c="";function f(v){const S=a?v.replace(/^\xEF\xBB\xBF/,""):v,[x,j]=vE(`${s}${S}`);for(const g of x)d(g);s=j,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),j=v[S+1]===" "?2:1,g=v.slice(S+j);p(x,g,v);return}p(v,"",v)}function p(v,S,x){switch(v){case"event":c=S;break;case"data":u=`${u}${S}
71
+ `;break;case"id":o=S.includes("\0")?void 0:S;break;case"retry":/^\d+$/.test(S)?r(parseInt(S,10)):n(new Lu(`Invalid \`retry\` value: "${S}"`,{type:"invalid-retry",value:S,line:x}));break;default:n(new Lu(`Unknown field "${v.length>20?`${v.slice(0,20)}…`:v}"`,{type:"unknown-field",field:v,value:S,line:x}));break}}function h(){u.length>0&&t({id:o,event:c||void 0,data:u.endsWith(`
72
+ `)?u.slice(0,-1):u}),o=void 0,u="",c=""}function m(v={}){s&&v.consume&&d(s),a=!0,o=void 0,u="",c="",s=""}return{feed:f,reset:m}}function vE(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 wE extends TransformStream{constructor({onError:t,onRetry:n,onComment:r}={}){let i;super({start(s){i=bE({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 P1({argument:"separator",message:`The separator "${r}" must not be part of the alphabet "${n}".`});return()=>`${e}${r}${i()}`},kE=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 SE=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,_E=/"(?: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 Zu(e){const t=JSON.parse(e);return t===null||typeof t!="object"||SE.test(e)===!1&&_E.test(e)===!1?t:jE(t)}function jE(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 CE(e){const{stackTraceLimit:t}=Error;try{Error.stackTraceLimit=0}catch{return Zu(e)}try{return Zu(e)}finally{Error.stackTraceLimit=t}}function Ao(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]=Sn(n[r])}e.items!=null&&(e.items=Array.isArray(e.items)?e.items.map(Sn):Sn(e.items)),e.anyOf!=null&&(e.anyOf=e.anyOf.map(Sn)),e.allOf!=null&&(e.allOf=e.allOf.map(Sn)),e.oneOf!=null&&(e.oneOf=e.oneOf.map(Sn));const{definitions:t}=e;if(t!=null)for(const n of Object.keys(t))t[n]=Sn(t[n]);return e}function Sn(e){return typeof e=="boolean"?e:Ao(e)}var NE=Symbol("Let zodToJsonSchema decide on which parser to use"),Bu={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"},EE=e=>typeof e=="string"?{...Bu,name:e}:{...Bu,...e};function Ct(){return{}}function IE(e,t){var n,r,i;const s={type:"array"};return(n=e.type)!=null&&n._def&&((i=(r=e.type)==null?void 0:r._def)==null?void 0:i.typeName)!==we.ZodAny&&(s.items=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 TE(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 zE(){return{type:"boolean"}}function Dh(e,t){return Re(e.type._def,t)}var AE=(e,t)=>Re(e.innerType._def,t);function Rh(e,t,n){const r=n??t.dateStrategy;if(Array.isArray(r))return{anyOf:r.map((i,s)=>Rh(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 PE(e)}}var PE=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 OE(e,t){return{...Re(e.innerType._def,t),default:e.defaultValue()}}function DE(e,t){return t.effectStrategy==="input"?Re(e.schema._def,t):Ct()}function RE(e){return{type:"string",enum:Array.from(e.values)}}var ME=e=>"type"in e&&e.type==="string"?!1:"allOf"in e;function $E(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(ME(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 FE(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 Mh(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"?ZE(e):e}var LE=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function ZE(e){let t="";for(let n=0;n<e.length;n++)LE.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:Vu(t,r),...n&&r.errorMessages&&{errorMessage:{pattern:n}}})):e.pattern=Vu(t,r)}function Vu(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,u=!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]/)){u?(s+=i[c],s+=`${i[c-2]}-${i[c]}`.toUpperCase(),u=!1):i[c+1]==="-"&&((n=i[c+2])!=null&&n.match(/[a-z]/))?(s+=i[c],u=!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 $h(e,t){var n,r,i,s,a,o;const u={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)===we.ZodString&&((i=e.keyType._def.checks)!=null&&i.length)){const{type:c,...f}=Mh(e.keyType._def,t);return{...u,propertyNames:f}}else{if(((s=e.keyType)==null?void 0:s._def.typeName)===we.ZodEnum)return{...u,propertyNames:{enum:e.keyType._def.values}};if(((a=e.keyType)==null?void 0:a._def.typeName)===we.ZodBranded&&e.keyType._def.type._def.typeName===we.ZodString&&((o=e.keyType._def.type._def.checks)!=null&&o.length)){const{type:c,...f}=Dh(e.keyType._def,t);return{...u,propertyNames:f}}}return u}function BE(e,t){if(t.mapStrategy==="record")return $h(e,t);const n=Re(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||Ct(),r=Re(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||Ct();return{type:"array",maxItems:125,items:{type:"array",items:[n,r],minItems:2,maxItems:2}}}function VE(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 UE(){return{not:Ct()}}function JE(){return{type:"null"}}var Da={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function HE(e,t){const n=e.options instanceof Map?Array.from(e.options.values()):e.options;if(n.every(r=>r._def.typeName in Da&&(!r._def.checks||!r._def.checks.length))){const r=n.reduce((i,s)=>{const a=Da[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 WE(e,t)}var WE=(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 qE(e,t){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return{type:[Da[e.innerType._def.typeName],"null"]};const n=Re(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return n&&{anyOf:[n,{type:"null"}]}}function GE(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 KE(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 u=XE(o),c=Re(o._def,{...t,currentPath:[...t.currentPath,"properties",a],propertyPath:[...t.currentPath,"properties",a]});c!==void 0&&(n.properties[a]=c,u||r.push(a))}r.length&&(n.required=r);const s=YE(e,t);return s!==void 0&&(n.additionalProperties=s),n}function YE(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 XE(e){try{return e.isOptional()}catch{return!0}}var QE=(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:Ct()},r]}:Ct()},eI=(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 tI(e,t){return Re(e.type._def,t)}function nI(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 rI(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 iI(){return{not:Ct()}}function sI(){return Ct()}var aI=(e,t)=>Re(e.innerType._def,t),oI=(e,t,n)=>{switch(t){case we.ZodString:return Mh(e,n);case we.ZodNumber:return GE(e);case we.ZodObject:return KE(e,n);case we.ZodBigInt:return TE(e);case we.ZodBoolean:return zE();case we.ZodDate:return Rh(e,n);case we.ZodUndefined:return iI();case we.ZodNull:return JE();case we.ZodArray:return IE(e,n);case we.ZodUnion:case we.ZodDiscriminatedUnion:return HE(e,n);case we.ZodIntersection:return $E(e,n);case we.ZodTuple:return rI(e,n);case we.ZodRecord:return $h(e,n);case we.ZodLiteral:return FE(e);case we.ZodEnum:return RE(e);case we.ZodNativeEnum:return VE(e);case we.ZodNullable:return qE(e,n);case we.ZodOptional:return QE(e,n);case we.ZodMap:return BE(e,n);case we.ZodSet:return nI(e,n);case we.ZodLazy:return()=>e.getter()._def;case we.ZodPromise:return tI(e,n);case we.ZodNaN:case we.ZodNever:return UE();case we.ZodEffects:return DE(e,n);case we.ZodAny:return Ct();case we.ZodUnknown:return sI();case we.ZodDefault:return OE(e,n);case we.ZodBranded:return Dh(e,n);case we.ZodReadonly:return aI(e,n);case we.ZodCatch:return AE(e,n);case we.ZodPipeline:return eI(e,n);case we.ZodFunction:case we.ZodVoid:case we.ZodSymbol:return;default:return(r=>{})()}},lI=(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 u=(r=t.override)==null?void 0:r.call(t,e,t,i,n);if(u!==NE)return u}if(i&&!n){const u=uI(i,t);if(u!==void 0)return u}const s={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,s);const a=oI(e,e.typeName,t),o=typeof a=="function"?Re(a(),t):a;if(o&&cI(e,t,o),t.postProcess){const u=t.postProcess(o,e,t);return s.jsonSchema=o,u}return s.jsonSchema=o,o}var uI=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:lI(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`),Ct()):t.$refStrategy==="seen"?Ct():void 0}},cI=(e,t,n)=>(e.description&&(n.description=e.description),n),dI=e=>{const t=EE(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}]))}},fI=(e,t)=>{var n;const r=dI(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:Ct()}},{}):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:Ct(),o=typeof t=="object"&&t.name!==void 0&&t.nameStrategy==="title"?t.name:void 0;o!==void 0&&(a.title=o);const u=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 u.$schema="http://json-schema.org/draft-07/schema#",u},Ra=Symbol.for("vercel.ai.schema");function pI(e){let t;return()=>(t==null&&(t=e()),t)}function Ns(e,{validate:t}={}){return{[Ra]:!0,_type:void 0,get jsonSchema(){return typeof e=="function"&&(e=e()),e},validate:t}}function hI(e){return typeof e=="object"&&e!==null&&Ra in e&&e[Ra]===!0&&"jsonSchema"in e&&"validate"in e}function Po(e){return e==null?Ns({properties:{},additionalProperties:!1}):hI(e)?e:"~standard"in e?e["~standard"].vendor==="zod"?Fh(e):mI(e):e()}function mI(e){return Ns(()=>Ao(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 gI(e,t){var n;const r=(n=void 0)!=null?n:!1;return Ns(()=>fI(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 xI(e,t){var n;const r=(n=void 0)!=null?n:!1;return Ns(()=>Ao(tN(e,{target:"draft-7",io:"input",reused:r?"ref":"inline"})),{validate:async i=>{const s=await jh(e,i);return s.success?{success:!0,value:s.data}:{success:!1,error:s.error}}})}function yI(e){return"_zod"in e}function Fh(e,t){return yI(e)?xI(e):gI(e)}async function Uu({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=Po(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=CE(e);return t==null?{success:!0,value:n,rawValue:n}:await Qr({value:n,schema:t})}catch(n){return{success:!1,error:pu.isInstance(n)?n:new pu({text:e,cause:n}),rawValue:void 0}}}function bI({stream:e,schema:t}){return e.pipeThrough(new TextDecoderStream).pipeThrough(new wE).pipeThrough(new TransformStream({async transform({data:n},r){n!=="[DONE]"&&r.enqueue(await Pn({text:n,schema:t}))}}))}async function un(e){return typeof e=="function"&&(e=e()),Promise.resolve(e)}var vI=Object.defineProperty,wI=(e,t)=>{for(var n in t)vI(e,n,{get:t[n],enumerable:!0})},Lh="AI_NoObjectGeneratedError",Zh=`vercel.ai.error.${Lh}`,kI=Symbol.for(Zh),Bh,fn=class extends qt{constructor({message:e="No object generated.",cause:t,text:n,response:r,usage:i,finishReason:s}){super({name:Lh,message:e,cause:t}),this[Bh]=!0,this.text=n,this.response=r,this.usage=i,this.finishReason=s}static isInstance(e){return qt.hasMarker(e,Zh)}};Bh=kI;var Vh="AI_UIMessageStreamError",Uh=`vercel.ai.error.${Vh}`,SI=Symbol.for(Uh),Jh,Vn=class extends qt{constructor({chunkType:e,chunkId:t,message:n}){super({name:Vh,message:n}),this[Jh]=!0,this.chunkType=e,this.chunkId=t}static isInstance(e){return qt.hasMarker(e,Uh)}};Jh=SI;var Hh=ft([ae(),es(Uint8Array),es(ArrayBuffer),Oh(e=>{var t,n;return(n=(t=globalThis.Buffer)==null?void 0:t.isBuffer(e))!=null?n:!1},{message:"Must be a Buffer"})]),ei=gE(()=>ft([UN(),ae(),LN(),ut(),Yr(ae(),ei.optional()),gr(ei)])),Ee=Yr(ae(),Yr(ae(),ei.optional())),Wh=$e({type:me("text"),text:ae(),providerOptions:Ee.optional()}),_I=$e({type:me("image"),image:ft([Hh,es(URL)]),mediaType:ae().optional(),providerOptions:Ee.optional()}),qh=$e({type:me("file"),data:ft([Hh,es(URL)]),filename:ae().optional(),mediaType:ae(),providerOptions:Ee.optional()}),jI=$e({type:me("reasoning"),text:ae(),providerOptions:Ee.optional()}),CI=$e({type:me("tool-call"),toolCallId:ae(),toolName:ae(),input:Ut(),providerOptions:Ee.optional(),providerExecuted:ut().optional()}),NI=GN("type",[$e({type:me("text"),value:ae(),providerOptions:Ee.optional()}),$e({type:me("json"),value:ei,providerOptions:Ee.optional()}),$e({type:me("execution-denied"),reason:ae().optional(),providerOptions:Ee.optional()}),$e({type:me("error-text"),value:ae(),providerOptions:Ee.optional()}),$e({type:me("error-json"),value:ei,providerOptions:Ee.optional()}),$e({type:me("content"),value:gr(ft([$e({type:me("text"),text:ae(),providerOptions:Ee.optional()}),$e({type:me("media"),data:ae(),mediaType:ae()}),$e({type:me("file-data"),data:ae(),mediaType:ae(),filename:ae().optional(),providerOptions:Ee.optional()}),$e({type:me("file-url"),url:ae(),providerOptions:Ee.optional()}),$e({type:me("file-id"),fileId:ft([ae(),Yr(ae(),ae())]),providerOptions:Ee.optional()}),$e({type:me("image-data"),data:ae(),mediaType:ae(),providerOptions:Ee.optional()}),$e({type:me("image-url"),url:ae(),providerOptions:Ee.optional()}),$e({type:me("image-file-id"),fileId:ft([ae(),Yr(ae(),ae())]),providerOptions:Ee.optional()}),$e({type:me("custom"),providerOptions:Ee.optional()})]))})]),Gh=$e({type:me("tool-result"),toolCallId:ae(),toolName:ae(),output:NI,providerOptions:Ee.optional()}),EI=$e({type:me("tool-approval-request"),approvalId:ae(),toolCallId:ae()}),II=$e({type:me("tool-approval-response"),approvalId:ae(),approved:ut(),reason:ae().optional()}),TI=$e({role:me("system"),content:ae(),providerOptions:Ee.optional()}),zI=$e({role:me("user"),content:ft([ae(),gr(ft([Wh,_I,qh]))]),providerOptions:Ee.optional()}),AI=$e({role:me("assistant"),content:ft([ae(),gr(ft([Wh,qh,jI,CI,Gh,EI]))]),providerOptions:Ee.optional()}),PI=$e({role:me("tool"),content:gr(ft([Gh,II])),providerOptions:Ee.optional()});ft([TI,zI,AI,PI]);function Kh(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]=Kh(s,i):n[r]=i}return n}var OI={};wI(OI,{array:()=>$I,choice:()=>FI,json:()=>LI,object:()=>MI,text:()=>RI});function DI(e){const t=["ROOT"];let n=-1,r=null;function i(u,c,f){switch(u){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(u,c){switch(u){case",":{t.pop(),t.push("INSIDE_OBJECT_AFTER_COMMA");break}case"}":{n=c,t.pop();break}}}function a(u,c){switch(u){case",":{t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{n=c,t.pop();break}}}for(let u=0;u<e.length;u++){const c=e[u];switch(t[t.length-1]){case"ROOT":i(c,u,"FINISH");break;case"INSIDE_OBJECT_START":{switch(c){case'"':{t.pop(),t.push("INSIDE_OBJECT_KEY");break}case"}":{n=u,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,u,"INSIDE_OBJECT_AFTER_VALUE");break}case"INSIDE_OBJECT_AFTER_VALUE":{s(c,u);break}case"INSIDE_STRING":{switch(c){case'"':{t.pop(),n=u;break}case"\\":{t.push("INSIDE_STRING_ESCAPE");break}default:n=u}break}case"INSIDE_ARRAY_START":{switch(c){case"]":{n=u,t.pop();break}default:{n=u,i(c,u,"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=u,t.pop();break}default:{n=u;break}}break}case"INSIDE_ARRAY_AFTER_COMMA":{i(c,u,"INSIDE_ARRAY_AFTER_VALUE");break}case"INSIDE_STRING_ESCAPE":{t.pop(),n=u;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=u;break}case"e":case"E":case"-":case".":break;case",":{t.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&a(c,u),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&s(c,u);break}case"}":{t.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&s(c,u);break}case"]":{t.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&a(c,u);break}default:{t.pop();break}}break}case"INSIDE_LITERAL":{const d=e.substring(r,u+1);!"false".startsWith(d)&&!"true".startsWith(d)&&!"null".startsWith(d)?(t.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"?s(c,u):t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&a(c,u)):n=u;break}}}let o=e.slice(0,n+1);for(let u=t.length-1;u>=0;u--)switch(t[u]){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:DI(e)}),t.success?{value:t.value,state:"repaired-parse"}:{value:void 0,state:"failed-parse"})}var RI=()=>({name:"text",responseFormat:Promise.resolve({type:"text"}),async parseCompleteOutput({text:e}){return e},async parsePartialOutput({text:e}){return{partial:e}},createElementStreamTransform(){}}),MI=({schema:e,name:t,description:n})=>{const r=Po(e);return{name:"object",responseFormat:un(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 fn({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 fn({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(){}}},$I=({element:e,name:t,description:n})=>{const r=Po(e);return{name:"array",responseFormat:un(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 fn({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 fn({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 u of o.elements){const c=await Qr({value:u,schema:r});if(!c.success)throw new fn({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,u=[];for(const c of o){const f=await Qr({value:c,schema:r});f.success&&u.push(f.value)}return{partial:u}}}},createElementStreamTransform(){let i=0;return new TransformStream({transform({partialOutput:s},a){if(s!=null)for(;i<s.length;i++)a.enqueue(s[i])}})}}},FI=({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 fn({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 fn({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(){}}),LI=({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 fn({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 ZI=pI(()=>Fh(ft([Ve({type:me("text-start"),id:ae(),providerMetadata:Ee.optional()}),Ve({type:me("text-delta"),id:ae(),delta:ae(),providerMetadata:Ee.optional()}),Ve({type:me("text-end"),id:ae(),providerMetadata:Ee.optional()}),Ve({type:me("error"),errorText:ae()}),Ve({type:me("tool-input-start"),toolCallId:ae(),toolName:ae(),providerExecuted:ut().optional(),providerMetadata:Ee.optional(),dynamic:ut().optional(),title:ae().optional()}),Ve({type:me("tool-input-delta"),toolCallId:ae(),inputTextDelta:ae()}),Ve({type:me("tool-input-available"),toolCallId:ae(),toolName:ae(),input:Ut(),providerExecuted:ut().optional(),providerMetadata:Ee.optional(),dynamic:ut().optional(),title:ae().optional()}),Ve({type:me("tool-input-error"),toolCallId:ae(),toolName:ae(),input:Ut(),providerExecuted:ut().optional(),providerMetadata:Ee.optional(),dynamic:ut().optional(),errorText:ae(),title:ae().optional()}),Ve({type:me("tool-approval-request"),approvalId:ae(),toolCallId:ae()}),Ve({type:me("tool-output-available"),toolCallId:ae(),output:Ut(),providerExecuted:ut().optional(),providerMetadata:Ee.optional(),dynamic:ut().optional(),preliminary:ut().optional()}),Ve({type:me("tool-output-error"),toolCallId:ae(),errorText:ae(),providerExecuted:ut().optional(),providerMetadata:Ee.optional(),dynamic:ut().optional()}),Ve({type:me("tool-output-denied"),toolCallId:ae()}),Ve({type:me("reasoning-start"),id:ae(),providerMetadata:Ee.optional()}),Ve({type:me("reasoning-delta"),id:ae(),delta:ae(),providerMetadata:Ee.optional()}),Ve({type:me("reasoning-end"),id:ae(),providerMetadata:Ee.optional()}),Ve({type:me("source-url"),sourceId:ae(),url:ae(),title:ae().optional(),providerMetadata:Ee.optional()}),Ve({type:me("source-document"),sourceId:ae(),mediaType:ae(),title:ae(),filename:ae().optional(),providerMetadata:Ee.optional()}),Ve({type:me("file"),url:ae(),mediaType:ae(),providerMetadata:Ee.optional()}),Ve({type:Oh(e=>typeof e=="string"&&e.startsWith("data-"),{message:'Type must start with "data-"'}),id:ae().optional(),data:Ut(),transient:ut().optional()}),Ve({type:me("start-step")}),Ve({type:me("finish-step")}),Ve({type:me("start"),messageId:ae().optional(),messageMetadata:Ut().optional()}),Ve({type:me("finish"),finishReason:zh(["stop","length","content-filter","tool-calls","error","other"]).optional(),messageMetadata:Ut().optional()}),Ve({type:me("abort"),reason:ae().optional()}),Ve({type:me("message-metadata"),messageMetadata:Ut()})])));function BI(e){return e.type.startsWith("data-")}function Ma(e){return e.type.startsWith("tool-")}function VI(e){return e.type==="dynamic-tool"}function ns(e){return Ma(e)||VI(e)}function Ju(e){return e.type.split("-").slice(1).join("-")}function UI({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 JI({stream:e,messageMetadataSchema:t,dataPartSchemas:n,runUpdateMessageJob:r,onError:i,onToolCall:s,onData:a}){return e.pipeThrough(new TransformStream({async transform(o,u){await r(async({state:c,write:f})=>{var d,p,h,m;function v(g){const E=c.message.parts.filter(ns).find(k=>k.toolCallId===g);if(E==null)throw new Vn({chunkType:"tool-invocation",chunkId:g,message:`No tool invocation found for tool call ID "${g}".`});return E}function S(g){var I;const E=c.message.parts.find(J=>Ma(J)&&J.toolCallId===g.toolCallId),k=g,N=E;if(E!=null){E.state=g.state,N.input=k.input,N.output=k.output,N.errorText=k.errorText,N.rawInput=k.rawInput,N.preliminary=k.preliminary,g.title!==void 0&&(N.title=g.title),N.providerExecuted=(I=k.providerExecuted)!=null?I:E.providerExecuted;const J=k.providerMetadata;if(J!=null)if(g.state==="output-available"||g.state==="output-error"){const L=E;L.resultProviderMetadata=J}else E.callProviderMetadata=J}else c.message.parts.push({type:`tool-${g.toolName}`,toolCallId:g.toolCallId,state:g.state,title:g.title,input:k.input,output:k.output,rawInput:k.rawInput,errorText:k.errorText,providerExecuted:k.providerExecuted,preliminary:k.preliminary,...k.providerMetadata!=null&&(g.state==="output-available"||g.state==="output-error")?{resultProviderMetadata:k.providerMetadata}:{},...k.providerMetadata!=null&&!(g.state==="output-available"||g.state==="output-error")?{callProviderMetadata:k.providerMetadata}:{}})}function x(g){var I,E;const k=c.message.parts.find(L=>L.type==="dynamic-tool"&&L.toolCallId===g.toolCallId),N=g,J=k;if(k!=null){k.state=g.state,J.toolName=g.toolName,J.input=N.input,J.output=N.output,J.errorText=N.errorText,J.rawInput=(I=N.rawInput)!=null?I:J.rawInput,J.preliminary=N.preliminary,g.title!==void 0&&(J.title=g.title),J.providerExecuted=(E=N.providerExecuted)!=null?E:k.providerExecuted;const L=N.providerMetadata;if(L!=null)if(g.state==="output-available"||g.state==="output-error"){const C=k;C.resultProviderMetadata=L}else k.callProviderMetadata=L}else c.message.parts.push({type:"dynamic-tool",toolName:g.toolName,toolCallId:g.toolCallId,state:g.state,input:N.input,output:N.output,errorText:N.errorText,preliminary:N.preliminary,providerExecuted:N.providerExecuted,title:g.title,...N.providerMetadata!=null&&(g.state==="output-available"||g.state==="output-error")?{resultProviderMetadata:N.providerMetadata}:{},...N.providerMetadata!=null&&!(g.state==="output-available"||g.state==="output-error")?{callProviderMetadata:N.providerMetadata}:{}})}async function j(g){if(g!=null){const I=c.message.metadata!=null?Kh(c.message.metadata,g):g;t!=null&&await Uu({value:I,schema:t,context:{field:"message.metadata",entityId:c.message.id}}),c.message.metadata=I}}switch(o.type){case"text-start":{const g={type:"text",text:"",providerMetadata:o.providerMetadata,state:"streaming"};c.activeTextParts[o.id]=g,c.message.parts.push(g),f();break}case"text-delta":{const g=c.activeTextParts[o.id];if(g==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.`});g.text+=o.delta,g.providerMetadata=(d=o.providerMetadata)!=null?d:g.providerMetadata,f();break}case"text-end":{const g=c.activeTextParts[o.id];if(g==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.`});g.state="done",g.providerMetadata=(p=o.providerMetadata)!=null?p:g.providerMetadata,delete c.activeTextParts[o.id],f();break}case"reasoning-start":{const g={type:"reasoning",text:"",providerMetadata:o.providerMetadata,state:"streaming"};c.activeReasoningParts[o.id]=g,c.message.parts.push(g),f();break}case"reasoning-delta":{const g=c.activeReasoningParts[o.id];if(g==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.`});g.text+=o.delta,g.providerMetadata=(h=o.providerMetadata)!=null?h:g.providerMetadata,f();break}case"reasoning-end":{const g=c.activeReasoningParts[o.id];if(g==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.`});g.providerMetadata=(m=o.providerMetadata)!=null?m:g.providerMetadata,g.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 g=c.message.parts.filter(Ma);c.partialToolCalls[o.toolCallId]={text:"",toolName:o.toolName,index:g.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 g=c.partialToolCalls[o.toolCallId];if(g==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.`});g.text+=o.inputTextDelta;const{value:I}=await di(g.text);g.dynamic?x({toolCallId:o.toolCallId,toolName:g.toolName,state:"input-streaming",input:I,title:g.title}):S({toolCallId:o.toolCallId,toolName:g.toolName,state:"input-streaming",input:I,title:g.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 g=c.message.parts.filter(ns).find(E=>E.toolCallId===o.toolCallId);(g!=null?g.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 g=v(o.toolCallId);g.state="approval-requested",g.approval={id:o.approvalId},f();break}case"tool-output-denied":{const g=v(o.toolCallId);g.state="output-denied",f();break}case"tool-output-available":{const g=v(o.toolCallId);g.type==="dynamic-tool"?x({toolCallId:o.toolCallId,toolName:g.toolName,state:"output-available",input:g.input,output:o.output,preliminary:o.preliminary,providerExecuted:o.providerExecuted,providerMetadata:o.providerMetadata,title:g.title}):S({toolCallId:o.toolCallId,toolName:Ju(g),state:"output-available",input:g.input,output:o.output,providerExecuted:o.providerExecuted,preliminary:o.preliminary,providerMetadata:o.providerMetadata,title:g.title}),f();break}case"tool-output-error":{const g=v(o.toolCallId);g.type==="dynamic-tool"?x({toolCallId:o.toolCallId,toolName:g.toolName,state:"output-error",input:g.input,errorText:o.errorText,providerExecuted:o.providerExecuted,providerMetadata:o.providerMetadata,title:g.title}):S({toolCallId:o.toolCallId,toolName:Ju(g),state:"output-error",input:g.input,rawInput:g.rawInput,errorText:o.errorText,providerExecuted:o.providerExecuted,providerMetadata:o.providerMetadata,title:g.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 j(o.messageMetadata),(o.messageId!=null||o.messageMetadata!=null)&&f();break}case"finish":{o.finishReason!=null&&(c.finishReason=o.finishReason),await j(o.messageMetadata),o.messageMetadata!=null&&f();break}case"message-metadata":{await j(o.messageMetadata),o.messageMetadata!=null&&f();break}case"error":{i==null||i(new Error(o.errorText));break}default:if(BI(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),k=E>=0?E:c.message.parts.length;await Uu({value:o.data,schema:n[o.type],context:{field:`message.parts[${k}].data`,entityName:o.type,entityId:o.id}})}const g=o;if(g.transient){a==null||a(g);break}const I=g.id!=null?c.message.parts.find(E=>g.type===E.type&&g.id===E.id):void 0;I!=null?I.data=g.data:c.message.parts.push(g),a==null||a(g),f()}}u.enqueue(o)})}}))}async function HI({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 WI=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 qI(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=u=>{var c;s((c=u.target)==null?void 0:c.result)},o.onerror=u=>a(u),o.readAsDataURL(t)});return{type:"file",mediaType:r,filename:n,url:i}}))}var GI=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 un(this.body),u=await un(this.headers),c=await un(this.credentials),f={...Bn(u),...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,m=(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(m),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 un(this.body),o=await un(this.headers),u=await un(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:u,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:u,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)}},Yh=class extends GI{constructor(e={}){super(e)}processResponseStream(e){return bI({stream:e,schema:ZI}).pipeThrough(new TransformStream({async transform(t,n){if(!t.success)throw t.error;n.enqueue(t.value)}}))}},KI=class{constructor({generateId:e=kE,id:t=e(),transport:n=new Yh,messageMetadataSchema:r,dataPartSchemas:i,state:s,onError:a,onToolCall:o,onFinish:u,onData:c,sendAutomaticallyWhen:f}){this.activeResponse=void 0,this.jobExecutor=new WI,this.sendMessage=async(d,p)=>{var h,m,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 qI(d.files),..."text"in d&&d.text!=null?[{type:"text",text:d.text}]:[]]}:x=d,d.messageId!=null){const j=this.state.messages.findIndex(g=>g.id===d.messageId);if(j===-1)throw new Error(`message with id ${d.messageId} not found`);if(this.state.messages[j].role!=="user")throw new Error(`message with id ${d.messageId} is not a user message`);this.state.messages=this.state.messages.slice(0,j+1),this.state.replaceMessage(j,{...x,id:d.messageId,role:(m=x.role)!=null?m:"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(m=>m.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:m})=>this.jobExecutor.run(async()=>{const v=this.state.messages,S=v[v.length-1],x=j=>ns(j)&&j.state==="approval-requested"&&j.approval.id===d?{...j,state:"approval-responded",approval:{id:d,approved:p,reason:h}}:j;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(j=>{var g;j&&this.makeRequest({trigger:"submit-message",messageId:(g=this.lastMessage)==null?void 0:g.id,...m})})}),this.addToolOutput=async({state:d="output-available",toolCallId:p,output:h,errorText:m,options:v})=>this.jobExecutor.run(async()=>{const S=this.state.messages,x=S[S.length-1],j=g=>ns(g)&&g.toolCallId===p?{...g,state:d,output:h,errorText:m}:g;this.state.replaceMessage(S.length-1,{...x,parts:x.parts.map(j)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(j)),this.status!=="streaming"&&this.status!=="submitted"&&this.sendAutomaticallyWhen&&this.shouldSendAutomatically().then(g=>{var I;g&&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=u,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 u;if(e==="resume-stream")try{const h=await this.transport.reconnectToStream({chatId:this.id,metadata:t,headers:n,body:r});if(h==null)return;u=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:UI({lastMessage:this.state.snapshot(c),messageId:this.generateId()}),abortController:new AbortController};h.abortController.signal.addEventListener("abort",()=>{f=!0}),this.activeResponse=h;let m;e==="resume-stream"?m=u:m=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 HI({stream:JI({stream:m,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,Hu;function YI(){if(Hu)return oa;Hu=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(),u=o-i,c=n-u;c<=0?(i=o,t.apply(this,a)):r=setTimeout(()=>{i=Date.now(),t.apply(this,a)},c)}}return oa=e,oa}var XI=YI();const QI=Ba(XI);var Xh=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},Ue=(e,t,n)=>(Xh(e,t,"read from private field"),n?n.call(e):t.get(e)),Zt=(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)},ln=(e,t,n,r)=>(Xh(e,t,"write to private field"),t.set(e,n),n);function eT(e,t){return t!=null?QI(e,t):e}var Nt,Ti,zi,Tr,zr,Ar,Wn,$a,Fa,tT=class{constructor(e=[]){Zt(this,Nt,void 0),Zt(this,Ti,"ready"),Zt(this,zi,void 0),Zt(this,Tr,new Set),Zt(this,zr,new Set),Zt(this,Ar,new Set),this.pushMessage=t=>{ln(this,Nt,Ue(this,Nt).concat(t)),Ue(this,Wn).call(this)},this.popMessage=()=>{ln(this,Nt,Ue(this,Nt).slice(0,-1)),Ue(this,Wn).call(this)},this.replaceMessage=(t,n)=>{ln(this,Nt,[...Ue(this,Nt).slice(0,t),this.snapshot(n),...Ue(this,Nt).slice(t+1)]),Ue(this,Wn).call(this)},this.snapshot=t=>structuredClone(t),this["~registerMessagesCallback"]=(t,n)=>{const r=n?eT(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)}),Zt(this,Wn,()=>{Ue(this,Tr).forEach(t=>t())}),Zt(this,$a,()=>{Ue(this,zr).forEach(t=>t())}),Zt(this,Fa,()=>{Ue(this,Ar).forEach(t=>t())}),ln(this,Nt,e)}get status(){return Ue(this,Ti)}set status(e){ln(this,Ti,e),Ue(this,$a).call(this)}get error(){return Ue(this,zi)}set error(e){ln(this,zi,e),Ue(this,Fa).call(this)}get messages(){return Ue(this,Nt)}set messages(e){ln(this,Nt,[...e]),Ue(this,Wn).call(this)}};Nt=new WeakMap;Ti=new WeakMap;zi=new WeakMap;Tr=new WeakMap;zr=new WeakMap;Ar=new WeakMap;Wn=new WeakMap;$a=new WeakMap;Fa=new WeakMap;var qn,Wu=class extends KI{constructor({messages:e,...t}){const n=new tT(e);super({...t,state:n}),Zt(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),ln(this,qn,n)}};qn=new WeakMap;function nT({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,m;return(m=(h=r.current).onToolCall)==null?void 0:m.call(h,p)},onData:p=>{var h,m;return(m=(h=r.current).onData)==null?void 0:m.call(h,p)},onFinish:p=>{var h,m;return(m=(h=r.current).onFinish)==null?void 0:m.call(h,p)},onError:p=>{var h,m;return(m=(h=r.current).onError)==null?void 0:m.call(h,p)},sendAutomaticallyWhen:p=>{var h,m,v;return(v=(m=(h=r.current).sendAutomaticallyWhen)==null?void 0:m.call(h,p))!=null?v:!1}},s=b.useRef("chat"in n?n.chat:new Wu(i));("chat"in n&&n.chat!==s.current||"id"in n&&s.current.id!==n.id)&&(s.current="chat"in n?n.chat:new Wu(i));const o=b.useCallback(p=>s.current["~registerMessagesCallback"](p,e),[e,s.current.id]),u=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:u,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 Qh(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 em(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 tm(e,t,n){if(!(n!=null&&n.selectedText)){const i=rT(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 u;if(o===-1)u=s;else if(n.startLine&&n.startLine>0){const d=uT(e,n.startLine);u=cT(e,i,d)}else u=s;const c=e.slice(0,u),f=e.slice(u+i.length);return{original:e,modified:c+t+f}}if(n.startLine&&n.endLine){const o=oT(e,t,n.startLine,n.endLine);if(o)return o}const a=qu(e,t);return a||{original:e,modified:t}}const r=qu(e,t);return r||{original:e,modified:t}}function rT(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(!La(i,r,n))return null;const o=JSON.stringify(i,null,a);return{original:e,modified:o}}function La(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(La(i,t,n))return!0}return!1}if(e&&typeof e=="object"){for(const r of Object.values(e))if(La(r,t,n))return!0}return!1}function qu(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(","),u=Object.keys(a).sort().join(",");if(o===u)return null}}catch{}}catch{}const n=iT(t);if(n.length===0)return null;let r=e,i=!1;for(const s of n){const a=sT(r,t,s);a&&(r=a,i=!0)}return i?{original:e,modified:r}:null}function iT(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 sT(e,t,n){const r=`"${n}"`,i=Gu(e,r);if(i.length===0)return null;const s=Gu(t,r);if(s.length===0)return null;const a=s[0],o=t.slice(a.start,a.end);let u=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=lT(p,o);h>f&&(f=h,u=d)}}const c=i[u];return e.slice(0,c.start)+o+e.slice(c.end)}function Gu(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 u=o+1,c=aT(e,u);if(c===-1){r=i+1;continue}n.push({start:i,end:c}),r=c}return n}function aT(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,u=!1;for(;o<e.length&&a>0;){if(e[o]==="\\"&&u){o+=2;continue}e[o]==='"'&&(u=!u),u||(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 oT(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 lT(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 uT(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 cT(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 dT(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 fT(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=Qh(r.props.templates||[],i.templates);else return null;return{original:e,modified:JSON.stringify(r,null,2)}}catch{return null}}function pT(){const e=De(G=>G.threads),t=De(G=>G.activeThreadId),n=De(G=>G.updateThreadMessages),r=De(G=>G.updateThreadTitle),i=De(G=>G.clearContext),s=De(G=>G.contextAttachments),a=De(G=>G.scope),o=De(G=>G.model),u=Oe(G=>G.activeTab),c=Oe(G=>G.documents),f=Oe(G=>G.documentTypes),d=Oe(G=>G.setPendingDiff),p=Oe(G=>G.createDocument),h=Oe(G=>G.openDocument),m=b.useRef(e);m.current=e;const v=b.useRef(u);v.current=u;const S=b.useRef(c);S.current=c;const x=b.useRef(f);x.current=f;const j=b.useRef(t);j.current=t;const g=u?t[u]:void 0,I=b.useRef(g);I.current=g;const E=b.useRef([]),k=b.useRef([]),N=b.useRef({}),J=b.useRef({}),[,L]=b.useState(0),C=b.useCallback(()=>L(G=>G+1),[]),z=b.useRef(null);z.current||(z.current=new Yh({api:"/api/ai/chat"}));const A=b.useCallback(()=>{const G=S.current.find(B=>B.name===v.current);return G?{name:G.name,text:G.text}:void 0},[]),M=b.useCallback(G=>N.current[G]||[],[]),$=nT({transport:z.current,onError:()=>{E.current.shift(),k.current.shift(),i()},onFinish:({messages:G})=>{var W,Z;const B=I.current;if(B){n(B,G);const se=m.current[B];if(se&&se.title.startsWith("Chat ")){const re=G.find(ne=>ne.role==="user");if(re){const ne=((W=re.parts)==null?void 0:W.filter(de=>de.type==="text").map(de=>de.text).join(""))||"";if(ne){const de=ne.length>50?ne.slice(0,50)+"...":ne;r(B,de)}}}}const ie=E.current.shift()||[],w=k.current.shift()||"global",le=G.filter(se=>se.role==="user"),q=le[le.length-1];q!=null&&q.id&&(N.current[q.id]=ie,J.current[q.id]=w);const y=G.filter(se=>se.role==="assistant").pop();if(y){const re=[...(((Z=y.parts)==null?void 0:Z.filter(ne=>ne.type==="text").map(ne=>ne.text).join(""))||"").matchAll(/```(?:json|jsonc)\s*\n([\s\S]*?)```/g)];if(re.length>0){const ne=dT(re);if(ne){const de=re[re.length-1][1],ge=v.current;if(ge){const Ne=S.current.find(ve=>ve.name===ge),be=(Ne==null?void 0:Ne.text)||"",xe=ie[0],U=fT(be,ne,w);!U&&w!=="global"&&console.warn(`[chat] scopedMerge failed for scope="${w}", falling back to text merge`);const{original:Ae,modified:X}=U??tm(be,ne,xe);d(ge,Ae,X,em(de.replace(/\n$/,"")))}else{const Ne=`ai-generated-${Date.now()}`;p(Ne,ne),h(Ne)}}}}i()}});b.useEffect(()=>{const G=$.messages.filter(B=>B.role==="user");for(let B=G.length-1;B>=0;B--){const ie=G[B].id;if(ie in N.current)break;E.current.length>0&&(N.current[ie]=E.current[0],J.current[ie]=k.current[0]||"global",C());break}},[$.messages,C]);const F=b.useCallback((G,B)=>{E.current.push([...s]),k.current.push(a),i();const ie={text:G};B!=null&&B.length&&(ie.files=B),$.sendMessage(ie,{body:{format:yt,context:s,activeDocument:A(),documentType:v.current&&x.current[v.current]||"application/json+report",scope:a,model:o}})},[$.sendMessage,s,A,i,a,o]),P=b.useCallback(G=>J.current[G],[]);return{messages:$.messages,sendMessage:F,status:$.status,error:$.error,setMessages:$.setMessages,stop:$.stop,getMessageContext:M,getMessageScope:P}}const nm=b.createContext(null);function hT({children:e}){const t=pT();return l.jsx(nm.Provider,{value:t,children:e})}function mT(){const e=b.useContext(nm);if(!e)throw new Error("useChatSessionContext must be used within ChatSessionProvider");return e}function gT(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 xT(e,t=50){const n=e.replace(/[\n\r]+/g," ").replace(/\s+/g," ").trim();return n.length>t?n.slice(0,t)+"…":n}function rm({context:e,onRemove:t,variant:n="default"}){var c;const r=gT(e),i=((c=e.documentName)==null?void 0:c.replace(/\.json$/,""))??"",s=i?`${i} › ${r}`:r,a=xT(e.selectedText),o=n==="sent",u=l.jsxs("div",{className:`group flex items-center gap-1.5 rounded-md border pl-2 ${t?"pr-1":"pr-2"} py-1 text-xs max-w-[280px] transition-colors ${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:[l.jsx(fg,{className:`h-3 w-3 shrink-0 ${o?"text-primary-foreground/60":"text-primary/60"}`}),l.jsx("span",{className:"truncate font-medium",children:s}),t&&l.jsx("button",{type:"button",onClick:t,className:"shrink-0 rounded-sm p-0.5 opacity-60 hover:opacity-100 hover:bg-muted transition-opacity cursor-pointer","aria-label":"Remove context",children:l.jsx(pn,{className:"h-3 w-3"})})]});return l.jsxs(We,{children:[l.jsx(qe,{asChild:!0,children:u}),l.jsxs(Ge,{side:"top",className:"max-w-xs",children:[l.jsx("p",{className:"text-xs font-medium mb-0.5",children:s}),l.jsx("p",{className:"text-xs text-muted-foreground font-mono",children:a}),e.jsonPath&&l.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 im=32,yT=10,sm=9,am=13,bT=160,vT=6158,wT=8192,kT=8203,ST=8239,_T=8287,jT=12288,CT=65279;function NT(e){return/^[0-9A-Fa-f]$/.test(e)}function _n(e){return e>="0"&&e<="9"}function ET(e){return e>=" "}function ji(e){return`,:[]/{}()
92
+ +`.includes(e)}function Ku(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"||e==="_"||e==="$"}function Yu(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"||e==="_"||e==="$"||e>="0"&&e<="9"}const Xu=/^(http|https|ftp|mailto|file|data|irc):\/\/$/,Qu=/^[A-Za-z0-9-._~:/?#@!$&'()*+;=]$/;function ec(e){return`,[]/{}
93
+ +`.includes(e)}function tc(e){return Ai(e)||IT.test(e)}const IT=/^[[{\w-]$/;function TT(e){return e===`
94
+ `||e==="\r"||e===" "||e==="\b"||e==="\f"}function jn(e,t){const n=e.charCodeAt(t);return n===im||n===yT||n===sm||n===am}function zT(e,t){const n=e.charCodeAt(t);return n===im||n===sm||n===am}function AT(e,t){const n=e.charCodeAt(t);return n===bT||n===vT||n>=wT&&n<=kT||n===ST||n===_T||n===jT||n===CT}function Ai(e){return om(e)||Za(e)}function om(e){return e==='"'||e==="“"||e==="”"}function nc(e){return e==='"'}function Za(e){return e==="'"||e==="‘"||e==="’"||e==="`"||e==="´"}function rc(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(!jn(e,n-1))return e+t;for(;jn(e,n-1);)n--;return e.substring(0,n)+t+e.substring(n)}function PT(e,t,n){return e.substring(0,t)+e.substring(t+n)}function OT(e){return/[,\n][ \t\r]*$/.test(e)}const DT={"\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t"},RT={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:`
95
+ `,r:"\r",t:" "};function ic(e){let t=0,n="";c(["```","[```","{```"]),s()||$(),c(["```","```]","```}"]);const i=d(",");for(i&&a(),tc(e[t])&&OT(n)?(i||(n=Pt(n,",")),x()):i&&(n=jr(n,","));e[t]==="}"||e[t]==="]";)t++,a();if(t>=e.length)return n;M();function s(){a();const B=v()||S()||j()||I()||E()||N(!1)||J();return a(),B}function a(){let B=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;const ie=t;let w=o(B);do w=u(),w&&(w=o(B));while(w);return t>ie}function o(B){const ie=B?jn:zT;let w="";for(;;)if(ie(e,t))w+=e[t],t++;else if(AT(e,t))w+=" ",t++;else break;return w.length>0?(n+=w,!0):!1}function u(){if(e[t]==="/"&&e[t+1]==="*"){for(;t<e.length&&!MT(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(B){if(f(B)){if(Ku(e[t]))for(;t<e.length&&Yu(e[t]);)t++;return a(),!0}return!1}function f(B){o(!0);for(const ie of B){const w=t+ie.length;if(e.slice(t,w)===ie)return t=w,!0}return!1}function d(B){return e[t]===B?(n+=e[t],t++,!0):!1}function p(B){return e[t]===B?(t++,!0):!1}function h(){return p("\\")}function m(){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 B=!0;for(;t<e.length&&e[t]!=="}";){let ie;if(B?(ie=!0,B=!1):(ie=d(","),ie||(n=Pt(n,",")),a()),m(),!(j()||N(!0))){e[t]==="}"||e[t]==="{"||e[t]==="]"||e[t]==="["||e[t]===void 0?n=jr(n,","):F();break}a();const le=d(":"),q=t>=e.length;le||(tc(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 B=!0;for(;t<e.length&&e[t]!=="]";)if(B?B=!1:d(",")||(n=Pt(n,",")),m(),!s()){n=jr(n,",");break}return e[t]==="]"?(n+="]",t++):n=Pt(n,"]"),!0}return!1}function x(){let B=!0,ie=!0;for(;ie;)B?B=!1:d(",")||(n=Pt(n,",")),ie=s();ie||(n=jr(n,",")),n=`[
97
+ ${n}
98
+ ]`}function j(){let B=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,ie=arguments.length>1&&arguments[1]!==void 0?arguments[1]:-1,w=e[t]==="\\";if(w&&(t++,w=!0),Ai(e[t])){const le=nc(e[t])?nc:rc(e[t])?rc:Za(e[t])?Za:om,q=t,y=n.length;let W='"';for(t++;;){if(t>=e.length){const Z=L(t-1);return!B&&ji(e.charAt(Z))?(t=q,n=n.substring(0,y),j(!0)):(W=Pt(W,'"'),n+=W,!0)}if(t===ie)return W=Pt(W,'"'),n+=W,!0;if(le(e[t])){const Z=t,se=W.length;if(W+='"',t++,n+=W,a(!1),B||t>=e.length||ji(e[t])||Ai(e[t])||_n(e[t]))return g(),!0;const re=L(Z-1),ne=e.charAt(re);if(ne===",")return t=q,n=n.substring(0,y),j(!1,re);if(ji(ne))return t=q,n=n.substring(0,y),j(!0);n=n.substring(0,y),t=Z+1,W=`${W.substring(0,se)}\\${W.substring(se)}`}else if(B&&ec(e[t])){if(e[t-1]===":"&&Xu.test(e.substring(q+1,t+2)))for(;t<e.length&&Qu.test(e[t]);)W+=e[t],t++;return W=Pt(W,'"'),n+=W,g(),!0}else if(e[t]==="\\"){const Z=e.charAt(t+1);if(RT[Z]!==void 0)W+=e.slice(t,t+2),t+=2;else if(Z==="u"){let re=2;for(;re<6&&NT(e[t+re]);)re++;re===6?(W+=e.slice(t,t+6),t+=6):t+re>=e.length?t=e.length:G()}else W+=Z,t+=2}else{const Z=e.charAt(t);Z==='"'&&e[t-1]!=="\\"?(W+=`\\${Z}`,t++):TT(Z)?(W+=DT[Z],t++):(ET(Z)||A(Z),W+=Z,t++)}w&&h()}}return!1}function g(){let B=!1;for(a();e[t]==="+";){B=!0,t++,a(),n=jr(n,'"',!0);const ie=n.length;j()?n=PT(n,ie,1):n=Pt(n,'"')}return B}function I(){const B=t;if(e[t]==="-"){if(t++,C())return z(B),!0;if(!_n(e[t]))return t=B,!1}for(;_n(e[t]);)t++;if(e[t]==="."){if(t++,C())return z(B),!0;if(!_n(e[t]))return t=B,!1;for(;_n(e[t]);)t++}if(e[t]==="e"||e[t]==="E"){if(t++,(e[t]==="-"||e[t]==="+")&&t++,C())return z(B),!0;if(!_n(e[t]))return t=B,!1;for(;_n(e[t]);)t++}if(!C())return t=B,!1;if(t>B){const ie=e.slice(B,t),w=/^0\d/.test(ie);return n+=w?`"${ie}"`:ie,!0}return!1}function E(){return k("true","true")||k("false","false")||k("null","null")||k("True","true")||k("False","false")||k("None","null")}function k(B,ie){return e.slice(t,t+B.length)===B?(n+=ie,t+=B.length,!0):!1}function N(B){const ie=t;if(Ku(e[t])){for(;t<e.length&&Yu(e[t]);)t++;let w=t;for(;jn(e,w);)w++;if(e[w]==="(")return t=w+1,s(),e[t]===")"&&(t++,e[t]===";"&&t++),!0}for(;t<e.length&&!ec(e[t])&&!Ai(e[t])&&(!B||e[t]!==":");)t++;if(e[t-1]===":"&&Xu.test(e.substring(ie,t+2)))for(;t<e.length&&Qu.test(e[t]);)t++;if(t>ie){for(;jn(e,t-1)&&t>0;)t--;const w=e.slice(ie,t);return n+=w==="undefined"?"null":JSON.stringify(w),e[t]==='"'&&t++,!0}}function J(){if(e[t]==="/"){const B=t;for(t++;t<e.length&&(e[t]!=="/"||e[t-1]==="\\");)t++;return t++,n+=JSON.stringify(e.substring(B,t)),!0}}function L(B){let ie=B;for(;ie>0&&jn(e,ie);)ie--;return ie}function C(){return t>=e.length||ji(e[t])||jn(e,t)}function z(B){n+=`${e.slice(B,t)}0`}function A(B){throw new Un(`Invalid character ${JSON.stringify(B)}`,t)}function M(){throw new Un(`Unexpected character ${JSON.stringify(e[t])}`,t)}function $(){throw new Un("Unexpected end of json string",e.length)}function F(){throw new Un("Object key expected",t)}function P(){throw new Un("Colon expected",t)}function G(){const B=e.slice(t,t+6);throw new Un(`Invalid unicode character "${B}"`,t)}}function MT(e,t){return e[t]==="*"&&e[t+1]==="/"}function $T({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 ic(e)}catch{}const x=`{${e}}`;try{return JSON.parse(x),x}catch{}try{return ic(x)}catch{return null}},[e]),u=b.useMemo(()=>em(o||e),[o,e]),c=Oe(x=>x.activeTab),f=Oe(x=>x.documents),d=Oe(x=>(x.acceptedApplyIds||[]).includes(u)),p=Oe(x=>x.setPendingDiff),h=Oe(x=>x.createDocument),m=Oe(x=>x.openDocument),v=b.useCallback(()=>{if(o){a(null);try{if(c){const x=f.find(k=>k.name===c),j=(x==null?void 0:x.text)||"";if(n==="templates")try{const k=JSON.parse(j),N=JSON.parse(o);if(Array.isArray(N.templates)){k.props||(k.props={}),k.props.templates=Qh(k.props.templates||[],N.templates);const J=JSON.stringify(k,null,2);p(c,j,J,u);return}}catch{}const g=t==null?void 0:t[0],{original:I,modified:E}=tm(j,o,g);p(c,I,E,u)}else{const x=`ai-generated-${Date.now()}`;h(x,o),m(x)}}catch(x){a(x instanceof Error?x.message:"Merge failed")}}},[o,c,f,p,h,m,t,n,u]),S=b.useCallback(async()=>{await navigator.clipboard.writeText(e),i(!0),setTimeout(()=>i(!1),1500)},[e]);return l.jsxs("div",{className:"flex flex-col gap-1 px-3 py-2 border-t",children:[l.jsxs("div",{className:"flex gap-1.5",children:[l.jsx(Ce,{variant:"secondary",size:"sm",onClick:v,disabled:d||!o,children:d?"Applied":o?"Apply to Editor":"Invalid JSON"}),l.jsx(Ce,{variant:"ghost",size:"sm",onClick:S,children:r?l.jsx(hn,{className:"h-3.5 w-3.5"}):l.jsx(os,{className:"h-3.5 w-3.5"})})]}),s&&l.jsx("p",{className:"text-xs text-destructive m-0",children:s})]})}function FT({threads:e,activeThread:t,disabled:n,onSwitch:r,onCreate:i,onDelete:s,onRename:a}){const[o,u]=b.useState(null),[c,f]=b.useState(""),[d,p]=b.useState(null),h=b.useRef(null),m=(t==null?void 0:t.title)||"New Chat",v=m.length>24?m.slice(0,24)+"...":m;b.useEffect(()=>{o&&requestAnimationFrame(()=>{var N;return(N=h.current)==null?void 0:N.focus()})},[o]);const S=b.useCallback((N,J)=>{J.stopPropagation(),J.preventDefault(),u(N.id),f(N.title),p(null)},[]),x=b.useCallback(()=>{o&&c.trim()&&a(o,c.trim()),u(null),f("")},[o,c,a]),j=b.useCallback(()=>{u(null),f("")},[]),g=b.useCallback(N=>{N.stopPropagation(),N.key==="Enter"?(N.preventDefault(),x()):N.key==="Escape"&&(N.preventDefault(),j())},[x,j]),I=b.useCallback((N,J)=>{J.stopPropagation(),J.preventDefault(),p(N),u(null)},[]),E=b.useCallback(N=>{N.stopPropagation(),N.preventDefault(),d&&(s(d),p(null))},[d,s]),k=b.useCallback(N=>{N.stopPropagation(),N.preventDefault(),p(null)},[]);return l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsxs(ds,{onOpenChange:N=>{N||(u(null),p(null))},children:[l.jsx(fs,{asChild:!0,disabled:n,children:l.jsxs("button",{className:"flex items-center gap-1 text-sm font-semibold tracking-tight hover:text-foreground/80 transition-colors max-w-[180px] cursor-pointer",children:[l.jsx("div",{className:"h-2 w-2 rounded-full bg-primary/70 shrink-0"}),l.jsx("span",{className:"truncate",children:v}),l.jsx(ti,{className:"h-3 w-3 shrink-0 opacity-60"})]})}),l.jsxs(ai,{align:"start",className:"w-64",children:[e.map(N=>{const J=o===N.id;return d===N.id?l.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 text-sm",children:[l.jsx("span",{className:"text-destructive text-xs flex-1 truncate",children:"Delete this thread?"}),l.jsx("button",{className:"shrink-0 text-destructive hover:text-destructive/80 transition-colors cursor-pointer",onClick:E,children:l.jsx(hn,{className:"h-3.5 w-3.5"})}),l.jsx("button",{className:"shrink-0 text-muted-foreground hover:text-foreground transition-colors cursor-pointer",onClick:k,children:l.jsx(pn,{className:"h-3.5 w-3.5"})})]},N.id):J?l.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1",onClick:C=>C.stopPropagation(),onPointerDown:C=>C.stopPropagation(),children:[l.jsx("input",{ref:h,type:"text",value:c,onChange:C=>f(C.target.value),onKeyDown:g,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"}),l.jsx("button",{className:"shrink-0 text-primary hover:text-primary/80 transition-colors cursor-pointer",onMouseDown:C=>{C.preventDefault(),x()},children:l.jsx(hn,{className:"h-3.5 w-3.5"})}),l.jsx("button",{className:"shrink-0 text-muted-foreground hover:text-foreground transition-colors cursor-pointer",onMouseDown:C=>{C.preventDefault(),j()},children:l.jsx(pn,{className:"h-3.5 w-3.5"})})]},N.id):l.jsxs(Ot,{onSelect:()=>r(N.id),className:`group ${N.id===(t==null?void 0:t.id)?"bg-accent":""}`,children:[l.jsx("span",{className:"truncate flex-1",children:N.title.length>30?N.title.slice(0,30)+"...":N.title}),l.jsxs("div",{className:"ml-auto shrink-0 flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[l.jsx("button",{className:"text-muted-foreground hover:text-foreground transition-colors p-0.5 cursor-pointer",onClick:C=>S(N,C),children:l.jsx(pg,{className:"h-3 w-3"})}),e.length>1&&l.jsx("button",{className:"text-muted-foreground hover:text-destructive transition-colors p-0.5 cursor-pointer",onClick:C=>I(N.id,C),children:l.jsx(Ua,{className:"h-3 w-3"})})]})]},N.id)}),l.jsx(sr,{}),l.jsxs(Ot,{onSelect:N=>{N.preventDefault();const J=i();J&&(u(J),f(Ka()),p(null))},children:[l.jsx(Xt,{className:"h-3.5 w-3.5 mr-1.5"}),"New Chat"]})]})]}),l.jsx(Ce,{variant:"ghost",size:"icon",className:"h-6 w-6 text-muted-foreground hover:text-foreground",onClick:()=>i(),disabled:n,title:"New chat thread",children:l.jsx(Xt,{className:"h-3.5 w-3.5"})})]})}const lm=new Set(["image/png","image/jpeg","image/gif","image/webp","application/pdf","text/plain","text/markdown","text/csv","text/html"]),LT=Array.from(lm).join(","),ZT=20*1024*1024,sc=10;function BT(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 ac(e){return Array.from(e).filter(t=>lm.has(t.type)&&t.size<=ZT)}function um(e){return e.startsWith("image/")}function oc(){var K,fe,_e;const e=De(D=>D.contextAttachments),t=De(D=>D.addContext),n=De(D=>D.removeContext),r=De(D=>D.scope),i=De(D=>D.setScope),s=De(D=>D.model),a=De(D=>D.setModel),o=De(D=>D.openChat),u=De(D=>D.closeChat),c=De(D=>D.threads),f=De(D=>D.activeThreadId),d=De(D=>D.createThread),p=De(D=>D.deleteThread),h=De(D=>D.switchThread),m=De(D=>D.updateThreadMessages),v=De(D=>D.updateThreadTitle),S=De(D=>D.deleteThreadsForDocument),x=Oe(D=>D.activeTab),j=Oe(D=>D.documents),{messages:g,sendMessage:I,status:E,error:k,setMessages:N,stop:J,getMessageContext:L,getMessageScope:C}=mT(),[z,A]=b.useState(""),[M,$]=b.useState([]),[F,P]=b.useState(!1),[G,B]=b.useState(!1),ie=b.useRef(null),w=b.useRef(null),le=b.useRef(null),q=b.useCallback(async D=>{const pe=ac(D);if(pe.length===0)return;const Te=await Promise.all(pe.map(BT));$(Le=>{const nt=[...Le,...Te];return nt.length>sc?nt.slice(0,sc):nt})},[]),y=b.useCallback(D=>{$(pe=>pe.filter((Te,Le)=>Le!==D))},[]),W=b.useCallback(D=>{var Te;const pe=(Te=D.clipboardData)==null?void 0:Te.files;if(pe&&pe.length>0){const Le=ac(pe);Le.length>0&&(D.preventDefault(),q(Le))}},[q]),Z=b.useCallback(D=>{var Te;D.preventDefault(),B(!1);const pe=(Te=D.dataTransfer)==null?void 0:Te.files;pe&&pe.length>0&&q(Array.from(pe))},[q]),se=b.useCallback(D=>{D.preventDefault(),B(!0)},[]),re=b.useCallback(()=>B(!1),[]),ne=x?f[x]:void 0,de=ne?c[ne]:void 0,ge=b.useMemo(()=>x?Object.values(c).filter(D=>D.documentName===x).sort((D,pe)=>pe.updatedAt-D.updatedAt):[],[c,x]);b.useEffect(()=>{x&&ge.length===0&&d(x)},[x,ge.length,d]);const Ne=b.useRef(c);Ne.current=c,b.useEffect(()=>{const D=new Set(j.map(Te=>Te.name)),pe=new Set;for(const Te of Object.values(Ne.current))!D.has(Te.documentName)&&Te.documentName!=="__migrated__"&&pe.add(Te.documentName);for(const Te of pe)S(Te)},[j,S]);const be=b.useRef(null);b.useEffect(()=>{be.current!==ne&&(be.current=ne,N((de==null?void 0:de.messages)??[]))},[ne,de,N]),b.useEffect(()=>{var D;(D=ie.current)==null||D.scrollIntoView({behavior:"smooth"})},[g,E]),b.useEffect(()=>{const D=pe=>{var nt;const{documentName:Te,selection:Le}=pe.detail;t({...Le,documentName:Te}),o(),(nt=w.current)==null||nt.focus()};return window.addEventListener("monaco-selection-to-ai",D),()=>window.removeEventListener("monaco-selection-to-ai",D)},[t,o]);const xe=E==="streaming",U=E==="submitted"||xe,Ae=b.useCallback(D=>{D.preventDefault(),!(!z.trim()&&M.length===0||U)&&(I(z,M.length>0?M:void 0),A(""),$([]))},[z,M,U,I]),X=b.useCallback(D=>{D.key==="Enter"&&!D.shiftKey&&(D.preventDefault(),Ae(D))},[Ae]),ve=b.useCallback(()=>{g.length!==0&&P(!0)},[g.length]),_=b.useCallback(()=>{P(!1),N([]),ne&&(m(ne,[]),v(ne,Ka()))},[N,ne,m,v]),[T,O]=b.useState(null),ee=b.useCallback(D=>{O(D)},[]),Y=b.useCallback(()=>{var nt,et;if(!T)return;const D=g.findIndex(it=>it.id===T);if(D===-1){O(null);return}const pe=g[D],Te=new Set([D]);pe.role==="user"&&((nt=g[D+1])==null?void 0:nt.role)==="assistant"?Te.add(D+1):pe.role==="assistant"&&D>0&&((et=g[D-1])==null?void 0:et.role)==="user"&&Te.add(D-1);const Le=g.filter((it,sn)=>!Te.has(sn));N(Le),ne&&m(ne,Le),O(null)},[T,g,N,ne,m]),Q=b.useCallback(D=>{if(!U){if(ge.length<=1){ve();return}p(D)}},[U,ge.length,ve,p]),ce=b.useCallback(()=>{if(!(!x||U))return d(x)},[x,U,d]),ye=b.useCallback(D=>{U||D===ne||h(D)},[U,ne,h]),R=b.useCallback((D,pe)=>{v(D,pe)},[v]);return l.jsxs("div",{className:"flex flex-col h-full border-l bg-surface-chat",children:[l.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border/60 bg-surface-chat",children:[l.jsx(FT,{threads:ge,activeThread:de,disabled:U,onSwitch:ye,onCreate:ce,onDelete:Q,onRename:R}),l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx(Ce,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs text-muted-foreground hover:text-foreground",onClick:ve,disabled:U||g.length===0,children:"Clear"}),l.jsx(Ce,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:u,title:"Close chat",children:l.jsx(pn,{className:"h-3.5 w-3.5"})})]})]}),l.jsx(Zr,{className:"flex-1 min-h-0 [&_[data-radix-scroll-area-viewport]>div]:!block",children:l.jsxs("div",{className:"p-3 space-y-4 min-w-0",children:[g.length===0&&l.jsxs("div",{className:"flex flex-col items-center justify-center py-12 px-4",children:[l.jsx("div",{className:"rounded-xl bg-primary/10 p-3 mb-4",children:l.jsx(Ro,{className:"h-5 w-5 text-primary"})}),l.jsx("p",{className:"text-sm font-medium text-foreground/80 mb-1",children:"JSON Assistant"}),l.jsx("p",{className:"text-xs text-muted-foreground text-center max-w-[200px] mb-4",children:"Generate, edit, and refine your JSON document definitions with AI."}),l.jsxs("div",{className:"flex items-center gap-1.5 rounded-md bg-muted/50 px-2.5 py-1.5",children:[l.jsx(Br,{shortcut:"mod+k"}),l.jsx("span",{className:"text-xs text-muted-foreground",children:"to send a selection"})]})]}),g.map((D,pe)=>{let Te;if(D.role==="user"){const et=L(D.id);et&&et.length>0&&(Te=et)}else if(D.role==="assistant"){for(let et=pe-1;et>=0;et--)if(g[et].role==="user"){Te=L(g[et].id);break}}const Le=xe&&pe===g.length-1&&D.role==="assistant",nt=D.role==="user"?C(D.id):void 0;return l.jsx(VT,{msg:D,isStreaming:Le,context:Te,scope:nt,onDelete:U?void 0:ee},D.id)}),U&&((K=g[g.length-1])==null?void 0:K.role)!=="assistant"&&l.jsx("div",{className:"flex justify-start",children:l.jsx("div",{className:"rounded-lg px-3 py-2 bg-muted/60 border border-border/40",children:l.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[l.jsx(ua,{className:"h-3.5 w-3.5 animate-spin text-primary"}),l.jsx("span",{children:"Thinking..."})]})})}),k&&!U&&l.jsx("div",{className:"flex justify-start",children:l.jsx("div",{className:"rounded-lg px-3 py-2 bg-destructive/10 border border-destructive/30 text-destructive text-sm max-w-[90%]",children:k.message||"Something went wrong"})}),l.jsx("div",{ref:ie})]})}),l.jsxs("div",{className:`border-t border-border/60 p-2.5 space-y-2 bg-surface-chat transition-colors ${G?"ring-2 ring-primary/40 bg-primary/5":""}`,onDrop:Z,onDragOver:se,onDragLeave:re,children:[e.length>0&&l.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.map((D,pe)=>l.jsx(rm,{context:D,onRemove:()=>n(pe)},pe))}),l.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[l.jsx(HT,{model:s,setModel:a}),yt==="pptx"&&x&&l.jsx(qT,{scope:r,setScope:i,docSize:((_e=(fe=j.find(D=>D.name===x))==null?void 0:fe.text)==null?void 0:_e.length)??0})]}),M.length>0&&l.jsx("div",{className:"flex flex-wrap gap-1.5",children:M.map((D,pe)=>l.jsxs("div",{className:"relative group",children:[um(D.mediaType)?l.jsx("img",{src:D.url,alt:D.filename||"attachment",className:"h-14 w-14 rounded-md object-cover border border-border/60"}):l.jsxs("div",{className:"h-14 px-2.5 flex items-center gap-1.5 rounded-md border border-border/60 bg-muted/60 max-w-[140px]",children:[l.jsx(ca,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),l.jsx("span",{className:"text-xs truncate text-muted-foreground",children:D.filename||"file"})]}),l.jsx("button",{type:"button",onClick:()=>y(pe),className:"absolute -top-1.5 -right-1.5 rounded-full bg-destructive text-destructive-foreground p-0.5 opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",children:l.jsx(pn,{className:"h-3 w-3"})})]},pe))}),l.jsxs("form",{onSubmit:Ae,className:"flex items-end gap-2",children:[l.jsx("input",{ref:le,type:"file",accept:LT,multiple:!0,className:"hidden",onChange:D=>{D.target.files&&q(Array.from(D.target.files)),D.target.value=""}}),l.jsx(Ce,{type:"button",variant:"ghost",size:"icon",className:"shrink-0 h-9 w-9 rounded-lg text-muted-foreground hover:text-foreground",onClick:()=>{var D;return(D=le.current)==null?void 0:D.click()},title:"Attach file",children:l.jsx(ca,{className:"h-4 w-4"})}),l.jsx("textarea",{ref:w,value:z,onChange:D=>{A(D.target.value);const pe=D.target;pe.style.height="auto",pe.style.height=`${Math.min(pe.scrollHeight,128)}px`},onKeyDown:X,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}),U?l.jsx(Ce,{type:"button",size:"icon",variant:"destructive",className:"shrink-0 h-9 w-9 rounded-lg",onClick:J,title:"Stop generating",children:l.jsx(hg,{className:"h-4 w-4"})}):l.jsx(Ce,{type:"submit",size:"icon",disabled:!z.trim()&&M.length===0,className:"shrink-0 h-9 w-9 rounded-lg",children:l.jsx(Ro,{className:"h-4 w-4"})})]})]}),l.jsx(_t,{open:F,onOpenChange:P,children:l.jsxs(bt,{className:"max-w-sm",children:[l.jsxs(Ft,{children:[l.jsx(Lt,{children:"Clear thread"}),l.jsx(nn,{children:"This will delete all messages in this thread. This action cannot be undone."})]}),l.jsxs(mn,{children:[l.jsx(Mo,{asChild:!0,children:l.jsx(Ce,{variant:"ghost",size:"sm",children:"Cancel"})}),l.jsx(Ce,{variant:"destructive",size:"sm",onClick:_,children:"Clear"})]})]})}),l.jsx(_t,{open:T!==null,onOpenChange:D=>{D||O(null)},children:l.jsxs(bt,{className:"max-w-sm",children:[l.jsxs(Ft,{children:[l.jsx(Lt,{children:"Delete message"}),l.jsx(nn,{children:"This will delete the message and its paired response. This action cannot be undone."})]}),l.jsxs(mn,{children:[l.jsx(Mo,{asChild:!0,children:l.jsx(Ce,{variant:"ghost",size:"sm",children:"Cancel"})}),l.jsx(Ce,{variant:"destructive",size:"sm",onClick:Y,children:"Delete"})]})]})})]})}const VT=b.memo(function({msg:t,isStreaming:n,context:r,scope:i,onDelete:s}){var u,c;const a=((u=t.parts)==null?void 0:u.filter(f=>f.type==="text").map(f=>f.text).join(""))||"",o=((c=t.parts)==null?void 0:c.filter(f=>f.type==="file"))||[];return l.jsx("div",{className:`group/msg flex ${t.role==="user"?"justify-end":"justify-start"}`,children:l.jsxs("div",{className:`rounded-lg px-3 py-2 max-w-[90%] overflow-hidden min-w-0 ${t.role==="user"?"bg-primary text-primary-foreground":"bg-muted/60 border border-border/40"}`,children:[t.role==="user"?l.jsxs("div",{children:[o.length>0&&l.jsx("div",{className:"flex flex-wrap gap-1 mb-1.5",children:o.map((f,d)=>um(f.mediaType)?l.jsx("img",{src:f.url,alt:f.filename||"image",className:"h-20 max-w-[160px] rounded-sm object-cover"},d):l.jsxs("div",{className:"flex items-center gap-1.5 rounded-sm bg-primary-foreground/20 px-2 py-1",children:[l.jsx(ca,{className:"h-3 w-3 shrink-0"}),l.jsx("span",{className:"text-xs truncate max-w-[120px]",children:f.filename||"file"})]},d))}),r&&r.length>0&&l.jsx("div",{className:"flex flex-wrap gap-1 mb-1.5",children:r.map((f,d)=>l.jsx(rm,{context:f,variant:"sent"},d))}),a&&l.jsx("div",{className:"whitespace-pre-wrap text-sm break-words",children:a}),i&&i!=="global"&&l.jsx("span",{className:"text-[10px] text-primary-foreground/60 mt-0.5 block text-right",children:i})]}):l.jsx(UT,{text:a,isStreaming:n,context:r,scope:i}),s&&!n&&l.jsx("div",{className:"opacity-0 transition-opacity group-hover/msg:opacity-100 focus-within:opacity-100 mt-1",children:l.jsx("button",{type:"button","aria-label":"Delete message",onClick:()=>s(t.id),className:`p-0.5 rounded-sm cursor-pointer focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring ${t.role==="user"?"text-primary-foreground/50 hover:text-primary-foreground/80":"text-muted-foreground hover:text-destructive"}`,children:l.jsx(Ua,{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 UT({text:e,isStreaming:t,context:n,scope:r}){return t?l.jsx("div",{className:"text-sm prose prose-sm dark:prose-invert break-words [&_pre]:overflow-x-auto [&_p]:my-1",children:l.jsx("pre",{className:"whitespace-pre-wrap font-sans text-sm m-0 p-0 bg-transparent border-none",children:e})}):l.jsx("div",{className:"text-sm prose prose-sm dark:prose-invert break-words [&_pre]:overflow-x-auto [&_p]:my-1 [&_ul]:my-1 [&_ol]:my-1 [&_li]:my-0.5 [&_h1]:text-base [&_h2]:text-sm [&_h3]:text-sm [&_h1]:my-2 [&_h2]:my-1.5 [&_h3]:my-1",children:l.jsx(xk,{remarkPlugins:[T1],components:{pre:({children:i})=>l.jsx(l.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-",""))||"",u=String(s).replace(/\n$/,"");if(!a)return l.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 l.jsxs("div",{className:"my-2 rounded-lg border bg-card",children:[l.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 bg-muted/60 border-b text-xs text-muted-foreground",children:[l.jsx("span",{className:"font-mono",children:o||"code"}),!c&&l.jsx(GT,{text:u})]}),l.jsx("pre",{className:"p-3 text-xs font-mono overflow-x-auto max-h-80 overflow-y-auto m-0",children:l.jsx("code",{children:u})}),c&&l.jsx($T,{json:u,context:n,scope:r})]})}},children:e})})}const JT=[{value:"opus",label:"Opus"},{value:"sonnet",label:"Sonnet"},{value:"haiku",label:"Haiku"}];function HT({model:e,setModel:t}){return l.jsxs(Fr,{value:e,onValueChange:n=>t(n),children:[l.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:l.jsx(Lr,{})}),l.jsx(ir,{children:JT.map(n=>l.jsx(Tn,{value:n.value,className:"text-xs",children:n.label},n.value))})]})}const lc={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"},WT=1e5;function qT({scope:e,setScope:t,docSize:n}){return l.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Scope"}),l.jsx("div",{className:"flex items-center bg-muted/40 rounded-md p-0.5 gap-px",children:Object.keys(lc).map(r=>l.jsxs(We,{children:[l.jsx(qe,{asChild:!0,children:l.jsx("button",{type:"button",onClick:()=>t(r),className:`px-2 py-0.5 rounded-sm text-[10px] cursor-pointer transition-colors ${e===r?"bg-background text-foreground font-medium shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:r})}),l.jsx(Ge,{side:"top",className:"text-xs max-w-[200px]",children:lc[r]})]},r))})]}),e==="global"&&n>WT&&l.jsxs("div",{className:"text-[10px] text-warning flex items-center gap-1",children:[l.jsx(Qc,{className:"h-3 w-3 shrink-0"}),l.jsxs("span",{children:["Large doc — switch to"," ",l.jsx("button",{type:"button",onClick:()=>t("slides"),className:"underline cursor-pointer hover:text-warning/80",children:"slides"})," ","or"," ",l.jsx("button",{type:"button",onClick:()=>t("templates"),className:"underline cursor-pointer hover:text-warning/80",children:"templates"})]})]})]})}function GT({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 l.jsx("button",{onClick:r,className:"text-xs text-muted-foreground hover:text-foreground transition-colors",children:t?"Copied!":"Copy"})}function KT({discoveryData:e}){const t=$d(),n=jx(),r=De(C=>C.chatOpen),i=De(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,u]=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,[m,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 j=b.useRef(n);b.useEffect(()=>{n&&!j.current&&s&&(x(!0),a(!1),setTimeout(()=>{v(!0),x(!1)},h)),!n&&j.current&&!s&&(x(!0),a(!0),setTimeout(()=>{v(!1),x(!1)},h)),j.current=n},[n,s]);const g=b.useCallback(()=>{if(t){p(C=>!C);return}x(!0),a(C=>!C),setTimeout(()=>{v(C=>!C),x(!1)},h)},[t]),I=b.useCallback(()=>u(C=>!C),[]),E=b.useRef(i),k=b.useRef(g),N=b.useRef(I);b.useEffect(()=>{E.current=i}),b.useEffect(()=>{k.current=g}),b.useEffect(()=>{N.current=I}),b.useEffect(()=>{const C=z=>{(z.metaKey||z.ctrlKey)&&(z.code==="KeyB"&&!z.shiftKey&&(z.preventDefault(),k.current()),z.code==="KeyJ"&&z.shiftKey&&(z.preventDefault(),z.stopPropagation(),E.current()),z.code==="KeyP"&&z.shiftKey&&(z.preventDefault(),N.current()))};return window.addEventListener("keydown",C,!0),()=>window.removeEventListener("keydown",C,!0)},[]);const J=hT,L=[{key:"editor",icon:la,label:"Editor"},{key:"preview",icon:ed,label:"Preview"},{key:"chat",icon:td,label:"Chat"}];return t?l.jsx(J,{children:l.jsxs("div",{className:"flex flex-col h-full w-full overflow-hidden",children:[l.jsxs("div",{className:"flex items-center gap-1 px-2 py-1.5 border-b bg-sidebar shrink-0",children:[l.jsxs(Dd,{open:d,onOpenChange:p,children:[l.jsx(vx,{asChild:!0,children:l.jsx(Ce,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0",children:l.jsx(Xc,{className:"h-4 w-4"})})}),l.jsx(Xa,{side:"left",className:"p-0 w-72",children:l.jsx(el,{discoveryData:e,onToggleSidebar:()=>p(!1),isCollapsed:!1})})]}),l.jsx("div",{className:"flex gap-0.5 flex-1 min-w-0",children:L.map(({key:C,icon:z,label:A})=>l.jsxs(Ce,{variant:c===C?"default":"ghost",size:"sm",className:"h-7 gap-1.5 text-xs flex-1",onClick:()=>f(C),children:[l.jsx(z,{className:"h-3.5 w-3.5"}),l.jsx("span",{className:"hidden xs:inline",children:A})]},C))})]}),c!=="chat"&&l.jsx(xl,{previewOpen:o,onTogglePreview:I}),l.jsxs("div",{className:"flex-1 min-h-0",children:[c==="editor"&&l.jsx("div",{className:"h-full bg-surface-editor",children:l.jsx(tl,{})}),c==="preview"&&l.jsx("div",{className:"h-full bg-surface-preview",children:l.jsx(nl,{})}),c==="chat"&&l.jsx(oc,{})]})]})}):l.jsx(J,{children:l.jsxs("div",{className:"flex h-full w-full overflow-hidden",children:[l.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:l.jsx(el,{discoveryData:e,onToggleSidebar:g,isCollapsed:m,isAnimating:S})}),l.jsxs("div",{className:"flex-1 min-w-0 flex flex-col h-full",children:[l.jsx(xl,{previewOpen:o,onTogglePreview:I}),l.jsxs(Ly,{direction:"horizontal",autoSaveId:"layout-main",className:"flex-1 min-h-0",children:[l.jsx(Ms,{defaultSize:o?50:100,minSize:20,id:"editor",order:1,children:l.jsx("div",{className:"h-full bg-surface-editor",children:l.jsx(tl,{})})}),o&&l.jsxs(l.Fragment,{children:[l.jsx(fl,{withHandle:!0}),l.jsx(Ms,{defaultSize:50,minSize:20,id:"preview",order:2,children:l.jsx("div",{className:"h-full bg-surface-preview",children:l.jsx(nl,{})})})]}),r&&l.jsxs(l.Fragment,{children:[l.jsx(fl,{withHandle:!0}),l.jsx(Ms,{defaultSize:30,minSize:25,maxSize:50,id:"chat",order:3,children:l.jsx(oc,{})})]})]})]})]})})}function YT(){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 u=await o.json();if(!u.success)throw new Error(u.error||"Discovery failed");t(u.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 XT(){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 u=await o.json();if(!u.success)throw new Error(u.error||"Failed to load plugins");return s(u.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 QT(){const{data:e,loading:t,error:n}=YT(),{loadPlugins:r}=XT(),i=Rt(s=>s.applyPluginsWithValidation);return b.useEffect(()=>{e&&e.plugins.length>0&&r().then(s=>{if(s){console.log("Plugins loaded successfully");const a=Rt.getState().selectedPlugins;a.size>0&&(console.log("Auto-applying persisted plugin selections:",Array.from(a)),i())}})},[e,r,i]),t?l.jsx("div",{className:"flex items-center justify-center h-screen",children:l.jsxs("div",{className:"text-center",children:[l.jsx("div",{className:"text-lg font-medium",children:"Discovering project resources..."}),l.jsx("div",{className:"text-sm text-muted-foreground mt-2",children:"Searching for documents, themes, and plugins"})]})}):n?l.jsx("div",{className:"flex items-center justify-center h-screen",children:l.jsxs("div",{className:"text-center",children:[l.jsx("div",{className:"text-lg font-medium text-destructive",children:"Discovery failed"}),l.jsx("div",{className:"text-sm text-muted-foreground mt-2",children:n}),l.jsx("div",{className:"text-xs text-muted-foreground mt-4",children:"The playground will work with limited functionality."})]})}):l.jsx(xg,{children:l.jsx(yg,{children:l.jsx(bg,{children:l.jsx(vg,{children:l.jsx(wg,{children:l.jsx(rx,{children:l.jsx(Ld,{children:l.jsx("section",{className:"flex h-screen w-full flex-col",children:l.jsx("div",{className:"grow overflow-hidden",children:l.jsx(KT,{discoveryData:e})})})})})})})})})})}const uz=Object.freeze(Object.defineProperty({__proto__:null,HomePage:QT},Symbol.toStringTag,{value:"Module"}));export{Wt as B,_t as D,uz as H,Wy as P,Dr as S,Hr as T,bf as a,Od as b,bt as c,Ft as d,Lt as e,Vy as u};
99
+ //# sourceMappingURL=HomePage-DdoBbkci.js.map