@json-to-office/jto 0.22.0 → 0.23.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 (22) hide show
  1. package/dist/cli.js +1 -1
  2. package/dist/client/assets/HomePage-Bk6bS7bR.js +99 -0
  3. package/dist/client/assets/HomePage-Bk6bS7bR.js.map +1 -0
  4. package/dist/client/assets/{JsonEditorPage-Bclb98Ti.js → JsonEditorPage-mmIadgaO.js} +3 -3
  5. package/dist/client/assets/{JsonEditorPage-Bclb98Ti.js.map → JsonEditorPage-mmIadgaO.js.map} +1 -1
  6. package/dist/client/assets/{MonacoPluginProvider-BbjmAGrJ.js → MonacoPluginProvider-a4dXqdLj.js} +3 -3
  7. package/dist/client/assets/{MonacoPluginProvider-BbjmAGrJ.js.map → MonacoPluginProvider-a4dXqdLj.js.map} +1 -1
  8. package/dist/client/assets/{button-CSrOcD5F.js → button-CtsIzJf1.js} +2 -2
  9. package/dist/client/assets/{button-CSrOcD5F.js.map → button-CtsIzJf1.js.map} +1 -1
  10. package/dist/client/assets/{editor-CGjdiUtd.js → editor-CZUatu7z.js} +2 -2
  11. package/dist/client/assets/{editor-CGjdiUtd.js.map → editor-CZUatu7z.js.map} +1 -1
  12. package/dist/client/assets/{editor-monaco-json-Bw2M2Xcf.js → editor-monaco-json-C1RuQNyj.js} +2 -2
  13. package/dist/client/assets/{editor-monaco-json-Bw2M2Xcf.js.map → editor-monaco-json-C1RuQNyj.js.map} +1 -1
  14. package/dist/client/assets/{index-Bn9d6cEh.js → index-BcOsOdHe.js} +4 -4
  15. package/dist/client/assets/index-BcOsOdHe.js.map +1 -0
  16. package/dist/client/assets/{preview-C51sEB99.js → preview-DYuTX4mt.js} +2 -2
  17. package/dist/client/assets/{preview-C51sEB99.js.map → preview-DYuTX4mt.js.map} +1 -1
  18. package/dist/client/index.html +1 -1
  19. package/package.json +4 -4
  20. package/dist/client/assets/HomePage-BW2AGCC2.js +0 -99
  21. package/dist/client/assets/HomePage-BW2AGCC2.js.map +0 -1
  22. package/dist/client/assets/index-Bn9d6cEh.js.map +0 -1
@@ -0,0 +1,99 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/editor-CZUatu7z.js","assets/react-vendor-CTFDOf2G.js","assets/editor-monaco-json-C1RuQNyj.js","assets/index-BcOsOdHe.js","assets/query-vendor-Df8-oete.js","assets/radix-ui-BQBCrmlJ.js","assets/ui-vendor-HKNXoiLD.js","assets/monaco-editor-BcgxPCqT.js","assets/state-vendor-ByFYl9bq.js","assets/index-Auo5vP51.css","assets/MonacoPluginProvider-a4dXqdLj.js","assets/button-CtsIzJf1.js","assets/preview-DYuTX4mt.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 Mo=(e,t,n)=>dm(e,typeof t!="symbol"?t+"":t,n);import{r as b,j as u,c as Ee,R as cc,g as Ua}from"./react-vendor-CTFDOf2G.js";import{b as dc,c as Ja,d as fc,e as pc,f as ts,g as ns,D as rs,O as is,h as fm,V as pm,i as hc,I as hm,j as mm,k as mc,l as gm,m as gc,n as xm,o as ym,G as bm,S as xc,p as yc,L as bc,q as vc,r as wc,s as lr,t as vm,u as wm,v as km,w as kc,x as Sc,y as _c,z as jc,A as Nc,B as Cc,E as Ec,F as Ic,H as zc,J as Tc,K as Ac,M as Sm,N as _m,Q as Pc,U as jm,W as Nm,X as Cm,Y as Em,Z as Im,_ as zm,$ as Tm,a0 as Am,a1 as Pm,a2 as Oc,a3 as Dc,a4 as Rc,a5 as Mc,a6 as $c,a7 as Fc,a8 as Lc,a9 as Zc,aa as Bc,ab as Om,ac as Vc,ad as Uc,ae as Jc}from"./radix-ui-BQBCrmlJ.js";import{c as W,u as ur,S as Yt,A as Hc,T as oi,C as Dm,E as Rm,F as yt,a as Mm,b as $m,d as qe,e as Ge,f as Ke,g as Wc,s as Ns,_ as qc,h as li,i as Fm,j as Lm,k as Zm,l as hr,m as vi,W as Bm}from"./index-BcOsOdHe.js";import{X as Nn,C as on,a as un,b as Vm,d as Qr,G as Gc,F as Um,e as ss,f as Kc,P as Jm,g as $o,h as la,i as Yc,S as Xc,B as Fo,j as Hm,k as Wm,l as qm,m as as,n as Gm,M as Km,o as Ym,p as Xm,q as Qc,r as Qm,s as Lo,t as zi,u as eg,I as ed,v as tg,w as ng,R as rg,x as ig,T as td,E as sg,y as ag,z as og,A as lg,D as nd,H as Ha,J as rd,K as ug,L as id,N as ua,O as cg,Q as dg,U as Zo,V as ca,W as fg}from"./ui-vendor-HKNXoiLD.js";import{B as we}from"./button-CtsIzJf1.js";import{u as Ae,i as pg,a as da,b as vn,g as fa,c as Dt,T as sd,d as ui,S as hg,O as mg,e as gg,M as xg,D as yg}from"./MonacoPluginProvider-a4dXqdLj.js";import{u as ad,a as bg,d as vg,p as wg,b as kg,e as Sg}from"./state-vendor-ByFYl9bq.js";import{b as _g}from"./query-vendor-Df8-oete.js";const It=dc,Bo=fc,jg=pc,Vo=Ja,od=b.forwardRef(({className:e,...t},n)=>u.jsx(is,{ref:n,className:W("fixed inset-0 z-50 bg-black/80",e),...t}));od.displayName=is.displayName;const St=b.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(jg,{children:[u.jsx(od,{}),u.jsxs(ts,{ref:r,className:W("bg-background fixed top-[50%] left-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border p-6 shadow-lg sm:rounded-lg",e),...n,children:[t,u.jsxs(Ja,{className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 cursor-pointer rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-none disabled:pointer-events-none",children:[u.jsx(Nn,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));St.displayName=ts.displayName;const Ut=({className:e,...t})=>u.jsx("div",{className:W("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Ut.displayName="DialogHeader";const Cn=({className:e,...t})=>u.jsx("div",{className:W("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});Cn.displayName="DialogFooter";const Jt=b.forwardRef(({className:e,...t},n)=>u.jsx(ns,{ref:n,className:W("text-lg leading-none font-semibold tracking-tight",e),...t}));Jt.displayName=ns.displayName;const cn=b.forwardRef(({className:e,...t},n)=>u.jsx(rs,{ref:n,className:W("text-muted-foreground text-sm",e),...t}));cn.displayName=rs.displayName;const Mr=fm,Ng=bm,$r=pm,tr=b.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(hc,{ref:r,className:W("border-input ring-offset-background placeholder:text-muted-foreground focus:ring-ring flex min-h-9 w-full min-w-0 items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm shadow-sm focus:ring-1 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50 [&>span]:min-w-0 [&>span]:whitespace-normal [&>span]:break-words text-left cursor-pointer",e),...n,children:[t,u.jsx(hm,{asChild:!0,children:u.jsx(on,{className:"h-4 w-4 shrink-0 opacity-50"})})]}));tr.displayName=hc.displayName;const ld=b.forwardRef(({className:e,...t},n)=>u.jsx(xc,{ref:n,className:W("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(Vm,{className:"h-4 w-4"})}));ld.displayName=xc.displayName;const ud=b.forwardRef(({className:e,...t},n)=>u.jsx(yc,{ref:n,className:W("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(on,{className:"h-4 w-4"})}));ud.displayName=yc.displayName;const nr=b.forwardRef(({className:e,children:t,position:n="popper",...r},i)=>u.jsx(mm,{children:u.jsxs(mc,{ref:i,className:W("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border shadow-md",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[u.jsx(ld,{}),u.jsx(gm,{className:W("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),u.jsx(ud,{})]})}));nr.displayName=mc.displayName;const cd=b.forwardRef(({className:e,...t},n)=>u.jsx(bc,{ref:n,className:W("px-2 py-1.5 text-sm font-semibold",e),...t}));cd.displayName=bc.displayName;const En=b.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(gc,{ref:r,className:W("focus:bg-accent focus:text-accent-foreground relative flex w-full cursor-pointer items-center rounded-sm py-1.5 pr-8 pl-2 text-sm outline-none select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[u.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(xm,{children:u.jsx(un,{className:"h-4 w-4"})})}),u.jsx(ym,{children:t})]}));En.displayName=gc.displayName;const Cg=b.forwardRef(({className:e,...t},n)=>u.jsx(vc,{ref:n,className:W("bg-muted -mx-1 my-1 h-px",e),...t}));Cg.displayName=vc.displayName;const ei=b.forwardRef(({className:e,type:t,...n},r)=>u.jsx("input",{type:t,className:W("border-input file:text-foreground placeholder:text-muted-foreground focus-visible:ring-ring flex h-9 w-full rounded-md border bg-transparent px-3 py-1 text-base shadow-sm 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 md:text-sm",e),ref:r,...n}));ei.displayName="Input";const Eg=Qr("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Kn=b.forwardRef(({className:e,...t},n)=>u.jsx(wc,{ref:n,className:W(Eg(),e),...t}));Kn.displayName=wc.displayName;const Ig=Qr("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Vt({className:e,variant:t,...n}){return u.jsx("div",{className:W(Ig({variant:t}),e),...n})}const zg=({open:e,onOpenChange:t})=>{const{documents:n,documentTypes:r,activeTab:i,createDocument:s,openDocument:a}=Ae(ad(I=>({documents:I.documents,documentTypes:I.documentTypes,activeTab:I.activeTab,createDocument:I.createDocument,openDocument:I.openDocument}))),{toast:o}=ur(),l=b.useMemo(()=>n.filter(I=>r[I.name]!=="application/json+theme"),[n,r]),[c,f]=b.useState(""),[d,p]=b.useState(""),[h,m]=b.useState("playground"),[v,S]=b.useState(!1),[y,_]=b.useState(null),[g,z]=b.useState(null),[C,w]=b.useState(null),E=()=>{_(null),z(null),w(null)};b.useEffect(()=>{if(!e)return;_(null),z(null),w(null);const I=l.map(Z=>Z.name),O=I.includes(i)?i:I[0]??"";p(O),f(I.find(Z=>Z!==O)??"")},[e]);const R=async()=>{const I=l.find(Z=>Z.name===c),O=l.find(Z=>Z.name===d);if(!(!I||!O)){S(!0),_(null),z(null),w(null);try{const Z=await fetch(Hc.diff,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldDefinition:I.text,newDefinition:O.text,options:{author:h||"playground"}})}),M=await Z.json();if(!Z.ok||!M.success){const T=Array.isArray(M.errors)?`: ${M.errors.slice(0,3).map(A=>A.message||String(A)).join("; ")}`:"";throw new Error((M.error||`Diff failed (${Z.status})`)+T)}z(M.data.summary),w(M.data.document)}catch(Z){_(Z instanceof Error?Z.message:"Diff failed")}finally{S(!1)}}},K=()=>{if(!C)return;const I=new Set(n.map(M=>M.name));let O=`${d}-redline`,Z=2;for(;I.has(O);)O=`${d}-redline-${Z++}`;s(O,JSON.stringify(C,null,2)),a(O),o({title:`Redline created: ${O}`}),t(!1)},j=g?g.tracked.modified+g.tracked.inserted+g.tracked.deleted:0;return u.jsx(It,{open:e,onOpenChange:t,children:u.jsxs(St,{className:"sm:max-w-[560px]",children:[u.jsxs(Ut,{children:[u.jsxs(Jt,{className:"flex items-center gap-2",children:[u.jsx(Gc,{className:"size-4"}),"Compare documents"]}),u.jsx(cn,{children:"Diff two versions into a redline with native Word tracked changes (accept/reject in Word)."})]}),u.jsxs("div",{className:"grid gap-4 py-2",children:[u.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[u.jsxs("div",{className:"grid gap-1.5",children:[u.jsx(Kn,{htmlFor:"diff-base",children:"Base (old)"}),u.jsxs(Mr,{value:c,onValueChange:I=>{f(I),E()},children:[u.jsx(tr,{id:"diff-base",children:u.jsx($r,{placeholder:"Select document"})}),u.jsx(nr,{children:l.map(I=>u.jsx(En,{value:I.name,children:I.name},I.name))})]})]}),u.jsxs("div",{className:"grid gap-1.5",children:[u.jsx(Kn,{htmlFor:"diff-revised",children:"Revised (new)"}),u.jsxs(Mr,{value:d,onValueChange:I=>{p(I),E()},children:[u.jsx(tr,{id:"diff-revised",children:u.jsx($r,{placeholder:"Select document"})}),u.jsx(nr,{children:l.map(I=>u.jsx(En,{value:I.name,children:I.name},I.name))})]})]})]}),u.jsxs("div",{className:"grid gap-1.5",children:[u.jsx(Kn,{htmlFor:"diff-author",children:"Revision author"}),u.jsx(ei,{id:"diff-author",value:h,onChange:I=>{m(I.target.value),E()},placeholder:"playground"})]}),y&&u.jsx("p",{className:"text-sm text-destructive",role:"alert",children:y}),g&&u.jsxs("div",{className:"rounded-md border p-3 text-sm grid gap-2",children:[u.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[u.jsxs(Vt,{variant:"secondary",children:[g.tracked.inserted," inserted"]}),u.jsxs(Vt,{variant:"secondary",children:[g.tracked.deleted," deleted"]}),u.jsxs(Vt,{variant:"secondary",children:[g.tracked.modified," modified"]}),u.jsxs("span",{className:"text-muted-foreground text-xs",children:[g.unchangedBlocks," blocks unchanged"]})]}),j===0&&g.untracked.length===0&&u.jsx("p",{className:"text-muted-foreground",children:"The documents are identical."}),g.untracked.length>0&&u.jsxs("div",{className:"grid gap-1 max-h-32 overflow-y-auto",children:[u.jsxs("p",{className:"font-medium text-amber-600 dark:text-amber-500",children:[g.untracked.length," change(s) not expressible as tracked changes:"]}),g.untracked.map((I,O)=>u.jsxs("p",{className:"text-xs text-muted-foreground",children:[I.path," [",I.component,"] ",I.detail]},O))]}),g.notes.map((I,O)=>u.jsxs("p",{className:"text-xs text-muted-foreground",children:["Note: ",I]},O))]})]}),u.jsx(Cn,{children:g&&j+g.untracked.length>0?u.jsxs(we,{onClick:K,children:[u.jsx(Um,{className:"size-4 mr-1"}),"Open redline"]}):u.jsxs(we,{onClick:R,disabled:v||!c||!d||c===d,children:[v&&u.jsx(Yt,{className:"size-4 mr-1"}),"Compare"]})})]})})};var ti=e=>e.type==="checkbox",kn=e=>e instanceof Date,ct=e=>e==null;const dd=e=>typeof e=="object";var Xe=e=>!ct(e)&&!Array.isArray(e)&&dd(e)&&!kn(e),fd=e=>Xe(e)&&e.target?ti(e.target)?e.target.checked:e.target.value:e,Tg=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,pd=(e,t)=>e.has(Tg(t)),Ag=e=>{const t=e.constructor&&e.constructor.prototype;return Xe(t)&&t.hasOwnProperty("isPrototypeOf")},Wa=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(!(Wa&&(e instanceof Blob||r))&&(n||Xe(e)))if(t=n?[]:{},!n&&!Ag(e))t=e;else for(const i in e)e.hasOwnProperty(i)&&(t[i]=mt(e[i]));else return e;return t}var os=e=>Array.isArray(e)?e.filter(Boolean):[],Ye=e=>e===void 0,ue=(e,t,n)=>{if(!t||!Xe(e))return n;const r=os(t.split(/[,[\].]+?/)).reduce((i,s)=>ct(i)?i:i[s],e);return Ye(r)||r===e?Ye(e[t])?n:e[t]:r},Ct=e=>typeof e=="boolean",qa=e=>/^\w*$/.test(e),hd=e=>os(e.replace(/["|']|\]/g,"").split(/\.|\[/)),De=(e,t,n)=>{let r=-1;const i=qa(t)?[t]:hd(t),s=i.length,a=s-1;for(;++r<s;){const o=i[r];let l=n;if(r!==a){const c=e[o];l=Xe(c)||Array.isArray(c)?c:isNaN(+i[r+1])?{}:[]}if(o==="__proto__"||o==="constructor"||o==="prototype")return;e[o]=l,e=e[o]}return e};const Ti={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},Ot={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},Gt={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},md=Ee.createContext(null),ls=()=>Ee.useContext(md),Pg=e=>{const{children:t,...n}=e;return Ee.createElement(md.Provider,{value:n},t)};var gd=(e,t,n,r=!0)=>{const i={defaultValues:t._defaultValues};for(const s in e)Object.defineProperty(i,s,{get:()=>{const a=s;return t._proxyFormState[a]!==Ot.all&&(t._proxyFormState[a]=!r||Ot.all),n&&(n[a]=!0),e[a]}});return i},gt=e=>Xe(e)&&!Object.keys(e).length,xd=(e,t,n,r)=>{n(e);const{name:i,...s}=e;return gt(s)||Object.keys(s).length>=Object.keys(t).length||Object.keys(s).find(a=>t[a]===(!r||Ot.all))},Tr=e=>Array.isArray(e)?e:[e],yd=(e,t,n)=>!e||!t||e===t||Tr(e).some(r=>r&&(n?r===t:r.startsWith(t)||t.startsWith(r)));function Ga(e){const t=Ee.useRef(e);t.current=e,Ee.useEffect(()=>{const n=!e.disabled&&t.current.subject&&t.current.subject.subscribe({next:t.current.next});return()=>{n&&n.unsubscribe()}},[e.disabled])}function Og(e){const t=ls(),{control:n=t.control,disabled:r,name:i,exact:s}=e||{},[a,o]=Ee.useState(n._formState),l=Ee.useRef(!0),c=Ee.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1}),f=Ee.useRef(i);return f.current=i,Ga({disabled:r,next:d=>l.current&&yd(f.current,d.name,s)&&xd(d,c.current,n._updateFormState)&&o({...n._formState,...d}),subject:n._subjects.state}),Ee.useEffect(()=>(l.current=!0,c.current.isValid&&n._updateValid(!0),()=>{l.current=!1}),[n]),Ee.useMemo(()=>gd(a,n,c.current,!1),[a,n])}var Bt=e=>typeof e=="string",bd=(e,t,n,r,i)=>Bt(e)?(r&&t.watch.add(e),ue(n,e,i)):Array.isArray(e)?e.map(s=>(r&&t.watch.add(s),ue(n,s))):(r&&(t.watchAll=!0),n);function Dg(e){const t=ls(),{control:n=t.control,name:r,defaultValue:i,disabled:s,exact:a}=e||{},o=Ee.useRef(r);o.current=r,Ga({disabled:s,subject:n._subjects.values,next:f=>{yd(o.current,f.name,a)&&c(mt(bd(o.current,n._names,f.values||n._formValues,!1,i)))}});const[l,c]=Ee.useState(n._getWatch(r,i));return Ee.useEffect(()=>n._removeUnmounted()),l}function Rg(e){const t=ls(),{name:n,disabled:r,control:i=t.control,shouldUnregister:s}=e,a=pd(i._names.array,n),o=Dg({control:i,name:n,defaultValue:ue(i._formValues,n,ue(i._defaultValues,n,e.defaultValue)),exact:!0}),l=Og({control:i,name:n,exact:!0}),c=Ee.useRef(i.register(n,{...e.rules,value:o,...Ct(e.disabled)?{disabled:e.disabled}:{}})),f=Ee.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!ue(l.errors,n)},isDirty:{enumerable:!0,get:()=>!!ue(l.dirtyFields,n)},isTouched:{enumerable:!0,get:()=>!!ue(l.touchedFields,n)},isValidating:{enumerable:!0,get:()=>!!ue(l.validatingFields,n)},error:{enumerable:!0,get:()=>ue(l.errors,n)}}),[l,n]),d=Ee.useMemo(()=>({name:n,value:o,...Ct(r)||l.disabled?{disabled:l.disabled||r}:{},onChange:p=>c.current.onChange({target:{value:fd(p),name:n},type:Ti.CHANGE}),onBlur:()=>c.current.onBlur({target:{value:ue(i._formValues,n),name:n},type:Ti.BLUR}),ref:p=>{const h=ue(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,l.disabled,o,i._fields]);return Ee.useEffect(()=>{const p=i._options.shouldUnregister||s,h=(m,v)=>{const S=ue(i._fields,m);S&&S._f&&(S._f.mount=v)};if(h(n,!0),p){const m=mt(ue(i._options.defaultValues,n));De(i._defaultValues,n,m),Ye(ue(i._formValues,n))&&De(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]),Ee.useEffect(()=>{i._updateDisabledField({disabled:r,fields:i._fields,name:n})},[r,n,i]),Ee.useMemo(()=>({field:d,formState:l,fieldState:f}),[d,l,f])}const Mg=e=>e.render(Rg(e));var $g=(e,t,n,r,i)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:i||!0}}:{},Uo=e=>({isOnSubmit:!e||e===Ot.onSubmit,isOnBlur:e===Ot.onBlur,isOnChange:e===Ot.onChange,isOnAll:e===Ot.all,isOnTouch:e===Ot.onTouched}),Jo=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some(r=>e.startsWith(r)&&/^\.\w+/.test(e.slice(r.length))));const Ar=(e,t,n,r)=>{for(const i of n||Object.keys(e)){const s=ue(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(Ar(o,t))break}else if(Xe(o)&&Ar(o,t))break}}};var Fg=(e,t,n)=>{const r=Tr(ue(e,n));return De(r,"root",t[n]),De(e,n,r),e},Ka=e=>e.type==="file",Zt=e=>typeof e=="function",Ai=e=>{if(!Wa)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},wi=e=>Bt(e),Ya=e=>e.type==="radio",Pi=e=>e instanceof RegExp;const Ho={value:!1,isValid:!1},Wo={value:!0,isValid:!0};var vd=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&&!Ye(e[0].attributes.value)?Ye(e[0].value)||e[0].value===""?Wo:{value:e[0].value,isValid:!0}:Wo:Ho}return Ho};const qo={isValid:!1,value:null};var wd=e=>Array.isArray(e)?e.reduce((t,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:t,qo):qo;function Go(e,t,n="validate"){if(wi(e)||Array.isArray(e)&&e.every(wi)||Ct(e)&&!e)return{type:n,message:wi(e)?e:"",ref:t}}var On=e=>Xe(e)&&!Pi(e)?e:{value:e,message:""},Ko=async(e,t,n,r,i,s)=>{const{ref:a,refs:o,required:l,maxLength:c,minLength:f,min:d,max:p,pattern:h,validate:m,name:v,valueAsNumber:S,mount:y}=e._f,_=ue(n,v);if(!y||t.has(v))return{};const g=o?o[0]:a,z=O=>{i&&g.reportValidity&&(g.setCustomValidity(Ct(O)?"":O||""),g.reportValidity())},C={},w=Ya(a),E=ti(a),R=w||E,K=(S||Ka(a))&&Ye(a.value)&&Ye(_)||Ai(a)&&a.value===""||_===""||Array.isArray(_)&&!_.length,j=$g.bind(null,v,r,C),I=(O,Z,M,T=Gt.maxLength,A=Gt.minLength)=>{const J=O?Z:M;C[v]={type:O?T:A,message:J,ref:a,...j(O?T:A,J)}};if(s?!Array.isArray(_)||!_.length:l&&(!R&&(K||ct(_))||Ct(_)&&!_||E&&!vd(o).isValid||w&&!wd(o).isValid)){const{value:O,message:Z}=wi(l)?{value:!!l,message:l}:On(l);if(O&&(C[v]={type:Gt.required,message:Z,ref:g,...j(Gt.required,Z)},!r))return z(Z),C}if(!K&&(!ct(d)||!ct(p))){let O,Z;const M=On(p),T=On(d);if(!ct(_)&&!isNaN(_)){const A=a.valueAsNumber||_&&+_;ct(M.value)||(O=A>M.value),ct(T.value)||(Z=A<T.value)}else{const A=a.valueAsDate||new Date(_),J=k=>new Date(new Date().toDateString()+" "+k),B=a.type=="time",ne=a.type=="week";Bt(M.value)&&_&&(O=B?J(_)>J(M.value):ne?_>M.value:A>new Date(M.value)),Bt(T.value)&&_&&(Z=B?J(_)<J(T.value):ne?_<T.value:A<new Date(T.value))}if((O||Z)&&(I(!!O,M.message,T.message,Gt.max,Gt.min),!r))return z(C[v].message),C}if((c||f)&&!K&&(Bt(_)||s&&Array.isArray(_))){const O=On(c),Z=On(f),M=!ct(O.value)&&_.length>+O.value,T=!ct(Z.value)&&_.length<+Z.value;if((M||T)&&(I(M,O.message,Z.message),!r))return z(C[v].message),C}if(h&&!K&&Bt(_)){const{value:O,message:Z}=On(h);if(Pi(O)&&!_.match(O)&&(C[v]={type:Gt.pattern,message:Z,ref:a,...j(Gt.pattern,Z)},!r))return z(Z),C}if(m){if(Zt(m)){const O=await m(_,n),Z=Go(O,g);if(Z&&(C[v]={...Z,...j(Gt.validate,Z.message)},!r))return z(Z.message),C}else if(Xe(m)){let O={};for(const Z in m){if(!gt(O)&&!r)break;const M=Go(await m[Z](_,n),g,Z);M&&(O={...M,...j(Z,M.message)},z(M.message),r&&(C[v]=O))}if(!gt(O)&&(C[v]={ref:g,...O},!r))return C}}return z(!0),C};function Lg(e,t){const n=t.slice(0,-1).length;let r=0;for(;r<n;)e=Ye(e)?r++:e[t[r++]];return e}function Zg(e){for(const t in e)if(e.hasOwnProperty(t)&&!Ye(e[t]))return!1;return!0}function rt(e,t){const n=Array.isArray(t)?t:qa(t)?[t]:hd(t),r=n.length===1?e:Lg(e,n),i=n.length-1,s=n[i];return r&&delete r[s],i!==0&&(Xe(r)&&gt(r)||Array.isArray(r)&&Zg(r))&&rt(e,n.slice(0,-1)),e}var Cs=()=>{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=[]}}},pa=e=>ct(e)||!dd(e);function sn(e,t){if(pa(e)||pa(t))return e===t;if(kn(e)&&kn(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(kn(s)&&kn(a)||Xe(s)&&Xe(a)||Array.isArray(s)&&Array.isArray(a)?!sn(s,a):s!==a)return!1}}return!0}var kd=e=>e.type==="select-multiple",Bg=e=>Ya(e)||ti(e),Es=e=>Ai(e)&&e.isConnected,Sd=e=>{for(const t in e)if(Zt(e[t]))return!0;return!1};function Oi(e,t={}){const n=Array.isArray(e);if(Xe(e)||n)for(const r in e)Array.isArray(e[r])||Xe(e[r])&&!Sd(e[r])?(t[r]=Array.isArray(e[r])?[]:{},Oi(e[r],t[r])):ct(e[r])||(t[r]=!0);return t}function _d(e,t,n){const r=Array.isArray(e);if(Xe(e)||r)for(const i in e)Array.isArray(e[i])||Xe(e[i])&&!Sd(e[i])?Ye(t)||pa(n[i])?n[i]=Array.isArray(e[i])?Oi(e[i],[]):{...Oi(e[i])}:_d(e[i],ct(t)?{}:t[i],n[i]):n[i]=!sn(e[i],t[i]);return n}var mr=(e,t)=>_d(e,t,Oi(t)),jd=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>Ye(e)?e:t?e===""?NaN:e&&+e:n&&Bt(e)?new Date(e):r?r(e):e;function Is(e){const t=e.ref;return Ka(t)?t.files:Ya(t)?wd(e.refs).value:kd(t)?[...t.selectedOptions].map(({value:n})=>n):ti(t)?vd(e.refs).value:jd(Ye(t.value)?e.ref.value:t.value,e)}var Vg=(e,t,n,r)=>{const i={};for(const s of e){const a=ue(t,s);a&&De(i,s,a._f)}return{criteriaMode:n,names:[...e],fields:i,shouldUseNativeValidation:r}},gr=e=>Ye(e)?e:Pi(e)?e.source:Xe(e)?Pi(e.value)?e.value.source:e.value:e;const Yo="AsyncFunction";var Ug=e=>!!e&&!!e.validate&&!!(Zt(e.validate)&&e.validate.constructor.name===Yo||Xe(e.validate)&&Object.values(e.validate).find(t=>t.constructor.name===Yo)),Jg=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function Xo(e,t,n){const r=ue(e,n);if(r||qa(n))return{error:r,name:n};const i=n.split(".");for(;i.length;){const s=i.join("."),a=ue(t,s),o=ue(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 Hg=(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,Wg=(e,t)=>!os(ue(e,t)).length&&rt(e,t);const qg={mode:Ot.onSubmit,reValidateMode:Ot.onChange,shouldFocusError:!0};function Gg(e={}){let t={...qg,...e},n={submitCount:0,isDirty:!1,isLoading:Zt(t.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1},r={},i=Xe(t.defaultValues)||Xe(t.values)?mt(t.defaultValues||t.values)||{}:{},s=t.shouldUnregister?{}:mt(i),a={action:!1,mount:!1,watch:!1},o={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},l,c=0;const f={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},d={values:Cs(),array:Cs(),state:Cs()},p=Uo(t.mode),h=Uo(t.reValidateMode),m=t.criteriaMode===Ot.all,v=N=>P=>{clearTimeout(c),c=setTimeout(N,P)},S=async N=>{if(!t.disabled&&(f.isValid||N)){const P=t.resolver?gt((await R()).errors):await j(r,!0);P!==n.isValid&&d.state.next({isValid:P})}},y=(N,P)=>{!t.disabled&&(f.isValidating||f.validatingFields)&&((N||Array.from(o.mount)).forEach(L=>{L&&(P?De(n.validatingFields,L,P):rt(n.validatingFields,L))}),d.state.next({validatingFields:n.validatingFields,isValidating:!gt(n.validatingFields)}))},_=(N,P=[],L,re,te=!0,X=!0)=>{if(re&&L&&!t.disabled){if(a.action=!0,X&&Array.isArray(ue(r,N))){const pe=L(ue(r,N),re.argA,re.argB);te&&De(r,N,pe)}if(X&&Array.isArray(ue(n.errors,N))){const pe=L(ue(n.errors,N),re.argA,re.argB);te&&De(n.errors,N,pe),Wg(n.errors,N)}if(f.touchedFields&&X&&Array.isArray(ue(n.touchedFields,N))){const pe=L(ue(n.touchedFields,N),re.argA,re.argB);te&&De(n.touchedFields,N,pe)}f.dirtyFields&&(n.dirtyFields=mr(i,s)),d.state.next({name:N,isDirty:O(N,P),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else De(s,N,P)},g=(N,P)=>{De(n.errors,N,P),d.state.next({errors:n.errors})},z=N=>{n.errors=N,d.state.next({errors:n.errors,isValid:!1})},C=(N,P,L,re)=>{const te=ue(r,N);if(te){const X=ue(s,N,Ye(L)?ue(i,N):L);Ye(X)||re&&re.defaultChecked||P?De(s,N,P?X:Is(te._f)):T(N,X),a.mount&&S()}},w=(N,P,L,re,te)=>{let X=!1,pe=!1;const ve={name:N};if(!t.disabled){const F=!!(ue(r,N)&&ue(r,N)._f&&ue(r,N)._f.disabled);if(!L||re){f.isDirty&&(pe=n.isDirty,n.isDirty=ve.isDirty=O(),X=pe!==ve.isDirty);const q=F||sn(ue(i,N),P);pe=!!(!F&&ue(n.dirtyFields,N)),q||F?rt(n.dirtyFields,N):De(n.dirtyFields,N,!0),ve.dirtyFields=n.dirtyFields,X=X||f.dirtyFields&&pe!==!q}if(L){const q=ue(n.touchedFields,N);q||(De(n.touchedFields,N,L),ve.touchedFields=n.touchedFields,X=X||f.touchedFields&&q!==L)}X&&te&&d.state.next(ve)}return X?ve:{}},E=(N,P,L,re)=>{const te=ue(n.errors,N),X=f.isValid&&Ct(P)&&n.isValid!==P;if(t.delayError&&L?(l=v(()=>g(N,L)),l(t.delayError)):(clearTimeout(c),l=null,L?De(n.errors,N,L):rt(n.errors,N)),(L?!sn(te,L):te)||!gt(re)||X){const pe={...re,...X&&Ct(P)?{isValid:P}:{},errors:n.errors,name:N};n={...n,...pe},d.state.next(pe)}},R=async N=>{y(N,!0);const P=await t.resolver(s,t.context,Vg(N||o.mount,r,t.criteriaMode,t.shouldUseNativeValidation));return y(N),P},K=async N=>{const{errors:P}=await R(N);if(N)for(const L of N){const re=ue(P,L);re?De(n.errors,L,re):rt(n.errors,L)}else n.errors=P;return P},j=async(N,P,L={valid:!0})=>{for(const re in N){const te=N[re];if(te){const{_f:X,...pe}=te;if(X){const ve=o.array.has(X.name),F=te._f&&Ug(te._f);F&&f.validatingFields&&y([re],!0);const q=await Ko(te,o.disabled,s,m,t.shouldUseNativeValidation&&!P,ve);if(F&&f.validatingFields&&y([re]),q[X.name]&&(L.valid=!1,P))break;!P&&(ue(q,X.name)?ve?Fg(n.errors,q,X.name):De(n.errors,X.name,q[X.name]):rt(n.errors,X.name))}!gt(pe)&&await j(pe,P,L)}}return L.valid},I=()=>{for(const N of o.unMount){const P=ue(r,N);P&&(P._f.refs?P._f.refs.every(L=>!Es(L)):!Es(P._f.ref))&&ie(N)}o.unMount=new Set},O=(N,P)=>!t.disabled&&(N&&P&&De(s,N,P),!sn(ce(),i)),Z=(N,P,L)=>bd(N,o,{...a.mount?s:Ye(P)?i:Bt(N)?{[N]:P}:P},L,P),M=N=>os(ue(a.mount?s:i,N,t.shouldUnregister?ue(i,N,[]):[])),T=(N,P,L={})=>{const re=ue(r,N);let te=P;if(re){const X=re._f;X&&(!X.disabled&&De(s,N,jd(P,X)),te=Ai(X.ref)&&ct(P)?"":P,kd(X.ref)?[...X.ref.options].forEach(pe=>pe.selected=te.includes(pe.value)):X.refs?ti(X.ref)?X.refs.length>1?X.refs.forEach(pe=>(!pe.defaultChecked||!pe.disabled)&&(pe.checked=Array.isArray(te)?!!te.find(ve=>ve===pe.value):te===pe.value)):X.refs[0]&&(X.refs[0].checked=!!te):X.refs.forEach(pe=>pe.checked=pe.value===te):Ka(X.ref)?X.ref.value="":(X.ref.value=te,X.ref.type||d.values.next({name:N,values:{...s}})))}(L.shouldDirty||L.shouldTouch)&&w(N,te,L.shouldTouch,L.shouldDirty,!0),L.shouldValidate&&k(N)},A=(N,P,L)=>{for(const re in P){const te=P[re],X=`${N}.${re}`,pe=ue(r,X);(o.array.has(N)||Xe(te)||pe&&!pe._f)&&!kn(te)?A(X,te,L):T(X,te,L)}},J=(N,P,L={})=>{const re=ue(r,N),te=o.array.has(N),X=mt(P);De(s,N,X),te?(d.array.next({name:N,values:{...s}}),(f.isDirty||f.dirtyFields)&&L.shouldDirty&&d.state.next({name:N,dirtyFields:mr(i,s),isDirty:O(N,X)})):re&&!re._f&&!ct(X)?A(N,X,L):T(N,X,L),Jo(N,o)&&d.state.next({...n}),d.values.next({name:a.mount?N:void 0,values:{...s}})},B=async N=>{a.mount=!0;const P=N.target;let L=P.name,re=!0;const te=ue(r,L),X=()=>P.type?Is(te._f):fd(N),pe=ve=>{re=Number.isNaN(ve)||kn(ve)&&isNaN(ve.getTime())||sn(ve,ue(s,L,ve))};if(te){let ve,F;const q=X(),he=N.type===Ti.BLUR||N.type===Ti.FOCUS_OUT,Se=!Jg(te._f)&&!t.resolver&&!ue(n.errors,L)&&!te._f.deps||Hg(he,ue(n.touchedFields,L),n.isSubmitted,h,p),D=Jo(L,o,he);De(s,L,q),he?(te._f.onBlur&&te._f.onBlur(N),l&&l(0)):te._f.onChange&&te._f.onChange(N);const me=w(L,q,he,!1),Ce=!gt(me)||D;if(!he&&d.values.next({name:L,type:N.type,values:{...s}}),Se)return f.isValid&&(t.mode==="onBlur"&&he?S():he||S()),Ce&&d.state.next({name:L,...D?{}:me});if(!he&&D&&d.state.next({...n}),t.resolver){const{errors:$e}=await R([L]);if(pe(q),re){const nt=Xo(n.errors,r,L),et=Xo($e,r,nt.name||L);ve=et.error,L=et.name,F=gt($e)}}else y([L],!0),ve=(await Ko(te,o.disabled,s,m,t.shouldUseNativeValidation))[L],y([L]),pe(q),re&&(ve?F=!1:f.isValid&&(F=await j(r,!0)));re&&(te._f.deps&&k(te._f.deps),E(L,F,ve,me))}},ne=(N,P)=>{if(ue(n.errors,P)&&N.focus)return N.focus(),1},k=async(N,P={})=>{let L,re;const te=Tr(N);if(t.resolver){const X=await K(Ye(N)?N:te);L=gt(X),re=N?!te.some(pe=>ue(X,pe)):L}else N?(re=(await Promise.all(te.map(async X=>{const pe=ue(r,X);return await j(pe&&pe._f?{[X]:pe}:pe)}))).every(Boolean),!(!re&&!n.isValid)&&S()):re=L=await j(r);return d.state.next({...!Bt(N)||f.isValid&&L!==n.isValid?{}:{name:N},...t.resolver||!N?{isValid:L}:{},errors:n.errors}),P.shouldFocus&&!re&&Ar(r,ne,N?te:o.mount),re},ce=N=>{const P={...a.mount?s:i};return Ye(N)?P:Bt(N)?ue(P,N):N.map(L=>ue(P,L))},de=(N,P)=>({invalid:!!ue((P||n).errors,N),isDirty:!!ue((P||n).dirtyFields,N),error:ue((P||n).errors,N),isValidating:!!ue(n.validatingFields,N),isTouched:!!ue((P||n).touchedFields,N)}),x=N=>{N&&Tr(N).forEach(P=>rt(n.errors,P)),d.state.next({errors:N?n.errors:{}})},H=(N,P,L)=>{const re=(ue(r,N,{_f:{}})._f||{}).ref,te=ue(n.errors,N)||{},{ref:X,message:pe,type:ve,...F}=te;De(n.errors,N,{...F,...P,ref:re}),d.state.next({name:N,errors:n.errors,isValid:!1}),L&&L.shouldFocus&&re&&re.focus&&re.focus()},G=(N,P)=>Zt(N)?d.values.subscribe({next:L=>N(Z(void 0,P),L)}):Z(N,P,!0),ie=(N,P={})=>{for(const L of N?Tr(N):o.mount)o.mount.delete(L),o.array.delete(L),P.keepValue||(rt(r,L),rt(s,L)),!P.keepError&&rt(n.errors,L),!P.keepDirty&&rt(n.dirtyFields,L),!P.keepTouched&&rt(n.touchedFields,L),!P.keepIsValidating&&rt(n.validatingFields,L),!t.shouldUnregister&&!P.keepDefaultValue&&rt(i,L);d.values.next({values:{...s}}),d.state.next({...n,...P.keepDirty?{isDirty:O()}:{}}),!P.keepIsValid&&S()},ae=({disabled:N,name:P,field:L,fields:re})=>{(Ct(N)&&a.mount||N||o.disabled.has(P))&&(N?o.disabled.add(P):o.disabled.delete(P),w(P,Is(L?L._f:ue(re,P)._f),!1,!1,!0))},Q=(N,P={})=>{let L=ue(r,N);const re=Ct(P.disabled)||Ct(t.disabled);return De(r,N,{...L||{},_f:{...L&&L._f?L._f:{ref:{name:N}},name:N,mount:!0,...P}}),o.mount.add(N),L?ae({field:L,disabled:Ct(P.disabled)?P.disabled:t.disabled,name:N}):C(N,!0,P.value),{...re?{disabled:P.disabled||t.disabled}:{},...t.progressive?{required:!!P.required,min:gr(P.min),max:gr(P.max),minLength:gr(P.minLength),maxLength:gr(P.maxLength),pattern:gr(P.pattern)}:{},name:N,onChange:B,onBlur:B,ref:te=>{if(te){Q(N,P),L=ue(r,N);const X=Ye(te.value)&&te.querySelectorAll&&te.querySelectorAll("input,select,textarea")[0]||te,pe=Bg(X),ve=L._f.refs||[];if(pe?ve.find(F=>F===X):X===L._f.ref)return;De(r,N,{_f:{...L._f,...pe?{refs:[...ve.filter(Es),X,...Array.isArray(ue(i,N))?[{}]:[]],ref:{type:X.type,name:N}}:{ref:X}}}),C(N,!1,void 0,X)}else L=ue(r,N,{}),L._f&&(L._f.mount=!1),(t.shouldUnregister||P.shouldUnregister)&&!(pd(o.array,N)&&a.action)&&o.unMount.add(N)}}},$=()=>t.shouldFocusError&&Ar(r,ne,o.mount),ee=N=>{Ct(N)&&(d.state.next({disabled:N}),Ar(r,(P,L)=>{const re=ue(r,L);re&&(P.disabled=re._f.disabled||N,Array.isArray(re._f.refs)&&re._f.refs.forEach(te=>{te.disabled=re._f.disabled||N}))},0,!1))},V=(N,P)=>async L=>{let re;L&&(L.preventDefault&&L.preventDefault(),L.persist&&L.persist());let te=mt(s);if(o.disabled.size)for(const X of o.disabled)De(te,X,void 0);if(d.state.next({isSubmitting:!0}),t.resolver){const{errors:X,values:pe}=await R();n.errors=X,te=pe}else await j(r);if(rt(n.errors,"root"),gt(n.errors)){d.state.next({errors:{}});try{await N(te,L)}catch(X){re=X}}else P&&await P({...n.errors},L),$(),setTimeout($);if(d.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:gt(n.errors)&&!re,submitCount:n.submitCount+1,errors:n.errors}),re)throw re},se=(N,P={})=>{ue(r,N)&&(Ye(P.defaultValue)?J(N,mt(ue(i,N))):(J(N,P.defaultValue),De(i,N,mt(P.defaultValue))),P.keepTouched||rt(n.touchedFields,N),P.keepDirty||(rt(n.dirtyFields,N),n.isDirty=P.defaultValue?O(N,mt(ue(i,N))):O()),P.keepError||(rt(n.errors,N),f.isValid&&S()),d.state.next({...n}))},le=(N,P={})=>{const L=N?mt(N):i,re=mt(L),te=gt(N),X=te?i:re;if(P.keepDefaultValues||(i=L),!P.keepValues){if(P.keepDirtyValues){const pe=new Set([...o.mount,...Object.keys(mr(i,s))]);for(const ve of Array.from(pe))ue(n.dirtyFields,ve)?De(X,ve,ue(s,ve)):J(ve,ue(X,ve))}else{if(Wa&&Ye(N))for(const pe of o.mount){const ve=ue(r,pe);if(ve&&ve._f){const F=Array.isArray(ve._f.refs)?ve._f.refs[0]:ve._f.ref;if(Ai(F)){const q=F.closest("form");if(q){q.reset();break}}}}r={}}s=t.shouldUnregister?P.keepDefaultValues?mt(i):{}:mt(X),d.array.next({values:{...X}}),d.values.next({values:{...X}})}o={mount:P.keepDirtyValues?o.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},a.mount=!f.isValid||!!P.keepIsValid||!!P.keepDirtyValues,a.watch=!!t.shouldUnregister,d.state.next({submitCount:P.keepSubmitCount?n.submitCount:0,isDirty:te?!1:P.keepDirty?n.isDirty:!!(P.keepDefaultValues&&!sn(N,i)),isSubmitted:P.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:te?{}:P.keepDirtyValues?P.keepDefaultValues&&s?mr(i,s):n.dirtyFields:P.keepDefaultValues&&N?mr(i,N):P.keepDirty?n.dirtyFields:{},touchedFields:P.keepTouched?n.touchedFields:{},errors:P.keepErrors?n.errors:{},isSubmitSuccessful:P.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1})},ge=(N,P)=>le(Zt(N)?N(s):N,P);return{control:{register:Q,unregister:ie,getFieldState:de,handleSubmit:V,setError:H,_executeSchema:R,_getWatch:Z,_getDirty:O,_updateValid:S,_removeUnmounted:I,_updateFieldArray:_,_updateDisabledField:ae,_getFieldArray:M,_reset:le,_resetDefaultValues:()=>Zt(t.defaultValues)&&t.defaultValues().then(N=>{ge(N,t.resetOptions),d.state.next({isLoading:!1})}),_updateFormState:N=>{n={...n,...N}},_disableForm:ee,_subjects:d,_proxyFormState:f,_setErrors:z,get _fields(){return r},get _formValues(){return s},get _state(){return a},set _state(N){a=N},get _defaultValues(){return i},get _names(){return o},set _names(N){o=N},get _formState(){return n},set _formState(N){n=N},get _options(){return t},set _options(N){t={...t,...N}}},trigger:k,register:Q,handleSubmit:V,watch:G,setValue:J,getValues:ce,reset:ge,resetField:se,clearErrors:x,unregister:ie,setError:H,setFocus:(N,P={})=>{const L=ue(r,N),re=L&&L._f;if(re){const te=re.refs?re.refs[0]:re.ref;te.focus&&(te.focus(),P.shouldSelect&&Zt(te.select)&&te.select())}},getFieldState:de}}function Kg(e={}){const t=Ee.useRef(void 0),n=Ee.useRef(void 0),[r,i]=Ee.useState({isDirty:!1,isValidating:!1,isLoading:Zt(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,defaultValues:Zt(e.defaultValues)?void 0:e.defaultValues});t.current||(t.current={...Gg(e),formState:r});const s=t.current.control;return s._options=e,Ga({subject:s._subjects.state,next:a=>{xd(a,s._proxyFormState,s._updateFormState,!0)&&i({...s._formState})}}),Ee.useEffect(()=>s._disableForm(e.disabled),[s,e.disabled]),Ee.useEffect(()=>{if(s._proxyFormState.isDirty){const a=s._getDirty();a!==r.isDirty&&s._subjects.state.next({isDirty:a})}},[s,r.isDirty]),Ee.useEffect(()=>{e.values&&!sn(e.values,n.current)?(s._reset(e.values,s._options.resetOptions),n.current=e.values,i(a=>({...a}))):s._resetDefaultValues()},[e.values,s]),Ee.useEffect(()=>{e.errors&&s._setErrors(e.errors)},[e.errors,s]),Ee.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()}),Ee.useEffect(()=>{e.shouldUnregister&&s._subjects.values.next({values:s._getWatch()})},[e.shouldUnregister,s]),t.current.formState=gd(r,s),t.current}function Yg(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 Xg=Pg,Nd=b.createContext({}),Qo=({...e})=>u.jsx(Nd.Provider,{value:{name:e.name},children:u.jsx(Mg,{...e})}),us=()=>{const e=b.useContext(Nd),t=b.useContext(Cd),{getFieldState:n,formState:r}=ls(),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}},Cd=b.createContext({}),ha=b.forwardRef(({className:e,...t},n)=>{const r=b.useId();return u.jsx(Cd.Provider,{value:{id:r},children:u.jsx("div",{ref:n,className:W("space-y-2",e),...t})})});ha.displayName="FormItem";const ma=b.forwardRef(({className:e,...t},n)=>{const{error:r,formItemId:i}=us();return u.jsx(Kn,{ref:n,className:W(r&&"text-destructive",e),htmlFor:i,...t})});ma.displayName="FormLabel";const ga=b.forwardRef(({...e},t)=>{const{error:n,formItemId:r,formDescriptionId:i,formMessageId:s}=us();return u.jsx(lr,{ref:t,id:r,"aria-describedby":n?`${i} ${s}`:`${i}`,"aria-invalid":!!n,...e})});ga.displayName="FormControl";const Ed=b.forwardRef(({className:e,...t},n)=>{const{formDescriptionId:r}=us();return u.jsx("p",{ref:n,id:r,className:W("text-muted-foreground text-[0.8rem]",e),...t})});Ed.displayName="FormDescription";const xa=b.forwardRef(({className:e,children:t,...n},r)=>{const{error:i,formMessageId:s}=us(),a=i?String(i==null?void 0:i.message):t;return a?u.jsx("p",{ref:r,id:s,className:W("text-destructive text-[0.8rem] font-medium",e),...n,children:a}):null});xa.displayName="FormMessage";function Xa(){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 Id=()=>({chatOpen:!1,scope:"global",model:"opus",contextAttachments:[],threads:{},activeThreadId:{}}),Qg=(e=Id())=>bg()(vg(wg((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:Xa(),messages:[],createdAt:s,updatedAt:s};return t(o=>({threads:{...o.threads,[i]:a},activeThreadId:{...o.activeThreadId,[r]:i}})),i},deleteThread:r=>{const i=n(),s=i.threads[r];if(!s)return;const a=Object.fromEntries(Object.entries(i.threads).filter(([c])=>c!==r)),o=s.documentName,l={...i.activeThreadId};if(l[o]===r){const c=Object.values(a).filter(f=>f.documentName===o);c.length>0?(c.sort((f,d)=>d.updatedAt-f.updatedAt),l[o]=c[0].id):delete l[o]}t({threads:a,activeThreadId:l})},switchThread:r=>{const s=n().threads[r];s&&t(a=>({activeThreadId:{...a.activeThreadId,[s.documentName]:r}}))},updateThreadMessages:(r,i)=>{t(s=>{const a=s.threads[r];return a?{threads:{...s.threads,[r]:{...a,messages:i,updatedAt:Date.now()}}}:s})},updateThreadTitle:(r,i)=>{t(s=>{const a=s.threads[r];return a?{threads:{...s.threads,[r]:{...a,title:i}}}:s})},deleteThreadsForDocument:r=>{t(i=>{const s={...i.threads},a={...i.activeThreadId};for(const[o,l]of Object.entries(s))l.documentName===r&&delete s[o];return delete a[r],{threads:s,activeThreadId:a}})},renameThreadsForDocument:(r,i)=>{t(s=>{const a={...s.threads},o={...s.activeThreadId};for(const[l,c]of Object.entries(a))c.documentName===r&&(a[l]={...c,documentName:i});return r in o&&(o[i]=o[r],delete o[r]),{threads:a,activeThreadId:o}})},clearChat:()=>{t(r=>({contextAttachments:[]}))}}),{name:"chat-storage",version:1,storage:kg(()=>pg),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}}))),zd=b.createContext(void 0),ex=({children:e})=>{const t=b.useRef(null);return t.current||(t.current=Qg(Id())),u.jsx(zd.Provider,{value:t.current,children:e})},Te=e=>{const t=b.useContext(zd);if(!t)throw new Error("useChatStore must be used within ChatStoreProvider");return Sg(t,e)};function tx(e,t,n){return t.filter(r=>r.name!==n).every(r=>r.name!==e)}function nx(e,t,n){const r={},i=[];e!=="delete"&&(r.name=oi.String({minLength:1,maxLength:120,pattern:"^[a-zA-Z0-9-_. ]+$",description:"Document name (e.g., my-report.docx.json or my-theme.theme.json)"}),i.push("name")),e==="create"&&(r.template=oi.Optional(oi.String({description:"Template selection"})));const s=oi.Object(r,{additionalProperties:!1,required:i.length>0?i:void 0});return{schema:s,validate:a=>{const o=[];if(!Dm(s,a))for(const c of Rm(s,a))o.push({path:c.path.replace(/^\//,""),message:c.message});const l=a;if(e!=="delete"&&l.name){const c=l.name.trim();c?(l.name=c,t(c)||o.push({path:"name",message:"Document with this name already exists"})):o.push({path:"name",message:"Name can't be empty"})}return e==="create"&&(n!=null&&n.length)&&l.template&&(n.some(c=>c.name===l.template)||o.push({path:"template",message:"You must select a valid template"})),{success:o.length===0,data:o.length===0?l:void 0,errors:o}}}}function rx(e,t,n){return e==="create"?{name:"",template:t}:e==="update"?{name:n}:{}}const ix=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"}}),Dn="__empty__";function sx({mode:e,shouldReset:t,postSubmit:n,selectedName:r,discoveredDocuments:i,discoveredThemes:s,isTheme:a}){const[o,l]=b.useState(!1),[c,f]=b.useState(null),[d,p]=b.useState("idle"),{toast:h}=ur(),m=ix(a),{documents:v,openTabs:S,createDocument:y,renameDocument:_,deleteDocument:g,openDocument:z,closeDocument:C}=Ae(ce=>ce),{updateTheme:w,removeTheme:E}=da(ce=>ce),R=Te(ce=>ce.renameThreadsForDocument),K=Te(ce=>ce.deleteThreadsForDocument),j=b.useMemo(()=>a?s||[]:i||[],[a,i,s]),I=b.useMemo(()=>{const ce={current:[],downstream:[]};return j.forEach(de=>{ce[de.location]&&ce[de.location].push(de)}),ce},[j]),O=b.useMemo(()=>j.map(ce=>({name:ce.name,type:"application/json",text:"",mtime:new Date,ctime:new Date,atime:new Date})),[j]),Z=b.useMemo(()=>nx(e,ce=>tx(ce,v,r),O),[e,v,r,O]),M=Z.schema,T=b.useMemo(()=>{const ce=new Map;return j.forEach(de=>ce.set(de.path,de)),ce},[j]),A=Dn,J=Kg({resolver:Yg(Z.validate),defaultValues:rx(e,void 0,r)}),[B,ne]=b.useState(A);b.useEffect(()=>{if(B&&B!==Dn&&e==="create"){const ce=T.get(B);if(ce){f(null),p("loading");let de=!1;return fetch(`/api/discovery/${a?"themes":"documents"}/${encodeURIComponent(ce.name)}/content`).then(x=>{if(!x.ok)throw new Error(`Failed to fetch content: ${x.statusText}`);return x.text()}).then(x=>{if(de)return;const H=JSON.parse(x);f(JSON.stringify(H,null,2)),p("idle")}).catch(x=>{de||(console.error("Failed to copy template:",x),f(null),p("error"))}),()=>{de=!0}}}p("idle")},[B,e,T,a]),b.useEffect(()=>{t&&(J.reset(),f(null),p("idle"),ne(A))},[J,t]);const k=J.handleSubmit(async({name:ce,template:de})=>{l(!0);try{if(await new Promise(x=>setTimeout(x,200)),e==="create"){const x=B?T.get(B):j.find(se=>se.name===de);let H,G=ce;if(!!B&&B!==Dn&&c===null){h({title:d==="loading"?"Template still loading":`Could not copy ${(x==null?void 0:x.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 se=G.replace(/\.(json|theme)$/i,"").toLowerCase().replace(/\s+/g,"-"),le=yt==="docx"?Mm(se):{name:se,colors:{primary:"#2563EB",secondary:"#64748B",accent:"#F8FAFC",background:"#FFFFFF",text:"#334155"},fonts:{heading:"Calibri",body:"Calibri"},defaults:{fontSize:18,fontColor:"#334155"}};H=c||JSON.stringify(le,null,2);const ge=`.${yt}.theme.json`;G.endsWith(ge)||(G=G.replace(/\.(pptx|docx)\.theme\.json$/i,"").replace(/\.theme\.json$/i,"").replace(/\.json$/i,""),G+=ge)}else{const se=x;H=c||JSON.stringify(yt==="docx"?{name:"docx",props:{theme:(se==null?void 0:se.theme)||"default",metadata:{title:(se==null?void 0:se.title)||G.replace(/\.(json|js)$/i,"")}},children:[{name:"section",props:{},children:[{name:"paragraph",props:{text:"Start writing your document content here..."}}]}]}:{name:"pptx",props:{title:(se==null?void 0:se.title)||G.replace(/\.(json|js)$/i,""),theme:(se==null?void 0:se.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 le=yt==="docx"?".docx.json":".pptx.json";!G.endsWith(le)&&!G.endsWith(".json")&&(G+=le)}const ae=G.match(/(\.(pptx|docx)(\.theme)?\.json|\.json)$/i),Q=ae?ae[0]:"",$=G.slice(0,G.length-Q.length);let ee=G,V=1;for(;v.some(se=>se.name===ee);)V++,ee=`${$} (${V})${Q}`;G=ee,y(G,H),z(G),a&&w(G,H)}else if(e==="update"){const x=r,H=ce,G=S.includes(x);G&&C(x),_(x,H),R(x,H),G&&z(H)}else if(e==="delete"){const x=r;C(x),g(x),K(x),a&&E(x)}n()}finally{l(!1)}});return u.jsx(Xg,{...J,children:u.jsxs("form",{onSubmit:k,children:[u.jsxs(Ut,{children:[u.jsx(Jt,{children:m[e].title}),u.jsx(cn,{children:m[e].description})]}),u.jsxs("div",{className:"flex flex-col gap-4 py-4",children:[M.properties&&"name"in M.properties&&u.jsx(Qo,{control:J.control,name:"name",render:({field:ce})=>u.jsxs(ha,{children:[u.jsx(ma,{children:"Name"}),u.jsx(ga,{children:u.jsx(ei,{placeholder:"Enter a name or select a template below",autoComplete:"off",...ce})}),u.jsx(xa,{})]})}),e==="create"&&u.jsx(Qo,{control:J.control,name:"template",render:({field:ce})=>u.jsxs(ha,{children:[u.jsx(ma,{children:a?"Base Theme":"Base Document"}),u.jsxs(Mr,{onValueChange:de=>{if(de===Dn)ce.onChange(void 0),J.setValue("name",""),ne(Dn),f(null);else{const x=T.get(de);x&&(ce.onChange(x.name),J.setValue("name",x.name),ne(de))}},defaultValue:A,children:[u.jsx(ga,{children:u.jsx(tr,{children:u.jsx($r,{placeholder:`Select a discovered ${a?"theme":"document"}`})})}),u.jsxs(nr,{className:"max-h-[300px]",children:[u.jsxs(En,{value:Dn,children:["Empty ",a?"theme":"document"]}),Object.entries(I).map(([de,x])=>x.length===0?null:u.jsxs(Ng,{children:[u.jsx(cd,{children:de==="current"?"📁 Current Directory":"📦 Project"}),x.map(H=>{let G;return H.title&&H.title!==H.name?G=H.title:H.description&&(G=H.description.length>40?H.description.substring(0,40)+"...":H.description),u.jsx(En,{value:H.path,className:"pl-6",children:u.jsxs("span",{className:"flex flex-col",children:[u.jsx("span",{className:"font-medium",children:H.name}),G&&u.jsx("span",{className:"text-muted-foreground text-xs",children:G})]})},H.path)})]},de))]})]}),u.jsxs(Ed,{children:["Start empty or select a discovered"," ",a?"theme":"document"," as a starting point"]}),u.jsx(xa,{})]})})]}),u.jsx(Cn,{children:u.jsx(we,{type:"submit",variant:m[e].buttonVariant,disabled:o,children:o?u.jsxs(u.Fragment,{children:[u.jsx(Yt,{size:"sm",className:"mr-2"}),e==="create"?"Creating...":e==="update"?"Saving...":"Deleting..."]}):m[e].button})})]})})}const Di=Ee.memo(sx),ax=vm,ox=wm,lx=b.forwardRef(({className:e,inset:t,children:n,...r},i)=>u.jsxs(jc,{ref:i,className:W("focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground flex cursor-pointer items-center rounded-sm px-2 py-1.5 text-sm outline-none select-none",t&&"pl-8",e),...r,children:[n,u.jsx(ss,{className:"ml-auto h-4 w-4"})]}));lx.displayName=jc.displayName;const ux=b.forwardRef(({className:e,...t},n)=>u.jsx(Nc,{ref:n,className:W("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] overflow-hidden rounded-md border p-1 shadow-lg",e),...t}));ux.displayName=Nc.displayName;const Td=b.forwardRef(({className:e,...t},n)=>u.jsx(km,{children:u.jsx(kc,{ref:n,className:W("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] overflow-hidden rounded-md border p-1 shadow-md",e),...t})}));Td.displayName=kc.displayName;const Sr=b.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Sc,{ref:r,className:W("focus:bg-accent focus:text-accent-foreground relative flex cursor-pointer items-center rounded-sm px-2 py-1.5 text-sm outline-none select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));Sr.displayName=Sc.displayName;const cx=b.forwardRef(({className:e,children:t,checked:n,...r},i)=>u.jsxs(Cc,{ref:i,className:W("focus:bg-accent focus:text-accent-foreground relative flex cursor-pointer items-center rounded-sm py-1.5 pr-2 pl-8 text-sm outline-none select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(Ec,{children:u.jsx(un,{className:"h-4 w-4"})})}),t]}));cx.displayName=Cc.displayName;const dx=b.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Ic,{ref:r,className:W("focus:bg-accent focus:text-accent-foreground relative flex cursor-pointer items-center rounded-sm py-1.5 pr-2 pl-8 text-sm outline-none select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(Ec,{children:u.jsx(Kc,{className:"h-4 w-4 fill-current"})})}),t]}));dx.displayName=Ic.displayName;const fx=b.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(zc,{ref:r,className:W("text-foreground px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));fx.displayName=zc.displayName;const ya=b.forwardRef(({className:e,...t},n)=>u.jsx(_c,{ref:n,className:W("bg-border -mx-1 my-1 h-px",e),...t}));ya.displayName=_c.displayName;const ki=({className:e,...t})=>u.jsx("span",{className:W("text-muted-foreground ml-auto text-xs tracking-widest",e),...t});ki.displayName="ContextMenuShortcut";const Ad=b.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},i)=>u.jsx(Tc,{ref:i,decorative:n,orientation:t,className:W("bg-border shrink-0",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));Ad.displayName=Tc.displayName;const Pd=dc,px=fc,hx=pc,Od=b.forwardRef(({className:e,...t},n)=>u.jsx(is,{className:W("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/80",e),...t,ref:n}));Od.displayName=is.displayName;const mx=Qr("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"}}),Qa=b.forwardRef(({side:e="right",className:t,children:n,...r},i)=>u.jsxs(hx,{children:[u.jsx(Od,{}),u.jsxs(ts,{ref:i,className:W(mx({side:e}),t),...r,children:[u.jsxs(Ja,{className:"ring-offset-background focus:ring-ring data-[state=open]:bg-secondary absolute top-4 right-4 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-none disabled:pointer-events-none",children:[u.jsx(Nn,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]}),n]})]}));Qa.displayName=ts.displayName;const gx=b.forwardRef(({className:e,...t},n)=>u.jsx(ns,{ref:n,className:W("text-foreground text-lg font-semibold",e),...t}));gx.displayName=ns.displayName;const xx=b.forwardRef(({className:e,...t},n)=>u.jsx(rs,{ref:n,className:W("text-muted-foreground text-sm",e),...t}));xx.displayName=rs.displayName;function Pr({className:e,...t}){return u.jsx("div",{className:W("bg-primary/10 animate-pulse rounded-md",e),...t})}const zs=768,Ts=1200;function Dd(e){return typeof window<"u"?window.innerWidth<e:!1}function Rd(){const[e,t]=b.useState(()=>Dd(zs));return b.useEffect(()=>{const n=window.matchMedia(`(max-width: ${zs-1}px)`),r=()=>{t(window.innerWidth<zs)};return n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),e}function yx(){const[e,t]=b.useState(()=>Dd(Ts));return b.useEffect(()=>{const n=window.matchMedia(`(max-width: ${Ts-1}px)`),r=()=>{t(window.innerWidth<Ts)};return n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),e}const bx="sidebar_state",vx=60*60*24*7,wx="16rem",kx="18rem",Sx="3rem",_x="b",Md=b.createContext(null);function cs(){const e=b.useContext(Md);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}const $d=b.forwardRef(({defaultOpen:e=!0,open:t,onOpenChange:n,className:r,style:i,children:s,...a},o)=>{const l=Rd(),[c,f]=b.useState(!1),[d,p]=b.useState(e),h=t??d,m=b.useCallback(_=>{const g=typeof _=="function"?_(h):_;n?n(g):p(g),document.cookie=`${bx}=${g}; path=/; max-age=${vx}`},[n,h]),v=b.useCallback(()=>l?f(_=>!_):m(_=>!_),[l,m,f]);b.useEffect(()=>{const _=z=>{var E;const C=z;if(!C)return!1;const w=(E=C.tagName)==null?void 0:E.toLowerCase();return w==="input"||w==="textarea"||w==="select"||C.isContentEditable?!0:!!(C.closest&&C.closest(".monaco-editor"))},g=z=>{const C=z.metaKey||z.ctrlKey,w=z.key.toLowerCase();if(C&&w===_x){z.preventDefault(),v();return}C&&w==="s"&&!_(z.target)&&(z.preventDefault(),v())};return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[v]);const S=h?"expanded":"collapsed",y=b.useMemo(()=>({state:S,open:h,setOpen:m,isMobile:l,openMobile:c,setOpenMobile:f,toggleSidebar:v}),[S,h,m,l,c,f,v]);return u.jsx(Md.Provider,{value:y,children:u.jsx($m,{delayDuration:0,children:u.jsx("div",{style:{"--sidebar-width":wx,"--sidebar-width-icon":Sx,...i},className:W("group/sidebar-wrapper has-[[data-variant=inset]]:bg-sidebar flex min-h-svh w-full",r),ref:o,...a,children:s})})})});$d.displayName="SidebarProvider";const Fd=b.forwardRef(({side:e="left",variant:t="sidebar",collapsible:n="offcanvas",className:r,children:i,...s},a)=>{const{isMobile:o,state:l,openMobile:c,setOpenMobile:f}=cs();return n==="none"?u.jsx("div",{className:W("bg-sidebar text-sidebar-foreground flex h-full w-[--sidebar-width] flex-col",r),ref:a,...s,children:i}):o?u.jsx(Pd,{open:c,onOpenChange:f,...s,children:u.jsx(Qa,{"data-sidebar":"sidebar","data-mobile":"true",className:"bg-sidebar text-sidebar-foreground w-[--sidebar-width] p-0 [&>button]:hidden",style:{"--sidebar-width":kx},side:e,children:u.jsx("div",{className:"flex h-full w-full flex-col",children:i})})}):u.jsxs("div",{ref:a,className:"group peer text-sidebar-foreground hidden md:block","data-state":l,"data-collapsible":l==="collapsed"?n:"","data-variant":t,"data-side":e,children:[u.jsx("div",{className:W("relative h-svh w-[--sidebar-width] bg-transparent transition-[width] duration-200 ease-linear","group-data-[collapsible=offcanvas]:w-0","group-data-[side=right]:rotate-180",t==="floating"||t==="inset"?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon]")}),u.jsx("div",{className:W("fixed inset-y-0 z-10 hidden h-svh w-[--sidebar-width] transition-[left,right,width] duration-200 ease-linear md:flex",e==="left"?"left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]":"right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",t==="floating"||t==="inset"?"p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4)_+2px)]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon] group-data-[side=left]:border-r group-data-[side=right]:border-l",r),...s,children:u.jsx("div",{"data-sidebar":"sidebar",className:"bg-sidebar group-data-[variant=floating]:border-sidebar-border flex h-full w-full flex-col group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:shadow",children:i})})]})});Fd.displayName="Sidebar";const jx=b.forwardRef(({className:e,onClick:t,...n},r)=>{const{toggleSidebar:i}=cs();return u.jsxs(we,{ref:r,"data-sidebar":"trigger",variant:"ghost",size:"icon",className:W("h-7 w-7",e),onClick:s=>{t==null||t(s),i()},...n,children:[u.jsx(Jm,{}),u.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});jx.displayName="SidebarTrigger";const Nx=b.forwardRef(({className:e,...t},n)=>{const{toggleSidebar:r}=cs();return u.jsx("button",{ref:n,"data-sidebar":"rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:r,title:"Toggle Sidebar",className:W("hover:after:bg-sidebar-border absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] sm:flex","[[data-side=left]_&]:cursor-w-resize [[data-side=right]_&]:cursor-e-resize","[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize","group-data-[collapsible=offcanvas]:hover:bg-sidebar group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full","[[data-side=left][data-collapsible=offcanvas]_&]:-right-2","[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",e),...t})});Nx.displayName="SidebarRail";const Cx=b.forwardRef(({className:e,...t},n)=>u.jsx("main",{ref:n,className:W("bg-background relative flex min-h-svh flex-1 flex-col","peer-data-[variant=inset]:min-h-[calc(100svh-theme(spacing.4))] md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow md:peer-data-[state=collapsed]:peer-data-[variant=inset]:ml-2",e),...t}));Cx.displayName="SidebarInset";const Ex=b.forwardRef(({className:e,...t},n)=>u.jsx(ei,{ref:n,"data-sidebar":"input",className:W("bg-background focus-visible:ring-sidebar-ring h-8 w-full shadow-none focus-visible:ring-2",e),...t}));Ex.displayName="SidebarInput";const Ld=b.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,"data-sidebar":"header",className:W("flex flex-col gap-2 p-2",e),...t}));Ld.displayName="SidebarHeader";const Zd=b.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,"data-sidebar":"footer",className:W("flex flex-col gap-2 p-2",e),...t}));Zd.displayName="SidebarFooter";const Bd=b.forwardRef(({className:e,...t},n)=>u.jsx(Ad,{ref:n,"data-sidebar":"separator",className:W("bg-sidebar-border mx-2 w-auto",e),...t}));Bd.displayName="SidebarSeparator";const Vd=b.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,"data-sidebar":"content",className:W("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",e),...t}));Vd.displayName="SidebarContent";const Si=b.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,"data-sidebar":"group",className:W("relative flex w-full min-w-0 flex-col p-2",e),...t}));Si.displayName="SidebarGroup";const _i=b.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const i=t?lr:"div";return u.jsx(i,{ref:r,"data-sidebar":"group-label",className:W("text-sidebar-foreground/70 ring-sidebar-ring flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium transition-[margin,opa] duration-200 ease-linear outline-none focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",e),...n})});_i.displayName="SidebarGroupLabel";const Ix=b.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const i=t?lr:"button";return u.jsx(i,{ref:r,"data-sidebar":"group-action",className:W("text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground absolute top-3.5 right-3 flex aspect-square w-5 items-center justify-center rounded-md p-0 transition-transform outline-none focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0 cursor-pointer","after:absolute after:-inset-2 after:md:hidden","group-data-[collapsible=icon]:hidden",e),...n})});Ix.displayName="SidebarGroupAction";const _r=b.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,"data-sidebar":"group-content",className:W("w-full text-sm",e),...t}));_r.displayName="SidebarGroupContent";const ba=b.forwardRef(({className:e,...t},n)=>u.jsx("ul",{ref:n,"data-sidebar":"menu",className:W("flex w-full min-w-0 flex-col gap-1",e),...t}));ba.displayName="SidebarMenu";const Ud=b.forwardRef(({className:e,...t},n)=>u.jsx("li",{ref:n,"data-sidebar":"menu-item",className:W("group/menu-item relative",e),...t}));Ud.displayName="SidebarMenuItem";const zx=Qr("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"}}),Jd=b.forwardRef(({asChild:e=!1,isActive:t=!1,variant:n="default",size:r="default",tooltip:i,className:s,...a},o)=>{const l=e?lr:"button",{isMobile:c,state:f}=cs(),d=u.jsx(l,{ref:o,"data-sidebar":"menu-button","data-size":r,"data-active":t,className:W(zx({variant:n,size:r}),s),...a});return i?(typeof i=="string"&&(i={children:i}),u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:d}),u.jsx(Ke,{side:"right",align:"center",hidden:f!=="collapsed"||c,...i})]})):d});Jd.displayName="SidebarMenuButton";const Tx=b.forwardRef(({className:e,asChild:t=!1,showOnHover:n=!1,...r},i)=>{const s=t?lr:"button";return u.jsx(s,{ref:i,"data-sidebar":"menu-action",className:W("text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground peer-hover/menu-button:text-sidebar-accent-foreground absolute top-1.5 right-1 flex aspect-square w-5 items-center justify-center rounded-md p-0 transition-transform outline-none focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0 cursor-pointer","after:absolute after:-inset-2 after:md:hidden","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",n&&"peer-data-[active=true]/menu-button:text-sidebar-accent-foreground group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 md:opacity-0",e),...r})});Tx.displayName="SidebarMenuAction";const Ax=b.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,"data-sidebar":"menu-badge",className:W("text-sidebar-foreground pointer-events-none absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums select-none","peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",e),...t}));Ax.displayName="SidebarMenuBadge";const Px=b.forwardRef(({className:e,showIcon:t=!1,...n},r)=>{const i=b.useMemo(()=>`${Math.floor(Math.random()*40)+50}%`,[]);return u.jsxs("div",{ref:r,"data-sidebar":"menu-skeleton",className:W("flex h-8 items-center gap-2 rounded-md px-2",e),...n,children:[t&&u.jsx(Pr,{className:"size-4 rounded-md","data-sidebar":"menu-skeleton-icon"}),u.jsx(Pr,{className:"h-4 max-w-[--skeleton-width] flex-1","data-sidebar":"menu-skeleton-text",style:{"--skeleton-width":i}})]})});Px.displayName="SidebarMenuSkeleton";const Ox=b.forwardRef(({className:e,...t},n)=>u.jsx("ul",{ref:n,"data-sidebar":"menu-sub",className:W("border-sidebar-border mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l px-2.5 py-0.5","group-data-[collapsible=icon]:hidden",e),...t}));Ox.displayName="SidebarMenuSub";const Dx=b.forwardRef(({...e},t)=>u.jsx("li",{ref:t,...e}));Dx.displayName="SidebarMenuSubItem";const Rx=b.forwardRef(({asChild:e=!1,size:t="md",isActive:n,className:r,...i},s)=>{const a=e?lr:"a";return u.jsx(a,{ref:s,"data-sidebar":"menu-sub-button","data-size":t,"data-active":n,className:W("text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground active:bg-sidebar-accent active:text-sidebar-accent-foreground [&>svg]:text-sidebar-accent-foreground flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 outline-none focus-visible:ring-2 disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 cursor-pointer","data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground",t==="sm"&&"text-xs",t==="md"&&"text-sm","group-data-[collapsible=icon]:hidden",r),...i})});Rx.displayName="SidebarMenuSubButton";function ji(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 Mx=typeof window<"u"?navigator.userAgent.toUpperCase().indexOf("MAC")>=0:!1;function $x({document:e,indicator:t,compact:n=!1}){const r=b.useRef(null),[i,s]=b.useState(!1),[a,o]=b.useState(!1),[l,c]=b.useState(!1),{openDocument:f,documentTypes:d,activeTab:p}=Ae(T=>T),{name:h,text:m,isGenerating:v}=vn(T=>T),y=(d[e.name]||"application/json+report")==="application/json+theme",_=p===e.name,[g,z]=b.useState(h),[C,w]=b.useState(m),E=100,R=0;b.useEffect(()=>{const T=setTimeout(()=>{h&&m?(z(h),w(m)):v||(z(""),w(""))},v?E:R);return()=>clearTimeout(T)},[h,m,v]);const K=g===e.name,j=T=>{var J;const A=new Set;try{const B=JSON.parse(T);(J=B.props)!=null&&J.theme&&A.add(B.props.theme),B.children&&Array.isArray(B.children)&&B.children.forEach(ne=>{var k;ne.name==="docx"&&((k=ne.props)!=null&&k.theme)&&A.add(ne.props.theme)})}catch{}return A},I=b.useMemo(()=>{if(!y||!C)return!1;try{const T=JSON.parse(e.text),A=fa(T);if(A)return j(C).has(A)}catch{}return!1},[y,C,e.text,e.name,g]),O=b.useCallback(()=>{o(!1)},[]),Z=b.useCallback(()=>{c(!1)},[]),M=u.jsxs(Jd,{variant:"default",size:"default",ref:r,className:W("text-sidebar-foreground focus:bg-accent focus:text-accent-foreground w-full",n?"justify-center px-1":"justify-start gap-2",i&&"bg-accent text-accent-foreground",_&&(n?"bg-green-50 text-green-700 dark:bg-green-900/20 dark:text-green-300":"bg-green-50 border-l-2 border-green-500 text-green-700 dark:bg-green-900/20 dark:border-green-400 dark:text-green-300"),K&&!_&&(n?"bg-blue-50 text-blue-700 dark:bg-blue-900/20 dark:text-blue-300":"bg-blue-50 border-l-2 border-blue-500 text-blue-700 dark:bg-blue-900/20 dark:border-blue-400 dark:text-blue-300"),I&&!_&&!K&&(n?"bg-purple-50 text-purple-700 dark:bg-purple-900/20 dark:text-purple-300":"bg-purple-50 border-l-2 border-purple-500 text-purple-700 dark:bg-purple-900/20 dark:border-purple-400 dark:text-purple-300")),title:e.name,onClick:()=>{f(e.name)},onKeyDown:T=>{var A;(T.ctrlKey||T.metaKey)&&T.key==="Enter"?(f(e.name),T.preventDefault()):T.key==="Enter"?(o(!0),T.preventDefault()):T.key==="Backspace"||T.key==="Delete"?(c(!0),T.preventDefault()):T.key==="Escape"&&((A=r.current)==null||A.blur(),T.preventDefault())},children:[_?u.jsx($o,{className:W("size-4","text-green-600 dark:text-green-400")}):K?u.jsx($o,{className:W("size-4","text-blue-600 dark:text-blue-400")}):y?u.jsx(la,{className:"size-4 text-purple-600 dark:text-purple-400"}):u.jsx(Yc,{className:"size-4 text-blue-600 dark:text-blue-400"}),!n&&u.jsx("span",{className:W("truncate flex-1",y&&!_&&!K&&!I&&"text-purple-700 dark:text-purple-300",(_||K||I)&&"font-medium"),children:e.name})]});return u.jsxs(Ud,{children:[u.jsxs(ax,{onOpenChange:s,children:[u.jsx(ox,{children:n?u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:M}),u.jsx(Ke,{side:"right",children:u.jsxs("div",{className:"text-xs",children:[e.name,y?u.jsx("div",{className:"opacity-70",children:"Theme"}):u.jsx("div",{className:"opacity-70",children:"Document"})]})})]}):M}),u.jsxs(Td,{children:[u.jsxs(Sr,{onClick:()=>f(e.name),children:["Open",u.jsx(ki,{children:Mx?"⌘⏎":"⌃⏎"})]}),u.jsx(ya,{}),u.jsx(Sr,{disabled:!e,onClick:()=>{e&&ji(e.name,new Blob([e.text],{type:e.type}))},children:"Download..."}),u.jsx(ya,{}),u.jsxs(Sr,{onClick:()=>o(!0),children:["Rename...",u.jsx(ki,{children:"⏎"})]}),u.jsxs(Sr,{onClick:()=>c(!0),children:["Delete",u.jsx(ki,{children:"⌫"})]})]})]}),u.jsx(It,{open:a,onOpenChange:o,children:u.jsx(St,{className:"sm:max-w-[425px]",onCloseAutoFocus:T=>{var A;T.preventDefault(),(A=r.current)==null||A.focus()},children:u.jsx(Di,{mode:"update",shouldReset:!a,postSubmit:O,selectedName:e.name})})}),u.jsx(It,{open:l,onOpenChange:c,children:u.jsx(St,{className:"sm:max-w-[425px]",onCloseAutoFocus:T=>{var A;T.preventDefault(),(A=r.current)==null||A.focus()},children:u.jsx(Di,{mode:"delete",shouldReset:!l,postSubmit:Z,selectedName:e.name})})})]})}const el=Ee.memo($x);async function Fx(e,t){const n=JSON.stringify({name:e,props:t,children:[]},null,2);await navigator.clipboard.writeText(n)}const Fr=b.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Ac,{ref:r,className:W("relative overflow-hidden",e),...n,children:[u.jsx(Sm,{className:"h-full w-full rounded-[inherit]",children:t}),u.jsx(Hd,{}),u.jsx(_m,{})]}));Fr.displayName=Ac.displayName;const Hd=b.forwardRef(({className:e,orientation:t="vertical",...n},r)=>u.jsx(Pc,{ref:r,orientation:t,className:W("flex touch-none transition-colors select-none",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:u.jsx(jm,{className:"bg-border relative flex-1 rounded-full"})}));Hd.displayName=Pc.displayName;function eo({className:e,...t}){return u.jsx(Nm,{"data-slot":"switch",className:W("peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 cursor-pointer",e),...t,children:u.jsx(Cm,{"data-slot":"switch-thumb",className:W("bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0")})})}const Lx=Qr("relative w-full rounded-lg 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-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}}),Ri=b.forwardRef(({className:e,variant:t,...n},r)=>u.jsx("div",{ref:r,role:"alert",className:W(Lx({variant:t}),e),...n}));Ri.displayName="Alert";const Zx=b.forwardRef(({className:e,...t},n)=>u.jsx("h5",{ref:n,className:W("mb-1 font-medium leading-none tracking-tight",e),...t}));Zx.displayName="AlertTitle";const Mi=b.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:W("text-sm [&_p]:leading-relaxed",e),...t}));Mi.displayName="AlertDescription";const $i=b.memo(({keyName:e,value:t,depth:n=0,isLast:r=!1})=>{const[i,s]=b.useState(n<2),a=t!==null&&typeof t=="object",o=Array.isArray(t),l=()=>s(!i),c=()=>t===null?u.jsx("span",{className:"text-orange-500",children:"null"}):t===void 0?u.jsx("span",{className:"text-gray-500",children:"undefined"}):typeof t=="boolean"?u.jsx("span",{className:"text-blue-500",children:String(t)}):typeof t=="number"?u.jsx("span",{className:"text-green-500",children:t}):typeof t=="string"?t.startsWith("http")?u.jsxs("span",{className:"text-purple-500",children:['"',t,'"']}):t.startsWith("#/")?u.jsxs("span",{className:"text-cyan-500",children:['"',t,'"']}):u.jsxs("span",{className:"text-amber-600",children:['"',t,'"']}):null,f=a?Object.keys(t).length:0;return u.jsxs("div",{className:W("text-sm",n>0&&"ml-4"),children:[u.jsxs("div",{className:"flex items-start hover:bg-muted/30 rounded px-1 py-0.5",children:[a&&u.jsx("button",{onClick:l,className:"mr-1 hover:bg-muted rounded p-0.5","aria-label":i?"Collapse":"Expand",children:i?u.jsx(on,{className:"h-3 w-3"}):u.jsx(ss,{className:"h-3 w-3"})}),!a&&u.jsx("span",{className:"w-4"}),e&&u.jsxs(u.Fragment,{children:[u.jsxs("span",{className:"text-blue-600 dark:text-blue-400",children:['"',e,'"']}),u.jsx("span",{className:"mx-1",children:":"})]}),a?u.jsxs("span",{className:"text-muted-foreground",children:[o?"[":"{",!i&&u.jsxs("span",{className:"mx-1 text-xs",children:[f," ",o?"items":"properties"]}),!i&&(o?"]":"}")]}):c(),!a&&!r&&u.jsx("span",{className:"text-muted-foreground",children:","})]}),a&&i&&u.jsxs("div",{className:"ml-4",children:[o?t.map((d,p)=>u.jsx($i,{keyName:String(p),value:d,depth:n+1,isLast:p===t.length-1},p)):Object.entries(t).map(([d,p],h,m)=>u.jsx($i,{keyName:d,value:p,depth:n+1,isLast:h===m.length-1},d)),u.jsx("div",{className:"ml-4",children:u.jsxs("span",{className:"text-muted-foreground",children:[o?"]":"}",!r&&","]})})]})]})});$i.displayName="JsonNode";const Fi=b.memo(({schema:e,loading:t=!1,error:n,className:r})=>t?u.jsxs("div",{className:W("space-y-4",r),children:[u.jsx(Pr,{className:"h-8 w-64"}),u.jsx(Pr,{className:"h-4 w-full"}),u.jsx(Pr,{className:"h-64 w-full"})]}):n?u.jsx(Ri,{variant:"destructive",className:r,children:u.jsx(Mi,{children:n})}):e?u.jsx(Fr,{className:W("h-full w-full rounded-md border bg-muted/10 p-4",r),children:u.jsx("div",{className:"font-mono text-xs",children:u.jsx($i,{value:e})})}):u.jsx(Ri,{className:r,children:u.jsx(Mi,{children:"No schema available"})}));Fi.displayName="SchemaViewer";function Bx({plugins:e,initialFocusedPlugin:t}){var g,z;const n=Dt(C=>C.togglePlugin),r=Dt(C=>C.isPluginSelected),i=Dt(C=>C.selectedPlugins),s=Dt(C=>C.isApplyingPlugins),[a,o]=b.useState(null),[l,c]=b.useState(null),[f,d]=b.useState("properties");b.useEffect(()=>{if(t){const C=e.find(w=>w.name===t);if(C){o(C);return}}e.length>0&&!a&&o(e[0])},[t,e]);const p=b.useMemo(()=>{const C={current:[],downstream:[],upstream:[]};return e.forEach(w=>{C[w.location]&&C[w.location].push(w)}),C},[e]),h=async(C,w)=>{a&&(await Fx(a.name,C.props),c(w),setTimeout(()=>c(null),2e3))},m=C=>{switch(C){case"current":return"Current Directory";case"downstream":return"Project";case"upstream":return"Parent Directories";default:return C}},v=C=>{switch(C){case"current":return u.jsx(Km,{className:"size-3"});case"downstream":return u.jsx(Gm,{className:"size-3"});case"upstream":return u.jsx(Yc,{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,y=(z=a==null?void 0:a.schema)==null?void 0:z.jsonSchema,_=(a==null?void 0:a.examples)&&a.examples.length>0;return u.jsxs(u.Fragment,{children:[u.jsxs(Ut,{children:[u.jsxs(Jt,{className:"flex items-center gap-2",children:[u.jsx(Xc,{className:"size-5 text-amber-600 dark:text-amber-400"}),"Plugins",u.jsxs(Vt,{variant:"secondary",className:"font-normal",children:[i.size," active"]})]}),u.jsxs(cn,{children:[e.length," plugin",e.length!==1?"s":""," discovered in your project"]})]}),u.jsxs("div",{className:"mt-3 flex gap-0 h-[600px] border rounded-lg overflow-hidden",children:[u.jsx("div",{className:"w-[240px] flex-none border-r bg-muted/30",children:u.jsx(Fr,{className:"h-full",children:u.jsx("div",{className:"p-2 space-y-3",children:Object.entries(p).map(([C,w])=>w.length===0?null:u.jsxs("div",{children:[u.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1 text-[11px] font-medium text-muted-foreground uppercase tracking-wider",children:[v(C),m(C)]}),u.jsx("div",{className:"space-y-0.5",children:w.map(E=>{const R=r(E.name),K=(a==null?void 0:a.name)===E.name;return u.jsxs("button",{onClick:()=>o(E),className:W("w-full text-left px-2 py-1.5 rounded-md transition-colors cursor-pointer","flex items-center gap-2",K?"bg-accent text-accent-foreground":"hover:bg-accent/50 text-foreground"),children:[u.jsx("div",{className:W("size-1.5 rounded-full flex-none transition-colors",R?"bg-amber-500 dark:bg-amber-400":"bg-muted-foreground/30")}),u.jsx("span",{className:"text-sm font-medium truncate flex-1",children:E.name})]},E.name)})})]},C))})})}),a?u.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[u.jsxs("div",{className:"flex-none px-5 py-4 border-b bg-background",children:[u.jsxs("div",{className:"flex items-start justify-between gap-3",children:[u.jsxs("div",{className:"min-w-0",children:[u.jsxs("div",{className:"flex items-center gap-2.5",children:[u.jsx("h3",{className:"text-base font-semibold truncate",children:a.name}),a.version&&u.jsxs(Vt,{variant:"outline",className:"font-mono text-[11px] flex-none",children:["v",a.version]})]}),a.description&&u.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:a.description})]}),u.jsxs("div",{className:"flex items-center gap-2 flex-none pt-0.5",children:[u.jsx("span",{className:"text-xs text-muted-foreground",children:r(a.name)?"On":"Off"}),u.jsx(eo,{checked:r(a.name),onCheckedChange:()=>n(a),disabled:s,"aria-label":`Toggle ${a.name}`})]})]}),u.jsxs("div",{className:"flex items-center gap-1.5 mt-2 text-xs text-muted-foreground",children:[v(a.location),u.jsx("span",{children:m(a.location)}),u.jsx("span",{className:"text-muted-foreground/60 mx-1",children:"/"}),u.jsx("span",{className:"font-mono truncate",children:a.relativePath})]})]}),u.jsxs("div",{className:"flex-none px-5 pt-3 pb-0 flex gap-1 border-b bg-background",children:[S&&u.jsx("button",{onClick:()=>d("properties"),className:W("px-3 py-1.5 text-sm font-medium rounded-t-md border-b-2 transition-colors cursor-pointer",f==="properties"?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),children:u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(Fo,{className:"size-3.5"}),"Properties"]})}),y&&u.jsx("button",{onClick:()=>d("schema"),className:W("px-3 py-1.5 text-sm font-medium rounded-t-md border-b-2 transition-colors cursor-pointer",f==="schema"?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),children:u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(Hm,{className:"size-3.5"}),"Schema"]})}),_&&u.jsx("button",{onClick:()=>d("examples"),className:W("px-3 py-1.5 text-sm font-medium rounded-t-md border-b-2 transition-colors cursor-pointer",f==="examples"?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),children:u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(Wm,{className:"size-3.5"}),"Examples",u.jsx(Vt,{variant:"secondary",className:"text-[10px] px-1.5 py-0 h-4",children:a.examples.length})]})})]}),u.jsx(Fr,{className:"flex-1",children:u.jsxs("div",{className:"p-5",children:[f==="properties"&&S&&u.jsx("div",{className:"space-y-1",children:Object.entries(a.schema.properties).map(([C,w])=>u.jsx(Vx,{name:C,prop:w},C))}),f==="schema"&&y&&u.jsx(Fi,{schema:a.schema.jsonSchema,loading:!1,className:"h-[420px]"}),f==="examples"&&_&&a.examples.map((C,w)=>u.jsxs("div",{className:W(w>0&&"mt-4 pt-4 border-t"),children:[u.jsxs("div",{className:"flex items-center justify-between mb-2",children:[u.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[C.title&&u.jsx("span",{className:"font-medium text-sm truncate",children:C.title}),!C.title&&u.jsxs("span",{className:"text-sm text-muted-foreground",children:["Example ",w+1]})]}),u.jsx(we,{size:"sm",variant:"ghost",className:"h-7 px-2 text-xs flex-none",onClick:()=>h(C,w),children:l===w?u.jsxs(u.Fragment,{children:[u.jsx(qm,{className:"size-3 mr-1 text-green-600"}),"Copied"]}):u.jsxs(u.Fragment,{children:[u.jsx(as,{className:"size-3 mr-1"}),"Copy"]})})]}),C.description&&u.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:C.description}),u.jsx("pre",{className:"p-3 bg-muted rounded-md overflow-x-auto text-xs font-mono leading-relaxed",children:JSON.stringify(C.props,null,2)})]},w)),!S&&!y&&!_&&u.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[u.jsx(Fo,{className:"size-10 mx-auto mb-3 opacity-20"}),u.jsx("p",{className:"text-sm",children:"No schema or examples available for this plugin"})]})]})})]}):u.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:u.jsx("p",{className:"text-sm",children:"Select a plugin to view details"})})]})]})}function Vx({name:e,prop:t}){var a;const[n,r]=b.useState(!1),i=t.description||t.enum||t.default!==void 0||t.items||t.properties,s=t.type||(t.enum?"enum":t.oneOf?"oneOf":"—");return u.jsxs("div",{className:"rounded-md border",children:[u.jsxs("button",{onClick:()=>i&&r(!n),className:W("w-full text-left flex items-center gap-2 px-3 py-2 text-sm",i&&"cursor-pointer hover:bg-muted/50"),children:[i?n?u.jsx(on,{className:"size-3 text-muted-foreground flex-none"}):u.jsx(ss,{className:"size-3 text-muted-foreground flex-none"}):u.jsx("span",{className:"size-3 flex-none"}),u.jsx("span",{className:"font-mono font-medium text-xs",children:e}),u.jsx(Vt,{variant:"outline",className:"text-[10px] px-1.5 py-0 h-4 flex-none",children:s}),t.optional===!1&&u.jsx("span",{className:"text-[10px] text-red-500 font-medium flex-none",children:"required"}),u.jsx("span",{className:"flex-1"}),t.default!==void 0&&u.jsxs("span",{className:"text-[10px] font-mono text-muted-foreground flex-none",children:["= ",JSON.stringify(t.default)]})]}),n&&i&&u.jsxs("div",{className:"px-3 pb-2 pt-0 ml-5 text-xs space-y-1 text-muted-foreground",children:[t.description&&u.jsx("p",{children:t.description}),t.enum&&u.jsxs("p",{children:[u.jsx("span",{className:"font-medium text-foreground",children:"Values: "}),t.enum.map((o,l)=>u.jsxs("span",{children:[l>0&&", ",u.jsx("code",{className:"bg-muted px-1 rounded",children:JSON.stringify(o)})]},l))]}),((a=t.items)==null?void 0:a.type)&&u.jsxs("p",{children:[u.jsx("span",{className:"font-medium text-foreground",children:"Items: "}),t.items.type]})]})]})}const As=Em,Ps=Im,Os=zm,to=Tm,no=Am,Ux=b.forwardRef(({className:e,inset:t,children:n,...r},i)=>u.jsxs($c,{ref:i,className:W("focus:bg-accent data-[state=open]:bg-accent flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none select-none [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",t&&"pl-8",e),...r,children:[n,u.jsx(ss,{className:"ml-auto"})]}));Ux.displayName=$c.displayName;const Jx=b.forwardRef(({className:e,...t},n)=>u.jsx(Fc,{ref:n,className:W("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] overflow-hidden rounded-md border p-1 shadow-lg",e),...t}));Jx.displayName=Fc.displayName;const ds=b.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(Pm,{children:u.jsx(Oc,{ref:r,sideOffset:t,className:W("bg-popover text-popover-foreground z-50 min-w-[8rem] overflow-hidden rounded-md 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})}));ds.displayName=Oc.displayName;const Kt=b.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Dc,{ref:r,className:W("focus:bg-accent focus:text-accent-foreground relative flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-sm transition-colors outline-none select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>svg]:size-4 [&>svg]:shrink-0",t&&"pl-8",e),...n}));Kt.displayName=Dc.displayName;const Hx=b.forwardRef(({className:e,children:t,checked:n,...r},i)=>u.jsxs(Lc,{ref:i,className:W("focus:bg-accent focus:text-accent-foreground relative flex cursor-pointer items-center rounded-sm py-1.5 pr-2 pl-8 text-sm transition-colors outline-none select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(Zc,{children:u.jsx(un,{className:"h-4 w-4"})})}),t]}));Hx.displayName=Lc.displayName;const Wx=b.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Bc,{ref:r,className:W("focus:bg-accent focus:text-accent-foreground relative flex cursor-pointer items-center rounded-sm py-1.5 pr-2 pl-8 text-sm transition-colors outline-none select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(Zc,{children:u.jsx(Kc,{className:"h-2 w-2 fill-current"})})}),t]}));Wx.displayName=Bc.displayName;const Wd=b.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Mc,{ref:r,className:W("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));Wd.displayName=Mc.displayName;const Lr=b.forwardRef(({className:e,...t},n)=>u.jsx(Rc,{ref:n,className:W("bg-muted -mx-1 my-1 h-px",e),...t}));Lr.displayName=Rc.displayName;function qx(){const{theme:e,setTheme:t}=Wc(),n=e==="system"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":e,r=b.useCallback(()=>{t(n==="dark"?"light":"dark")},[n,t]);return u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsxs(we,{variant:"ghost",size:"icon",onClick:r,children:[u.jsx(Ym,{className:"hidden dark:block"}),u.jsx(Xm,{className:"block dark:hidden"}),u.jsx("span",{className:"sr-only",children:"Toggle theme"})]})}),u.jsx(Ke,{children:u.jsx("p",{children:"Toggle theme"})})]})}const qd=Om,ro=b.forwardRef(({className:e,...t},n)=>u.jsx(Vc,{ref:n,className:W("bg-muted text-muted-foreground inline-flex h-9 items-center justify-center rounded-lg p-1",e),...t}));ro.displayName=Vc.displayName;const Zr=b.forwardRef(({className:e,...t},n)=>u.jsx(Uc,{ref:n,className:W("ring-offset-background focus-visible:ring-ring data-[state=active]:bg-background data-[state=active]:text-foreground inline-flex cursor-pointer items-center justify-center rounded-md 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 data-[state=active]:shadow",e),...t}));Zr.displayName=Uc.displayName;const Br=b.forwardRef(({className:e,...t},n)=>u.jsx(Jc,{ref:n,className:W("ring-offset-background focus-visible:ring-ring mt-2 focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none",e),...t}));Br.displayName=Jc.displayName;async function Gx(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 Kx(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 Yx(e){const t=Kx(e);return Gx(t)}const Gd=({open:e,onOpenChange:t,defaultTab:n="document"})=>{const[r,i]=b.useState(n),[s,a]=b.useState(null),[o,l]=b.useState(null),[c,f]=b.useState(!1),[d,p]=b.useState(!1),[h,m]=b.useState(null),[v,S]=b.useState(null),[y,_]=b.useState(!1),{toast:g}=ur(),z=Dt(Z=>Z.selectedPlugins),C=Array.from(z);b.useEffect(()=>{n&&i(n)},[n]);const w=b.useCallback(async()=>{f(!0),m(null);try{const Z=await Ns.fetchDocumentSchema(C);a(Z)}catch(Z){const M=Z instanceof Error?Z.message:"Failed to load document schema";m(M),g({variant:"destructive",title:"Error loading schema",description:M})}finally{f(!1)}},[C,g]),E=b.useCallback(async()=>{if(!o){p(!0),S(null);try{const Z=await Ns.fetchThemeSchema();l(Z)}catch(Z){const M=Z instanceof Error?Z.message:"Failed to load theme schema";S(M),g({variant:"destructive",title:"Error loading schema",description:M})}finally{p(!1)}}},[o,g]),[R,K]=b.useState([]);b.useEffect(()=>{e||(a(null),m(null))},[e]),b.useEffect(()=>{if(!e)return;const Z=C.length!==R.length||C.some((M,T)=>M!==R[T]);r==="document"?(!s||Z)&&(Z&&(Ns.clearPluginSchemaCache(),K([...C])),c||w()):r==="theme"&&!o&&!d&&E()},[r,e,s,o,c,d,C,R,w,E]);const j=C.length,I=r==="document"?s:o,O=async()=>{if(I)try{await Yx(I)&&(_(!0),g({title:"Schema copied",description:"The JSON schema has been copied to your clipboard"}),setTimeout(()=>_(!1),2e3))}catch(Z){console.error("Copy failed:",Z)}};return u.jsx(It,{open:e,onOpenChange:t,children:u.jsxs(St,{className:"max-w-4xl max-h-[90vh] overflow-hidden flex flex-col",children:[u.jsx(Ut,{children:u.jsx(Jt,{children:"Schema Viewer"})}),u.jsxs(qd,{value:r,onValueChange:Z=>i(Z),className:"flex-1 overflow-hidden flex flex-col",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs(ro,{children:[u.jsxs(Zr,{value:"document",className:"flex items-center gap-1",children:["Document",j>0&&u.jsxs(Vt,{variant:"secondary",className:"ml-1 text-xs px-1 py-0",children:["+",j]})]}),u.jsx(Zr,{value:"theme",children:"Theme"})]}),u.jsx("div",{className:"ml-auto",children:u.jsx(we,{variant:"ghost",size:"icon",onClick:O,disabled:y||!I,"aria-label":"Copy schema",children:y?u.jsx(un,{className:"h-4 w-4"}):u.jsx(as,{className:"h-4 w-4"})})})]}),u.jsxs("div",{className:"flex-1 overflow-auto mt-4",children:[u.jsx(Br,{value:"document",className:"h-full",children:u.jsx(Fi,{schema:s,loading:c,error:h||void 0})}),u.jsx(Br,{value:"theme",className:"h-full",children:u.jsx(Fi,{schema:o,loading:d,error:v||void 0})})]})]})]})})};function Xx({discoveryData:e,onToggleSidebar:t,isCollapsed:n=!1,isAnimating:r=!1}){const{documents:i,documentTypes:s,createDocument:a,openDocument:o}=Ae(ad($=>({documents:$.documents,documentTypes:$.documentTypes,createDocument:$.createDocument,openDocument:$.openDocument}))),l=da($=>$.updateTheme),c=da($=>$.removeTheme),f=b.useContext(sd),[d,p]=b.useState(!1),[h,m]=b.useState(!1),[v,S]=b.useState(!1),[y,_]=b.useState(null),g=Dt($=>$.togglePlugin),z=Dt($=>$.isPluginSelected),C=Dt($=>$.selectedPlugins),w=Dt($=>$.isApplyingPlugins),[E,R]=b.useState(!1),[K,j]=b.useState(!1),[I,O]=b.useState(new Set(["current-docs","current-themes"])),{toast:Z}=ur(),M=i.filter($=>s[$.name]!=="application/json+theme"),T=i.filter($=>s[$.name]==="application/json+theme"),A=b.useMemo(()=>{if(!e)return{current:[],downstream:[]};const $={current:[],downstream:[]};return e.documents.forEach(ee=>{$[ee.location]&&$[ee.location].push(ee)}),$},[e]),J=b.useMemo(()=>{if(!e)return{current:[],downstream:[]};const $={current:[],downstream:[]};return e.themes.forEach(ee=>{$[ee.location]&&$[ee.location].push(ee)}),$},[e]),B=b.useMemo(()=>{const $=new Set;return M.forEach(ee=>{try{const V=JSON.parse(ee.text);V.children&&Array.isArray(V.children)&&V.children.forEach(se=>{var le;se.name==="docx"&&((le=se.props)!=null&&le.theme)&&$.add(se.props.theme)})}catch{}}),$},[M]),ne=b.useCallback(()=>{p(!1)},[]),k=b.useCallback(()=>{m(!1)},[]),ce=b.useRef(new Map);b.useEffect(()=>{const $=ce.current,ee=new Map;T.forEach(V=>{ee.set(V.name,V.text),$.get(V.name)!==V.text&&l(V.name,V.text)}),$.forEach((V,se)=>{ee.has(se)||c(se)}),ce.current=ee},[T,l,c]);const de=b.useRef(!1);b.useEffect(()=>{if(de.current||!f)return;de.current=!0;const $=new Set(T.map(V=>V.name));Object.keys(f.getState().customThemes).forEach(V=>{$.has(V)||c(V)})},[T,c,f]);const x=$=>{O(ee=>{const V=new Set(ee);return V.has($)?V.delete($):V.add($),V})},H=Ae($=>$.activeTab),G=H&&s[H]==="application/json+theme"?"theme":"document",{resolvedTheme:ie}=Wc(),ae=ie==="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",Q=b.useCallback(async($,ee)=>{if(i.some(V=>V.name===$)){o($);return}try{const V=await fetch(`/api/discovery/${ee?"themes":"documents"}/${encodeURIComponent($)}/content`);if(!V.ok)throw new Error(V.statusText);const se=await V.text(),le=JSON.parse(se);a($,JSON.stringify(le,null,2)),o($),Z({title:`Added ${ee?"theme":"document"}: ${$}`})}catch{Z({title:"Failed to load",description:`Could not load ${$}`,variant:"destructive"})}},[i,a,o,Z]);return u.jsxs(u.Fragment,{children:[u.jsxs(Fd,{collapsible:"none",style:{"--sidebar-width":n?"3rem":"16rem"},children:[u.jsx(Ld,{children:u.jsx("div",{className:W("flex items-center transition-opacity duration-150 ease-out",r?"opacity-0":"opacity-100",n?"justify-center":"justify-between"),children:n?u.jsx(we,{variant:"ghost",size:"icon","aria-label":"Expand sidebar","aria-expanded":!1,onClick:t,children:u.jsx(Qc,{className:"h-4 w-4"})}):u.jsxs(u.Fragment,{children:[u.jsx("a",{href:"/",className:"flex items-center pl-2",children:u.jsx("img",{src:ae,alt:"WiseAir logo",className:"h-5 w-auto max-w-[120px] shrink-0"})}),u.jsx("div",{className:"flex items-center gap-1",children:u.jsx(we,{variant:"ghost",size:"icon","aria-label":"Collapse sidebar","aria-expanded":!0,onClick:t,children:u.jsx(Qm,{className:"h-4 w-4"})})})]})})}),u.jsxs(Vd,{className:W("h-full transition-opacity duration-150 ease-out",r?"opacity-0":"opacity-100"),children:[u.jsxs(Si,{children:[u.jsxs(_i,{className:W("flex items-center",n?"justify-center":"justify-between"),children:[u.jsxs("div",{className:"flex items-center gap-2",children:[!n&&u.jsx(Lo,{className:"size-3"}),!n&&u.jsx("span",{children:"Active Documents"})]}),u.jsxs("div",{className:"flex items-center gap-0.5",children:[yt==="docx"&&!n&&u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsx(we,{className:"h-6 w-6 p-0 flex-shrink-0",variant:"ghost",size:"icon","aria-label":"Compare documents",disabled:M.length<2,onClick:()=>j(!0),children:u.jsx(Gc,{className:"size-4"})})}),u.jsx(Ke,{side:"bottom",children:u.jsx("span",{className:"text-xs",children:M.length<2?"Compare needs two documents":"Compare documents (redline)"})})]}),u.jsxs(It,{open:d,onOpenChange:p,children:[u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsx(Bo,{asChild:!0,children:u.jsx(we,{className:W("p-0 flex-shrink-0",n?"mx-auto h-8 w-8 rounded border border-dashed border-sidebar-foreground/20 hover:border-sidebar-foreground/40":"h-6 w-6"),variant:"ghost",size:"icon",children:u.jsx(zi,{className:n?"size-3.5":"size-4"})})})}),u.jsx(Ke,{side:n?"right":"bottom",children:u.jsx("span",{className:"text-xs",children:"New Document"})})]}),u.jsx(St,{className:"sm:max-w-[525px]",children:u.jsx(Di,{mode:"create",shouldReset:!d,postSubmit:ne,discoveredDocuments:(e==null?void 0:e.documents)||[]})})]})]})]}),n?u.jsx(_r,{children:u.jsx("div",{className:"flex flex-col items-center gap-0.5 px-0.5",children:M.map($=>{const ee=H===$.name;return u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsxs("button",{onClick:()=>o($.name),"aria-label":$.name,className:W("relative w-8 h-8 rounded flex items-center justify-center text-[11px] font-bold transition-colors cursor-pointer",ee?"bg-green-100 text-green-700 dark:bg-green-900/40 dark:text-green-300":"text-muted-foreground hover:bg-accent hover:text-accent-foreground"),children:[ee&&u.jsx("span",{className:"absolute left-0 top-1 bottom-1 w-0.5 rounded-full bg-green-500 dark:bg-green-400"}),$.name.replace(/\.[^.]+$/,"").slice(0,2).toUpperCase()]})}),u.jsx(Ke,{side:"right",children:u.jsx("span",{className:"text-xs",children:$.name})})]},$.name)})})}):u.jsx(_r,{children:u.jsx(ba,{children:M.length>0?M.map(($,ee)=>u.jsx(el,{document:$,compact:n},`doc-${ee}`)):u.jsx("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"No active documents. Click + to create one."})})})]}),u.jsx(Bd,{}),u.jsxs(Si,{children:[u.jsxs(_i,{className:W("flex items-center",n?"justify-center":"justify-between"),children:[u.jsxs("div",{className:"flex items-center gap-2",children:[!n&&u.jsx(la,{className:"size-3 text-purple-600 dark:text-purple-400"}),!n&&u.jsx("span",{children:"Active Themes"})]}),u.jsxs(It,{open:h,onOpenChange:m,children:[u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsx(Bo,{asChild:!0,children:u.jsx(we,{className:W("p-0 flex-shrink-0",n?"mx-auto h-8 w-8 rounded border border-dashed border-sidebar-foreground/20 hover:border-sidebar-foreground/40":"h-6 w-6"),variant:"ghost",size:"icon",children:u.jsx(zi,{className:n?"size-3.5":"size-4"})})})}),u.jsx(Ke,{side:n?"right":"bottom",children:u.jsx("span",{className:"text-xs",children:"New Theme"})})]}),u.jsx(St,{className:"sm:max-w-[525px]",children:u.jsx(Di,{mode:"create",shouldReset:!h,postSubmit:k,discoveredThemes:(e==null?void 0:e.themes)||[],isTheme:!0})})]})]}),n?u.jsx(_r,{children:u.jsx("div",{className:"flex flex-col items-center gap-0.5 px-0.5",children:T.map($=>{const ee=H===$.name;let V=null;try{const le=JSON.parse($.text);V=fa(le)}catch{}const se=V?B.has(V):!1;return u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsxs("button",{onClick:()=>o($.name),"aria-label":$.name,className:W("relative w-8 h-8 rounded flex items-center justify-center text-[11px] font-bold transition-colors cursor-pointer",ee?"bg-purple-100 text-purple-700 dark:bg-purple-900/40 dark:text-purple-300":se?"bg-purple-50 text-purple-600 dark:bg-purple-900/20 dark:text-purple-400":"text-muted-foreground hover:bg-accent hover:text-accent-foreground"),children:[ee&&u.jsx("span",{className:"absolute left-0 top-1 bottom-1 w-0.5 rounded-full bg-purple-500 dark:bg-purple-400"}),(V||$.name).charAt(0).toUpperCase()]})}),u.jsx(Ke,{side:"right",children:u.jsxs("div",{className:"text-xs",children:[$.name,se&&u.jsx("div",{className:"opacity-70",children:"In use"})]})})]},$.name)})})}):u.jsx(_r,{children:u.jsx(ba,{children:T.length>0?T.map(($,ee)=>{let V=null;try{const le=JSON.parse($.text);V=fa(le)}catch{}const se=V?B.has(V):!1;return u.jsx(el,{document:$,compact:n,indicator:se?"in-use":void 0},`theme-${ee}`)}):u.jsxs("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:["No active themes."," ",e&&e.themes.length>0?"Click + to add one.":"No themes discovered in project."]})})})]}),!n&&e&&(e.documents.length>0||e.themes.length>0)&&u.jsxs(Si,{className:"mt-2 border-t pt-4",children:[u.jsxs(_i,{className:"flex items-center mb-2 gap-2",children:[u.jsx(eg,{className:"size-3"}),u.jsx("span",{children:"Discovered Resources"})]}),u.jsxs(u.Fragment,{children:[Object.entries(A).map(([$,ee])=>{if(ee.length===0)return null;const V=`${$}-docs`,se=I.has(V);return u.jsxs(As,{open:se,children:[u.jsxs(Ps,{className:"flex items-center gap-1 px-3 py-1 text-xs font-medium text-muted-foreground hover:text-foreground transition-colors cursor-pointer w-full",onClick:()=>x(V),children:[u.jsx(on,{className:W("size-3 transition-transform",!se&&"-rotate-90")}),u.jsx(Lo,{className:"size-3"}),$==="current"?"Current Directory":"Project"," ","Documents (",ee.length,")"]}),u.jsx(Os,{children:u.jsx("div",{className:"pl-4 space-y-0.5",children:ee.map((le,ge)=>{const Oe=i.some(We=>We.name===le.name);return u.jsxs("button",{onClick:()=>Q(le.name,!1),className:W("w-full text-left py-1 px-2 rounded text-sm transition-colors","border-l-2 border-blue-400/60 dark:border-blue-500/40","hover:bg-accent hover:text-accent-foreground",Oe&&"opacity-50"),children:[u.jsx("div",{className:"font-medium truncate",children:le.name}),le.title&&u.jsx("div",{className:"text-xs text-muted-foreground truncate",children:le.title})]},ge)})})})]},V)}),Object.entries(J).map(([$,ee])=>{if(ee.length===0)return null;const V=`${$}-themes`,se=I.has(V);return u.jsxs(As,{open:se,children:[u.jsxs(Ps,{className:"flex items-center gap-1 px-3 py-1 text-xs font-medium text-muted-foreground hover:text-foreground transition-colors cursor-pointer w-full",onClick:()=>x(V),children:[u.jsx(on,{className:W("size-3 transition-transform",!se&&"-rotate-90")}),u.jsx(la,{className:"size-3"}),$==="current"?"Current Directory":"Project"," ","Themes (",ee.length,")"]}),u.jsx(Os,{children:u.jsx("div",{className:"pl-4 space-y-0.5",children:ee.map((le,ge)=>{const Oe=i.some(We=>We.name===le.name);return u.jsxs("button",{onClick:()=>Q(le.name,!0),className:W("w-full text-left py-1 px-2 rounded text-sm transition-colors","border-l-2 border-purple-400/60 dark:border-purple-500/40","hover:bg-accent hover:text-accent-foreground",Oe&&"opacity-50"),children:[u.jsx("div",{className:"font-medium truncate",children:le.name}),le.description&&u.jsx("div",{className:"text-xs text-muted-foreground truncate",children:le.description})]},ge)})})})]},V)}),e&&e.plugins.length>0&&u.jsxs(As,{open:I.has("plugins"),children:[u.jsxs(Ps,{className:"flex items-center gap-1 px-3 py-1 text-xs font-medium text-muted-foreground hover:text-foreground transition-colors cursor-pointer w-full",onClick:()=>x("plugins"),children:[u.jsx(on,{className:W("size-3 transition-transform",!I.has("plugins")&&"-rotate-90")}),u.jsx(Xc,{className:"size-3 text-amber-600 dark:text-amber-400"}),"Plugins (",C.size,"/",e.plugins.length,")"]}),u.jsx(Os,{children:u.jsx("div",{className:"pl-4 space-y-0.5",children:e.plugins.map(($,ee)=>{const V=z($.name);return u.jsxs("div",{className:W("py-1 px-2 text-sm border-l-2 flex items-center gap-2 group transition-colors",V?"border-amber-500 dark:border-amber-400 text-foreground":"border-amber-400/30 dark:border-amber-500/20 text-muted-foreground"),children:[u.jsxs("div",{className:"flex-1 min-w-0",children:[u.jsx("div",{className:"font-medium truncate",children:$.name}),$.description&&u.jsx("div",{className:"text-xs opacity-70 truncate",children:$.description})]}),u.jsx("button",{className:"flex-none size-5 flex items-center justify-center rounded-sm opacity-0 group-hover:opacity-100 hover:bg-accent transition-all cursor-pointer",title:`View details for ${$.name}`,onClick:se=>{se.stopPropagation(),_($.name),S(!0)},children:u.jsx(ed,{className:"size-3 text-muted-foreground"})}),u.jsx(eo,{checked:V,onCheckedChange:()=>g($),disabled:w,className:"flex-none scale-[0.8]","aria-label":`Toggle ${$.name} plugin`})]},ee)})})})]})]})]})]}),u.jsx(Zd,{children:u.jsx("div",{className:W("flex w-full items-center transition-opacity duration-150 ease-out",r?"opacity-0":"opacity-100",n?"justify-center":"justify-end pr-2"),children:u.jsx(qx,{})})}),u.jsx(It,{open:v,onOpenChange:$=>{S($),$||_(null)},children:u.jsx(St,{className:"sm:max-w-5xl max-h-[85vh] overflow-hidden",children:u.jsx(Bx,{plugins:(e==null?void 0:e.plugins)||[],initialFocusedPlugin:y})})})]}),u.jsx(Gd,{open:E,onOpenChange:R,defaultTab:G==="theme"?"theme":"document"}),u.jsx(zg,{open:K,onOpenChange:j})]})}const tl=b.memo(Xx),Qx=b.lazy(()=>qc(()=>import("./editor-CZUatu7z.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11])).then(e=>({default:e.Editor})));function nl(){return u.jsx(b.Suspense,{fallback:u.jsx("div",{className:"flex items-center justify-center h-full",children:u.jsxs("div",{className:"text-center",children:[u.jsx(Yt,{className:"w-8 h-8 mx-auto mb-2"}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading editor..."})]})}),children:u.jsx(Qx,{})})}const ey=b.lazy(()=>qc(()=>import("./preview-DYuTX4mt.js"),__vite__mapDeps([12,1,3,4,5,6,7,8,9,10,11])).then(e=>({default:e.Preview})));function rl(){return u.jsx(b.Suspense,{fallback:u.jsx("div",{className:"flex items-center justify-center h-full",children:u.jsxs("div",{className:"text-center",children:[u.jsx(Yt,{className:"w-8 h-8 mx-auto mb-2"}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading preview..."})]})}),children:u.jsx(ey,{})})}const{createElement:rr,createContext:ty,forwardRef:Kd,useCallback:pt,useContext:Yd,useEffect:_n,useImperativeHandle:Xd,useLayoutEffect:ny,useMemo:ry,useRef:xt,useState:Yn}=cc,il=cc[`useId${Math.random()}`.slice(0,5)],iy=ny,fs=ty(null);fs.displayName="PanelGroupContext";const jn=iy,sy=typeof il=="function"?il:()=>null;let ay=0;function io(e=null){const t=sy(),n=xt(e||t||null);return n.current===null&&(n.current=""+ay++),e??n.current}function Qd({children:e,className:t="",collapsedSize:n,collapsible:r,defaultSize:i,forwardedRef:s,id:a,maxSize:o,minSize:l,onCollapse:c,onExpand:f,onResize:d,order:p,style:h,tagName:m="div",...v}){const S=Yd(fs);if(S===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:y,expandPanel:_,getPanelSize:g,getPanelStyle:z,groupId:C,isPanelCollapsed:w,reevaluatePanelConstraints:E,registerPanel:R,resizePanel:K,unregisterPanel:j}=S,I=io(a),O=xt({callbacks:{onCollapse:c,onExpand:f,onResize:d},constraints:{collapsedSize:n,collapsible:r,defaultSize:i,maxSize:o,minSize:l},id:I,idIsFromProps:a!==void 0,order:p});xt({didLogMissingDefaultSizeWarning:!1}),jn(()=>{const{callbacks:M,constraints:T}=O.current,A={...T};O.current.id=I,O.current.idIsFromProps=a!==void 0,O.current.order=p,M.onCollapse=c,M.onExpand=f,M.onResize=d,T.collapsedSize=n,T.collapsible=r,T.defaultSize=i,T.maxSize=o,T.minSize=l,(A.collapsedSize!==T.collapsedSize||A.collapsible!==T.collapsible||A.maxSize!==T.maxSize||A.minSize!==T.minSize)&&E(O.current,A)}),jn(()=>{const M=O.current;return R(M),()=>{j(M)}},[p,I,R,j]),Xd(s,()=>({collapse:()=>{y(O.current)},expand:M=>{_(O.current,M)},getId(){return I},getSize(){return g(O.current)},isCollapsed(){return w(O.current)},isExpanded(){return!w(O.current)},resize:M=>{K(O.current,M)}}),[y,_,g,w,I,K]);const Z=z(O.current,i);return rr(m,{...v,children:e,className:t,id:a,style:{...Z,...h},"data-panel":"","data-panel-collapsible":r||void 0,"data-panel-group-id":C,"data-panel-id":I,"data-panel-size":parseFloat(""+Z.flexGrow).toFixed(1)})}const ef=Kd((e,t)=>rr(Qd,{...e,forwardedRef:t}));Qd.displayName="Panel";ef.displayName="forwardRef(Panel)";let va=null,Sn=null;function oy(e,t){if(t){const n=(t&af)!==0,r=(t&of)!==0,i=(t&lf)!==0,s=(t&uf)!==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 ly(){Sn!==null&&(document.head.removeChild(Sn),va=null,Sn=null)}function Ds(e,t){const n=oy(e,t);va!==n&&(va=n,Sn===null&&(Sn=document.createElement("style"),document.head.appendChild(Sn)),Sn.innerHTML=`*{cursor: ${n}!important;}`)}function tf(e){return e.type==="keydown"}function nf(e){return e.type.startsWith("pointer")}function rf(e){return e.type.startsWith("mouse")}function ps(e){if(nf(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(rf(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function uy(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function cy(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 dy(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:ol(e),b:ol(t)};let r;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),r=e;_e(r,"Stacking order can only be calculated for elements with a common ancestor");const i={a:al(sl(n.a)),b:al(sl(n.b))};if(i.a===i.b){const s=r.childNodes,a={a:n.a.at(-1),b:n.b.at(-1)};let o=s.length;for(;o--;){const l=s[o];if(l===a.a)return 1;if(l===a.b)return-1}}return Math.sign(i.a-i.b)}const fy=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function py(e){var t;const n=getComputedStyle((t=sf(e))!==null&&t!==void 0?t:e).display;return n==="flex"||n==="inline-flex"}function hy(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||py(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"||fy.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function sl(e){let t=e.length;for(;t--;){const n=e[t];if(_e(n,"Missing node"),hy(n))return n}return null}function al(e){return e&&Number(getComputedStyle(e).zIndex)||0}function ol(e){const t=[];for(;e;)t.push(e),e=sf(e);return t}function sf(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}const af=1,of=2,lf=4,uf=8,my=uy()==="coarse";let Rt=[],Xn=!1,an=new Map,hs=new Map;const Vr=new Set;function gy(e,t,n,r,i){var s;const{ownerDocument:a}=t,o={direction:n,element:t,hitAreaMargins:r,setResizeHandlerState:i},l=(s=an.get(a))!==null&&s!==void 0?s:0;return an.set(a,l+1),Vr.add(o),Li(),function(){var f;hs.delete(e),Vr.delete(o);const d=(f=an.get(a))!==null&&f!==void 0?f:1;if(an.set(a,d-1),Li(),d===1&&an.delete(a),Rt.includes(o)){const p=Rt.indexOf(o);p>=0&&Rt.splice(p,1),ao(),i("up",!0,null)}}}function ll(e){const{target:t}=e,{x:n,y:r}=ps(e);Xn=!0,so({target:t,x:n,y:r}),Li(),Rt.length>0&&(Zi("down",e),e.preventDefault(),e.stopPropagation())}function xr(e){const{x:t,y:n}=ps(e);if(Xn&&e.buttons===0&&(Xn=!1,Zi("up",e)),!Xn){const{target:r}=e;so({target:r,x:t,y:n})}Zi("move",e),ao(),Rt.length>0&&e.preventDefault()}function Rn(e){const{target:t}=e,{x:n,y:r}=ps(e);hs.clear(),Xn=!1,Rt.length>0&&e.preventDefault(),Zi("up",e),so({target:t,x:n,y:r}),ao(),Li()}function so({target:e,x:t,y:n}){Rt.splice(0);let r=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(r=e),Vr.forEach(i=>{const{element:s,hitAreaMargins:a}=i,o=s.getBoundingClientRect(),{bottom:l,left:c,right:f,top:d}=o,p=my?a.coarse:a.fine;if(t>=c-p&&t<=f+p&&n>=d-p&&n<=l+p){if(r!==null&&document.contains(r)&&s!==r&&!s.contains(r)&&!r.contains(s)&&dy(r,s)>0){let m=r,v=!1;for(;m&&!m.contains(s);){if(cy(m.getBoundingClientRect(),o)){v=!0;break}m=m.parentElement}if(v)return}Rt.push(i)}})}function Rs(e,t){hs.set(e,t)}function ao(){let e=!1,t=!1;Rt.forEach(r=>{const{direction:i}=r;i==="horizontal"?e=!0:t=!0});let n=0;hs.forEach(r=>{n|=r}),e&&t?Ds("intersection",n):e?Ds("horizontal",n):t?Ds("vertical",n):ly()}function Li(){an.forEach((e,t)=>{const{body:n}=t;n.removeEventListener("contextmenu",Rn),n.removeEventListener("pointerdown",ll),n.removeEventListener("pointerleave",xr),n.removeEventListener("pointermove",xr)}),window.removeEventListener("pointerup",Rn),window.removeEventListener("pointercancel",Rn),Vr.size>0&&(Xn?(Rt.length>0&&an.forEach((e,t)=>{const{body:n}=t;e>0&&(n.addEventListener("contextmenu",Rn),n.addEventListener("pointerleave",xr),n.addEventListener("pointermove",xr))}),window.addEventListener("pointerup",Rn),window.addEventListener("pointercancel",Rn)):an.forEach((e,t)=>{const{body:n}=t;e>0&&(n.addEventListener("pointerdown",ll,{capture:!0}),n.addEventListener("pointermove",xr))}))}function Zi(e,t){Vr.forEach(n=>{const{setResizeHandlerState:r}=n,i=Rt.includes(n);r(e,i,t)})}function xy(){const[e,t]=Yn(0);return pt(()=>t(n=>n+1),[])}function _e(e,t){if(!e)throw console.error(t),Error(t)}const oo=10;function In(e,t,n=oo){return e.toFixed(n)===t.toFixed(n)?0:e>t?1:-1}function Xt(e,t,n=oo){return In(e,t,n)===0}function kt(e,t,n){return In(e,t,n)===0}function yy(e,t,n){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++){const i=e[r],s=t[r];if(!kt(i,s,n))return!1}return!0}function Wn({panelConstraints:e,panelIndex:t,size:n}){const r=e[t];_e(r!=null,`Panel constraints not found for index ${t}`);let{collapsedSize:i=0,collapsible:s,maxSize:a=100,minSize:o=0}=r;if(In(n,o)<0)if(s){const l=(i+o)/2;In(n,l)<0?n=i:n=o}else n=o;return n=Math.min(a,n),n=parseFloat(n.toFixed(oo)),n}function jr({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:s}){if(kt(e,0))return t;const a=[...t],[o,l]=r;_e(o!=null,"Invalid first pivot index"),_e(l!=null,"Invalid second pivot index");let c=0;if(s==="keyboard"){{const d=e<0?l:o,p=n[d];_e(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(_e(S!=null,`Previous layout not found for panel index ${d}`),kt(S,h)){const y=v-S;In(y,Math.abs(e))>0&&(e=e<0?0-y:y)}}}{const d=e<0?o:l,p=n[d];_e(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(_e(S!=null,`Previous layout not found for panel index ${d}`),kt(S,v)){const y=S-h;In(y,Math.abs(e))>0&&(e=e<0?0-y:y)}}}}{const d=e<0?1:-1;let p=e<0?l:o,h=0;for(;;){const v=t[p];_e(v!=null,`Previous layout not found for panel index ${p}`);const y=Wn({panelConstraints:n,panelIndex:p,size:100})-v;if(h+=y,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:l;for(;p>=0&&p<n.length;){const h=Math.abs(e)-Math.abs(c),m=t[p];_e(m!=null,`Previous layout not found for panel index ${p}`);const v=m-h,S=Wn({panelConstraints:n,panelIndex:p,size:v});if(!kt(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(yy(i,a))return i;{const d=e<0?l:o,p=t[d];_e(p!=null,`Previous layout not found for panel index ${d}`);const h=p+c,m=Wn({panelConstraints:n,panelIndex:d,size:h});if(a[d]=m,!kt(m,h)){let v=h-m,y=e<0?l:o;for(;y>=0&&y<n.length;){const _=a[y];_e(_!=null,`Previous layout not found for panel index ${y}`);const g=_+v,z=Wn({panelConstraints:n,panelIndex:y,size:g});if(kt(_,z)||(v-=z-_,a[y]=z),kt(v,0))break;e>0?y--:y++}}}const f=a.reduce((d,p)=>p+d,0);return kt(f,100)?a:i}function by({layout:e,panelsArray:t,pivotIndices:n}){let r=0,i=100,s=0,a=0;const o=n[0];_e(o!=null,"No pivot index found"),t.forEach((d,p)=>{const{constraints:h}=d,{maxSize:m=100,minSize:v=0}=h;p===o?(r=v,i=m):(s+=v,a+=m)});const l=Math.min(i,100-s),c=Math.max(r,100-a),f=e[o];return{valueMax:l,valueMin:c,valueNow:f}}function Ur(e,t=document){return Array.from(t.querySelectorAll(`[data-panel-resize-handle-id][data-panel-group-id="${e}"]`))}function cf(e,t,n=document){const i=Ur(e,n).findIndex(s=>s.getAttribute("data-panel-resize-handle-id")===t);return i??null}function df(e,t,n){const r=cf(e,t,n);return r!=null?[r,r+1]:[-1,-1]}function ff(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 ms(e,t=document){const n=t.querySelector(`[data-panel-resize-handle-id="${e}"]`);return n||null}function vy(e,t,n,r=document){var i,s,a,o;const l=ms(t,r),c=Ur(e,r),f=l?c.indexOf(l):-1,d=(i=(s=n[f])===null||s===void 0?void 0:s.id)!==null&&i!==void 0?i:null,p=(a=(o=n[f+1])===null||o===void 0?void 0:o.id)!==null&&a!==void 0?a:null;return[d,p]}function wy({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:r,panelDataArray:i,panelGroupElement:s,setLayout:a}){xt({didWarnAboutMissingResizeHandle:!1}),jn(()=>{if(!s)return;const o=Ur(n,s);for(let l=0;l<i.length-1;l++){const{valueMax:c,valueMin:f,valueNow:d}=by({layout:r,panelsArray:i,pivotIndices:[l,l+1]}),p=o[l];if(p!=null){const h=i[l];_e(h,`No panel data found for index "${l}"`),p.setAttribute("aria-controls",h.id),p.setAttribute("aria-valuemax",""+Math.round(c)),p.setAttribute("aria-valuemin",""+Math.round(f)),p.setAttribute("aria-valuenow",d!=null?""+Math.round(d):"")}}return()=>{o.forEach((l,c)=>{l.removeAttribute("aria-controls"),l.removeAttribute("aria-valuemax"),l.removeAttribute("aria-valuemin"),l.removeAttribute("aria-valuenow")})}},[n,r,i,s]),_n(()=>{if(!s)return;const o=t.current;_e(o,"Eager values not found");const{panelDataArray:l}=o,c=ff(n,s);_e(c!=null,`No group found for id "${n}"`);const f=Ur(n,s);_e(f,`No resize handles found for group id "${n}"`);const d=f.map(p=>{const h=p.getAttribute("data-panel-resize-handle-id");_e(h,"Resize handle element has no handle id attribute");const[m,v]=vy(n,h,l,s);if(m==null||v==null)return()=>{};const S=y=>{if(!y.defaultPrevented)switch(y.key){case"Enter":{y.preventDefault();const _=l.findIndex(g=>g.id===m);if(_>=0){const g=l[_];_e(g,`No panel data found for index ${_}`);const z=r[_],{collapsedSize:C=0,collapsible:w,minSize:E=0}=g.constraints;if(z!=null&&w){const R=jr({delta:kt(z,C)?E-C:C-z,initialLayout:r,panelConstraints:l.map(K=>K.constraints),pivotIndices:df(n,h,s),prevLayout:r,trigger:"keyboard"});r!==R&&a(R)}}break}}};return p.addEventListener("keydown",S),()=>{p.removeEventListener("keydown",S)}});return()=>{d.forEach(p=>p())}},[s,e,t,n,r,i,a])}function ul(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 pf(e,t){const n=e==="horizontal",{x:r,y:i}=ps(t);return n?r:i}function ky(e,t,n,r,i){const s=n==="horizontal",a=ms(t,i);_e(a,`No resize handle element found for id "${t}"`);const o=a.getAttribute("data-panel-group-id");_e(o,"Resize handle element has no group id attribute");let{initialCursorPosition:l}=r;const c=pf(n,e),f=ff(o,i);_e(f,`No group element found for id "${o}"`);const d=f.getBoundingClientRect(),p=s?d.width:d.height;return(c-l)/p*100}function Sy(e,t,n,r,i,s){if(tf(e)){const a=n==="horizontal";let o=0;e.shiftKey?o=100:i!=null?o=i:o=10;let l=0;switch(e.key){case"ArrowDown":l=a?0:o;break;case"ArrowLeft":l=a?-o:0;break;case"ArrowRight":l=a?o:0;break;case"ArrowUp":l=a?0:-o;break;case"End":l=100;break;case"Home":l=-100;break}return l}else return r==null?0:ky(e,t,n,r,s)}function _y({panelDataArray:e}){const t=Array(e.length),n=e.map(s=>s.constraints);let r=0,i=100;for(let s=0;s<e.length;s++){const a=n[s];_e(a,`Panel constraints not found for index ${s}`);const{defaultSize:o}=a;o!=null&&(r++,t[s]=o,i-=o)}for(let s=0;s<e.length;s++){const a=n[s];_e(a,`Panel constraints not found for index ${s}`);const{defaultSize:o}=a;if(o!=null)continue;const l=e.length-r,c=i/l;r++,t[s]=c,i-=c}return t}function Mn(e,t,n){t.forEach((r,i)=>{const s=e[i];_e(s,`Panel data not found for index ${i}`);const{callbacks:a,constraints:o,id:l}=s,{collapsedSize:c=0,collapsible:f}=o,d=n[l];if(d==null||r!==d){n[l]=r;const{onCollapse:p,onExpand:h,onResize:m}=a;m&&m(r,d),f&&(p||h)&&(h&&(d==null||Xt(d,c))&&!Xt(r,c)&&h(),p&&(d==null||!Xt(d,c))&&Xt(r,c)&&p())}})}function ci(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function jy({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 Ny(e,t=10){let n=null;return(...i)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...i)},t)}}function cl(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 hf(e){return`react-resizable-panels:${e}`}function mf(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 gf(e,t){try{const n=hf(e),r=t.getItem(n);if(r){const i=JSON.parse(r);if(typeof i=="object"&&i!=null)return i}}catch{}return null}function Cy(e,t,n){var r,i;const s=(r=gf(e,n))!==null&&r!==void 0?r:{},a=mf(t);return(i=s[a])!==null&&i!==void 0?i:null}function Ey(e,t,n,r,i){var s;const a=hf(e),o=mf(t),l=(s=gf(e,i))!==null&&s!==void 0?s:{};l[o]={expandToSizes:Object.fromEntries(n.entries()),layout:r};try{i.setItem(a,JSON.stringify(l))}catch(c){console.error(c)}}function dl({layout:e,panelConstraints:t}){const n=[...e],r=n.reduce((s,a)=>s+a,0);if(n.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${n.map(s=>`${s}%`).join(", ")}`);if(!kt(r,100)&&n.length>0)for(let s=0;s<t.length;s++){const a=n[s];_e(a!=null,`No layout data found for index ${s}`);const o=100/r*a;n[s]=o}let i=0;for(let s=0;s<t.length;s++){const a=n[s];_e(a!=null,`No layout data found for index ${s}`);const o=Wn({panelConstraints:t,panelIndex:s,size:a});a!=o&&(i+=a-o,n[s]=o)}if(!kt(i,0))for(let s=0;s<t.length;s++){const a=n[s];_e(a!=null,`No layout data found for index ${s}`);const o=a+i,l=Wn({panelConstraints:t,panelIndex:s,size:o});if(a!==l&&(i-=l-a,n[s]=l,kt(i,0)))break}return n}const Iy=100,Nr={getItem:e=>(cl(Nr),Nr.getItem(e)),setItem:(e,t)=>{cl(Nr),Nr.setItem(e,t)}},fl={};function xf({autoSaveId:e=null,children:t,className:n="",direction:r,forwardedRef:i,id:s=null,onLayout:a=null,keyboardResizeBy:o=null,storage:l=Nr,style:c,tagName:f="div",...d}){const p=io(s),h=xt(null),[m,v]=Yn(null),[S,y]=Yn([]),_=xy(),g=xt({}),z=xt(new Map),C=xt(0),w=xt({autoSaveId:e,direction:r,dragState:m,id:p,keyboardResizeBy:o,onLayout:a,storage:l}),E=xt({layout:S,panelDataArray:[],panelDataArrayChanged:!1});xt({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),Xd(i,()=>({getId:()=>w.current.id,getLayout:()=>{const{layout:x}=E.current;return x},setLayout:x=>{const{onLayout:H}=w.current,{layout:G,panelDataArray:ie}=E.current,ae=dl({layout:x,panelConstraints:ie.map(Q=>Q.constraints)});ul(G,ae)||(y(ae),E.current.layout=ae,H&&H(ae),Mn(ie,ae,g.current))}}),[]),jn(()=>{w.current.autoSaveId=e,w.current.direction=r,w.current.dragState=m,w.current.id=p,w.current.onLayout=a,w.current.storage=l}),wy({committedValuesRef:w,eagerValuesRef:E,groupId:p,layout:S,panelDataArray:E.current.panelDataArray,setLayout:y,panelGroupElement:h.current}),_n(()=>{const{panelDataArray:x}=E.current;if(e){if(S.length===0||S.length!==x.length)return;let H=fl[e];H==null&&(H=Ny(Ey,Iy),fl[e]=H);const G=[...x],ie=new Map(z.current);H(e,G,ie,S,l)}},[e,S,l]),_n(()=>{});const R=pt(x=>{const{onLayout:H}=w.current,{layout:G,panelDataArray:ie}=E.current;if(x.constraints.collapsible){const ae=ie.map(V=>V.constraints),{collapsedSize:Q=0,panelSize:$,pivotIndices:ee}=gn(ie,x,G);if(_e($!=null,`Panel size not found for panel "${x.id}"`),!Xt($,Q)){z.current.set(x.id,$);const se=Vn(ie,x)===ie.length-1?$-Q:Q-$,le=jr({delta:se,initialLayout:G,panelConstraints:ae,pivotIndices:ee,prevLayout:G,trigger:"imperative-api"});ci(G,le)||(y(le),E.current.layout=le,H&&H(le),Mn(ie,le,g.current))}}},[]),K=pt((x,H)=>{const{onLayout:G}=w.current,{layout:ie,panelDataArray:ae}=E.current;if(x.constraints.collapsible){const Q=ae.map(ge=>ge.constraints),{collapsedSize:$=0,panelSize:ee=0,minSize:V=0,pivotIndices:se}=gn(ae,x,ie),le=H??V;if(Xt(ee,$)){const ge=z.current.get(x.id),Oe=ge!=null&&ge>=le?ge:le,Qe=Vn(ae,x)===ae.length-1?ee-Oe:Oe-ee,N=jr({delta:Qe,initialLayout:ie,panelConstraints:Q,pivotIndices:se,prevLayout:ie,trigger:"imperative-api"});ci(ie,N)||(y(N),E.current.layout=N,G&&G(N),Mn(ae,N,g.current))}}},[]),j=pt(x=>{const{layout:H,panelDataArray:G}=E.current,{panelSize:ie}=gn(G,x,H);return _e(ie!=null,`Panel size not found for panel "${x.id}"`),ie},[]),I=pt((x,H)=>{const{panelDataArray:G}=E.current,ie=Vn(G,x);return jy({defaultSize:H,dragState:m,layout:S,panelData:G,panelIndex:ie})},[m,S]),O=pt(x=>{const{layout:H,panelDataArray:G}=E.current,{collapsedSize:ie=0,collapsible:ae,panelSize:Q}=gn(G,x,H);return _e(Q!=null,`Panel size not found for panel "${x.id}"`),ae===!0&&Xt(Q,ie)},[]),Z=pt(x=>{const{layout:H,panelDataArray:G}=E.current,{collapsedSize:ie=0,collapsible:ae,panelSize:Q}=gn(G,x,H);return _e(Q!=null,`Panel size not found for panel "${x.id}"`),!ae||In(Q,ie)>0},[]),M=pt(x=>{const{panelDataArray:H}=E.current;H.push(x),H.sort((G,ie)=>{const ae=G.order,Q=ie.order;return ae==null&&Q==null?0:ae==null?-1:Q==null?1:ae-Q}),E.current.panelDataArrayChanged=!0,_()},[_]);jn(()=>{if(E.current.panelDataArrayChanged){E.current.panelDataArrayChanged=!1;const{autoSaveId:x,onLayout:H,storage:G}=w.current,{layout:ie,panelDataArray:ae}=E.current;let Q=null;if(x){const ee=Cy(x,ae,G);ee&&(z.current=new Map(Object.entries(ee.expandToSizes)),Q=ee.layout)}Q==null&&(Q=_y({panelDataArray:ae}));const $=dl({layout:Q,panelConstraints:ae.map(ee=>ee.constraints)});ul(ie,$)||(y($),E.current.layout=$,H&&H($),Mn(ae,$,g.current))}}),jn(()=>{const x=E.current;return()=>{x.layout=[]}},[]);const T=pt(x=>{let H=!1;const G=h.current;return G&&window.getComputedStyle(G,null).getPropertyValue("direction")==="rtl"&&(H=!0),function(ae){ae.preventDefault();const Q=h.current;if(!Q)return()=>null;const{direction:$,dragState:ee,id:V,keyboardResizeBy:se,onLayout:le}=w.current,{layout:ge,panelDataArray:Oe}=E.current,{initialLayout:We}=ee??{},Qe=df(V,x,Q);let N=Sy(ae,x,$,ee,se,Q);const P=$==="horizontal";P&&H&&(N=-N);const L=Oe.map(X=>X.constraints),re=jr({delta:N,initialLayout:We??ge,panelConstraints:L,pivotIndices:Qe,prevLayout:ge,trigger:tf(ae)?"keyboard":"mouse-or-touch"}),te=!ci(ge,re);(nf(ae)||rf(ae))&&C.current!=N&&(C.current=N,!te&&N!==0?P?Rs(x,N<0?af:of):Rs(x,N<0?lf:uf):Rs(x,0)),te&&(y(re),E.current.layout=re,le&&le(re),Mn(Oe,re,g.current))}},[]),A=pt((x,H)=>{const{onLayout:G}=w.current,{layout:ie,panelDataArray:ae}=E.current,Q=ae.map(ge=>ge.constraints),{panelSize:$,pivotIndices:ee}=gn(ae,x,ie);_e($!=null,`Panel size not found for panel "${x.id}"`);const se=Vn(ae,x)===ae.length-1?$-H:H-$,le=jr({delta:se,initialLayout:ie,panelConstraints:Q,pivotIndices:ee,prevLayout:ie,trigger:"imperative-api"});ci(ie,le)||(y(le),E.current.layout=le,G&&G(le),Mn(ae,le,g.current))},[]),J=pt((x,H)=>{const{layout:G,panelDataArray:ie}=E.current,{collapsedSize:ae=0,collapsible:Q}=H,{collapsedSize:$=0,collapsible:ee,maxSize:V=100,minSize:se=0}=x.constraints,{panelSize:le}=gn(ie,x,G);le!=null&&(Q&&ee&&Xt(le,ae)?Xt(ae,$)||A(x,$):le<se?A(x,se):le>V&&A(x,V))},[A]),B=pt((x,H)=>{const{direction:G}=w.current,{layout:ie}=E.current;if(!h.current)return;const ae=ms(x,h.current);_e(ae,`Drag handle element not found for id "${x}"`);const Q=pf(G,H);v({dragHandleId:x,dragHandleRect:ae.getBoundingClientRect(),initialCursorPosition:Q,initialLayout:ie})},[]),ne=pt(()=>{v(null)},[]),k=pt(x=>{const{panelDataArray:H}=E.current,G=Vn(H,x);G>=0&&(H.splice(G,1),delete g.current[x.id],E.current.panelDataArrayChanged=!0,_())},[_]),ce=ry(()=>({collapsePanel:R,direction:r,dragState:m,expandPanel:K,getPanelSize:j,getPanelStyle:I,groupId:p,isPanelCollapsed:O,isPanelExpanded:Z,reevaluatePanelConstraints:J,registerPanel:M,registerResizeHandle:T,resizePanel:A,startDragging:B,stopDragging:ne,unregisterPanel:k,panelGroupElement:h.current}),[R,m,r,K,j,I,p,O,Z,J,M,T,A,B,ne,k]),de={display:"flex",flexDirection:r==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return rr(fs.Provider,{value:ce},rr(f,{...d,children:t,className:n,id:s,ref:h,style:{...de,...c},"data-panel-group":"","data-panel-group-direction":r,"data-panel-group-id":p}))}const yf=Kd((e,t)=>rr(xf,{...e,forwardedRef:t}));xf.displayName="PanelGroup";yf.displayName="forwardRef(PanelGroup)";function Vn(e,t){return e.findIndex(n=>n===t||n.id===t.id)}function gn(e,t,n){const r=Vn(e,t),s=r===e.length-1?[r-1,r]:[r,r+1],a=n[r];return{...t.constraints,panelSize:a,pivotIndices:s}}function zy({disabled:e,handleId:t,resizeHandler:n,panelGroupElement:r}){_n(()=>{if(e||n==null||r==null)return;const i=ms(t,r);if(i==null)return;const s=a=>{if(!a.defaultPrevented)switch(a.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{a.preventDefault(),n(a);break}case"F6":{a.preventDefault();const o=i.getAttribute("data-panel-group-id");_e(o,`No group element found for id "${o}"`);const l=Ur(o,r),c=cf(o,t,r);_e(c!==null,`No resize element found for id "${t}"`);const f=a.shiftKey?c>0?c-1:l.length-1:c+1<l.length?c+1:0;l[f].focus();break}}};return i.addEventListener("keydown",s),()=>{i.removeEventListener("keydown",s)}},[r,e,t,n])}function bf({children:e=null,className:t="",disabled:n=!1,hitAreaMargins:r,id:i,onBlur:s,onDragging:a,onFocus:o,style:l={},tabIndex:c=0,tagName:f="div",...d}){var p,h;const m=xt(null),v=xt({onDragging:a});_n(()=>{v.current.onDragging=a});const S=Yd(fs);if(S===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:y,groupId:_,registerResizeHandle:g,startDragging:z,stopDragging:C,panelGroupElement:w}=S,E=io(i),[R,K]=Yn("inactive"),[j,I]=Yn(!1),[O,Z]=Yn(null),M=xt({state:R});jn(()=>{M.current.state=R}),_n(()=>{if(n)Z(null);else{const B=g(E);Z(()=>B)}},[n,E,g]);const T=(p=r==null?void 0:r.coarse)!==null&&p!==void 0?p:15,A=(h=r==null?void 0:r.fine)!==null&&h!==void 0?h:5;return _n(()=>{if(n||O==null)return;const B=m.current;return _e(B,"Element ref not attached"),gy(E,B,y,{coarse:T,fine:A},(k,ce,de)=>{if(ce)switch(k){case"down":{K("drag"),_e(de,'Expected event to be defined for "down" action'),z(E,de);const{onDragging:x}=v.current;x&&x(!0);break}case"move":{const{state:x}=M.current;x!=="drag"&&K("hover"),_e(de,'Expected event to be defined for "move" action'),O(de);break}case"up":{K("hover"),C();const{onDragging:x}=v.current;x&&x(!1);break}}else K("inactive")})},[T,y,n,A,g,E,O,z,C]),zy({disabled:n,handleId:E,resizeHandler:O,panelGroupElement:w}),rr(f,{...d,children:e,className:t,id:i,onBlur:()=>{I(!1),s==null||s()},onFocus:()=>{I(!0),o==null||o()},ref:m,role:"separator",style:{...{touchAction:"none",userSelect:"none"},...l},tabIndex:c,"data-panel-group-direction":y,"data-panel-group-id":_,"data-resize-handle":"","data-resize-handle-active":R==="drag"?"pointer":j?"keyboard":void 0,"data-resize-handle-state":R,"data-panel-resize-handle-enabled":!n,"data-panel-resize-handle-id":E})}bf.displayName="PanelResizeHandle";const Ty=({className:e,...t})=>u.jsx(yf,{className:W("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...t}),Ms=ef,pl=({withHandle:e,className:t,...n})=>u.jsx(bf,{className:W("bg-border focus-visible:ring-ring relative flex w-px items-center justify-center after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-offset-1 focus-visible:outline-none data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:-translate-y-1/2 data-[panel-group-direction=vertical]:after:translate-x-0 [&[data-panel-group-direction=vertical]>div]:rotate-90",t),...n,children:e&&u.jsx("div",{className:"bg-border z-10 flex h-4 w-3 items-center justify-center rounded-sm border",children:u.jsx(tg,{className:"h-2.5 w-2.5"})})});function Ay({children:e,className:t}){return u.jsx("kbd",{className:W("inline-flex items-center justify-center min-w-[1.25rem] h-5 px-1 rounded border border-border bg-background text-[11px] font-mono font-medium text-muted-foreground shadow-[0_1px_0_0] shadow-border/50 leading-none select-none",t),children:e})}function Py({children:e,className:t}){return u.jsx("span",{className:W("inline-flex items-center gap-0.5",t),children:e})}const di=typeof navigator<"u"&&/Mac|iPod|iPhone|iPad/.test(navigator.platform);function wa({shortcut:e,className:t}){const r=e.split("+").map(i=>i.trim().toLowerCase()).map(i=>{switch(i){case"mod":return di?"⌘":"Ctrl";case"shift":return di?"⇧":"Shift";case"alt":return di?"⌥":"Alt";case"ctrl":return di?"⌃":"Ctrl";case"enter":return"↵";default:return i.toUpperCase()}});return u.jsx(Py,{className:t,children:r.map((i,s)=>u.jsx(Ay,{children:i},s))})}class Oy{constructor(t){Mo(this,"client");this.client=_g.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 Dy=new Oy;function Ry(){const e=b.useRef(null),t=b.useCallback(async(r,i,s,a,o)=>{e.current&&e.current.abort();const l=new AbortController;e.current=l;try{a==null||a("parsing","Validating JSON structure...");let c;try{c=JSON.parse(i)}catch(w){throw new Error(`Invalid JSON: ${w instanceof Error?w.message:"Unknown parse error"}`)}a==null||a("building",`Building ${li.toLowerCase()} structure...`);const f={jsonDefinition:c,options:o||{}};f.customThemes=s??{},a==null||a("rendering",`Generating ${yt.toUpperCase()} content...`);const d={"Content-Type":"application/json"};o!=null&&o.bypassCache&&(d["X-Bypass-Cache"]="true");const p=await fetch(Hc.generate,{method:"POST",headers:d,body:JSON.stringify(f),signal:l.signal}),h=await p.json();if(!p.ok||!h.success){const w=h.error||h.message||`API request failed with status: ${p.status}`;throw new Error(w)}const{data:m,cache:v,warnings:S}=h,y=v.status==="HIT"?"HIT":v.status==="MISS"?"MISS":"UNKNOWN",_=y==="HIT"?`Served from cache (Hit rate: ${v.hitRate})`:`Generated fresh ${li.toLowerCase()}`;a==null||a("finalizing",_);const g=globalThis.atob(m.document),z=new Uint8Array(g.length);for(let w=0;w<g.length;w++)z[w]=g.charCodeAt(w);const C=new Blob([z],{type:m.contentType});if(C.size===0)throw new Error(`Received empty ${li.toLowerCase()} from API`);return{name:r,text:i,blob:C,filename:m.filename,fileId:m.fileId,cacheStatus:y,cacheHitRate:v.hitRate,warnings:S}}catch(c){throw c instanceof Error&&c.name==="AbortError"?new Error(`${li} generation was cancelled`):c}finally{e.current===l&&(e.current=null)}},[]),n=b.useCallback(()=>{e.current&&(e.current.abort(),e.current=null)},[]);return{generatePresentation:t,generateDocument:t,cancelGeneration:n}}function My(e){if(!e||e.length===0)return null;const t=[{name:"heading",props:{level:1,text:"Document Generation Warnings"}},{name:"paragraph",props:{text:`${e.length} warning(s) were generated during document processing.`,spacing:{after:240}}}],n=new Map;for(const r of e){const i=n.get(r.component)||[];i.push(r),n.set(r.component,i)}for(const[r,i]of n.entries()){t.push({name:"heading",props:{level:2,text:`Component: ${r}`}});const s=[];for(const a of i){let o=a.message;if(a.context&&Object.keys(a.context).length>0){const l=Object.entries(a.context).map(([c,f])=>`${c}: ${JSON.stringify(f)}`).join(", ");o+=` (${l})`}s.push(o)}t.push({name:"list",props:{items:s,spacing:{after:120}}})}return{name:"docx",props:{metadata:{title:"Generation Warnings"},theme:"minimal"},children:t}}function $y({open:e,onClose:t,nonSafeFonts:n,onChoose:r}){const[i,s]=Ee.useState("custom");Ee.useEffect(()=>{e&&s("custom")},[e]);const a=n.length===1?n[0]:n.slice(0,3).join(", ")+(n.length>3?` +${n.length-3} more`:""),o=[{value:"custom",title:"Keep custom fonts",desc:"Recipients with the font installed see the authored typeface. Others get a generic fallback."},{value:"substitute",title:"Convert to safe fonts",desc:"Rewrite non-safe families to Calibri / Georgia / Consolas so every recipient sees the same glyphs."}];return u.jsx(It,{open:e,onOpenChange:l=>!l&&t(),children:u.jsxs(St,{className:"max-w-md",children:[u.jsxs(Ut,{children:[u.jsx(Jt,{children:"Non-safe fonts in this document"}),u.jsxs(cn,{children:[a," ",n.length===1?"is":"are"," not in the built-in safe list. Choose how to export."]})]}),u.jsx("div",{className:"grid gap-2 py-2",children:o.map(l=>{const c=i===l.value;return u.jsxs("button",{type:"button",onClick:()=>s(l.value),className:`text-left rounded-md border px-3 py-2 transition-colors ${c?"border-primary bg-primary/5":"border-border hover:bg-muted/40"}`,children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("span",{className:`h-3.5 w-3.5 rounded-full border flex items-center justify-center ${c?"border-primary":"border-muted-foreground/50"}`,children:c&&u.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-primary"})}),u.jsx("span",{className:"text-sm font-medium",children:l.title})]}),u.jsx("p",{className:"mt-1 text-xs text-muted-foreground pl-6",children:l.desc})]},l.value)})}),u.jsxs(Cn,{children:[u.jsx(we,{variant:"outline",size:"sm",onClick:t,children:"Cancel"}),u.jsx(we,{size:"sm",onClick:()=>{r(i),t()},children:"Download"})]})]})})}const hl=yt==="docx"?["docxjs","LibreOffice"]:["LibreOffice"],$s={docxjs:["⚡","(Fast) works in the browser — lower fidelity"],LibreOffice:["🖨️","(High fidelity) converts to PDF locally with LibreOffice"]};function Fy({name:e,blob:t,displayReloadButton:n,iframeRef:r,autoReload:i,onToggleAutoReload:s,onManualRender:a,isGenerating:o,isRendering:l,onShowCacheMetrics:c,onShowSchemas:f,onShowFonts:d,documentText:p,warnings:h,renderingLibrary:m,setRenderingLibrary:v,onToggleChat:S,chatOpen:y,onTogglePreview:_,previewOpen:g}){const z=m!=="docxjs",[C,w]=b.useState(!1),[E,R]=b.useState(!1),[K,j]=b.useState(!1),[I,O]=b.useState(!1),[Z,M]=b.useState(!1),[T,A]=b.useState(!1),{toast:J}=ur(),{generateDocument:B}=Ry(),ne=b.useContext(sd),k=b.useCallback(()=>{const V={},{customThemes:se}=ne.getState();return Object.values(se).forEach(le=>{le.valid&&le.parsed&&(V[le.name]=le.parsed)}),V},[ne]),ce=Ee.useMemo(()=>{if(!p)return[];try{const V=JSON.parse(p);return[...(yt==="pptx"?Fm:Lm)(V)].filter(le=>!Zm(le))}catch{return[]}},[p]),[de,x]=b.useState(!1),H=b.useCallback(async()=>{if(t){w(!0);try{await new Promise(V=>setTimeout(V,100)),ji(`${e}${hr}`,t)}finally{setTimeout(()=>w(!1),500)}}},[t,e]),G=b.useCallback(async()=>{if(t){if(ce.length===0){await H();return}x(!0)}},[t,ce.length,H]),ie=b.useCallback(async V=>{var se;if(p){w(!0);try{const le=await B(e,p,k(),void 0,{bypassCache:!0,fonts:{mode:V}});if(le.blob.size===0)J({title:"Export failed",description:"The server returned an empty document.",variant:"destructive"});else{ji(`${e}${hr}`,le.blob);const ge=(se=le.warnings)==null?void 0:se.find(Oe=>{var We,Qe;return((We=Oe.context)==null?void 0:We.code)==="FONT_MODE_SUBSTITUTED"||((Qe=Oe.context)==null?void 0:Qe.code)==="FONT_MODE_CUSTOM"});ge&&J({title:V==="substitute"?"Fonts substituted":"Non-safe fonts kept",description:ge.message})}}catch(le){J({title:"Export failed",description:le instanceof Error?le.message:String(le),variant:"destructive"})}finally{setTimeout(()=>w(!1),500)}}},[p,e,B,J,k]),ae=b.useCallback(async()=>{if(!(!h||h.length===0)){R(!0);try{const V=My(h);if(!V){J({title:"No warnings",description:"There are no warnings to download.",variant:"destructive"});return}const se=await B("warnings",JSON.stringify(V,null,2),{});se&&typeof se=="object"&&"blob"in se&&se.blob&&(ji(`${e}-warnings${hr}`,se.blob),J({title:"Warnings downloaded",description:`Downloaded warnings document with ${h.length} warning(s).`}))}catch(V){console.error("Failed to generate warnings document:",V),J({title:"Download failed",description:V instanceof Error?V.message:"Failed to generate warnings document",variant:"destructive"})}finally{setTimeout(()=>R(!1),500)}}},[h,e,B,J]),Q=b.useCallback(async()=>{const V=r==null?void 0:r.current;if(V!=null&&V.src){j(!0);try{await new Promise(le=>{let ge=null,Oe=!1;const We=()=>{ge&&(clearTimeout(ge),ge=null),V.removeEventListener("load",N),V.removeEventListener("error",P)},Qe=()=>{Oe||(Oe=!0,We(),le())},N=()=>Qe(),P=()=>Qe();V.addEventListener("load",N),V.addEventListener("error",P),ge=setTimeout(()=>{console.warn("Iframe reload timed out after 5 seconds"),Qe()},5e3);const L=V.src,re=L.includes("?")?"&":"?",te=Date.now();V.src=`${L}${re}_reload=${te}`})}catch(se){console.error("Iframe reload failed:",se)}finally{j(!1)}}},[r]),$=b.useCallback(async()=>{O(!0);try{await Dy.delete(`/${yt}/cache`),window.dispatchEvent(new CustomEvent("cache:cleared")),J({title:"Cache Cleared",description:"All caches (document and component) have been successfully cleared.",variant:"default"})}catch(V){console.error("Failed to clear cache:",V),J({title:"Cache Clear Failed",description:"Failed to clear caches. Please try again.",variant:"destructive"})}finally{O(!1)}},[J]),ee=b.useCallback(async()=>{if(!p){J({title:"No document available",description:"Please select a document to copy standard components",variant:"destructive"});return}A(!0);try{const V=await fetch(`/api/${yt}/standard-components`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonDefinition:p})});if(!V.ok){let ge=`Request failed with status ${V.status}`;try{const Oe=await V.json();Oe.message&&(ge=Oe.message)}catch{}J({title:"Failed to get standard components",description:ge,variant:"destructive"});return}const se=await V.json(),le=JSON.stringify(se.data,null,2);await navigator.clipboard.writeText(le),J({title:"Copied to clipboard",description:"Standard modules JSON has been copied"})}catch(V){console.error("Error copying standard components:",V),J({title:"Error",description:V instanceof Error?V.message:"Failed to copy standard components",variant:"destructive"})}finally{A(!1)}},[p,J]);return u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"bg-sidebar flex flex-row flex-nowrap items-center justify-between gap-x-2 px-3 py-1.5",children:[u.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[u.jsx("p",{className:"text-foreground text-sm font-semibold tracking-tight truncate flex-1 min-w-0",children:e}),u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsx("button",{type:"button","aria-label":"Preview disclaimer",className:"cursor-help inline-flex items-center justify-center h-6 w-6 rounded hover:bg-muted/60 shrink-0",children:u.jsx(ed,{className:"h-3.5 w-3.5 text-muted-foreground"})})}),u.jsx(Ke,{className:"max-w-sm",children:u.jsxs("p",{className:"text-sm",children:["Preview uses"," ",yt==="docx"?"docx-preview":"LibreOffice PDF conversion",". Download the ",hr," to verify fidelity."]})})]})]}),u.jsxs("div",{className:"flex flex-row items-center gap-x-1 shrink-0",children:[(!i||z)&&u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsxs(we,{variant:"default",size:"sm",className:"gap-1.5 h-7 px-2.5",onClick:a,"aria-label":"Render preview",disabled:o||l||g===!1,children:[l?u.jsx(Yt,{size:"sm"}):u.jsx(ng,{className:"h-3.5 w-3.5"}),u.jsx("span",{className:"text-xs font-medium hidden sm:inline",children:"Run"})]})}),u.jsx(Ke,{children:u.jsx("p",{children:g===!1?"Open preview to run":l?"Rendering preview...":"Render preview"})})]}),yt==="docx"&&u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsxs("div",{className:"flex items-center gap-1.5 cursor-help ml-2 mr-1",children:[u.jsx(Kn,{className:"text-xs text-muted-foreground hidden sm:inline",children:"Auto"}),u.jsx(eo,{checked:i,onCheckedChange:s,disabled:z})]})}),u.jsx(Ke,{children:u.jsx("p",{children:z?"Auto-reload is not available for Office, Docs, and LibreOffice renderers":`${i?"Disable":"Enable"} automatic preview reload on content changes`})})]}),n&&i&&u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsx(we,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:Q,disabled:K||o||l,children:K?u.jsx(Yt,{size:"sm"}):u.jsx(rg,{className:"h-3.5 w-3.5"})})}),u.jsx(Ke,{children:u.jsx("p",{children:K?"Reloading...":"Reload"})})]}),u.jsx("div",{className:"w-px h-4 bg-border/60 mx-1"}),u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsxs(we,{variant:"outline",size:"sm",className:"gap-1.5 h-7 px-2.5",disabled:!t||C||o,onClick:G,children:[C?u.jsx(Yt,{size:"sm"}):u.jsx(ig,{className:"h-3.5 w-3.5"}),u.jsx("span",{className:"text-xs font-medium hidden sm:inline",children:"Download"})]})}),u.jsx(Ke,{children:u.jsxs("p",{children:["Download ",hr]})})]}),h&&h.length>0&&u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsx(we,{variant:"outline",size:"icon",className:"h-7 w-7 bg-amber-50 dark:bg-amber-950 text-amber-600 dark:text-amber-400 border-amber-200 dark:border-amber-800 hover:bg-amber-100 dark:hover:bg-amber-900",disabled:E||o,onClick:ae,children:E?u.jsx(Yt,{size:"sm"}):u.jsx(td,{className:"h-3.5 w-3.5"})})}),u.jsx(Ke,{children:u.jsxs("p",{children:["Download warnings (",h.length,")"]})})]}),m&&v&&u.jsxs(Mr,{value:m,onValueChange:v,children:[u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsx(tr,{className:"w-[140px] h-7 text-xs hidden lg:flex",children:u.jsx($r,{placeholder:"Renderer"})})}),u.jsx(Ke,{children:u.jsx("p",{children:"Select the rendering library"})})]}),u.jsx(nr,{className:"text-sidebar-foreground",children:hl.map(V=>u.jsxs(En,{value:V,children:[u.jsxs(qe,{children:[u.jsx(Ge,{tabIndex:-1,children:$s[V][0]}),u.jsx(Ke,{children:$s[V][1]})]})," ",V]},V))})]}),u.jsx("div",{className:"w-px h-4 bg-border/60 mx-1"}),u.jsxs(to,{children:[u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsx(no,{asChild:!0,children:u.jsx(we,{variant:"ghost",size:"icon",className:"h-7 w-7",children:u.jsx(sg,{className:"h-3.5 w-3.5"})})})}),u.jsx(Ke,{children:u.jsx("p",{children:"More actions"})})]}),u.jsxs(ds,{align:"end",className:"w-52",children:[f&&u.jsxs(Kt,{onClick:f,children:[u.jsx(ag,{className:"h-4 w-4 mr-2"}),"View JSON Schemas"]}),d&&u.jsxs(Kt,{onClick:d,children:[u.jsx(og,{className:"h-4 w-4 mr-2"}),"Browse fonts"]}),c&&u.jsxs(Kt,{onClick:c,children:[u.jsx(lg,{className:"h-4 w-4 mr-2"}),"View cache metrics"]}),u.jsxs(Kt,{onClick:ee,disabled:!p||T,children:[u.jsx(nd,{className:"h-4 w-4 mr-2"}),T?"Copying...":"Copy standard components"]}),u.jsx(Lr,{}),u.jsxs(Kt,{onClick:()=>M(!0),disabled:I,className:"text-destructive focus:text-destructive",children:[u.jsx(Ha,{className:"h-4 w-4 mr-2"}),I?"Clearing...":"Clear all caches"]}),m&&v&&u.jsxs(u.Fragment,{children:[u.jsx(Lr,{className:"lg:hidden"}),hl.map(V=>u.jsxs(Kt,{className:"lg:hidden",onClick:()=>v(V),children:[u.jsx("span",{className:"mr-2",children:m===V?"●":"○"}),$s[V][0]," ",V]},V))]})]})]}),_&&u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsx(we,{variant:g?"default":"ghost",size:"icon",className:"h-7 w-7",onClick:_,children:g?u.jsx(rd,{className:"h-3.5 w-3.5"}):u.jsx(ug,{className:"h-3.5 w-3.5"})})}),u.jsx(Ke,{children:u.jsxs("span",{className:"flex items-center gap-1.5",children:[g?"Hide":"Show"," Preview"," ",u.jsx(wa,{shortcut:"mod+shift+p"})]})})]}),S&&u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsx(we,{variant:y?"default":"ghost",size:"icon",className:"h-7 w-7",onClick:S,children:u.jsx(id,{className:"h-3.5 w-3.5"})})}),u.jsx(Ke,{children:u.jsxs("span",{className:"flex items-center gap-1.5",children:[y?"Close":"Open"," AI Chat"," ",u.jsx(wa,{shortcut:"mod+shift+j"})]})})]})]})]}),u.jsx($y,{open:de,onClose:()=>x(!1),nonSafeFonts:ce,onChoose:ie}),u.jsx(It,{open:Z,onOpenChange:M,children:u.jsxs(St,{className:"max-w-sm",children:[u.jsxs(Ut,{children:[u.jsx(Jt,{children:"Clear all caches?"}),u.jsx(cn,{children:"This will clear document and component caches. Next generation will be uncached."})]}),u.jsxs(Cn,{children:[u.jsx(we,{variant:"outline",size:"sm",onClick:()=>M(!1),children:"Cancel"}),u.jsx(we,{variant:"destructive",size:"sm",disabled:I,onClick:async()=>{await $(),M(!1)},children:I?u.jsx(Yt,{size:"sm"}):"Clear"})]})]})})]})}const Ly=Ee.memo(Fy);function Zy(e,t,n){if(t.length===0)return n;const r=ml(e,t[0]);let i=r;for(let s=0;s<t.length-1;s++){const a=t[s],o=t[s+1],l=i[a],c=ml(l,o);i[a]=c,i=c}return i[t[t.length-1]]=n,r}function ml(e,t){return typeof t=="number"?Array.isArray(e)?[...e]:[]:e&&typeof e=="object"&&!Array.isArray(e)?{...e}:{}}const By={safe:[],google:[]};function Vy(e,t){var f;const n=`gf-${e.replace(/\s+/g,"-")}`,r=document.getElementById(n),i=new Set(t&&t.length>0?t:[400,700]),s=new Set(((f=r==null?void 0:r.dataset.weights)==null?void 0:f.split(",").map(Number).filter(d=>!Number.isNaN(d)))??[]),a=new Set([...s,...i]);if(r&&a.size===s.size)return;const o=[...a].sort((d,p)=>d-p).join(";"),l=`https://fonts.googleapis.com/css2?family=${encodeURIComponent(e)}:wght@${o}&display=swap`,c=r??document.createElement("link");r||(c.id=n,c.rel="stylesheet",document.head.appendChild(c)),c.href=l,c.dataset.weights=[...a].sort((d,p)=>d-p).join(",")}function Uy(){const e=Ae(i=>i.activeTab),t=Ae(i=>i.documents),n=Ae(i=>i.documentTypes),r=Ae(i=>i.saveDocument);return b.useCallback(i=>{if(!e)return{ok:!1,error:"No active file"};if(n[e]!=="application/json+theme")return{ok:!1,error:"Fonts are registered on themes, not documents. Open a .theme.json file and try again."};const s=t.find(l=>l.name===e);if(!s)return{ok:!1,error:"Active theme not found"};let a;try{a=JSON.parse(s.text)}catch(l){return{ok:!1,error:`Active theme is not valid JSON: ${l.message}`}}const o=i(a);return r(e,JSON.stringify(o,null,2)),{ok:!0,name:e}},[e,t,n,r])}function Jy(){const e=Ae(r=>r.activeTab),t=Ae(r=>r.documents),n=Ae(r=>r.saveDocument);return b.useCallback((r,i)=>{if(!e)return{ok:!1,error:"No active file"};const s=t.find(l=>l.name===e);if(!s)return{ok:!1,error:"Active document not found"};let a;try{a=JSON.parse(s.text)}catch(l){return{ok:!1,error:`Active document is not valid JSON: ${l.message}`}}const o=Zy(a,r,i);return n(e,JSON.stringify(o,null,2)),{ok:!0,name:e}},[e,t,n])}function Hy(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 gl(e){return e.map((t,n)=>typeof t=="number"?`[${t}]`:n===0?t:`.${t}`).join("")}const Wy=({open:e,onOpenChange:t})=>{const n=vi(A=>A.open),r=vi(A=>A.contextual),i=vi(A=>A.close),s=e??n,a=r,o=b.useCallback(A=>{t&&t(A),A||i()},[t,i]),[l,c]=b.useState(By),[f,d]=b.useState(!1),[p,h]=b.useState(""),[m,v]=b.useState("safe"),[S,y]=b.useState(null),[_,g]=b.useState(null),{toast:z}=ur(),C=Uy(),w=Jy(),E=Ae(A=>A.activeTab),R=Ae(A=>A.documentTypes),K=E&&R[E]==="application/json+theme",j=!!a||K;b.useEffect(()=>{s&&(l.safe.length>0||l.google.length>0||(d(!0),fetch("/api/fonts/catalog").then(A=>A.json()).then(A=>c(A)).catch(A=>{z({variant:"destructive",title:"Font catalog unavailable",description:A.message})}).finally(()=>d(!1))))},[s,l,z]),b.useEffect(()=>{if(!(m!=="google"||l.google.length===0))for(const A of l.google)Vy(A.family,A.weights)},[m,l]);const I=b.useMemo(()=>l.safe.filter(A=>A.toLowerCase().includes(p.toLowerCase())),[l.safe,p]),O=b.useMemo(()=>l.google.filter(A=>A.family.toLowerCase().includes(p.toLowerCase())),[l.google,p]),Z=b.useCallback(async A=>{try{await navigator.clipboard.writeText(A),g(A),setTimeout(()=>g(null),1500)}catch{z({variant:"destructive",title:"Copy failed",description:"Your browser blocked clipboard write."})}},[z]),M=b.useCallback(async(A,J,B)=>{y(A);try{const ne=C(k=>(Hy(k,B,A),k));if(!ne.ok){z({variant:"destructive",title:"Could not insert font",description:ne.error});return}z({title:"Font inserted",description:`${A} set as ${B} font in "${ne.name}".`})}finally{y(null)}},[C,z]),T=b.useCallback(async A=>{if(a){y(A);try{const J=w(a.jsonPath,A);if(!J.ok){z({variant:"destructive",title:"Could not insert font",description:J.error});return}z({title:"Font inserted",description:`${A} set at ${gl(a.jsonPath)}.`}),o(!1)}finally{y(null)}}},[a,w,z,o]);return u.jsx(It,{open:s,onOpenChange:o,children:u.jsxs(St,{className:"max-w-4xl max-h-[90vh] overflow-hidden flex flex-col",children:[u.jsx(Ut,{children:u.jsx(Jt,{children:a?`Font for ${gl(a.jsonPath)}`:"Fonts"})}),!a&&!K&&u.jsx(Ri,{children:u.jsxs(Mi,{children:["Fonts are registered on themes. Open a ",u.jsx("code",{children:".theme.json"})," ","file to apply a font — the buttons below are disabled until you do."]})}),u.jsxs(qd,{value:m,onValueChange:A=>v(A),className:"flex-1 overflow-hidden flex flex-col",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs(ro,{children:[u.jsxs(Zr,{value:"safe",children:["Safe",u.jsx(Vt,{variant:"secondary",className:"ml-1 text-xs px-1 py-0",children:l.safe.length})]}),u.jsxs(Zr,{value:"google",children:["Google",u.jsx(Vt,{variant:"secondary",className:"ml-1 text-xs px-1 py-0",children:l.google.length})]})]}),u.jsx(ei,{type:"search",placeholder:"Search fonts...",value:p,onChange:A=>h(A.target.value),className:"ml-auto max-w-xs"})]}),u.jsxs("div",{className:"flex-1 overflow-auto mt-4 pr-2",children:[u.jsx(Br,{value:"safe",className:"m-0",children:f&&I.length===0?u.jsxs("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:[u.jsx(ua,{className:"animate-spin mr-2"})," Loading catalog..."]}):u.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:I.map(A=>u.jsx(xl,{family:A,meta:u.jsx("span",{className:"text-xs",children:"Installed with Office"}),previewStyle:{fontFamily:`"${A}", sans-serif`},onCopy:()=>Z(A),copied:_===A,contextual:!!a,onUseThis:()=>T(A),onInsertHeading:()=>M(A,"safe","heading"),onInsertBody:()=>M(A,"safe","body"),applying:S===A,disabled:!j},A))})}),u.jsx(Br,{value:"google",className:"m-0",children:f&&O.length===0?u.jsxs("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:[u.jsx(ua,{className:"animate-spin mr-2"})," Loading catalog..."]}):u.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:O.map(A=>u.jsx(xl,{family:A.family,meta:u.jsxs("span",{className:"text-xs",children:[A.category," · ",A.weights.length," weights"]}),previewStyle:{fontFamily:`"${A.family}", sans-serif`},onCopy:()=>Z(A.family),copied:_===A.family,contextual:!!a,onUseThis:()=>T(A.family),onInsertHeading:()=>M(A.family,"google","heading"),onInsertBody:()=>M(A.family,"google","body"),applying:S===A.family,disabled:!j,extraAction:u.jsx(Gy,{family:A.family,weights:A.weights,hasItalic:A.hasItalic})},A.family))})})]})]})]})})},qy="The quick brown fox jumps over the lazy dog",Gy=({family:e,weights:t,hasItalic:n})=>{const r=b.useMemo(()=>[...t].sort((i,s)=>i-s),[t]);return u.jsxs(to,{children:[u.jsx(no,{asChild:!0,children:u.jsx(we,{size:"sm",variant:"ghost","aria-label":"Show variants",children:"Variants"})}),u.jsxs(ds,{align:"end",className:"min-w-[260px]",children:[u.jsxs(Wd,{className:"text-xs text-muted-foreground",children:[r.length," weight",r.length===1?"":"s",n?" · italic available":""]}),u.jsx(Lr,{}),r.map(i=>{const s=Bm[i]??String(i);return u.jsxs("div",{className:"flex flex-col gap-0.5 px-2 py-1.5",children:[u.jsx("span",{className:"truncate",style:{fontFamily:`"${e}", sans-serif`,fontWeight:i},children:s}),u.jsxs("span",{className:"text-xs text-muted-foreground font-mono",children:["fontWeight: ",i]})]},i)})]})]})},xl=({family:e,meta:t,previewStyle:n,onCopy:r,copied:i,contextual:s,onUseThis:a,onInsertHeading:o,onInsertBody:l,applying:c,disabled:f,extraAction:d})=>u.jsxs("div",{className:"border rounded-md p-3 flex flex-col gap-2 bg-card",children:[u.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[u.jsx("div",{className:"font-medium truncate",children:e}),u.jsx("div",{className:"text-muted-foreground",children:t})]}),u.jsx("div",{className:"text-lg truncate",style:n,"aria-hidden":!0,children:qy}),u.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[s?u.jsx(we,{size:"sm",onClick:a,disabled:c||f,"aria-label":`Use ${e} at the target path`,children:"Use this font"}):u.jsxs(u.Fragment,{children:[u.jsx(we,{size:"sm",variant:"secondary",onClick:o,disabled:c||f,"aria-label":`Set ${e} as heading font`,children:"Set heading"}),u.jsx(we,{size:"sm",variant:"secondary",onClick:l,disabled:c||f,"aria-label":`Set ${e} as body font`,children:"Set body"})]}),d,u.jsx(we,{size:"sm",variant:"ghost",className:"ml-auto",onClick:r,"aria-label":`Copy ${e}`,children:i?u.jsx(un,{className:"h-4 w-4"}):u.jsx(as,{className:"h-4 w-4"})})]})]});function yl({previewOpen:e,onTogglePreview:t}){const n=vn(R=>R.name||""),r=vn(R=>R.blob),i=vn(R=>R.isGenerating),s=vn(R=>R.text),a=vn(R=>R.warnings),o=vn(R=>R.isRendering),l=ui(R=>R.autoReload),c=ui(R=>R.renderingLibrary),f=ui(R=>R.setSettings),d=ui(R=>R.useGlobalPreviewHeader??!0),p=Ae(R=>R.activeTab),h=Ae(R=>R.documentTypes),m=p&&h[p]==="application/json+theme"?"theme":"document",v=Te(R=>R.chatOpen),S=Te(R=>R.toggleChat),[y,_]=Ee.useState(!1),g=vi(R=>R.openFor);if(!d)return null;const z=b.useCallback(()=>f({saveDocumentDebounceWait:2e3,autoReload:!l}),[l,f]),C=b.useCallback(()=>{window.dispatchEvent(new CustomEvent("preview:manualRender"))},[]),w=b.useCallback(()=>{window.dispatchEvent(new CustomEvent("preview:showCacheMetrics"))},[]),E=(n==null?void 0:n.trim())||"Preview";return u.jsxs("div",{className:"sticky top-0 z-20",children:[u.jsx(Ly,{name:E,blob:r,displayReloadButton:!1,autoReload:l,onToggleAutoReload:z,onManualRender:C,isGenerating:i,isRendering:!!o,onShowCacheMetrics:w,onShowSchemas:()=>_(!0),onShowFonts:()=>g(),documentText:s,warnings:a,renderingLibrary:c,setRenderingLibrary:R=>f({renderingLibrary:R}),onToggleChat:S,chatOpen:v,onTogglePreview:t,previewOpen:e}),u.jsx(Gd,{open:y,onOpenChange:_,defaultTab:m==="theme"?"theme":"document"}),u.jsx(Wy,{})]})}function Ky(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const Yy=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Xy=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Qy={};function bl(e,t){return(Qy.jsx?Xy:Yy).test(e)}const eb=/[ \t\n\f\r]/g;function tb(e){return typeof e=="object"?e.type==="text"?vl(e.value):!1:vl(e)}function vl(e){return e.replace(eb,"")===""}class ni{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}ni.prototype.normal={};ni.prototype.property={};ni.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 ni(n,r,t)}function ka(e){return e.toLowerCase()}class bt{constructor(t,n){this.attribute=n,this.property=t}}bt.prototype.attribute="";bt.prototype.booleanish=!1;bt.prototype.boolean=!1;bt.prototype.commaOrSpaceSeparated=!1;bt.prototype.commaSeparated=!1;bt.prototype.defined=!1;bt.prototype.mustUseProperty=!1;bt.prototype.number=!1;bt.prototype.overloadedBoolean=!1;bt.prototype.property="";bt.prototype.spaceSeparated=!1;bt.prototype.space=void 0;let nb=0;const ke=An(),tt=An(),Sa=An(),Y=An(),Fe=An(),Qn=An(),wt=An();function An(){return 2**++nb}const _a=Object.freeze(Object.defineProperty({__proto__:null,boolean:ke,booleanish:tt,commaOrSpaceSeparated:wt,commaSeparated:Qn,number:Y,overloadedBoolean:Sa,spaceSeparated:Fe},Symbol.toStringTag,{value:"Module"})),Fs=Object.keys(_a);class lo extends bt{constructor(t,n,r,i){let s=-1;if(super(t,n),wl(this,"space",i),typeof r=="number")for(;++s<Fs.length;){const a=Fs[s];wl(this,Fs[s],(r&_a[a])===_a[a])}}}lo.prototype.defined=!0;function wl(e,t,n){n&&(e[t]=n)}function cr(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const s=new lo(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[ka(r)]=r,n[ka(s.attribute)]=r}return new ni(t,n,e.space)}const wf=cr({properties:{ariaActiveDescendant:null,ariaAtomic:tt,ariaAutoComplete:null,ariaBusy:tt,ariaChecked:tt,ariaColCount:Y,ariaColIndex:Y,ariaColSpan:Y,ariaControls:Fe,ariaCurrent:null,ariaDescribedBy:Fe,ariaDetails:null,ariaDisabled:tt,ariaDropEffect:Fe,ariaErrorMessage:null,ariaExpanded:tt,ariaFlowTo:Fe,ariaGrabbed:tt,ariaHasPopup:null,ariaHidden:tt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Fe,ariaLevel:Y,ariaLive:null,ariaModal:tt,ariaMultiLine:tt,ariaMultiSelectable:tt,ariaOrientation:null,ariaOwns:Fe,ariaPlaceholder:null,ariaPosInSet:Y,ariaPressed:tt,ariaReadOnly:tt,ariaRelevant:null,ariaRequired:tt,ariaRoleDescription:Fe,ariaRowCount:Y,ariaRowIndex:Y,ariaRowSpan:Y,ariaSelected:tt,ariaSetSize:Y,ariaSort:null,ariaValueMax:Y,ariaValueMin:Y,ariaValueNow:Y,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function kf(e,t){return t in e?e[t]:t}function Sf(e,t){return kf(e,t.toLowerCase())}const rb=cr({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Qn,acceptCharset:Fe,accessKey:Fe,action:null,allow:null,allowFullScreen:ke,allowPaymentRequest:ke,allowUserMedia:ke,alt:null,as:null,async:ke,autoCapitalize:null,autoComplete:Fe,autoFocus:ke,autoPlay:ke,blocking:Fe,capture:null,charSet:null,checked:ke,cite:null,className:Fe,cols:Y,colSpan:null,content:null,contentEditable:tt,controls:ke,controlsList:Fe,coords:Y|Qn,crossOrigin:null,data:null,dateTime:null,decoding:null,default:ke,defer:ke,dir:null,dirName:null,disabled:ke,download:Sa,draggable:tt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:ke,formTarget:null,headers:Fe,height:Y,hidden:Sa,high:Y,href:null,hrefLang:null,htmlFor:Fe,httpEquiv:Fe,id:null,imageSizes:null,imageSrcSet:null,inert:ke,inputMode:null,integrity:null,is:null,isMap:ke,itemId:null,itemProp:Fe,itemRef:Fe,itemScope:ke,itemType:Fe,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:ke,low:Y,manifest:null,max:null,maxLength:Y,media:null,method:null,min:null,minLength:Y,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:Y,pattern:null,ping:Fe,placeholder:null,playsInline:ke,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:ke,referrerPolicy:null,rel:Fe,required:ke,reversed:ke,rows:Y,rowSpan:Y,sandbox:Fe,scope:null,scoped:ke,seamless:ke,selected:ke,shadowRootClonable:ke,shadowRootDelegatesFocus:ke,shadowRootMode:null,shape:null,size:Y,sizes:null,slot:null,span:Y,spellCheck:tt,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Y,step:null,style:null,tabIndex:Y,target:null,title:null,translate:null,type:null,typeMustMatch:ke,useMap:null,value:tt,width:Y,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Fe,axis:null,background:null,bgColor:null,border:Y,borderColor:null,bottomMargin:Y,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:ke,declare:ke,event:null,face:null,frame:null,frameBorder:null,hSpace:Y,leftMargin:Y,link:null,longDesc:null,lowSrc:null,marginHeight:Y,marginWidth:Y,noResize:ke,noHref:ke,noShade:ke,noWrap:ke,object:null,profile:null,prompt:null,rev:null,rightMargin:Y,rules:null,scheme:null,scrolling:tt,standby:null,summary:null,text:null,topMargin:Y,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Y,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:ke,disableRemotePlayback:ke,prefix:null,property:null,results:Y,security:null,unselectable:null},space:"html",transform:Sf}),ib=cr({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:wt,accentHeight:Y,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Y,amplitude:Y,arabicForm:null,ascent:Y,attributeName:null,attributeType:null,azimuth:Y,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Y,by:null,calcMode:null,capHeight:Y,className:Fe,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Y,diffuseConstant:Y,direction:null,display:null,dur:null,divisor:Y,dominantBaseline:null,download:ke,dx:null,dy:null,edgeMode:null,editable:null,elevation:Y,enableBackground:null,end:null,event:null,exponent:Y,externalResourcesRequired:null,fill:null,fillOpacity:Y,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Qn,g2:Qn,glyphName:Qn,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Y,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Y,horizOriginX:Y,horizOriginY:Y,id:null,ideographic:Y,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Y,k:Y,k1:Y,k2:Y,k3:Y,k4:Y,kernelMatrix:wt,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Y,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Y,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Y,overlineThickness:Y,paintOrder:null,panose1:null,path:null,pathLength:Y,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Fe,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Y,pointsAtY:Y,pointsAtZ:Y,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:wt,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:wt,rev:wt,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:wt,requiredFeatures:wt,requiredFonts:wt,requiredFormats:wt,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Y,specularExponent:Y,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Y,strikethroughThickness:Y,string:null,stroke:null,strokeDashArray:wt,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Y,strokeOpacity:Y,strokeWidth:null,style:null,surfaceScale:Y,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:wt,tabIndex:Y,tableValues:null,target:null,targetX:Y,targetY:Y,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:wt,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Y,underlineThickness:Y,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Y,values:null,vAlphabetic:Y,vMathematical:Y,vectorEffect:null,vHanging:Y,vIdeographic:Y,version:null,vertAdvY:Y,vertOriginX:Y,vertOriginY:Y,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Y,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:kf}),_f=cr({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=cr({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Sf}),Nf=cr({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),sb={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"},ab=/[A-Z]/g,kl=/-[a-z]/g,ob=/^data[-\w.:]+$/i;function lb(e,t){const n=ka(t);let r=t,i=bt;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&ob.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(kl,cb);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!kl.test(s)){let a=s.replace(ab,ub);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}i=lo}return new i(r,t)}function ub(e){return"-"+e.toLowerCase()}function cb(e){return e.charAt(1).toUpperCase()}const db=vf([wf,rb,_f,jf,Nf],"html"),uo=vf([wf,ib,_f,jf,Nf],"svg");function fb(e){return e.join(" ").trim()}var $n={},Ls,Sl;function pb(){if(Sl)return Ls;Sl=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,a=/^[;\s]*/,o=/^\s+|\s+$/g,l=`
3
+ `,c="/",f="*",d="",p="comment",h="declaration";function m(S,y){if(typeof S!="string")throw new TypeError("First argument must be a string");if(!S)return[];y=y||{};var _=1,g=1;function z(M){var T=M.match(t);T&&(_+=T.length);var A=M.lastIndexOf(l);g=~A?M.length-A:g+M.length}function C(){var M={line:_,column:g};return function(T){return T.position=new w(M),K(),T}}function w(M){this.start=M,this.end={line:_,column:g},this.source=y.source}w.prototype.content=S;function E(M){var T=new Error(y.source+":"+_+":"+g+": "+M);if(T.reason=M,T.filename=y.source,T.line=_,T.column=g,T.source=S,!y.silent)throw T}function R(M){var T=M.exec(S);if(T){var A=T[0];return z(A),S=S.slice(A.length),T}}function K(){R(n)}function j(M){var T;for(M=M||[];T=I();)T!==!1&&M.push(T);return M}function I(){var M=C();if(!(c!=S.charAt(0)||f!=S.charAt(1))){for(var T=2;d!=S.charAt(T)&&(f!=S.charAt(T)||c!=S.charAt(T+1));)++T;if(T+=2,d===S.charAt(T-1))return E("End of comment missing");var A=S.slice(2,T-2);return g+=2,z(A),S=S.slice(T),g+=2,M({type:p,comment:A})}}function O(){var M=C(),T=R(r);if(T){if(I(),!R(i))return E("property missing ':'");var A=R(s),J=M({type:h,property:v(T[0].replace(e,d)),value:A?v(A[0].replace(e,d)):d});return R(a),J}}function Z(){var M=[];j(M);for(var T;T=O();)T!==!1&&(M.push(T),j(M));return M}return K(),Z()}function v(S){return S?S.replace(o,d):d}return Ls=m,Ls}var _l;function hb(){if(_l)return $n;_l=1;var e=$n&&$n.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty($n,"__esModule",{value:!0}),$n.default=n;const t=e(pb());function n(r,i){let s=null;if(!r||typeof r!="string")return s;const a=(0,t.default)(r),o=typeof i=="function";return a.forEach(l=>{if(l.type!=="declaration")return;const{property:c,value:f}=l;o?i(c,f,l):f&&(s=s||{},s[c]=f)}),s}return $n}var yr={},jl;function mb(){if(jl)return yr;jl=1,Object.defineProperty(yr,"__esModule",{value:!0}),yr.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,i=/^-(ms)-/,s=function(c){return!c||n.test(c)||e.test(c)},a=function(c,f){return f.toUpperCase()},o=function(c,f){return"".concat(f,"-")},l=function(c,f){return f===void 0&&(f={}),s(c)?c:(c=c.toLowerCase(),f.reactCompat?c=c.replace(i,o):c=c.replace(r,o),c.replace(t,a))};return yr.camelCase=l,yr}var br,Nl;function gb(){if(Nl)return br;Nl=1;var e=br&&br.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},t=e(hb()),n=mb();function r(i,s){var a={};return!i||typeof i!="string"||(0,t.default)(i,function(o,l){o&&l&&(a[(0,n.camelCase)(o,s)]=l)}),a}return r.default=r,br=r,br}var xb=gb();const yb=Ua(xb),Cf=Ef("end"),co=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 bb(e){const t=co(e),n=Cf(e);if(t&&n)return{start:t,end:n}}function Or(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?ja(e):""}function ja(e){return El(e&&e.line)+":"+El(e&&e.column)}function Cl(e){return ja(e&&e.start)+"-"+ja(e&&e.end)}function El(e){return e&&typeof e=="number"?e:1}class at extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",s={},a=!1;if(n&&("line"in n&&"column"in n?s={place:n}:"start"in n&&"end"in n?s={place:n}:"type"in n?s={ancestors:[n],place:n.position}:s={...n}),typeof t=="string"?i=t:!s.cause&&t&&(a=!0,i=t.message,s.cause=t),!s.ruleId&&!s.source&&typeof r=="string"){const l=r.indexOf(":");l===-1?s.ruleId=r:(s.source=r.slice(0,l),s.ruleId=r.slice(l+1))}if(!s.place&&s.ancestors&&s.ancestors){const l=s.ancestors[s.ancestors.length-1];l&&(s.place=l.position)}const o=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=o?o.line:void 0,this.name=Or(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 fo={}.hasOwnProperty,vb=new Map,wb=/[A-Z]/g,kb=new Set(["table","tbody","thead","tfoot","tr"]),Sb=new Set(["td","th"]),If="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function _b(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=Ab(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=Tb(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"?uo:db,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},s=zf(i,e,void 0);return s&&typeof s!="string"?s:i.create(e,i.Fragment,{children:s||void 0},void 0)}function zf(e,t,n){if(t.type==="element")return jb(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return Nb(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return Eb(e,t,n);if(t.type==="mdxjsEsm")return Cb(e,t);if(t.type==="root")return Ib(e,t,n);if(t.type==="text")return zb(e,t)}function jb(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=uo,e.schema=i),e.ancestors.push(t);const s=Af(e,t.tagName,!1),a=Pb(e,t);let o=ho(e,t);return kb.has(t.tagName)&&(o=o.filter(function(l){return typeof l=="string"?!tb(l):!0})),Tf(e,a,s,t),po(a,o),e.ancestors.pop(),e.schema=r,e.create(t,s,a,n)}function Nb(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)}Jr(e,t.position)}function Cb(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Jr(e,t.position)}function Eb(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=uo,e.schema=i),e.ancestors.push(t);const s=t.name===null?e.Fragment:Af(e,t.name,!0),a=Ob(e,t),o=ho(e,t);return Tf(e,a,s,t),po(a,o),e.ancestors.pop(),e.schema=r,e.create(t,s,a,n)}function Ib(e,t,n){const r={};return po(r,ho(e,t)),e.create(t,e.Fragment,r,n)}function zb(e,t){return t.value}function Tf(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function po(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function Tb(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 Ab(e,t){return n;function n(r,i,s,a){const o=Array.isArray(s.children),l=co(r);return t(i,s,a,o,{columnNumber:l?l.column-1:void 0,fileName:e,lineNumber:l?l.line:void 0},void 0)}}function Pb(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&fo.call(t.properties,i)){const s=Db(e,i,t.properties[i]);if(s){const[a,o]=s;e.tableCellAlignToStyle&&a==="align"&&typeof o=="string"&&Sb.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 Ob(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 Jr(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 Jr(e,t.position);else s=r.value===null?!0:r.value;n[i]=s}return n}function ho(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:vb;for(;++r<t.children.length;){const s=t.children[r];let a;if(e.passKeys){const l=s.type==="element"?s.tagName:s.type==="mdxJsxFlowElement"||s.type==="mdxJsxTextElement"?s.name:void 0;if(l){const c=i.get(l)||0;a=l+"-"+c,i.set(l,c+1)}}const o=zf(e,s,a);o!==void 0&&n.push(o)}return n}function Db(e,t,n){const r=lb(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?Ky(n):fb(n)),r.property==="style"){let i=typeof n=="object"?n:Rb(e,String(n));return e.stylePropertyNameCase==="css"&&(i=Mb(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&r.space?sb[r.property]||r.property:r.attribute,n]}}function Rb(e,t){try{return yb(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=bl(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=bl(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const i=r.value;return fo.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(r);Jr(e)}function Jr(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 Mb(e){const t={};let n;for(n in e)fo.call(e,n)&&(t[$b(n)]=e[n]);return t}function $b(e){let t=e.replace(wb,Fb);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function Fb(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"]},Lb={};function mo(e,t){const n=Lb,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(Zb(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 Il(e.children,t,n)}return Array.isArray(e)?Il(e,t,n):""}function Il(e,t,n){const r=[];let i=-1;for(;++i<e.length;)r[i]=Pf(e[i],t,n);return r.join("")}function Zb(e){return!!(e&&typeof e=="object")}const zl=document.createElement("i");function go(e){const t="&"+e+";";zl.innerHTML=t;const n=zl.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function _t(e,t,n,r){const i=e.length;let s=0,a;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)a=Array.from(r),a.unshift(t,n),e.splice(...a);else for(n&&e.splice(t,n);s<r.length;)a=r.slice(s,s+1e4),a.unshift(t,0),e.splice(...a),s+=1e4,t+=1e4}function Et(e,t){return e.length>0?(_t(e,e.length,0,t),e):t}const Tl={}.hasOwnProperty;function Of(e){const t={};let n=-1;for(;++n<e.length;)Bb(t,e[n]);return t}function Bb(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];Vb(i[a],Array.isArray(o)?o:o?[o]:[])}}}function Vb(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);_t(e,0,0,r)}function 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 Mt(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const dt=pn(/[A-Za-z]/),st=pn(/[\dA-Za-z]/),Ub=pn(/[#-'*+\--9=?A-Z^-~]/);function Bi(e){return e!==null&&(e<32||e===127)}const Na=pn(/\d/),Jb=pn(/[\dA-Fa-f]/),Hb=pn(/[!-/:-@[-`{-~]/);function xe(e){return e!==null&&e<-2}function Me(e){return e!==null&&(e<0||e===32)}function Ne(e){return e===-2||e===-1||e===32}const gs=pn(new RegExp("\\p{P}|\\p{S}","u")),zn=pn(/\s/);function pn(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function dr(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 ze(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let s=0;return a;function a(l){return Ne(l)?(e.enter(n),o(l)):t(l)}function o(l){return Ne(l)&&s++<i?(e.consume(l),o):(e.exit(n),t(l))}}const Wb={tokenize:qb};function qb(e){const t=e.attempt(this.parser.constructs.contentInitial,r,i);let n;return t;function r(o){if(o===null){e.consume(o);return}return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),ze(e,t,"linePrefix")}function i(o){return e.enter("paragraph"),s(o)}function s(o){const l=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=l),n=l,a(o)}function a(o){if(o===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(o);return}return xe(o)?(e.consume(o),e.exit("chunkText"),s):(e.consume(o),a)}}const Gb={tokenize:Kb},Al={tokenize:Yb};function Kb(e){const t=this,n=[];let r=0,i,s,a;return o;function o(g){if(r<n.length){const z=n[r];return t.containerState=z[1],e.attempt(z[0].continuation,l,c)(g)}return c(g)}function l(g){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&_();const z=t.events.length;let C=z,w;for(;C--;)if(t.events[C][0]==="exit"&&t.events[C][1].type==="chunkFlow"){w=t.events[C][1].end;break}y(r);let E=z;for(;E<t.events.length;)t.events[E][1].end={...w},E++;return _t(t.events,C+1,0,t.events.slice(z)),t.events.length=E,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(Al,f,d)(g)}function f(g){return i&&_(),y(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(Al,h,m)(g)}function h(g){return r++,n.push([t.currentConstruct,t.containerState]),p(g)}function m(g){if(g===null){i&&_(),y(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),y(0),e.consume(g);return}return xe(g)?(e.consume(g),S(e.exit("chunkFlow")),r=0,t.interrupt=void 0,o):(e.consume(g),v)}function S(g,z){const C=t.sliceStream(g);if(z&&C.push(null),g.previous=s,s&&(s.next=g),s=g,i.defineSkip(g.start),i.write(C),t.parser.lazy[g.start.line]){let w=i.events.length;for(;w--;)if(i.events[w][1].start.offset<a&&(!i.events[w][1].end||i.events[w][1].end.offset>a))return;const E=t.events.length;let R=E,K,j;for(;R--;)if(t.events[R][0]==="exit"&&t.events[R][1].type==="chunkFlow"){if(K){j=t.events[R][1].end;break}K=!0}for(y(r),w=E;w<t.events.length;)t.events[w][1].end={...j},w++;_t(t.events,R+1,0,t.events.slice(E)),t.events.length=w}}function y(g){let z=n.length;for(;z-- >g;){const C=n[z];t.containerState=C[1],C[0].exit.call(t,e)}n.length=g}function _(){i.write([null]),s=void 0,i=void 0,t.containerState._closeFlow=void 0}}function Yb(e,t,n){return ze(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function ir(e){if(e===null||Me(e)||zn(e))return 1;if(gs(e))return 2}function xs(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 Ca={name:"attention",resolveAll:Xb,tokenize:Qb};function Xb(e,t){let n=-1,r,i,s,a,o,l,c,f;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;l=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const d={...e[r][1].end},p={...e[n][1].start};Pl(d,-l),Pl(p,l),a={type:l>1?"strongSequence":"emphasisSequence",start:d,end:{...e[r][1].end}},o={type:l>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:p},s={type:l>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:l>1?"strong":"emphasis",start:{...a.start},end:{...o.end}},e[r][1].end={...a.start},e[n][1].start={...o.end},c=[],e[r][1].end.offset-e[r][1].start.offset&&(c=Et(c,[["enter",e[r][1],t],["exit",e[r][1],t]])),c=Et(c,[["enter",i,t],["enter",a,t],["exit",a,t],["enter",s,t]]),c=Et(c,xs(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),c=Et(c,[["exit",s,t],["enter",o,t],["exit",o,t],["exit",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(f=2,c=Et(c,[["enter",e[n][1],t],["exit",e[n][1],t]])):f=0,_t(e,r-1,n-r+3,c),n=r+c.length-f-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function Qb(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=ir(r);let s;return a;function a(l){return s=l,e.enter("attentionSequence"),o(l)}function o(l){if(l===s)return e.consume(l),o;const c=e.exit("attentionSequence"),f=ir(l),d=!f||f===2&&i||n.includes(l),p=!i||i===2&&f||n.includes(r);return c._open=!!(s===42?d:d&&(i||!p)),c._close=!!(s===42?p:p&&(f||!d)),t(l)}}function Pl(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const ev={name:"autolink",tokenize:tv};function tv(e,t,n){let r=0;return i;function i(h){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),s}function s(h){return dt(h)?(e.consume(h),a):h===64?n(h):c(h)}function a(h){return h===43||h===45||h===46||st(h)?(r=1,o(h)):c(h)}function o(h){return h===58?(e.consume(h),r=0,l):(h===43||h===45||h===46||st(h))&&r++<32?(e.consume(h),o):(r=0,c(h))}function l(h){return h===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.exit("autolink"),t):h===null||h===32||h===60||Bi(h)?n(h):(e.consume(h),l)}function c(h){return h===64?(e.consume(h),f):Ub(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 ri={partial:!0,tokenize:nv};function nv(e,t,n){return r;function r(s){return Ne(s)?ze(e,i,"linePrefix")(s):i(s)}function i(s){return s===null||xe(s)?t(s):n(s)}}const Rf={continuation:{tokenize:iv},exit:sv,name:"blockQuote",tokenize:rv};function rv(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 Ne(a)?(e.enter("blockQuotePrefixWhitespace"),e.consume(a),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(a))}}function iv(e,t,n){const r=this;return i;function i(a){return Ne(a)?ze(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 sv(e){e.exit("blockQuote")}const Mf={name:"characterEscape",tokenize:av};function av(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 Hb(s)?(e.enter("characterEscapeValue"),e.consume(s),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(s)}}const $f={name:"characterReference",tokenize:ov};function ov(e,t,n){const r=this;let i=0,s,a;return o;function o(d){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(d),e.exit("characterReferenceMarker"),l}function l(d){return d===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(d),e.exit("characterReferenceMarkerNumeric"),c):(e.enter("characterReferenceValue"),s=31,a=st,f(d))}function c(d){return d===88||d===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(d),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),s=6,a=Jb,f):(e.enter("characterReferenceValue"),s=7,a=Na,f(d))}function f(d){if(d===59&&i){const p=e.exit("characterReferenceValue");return a===st&&!go(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 Ol={partial:!0,tokenize:uv},Dl={concrete:!0,name:"codeFenced",tokenize:lv};function lv(e,t,n){const r=this,i={partial:!0,tokenize:C};let s=0,a=0,o;return l;function l(w){return c(w)}function c(w){const E=r.events[r.events.length-1];return s=E&&E[1].type==="linePrefix"?E[2].sliceSerialize(E[1],!0).length:0,o=w,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),f(w)}function f(w){return w===o?(a++,e.consume(w),f):a<3?n(w):(e.exit("codeFencedFenceSequence"),Ne(w)?ze(e,d,"whitespace")(w):d(w))}function d(w){return w===null||xe(w)?(e.exit("codeFencedFence"),r.interrupt?t(w):e.check(Ol,v,z)(w)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),p(w))}function p(w){return w===null||xe(w)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),d(w)):Ne(w)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),ze(e,h,"whitespace")(w)):w===96&&w===o?n(w):(e.consume(w),p)}function h(w){return w===null||xe(w)?d(w):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),m(w))}function m(w){return w===null||xe(w)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),d(w)):w===96&&w===o?n(w):(e.consume(w),m)}function v(w){return e.attempt(i,z,S)(w)}function S(w){return e.enter("lineEnding"),e.consume(w),e.exit("lineEnding"),y}function y(w){return s>0&&Ne(w)?ze(e,_,"linePrefix",s+1)(w):_(w)}function _(w){return w===null||xe(w)?e.check(Ol,v,z)(w):(e.enter("codeFlowValue"),g(w))}function g(w){return w===null||xe(w)?(e.exit("codeFlowValue"),_(w)):(e.consume(w),g)}function z(w){return e.exit("codeFenced"),t(w)}function C(w,E,R){let K=0;return j;function j(T){return w.enter("lineEnding"),w.consume(T),w.exit("lineEnding"),I}function I(T){return w.enter("codeFencedFence"),Ne(T)?ze(w,O,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(T):O(T)}function O(T){return T===o?(w.enter("codeFencedFenceSequence"),Z(T)):R(T)}function Z(T){return T===o?(K++,w.consume(T),Z):K>=a?(w.exit("codeFencedFenceSequence"),Ne(T)?ze(w,M,"whitespace")(T):M(T)):R(T)}function M(T){return T===null||xe(T)?(w.exit("codeFencedFence"),E(T)):R(T)}}}function uv(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:dv},cv={partial:!0,tokenize:fv};function dv(e,t,n){const r=this;return i;function i(c){return e.enter("codeIndented"),ze(e,s,"linePrefix",5)(c)}function s(c){const f=r.events[r.events.length-1];return f&&f[1].type==="linePrefix"&&f[2].sliceSerialize(f[1],!0).length>=4?a(c):n(c)}function a(c){return c===null?l(c):xe(c)?e.attempt(cv,a,l)(c):(e.enter("codeFlowValue"),o(c))}function o(c){return c===null||xe(c)?(e.exit("codeFlowValue"),a(c)):(e.consume(c),o)}function l(c){return e.exit("codeIndented"),t(c)}}function fv(e,t,n){const r=this;return i;function i(a){return r.parser.lazy[r.now().line]?n(a):xe(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),i):ze(e,s,"linePrefix",5)(a)}function s(a){const o=r.events[r.events.length-1];return o&&o[1].type==="linePrefix"&&o[2].sliceSerialize(o[1],!0).length>=4?t(a):xe(a)?i(a):n(a)}}const pv={name:"codeText",previous:mv,resolve:hv,tokenize:gv};function hv(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 mv(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function gv(e,t,n){let r=0,i,s;return a;function a(d){return e.enter("codeText"),e.enter("codeTextSequence"),o(d)}function o(d){return d===96?(e.consume(d),r++,o):(e.exit("codeTextSequence"),l(d))}function l(d){return d===null?n(d):d===32?(e.enter("space"),e.consume(d),e.exit("space"),l):d===96?(s=e.enter("codeTextSequence"),i=0,f(d)):xe(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),l):(e.enter("codeTextData"),c(d))}function c(d){return d===null||d===32||d===96||xe(d)?(e.exit("codeTextData"),l(d)):(e.consume(d),c)}function f(d){return d===96?(e.consume(d),i++,f):i===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(d)):(s.type="codeTextData",c(d))}}class xv{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&&vr(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),vr(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),vr(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);vr(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);vr(this.left,n.reverse())}}}function vr(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,l,c;const f=new xv(e);for(;++n<f.length;){for(;n in t;)n=t[n];if(r=f.get(n),n&&r[1].type==="chunkFlow"&&f.get(n-1)[1].type==="listItemPrefix"&&(l=r[1]._tokenizer.events,s=0,s<l.length&&l[s][1].type==="lineEndingBlank"&&(s+=2),s<l.length&&l[s][1].type==="content"))for(;++s<l.length&&l[s][1].type!=="content";)l[s][1].type==="chunkText"&&(l[s][1]._isInFirstContentOfListItem=!0,s++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,yv(f,n)),n=t[n],c=!0);else if(r[1]._container){for(s=n,i=void 0;s--;)if(a=f.get(s),a[1].type==="lineEnding"||a[1].type==="lineEndingBlank")a[0]==="enter"&&(i&&(f.get(i)[1].type="lineEndingBlank"),a[1].type="lineEnding",i=s);else if(!(a[1].type==="linePrefix"||a[1].type==="listItemIndent"))break;i&&(r[1].end={...f.get(i)[1].start},o=f.slice(i,n),o.unshift(r),f.splice(i,n-i+1,o))}}return _t(e,0,Number.POSITIVE_INFINITY,f.slice(0)),!c}function yv(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const s=[];let a=n._tokenizer;a||(a=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(a._contentTypeTextTrailing=!0));const o=a.events,l=[],c={};let f,d,p=-1,h=n,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 y=o.slice(S[p],S[p+1]),_=s.pop();l.push([_,_+y.length-1]),e.splice(_,2,y)}for(l.reverse(),p=-1;++p<l.length;)c[m+l[p][0]]=m+l[p][1],m+=l[p][1]-l[p][0]-1;return c}const bv={resolve:wv,tokenize:kv},vv={partial:!0,tokenize:Sv};function wv(e){return Ff(e),e}function kv(e,t){let n;return r;function r(o){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),i(o)}function i(o){return o===null?s(o):xe(o)?e.check(vv,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 Sv(e,t,n){const r=this;return i;function i(a){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),ze(e,s,"linePrefix")}function s(a){if(a===null||xe(a))return n(a);const o=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&o&&o[1].type==="linePrefix"&&o[2].sliceSerialize(o[1],!0).length>=4?t(a):e.interrupt(r.parser.constructs.flow,n,t)(a)}}function Lf(e,t,n,r,i,s,a,o,l){const c=l||Number.POSITIVE_INFINITY;let f=0;return d;function d(y){return y===60?(e.enter(r),e.enter(i),e.enter(s),e.consume(y),e.exit(s),p):y===null||y===32||y===41||Bi(y)?n(y):(e.enter(r),e.enter(a),e.enter(o),e.enter("chunkString",{contentType:"string"}),v(y))}function p(y){return y===62?(e.enter(s),e.consume(y),e.exit(s),e.exit(i),e.exit(r),t):(e.enter(o),e.enter("chunkString",{contentType:"string"}),h(y))}function h(y){return y===62?(e.exit("chunkString"),e.exit(o),p(y)):y===null||y===60||xe(y)?n(y):(e.consume(y),y===92?m:h)}function m(y){return y===60||y===62||y===92?(e.consume(y),h):h(y)}function v(y){return!f&&(y===null||y===41||Me(y))?(e.exit("chunkString"),e.exit(o),e.exit(a),e.exit(r),t(y)):f<c&&y===40?(e.consume(y),f++,v):y===41?(e.consume(y),f--,v):y===null||y===32||y===40||Bi(y)?n(y):(e.consume(y),y===92?S:v)}function S(y){return y===40||y===41||y===92?(e.consume(y),v):v(y)}}function Zf(e,t,n,r,i,s){const a=this;let o=0,l;return c;function c(h){return e.enter(r),e.enter(i),e.consume(h),e.exit(i),e.enter(s),f}function f(h){return o>999||h===null||h===91||h===93&&!l||h===94&&!o&&"_hiddenFootnoteSupport"in a.parser.constructs?n(h):h===93?(e.exit(s),e.enter(i),e.consume(h),e.exit(i),e.exit(r),t):xe(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),f):(e.enter("chunkString",{contentType:"string"}),d(h))}function d(h){return h===null||h===91||h===93||xe(h)||o++>999?(e.exit("chunkString"),f(h)):(e.consume(h),l||(l=!Ne(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,l):n(p)}function l(p){return p===a?(e.enter(i),e.consume(p),e.exit(i),e.exit(r),t):(e.enter(s),c(p))}function c(p){return p===a?(e.exit(s),l(a)):p===null?n(p):xe(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),ze(e,c,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),f(p))}function f(p){return p===a||p===null||xe(p)?(e.exit("chunkString"),c(p)):(e.consume(p),p===92?d:f)}function d(p){return p===a||p===92?(e.consume(p),f):f(p)}}function Dr(e,t){let n;return r;function r(i){return xe(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):Ne(i)?ze(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const _v={name:"definition",tokenize:Nv},jv={partial:!0,tokenize:Cv};function Nv(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=Mt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),h===58?(e.enter("definitionMarker"),e.consume(h),e.exit("definitionMarker"),l):n(h)}function l(h){return Me(h)?Dr(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(jv,d,d)(h)}function d(h){return Ne(h)?ze(e,p,"whitespace")(h):p(h)}function p(h){return h===null||xe(h)?(e.exit("definition"),r.parser.defined.push(i),t(h)):n(h)}}function Cv(e,t,n){return r;function r(o){return Me(o)?Dr(e,i)(o):n(o)}function i(o){return Bf(e,s,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(o)}function s(o){return Ne(o)?ze(e,a,"whitespace")(o):a(o)}function a(o){return o===null||xe(o)?t(o):n(o)}}const Ev={name:"hardBreakEscape",tokenize:Iv};function Iv(e,t,n){return r;function r(s){return e.enter("hardBreakEscape"),e.consume(s),i}function i(s){return xe(s)?(e.exit("hardBreakEscape"),t(s)):n(s)}}const zv={name:"headingAtx",resolve:Tv,tokenize:Av};function Tv(e,t){let n=e.length-2,r=3,i,s;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(i={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},s={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},_t(e,r,n-r+1,[["enter",i,t],["enter",s,t],["exit",s,t],["exit",i,t]])),e}function Av(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||Me(f)?(e.exit("atxHeadingSequence"),o(f)):n(f)}function o(f){return f===35?(e.enter("atxHeadingSequence"),l(f)):f===null||xe(f)?(e.exit("atxHeading"),t(f)):Ne(f)?ze(e,o,"whitespace")(f):(e.enter("atxHeadingText"),c(f))}function l(f){return f===35?(e.consume(f),l):(e.exit("atxHeadingSequence"),o(f))}function c(f){return f===null||f===35||Me(f)?(e.exit("atxHeadingText"),o(f)):(e.consume(f),c)}}const Pv=["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"],Rl=["pre","script","style","textarea"],Ov={concrete:!0,name:"htmlFlow",resolveTo:Mv,tokenize:$v},Dv={partial:!0,tokenize:Lv},Rv={partial:!0,tokenize:Fv};function Mv(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 $v(e,t,n){const r=this;let i,s,a,o,l;return c;function c(x){return f(x)}function f(x){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(x),d}function d(x){return x===33?(e.consume(x),p):x===47?(e.consume(x),s=!0,v):x===63?(e.consume(x),i=3,r.interrupt?t:k):dt(x)?(e.consume(x),a=String.fromCharCode(x),S):n(x)}function p(x){return x===45?(e.consume(x),i=2,h):x===91?(e.consume(x),i=5,o=0,m):dt(x)?(e.consume(x),i=4,r.interrupt?t:k):n(x)}function h(x){return x===45?(e.consume(x),r.interrupt?t:k):n(x)}function m(x){const H="CDATA[";return x===H.charCodeAt(o++)?(e.consume(x),o===H.length?r.interrupt?t:O:m):n(x)}function v(x){return dt(x)?(e.consume(x),a=String.fromCharCode(x),S):n(x)}function S(x){if(x===null||x===47||x===62||Me(x)){const H=x===47,G=a.toLowerCase();return!H&&!s&&Rl.includes(G)?(i=1,r.interrupt?t(x):O(x)):Pv.includes(a.toLowerCase())?(i=6,H?(e.consume(x),y):r.interrupt?t(x):O(x)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(x):s?_(x):g(x))}return x===45||st(x)?(e.consume(x),a+=String.fromCharCode(x),S):n(x)}function y(x){return x===62?(e.consume(x),r.interrupt?t:O):n(x)}function _(x){return Ne(x)?(e.consume(x),_):j(x)}function g(x){return x===47?(e.consume(x),j):x===58||x===95||dt(x)?(e.consume(x),z):Ne(x)?(e.consume(x),g):j(x)}function z(x){return x===45||x===46||x===58||x===95||st(x)?(e.consume(x),z):C(x)}function C(x){return x===61?(e.consume(x),w):Ne(x)?(e.consume(x),C):g(x)}function w(x){return x===null||x===60||x===61||x===62||x===96?n(x):x===34||x===39?(e.consume(x),l=x,E):Ne(x)?(e.consume(x),w):R(x)}function E(x){return x===l?(e.consume(x),l=null,K):x===null||xe(x)?n(x):(e.consume(x),E)}function R(x){return x===null||x===34||x===39||x===47||x===60||x===61||x===62||x===96||Me(x)?C(x):(e.consume(x),R)}function K(x){return x===47||x===62||Ne(x)?g(x):n(x)}function j(x){return x===62?(e.consume(x),I):n(x)}function I(x){return x===null||xe(x)?O(x):Ne(x)?(e.consume(x),I):n(x)}function O(x){return x===45&&i===2?(e.consume(x),A):x===60&&i===1?(e.consume(x),J):x===62&&i===4?(e.consume(x),ce):x===63&&i===3?(e.consume(x),k):x===93&&i===5?(e.consume(x),ne):xe(x)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(Dv,de,Z)(x)):x===null||xe(x)?(e.exit("htmlFlowData"),Z(x)):(e.consume(x),O)}function Z(x){return e.check(Rv,M,de)(x)}function M(x){return e.enter("lineEnding"),e.consume(x),e.exit("lineEnding"),T}function T(x){return x===null||xe(x)?Z(x):(e.enter("htmlFlowData"),O(x))}function A(x){return x===45?(e.consume(x),k):O(x)}function J(x){return x===47?(e.consume(x),a="",B):O(x)}function B(x){if(x===62){const H=a.toLowerCase();return Rl.includes(H)?(e.consume(x),ce):O(x)}return dt(x)&&a.length<8?(e.consume(x),a+=String.fromCharCode(x),B):O(x)}function ne(x){return x===93?(e.consume(x),k):O(x)}function k(x){return x===62?(e.consume(x),ce):x===45&&i===2?(e.consume(x),k):O(x)}function ce(x){return x===null||xe(x)?(e.exit("htmlFlowData"),de(x)):(e.consume(x),ce)}function de(x){return e.exit("htmlFlow"),t(x)}}function Fv(e,t,n){const r=this;return i;function i(a){return xe(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),s):n(a)}function s(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}function Lv(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(ri,t,n)}}const Zv={name:"htmlText",tokenize:Bv};function Bv(e,t,n){const r=this;let i,s,a;return o;function o(k){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(k),l}function l(k){return k===33?(e.consume(k),c):k===47?(e.consume(k),C):k===63?(e.consume(k),g):dt(k)?(e.consume(k),R):n(k)}function c(k){return k===45?(e.consume(k),f):k===91?(e.consume(k),s=0,m):dt(k)?(e.consume(k),_):n(k)}function f(k){return k===45?(e.consume(k),h):n(k)}function d(k){return k===null?n(k):k===45?(e.consume(k),p):xe(k)?(a=d,J(k)):(e.consume(k),d)}function p(k){return k===45?(e.consume(k),h):d(k)}function h(k){return k===62?A(k):k===45?p(k):d(k)}function m(k){const ce="CDATA[";return k===ce.charCodeAt(s++)?(e.consume(k),s===ce.length?v:m):n(k)}function v(k){return k===null?n(k):k===93?(e.consume(k),S):xe(k)?(a=v,J(k)):(e.consume(k),v)}function S(k){return k===93?(e.consume(k),y):v(k)}function y(k){return k===62?A(k):k===93?(e.consume(k),y):v(k)}function _(k){return k===null||k===62?A(k):xe(k)?(a=_,J(k)):(e.consume(k),_)}function g(k){return k===null?n(k):k===63?(e.consume(k),z):xe(k)?(a=g,J(k)):(e.consume(k),g)}function z(k){return k===62?A(k):g(k)}function C(k){return dt(k)?(e.consume(k),w):n(k)}function w(k){return k===45||st(k)?(e.consume(k),w):E(k)}function E(k){return xe(k)?(a=E,J(k)):Ne(k)?(e.consume(k),E):A(k)}function R(k){return k===45||st(k)?(e.consume(k),R):k===47||k===62||Me(k)?K(k):n(k)}function K(k){return k===47?(e.consume(k),A):k===58||k===95||dt(k)?(e.consume(k),j):xe(k)?(a=K,J(k)):Ne(k)?(e.consume(k),K):A(k)}function j(k){return k===45||k===46||k===58||k===95||st(k)?(e.consume(k),j):I(k)}function I(k){return k===61?(e.consume(k),O):xe(k)?(a=I,J(k)):Ne(k)?(e.consume(k),I):K(k)}function O(k){return k===null||k===60||k===61||k===62||k===96?n(k):k===34||k===39?(e.consume(k),i=k,Z):xe(k)?(a=O,J(k)):Ne(k)?(e.consume(k),O):(e.consume(k),M)}function Z(k){return k===i?(e.consume(k),i=void 0,T):k===null?n(k):xe(k)?(a=Z,J(k)):(e.consume(k),Z)}function M(k){return k===null||k===34||k===39||k===60||k===61||k===96?n(k):k===47||k===62||Me(k)?K(k):(e.consume(k),M)}function T(k){return k===47||k===62||Me(k)?K(k):n(k)}function A(k){return k===62?(e.consume(k),e.exit("htmlTextData"),e.exit("htmlText"),t):n(k)}function J(k){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(k),e.exit("lineEnding"),B}function B(k){return Ne(k)?ze(e,ne,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(k):ne(k)}function ne(k){return e.enter("htmlTextData"),a(k)}}const xo={name:"labelEnd",resolveAll:Hv,resolveTo:Wv,tokenize:qv},Vv={tokenize:Gv},Uv={tokenize:Kv},Jv={tokenize:Yv};function Hv(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const i=r.type==="labelImage"?4:2;r.type="data",t+=i}}return e.length!==n.length&&_t(e,0,e.length,n),e}function Wv(e,t){let n=e.length,r=0,i,s,a,o;for(;n--;)if(i=e[n][1],s){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;e[n][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(a){if(e[n][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(s=n,i.type!=="labelLink")){r=2;break}}else i.type==="labelEnd"&&(a=n);const l={type:e[s][1].type==="labelLink"?"link":"image",start:{...e[s][1].start},end:{...e[e.length-1][1].end}},c={type:"label",start:{...e[s][1].start},end:{...e[a][1].end}},f={type:"labelText",start:{...e[s+r+2][1].end},end:{...e[a-2][1].start}};return o=[["enter",l,t],["enter",c,t]],o=Et(o,e.slice(s+1,s+r+3)),o=Et(o,[["enter",f,t]]),o=Et(o,xs(t.parser.constructs.insideSpan.null,e.slice(s+r+4,a-3),t)),o=Et(o,[["exit",f,t],e[a-2],e[a-1],["exit",c,t]]),o=Et(o,e.slice(a+1)),o=Et(o,[["exit",l,t]]),_t(e,s,e.length,o),e}function qv(e,t,n){const r=this;let i=r.events.length,s,a;for(;i--;)if((r.events[i][1].type==="labelImage"||r.events[i][1].type==="labelLink")&&!r.events[i][1]._balanced){s=r.events[i][1];break}return o;function o(p){return s?s._inactive?d(p):(a=r.parser.defined.includes(Mt(r.sliceSerialize({start:s.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(p),e.exit("labelMarker"),e.exit("labelEnd"),l):n(p)}function l(p){return p===40?e.attempt(Vv,f,a?f:d)(p):p===91?e.attempt(Uv,f,a?c:d)(p):a?f(p):d(p)}function c(p){return e.attempt(Jv,f,d)(p)}function f(p){return t(p)}function d(p){return s._balanced=!0,n(p)}}function Gv(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 Me(d)?Dr(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 Me(d)?Dr(e,l)(d):f(d)}function o(d){return n(d)}function l(d){return d===34||d===39||d===40?Bf(e,c,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(d):f(d)}function c(d){return Me(d)?Dr(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 Kv(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(Mt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(o):n(o)}function a(o){return n(o)}}function Yv(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 Xv={name:"labelStartImage",resolveAll:xo.resolveAll,tokenize:Qv};function Qv(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 ew={name:"labelStartLink",resolveAll:xo.resolveAll,tokenize:tw};function tw(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:nw};function nw(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),ze(e,t,"linePrefix")}}const Ni={name:"thematicBreak",tokenize:rw};function rw(e,t,n){let r=0,i;return s;function s(c){return e.enter("thematicBreak"),a(c)}function a(c){return i=c,o(c)}function o(c){return c===i?(e.enter("thematicBreakSequence"),l(c)):r>=3&&(c===null||xe(c))?(e.exit("thematicBreak"),t(c)):n(c)}function l(c){return c===i?(e.consume(c),r++,l):(e.exit("thematicBreakSequence"),Ne(c)?ze(e,o,"whitespace")(c):o(c))}}const ht={continuation:{tokenize:ow},exit:uw,name:"list",tokenize:aw},iw={partial:!0,tokenize:cw},sw={partial:!0,tokenize:lw};function aw(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:Na(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(Ni,n,c)(h):c(h);if(!r.interrupt||h===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),l(h)}return n(h)}function l(h){return Na(h)&&++a<10?(e.consume(h),l):(!r.interrupt||a<2)&&(r.containerState.marker?h===r.containerState.marker:h===41||h===46)?(e.exit("listItemValue"),c(h)):n(h)}function c(h){return e.enter("listItemMarker"),e.consume(h),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||h,e.check(ri,r.interrupt?n:f,e.attempt(iw,p,d))}function f(h){return r.containerState.initialBlankLine=!0,s++,p(h)}function d(h){return Ne(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 ow(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(ri,i,s);function i(o){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,ze(e,t,"listItemIndent",r.containerState.size+1)(o)}function s(o){return r.containerState.furtherBlankLines||!Ne(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(sw,t,a)(o))}function a(o){return r.containerState._closeFlow=!0,r.interrupt=void 0,ze(e,e.attempt(ht,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o)}}function lw(e,t,n){const r=this;return ze(e,i,"listItemIndent",r.containerState.size+1);function i(s){const a=r.events[r.events.length-1];return a&&a[1].type==="listItemIndent"&&a[2].sliceSerialize(a[1],!0).length===r.containerState.size?t(s):n(s)}}function uw(e){e.exit(this.containerState.type)}function cw(e,t,n){const r=this;return ze(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(s){const a=r.events[r.events.length-1];return!Ne(s)&&a&&a[1].type==="listItemPrefixWhitespace"?t(s):n(s)}}const Ml={name:"setextUnderline",resolveTo:dw,tokenize:fw};function dw(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 fw(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"),Ne(c)?ze(e,l,"lineSuffix")(c):l(c))}function l(c){return c===null||xe(c)?(e.exit("setextHeadingLine"),t(c)):n(c)}}const pw={tokenize:hw};function hw(e){const t=this,n=e.attempt(ri,r,e.attempt(this.parser.constructs.flowInitial,i,ze(e,e.attempt(this.parser.constructs.flow,i,e.attempt(bv,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 mw={resolveAll:Uf()},gw=Vf("string"),xw=Vf("text");function Vf(e){return{resolveAll:Uf(e==="text"?yw:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],s=n.attempt(i,a,o);return a;function a(f){return c(f)?s(f):o(f)}function o(f){if(f===null){n.consume(f);return}return n.enter("data"),n.consume(f),l}function l(f){return c(f)?(n.exit("data"),s(f)):(n.consume(f),l)}function c(f){if(f===null)return!0;const d=i[f];let p=-1;if(d)for(;++p<d.length;){const h=d[p];if(!h.previous||h.previous.call(r,r.previous))return!0}return!1}}}function 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 yw(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],i=t.sliceStream(r);let s=i.length,a=-1,o=0,l;for(;s--;){const c=i[s];if(typeof c=="string"){for(a=c.length;c.charCodeAt(a-1)===32;)o++,a--;if(a)break;a=-1}else if(c===-2)l=!0,o++;else if(c!==-1){s++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(o=0),o){const c={type:n===e.length||l||o<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:s?a:r.start._bufferIndex+a,_index:r.start._index+s,line:r.end.line,column:r.end.column-o,offset:r.end.offset-o},end:{...r.end}};r.end={...c.start},r.start.offset===r.end.offset?Object.assign(r,c):(e.splice(n,0,["enter",c,t],["exit",c,t]),n+=2)}n++}return e}const bw={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},vw={91:_v},ww={[-2]:Bs,[-1]:Bs,32:Bs},kw={35:zv,42:Ni,45:[Ml,Ni],60:Ov,61:Ml,95:Ni,96:Dl,126:Dl},Sw={38:$f,92:Mf},_w={[-5]:Vs,[-4]:Vs,[-3]:Vs,33:Xv,38:$f,42:Ca,60:[ev,Zv],91:ew,92:[Ev,Mf],93:xo,95:Ca,96:pv},jw={null:[Ca,mw]},Nw={null:[42,95]},Cw={null:[]},Ew=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:Nw,contentInitial:vw,disable:Cw,document:bw,flow:kw,flowInitial:ww,insideSpan:jw,string:Sw,text:_w},Symbol.toStringTag,{value:"Module"}));function Iw(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const i={},s=[];let a=[],o=[];const l={attempt:E(C),check:E(w),consume:_,enter:g,exit:z,interrupt:E(w,{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,l);return t.resolveAll&&s.push(t),c;function d(I){return a=Et(a,I),S(),a[a.length-1]!==null?[]:(R(t,0),c.events=xs(s,c.events,c),c.events)}function p(I,O){return Tw(h(I),O)}function h(I){return zw(a,I)}function m(){const{_bufferIndex:I,_index:O,line:Z,column:M,offset:T}=r;return{_bufferIndex:I,_index:O,line:Z,column:M,offset:T}}function v(I){i[I.line]=I.column,j()}function S(){let I;for(;r._index<a.length;){const O=a[r._index];if(typeof O=="string")for(I=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===I&&r._bufferIndex<O.length;)y(O.charCodeAt(r._bufferIndex));else y(O)}}function y(I){f=f(I)}function _(I){xe(I)?(r.line++,r.column=1,r.offset+=I===-3?2:1,j()):I!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===a[r._index].length&&(r._bufferIndex=-1,r._index++)),c.previous=I}function g(I,O){const Z=O||{};return Z.type=I,Z.start=m(),c.events.push(["enter",Z,c]),o.push(Z),Z}function z(I){const O=o.pop();return O.end=m(),c.events.push(["exit",O,c]),O}function C(I,O){R(I,O.from)}function w(I,O){O.restore()}function E(I,O){return Z;function Z(M,T,A){let J,B,ne,k;return Array.isArray(M)?de(M):"tokenize"in M?de([M]):ce(M);function ce(ie){return ae;function ae(Q){const $=Q!==null&&ie[Q],ee=Q!==null&&ie.null,V=[...Array.isArray($)?$:$?[$]:[],...Array.isArray(ee)?ee:ee?[ee]:[]];return de(V)(Q)}}function de(ie){return J=ie,B=0,ie.length===0?A:x(ie[B])}function x(ie){return ae;function ae(Q){return k=K(),ne=ie,ie.partial||(c.currentConstruct=ie),ie.name&&c.parser.constructs.disable.null.includes(ie.name)?G():ie.tokenize.call(O?Object.assign(Object.create(c),O):c,l,H,G)(Q)}}function H(ie){return I(ne,k),T}function G(ie){return k.restore(),++B<J.length?x(J[B]):A}}}function R(I,O){I.resolveAll&&!s.includes(I)&&s.push(I),I.resolve&&_t(c.events,O,c.events.length-O,I.resolve(c.events.slice(O),c)),I.resolveTo&&(c.events=I.resolveTo(c.events,c))}function K(){const I=m(),O=c.previous,Z=c.currentConstruct,M=c.events.length,T=Array.from(o);return{from:M,restore:A};function A(){r=I,c.previous=O,c.currentConstruct=Z,c.events.length=M,o=T,j()}}function j(){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 Tw(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 Aw(e){const r={constructs:Of([Ew,...(e||{}).extensions||[]]),content:i(Wb),defined:[],document:i(Gb),flow:i(pw),lazy:{},string:i(gw),text:i(xw)};return r;function i(s){return a;function a(o){return Iw(r,s,o)}}}function Pw(e){for(;!Ff(e););return e}const $l=/[\0\t\n\r]/g;function Ow(){let e=1,t="",n=!0,r;return i;function i(s,a,o){const l=[];let c,f,d,p,h;for(s=t+(typeof s=="string"?s.toString():new TextDecoder(a||void 0).decode(s)),d=0,t="",n&&(s.charCodeAt(0)===65279&&d++,n=void 0);d<s.length;){if($l.lastIndex=d,c=$l.exec(s),p=c&&c.index!==void 0?c.index:s.length,h=s.charCodeAt(p),!c){t=s.slice(d);break}if(h===10&&d===p&&r)l.push(-3),r=void 0;else switch(r&&(l.push(-5),r=void 0),d<p&&(l.push(s.slice(d,p)),e+=p-d),h){case 0:{l.push(65533),e++;break}case 9:{for(f=Math.ceil(e/4)*4,l.push(-2);e++<f;)l.push(-1);break}case 10:{l.push(-4),e=1;break}default:r=!0,e=1}d=p+1}return o&&(r&&l.push(-5),t&&l.push(t),l.push(null)),l}}const Dw=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Rw(e){return e.replace(Dw,Mw)}function Mw(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 go(n)||e}const Jf={}.hasOwnProperty;function $w(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),Fw(n)(Pw(Aw(n).document().write(Ow()(e,t,!0))))}function Fw(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(P),autolinkProtocol:K,autolinkEmail:K,atxHeading:s(Oe),blockQuote:s(ee),characterEscape:K,characterReference:K,codeFenced:s(V),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:s(V,a),codeText:s(se,a),codeTextData:K,data:K,codeFlowValue:K,definition:s(le),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:s(ge),hardBreakEscape:s(We),hardBreakTrailing:s(We),htmlFlow:s(Qe,a),htmlFlowData:K,htmlText:s(Qe,a),htmlTextData:K,image:s(N),label:a,link:s(P),listItem:s(re),listItemValue:p,listOrdered:s(L,d),listUnordered:s(L),paragraph:s(te),reference:x,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:s(Oe),strong:s(X),thematicBreak:s(ve)},exit:{atxHeading:l(),atxHeadingSequence:C,autolink:l(),autolinkEmail:$,autolinkProtocol:Q,blockQuote:l(),characterEscapeValue:j,characterReferenceMarkerHexadecimal:G,characterReferenceMarkerNumeric:G,characterReferenceValue:ie,characterReference:ae,codeFenced:l(S),codeFencedFence:v,codeFencedFenceInfo:h,codeFencedFenceMeta:m,codeFlowValue:j,codeIndented:l(y),codeText:l(T),codeTextData:j,data:j,definition:l(),definitionDestinationString:z,definitionLabelString:_,definitionTitleString:g,emphasis:l(),hardBreakEscape:l(O),hardBreakTrailing:l(O),htmlFlow:l(Z),htmlFlowData:j,htmlText:l(M),htmlTextData:j,image:l(J),label:ne,labelText:B,lineEnding:I,link:l(A),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:H,resourceDestinationString:k,resourceTitleString:ce,resource:de,setextHeading:l(R),setextHeadingLineSequence:E,setextHeadingText:w,strong:l(),thematicBreak:l()}};Hf(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(F){let q={type:"root",children:[]};const he={stack:[q],tokenStack:[],config:t,enter:o,exit:c,buffer:a,resume:f,data:n},Se=[];let D=-1;for(;++D<F.length;)if(F[D][1].type==="listOrdered"||F[D][1].type==="listUnordered")if(F[D][0]==="enter")Se.push(D);else{const me=Se.pop();D=i(F,me,D)}for(D=-1;++D<F.length;){const me=t[F[D][0]];Jf.call(me,F[D][1].type)&&me[F[D][1].type].call(Object.assign({sliceSerialize:F[D][2].sliceSerialize},he),F[D][1])}if(he.tokenStack.length>0){const me=he.tokenStack[he.tokenStack.length-1];(me[1]||Fl).call(he,void 0,me[0])}for(q.position={start:tn(F.length>0?F[0][1].start:{line:1,column:1,offset:0}),end:tn(F.length>0?F[F.length-2][1].end:{line:1,column:1,offset:0})},D=-1;++D<t.transforms.length;)q=t.transforms[D](q)||q;return q}function i(F,q,he){let Se=q-1,D=-1,me=!1,Ce,$e,nt,et;for(;++Se<=he;){const it=F[Se];switch(it[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{it[0]==="enter"?D++:D--,et=void 0;break}case"lineEndingBlank":{it[0]==="enter"&&(Ce&&!et&&!D&&!nt&&(nt=Se),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(Ce){let en=Se;for($e=void 0;en--;){const qt=F[en];if(qt[1].type==="lineEnding"||qt[1].type==="lineEndingBlank"){if(qt[0]==="exit")continue;$e&&(F[$e][1].type="lineEndingBlank",me=!0),qt[1].type="lineEnding",$e=en}else if(!(qt[1].type==="linePrefix"||qt[1].type==="blockQuotePrefix"||qt[1].type==="blockQuotePrefixWhitespace"||qt[1].type==="blockQuoteMarker"||qt[1].type==="listItemIndent"))break}nt&&(!$e||nt<$e)&&(Ce._spread=!0),Ce.end=Object.assign({},$e?F[$e][1].start:it[1].end),F.splice($e||Se,0,["exit",Ce,it[2]]),Se++,he++}if(it[1].type==="listItemPrefix"){const en={type:"listItem",_spread:!1,start:Object.assign({},it[1].start),end:void 0};Ce=en,F.splice(Se,0,["enter",en,it[2]]),Se++,he++,nt=void 0,et=!0}}}return F[q][1]._spread=me,he}function s(F,q){return he;function he(Se){o.call(this,F(Se),Se),q&&q.call(this,Se)}}function a(){this.stack.push({type:"fragment",children:[]})}function o(F,q,he){this.stack[this.stack.length-1].children.push(F),this.stack.push(F),this.tokenStack.push([q,he||void 0]),F.position={start:tn(q.start),end:void 0}}function l(F){return q;function q(he){F&&F.call(this,he),c.call(this,he)}}function c(F,q){const he=this.stack.pop(),Se=this.tokenStack.pop();if(Se)Se[0].type!==F.type&&(q?q.call(this,F,Se[0]):(Se[1]||Fl).call(this,F,Se[0]));else throw new Error("Cannot close `"+F.type+"` ("+Or({start:F.start,end:F.end})+"): it’s not open");he.position.end=tn(F.end)}function f(){return mo(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function p(F){if(this.data.expectingFirstListItemValue){const q=this.stack[this.stack.length-2];q.start=Number.parseInt(this.sliceSerialize(F),10),this.data.expectingFirstListItemValue=void 0}}function h(){const F=this.resume(),q=this.stack[this.stack.length-1];q.lang=F}function m(){const F=this.resume(),q=this.stack[this.stack.length-1];q.meta=F}function v(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function S(){const F=this.resume(),q=this.stack[this.stack.length-1];q.value=F.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function y(){const F=this.resume(),q=this.stack[this.stack.length-1];q.value=F.replace(/(\r?\n|\r)$/g,"")}function _(F){const q=this.resume(),he=this.stack[this.stack.length-1];he.label=q,he.identifier=Mt(this.sliceSerialize(F)).toLowerCase()}function g(){const F=this.resume(),q=this.stack[this.stack.length-1];q.title=F}function z(){const F=this.resume(),q=this.stack[this.stack.length-1];q.url=F}function C(F){const q=this.stack[this.stack.length-1];if(!q.depth){const he=this.sliceSerialize(F).length;q.depth=he}}function w(){this.data.setextHeadingSlurpLineEnding=!0}function E(F){const q=this.stack[this.stack.length-1];q.depth=this.sliceSerialize(F).codePointAt(0)===61?1:2}function R(){this.data.setextHeadingSlurpLineEnding=void 0}function K(F){const he=this.stack[this.stack.length-1].children;let Se=he[he.length-1];(!Se||Se.type!=="text")&&(Se=pe(),Se.position={start:tn(F.start),end:void 0},he.push(Se)),this.stack.push(Se)}function j(F){const q=this.stack.pop();q.value+=this.sliceSerialize(F),q.position.end=tn(F.end)}function I(F){const q=this.stack[this.stack.length-1];if(this.data.atHardBreak){const he=q.children[q.children.length-1];he.position.end=tn(F.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(q.type)&&(K.call(this,F),j.call(this,F))}function O(){this.data.atHardBreak=!0}function Z(){const F=this.resume(),q=this.stack[this.stack.length-1];q.value=F}function M(){const F=this.resume(),q=this.stack[this.stack.length-1];q.value=F}function T(){const F=this.resume(),q=this.stack[this.stack.length-1];q.value=F}function A(){const F=this.stack[this.stack.length-1];if(this.data.inReference){const q=this.data.referenceType||"shortcut";F.type+="Reference",F.referenceType=q,delete F.url,delete F.title}else delete F.identifier,delete F.label;this.data.referenceType=void 0}function J(){const F=this.stack[this.stack.length-1];if(this.data.inReference){const q=this.data.referenceType||"shortcut";F.type+="Reference",F.referenceType=q,delete F.url,delete F.title}else delete F.identifier,delete F.label;this.data.referenceType=void 0}function B(F){const q=this.sliceSerialize(F),he=this.stack[this.stack.length-2];he.label=Rw(q),he.identifier=Mt(q).toLowerCase()}function ne(){const F=this.stack[this.stack.length-1],q=this.resume(),he=this.stack[this.stack.length-1];if(this.data.inReference=!0,he.type==="link"){const Se=F.children;he.children=Se}else he.alt=q}function k(){const F=this.resume(),q=this.stack[this.stack.length-1];q.url=F}function ce(){const F=this.resume(),q=this.stack[this.stack.length-1];q.title=F}function de(){this.data.inReference=void 0}function x(){this.data.referenceType="collapsed"}function H(F){const q=this.resume(),he=this.stack[this.stack.length-1];he.label=q,he.identifier=Mt(this.sliceSerialize(F)).toLowerCase(),this.data.referenceType="full"}function G(F){this.data.characterReferenceType=F.type}function ie(F){const q=this.sliceSerialize(F),he=this.data.characterReferenceType;let Se;he?(Se=Df(q,he==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Se=go(q);const D=this.stack[this.stack.length-1];D.value+=Se}function ae(F){const q=this.stack.pop();q.position.end=tn(F.end)}function Q(F){j.call(this,F);const q=this.stack[this.stack.length-1];q.url=this.sliceSerialize(F)}function $(F){j.call(this,F);const q=this.stack[this.stack.length-1];q.url="mailto:"+this.sliceSerialize(F)}function ee(){return{type:"blockquote",children:[]}}function V(){return{type:"code",lang:null,meta:null,value:""}}function se(){return{type:"inlineCode",value:""}}function le(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function ge(){return{type:"emphasis",children:[]}}function Oe(){return{type:"heading",depth:0,children:[]}}function We(){return{type:"break"}}function Qe(){return{type:"html",value:""}}function N(){return{type:"image",title:null,url:"",alt:null}}function P(){return{type:"link",title:null,url:"",children:[]}}function L(F){return{type:"list",ordered:F.type==="listOrdered",start:null,spread:F._spread,children:[]}}function re(F){return{type:"listItem",spread:F._spread,checked:null,children:[]}}function te(){return{type:"paragraph",children:[]}}function X(){return{type:"strong",children:[]}}function pe(){return{type:"text",value:""}}function ve(){return{type:"thematicBreak"}}}function tn(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):Lw(e,r)}}function Lw(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 Fl(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+Or({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Or({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+Or({start:t.start,end:t.end})+") is still open")}function Zw(e){const t=this;t.parser=n;function n(r){return $w(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function Bw(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 Vw(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
6
+ `}]}function Uw(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 Jw(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Hw(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Ww(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),i=dr(r.toLowerCase()),s=e.footnoteOrder.indexOf(r);let a,o=e.footnoteCounts.get(r);o===void 0?(o=0,e.footnoteOrder.push(r),a=e.footnoteOrder.length):a=s+1,o+=1,e.footnoteCounts.set(r,o);const l={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+i,id:n+"fnref-"+i+(o>1?"-"+o:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(a)}]};e.patch(t,l);const c={type:"element",tagName:"sup",properties:{},children:[l]};return e.patch(t,c),e.applyData(t,c)}function qw(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 Gw(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 Kw(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Wf(e,t);const i={src:dr(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 Yw(e,t){const n={src:dr(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 Xw(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 Qw(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Wf(e,t);const i={href:dr(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 e0(e,t){const n={href:dr(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 t0(e,t,n){const r=e.all(t),i=n?n0(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 l=r[r.length-1];l&&(i||l.type!=="element"||l.tagName!=="p")&&a.push({type:"text",value:`
9
+ `});const c={type:"element",tagName:"li",properties:s,children:a};return e.patch(t,c),e.applyData(t,c)}function n0(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 r0(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 i0(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function s0(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function a0(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function o0(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=co(t.children[1]),l=Cf(t.children[t.children.length-1]);o&&l&&(a.position={start:o,end:l}),i.push(a)}const s={type:"element",tagName:"table",properties:{},children:e.wrap(i,!0)};return e.patch(t,s),e.applyData(t,s)}function l0(e,t,n){const r=n?n.children:void 0,s=(r?r.indexOf(t):1)===0?"th":"td",a=n&&n.type==="table"?n.align:void 0,o=a?a.length:t.children.length;let l=-1;const c=[];for(;++l<o;){const d=t.children[l],p={},h=a?a[l]:void 0;h&&(p.align=h);let 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 u0(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const Ll=9,Zl=32;function c0(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),i=0;const s=[];for(;r;)s.push(Bl(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return s.push(Bl(t.slice(i),i>0,!1)),s.join("")}function Bl(e,t,n){let r=0,i=e.length;if(t){let s=e.codePointAt(r);for(;s===Ll||s===Zl;)r++,s=e.codePointAt(r)}if(n){let s=e.codePointAt(i-1);for(;s===Ll||s===Zl;)i--,s=e.codePointAt(i-1)}return i>r?e.slice(r,i):""}function d0(e,t){const n={type:"text",value:c0(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function f0(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const p0={blockquote:Bw,break:Vw,code:Uw,delete:Jw,emphasis:Hw,footnoteReference:Ww,heading:qw,html:Gw,imageReference:Kw,image:Yw,inlineCode:Xw,linkReference:Qw,link:e0,listItem:t0,list:r0,paragraph:i0,root:s0,strong:a0,table:o0,tableCell:u0,tableRow:l0,text:d0,thematicBreak:f0,toml:fi,yaml:fi,definition:fi,footnoteDefinition:fi};function fi(){}const Gf=-1,ys=0,Rr=1,Vi=2,yo=3,bo=4,vo=5,wo=6,Kf=7,Yf=8,Vl=typeof self=="object"?self:globalThis,h0=(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 ys:case Gf:return n(a,i);case Rr:{const o=n([],i);for(const l of a)o.push(r(l));return o}case Vi:{const o=n({},i);for(const[l,c]of a)o[r(l)]=r(c);return o}case yo:return n(new Date(a),i);case bo:{const{source:o,flags:l}=a;return n(new RegExp(o,l),i)}case vo:{const o=n(new Map,i);for(const[l,c]of a)o.set(r(l),r(c));return o}case wo:{const o=n(new Set,i);for(const l of a)o.add(r(l));return o}case Kf:{const{name:o,message:l}=a;return n(new Vl[o](l),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 Vl[s](a),i)};return r},Ul=e=>h0(new Map,e)(0),Fn="",{toString:m0}={},{keys:g0}=Object,wr=e=>{const t=typeof e;if(t!=="object"||!e)return[ys,t];const n=m0.call(e).slice(8,-1);switch(n){case"Array":return[Rr,Fn];case"Object":return[Vi,Fn];case"Date":return[yo,Fn];case"RegExp":return[bo,Fn];case"Map":return[vo,Fn];case"Set":return[wo,Fn];case"DataView":return[Rr,n]}return n.includes("Array")?[Rr,n]:n.includes("Error")?[Kf,n]:[Vi,n]},pi=([e,t])=>e===ys&&(t==="function"||t==="symbol"),x0=(e,t,n,r)=>{const i=(a,o)=>{const l=r.push(a)-1;return n.set(o,l),l},s=a=>{if(n.has(a))return n.get(a);let[o,l]=wr(a);switch(o){case ys:{let f=a;switch(l){case"bigint":o=Yf,f=a.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+l);f=null;break;case"undefined":return i([Gf],a)}return i([o,f],a)}case Rr:{if(l){let p=a;return l==="DataView"?p=new Uint8Array(a.buffer):l==="ArrayBuffer"&&(p=new Uint8Array(a)),i([l,[...p]],a)}const f=[],d=i([o,f],a);for(const p of a)f.push(s(p));return d}case Vi:{if(l)switch(l){case"BigInt":return i([l,a.toString()],a);case"Boolean":case"Number":case"String":return i([l,a.valueOf()],a)}if(t&&"toJSON"in a)return s(a.toJSON());const f=[],d=i([o,f],a);for(const p of g0(a))(e||!pi(wr(a[p])))&&f.push([s(p),s(a[p])]);return d}case yo:return i([o,a.toISOString()],a);case bo:{const{source:f,flags:d}=a;return i([o,{source:f,flags:d}],a)}case vo:{const f=[],d=i([o,f],a);for(const[p,h]of a)(e||!(pi(wr(p))||pi(wr(h))))&&f.push([s(p),s(h)]);return d}case wo:{const f=[],d=i([o,f],a);for(const p of a)(e||!pi(wr(p)))&&f.push(s(p));return d}}const{message:c}=a;return i([o,{name:l,message:c}],a)};return s},Jl=(e,{json:t,lossy:n}={})=>{const r=[];return x0(!(t||n),!!t,new Map,r)(e),r},Ui=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?Ul(Jl(e,t)):structuredClone(e):(e,t)=>Ul(Jl(e,t));function y0(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 b0(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function v0(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||y0,r=e.options.footnoteBackLabel||b0,i=e.options.footnoteLabel||"Footnotes",s=e.options.footnoteLabelTagName||"h2",a=e.options.footnoteLabelProperties||{className:["sr-only"]},o=[];let l=-1;for(;++l<e.footnoteOrder.length;){const c=e.footnoteById.get(e.footnoteOrder[l]);if(!c)continue;const f=e.all(c),d=String(c.identifier).toUpperCase(),p=dr(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 _=typeof n=="string"?n:n(l,h);typeof _=="string"&&(_={type:"text",value:_}),m.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+p+(h>1?"-"+h:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(l,h),className:["data-footnote-backref"]},children:Array.isArray(_)?_:[_]})}const S=f[f.length-1];if(S&&S.type==="element"&&S.tagName==="p"){const _=S.children[S.children.length-1];_&&_.type==="text"?_.value+=" ":S.children.push({type:"text",value:" "}),S.children.push(...m)}else f.push(...m);const y={type:"element",tagName:"li",properties:{id:t+"fn-"+p},children:e.wrap(f,!0)};e.patch(c,y),o.push(y)}if(o.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:s,properties:{...Ui(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 bs=function(e){if(e==null)return _0;if(typeof e=="function")return vs(e);if(typeof e=="object")return Array.isArray(e)?w0(e):k0(e);if(typeof e=="string")return S0(e);throw new Error("Expected function, string, or object as test")};function w0(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=bs(e[n]);return vs(r);function r(...i){let s=-1;for(;++s<t.length;)if(t[s].apply(this,i))return!0;return!1}}function k0(e){const t=e;return vs(n);function n(r){const i=r;let s;for(s in e)if(i[s]!==t[s])return!1;return!0}}function S0(e){return vs(t);function t(n){return n&&n.type===e}}function vs(e){return t;function t(n,r,i){return!!(j0(n)&&e.call(this,n,typeof r=="number"?r:void 0,i||void 0))}}function _0(){return!0}function j0(e){return e!==null&&typeof e=="object"&&"type"in e}const Xf=[],N0=!0,Ea=!1,C0="skip";function Qf(e,t,n,r){let i;typeof t=="function"&&typeof n!="function"?(r=n,n=t):i=t;const s=bs(i),a=r?-1:1;o(e,void 0,[])();function o(l,c,f){const d=l&&typeof l=="object"?l:{};if(typeof d.type=="string"){const h=typeof d.tagName=="string"?d.tagName:typeof d.name=="string"?d.name:void 0;Object.defineProperty(p,"name",{value:"node ("+(l.type+(h?"<"+h+">":""))+")"})}return p;function p(){let h=Xf,m,v,S;if((!t||s(l,c,f[f.length-1]||void 0))&&(h=E0(n(l,f)),h[0]===Ea))return h;if("children"in l&&l.children){const y=l;if(y.children&&h[0]!==C0)for(v=(r?y.children.length:-1)+a,S=f.concat(y);v>-1&&v<y.children.length;){const _=y.children[v];if(m=o(_,v,S)(),m[0]===Ea)return m;v=typeof m[1]=="number"?m[1]:v+a}}return h}}}function E0(e){return Array.isArray(e)?e:typeof e=="number"?[N0,e]:e==null?Xf:[e]}function ko(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(l,c){const f=c[c.length-1],d=f?f.children.indexOf(l):void 0;return a(l,d,f)}}const Ia={}.hasOwnProperty,I0={};function z0(e,t){const n=t||I0,r=new Map,i=new Map,s=new Map,a={...p0,...n.handlers},o={all:c,applyData:A0,definitionById:r,footnoteById:i,footnoteCounts:s,footnoteOrder:[],handlers:a,one:l,options:n,patch:T0,wrap:O0};return ko(e,function(f){if(f.type==="definition"||f.type==="footnoteDefinition"){const d=f.type==="definition"?r:i,p=String(f.identifier).toUpperCase();d.has(p)||d.set(p,f)}}),o;function l(f,d){const p=f.type,h=o.handlers[p];if(Ia.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,y=Ui(S);return y.children=o.all(f),y}return Ui(f)}return(o.options.unknownHandler||P0)(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=Hl(m.value)),!Array.isArray(m)&&m.type==="element")){const v=m.children[0];v&&v.type==="text"&&(v.value=Hl(v.value))}Array.isArray(m)?d.push(...m):d.push(m)}}}return d}}function T0(e,t){e.position&&(t.position=bb(e))}function A0(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,Ui(s)),"children"in n&&n.children&&i!==null&&i!==void 0&&(n.children=i)}return n}function P0(e,t){const n=t.data||{},r="value"in t&&!(Ia.call(n,"hProperties")||Ia.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 O0(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 Hl(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function Wl(e,t){const n=z0(e,t),r=n.one(e,void 0),i=v0(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 D0(e,t){return e&&"run"in e?async function(n,r){const i=Wl(n,{file:r,...t});await e.run(i,r)}:function(n,r){return Wl(n,{file:r,...e||t})}}function ql(e){if(e)throw e}var Us,Gl;function R0(){if(Gl)return Us;Gl=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=function(c){return typeof Array.isArray=="function"?Array.isArray(c):t.call(c)==="[object Array]"},s=function(c){if(!c||t.call(c)!=="[object Object]")return!1;var f=e.call(c,"constructor"),d=c.constructor&&c.constructor.prototype&&e.call(c.constructor.prototype,"isPrototypeOf");if(c.constructor&&!f&&!d)return!1;var p;for(p in c);return typeof p>"u"||e.call(c,p)},a=function(c,f){n&&f.name==="__proto__"?n(c,f.name,{enumerable:!0,configurable:!0,value:f.newValue,writable:!0}):c[f.name]=f.newValue},o=function(c,f){if(f==="__proto__")if(e.call(c,f)){if(r)return r(c,f).value}else return;return c[f]};return Us=function l(){var c,f,d,p,h,m,v=arguments[0],S=1,y=arguments.length,_=!1;for(typeof v=="boolean"&&(_=v,v=arguments[1]||{},S=2),(v==null||typeof v!="object"&&typeof v!="function")&&(v={});S<y;++S)if(c=arguments[S],c!=null)for(f in c)d=o(v,f),p=o(c,f),v!==p&&(_&&p&&(s(p)||(h=i(p)))?(h?(h=!1,m=d&&i(d)?d:[]):m=d&&s(d)?d:{},a(v,{name:f,newValue:l(_,m,p)})):typeof p<"u"&&a(v,{name:f,newValue:p}));return v},Us}var M0=R0();const Js=Ua(M0);function za(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 $0(){const e=[],t={run:n,use:r};return t;function n(...i){let s=-1;const a=i.pop();if(typeof a!="function")throw new TypeError("Expected function as last argument, not "+a);o(null,...i);function o(l,...c){const f=e[++s];let d=-1;if(l){a(l);return}for(;++d<i.length;)(c[d]===null||c[d]===void 0)&&(c[d]=i[d]);i=c,f?F0(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 F0(e,t){let n;return r;function r(...a){const o=e.length>a.length;let l;o&&a.push(i);try{l=e.apply(this,a)}catch(c){const f=c;if(o&&n)throw f;return i(f)}o||(l&&l.then&&typeof l.then=="function"?l.then(s,i):l instanceof Error?i(l):s(l))}function i(a,...o){n||(n=!0,t(a,...o))}function s(a){i(null,a)}}const Ft={basename:L0,dirname:Z0,extname:B0,join:V0,sep:"/"};function L0(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');ii(e);let n=0,r=-1,i=e.length,s;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(s){n=i+1;break}}else r<0&&(s=!0,r=i+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let 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 Z0(e){if(ii(e),e.length===0)return".";let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||(r=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function B0(e){ii(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 V0(...e){let t=-1,n;for(;++t<e.length;)ii(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":U0(n)}function U0(e){ii(e);const t=e.codePointAt(0)===47;let n=J0(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function J0(e,t){let n="",r=0,i=-1,s=0,a=-1,o,l;for(;++a<=e.length;){if(a<e.length)o=e.codePointAt(a);else{if(o===47)break;o=47}if(o===47){if(!(i===a-1||s===1))if(i!==a-1&&s===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(l=n.lastIndexOf("/"),l!==n.length-1){l<0?(n="",r=0):(n=n.slice(0,l),r=n.length-1-n.lastIndexOf("/")),i=a,s=0;continue}}else if(n.length>0){n="",r=0,i=a,s=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(i+1,a):n=e.slice(i+1,a),r=a-i-1;i=a,s=0}else o===46&&s>-1?s++:s=-1}return n}function ii(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const H0={cwd:W0};function W0(){return"/"}function Ta(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function q0(e){if(typeof e=="string")e=new URL(e);else if(!Ta(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 G0(e)}function G0(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?Ta(t)?n={path:t}:typeof t=="string"||K0(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":H0.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"?Ft.basename(this.path):void 0}set basename(t){qs(t,"basename"),Ws(t,"basename"),this.path=Ft.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Ft.dirname(this.path):void 0}set dirname(t){Kl(this.basename,"dirname"),this.path=Ft.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Ft.extname(this.path):void 0}set extname(t){if(Ws(t,"extname"),Kl(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=Ft.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){Ta(t)&&(t=q0(t)),qs(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Ft.basename(this.path,this.extname):void 0}set stem(t){qs(t,"stem"),Ws(t,"stem"),this.path=Ft.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(Ft.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Ft.sep+"`")}function qs(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function Kl(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function K0(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const Y0=function(e){const r=this.constructor.prototype,i=r[e],s=function(){return i.apply(s,arguments)};return Object.setPrototypeOf(s,r),s},X0={}.hasOwnProperty;class So extends Y0{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=$0()}copy(){const t=new So;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):X0.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=hi(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=hi(t),l=r.parse(o);r.run(l,o,function(f,d,p){if(f||!d||!p)return c(f);const h=d,m=r.stringify(h,p);tk(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),Xl("processSync","process",n),r;function i(s,a){n=!0,ql(s),r=a}}run(t,n,r){Yl(t),this.freeze();const i=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?s(void 0,r):new Promise(s);function s(a,o){const l=hi(n);i.run(t,l,c);function c(f,d,p){const h=d||t;f?o(f):a?a(h):r(void 0,h,p)}}}runSync(t,n){let r=!1,i;return this.run(t,n,s),Xl("runSync","run",r),i;function s(a,o){ql(a),i=o,r=!0}}stringify(t,n){this.freeze();const r=hi(n),i=this.compiler||this.Compiler;return Ks("stringify",i),Yl(t),i(t,r)}use(t,...n){const r=this.attachers,i=this.namespace;if(Ys("use",this.frozen),t!=null)if(typeof t=="function")l(t,n);else if(typeof t=="object")Array.isArray(t)?o(t):a(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function s(c){if(typeof c=="function")l(c,[]);else if(typeof c=="object")if(Array.isArray(c)){const[f,...d]=c;l(f,d)}else a(c);else throw new TypeError("Expected usable value, not `"+c+"`")}function a(c){if(!("plugins"in c)&&!("settings"in c))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");o(c.plugins),c.settings&&(i.settings=Js(!0,i.settings,c.settings))}function o(c){let f=-1;if(c!=null)if(Array.isArray(c))for(;++f<c.length;){const d=c[f];s(d)}else throw new TypeError("Expected a list of plugins, not `"+c+"`")}function l(c,f){let d=-1,p=-1;for(;++d<r.length;)if(r[d][0]===c){p=d;break}if(p===-1)r.push([c,...f]);else if(f.length>0){let[h,...m]=f;const v=r[p][1];za(v)&&za(h)&&(h=Js(!0,v,h)),r[p]=[c,h,...m]}}}}const Q0=new So().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 Yl(e){if(!za(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function Xl(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function hi(e){return ek(e)?e:new ep(e)}function ek(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function tk(e){return typeof e=="string"||nk(e)}function nk(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const rk="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",Ql=[],eu={allowDangerousHtml:!0},ik=/^(https?|ircs?|mailto|xmpp)$/i,sk=[{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 ak(e){const t=ok(e),n=lk(e);return uk(t.runSync(t.parse(n),n),e)}function ok(e){const t=e.rehypePlugins||Ql,n=e.remarkPlugins||Ql,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...eu}:eu;return Q0().use(Zw).use(n).use(D0,r).use(t)}function lk(e){const t=e.children||"",n=new ep;return typeof t=="string"&&(n.value=t),n}function uk(e,t){const n=t.allowedElements,r=t.allowElement,i=t.components,s=t.disallowedElements,a=t.skipHtml,o=t.unwrapDisallowed,l=t.urlTransform||ck;for(const f of sk)Object.hasOwn(t,f.from)&&(""+f.from+(f.to?"use `"+f.to+"` instead":"remove it")+rk+f.id,void 0);return ko(e,c),_b(e,{Fragment:u.Fragment,components:i,ignoreInvalidStyle:!0,jsx:u.jsx,jsxs:u.jsxs,passKeys:!0,passNode:!0});function c(f,d,p){if(f.type==="raw"&&p&&typeof d=="number")return a?p.children.splice(d,1):p.children[d]={type:"text",value:f.value},d;if(f.type==="element"){let h;for(h in Zs)if(Object.hasOwn(Zs,h)&&Object.hasOwn(f.properties,h)){const m=f.properties[h],v=Zs[h];(v===null||v.includes(f.tagName))&&(f.properties[h]=l(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 ck(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||ik.test(e.slice(0,t))?e:""}function tu(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 dk(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function fk(e,t,n){const i=bs((n||{}).ignore||[]),s=pk(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 l(c,f)}function l(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 y=!1,_=[];p.lastIndex=0;let g=p.exec(c.value);for(;g;){const z=g.index,C={index:g.index,input:g.input,stack:[...f,c]};let w=h(...g,C);if(typeof w=="string"&&(w=w.length>0?{type:"text",value:w}:void 0),w===!1?p.lastIndex=z+1:(m!==z&&_.push({type:"text",value:c.value.slice(m,z)}),Array.isArray(w)?_.push(...w):w&&_.push(w),m=z+g[0].length,y=!0),!p.global)break;g=p.exec(c.value)}return y?(m<c.value.length&&_.push({type:"text",value:c.value.slice(m)}),d.children.splice(S,1,..._)):_=[c],S+_.length}}function pk(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([hk(i[0]),mk(i[1])])}return t}function hk(e){return typeof e=="string"?new RegExp(dk(e),"g"):e}function mk(e){return typeof e=="function"?e:function(){return e}}const Xs="phrasing",Qs=["autolink","link","image","label"];function gk(){return{transforms:[Sk],enter:{literalAutolink:yk,literalAutolinkEmail:ea,literalAutolinkHttp:ea,literalAutolinkWww:ea},exit:{literalAutolink:kk,literalAutolinkEmail:wk,literalAutolinkHttp:bk,literalAutolinkWww:vk}}}function xk(){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 yk(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function ea(e){this.config.enter.autolinkProtocol.call(this,e)}function bk(e){this.config.exit.autolinkProtocol.call(this,e)}function vk(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 wk(e){this.config.exit.autolinkEmail.call(this,e)}function kk(e){this.exit(e)}function Sk(e){fk(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,_k],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),jk]],{ignore:["link","linkReference"]})}function _k(e,t,n,r,i){let s="";if(!tp(i)||(/^w/i.test(t)&&(n=t+n,t="",s="http://"),!Nk(n)))return!1;const a=Ck(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 jk(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 Nk(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 Ck(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=tu(e,"(");let s=tu(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||zn(n)||gs(n))&&(!t||n!==47)}np.peek=Rk;function Ek(){this.buffer()}function Ik(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function zk(){this.buffer()}function Tk(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function Ak(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Mt(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Pk(e){this.exit(e)}function Ok(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Mt(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Dk(e){this.exit(e)}function Rk(){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 Mk(){return{enter:{gfmFootnoteCallString:Ek,gfmFootnoteCall:Ik,gfmFootnoteDefinitionLabelString:zk,gfmFootnoteDefinition:Tk},exit:{gfmFootnoteCallString:Ak,gfmFootnoteCall:Pk,gfmFootnoteDefinitionLabelString:Ok,gfmFootnoteDefinition:Dk}}}function $k(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 l=o.move("[^");const c=s.enter("footnoteDefinition"),f=s.enter("label");return l+=o.move(s.safe(s.associationId(r),{before:l,after:"]"})),f(),l+=o.move("]:"),r.children&&r.children.length>0&&(o.shift(4),l+=o.move((t?`
16
+ `:" ")+s.indentLines(s.containerFlow(r,o.current()),t?rp:Fk))),c(),l}}function Fk(e,t,n){return t===0?e:rp(e,t,n)}function rp(e,t,n){return(n?"":" ")+e}const Lk=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];ip.peek=Jk;function Zk(){return{canContainEols:["delete"],enter:{strikethrough:Vk},exit:{strikethrough:Uk}}}function Bk(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:Lk}],handlers:{delete:ip}}}function Vk(e){this.enter({type:"delete",children:[]},e)}function Uk(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 Jk(){return"~"}function Hk(e){return e.length}function Wk(e,t){const n=t||{},r=(n.align||[]).concat(),i=n.stringLength||Hk,s=[],a=[],o=[],l=[];let c=0,f=-1;for(;++f<e.length;){const v=[],S=[];let y=-1;for(e[f].length>c&&(c=e[f].length);++y<e[f].length;){const _=qk(e[f][y]);if(n.alignDelimiters!==!1){const g=i(_);S[y]=g,(l[y]===void 0||g>l[y])&&(l[y]=g)}v.push(_)}a[f]=v,o[f]=S}let d=-1;if(typeof r=="object"&&"length"in r)for(;++d<c;)s[d]=nu(r[d]);else{const v=nu(r);for(;++d<c;)s[d]=v}d=-1;const p=[],h=[];for(;++d<c;){const v=s[d];let S="",y="";v===99?(S=":",y=":"):v===108?S=":":v===114&&(y=":");let _=n.alignDelimiters===!1?1:Math.max(1,l[d]-S.length-y.length);const g=S+"-".repeat(_)+y;n.alignDelimiters!==!1&&(_=S.length+_+y.length,_>l[d]&&(l[d]=_),h[d]=_),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 y=[];for(;++d<c;){const _=v[d]||"";let g="",z="";if(n.alignDelimiters!==!1){const C=l[d]-(S[d]||0),w=s[d];w===114?g=" ".repeat(C):w===99?C%2?(g=" ".repeat(C/2+.5),z=" ".repeat(C/2-.5)):(g=" ".repeat(C/2),z=g):z=" ".repeat(C)}n.delimiterStart!==!1&&!d&&y.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&_==="")&&(n.delimiterStart!==!1||d)&&y.push(" "),n.alignDelimiters!==!1&&y.push(g),y.push(_),n.alignDelimiters!==!1&&y.push(z),n.padding!==!1&&y.push(" "),(n.delimiterEnd!==!1||d!==c-1)&&y.push("|")}m.push(n.delimiterEnd===!1?y.join("").replace(/ +$/,""):y.join(""))}return m.join(`
17
+ `)}function qk(e){return e==null?"":String(e)}function nu(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 Gk(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()),Kk);return i(),a}function Kk(e,t,n){return">"+(n?"":" ")+e}function Yk(e,t){return ru(e,t.inConstruct,!0)&&!ru(e,t.notInConstruct,!1)}function ru(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 iu(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
18
+ `&&Yk(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?"":" ";return`\\
19
+ `}function Xk(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 Qk(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 eS(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 tS(e,t,n,r){const i=eS(n),s=e.value||"",a=i==="`"?"GraveAccent":"Tilde";if(Qk(e,n)){const d=n.enter("codeIndented"),p=n.indentLines(s,nS);return d(),p}const o=n.createTracker(r),l=i.repeat(Math.max(Xk(s,i)+1,3)),c=n.enter("codeFenced");let f=o.move(l);if(e.lang){const d=n.enter(`codeFencedLang${a}`);f+=o.move(n.safe(e.lang,{before:f,after:" ",encode:["`"],...o.current()})),d()}if(e.lang&&e.meta){const d=n.enter(`codeFencedMeta${a}`);f+=o.move(" "),f+=o.move(n.safe(e.meta,{before:f,after:`
20
+ `,encode:["`"],...o.current()})),d()}return f+=o.move(`
21
+ `),s&&(f+=o.move(s+`
22
+ `)),f+=o.move(l),c(),f}function nS(e,t,n){return(n?"":" ")+e}function _o(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 rS(e,t,n,r){const i=_o(n),s=i==='"'?"Quote":"Apostrophe",a=n.enter("definition");let o=n.enter("label");const l=n.createTracker(r);let c=l.move("[");return c+=l.move(n.safe(n.associationId(e),{before:c,after:"]",...l.current()})),c+=l.move("]: "),o(),!e.url||/[\0- \u007F]/.test(e.url)?(o=n.enter("destinationLiteral"),c+=l.move("<"),c+=l.move(n.safe(e.url,{before:c,after:">",...l.current()})),c+=l.move(">")):(o=n.enter("destinationRaw"),c+=l.move(n.safe(e.url,{before:c,after:e.title?" ":`
23
+ `,...l.current()}))),o(),e.title&&(o=n.enter(`title${s}`),c+=l.move(" "+i),c+=l.move(n.safe(e.title,{before:c,after:i,...l.current()})),c+=l.move(i),o()),a(),c}function iS(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 Hr(e){return"&#x"+e.toString(16).toUpperCase()+";"}function Ji(e,t,n){const r=ir(e),i=ir(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=sS;function sp(e,t,n,r){const i=iS(n),s=n.enter("emphasis"),a=n.createTracker(r),o=a.move(i);let l=a.move(n.containerPhrasing(e,{after:i,before:o,...a.current()}));const c=l.charCodeAt(0),f=Ji(r.before.charCodeAt(r.before.length-1),c,i);f.inside&&(l=Hr(c)+l.slice(1));const d=l.charCodeAt(l.length-1),p=Ji(r.after.charCodeAt(0),d,i);p.inside&&(l=l.slice(0,-1)+Hr(d));const h=a.move(i);return s(),n.attentionEncodeSurroundingInfo={after:p.outside,before:f.outside},o+l+h}function sS(e,t,n){return n.options.emphasis||"*"}function aS(e,t){let n=!1;return ko(e,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return n=!0,Ea}),!!((!e.depth||e.depth<3)&&mo(e)&&(t.options.setext||n))}function oS(e,t,n,r){const i=Math.max(Math.min(6,e.depth||1),1),s=n.createTracker(r);if(aS(e,n)){const f=n.enter("headingSetext"),d=n.enter("phrasing"),p=n.containerPhrasing(e,{...s.current(),before:`
24
+ `,after:`
25
+ `});return d(),f(),p+`
26
+ `+(i===1?"=":"-").repeat(p.length-(Math.max(p.lastIndexOf("\r"),p.lastIndexOf(`
27
+ `))+1))}const a="#".repeat(i),o=n.enter("headingAtx"),l=n.enter("phrasing");s.move(a+" ");let c=n.containerPhrasing(e,{before:"# ",after:`
28
+ `,...s.current()});return/^[\t ]/.test(c)&&(c=Hr(c.charCodeAt(0))+c.slice(1)),c=c?a+" "+c:a,n.options.closeAtx&&(c+=" "+a),l(),o(),c}ap.peek=lS;function ap(e){return e.value||""}function lS(){return"<"}op.peek=uS;function op(e,t,n,r){const i=_o(n),s=i==='"'?"Quote":"Apostrophe",a=n.enter("image");let o=n.enter("label");const l=n.createTracker(r);let c=l.move("![");return c+=l.move(n.safe(e.alt,{before:c,after:"]",...l.current()})),c+=l.move("]("),o(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(o=n.enter("destinationLiteral"),c+=l.move("<"),c+=l.move(n.safe(e.url,{before:c,after:">",...l.current()})),c+=l.move(">")):(o=n.enter("destinationRaw"),c+=l.move(n.safe(e.url,{before:c,after:e.title?" ":")",...l.current()}))),o(),e.title&&(o=n.enter(`title${s}`),c+=l.move(" "+i),c+=l.move(n.safe(e.title,{before:c,after:i,...l.current()})),c+=l.move(i),o()),c+=l.move(")"),a(),c}function uS(){return"!"}lp.peek=cS;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 l=o.move("![");const c=n.safe(e.alt,{before:l,after:"]",...o.current()});l+=o.move(c+"]["),a();const f=n.stack;n.stack=[],a=n.enter("reference");const d=n.safe(n.associationId(e),{before:l,after:"]",...o.current()});return a(),n.stack=f,s(),i==="full"||!c||c!==d?l+=o.move(d+"]"):i==="shortcut"?l=l.slice(0,-1):l+=o.move("]"),l}function cS(){return"!"}up.peek=dS;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 l;if(a.atBreak)for(;l=o.exec(r);){let c=l.index;r.charCodeAt(c)===10&&r.charCodeAt(c-1)===13&&c--,r=r.slice(0,c)+" "+r.slice(l.index+1)}}return i+r+i}function dS(){return"`"}function cp(e,t){const n=mo(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=fS;function dp(e,t,n,r){const i=_o(n),s=i==='"'?"Quote":"Apostrophe",a=n.createTracker(r);let o,l;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"),l=n.enter("label");let c=a.move("[");return c+=a.move(n.containerPhrasing(e,{before:c,after:"](",...a.current()})),c+=a.move("]("),l(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(l=n.enter("destinationLiteral"),c+=a.move("<"),c+=a.move(n.safe(e.url,{before:c,after:">",...a.current()})),c+=a.move(">")):(l=n.enter("destinationRaw"),c+=a.move(n.safe(e.url,{before:c,after:e.title?" ":")",...a.current()}))),l(),e.title&&(l=n.enter(`title${s}`),c+=a.move(" "+i),c+=a.move(n.safe(e.title,{before:c,after:i,...a.current()})),c+=a.move(i),l()),c+=a.move(")"),o(),c}function fS(e,t,n){return cp(e,n)?"<":"["}fp.peek=pS;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 l=o.move("[");const c=n.containerPhrasing(e,{before:l,after:"]",...o.current()});l+=o.move(c+"]["),a();const f=n.stack;n.stack=[],a=n.enter("reference");const d=n.safe(n.associationId(e),{before:l,after:"]",...o.current()});return a(),n.stack=f,s(),i==="full"||!c||c!==d?l+=o.move(d+"]"):i==="shortcut"?l=l.slice(0,-1):l+=o.move("]"),l}function pS(){return"["}function jo(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 hS(e){const t=jo(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 mS(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 gS(e,t,n,r){const i=n.enter("list"),s=n.bulletCurrent;let a=e.ordered?mS(n):jo(n);const o=e.ordered?a==="."?")":".":hS(n);let l=t&&n.bulletLastUsed?a===n.bulletLastUsed:!1;if(!e.ordered){const f=e.children?e.children[0]:void 0;if((a==="*"||a==="-")&&f&&(!f.children||!f.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(l=!0),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"){l=!0;break}}}}l&&(a=o),n.bulletCurrent=a;const c=n.containerFlow(e,r);return n.bulletLastUsed=a,n.bulletCurrent=s,i(),c}function xS(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 yS(e,t,n,r){const i=xS(n);let s=n.bulletCurrent||jo(n);t&&t.type==="list"&&t.ordered&&(s=(typeof t.start=="number"&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+s);let a=s.length+1;(i==="tab"||i==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(a=Math.ceil(a/4)*4);const o=n.createTracker(r);o.move(s+" ".repeat(a-s.length)),o.shift(a);const l=n.enter("listItem"),c=n.indentLines(n.containerFlow(e,o.current()),f);return l(),c;function f(d,p,h){return p?(h?"":" ".repeat(a))+d:(h?s:s+" ".repeat(a-s.length))+d}}function bS(e,t,n,r){const i=n.enter("paragraph"),s=n.enter("phrasing"),a=n.containerPhrasing(e,r);return s(),i(),a}const vS=bs(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function wS(e,t,n,r){return(e.children.some(function(a){return vS(a)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function kS(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=SS;function hp(e,t,n,r){const i=kS(n),s=n.enter("strong"),a=n.createTracker(r),o=a.move(i+i);let l=a.move(n.containerPhrasing(e,{after:i,before:o,...a.current()}));const c=l.charCodeAt(0),f=Ji(r.before.charCodeAt(r.before.length-1),c,i);f.inside&&(l=Hr(c)+l.slice(1));const d=l.charCodeAt(l.length-1),p=Ji(r.after.charCodeAt(0),d,i);p.inside&&(l=l.slice(0,-1)+Hr(d));const h=a.move(i+i);return s(),n.attentionEncodeSurroundingInfo={after:p.outside,before:f.outside},o+l+h}function SS(e,t,n){return n.options.strong||"*"}function _S(e,t,n,r){return n.safe(e.value,r)}function jS(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 NS(e,t,n){const r=(pp(n)+(n.options.ruleSpaces?" ":"")).repeat(jS(n));return n.options.ruleSpaces?r.slice(0,-1):r}const mp={blockquote:Gk,break:iu,code:tS,definition:rS,emphasis:sp,hardBreak:iu,heading:oS,html:ap,image:op,imageReference:lp,inlineCode:up,link:dp,linkReference:fp,list:gS,listItem:yS,paragraph:bS,root:wS,strong:hp,text:_S,thematicBreak:NS};function CS(){return{enter:{table:ES,tableData:su,tableHeader:su,tableRow:zS},exit:{codeText:TS,table:IS,tableData:ta,tableHeader:ta,tableRow:ta}}}function ES(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 IS(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 su(e){this.enter({type:"tableCell",children:[]},e)}function TS(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,AS));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function AS(e,t){return t==="|"?t:e}function PS(e){const t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,s=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
29
+ `,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:p,table:a,tableCell:l,tableRow:o}};function a(h,m,v,S){return c(f(h,v,S),h.align)}function o(h,m,v,S){const y=d(h,v,S),_=c([y]);return _.slice(0,_.indexOf(`
30
+ `))}function l(h,m,v,S){const y=v.enter("tableCell"),_=v.enter("phrasing"),g=v.containerPhrasing(h,{...S,before:s,after:s});return _(),y(),g}function c(h,m){return Wk(h,{align:m,alignDelimiters:r,padding:n,stringLength:i})}function f(h,m,v){const S=h.children;let y=-1;const _=[],g=m.enter("table");for(;++y<S.length;)_[y]=d(S[y],m,v);return g(),_}function d(h,m,v){const S=h.children;let y=-1;const _=[],g=m.enter("tableRow");for(;++y<S.length;)_[y]=l(S[y],h,m,v);return g(),_}function p(h,m,v){let S=mp.inlineCode(h,m,v);return v.stack.includes("tableCell")&&(S=S.replace(/\|/g,"\\$&")),S}}function OS(){return{exit:{taskListCheckValueChecked:au,taskListCheckValueUnchecked:au,paragraph:RS}}}function DS(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:MS}}}function au(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function RS(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 MS(e,t,n,r){const i=e.children[0],s=typeof e.checked=="boolean"&&i&&i.type==="paragraph",a="["+(e.checked?"x":" ")+"] ",o=n.createTracker(r);s&&o.move(a);let l=mp.listItem(e,t,n,{...r,...o.current()});return s&&(l=l.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,c)),l;function c(f){return f+a}}function $S(){return[gk(),Mk(),Zk(),CS(),OS()]}function FS(e){return{extensions:[xk(),$k(e),Bk(),PS(e),DS()]}}const LS={tokenize:HS,partial:!0},gp={tokenize:WS,partial:!0},xp={tokenize:qS,partial:!0},yp={tokenize:GS,partial:!0},ZS={tokenize:KS,partial:!0},bp={name:"wwwAutolink",tokenize:US,previous:wp},vp={name:"protocolAutolink",tokenize:JS,previous:kp},Qt={name:"emailAutolink",tokenize:VS,previous:Sp},Wt={};function BS(){return{text:Wt}}let xn=48;for(;xn<123;)Wt[xn]=Qt,xn++,xn===58?xn=65:xn===91&&(xn=97);Wt[43]=Qt;Wt[45]=Qt;Wt[46]=Qt;Wt[95]=Qt;Wt[72]=[Qt,vp];Wt[104]=[Qt,vp];Wt[87]=[Qt,bp];Wt[119]=[Qt,bp];function VS(e,t,n){const r=this;let i,s;return a;function a(d){return!Aa(d)||!Sp.call(r,r.previous)||No(r.events)?n(d):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),o(d))}function o(d){return Aa(d)?(e.consume(d),o):d===64?(e.consume(d),l):n(d)}function l(d){return d===46?e.check(ZS,f,c)(d):d===45||d===95||st(d)?(s=!0,e.consume(d),l):f(d)}function c(d){return e.consume(d),i=!0,l}function f(d){return s&&i&&dt(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(d)):n(d)}}function US(e,t,n){const r=this;return i;function i(a){return a!==87&&a!==119||!wp.call(r,r.previous)||No(r.events)?n(a):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(LS,e.attempt(gp,e.attempt(xp,s),n),n)(a))}function s(a){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(a)}}function JS(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)&&!No(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),i+=String.fromCodePoint(d),e.consume(d),o):n(d)}function o(d){if(dt(d)&&i.length<5)return i+=String.fromCodePoint(d),e.consume(d),o;if(d===58){const p=i.toLowerCase();if(p==="http"||p==="https")return e.consume(d),l}return n(d)}function l(d){return d===47?(e.consume(d),s?c:(s=!0,l)):n(d)}function c(d){return d===null||Bi(d)||Me(d)||zn(d)||gs(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 HS(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 WS(e,t,n){let r,i,s;return a;function a(c){return c===46||c===95?e.check(yp,l,o)(c):c===null||Me(c)||zn(c)||c!==45&&gs(c)?l(c):(s=!0,e.consume(c),a)}function o(c){return c===95?r=!0:(i=r,r=void 0),e.consume(c),a}function l(c){return i||r||!s?n(c):t(c)}}function qS(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||Me(a)||zn(a)?t(a):(e.consume(a),i)}function s(a){return a===41&&r++,e.consume(a),i}}function GS(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||Me(o)||zn(o)?t(o):n(o)}function i(o){return o===null||o===40||o===91||Me(o)||zn(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 KS(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||Me(e)}function kp(e){return!dt(e)}function Sp(e){return!(e===47||Aa(e))}function Aa(e){return e===43||e===45||e===46||e===95||st(e)}function No(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 YS={tokenize:s1,partial:!0};function XS(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:n1,continuation:{tokenize:r1},exit:i1}},text:{91:{name:"gfmFootnoteCall",tokenize:t1},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:QS,resolveTo:e1}}}}function QS(e,t,n){const r=this;let i=r.events.length;const s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a;for(;i--;){const l=r.events[i][1];if(l.type==="labelImage"){a=l;break}if(l.type==="gfmFootnoteCall"||l.type==="labelLink"||l.type==="label"||l.type==="image"||l.type==="link")break}return o;function o(l){if(!a||!a._balanced)return n(l);const c=Mt(r.sliceSerialize({start:a.end,end:r.now()}));return c.codePointAt(0)!==94||!s.includes(c.slice(1))?n(l):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(l),e.exit("gfmFootnoteCallLabelMarker"),t(l))}}function e1(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 t1(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s=0,a;return o;function o(d){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),l}function l(d){return d!==94?n(d):(e.enter("gfmFootnoteCallMarker"),e.consume(d),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",c)}function c(d){if(s>999||d===93&&!a||d===null||d===91||Me(d))return n(d);if(d===93){e.exit("chunkString");const p=e.exit("gfmFootnoteCallString");return i.includes(Mt(r.sliceSerialize(p)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(d)}return Me(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 n1(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s,a=0,o;return l;function l(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||Me(m))return n(m);if(m===93){e.exit("chunkString");const v=e.exit("gfmFootnoteDefinitionLabelString");return s=Mt(r.sliceSerialize(v)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),p}return Me(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),ze(e,h,"gfmFootnoteDefinitionWhitespace")):n(m)}function h(m){return t(m)}}function r1(e,t,n){return e.check(ri,t,e.attempt(YS,t,n))}function i1(e){e.exit("gfmFootnoteDefinition")}function s1(e,t,n){const r=this;return ze(e,i,"gfmFootnoteDefinitionIndent",5);function i(s){const a=r.events[r.events.length-1];return a&&a[1].type==="gfmFootnoteDefinitionIndent"&&a[2].sliceSerialize(a[1],!0).length===4?t(s):n(s)}}function a1(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:s,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(a,o){let l=-1;for(;++l<a.length;)if(a[l][0]==="enter"&&a[l][1].type==="strikethroughSequenceTemporary"&&a[l][1]._close){let c=l;for(;c--;)if(a[c][0]==="exit"&&a[c][1].type==="strikethroughSequenceTemporary"&&a[c][1]._open&&a[l][1].end.offset-a[l][1].start.offset===a[c][1].end.offset-a[c][1].start.offset){a[l][1].type="strikethroughSequence",a[c][1].type="strikethroughSequence";const f={type:"strikethrough",start:Object.assign({},a[c][1].start),end:Object.assign({},a[l][1].end)},d={type:"strikethroughText",start:Object.assign({},a[c][1].end),end:Object.assign({},a[l][1].start)},p=[["enter",f,o],["enter",a[c][1],o],["exit",a[c][1],o],["enter",d,o]],h=o.parser.constructs.insideSpan.null;h&&_t(p,p.length,0,xs(h,a.slice(c+1,l),o)),_t(p,p.length,0,[["exit",d,o],["enter",a[l][1],o],["exit",a[l][1],o],["exit",f,o]]),_t(a,c-1,l-c+3,p),l=c+p.length-2;break}}for(l=-1;++l<a.length;)a[l][1].type==="strikethroughSequenceTemporary"&&(a[l][1].type="data");return a}function s(a,o,l){const c=this.previous,f=this.events;let d=0;return p;function p(m){return c===126&&f[f.length-1][1].type!=="characterEscape"?l(m):(a.enter("strikethroughSequenceTemporary"),h(m))}function h(m){const v=ir(c);if(m===126)return d>1?l(m):(a.consume(m),d++,h);if(d<2&&!n)return l(m);const S=a.exit("strikethroughSequenceTemporary"),y=ir(m);return S._open=!y||y===2&&!!v,S._close=!v||v===2&&!!y,o(m)}}}class o1{constructor(){this.map=[]}add(t,n,r){l1(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 l1(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 u1(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 c1(){return{flow:{null:{name:"table",tokenize:d1,resolveAll:f1}}}}function d1(e,t,n){const r=this;let i=0,s=0,a;return o;function o(j){let I=r.events.length-1;for(;I>-1;){const M=r.events[I][1].type;if(M==="lineEnding"||M==="linePrefix")I--;else break}const O=I>-1?r.events[I][1].type:null,Z=O==="tableHead"||O==="tableRow"?w:l;return Z===w&&r.parser.lazy[r.now().line]?n(j):Z(j)}function l(j){return e.enter("tableHead"),e.enter("tableRow"),c(j)}function c(j){return j===124||(a=!0,s+=1),f(j)}function f(j){return j===null?n(j):xe(j)?s>1?(s=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(j),e.exit("lineEnding"),h):n(j):Ne(j)?ze(e,f,"whitespace")(j):(s+=1,a&&(a=!1,i+=1),j===124?(e.enter("tableCellDivider"),e.consume(j),e.exit("tableCellDivider"),a=!0,f):(e.enter("data"),d(j)))}function d(j){return j===null||j===124||Me(j)?(e.exit("data"),f(j)):(e.consume(j),j===92?p:d)}function p(j){return j===92||j===124?(e.consume(j),d):d(j)}function h(j){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(j):(e.enter("tableDelimiterRow"),a=!1,Ne(j)?ze(e,m,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(j):m(j))}function m(j){return j===45||j===58?S(j):j===124?(a=!0,e.enter("tableCellDivider"),e.consume(j),e.exit("tableCellDivider"),v):C(j)}function v(j){return Ne(j)?ze(e,S,"whitespace")(j):S(j)}function S(j){return j===58?(s+=1,a=!0,e.enter("tableDelimiterMarker"),e.consume(j),e.exit("tableDelimiterMarker"),y):j===45?(s+=1,y(j)):j===null||xe(j)?z(j):C(j)}function y(j){return j===45?(e.enter("tableDelimiterFiller"),_(j)):C(j)}function _(j){return j===45?(e.consume(j),_):j===58?(a=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(j),e.exit("tableDelimiterMarker"),g):(e.exit("tableDelimiterFiller"),g(j))}function g(j){return Ne(j)?ze(e,z,"whitespace")(j):z(j)}function z(j){return j===124?m(j):j===null||xe(j)?!a||i!==s?C(j):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(j)):C(j)}function C(j){return n(j)}function w(j){return e.enter("tableRow"),E(j)}function E(j){return j===124?(e.enter("tableCellDivider"),e.consume(j),e.exit("tableCellDivider"),E):j===null||xe(j)?(e.exit("tableRow"),t(j)):Ne(j)?ze(e,E,"whitespace")(j):(e.enter("data"),R(j))}function R(j){return j===null||j===124||Me(j)?(e.exit("data"),E(j)):(e.consume(j),j===92?K:R)}function K(j){return j===92||j===124?(e.consume(j),R):R(j)}}function f1(e,t){let n=-1,r=!0,i=0,s=[0,0,0,0],a=[0,0,0,0],o=!1,l=0,c,f,d;const p=new o1;for(;++n<e.length;){const h=e[n],m=h[1];h[0]==="enter"?m.type==="tableHead"?(o=!1,l!==0&&(ou(p,t,l,c,f),f=void 0,l=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=mi(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=mi(p,t,s,i,void 0,d)),s=a,a=[s[1],n,0,0])):m.type==="tableHead"?(o=!0,l=n):m.type==="tableRow"||m.type==="tableDelimiterRow"?(l=n,s[1]!==0?(a[0]=a[1],d=mi(p,t,s,i,n,d)):a[1]!==0&&(d=mi(p,t,a,i,n,d)),i=0):i&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")&&(a[3]=n)}for(l!==0&&ou(p,t,l,c,f),p.consume(t.events),n=-1;++n<t.events.length;){const h=t.events[n];h[0]==="enter"&&h[1].type==="table"&&(h[1]._align=u1(t.events,n))}return e}function mi(e,t,n,r,i,s){const a=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",o="tableContent";n[0]!==0&&(s.end=Object.assign({},Un(t.events,n[0])),e.add(n[0],0,[["exit",s,t]]));const l=Un(t.events,n[1]);if(s={type:a,start:Object.assign({},l),end:Object.assign({},l)},e.add(n[1],0,[["enter",s,t]]),n[2]!==0){const c=Un(t.events,n[2]),f=Un(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({},Un(t.events,i)),e.add(i,0,[["exit",s,t]]),s=void 0),s}function ou(e,t,n,r,i){const s=[],a=Un(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 Un(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const p1={name:"tasklistCheck",tokenize:m1};function h1(){return{text:{91:p1}}}function m1(e,t,n){const r=this;return i;function i(l){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(l):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),s)}function s(l){return Me(l)?(e.enter("taskListCheckValueUnchecked"),e.consume(l),e.exit("taskListCheckValueUnchecked"),a):l===88||l===120?(e.enter("taskListCheckValueChecked"),e.consume(l),e.exit("taskListCheckValueChecked"),a):n(l)}function a(l){return l===93?(e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),o):n(l)}function o(l){return xe(l)?t(l):Ne(l)?e.check({tokenize:g1},t,n)(l):n(l)}}function g1(e,t,n){return ze(e,r,"whitespace");function r(i){return i===null?n(i):t(i)}}function x1(e){return Of([BS(),XS(),a1(e),c1(),h1()])}const y1={};function b1(e){const t=this,n=e||y1,r=t.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),s=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),a=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(x1(n)),s.push($S()),a.push(FS(n))}var _p="vercel.ai.error",v1=Symbol.for(_p),lu,uu,Ht=class jp extends(uu=Error,lu=v1,uu){constructor({name:t,message:n,cause:r}){super(n),this[lu]=!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 Np(e){return e==null?"unknown error":typeof e=="string"?e:e instanceof Error?e.message:JSON.stringify(e)}var Cp="AI_InvalidArgumentError",Ep=`vercel.ai.error.${Cp}`,w1=Symbol.for(Ep),cu,du,k1=class extends(du=Ht,cu=w1,du){constructor({message:e,cause:t,argument:n}){super({name:Cp,message:e,cause:t}),this[cu]=!0,this.argument=n}static isInstance(e){return Ht.hasMarker(e,Ep)}},Ip="AI_JSONParseError",zp=`vercel.ai.error.${Ip}`,S1=Symbol.for(zp),fu,pu,hu=class extends(pu=Ht,fu=S1,pu){constructor({text:e,cause:t}){super({name:Ip,message:`JSON parsing failed: Text: ${e}.
31
+ Error message: ${Np(t)}`,cause:t}),this[fu]=!0,this.text=e}static isInstance(e){return Ht.hasMarker(e,zp)}},Tp="AI_TypeValidationError",Ap=`vercel.ai.error.${Tp}`,_1=Symbol.for(Ap),mu,gu,sr=class Pa extends(gu=Ht,mu=_1,gu){constructor({value:t,cause:n,context:r}){let i="Type validation failed";if(r!=null&&r.field&&(i+=` for ${r.field}`),r!=null&&r.entityName||r!=null&&r.entityId){i+=" (";const s=[];r.entityName&&s.push(r.entityName),r.entityId&&s.push(`id: "${r.entityId}"`),i+=s.join(", "),i+=")"}super({name:Tp,message:`${i}: Value: ${JSON.stringify(t)}.
32
+ Error message: ${Np(n)}`,cause:n}),this[mu]=!0,this.value=t,this.context=r}static isInstance(t){return Ht.hasMarker(t,Ap)}static wrap({value:t,cause:n,context:r}){var i,s,a;return Pa.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 Pa({value:t,cause:n,context:r})}};function U(e,t,n){function r(o,l){if(o._zod||Object.defineProperty(o,"_zod",{value:{def:l,constr:a,traits:new Set},enumerable:!1}),o._zod.traits.has(e))return;o._zod.traits.add(e),t(o,l);const c=a.prototype,f=Object.keys(c);for(let d=0;d<f.length;d++){const p=f[d];p in o||(o[p]=c[p].bind(o))}}const i=(n==null?void 0:n.Parent)??Object;class s extends i{}Object.defineProperty(s,"name",{value:e});function a(o){var l;const c=n!=null&&n.Parent?new s:this;r(c,o),(l=c._zod).deferred??(l.deferred=[]);for(const f of c._zod.deferred)f();return c}return Object.defineProperty(a,"init",{value:r}),Object.defineProperty(a,Symbol.hasInstance,{value:o=>{var l,c;return n!=null&&n.Parent&&o instanceof n.Parent?!0:(c=(l=o==null?void 0:o._zod)==null?void 0:l.traits)==null?void 0:c.has(e)}}),Object.defineProperty(a,"name",{value:e}),a}class er 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 dn(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 Oa(e,t){return typeof t=="bigint"?t.toString():t}function ws(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Co(e){return e==null}function Eo(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function j1(e,t){const n=(e.toString().split(".")[1]||"").length,r=t.toString();let i=(r.split(".")[1]||"").length;if(i===0&&/\d?e-\d?/.test(r)){const l=r.match(/\d?e-(\d?)/);l!=null&&l[1]&&(i=Number.parseInt(l[1]))}const s=n>i?n:i,a=Number.parseInt(e.toFixed(s).replace(".","")),o=Number.parseInt(t.toFixed(s).replace(".",""));return a%o/10**s}const xu=Symbol("evaluating");function Ie(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==xu)return r===void 0&&(r=xu,r=n()),r},set(i){Object.defineProperty(e,t,{value:i})},configurable:!0})}function Pn(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function hn(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function yu(e){return JSON.stringify(e)}function N1(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Rp="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Wr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const C1=ws(()=>{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 ar(e){if(Wr(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(Wr(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Mp(e){return ar(e)?{...e}:Array.isArray(e)?[...e]:e}const E1=new Set(["string","number","symbol"]);function or(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function mn(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 fe(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 I1(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 T1(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=hn(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 Pn(this,"shape",a),a},checks:[]});return mn(e,s)}function A1(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=hn(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 Pn(this,"shape",a),a},checks:[]});return mn(e,s)}function P1(e,t){if(!ar(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=hn(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t};return Pn(this,"shape",s),s}});return mn(e,i)}function O1(e,t){if(!ar(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=hn(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return Pn(this,"shape",r),r}});return mn(e,n)}function D1(e,t){const n=hn(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return Pn(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:[]});return mn(e,n)}function R1(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=hn(t._zod.def,{get shape(){const o=t._zod.def.shape,l={...o};if(n)for(const c in n){if(!(c in o))throw new Error(`Unrecognized key: "${c}"`);n[c]&&(l[c]=e?new e({type:"optional",innerType:o[c]}):o[c])}else for(const c in o)l[c]=e?new e({type:"optional",innerType:o[c]}):o[c];return Pn(this,"shape",l),l},checks:[]});return mn(t,a)}function M1(e,t,n){const r=hn(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 Pn(this,"shape",s),s}});return mn(t,r)}function qn(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 Gn(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function gi(e){return typeof e=="string"?e:e==null?void 0:e.message}function fn(e,t,n){var i,s,a,o,l,c;const r={...e,path:e.path??[]};if(!e.message){const f=gi((a=(s=(i=e.inst)==null?void 0:i._zod.def)==null?void 0:s.error)==null?void 0:a.call(s,e))??gi((o=t==null?void 0:t.error)==null?void 0:o.call(t,e))??gi((l=n.customError)==null?void 0:l.call(n,e))??gi((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 Io(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function qr(...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,Oa,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Fp=U("$ZodError",$p),Lp=U("$ZodError",$p,{Parent:Error});function $1(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 F1(e,t=n=>n.message){const n={_errors:[]},r=i=>{for(const s of i.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(a=>r({issues:a}));else if(s.code==="invalid_key")r({issues:s.issues});else if(s.code==="invalid_element")r({issues:s.issues});else if(s.path.length===0)n._errors.push(t(s));else{let a=n,o=0;for(;o<s.path.length;){const l=s.path[o];o===s.path.length-1?(a[l]=a[l]||{_errors:[]},a[l]._errors.push(t(s))):a[l]=a[l]||{_errors:[]},a=a[l],o++}}};return r(e),n}const zo=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 er;if(a.issues.length){const o=new((i==null?void 0:i.Err)??e)(a.issues.map(l=>fn(l,s,dn())));throw Rp(o,i==null?void 0:i.callee),o}return a.value},To=e=>async(t,n,r,i)=>{const s=r?Object.assign(r,{async:!0}):{async:!0};let a=t._zod.run({value:n,issues:[]},s);if(a instanceof Promise&&(a=await a),a.issues.length){const o=new((i==null?void 0:i.Err)??e)(a.issues.map(l=>fn(l,s,dn())));throw Rp(o,i==null?void 0:i.callee),o}return a.value},ks=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 er;return s.issues.length?{success:!1,error:new(e??Fp)(s.issues.map(a=>fn(a,i,dn())))}:{success:!0,data:s.value}},L1=ks(Lp),Ss=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=>fn(a,i,dn())))}:{success:!0,data:s.value}},Z1=Ss(Lp),B1=e=>(t,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return zo(e)(t,n,i)},V1=e=>(t,n,r)=>zo(e)(t,n,r),U1=e=>async(t,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return To(e)(t,n,i)},J1=e=>async(t,n,r)=>To(e)(t,n,r),H1=e=>(t,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return ks(e)(t,n,i)},W1=e=>(t,n,r)=>ks(e)(t,n,r),q1=e=>async(t,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Ss(e)(t,n,i)},G1=e=>async(t,n,r)=>Ss(e)(t,n,r),K1=/^[cC][^\s-]{8,}$/,Y1=/^[0-9a-z]+$/,X1=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Q1=/^[0-9a-vA-V]{20}$/,e_=/^[A-Za-z0-9]{27}$/,t_=/^[a-zA-Z0-9_-]{21}$/,n_=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,r_=/^([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})$/,bu=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)$/,i_=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,s_="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function a_(){return new RegExp(s_,"u")}const o_=/^(?:(?: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])$/,l_=/^(([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}|:))$/,u_=/^((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])$/,c_=/^(([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])$/,d_=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Zp=/^[A-Za-z0-9_-]*$/,f_=/^\+[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])))",p_=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 h_(e){return new RegExp(`^${Vp(e)}$`)}function m_(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 g_=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}$`)},x_=/^-?\d+$/,Up=/^-?\d+(?:\.\d+)?$/,y_=/^(?:true|false)$/i,b_=/^null$/i,v_=/^[^A-Z]*$/,w_=/^[^a-z]*$/,vt=U("$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=U("$ZodCheckLessThan",(e,t)=>{vt.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=U("$ZodCheckGreaterThan",(e,t)=>{vt.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})}}),k_=U("$ZodCheckMultipleOf",(e,t)=>{vt.init(e,t),e._zod.onattach.push(n=>{var r;(r=n._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):j1(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})}}),S_=U("$ZodCheckNumberFormat",(e,t)=>{var a;vt.init(e,t),t.format=t.format||"float64";const n=(a=t.format)==null?void 0:a.includes("int"),r=n?"int":"number",[i,s]=z1[t.format];e._zod.onattach.push(o=>{const l=o._zod.bag;l.format=t.format,l.minimum=i,l.maximum=s,n&&(l.pattern=x_)}),e._zod.check=o=>{const l=o.value;if(n){if(!Number.isInteger(l)){o.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:l,inst:e});return}if(!Number.isSafeInteger(l)){l>0?o.issues.push({input:l,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:l,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}l<i&&o.issues.push({origin:"number",input:l,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort}),l>s&&o.issues.push({origin:"number",input:l,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}}),__=U("$ZodCheckMaxLength",(e,t)=>{var n;vt.init(e,t),(n=e._zod.def).when??(n.when=r=>{const i=r.value;return!Co(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=Io(i);r.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),j_=U("$ZodCheckMinLength",(e,t)=>{var n;vt.init(e,t),(n=e._zod.def).when??(n.when=r=>{const i=r.value;return!Co(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=Io(i);r.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),N_=U("$ZodCheckLengthEquals",(e,t)=>{var n;vt.init(e,t),(n=e._zod.def).when??(n.when=r=>{const i=r.value;return!Co(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=Io(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})}}),_s=U("$ZodCheckStringFormat",(e,t)=>{var n,r;vt.init(e,t),e._zod.onattach.push(i=>{const s=i._zod.bag;s.format=t.format,t.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=i=>{t.pattern.lastIndex=0,!t.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:t.format,input:i.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),C_=U("$ZodCheckRegex",(e,t)=>{_s.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})}}),E_=U("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=v_),_s.init(e,t)}),I_=U("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=w_),_s.init(e,t)}),z_=U("$ZodCheckIncludes",(e,t)=>{vt.init(e,t);const n=or(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})}}),T_=U("$ZodCheckStartsWith",(e,t)=>{vt.init(e,t);const n=new RegExp(`^${or(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})}}),A_=U("$ZodCheckEndsWith",(e,t)=>{vt.init(e,t);const n=new RegExp(`.*${or(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})}}),P_=U("$ZodCheckOverwrite",(e,t)=>{vt.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class O_{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 D_={major:4,minor:3,patch:6},Ve=U("$ZodType",(e,t)=>{var i;var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=D_;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const s of r)for(const a of s._zod.onattach)a(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),(i=e._zod.deferred)==null||i.push(()=>{e._zod.run=e._zod.parse});else{const s=(o,l,c)=>{let f=qn(o),d;for(const p of l){if(p._zod.def.when){if(!p._zod.def.when(o))continue}else if(f)continue;const h=o.issues.length,m=p._zod.check(o);if(m instanceof Promise&&(c==null?void 0:c.async)===!1)throw new er;if(d||m instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await m,o.issues.length!==h&&(f||(f=qn(o,h)))});else{if(o.issues.length===h)continue;f||(f=qn(o,h))}}return d?d.then(()=>o):o},a=(o,l,c)=>{if(qn(o))return o.aborted=!0,o;const f=s(l,r,c);if(f instanceof Promise){if(c.async===!1)throw new er;return f.then(d=>e._zod.parse(d,c))}return e._zod.parse(f,c)};e._zod.run=(o,l)=>{if(l.skipChecks)return e._zod.parse(o,l);if(l.direction==="backward"){const f=e._zod.parse({value:o.value,issues:[]},{...l,skipChecks:!0});return f instanceof Promise?f.then(d=>a(d,o,l)):a(f,o,l)}const c=e._zod.parse(o,l);if(c instanceof Promise){if(l.async===!1)throw new er;return c.then(f=>s(f,r,l))}return s(c,r,l)}}Ie(e,"~standard",()=>({validate:s=>{var a;try{const o=L1(e,s);return o.success?{value:o.data}:{issues:(a=o.error)==null?void 0:a.issues}}catch{return Z1(e,s).then(l=>{var c;return l.success?{value:l.data}:{issues:(c=l.error)==null?void 0:c.issues}})}},vendor:"zod",version:1}))}),Ao=U("$ZodString",(e,t)=>{var n;Ve.init(e,t),e._zod.pattern=[...((n=e==null?void 0:e._zod.bag)==null?void 0:n.patterns)??[]].pop()??g_(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}}),Je=U("$ZodStringFormat",(e,t)=>{_s.init(e,t),Ao.init(e,t)}),R_=U("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=r_),Je.init(e,t)}),M_=U("$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=bu(r))}else t.pattern??(t.pattern=bu());Je.init(e,t)}),$_=U("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=i_),Je.init(e,t)}),F_=U("$ZodURL",(e,t)=>{Je.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})}}}),L_=U("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=a_()),Je.init(e,t)}),Z_=U("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=t_),Je.init(e,t)}),B_=U("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=K1),Je.init(e,t)}),V_=U("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Y1),Je.init(e,t)}),U_=U("$ZodULID",(e,t)=>{t.pattern??(t.pattern=X1),Je.init(e,t)}),J_=U("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Q1),Je.init(e,t)}),H_=U("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=e_),Je.init(e,t)}),W_=U("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=m_(t)),Je.init(e,t)}),q_=U("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=p_),Je.init(e,t)}),G_=U("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=h_(t)),Je.init(e,t)}),K_=U("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=n_),Je.init(e,t)}),Y_=U("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=o_),Je.init(e,t),e._zod.bag.format="ipv4"}),X_=U("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=l_),Je.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})}}}),Q_=U("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=u_),Je.init(e,t)}),ej=U("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=c_),Je.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 tj=U("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=d_),Je.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 nj(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 rj=U("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Zp),Je.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{nj(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),ij=U("$ZodE164",(e,t)=>{t.pattern??(t.pattern=f_),Je.init(e,t)});function sj(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 aj=U("$ZodJWT",(e,t)=>{Je.init(e,t),e._zod.check=n=>{sj(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),Gp=U("$ZodNumber",(e,t)=>{Ve.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}}),oj=U("$ZodNumberFormat",(e,t)=>{S_.init(e,t),Gp.init(e,t)}),lj=U("$ZodBoolean",(e,t)=>{Ve.init(e,t),e._zod.pattern=y_,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}}),uj=U("$ZodNull",(e,t)=>{Ve.init(e,t),e._zod.pattern=b_,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}}),cj=U("$ZodUnknown",(e,t)=>{Ve.init(e,t),e._zod.parse=n=>n}),dj=U("$ZodNever",(e,t)=>{Ve.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function vu(e,t,n){e.issues.length&&t.issues.push(...Gn(n,e.issues)),t.value[n]=e.value}const fj=U("$ZodArray",(e,t)=>{Ve.init(e,t),e._zod.parse=(n,r)=>{const i=n.value;if(!Array.isArray(i))return n.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),n;n.value=Array(i.length);const s=[];for(let a=0;a<i.length;a++){const o=i[a],l=t.element._zod.run({value:o,issues:[]},r);l instanceof Promise?s.push(l.then(c=>vu(c,n,a))):vu(l,n,a)}return s.length?Promise.all(s).then(()=>n):n}});function Hi(e,t,n,r,i){if(e.issues.length){if(i&&!(n in r))return;t.issues.push(...Gn(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=I1(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,l=i.catchall._zod,c=l.def.type,f=l.optout==="optional";for(const d in t){if(o.has(d))continue;if(c==="never"){a.push(d);continue}const p=l.run({value:t[d],issues:[]},r);p instanceof Promise?e.push(p.then(h=>Hi(h,n,d,t,f))):Hi(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 pj=U("$ZodObject",(e,t)=>{Ve.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape");if(!(n!=null&&n.get)){const o=t.shape;Object.defineProperty(t,"shape",{get:()=>{const l={...o};return Object.defineProperty(t,"shape",{value:l}),l}})}const r=ws(()=>Kp(t));Ie(e._zod,"propValues",()=>{const o=t.shape,l={};for(const c in o){const f=o[c]._zod;if(f.values){l[c]??(l[c]=new Set);for(const d of f.values)l[c].add(d)}}return l});const i=Wr,s=t.catchall;let a;e._zod.parse=(o,l)=>{a??(a=r.value);const c=o.value;if(!i(c))return o.issues.push({expected:"object",code:"invalid_type",input:c,inst:e}),o;o.value={};const f=[],d=a.shape;for(const p of a.keys){const h=d[p],m=h._zod.optout==="optional",v=h._zod.run({value:c[p],issues:[]},l);v instanceof Promise?f.push(v.then(S=>Hi(S,o,p,c,m))):Hi(v,o,p,c,m)}return s?Yp(f,c,o,l,r.value,e):f.length?Promise.all(f).then(()=>o):o}}),hj=U("$ZodObjectJIT",(e,t)=>{pj.init(e,t);const n=e._zod.parse,r=ws(()=>Kp(t)),i=p=>{var g;const h=new O_(["shape","payload","ctx"]),m=r.value,v=z=>{const C=yu(z);return`shape[${C}]._zod.run({ value: input[${C}], issues: [] }, ctx)`};h.write("const input = payload.value;");const S=Object.create(null);let y=0;for(const z of m.keys)S[z]=`key_${y++}`;h.write("const newResult = {};");for(const z of m.keys){const C=S[z],w=yu(z),E=p[z],R=((g=E==null?void 0:E._zod)==null?void 0:g.optout)==="optional";h.write(`const ${C} = ${v(z)};`),R?h.write(`
35
+ if (${C}.issues.length) {
36
+ if (${w} in input) {
37
+ payload.issues = payload.issues.concat(${C}.issues.map(iss => ({
38
+ ...iss,
39
+ path: iss.path ? [${w}, ...iss.path] : [${w}]
40
+ })));
41
+ }
42
+ }
43
+
44
+ if (${C}.value === undefined) {
45
+ if (${w} in input) {
46
+ newResult[${w}] = undefined;
47
+ }
48
+ } else {
49
+ newResult[${w}] = ${C}.value;
50
+ }
51
+
52
+ `):h.write(`
53
+ if (${C}.issues.length) {
54
+ payload.issues = payload.issues.concat(${C}.issues.map(iss => ({
55
+ ...iss,
56
+ path: iss.path ? [${w}, ...iss.path] : [${w}]
57
+ })));
58
+ }
59
+
60
+ if (${C}.value === undefined) {
61
+ if (${w} in input) {
62
+ newResult[${w}] = undefined;
63
+ }
64
+ } else {
65
+ newResult[${w}] = ${C}.value;
66
+ }
67
+
68
+ `)}h.write("payload.value = newResult;"),h.write("return payload;");const _=h.compile();return(z,C)=>_(p,z,C)};let s;const a=Wr,o=!Op.jitless,c=o&&C1.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 wu(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=>!qn(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=>fn(a,r,dn())))}),t)}const Xp=U("$ZodUnion",(e,t)=>{Ve.init(e,t),Ie(e._zod,"optin",()=>t.options.some(i=>i._zod.optin==="optional")?"optional":void 0),Ie(e._zod,"optout",()=>t.options.some(i=>i._zod.optout==="optional")?"optional":void 0),Ie(e._zod,"values",()=>{if(t.options.every(i=>i._zod.values))return new Set(t.options.flatMap(i=>Array.from(i._zod.values)))}),Ie(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=>Eo(s.source)).join("|")})$`)}});const n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(i,s)=>{if(n)return r(i,s);let a=!1;const o=[];for(const l of t.options){const c=l._zod.run({value:i.value,issues:[]},s);if(c instanceof Promise)o.push(c),a=!0;else{if(c.issues.length===0)return c;o.push(c)}}return a?Promise.all(o).then(l=>wu(l,i,e,s)):wu(o,i,e,s)}}),mj=U("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Xp.init(e,t);const n=e._zod.parse;Ie(e._zod,"propValues",()=>{const i={};for(const s of t.options){const a=s._zod.propValues;if(!a||Object.keys(a).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(const[o,l]of Object.entries(a)){i[o]||(i[o]=new Set);for(const c of l)i[o].add(c)}}return i});const r=ws(()=>{var a;const i=t.options,s=new Map;for(const o of i){const l=(a=o._zod.propValues)==null?void 0:a[t.discriminator];if(!l||l.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(o)}"`);for(const c of l){if(s.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);s.set(c,o)}}return s});e._zod.parse=(i,s)=>{const a=i.value;if(!Wr(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)}}),gj=U("$ZodIntersection",(e,t)=>{Ve.init(e,t),e._zod.parse=(n,r)=>{const i=n.value,s=t.left._zod.run({value:i,issues:[]},r),a=t.right._zod.run({value:i,issues:[]},r);return s instanceof Promise||a instanceof Promise?Promise.all([s,a]).then(([l,c])=>ku(n,l,c)):ku(n,s,a)}});function Da(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(ar(e)&&ar(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=Da(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=Da(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 ku(e,t,n){const r=new Map;let i;for(const o of t.issues)if(o.code==="unrecognized_keys"){i??(i=o);for(const l of o.keys)r.has(l)||r.set(l,{}),r.get(l).l=!0}else e.issues.push(o);for(const o of n.issues)if(o.code==="unrecognized_keys")for(const l of o.keys)r.has(l)||r.set(l,{}),r.get(l).r=!0;else e.issues.push(o);const s=[...r].filter(([,o])=>o.l&&o.r).map(([o])=>o);if(s.length&&i&&e.issues.push({...i,keys:s}),qn(e))return e;const a=Da(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 xj=U("$ZodRecord",(e,t)=>{Ve.init(e,t),e._zod.parse=(n,r)=>{const i=n.value;if(!ar(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(...Gn(c,d.issues)),n.value[c]=d.value})):(f.issues.length&&n.issues.push(...Gn(c,f.issues)),n.value[c]=f.value)}let l;for(const c in i)o.has(c)||(l=l??[],l.push(c));l&&l.length>0&&n.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:l})}else{n.value={};for(const o of Reflect.ownKeys(i)){if(o==="__proto__")continue;let l=t.keyType._zod.run({value:o,issues:[]},r);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof o=="string"&&Up.test(o)&&l.issues.length){const d=t.keyType._zod.run({value:Number(o),issues:[]},r);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");d.issues.length===0&&(l=d)}if(l.issues.length){t.mode==="loose"?n.value[o]=i[o]:n.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(d=>fn(d,r,dn())),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(...Gn(o,d.issues)),n.value[l.value]=d.value})):(f.issues.length&&n.issues.push(...Gn(o,f.issues)),n.value[l.value]=f.value)}}return s.length?Promise.all(s).then(()=>n):n}}),yj=U("$ZodEnum",(e,t)=>{Ve.init(e,t);const n=Dp(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(i=>E1.has(typeof i)).map(i=>typeof i=="string"?or(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}}),bj=U("$ZodLiteral",(e,t)=>{if(Ve.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"?or(r):r?or(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}}),vj=U("$ZodTransform",(e,t)=>{Ve.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 er;return n.value=i,n}});function Su(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const Qp=U("$ZodOptional",(e,t)=>{Ve.init(e,t),e._zod.optin="optional",e._zod.optout="optional",Ie(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Ie(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Eo(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=>Su(s,n.value)):Su(i,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,r)}}),wj=U("$ZodExactOptional",(e,t)=>{Qp.init(e,t),Ie(e._zod,"values",()=>t.innerType._zod.values),Ie(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),kj=U("$ZodNullable",(e,t)=>{Ve.init(e,t),Ie(e._zod,"optin",()=>t.innerType._zod.optin),Ie(e._zod,"optout",()=>t.innerType._zod.optout),Ie(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Eo(n.source)}|null)$`):void 0}),Ie(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)}),Sj=U("$ZodDefault",(e,t)=>{Ve.init(e,t),e._zod.optin="optional",Ie(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=>_u(s,t)):_u(i,t)}});function _u(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const _j=U("$ZodPrefault",(e,t)=>{Ve.init(e,t),e._zod.optin="optional",Ie(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))}),jj=U("$ZodNonOptional",(e,t)=>{Ve.init(e,t),Ie(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=>ju(s,e)):ju(i,e)}});function ju(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 Nj=U("$ZodCatch",(e,t)=>{Ve.init(e,t),Ie(e._zod,"optin",()=>t.innerType._zod.optin),Ie(e._zod,"optout",()=>t.innerType._zod.optout),Ie(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=>fn(a,r,dn()))},input:n.value}),n.issues=[]),n)):(n.value=i.value,i.issues.length&&(n.value=t.catchValue({...n,error:{issues:i.issues.map(s=>fn(s,r,dn()))},input:n.value}),n.issues=[]),n)}}),Cj=U("$ZodPipe",(e,t)=>{Ve.init(e,t),Ie(e._zod,"values",()=>t.in._zod.values),Ie(e._zod,"optin",()=>t.in._zod.optin),Ie(e._zod,"optout",()=>t.out._zod.optout),Ie(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=>xi(a,t.in,r)):xi(s,t.in,r)}const i=t.in._zod.run(n,r);return i instanceof Promise?i.then(s=>xi(s,t.out,r)):xi(i,t.out,r)}});function xi(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const Ej=U("$ZodReadonly",(e,t)=>{Ve.init(e,t),Ie(e._zod,"propValues",()=>t.innerType._zod.propValues),Ie(e._zod,"values",()=>t.innerType._zod.values),Ie(e._zod,"optin",()=>{var n,r;return(r=(n=t.innerType)==null?void 0:n._zod)==null?void 0:r.optin}),Ie(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(Nu):Nu(i)}});function Nu(e){return e.value=Object.freeze(e.value),e}const Ij=U("$ZodLazy",(e,t)=>{Ve.init(e,t),Ie(e._zod,"innerType",()=>t.getter()),Ie(e._zod,"pattern",()=>{var n,r;return(r=(n=e._zod.innerType)==null?void 0:n._zod)==null?void 0:r.pattern}),Ie(e._zod,"propValues",()=>{var n,r;return(r=(n=e._zod.innerType)==null?void 0:n._zod)==null?void 0:r.propValues}),Ie(e._zod,"optin",()=>{var n,r;return((r=(n=e._zod.innerType)==null?void 0:n._zod)==null?void 0:r.optin)??void 0}),Ie(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=U("$ZodCustom",(e,t)=>{vt.init(e,t),Ve.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(qr(i))}}var Eu;class Tj{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 Aj(){return new Tj}(Eu=globalThis).__zod_globalRegistry??(Eu.__zod_globalRegistry=Aj());const Cr=globalThis.__zod_globalRegistry;function Pj(e,t){return new e({type:"string",...fe(t)})}function Oj(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...fe(t)})}function Iu(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...fe(t)})}function Dj(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...fe(t)})}function Rj(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...fe(t)})}function Mj(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...fe(t)})}function $j(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...fe(t)})}function Fj(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...fe(t)})}function Lj(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...fe(t)})}function Zj(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...fe(t)})}function Bj(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...fe(t)})}function Vj(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...fe(t)})}function Uj(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...fe(t)})}function Jj(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...fe(t)})}function Hj(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...fe(t)})}function Wj(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...fe(t)})}function qj(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...fe(t)})}function Gj(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...fe(t)})}function Kj(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...fe(t)})}function Yj(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...fe(t)})}function Xj(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...fe(t)})}function Qj(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...fe(t)})}function eN(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...fe(t)})}function tN(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...fe(t)})}function nN(e,t){return new e({type:"string",format:"date",check:"string_format",...fe(t)})}function rN(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...fe(t)})}function iN(e,t){return new e({type:"string",format:"duration",check:"string_format",...fe(t)})}function sN(e,t){return new e({type:"number",checks:[],...fe(t)})}function aN(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...fe(t)})}function oN(e,t){return new e({type:"boolean",...fe(t)})}function lN(e,t){return new e({type:"null",...fe(t)})}function uN(e){return new e({type:"unknown"})}function cN(e,t){return new e({type:"never",...fe(t)})}function zu(e,t){return new Hp({check:"less_than",...fe(t),value:e,inclusive:!1})}function na(e,t){return new Hp({check:"less_than",...fe(t),value:e,inclusive:!0})}function Tu(e,t){return new Wp({check:"greater_than",...fe(t),value:e,inclusive:!1})}function ra(e,t){return new Wp({check:"greater_than",...fe(t),value:e,inclusive:!0})}function Au(e,t){return new k_({check:"multiple_of",...fe(t),value:e})}function eh(e,t){return new __({check:"max_length",...fe(t),maximum:e})}function Wi(e,t){return new j_({check:"min_length",...fe(t),minimum:e})}function th(e,t){return new N_({check:"length_equals",...fe(t),length:e})}function dN(e,t){return new C_({check:"string_format",format:"regex",...fe(t),pattern:e})}function fN(e){return new E_({check:"string_format",format:"lowercase",...fe(e)})}function pN(e){return new I_({check:"string_format",format:"uppercase",...fe(e)})}function hN(e,t){return new z_({check:"string_format",format:"includes",...fe(t),includes:e})}function mN(e,t){return new T_({check:"string_format",format:"starts_with",...fe(t),prefix:e})}function gN(e,t){return new A_({check:"string_format",format:"ends_with",...fe(t),suffix:e})}function fr(e){return new P_({check:"overwrite",tx:e})}function xN(e){return fr(t=>t.normalize(e))}function yN(){return fr(e=>e.trim())}function bN(){return fr(e=>e.toLowerCase())}function vN(){return fr(e=>e.toUpperCase())}function wN(){return fr(e=>N1(e))}function kN(e,t,n){return new e({type:"array",element:t,...fe(n)})}function SN(e,t,n){const r=fe(n);return r.abort??(r.abort=!0),new e({type:"custom",check:"custom",fn:t,...r})}function _N(e,t,n){return new e({type:"custom",check:"custom",fn:t,...fe(n)})}function jN(e){const t=NN(n=>(n.addIssue=r=>{if(typeof r=="string")n.issues.push(qr(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(qr(i))}},e(n.value,n)));return t}function NN(e,t){const n=new vt({check:"custom",...fe(t)});return n._zod.check=e,n}function qi(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)??Cr,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 Le(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),Le(h,t,p),t.seen.get(h).isParent=!0)}const l=t.metadataRegistry.get(e);return l&&Object.assign(a.schema,l),t.io==="input"&&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 Gi(e,t){var a,o,l,c;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const f of e.seen.entries()){const d=(a=e.metadataRegistry.get(f[0]))==null?void 0:a.id;if(d){const p=r.get(d);if(p&&p!==f[0])throw new Error(`Duplicate schema id "${d}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(d,f[0])}}const i=f=>{var v;const d=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const S=(v=e.external.registry.get(f[0]))==null?void 0:v.id,y=e.external.uri??(g=>g);if(S)return{ref:y(S)};const _=f[1].defId??f[1].schema.id??`schema${e.counter++}`;return f[1].defId=_,{defId:_,ref:`${y("__shared")}#/${d}/${_}`}}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=(l=e.external.registry.get(f[0]))==null?void 0:l.id;if(t!==f[0]&&h){s(f);continue}}if((c=e.metadataRegistry.get(f[0]))==null?void 0:c.id){s(f);continue}if(d.cycle){s(f);continue}if(d.count>1&&e.reused==="ref"){s(f);continue}}}function Ki(e,t){var a,o,l;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=c=>{const f=e.seen.get(c);if(f.ref===null)return;const d=f.def??f.schema,p={...d},h=f.ref;if(f.ref=null,h){r(h);const v=e.seen.get(h),S=v.schema;if(S.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(d.allOf=d.allOf??[],d.allOf.push(S)):Object.assign(d,S),Object.assign(d,p),c._zod.parent===h)for(const _ in d)_==="$ref"||_==="allOf"||_ in p||delete d[_];if(S.$ref&&v.def)for(const _ in d)_==="$ref"||_==="allOf"||_ in v.def&&JSON.stringify(d[_])===JSON.stringify(v.def[_])&&delete d[_]}const 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=((l=e.external)==null?void 0:l.defs)??{};for(const c of e.seen.entries()){const f=c[1];f.def&&f.defId&&(s[f.defId]=f.def)}e.external||Object.keys(s).length>0&&(e.target==="draft-2020-12"?i.$defs=s:i.definitions=s);try{const c=JSON.parse(JSON.stringify(i));return Object.defineProperty(c,"~standard",{value:{...t["~standard"],jsonSchema:{input:Yi(t,"input",e.processors),output:Yi(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 CN=(e,t={})=>n=>{const r=qi({...n,processors:t});return Le(e,r),Gi(r,e),Ki(r,e)},Yi=(e,t,n={})=>r=>{const{libraryOptions:i,target:s}=r??{},a=qi({...i??{},target:s,io:t,processors:n});return Le(e,a),Gi(a,e),Ki(a,e)},EN={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:l,contentEncoding:c}=e._zod.bag;if(typeof s=="number"&&(i.minLength=s),typeof a=="number"&&(i.maxLength=a),o&&(i.format=EN[o]??o,i.format===""&&delete i.format,o==="time"&&delete i.format),c&&(i.contentEncoding=c),l&&l.size>0){const f=[...l];f.length===1?i.pattern=f[0].source:f.length>1&&(i.allOf=[...f.map(d=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:d.source}))])}},rh=(e,t,n,r)=>{const i=n,{minimum:s,maximum:a,format:o,multipleOf:l,exclusiveMaximum:c,exclusiveMinimum:f}=e._zod.bag;typeof o=="string"&&o.includes("int")?i.type="integer":i.type="number",typeof f=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(i.minimum=f,i.exclusiveMinimum=!0):i.exclusiveMinimum=f),typeof s=="number"&&(i.minimum=s,typeof f=="number"&&t.target!=="draft-04"&&(f>=s?delete i.minimum:delete i.exclusiveMinimum)),typeof c=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(i.maximum=c,i.exclusiveMaximum=!0):i.exclusiveMaximum=c),typeof a=="number"&&(i.maximum=a,typeof c=="number"&&t.target!=="draft-04"&&(c<=a?delete i.maximum:delete i.exclusiveMaximum)),typeof l=="number"&&(i.multipleOf=l)},ih=(e,t,n,r)=>{n.type="boolean"},IN=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema")},zN=(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"},TN=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},AN=(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={}},PN=(e,t,n,r)=>{},oh=(e,t,n,r)=>{},ON=(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},DN=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema")},RN=(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},MN=(e,t,n,r)=>{const i=n,s={type:"string",format:"binary",contentEncoding:"binary"},{minimum:a,maximum:o,mime:l}=e._zod.bag;a!==void 0&&(s.minLength=a),o!==void 0&&(s.maxLength=o),l?l.length===1?(s.contentMediaType=l[0],Object.assign(i,s)):(Object.assign(i,s),i.anyOf=l.map(c=>({contentMediaType:c}))):Object.assign(i,s)},$N=(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")},FN=(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")},LN=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema")},ZN=(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=Le(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]=Le(a[f],t,{...r,path:[...r.path,"properties",f]});const o=new Set(Object.keys(a)),l=new Set([...o].filter(f=>{const d=s.shape[f]._zod;return t.io==="input"?d.optin===void 0:d.optout===void 0}));l.size>0&&(i.required=Array.from(l)),((c=s.catchall)==null?void 0:c._zod.def.type)==="never"?i.additionalProperties=!1:s.catchall?s.catchall&&(i.additionalProperties=Le(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,l)=>Le(o,t,{...r,path:[...r.path,s?"oneOf":"anyOf",l]}));s?n.oneOf=a:n.anyOf=a},mh=(e,t,n,r)=>{const i=e._zod.def,s=Le(i.left,t,{...r,path:[...r.path,"allOf",0]}),a=Le(i.right,t,{...r,path:[...r.path,"allOf",1]}),o=c=>"allOf"in c&&Object.keys(c).length===1,l=[...o(s)?s.allOf:[s],...o(a)?a.allOf:[a]];n.allOf=l},BN=(e,t,n,r)=>{const i=n,s=e._zod.def;i.type="array";const a=t.target==="draft-2020-12"?"prefixItems":"items",o=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",l=s.items.map((p,h)=>Le(p,t,{...r,path:[...r.path,a,h]})),c=s.rest?Le(s.rest,t,{...r,path:[...r.path,o,...t.target==="openapi-3.0"?[s.items.length]:[]]}):null;t.target==="draft-2020-12"?(i.prefixItems=l,c&&(i.items=c)):t.target==="openapi-3.0"?(i.items={anyOf:l},c&&i.items.anyOf.push(c),i.minItems=l.length,c||(i.maxItems=l.length)):(i.items=l,c&&(i.additionalItems=c));const{minimum:f,maximum:d}=e._zod.bag;typeof f=="number"&&(i.minItems=f),typeof d=="number"&&(i.maxItems=d)},gh=(e,t,n,r)=>{const i=n,s=e._zod.def;i.type="object";const a=s.keyType,o=a._zod.bag,l=o==null?void 0:o.patterns;if(s.mode==="loose"&&l&&l.size>0){const f=Le(s.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});i.patternProperties={};for(const d of l)i.patternProperties[d.source]=f}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(i.propertyNames=Le(s.keyType,t,{...r,path:[...r.path,"propertyNames"]})),i.additionalProperties=Le(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=Le(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;Le(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType},bh=(e,t,n,r)=>{const i=e._zod.def;Le(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;Le(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;Le(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;Le(s,t,r);const a=t.seen.get(e);a.ref=s},Sh=(e,t,n,r)=>{const i=e._zod.def;Le(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType,n.readOnly=!0},VN=(e,t,n,r)=>{const i=e._zod.def;Le(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType},Po=(e,t,n,r)=>{const i=e._zod.def;Le(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType},_h=(e,t,n,r)=>{const i=e._zod.innerType;Le(i,t,r);const s=t.seen.get(e);s.ref=i},Pu={string:nh,number:rh,boolean:ih,bigint:IN,symbol:zN,null:sh,undefined:TN,void:AN,never:ah,any:PN,unknown:oh,date:ON,enum:lh,literal:uh,nan:DN,template_literal:RN,file:MN,success:$N,custom:ch,function:FN,transform:dh,map:LN,set:ZN,array:fh,object:ph,union:hh,intersection:mh,tuple:BN,record:gh,nullable:xh,nonoptional:yh,default:bh,prefault:vh,catch:wh,pipe:kh,readonly:Sh,promise:VN,optional:Po,lazy:_h};function UN(e,t){if("_idmap"in e){const r=e,i=qi({...t,processors:Pu}),s={};for(const l of r._idmap.entries()){const[c,f]=l;Le(f,i)}const a={},o={registry:r,uri:t==null?void 0:t.uri,defs:s};i.external=o;for(const l of r._idmap.entries()){const[c,f]=l;Gi(i,f),a[c]=Ki(i,f)}if(Object.keys(s).length>0){const l=i.target==="draft-2020-12"?"$defs":"definitions";a.__shared={[l]:s}}return{schemas:a}}const n=qi({...t,processors:Pu});return Le(e,n),Gi(n,e),Ki(n,e)}const JN=U("ZodISODateTime",(e,t)=>{W_.init(e,t),He.init(e,t)});function HN(e){return tN(JN,e)}const WN=U("ZodISODate",(e,t)=>{q_.init(e,t),He.init(e,t)});function qN(e){return nN(WN,e)}const GN=U("ZodISOTime",(e,t)=>{G_.init(e,t),He.init(e,t)});function KN(e){return rN(GN,e)}const YN=U("ZodISODuration",(e,t)=>{K_.init(e,t),He.init(e,t)});function XN(e){return iN(YN,e)}const QN=(e,t)=>{Fp.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>F1(e,n)},flatten:{value:n=>$1(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,Oa,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,Oa,2)}},isEmpty:{get(){return e.issues.length===0}}})},zt=U("ZodError",QN,{Parent:Error}),eC=zo(zt),tC=To(zt),nC=ks(zt),jh=Ss(zt),rC=B1(zt),iC=V1(zt),sC=U1(zt),aC=J1(zt),oC=H1(zt),lC=W1(zt),uC=q1(zt),cC=G1(zt),Ue=U("ZodType",(e,t)=>(Ve.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Yi(e,"input"),output:Yi(e,"output")}}),e.toJSONSchema=CN(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(hn(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)=>mn(e,n,r),e.brand=()=>e,e.register=(n,r)=>(n.add(e,r),e),e.parse=(n,r)=>eC(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>nC(e,n,r),e.parseAsync=async(n,r)=>tC(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>jh(e,n,r),e.spa=e.safeParseAsync,e.encode=(n,r)=>rC(e,n,r),e.decode=(n,r)=>iC(e,n,r),e.encodeAsync=async(n,r)=>sC(e,n,r),e.decodeAsync=async(n,r)=>aC(e,n,r),e.safeEncode=(n,r)=>oC(e,n,r),e.safeDecode=(n,r)=>lC(e,n,r),e.safeEncodeAsync=async(n,r)=>uC(e,n,r),e.safeDecodeAsync=async(n,r)=>cC(e,n,r),e.refine=(n,r)=>e.check(aE(n,r)),e.superRefine=n=>e.check(oE(n)),e.overwrite=n=>e.check(fr(n)),e.optional=()=>Ru(e),e.exactOptional=()=>HC(e),e.nullable=()=>Mu(e),e.nullish=()=>Ru(Mu(e)),e.nonoptional=n=>XC(e,n),e.array=()=>pr(e),e.or=n=>ft([e,n]),e.and=n=>LC(e,n),e.transform=n=>$u(e,UC(n)),e.default=n=>GC(e,n),e.prefault=n=>YC(e,n),e.catch=n=>eE(e,n),e.pipe=n=>$u(e,n),e.readonly=()=>rE(e),e.describe=n=>{const r=e.clone();return Cr.add(r,{description:n}),r},Object.defineProperty(e,"description",{get(){var n;return(n=Cr.get(e))==null?void 0:n.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return Cr.get(e);const r=e.clone();return Cr.add(r,n[0]),r},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=n=>n(e),e)),Nh=U("_ZodString",(e,t)=>{Ao.init(e,t),Ue.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(dN(...r)),e.includes=(...r)=>e.check(hN(...r)),e.startsWith=(...r)=>e.check(mN(...r)),e.endsWith=(...r)=>e.check(gN(...r)),e.min=(...r)=>e.check(Wi(...r)),e.max=(...r)=>e.check(eh(...r)),e.length=(...r)=>e.check(th(...r)),e.nonempty=(...r)=>e.check(Wi(1,...r)),e.lowercase=r=>e.check(fN(r)),e.uppercase=r=>e.check(pN(r)),e.trim=()=>e.check(yN()),e.normalize=(...r)=>e.check(xN(...r)),e.toLowerCase=()=>e.check(bN()),e.toUpperCase=()=>e.check(vN()),e.slugify=()=>e.check(wN())}),dC=U("ZodString",(e,t)=>{Ao.init(e,t),Nh.init(e,t),e.email=n=>e.check(Oj(fC,n)),e.url=n=>e.check(Fj(pC,n)),e.jwt=n=>e.check(eN(EC,n)),e.emoji=n=>e.check(Lj(hC,n)),e.guid=n=>e.check(Iu(Ou,n)),e.uuid=n=>e.check(Dj(yi,n)),e.uuidv4=n=>e.check(Rj(yi,n)),e.uuidv6=n=>e.check(Mj(yi,n)),e.uuidv7=n=>e.check($j(yi,n)),e.nanoid=n=>e.check(Zj(mC,n)),e.guid=n=>e.check(Iu(Ou,n)),e.cuid=n=>e.check(Bj(gC,n)),e.cuid2=n=>e.check(Vj(xC,n)),e.ulid=n=>e.check(Uj(yC,n)),e.base64=n=>e.check(Yj(jC,n)),e.base64url=n=>e.check(Xj(NC,n)),e.xid=n=>e.check(Jj(bC,n)),e.ksuid=n=>e.check(Hj(vC,n)),e.ipv4=n=>e.check(Wj(wC,n)),e.ipv6=n=>e.check(qj(kC,n)),e.cidrv4=n=>e.check(Gj(SC,n)),e.cidrv6=n=>e.check(Kj(_C,n)),e.e164=n=>e.check(Qj(CC,n)),e.datetime=n=>e.check(HN(n)),e.date=n=>e.check(qN(n)),e.time=n=>e.check(KN(n)),e.duration=n=>e.check(XN(n))});function oe(e){return Pj(dC,e)}const He=U("ZodStringFormat",(e,t)=>{Je.init(e,t),Nh.init(e,t)}),fC=U("ZodEmail",(e,t)=>{$_.init(e,t),He.init(e,t)}),Ou=U("ZodGUID",(e,t)=>{R_.init(e,t),He.init(e,t)}),yi=U("ZodUUID",(e,t)=>{M_.init(e,t),He.init(e,t)}),pC=U("ZodURL",(e,t)=>{F_.init(e,t),He.init(e,t)}),hC=U("ZodEmoji",(e,t)=>{L_.init(e,t),He.init(e,t)}),mC=U("ZodNanoID",(e,t)=>{Z_.init(e,t),He.init(e,t)}),gC=U("ZodCUID",(e,t)=>{B_.init(e,t),He.init(e,t)}),xC=U("ZodCUID2",(e,t)=>{V_.init(e,t),He.init(e,t)}),yC=U("ZodULID",(e,t)=>{U_.init(e,t),He.init(e,t)}),bC=U("ZodXID",(e,t)=>{J_.init(e,t),He.init(e,t)}),vC=U("ZodKSUID",(e,t)=>{H_.init(e,t),He.init(e,t)}),wC=U("ZodIPv4",(e,t)=>{Y_.init(e,t),He.init(e,t)}),kC=U("ZodIPv6",(e,t)=>{X_.init(e,t),He.init(e,t)}),SC=U("ZodCIDRv4",(e,t)=>{Q_.init(e,t),He.init(e,t)}),_C=U("ZodCIDRv6",(e,t)=>{ej.init(e,t),He.init(e,t)}),jC=U("ZodBase64",(e,t)=>{tj.init(e,t),He.init(e,t)}),NC=U("ZodBase64URL",(e,t)=>{rj.init(e,t),He.init(e,t)}),CC=U("ZodE164",(e,t)=>{ij.init(e,t),He.init(e,t)}),EC=U("ZodJWT",(e,t)=>{aj.init(e,t),He.init(e,t)}),Ch=U("ZodNumber",(e,t)=>{Gp.init(e,t),Ue.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(zu(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(Du(r)),e.safe=r=>e.check(Du(r)),e.positive=r=>e.check(Tu(0,r)),e.nonnegative=r=>e.check(ra(0,r)),e.negative=r=>e.check(zu(0,r)),e.nonpositive=r=>e.check(na(0,r)),e.multipleOf=(r,i)=>e.check(Au(r,i)),e.step=(r,i)=>e.check(Au(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 IC(e){return sN(Ch,e)}const zC=U("ZodNumberFormat",(e,t)=>{oj.init(e,t),Ch.init(e,t)});function Du(e){return aN(zC,e)}const TC=U("ZodBoolean",(e,t)=>{lj.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ih(e,n,r)});function ut(e){return oN(TC,e)}const AC=U("ZodNull",(e,t)=>{uj.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(n,r,i)=>sh(e,n,r)});function PC(e){return lN(AC,e)}const OC=U("ZodUnknown",(e,t)=>{cj.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(n,r,i)=>oh()});function Lt(){return uN(OC)}const DC=U("ZodNever",(e,t)=>{dj.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ah(e,n,r)});function Eh(e){return cN(DC,e)}const RC=U("ZodArray",(e,t)=>{fj.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(n,r,i)=>fh(e,n,r,i),e.element=t.element,e.min=(n,r)=>e.check(Wi(n,r)),e.nonempty=n=>e.check(Wi(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 pr(e,t){return kN(RC,e,t)}const Ih=U("ZodObject",(e,t)=>{hj.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ph(e,n,r,i),Ie(e,"shape",()=>t.shape),e.keyof=()=>Th(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Lt()}),e.loose=()=>e.clone({...e._zod.def,catchall:Lt()}),e.strict=()=>e.clone({...e._zod.def,catchall:Eh()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>P1(e,n),e.safeExtend=n=>O1(e,n),e.merge=n=>D1(e,n),e.pick=n=>T1(e,n),e.omit=n=>A1(e,n),e.partial=(...n)=>R1(Ah,e,n[0]),e.required=(...n)=>M1(Ph,e,n[0])});function Re(e,t){const n={type:"object",shape:e??{},...fe(t)};return new Ih(n)}function Ze(e,t){return new Ih({type:"object",shape:e,catchall:Eh(),...fe(t)})}const zh=U("ZodUnion",(e,t)=>{Xp.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(n,r,i)=>hh(e,n,r,i),e.options=t.options});function ft(e,t){return new zh({type:"union",options:e,...fe(t)})}const MC=U("ZodDiscriminatedUnion",(e,t)=>{zh.init(e,t),mj.init(e,t)});function $C(e,t,n){return new MC({type:"union",options:t,discriminator:e,...fe(n)})}const FC=U("ZodIntersection",(e,t)=>{gj.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(n,r,i)=>mh(e,n,r,i)});function LC(e,t){return new FC({type:"intersection",left:e,right:t})}const ZC=U("ZodRecord",(e,t)=>{xj.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(n,r,i)=>gh(e,n,r,i),e.keyType=t.keyType,e.valueType=t.valueType});function Gr(e,t,n){return new ZC({type:"record",keyType:e,valueType:t,...fe(n)})}const Ra=U("ZodEnum",(e,t)=>{yj.init(e,t),Ue.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 Ra({...t,checks:[],...fe(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 Ra({...t,checks:[],...fe(i),entries:s})}});function Th(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new Ra({type:"enum",entries:n,...fe(t)})}const BC=U("ZodLiteral",(e,t)=>{bj.init(e,t),Ue.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 ye(e,t){return new BC({type:"literal",values:Array.isArray(e)?e:[e],...fe(t)})}const VC=U("ZodTransform",(e,t)=>{vj.init(e,t),Ue.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(qr(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(qr(a))}};const i=t.transform(n.value,n);return i instanceof Promise?i.then(s=>(n.value=s,n)):(n.value=i,n)}});function UC(e){return new VC({type:"transform",transform:e})}const Ah=U("ZodOptional",(e,t)=>{Qp.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Po(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function Ru(e){return new Ah({type:"optional",innerType:e})}const JC=U("ZodExactOptional",(e,t)=>{wj.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Po(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function HC(e){return new JC({type:"optional",innerType:e})}const WC=U("ZodNullable",(e,t)=>{kj.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(n,r,i)=>xh(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function Mu(e){return new WC({type:"nullable",innerType:e})}const qC=U("ZodDefault",(e,t)=>{Sj.init(e,t),Ue.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 GC(e,t){return new qC({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Mp(t)}})}const KC=U("ZodPrefault",(e,t)=>{_j.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(n,r,i)=>vh(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function YC(e,t){return new KC({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Mp(t)}})}const Ph=U("ZodNonOptional",(e,t)=>{jj.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(n,r,i)=>yh(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function XC(e,t){return new Ph({type:"nonoptional",innerType:e,...fe(t)})}const QC=U("ZodCatch",(e,t)=>{Nj.init(e,t),Ue.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 eE(e,t){return new QC({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const tE=U("ZodPipe",(e,t)=>{Cj.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(n,r,i)=>kh(e,n,r,i),e.in=t.in,e.out=t.out});function $u(e,t){return new tE({type:"pipe",in:e,out:t})}const nE=U("ZodReadonly",(e,t)=>{Ej.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Sh(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function rE(e){return new nE({type:"readonly",innerType:e})}const iE=U("ZodLazy",(e,t)=>{Ij.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(n,r,i)=>_h(e,n,r,i),e.unwrap=()=>e._zod.def.getter()});function sE(e){return new iE({type:"lazy",getter:e})}const Oo=U("ZodCustom",(e,t)=>{zj.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ch(e,n)});function Oh(e,t){return SN(Oo,e??(()=>!0),t)}function aE(e,t={}){return _N(Oo,e,t)}function oE(e){return jN(e)}function Xi(e,t={}){const n=new Oo({type:"custom",check:"custom",fn:r=>r instanceof e,abort:!0,...fe(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 Kr;(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})(Kr||(Kr={}));var Fu;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(Fu||(Fu={}));Kr.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]);Kr.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 Qi extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=t}format(t){const n=t||function(s){return s.message},r={_errors:[]},i=s=>{for(const a of s.issues)if(a.code==="invalid_union")a.unionErrors.map(i);else if(a.code==="invalid_return_type")i(a.returnTypeError);else if(a.code==="invalid_arguments")i(a.argumentsError);else if(a.path.length===0)r._errors.push(n(a));else{let o=r,l=0;for(;l<a.path.length;){const c=a.path[l];l===a.path.length-1?(o[c]=o[c]||{_errors:[]},o[c]._errors.push(n(a))):o[c]=o[c]||{_errors:[]},o=o[c],l++}}};return i(this),r}static assert(t){if(!(t instanceof Qi))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Kr.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()}}Qi.create=e=>new Qi(e);var Lu;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})(Lu||(Lu={}));var be;(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"})(be||(be={}));class Zu 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 lE(e){if(typeof e=="function")throw new TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");const{onEvent:t=ia,onError:n=ia,onRetry:r=ia,onComment:i}=e;let s="",a=!0,o,l="",c="";function f(v){const S=a?v.replace(/^\xEF\xBB\xBF/,""):v,[y,_]=uE(`${s}${S}`);for(const g of y)d(g);s=_,a=!1}function d(v){if(v===""){h();return}if(v.startsWith(":")){i&&i(v.slice(v.startsWith(": ")?2:1));return}const S=v.indexOf(":");if(S!==-1){const y=v.slice(0,S),_=v[S+1]===" "?2:1,g=v.slice(S+_);p(y,g,v);return}p(v,"",v)}function p(v,S,y){switch(v){case"event":c=S;break;case"data":l=`${l}${S}
71
+ `;break;case"id":o=S.includes("\0")?void 0:S;break;case"retry":/^\d+$/.test(S)?r(parseInt(S,10)):n(new Zu(`Invalid \`retry\` value: "${S}"`,{type:"invalid-retry",value:S,line:y}));break;default:n(new Zu(`Unknown field "${v.length>20?`${v.slice(0,20)}…`:v}"`,{type:"unknown-field",field:v,value:S,line:y}));break}}function h(){l.length>0&&t({id:o,event:c||void 0,data:l.endsWith(`
72
+ `)?l.slice(0,-1):l}),o=void 0,l="",c=""}function m(v={}){s&&v.consume&&d(s),a=!0,o=void 0,l="",c="",s=""}return{feed:f,reset:m}}function uE(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 cE extends TransformStream{constructor({onError:t,onRetry:n,onComment:r}={}){let i;super({start(s){i=lE({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 si=({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 k1({argument:"separator",message:`The separator "${r}" must not be part of the alphabet "${n}".`});return()=>`${e}${r}${i()}`},dE=si();function Ln(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 fE=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,pE=/"(?: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 Bu(e){const t=JSON.parse(e);return t===null||typeof t!="object"||fE.test(e)===!1&&pE.test(e)===!1?t:hE(t)}function hE(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 mE(e){const{stackTraceLimit:t}=Error;try{Error.stackTraceLimit=0}catch{return Bu(e)}try{return Bu(e)}finally{Error.stackTraceLimit=t}}function Do(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]=yn(n[r])}e.items!=null&&(e.items=Array.isArray(e.items)?e.items.map(yn):yn(e.items)),e.anyOf!=null&&(e.anyOf=e.anyOf.map(yn)),e.allOf!=null&&(e.allOf=e.allOf.map(yn)),e.oneOf!=null&&(e.oneOf=e.oneOf.map(yn));const{definitions:t}=e;if(t!=null)for(const n of Object.keys(t))t[n]=yn(t[n]);return e}function yn(e){return typeof e=="boolean"?e:Do(e)}var gE=Symbol("Let zodToJsonSchema decide on which parser to use"),Vu={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"},xE=e=>typeof e=="string"?{...Vu,name:e}:{...Vu,...e};function jt(){return{}}function yE(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)!==be.ZodAny&&(s.items=Pe(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 bE(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 vE(){return{type:"boolean"}}function Dh(e,t){return Pe(e.type._def,t)}var wE=(e,t)=>Pe(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 kE(e)}}var kE=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 SE(e,t){return{...Pe(e.innerType._def,t),default:e.defaultValue()}}function _E(e,t){return t.effectStrategy==="input"?Pe(e.schema._def,t):jt()}function jE(e){return{type:"string",enum:Array.from(e.values)}}var NE=e=>"type"in e&&e.type==="string"?!1:"allOf"in e;function CE(e,t){const n=[Pe(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),Pe(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(i=>!!i),r=[];return n.forEach(i=>{if(NE(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 EE(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,Tt={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,Tt.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,Tt.cuid,r.message,t);break;case"cuid2":ot(n,Tt.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,Tt.base64url,r.message,t);break;case"jwt":ot(n,Tt.jwt,r.message,t);break;case"cidr":{r.version!=="v6"&&ot(n,Tt.ipv4Cidr,r.message,t),r.version!=="v4"&&ot(n,Tt.ipv6Cidr,r.message,t);break}case"emoji":ot(n,Tt.emoji(),r.message,t);break;case"ulid":{ot(n,Tt.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,Tt.base64,r.message,t);break}}break}case"nanoid":ot(n,Tt.nanoid,r.message,t)}return n}function aa(e,t){return t.patternStrategy==="escape"?zE(e):e}var IE=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function zE(e){let t="";for(let n=0;n<e.length;n++)IE.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:Uu(t,r),...n&&r.errorMessages&&{errorMessage:{pattern:n}}})):e.pattern=Uu(t,r)}function Uu(e,t){var n;if(!t.applyRegexFlags||!e.flags)return e.source;const r={i:e.flags.includes("i"),m:e.flags.includes("m"),s:e.flags.includes("s")},i=r.i?e.source.toLowerCase():e.source;let s="",a=!1,o=!1,l=!1;for(let c=0;c<i.length;c++){if(a){s+=i[c],a=!1;continue}if(r.i){if(o){if(i[c].match(/[a-z]/)){l?(s+=i[c],s+=`${i[c-2]}-${i[c]}`.toUpperCase(),l=!1):i[c+1]==="-"&&((n=i[c+2])!=null&&n.match(/[a-z]/))?(s+=i[c],l=!0):s+=`${i[c]}${i[c].toUpperCase()}`;continue}}else if(i[c].match(/[a-z]/)){s+=`[${i[c]}${i[c].toUpperCase()}]`;continue}}if(r.m){if(i[c]==="^"){s+=`(^|(?<=[\r
75
+ ]))`;continue}else if(i[c]==="$"){s+=`($|(?=[\r
76
+ ]))`;continue}}if(r.s&&i[c]==="."){s+=o?`${i[c]}\r
77
+ `:`[${i[c]}\r
78
+ ]`;continue}s+=i[c],i[c]==="\\"?a=!0:o&&i[c]==="]"?o=!1:!o&&i[c]==="["&&(o=!0)}try{new RegExp(s)}catch{return console.warn(`Could not convert regex pattern at ${t.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),e.source}return s}function $h(e,t){var n,r,i,s,a,o;const l={type:"object",additionalProperties:(n=Pe(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]}))!=null?n:t.allowedAdditionalProperties};if(((r=e.keyType)==null?void 0:r._def.typeName)===be.ZodString&&((i=e.keyType._def.checks)!=null&&i.length)){const{type:c,...f}=Mh(e.keyType._def,t);return{...l,propertyNames:f}}else{if(((s=e.keyType)==null?void 0:s._def.typeName)===be.ZodEnum)return{...l,propertyNames:{enum:e.keyType._def.values}};if(((a=e.keyType)==null?void 0:a._def.typeName)===be.ZodBranded&&e.keyType._def.type._def.typeName===be.ZodString&&((o=e.keyType._def.type._def.checks)!=null&&o.length)){const{type:c,...f}=Dh(e.keyType._def,t);return{...l,propertyNames:f}}}return l}function TE(e,t){if(t.mapStrategy==="record")return $h(e,t);const n=Pe(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||jt(),r=Pe(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||jt();return{type:"array",maxItems:125,items:{type:"array",items:[n,r],minItems:2,maxItems:2}}}function AE(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 PE(){return{not:jt()}}function OE(){return{type:"null"}}var Ma={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function DE(e,t){const n=e.options instanceof Map?Array.from(e.options.values()):e.options;if(n.every(r=>r._def.typeName in Ma&&(!r._def.checks||!r._def.checks.length))){const r=n.reduce((i,s)=>{const a=Ma[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 RE(e,t)}var RE=(e,t)=>{const n=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((r,i)=>Pe(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 ME(e,t){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return{type:[Ma[e.innerType._def.typeName],"null"]};const n=Pe(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return n&&{anyOf:[n,{type:"null"}]}}function $E(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 FE(e,t){const n={type:"object",properties:{}},r=[],i=e.shape();for(const a in i){let o=i[a];if(o===void 0||o._def===void 0)continue;const l=ZE(o),c=Pe(o._def,{...t,currentPath:[...t.currentPath,"properties",a],propertyPath:[...t.currentPath,"properties",a]});c!==void 0&&(n.properties[a]=c,l||r.push(a))}r.length&&(n.required=r);const s=LE(e,t);return s!==void 0&&(n.additionalProperties=s),n}function LE(e,t){if(e.catchall._def.typeName!=="ZodNever")return Pe(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 ZE(e){try{return e.isOptional()}catch{return!0}}var BE=(e,t)=>{var n;if(t.currentPath.toString()===((n=t.propertyPath)==null?void 0:n.toString()))return Pe(e.innerType._def,t);const r=Pe(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return r?{anyOf:[{not:jt()},r]}:jt()},VE=(e,t)=>{if(t.pipeStrategy==="input")return Pe(e.in._def,t);if(t.pipeStrategy==="output")return Pe(e.out._def,t);const n=Pe(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),r=Pe(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",n?"1":"0"]});return{allOf:[n,r].filter(i=>i!==void 0)}};function UE(e,t){return Pe(e.type._def,t)}function JE(e,t){const r={type:"array",uniqueItems:!0,items:Pe(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 HE(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((n,r)=>Pe(n._def,{...t,currentPath:[...t.currentPath,"items",`${r}`]})).reduce((n,r)=>r===void 0?n:[...n,r],[]),additionalItems:Pe(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((n,r)=>Pe(n._def,{...t,currentPath:[...t.currentPath,"items",`${r}`]})).reduce((n,r)=>r===void 0?n:[...n,r],[])}}function WE(){return{not:jt()}}function qE(){return jt()}var GE=(e,t)=>Pe(e.innerType._def,t),KE=(e,t,n)=>{switch(t){case be.ZodString:return Mh(e,n);case be.ZodNumber:return $E(e);case be.ZodObject:return FE(e,n);case be.ZodBigInt:return bE(e);case be.ZodBoolean:return vE();case be.ZodDate:return Rh(e,n);case be.ZodUndefined:return WE();case be.ZodNull:return OE();case be.ZodArray:return yE(e,n);case be.ZodUnion:case be.ZodDiscriminatedUnion:return DE(e,n);case be.ZodIntersection:return CE(e,n);case be.ZodTuple:return HE(e,n);case be.ZodRecord:return $h(e,n);case be.ZodLiteral:return EE(e);case be.ZodEnum:return jE(e);case be.ZodNativeEnum:return AE(e);case be.ZodNullable:return ME(e,n);case be.ZodOptional:return BE(e,n);case be.ZodMap:return TE(e,n);case be.ZodSet:return JE(e,n);case be.ZodLazy:return()=>e.getter()._def;case be.ZodPromise:return UE(e,n);case be.ZodNaN:case be.ZodNever:return PE();case be.ZodEffects:return _E(e,n);case be.ZodAny:return jt();case be.ZodUnknown:return qE();case be.ZodDefault:return SE(e,n);case be.ZodBranded:return Dh(e,n);case be.ZodReadonly:return GE(e,n);case be.ZodCatch:return wE(e,n);case be.ZodPipeline:return VE(e,n);case be.ZodFunction:case be.ZodVoid:case be.ZodSymbol:return;default:return(r=>{})()}},YE=(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 Pe(e,t,n=!1){var r;const i=t.seen.get(e);if(t.override){const l=(r=t.override)==null?void 0:r.call(t,e,t,i,n);if(l!==gE)return l}if(i&&!n){const l=XE(i,t);if(l!==void 0)return l}const s={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,s);const a=KE(e,e.typeName,t),o=typeof a=="function"?Pe(a(),t):a;if(o&&QE(e,t,o),t.postProcess){const l=t.postProcess(o,e,t);return s.jsonSchema=o,l}return s.jsonSchema=o,o}var XE=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:YE(t.currentPath,e.path)};case"none":case"seen":return e.path.length<t.currentPath.length&&e.path.every((n,r)=>t.currentPath[r]===n)?(console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),jt()):t.$refStrategy==="seen"?jt():void 0}},QE=(e,t,n)=>(e.description&&(n.description=e.description),n),eI=e=>{const t=xE(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}]))}},tI=(e,t)=>{var n;const r=eI(t);let i=typeof t=="object"&&t.definitions?Object.entries(t.definitions).reduce((c,[f,d])=>{var p;return{...c,[f]:(p=Pe(d._def,{...r,currentPath:[...r.basePath,r.definitionPath,f]},!0))!=null?p:jt()}},{}):void 0;const s=typeof t=="string"?t:(t==null?void 0:t.nameStrategy)==="title"||t==null?void 0:t.name,a=(n=Pe(e._def,s===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,s]},!1))!=null?n:jt(),o=typeof t=="object"&&t.name!==void 0&&t.nameStrategy==="title"?t.name:void 0;o!==void 0&&(a.title=o);const l=s===void 0?i?{...a,[r.definitionPath]:i}:a:{$ref:[...r.$refStrategy==="relative"?[]:r.basePath,r.definitionPath,s].join("/"),[r.definitionPath]:{...i,[s]:a}};return l.$schema="http://json-schema.org/draft-07/schema#",l},$a=Symbol.for("vercel.ai.schema");function nI(e){let t;return()=>(t==null&&(t=e()),t)}function js(e,{validate:t}={}){return{[$a]:!0,_type:void 0,get jsonSchema(){return typeof e=="function"&&(e=e()),e},validate:t}}function rI(e){return typeof e=="object"&&e!==null&&$a in e&&e[$a]===!0&&"jsonSchema"in e&&"validate"in e}function Ro(e){return e==null?js({properties:{},additionalProperties:!1}):rI(e)?e:"~standard"in e?e["~standard"].vendor==="zod"?Fh(e):iI(e):e()}function iI(e){return js(()=>Do(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 sr({value:t,cause:n.issues})}}})}function sI(e,t){var n;const r=(n=void 0)!=null?n:!1;return js(()=>tI(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 aI(e,t){var n;const r=(n=void 0)!=null?n:!1;return js(()=>Do(UN(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 oI(e){return"_zod"in e}function Fh(e,t){return oI(e)?aI(e):sI(e)}async function Ju({value:e,schema:t,context:n}){const r=await Yr({value:e,schema:t,context:n});if(!r.success)throw sr.wrap({value:e,cause:r.error,context:n});return r.value}async function Yr({value:e,schema:t,context:n}){const r=Ro(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:sr.wrap({value:e,cause:i.error,context:n}),rawValue:e}}catch(i){return{success:!1,error:sr.wrap({value:e,cause:i,context:n}),rawValue:e}}}async function Tn({text:e,schema:t}){try{const n=mE(e);return t==null?{success:!0,value:n,rawValue:n}:await Yr({value:n,schema:t})}catch(n){return{success:!1,error:hu.isInstance(n)?n:new hu({text:e,cause:n}),rawValue:void 0}}}function lI({stream:e,schema:t}){return e.pipeThrough(new TextDecoderStream).pipeThrough(new cE).pipeThrough(new TransformStream({async transform({data:n},r){n!=="[DONE]"&&r.enqueue(await Tn({text:n,schema:t}))}}))}async function rn(e){return typeof e=="function"&&(e=e()),Promise.resolve(e)}var uI=Object.defineProperty,cI=(e,t)=>{for(var n in t)uI(e,n,{get:t[n],enumerable:!0})},Lh="AI_NoObjectGeneratedError",Zh=`vercel.ai.error.${Lh}`,dI=Symbol.for(Zh),Bh,ln=class extends Ht{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 Ht.hasMarker(e,Zh)}};Bh=dI;var Vh="AI_UIMessageStreamError",Uh=`vercel.ai.error.${Vh}`,fI=Symbol.for(Uh),Jh,Zn=class extends Ht{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 Ht.hasMarker(e,Uh)}};Jh=fI;var Hh=ft([oe(),Xi(Uint8Array),Xi(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"})]),Xr=sE(()=>ft([PC(),oe(),IC(),ut(),Gr(oe(),Xr.optional()),pr(Xr)])),je=Gr(oe(),Gr(oe(),Xr.optional())),Wh=Re({type:ye("text"),text:oe(),providerOptions:je.optional()}),pI=Re({type:ye("image"),image:ft([Hh,Xi(URL)]),mediaType:oe().optional(),providerOptions:je.optional()}),qh=Re({type:ye("file"),data:ft([Hh,Xi(URL)]),filename:oe().optional(),mediaType:oe(),providerOptions:je.optional()}),hI=Re({type:ye("reasoning"),text:oe(),providerOptions:je.optional()}),mI=Re({type:ye("tool-call"),toolCallId:oe(),toolName:oe(),input:Lt(),providerOptions:je.optional(),providerExecuted:ut().optional()}),gI=$C("type",[Re({type:ye("text"),value:oe(),providerOptions:je.optional()}),Re({type:ye("json"),value:Xr,providerOptions:je.optional()}),Re({type:ye("execution-denied"),reason:oe().optional(),providerOptions:je.optional()}),Re({type:ye("error-text"),value:oe(),providerOptions:je.optional()}),Re({type:ye("error-json"),value:Xr,providerOptions:je.optional()}),Re({type:ye("content"),value:pr(ft([Re({type:ye("text"),text:oe(),providerOptions:je.optional()}),Re({type:ye("media"),data:oe(),mediaType:oe()}),Re({type:ye("file-data"),data:oe(),mediaType:oe(),filename:oe().optional(),providerOptions:je.optional()}),Re({type:ye("file-url"),url:oe(),providerOptions:je.optional()}),Re({type:ye("file-id"),fileId:ft([oe(),Gr(oe(),oe())]),providerOptions:je.optional()}),Re({type:ye("image-data"),data:oe(),mediaType:oe(),providerOptions:je.optional()}),Re({type:ye("image-url"),url:oe(),providerOptions:je.optional()}),Re({type:ye("image-file-id"),fileId:ft([oe(),Gr(oe(),oe())]),providerOptions:je.optional()}),Re({type:ye("custom"),providerOptions:je.optional()})]))})]),Gh=Re({type:ye("tool-result"),toolCallId:oe(),toolName:oe(),output:gI,providerOptions:je.optional()}),xI=Re({type:ye("tool-approval-request"),approvalId:oe(),toolCallId:oe()}),yI=Re({type:ye("tool-approval-response"),approvalId:oe(),approved:ut(),reason:oe().optional()}),bI=Re({role:ye("system"),content:oe(),providerOptions:je.optional()}),vI=Re({role:ye("user"),content:ft([oe(),pr(ft([Wh,pI,qh]))]),providerOptions:je.optional()}),wI=Re({role:ye("assistant"),content:ft([oe(),pr(ft([Wh,qh,hI,mI,Gh,xI]))]),providerOptions:je.optional()}),kI=Re({role:ye("tool"),content:pr(ft([Gh,yI])),providerOptions:je.optional()});ft([bI,vI,wI,kI]);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 SI={};cI(SI,{array:()=>CI,choice:()=>EI,json:()=>II,object:()=>NI,text:()=>jI});function _I(e){const t=["ROOT"];let n=-1,r=null;function i(l,c,f){switch(l){case'"':{n=c,t.pop(),t.push(f),t.push("INSIDE_STRING");break}case"f":case"t":case"n":{n=c,r=c,t.pop(),t.push(f),t.push("INSIDE_LITERAL");break}case"-":{t.pop(),t.push(f),t.push("INSIDE_NUMBER");break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{n=c,t.pop(),t.push(f),t.push("INSIDE_NUMBER");break}case"{":{n=c,t.pop(),t.push(f),t.push("INSIDE_OBJECT_START");break}case"[":{n=c,t.pop(),t.push(f),t.push("INSIDE_ARRAY_START");break}}}function s(l,c){switch(l){case",":{t.pop(),t.push("INSIDE_OBJECT_AFTER_COMMA");break}case"}":{n=c,t.pop();break}}}function a(l,c){switch(l){case",":{t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{n=c,t.pop();break}}}for(let l=0;l<e.length;l++){const c=e[l];switch(t[t.length-1]){case"ROOT":i(c,l,"FINISH");break;case"INSIDE_OBJECT_START":{switch(c){case'"':{t.pop(),t.push("INSIDE_OBJECT_KEY");break}case"}":{n=l,t.pop();break}}break}case"INSIDE_OBJECT_AFTER_COMMA":{switch(c){case'"':{t.pop(),t.push("INSIDE_OBJECT_KEY");break}}break}case"INSIDE_OBJECT_KEY":{switch(c){case'"':{t.pop(),t.push("INSIDE_OBJECT_AFTER_KEY");break}}break}case"INSIDE_OBJECT_AFTER_KEY":{switch(c){case":":{t.pop(),t.push("INSIDE_OBJECT_BEFORE_VALUE");break}}break}case"INSIDE_OBJECT_BEFORE_VALUE":{i(c,l,"INSIDE_OBJECT_AFTER_VALUE");break}case"INSIDE_OBJECT_AFTER_VALUE":{s(c,l);break}case"INSIDE_STRING":{switch(c){case'"':{t.pop(),n=l;break}case"\\":{t.push("INSIDE_STRING_ESCAPE");break}default:n=l}break}case"INSIDE_ARRAY_START":{switch(c){case"]":{n=l,t.pop();break}default:{n=l,i(c,l,"INSIDE_ARRAY_AFTER_VALUE");break}}break}case"INSIDE_ARRAY_AFTER_VALUE":{switch(c){case",":{t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{n=l,t.pop();break}default:{n=l;break}}break}case"INSIDE_ARRAY_AFTER_COMMA":{i(c,l,"INSIDE_ARRAY_AFTER_VALUE");break}case"INSIDE_STRING_ESCAPE":{t.pop(),n=l;break}case"INSIDE_NUMBER":{switch(c){case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{n=l;break}case"e":case"E":case"-":case".":break;case",":{t.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&a(c,l),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&s(c,l);break}case"}":{t.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&s(c,l);break}case"]":{t.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&a(c,l);break}default:{t.pop();break}}break}case"INSIDE_LITERAL":{const d=e.substring(r,l+1);!"false".startsWith(d)&&!"true".startsWith(d)&&!"null".startsWith(d)?(t.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"?s(c,l):t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&a(c,l)):n=l;break}}}let o=e.slice(0,n+1);for(let l=t.length-1;l>=0;l--)switch(t[l]){case"INSIDE_STRING":{o+='"';break}case"INSIDE_OBJECT_KEY":case"INSIDE_OBJECT_AFTER_KEY":case"INSIDE_OBJECT_AFTER_COMMA":case"INSIDE_OBJECT_START":case"INSIDE_OBJECT_BEFORE_VALUE":case"INSIDE_OBJECT_AFTER_VALUE":{o+="}";break}case"INSIDE_ARRAY_START":case"INSIDE_ARRAY_AFTER_COMMA":case"INSIDE_ARRAY_AFTER_VALUE":{o+="]";break}case"INSIDE_LITERAL":{const f=e.substring(r,e.length);"true".startsWith(f)?o+="true".slice(f.length):"false".startsWith(f)?o+="false".slice(f.length):"null".startsWith(f)&&(o+="null".slice(f.length))}}return o}async function ai(e){if(e===void 0)return{value:void 0,state:"undefined-input"};let t=await Tn({text:e});return t.success?{value:t.value,state:"successful-parse"}:(t=await Tn({text:_I(e)}),t.success?{value:t.value,state:"repaired-parse"}:{value:void 0,state:"failed-parse"})}var jI=()=>({name:"text",responseFormat:Promise.resolve({type:"text"}),async parseCompleteOutput({text:e}){return e},async parsePartialOutput({text:e}){return{partial:e}},createElementStreamTransform(){}}),NI=({schema:e,name:t,description:n})=>{const r=Ro(e);return{name:"object",responseFormat:rn(r.jsonSchema).then(i=>({type:"json",schema:i,...t!=null&&{name:t},...n!=null&&{description:n}})),async parseCompleteOutput({text:i},s){const a=await Tn({text:i});if(!a.success)throw new ln({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 Yr({value:a.value,schema:r});if(!o.success)throw new ln({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 ai(i);switch(s.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return{partial:s.value}}},createElementStreamTransform(){}}},CI=({element:e,name:t,description:n})=>{const r=Ro(e);return{name:"array",responseFormat:rn(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 Tn({text:i});if(!a.success)throw new ln({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 ln({message:"No object generated: response did not match schema.",cause:new sr({value:o,cause:"response must be an object with an elements array"}),text:i,response:s.response,usage:s.usage,finishReason:s.finishReason});for(const l of o.elements){const c=await Yr({value:l,schema:r});if(!c.success)throw new ln({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 ai(i);switch(s.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":{const a=s.value;if(a==null||typeof a!="object"||!("elements"in a)||!Array.isArray(a.elements))return;const o=s.state==="repaired-parse"&&a.elements.length>0?a.elements.slice(0,-1):a.elements,l=[];for(const c of o){const f=await Yr({value:c,schema:r});f.success&&l.push(f.value)}return{partial:l}}}},createElementStreamTransform(){let i=0;return new TransformStream({transform({partialOutput:s},a){if(s!=null)for(;i<s.length;i++)a.enqueue(s[i])}})}}},EI=({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 Tn({text:r});if(!s.success)throw new ln({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 ln({message:"No object generated: response did not match schema.",cause:new sr({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 ai(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(){}}),II=({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 Tn({text:n});if(!i.success)throw new ln({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 ai(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(){}});si({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=nI(()=>Fh(ft([Ze({type:ye("text-start"),id:oe(),providerMetadata:je.optional()}),Ze({type:ye("text-delta"),id:oe(),delta:oe(),providerMetadata:je.optional()}),Ze({type:ye("text-end"),id:oe(),providerMetadata:je.optional()}),Ze({type:ye("error"),errorText:oe()}),Ze({type:ye("tool-input-start"),toolCallId:oe(),toolName:oe(),providerExecuted:ut().optional(),providerMetadata:je.optional(),dynamic:ut().optional(),title:oe().optional()}),Ze({type:ye("tool-input-delta"),toolCallId:oe(),inputTextDelta:oe()}),Ze({type:ye("tool-input-available"),toolCallId:oe(),toolName:oe(),input:Lt(),providerExecuted:ut().optional(),providerMetadata:je.optional(),dynamic:ut().optional(),title:oe().optional()}),Ze({type:ye("tool-input-error"),toolCallId:oe(),toolName:oe(),input:Lt(),providerExecuted:ut().optional(),providerMetadata:je.optional(),dynamic:ut().optional(),errorText:oe(),title:oe().optional()}),Ze({type:ye("tool-approval-request"),approvalId:oe(),toolCallId:oe()}),Ze({type:ye("tool-output-available"),toolCallId:oe(),output:Lt(),providerExecuted:ut().optional(),providerMetadata:je.optional(),dynamic:ut().optional(),preliminary:ut().optional()}),Ze({type:ye("tool-output-error"),toolCallId:oe(),errorText:oe(),providerExecuted:ut().optional(),providerMetadata:je.optional(),dynamic:ut().optional()}),Ze({type:ye("tool-output-denied"),toolCallId:oe()}),Ze({type:ye("reasoning-start"),id:oe(),providerMetadata:je.optional()}),Ze({type:ye("reasoning-delta"),id:oe(),delta:oe(),providerMetadata:je.optional()}),Ze({type:ye("reasoning-end"),id:oe(),providerMetadata:je.optional()}),Ze({type:ye("source-url"),sourceId:oe(),url:oe(),title:oe().optional(),providerMetadata:je.optional()}),Ze({type:ye("source-document"),sourceId:oe(),mediaType:oe(),title:oe(),filename:oe().optional(),providerMetadata:je.optional()}),Ze({type:ye("file"),url:oe(),mediaType:oe(),providerMetadata:je.optional()}),Ze({type:Oh(e=>typeof e=="string"&&e.startsWith("data-"),{message:'Type must start with "data-"'}),id:oe().optional(),data:Lt(),transient:ut().optional()}),Ze({type:ye("start-step")}),Ze({type:ye("finish-step")}),Ze({type:ye("start"),messageId:oe().optional(),messageMetadata:Lt().optional()}),Ze({type:ye("finish"),finishReason:Th(["stop","length","content-filter","tool-calls","error","other"]).optional(),messageMetadata:Lt().optional()}),Ze({type:ye("abort"),reason:oe().optional()}),Ze({type:ye("message-metadata"),messageMetadata:Lt()})])));function TI(e){return e.type.startsWith("data-")}function Fa(e){return e.type.startsWith("tool-")}function AI(e){return e.type==="dynamic-tool"}function es(e){return Fa(e)||AI(e)}function Hu(e){return e.type.split("-").slice(1).join("-")}function PI({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 OI({stream:e,messageMetadataSchema:t,dataPartSchemas:n,runUpdateMessageJob:r,onError:i,onToolCall:s,onData:a}){return e.pipeThrough(new TransformStream({async transform(o,l){await r(async({state:c,write:f})=>{var d,p,h,m;function v(g){const C=c.message.parts.filter(es).find(w=>w.toolCallId===g);if(C==null)throw new Zn({chunkType:"tool-invocation",chunkId:g,message:`No tool invocation found for tool call ID "${g}".`});return C}function S(g){var z;const C=c.message.parts.find(R=>Fa(R)&&R.toolCallId===g.toolCallId),w=g,E=C;if(C!=null){C.state=g.state,E.input=w.input,E.output=w.output,E.errorText=w.errorText,E.rawInput=w.rawInput,E.preliminary=w.preliminary,g.title!==void 0&&(E.title=g.title),E.providerExecuted=(z=w.providerExecuted)!=null?z:C.providerExecuted;const R=w.providerMetadata;if(R!=null)if(g.state==="output-available"||g.state==="output-error"){const K=C;K.resultProviderMetadata=R}else C.callProviderMetadata=R}else c.message.parts.push({type:`tool-${g.toolName}`,toolCallId:g.toolCallId,state:g.state,title:g.title,input:w.input,output:w.output,rawInput:w.rawInput,errorText:w.errorText,providerExecuted:w.providerExecuted,preliminary:w.preliminary,...w.providerMetadata!=null&&(g.state==="output-available"||g.state==="output-error")?{resultProviderMetadata:w.providerMetadata}:{},...w.providerMetadata!=null&&!(g.state==="output-available"||g.state==="output-error")?{callProviderMetadata:w.providerMetadata}:{}})}function y(g){var z,C;const w=c.message.parts.find(K=>K.type==="dynamic-tool"&&K.toolCallId===g.toolCallId),E=g,R=w;if(w!=null){w.state=g.state,R.toolName=g.toolName,R.input=E.input,R.output=E.output,R.errorText=E.errorText,R.rawInput=(z=E.rawInput)!=null?z:R.rawInput,R.preliminary=E.preliminary,g.title!==void 0&&(R.title=g.title),R.providerExecuted=(C=E.providerExecuted)!=null?C:w.providerExecuted;const K=E.providerMetadata;if(K!=null)if(g.state==="output-available"||g.state==="output-error"){const j=w;j.resultProviderMetadata=K}else w.callProviderMetadata=K}else c.message.parts.push({type:"dynamic-tool",toolName:g.toolName,toolCallId:g.toolCallId,state:g.state,input:E.input,output:E.output,errorText:E.errorText,preliminary:E.preliminary,providerExecuted:E.providerExecuted,title:g.title,...E.providerMetadata!=null&&(g.state==="output-available"||g.state==="output-error")?{resultProviderMetadata:E.providerMetadata}:{},...E.providerMetadata!=null&&!(g.state==="output-available"||g.state==="output-error")?{callProviderMetadata:E.providerMetadata}:{}})}async function _(g){if(g!=null){const z=c.message.metadata!=null?Kh(c.message.metadata,g):g;t!=null&&await Ju({value:z,schema:t,context:{field:"message.metadata",entityId:c.message.id}}),c.message.metadata=z}}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 Zn({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 Zn({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 Zn({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 Zn({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(Fa);c.partialToolCalls[o.toolCallId]={text:"",toolName:o.toolName,index:g.length,dynamic:o.dynamic,title:o.title},o.dynamic?y({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 Zn({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:z}=await ai(g.text);g.dynamic?y({toolCallId:o.toolCallId,toolName:g.toolName,state:"input-streaming",input:z,title:g.title}):S({toolCallId:o.toolCallId,toolName:g.toolName,state:"input-streaming",input:z,title:g.title}),f();break}case"tool-input-available":{o.dynamic?y({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(es).find(C=>C.toolCallId===o.toolCallId);(g!=null?g.type==="dynamic-tool":!!o.dynamic)?y({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"?y({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:Hu(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"?y({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:Hu(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 _(o.messageMetadata),(o.messageId!=null||o.messageMetadata!=null)&&f();break}case"finish":{o.finishReason!=null&&(c.finishReason=o.finishReason),await _(o.messageMetadata),o.messageMetadata!=null&&f();break}case"message-metadata":{await _(o.messageMetadata),o.messageMetadata!=null&&f();break}case"error":{i==null||i(new Error(o.errorText));break}default:if(TI(o)){if((n==null?void 0:n[o.type])!=null){const C=c.message.parts.findIndex(E=>"id"in E&&"data"in E&&E.id===o.id&&E.type===o.type),w=C>=0?C:c.message.parts.length;await Ju({value:o.data,schema:n[o.type],context:{field:`message.parts[${w}].data`,entityName:o.type,entityId:o.id}})}const g=o;if(g.transient){a==null||a(g);break}const z=g.id!=null?c.message.parts.find(C=>g.type===C.type&&g.id===C.id):void 0;z!=null?z.data=g.data:c.message.parts.push(g),a==null||a(g),f()}}l.enqueue(o)})}}))}async function DI({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()}}si({prefix:"aitxt",size:24});si({prefix:"aiobj",size:24});var RI=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()})}};si({prefix:"aiobj",size:24});async function MI(e){if(e==null)return[];if(!globalThis.FileList||!(e instanceof globalThis.FileList))throw new Error("FileList is not supported in the current environment");return Promise.all(Array.from(e).map(async t=>{const{name:n,type:r}=t,i=await new Promise((s,a)=>{const o=new FileReader;o.onload=l=>{var c;s((c=l.target)==null?void 0:c.result)},o.onerror=l=>a(l),o.readAsDataURL(t)});return{type:"file",mediaType:r,filename:n,url:i}}))}var $I=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 rn(this.body),l=await rn(this.headers),c=await rn(this.credentials),f={...Ln(l),...Ln(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?Ln(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,y=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(!y.ok)throw new Error((a=await y.text())!=null?a:"Failed to fetch the chat response.");if(!y.body)throw new Error("The response body is empty.");return this.processResponseStream(y.body)}async reconnectToStream(e){var t,n,r,i,s;const a=await rn(this.body),o=await rn(this.headers),l=await rn(this.credentials),c={...Ln(o),...Ln(e.headers)},f=await((t=this.prepareReconnectToStreamRequest)==null?void 0:t.call(this,{api:this.api,id:e.chatId,body:{...a,...e.body},headers:c,credentials:l,requestMetadata:e.metadata})),d=(n=f==null?void 0:f.api)!=null?n:`${this.api}/${e.chatId}/stream`,p=(f==null?void 0:f.headers)!==void 0?Ln(f.headers):c,h=(r=f==null?void 0:f.credentials)!=null?r:l,v=await((i=this.fetch)!=null?i:globalThis.fetch)(d,{method:"GET",headers:p,credentials:h});if(v.status===204)return null;if(!v.ok)throw new Error((s=await v.text())!=null?s:"Failed to fetch the chat response.");if(!v.body)throw new Error("The response body is empty.");return this.processResponseStream(v.body)}},Yh=class extends $I{constructor(e={}){super(e)}processResponseStream(e){return lI({stream:e,schema:zI}).pipeThrough(new TransformStream({async transform(t,n){if(!t.success)throw t.error;n.enqueue(t.value)}}))}},FI=class{constructor({generateId:e=dE,id:t=e(),transport:n=new Yh,messageMetadataSchema:r,dataPartSchemas:i,state:s,onError:a,onToolCall:o,onFinish:l,onData:c,sendAutomaticallyWhen:f}){this.activeResponse=void 0,this.jobExecutor=new RI,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 y;if("text"in d||"files"in d?y={parts:[...Array.isArray(d.files)?d.files:await MI(d.files),..."text"in d&&d.text!=null?[{type:"text",text:d.text}]:[]]}:y=d,d.messageId!=null){const _=this.state.messages.findIndex(g=>g.id===d.messageId);if(_===-1)throw new Error(`message with id ${d.messageId} not found`);if(this.state.messages[_].role!=="user")throw new Error(`message with id ${d.messageId} is not a user message`);this.state.messages=this.state.messages.slice(0,_+1),this.state.replaceMessage(_,{...y,id:d.messageId,role:(m=y.role)!=null?m:"user",metadata:d.metadata})}else this.state.pushMessage({...y,id:(v=y.id)!=null?v:this.generateId(),role:(S=y.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],y=_=>es(_)&&_.state==="approval-requested"&&_.approval.id===d?{..._,state:"approval-responded",approval:{id:d,approved:p,reason:h}}:_;this.state.replaceMessage(v.length-1,{...S,parts:S.parts.map(y)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(y)),this.status!=="streaming"&&this.status!=="submitted"&&this.sendAutomaticallyWhen&&this.shouldSendAutomatically().then(_=>{var g;_&&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,y=S[S.length-1],_=g=>es(g)&&g.toolCallId===p?{...g,state:d,output:h,errorText:m}:g;this.state.replaceMessage(S.length-1,{...y,parts:y.parts.map(_)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(_)),this.status!=="streaming"&&this.status!=="submitted"&&this.sendAutomaticallyWhen&&this.shouldSendAutomatically().then(g=>{var z;g&&this.makeRequest({trigger:"submit-message",messageId:(z=this.lastMessage)==null?void 0:z.id,...v})})}),this.addToolResult=this.addToolOutput,this.stop=async()=>{var d;this.status!=="streaming"&&this.status!=="submitted"||(d=this.activeResponse)!=null&&d.abortController&&this.activeResponse.abortController.abort()},this.id=t,this.transport=n,this.generateId=e,this.messageMetadataSchema=r,this.dataPartSchemas=i,this.state=s,this.onError=a,this.onToolCall=o,this.onFinish=l,this.onData=c,this.sendAutomaticallyWhen=f}get status(){return this.state.status}setStatus({status:e,error:t}){this.status!==e&&(this.state.status=e,this.state.error=t)}get error(){return this.state.error}get messages(){return this.state.messages}get lastMessage(){return this.state.messages[this.state.messages.length-1]}set messages(e){this.state.messages=e}async shouldSendAutomatically(){if(!this.sendAutomaticallyWhen)return!1;const e=this.sendAutomaticallyWhen({messages:this.state.messages});return e&&typeof e=="object"&&"then"in e?await e:e}async makeRequest({trigger:e,metadata:t,headers:n,body:r,messageId:i}){var s,a,o;let l;if(e==="resume-stream")try{const h=await this.transport.reconnectToStream({chatId:this.id,metadata:t,headers:n,body:r});if(h==null)return;l=h}catch(h){this.onError&&h instanceof Error&&this.onError(h),this.setStatus({status:"error",error:h});return}this.setStatus({status:"submitted",error:void 0});const c=this.lastMessage;let f=!1,d=!1,p=!1;try{const h={state:PI({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=l: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 y;this.setStatus({status:"streaming"}),h.state.message.id===((y=this.lastMessage)==null?void 0:y.id)?this.state.replaceMessage(this.state.messages.length-1,h.state.message):this.state.pushMessage(h.state.message)}}));await DI({stream:OI({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,Wu;function LI(){if(Wu)return oa;Wu=1;function e(t,n){if(typeof t!="function")throw new TypeError(`Expected the first argument to be a \`function\`, got \`${typeof t}\`.`);let r,i=0;return function(...a){clearTimeout(r);const o=Date.now(),l=o-i,c=n-l;c<=0?(i=o,t.apply(this,a)):r=setTimeout(()=>{i=Date.now(),t.apply(this,a)},c)}}return oa=e,oa}var ZI=LI();const BI=Ua(ZI);var Xh=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},Be=(e,t,n)=>(Xh(e,t,"read from private field"),n?n.call(e):t.get(e)),$t=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},nn=(e,t,n,r)=>(Xh(e,t,"write to private field"),t.set(e,n),n);function VI(e,t){return t!=null?BI(e,t):e}var Nt,Ci,Ei,Er,Ir,zr,Jn,La,Za,UI=class{constructor(e=[]){$t(this,Nt,void 0),$t(this,Ci,"ready"),$t(this,Ei,void 0),$t(this,Er,new Set),$t(this,Ir,new Set),$t(this,zr,new Set),this.pushMessage=t=>{nn(this,Nt,Be(this,Nt).concat(t)),Be(this,Jn).call(this)},this.popMessage=()=>{nn(this,Nt,Be(this,Nt).slice(0,-1)),Be(this,Jn).call(this)},this.replaceMessage=(t,n)=>{nn(this,Nt,[...Be(this,Nt).slice(0,t),this.snapshot(n),...Be(this,Nt).slice(t+1)]),Be(this,Jn).call(this)},this.snapshot=t=>structuredClone(t),this["~registerMessagesCallback"]=(t,n)=>{const r=n?VI(t,n):t;return Be(this,Er).add(r),()=>{Be(this,Er).delete(r)}},this["~registerStatusCallback"]=t=>(Be(this,Ir).add(t),()=>{Be(this,Ir).delete(t)}),this["~registerErrorCallback"]=t=>(Be(this,zr).add(t),()=>{Be(this,zr).delete(t)}),$t(this,Jn,()=>{Be(this,Er).forEach(t=>t())}),$t(this,La,()=>{Be(this,Ir).forEach(t=>t())}),$t(this,Za,()=>{Be(this,zr).forEach(t=>t())}),nn(this,Nt,e)}get status(){return Be(this,Ci)}set status(e){nn(this,Ci,e),Be(this,La).call(this)}get error(){return Be(this,Ei)}set error(e){nn(this,Ei,e),Be(this,Za).call(this)}get messages(){return Be(this,Nt)}set messages(e){nn(this,Nt,[...e]),Be(this,Jn).call(this)}};Nt=new WeakMap;Ci=new WeakMap;Ei=new WeakMap;Er=new WeakMap;Ir=new WeakMap;zr=new WeakMap;Jn=new WeakMap;La=new WeakMap;Za=new WeakMap;var Hn,qu=class extends FI{constructor({messages:e,...t}){const n=new UI(e);super({...t,state:n}),$t(this,Hn,void 0),this["~registerMessagesCallback"]=(r,i)=>Be(this,Hn)["~registerMessagesCallback"](r,i),this["~registerStatusCallback"]=r=>Be(this,Hn)["~registerStatusCallback"](r),this["~registerErrorCallback"]=r=>Be(this,Hn)["~registerErrorCallback"](r),nn(this,Hn,n)}};Hn=new WeakMap;function JI({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 qu(i));("chat"in n&&n.chat!==s.current||"id"in n&&s.current.id!==n.id)&&(s.current="chat"in n?n.chat:new qu(i));const o=b.useCallback(p=>s.current["~registerMessagesCallback"](p,e),[e,s.current.id]),l=b.useSyncExternalStore(o,()=>s.current.messages,()=>s.current.messages),c=b.useSyncExternalStore(s.current["~registerStatusCallback"],()=>s.current.status,()=>s.current.status),f=b.useSyncExternalStore(s.current["~registerErrorCallback"],()=>s.current.error,()=>s.current.error),d=b.useCallback(p=>{typeof p=="function"&&(p=p(s.current.messages)),s.current.messages=p},[s]);return b.useEffect(()=>{t&&s.current.resumeStream()},[t,s]),{id:s.current.id,messages:l,setMessages:d,sendMessage:s.current.sendMessage,regenerate:s.current.regenerate,clearError:s.current.clearError,stop:s.current.stop,error:f,resumeStream:s.current.resumeStream,status:c,addToolResult:s.current.addToolOutput,addToolOutput:s.current.addToolOutput,addToolApprovalResponse:s.current.addToolApprovalResponse}}function 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=HI(e,t);if(i)return i}if(n!=null&&n.selectedText){const i=n.selectedText,s=e.indexOf(i);if(s!==-1){const o=e.indexOf(i,s+1);let l;if(o===-1)l=s;else if(n.startLine&&n.startLine>0){const d=XI(e,n.startLine);l=QI(e,i,d)}else l=s;const c=e.slice(0,l),f=e.slice(l+i.length);return{original:e,modified:c+t+f}}if(n.startLine&&n.endLine){const o=KI(e,t,n.startLine,n.endLine);if(o)return o}const a=Gu(e,t);return a||{original:e,modified:t}}const r=Gu(e,t);return r||{original:e,modified:t}}function HI(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(!Ba(i,r,n))return null;const o=JSON.stringify(i,null,a);return{original:e,modified:o}}function Ba(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(Ba(i,t,n))return!0}return!1}if(e&&typeof e=="object"){for(const r of Object.values(e))if(Ba(r,t,n))return!0}return!1}function Gu(e,t){try{const s=JSON.parse(t);if(s&&typeof s=="object"&&!Array.isArray(s))try{const a=JSON.parse(e);if(a&&typeof a=="object"&&!Array.isArray(a)){const o=Object.keys(s).sort().join(","),l=Object.keys(a).sort().join(",");if(o===l)return null}}catch{}}catch{}const n=WI(t);if(n.length===0)return null;let r=e,i=!1;for(const s of n){const a=qI(r,t,s);a&&(r=a,i=!0)}return i?{original:e,modified:r}:null}function WI(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 qI(e,t,n){const r=`"${n}"`,i=Ku(e,r);if(i.length===0)return null;const s=Ku(t,r);if(s.length===0)return null;const a=s[0],o=t.slice(a.start,a.end);let l=0;if(i.length>1){let f=-1;for(let d=0;d<i.length;d++){const p=e.slice(i[d].start,i[d].end),h=YI(p,o);h>f&&(f=h,l=d)}}const c=i[l];return e.slice(0,c.start)+o+e.slice(c.end)}function Ku(e,t){const n=[];let r=0;for(;;){const i=e.indexOf(t,r);if(i===-1)break;let s=i-1;for(;s>=0&&(e[s]===" "||e[s]===" ");)s--;const a=s<0?"":e[s];if(a!==""&&a!=="{"&&a!==","&&a!==`
84
+ `&&a!=="\r"){r=i+1;continue}const o=e.indexOf(":",i+t.length);if(o===-1){r=i+1;continue}const l=o+1,c=GI(e,l);if(c===-1){r=i+1;continue}n.push({start:i,end:c}),r=c}return n}function GI(e,t){for(;t<e.length&&/\s/.test(e[t]);)t++;if(t>=e.length)return-1;const n=e[t];if(n==='"'){let i=t+1;for(;i<e.length;){if(e[i]==="\\"){i+=2;continue}if(e[i]==='"')return i+1;i++}return-1}if(n==="["||n==="{"){const i=n,s=n==="["?"]":"}";let a=1,o=t+1,l=!1;for(;o<e.length&&a>0;){if(e[o]==="\\"&&l){o+=2;continue}e[o]==='"'&&(l=!l),l||(e[o]===i?a++:e[o]===s&&a--),o++}return a===0?o:-1}let r=t;for(;r<e.length&&/[^\s,\]}]/.test(e[r]);)r++;return r>t?r:-1}function KI(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 YI(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 XI(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 QI(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 ez(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 tz(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 nz(){const e=Te(J=>J.threads),t=Te(J=>J.activeThreadId),n=Te(J=>J.updateThreadMessages),r=Te(J=>J.updateThreadTitle),i=Te(J=>J.clearContext),s=Te(J=>J.contextAttachments),a=Te(J=>J.scope),o=Te(J=>J.model),l=Ae(J=>J.activeTab),c=Ae(J=>J.documents),f=Ae(J=>J.documentTypes),d=Ae(J=>J.setPendingDiff),p=Ae(J=>J.createDocument),h=Ae(J=>J.openDocument),m=b.useRef(e);m.current=e;const v=b.useRef(l);v.current=l;const S=b.useRef(c);S.current=c;const y=b.useRef(f);y.current=f;const _=b.useRef(t);_.current=t;const g=l?t[l]:void 0,z=b.useRef(g);z.current=g;const C=b.useRef([]),w=b.useRef([]),E=b.useRef({}),R=b.useRef({}),[,K]=b.useState(0),j=b.useCallback(()=>K(J=>J+1),[]),I=b.useRef(null);I.current||(I.current=new Yh({api:"/api/ai/chat"}));const O=b.useCallback(()=>{const J=S.current.find(B=>B.name===v.current);return J?{name:J.name,text:J.text}:void 0},[]),Z=b.useCallback(J=>E.current[J]||[],[]),M=JI({transport:I.current,onError:()=>{C.current.shift(),w.current.shift(),i()},onFinish:({messages:J})=>{var H,G;const B=z.current;if(B){n(B,J);const ie=m.current[B];if(ie&&ie.title.startsWith("Chat ")){const ae=J.find(Q=>Q.role==="user");if(ae){const Q=((H=ae.parts)==null?void 0:H.filter($=>$.type==="text").map($=>$.text).join(""))||"";if(Q){const $=Q.length>50?Q.slice(0,50)+"...":Q;r(B,$)}}}}const ne=C.current.shift()||[],k=w.current.shift()||"global",ce=J.filter(ie=>ie.role==="user"),de=ce[ce.length-1];de!=null&&de.id&&(E.current[de.id]=ne,R.current[de.id]=k);const x=J.filter(ie=>ie.role==="assistant").pop();if(x){const ae=[...(((G=x.parts)==null?void 0:G.filter(Q=>Q.type==="text").map(Q=>Q.text).join(""))||"").matchAll(/```(?:json|jsonc)\s*\n([\s\S]*?)```/g)];if(ae.length>0){const Q=ez(ae);if(Q){const $=ae[ae.length-1][1],ee=v.current;if(ee){const V=S.current.find(Qe=>Qe.name===ee),se=(V==null?void 0:V.text)||"",le=ne[0],ge=tz(se,Q,k);!ge&&k!=="global"&&console.warn(`[chat] scopedMerge failed for scope="${k}", falling back to text merge`);const{original:Oe,modified:We}=ge??tm(se,Q,le);d(ee,Oe,We,em($.replace(/\n$/,"")))}else{const V=`ai-generated-${Date.now()}`;p(V,Q),h(V)}}}}i()}});b.useEffect(()=>{const J=M.messages.filter(B=>B.role==="user");for(let B=J.length-1;B>=0;B--){const ne=J[B].id;if(ne in E.current)break;C.current.length>0&&(E.current[ne]=C.current[0],R.current[ne]=w.current[0]||"global",j());break}},[M.messages,j]);const T=b.useCallback((J,B)=>{C.current.push([...s]),w.current.push(a),i();const ne={text:J};B!=null&&B.length&&(ne.files=B),M.sendMessage(ne,{body:{format:yt,context:s,activeDocument:O(),documentType:v.current&&y.current[v.current]||"application/json+report",scope:a,model:o}})},[M.sendMessage,s,O,i,a,o]),A=b.useCallback(J=>R.current[J],[]);return{messages:M.messages,sendMessage:T,status:M.status,error:M.error,setMessages:M.setMessages,stop:M.stop,getMessageContext:Z,getMessageScope:A}}const nm=b.createContext(null);function rz({children:e}){const t=nz();return u.jsx(nm.Provider,{value:t,children:e})}function iz(){const e=b.useContext(nm);if(!e)throw new Error("useChatSessionContext must be used within ChatSessionProvider");return e}function sz(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 az(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=sz(e),i=((c=e.documentName)==null?void 0:c.replace(/\.json$/,""))??"",s=i?`${i} › ${r}`:r,a=az(e.selectedText),o=n==="sent",l=u.jsxs("div",{className:`group flex items-center gap-1.5 rounded-md border pl-2 ${t?"pr-1":"pr-2"} py-1 text-xs max-w-[280px] transition-colors ${o?"border-primary-foreground/20 bg-primary-foreground/10 hover:bg-primary-foreground/20":"border-primary/20 bg-primary/5 hover:bg-primary/10"}`,children:[u.jsx(cg,{className:`h-3 w-3 shrink-0 ${o?"text-primary-foreground/60":"text-primary/60"}`}),u.jsx("span",{className:"truncate font-medium",children:s}),t&&u.jsx("button",{type:"button",onClick:t,className:"shrink-0 rounded-sm p-0.5 opacity-60 hover:opacity-100 hover:bg-muted transition-opacity cursor-pointer","aria-label":"Remove context",children:u.jsx(Nn,{className:"h-3 w-3"})})]});return u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:l}),u.jsxs(Ke,{side:"top",className:"max-w-xs",children:[u.jsx("p",{className:"text-xs font-medium mb-0.5",children:s}),u.jsx("p",{className:"text-xs text-muted-foreground font-mono",children:a}),e.jsonPath&&u.jsx("p",{className:"text-[10px] text-muted-foreground/60 mt-1",children:e.jsonPath})]})]})}class Bn extends Error{constructor(t,n){super(`${t} at position ${n}`),this.position=n}}const im=32,oz=10,sm=9,am=13,lz=160,uz=6158,cz=8192,dz=8203,fz=8239,pz=8287,hz=12288,mz=65279;function gz(e){return/^[0-9A-Fa-f]$/.test(e)}function bn(e){return e>="0"&&e<="9"}function xz(e){return e>=" "}function bi(e){return`,:[]/{}()
92
+ +`.includes(e)}function Yu(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"||e==="_"||e==="$"}function Xu(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"||e==="_"||e==="$"||e>="0"&&e<="9"}const Qu=/^(http|https|ftp|mailto|file|data|irc):\/\/$/,ec=/^[A-Za-z0-9-._~:/?#@!$&'()*+;=]$/;function tc(e){return`,[]/{}
93
+ +`.includes(e)}function nc(e){return Ii(e)||yz.test(e)}const yz=/^[[{\w-]$/;function bz(e){return e===`
94
+ `||e==="\r"||e===" "||e==="\b"||e==="\f"}function wn(e,t){const n=e.charCodeAt(t);return n===im||n===oz||n===sm||n===am}function vz(e,t){const n=e.charCodeAt(t);return n===im||n===sm||n===am}function wz(e,t){const n=e.charCodeAt(t);return n===lz||n===uz||n>=cz&&n<=dz||n===fz||n===pz||n===hz||n===mz}function Ii(e){return om(e)||Va(e)}function om(e){return e==='"'||e==="“"||e==="”"}function rc(e){return e==='"'}function Va(e){return e==="'"||e==="‘"||e==="’"||e==="`"||e==="´"}function ic(e){return e==="'"}function kr(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(!wn(e,n-1))return e+t;for(;wn(e,n-1);)n--;return e.substring(0,n)+t+e.substring(n)}function kz(e,t,n){return e.substring(0,t)+e.substring(t+n)}function Sz(e){return/[,\n][ \t\r]*$/.test(e)}const _z={"\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t"},jz={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:`
95
+ `,r:"\r",t:" "};function sc(e){let t=0,n="";c(["```","[```","{```"]),s()||M(),c(["```","```]","```}"]);const i=d(",");for(i&&a(),nc(e[t])&&Sz(n)?(i||(n=Pt(n,",")),y()):i&&(n=kr(n,","));e[t]==="}"||e[t]==="]";)t++,a();if(t>=e.length)return n;Z();function s(){a();const B=v()||S()||_()||z()||C()||E(!1)||R();return a(),B}function a(){let B=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;const ne=t;let k=o(B);do k=l(),k&&(k=o(B));while(k);return t>ne}function o(B){const ne=B?wn:vz;let k="";for(;;)if(ne(e,t))k+=e[t],t++;else if(wz(e,t))k+=" ",t++;else break;return k.length>0?(n+=k,!0):!1}function l(){if(e[t]==="/"&&e[t+1]==="*"){for(;t<e.length&&!Nz(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(Yu(e[t]))for(;t<e.length&&Xu(e[t]);)t++;return a(),!0}return!1}function f(B){o(!0);for(const ne of B){const k=t+ne.length;if(e.slice(t,k)===ne)return t=k,!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 ne;if(B?(ne=!0,B=!1):(ne=d(","),ne||(n=Pt(n,",")),a()),m(),!(_()||E(!0))){e[t]==="}"||e[t]==="{"||e[t]==="]"||e[t]==="["||e[t]===void 0?n=kr(n,","):T();break}a();const ce=d(":"),de=t>=e.length;ce||(nc(e[t])||de?n=Pt(n,":"):A()),s()||(ce||de?n+="null":A())}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=kr(n,",");break}return e[t]==="]"?(n+="]",t++):n=Pt(n,"]"),!0}return!1}function y(){let B=!0,ne=!0;for(;ne;)B?B=!1:d(",")||(n=Pt(n,",")),ne=s();ne||(n=kr(n,",")),n=`[
97
+ ${n}
98
+ ]`}function _(){let B=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,ne=arguments.length>1&&arguments[1]!==void 0?arguments[1]:-1,k=e[t]==="\\";if(k&&(t++,k=!0),Ii(e[t])){const ce=rc(e[t])?rc:ic(e[t])?ic:Va(e[t])?Va:om,de=t,x=n.length;let H='"';for(t++;;){if(t>=e.length){const G=K(t-1);return!B&&bi(e.charAt(G))?(t=de,n=n.substring(0,x),_(!0)):(H=Pt(H,'"'),n+=H,!0)}if(t===ne)return H=Pt(H,'"'),n+=H,!0;if(ce(e[t])){const G=t,ie=H.length;if(H+='"',t++,n+=H,a(!1),B||t>=e.length||bi(e[t])||Ii(e[t])||bn(e[t]))return g(),!0;const ae=K(G-1),Q=e.charAt(ae);if(Q===",")return t=de,n=n.substring(0,x),_(!1,ae);if(bi(Q))return t=de,n=n.substring(0,x),_(!0);n=n.substring(0,x),t=G+1,H=`${H.substring(0,ie)}\\${H.substring(ie)}`}else if(B&&tc(e[t])){if(e[t-1]===":"&&Qu.test(e.substring(de+1,t+2)))for(;t<e.length&&ec.test(e[t]);)H+=e[t],t++;return H=Pt(H,'"'),n+=H,g(),!0}else if(e[t]==="\\"){const G=e.charAt(t+1);if(jz[G]!==void 0)H+=e.slice(t,t+2),t+=2;else if(G==="u"){let ae=2;for(;ae<6&&gz(e[t+ae]);)ae++;ae===6?(H+=e.slice(t,t+6),t+=6):t+ae>=e.length?t=e.length:J()}else H+=G,t+=2}else{const G=e.charAt(t);G==='"'&&e[t-1]!=="\\"?(H+=`\\${G}`,t++):bz(G)?(H+=_z[G],t++):(xz(G)||O(G),H+=G,t++)}k&&h()}}return!1}function g(){let B=!1;for(a();e[t]==="+";){B=!0,t++,a(),n=kr(n,'"',!0);const ne=n.length;_()?n=kz(n,ne,1):n=Pt(n,'"')}return B}function z(){const B=t;if(e[t]==="-"){if(t++,j())return I(B),!0;if(!bn(e[t]))return t=B,!1}for(;bn(e[t]);)t++;if(e[t]==="."){if(t++,j())return I(B),!0;if(!bn(e[t]))return t=B,!1;for(;bn(e[t]);)t++}if(e[t]==="e"||e[t]==="E"){if(t++,(e[t]==="-"||e[t]==="+")&&t++,j())return I(B),!0;if(!bn(e[t]))return t=B,!1;for(;bn(e[t]);)t++}if(!j())return t=B,!1;if(t>B){const ne=e.slice(B,t),k=/^0\d/.test(ne);return n+=k?`"${ne}"`:ne,!0}return!1}function C(){return w("true","true")||w("false","false")||w("null","null")||w("True","true")||w("False","false")||w("None","null")}function w(B,ne){return e.slice(t,t+B.length)===B?(n+=ne,t+=B.length,!0):!1}function E(B){const ne=t;if(Yu(e[t])){for(;t<e.length&&Xu(e[t]);)t++;let k=t;for(;wn(e,k);)k++;if(e[k]==="(")return t=k+1,s(),e[t]===")"&&(t++,e[t]===";"&&t++),!0}for(;t<e.length&&!tc(e[t])&&!Ii(e[t])&&(!B||e[t]!==":");)t++;if(e[t-1]===":"&&Qu.test(e.substring(ne,t+2)))for(;t<e.length&&ec.test(e[t]);)t++;if(t>ne){for(;wn(e,t-1)&&t>0;)t--;const k=e.slice(ne,t);return n+=k==="undefined"?"null":JSON.stringify(k),e[t]==='"'&&t++,!0}}function R(){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 K(B){let ne=B;for(;ne>0&&wn(e,ne);)ne--;return ne}function j(){return t>=e.length||bi(e[t])||wn(e,t)}function I(B){n+=`${e.slice(B,t)}0`}function O(B){throw new Bn(`Invalid character ${JSON.stringify(B)}`,t)}function Z(){throw new Bn(`Unexpected character ${JSON.stringify(e[t])}`,t)}function M(){throw new Bn("Unexpected end of json string",e.length)}function T(){throw new Bn("Object key expected",t)}function A(){throw new Bn("Colon expected",t)}function J(){const B=e.slice(t,t+6);throw new Bn(`Invalid unicode character "${B}"`,t)}}function Nz(e,t){return e[t]==="*"&&e[t+1]==="/"}function Cz({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 sc(e)}catch{}const y=`{${e}}`;try{return JSON.parse(y),y}catch{}try{return sc(y)}catch{return null}},[e]),l=b.useMemo(()=>em(o||e),[o,e]),c=Ae(y=>y.activeTab),f=Ae(y=>y.documents),d=Ae(y=>(y.acceptedApplyIds||[]).includes(l)),p=Ae(y=>y.setPendingDiff),h=Ae(y=>y.createDocument),m=Ae(y=>y.openDocument),v=b.useCallback(()=>{if(o){a(null);try{if(c){const y=f.find(w=>w.name===c),_=(y==null?void 0:y.text)||"";if(n==="templates")try{const w=JSON.parse(_),E=JSON.parse(o);if(Array.isArray(E.templates)){w.props||(w.props={}),w.props.templates=Qh(w.props.templates||[],E.templates);const R=JSON.stringify(w,null,2);p(c,_,R,l);return}}catch{}const g=t==null?void 0:t[0],{original:z,modified:C}=tm(_,o,g);p(c,z,C,l)}else{const y=`ai-generated-${Date.now()}`;h(y,o),m(y)}}catch(y){a(y instanceof Error?y.message:"Merge failed")}}},[o,c,f,p,h,m,t,n,l]),S=b.useCallback(async()=>{await navigator.clipboard.writeText(e),i(!0),setTimeout(()=>i(!1),1500)},[e]);return u.jsxs("div",{className:"flex flex-col gap-1 px-3 py-2 border-t",children:[u.jsxs("div",{className:"flex gap-1.5",children:[u.jsx(we,{variant:"secondary",size:"sm",onClick:v,disabled:d||!o,children:d?"Applied":o?"Apply to Editor":"Invalid JSON"}),u.jsx(we,{variant:"ghost",size:"sm",onClick:S,children:r?u.jsx(un,{className:"h-3.5 w-3.5"}):u.jsx(as,{className:"h-3.5 w-3.5"})})]}),s&&u.jsx("p",{className:"text-xs text-destructive m-0",children:s})]})}function Ez({threads:e,activeThread:t,disabled:n,onSwitch:r,onCreate:i,onDelete:s,onRename:a}){const[o,l]=b.useState(null),[c,f]=b.useState(""),[d,p]=b.useState(null),h=b.useRef(null),m=(t==null?void 0:t.title)||"New Chat",v=m.length>24?m.slice(0,24)+"...":m;b.useEffect(()=>{o&&requestAnimationFrame(()=>{var E;return(E=h.current)==null?void 0:E.focus()})},[o]);const S=b.useCallback((E,R)=>{R.stopPropagation(),R.preventDefault(),l(E.id),f(E.title),p(null)},[]),y=b.useCallback(()=>{o&&c.trim()&&a(o,c.trim()),l(null),f("")},[o,c,a]),_=b.useCallback(()=>{l(null),f("")},[]),g=b.useCallback(E=>{E.stopPropagation(),E.key==="Enter"?(E.preventDefault(),y()):E.key==="Escape"&&(E.preventDefault(),_())},[y,_]),z=b.useCallback((E,R)=>{R.stopPropagation(),R.preventDefault(),p(E),l(null)},[]),C=b.useCallback(E=>{E.stopPropagation(),E.preventDefault(),d&&(s(d),p(null))},[d,s]),w=b.useCallback(E=>{E.stopPropagation(),E.preventDefault(),p(null)},[]);return u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsxs(to,{onOpenChange:E=>{E||(l(null),p(null))},children:[u.jsx(no,{asChild:!0,disabled:n,children:u.jsxs("button",{className:"flex items-center gap-1 text-sm font-semibold tracking-tight hover:text-foreground/80 transition-colors max-w-[180px] cursor-pointer",children:[u.jsx("div",{className:"h-2 w-2 rounded-full bg-primary/70 shrink-0"}),u.jsx("span",{className:"truncate",children:v}),u.jsx(on,{className:"h-3 w-3 shrink-0 opacity-60"})]})}),u.jsxs(ds,{align:"start",className:"w-64",children:[e.map(E=>{const R=o===E.id;return d===E.id?u.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 text-sm",children:[u.jsx("span",{className:"text-red-400 text-xs flex-1 truncate",children:"Delete this thread?"}),u.jsx("button",{className:"shrink-0 text-red-400 hover:text-red-300 transition-colors cursor-pointer",onClick:C,children:u.jsx(un,{className:"h-3.5 w-3.5"})}),u.jsx("button",{className:"shrink-0 text-muted-foreground hover:text-foreground transition-colors cursor-pointer",onClick:w,children:u.jsx(Nn,{className:"h-3.5 w-3.5"})})]},E.id):R?u.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1",onClick:j=>j.stopPropagation(),onPointerDown:j=>j.stopPropagation(),children:[u.jsx("input",{ref:h,type:"text",value:c,onChange:j=>f(j.target.value),onKeyDown:g,onBlur:y,className:"flex-1 min-w-0 text-sm rounded border border-border bg-background px-1.5 py-0.5 outline-none focus:ring-1 focus:ring-primary/40"}),u.jsx("button",{className:"shrink-0 text-primary hover:text-primary/80 transition-colors cursor-pointer",onMouseDown:j=>{j.preventDefault(),y()},children:u.jsx(un,{className:"h-3.5 w-3.5"})}),u.jsx("button",{className:"shrink-0 text-muted-foreground hover:text-foreground transition-colors cursor-pointer",onMouseDown:j=>{j.preventDefault(),_()},children:u.jsx(Nn,{className:"h-3.5 w-3.5"})})]},E.id):u.jsxs(Kt,{onSelect:()=>r(E.id),className:`group ${E.id===(t==null?void 0:t.id)?"bg-accent":""}`,children:[u.jsx("span",{className:"truncate flex-1",children:E.title.length>30?E.title.slice(0,30)+"...":E.title}),u.jsxs("div",{className:"ml-auto shrink-0 flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[u.jsx("button",{className:"text-muted-foreground hover:text-foreground transition-colors p-0.5 cursor-pointer",onClick:j=>S(E,j),children:u.jsx(dg,{className:"h-3 w-3"})}),e.length>1&&u.jsx("button",{className:"text-muted-foreground hover:text-destructive transition-colors p-0.5 cursor-pointer",onClick:j=>z(E.id,j),children:u.jsx(Ha,{className:"h-3 w-3"})})]})]},E.id)}),u.jsx(Lr,{}),u.jsxs(Kt,{onSelect:E=>{E.preventDefault();const R=i();R&&(l(R),f(Xa()),p(null))},children:[u.jsx(zi,{className:"h-3.5 w-3.5 mr-1.5"}),"New Chat"]})]})]}),u.jsx(we,{variant:"ghost",size:"icon",className:"h-6 w-6 text-muted-foreground hover:text-foreground",onClick:()=>i(),disabled:n,title:"New chat thread",children:u.jsx(zi,{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"]),Iz=Array.from(lm).join(","),zz=20*1024*1024,ac=10;function Tz(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 oc(e){return Array.from(e).filter(t=>lm.has(t.type)&&t.size<=zz)}function um(e){return e.startsWith("image/")}function lc(){var q,he,Se;const e=Te(D=>D.contextAttachments),t=Te(D=>D.addContext),n=Te(D=>D.removeContext),r=Te(D=>D.scope),i=Te(D=>D.setScope),s=Te(D=>D.model),a=Te(D=>D.setModel),o=Te(D=>D.openChat),l=Te(D=>D.closeChat),c=Te(D=>D.threads),f=Te(D=>D.activeThreadId),d=Te(D=>D.createThread),p=Te(D=>D.deleteThread),h=Te(D=>D.switchThread),m=Te(D=>D.updateThreadMessages),v=Te(D=>D.updateThreadTitle),S=Te(D=>D.deleteThreadsForDocument),y=Ae(D=>D.activeTab),_=Ae(D=>D.documents),{messages:g,sendMessage:z,status:C,error:w,setMessages:E,stop:R,getMessageContext:K,getMessageScope:j}=iz(),[I,O]=b.useState(""),[Z,M]=b.useState([]),[T,A]=b.useState(!1),[J,B]=b.useState(!1),ne=b.useRef(null),k=b.useRef(null),ce=b.useRef(null),de=b.useCallback(async D=>{const me=oc(D);if(me.length===0)return;const Ce=await Promise.all(me.map(Tz));M($e=>{const nt=[...$e,...Ce];return nt.length>ac?nt.slice(0,ac):nt})},[]),x=b.useCallback(D=>{M(me=>me.filter((Ce,$e)=>$e!==D))},[]),H=b.useCallback(D=>{var Ce;const me=(Ce=D.clipboardData)==null?void 0:Ce.files;if(me&&me.length>0){const $e=oc(me);$e.length>0&&(D.preventDefault(),de($e))}},[de]),G=b.useCallback(D=>{var Ce;D.preventDefault(),B(!1);const me=(Ce=D.dataTransfer)==null?void 0:Ce.files;me&&me.length>0&&de(Array.from(me))},[de]),ie=b.useCallback(D=>{D.preventDefault(),B(!0)},[]),ae=b.useCallback(()=>B(!1),[]),Q=y?f[y]:void 0,$=Q?c[Q]:void 0,ee=b.useMemo(()=>y?Object.values(c).filter(D=>D.documentName===y).sort((D,me)=>me.updatedAt-D.updatedAt):[],[c,y]);b.useEffect(()=>{y&&ee.length===0&&d(y)},[y,ee.length,d]);const V=b.useRef(c);V.current=c,b.useEffect(()=>{const D=new Set(_.map(Ce=>Ce.name)),me=new Set;for(const Ce of Object.values(V.current))!D.has(Ce.documentName)&&Ce.documentName!=="__migrated__"&&me.add(Ce.documentName);for(const Ce of me)S(Ce)},[_,S]);const se=b.useRef(null);b.useEffect(()=>{se.current!==Q&&(se.current=Q,E(($==null?void 0:$.messages)??[]))},[Q,$,E]),b.useEffect(()=>{var D;(D=ne.current)==null||D.scrollIntoView({behavior:"smooth"})},[g,C]),b.useEffect(()=>{const D=me=>{var nt;const{documentName:Ce,selection:$e}=me.detail;t({...$e,documentName:Ce}),o(),(nt=k.current)==null||nt.focus()};return window.addEventListener("monaco-selection-to-ai",D),()=>window.removeEventListener("monaco-selection-to-ai",D)},[t,o]);const le=C==="streaming",ge=C==="submitted"||le,Oe=b.useCallback(D=>{D.preventDefault(),!(!I.trim()&&Z.length===0||ge)&&(z(I,Z.length>0?Z:void 0),O(""),M([]))},[I,Z,ge,z]),We=b.useCallback(D=>{D.key==="Enter"&&!D.shiftKey&&(D.preventDefault(),Oe(D))},[Oe]),Qe=b.useCallback(()=>{g.length!==0&&A(!0)},[g.length]),N=b.useCallback(()=>{A(!1),E([]),Q&&(m(Q,[]),v(Q,Xa()))},[E,Q,m,v]),[P,L]=b.useState(null),re=b.useCallback(D=>{L(D)},[]),te=b.useCallback(()=>{var nt,et;if(!P)return;const D=g.findIndex(it=>it.id===P);if(D===-1){L(null);return}const me=g[D],Ce=new Set([D]);me.role==="user"&&((nt=g[D+1])==null?void 0:nt.role)==="assistant"?Ce.add(D+1):me.role==="assistant"&&D>0&&((et=g[D-1])==null?void 0:et.role)==="user"&&Ce.add(D-1);const $e=g.filter((it,en)=>!Ce.has(en));E($e),Q&&m(Q,$e),L(null)},[P,g,E,Q,m]),X=b.useCallback(D=>{if(!ge){if(ee.length<=1){Qe();return}p(D)}},[ge,ee.length,Qe,p]),pe=b.useCallback(()=>{if(!(!y||ge))return d(y)},[y,ge,d]),ve=b.useCallback(D=>{ge||D===Q||h(D)},[ge,Q,h]),F=b.useCallback((D,me)=>{v(D,me)},[v]);return u.jsxs("div",{className:"flex flex-col h-full border-l bg-surface-chat",children:[u.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border/60 bg-surface-chat",children:[u.jsx(Ez,{threads:ee,activeThread:$,disabled:ge,onSwitch:ve,onCreate:pe,onDelete:X,onRename:F}),u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsx(we,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs text-muted-foreground hover:text-foreground",onClick:Qe,disabled:ge||g.length===0,children:"Clear"}),u.jsx(we,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:l,title:"Close chat",children:u.jsx(Nn,{className:"h-3.5 w-3.5"})})]})]}),u.jsx(Fr,{className:"flex-1 min-h-0 [&_[data-radix-scroll-area-viewport]>div]:!block",children:u.jsxs("div",{className:"p-3 space-y-4 min-w-0",children:[g.length===0&&u.jsxs("div",{className:"flex flex-col items-center justify-center py-12 px-4",children:[u.jsx("div",{className:"rounded-xl bg-primary/10 p-3 mb-4",children:u.jsx(Zo,{className:"h-5 w-5 text-primary"})}),u.jsx("p",{className:"text-sm font-medium text-foreground/80 mb-1",children:"JSON Assistant"}),u.jsx("p",{className:"text-xs text-muted-foreground text-center max-w-[200px] mb-4",children:"Generate, edit, and refine your JSON document definitions with AI."}),u.jsxs("div",{className:"flex items-center gap-1.5 rounded-md bg-muted/50 px-2.5 py-1.5",children:[u.jsx(wa,{shortcut:"mod+k"}),u.jsx("span",{className:"text-xs text-muted-foreground",children:"to send a selection"})]})]}),g.map((D,me)=>{let Ce;if(D.role==="user"){const et=K(D.id);et&&et.length>0&&(Ce=et)}else if(D.role==="assistant"){for(let et=me-1;et>=0;et--)if(g[et].role==="user"){Ce=K(g[et].id);break}}const $e=le&&me===g.length-1&&D.role==="assistant",nt=D.role==="user"?j(D.id):void 0;return u.jsx(Az,{msg:D,isStreaming:$e,context:Ce,scope:nt,onDelete:ge?void 0:re},D.id)}),ge&&((q=g[g.length-1])==null?void 0:q.role)!=="assistant"&&u.jsx("div",{className:"flex justify-start",children:u.jsx("div",{className:"rounded-lg px-3 py-2 bg-muted/60 border border-border/40",children:u.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(ua,{className:"h-3.5 w-3.5 animate-spin text-primary"}),u.jsx("span",{children:"Thinking..."})]})})}),w&&!ge&&u.jsx("div",{className:"flex justify-start",children:u.jsx("div",{className:"rounded-lg px-3 py-2 bg-destructive/10 border border-destructive/30 text-destructive text-sm max-w-[90%]",children:w.message||"Something went wrong"})}),u.jsx("div",{ref:ne})]})}),u.jsxs("div",{className:`border-t border-border/60 p-2.5 space-y-2 bg-surface-chat transition-colors ${J?"ring-2 ring-primary/40 bg-primary/5":""}`,onDrop:G,onDragOver:ie,onDragLeave:ae,children:[e.length>0&&u.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.map((D,me)=>u.jsx(rm,{context:D,onRemove:()=>n(me)},me))}),u.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[u.jsx(Dz,{model:s,setModel:a}),yt==="pptx"&&y&&u.jsx(Mz,{scope:r,setScope:i,docSize:((Se=(he=_.find(D=>D.name===y))==null?void 0:he.text)==null?void 0:Se.length)??0})]}),Z.length>0&&u.jsx("div",{className:"flex flex-wrap gap-1.5",children:Z.map((D,me)=>u.jsxs("div",{className:"relative group",children:[um(D.mediaType)?u.jsx("img",{src:D.url,alt:D.filename||"attachment",className:"h-14 w-14 rounded-md object-cover border border-border/60"}):u.jsxs("div",{className:"h-14 px-2.5 flex items-center gap-1.5 rounded-md border border-border/60 bg-muted/60 max-w-[140px]",children:[u.jsx(ca,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),u.jsx("span",{className:"text-xs truncate text-muted-foreground",children:D.filename||"file"})]}),u.jsx("button",{type:"button",onClick:()=>x(me),className:"absolute -top-1.5 -right-1.5 rounded-full bg-destructive text-destructive-foreground p-0.5 opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",children:u.jsx(Nn,{className:"h-3 w-3"})})]},me))}),u.jsxs("form",{onSubmit:Oe,className:"flex items-end gap-2",children:[u.jsx("input",{ref:ce,type:"file",accept:Iz,multiple:!0,className:"hidden",onChange:D=>{D.target.files&&de(Array.from(D.target.files)),D.target.value=""}}),u.jsx(we,{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=ce.current)==null?void 0:D.click()},title:"Attach file",children:u.jsx(ca,{className:"h-4 w-4"})}),u.jsx("textarea",{ref:k,value:I,onChange:D=>{O(D.target.value);const me=D.target;me.style.height="auto",me.style.height=`${Math.min(me.scrollHeight,128)}px`},onKeyDown:We,onPaste:H,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}),ge?u.jsx(we,{type:"button",size:"icon",variant:"destructive",className:"shrink-0 h-9 w-9 rounded-lg",onClick:R,title:"Stop generating",children:u.jsx(fg,{className:"h-4 w-4"})}):u.jsx(we,{type:"submit",size:"icon",disabled:!I.trim()&&Z.length===0,className:"shrink-0 h-9 w-9 rounded-lg",children:u.jsx(Zo,{className:"h-4 w-4"})})]})]}),u.jsx(It,{open:T,onOpenChange:A,children:u.jsxs(St,{className:"max-w-sm",children:[u.jsxs(Ut,{children:[u.jsx(Jt,{children:"Clear thread"}),u.jsx(cn,{children:"This will delete all messages in this thread. This action cannot be undone."})]}),u.jsxs(Cn,{children:[u.jsx(Vo,{asChild:!0,children:u.jsx(we,{variant:"ghost",size:"sm",children:"Cancel"})}),u.jsx(we,{variant:"destructive",size:"sm",onClick:N,children:"Clear"})]})]})}),u.jsx(It,{open:P!==null,onOpenChange:D=>{D||L(null)},children:u.jsxs(St,{className:"max-w-sm",children:[u.jsxs(Ut,{children:[u.jsx(Jt,{children:"Delete message"}),u.jsx(cn,{children:"This will delete the message and its paired response. This action cannot be undone."})]}),u.jsxs(Cn,{children:[u.jsx(Vo,{asChild:!0,children:u.jsx(we,{variant:"ghost",size:"sm",children:"Cancel"})}),u.jsx(we,{variant:"destructive",size:"sm",onClick:te,children:"Delete"})]})]})})]})}const Az=b.memo(function({msg:t,isStreaming:n,context:r,scope:i,onDelete:s}){var l,c;const a=((l=t.parts)==null?void 0:l.filter(f=>f.type==="text").map(f=>f.text).join(""))||"",o=((c=t.parts)==null?void 0:c.filter(f=>f.type==="file"))||[];return u.jsx("div",{className:`group/msg flex ${t.role==="user"?"justify-end":"justify-start"}`,children:u.jsxs("div",{className:`rounded-lg px-3 py-2 max-w-[90%] overflow-hidden min-w-0 ${t.role==="user"?"bg-primary text-primary-foreground":"bg-muted/60 border border-border/40"}`,children:[t.role==="user"?u.jsxs("div",{children:[o.length>0&&u.jsx("div",{className:"flex flex-wrap gap-1 mb-1.5",children:o.map((f,d)=>um(f.mediaType)?u.jsx("img",{src:f.url,alt:f.filename||"image",className:"h-20 max-w-[160px] rounded object-cover"},d):u.jsxs("div",{className:"flex items-center gap-1.5 rounded bg-primary-foreground/20 px-2 py-1",children:[u.jsx(ca,{className:"h-3 w-3 shrink-0"}),u.jsx("span",{className:"text-xs truncate max-w-[120px]",children:f.filename||"file"})]},d))}),r&&r.length>0&&u.jsx("div",{className:"flex flex-wrap gap-1 mb-1.5",children:r.map((f,d)=>u.jsx(rm,{context:f,variant:"sent"},d))}),a&&u.jsx("div",{className:"whitespace-pre-wrap text-sm break-words",children:a}),i&&i!=="global"&&u.jsx("span",{className:"text-[10px] text-primary-foreground/60 mt-0.5 block text-right",children:i})]}):u.jsx(Pz,{text:a,isStreaming:n,context:r,scope:i}),s&&!n&&u.jsx("div",{className:"opacity-0 group-hover/msg:opacity-100 transition-opacity mt-1",children:u.jsx("button",{type:"button",onClick:()=>s(t.id),className:`p-0.5 rounded cursor-pointer ${t.role==="user"?"text-primary-foreground/50 hover:text-primary-foreground/80":"text-muted-foreground hover:text-destructive"}`,children:u.jsx(Ha,{className:"h-3 w-3"})})})]})})},(e,t)=>e.msg.id===t.msg.id&&e.isStreaming===t.isStreaming&&e.scope===t.scope&&e.onDelete===t.onDelete&&e.context===t.context);function Pz({text:e,isStreaming:t,context:n,scope:r}){return t?u.jsx("div",{className:"text-sm prose prose-sm dark:prose-invert break-words [&_pre]:overflow-x-auto [&_p]:my-1",children:u.jsx("pre",{className:"whitespace-pre-wrap font-sans text-sm m-0 p-0 bg-transparent border-none",children:e})}):u.jsx("div",{className:"text-sm prose prose-sm dark:prose-invert break-words [&_pre]:overflow-x-auto [&_p]:my-1 [&_ul]:my-1 [&_ol]:my-1 [&_li]:my-0.5 [&_h1]:text-base [&_h2]:text-sm [&_h3]:text-sm [&_h1]:my-2 [&_h2]:my-1.5 [&_h3]:my-1",children:u.jsx(ak,{remarkPlugins:[b1],components:{pre:({children:i})=>u.jsx(u.Fragment,{children:i}),code:({className:i,children:s})=>{const a=i==null?void 0:i.startsWith("language-"),o=(i==null?void 0:i.replace("language-",""))||"",l=String(s).replace(/\n$/,"");if(!a)return u.jsx("code",{className:"rounded bg-muted px-1 py-0.5 text-xs font-mono",children:s});const c=o==="json"||o==="jsonc";return u.jsxs("div",{className:"my-2 rounded-lg border bg-card",children:[u.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 bg-muted/60 border-b text-xs text-muted-foreground",children:[u.jsx("span",{className:"font-mono",children:o||"code"}),!c&&u.jsx($z,{text:l})]}),u.jsx("pre",{className:"p-3 text-xs font-mono overflow-x-auto max-h-80 overflow-y-auto m-0",children:u.jsx("code",{children:l})}),c&&u.jsx(Cz,{json:l,context:n,scope:r})]})}},children:e})})}const Oz=[{value:"opus",label:"Opus"},{value:"sonnet",label:"Sonnet"},{value:"haiku",label:"Haiku"}];function Dz({model:e,setModel:t}){return u.jsxs(Mr,{value:e,onValueChange:n=>t(n),children:[u.jsx(tr,{className:"h-6 w-auto gap-1 border-none bg-muted/40 px-2 py-0 text-[10px] shadow-none focus:ring-0",children:u.jsx($r,{})}),u.jsx(nr,{children:Oz.map(n=>u.jsx(En,{value:n.value,className:"text-xs",children:n.label},n.value))})]})}const uc={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"},Rz=1e5;function Mz({scope:e,setScope:t,docSize:n}){return u.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Scope"}),u.jsx("div",{className:"flex items-center bg-muted/40 rounded-md p-0.5 gap-px",children:Object.keys(uc).map(r=>u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsx("button",{type:"button",onClick:()=>t(r),className:`px-2 py-0.5 rounded text-[10px] cursor-pointer transition-colors ${e===r?"bg-background text-foreground font-medium shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:r})}),u.jsx(Ke,{side:"top",className:"text-xs max-w-[200px]",children:uc[r]})]},r))})]}),e==="global"&&n>Rz&&u.jsxs("div",{className:"text-[10px] text-amber-500 flex items-center gap-1",children:[u.jsx(td,{className:"h-3 w-3 shrink-0"}),u.jsxs("span",{children:["Large doc — switch to"," ",u.jsx("button",{type:"button",onClick:()=>t("slides"),className:"underline cursor-pointer hover:text-amber-400",children:"slides"})," ","or"," ",u.jsx("button",{type:"button",onClick:()=>t("templates"),className:"underline cursor-pointer hover:text-amber-400",children:"templates"})]})]})]})}function $z({text:e}){const[t,n]=b.useState(!1),r=b.useCallback(async()=>{await navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),1500)},[e]);return u.jsx("button",{onClick:r,className:"text-xs text-muted-foreground hover:text-foreground transition-colors",children:t?"Copied!":"Copy"})}function Fz({discoveryData:e}){const t=Rd(),n=yx(),r=Te(j=>j.chatOpen),i=Te(j=>j.toggleChat),[s,a]=b.useState(()=>{try{const j=localStorage.getItem("dev-env.sidebar-open");return n?!1:j?j==="true":!0}catch{return!n}}),[o,l]=b.useState(()=>{try{const j=localStorage.getItem("dev-env.preview-open");return j?j==="true":!0}catch{return!0}}),[c,f]=b.useState("editor"),[d,p]=b.useState(!1),h=150,[m,v]=b.useState(!s),[S,y]=b.useState(!1);b.useEffect(()=>{try{localStorage.setItem("dev-env.sidebar-open",String(s))}catch{}},[s]),b.useEffect(()=>{try{localStorage.setItem("dev-env.preview-open",String(o))}catch{}},[o]);const _=b.useRef(n);b.useEffect(()=>{n&&!_.current&&s&&(y(!0),a(!1),setTimeout(()=>{v(!0),y(!1)},h)),!n&&_.current&&!s&&(y(!0),a(!0),setTimeout(()=>{v(!1),y(!1)},h)),_.current=n},[n,s]);const g=b.useCallback(()=>{if(t){p(j=>!j);return}y(!0),a(j=>!j),setTimeout(()=>{v(j=>!j),y(!1)},h)},[t]),z=b.useCallback(()=>l(j=>!j),[]),C=b.useRef(i),w=b.useRef(g),E=b.useRef(z);b.useEffect(()=>{C.current=i}),b.useEffect(()=>{w.current=g}),b.useEffect(()=>{E.current=z}),b.useEffect(()=>{const j=I=>{(I.metaKey||I.ctrlKey)&&(I.code==="KeyB"&&!I.shiftKey&&(I.preventDefault(),w.current()),I.code==="KeyJ"&&I.shiftKey&&(I.preventDefault(),I.stopPropagation(),C.current()),I.code==="KeyP"&&I.shiftKey&&(I.preventDefault(),E.current()))};return window.addEventListener("keydown",j,!0),()=>window.removeEventListener("keydown",j,!0)},[]);const R=rz,K=[{key:"editor",icon:nd,label:"Editor"},{key:"preview",icon:rd,label:"Preview"},{key:"chat",icon:id,label:"Chat"}];return t?u.jsx(R,{children:u.jsxs("div",{className:"flex flex-col h-full w-full overflow-hidden",children:[u.jsxs("div",{className:"flex items-center gap-1 px-2 py-1.5 border-b bg-sidebar shrink-0",children:[u.jsxs(Pd,{open:d,onOpenChange:p,children:[u.jsx(px,{asChild:!0,children:u.jsx(we,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0",children:u.jsx(Qc,{className:"h-4 w-4"})})}),u.jsx(Qa,{side:"left",className:"p-0 w-72",children:u.jsx(tl,{discoveryData:e,onToggleSidebar:()=>p(!1),isCollapsed:!1})})]}),u.jsx("div",{className:"flex gap-0.5 flex-1 min-w-0",children:K.map(({key:j,icon:I,label:O})=>u.jsxs(we,{variant:c===j?"default":"ghost",size:"sm",className:"h-7 gap-1.5 text-xs flex-1",onClick:()=>f(j),children:[u.jsx(I,{className:"h-3.5 w-3.5"}),u.jsx("span",{className:"hidden xs:inline",children:O})]},j))})]}),c!=="chat"&&u.jsx(yl,{previewOpen:o,onTogglePreview:z}),u.jsxs("div",{className:"flex-1 min-h-0",children:[c==="editor"&&u.jsx("div",{className:"h-full bg-surface-editor",children:u.jsx(nl,{})}),c==="preview"&&u.jsx("div",{className:"h-full bg-surface-preview",children:u.jsx(rl,{})}),c==="chat"&&u.jsx(lc,{})]})]})}):u.jsx(R,{children:u.jsxs("div",{className:"flex h-full w-full overflow-hidden",children:[u.jsx("div",{className:W("shrink-0 overflow-hidden border-r bg-sidebar","transition-[width] duration-300 ease-[cubic-bezier(0.16,1,0.3,1)]",s?"w-64":"w-12"),children:u.jsx(tl,{discoveryData:e,onToggleSidebar:g,isCollapsed:m,isAnimating:S})}),u.jsxs("div",{className:"flex-1 min-w-0 flex flex-col h-full",children:[u.jsx(yl,{previewOpen:o,onTogglePreview:z}),u.jsxs(Ty,{direction:"horizontal",autoSaveId:"layout-main",className:"flex-1 min-h-0",children:[u.jsx(Ms,{defaultSize:o?50:100,minSize:20,id:"editor",order:1,children:u.jsx("div",{className:"h-full bg-surface-editor",children:u.jsx(nl,{})})}),o&&u.jsxs(u.Fragment,{children:[u.jsx(pl,{withHandle:!0}),u.jsx(Ms,{defaultSize:50,minSize:20,id:"preview",order:2,children:u.jsx("div",{className:"h-full bg-surface-preview",children:u.jsx(rl,{})})})]}),r&&u.jsxs(u.Fragment,{children:[u.jsx(pl,{withHandle:!0}),u.jsx(Ms,{defaultSize:30,minSize:25,maxSize:50,id:"chat",order:3,children:u.jsx(lc,{})})]})]})]})]})})}function Lz(){const[e,t]=b.useState(null),[n,r]=b.useState(!0),[i,s]=b.useState(null),a=b.useCallback(async()=>{r(!0),s(null);try{const o=await fetch("/api/discovery/all");if(!o.ok)throw new Error(`Discovery failed: ${o.statusText}`);const l=await o.json();if(!l.success)throw new Error(l.error||"Discovery failed");t(l.data)}catch(o){console.error("Discovery error:",o),s(o instanceof Error?o.message:"Failed to fetch discovered items"),t({plugins:[],documents:[],themes:[]})}finally{r(!1)}},[]);return b.useEffect(()=>{a()},[a]),{data:e,loading:n,error:i,refetch:a}}function Zz(){const[e,t]=b.useState(!1),[n,r]=b.useState(null),[i,s]=b.useState(0);return{loadPlugins:b.useCallback(async()=>{t(!0),r(null);try{const o=await fetch("/api/discovery/load-plugins",{method:"POST"});if(!o.ok)throw new Error(`Failed to load plugins: ${o.statusText}`);const l=await o.json();if(!l.success)throw new Error(l.error||"Failed to load plugins");return s(l.data.loaded),!0}catch(o){return console.error("Plugin loading error:",o),r(o instanceof Error?o.message:"Failed to load plugins"),!1}finally{t(!1)}},[]),loading:e,error:n,loadedCount:i}}function Bz(){const{data:e,loading:t,error:n}=Lz(),{loadPlugins:r}=Zz(),i=Dt(s=>s.applyPluginsWithValidation);return b.useEffect(()=>{e&&e.plugins.length>0&&r().then(s=>{if(s){console.log("Plugins loaded successfully");const a=Dt.getState().selectedPlugins;a.size>0&&(console.log("Auto-applying persisted plugin selections:",Array.from(a)),i())}})},[e,r,i]),t?u.jsx("div",{className:"flex items-center justify-center h-screen",children:u.jsxs("div",{className:"text-center",children:[u.jsx("div",{className:"text-lg font-medium",children:"Discovering project resources..."}),u.jsx("div",{className:"text-sm text-muted-foreground mt-2",children:"Searching for documents, themes, and plugins"})]})}):n?u.jsx("div",{className:"flex items-center justify-center h-screen",children:u.jsxs("div",{className:"text-center",children:[u.jsx("div",{className:"text-lg font-medium text-destructive",children:"Discovery failed"}),u.jsx("div",{className:"text-sm text-muted-foreground mt-2",children:n}),u.jsx("div",{className:"text-xs text-muted-foreground mt-4",children:"The playground will work with limited functionality."})]})}):u.jsx(hg,{children:u.jsx(mg,{children:u.jsx(gg,{children:u.jsx(xg,{children:u.jsx(yg,{children:u.jsx(ex,{children:u.jsx($d,{children:u.jsx("section",{className:"flex h-screen w-full flex-col",children:u.jsx("div",{className:"grow overflow-hidden",children:u.jsx(Fz,{discoveryData:e})})})})})})})})})})}const Xz=Object.freeze(Object.defineProperty({__proto__:null,HomePage:Bz},Symbol.toStringTag,{value:"Module"}));export{Vt as B,It as D,Xz as H,Ly as P,Pr as S,Br as T,qd as a,Ad as b,St as c,Ut as d,Jt as e,Ry as u};
99
+ //# sourceMappingURL=HomePage-Bk6bS7bR.js.map