@deepagents/devtool 7.45.5 → 7.46.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.
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./css-DUjzNfgv.js","./css-BGIxQoYs.js","./html-BHZv6uqE.js","./javascript-BzbQS41l.js","./javascript-Yelw-5ZN.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{a as e,c as t,d as n,i as r,l as i,o as a,r as o,s,t as c,u as l}from"./preload-helper-DtyrgAzE.js";import{$ as u,$a as d,$n as f,A as p,Aa as m,An as h,Ar as g,B as _,Ba as v,Bi as y,Cn as b,Cr as x,Ct as S,D as C,Di as w,Dn as T,Dr as E,E as D,Ea as ee,En as te,Er as O,F as ne,Fa as k,Fn as re,Fr as A,G as j,Ga as ie,Gi as M,Gn as ae,H as oe,Ha as se,Hi as N,Hn as ce,I as le,Ia as ue,In as de,It as fe,J as pe,Ja as me,Ji as he,Jn as ge,Jr as _e,K as ve,Ka as ye,Kn as be,Kr as P,L as xe,La as Se,Li as Ce,Ln as we,M as Te,Mn as Ee,Mr as De,N as Oe,Na as ke,Nn as Ae,Nr as je,O as Me,Oa as Ne,Oi as Pe,On as Fe,Ot as Ie,P as Le,Pa as Re,Pn as ze,Pr as Be,Q as Ve,Qa as He,Qn as Ue,Qr as We,R as Ge,Ra as Ke,Ri as qe,Rn as Je,S as Ye,Sn as Xe,Sr as Ze,St as Qe,T as F,Ta as $e,Tn as et,Tr as tt,Tt as nt,U as rt,Ua as it,Ui as at,Un as ot,Ur as st,V as ct,Va as lt,Vi as ut,Vn as dt,Vr as ft,W as pt,Wi as mt,Wn as ht,X as gt,Xa as _t,Y as vt,Ya as yt,Yi as bt,Yn as xt,Z as St,Za as Ct,Zi as wt,Zn as Tt,Zr as Et,_ as Dt,_n as Ot,_r as kt,_t as At,ao as jt,at as Mt,b as eee,ba as Nt,bn as Pt,br as Ft,bt as It,ca as Lt,cr as Rt,ct as zt,dr as Bt,dt as Vt,ea as Ht,ei as Ut,eo as Wt,er as Gt,et as Kt,f as I,fi as qt,fr as Jt,ft as Yt,g as Xt,ga as Zt,gn as Qt,gr as $t,gt as en,h as tn,hn as nn,hr as rn,ht as an,i as on,ia as sn,in as cn,io as ln,ir as un,it as dn,j as fn,jn as pn,jr as mn,jt as hn,k as L,kn as gn,la as _n,lt as vn,m as yn,mi as bn,mn as xn,mr as Sn,mt as Cn,na as wn,ni as Tn,no as En,nr as Dn,nt as On,oa as kn,or as An,ot as jn,p as Mn,pi as Nn,pn as Pn,pr as Fn,pt as In,q as Ln,qa as Rn,qi as zn,qn as Bn,qr as Vn,rr as Hn,rt as Un,sr as Wn,st as Gn,t as Kn,ti as qn,to as Jn,tt as Yn,ur as Xn,ut as Zn,v as Qn,vn as $n,vt as er,w as tr,wn as nr,wr as rr,wt as ir,x as ar,xn as or,xr as sr,xt as cr,y as lr,yn as ur,yr as dr,yt as fr,z as pr,za as mr,zi as hr,zn as gr,zr as _r}from"./runtime-data-D25NI3GU.js";import{A as vr,C as yr,D as br,E as xr,F as Sr,I as Cr,M as wr,N as Tr,O as Er,P as Dr,S as Or,T as kr,_ as Ar,a as jr,b as Mr,c as Nr,d as Pr,f as Fr,g as Ir,h as Lr,j as Rr,k as zr,l as Br,m as Vr,o as Hr,p as Ur,s as Wr,t as Gr,v as Kr,x as qr,y as Jr}from"./chunk-RIHGWQV5-B2_k0rRP.js";var Yr={name:`circle-check-big`,size:24,node:[[`path`,{d:`M21.801 10A10 10 0 1 1 17 3.335`,key:`yps3ct`}],[`path`,{d:`m9 11 3 3L22 4`,key:`1pflzl`}]],aliases:[`check-circle`]};Yr.node;var Xr=En(Yr),Zr={name:`circle-question-mark`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9 9.5a3 2.5 0 016 0c0 2-2 2-3 3.5`,key:`1awbb0`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`help-circle`,`circle-help`]};Zr.node;var Qr=En(Zr),$r={name:`circle-x`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]],aliases:[`x-circle`]};$r.node;var ei=En($r),ti={name:`clock`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]};ti.node;var ni=En(ti),ri={name:`copy`,size:24,node:[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]};ri.node;var ii=En(ri),ai={name:`corner-down-right`,size:24,node:[[`path`,{d:`m15 10 5 5-5 5`,key:`qqa56n`}],[`path`,{d:`M4 4v7a4 4 0 0 0 4 4h12`,key:`z08zvw`}]]};ai.node;var oi=En(ai),si={name:`lightbulb`,size:24,node:[[`path`,{d:`M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5`,key:`1gvzjb`}],[`path`,{d:`M9 18h6`,key:`x1upvd`}],[`path`,{d:`M10 22h4`,key:`ceow96`}]]};si.node;var ci=En(si),li={name:`list-plus`,size:24,node:[[`path`,{d:`M16 5H3`,key:`m91uny`}],[`path`,{d:`M11 12H3`,key:`51ecnj`}],[`path`,{d:`M16 19H3`,key:`zzsher`}],[`path`,{d:`M18 9v6`,key:`1twb98`}],[`path`,{d:`M21 12h-6`,key:`bt1uis`}]]};li.node;var ui=En(li),di={name:`loader`,size:24,node:[[`path`,{d:`M12 2v4`,key:`3427ic`}],[`path`,{d:`m16.2 7.8 2.9-2.9`,key:`r700ao`}],[`path`,{d:`M18 12h4`,key:`wj9ykh`}],[`path`,{d:`m16.2 16.2 2.9 2.9`,key:`1bxg5t`}],[`path`,{d:`M12 18v4`,key:`jadmvz`}],[`path`,{d:`m4.9 19.1 2.9-2.9`,key:`bwix9q`}],[`path`,{d:`M2 12h4`,key:`j09sii`}],[`path`,{d:`m4.9 4.9 2.9 2.9`,key:`giyufr`}]]};di.node;var tee=En(di),fi={name:`mic`,size:24,node:[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M19 10v2a7 7 0 0 1-14 0v-2`,key:`1vc78b`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`13`,rx:`3`,key:`s6n7sd`}]]};fi.node;var pi=En(fi),mi={name:`minus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]};mi.node;var hi=En(mi),gi={name:`package`,size:24,node:[[`path`,{d:`M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z`,key:`1a0edw`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}],[`polyline`,{points:`3.29 7 12 12 20.71 7`,key:`ousv84`}],[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}]]};gi.node;var _i=En(gi),vi={name:`paperclip`,size:24,node:[[`path`,{d:`m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551`,key:`1miecu`}]]};vi.node;var yi=En(vi),bi={name:`plus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]};bi.node;var xi=En(bi),Si={name:`refresh-cw`,size:24,node:[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]};Si.node;var Ci=En(Si),wi={name:`square`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]};wi.node;var Ti=En(wi),Ei={name:`wrench`,size:24,node:[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]};Ei.node;var Di=En(Ei),R=n(e(),1);function Oi(e){let{open:t,defaultOpen:n=!1,onOpenChange:r,disabled:i}=e,[a,o]=ie({controlled:t,default:n,name:`Collapsible`,state:`open`}),{mounted:s,setMounted:c,transitionStatus:l}=Lt(a,!0,!0),u=m(),[d,f]=R.useState(),p=d===null?void 0:d??u,h=it(e=>{let t=!a,n=Ne(ee,e.nativeEvent);r(t,n),!n.isCanceled&&o(t)});return R.useMemo(()=>({defaultPanelId:u,disabled:i,handleTrigger:h,mounted:s,open:a,panelId:p,setMounted:c,setOpen:o,setPanelIdState:f,transitionStatus:l}),[u,i,h,s,a,p,c,o,f,l])}var ki=R.createContext(void 0);function Ai(){let e=R.useContext(ki);if(e===void 0)throw Error(Se(15));return e}var ji=`data-open`,Mi=`data-closed`,Ni=kn,Pi=`data-panel-open`,Fi={[ji]:``},Ii={[Mi]:``},Li={open(e){return e?{[Pi]:``}:null}},Ri={open(e){return e?Fi:Ii}},zi={height:void 0,width:void 0};function Bi(e){let{externalRef:t,hiddenUntilFound:n,id:r,keepMounted:i,mounted:a,onOpenChange:o,open:s,setMounted:c,setOpen:l,transitionStatus:u}=e,d=R.useRef(null),f=R.useRef(null),[p,m]=R.useState(zi),h=R.useRef(zi),g=R.useRef(!1),_=R.useRef(s),v=R.useRef(!1),[y,b]=R.useState(!1),x=R.useRef(null),S=ue(t,d),C=mt(s),w=at(d),T=!s&&!a,E=y?`idle`:u,D=s&&(_.current||v.current),ee=!s&&a&&f.current===`css-animation`&&p.height===void 0&&p.width===void 0?h.current:p,te=n&&T&&f.current!==`css-animation`,O=it((e,t=!0)=>{t&&(h.current=e),m(e)}),ne=it(()=>{x.current?.(),x.current=null}),k=it(e=>{ne(),x.current=()=>{x.current=null,e()}}),re=it(()=>{s&&a&&f.current===`css-animation`&&(v.current=!0)});mr(()=>{!y||u===`starting`||b(!1)},[y,u]),R.useEffect(()=>()=>{re(),ne()},[re,ne]),mr(()=>{s||(_.current=!1,v.current=!1);let e=d.current;if(!e)return;!s&&x.current&&ne();let t=Hi(e,D);if(f.current=t,s&&u===`idle`&&_.current&&t===`css-animation`){h.current=Vi(e);return}if(s&&u===`starting`){let n=g.current;if(g.current=!1,t===`none`){O(Vi(e)),b(!0);return}if(t===`css-transition`){let t=nee(e);if(O(Vi(e)),!n)return t;let r=Wi(e,`transition-duration`,`0s`);return k(r),b(!0),t}O(Vi(e));let r=Wi(e,`animation-name`,`none`);if(!n){r();return}let i=Wi(e,`animation-duration`,`0s`);r(),k(i),b(!0);return}if(!s&&a&&(u===`idle`||u===`starting`)){if(t===`none`){O(zi,!1),c(!1);return}O(Vi(e));return}if(u!==`ending`)return;if(t===`none`){c(!1);return}let n=Vi(e);if(!(n.height>0||n.width>0)){c(!1);return}O(n),t===`css-animation`&&Wi(e,`animation-name`,`none`)()},[a,s,ne,O,c,k,D,u]),N({enabled:s&&a&&E===`idle`,open:!0,ref:d,onComplete(){s&&O(zi,!1)}}),R.useEffect(()=>{if(s||!a||E!==`ending`)return;if(!d.current){c(!1),O(zi,!1);return}let e=new AbortController,t=-1;function n(){C.current||(c(!1),O(zi,!1))}return t=_n.request(()=>{w(n,e.signal)}),()=>{_n.cancel(t),e.abort()}},[C,a,s,E,w,O,c]),mr(()=>{let e=d.current;!e||!n||!T||e.setAttribute(`hidden`,`until-found`)},[T,n]),R.useEffect(function(){let e=d.current;if(!e)return;let t=M.create(),n=-1,r=(r,i)=>{t.start(0,()=>{C.current||(n=_n.request(()=>{C.current||(r&&(g.current=!1),i&&e.setAttribute(Ni,``),e.setAttribute(`hidden`,`until-found`))}))})},i=zn(e,`beforematch`,t=>{let n=Ne(Nt,t);if(o(!0,n),n.isCanceled){r(!1,!1);return}g.current=!0;let i=e.hasAttribute(Ni);e.removeAttribute(Ni),l(!0),r(!0,i)});return()=>{t.clear(),_n.cancel(n),i()}},[C,o,l]);let A=i||n||a||s;return{height:ee.height,props:{...te?{[Ni]:``}:void 0,hidden:T,id:r},ref:S,shouldPreventOpenAnimation:D,shouldRender:A,transitionStatus:E,width:ee.width}}function Vi(e){return{height:e.scrollHeight,width:e.scrollWidth}}function Hi(e,t){let n=Ht(e).getComputedStyle(e),r=(n.animationName.split(`,`).map(e=>e.trim()).some(e=>e!==``&&e!==`none`)||t)&&Ui(n.animationDuration),i=Ui(n.transitionDuration);return r&&i||i?`css-transition`:r?`css-animation`:`none`}function Ui(e){return e.split(`,`).map(e=>e.trim()).some(e=>e!==``&&Number.parseFloat(e)>0)}function Wi(e,t,n){let r=e.style.getPropertyValue(t),i=e.style.getPropertyPriority(t);return e.style.setProperty(t,n),()=>{if(r===``){e.style.removeProperty(t);return}e.style.setProperty(t,r,i)}}function nee(e){let t={"justify-content":e.style.justifyContent,"align-items":e.style.alignItems,"align-content":e.style.alignContent,"justify-items":e.style.justifyItems};Object.keys(t).forEach(t=>{e.style.setProperty(t,`initial`,`important`)});function n(){Object.entries(t).forEach(([t,n])=>{if(n===``){e.style.removeProperty(t);return}e.style.setProperty(t,n)})}let r=_n.request(n);return()=>{_n.cancel(r),n()}}var z=r(),Gi=hr(`group/attachment relative flex w-fit max-w-full min-w-0 shrink-0 flex-wrap rounded-xl border bg-card text-card-foreground transition-colors focus-within:ring-1 focus-within:ring-ring/50 has-[>a,>button]:hover:bg-muted/50 data-[state=error]:border-destructive/30 data-[state=idle]:border-dashed`,{variants:{size:{default:`gap-2 text-sm has-data-[slot=attachment-content]:px-2.5 has-data-[slot=attachment-content]:py-2 has-data-[slot=attachment-media]:p-2`,sm:`gap-2.5 text-xs has-data-[slot=attachment-content]:px-2 has-data-[slot=attachment-content]:py-1.5 has-data-[slot=attachment-media]:p-1.5`,xs:`gap-1.5 rounded-lg text-xs has-data-[slot=attachment-content]:px-1.5 has-data-[slot=attachment-content]:py-1 has-data-[slot=attachment-media]:p-1`},orientation:{horizontal:`min-w-40 items-center`,vertical:`w-24 flex-col has-data-[slot=attachment-content]:w-30`}}});function Ki({className:e,state:t=`done`,size:n=`default`,orientation:r=`horizontal`,...i}){return(0,z.jsx)(`div`,{"data-slot":`attachment`,"data-state":t,"data-size":n,"data-orientation":r,className:ut(Gi({size:n,orientation:r}),e),...i})}var qi=hr(`relative flex aspect-square w-10 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-muted text-foreground group-data-[orientation=vertical]/attachment:w-full group-data-[size=sm]/attachment:w-8 group-data-[size=xs]/attachment:w-7 group-data-[size=xs]/attachment:rounded-md group-data-[state=error]/attachment:bg-destructive/10 group-data-[state=error]/attachment:text-destructive group-data-[orientation=vertical]/attachment:*:data-[slot=spinner]:size-6! [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 group-data-[orientation=vertical]/attachment:[&_svg:not([class*='size-'])]:size-6 group-data-[size=xs]/attachment:[&_svg:not([class*='size-'])]:size-3.5`,{variants:{variant:{icon:``,image:`opacity-60 group-data-[state=done]/attachment:opacity-100 group-data-[state=idle]/attachment:opacity-100 *:[img]:aspect-square *:[img]:w-full *:[img]:object-cover`}},defaultVariants:{variant:`icon`}});function Ji({className:e,variant:t=`icon`,...n}){return(0,z.jsx)(`div`,{"data-slot":`attachment-media`,"data-variant":t,className:ut(qi({variant:t}),e),...n})}function Yi({className:e,...t}){return(0,z.jsx)(`div`,{"data-slot":`attachment-group`,className:ut(`flex min-w-0 scroll-fade-x snap-x snap-mandatory scroll-px-1 scrollbar-none gap-3 overflow-x-auto overscroll-x-contain py-1 *:data-[slot=attachment]:flex-none *:data-[slot=attachment]:snap-start`,e),...t})}function Xi({className:e,orientation:t=`horizontal`,...n}){return(0,z.jsx)(ze,{"data-slot":`separator`,orientation:t,className:ut(`shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch`,e),...n})}function Zi({className:e,size:t=`default`,...n}){return(0,z.jsx)(`div`,{"data-slot":`card`,"data-size":t,className:ut(`group/card flex flex-col gap-(--card-spacing) overflow-hidden rounded-xl bg-card py-(--card-spacing) text-sm text-card-foreground ring-1 ring-foreground/10 [--card-spacing:--spacing(4)] has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:[--card-spacing:--spacing(3)] data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl`,e),...n})}function Qi({className:e,...t}){return(0,z.jsx)(`div`,{"data-slot":`card-header`,className:ut(`group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-xl px-(--card-spacing) has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-(--card-spacing)`,e),...t})}function $i({className:e,...t}){return(0,z.jsx)(`div`,{"data-slot":`card-title`,className:ut(`text-base leading-snug font-medium group-data-[size=sm]/card:text-sm`,e),...t})}function ea({className:e,...t}){return(0,z.jsx)(`div`,{"data-slot":`card-description`,className:ut(`text-sm text-muted-foreground`,e),...t})}function ta({className:e,...t}){return(0,z.jsx)(`div`,{"data-slot":`card-action`,className:ut(`col-start-2 row-span-2 row-start-1 self-start justify-self-end`,e),...t})}function na({className:e,...t}){return(0,z.jsx)(`div`,{"data-slot":`card-content`,className:ut(`px-(--card-spacing)`,e),...t})}function ra({className:e,...t}){return(0,z.jsx)(`div`,{"data-slot":`card-footer`,className:ut(`flex items-center rounded-b-xl border-t bg-muted/50 p-(--card-spacing)`,e),...t})}function ia(e){if(!e)return null;for(let t of e.elements){let e=t.tagName;if(e===`BUTTON`||e===`INPUT`){let e=t;if(e.type===`submit`)return e}}return null}var aa=`data-checked`,oa=`data-unchecked`;function sa(e){return{checked(t){return e.indeterminate?{}:t?{[aa]:``}:{[oa]:``}},...Ae}}var ca=R.createContext({disabled:!1});function la(){return R.useContext(ca)}function ua(e,t,n,r=!0,i,a){let[o,s]=R.useState(),c=m(i?`${i}-label`:void 0),l=!!a?.trim(),u=e??(l?void 0:t)??o;return mr(()=>{let i=e||t||l||!r?void 0:da(n.current,c);o!==i&&s(i)}),u}function da(e,t){let n=fa(e);if(n)return!n.id&&t&&(n.id=t),n.id||void 0}function fa(e){if(!e)return;let t=e.parentElement;if(t&&t.tagName===`LABEL`)return t;let n=e.id;if(n){let t=e.nextElementSibling;if(t&&t.htmlFor===n)return t}let r=e.labels;return r&&r[0]}var pa=R.createContext(void 0);function ma(){return R.useContext(pa)}var ha=R.createContext(void 0);function ga(){let e=R.useContext(ha);if(e===void 0)throw Error(Se(14));return e}var _a=`data-parent`,va=R.forwardRef(function(e,t){let{checked:n,className:r,defaultChecked:i=!1,"aria-labelledby":a,disabled:o=!1,form:s,id:c,indeterminate:l=!1,inputRef:u,name:d,onCheckedChange:f,parent:p=!1,readOnly:g=!1,render:_,required:v=!1,uncheckedValue:y,value:b,nativeButton:x=!1,style:S,...C}=e,{clearErrors:w}=Fe(),{disabled:E,name:D,setDirty:ee,setFilled:O,setTouched:ne,state:k,validationMode:re,validityData:A,validation:j}=pn(),M=la(),{labelId:ae,registerControlId:oe,getDescriptionProps:se}=T(),N=ma(),le=N?.allValues===void 0?void 0:N.parent,de=le!==void 0,fe=E||M.disabled||N?.disabled||o,pe=D??d,me=b??pe,ge=m(),_e=N?.registerControlId!==oe,ve=te({id:c||void 0,enabled:_e}),ye=x?ve:ge,be={};de&&(p?be=le.getParentProps():me!==void 0&&(be=le.getChildProps(me)));let{checked:P=n,indeterminate:xe=l,onCheckedChange:Se,...Ce}=be,we=N?.value,Te=R.useRef(null),Ee=h(fe,Te),{getButtonProps:De,buttonRef:Oe}=he({disabled:fe,native:x}),Ae=N?.validation??j,[je,Me]=ie({controlled:me!==void 0&&we!==void 0&&!p?we.includes(me):P,default:i,name:`Checkbox`,state:`checked`}),Pe=de?!!P:je,Ie=de&&xe||l;gn(Te,ge,je,void 0,!N&&!fe,d);let Le=le?.registerChildId,ze=R.useRef(null),Be=Ae.registerInput,Ve=N?me:void 0,He=R.useCallback(e=>Be(e,{controlRef:Te,value:Ve}),[Be,Ve]),Ue=ue(u,ze,p?void 0:He),We=ua(a,ae,ze,!x,ve,C[`aria-label`]);mr(()=>{ze.current&&(ze.current.indeterminate=Ie),N||O(je)},[je,Ie,N,O]),ce(je,()=>{N||(w(pe),ee(je!==A.initialValue),Ae.change(je))});let Ge=Re({checked:je,disabled:fe,form:s,name:p?void 0:pe,id:x?void 0:ve,required:v,ref:Ue,style:pe?Tn:qn,tabIndex:-1,type:`checkbox`,"aria-hidden":!0,onChange(e){if(e.nativeEvent.defaultPrevented)return;if(g){e.preventDefault();return}let t=e.currentTarget.checked,n=Ne(Nt,e.nativeEvent);if(f?.(t,n),!n.isCanceled&&(Se?.(t,n),!n.isCanceled&&(Me(t),me!==void 0&&N!==void 0&&!p&&!de))){let e=t?[...N.value,me]:N.value.filter(e=>e!==me);N.setValue(e,n)}},onClick(e){e.stopPropagation()},onFocus(){Te.current?.focus()}},b===void 0?lt:{value:(N?je&&b:b)||``},se,e=>Ae.getValidationProps(fe,e));R.useEffect(()=>{if(!le||me===void 0)return;let e=le.disabledStatesRef.current;return e.set(me,fe),()=>{e.delete(me)}},[le,fe,me]);let Ke=R.useMemo(()=>({...k,checked:Pe,disabled:fe,readOnly:g,required:v,indeterminate:Ie}),[k,Pe,fe,g,v,Ie]),qe=sa(Ke),Je=ke(`span`,e,{state:Ke,ref:[Oe,Te,t],props:[{id:ye,role:`checkbox`,"aria-checked":Ie?`mixed`:Pe,"aria-readonly":g||void 0,"aria-required":v||void 0,"aria-labelledby":We,[_a]:p?``:void 0,onFocus(){Ee(!0)},onBlur(){let e=ze.current;e&&(ne(!0),Ee(!1),re===`onBlur`&&Ae.commit(N?we:e.checked))},onKeyDown(e){if(e.key!==`Enter`||(e.preventBaseUIHandler(),e.defaultPrevented))return;let t=ze.current?.form??null,n=e.currentTarget,r=e.nativeEvent,i=e.preventDefault,a=r.preventDefault,o=!1;e.preventDefault=()=>{o=!0,i.call(e)},r.preventDefault=()=>{o=!0,a.call(r)},a.call(r),Ht(n).queueMicrotask(()=>{e.preventDefault=i,r.preventDefault=a,o||ia(t)?.click()})},onClick(e){if(g||fe)return;e.preventDefault();let t=ze.current;t&&bt(t,e)}},C,Ce,De,se,e=>Ae.getValidationProps(fe,e)],stateAttributesMapping:qe}),Ye=Je.props.id;return mr(()=>{if(!(!Le||p||me===void 0||Ye===void 0))return Le(me,Ye)},[Le,p,me,Ye]),(0,z.jsxs)(ha.Provider,{value:Ke,children:[Je,!je&&!N&&pe&&!p&&y!==void 0&&(0,z.jsx)(`input`,{type:`hidden`,form:s,name:pe,value:y,disabled:fe}),(0,z.jsx)(`input`,{...Ge,suppressHydrationWarning:!0})]})}),ya=R.forwardRef(function(e,t){let{render:n,className:r,style:i,keepMounted:a=!1,...o}=e,s=ga(),c=s.checked||s.indeterminate,{mounted:l,transitionStatus:u,setMounted:d}=Lt(c),f=R.useRef(null),p={...s,transitionStatus:u};N({batch:!0,enabled:!c,open:c,ref:f,onComplete(){c||d(!1)}});let m={...sa(s),...sn},h=a||l,g=ke(`span`,e,{ref:[t,f],state:p,stateAttributesMapping:m,props:o});return h?g:null});function ba({className:e,...t}){return(0,z.jsx)(va,{"data-slot":`checkbox`,className:ut(`peer relative flex size-4 shrink-0 items-center justify-center rounded-[4px] border border-input transition-colors outline-none group-has-disabled/field:opacity-50 group-has-[:focus-visible]/field-label:ring-0 group-has-[:focus-visible]/field-label:not-data-checked:border-input after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground group-has-[:focus-visible]/field-label:data-checked:border-primary dark:data-checked:bg-primary`,e),...t,children:(0,z.jsx)(ya,{"data-slot":`checkbox-indicator`,className:`grid place-content-center text-current transition-none [&>svg]:size-3.5`,children:(0,z.jsx)(d,{})})})}var xa=hr(`group/code-block relative flex w-full min-w-0 flex-col overflow-hidden rounded-lg text-sm has-[>[data-slot=code-block-content]:focus-visible]:ring-3 has-[>[data-slot=code-block-content]:focus-visible]:ring-ring/50 data-[size=sm]:text-xs`,{variants:{variant:{default:`border border-input text-foreground has-[>[data-slot=code-block-content]:focus-visible]:border-ring dark:bg-input/30`,destructive:`border border-destructive/30 text-destructive dark:border-destructive/40`}},defaultVariants:{variant:`default`}});function Sa({className:e,variant:t=`default`,size:n=`default`,...r}){return(0,z.jsx)(`div`,{"data-slot":`code-block`,"data-variant":t,"data-size":n,className:ut(xa({variant:t}),e),...r})}function Ca({className:e,...t}){return(0,z.jsx)(`div`,{"data-slot":`code-block-actions`,className:ut(`-my-1 ms-auto -me-1.5 flex shrink-0 items-center gap-1 [[data-slot=code-block]>&]:absolute [[data-slot=code-block]>&]:end-2 [[data-slot=code-block]>&]:top-2 [[data-slot=code-block]>&]:z-10 [[data-slot=code-block]>&]:m-0 [[data-slot=code-block]>&]:opacity-0 [[data-slot=code-block]>&]:transition-opacity [[data-slot=code-block]>&]:group-focus-within/code-block:opacity-100 [[data-slot=code-block]>&]:group-hover/code-block:opacity-100 group-data-[size=sm]/code-block:[[data-slot=code-block]>&]:end-1.5 group-data-[size=sm]/code-block:[[data-slot=code-block]>&]:top-1.5 [[data-slot=code-block]>&]:pointer-coarse:opacity-100 [[data-slot=code-block]>&]:*:[button]:bg-background [[data-slot=code-block]>&]:*:[button]:ring-1 [[data-slot=code-block]>&]:*:[button]:ring-foreground/10`,e),...t})}function wa({className:e,children:t,style:n,wrap:r=!1,lineNumbers:i=!1,startLine:a=1,...o}){return(0,z.jsx)(`pre`,{"data-slot":`code-block-content`,"data-wrap":r||void 0,"data-numbered":i||void 0,dir:`ltr`,tabIndex:0,style:{counterReset:`line ${a-1}`,...n},className:ut(`min-h-0 min-w-0 scroll-fade-x scrollbar-thin overflow-auto px-3 py-3 text-start font-mono leading-relaxed outline-none group-has-data-[slot=code-block-footer]/code-block:pb-2 group-has-data-[slot=code-block-header]/code-block:pt-2 group-data-[size=sm]/code-block:px-2.5 group-data-[size=sm]/code-block:py-2.5 group-data-[size=sm]/code-block:group-has-data-[slot=code-block-header]/code-block:pt-1.5 data-wrap:scroll-fade-y data-wrap:wrap-break-word data-wrap:whitespace-pre-wrap`,e),...o,children:(0,z.jsx)(`code`,{"data-slot":`code-block-code`,className:`grid min-h-lh min-w-max content-start in-data-numbered:grid-cols-[auto_1fr] in-data-wrap:min-w-0`,children:i&&typeof t==`string`?t.replace(/\n$/,``).split(`
|
|
3
|
-
`).map((e,t)=>(0,z.jsx)(
|
|
4
|
-
`:n})})}var Da={...Ri,...sn},Oa=R.forwardRef(function(e,t){let{render:n,className:r,defaultOpen:i=!1,disabled:a=!1,onOpenChange:o,open:s,style:c,...l}=e,u=it(o),d=Oi({open:s,defaultOpen:i,onOpenChange:u,disabled:a}),f=R.useMemo(()=>({open:d.open,disabled:d.disabled,transitionStatus:d.transitionStatus}),[d.open,d.disabled,d.transitionStatus]),p=R.useMemo(()=>({...d,onOpenChange:u,state:f}),[d,u,f]),m=ke(`div`,e,{state:f,ref:t,props:l,stateAttributesMapping:Da});return(0,z.jsx)(ki.Provider,{value:p,children:m})}),ka={...Li,...sn},Aa=R.forwardRef(function(e,t){let{panelId:n,open:r,handleTrigger:i,state:a,disabled:o}=Ai(),{className:s,disabled:c=o,render:l,nativeButton:u=!0,style:d,...f}=e,{getButtonProps:p,buttonRef:m}=he({disabled:c,native:u});return ke(`button`,e,{state:a,ref:[t,m],props:[{"aria-controls":r?n:void 0,"aria-expanded":r,onClick:i},f,p],stateAttributesMapping:ka})}),ja=`--collapsible-panel-height`,Ma=`--collapsible-panel-width`,Na=R.forwardRef(function(e,t){let{className:n,hiddenUntilFound:r,keepMounted:i,render:a,id:o,style:s,...c}=e,{defaultPanelId:l,mounted:u,onOpenChange:d,open:f,setMounted:p,setPanelIdState:m,setOpen:h,state:g,transitionStatus:_}=Ai(),v=r??!1,y=i??!1,b=o||void 0,x=b??l;mr(()=>(m(e=>b??(e===null?void 0:e)),()=>{m(e=>e===b?null:e)}),[b,m]);let{height:S,props:C,ref:w,shouldPreventOpenAnimation:T,shouldRender:E,transitionStatus:D,width:ee}=Bi({externalRef:t,hiddenUntilFound:v,id:x,keepMounted:y,mounted:u,onOpenChange:d,open:f,setMounted:p,setOpen:h,transitionStatus:_}),te={...g,transitionStatus:D},O=k(s,te),ne=ke(`div`,{...e,style:void 0},{state:te,ref:w,props:[C,{style:{[ja]:S===void 0?`auto`:`${S}px`,[Ma]:ee===void 0?`auto`:`${ee}px`}},c,O?{style:O}:void 0,T?{style:{animationName:`none`}}:void 0],stateAttributesMapping:Da});return E?ne:null});function Pa({...e}){return(0,z.jsx)(Oa,{"data-slot":`collapsible`,...e})}function Fa({...e}){return(0,z.jsx)(Aa,{"data-slot":`collapsible-trigger`,...e})}function Ia({...e}){return(0,z.jsx)(Na,{"data-slot":`collapsible-content`,...e})}var La=R.createContext(void 0);function Ra(e=!1){let t=R.useContext(La);if(!t&&!e)throw Error(Se(86));return t}Object.keys(Ee);function za(e,t){return e.matches(`:disabled`)?!1:!t||e.form===t||e.form===null&&!e.hasAttribute(`form`)}var Ba=`data-composite-item-active`;function Va(e){let{loopFocus:t=!0,orientation:n=`both`,grid:r,onLoop:i,direction:a,highlightedIndex:o,onHighlightedIndexChange:s,rootRef:c,enableHomeAndEndKeys:l=!1,stopEventPropagation:u,disabledIndices:d,modifierKeys:p=v}=e,[m,h]=R.useState(0),g=r!=null,_=R.useRef(null),y=ue(_,c),b=R.useRef([]),x=R.useRef(!1),S=R.useRef(null),C=o??m,w=it((e,t=!1)=>{if(S.current=b.current[e]??null,(s??h)(e),t){let t=b.current[e];Gt(_.current,t,a,n)}}),T=it(e=>{if(e.size===0)return;if(x.current){let e=b.current,t=e.indexOf(S.current);if(t===-1){let t=e[C];!t||We(e,C,d)?w(Ha(e,d)):S.current=t}else t!==C&&w(t);return}x.current=!0;let t=Array.from(e.keys()),r=t.find(e=>e?.hasAttribute(`data-composite-item-active`))??null,i=r?e.get(r)?.index??-1:-1;if(i!==-1)w(i);else if(We(t,C,d)){let e=P(t,{disabledIndices:d});Et(t,e)||w(e)}Gt(_.current,r,a,n)});mr(()=>{if(d==null||o!=null||!x.current)return;let e=b.current;if(We(e,C,d)){let t=P(e,{disabledIndices:d});Et(e,t)||w(t)}},[d,o,C,b,w]);let E=it((e,t,n)=>i?i(e,t,n,b):n),D=it(e=>{let o=e.key===`Home`||e.key===`End`;if(!xt.has(e.key)||!l&&o||Ua(e,p)||!_.current)return;let s=a===`rtl`,c=s?be:Bn,m=s?Bn:be,h=n===`vertical`?ae:c,v=n===`vertical`?ge:m,y=Pe(e.nativeEvent);if(y!=null&&f(y)&&!xn(y)){let t=y.selectionStart,n=y.selectionEnd,r=y.value;if(t==null||e.shiftKey||t!==n||e.key!==v&&t<r.length||e.key!==h&&t>0)return}let x=C,S=_e(b,d),T=Vn(b,d);r!=null&&(x=r({disabledIndices:d,elementsRef:b,event:e,highlightedIndex:C,loopFocus:t,maxIndex:T,minIndex:S,onLoop:E,orientation:n,rtl:s}));let D=n!==`vertical`&&e.key===c||n!==`horizontal`&&e.key===`ArrowDown`,ee=n!==`vertical`&&e.key===m||n!==`horizontal`&&e.key===`ArrowUp`;l&&(e.key===`Home`?x=S:e.key===`End`&&(x=T)),x===C&&(D||ee)&&(t&&x===T&&D?(x=S,i&&(x=i(e,C,x,b))):t&&x===S&&ee?(x=T,i&&(x=i(e,C,x,b))):x=P(b.current,{startingIndex:x,decrement:ee,disabledIndices:d})),x!==C&&!Et(b.current,x)&&(u&&e.stopPropagation(),(g||o||D||ee)&&e.preventDefault(),w(x,!0),queueMicrotask(()=>{b.current[x]?.focus()}))});return{props:{ref:y,onFocus(e){let t=_.current,n=Pe(e.nativeEvent);!t||n==null||!f(n)||n.setSelectionRange(0,n.value.length)},onKeyDown:D},highlightedIndex:C,onHighlightedIndexChange:w,elementsRef:b,onMapChange:T,relayKeyboardEvent:D}}function Ha(e,t){let n=-1;for(let r=0;r<e.length;r+=1){let i=e[r];if(!(!i||We(e,r,t))){if(i.hasAttribute(`data-composite-item-active`))return r;n===-1&&(n=r)}}return Math.max(n,0)}function Ua(e,t){for(let n of Tt)if(!t.includes(n)&&e.getModifierState(n))return!0;return!1}function Wa(e){let{render:t,className:n,style:r,refs:i=v,props:a=v,state:o=lt,stateAttributesMapping:s,highlightedIndex:c,onHighlightedIndexChange:l,orientation:u,grid:d,loopFocus:f,onLoop:p,enableHomeAndEndKeys:m,onMapChange:h,stopEventPropagation:g=!0,rootRef:_,disabledIndices:y,modifierKeys:x,highlightItemOnHover:S=!1,tag:C=`div`,...w}=e,{props:T,highlightedIndex:E,onHighlightedIndexChange:D,elementsRef:ee,onMapChange:te,relayKeyboardEvent:O}=Va({grid:d,loopFocus:f,onLoop:p,orientation:u,highlightedIndex:c,onHighlightedIndexChange:l,rootRef:_,stopEventPropagation:g,enableHomeAndEndKeys:m,direction:b(),disabledIndices:y,modifierKeys:x}),ne=ke(C,e,{state:o,ref:i,props:[T,...a,w],stateAttributesMapping:s}),k=R.useMemo(()=>({highlightedIndex:E,onHighlightedIndexChange:D,highlightItemOnHover:S,relayKeyboardEvent:O}),[E,D,S,O]);return(0,z.jsx)(wt.Provider,{value:k,children:(0,z.jsx)(Ke,{elementsRef:ee,onMapChange:e=>{h?.(e),te(e)},children:ne})})}var Ga=R.createContext(void 0);function Ka(e){let t=R.useContext(Ga);if(t===void 0&&!e)throw Error(Se(47));return t}var qa=n(o(),1),Ja={...Rt,disabled:e=>e.disabled,instantType:e=>e.instantType===`trigger-change`&&!Rt.open(e)?void 0:e.instantType,openMethod:e=>e.openMethod,openChangeReason:e=>e.openChangeReason,isPressOpenedByTrigger:(e,t)=>e.openChangeReason===`trigger-press`&&Rt.isOpenedByTrigger(e,t),isTouchPressOpen:(e,t)=>t&&e.openMethod===`touch`&&e.openChangeReason===`trigger-press`,hasTriggerFocusGuards:(e,t)=>Rt.isOpenedByTrigger(e,t)&&!e.focusManagerModal,modal:e=>e.modal,titleElementId:e=>e.titleElementId,descriptionElementId:e=>e.descriptionElementId,openOnHover:e=>e.openOnHover,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin},Ya=class extends Xn{constructor(e,t,n){let r=new rn;super(Xa(e,r,t,n),Za(r),Ja)}setOpen=(e,t)=>{let n=t.reason===$e,r=t.reason===`trigger-press`&&t.event.detail===0,i=!e&&(t.reason===`escape-key`||t.reason==null),a=dr(t),o=this.select(`activeTriggerId`);if(!e&&t.reason===`close-press`&&t.trigger==null&&o!=null&&(t.trigger=this.context.triggerElements.getById(o)??this.select(`activeTriggerElement`)??void 0),this.context.onOpenChange?.(e,t),t.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(e,t);let s=()=>{let n=sr(this.state,e,t.trigger,a());n.openChangeReason=t.reason,this.update(n)};n?(this.context.stickIfOpen=!0,this.context.stickIfOpenTimeout.start(500,()=>{this.context.stickIfOpen=!1}),qa.flushSync(s)):s();let c;r?c=`click`:i?c=`dismiss`:t.reason===`focus-out`&&(c=`focus`),this.set(`instantType`,c)}};function Xa(e,t,n,r=!1){let i={...Wn(t,n,r),disabled:!1,modal:!1,focusManagerModal:!1,instantType:void 0,openMethod:null,openChangeReason:null,titleElementId:void 0,descriptionElementId:void 0,openOnHover:!1,closeDelay:0,adaptiveOrigin:void 0,...e};return i.open&&e?.mounted===void 0&&(i.mounted=!0),i}function Za(e){return{popupRef:R.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:R.createRef(),beforeTriggerFocusGuardRef:R.createRef(),beforeContentFocusGuardRef:R.createRef(),stickIfOpenTimeout:new M,stickIfOpen:!0,triggerElements:e}}var Qa=Bt(function({props:e}){let{children:t,open:n,defaultOpen:r=!1,onOpenChange:i,onOpenChangeComplete:a,modal:o=!1,handle:s,triggerId:c,defaultTriggerId:l=null}=e,u=eo(s,{modal:o,open:r,openProp:n,activeTriggerId:l,triggerIdProp:c});u.useControlledProp(`openProp`,n),u.useControlledProp(`triggerIdProp`,c);let d=u.useState(`open`),f=u.useState(`mounted`),p=u.useState(`payload`);u.useContextCallback(`onOpenChange`,i),u.useContextCallback(`onOpenChangeComplete`,a),O(u,d),Ze(u);let{forceUnmount:m}=x(d,u,()=>{u.context.stickIfOpen=!0,u.set(`openChangeReason`,null)});u.useSyncedValues({modal:o}),R.useEffect(()=>{d||u.context.stickIfOpenTimeout.clear()},[u,d]),R.useImperativeHandle(e.actionsRef,()=>({unmount:m,close:()=>u.setOpen(!1,Ne(Zt))}),[m,u]);let h=d||f||s!=null;return(0,z.jsxs)(Ga.Provider,{value:u,children:[s&&(0,z.jsx)(kt,{handle:s,store:u}),h&&(0,z.jsx)(to,{store:u,modal:o}),typeof t==`function`?t({payload:p}):t]})});function $a(e){return Ka(!0)?(0,z.jsx)(Qa,{props:e}):(0,z.jsx)(Be,{children:(0,z.jsx)(Qa,{props:e})})}function eo(e,t){let n=tt((e,n)=>new Ya(t,e,n));return R.useEffect(()=>n.context.stickIfOpenTimeout.disposeEffect(),[n]),n}function to({store:e,modal:t}){let n=g(e.useState(`floatingRootContext`),{outsidePressEvent:{mouse:t===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}}),r=n.reference,i=n.floating;return rr(e,{activeTriggerProps:r,inactiveTriggerProps:r,popupProps:i}),null}var no=Jt(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,handle:s,payload:c,openOnHover:l=!1,delay:u=300,closeDelay:d=0,id:f,...p}=e,h=Ka(!0),g=An(s)??h;if(!g)throw Error(Se(74));let _=m(f),v=g.useState(`isTriggerActive`,_),y=g.useState(`floatingRootContext`),b=g.useState(`isOpenedByTrigger`,_),x=g.useState(`triggerPopupId`,_),S=R.useRef(null),{registerTrigger:C,isMountedByThisTrigger:w}=E(_,S,g,{payload:c,disabled:a,openOnHover:l,closeDelay:d}),T=g.useState(`isPressOpenedByTrigger`,_),D=g.useState(`isTouchPressOpen`,l),ee=g.useState(`hasTriggerFocusGuards`,_),te=Hn(y,{enabled:!a&&l&&!D,mouseOnly:!0,move:!1,handleClose:Dn(),restMs:u,delay:{close:d},triggerElementRef:S,isActiveTrigger:v,isClosing:()=>g.select(`transitionStatus`)===`ending`}),O=mn(y,{stickIfOpen:it(()=>g.context.stickIfOpen)}),ne=dt(()=>g.select(`open`),e=>{g.set(`openMethod`,e)}),k=g.useState(`triggerProps`,w),{getButtonProps:re,buttonRef:A}=he({disabled:a,native:o}),j={open(e){return T?Nn.open(e):bn.open(e)}},{handlePreFocusGuardFocus:ie,handleFocusTargetFocus:M}=nn(g,S),ae=ke(`button`,e,{state:{disabled:a,open:b},ref:[A,t,C,S],props:[O.reference,te,k,ne,{[ft]:``,id:_,"aria-haspopup":`dialog`,"aria-expanded":b,"aria-controls":x},p,re],stateAttributesMapping:j}),oe=(0,z.jsx)(R.Fragment,{children:ae},_);return ee?(0,z.jsxs)(R.Fragment,{children:[(0,z.jsx)(Ut,{ref:g.context.beforeTriggerFocusGuardRef,onFocus:ie}),oe,(0,z.jsx)(Ut,{ref:g.context.triggerFocusTargetRef,onFocus:M})]}):oe}),ro=R.createContext(void 0);function io(){let e=R.useContext(ro);if(e===void 0)throw Error(Se(45));return e}var ao=R.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return Ka().useState(`mounted`)||n?(0,z.jsx)(ro.Provider,{value:n,children:(0,z.jsx)(_r,{ref:t,...r})}):null}),oo=R.createContext(void 0);function so(){let e=R.useContext(oo);if(!e)throw Error(Se(46));return e}var co=R.forwardRef(function(e,t){let{render:n,className:r,style:i,anchor:a,positionMethod:o,side:s,align:c,sideOffset:l,alignOffset:u,collisionBoundary:d=`clipping-ancestors`,collisionPadding:f,arrowPadding:p,sticky:m,disableAnchorTracking:h=!1,collisionAvoidance:g=st,..._}=e,v=Ka(),y=io(),b=A(),x=v.useState(`floatingRootContext`),S=v.useState(`mounted`),C=v.useState(`open`),w=v.useState(`openChangeReason`),T=v.useState(`activeTriggerElement`),E=v.useState(`modal`),D=v.useState(`openMethod`),ee=v.useState(`positionerElement`),te=v.useState(`instantType`),O=v.useState(`transitionStatus`),ne=Xe({anchor:a,floatingRootContext:x,positionMethod:o,mounted:S,side:s,sideOffset:l,align:c,alignOffset:u,arrowPadding:p,collisionBoundary:d,collisionPadding:f,sticky:m,disableAnchorTracking:h,keepMounted:y,nodeId:b,collisionAvoidance:g,adaptiveOrigin:v.useState(`adaptiveOrigin`)});Ot({store:v,domReference:x.useState(`domReferenceElement`),positionerElement:ee,open:C});let k=E===!0&&w!==`trigger-hover`;ur(C&&k,D===`touch`,ee,T);let re=v.useStateSetter(`positionerElement`),j=Pt(e,{open:C,side:ne.side,align:ne.align,anchorHidden:ne.anchorHidden,instant:te},{styles:ne.positionerStyles,transitionStatus:O,props:_,refs:[t,re],hidden:!S,inert:!C});return(0,z.jsxs)(oo.Provider,{value:ne,children:[S&&k&&(0,z.jsx)(ot,{inert:ht(!C),cutout:T}),(0,z.jsx)(je,{id:b,children:j})]})}),lo=R.createContext(void 0);function uo(){let[e,t]=R.useState(0),n=it(()=>(t(e=>e+1),()=>{t(e=>Math.max(0,e-1))}));return{context:R.useMemo(()=>({register:n}),[n]),hasClosePart:e>0}}var fo=R.forwardRef(function(e,t){let{render:n,className:r,style:i,initialFocus:a,finalFocus:o,...s}=e,c=Ka(),l=so(),u=$n(!0)!=null,{context:d,hasClosePart:f}=uo(),p=c.useState(`open`),m=c.useState(`openMethod`),h=c.useState(`instantType`),g=c.useState(`transitionStatus`),_=c.useState(`popupProps`),v=c.useState(`titleElementId`),y=c.useState(`descriptionElementId`),b=c.useState(`modal`),x=c.useState(`mounted`),S=c.useState(`openChangeReason`),C=c.useState(`activeTriggerElement`),w=c.useState(`floatingRootContext`),T=w.useState(`floatingId`),E=c.useState(`disabled`),D=c.useState(`openOnHover`),ee=c.useState(`closeDelay`);N({open:p,ref:c.context.popupRef,onComplete(){p&&c.context.onOpenChangeComplete?.(!0)}}),un(w,{enabled:D&&!E,closeDelay:ee});let te=a===void 0?Ft(c.context.popupRef):a,O=b!==!1&&f;c.useSyncedValue(`focusManagerModal`,O);let ne=c.useStateSetter(`popupElement`),k=ke(`div`,e,{state:{open:p,side:l.side,align:l.align,instant:h,transitionStatus:g},ref:[t,c.context.popupRef,ne],props:[_,{id:T,role:`dialog`,...$t,"aria-labelledby":v,"aria-describedby":y,onKeyDown(e){u&&xt.has(e.key)&&e.stopPropagation()}},or(g),s],stateAttributesMapping:qt});return(0,z.jsx)(De,{context:w,openInteractionType:m,modal:O,disabled:!x||S===`trigger-hover`,initialFocus:te,returnFocus:o,restoreFocus:`popup`,getInsideElements:()=>[c.context.beforeTriggerFocusGuardRef.current],previousFocusableElement:wn(C)?C:void 0,nextFocusableElement:c.context.triggerFocusTargetRef,beforeContentFocusGuardRef:c.context.beforeContentFocusGuardRef,children:(0,z.jsx)(lo.Provider,{value:d,children:k})})}),po=R.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=Ka(),s=m(a.id);return o.useSyncedValueWithCleanup(`titleElementId`,s),ke(`h2`,e,{ref:t,props:[{id:s},a]})}),mo=R.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=Ka(),s=m(a.id);return o.useSyncedValueWithCleanup(`descriptionElementId`,s),ke(`p`,e,{ref:t,props:[{id:s},a]})}),ho=`data-checked`,go=`data-unchecked`,_o={checked(e){return e?{[ho]:``}:{[go]:``}},...sn,...Ae},vo=R.createContext(void 0);function yo(){return R.useContext(vo)}var bo=R.createContext(void 0);function xo(){let e=R.useContext(bo);if(e===void 0)throw Error(Se(52));return e}var So=R.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,readOnly:a=!1,required:o=!1,"aria-labelledby":s,value:c,inputRef:l,nativeButton:u=!1,id:d,style:f,...p}=e,g=yo(),{disabled:_,readOnly:v,required:y,form:b,checkedValue:x,touched:S=!1,validation:C,name:w,setCheckedValue:E=se,setTouched:D=se,registerInputRef:ee=se}=g??{},{setTouched:O,setFilled:ne,state:k,disabled:re}=pn(),A=la(),{labelId:j,getDescriptionProps:ie}=T(),M=re||A.disabled||_||i,ae=v||a,oe=y||o,N=b,ce=g?x===c:c===``,le=R.useRef(null),de=h(M,le),fe=R.useRef(null),pe=C?.registerInput,me=ue(l,fe,ee,R.useCallback(e=>pe?.(e,{controlRef:le,value:void 0}),[pe]));mr(()=>{fe.current?.checked&&ne(!0)},[ne]),mr(()=>{if(fe.current){if(M&&ce){ee(null);return}ee(fe.current)}},[ce,M,ee]);let ge=m(),_e=te({id:d}),ve=u?void 0:_e,ye={role:`radio`,"aria-checked":ce,"aria-labelledby":ua(s,j,fe,!u,ve,p[`aria-label`]),[Ba]:ce?``:void 0,id:u?_e:ge,onKeyDown(e){e.key===`Enter`&&e.preventDefault()},onClick(e){if(e.defaultPrevented||M||ae)return;e.preventDefault();let t=fe.current;t&&bt(t,e)},onFocus(e){de(!0),!(e.defaultPrevented||M||ae||!S)&&(fe.current?.click(),D(!1))},onBlur(){g||de(!1)}},{getButtonProps:be,buttonRef:P}=he({disabled:M,native:u,composite:!1}),xe={type:`radio`,ref:me,form:N,id:ve,name:w,tabIndex:-1,style:w?Tn:qn,"aria-hidden":!0,...c===void 0?lt:{value:nr(c)},disabled:M,checked:ce,required:oe,readOnly:ae,onChange(e){if(e.nativeEvent.defaultPrevented||M||ae||c===void 0)return;let t=Ne(Nt,e.nativeEvent);E(c,t),!t.isCanceled&&O(!0)},onClick(e){e.stopPropagation()},onFocus(){le.current?.focus()}},Se=R.useMemo(()=>({...k,required:oe,disabled:M,readOnly:ae,checked:ce}),[k,M,ae,ce,oe]),Ce=Se,we=g!==void 0,Te=[t,le,P],Ee=[ye,p,be,ie,C?e=>C.getValidationProps(M,e):lt],De=ke(`span`,e,{enabled:!we,state:Se,ref:Te,props:Ee,stateAttributesMapping:_o});return(0,z.jsxs)(bo.Provider,{value:Ce,children:[we?(0,z.jsx)(Qt,{tag:`span`,render:n,className:r,style:f,state:Se,refs:Te,props:Ee,stateAttributesMapping:_o}):De,(0,z.jsx)(`input`,{...xe,suppressHydrationWarning:!0})]})}),Co=R.forwardRef(function(e,t){let{render:n,className:r,style:i,keepMounted:a=!1,...o}=e,s=xo(),c=s.checked,{mounted:l,transitionStatus:u,setMounted:d}=Lt(c),f={...s,transitionStatus:u},p=R.useRef(null),m=a||l,h=ke(`span`,e,{ref:[t,p],state:f,props:o,stateAttributesMapping:_o});return N({batch:!0,enabled:!c,open:c,ref:p,onComplete(){c||d(!1)}}),m?h:null}),wo=[Ue],To=R.forwardRef(function(e,t){let{render:n,className:r,disabled:i,readOnly:a,required:o,onValueChange:s,value:c,defaultValue:l,form:u,name:d,inputRef:f,id:p,style:h,...g}=e,{setTouched:_,setFocused:v,validationMode:y,name:b,disabled:x,state:S,validation:C,setDirty:E,setFilled:D,validityData:ee}=pn(),{labelId:te}=T(),{clearErrors:O,elementRef:ne}=Fe(),k=Ra(!0),re=x||i,A=b??d,j=m(p),[M,ae]=ie({controlled:c,default:l,name:`RadioGroup`,state:`value`}),[oe,se]=R.useState(!1),N=it((e,t)=>{s?.(e,t),!t.isCanceled&&ae(e)}),le=C.getInputControl,de=R.useMemo(()=>({get current(){return le()}}),[le]),fe=R.useRef(null),pe=R.useRef(null),me=ue(fe,f),he=R.useRef(me),ge=it(e=>{fe.current===e&&he.current===me||(he.current=me,me?.(e))});mr(()=>{ge(fe.current)},[me,ge]);let _e=it(e=>{if(e){if(!e.disabled){pe.current||=e;let t=fe.current;(e.checked||t==null||t.disabled)&&ge(e)}return()=>{pe.current===e&&(pe.current=null),fe.current===e&&ge(null)}}}),ve=it(()=>{let e=ne.current;if(!e)return M??null;for(let t of C.registeredInputs.keys())if(t.checked&&za(t,e))return M??null;return null});gn(de,j,M??null,ve,!re,d),ce(M,()=>{O(A),E(M!==ee.initialValue),D(M!=null),C.change(M);let e=pe.current;M==null&&e&&!e.disabled&&ge(e)});let ye=te??k?.legendId,be={...S,disabled:re??!1,required:o??!1,readOnly:a??!1},P=R.useMemo(()=>({checkedValue:M,disabled:re,form:u,validation:C,name:A,readOnly:a,registerInputRef:_e,required:o,setCheckedValue:N,setTouched:se,touched:oe}),[M,re,u,C,A,a,_e,o,N,se,oe]),xe={id:p,role:`radiogroup`,"aria-required":o||void 0,"aria-disabled":re||void 0,"aria-readonly":a||void 0,"aria-labelledby":ye,onBlur(e){w(e.currentTarget,e.relatedTarget)||(se(!1),_(!0),v(!1),y===`onBlur`&&C.commit(M))},onKeyDownCapture(e){e.key.startsWith(`Arrow`)&&se(!0)}};return(0,z.jsx)(vo.Provider,{value:P,children:(0,z.jsx)(Wa,{render:n,className:r,style:h,state:be,props:[xe,g,e=>C.getValidationProps(re??!1,e)],refs:[t],stateAttributesMapping:Ae,enableHomeAndEndKeys:!1,modifierKeys:wo})})}),Eo=hr(`group/item flex w-full flex-wrap items-center rounded-lg border text-sm transition-colors duration-100 outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 [a]:transition-colors [a]:hover:bg-muted`,{variants:{variant:{default:`border-transparent`,outline:`border-border`,muted:`border-transparent bg-muted/50`},size:{default:`gap-2.5 px-3 py-2.5`,sm:`gap-2.5 px-3 py-2.5`,xs:`gap-2 px-2.5 py-2 in-data-[slot=dropdown-menu-content]:p-0`}},defaultVariants:{variant:`default`,size:`default`}});function Do({className:e,variant:t=`default`,size:n=`default`,render:r,...i}){return de({defaultTagName:`div`,props:Re({className:ut(Eo({variant:t,size:n,className:e}))},i),render:r,state:{slot:`item`,variant:t,size:n}})}var Oo=hr(`flex shrink-0 items-center justify-center gap-2 group-has-data-[slot=item-description]/item:translate-y-0.5 group-has-data-[slot=item-description]/item:self-start [&_svg]:pointer-events-none`,{variants:{variant:{default:`bg-transparent`,icon:`[&_svg:not([class*='size-'])]:size-4`,image:`size-10 overflow-hidden rounded-sm group-data-[size=sm]/item:size-8 group-data-[size=xs]/item:size-6 [&_img]:size-full [&_img]:object-cover`}},defaultVariants:{variant:`default`}});function ko({className:e,variant:t=`default`,...n}){return(0,z.jsx)(`div`,{"data-slot":`item-media`,"data-variant":t,className:ut(Oo({variant:t,className:e})),...n})}function Ao({className:e,...t}){return(0,z.jsx)(`div`,{"data-slot":`item-content`,className:ut(`flex flex-1 flex-col gap-1 group-data-[size=xs]/item:gap-0 [&+[data-slot=item-content]]:flex-none`,e),...t})}function jo({className:e,...t}){return(0,z.jsx)(`div`,{"data-slot":`item-title`,className:ut(`line-clamp-1 flex w-fit items-center gap-2 text-sm leading-snug font-medium underline-offset-4`,e),...t})}function Mo({className:e,...t}){return(0,z.jsx)(`p`,{"data-slot":`item-description`,className:ut(`line-clamp-2 text-start text-sm leading-normal font-normal text-muted-foreground group-data-[size=xs]/item:text-xs [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary`,e),...t})}function No({...e}){return(0,z.jsx)($a,{"data-slot":`popover`,...e})}function Po({...e}){return(0,z.jsx)(no,{"data-slot":`popover-trigger`,...e})}function Fo({className:e,align:t=`center`,alignOffset:n=0,side:r=`bottom`,sideOffset:i=4,...a}){return(0,z.jsx)(ao,{children:(0,z.jsx)(co,{align:t,alignOffset:n,side:r,sideOffset:i,className:`isolate z-50`,children:(0,z.jsx)(fo,{"data-slot":`popover-content`,className:ut(`z-50 flex w-72 origin-(--transform-origin) flex-col gap-2.5 rounded-lg bg-popover p-2.5 text-sm text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-start-2 data-[side=inline-start]:slide-in-from-end-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 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...a})})})}function Io({className:e,...t}){return(0,z.jsx)(`div`,{"data-slot":`popover-header`,className:ut(`flex flex-col gap-0.5 text-sm`,e),...t})}function Lo({className:e,...t}){return(0,z.jsx)(po,{"data-slot":`popover-title`,className:ut(`font-medium`,e),...t})}function Ro({className:e,...t}){return(0,z.jsx)(mo,{"data-slot":`popover-description`,className:ut(`text-muted-foreground`,e),...t})}function zo({className:e,...t}){return(0,z.jsx)(To,{"data-slot":`radio-group`,className:ut(`grid w-full gap-2`,e),...t})}function Bo({className:e,...t}){return(0,z.jsx)(So,{"data-slot":`radio-group-item`,className:ut(`group/radio-group-item peer relative flex aspect-square size-4 shrink-0 rounded-full border border-input outline-none group-has-[:focus-visible]/field-label:ring-0 group-has-[:focus-visible]/field-label:not-data-checked:border-input after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground group-has-[:focus-visible]/field-label:data-checked:border-primary dark:data-checked:bg-primary`,e),...t,children:(0,z.jsx)(Co,{"data-slot":`radio-group-indicator`,className:`flex size-4 items-center justify-center`,children:(0,z.jsx)(`span`,{className:`absolute top-1/2 start-1/2 size-2 -translate-x-1/2 rtl:translate-x-1/2 -translate-y-1/2 rounded-full bg-primary-foreground`})})})}function Vo({className:e,...t}){return(0,z.jsx)(me,{"data-slot":`spinner`,role:`status`,"aria-label":`Loading`,className:ut(`size-4 animate-spin`,e),...t})}var Ho=class extends Error{constructor(e){super(e),this.name=`ShikiError`}};function Uo(e){return Wo(e)}function Wo(e){return Array.isArray(e)?Go(e):e instanceof RegExp?e:typeof e==`object`?Ko(e):e}function Go(e){let t=[];for(let n=0,r=e.length;n<r;n++)t[n]=Wo(e[n]);return t}function Ko(e){let t={};for(let n in e)t[n]=Wo(e[n]);return t}function qo(e,...t){return t.forEach(t=>{for(let n in t)e[n]=t[n]}),e}function Jo(e){let t=~e.lastIndexOf(`/`)||~e.lastIndexOf(`\\`);return t===0?e:~t===e.length-1?Jo(e.substring(0,e.length-1)):e.substr(~t+1)}var Yo=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,Xo=class{static hasCaptures(e){return e===null?!1:(Yo.lastIndex=0,Yo.test(e))}static replaceCaptures(e,t,n){return e.replace(Yo,(e,r,i,a)=>{let o=n[parseInt(r||i,10)];if(o){let e=t.substring(o.start,o.end);for(;e[0]===`.`;)e=e.substring(1);switch(a){case`downcase`:return e.toLowerCase();case`upcase`:return e.toUpperCase();default:return e}}else return e})}};function Zo(e,t){return e<t?-1:+(e>t)}function Qo(e,t){if(e===null&&t===null)return 0;if(!e)return-1;if(!t)return 1;let n=e.length,r=t.length;if(n===r){for(let r=0;r<n;r++){let n=Zo(e[r],t[r]);if(n!==0)return n}return 0}return n-r}function $o(e){return!!(/^#[0-9a-f]{6}$/i.test(e)||/^#[0-9a-f]{8}$/i.test(e)||/^#[0-9a-f]{3}$/i.test(e)||/^#[0-9a-f]{4}$/i.test(e))}function es(e){return e.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,`\\$&`)}var ts=class{constructor(e){this.fn=e}fn;cache=new Map;get(e){if(this.cache.has(e))return this.cache.get(e);let t=this.fn(e);return this.cache.set(e,t),t}},ns=class{constructor(e,t,n){this._colorMap=e,this._defaults=t,this._root=n}_colorMap;_defaults;_root;static createFromRawTheme(e,t){return this.createFromParsedTheme(cs(e),t)}static createFromParsedTheme(e,t){return ds(e,t)}_cachedMatchRoot=new ts(e=>this._root.match(e));getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(e){if(e===null)return this._defaults;let t=e.scopeName,n=this._cachedMatchRoot.get(t).find(t=>is(e.parent,t.parentScopes));return n?new ss(n.fontStyle,n.foreground,n.background):null}},rs=class e{constructor(e,t){this.parent=e,this.scopeName=t}parent;scopeName;static push(t,n){for(let r of n)t=new e(t,r);return t}static from(...t){let n=null;for(let r=0;r<t.length;r++)n=new e(n,t[r]);return n}push(t){return new e(this,t)}getSegments(){let e=this,t=[];for(;e;)t.push(e.scopeName),e=e.parent;return t.reverse(),t}toString(){return this.getSegments().join(` `)}extends(e){return this===e||this.parent!==null&&this.parent.extends(e)}getExtensionIfDefined(e){let t=[],n=this;for(;n&&n!==e;)t.push(n.scopeName),n=n.parent;return n===e?t.reverse():void 0}};function is(e,t){if(t.length===0)return!0;for(let n=0;n<t.length;n++){let r=t[n],i=!1;if(r===`>`){if(n===t.length-1)return!1;r=t[++n],i=!0}for(;e&&!as(e.scopeName,r);){if(i)return!1;e=e.parent}if(!e)return!1;e=e.parent}return!0}function as(e,t){return t===e||e.startsWith(t)&&e[t.length]===`.`}var ss=class{constructor(e,t,n){this.fontStyle=e,this.foregroundId=t,this.backgroundId=n}fontStyle;foregroundId;backgroundId};function cs(e){if(!e||!e.settings||!Array.isArray(e.settings))return[];let t=e.settings,n=[],r=0;for(let e=0,i=t.length;e<i;e++){let i=t[e];if(!i.settings)continue;let a;if(typeof i.scope==`string`){let e=i.scope;e=e.replace(/^[,]+/,``),e=e.replace(/[,]+$/,``),a=e.split(`,`)}else a=Array.isArray(i.scope)?i.scope:[``];let o=-1;if(typeof i.settings.fontStyle==`string`){o=0;let e=i.settings.fontStyle.split(` `);for(let t=0,n=e.length;t<n;t++)switch(e[t]){case`italic`:o|=1;break;case`bold`:o|=2;break;case`underline`:o|=4;break;case`strikethrough`:o|=8;break}}let s=null;typeof i.settings.foreground==`string`&&$o(i.settings.foreground)&&(s=i.settings.foreground);let c=null;typeof i.settings.background==`string`&&$o(i.settings.background)&&(c=i.settings.background);for(let t=0,i=a.length;t<i;t++){let i=a[t].trim().split(` `),l=i[i.length-1],u=null;i.length>1&&(u=i.slice(0,i.length-1),u.reverse()),n[r++]=new ls(l,u,e,o,s,c)}}return n}var ls=class{constructor(e,t,n,r,i,a){this.scope=e,this.parentScopes=t,this.index=n,this.fontStyle=r,this.foreground=i,this.background=a}scope;parentScopes;index;fontStyle;foreground;background},us=(e=>(e[e.NotSet=-1]=`NotSet`,e[e.None=0]=`None`,e[e.Italic=1]=`Italic`,e[e.Bold=2]=`Bold`,e[e.Underline=4]=`Underline`,e[e.Strikethrough=8]=`Strikethrough`,e))(us||{});function ds(e,t){e.sort((e,t)=>{let n=Zo(e.scope,t.scope);return n!==0||(n=Qo(e.parentScopes,t.parentScopes),n!==0)?n:e.index-t.index});let n=0,r=`#000000`,i=`#ffffff`;for(;e.length>=1&&e[0].scope===``;){let t=e.shift();t.fontStyle!==-1&&(n=t.fontStyle),t.foreground!==null&&(r=t.foreground),t.background!==null&&(i=t.background)}let a=new fs(t),o=new ss(n,a.getId(r),a.getId(i)),s=new hs(new ms(0,null,-1,0,0),[]);for(let t=0,n=e.length;t<n;t++){let n=e[t];s.insert(0,n.scope,n.parentScopes,n.fontStyle,a.getId(n.foreground),a.getId(n.background))}return new ns(a,o,s)}var fs=class{_isFrozen;_lastColorId;_id2color;_color2id;constructor(e){if(this._lastColorId=0,this._id2color=[],this._color2id=Object.create(null),Array.isArray(e)){this._isFrozen=!0;for(let t=0,n=e.length;t<n;t++)this._color2id[e[t]]=t,this._id2color[t]=e[t]}else this._isFrozen=!1}getId(e){if(e===null)return 0;e=e.toUpperCase();let t=this._color2id[e];if(t)return t;if(this._isFrozen)throw Error(`Missing color in color map - ${e}`);return t=++this._lastColorId,this._color2id[e]=t,this._id2color[t]=e,t}getColorMap(){return this._id2color.slice(0)}},ps=Object.freeze([]),ms=class e{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(e,t,n,r,i){this.scopeDepth=e,this.parentScopes=t||ps,this.fontStyle=n,this.foreground=r,this.background=i}clone(){return new e(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(e){let t=[];for(let n=0,r=e.length;n<r;n++)t[n]=e[n].clone();return t}acceptOverwrite(e,t,n,r){this.scopeDepth>e?console.log(`how did this happen?`):this.scopeDepth=e,t!==-1&&(this.fontStyle=t),n!==0&&(this.foreground=n),r!==0&&(this.background=r)}},hs=class e{constructor(e,t=[],n={}){this._mainRule=e,this._children=n,this._rulesWithParentScopes=t}_mainRule;_children;_rulesWithParentScopes;static _cmpBySpecificity(e,t){if(e.scopeDepth!==t.scopeDepth)return t.scopeDepth-e.scopeDepth;let n=0,r=0;for(;e.parentScopes[n]===`>`&&n++,t.parentScopes[r]===`>`&&r++,!(n>=e.parentScopes.length||r>=t.parentScopes.length);){let i=t.parentScopes[r].length-e.parentScopes[n].length;if(i!==0)return i;n++,r++}return t.parentScopes.length-e.parentScopes.length}match(t){if(t!==``){let e=t.indexOf(`.`),n,r;if(e===-1?(n=t,r=``):(n=t.substring(0,e),r=t.substring(e+1)),this._children.hasOwnProperty(n))return this._children[n].match(r)}let n=this._rulesWithParentScopes.concat(this._mainRule);return n.sort(e._cmpBySpecificity),n}insert(t,n,r,i,a,o){if(n===``){this._doInsertHere(t,r,i,a,o);return}let s=n.indexOf(`.`),c,l;s===-1?(c=n,l=``):(c=n.substring(0,s),l=n.substring(s+1));let u;this._children.hasOwnProperty(c)?u=this._children[c]:(u=new e(this._mainRule.clone(),ms.cloneArr(this._rulesWithParentScopes)),this._children[c]=u),u.insert(t+1,l,r,i,a,o)}_doInsertHere(e,t,n,r,i){if(t===null){this._mainRule.acceptOverwrite(e,n,r,i);return}for(let a=0,o=this._rulesWithParentScopes.length;a<o;a++){let o=this._rulesWithParentScopes[a];if(Qo(o.parentScopes,t)===0){o.acceptOverwrite(e,n,r,i);return}}n===-1&&(n=this._mainRule.fontStyle),r===0&&(r=this._mainRule.foreground),i===0&&(i=this._mainRule.background),this._rulesWithParentScopes.push(new ms(e,t,n,r,i))}},gs=class e{static toBinaryStr(e){return e.toString(2).padStart(32,`0`)}static print(t){let n=e.getLanguageId(t),r=e.getTokenType(t),i=e.getFontStyle(t),a=e.getForeground(t),o=e.getBackground(t);console.log({languageId:n,tokenType:r,fontStyle:i,foreground:a,background:o})}static getLanguageId(e){return(e&255)>>>0}static getTokenType(e){return(e&768)>>>8}static containsBalancedBrackets(e){return(e&1024)!=0}static getFontStyle(e){return(e&30720)>>>11}static getForeground(e){return(e&16744448)>>>15}static getBackground(e){return(e&4278190080)>>>24}static set(t,n,r,i,a,o,s){let c=e.getLanguageId(t),l=e.getTokenType(t),u=+!!e.containsBalancedBrackets(t),d=e.getFontStyle(t),f=e.getForeground(t),p=e.getBackground(t);return n!==0&&(c=n),r!==8&&(l=vs(r)),i!==null&&(u=+!!i),a!==-1&&(d=a),o!==0&&(f=o),s!==0&&(p=s),(c<<0|l<<8|u<<10|d<<11|f<<15|p<<24)>>>0}};function _s(e){return e}function vs(e){return e}function ys(e,t){let n=[],r=xs(e),i=r.next();for(;i!==null;){let e=0;if(i.length===2&&i.charAt(1)===`:`){switch(i.charAt(0)){case`R`:e=1;break;case`L`:e=-1;break;default:console.log(`Unknown priority ${i} in scope selector`)}i=r.next()}let t=o();if(n.push({matcher:t,priority:e}),i!==`,`)break;i=r.next()}return n;function a(){if(i===`-`){i=r.next();let e=a();return t=>!!e&&!e(t)}if(i===`(`){i=r.next();let e=s();return i===`)`&&(i=r.next()),e}if(bs(i)){let e=[];do e.push(i),i=r.next();while(bs(i));return n=>t(e,n)}return null}function o(){let e=[],t=a();for(;t;)e.push(t),t=a();return t=>e.every(e=>e(t))}function s(){let e=[],t=o();for(;t&&(e.push(t),i===`|`||i===`,`);){do i=r.next();while(i===`|`||i===`,`);t=o()}return t=>e.some(e=>e(t))}}function bs(e){return!!e&&!!e.match(/[\w\.:]+/)}function xs(e){let t=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,n=t.exec(e);return{next:()=>{if(!n)return null;let r=n[0];return n=t.exec(e),r}}}function Ss(e){typeof e.dispose==`function`&&e.dispose()}var Cs=class{constructor(e){this.scopeName=e}scopeName;toKey(){return this.scopeName}},ws=class{constructor(e,t){this.scopeName=e,this.ruleName=t}scopeName;ruleName;toKey(){return`${this.scopeName}#${this.ruleName}`}},Ts=class{_references=[];_seenReferenceKeys=new Set;get references(){return this._references}visitedRule=new Set;add(e){let t=e.toKey();this._seenReferenceKeys.has(t)||(this._seenReferenceKeys.add(t),this._references.push(e))}},Es=class{constructor(e,t){this.repo=e,this.initialScopeName=t,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new Cs(this.initialScopeName)]}repo;initialScopeName;seenFullScopeRequests=new Set;seenPartialScopeRequests=new Set;Q;processQueue(){let e=this.Q;this.Q=[];let t=new Ts;for(let n of e)Ds(n,this.initialScopeName,this.repo,t);for(let e of t.references)if(e instanceof Cs){if(this.seenFullScopeRequests.has(e.scopeName))continue;this.seenFullScopeRequests.add(e.scopeName),this.Q.push(e)}else{if(this.seenFullScopeRequests.has(e.scopeName)||this.seenPartialScopeRequests.has(e.toKey()))continue;this.seenPartialScopeRequests.add(e.toKey()),this.Q.push(e)}}};function Ds(e,t,n,r){let i=n.lookup(e.scopeName);if(!i){if(e.scopeName===t)throw Error(`No grammar provided for <${t}>`);return}let a=n.lookup(t);e instanceof Cs?ks({baseGrammar:a,selfGrammar:i},r):Os(e.ruleName,{baseGrammar:a,selfGrammar:i,repository:i.repository},r);let o=n.injections(e.scopeName);if(o)for(let e of o)r.add(new Cs(e))}function Os(e,t,n){if(t.repository&&t.repository[e]){let r=t.repository[e];As([r],t,n)}}function ks(e,t){e.selfGrammar.patterns&&Array.isArray(e.selfGrammar.patterns)&&As(e.selfGrammar.patterns,{...e,repository:e.selfGrammar.repository},t),e.selfGrammar.injections&&As(Object.values(e.selfGrammar.injections),{...e,repository:e.selfGrammar.repository},t)}function As(e,t,n){for(let r of e){if(n.visitedRule.has(r))continue;n.visitedRule.add(r);let e=r.repository?qo({},t.repository,r.repository):t.repository;Array.isArray(r.patterns)&&As(r.patterns,{...t,repository:e},n);let i=r.include;if(!i)continue;let a=Ns(i);switch(a.kind){case 0:ks({...t,selfGrammar:t.baseGrammar},n);break;case 1:ks(t,n);break;case 2:Os(a.ruleName,{...t,repository:e},n);break;case 3:case 4:let r=a.scopeName===t.selfGrammar.scopeName?t.selfGrammar:a.scopeName===t.baseGrammar.scopeName?t.baseGrammar:void 0;if(r){let i={baseGrammar:t.baseGrammar,selfGrammar:r,repository:e};a.kind===4?Os(a.ruleName,i,n):ks(i,n)}else a.kind===4?n.add(new ws(a.scopeName,a.ruleName)):n.add(new Cs(a.scopeName));break}}}var js=class{kind=0},ree=class{kind=1},iee=class{constructor(e){this.ruleName=e}ruleName;kind=2},aee=class{constructor(e){this.scopeName=e}scopeName;kind=3},Ms=class{constructor(e,t){this.scopeName=e,this.ruleName=t}scopeName;ruleName;kind=4};function Ns(e){if(e===`$base`)return new js;if(e===`$self`)return new ree;let t=e.indexOf(`#`);return t===-1?new aee(e):t===0?new iee(e.substring(1)):new Ms(e.substring(0,t),e.substring(t+1))}var Ps=/\\(\d+)/,Fs=/\\(\d+)/g,Is=-1,Ls=-2;function Rs(e){return e}function zs(e){return e}var Bs=class{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(e,t,n,r){this.$location=e,this.id=t,this._name=n||null,this._nameIsCapturing=Xo.hasCaptures(this._name),this._contentName=r||null,this._contentNameIsCapturing=Xo.hasCaptures(this._contentName)}get debugName(){let e=this.$location?`${Jo(this.$location.filename)}:${this.$location.line}`:`unknown`;return`${this.constructor.name}#${this.id} @ ${e}`}getName(e,t){return!this._nameIsCapturing||this._name===null||e===null||t===null?this._name:Xo.replaceCaptures(this._name,e,t)}getContentName(e,t){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:Xo.replaceCaptures(this._contentName,e,t)}},Vs=class extends Bs{retokenizeCapturedWithRuleId;constructor(e,t,n,r,i){super(e,t,n,r),this.retokenizeCapturedWithRuleId=i}dispose(){}collectPatterns(e,t){throw Error(`Not supported!`)}compile(e,t){throw Error(`Not supported!`)}compileAG(e,t,n,r){throw Error(`Not supported!`)}},Hs=class extends Bs{_match;captures;_cachedCompiledPatterns;constructor(e,t,n,r,i){super(e,t,n,null),this._match=new qs(r,this.id),this.captures=i,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null)}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(e,t){t.push(this._match)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new Js,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Us=class extends Bs{hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,n,r,i){super(e,t,n,r),this.patterns=i.patterns,this.hasMissingPatterns=i.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null)}collectPatterns(e,t){for(let n of this.patterns)e.getRule(n).collectPatterns(e,t)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new Js,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Ws=class extends Bs{_begin;beginCaptures;_end;endHasBackReferences;endCaptures;applyEndPatternLast;hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,n,r,i,a,o,s,c,l){super(e,t,n,r),this._begin=new qs(i,this.id),this.beginCaptures=a,this._end=new qs(o||``,-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=s,this.applyEndPatternLast=c||!1,this.patterns=l.patterns,this.hasMissingPatterns=l.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(e,t){return this._end.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e,t).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e,t).compileAG(e,n,r)}_getCachedCompiledPatterns(e,t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Js;for(let t of this.patterns)e.getRule(t).collectPatterns(e,this._cachedCompiledPatterns);this.applyEndPatternLast?this._cachedCompiledPatterns.push(this._end.hasBackReferences?this._end.clone():this._end):this._cachedCompiledPatterns.unshift(this._end.hasBackReferences?this._end.clone():this._end)}return this._end.hasBackReferences&&(this.applyEndPatternLast?this._cachedCompiledPatterns.setSource(this._cachedCompiledPatterns.length()-1,t):this._cachedCompiledPatterns.setSource(0,t)),this._cachedCompiledPatterns}},Gs=class extends Bs{_begin;beginCaptures;whileCaptures;_while;whileHasBackReferences;hasMissingPatterns;patterns;_cachedCompiledPatterns;_cachedCompiledWhilePatterns;constructor(e,t,n,r,i,a,o,s,c){super(e,t,n,r),this._begin=new qs(i,this.id),this.beginCaptures=a,this.whileCaptures=s,this._while=new qs(o,Ls),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=c.patterns,this.hasMissingPatterns=c.hasMissingPatterns,this._cachedCompiledPatterns=null,this._cachedCompiledWhilePatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null),this._cachedCompiledWhilePatterns&&=(this._cachedCompiledWhilePatterns.dispose(),null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugWhileRegExp(){return`${this._while.source}`}getWhileWithResolvedBackReferences(e,t){return this._while.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Js;for(let t of this.patterns)e.getRule(t).collectPatterns(e,this._cachedCompiledPatterns)}return this._cachedCompiledPatterns}compileWhile(e,t){return this._getCachedCompiledWhilePatterns(e,t).compile(e)}compileWhileAG(e,t,n,r){return this._getCachedCompiledWhilePatterns(e,t).compileAG(e,n,r)}_getCachedCompiledWhilePatterns(e,t){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new Js,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,t||``),this._cachedCompiledWhilePatterns}},Ks=class e{static createCaptureRule(e,t,n,r,i){return e.registerRule(e=>new Vs(t,e,n,r,i))}static getCompiledRuleId(t,n,r){return t.id||n.registerRule(i=>{if(t.id=i,t.match)return new Hs(t.$vscodeTextmateLocation,t.id,t.name,t.match,e._compileCaptures(t.captures,n,r));if(t.begin===void 0){t.repository&&(r=qo({},r,t.repository));let i=t.patterns;return i===void 0&&t.include&&(i=[{include:t.include}]),new Us(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,e._compilePatterns(i,n,r))}return t.while?new Gs(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,e._compileCaptures(t.beginCaptures||t.captures,n,r),t.while,e._compileCaptures(t.whileCaptures||t.captures,n,r),e._compilePatterns(t.patterns,n,r)):new Ws(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,e._compileCaptures(t.beginCaptures||t.captures,n,r),t.end,e._compileCaptures(t.endCaptures||t.captures,n,r),t.applyEndPatternLast,e._compilePatterns(t.patterns,n,r))}),t.id}static _compileCaptures(t,n,r){let i=[];if(t){let a=0;for(let e in t){if(e===`$vscodeTextmateLocation`)continue;let t=parseInt(e,10);t>a&&(a=t)}for(let e=0;e<=a;e++)i[e]=null;for(let a in t){if(a===`$vscodeTextmateLocation`)continue;let o=parseInt(a,10),s=0;t[a].patterns&&(s=e.getCompiledRuleId(t[a],n,r)),i[o]=e.createCaptureRule(n,t[a].$vscodeTextmateLocation,t[a].name,t[a].contentName,s)}}return i}static _compilePatterns(t,n,r){let i=[];if(t)for(let a=0,o=t.length;a<o;a++){let o=t[a],s=-1;if(o.include){let t=Ns(o.include);switch(t.kind){case 0:case 1:s=e.getCompiledRuleId(r[o.include],n,r);break;case 2:let i=r[t.ruleName];i&&(s=e.getCompiledRuleId(i,n,r));break;case 3:case 4:let a=t.scopeName,c=t.kind===4?t.ruleName:null,l=n.getExternalGrammar(a,r);if(l)if(c){let t=l.repository[c];t&&(s=e.getCompiledRuleId(t,n,l.repository))}else s=e.getCompiledRuleId(l.repository.$self,n,l.repository);break}}else s=e.getCompiledRuleId(o,n,r);if(s!==-1){let e=n.getRule(s),t=!1;if((e instanceof Us||e instanceof Ws||e instanceof Gs)&&e.hasMissingPatterns&&e.patterns.length===0&&(t=!0),t)continue;i.push(s)}}return{patterns:i,hasMissingPatterns:(t?t.length:0)!==i.length}}},qs=class e{source;ruleId;hasAnchor;hasBackReferences;_anchorCache;constructor(e,t){if(e&&typeof e==`string`){let t=e.length,n=0,r=[],i=!1;for(let a=0;a<t;a++)if(e.charAt(a)===`\\`&&a+1<t){let t=e.charAt(a+1);t===`z`?(r.push(e.substring(n,a)),r.push(`$(?!\\n)(?<!\\n)`),n=a+2):(t===`A`||t===`G`)&&(i=!0),a++}this.hasAnchor=i,n===0?this.source=e:(r.push(e.substring(n,t)),this.source=r.join(``))}else this.hasAnchor=!1,this.source=e;this.hasAnchor?this._anchorCache=this._buildAnchorCache():this._anchorCache=null,this.ruleId=t,typeof this.source==`string`?this.hasBackReferences=Ps.test(this.source):this.hasBackReferences=!1}clone(){return new e(this.source,this.ruleId)}setSource(e){this.source!==e&&(this.source=e,this.hasAnchor&&(this._anchorCache=this._buildAnchorCache()))}resolveBackReferences(e,t){if(typeof this.source!=`string`)throw Error(`This method should only be called if the source is a string`);let n=t.map(t=>e.substring(t.start,t.end));return Fs.lastIndex=0,this.source.replace(Fs,(e,t)=>es(n[parseInt(t,10)]||``))}_buildAnchorCache(){if(typeof this.source!=`string`)throw Error(`This method should only be called if the source is a string`);let e=[],t=[],n=[],r=[],i,a,o,s;for(i=0,a=this.source.length;i<a;i++)o=this.source.charAt(i),e[i]=o,t[i]=o,n[i]=o,r[i]=o,o===`\\`&&i+1<a&&(s=this.source.charAt(i+1),s===`A`?(e[i+1]=``,t[i+1]=``,n[i+1]=`A`,r[i+1]=`A`):s===`G`?(e[i+1]=``,t[i+1]=`G`,n[i+1]=``,r[i+1]=`G`):(e[i+1]=s,t[i+1]=s,n[i+1]=s,r[i+1]=s),i++);return{A0_G0:e.join(``),A0_G1:t.join(``),A1_G0:n.join(``),A1_G1:r.join(``)}}resolveAnchors(e,t){return!this.hasAnchor||!this._anchorCache||typeof this.source!=`string`?this.source:e?t?this._anchorCache.A1_G1:this._anchorCache.A1_G0:t?this._anchorCache.A0_G1:this._anchorCache.A0_G0}},Js=class{_items;_hasAnchors;_cached;_anchorCache;constructor(){this._items=[],this._hasAnchors=!1,this._cached=null,this._anchorCache={A0_G0:null,A0_G1:null,A1_G0:null,A1_G1:null}}dispose(){this._disposeCaches()}_disposeCaches(){this._cached&&=(this._cached.dispose(),null),this._anchorCache.A0_G0&&(this._anchorCache.A0_G0.dispose(),this._anchorCache.A0_G0=null),this._anchorCache.A0_G1&&(this._anchorCache.A0_G1.dispose(),this._anchorCache.A0_G1=null),this._anchorCache.A1_G0&&(this._anchorCache.A1_G0.dispose(),this._anchorCache.A1_G0=null),this._anchorCache.A1_G1&&(this._anchorCache.A1_G1.dispose(),this._anchorCache.A1_G1=null)}push(e){this._items.push(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}unshift(e){this._items.unshift(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}length(){return this._items.length}setSource(e,t){this._items[e].source!==t&&(this._disposeCaches(),this._items[e].setSource(t))}compile(e){if(!this._cached){let t=this._items.map(e=>e.source);this._cached=new Ys(e,t,this._items.map(e=>e.ruleId))}return this._cached}compileAG(e,t,n){return this._hasAnchors?t?n?(this._anchorCache.A1_G1||(this._anchorCache.A1_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G1):(this._anchorCache.A1_G0||(this._anchorCache.A1_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G0):n?(this._anchorCache.A0_G1||(this._anchorCache.A0_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G1):(this._anchorCache.A0_G0||(this._anchorCache.A0_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G0):this.compile(e)}_resolveAnchors(e,t,n){return new Ys(e,this._items.map(e=>e.resolveAnchors(t,n)),this._items.map(e=>e.ruleId))}},Ys=class{constructor(e,t,n){this.regExps=t,this.rules=n,this.scanner=e.createOnigScanner(t)}regExps;rules;scanner;dispose(){typeof this.scanner.dispose==`function`&&this.scanner.dispose()}toString(){let e=[];for(let t=0,n=this.rules.length;t<n;t++)e.push(` - `+this.rules[t]+`: `+this.regExps[t]);return e.join(`
|
|
5
|
-
`)}findNextMatchSync(e,t,n){let r=this.scanner.findNextMatchSync(e,t,n);return r?{ruleId:this.rules[r.index],captureIndices:r.captureIndices}:null}},
|
|
6
|
-
`;let a=this.createOnigString(e),o=a.content.length,s=new vc(n,e,this._tokenTypeMatchers,this.balancedBracketSelectors),c=ec(this,a,i,0,t,s,!0,r);return Ss(a),{lineLength:o,lineTokens:s,ruleStack:c.stack,stoppedEarly:c.stoppedEarly}}};function mc(e,t){return e=Uo(e),e.repository=e.repository||{},e.repository.$self={$vscodeTextmateLocation:e.$vscodeTextmateLocation,patterns:e.patterns,name:e.scopeName},e.repository.$base=t||e.repository.$self,e}var hc=class e{constructor(e,t,n){this.parent=e,this.scopePath=t,this.tokenAttributes=n}parent;scopePath;tokenAttributes;static fromExtension(t,n){let r=t,i=t?.scopePath??null;for(let t of n)i=rs.push(i,t.scopeNames),r=new e(r,i,t.encodedTokenAttributes);return r}static createRoot(t,n){return new e(null,new rs(null,t),n)}static createRootAndLookUpScopeName(t,n,r){let i=r.getMetadataForScope(t),a=new rs(null,t),o=r.themeProvider.themeMatch(a),s=e.mergeAttributes(n,i,o);return new e(null,a,s)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(` `)}equals(t){return e.equals(this,t)}static equals(e,t){do{if(e===t||!e&&!t)return!0;if(!e||!t||e.scopeName!==t.scopeName||e.tokenAttributes!==t.tokenAttributes)return!1;e=e.parent,t=t.parent}while(!0)}static mergeAttributes(e,t,n){let r=-1,i=0,a=0;return n!==null&&(r=n.fontStyle,i=n.foregroundId,a=n.backgroundId),gs.set(e,t.languageId,t.tokenType,null,r,i,a)}pushAttributed(t,n){if(t===null)return this;if(t.indexOf(` `)===-1)return e._pushAttributed(this,t,n);let r=t.split(/ /g),i=this;for(let t of r)i=e._pushAttributed(i,t,n);return i}static _pushAttributed(t,n,r){let i=r.getMetadataForScope(n),a=t.scopePath.push(n),o=r.themeProvider.themeMatch(a),s=e.mergeAttributes(t.tokenAttributes,i,o);return new e(t,a,s)}getScopeNames(){return this.scopePath.getSegments()}getExtensionIfDefined(e){let t=[],n=this;for(;n&&n!==e;)t.push({encodedTokenAttributes:n.tokenAttributes,scopeNames:n.scopePath.getExtensionIfDefined(n.parent?.scopePath??null)}),n=n.parent;return n===e?t.reverse():void 0}},gc=class e{constructor(e,t,n,r,i,a,o,s){this.parent=e,this.ruleId=t,this.beginRuleCapturedEOL=i,this.endRule=a,this.nameScopesList=o,this.contentNameScopesList=s,this.depth=this.parent?this.parent.depth+1:1,this._enterPos=n,this._anchorPos=r}parent;ruleId;beginRuleCapturedEOL;endRule;nameScopesList;contentNameScopesList;_stackElementBrand=void 0;static NULL=new e(null,0,0,0,!1,null,null,null);_enterPos;_anchorPos;depth;equals(t){return t!==null&&e._equals(this,t)}static _equals(e,t){return e===t?!0:this._structuralEquals(e,t)?hc.equals(e.contentNameScopesList,t.contentNameScopesList):!1}static _structuralEquals(e,t){do{if(e===t||!e&&!t)return!0;if(!e||!t||e.depth!==t.depth||e.ruleId!==t.ruleId||e.endRule!==t.endRule)return!1;e=e.parent,t=t.parent}while(!0)}clone(){return this}static _reset(e){for(;e;)e._enterPos=-1,e._anchorPos=-1,e=e.parent}reset(){e._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(t,n,r,i,a,o,s){return new e(this,t,n,r,i,a,o,s)}getEnterPos(){return this._enterPos}getAnchorPos(){return this._anchorPos}getRule(e){return e.getRule(this.ruleId)}toString(){let e=[];return this._writeString(e,0),`[`+e.join(`,`)+`]`}_writeString(e,t){return this.parent&&(t=this.parent._writeString(e,t)),e[t++]=`(${this.ruleId}, ${this.nameScopesList?.toString()}, ${this.contentNameScopesList?.toString()})`,t}withContentNameScopesList(e){return this.contentNameScopesList===e?this:this.parent.push(this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,this.endRule,this.nameScopesList,e)}withEndRule(t){return this.endRule===t?this:new e(this.parent,this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,t,this.nameScopesList,this.contentNameScopesList)}hasSameRuleAs(e){let t=this;for(;t&&t._enterPos===e._enterPos;){if(t.ruleId===e.ruleId)return!0;t=t.parent}return!1}toStateStackFrame(){return{ruleId:zs(this.ruleId),beginRuleCapturedEOL:this.beginRuleCapturedEOL,endRule:this.endRule,nameScopesList:this.nameScopesList?.getExtensionIfDefined(this.parent?.nameScopesList??null)??[],contentNameScopesList:this.contentNameScopesList?.getExtensionIfDefined(this.nameScopesList)??[]}}static pushFrame(t,n){let r=hc.fromExtension(t?.nameScopesList??null,n.nameScopesList);return new e(t,Rs(n.ruleId),n.enterPos??-1,n.anchorPos??-1,n.beginRuleCapturedEOL,n.endRule,r,hc.fromExtension(r,n.contentNameScopesList))}},_c=class{balancedBracketScopes;unbalancedBracketScopes;allowAny=!1;constructor(e,t){this.balancedBracketScopes=e.flatMap(e=>e===`*`?(this.allowAny=!0,[]):ys(e,dc).map(e=>e.matcher)),this.unbalancedBracketScopes=t.flatMap(e=>ys(e,dc).map(e=>e.matcher))}get matchesAlways(){return this.allowAny&&this.unbalancedBracketScopes.length===0}get matchesNever(){return this.balancedBracketScopes.length===0&&!this.allowAny}match(e){for(let t of this.unbalancedBracketScopes)if(t(e))return!1;for(let t of this.balancedBracketScopes)if(t(e))return!0;return this.allowAny}},vc=class{constructor(e,t,n,r){this.balancedBracketSelectors=r,this._emitBinaryTokens=e,this._tokenTypeOverrides=n,this._lineText=null,this._tokens=[],this._binaryTokens=[],this._lastTokenEndIndex=0}balancedBracketSelectors;_emitBinaryTokens;_lineText;_tokens;_binaryTokens;_lastTokenEndIndex;_tokenTypeOverrides;produce(e,t){this.produceFromScopes(e.contentNameScopesList,t)}produceFromScopes(e,t){if(this._lastTokenEndIndex>=t)return;if(this._emitBinaryTokens){let n=e?.tokenAttributes??0,r=!1;if(this.balancedBracketSelectors?.matchesAlways&&(r=!0),this._tokenTypeOverrides.length>0||this.balancedBracketSelectors&&!this.balancedBracketSelectors.matchesAlways&&!this.balancedBracketSelectors.matchesNever){let t=e?.getScopeNames()??[];for(let e of this._tokenTypeOverrides)e.matcher(t)&&(n=gs.set(n,0,_s(e.type),null,-1,0,0));this.balancedBracketSelectors&&(r=this.balancedBracketSelectors.match(t))}if(r&&(n=gs.set(n,0,8,r,-1,0,0)),this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-1]===n){this._lastTokenEndIndex=t;return}this._binaryTokens.push(this._lastTokenEndIndex),this._binaryTokens.push(n),this._lastTokenEndIndex=t;return}let n=e?.getScopeNames()??[];this._tokens.push({startIndex:this._lastTokenEndIndex,endIndex:t,scopes:n}),this._lastTokenEndIndex=t}getResult(e,t){return this._tokens.length>0&&this._tokens[this._tokens.length-1].startIndex===t-1&&this._tokens.pop(),this._tokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._tokens[this._tokens.length-1].startIndex=0),this._tokens}getBinaryResult(e,t){this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-2]===t-1&&(this._binaryTokens.pop(),this._binaryTokens.pop()),this._binaryTokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._binaryTokens[this._binaryTokens.length-2]=0);let n=new Uint32Array(this._binaryTokens.length);for(let e=0,t=this._binaryTokens.length;e<t;e++)n[e]=this._binaryTokens[e];return n}},yc=class{constructor(e,t){this._onigLib=t,this._theme=e}_onigLib;_grammars=new Map;_rawGrammars=new Map;_injectionGrammars=new Map;_theme;dispose(){for(let e of this._grammars.values())e.dispose()}setTheme(e){this._theme=e}getColorMap(){return this._theme.getColorMap()}addGrammar(e,t){this._rawGrammars.set(e.scopeName,e),t&&this._injectionGrammars.set(e.scopeName,t)}lookup(e){return this._rawGrammars.get(e)}injections(e){return this._injectionGrammars.get(e)}getDefaults(){return this._theme.getDefaults()}themeMatch(e){return this._theme.match(e)}grammarForScopeName(e,t,n,r,i){if(!this._grammars.has(e)){let a=this._rawGrammars.get(e);if(!a)return null;this._grammars.set(e,lc(e,a,t,n,r,i,this,this._onigLib))}return this._grammars.get(e)}},bc=class{_options;_syncRegistry;_ensureGrammarCache;constructor(e){this._options=e,this._syncRegistry=new yc(ns.createFromRawTheme(e.theme,e.colorMap),e.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(e,t){this._syncRegistry.setTheme(ns.createFromRawTheme(e,t))}getColorMap(){return this._syncRegistry.getColorMap()}loadGrammarWithEmbeddedLanguages(e,t,n){return this.loadGrammarWithConfiguration(e,t,{embeddedLanguages:n})}loadGrammarWithConfiguration(e,t,n){return this._loadGrammar(e,t,n.embeddedLanguages,n.tokenTypes,new _c(n.balancedBracketSelectors||[],n.unbalancedBracketSelectors||[]))}loadGrammar(e){return this._loadGrammar(e,0,null,null,null)}_loadGrammar(e,t,n,r,i){let a=new Es(this._syncRegistry,e);for(;a.Q.length>0;)a.Q.map(e=>this._loadSingleGrammar(e.scopeName)),a.processQueue();return this._grammarForScopeName(e,t,n,r,i)}_loadSingleGrammar(e){this._ensureGrammarCache.has(e)||(this._doLoadSingleGrammar(e),this._ensureGrammarCache.set(e,!0))}_doLoadSingleGrammar(e){let t=this._options.loadGrammar(e);if(t){let n=typeof this._options.getInjections==`function`?this._options.getInjections(e):void 0;this._syncRegistry.addGrammar(t,n)}}addGrammar(e,t=[],n=0,r=null){return this._syncRegistry.addGrammar(e,t),this._grammarForScopeName(e.scopeName,n,r)}_grammarForScopeName(e,t=0,n=null,r=null,i=null){return this._syncRegistry.grammarForScopeName(e,t,n,r,i)}},xc=gc.NULL;function Sc(e,t){let n=typeof e==`string`?{}:{...e.colorReplacements},r=typeof e==`string`?e:e.name;for(let[e,i]of Object.entries(t?.colorReplacements||{}))typeof i==`string`?n[e]=i:e===r&&Object.assign(n,i);return n}function Cc(e,t){return e&&(t?.[e?.toLowerCase()]||e)}function wc(e){return Array.isArray(e)?e:[e]}async function Tc(e){return Promise.resolve(typeof e==`function`?e():e).then(e=>e.default||e)}function Ec(e){return!e||[`plaintext`,`txt`,`text`,`plain`].includes(e)}function Dc(e){return e===`ansi`||Ec(e)}function Oc(e){return e===`none`}function kc(e){return Oc(e)}var Ac=/(\r?\n)/g;function jc(e,t=!1){if(e.length===0)return[[``,0]];let n=e.split(Ac),r=0,i=[];for(let e=0;e<n.length;e+=2){let a=t?n[e]+(n[e+1]||``):n[e];i.push([a,r]),r+=n[e].length,r+=n[e+1]?.length||0}return i}var Mc={light:`#333333`,dark:`#bbbbbb`},Nc={light:`#fffffe`,dark:`#1e1e1e`},Pc=`__shiki_resolved`;function Fc(e){if(e?.[Pc])return e;let t={...e};t.tokenColors&&!t.settings&&(t.settings=t.tokenColors,delete t.tokenColors),t.type||=`dark`,t.colorReplacements={...t.colorReplacements},t.settings||=[];let{bg:n,fg:r}=t;if(!n||!r){let e=t.settings?t.settings.find(e=>!e.name&&!e.scope):void 0;e?.settings?.foreground&&(r=e.settings.foreground),e?.settings?.background&&(n=e.settings.background),!r&&t?.colors?.[`editor.foreground`]&&(r=t.colors[`editor.foreground`]),!n&&t?.colors?.[`editor.background`]&&(n=t.colors[`editor.background`]),r||=t.type===`light`?Mc.light:Mc.dark,n||=t.type===`light`?Nc.light:Nc.dark,t.fg=r,t.bg=n}t.settings[0]&&t.settings[0].settings&&!t.settings[0].scope||t.settings.unshift({settings:{foreground:t.fg,background:t.bg}});let i=0,a=new Map;function o(e){if(a.has(e))return a.get(e);i+=1;let n=`#${i.toString(16).padStart(8,`0`).toLowerCase()}`;return t.colorReplacements?.[`#${n}`]?o(e):(a.set(e,n),n)}t.settings=t.settings.map(e=>{let n=e.settings?.foreground&&!e.settings.foreground.startsWith(`#`),r=e.settings?.background&&!e.settings.background.startsWith(`#`);if(!n&&!r)return e;let i={...e,settings:{...e.settings}};if(n){let n=o(e.settings.foreground);t.colorReplacements[n]=e.settings.foreground,i.settings.foreground=n}if(r){let n=o(e.settings.background);t.colorReplacements[n]=e.settings.background,i.settings.background=n}return i});for(let e of Object.keys(t.colors||{}))if((e===`editor.foreground`||e===`editor.background`||e.startsWith(`terminal.ansi`))&&!t.colors[e]?.startsWith(`#`)){let n=o(t.colors[e]);t.colorReplacements[n]=t.colors[e],t.colors[e]=n}return Object.defineProperty(t,Pc,{enumerable:!1,writable:!1,value:!0}),t}async function Ic(e){return[...new Set((await Promise.all(e.filter(e=>!Dc(e)).map(async e=>await Tc(e).then(e=>Array.isArray(e)?e:[e])))).flat())]}async function Lc(e){return(await Promise.all(e.map(async e=>kc(e)?null:Fc(await Tc(e))))).filter(e=>!!e)}function Rc(e,t){if(!t)return e;if(t[e]){let n=new Set([e]);for(;t[e];){if(e=t[e],n.has(e))throw new Ho(`Circular alias \`${[...n].join(` -> `)} -> ${e}\``);n.add(e)}}return e}var zc=class extends bc{_resolver;_themes;_langs;_alias;_resolvedThemes=new Map;_resolvedGrammars=new Map;_langMap=new Map;_langGraph=new Map;_textmateThemeCache=new WeakMap;_loadedThemesCache=null;_loadedLanguagesCache=null;constructor(e,t,n,r={}){super(e),this._resolver=e,this._themes=t,this._langs=n,this._alias=r,this._themes.map(e=>this.loadTheme(e)),this.loadLanguages(this._langs)}getTheme(e){return typeof e==`string`?this._resolvedThemes.get(e):this.loadTheme(e)}loadTheme(e){let t=Fc(e);return t.name&&(this._resolvedThemes.set(t.name,t),this._loadedThemesCache=null),t}getLoadedThemes(){return this._loadedThemesCache||=[...this._resolvedThemes.keys()],this._loadedThemesCache}setTheme(e){let t=this._textmateThemeCache.get(e);t||(t=ns.createFromRawTheme(e),this._textmateThemeCache.set(e,t)),this._syncRegistry.setTheme(t)}getGrammar(e){return e=Rc(e,this._alias),this._resolvedGrammars.get(e)}loadLanguage(e){if(this.getGrammar(e.name))return;let t=new Set([...this._langMap.values()].filter(t=>t.embeddedLangsLazy?.includes(e.name)));this._resolver.addLanguage(e);let n={balancedBracketSelectors:e.balancedBracketSelectors||[`*`],unbalancedBracketSelectors:e.unbalancedBracketSelectors||[]};this._syncRegistry._rawGrammars.set(e.scopeName,e);let r=this.loadGrammarWithConfiguration(e.scopeName,1,n);r.name=e.name,this._resolvedGrammars.set(e.name,r),e.aliases&&e.aliases.forEach(t=>{this._alias[t]=e.name}),this._loadedLanguagesCache=null;for(let e of t)this.reloadLanguage(e);if(e.injectTo){let t=[...this._langMap.values()].filter(t=>t!==e&&this._resolvedGrammars.has(t.name)&&e.injectTo.some(e=>t.scopeName===e||t.scopeName.startsWith(`${e}.`))&&!this.hasCurrentInjections(t.scopeName));for(let e of t)this.reloadLanguage(e)}}hasCurrentInjections(e){let t=this._syncRegistry?._injectionGrammars?.get(e)||[],n=this._resolver.getInjections(e)||[];return t.length===n.length&&t.every((e,t)=>e===n[t])}reloadLanguage(e){this._syncRegistry?._grammars?.get(e.scopeName)?.dispose(),this._resolvedGrammars.delete(e.name),this._loadedLanguagesCache=null,this._syncRegistry?._grammars?.delete(e.scopeName),this._syncRegistry?._injectionGrammars?.set(e.scopeName,this._resolver.getInjections(e.scopeName)||[]),this.loadLanguage(this._langMap.get(e.name)||e)}dispose(){super.dispose(),this._resolvedThemes.clear(),this._resolvedGrammars.clear(),this._langMap.clear(),this._langGraph.clear(),this._loadedThemesCache=null}loadLanguages(e){for(let t of e)this.resolveEmbeddedLanguages(t);let t=[...this._langGraph.entries()],n=t.filter(([e,t])=>!t);if(n.length){let e=t.filter(([e,t])=>t?(t.embeddedLanguages||t.embeddedLangs)?.some(e=>n.map(([e])=>e).includes(e)):!1).filter(e=>!n.includes(e));throw new Ho(`Missing languages ${n.map(([e])=>`\`${e}\``).join(`, `)}, required by ${e.map(([e])=>`\`${e}\``).join(`, `)}`)}for(let[e,n]of t)this._resolver.addLanguage(n);for(let[e,n]of t)this.loadLanguage(n)}getLoadedLanguages(){return this._loadedLanguagesCache||=[...new Set([...this._resolvedGrammars.keys(),...Object.keys(this._alias)])],this._loadedLanguagesCache}resolveEmbeddedLanguages(e){this._langMap.set(e.name,e),this._langGraph.set(e.name,e);let t=e.embeddedLanguages??e.embeddedLangs;if(t)for(let e of t)this._langGraph.set(e,this._langMap.get(e))}},Bc=class{_langs=new Map;_scopeToLang=new Map;_injections=new Map;_onigLib;constructor(e,t){this._onigLib={createOnigScanner:t=>e.createScanner(t),createOnigString:t=>e.createString(t)},t.forEach(e=>this.addLanguage(e))}get onigLib(){return this._onigLib}getLangRegistration(e){return this._langs.get(e)}loadGrammar(e){return this._scopeToLang.get(e)}addLanguage(e){this._langs.set(e.name,e),e.aliases&&e.aliases.forEach(t=>{this._langs.set(t,e)}),this._scopeToLang.set(e.scopeName,e),e.injectTo&&e.injectTo.forEach(t=>{this._injections.get(t)||this._injections.set(t,[]),this._injections.get(t).includes(e.scopeName)||this._injections.get(t).push(e.scopeName)})}getInjections(e){let t=e.split(`.`),n=[];for(let e=1;e<=t.length;e++){let r=t.slice(0,e).join(`.`);n=[...n,...this._injections.get(r)||[]]}return n}},Vc=0;function Hc(e){Vc+=1,e.warnings!==!1&&Vc>=10&&Vc%10==0&&console.warn(`[Shiki] ${Vc} instances have been created. Shiki is supposed to be used as a singleton, consider refactoring your code to cache your highlighter instance; Or call \`highlighter.dispose()\` to release unused instances.`);let t=!1;if(!e.engine)throw new Ho("`engine` option is required for synchronous mode");let n=(e.langs||[]).flat(1),r=(e.themes||[]).flat(1).map(Fc),i=new zc(new Bc(e.engine,n),r,n,e.langAlias),a;function o(t){return Rc(t,e.langAlias)}function s(e){g();let t=i.getGrammar(typeof e==`string`?e:e.name);if(!t)throw new Ho(`Language \`${e}\` not found, you may need to load it first`);return t}function c(e){if(e===`none`)return{bg:``,fg:``,name:`none`,settings:[],type:`dark`};g();let t=i.getTheme(e);if(!t)throw new Ho(`Theme \`${e}\` not found, you may need to load it first`);return t}function l(e){g();let t=c(e);return a!==e&&(i.setTheme(t),a=e),{theme:t,colorMap:i.getColorMap()}}function u(){return g(),i.getLoadedThemes()}function d(){return g(),i.getLoadedLanguages()}function f(...e){g(),i.loadLanguages(e.flat(1))}async function p(...e){return f(await Ic(e))}function m(...e){g();for(let t of e.flat(1))i.loadTheme(t)}async function h(...e){return g(),m(await Lc(e))}function g(){if(t)throw new Ho(`Shiki instance has been disposed`)}function _(){t||(t=!0,i.dispose(),--Vc)}return{setTheme:l,getTheme:c,getLanguage:s,getLoadedThemes:u,getLoadedLanguages:d,resolveLangAlias:o,loadLanguage:p,loadLanguageSync:f,loadTheme:h,loadThemeSync:m,dispose:_,[Symbol.dispose]:_}}async function Uc(e){e.engine||console.warn("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");let[t,n,r]=await Promise.all([Lc(e.themes||[]),Ic(e.langs||[]),e.engine]);return Hc({...e,themes:t,langs:n,engine:r})}var Wc=new WeakMap;function Gc(e,t){Wc.set(e,t)}function Kc(e){return Wc.get(e)}var qc=class e{_stacks={};lang;get themes(){return Object.keys(this._stacks)}get theme(){return this.themes[0]}get _stack(){return this._stacks[this.theme]}static initial(t,n){return new e(Object.fromEntries(wc(n).map(e=>[e,xc])),t)}constructor(...e){if(e.length===2){let[t,n]=e;this.lang=n,this._stacks=t}else{let[t,n,r]=e;this.lang=n,this._stacks={[r]:t}}}getInternalStack(e=this.theme){return this._stacks[e]}getScopes(e=this.theme){return Jc(this._stacks[e])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}};function Jc(e){let t=[],n=new Set;function r(e){if(n.has(e))return;n.add(e);let i=e?.nameScopesList?.scopeName;i&&t.push(i),e.parent&&r(e.parent)}return r(e),t}function Yc(e,t){if(!(e instanceof qc))throw new Ho(`Invalid grammar state`);return e.getInternalStack(t)}var Xc=/,/,Zc=/ /;function Qc(e,t,n={}){let{theme:r=e.getLoadedThemes()[0]}=n;if(Ec(e.resolveLangAlias(n.lang||`text`))||Oc(r))return jc(t).map(e=>[{content:e[0],offset:e[1]}]);let{theme:i,colorMap:a}=e.setTheme(r),o=e.getLanguage(n.lang||`text`);if(n.grammarState){if(n.grammarState.lang!==o.name)throw new Ho(`Grammar state language "${n.grammarState.lang}" does not match highlight language "${o.name}"`);if(!n.grammarState.themes.includes(i.name))throw new Ho(`Grammar state themes "${n.grammarState.themes}" do not contain highlight theme "${i.name}"`)}return el(t,o,i,a,n)}function $c(...e){if(e.length===2)return Kc(e[1]);let[t,n,r={}]=e,{lang:i=`text`,theme:a=t.getLoadedThemes()[0]}=r;if(Ec(i)||Oc(a))throw new Ho(`Plain language does not have grammar state`);if(i===`ansi`)throw new Ho(`ANSI language does not have grammar state`);let{theme:o,colorMap:s}=t.setTheme(a),c=t.getLanguage(i);return new qc(tl(n,c,o,s,r).stateStack,c.name,o.name)}function el(e,t,n,r,i){let a=tl(e,t,n,r,i),o=new qc(a.stateStack,t.name,n.name);return Gc(a.tokens,o),a.tokens}function tl(e,t,n,r,i){let a=Sc(n,i),{tokenizeMaxLineLength:o=0,tokenizeTimeLimit:s=500,includeExplanation:c=!1}=i,l=jc(e),u=i.grammarState?Yc(i.grammarState,n.name)??xc:i.grammarContextCode==null?xc:tl(i.grammarContextCode,t,n,r,{...i,grammarState:void 0,grammarContextCode:void 0}).stateStack,d=[],f=[];for(let e=0,i=l.length;e<i;e++){let[i,p]=l[e];if(i===``){d=[],f.push([]);continue}if(o>0&&i.length>=o){d=[],f.push([{content:i,offset:p,color:``,fontStyle:0}]);continue}let m,h,g;c&&c!==`tokenType`&&(m=t.tokenizeLine(i,u,s),h=m.tokens,g=0);let _=t.tokenizeLine2(i,u,s),v=_.tokens.length/2;for(let e=0;e<v;e++){let t=_.tokens[2*e],o=e+1<v?_.tokens[2*e+2]:i.length;if(t===o)continue;let s=_.tokens[2*e+1],l=Cc(r[gs.getForeground(s)],a),u=gs.getFontStyle(s),f={content:i.substring(t,o),offset:p+t,color:l,fontStyle:u};if(c===`tokenType`)f.type=gs.getTokenType(s);else if(c){let e=[];if(c!==`scopeName`)for(let t of n.settings){let n;switch(typeof t.scope){case`string`:n=t.scope.split(Xc).map(e=>e.trim());break;case`object`:n=t.scope;break;default:continue}e.push({settings:t,selectors:n.map(e=>e.split(Zc))})}f.explanation=[];let r=0;for(;t+r<o;){let t=h[g],n=i.substring(t.startIndex,t.endIndex);r+=n.length,f.explanation.push({content:n,scopes:c===`scopeName`?nl(t.scopes):rl(e,t.scopes)}),g+=1}}d.push(f)}f.push(d),d=[],u=_.ruleStack}return{tokens:f,stateStack:u}}function nl(e){return e.map(e=>({scopeName:e}))}function rl(e,t){let n=[];for(let r=0,i=t.length;r<i;r++){let i=t[r];n[r]={scopeName:i,themeMatches:ol(e,i,t.slice(0,r))}}return n}function il(e,t){return e===t||t.substring(0,e.length)===e&&t[e.length]===`.`}function al(e,t,n){if(!il(e.at(-1),t))return!1;let r=e.length-2,i=n.length-1;for(;r>=0&&i>=0;)il(e[r],n[i])&&--r,--i;return r===-1}function ol(e,t,n){let r=[];for(let{selectors:i,settings:a}of e)for(let e of i)if(al(e,t,n)){r.push(a);break}return r}function sl(e,t,n,r=Qc){let i=Object.entries(n.themes).filter(e=>e[1]).map(e=>({color:e[0],theme:e[1]})),a=i.map(i=>{let a=r(e,t,{...n,theme:i.theme});return{tokens:a,state:Kc(a),theme:typeof i.theme==`string`?i.theme:i.theme.name}}),o=cl(...a.map(e=>e.tokens)),s=o[0].map((e,t)=>e.map((e,r)=>{let a={content:e.content,variants:{},offset:e.offset};return`includeExplanation`in n&&n.includeExplanation&&(a.explanation=e.explanation),o.forEach((e,n)=>{let{content:o,explanation:s,offset:c,...l}=e[t][r];a.variants[i[n].color]=l}),a})),c=a[0].state?new qc(Object.fromEntries(a.map(e=>[e.theme,e.state?.getInternalStack(e.theme)])),a[0].state.lang):void 0;return c&&Gc(s,c),s}function cl(...e){let t=e.map(()=>[]),n=e.length;for(let r=0;r<e[0].length;r++){let i=e.map(e=>e[r]),a=t.map(()=>[]);t.forEach((e,t)=>e.push(a[t]));let o=i.map(()=>0),s=i.map(e=>e[0]);for(;s.every(e=>e);){let e=Math.min(...s.map(e=>e.content.length));for(let t=0;t<n;t++){let n=s[t];n.content.length===e?(a[t].push(n),o[t]+=1,s[t]=i[t][o[t]]):(a[t].push({...n,content:n.content.slice(0,e)}),s[t]={...n,content:n.content.slice(e),offset:n.offset+e})}}}return t}var ll=/["&'<>`]/g,ul=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,dl=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,fl=/[|\\{}()[\]^$+*?.]/g,pl=new WeakMap;function ml(e,t){if(e=e.replace(t.subset?hl(t.subset):ll,r),t.subset||t.escapeOnly)return e;return e.replace(ul,n).replace(dl,r);function n(e,n,r){return t.format((e.charCodeAt(0)-55296)*1024+e.charCodeAt(1)-56320+65536,r.charCodeAt(n+2),t)}function r(e,n,r){return t.format(e.charCodeAt(0),r.charCodeAt(n+1),t)}}function hl(e){let t=pl.get(e);return t||(t=gl(e),pl.set(e,t)),t}function gl(e){let t=[],n=-1;for(;++n<e.length;)t.push(e[n].replace(fl,`\\$&`));return RegExp(`(?:`+t.join(`|`)+`)`,`g`)}var _l=/[\dA-Fa-f]/;function vl(e,t,n){let r=`&#x`+e.toString(16).toUpperCase();return n&&t&&!_l.test(String.fromCharCode(t))?r:r+`;`}var yl=/\d/;function bl(e,t,n){let r=`&#`+String(e);return n&&t&&!yl.test(String.fromCharCode(t))?r:r+`;`}var xl=`AElig.AMP.Aacute.Acirc.Agrave.Aring.Atilde.Auml.COPY.Ccedil.ETH.Eacute.Ecirc.Egrave.Euml.GT.Iacute.Icirc.Igrave.Iuml.LT.Ntilde.Oacute.Ocirc.Ograve.Oslash.Otilde.Ouml.QUOT.REG.THORN.Uacute.Ucirc.Ugrave.Uuml.Yacute.aacute.acirc.acute.aelig.agrave.amp.aring.atilde.auml.brvbar.ccedil.cedil.cent.copy.curren.deg.divide.eacute.ecirc.egrave.eth.euml.frac12.frac14.frac34.gt.iacute.icirc.iexcl.igrave.iquest.iuml.laquo.lt.macr.micro.middot.nbsp.not.ntilde.oacute.ocirc.ograve.ordf.ordm.oslash.otilde.ouml.para.plusmn.pound.quot.raquo.reg.sect.shy.sup1.sup2.sup3.szlig.thorn.times.uacute.ucirc.ugrave.uml.uuml.yacute.yen.yuml`.split(`.`),Sl={nbsp:`\xA0`,iexcl:`¡`,cent:`¢`,pound:`£`,curren:`¤`,yen:`¥`,brvbar:`¦`,sect:`§`,uml:`¨`,copy:`©`,ordf:`ª`,laquo:`«`,not:`¬`,shy:``,reg:`®`,macr:`¯`,deg:`°`,plusmn:`±`,sup2:`²`,sup3:`³`,acute:`´`,micro:`µ`,para:`¶`,middot:`·`,cedil:`¸`,sup1:`¹`,ordm:`º`,raquo:`»`,frac14:`¼`,frac12:`½`,frac34:`¾`,iquest:`¿`,Agrave:`À`,Aacute:`Á`,Acirc:`Â`,Atilde:`Ã`,Auml:`Ä`,Aring:`Å`,AElig:`Æ`,Ccedil:`Ç`,Egrave:`È`,Eacute:`É`,Ecirc:`Ê`,Euml:`Ë`,Igrave:`Ì`,Iacute:`Í`,Icirc:`Î`,Iuml:`Ï`,ETH:`Ð`,Ntilde:`Ñ`,Ograve:`Ò`,Oacute:`Ó`,Ocirc:`Ô`,Otilde:`Õ`,Ouml:`Ö`,times:`×`,Oslash:`Ø`,Ugrave:`Ù`,Uacute:`Ú`,Ucirc:`Û`,Uuml:`Ü`,Yacute:`Ý`,THORN:`Þ`,szlig:`ß`,agrave:`à`,aacute:`á`,acirc:`â`,atilde:`ã`,auml:`ä`,aring:`å`,aelig:`æ`,ccedil:`ç`,egrave:`è`,eacute:`é`,ecirc:`ê`,euml:`ë`,igrave:`ì`,iacute:`í`,icirc:`î`,iuml:`ï`,eth:`ð`,ntilde:`ñ`,ograve:`ò`,oacute:`ó`,ocirc:`ô`,otilde:`õ`,ouml:`ö`,divide:`÷`,oslash:`ø`,ugrave:`ù`,uacute:`ú`,ucirc:`û`,uuml:`ü`,yacute:`ý`,thorn:`þ`,yuml:`ÿ`,fnof:`ƒ`,Alpha:`Α`,Beta:`Β`,Gamma:`Γ`,Delta:`Δ`,Epsilon:`Ε`,Zeta:`Ζ`,Eta:`Η`,Theta:`Θ`,Iota:`Ι`,Kappa:`Κ`,Lambda:`Λ`,Mu:`Μ`,Nu:`Ν`,Xi:`Ξ`,Omicron:`Ο`,Pi:`Π`,Rho:`Ρ`,Sigma:`Σ`,Tau:`Τ`,Upsilon:`Υ`,Phi:`Φ`,Chi:`Χ`,Psi:`Ψ`,Omega:`Ω`,alpha:`α`,beta:`β`,gamma:`γ`,delta:`δ`,epsilon:`ε`,zeta:`ζ`,eta:`η`,theta:`θ`,iota:`ι`,kappa:`κ`,lambda:`λ`,mu:`μ`,nu:`ν`,xi:`ξ`,omicron:`ο`,pi:`π`,rho:`ρ`,sigmaf:`ς`,sigma:`σ`,tau:`τ`,upsilon:`υ`,phi:`φ`,chi:`χ`,psi:`ψ`,omega:`ω`,thetasym:`ϑ`,upsih:`ϒ`,piv:`ϖ`,bull:`•`,hellip:`…`,prime:`′`,Prime:`″`,oline:`‾`,frasl:`⁄`,weierp:`℘`,image:`ℑ`,real:`ℜ`,trade:`™`,alefsym:`ℵ`,larr:`←`,uarr:`↑`,rarr:`→`,darr:`↓`,harr:`↔`,crarr:`↵`,lArr:`⇐`,uArr:`⇑`,rArr:`⇒`,dArr:`⇓`,hArr:`⇔`,forall:`∀`,part:`∂`,exist:`∃`,empty:`∅`,nabla:`∇`,isin:`∈`,notin:`∉`,ni:`∋`,prod:`∏`,sum:`∑`,minus:`−`,lowast:`∗`,radic:`√`,prop:`∝`,infin:`∞`,ang:`∠`,and:`∧`,or:`∨`,cap:`∩`,cup:`∪`,int:`∫`,there4:`∴`,sim:`∼`,cong:`≅`,asymp:`≈`,ne:`≠`,equiv:`≡`,le:`≤`,ge:`≥`,sub:`⊂`,sup:`⊃`,nsub:`⊄`,sube:`⊆`,supe:`⊇`,oplus:`⊕`,otimes:`⊗`,perp:`⊥`,sdot:`⋅`,lceil:`⌈`,rceil:`⌉`,lfloor:`⌊`,rfloor:`⌋`,lang:`〈`,rang:`〉`,loz:`◊`,spades:`♠`,clubs:`♣`,hearts:`♥`,diams:`♦`,quot:`"`,amp:`&`,lt:`<`,gt:`>`,OElig:`Œ`,oelig:`œ`,Scaron:`Š`,scaron:`š`,Yuml:`Ÿ`,circ:`ˆ`,tilde:`˜`,ensp:` `,emsp:` `,thinsp:` `,zwnj:``,zwj:``,lrm:``,rlm:``,ndash:`–`,mdash:`—`,lsquo:`‘`,rsquo:`’`,sbquo:`‚`,ldquo:`“`,rdquo:`”`,bdquo:`„`,dagger:`†`,Dagger:`‡`,permil:`‰`,lsaquo:`‹`,rsaquo:`›`,euro:`€`},Cl=[`cent`,`copy`,`divide`,`gt`,`lt`,`not`,`para`,`times`],wl={}.hasOwnProperty,Tl={},El;for(El in Sl)wl.call(Sl,El)&&(Tl[Sl[El]]=El);var Dl=/[^\dA-Za-z]/;function Ol(e,t,n,r){let i=String.fromCharCode(e);if(wl.call(Tl,i)){let e=Tl[i],a=`&`+e;return n&&xl.includes(e)&&!Cl.includes(e)&&(!r||t&&t!==61&&Dl.test(String.fromCharCode(t)))?a:a+`;`}return``}function kl(e,t,n){let r=vl(e,t,n.omitOptionalSemicolons),i;if((n.useNamedReferences||n.useShortestReferences)&&(i=Ol(e,t,n.omitOptionalSemicolons,n.attribute)),(n.useShortestReferences||!i)&&n.useShortestReferences){let i=bl(e,t,n.omitOptionalSemicolons);i.length<r.length&&(r=i)}return i&&(!n.useShortestReferences||i.length<r.length)?i:r}function Al(e){return`&#x`+e.toString(16).toUpperCase()+`;`}function jl(e,t){return ml(e,Object.assign({format:kl},t))}function Ml(e,t){return ml(e,Object.assign({format:Al},t))}var Nl=/^>|^->|<!--|-->|--!>|<!-$/g,Pl=[`>`],Fl=[`<`,`>`];function Il(e,t,n,r){return r.settings.bogusComments?`<?`+jl(e.value,Object.assign({},r.settings.characterReferences,{subset:Pl}))+`>`:`<!--`+e.value.replace(Nl,i)+`-->`;function i(e){return jl(e,Object.assign({},r.settings.characterReferences,{subset:Fl}))}}function Ll(e,t,n,r){return`<!`+(r.settings.upperDoctype?`DOCTYPE`:`doctype`)+(r.settings.tightDoctype?``:` `)+`html>`}var Rl=Vl(1),zl=Vl(-1),Bl=[];function Vl(e){return t;function t(t,n,r){let i=t?t.children:Bl,a=(n||0)+e,o=i[a];if(!r)for(;o&&Er(o);)a+=e,o=i[a];return o}}var Hl={}.hasOwnProperty;function Ul(e){return t;function t(t,n,r){return Hl.call(e,t.tagName)&&e[t.tagName](t,n,r)}}var Wl=Ul({body:ql,caption:Gl,colgroup:Gl,dd:Zl,dt:Xl,head:Gl,html:Kl,li:Yl,optgroup:$l,option:eu,p:Jl,rp:Ql,rt:Ql,tbody:nu,td:au,tfoot:ru,th:au,thead:tu,tr:iu});function Gl(e,t,n){let r=Rl(n,t,!0);return!r||r.type!==`comment`&&!(r.type===`text`&&Er(r.value.charAt(0)))}function Kl(e,t,n){let r=Rl(n,t);return!r||r.type!==`comment`}function ql(e,t,n){let r=Rl(n,t);return!r||r.type!==`comment`}function Jl(e,t,n){let r=Rl(n,t);return r?r.type===`element`&&(r.tagName===`address`||r.tagName===`article`||r.tagName===`aside`||r.tagName===`blockquote`||r.tagName===`details`||r.tagName===`div`||r.tagName===`dl`||r.tagName===`fieldset`||r.tagName===`figcaption`||r.tagName===`figure`||r.tagName===`footer`||r.tagName===`form`||r.tagName===`h1`||r.tagName===`h2`||r.tagName===`h3`||r.tagName===`h4`||r.tagName===`h5`||r.tagName===`h6`||r.tagName===`header`||r.tagName===`hgroup`||r.tagName===`hr`||r.tagName===`main`||r.tagName===`menu`||r.tagName===`nav`||r.tagName===`ol`||r.tagName===`p`||r.tagName===`pre`||r.tagName===`section`||r.tagName===`table`||r.tagName===`ul`):!n||!(n.type===`element`&&(n.tagName===`a`||n.tagName===`audio`||n.tagName===`del`||n.tagName===`ins`||n.tagName===`map`||n.tagName===`noscript`||n.tagName===`video`||n.tagName.includes(`-`)))}function Yl(e,t,n){let r=Rl(n,t);return!r||r.type===`element`&&r.tagName===`li`}function Xl(e,t,n){let r=Rl(n,t);return!!(r&&r.type===`element`&&(r.tagName===`dt`||r.tagName===`dd`))}function Zl(e,t,n){let r=Rl(n,t);return!r||r.type===`element`&&(r.tagName===`dt`||r.tagName===`dd`)}function Ql(e,t,n){let r=Rl(n,t);return!r||r.type===`element`&&(r.tagName===`rp`||r.tagName===`rt`)}function $l(e,t,n){let r=Rl(n,t);return!r||r.type===`element`&&r.tagName===`optgroup`}function eu(e,t,n){let r=Rl(n,t);return!r||r.type===`element`&&(r.tagName===`option`||r.tagName===`optgroup`)}function tu(e,t,n){let r=Rl(n,t);return!!(r&&r.type===`element`&&(r.tagName===`tbody`||r.tagName===`tfoot`))}function nu(e,t,n){let r=Rl(n,t);return!r||r.type===`element`&&(r.tagName===`tbody`||r.tagName===`tfoot`)}function ru(e,t,n){return!Rl(n,t)}function iu(e,t,n){let r=Rl(n,t);return!r||r.type===`element`&&r.tagName===`tr`}function au(e,t,n){let r=Rl(n,t);return!r||r.type===`element`&&(r.tagName===`td`||r.tagName===`th`)}var ou=Ul({body:lu,colgroup:uu,head:cu,html:su,tbody:du});function su(e){let t=Rl(e,-1);return!t||t.type!==`comment`}function cu(e){let t=new Set;for(let n of e.children)if(n.type===`element`&&(n.tagName===`base`||n.tagName===`title`)){if(t.has(n.tagName))return!1;t.add(n.tagName)}let n=e.children[0];return!n||n.type===`element`}function lu(e){let t=Rl(e,-1,!0);return!t||t.type!==`comment`&&!(t.type===`text`&&Er(t.value.charAt(0)))&&!(t.type===`element`&&(t.tagName===`meta`||t.tagName===`link`||t.tagName===`script`||t.tagName===`style`||t.tagName===`template`))}function uu(e,t,n){let r=zl(n,t);if(n&&r&&r.type===`element`&&r.tagName===`colgroup`&&Wl(r,n.children.indexOf(r),n))return!1;let i=Rl(e,-1,!0);return!!(i&&i.type===`element`&&i.tagName===`col`)}function du(e,t,n){let r=zl(n,t);if(n&&r&&r.type===`element`&&(r.tagName===`thead`||r.tagName===`tbody`)&&Wl(r,n.children.indexOf(r),n))return!1;let i=Rl(e,-1);return!!(i&&i.type===`element`&&i.tagName===`tr`)}var fu={name:[[`
|
|
2
|
+
import{a as e,c as t,d as n,i as r,l as i,o as a,r as o,s,t as c,u as l}from"./preload-helper-DtyrgAzE.js";import{$ as u,$a as d,$n as f,A as p,Aa as m,An as h,Ar as g,B as _,Ba as v,Bi as y,Cn as b,Cr as x,Ct as S,D as C,Di as w,Dn as T,Dr as E,E as D,Ea as ee,En as te,Er as O,F as ne,Fa as k,Fn as re,Fr as A,G as j,Ga as ie,Gi as M,Gn as ae,H as oe,Ha as se,Hi as N,Hn as ce,I as le,Ia as ue,In as de,It as fe,J as pe,Ja as me,Ji as he,Jn as ge,Jr as _e,K as ve,Ka as ye,Kn as be,Kr as P,L as xe,La as Se,Li as Ce,Ln as we,M as Te,Mn as Ee,Mr as De,N as Oe,Na as ke,Nn as Ae,Nr as je,O as Me,Oa as Ne,Oi as Pe,On as Fe,Ot as Ie,P as Le,Pa as Re,Pn as ze,Pr as Be,Q as Ve,Qa as He,Qn as Ue,Qr as We,R as Ge,Ra as Ke,Ri as qe,Rn as Je,S as Ye,Sn as Xe,Sr as Ze,St as Qe,T as F,Ta as $e,Tn as et,Tr as tt,Tt as nt,U as rt,Ua as it,Ui as at,Un as ot,Ur as st,V as ct,Va as lt,Vi as ut,Vn as dt,Vr as ft,W as pt,Wi as mt,Wn as ht,X as gt,Xa as _t,Y as vt,Ya as yt,Yi as bt,Yn as xt,Z as St,Za as Ct,Zi as wt,Zn as Tt,Zr as Et,_ as Dt,_n as Ot,_r as kt,_t as At,ao as jt,at as Mt,b as Nt,ba as Pt,bn as Ft,br as It,bt as Lt,ca as Rt,cr as zt,ct as eee,dr as Bt,dt as Vt,ea as Ht,ei as Ut,eo as Wt,er as Gt,et as Kt,f as I,fi as qt,fr as Jt,ft as Yt,g as Xt,ga as Zt,gn as Qt,gr as $t,gt as en,h as tn,hn as nn,hr as rn,ht as an,i as on,ia as sn,in as cn,io as ln,ir as un,it as dn,j as fn,jn as pn,jr as mn,jt as hn,k as L,kn as gn,la as _n,lt as vn,m as yn,mi as bn,mn as xn,mr as Sn,mt as Cn,na as wn,ni as Tn,no as En,nr as Dn,nt as On,oa as kn,or as An,ot as jn,p as Mn,pi as Nn,pn as Pn,pr as Fn,pt as In,q as Ln,qa as Rn,qi as zn,qn as Bn,qr as Vn,rr as Hn,rt as Un,sr as Wn,st as Gn,t as Kn,ti as qn,to as Jn,tt as Yn,ur as Xn,ut as Zn,v as Qn,vn as $n,vt as er,w as tr,wn as nr,wr as rr,wt as ir,x as ar,xn as or,xr as sr,xt as cr,y as lr,yn as ur,yr as dr,yt as fr,z as pr,za as mr,zi as hr,zn as gr,zr as _r}from"./runtime-data-D25NI3GU.js";import{A as vr,C as yr,D as br,E as xr,F as Sr,I as Cr,M as wr,N as Tr,O as Er,P as Dr,S as Or,T as kr,_ as Ar,a as jr,b as Mr,c as Nr,d as Pr,f as Fr,g as Ir,h as Lr,j as Rr,k as zr,l as Br,m as Vr,o as Hr,p as Ur,s as Wr,t as Gr,v as Kr,x as qr,y as Jr}from"./chunk-RIHGWQV5-B2_k0rRP.js";var Yr={name:`circle-check-big`,size:24,node:[[`path`,{d:`M21.801 10A10 10 0 1 1 17 3.335`,key:`yps3ct`}],[`path`,{d:`m9 11 3 3L22 4`,key:`1pflzl`}]],aliases:[`check-circle`]};Yr.node;var Xr=En(Yr),Zr={name:`circle-question-mark`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9 9.5a3 2.5 0 016 0c0 2-2 2-3 3.5`,key:`1awbb0`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`help-circle`,`circle-help`]};Zr.node;var tee=En(Zr),Qr={name:`circle-x`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]],aliases:[`x-circle`]};Qr.node;var $r=En(Qr),ei={name:`clock`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]};ei.node;var ti=En(ei),ni={name:`copy`,size:24,node:[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]};ni.node;var ri=En(ni),ii={name:`corner-down-right`,size:24,node:[[`path`,{d:`m15 10 5 5-5 5`,key:`qqa56n`}],[`path`,{d:`M4 4v7a4 4 0 0 0 4 4h12`,key:`z08zvw`}]]};ii.node;var ai=En(ii),oi={name:`lightbulb`,size:24,node:[[`path`,{d:`M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5`,key:`1gvzjb`}],[`path`,{d:`M9 18h6`,key:`x1upvd`}],[`path`,{d:`M10 22h4`,key:`ceow96`}]]};oi.node;var si=En(oi),ci={name:`list-plus`,size:24,node:[[`path`,{d:`M16 5H3`,key:`m91uny`}],[`path`,{d:`M11 12H3`,key:`51ecnj`}],[`path`,{d:`M16 19H3`,key:`zzsher`}],[`path`,{d:`M18 9v6`,key:`1twb98`}],[`path`,{d:`M21 12h-6`,key:`bt1uis`}]]};ci.node;var li=En(ci),ui={name:`loader`,size:24,node:[[`path`,{d:`M12 2v4`,key:`3427ic`}],[`path`,{d:`m16.2 7.8 2.9-2.9`,key:`r700ao`}],[`path`,{d:`M18 12h4`,key:`wj9ykh`}],[`path`,{d:`m16.2 16.2 2.9 2.9`,key:`1bxg5t`}],[`path`,{d:`M12 18v4`,key:`jadmvz`}],[`path`,{d:`m4.9 19.1 2.9-2.9`,key:`bwix9q`}],[`path`,{d:`M2 12h4`,key:`j09sii`}],[`path`,{d:`m4.9 4.9 2.9 2.9`,key:`giyufr`}]]};ui.node;var di=En(ui),fi={name:`mic`,size:24,node:[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M19 10v2a7 7 0 0 1-14 0v-2`,key:`1vc78b`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`13`,rx:`3`,key:`s6n7sd`}]]};fi.node;var pi=En(fi),mi={name:`minus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]};mi.node;var hi=En(mi),gi={name:`package`,size:24,node:[[`path`,{d:`M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z`,key:`1a0edw`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}],[`polyline`,{points:`3.29 7 12 12 20.71 7`,key:`ousv84`}],[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}]]};gi.node;var _i=En(gi),vi={name:`paperclip`,size:24,node:[[`path`,{d:`m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551`,key:`1miecu`}]]};vi.node;var yi=En(vi),bi={name:`plus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]};bi.node;var xi=En(bi),Si={name:`refresh-cw`,size:24,node:[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]};Si.node;var Ci=En(Si),wi={name:`square`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]};wi.node;var Ti=En(wi),Ei={name:`wrench`,size:24,node:[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]};Ei.node;var Di=En(Ei),R=n(e(),1);function Oi(e){let{open:t,defaultOpen:n=!1,onOpenChange:r,disabled:i}=e,[a,o]=ie({controlled:t,default:n,name:`Collapsible`,state:`open`}),{mounted:s,setMounted:c,transitionStatus:l}=Rt(a,!0,!0),u=m(),[d,f]=R.useState(),p=d===null?void 0:d??u,h=it(e=>{let t=!a,n=Ne(ee,e.nativeEvent);r(t,n),!n.isCanceled&&o(t)});return R.useMemo(()=>({defaultPanelId:u,disabled:i,handleTrigger:h,mounted:s,open:a,panelId:p,setMounted:c,setOpen:o,setPanelIdState:f,transitionStatus:l}),[u,i,h,s,a,p,c,o,f,l])}var ki=R.createContext(void 0);function Ai(){let e=R.useContext(ki);if(e===void 0)throw Error(Se(15));return e}var ji=`data-open`,Mi=`data-closed`,Ni=kn,Pi=`data-panel-open`,Fi={[ji]:``},Ii={[Mi]:``},Li={open(e){return e?{[Pi]:``}:null}},Ri={open(e){return e?Fi:Ii}},zi={height:void 0,width:void 0};function Bi(e){let{externalRef:t,hiddenUntilFound:n,id:r,keepMounted:i,mounted:a,onOpenChange:o,open:s,setMounted:c,setOpen:l,transitionStatus:u}=e,d=R.useRef(null),f=R.useRef(null),[p,m]=R.useState(zi),h=R.useRef(zi),g=R.useRef(!1),_=R.useRef(s),v=R.useRef(!1),[y,b]=R.useState(!1),x=R.useRef(null),S=ue(t,d),C=mt(s),w=at(d),T=!s&&!a,E=y?`idle`:u,D=s&&(_.current||v.current),ee=!s&&a&&f.current===`css-animation`&&p.height===void 0&&p.width===void 0?h.current:p,te=n&&T&&f.current!==`css-animation`,O=it((e,t=!0)=>{t&&(h.current=e),m(e)}),ne=it(()=>{x.current?.(),x.current=null}),k=it(e=>{ne(),x.current=()=>{x.current=null,e()}}),re=it(()=>{s&&a&&f.current===`css-animation`&&(v.current=!0)});mr(()=>{!y||u===`starting`||b(!1)},[y,u]),R.useEffect(()=>()=>{re(),ne()},[re,ne]),mr(()=>{s||(_.current=!1,v.current=!1);let e=d.current;if(!e)return;!s&&x.current&&ne();let t=Hi(e,D);if(f.current=t,s&&u===`idle`&&_.current&&t===`css-animation`){h.current=Vi(e);return}if(s&&u===`starting`){let n=g.current;if(g.current=!1,t===`none`){O(Vi(e)),b(!0);return}if(t===`css-transition`){let t=Gi(e);if(O(Vi(e)),!n)return t;let r=Wi(e,`transition-duration`,`0s`);return k(r),b(!0),t}O(Vi(e));let r=Wi(e,`animation-name`,`none`);if(!n){r();return}let i=Wi(e,`animation-duration`,`0s`);r(),k(i),b(!0);return}if(!s&&a&&(u===`idle`||u===`starting`)){if(t===`none`){O(zi,!1),c(!1);return}O(Vi(e));return}if(u!==`ending`)return;if(t===`none`){c(!1);return}let n=Vi(e);if(!(n.height>0||n.width>0)){c(!1);return}O(n),t===`css-animation`&&Wi(e,`animation-name`,`none`)()},[a,s,ne,O,c,k,D,u]),N({enabled:s&&a&&E===`idle`,open:!0,ref:d,onComplete(){s&&O(zi,!1)}}),R.useEffect(()=>{if(s||!a||E!==`ending`)return;if(!d.current){c(!1),O(zi,!1);return}let e=new AbortController,t=-1;function n(){C.current||(c(!1),O(zi,!1))}return t=_n.request(()=>{w(n,e.signal)}),()=>{_n.cancel(t),e.abort()}},[C,a,s,E,w,O,c]),mr(()=>{let e=d.current;!e||!n||!T||e.setAttribute(`hidden`,`until-found`)},[T,n]),R.useEffect(function(){let e=d.current;if(!e)return;let t=M.create(),n=-1,r=(r,i)=>{t.start(0,()=>{C.current||(n=_n.request(()=>{C.current||(r&&(g.current=!1),i&&e.setAttribute(Ni,``),e.setAttribute(`hidden`,`until-found`))}))})},i=zn(e,`beforematch`,t=>{let n=Ne(Pt,t);if(o(!0,n),n.isCanceled){r(!1,!1);return}g.current=!0;let i=e.hasAttribute(Ni);e.removeAttribute(Ni),l(!0),r(!0,i)});return()=>{t.clear(),_n.cancel(n),i()}},[C,o,l]);let A=i||n||a||s;return{height:ee.height,props:{...te?{[Ni]:``}:void 0,hidden:T,id:r},ref:S,shouldPreventOpenAnimation:D,shouldRender:A,transitionStatus:E,width:ee.width}}function Vi(e){return{height:e.scrollHeight,width:e.scrollWidth}}function Hi(e,t){let n=Ht(e).getComputedStyle(e),r=(n.animationName.split(`,`).map(e=>e.trim()).some(e=>e!==``&&e!==`none`)||t)&&Ui(n.animationDuration),i=Ui(n.transitionDuration);return r&&i||i?`css-transition`:r?`css-animation`:`none`}function Ui(e){return e.split(`,`).map(e=>e.trim()).some(e=>e!==``&&Number.parseFloat(e)>0)}function Wi(e,t,n){let r=e.style.getPropertyValue(t),i=e.style.getPropertyPriority(t);return e.style.setProperty(t,n),()=>{if(r===``){e.style.removeProperty(t);return}e.style.setProperty(t,r,i)}}function Gi(e){let t={"justify-content":e.style.justifyContent,"align-items":e.style.alignItems,"align-content":e.style.alignContent,"justify-items":e.style.justifyItems};Object.keys(t).forEach(t=>{e.style.setProperty(t,`initial`,`important`)});function n(){Object.entries(t).forEach(([t,n])=>{if(n===``){e.style.removeProperty(t);return}e.style.setProperty(t,n)})}let r=_n.request(n);return()=>{_n.cancel(r),n()}}var z=r(),Ki=hr(`group/attachment relative flex w-fit max-w-full min-w-0 shrink-0 flex-wrap rounded-xl border bg-card text-card-foreground transition-colors focus-within:ring-1 focus-within:ring-ring/50 has-[>a,>button]:hover:bg-muted/50 data-[state=error]:border-destructive/30 data-[state=idle]:border-dashed`,{variants:{size:{default:`gap-2 text-sm has-data-[slot=attachment-content]:px-2.5 has-data-[slot=attachment-content]:py-2 has-data-[slot=attachment-media]:p-2`,sm:`gap-2.5 text-xs has-data-[slot=attachment-content]:px-2 has-data-[slot=attachment-content]:py-1.5 has-data-[slot=attachment-media]:p-1.5`,xs:`gap-1.5 rounded-lg text-xs has-data-[slot=attachment-content]:px-1.5 has-data-[slot=attachment-content]:py-1 has-data-[slot=attachment-media]:p-1`},orientation:{horizontal:`min-w-40 items-center`,vertical:`w-24 flex-col has-data-[slot=attachment-content]:w-30`}}});function qi({className:e,state:t=`done`,size:n=`default`,orientation:r=`horizontal`,...i}){return(0,z.jsx)(`div`,{"data-slot":`attachment`,"data-state":t,"data-size":n,"data-orientation":r,className:ut(Ki({size:n,orientation:r}),e),...i})}var Ji=hr(`relative flex aspect-square w-10 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-muted text-foreground group-data-[orientation=vertical]/attachment:w-full group-data-[size=sm]/attachment:w-8 group-data-[size=xs]/attachment:w-7 group-data-[size=xs]/attachment:rounded-md group-data-[state=error]/attachment:bg-destructive/10 group-data-[state=error]/attachment:text-destructive group-data-[orientation=vertical]/attachment:*:data-[slot=spinner]:size-6! [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 group-data-[orientation=vertical]/attachment:[&_svg:not([class*='size-'])]:size-6 group-data-[size=xs]/attachment:[&_svg:not([class*='size-'])]:size-3.5`,{variants:{variant:{icon:``,image:`opacity-60 group-data-[state=done]/attachment:opacity-100 group-data-[state=idle]/attachment:opacity-100 *:[img]:aspect-square *:[img]:w-full *:[img]:object-cover`}},defaultVariants:{variant:`icon`}});function Yi({className:e,variant:t=`icon`,...n}){return(0,z.jsx)(`div`,{"data-slot":`attachment-media`,"data-variant":t,className:ut(Ji({variant:t}),e),...n})}function Xi({className:e,...t}){return(0,z.jsx)(`div`,{"data-slot":`attachment-group`,className:ut(`flex min-w-0 scroll-fade-x snap-x snap-mandatory scroll-px-1 scrollbar-none gap-3 overflow-x-auto overscroll-x-contain py-1 *:data-[slot=attachment]:flex-none *:data-[slot=attachment]:snap-start`,e),...t})}function Zi({className:e,orientation:t=`horizontal`,...n}){return(0,z.jsx)(ze,{"data-slot":`separator`,orientation:t,className:ut(`shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch`,e),...n})}function Qi({className:e,size:t=`default`,...n}){return(0,z.jsx)(`div`,{"data-slot":`card`,"data-size":t,className:ut(`group/card flex flex-col gap-(--card-spacing) overflow-hidden rounded-xl bg-card py-(--card-spacing) text-sm text-card-foreground ring-1 ring-foreground/10 [--card-spacing:--spacing(4)] has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:[--card-spacing:--spacing(3)] data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl`,e),...n})}function $i({className:e,...t}){return(0,z.jsx)(`div`,{"data-slot":`card-header`,className:ut(`group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-xl px-(--card-spacing) has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-(--card-spacing)`,e),...t})}function ea({className:e,...t}){return(0,z.jsx)(`div`,{"data-slot":`card-title`,className:ut(`text-base leading-snug font-medium group-data-[size=sm]/card:text-sm`,e),...t})}function ta({className:e,...t}){return(0,z.jsx)(`div`,{"data-slot":`card-description`,className:ut(`text-sm text-muted-foreground`,e),...t})}function na({className:e,...t}){return(0,z.jsx)(`div`,{"data-slot":`card-action`,className:ut(`col-start-2 row-span-2 row-start-1 self-start justify-self-end`,e),...t})}function ra({className:e,...t}){return(0,z.jsx)(`div`,{"data-slot":`card-content`,className:ut(`px-(--card-spacing)`,e),...t})}function ia({className:e,...t}){return(0,z.jsx)(`div`,{"data-slot":`card-footer`,className:ut(`flex items-center rounded-b-xl border-t bg-muted/50 p-(--card-spacing)`,e),...t})}function aa(e){if(!e)return null;for(let t of e.elements){let e=t.tagName;if(e===`BUTTON`||e===`INPUT`){let e=t;if(e.type===`submit`)return e}}return null}var oa=`data-checked`,sa=`data-unchecked`;function ca(e){return{checked(t){return e.indeterminate?{}:t?{[oa]:``}:{[sa]:``}},...Ae}}var la=R.createContext({disabled:!1});function ua(){return R.useContext(la)}function da(e,t,n,r=!0,i,a){let[o,s]=R.useState(),c=m(i?`${i}-label`:void 0),l=!!a?.trim(),u=e??(l?void 0:t)??o;return mr(()=>{let i=e||t||l||!r?void 0:fa(n.current,c);o!==i&&s(i)}),u}function fa(e,t){let n=pa(e);if(n)return!n.id&&t&&(n.id=t),n.id||void 0}function pa(e){if(!e)return;let t=e.parentElement;if(t&&t.tagName===`LABEL`)return t;let n=e.id;if(n){let t=e.nextElementSibling;if(t&&t.htmlFor===n)return t}let r=e.labels;return r&&r[0]}var ma=R.createContext(void 0);function ha(){return R.useContext(ma)}var ga=R.createContext(void 0);function _a(){let e=R.useContext(ga);if(e===void 0)throw Error(Se(14));return e}var va=`data-parent`,ya=R.forwardRef(function(e,t){let{checked:n,className:r,defaultChecked:i=!1,"aria-labelledby":a,disabled:o=!1,form:s,id:c,indeterminate:l=!1,inputRef:u,name:d,onCheckedChange:f,parent:p=!1,readOnly:g=!1,render:_,required:v=!1,uncheckedValue:y,value:b,nativeButton:x=!1,style:S,...C}=e,{clearErrors:w}=Fe(),{disabled:E,name:D,setDirty:ee,setFilled:O,setTouched:ne,state:k,validationMode:re,validityData:A,validation:j}=pn(),M=ua(),{labelId:ae,registerControlId:oe,getDescriptionProps:se}=T(),N=ha(),le=N?.allValues===void 0?void 0:N.parent,de=le!==void 0,fe=E||M.disabled||N?.disabled||o,pe=D??d,me=b??pe,ge=m(),_e=N?.registerControlId!==oe,ve=te({id:c||void 0,enabled:_e}),ye=x?ve:ge,be={};de&&(p?be=le.getParentProps():me!==void 0&&(be=le.getChildProps(me)));let{checked:P=n,indeterminate:xe=l,onCheckedChange:Se,...Ce}=be,we=N?.value,Te=R.useRef(null),Ee=h(fe,Te),{getButtonProps:De,buttonRef:Oe}=he({disabled:fe,native:x}),Ae=N?.validation??j,[je,Me]=ie({controlled:me!==void 0&&we!==void 0&&!p?we.includes(me):P,default:i,name:`Checkbox`,state:`checked`}),Pe=de?!!P:je,Ie=de&&xe||l;gn(Te,ge,je,void 0,!N&&!fe,d);let Le=le?.registerChildId,ze=R.useRef(null),Be=Ae.registerInput,Ve=N?me:void 0,He=R.useCallback(e=>Be(e,{controlRef:Te,value:Ve}),[Be,Ve]),Ue=ue(u,ze,p?void 0:He),We=da(a,ae,ze,!x,ve,C[`aria-label`]);mr(()=>{ze.current&&(ze.current.indeterminate=Ie),N||O(je)},[je,Ie,N,O]),ce(je,()=>{N||(w(pe),ee(je!==A.initialValue),Ae.change(je))});let Ge=Re({checked:je,disabled:fe,form:s,name:p?void 0:pe,id:x?void 0:ve,required:v,ref:Ue,style:pe?Tn:qn,tabIndex:-1,type:`checkbox`,"aria-hidden":!0,onChange(e){if(e.nativeEvent.defaultPrevented)return;if(g){e.preventDefault();return}let t=e.currentTarget.checked,n=Ne(Pt,e.nativeEvent);if(f?.(t,n),!n.isCanceled&&(Se?.(t,n),!n.isCanceled&&(Me(t),me!==void 0&&N!==void 0&&!p&&!de))){let e=t?[...N.value,me]:N.value.filter(e=>e!==me);N.setValue(e,n)}},onClick(e){e.stopPropagation()},onFocus(){Te.current?.focus()}},b===void 0?lt:{value:(N?je&&b:b)||``},se,e=>Ae.getValidationProps(fe,e));R.useEffect(()=>{if(!le||me===void 0)return;let e=le.disabledStatesRef.current;return e.set(me,fe),()=>{e.delete(me)}},[le,fe,me]);let Ke=R.useMemo(()=>({...k,checked:Pe,disabled:fe,readOnly:g,required:v,indeterminate:Ie}),[k,Pe,fe,g,v,Ie]),qe=ca(Ke),Je=ke(`span`,e,{state:Ke,ref:[Oe,Te,t],props:[{id:ye,role:`checkbox`,"aria-checked":Ie?`mixed`:Pe,"aria-readonly":g||void 0,"aria-required":v||void 0,"aria-labelledby":We,[va]:p?``:void 0,onFocus(){Ee(!0)},onBlur(){let e=ze.current;e&&(ne(!0),Ee(!1),re===`onBlur`&&Ae.commit(N?we:e.checked))},onKeyDown(e){if(e.key!==`Enter`||(e.preventBaseUIHandler(),e.defaultPrevented))return;let t=ze.current?.form??null,n=e.currentTarget,r=e.nativeEvent,i=e.preventDefault,a=r.preventDefault,o=!1;e.preventDefault=()=>{o=!0,i.call(e)},r.preventDefault=()=>{o=!0,a.call(r)},a.call(r),Ht(n).queueMicrotask(()=>{e.preventDefault=i,r.preventDefault=a,o||aa(t)?.click()})},onClick(e){if(g||fe)return;e.preventDefault();let t=ze.current;t&&bt(t,e)}},C,Ce,De,se,e=>Ae.getValidationProps(fe,e)],stateAttributesMapping:qe}),Ye=Je.props.id;return mr(()=>{if(!(!Le||p||me===void 0||Ye===void 0))return Le(me,Ye)},[Le,p,me,Ye]),(0,z.jsxs)(ga.Provider,{value:Ke,children:[Je,!je&&!N&&pe&&!p&&y!==void 0&&(0,z.jsx)(`input`,{type:`hidden`,form:s,name:pe,value:y,disabled:fe}),(0,z.jsx)(`input`,{...Ge,suppressHydrationWarning:!0})]})}),ba=R.forwardRef(function(e,t){let{render:n,className:r,style:i,keepMounted:a=!1,...o}=e,s=_a(),c=s.checked||s.indeterminate,{mounted:l,transitionStatus:u,setMounted:d}=Rt(c),f=R.useRef(null),p={...s,transitionStatus:u};N({batch:!0,enabled:!c,open:c,ref:f,onComplete(){c||d(!1)}});let m={...ca(s),...sn},h=a||l,g=ke(`span`,e,{ref:[t,f],state:p,stateAttributesMapping:m,props:o});return h?g:null});function xa({className:e,...t}){return(0,z.jsx)(ya,{"data-slot":`checkbox`,className:ut(`peer relative flex size-4 shrink-0 items-center justify-center rounded-[4px] border border-input transition-colors outline-none group-has-disabled/field:opacity-50 group-has-[:focus-visible]/field-label:ring-0 group-has-[:focus-visible]/field-label:not-data-checked:border-input after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground group-has-[:focus-visible]/field-label:data-checked:border-primary dark:data-checked:bg-primary`,e),...t,children:(0,z.jsx)(ba,{"data-slot":`checkbox-indicator`,className:`grid place-content-center text-current transition-none [&>svg]:size-3.5`,children:(0,z.jsx)(d,{})})})}var Sa=hr(`group/code-block relative flex w-full min-w-0 flex-col overflow-hidden rounded-lg text-sm has-[>[data-slot=code-block-content]:focus-visible]:ring-3 has-[>[data-slot=code-block-content]:focus-visible]:ring-ring/50 data-[size=sm]:text-xs`,{variants:{variant:{default:`border border-input text-foreground has-[>[data-slot=code-block-content]:focus-visible]:border-ring dark:bg-input/30`,destructive:`border border-destructive/30 text-destructive dark:border-destructive/40`}},defaultVariants:{variant:`default`}});function Ca({className:e,variant:t=`default`,size:n=`default`,...r}){return(0,z.jsx)(`div`,{"data-slot":`code-block`,"data-variant":t,"data-size":n,className:ut(Sa({variant:t}),e),...r})}function wa({className:e,...t}){return(0,z.jsx)(`div`,{"data-slot":`code-block-actions`,className:ut(`-my-1 ms-auto -me-1.5 flex shrink-0 items-center gap-1 [[data-slot=code-block]>&]:absolute [[data-slot=code-block]>&]:end-2 [[data-slot=code-block]>&]:top-2 [[data-slot=code-block]>&]:z-10 [[data-slot=code-block]>&]:m-0 [[data-slot=code-block]>&]:opacity-0 [[data-slot=code-block]>&]:transition-opacity [[data-slot=code-block]>&]:group-focus-within/code-block:opacity-100 [[data-slot=code-block]>&]:group-hover/code-block:opacity-100 group-data-[size=sm]/code-block:[[data-slot=code-block]>&]:end-1.5 group-data-[size=sm]/code-block:[[data-slot=code-block]>&]:top-1.5 [[data-slot=code-block]>&]:pointer-coarse:opacity-100 [[data-slot=code-block]>&]:*:[button]:bg-background [[data-slot=code-block]>&]:*:[button]:ring-1 [[data-slot=code-block]>&]:*:[button]:ring-foreground/10`,e),...t})}function Ta({className:e,children:t,style:n,wrap:r=!1,lineNumbers:i=!1,startLine:a=1,...o}){return(0,z.jsx)(`pre`,{"data-slot":`code-block-content`,"data-wrap":r||void 0,"data-numbered":i||void 0,dir:`ltr`,tabIndex:0,style:{counterReset:`line ${a-1}`,...n},className:ut(`min-h-0 min-w-0 scroll-fade-x scrollbar-thin overflow-auto px-3 py-3 text-start font-mono leading-relaxed outline-none group-has-data-[slot=code-block-footer]/code-block:pb-2 group-has-data-[slot=code-block-header]/code-block:pt-2 group-data-[size=sm]/code-block:px-2.5 group-data-[size=sm]/code-block:py-2.5 group-data-[size=sm]/code-block:group-has-data-[slot=code-block-header]/code-block:pt-1.5 data-wrap:scroll-fade-y data-wrap:wrap-break-word data-wrap:whitespace-pre-wrap`,e),...o,children:(0,z.jsx)(`code`,{"data-slot":`code-block-code`,className:`grid min-h-lh min-w-max content-start in-data-numbered:grid-cols-[auto_1fr] in-data-wrap:min-w-0`,children:i&&typeof t==`string`?t.replace(/\n$/,``).split(`
|
|
3
|
+
`).map((e,t)=>(0,z.jsx)(Da,{children:e},t)):t})})}var Ea=hr(`relative -mx-3 block min-h-lh px-3 group-data-[size=sm]/code-block:-mx-2.5 group-data-[size=sm]/code-block:px-2.5 before:min-w-6 before:text-end before:text-muted-foreground after:absolute after:start-1 after:top-0 after:text-muted-foreground after:select-none in-data-numbered:col-span-2 in-data-numbered:grid in-data-numbered:grid-cols-subgrid in-data-numbered:gap-x-3 in-data-numbered:[counter-increment:line] in-data-numbered:before:content-[counter(line)] in-data-numbered:before:select-none in-data-numbered:supports-[content:counter(line)_/_'']:before:content-[counter(line)_/_'']`,{variants:{variant:{default:``,added:`bg-muted after:content-['+']`,removed:`bg-destructive/10 after:text-destructive after:content-['−']`,highlighted:`bg-muted`}},defaultVariants:{variant:`default`}});function Da({className:e,variant:t=`default`,children:n,...r}){let i=n==null||n===``||Array.isArray(n)&&n.length===0;return(0,z.jsx)(`span`,{"data-slot":`code-block-line`,"data-variant":t,className:ut(Ea({variant:t}),e),...r,children:(0,z.jsx)(`span`,{"data-slot":`code-block-line-content`,className:`min-w-0`,children:i?`
|
|
4
|
+
`:n})})}var Oa={...Ri,...sn},ka=R.forwardRef(function(e,t){let{render:n,className:r,defaultOpen:i=!1,disabled:a=!1,onOpenChange:o,open:s,style:c,...l}=e,u=it(o),d=Oi({open:s,defaultOpen:i,onOpenChange:u,disabled:a}),f=R.useMemo(()=>({open:d.open,disabled:d.disabled,transitionStatus:d.transitionStatus}),[d.open,d.disabled,d.transitionStatus]),p=R.useMemo(()=>({...d,onOpenChange:u,state:f}),[d,u,f]),m=ke(`div`,e,{state:f,ref:t,props:l,stateAttributesMapping:Oa});return(0,z.jsx)(ki.Provider,{value:p,children:m})}),Aa={...Li,...sn},ja=R.forwardRef(function(e,t){let{panelId:n,open:r,handleTrigger:i,state:a,disabled:o}=Ai(),{className:s,disabled:c=o,render:l,nativeButton:u=!0,style:d,...f}=e,{getButtonProps:p,buttonRef:m}=he({disabled:c,native:u});return ke(`button`,e,{state:a,ref:[t,m],props:[{"aria-controls":r?n:void 0,"aria-expanded":r,onClick:i},f,p],stateAttributesMapping:Aa})}),Ma=`--collapsible-panel-height`,Na=`--collapsible-panel-width`,Pa=R.forwardRef(function(e,t){let{className:n,hiddenUntilFound:r,keepMounted:i,render:a,id:o,style:s,...c}=e,{defaultPanelId:l,mounted:u,onOpenChange:d,open:f,setMounted:p,setPanelIdState:m,setOpen:h,state:g,transitionStatus:_}=Ai(),v=r??!1,y=i??!1,b=o||void 0,x=b??l;mr(()=>(m(e=>b??(e===null?void 0:e)),()=>{m(e=>e===b?null:e)}),[b,m]);let{height:S,props:C,ref:w,shouldPreventOpenAnimation:T,shouldRender:E,transitionStatus:D,width:ee}=Bi({externalRef:t,hiddenUntilFound:v,id:x,keepMounted:y,mounted:u,onOpenChange:d,open:f,setMounted:p,setOpen:h,transitionStatus:_}),te={...g,transitionStatus:D},O=k(s,te),ne=ke(`div`,{...e,style:void 0},{state:te,ref:w,props:[C,{style:{[Ma]:S===void 0?`auto`:`${S}px`,[Na]:ee===void 0?`auto`:`${ee}px`}},c,O?{style:O}:void 0,T?{style:{animationName:`none`}}:void 0],stateAttributesMapping:Oa});return E?ne:null});function Fa({...e}){return(0,z.jsx)(ka,{"data-slot":`collapsible`,...e})}function Ia({...e}){return(0,z.jsx)(ja,{"data-slot":`collapsible-trigger`,...e})}function La({...e}){return(0,z.jsx)(Pa,{"data-slot":`collapsible-content`,...e})}var Ra=R.createContext(void 0);function za(e=!1){let t=R.useContext(Ra);if(!t&&!e)throw Error(Se(86));return t}Object.keys(Ee);function Ba(e,t){return e.matches(`:disabled`)?!1:!t||e.form===t||e.form===null&&!e.hasAttribute(`form`)}var Va=`data-composite-item-active`;function Ha(e){let{loopFocus:t=!0,orientation:n=`both`,grid:r,onLoop:i,direction:a,highlightedIndex:o,onHighlightedIndexChange:s,rootRef:c,enableHomeAndEndKeys:l=!1,stopEventPropagation:u,disabledIndices:d,modifierKeys:p=v}=e,[m,h]=R.useState(0),g=r!=null,_=R.useRef(null),y=ue(_,c),b=R.useRef([]),x=R.useRef(!1),S=R.useRef(null),C=o??m,w=it((e,t=!1)=>{if(S.current=b.current[e]??null,(s??h)(e),t){let t=b.current[e];Gt(_.current,t,a,n)}}),T=it(e=>{if(e.size===0)return;if(x.current){let e=b.current,t=e.indexOf(S.current);if(t===-1){let t=e[C];!t||We(e,C,d)?w(Ua(e,d)):S.current=t}else t!==C&&w(t);return}x.current=!0;let t=Array.from(e.keys()),r=t.find(e=>e?.hasAttribute(`data-composite-item-active`))??null,i=r?e.get(r)?.index??-1:-1;if(i!==-1)w(i);else if(We(t,C,d)){let e=P(t,{disabledIndices:d});Et(t,e)||w(e)}Gt(_.current,r,a,n)});mr(()=>{if(d==null||o!=null||!x.current)return;let e=b.current;if(We(e,C,d)){let t=P(e,{disabledIndices:d});Et(e,t)||w(t)}},[d,o,C,b,w]);let E=it((e,t,n)=>i?i(e,t,n,b):n),D=it(e=>{let o=e.key===`Home`||e.key===`End`;if(!xt.has(e.key)||!l&&o||Wa(e,p)||!_.current)return;let s=a===`rtl`,c=s?be:Bn,m=s?Bn:be,h=n===`vertical`?ae:c,v=n===`vertical`?ge:m,y=Pe(e.nativeEvent);if(y!=null&&f(y)&&!xn(y)){let t=y.selectionStart,n=y.selectionEnd,r=y.value;if(t==null||e.shiftKey||t!==n||e.key!==v&&t<r.length||e.key!==h&&t>0)return}let x=C,S=_e(b,d),T=Vn(b,d);r!=null&&(x=r({disabledIndices:d,elementsRef:b,event:e,highlightedIndex:C,loopFocus:t,maxIndex:T,minIndex:S,onLoop:E,orientation:n,rtl:s}));let D=n!==`vertical`&&e.key===c||n!==`horizontal`&&e.key===`ArrowDown`,ee=n!==`vertical`&&e.key===m||n!==`horizontal`&&e.key===`ArrowUp`;l&&(e.key===`Home`?x=S:e.key===`End`&&(x=T)),x===C&&(D||ee)&&(t&&x===T&&D?(x=S,i&&(x=i(e,C,x,b))):t&&x===S&&ee?(x=T,i&&(x=i(e,C,x,b))):x=P(b.current,{startingIndex:x,decrement:ee,disabledIndices:d})),x!==C&&!Et(b.current,x)&&(u&&e.stopPropagation(),(g||o||D||ee)&&e.preventDefault(),w(x,!0),queueMicrotask(()=>{b.current[x]?.focus()}))});return{props:{ref:y,onFocus(e){let t=_.current,n=Pe(e.nativeEvent);!t||n==null||!f(n)||n.setSelectionRange(0,n.value.length)},onKeyDown:D},highlightedIndex:C,onHighlightedIndexChange:w,elementsRef:b,onMapChange:T,relayKeyboardEvent:D}}function Ua(e,t){let n=-1;for(let r=0;r<e.length;r+=1){let i=e[r];if(!(!i||We(e,r,t))){if(i.hasAttribute(`data-composite-item-active`))return r;n===-1&&(n=r)}}return Math.max(n,0)}function Wa(e,t){for(let n of Tt)if(!t.includes(n)&&e.getModifierState(n))return!0;return!1}function Ga(e){let{render:t,className:n,style:r,refs:i=v,props:a=v,state:o=lt,stateAttributesMapping:s,highlightedIndex:c,onHighlightedIndexChange:l,orientation:u,grid:d,loopFocus:f,onLoop:p,enableHomeAndEndKeys:m,onMapChange:h,stopEventPropagation:g=!0,rootRef:_,disabledIndices:y,modifierKeys:x,highlightItemOnHover:S=!1,tag:C=`div`,...w}=e,{props:T,highlightedIndex:E,onHighlightedIndexChange:D,elementsRef:ee,onMapChange:te,relayKeyboardEvent:O}=Ha({grid:d,loopFocus:f,onLoop:p,orientation:u,highlightedIndex:c,onHighlightedIndexChange:l,rootRef:_,stopEventPropagation:g,enableHomeAndEndKeys:m,direction:b(),disabledIndices:y,modifierKeys:x}),ne=ke(C,e,{state:o,ref:i,props:[T,...a,w],stateAttributesMapping:s}),k=R.useMemo(()=>({highlightedIndex:E,onHighlightedIndexChange:D,highlightItemOnHover:S,relayKeyboardEvent:O}),[E,D,S,O]);return(0,z.jsx)(wt.Provider,{value:k,children:(0,z.jsx)(Ke,{elementsRef:ee,onMapChange:e=>{h?.(e),te(e)},children:ne})})}var Ka=R.createContext(void 0);function qa(e){let t=R.useContext(Ka);if(t===void 0&&!e)throw Error(Se(47));return t}var Ja=n(o(),1),Ya={...zt,disabled:e=>e.disabled,instantType:e=>e.instantType===`trigger-change`&&!zt.open(e)?void 0:e.instantType,openMethod:e=>e.openMethod,openChangeReason:e=>e.openChangeReason,isPressOpenedByTrigger:(e,t)=>e.openChangeReason===`trigger-press`&&zt.isOpenedByTrigger(e,t),isTouchPressOpen:(e,t)=>t&&e.openMethod===`touch`&&e.openChangeReason===`trigger-press`,hasTriggerFocusGuards:(e,t)=>zt.isOpenedByTrigger(e,t)&&!e.focusManagerModal,modal:e=>e.modal,titleElementId:e=>e.titleElementId,descriptionElementId:e=>e.descriptionElementId,openOnHover:e=>e.openOnHover,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin},Xa=class extends Xn{constructor(e,t,n){let r=new rn;super(Za(e,r,t,n),Qa(r),Ya)}setOpen=(e,t)=>{let n=t.reason===$e,r=t.reason===`trigger-press`&&t.event.detail===0,i=!e&&(t.reason===`escape-key`||t.reason==null),a=dr(t),o=this.select(`activeTriggerId`);if(!e&&t.reason===`close-press`&&t.trigger==null&&o!=null&&(t.trigger=this.context.triggerElements.getById(o)??this.select(`activeTriggerElement`)??void 0),this.context.onOpenChange?.(e,t),t.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(e,t);let s=()=>{let n=sr(this.state,e,t.trigger,a());n.openChangeReason=t.reason,this.update(n)};n?(this.context.stickIfOpen=!0,this.context.stickIfOpenTimeout.start(500,()=>{this.context.stickIfOpen=!1}),Ja.flushSync(s)):s();let c;r?c=`click`:i?c=`dismiss`:t.reason===`focus-out`&&(c=`focus`),this.set(`instantType`,c)}};function Za(e,t,n,r=!1){let i={...Wn(t,n,r),disabled:!1,modal:!1,focusManagerModal:!1,instantType:void 0,openMethod:null,openChangeReason:null,titleElementId:void 0,descriptionElementId:void 0,openOnHover:!1,closeDelay:0,adaptiveOrigin:void 0,...e};return i.open&&e?.mounted===void 0&&(i.mounted=!0),i}function Qa(e){return{popupRef:R.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:R.createRef(),beforeTriggerFocusGuardRef:R.createRef(),beforeContentFocusGuardRef:R.createRef(),stickIfOpenTimeout:new M,stickIfOpen:!0,triggerElements:e}}var $a=Bt(function({props:e}){let{children:t,open:n,defaultOpen:r=!1,onOpenChange:i,onOpenChangeComplete:a,modal:o=!1,handle:s,triggerId:c,defaultTriggerId:l=null}=e,u=to(s,{modal:o,open:r,openProp:n,activeTriggerId:l,triggerIdProp:c});u.useControlledProp(`openProp`,n),u.useControlledProp(`triggerIdProp`,c);let d=u.useState(`open`),f=u.useState(`mounted`),p=u.useState(`payload`);u.useContextCallback(`onOpenChange`,i),u.useContextCallback(`onOpenChangeComplete`,a),O(u,d),Ze(u);let{forceUnmount:m}=x(d,u,()=>{u.context.stickIfOpen=!0,u.set(`openChangeReason`,null)});u.useSyncedValues({modal:o}),R.useEffect(()=>{d||u.context.stickIfOpenTimeout.clear()},[u,d]),R.useImperativeHandle(e.actionsRef,()=>({unmount:m,close:()=>u.setOpen(!1,Ne(Zt))}),[m,u]);let h=d||f||s!=null;return(0,z.jsxs)(Ka.Provider,{value:u,children:[s&&(0,z.jsx)(kt,{handle:s,store:u}),h&&(0,z.jsx)(no,{store:u,modal:o}),typeof t==`function`?t({payload:p}):t]})});function eo(e){return qa(!0)?(0,z.jsx)($a,{props:e}):(0,z.jsx)(Be,{children:(0,z.jsx)($a,{props:e})})}function to(e,t){let n=tt((e,n)=>new Xa(t,e,n));return R.useEffect(()=>n.context.stickIfOpenTimeout.disposeEffect(),[n]),n}function no({store:e,modal:t}){let n=g(e.useState(`floatingRootContext`),{outsidePressEvent:{mouse:t===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}}),r=n.reference,i=n.floating;return rr(e,{activeTriggerProps:r,inactiveTriggerProps:r,popupProps:i}),null}var ro=Jt(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,handle:s,payload:c,openOnHover:l=!1,delay:u=300,closeDelay:d=0,id:f,...p}=e,h=qa(!0),g=An(s)??h;if(!g)throw Error(Se(74));let _=m(f),v=g.useState(`isTriggerActive`,_),y=g.useState(`floatingRootContext`),b=g.useState(`isOpenedByTrigger`,_),x=g.useState(`triggerPopupId`,_),S=R.useRef(null),{registerTrigger:C,isMountedByThisTrigger:w}=E(_,S,g,{payload:c,disabled:a,openOnHover:l,closeDelay:d}),T=g.useState(`isPressOpenedByTrigger`,_),D=g.useState(`isTouchPressOpen`,l),ee=g.useState(`hasTriggerFocusGuards`,_),te=Hn(y,{enabled:!a&&l&&!D,mouseOnly:!0,move:!1,handleClose:Dn(),restMs:u,delay:{close:d},triggerElementRef:S,isActiveTrigger:v,isClosing:()=>g.select(`transitionStatus`)===`ending`}),O=mn(y,{stickIfOpen:it(()=>g.context.stickIfOpen)}),ne=dt(()=>g.select(`open`),e=>{g.set(`openMethod`,e)}),k=g.useState(`triggerProps`,w),{getButtonProps:re,buttonRef:A}=he({disabled:a,native:o}),j={open(e){return T?Nn.open(e):bn.open(e)}},{handlePreFocusGuardFocus:ie,handleFocusTargetFocus:M}=nn(g,S),ae=ke(`button`,e,{state:{disabled:a,open:b},ref:[A,t,C,S],props:[O.reference,te,k,ne,{[ft]:``,id:_,"aria-haspopup":`dialog`,"aria-expanded":b,"aria-controls":x},p,re],stateAttributesMapping:j}),oe=(0,z.jsx)(R.Fragment,{children:ae},_);return ee?(0,z.jsxs)(R.Fragment,{children:[(0,z.jsx)(Ut,{ref:g.context.beforeTriggerFocusGuardRef,onFocus:ie}),oe,(0,z.jsx)(Ut,{ref:g.context.triggerFocusTargetRef,onFocus:M})]}):oe}),io=R.createContext(void 0);function ao(){let e=R.useContext(io);if(e===void 0)throw Error(Se(45));return e}var oo=R.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return qa().useState(`mounted`)||n?(0,z.jsx)(io.Provider,{value:n,children:(0,z.jsx)(_r,{ref:t,...r})}):null}),so=R.createContext(void 0);function co(){let e=R.useContext(so);if(!e)throw Error(Se(46));return e}var lo=R.forwardRef(function(e,t){let{render:n,className:r,style:i,anchor:a,positionMethod:o,side:s,align:c,sideOffset:l,alignOffset:u,collisionBoundary:d=`clipping-ancestors`,collisionPadding:f,arrowPadding:p,sticky:m,disableAnchorTracking:h=!1,collisionAvoidance:g=st,..._}=e,v=qa(),y=ao(),b=A(),x=v.useState(`floatingRootContext`),S=v.useState(`mounted`),C=v.useState(`open`),w=v.useState(`openChangeReason`),T=v.useState(`activeTriggerElement`),E=v.useState(`modal`),D=v.useState(`openMethod`),ee=v.useState(`positionerElement`),te=v.useState(`instantType`),O=v.useState(`transitionStatus`),ne=Xe({anchor:a,floatingRootContext:x,positionMethod:o,mounted:S,side:s,sideOffset:l,align:c,alignOffset:u,arrowPadding:p,collisionBoundary:d,collisionPadding:f,sticky:m,disableAnchorTracking:h,keepMounted:y,nodeId:b,collisionAvoidance:g,adaptiveOrigin:v.useState(`adaptiveOrigin`)});Ot({store:v,domReference:x.useState(`domReferenceElement`),positionerElement:ee,open:C});let k=E===!0&&w!==`trigger-hover`;ur(C&&k,D===`touch`,ee,T);let re=v.useStateSetter(`positionerElement`),j=Ft(e,{open:C,side:ne.side,align:ne.align,anchorHidden:ne.anchorHidden,instant:te},{styles:ne.positionerStyles,transitionStatus:O,props:_,refs:[t,re],hidden:!S,inert:!C});return(0,z.jsxs)(so.Provider,{value:ne,children:[S&&k&&(0,z.jsx)(ot,{inert:ht(!C),cutout:T}),(0,z.jsx)(je,{id:b,children:j})]})}),uo=R.createContext(void 0);function fo(){let[e,t]=R.useState(0),n=it(()=>(t(e=>e+1),()=>{t(e=>Math.max(0,e-1))}));return{context:R.useMemo(()=>({register:n}),[n]),hasClosePart:e>0}}var po=R.forwardRef(function(e,t){let{render:n,className:r,style:i,initialFocus:a,finalFocus:o,...s}=e,c=qa(),l=co(),u=$n(!0)!=null,{context:d,hasClosePart:f}=fo(),p=c.useState(`open`),m=c.useState(`openMethod`),h=c.useState(`instantType`),g=c.useState(`transitionStatus`),_=c.useState(`popupProps`),v=c.useState(`titleElementId`),y=c.useState(`descriptionElementId`),b=c.useState(`modal`),x=c.useState(`mounted`),S=c.useState(`openChangeReason`),C=c.useState(`activeTriggerElement`),w=c.useState(`floatingRootContext`),T=w.useState(`floatingId`),E=c.useState(`disabled`),D=c.useState(`openOnHover`),ee=c.useState(`closeDelay`);N({open:p,ref:c.context.popupRef,onComplete(){p&&c.context.onOpenChangeComplete?.(!0)}}),un(w,{enabled:D&&!E,closeDelay:ee});let te=a===void 0?It(c.context.popupRef):a,O=b!==!1&&f;c.useSyncedValue(`focusManagerModal`,O);let ne=c.useStateSetter(`popupElement`),k=ke(`div`,e,{state:{open:p,side:l.side,align:l.align,instant:h,transitionStatus:g},ref:[t,c.context.popupRef,ne],props:[_,{id:T,role:`dialog`,...$t,"aria-labelledby":v,"aria-describedby":y,onKeyDown(e){u&&xt.has(e.key)&&e.stopPropagation()}},or(g),s],stateAttributesMapping:qt});return(0,z.jsx)(De,{context:w,openInteractionType:m,modal:O,disabled:!x||S===`trigger-hover`,initialFocus:te,returnFocus:o,restoreFocus:`popup`,getInsideElements:()=>[c.context.beforeTriggerFocusGuardRef.current],previousFocusableElement:wn(C)?C:void 0,nextFocusableElement:c.context.triggerFocusTargetRef,beforeContentFocusGuardRef:c.context.beforeContentFocusGuardRef,children:(0,z.jsx)(uo.Provider,{value:d,children:k})})}),mo=R.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=qa(),s=m(a.id);return o.useSyncedValueWithCleanup(`titleElementId`,s),ke(`h2`,e,{ref:t,props:[{id:s},a]})}),ho=R.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=qa(),s=m(a.id);return o.useSyncedValueWithCleanup(`descriptionElementId`,s),ke(`p`,e,{ref:t,props:[{id:s},a]})}),go=`data-checked`,_o=`data-unchecked`,vo={checked(e){return e?{[go]:``}:{[_o]:``}},...sn,...Ae},yo=R.createContext(void 0);function bo(){return R.useContext(yo)}var xo=R.createContext(void 0);function So(){let e=R.useContext(xo);if(e===void 0)throw Error(Se(52));return e}var Co=R.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,readOnly:a=!1,required:o=!1,"aria-labelledby":s,value:c,inputRef:l,nativeButton:u=!1,id:d,style:f,...p}=e,g=bo(),{disabled:_,readOnly:v,required:y,form:b,checkedValue:x,touched:S=!1,validation:C,name:w,setCheckedValue:E=se,setTouched:D=se,registerInputRef:ee=se}=g??{},{setTouched:O,setFilled:ne,state:k,disabled:re}=pn(),A=ua(),{labelId:j,getDescriptionProps:ie}=T(),M=re||A.disabled||_||i,ae=v||a,oe=y||o,N=b,ce=g?x===c:c===``,le=R.useRef(null),de=h(M,le),fe=R.useRef(null),pe=C?.registerInput,me=ue(l,fe,ee,R.useCallback(e=>pe?.(e,{controlRef:le,value:void 0}),[pe]));mr(()=>{fe.current?.checked&&ne(!0)},[ne]),mr(()=>{if(fe.current){if(M&&ce){ee(null);return}ee(fe.current)}},[ce,M,ee]);let ge=m(),_e=te({id:d}),ve=u?void 0:_e,ye={role:`radio`,"aria-checked":ce,"aria-labelledby":da(s,j,fe,!u,ve,p[`aria-label`]),[Va]:ce?``:void 0,id:u?_e:ge,onKeyDown(e){e.key===`Enter`&&e.preventDefault()},onClick(e){if(e.defaultPrevented||M||ae)return;e.preventDefault();let t=fe.current;t&&bt(t,e)},onFocus(e){de(!0),!(e.defaultPrevented||M||ae||!S)&&(fe.current?.click(),D(!1))},onBlur(){g||de(!1)}},{getButtonProps:be,buttonRef:P}=he({disabled:M,native:u,composite:!1}),xe={type:`radio`,ref:me,form:N,id:ve,name:w,tabIndex:-1,style:w?Tn:qn,"aria-hidden":!0,...c===void 0?lt:{value:nr(c)},disabled:M,checked:ce,required:oe,readOnly:ae,onChange(e){if(e.nativeEvent.defaultPrevented||M||ae||c===void 0)return;let t=Ne(Pt,e.nativeEvent);E(c,t),!t.isCanceled&&O(!0)},onClick(e){e.stopPropagation()},onFocus(){le.current?.focus()}},Se=R.useMemo(()=>({...k,required:oe,disabled:M,readOnly:ae,checked:ce}),[k,M,ae,ce,oe]),Ce=Se,we=g!==void 0,Te=[t,le,P],Ee=[ye,p,be,ie,C?e=>C.getValidationProps(M,e):lt],De=ke(`span`,e,{enabled:!we,state:Se,ref:Te,props:Ee,stateAttributesMapping:vo});return(0,z.jsxs)(xo.Provider,{value:Ce,children:[we?(0,z.jsx)(Qt,{tag:`span`,render:n,className:r,style:f,state:Se,refs:Te,props:Ee,stateAttributesMapping:vo}):De,(0,z.jsx)(`input`,{...xe,suppressHydrationWarning:!0})]})}),wo=R.forwardRef(function(e,t){let{render:n,className:r,style:i,keepMounted:a=!1,...o}=e,s=So(),c=s.checked,{mounted:l,transitionStatus:u,setMounted:d}=Rt(c),f={...s,transitionStatus:u},p=R.useRef(null),m=a||l,h=ke(`span`,e,{ref:[t,p],state:f,props:o,stateAttributesMapping:vo});return N({batch:!0,enabled:!c,open:c,ref:p,onComplete(){c||d(!1)}}),m?h:null}),To=[Ue],Eo=R.forwardRef(function(e,t){let{render:n,className:r,disabled:i,readOnly:a,required:o,onValueChange:s,value:c,defaultValue:l,form:u,name:d,inputRef:f,id:p,style:h,...g}=e,{setTouched:_,setFocused:v,validationMode:y,name:b,disabled:x,state:S,validation:C,setDirty:E,setFilled:D,validityData:ee}=pn(),{labelId:te}=T(),{clearErrors:O,elementRef:ne}=Fe(),k=za(!0),re=x||i,A=b??d,j=m(p),[M,ae]=ie({controlled:c,default:l,name:`RadioGroup`,state:`value`}),[oe,se]=R.useState(!1),N=it((e,t)=>{s?.(e,t),!t.isCanceled&&ae(e)}),le=C.getInputControl,de=R.useMemo(()=>({get current(){return le()}}),[le]),fe=R.useRef(null),pe=R.useRef(null),me=ue(fe,f),he=R.useRef(me),ge=it(e=>{fe.current===e&&he.current===me||(he.current=me,me?.(e))});mr(()=>{ge(fe.current)},[me,ge]);let _e=it(e=>{if(e){if(!e.disabled){pe.current||=e;let t=fe.current;(e.checked||t==null||t.disabled)&&ge(e)}return()=>{pe.current===e&&(pe.current=null),fe.current===e&&ge(null)}}}),ve=it(()=>{let e=ne.current;if(!e)return M??null;for(let t of C.registeredInputs.keys())if(t.checked&&Ba(t,e))return M??null;return null});gn(de,j,M??null,ve,!re,d),ce(M,()=>{O(A),E(M!==ee.initialValue),D(M!=null),C.change(M);let e=pe.current;M==null&&e&&!e.disabled&&ge(e)});let ye=te??k?.legendId,be={...S,disabled:re??!1,required:o??!1,readOnly:a??!1},P=R.useMemo(()=>({checkedValue:M,disabled:re,form:u,validation:C,name:A,readOnly:a,registerInputRef:_e,required:o,setCheckedValue:N,setTouched:se,touched:oe}),[M,re,u,C,A,a,_e,o,N,se,oe]),xe={id:p,role:`radiogroup`,"aria-required":o||void 0,"aria-disabled":re||void 0,"aria-readonly":a||void 0,"aria-labelledby":ye,onBlur(e){w(e.currentTarget,e.relatedTarget)||(se(!1),_(!0),v(!1),y===`onBlur`&&C.commit(M))},onKeyDownCapture(e){e.key.startsWith(`Arrow`)&&se(!0)}};return(0,z.jsx)(yo.Provider,{value:P,children:(0,z.jsx)(Ga,{render:n,className:r,style:h,state:be,props:[xe,g,e=>C.getValidationProps(re??!1,e)],refs:[t],stateAttributesMapping:Ae,enableHomeAndEndKeys:!1,modifierKeys:To})})}),Do=hr(`group/item flex w-full flex-wrap items-center rounded-lg border text-sm transition-colors duration-100 outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 [a]:transition-colors [a]:hover:bg-muted`,{variants:{variant:{default:`border-transparent`,outline:`border-border`,muted:`border-transparent bg-muted/50`},size:{default:`gap-2.5 px-3 py-2.5`,sm:`gap-2.5 px-3 py-2.5`,xs:`gap-2 px-2.5 py-2 in-data-[slot=dropdown-menu-content]:p-0`}},defaultVariants:{variant:`default`,size:`default`}});function Oo({className:e,variant:t=`default`,size:n=`default`,render:r,...i}){return de({defaultTagName:`div`,props:Re({className:ut(Do({variant:t,size:n,className:e}))},i),render:r,state:{slot:`item`,variant:t,size:n}})}var ko=hr(`flex shrink-0 items-center justify-center gap-2 group-has-data-[slot=item-description]/item:translate-y-0.5 group-has-data-[slot=item-description]/item:self-start [&_svg]:pointer-events-none`,{variants:{variant:{default:`bg-transparent`,icon:`[&_svg:not([class*='size-'])]:size-4`,image:`size-10 overflow-hidden rounded-sm group-data-[size=sm]/item:size-8 group-data-[size=xs]/item:size-6 [&_img]:size-full [&_img]:object-cover`}},defaultVariants:{variant:`default`}});function Ao({className:e,variant:t=`default`,...n}){return(0,z.jsx)(`div`,{"data-slot":`item-media`,"data-variant":t,className:ut(ko({variant:t,className:e})),...n})}function jo({className:e,...t}){return(0,z.jsx)(`div`,{"data-slot":`item-content`,className:ut(`flex flex-1 flex-col gap-1 group-data-[size=xs]/item:gap-0 [&+[data-slot=item-content]]:flex-none`,e),...t})}function Mo({className:e,...t}){return(0,z.jsx)(`div`,{"data-slot":`item-title`,className:ut(`line-clamp-1 flex w-fit items-center gap-2 text-sm leading-snug font-medium underline-offset-4`,e),...t})}function No({className:e,...t}){return(0,z.jsx)(`p`,{"data-slot":`item-description`,className:ut(`line-clamp-2 text-start text-sm leading-normal font-normal text-muted-foreground group-data-[size=xs]/item:text-xs [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary`,e),...t})}function Po({...e}){return(0,z.jsx)(eo,{"data-slot":`popover`,...e})}function Fo({...e}){return(0,z.jsx)(ro,{"data-slot":`popover-trigger`,...e})}function Io({className:e,align:t=`center`,alignOffset:n=0,side:r=`bottom`,sideOffset:i=4,...a}){return(0,z.jsx)(oo,{children:(0,z.jsx)(lo,{align:t,alignOffset:n,side:r,sideOffset:i,className:`isolate z-50`,children:(0,z.jsx)(po,{"data-slot":`popover-content`,className:ut(`z-50 flex w-72 origin-(--transform-origin) flex-col gap-2.5 rounded-lg bg-popover p-2.5 text-sm text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-start-2 data-[side=inline-start]:slide-in-from-end-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 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...a})})})}function Lo({className:e,...t}){return(0,z.jsx)(`div`,{"data-slot":`popover-header`,className:ut(`flex flex-col gap-0.5 text-sm`,e),...t})}function Ro({className:e,...t}){return(0,z.jsx)(mo,{"data-slot":`popover-title`,className:ut(`font-medium`,e),...t})}function zo({className:e,...t}){return(0,z.jsx)(ho,{"data-slot":`popover-description`,className:ut(`text-muted-foreground`,e),...t})}function Bo({className:e,...t}){return(0,z.jsx)(Eo,{"data-slot":`radio-group`,className:ut(`grid w-full gap-2`,e),...t})}function Vo({className:e,...t}){return(0,z.jsx)(Co,{"data-slot":`radio-group-item`,className:ut(`group/radio-group-item peer relative flex aspect-square size-4 shrink-0 rounded-full border border-input outline-none group-has-[:focus-visible]/field-label:ring-0 group-has-[:focus-visible]/field-label:not-data-checked:border-input after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground group-has-[:focus-visible]/field-label:data-checked:border-primary dark:data-checked:bg-primary`,e),...t,children:(0,z.jsx)(wo,{"data-slot":`radio-group-indicator`,className:`flex size-4 items-center justify-center`,children:(0,z.jsx)(`span`,{className:`absolute top-1/2 start-1/2 size-2 -translate-x-1/2 rtl:translate-x-1/2 -translate-y-1/2 rounded-full bg-primary-foreground`})})})}function Ho({className:e,...t}){return(0,z.jsx)(me,{"data-slot":`spinner`,role:`status`,"aria-label":`Loading`,className:ut(`size-4 animate-spin`,e),...t})}var Uo=class extends Error{constructor(e){super(e),this.name=`ShikiError`}};function Wo(e){return Go(e)}function Go(e){return Array.isArray(e)?Ko(e):e instanceof RegExp?e:typeof e==`object`?qo(e):e}function Ko(e){let t=[];for(let n=0,r=e.length;n<r;n++)t[n]=Go(e[n]);return t}function qo(e){let t={};for(let n in e)t[n]=Go(e[n]);return t}function Jo(e,...t){return t.forEach(t=>{for(let n in t)e[n]=t[n]}),e}function Yo(e){let t=~e.lastIndexOf(`/`)||~e.lastIndexOf(`\\`);return t===0?e:~t===e.length-1?Yo(e.substring(0,e.length-1)):e.substr(~t+1)}var Xo=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,Zo=class{static hasCaptures(e){return e===null?!1:(Xo.lastIndex=0,Xo.test(e))}static replaceCaptures(e,t,n){return e.replace(Xo,(e,r,i,a)=>{let o=n[parseInt(r||i,10)];if(o){let e=t.substring(o.start,o.end);for(;e[0]===`.`;)e=e.substring(1);switch(a){case`downcase`:return e.toLowerCase();case`upcase`:return e.toUpperCase();default:return e}}else return e})}};function Qo(e,t){return e<t?-1:+(e>t)}function $o(e,t){if(e===null&&t===null)return 0;if(!e)return-1;if(!t)return 1;let n=e.length,r=t.length;if(n===r){for(let r=0;r<n;r++){let n=Qo(e[r],t[r]);if(n!==0)return n}return 0}return n-r}function es(e){return!!(/^#[0-9a-f]{6}$/i.test(e)||/^#[0-9a-f]{8}$/i.test(e)||/^#[0-9a-f]{3}$/i.test(e)||/^#[0-9a-f]{4}$/i.test(e))}function ts(e){return e.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,`\\$&`)}var ns=class{constructor(e){this.fn=e}fn;cache=new Map;get(e){if(this.cache.has(e))return this.cache.get(e);let t=this.fn(e);return this.cache.set(e,t),t}},rs=class{constructor(e,t,n){this._colorMap=e,this._defaults=t,this._root=n}_colorMap;_defaults;_root;static createFromRawTheme(e,t){return this.createFromParsedTheme(ls(e),t)}static createFromParsedTheme(e,t){return fs(e,t)}_cachedMatchRoot=new ns(e=>this._root.match(e));getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(e){if(e===null)return this._defaults;let t=e.scopeName,n=this._cachedMatchRoot.get(t).find(t=>as(e.parent,t.parentScopes));return n?new cs(n.fontStyle,n.foreground,n.background):null}},is=class e{constructor(e,t){this.parent=e,this.scopeName=t}parent;scopeName;static push(t,n){for(let r of n)t=new e(t,r);return t}static from(...t){let n=null;for(let r=0;r<t.length;r++)n=new e(n,t[r]);return n}push(t){return new e(this,t)}getSegments(){let e=this,t=[];for(;e;)t.push(e.scopeName),e=e.parent;return t.reverse(),t}toString(){return this.getSegments().join(` `)}extends(e){return this===e||this.parent!==null&&this.parent.extends(e)}getExtensionIfDefined(e){let t=[],n=this;for(;n&&n!==e;)t.push(n.scopeName),n=n.parent;return n===e?t.reverse():void 0}};function as(e,t){if(t.length===0)return!0;for(let n=0;n<t.length;n++){let r=t[n],i=!1;if(r===`>`){if(n===t.length-1)return!1;r=t[++n],i=!0}for(;e&&!ss(e.scopeName,r);){if(i)return!1;e=e.parent}if(!e)return!1;e=e.parent}return!0}function ss(e,t){return t===e||e.startsWith(t)&&e[t.length]===`.`}var cs=class{constructor(e,t,n){this.fontStyle=e,this.foregroundId=t,this.backgroundId=n}fontStyle;foregroundId;backgroundId};function ls(e){if(!e||!e.settings||!Array.isArray(e.settings))return[];let t=e.settings,n=[],r=0;for(let e=0,i=t.length;e<i;e++){let i=t[e];if(!i.settings)continue;let a;if(typeof i.scope==`string`){let e=i.scope;e=e.replace(/^[,]+/,``),e=e.replace(/[,]+$/,``),a=e.split(`,`)}else a=Array.isArray(i.scope)?i.scope:[``];let o=-1;if(typeof i.settings.fontStyle==`string`){o=0;let e=i.settings.fontStyle.split(` `);for(let t=0,n=e.length;t<n;t++)switch(e[t]){case`italic`:o|=1;break;case`bold`:o|=2;break;case`underline`:o|=4;break;case`strikethrough`:o|=8;break}}let s=null;typeof i.settings.foreground==`string`&&es(i.settings.foreground)&&(s=i.settings.foreground);let c=null;typeof i.settings.background==`string`&&es(i.settings.background)&&(c=i.settings.background);for(let t=0,i=a.length;t<i;t++){let i=a[t].trim().split(` `),l=i[i.length-1],u=null;i.length>1&&(u=i.slice(0,i.length-1),u.reverse()),n[r++]=new us(l,u,e,o,s,c)}}return n}var us=class{constructor(e,t,n,r,i,a){this.scope=e,this.parentScopes=t,this.index=n,this.fontStyle=r,this.foreground=i,this.background=a}scope;parentScopes;index;fontStyle;foreground;background},ds=(e=>(e[e.NotSet=-1]=`NotSet`,e[e.None=0]=`None`,e[e.Italic=1]=`Italic`,e[e.Bold=2]=`Bold`,e[e.Underline=4]=`Underline`,e[e.Strikethrough=8]=`Strikethrough`,e))(ds||{});function fs(e,t){e.sort((e,t)=>{let n=Qo(e.scope,t.scope);return n!==0||(n=$o(e.parentScopes,t.parentScopes),n!==0)?n:e.index-t.index});let n=0,r=`#000000`,i=`#ffffff`;for(;e.length>=1&&e[0].scope===``;){let t=e.shift();t.fontStyle!==-1&&(n=t.fontStyle),t.foreground!==null&&(r=t.foreground),t.background!==null&&(i=t.background)}let a=new ps(t),o=new cs(n,a.getId(r),a.getId(i)),s=new gs(new hs(0,null,-1,0,0),[]);for(let t=0,n=e.length;t<n;t++){let n=e[t];s.insert(0,n.scope,n.parentScopes,n.fontStyle,a.getId(n.foreground),a.getId(n.background))}return new rs(a,o,s)}var ps=class{_isFrozen;_lastColorId;_id2color;_color2id;constructor(e){if(this._lastColorId=0,this._id2color=[],this._color2id=Object.create(null),Array.isArray(e)){this._isFrozen=!0;for(let t=0,n=e.length;t<n;t++)this._color2id[e[t]]=t,this._id2color[t]=e[t]}else this._isFrozen=!1}getId(e){if(e===null)return 0;e=e.toUpperCase();let t=this._color2id[e];if(t)return t;if(this._isFrozen)throw Error(`Missing color in color map - ${e}`);return t=++this._lastColorId,this._color2id[e]=t,this._id2color[t]=e,t}getColorMap(){return this._id2color.slice(0)}},ms=Object.freeze([]),hs=class e{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(e,t,n,r,i){this.scopeDepth=e,this.parentScopes=t||ms,this.fontStyle=n,this.foreground=r,this.background=i}clone(){return new e(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(e){let t=[];for(let n=0,r=e.length;n<r;n++)t[n]=e[n].clone();return t}acceptOverwrite(e,t,n,r){this.scopeDepth>e?console.log(`how did this happen?`):this.scopeDepth=e,t!==-1&&(this.fontStyle=t),n!==0&&(this.foreground=n),r!==0&&(this.background=r)}},gs=class e{constructor(e,t=[],n={}){this._mainRule=e,this._children=n,this._rulesWithParentScopes=t}_mainRule;_children;_rulesWithParentScopes;static _cmpBySpecificity(e,t){if(e.scopeDepth!==t.scopeDepth)return t.scopeDepth-e.scopeDepth;let n=0,r=0;for(;e.parentScopes[n]===`>`&&n++,t.parentScopes[r]===`>`&&r++,!(n>=e.parentScopes.length||r>=t.parentScopes.length);){let i=t.parentScopes[r].length-e.parentScopes[n].length;if(i!==0)return i;n++,r++}return t.parentScopes.length-e.parentScopes.length}match(t){if(t!==``){let e=t.indexOf(`.`),n,r;if(e===-1?(n=t,r=``):(n=t.substring(0,e),r=t.substring(e+1)),this._children.hasOwnProperty(n))return this._children[n].match(r)}let n=this._rulesWithParentScopes.concat(this._mainRule);return n.sort(e._cmpBySpecificity),n}insert(t,n,r,i,a,o){if(n===``){this._doInsertHere(t,r,i,a,o);return}let s=n.indexOf(`.`),c,l;s===-1?(c=n,l=``):(c=n.substring(0,s),l=n.substring(s+1));let u;this._children.hasOwnProperty(c)?u=this._children[c]:(u=new e(this._mainRule.clone(),hs.cloneArr(this._rulesWithParentScopes)),this._children[c]=u),u.insert(t+1,l,r,i,a,o)}_doInsertHere(e,t,n,r,i){if(t===null){this._mainRule.acceptOverwrite(e,n,r,i);return}for(let a=0,o=this._rulesWithParentScopes.length;a<o;a++){let o=this._rulesWithParentScopes[a];if($o(o.parentScopes,t)===0){o.acceptOverwrite(e,n,r,i);return}}n===-1&&(n=this._mainRule.fontStyle),r===0&&(r=this._mainRule.foreground),i===0&&(i=this._mainRule.background),this._rulesWithParentScopes.push(new hs(e,t,n,r,i))}},_s=class e{static toBinaryStr(e){return e.toString(2).padStart(32,`0`)}static print(t){let n=e.getLanguageId(t),r=e.getTokenType(t),i=e.getFontStyle(t),a=e.getForeground(t),o=e.getBackground(t);console.log({languageId:n,tokenType:r,fontStyle:i,foreground:a,background:o})}static getLanguageId(e){return(e&255)>>>0}static getTokenType(e){return(e&768)>>>8}static containsBalancedBrackets(e){return(e&1024)!=0}static getFontStyle(e){return(e&30720)>>>11}static getForeground(e){return(e&16744448)>>>15}static getBackground(e){return(e&4278190080)>>>24}static set(t,n,r,i,a,o,s){let c=e.getLanguageId(t),l=e.getTokenType(t),u=+!!e.containsBalancedBrackets(t),d=e.getFontStyle(t),f=e.getForeground(t),p=e.getBackground(t);return n!==0&&(c=n),r!==8&&(l=ys(r)),i!==null&&(u=+!!i),a!==-1&&(d=a),o!==0&&(f=o),s!==0&&(p=s),(c<<0|l<<8|u<<10|d<<11|f<<15|p<<24)>>>0}};function vs(e){return e}function ys(e){return e}function bs(e,t){let n=[],r=Ss(e),i=r.next();for(;i!==null;){let e=0;if(i.length===2&&i.charAt(1)===`:`){switch(i.charAt(0)){case`R`:e=1;break;case`L`:e=-1;break;default:console.log(`Unknown priority ${i} in scope selector`)}i=r.next()}let t=o();if(n.push({matcher:t,priority:e}),i!==`,`)break;i=r.next()}return n;function a(){if(i===`-`){i=r.next();let e=a();return t=>!!e&&!e(t)}if(i===`(`){i=r.next();let e=s();return i===`)`&&(i=r.next()),e}if(xs(i)){let e=[];do e.push(i),i=r.next();while(xs(i));return n=>t(e,n)}return null}function o(){let e=[],t=a();for(;t;)e.push(t),t=a();return t=>e.every(e=>e(t))}function s(){let e=[],t=o();for(;t&&(e.push(t),i===`|`||i===`,`);){do i=r.next();while(i===`|`||i===`,`);t=o()}return t=>e.some(e=>e(t))}}function xs(e){return!!e&&!!e.match(/[\w\.:]+/)}function Ss(e){let t=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,n=t.exec(e);return{next:()=>{if(!n)return null;let r=n[0];return n=t.exec(e),r}}}function Cs(e){typeof e.dispose==`function`&&e.dispose()}var ws=class{constructor(e){this.scopeName=e}scopeName;toKey(){return this.scopeName}},Ts=class{constructor(e,t){this.scopeName=e,this.ruleName=t}scopeName;ruleName;toKey(){return`${this.scopeName}#${this.ruleName}`}},Es=class{_references=[];_seenReferenceKeys=new Set;get references(){return this._references}visitedRule=new Set;add(e){let t=e.toKey();this._seenReferenceKeys.has(t)||(this._seenReferenceKeys.add(t),this._references.push(e))}},Ds=class{constructor(e,t){this.repo=e,this.initialScopeName=t,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new ws(this.initialScopeName)]}repo;initialScopeName;seenFullScopeRequests=new Set;seenPartialScopeRequests=new Set;Q;processQueue(){let e=this.Q;this.Q=[];let t=new Es;for(let n of e)Os(n,this.initialScopeName,this.repo,t);for(let e of t.references)if(e instanceof ws){if(this.seenFullScopeRequests.has(e.scopeName))continue;this.seenFullScopeRequests.add(e.scopeName),this.Q.push(e)}else{if(this.seenFullScopeRequests.has(e.scopeName)||this.seenPartialScopeRequests.has(e.toKey()))continue;this.seenPartialScopeRequests.add(e.toKey()),this.Q.push(e)}}};function Os(e,t,n,r){let i=n.lookup(e.scopeName);if(!i){if(e.scopeName===t)throw Error(`No grammar provided for <${t}>`);return}let a=n.lookup(t);e instanceof ws?As({baseGrammar:a,selfGrammar:i},r):ks(e.ruleName,{baseGrammar:a,selfGrammar:i,repository:i.repository},r);let o=n.injections(e.scopeName);if(o)for(let e of o)r.add(new ws(e))}function ks(e,t,n){if(t.repository&&t.repository[e]){let r=t.repository[e];js([r],t,n)}}function As(e,t){e.selfGrammar.patterns&&Array.isArray(e.selfGrammar.patterns)&&js(e.selfGrammar.patterns,{...e,repository:e.selfGrammar.repository},t),e.selfGrammar.injections&&js(Object.values(e.selfGrammar.injections),{...e,repository:e.selfGrammar.repository},t)}function js(e,t,n){for(let r of e){if(n.visitedRule.has(r))continue;n.visitedRule.add(r);let e=r.repository?Jo({},t.repository,r.repository):t.repository;Array.isArray(r.patterns)&&js(r.patterns,{...t,repository:e},n);let i=r.include;if(!i)continue;let a=Ps(i);switch(a.kind){case 0:As({...t,selfGrammar:t.baseGrammar},n);break;case 1:As(t,n);break;case 2:ks(a.ruleName,{...t,repository:e},n);break;case 3:case 4:let r=a.scopeName===t.selfGrammar.scopeName?t.selfGrammar:a.scopeName===t.baseGrammar.scopeName?t.baseGrammar:void 0;if(r){let i={baseGrammar:t.baseGrammar,selfGrammar:r,repository:e};a.kind===4?ks(a.ruleName,i,n):As(i,n)}else a.kind===4?n.add(new Ts(a.scopeName,a.ruleName)):n.add(new ws(a.scopeName));break}}}var Ms=class{kind=0},Ns=class{kind=1},nee=class{constructor(e){this.ruleName=e}ruleName;kind=2},ree=class{constructor(e){this.scopeName=e}scopeName;kind=3},iee=class{constructor(e,t){this.scopeName=e,this.ruleName=t}scopeName;ruleName;kind=4};function Ps(e){if(e===`$base`)return new Ms;if(e===`$self`)return new Ns;let t=e.indexOf(`#`);return t===-1?new ree(e):t===0?new nee(e.substring(1)):new iee(e.substring(0,t),e.substring(t+1))}var Fs=/\\(\d+)/,Is=/\\(\d+)/g,Ls=-1,Rs=-2;function zs(e){return e}function Bs(e){return e}var Vs=class{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(e,t,n,r){this.$location=e,this.id=t,this._name=n||null,this._nameIsCapturing=Zo.hasCaptures(this._name),this._contentName=r||null,this._contentNameIsCapturing=Zo.hasCaptures(this._contentName)}get debugName(){let e=this.$location?`${Yo(this.$location.filename)}:${this.$location.line}`:`unknown`;return`${this.constructor.name}#${this.id} @ ${e}`}getName(e,t){return!this._nameIsCapturing||this._name===null||e===null||t===null?this._name:Zo.replaceCaptures(this._name,e,t)}getContentName(e,t){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:Zo.replaceCaptures(this._contentName,e,t)}},Hs=class extends Vs{retokenizeCapturedWithRuleId;constructor(e,t,n,r,i){super(e,t,n,r),this.retokenizeCapturedWithRuleId=i}dispose(){}collectPatterns(e,t){throw Error(`Not supported!`)}compile(e,t){throw Error(`Not supported!`)}compileAG(e,t,n,r){throw Error(`Not supported!`)}},Us=class extends Vs{_match;captures;_cachedCompiledPatterns;constructor(e,t,n,r,i){super(e,t,n,null),this._match=new Js(r,this.id),this.captures=i,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null)}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(e,t){t.push(this._match)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new Ys,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Ws=class extends Vs{hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,n,r,i){super(e,t,n,r),this.patterns=i.patterns,this.hasMissingPatterns=i.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null)}collectPatterns(e,t){for(let n of this.patterns)e.getRule(n).collectPatterns(e,t)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new Ys,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Gs=class extends Vs{_begin;beginCaptures;_end;endHasBackReferences;endCaptures;applyEndPatternLast;hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,n,r,i,a,o,s,c,l){super(e,t,n,r),this._begin=new Js(i,this.id),this.beginCaptures=a,this._end=new Js(o||``,-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=s,this.applyEndPatternLast=c||!1,this.patterns=l.patterns,this.hasMissingPatterns=l.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(e,t){return this._end.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e,t).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e,t).compileAG(e,n,r)}_getCachedCompiledPatterns(e,t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Ys;for(let t of this.patterns)e.getRule(t).collectPatterns(e,this._cachedCompiledPatterns);this.applyEndPatternLast?this._cachedCompiledPatterns.push(this._end.hasBackReferences?this._end.clone():this._end):this._cachedCompiledPatterns.unshift(this._end.hasBackReferences?this._end.clone():this._end)}return this._end.hasBackReferences&&(this.applyEndPatternLast?this._cachedCompiledPatterns.setSource(this._cachedCompiledPatterns.length()-1,t):this._cachedCompiledPatterns.setSource(0,t)),this._cachedCompiledPatterns}},Ks=class extends Vs{_begin;beginCaptures;whileCaptures;_while;whileHasBackReferences;hasMissingPatterns;patterns;_cachedCompiledPatterns;_cachedCompiledWhilePatterns;constructor(e,t,n,r,i,a,o,s,c){super(e,t,n,r),this._begin=new Js(i,this.id),this.beginCaptures=a,this.whileCaptures=s,this._while=new Js(o,Rs),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=c.patterns,this.hasMissingPatterns=c.hasMissingPatterns,this._cachedCompiledPatterns=null,this._cachedCompiledWhilePatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null),this._cachedCompiledWhilePatterns&&=(this._cachedCompiledWhilePatterns.dispose(),null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugWhileRegExp(){return`${this._while.source}`}getWhileWithResolvedBackReferences(e,t){return this._while.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Ys;for(let t of this.patterns)e.getRule(t).collectPatterns(e,this._cachedCompiledPatterns)}return this._cachedCompiledPatterns}compileWhile(e,t){return this._getCachedCompiledWhilePatterns(e,t).compile(e)}compileWhileAG(e,t,n,r){return this._getCachedCompiledWhilePatterns(e,t).compileAG(e,n,r)}_getCachedCompiledWhilePatterns(e,t){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new Ys,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,t||``),this._cachedCompiledWhilePatterns}},qs=class e{static createCaptureRule(e,t,n,r,i){return e.registerRule(e=>new Hs(t,e,n,r,i))}static getCompiledRuleId(t,n,r){return t.id||n.registerRule(i=>{if(t.id=i,t.match)return new Us(t.$vscodeTextmateLocation,t.id,t.name,t.match,e._compileCaptures(t.captures,n,r));if(t.begin===void 0){t.repository&&(r=Jo({},r,t.repository));let i=t.patterns;return i===void 0&&t.include&&(i=[{include:t.include}]),new Ws(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,e._compilePatterns(i,n,r))}return t.while?new Ks(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,e._compileCaptures(t.beginCaptures||t.captures,n,r),t.while,e._compileCaptures(t.whileCaptures||t.captures,n,r),e._compilePatterns(t.patterns,n,r)):new Gs(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,e._compileCaptures(t.beginCaptures||t.captures,n,r),t.end,e._compileCaptures(t.endCaptures||t.captures,n,r),t.applyEndPatternLast,e._compilePatterns(t.patterns,n,r))}),t.id}static _compileCaptures(t,n,r){let i=[];if(t){let a=0;for(let e in t){if(e===`$vscodeTextmateLocation`)continue;let t=parseInt(e,10);t>a&&(a=t)}for(let e=0;e<=a;e++)i[e]=null;for(let a in t){if(a===`$vscodeTextmateLocation`)continue;let o=parseInt(a,10),s=0;t[a].patterns&&(s=e.getCompiledRuleId(t[a],n,r)),i[o]=e.createCaptureRule(n,t[a].$vscodeTextmateLocation,t[a].name,t[a].contentName,s)}}return i}static _compilePatterns(t,n,r){let i=[];if(t)for(let a=0,o=t.length;a<o;a++){let o=t[a],s=-1;if(o.include){let t=Ps(o.include);switch(t.kind){case 0:case 1:s=e.getCompiledRuleId(r[o.include],n,r);break;case 2:let i=r[t.ruleName];i&&(s=e.getCompiledRuleId(i,n,r));break;case 3:case 4:let a=t.scopeName,c=t.kind===4?t.ruleName:null,l=n.getExternalGrammar(a,r);if(l)if(c){let t=l.repository[c];t&&(s=e.getCompiledRuleId(t,n,l.repository))}else s=e.getCompiledRuleId(l.repository.$self,n,l.repository);break}}else s=e.getCompiledRuleId(o,n,r);if(s!==-1){let e=n.getRule(s),t=!1;if((e instanceof Ws||e instanceof Gs||e instanceof Ks)&&e.hasMissingPatterns&&e.patterns.length===0&&(t=!0),t)continue;i.push(s)}}return{patterns:i,hasMissingPatterns:(t?t.length:0)!==i.length}}},Js=class e{source;ruleId;hasAnchor;hasBackReferences;_anchorCache;constructor(e,t){if(e&&typeof e==`string`){let t=e.length,n=0,r=[],i=!1;for(let a=0;a<t;a++)if(e.charAt(a)===`\\`&&a+1<t){let t=e.charAt(a+1);t===`z`?(r.push(e.substring(n,a)),r.push(`$(?!\\n)(?<!\\n)`),n=a+2):(t===`A`||t===`G`)&&(i=!0),a++}this.hasAnchor=i,n===0?this.source=e:(r.push(e.substring(n,t)),this.source=r.join(``))}else this.hasAnchor=!1,this.source=e;this.hasAnchor?this._anchorCache=this._buildAnchorCache():this._anchorCache=null,this.ruleId=t,typeof this.source==`string`?this.hasBackReferences=Fs.test(this.source):this.hasBackReferences=!1}clone(){return new e(this.source,this.ruleId)}setSource(e){this.source!==e&&(this.source=e,this.hasAnchor&&(this._anchorCache=this._buildAnchorCache()))}resolveBackReferences(e,t){if(typeof this.source!=`string`)throw Error(`This method should only be called if the source is a string`);let n=t.map(t=>e.substring(t.start,t.end));return Is.lastIndex=0,this.source.replace(Is,(e,t)=>ts(n[parseInt(t,10)]||``))}_buildAnchorCache(){if(typeof this.source!=`string`)throw Error(`This method should only be called if the source is a string`);let e=[],t=[],n=[],r=[],i,a,o,s;for(i=0,a=this.source.length;i<a;i++)o=this.source.charAt(i),e[i]=o,t[i]=o,n[i]=o,r[i]=o,o===`\\`&&i+1<a&&(s=this.source.charAt(i+1),s===`A`?(e[i+1]=``,t[i+1]=``,n[i+1]=`A`,r[i+1]=`A`):s===`G`?(e[i+1]=``,t[i+1]=`G`,n[i+1]=``,r[i+1]=`G`):(e[i+1]=s,t[i+1]=s,n[i+1]=s,r[i+1]=s),i++);return{A0_G0:e.join(``),A0_G1:t.join(``),A1_G0:n.join(``),A1_G1:r.join(``)}}resolveAnchors(e,t){return!this.hasAnchor||!this._anchorCache||typeof this.source!=`string`?this.source:e?t?this._anchorCache.A1_G1:this._anchorCache.A1_G0:t?this._anchorCache.A0_G1:this._anchorCache.A0_G0}},Ys=class{_items;_hasAnchors;_cached;_anchorCache;constructor(){this._items=[],this._hasAnchors=!1,this._cached=null,this._anchorCache={A0_G0:null,A0_G1:null,A1_G0:null,A1_G1:null}}dispose(){this._disposeCaches()}_disposeCaches(){this._cached&&=(this._cached.dispose(),null),this._anchorCache.A0_G0&&(this._anchorCache.A0_G0.dispose(),this._anchorCache.A0_G0=null),this._anchorCache.A0_G1&&(this._anchorCache.A0_G1.dispose(),this._anchorCache.A0_G1=null),this._anchorCache.A1_G0&&(this._anchorCache.A1_G0.dispose(),this._anchorCache.A1_G0=null),this._anchorCache.A1_G1&&(this._anchorCache.A1_G1.dispose(),this._anchorCache.A1_G1=null)}push(e){this._items.push(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}unshift(e){this._items.unshift(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}length(){return this._items.length}setSource(e,t){this._items[e].source!==t&&(this._disposeCaches(),this._items[e].setSource(t))}compile(e){if(!this._cached){let t=this._items.map(e=>e.source);this._cached=new Xs(e,t,this._items.map(e=>e.ruleId))}return this._cached}compileAG(e,t,n){return this._hasAnchors?t?n?(this._anchorCache.A1_G1||(this._anchorCache.A1_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G1):(this._anchorCache.A1_G0||(this._anchorCache.A1_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G0):n?(this._anchorCache.A0_G1||(this._anchorCache.A0_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G1):(this._anchorCache.A0_G0||(this._anchorCache.A0_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G0):this.compile(e)}_resolveAnchors(e,t,n){return new Xs(e,this._items.map(e=>e.resolveAnchors(t,n)),this._items.map(e=>e.ruleId))}},Xs=class{constructor(e,t,n){this.regExps=t,this.rules=n,this.scanner=e.createOnigScanner(t)}regExps;rules;scanner;dispose(){typeof this.scanner.dispose==`function`&&this.scanner.dispose()}toString(){let e=[];for(let t=0,n=this.rules.length;t<n;t++)e.push(` - `+this.rules[t]+`: `+this.regExps[t]);return e.join(`
|
|
5
|
+
`)}findNextMatchSync(e,t,n){let r=this.scanner.findNextMatchSync(e,t,n);return r?{ruleId:this.rules[r.index],captureIndices:r.captureIndices}:null}},Zs=class{constructor(e,t){this.languageId=e,this.tokenType=t}languageId;tokenType},Qs=class e{_defaultAttributes;_embeddedLanguagesMatcher;constructor(e,t){this._defaultAttributes=new Zs(e,8),this._embeddedLanguagesMatcher=new $s(Object.entries(t||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(t){return t===null?e._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(t)}static _NULL_SCOPE_METADATA=new Zs(0,0);_getBasicScopeAttributes=new ns(e=>new Zs(this._scopeToLanguage(e),this._toStandardTokenType(e)));_scopeToLanguage(e){return this._embeddedLanguagesMatcher.match(e)||0}_toStandardTokenType(t){let n=t.match(e.STANDARD_TOKEN_TYPE_REGEXP);if(!n)return 8;switch(n[1]){case`comment`:return 1;case`string`:return 2;case`regex`:return 3;case`meta.embedded`:return 0}throw Error(`Unexpected match for standard token type!`)}static STANDARD_TOKEN_TYPE_REGEXP=/\b(comment|string|regex|meta\.embedded)\b/},$s=class{values;scopesRegExp;constructor(e){if(e.length===0)this.values=null,this.scopesRegExp=null;else{this.values=new Map(e);let t=e.map(([e,t])=>ts(e));t.sort(),t.reverse(),this.scopesRegExp=RegExp(`^((${t.join(`)|(`)}))($|\\.)`,``)}}match(e){if(!this.scopesRegExp)return;let t=e.match(this.scopesRegExp);if(t)return this.values.get(t[1])}};typeof process<`u`&&{}.VSCODE_TEXTMATE_DEBUG;var ec=class{constructor(e,t){this.stack=e,this.stoppedEarly=t}stack;stoppedEarly};function tc(e,t,n,r,i,a,o,s){let c=t.content.length,l=!1,u=-1;if(o){let o=nc(e,t,n,r,i,a);i=o.stack,r=o.linePos,n=o.isFirstLine,u=o.anchorPosition}let d=Date.now();for(;!l;){if(s!==0&&Date.now()-d>s)return new ec(i,!0);f()}return new ec(i,!1);function f(){let o=rc(e,t,n,r,i,u);if(!o){a.produce(i,c),l=!0;return}let s=o.captureIndices,d=o.matchedRuleId,f=s&&s.length>0?s[0].end>r:!1;if(d===Ls){let o=i.getRule(e);a.produce(i,s[0].start),i=i.withContentNameScopesList(i.nameScopesList),cc(e,t,n,i,a,o.endCaptures,s),a.produce(i,s[0].end);let d=i;if(i=i.parent,u=d.getAnchorPos(),!f&&d.getEnterPos()===r){i=d,a.produce(i,c),l=!0;return}}else{let o=e.getRule(d);a.produce(i,s[0].start);let p=i,m=o.getName(t.content,s),h=i.contentNameScopesList.pushAttributed(m,e);if(i=i.push(d,r,u,s[0].end===c,null,h,h),o instanceof Gs){let r=o;cc(e,t,n,i,a,r.beginCaptures,s),a.produce(i,s[0].end),u=s[0].end;let d=r.getContentName(t.content,s),m=h.pushAttributed(d,e);if(i=i.withContentNameScopesList(m),r.endHasBackReferences&&(i=i.withEndRule(r.getEndWithResolvedBackReferences(t.content,s))),!f&&p.hasSameRuleAs(i)){i=i.pop(),a.produce(i,c),l=!0;return}}else if(o instanceof Ks){let r=o;cc(e,t,n,i,a,r.beginCaptures,s),a.produce(i,s[0].end),u=s[0].end;let d=r.getContentName(t.content,s),m=h.pushAttributed(d,e);if(i=i.withContentNameScopesList(m),r.whileHasBackReferences&&(i=i.withEndRule(r.getWhileWithResolvedBackReferences(t.content,s))),!f&&p.hasSameRuleAs(i)){i=i.pop(),a.produce(i,c),l=!0;return}}else if(cc(e,t,n,i,a,o.captures,s),a.produce(i,s[0].end),i=i.pop(),!f){i=i.safePop(),a.produce(i,c),l=!0;return}}s[0].end>r&&(r=s[0].end,n=!1)}}function nc(e,t,n,r,i,a){let o=i.beginRuleCapturedEOL?0:-1,s=[];for(let t=i;t;t=t.pop()){let n=t.getRule(e);n instanceof Ks&&s.push({rule:n,stack:t})}for(let c=s.pop();c;c=s.pop()){let{ruleScanner:s,findOptions:l}=sc(c.rule,e,c.stack.endRule,n,r===o),u=s.findNextMatchSync(t,r,l);if(u){if(u.ruleId!==Rs){i=c.stack.pop();break}u.captureIndices&&u.captureIndices.length&&(a.produce(c.stack,u.captureIndices[0].start),cc(e,t,n,c.stack,a,c.rule.whileCaptures,u.captureIndices),a.produce(c.stack,u.captureIndices[0].end),o=u.captureIndices[0].end,u.captureIndices[0].end>r&&(r=u.captureIndices[0].end,n=!1))}else{i=c.stack.pop();break}}return{stack:i,linePos:r,anchorPosition:o,isFirstLine:n}}function rc(e,t,n,r,i,a){let o=ic(e,t,n,r,i,a),s=e.getInjections();if(s.length===0)return o;let c=ac(s,e,t,n,r,i,a);if(!c)return o;if(!o)return c;let l=o.captureIndices[0].start,u=c.captureIndices[0].start;return u<l||c.priorityMatch&&u===l?c:o}function ic(e,t,n,r,i,a){let{ruleScanner:o,findOptions:s}=oc(i.getRule(e),e,i.endRule,n,r===a),c=o.findNextMatchSync(t,r,s);return c?{captureIndices:c.captureIndices,matchedRuleId:c.ruleId}:null}function ac(e,t,n,r,i,a,o){let s=Number.MAX_VALUE,c=null,l,u=0,d=a.contentNameScopesList.getScopeNames();for(let a=0,f=e.length;a<f;a++){let f=e[a];if(!f.matcher(d))continue;let{ruleScanner:p,findOptions:m}=oc(t.getRule(f.ruleId),t,null,r,i===o),h=p.findNextMatchSync(n,i,m);if(!h)continue;let g=h.captureIndices[0].start;if(!(g>=s)&&(s=g,c=h.captureIndices,l=h.ruleId,u=f.priority,s===i))break}return c?{priorityMatch:u===-1,captureIndices:c,matchedRuleId:l}:null}function oc(e,t,n,r,i){return{ruleScanner:e.compileAG(t,n,r,i),findOptions:0}}function sc(e,t,n,r,i){return{ruleScanner:e.compileWhileAG(t,n,r,i),findOptions:0}}function cc(e,t,n,r,i,a,o){if(a.length===0)return;let s=t.content,c=Math.min(a.length,o.length),l=[],u=o[0].end;for(let t=0;t<c;t++){let c=a[t];if(c===null)continue;let d=o[t];if(d.length===0)continue;if(d.start>u)break;for(;l.length>0&&l[l.length-1].endPos<=d.start;)i.produceFromScopes(l[l.length-1].scopes,l[l.length-1].endPos),l.pop();if(l.length>0?i.produceFromScopes(l[l.length-1].scopes,d.start):i.produce(r,d.start),c.retokenizeCapturedWithRuleId){let t=c.getName(s,o),a=r.contentNameScopesList.pushAttributed(t,e),l=c.getContentName(s,o),u=a.pushAttributed(l,e),f=r.push(c.retokenizeCapturedWithRuleId,d.start,-1,!1,null,a,u),p=e.createOnigString(s.substring(0,d.end));tc(e,p,n&&d.start===0,d.start,f,i,!1,0),Cs(p);continue}let f=c.getName(s,o);if(f!==null){let t=(l.length>0?l[l.length-1].scopes:r.contentNameScopesList).pushAttributed(f,e);l.push(new lc(t,d.end))}}for(;l.length>0;)i.produceFromScopes(l[l.length-1].scopes,l[l.length-1].endPos),l.pop()}var lc=class{scopes;endPos;constructor(e,t){this.scopes=e,this.endPos=t}};function uc(e,t,n,r,i,a,o,s){return new mc(e,t,n,r,i,a,o,s)}function dc(e,t,n,r,i){let a=bs(t,fc),o=qs.getCompiledRuleId(n,r,i.repository);for(let n of a)e.push({debugSelector:t,matcher:n.matcher,ruleId:o,grammar:i,priority:n.priority})}function fc(e,t){if(t.length<e.length)return!1;let n=0;return e.every(e=>{for(let r=n;r<t.length;r++)if(pc(t[r],e))return n=r+1,!0;return!1})}function pc(e,t){if(!e)return!1;if(e===t)return!0;let n=t.length;return e.length>n&&e.substr(0,n)===t&&e[n]===`.`}var mc=class{constructor(e,t,n,r,i,a,o,s){if(this._rootScopeName=e,this.balancedBracketSelectors=a,this._onigLib=s,this._basicScopeAttributesProvider=new Qs(n,r),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=o,this._grammar=hc(t,null),this._injections=null,this._tokenTypeMatchers=[],i)for(let e of Object.keys(i)){let t=bs(e,fc);for(let n of t)this._tokenTypeMatchers.push({matcher:n.matcher,type:i[e]})}}_rootScopeName;balancedBracketSelectors;_onigLib;_rootId;_lastRuleId;_ruleId2desc;_includedGrammars;_grammarRepository;_grammar;_injections;_basicScopeAttributesProvider;_tokenTypeMatchers;get themeProvider(){return this._grammarRepository}dispose(){for(let e of this._ruleId2desc)e&&e.dispose()}createOnigScanner(e){return this._onigLib.createOnigScanner(e)}createOnigString(e){return this._onigLib.createOnigString(e)}getMetadataForScope(e){return this._basicScopeAttributesProvider.getBasicScopeAttributes(e)}_collectInjections(){let e={lookup:e=>e===this._rootScopeName?this._grammar:this.getExternalGrammar(e),injections:e=>this._grammarRepository.injections(e)},t=[],n=this._rootScopeName,r=e.lookup(n);if(r){let e=r.injections;if(e)for(let n in e)dc(t,n,e[n],this,r);let i=this._grammarRepository.injections(n);i&&i.forEach(e=>{let n=this.getExternalGrammar(e);if(n){let e=n.injectionSelector;e&&dc(t,e,n,this,n)}})}return t.sort((e,t)=>e.priority-t.priority),t}getInjections(){return this._injections===null&&(this._injections=this._collectInjections()),this._injections}registerRule(e){let t=++this._lastRuleId,n=e(zs(t));return this._ruleId2desc[t]=n,n}getRule(e){return this._ruleId2desc[Bs(e)]}getExternalGrammar(e,t){if(this._includedGrammars[e])return this._includedGrammars[e];if(this._grammarRepository){let n=this._grammarRepository.lookup(e);if(n)return this._includedGrammars[e]=hc(n,t&&t.$base),this._includedGrammars[e]}}tokenizeLine(e,t,n=0){let r=this._tokenize(e,t,!1,n);return{tokens:r.lineTokens.getResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}tokenizeLine2(e,t,n=0){let r=this._tokenize(e,t,!0,n);return{tokens:r.lineTokens.getBinaryResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}_tokenize(e,t,n,r){this._rootId===-1&&(this._rootId=qs.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections());let i;if(!t||t===_c.NULL){i=!0;let e=this._basicScopeAttributesProvider.getDefaultAttributes(),n=this.themeProvider.getDefaults(),r=_s.set(0,e.languageId,e.tokenType,null,n.fontStyle,n.foregroundId,n.backgroundId),a=this.getRule(this._rootId).getName(null,null),o;o=a?gc.createRootAndLookUpScopeName(a,r,this):gc.createRoot(`unknown`,r),t=new _c(null,this._rootId,-1,-1,!1,null,o,o)}else i=!1,t.reset();e+=`
|
|
6
|
+
`;let a=this.createOnigString(e),o=a.content.length,s=new yc(n,e,this._tokenTypeMatchers,this.balancedBracketSelectors),c=tc(this,a,i,0,t,s,!0,r);return Cs(a),{lineLength:o,lineTokens:s,ruleStack:c.stack,stoppedEarly:c.stoppedEarly}}};function hc(e,t){return e=Wo(e),e.repository=e.repository||{},e.repository.$self={$vscodeTextmateLocation:e.$vscodeTextmateLocation,patterns:e.patterns,name:e.scopeName},e.repository.$base=t||e.repository.$self,e}var gc=class e{constructor(e,t,n){this.parent=e,this.scopePath=t,this.tokenAttributes=n}parent;scopePath;tokenAttributes;static fromExtension(t,n){let r=t,i=t?.scopePath??null;for(let t of n)i=is.push(i,t.scopeNames),r=new e(r,i,t.encodedTokenAttributes);return r}static createRoot(t,n){return new e(null,new is(null,t),n)}static createRootAndLookUpScopeName(t,n,r){let i=r.getMetadataForScope(t),a=new is(null,t),o=r.themeProvider.themeMatch(a),s=e.mergeAttributes(n,i,o);return new e(null,a,s)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(` `)}equals(t){return e.equals(this,t)}static equals(e,t){do{if(e===t||!e&&!t)return!0;if(!e||!t||e.scopeName!==t.scopeName||e.tokenAttributes!==t.tokenAttributes)return!1;e=e.parent,t=t.parent}while(!0)}static mergeAttributes(e,t,n){let r=-1,i=0,a=0;return n!==null&&(r=n.fontStyle,i=n.foregroundId,a=n.backgroundId),_s.set(e,t.languageId,t.tokenType,null,r,i,a)}pushAttributed(t,n){if(t===null)return this;if(t.indexOf(` `)===-1)return e._pushAttributed(this,t,n);let r=t.split(/ /g),i=this;for(let t of r)i=e._pushAttributed(i,t,n);return i}static _pushAttributed(t,n,r){let i=r.getMetadataForScope(n),a=t.scopePath.push(n),o=r.themeProvider.themeMatch(a),s=e.mergeAttributes(t.tokenAttributes,i,o);return new e(t,a,s)}getScopeNames(){return this.scopePath.getSegments()}getExtensionIfDefined(e){let t=[],n=this;for(;n&&n!==e;)t.push({encodedTokenAttributes:n.tokenAttributes,scopeNames:n.scopePath.getExtensionIfDefined(n.parent?.scopePath??null)}),n=n.parent;return n===e?t.reverse():void 0}},_c=class e{constructor(e,t,n,r,i,a,o,s){this.parent=e,this.ruleId=t,this.beginRuleCapturedEOL=i,this.endRule=a,this.nameScopesList=o,this.contentNameScopesList=s,this.depth=this.parent?this.parent.depth+1:1,this._enterPos=n,this._anchorPos=r}parent;ruleId;beginRuleCapturedEOL;endRule;nameScopesList;contentNameScopesList;_stackElementBrand=void 0;static NULL=new e(null,0,0,0,!1,null,null,null);_enterPos;_anchorPos;depth;equals(t){return t!==null&&e._equals(this,t)}static _equals(e,t){return e===t?!0:this._structuralEquals(e,t)?gc.equals(e.contentNameScopesList,t.contentNameScopesList):!1}static _structuralEquals(e,t){do{if(e===t||!e&&!t)return!0;if(!e||!t||e.depth!==t.depth||e.ruleId!==t.ruleId||e.endRule!==t.endRule)return!1;e=e.parent,t=t.parent}while(!0)}clone(){return this}static _reset(e){for(;e;)e._enterPos=-1,e._anchorPos=-1,e=e.parent}reset(){e._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(t,n,r,i,a,o,s){return new e(this,t,n,r,i,a,o,s)}getEnterPos(){return this._enterPos}getAnchorPos(){return this._anchorPos}getRule(e){return e.getRule(this.ruleId)}toString(){let e=[];return this._writeString(e,0),`[`+e.join(`,`)+`]`}_writeString(e,t){return this.parent&&(t=this.parent._writeString(e,t)),e[t++]=`(${this.ruleId}, ${this.nameScopesList?.toString()}, ${this.contentNameScopesList?.toString()})`,t}withContentNameScopesList(e){return this.contentNameScopesList===e?this:this.parent.push(this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,this.endRule,this.nameScopesList,e)}withEndRule(t){return this.endRule===t?this:new e(this.parent,this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,t,this.nameScopesList,this.contentNameScopesList)}hasSameRuleAs(e){let t=this;for(;t&&t._enterPos===e._enterPos;){if(t.ruleId===e.ruleId)return!0;t=t.parent}return!1}toStateStackFrame(){return{ruleId:Bs(this.ruleId),beginRuleCapturedEOL:this.beginRuleCapturedEOL,endRule:this.endRule,nameScopesList:this.nameScopesList?.getExtensionIfDefined(this.parent?.nameScopesList??null)??[],contentNameScopesList:this.contentNameScopesList?.getExtensionIfDefined(this.nameScopesList)??[]}}static pushFrame(t,n){let r=gc.fromExtension(t?.nameScopesList??null,n.nameScopesList);return new e(t,zs(n.ruleId),n.enterPos??-1,n.anchorPos??-1,n.beginRuleCapturedEOL,n.endRule,r,gc.fromExtension(r,n.contentNameScopesList))}},vc=class{balancedBracketScopes;unbalancedBracketScopes;allowAny=!1;constructor(e,t){this.balancedBracketScopes=e.flatMap(e=>e===`*`?(this.allowAny=!0,[]):bs(e,fc).map(e=>e.matcher)),this.unbalancedBracketScopes=t.flatMap(e=>bs(e,fc).map(e=>e.matcher))}get matchesAlways(){return this.allowAny&&this.unbalancedBracketScopes.length===0}get matchesNever(){return this.balancedBracketScopes.length===0&&!this.allowAny}match(e){for(let t of this.unbalancedBracketScopes)if(t(e))return!1;for(let t of this.balancedBracketScopes)if(t(e))return!0;return this.allowAny}},yc=class{constructor(e,t,n,r){this.balancedBracketSelectors=r,this._emitBinaryTokens=e,this._tokenTypeOverrides=n,this._lineText=null,this._tokens=[],this._binaryTokens=[],this._lastTokenEndIndex=0}balancedBracketSelectors;_emitBinaryTokens;_lineText;_tokens;_binaryTokens;_lastTokenEndIndex;_tokenTypeOverrides;produce(e,t){this.produceFromScopes(e.contentNameScopesList,t)}produceFromScopes(e,t){if(this._lastTokenEndIndex>=t)return;if(this._emitBinaryTokens){let n=e?.tokenAttributes??0,r=!1;if(this.balancedBracketSelectors?.matchesAlways&&(r=!0),this._tokenTypeOverrides.length>0||this.balancedBracketSelectors&&!this.balancedBracketSelectors.matchesAlways&&!this.balancedBracketSelectors.matchesNever){let t=e?.getScopeNames()??[];for(let e of this._tokenTypeOverrides)e.matcher(t)&&(n=_s.set(n,0,vs(e.type),null,-1,0,0));this.balancedBracketSelectors&&(r=this.balancedBracketSelectors.match(t))}if(r&&(n=_s.set(n,0,8,r,-1,0,0)),this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-1]===n){this._lastTokenEndIndex=t;return}this._binaryTokens.push(this._lastTokenEndIndex),this._binaryTokens.push(n),this._lastTokenEndIndex=t;return}let n=e?.getScopeNames()??[];this._tokens.push({startIndex:this._lastTokenEndIndex,endIndex:t,scopes:n}),this._lastTokenEndIndex=t}getResult(e,t){return this._tokens.length>0&&this._tokens[this._tokens.length-1].startIndex===t-1&&this._tokens.pop(),this._tokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._tokens[this._tokens.length-1].startIndex=0),this._tokens}getBinaryResult(e,t){this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-2]===t-1&&(this._binaryTokens.pop(),this._binaryTokens.pop()),this._binaryTokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._binaryTokens[this._binaryTokens.length-2]=0);let n=new Uint32Array(this._binaryTokens.length);for(let e=0,t=this._binaryTokens.length;e<t;e++)n[e]=this._binaryTokens[e];return n}},bc=class{constructor(e,t){this._onigLib=t,this._theme=e}_onigLib;_grammars=new Map;_rawGrammars=new Map;_injectionGrammars=new Map;_theme;dispose(){for(let e of this._grammars.values())e.dispose()}setTheme(e){this._theme=e}getColorMap(){return this._theme.getColorMap()}addGrammar(e,t){this._rawGrammars.set(e.scopeName,e),t&&this._injectionGrammars.set(e.scopeName,t)}lookup(e){return this._rawGrammars.get(e)}injections(e){return this._injectionGrammars.get(e)}getDefaults(){return this._theme.getDefaults()}themeMatch(e){return this._theme.match(e)}grammarForScopeName(e,t,n,r,i){if(!this._grammars.has(e)){let a=this._rawGrammars.get(e);if(!a)return null;this._grammars.set(e,uc(e,a,t,n,r,i,this,this._onigLib))}return this._grammars.get(e)}},xc=class{_options;_syncRegistry;_ensureGrammarCache;constructor(e){this._options=e,this._syncRegistry=new bc(rs.createFromRawTheme(e.theme,e.colorMap),e.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(e,t){this._syncRegistry.setTheme(rs.createFromRawTheme(e,t))}getColorMap(){return this._syncRegistry.getColorMap()}loadGrammarWithEmbeddedLanguages(e,t,n){return this.loadGrammarWithConfiguration(e,t,{embeddedLanguages:n})}loadGrammarWithConfiguration(e,t,n){return this._loadGrammar(e,t,n.embeddedLanguages,n.tokenTypes,new vc(n.balancedBracketSelectors||[],n.unbalancedBracketSelectors||[]))}loadGrammar(e){return this._loadGrammar(e,0,null,null,null)}_loadGrammar(e,t,n,r,i){let a=new Ds(this._syncRegistry,e);for(;a.Q.length>0;)a.Q.map(e=>this._loadSingleGrammar(e.scopeName)),a.processQueue();return this._grammarForScopeName(e,t,n,r,i)}_loadSingleGrammar(e){this._ensureGrammarCache.has(e)||(this._doLoadSingleGrammar(e),this._ensureGrammarCache.set(e,!0))}_doLoadSingleGrammar(e){let t=this._options.loadGrammar(e);if(t){let n=typeof this._options.getInjections==`function`?this._options.getInjections(e):void 0;this._syncRegistry.addGrammar(t,n)}}addGrammar(e,t=[],n=0,r=null){return this._syncRegistry.addGrammar(e,t),this._grammarForScopeName(e.scopeName,n,r)}_grammarForScopeName(e,t=0,n=null,r=null,i=null){return this._syncRegistry.grammarForScopeName(e,t,n,r,i)}},Sc=_c.NULL;function Cc(e,t){let n=typeof e==`string`?{}:{...e.colorReplacements},r=typeof e==`string`?e:e.name;for(let[e,i]of Object.entries(t?.colorReplacements||{}))typeof i==`string`?n[e]=i:e===r&&Object.assign(n,i);return n}function wc(e,t){return e&&(t?.[e?.toLowerCase()]||e)}function Tc(e){return Array.isArray(e)?e:[e]}async function Ec(e){return Promise.resolve(typeof e==`function`?e():e).then(e=>e.default||e)}function Dc(e){return!e||[`plaintext`,`txt`,`text`,`plain`].includes(e)}function Oc(e){return e===`ansi`||Dc(e)}function kc(e){return e===`none`}function Ac(e){return kc(e)}var jc=/(\r?\n)/g;function Mc(e,t=!1){if(e.length===0)return[[``,0]];let n=e.split(jc),r=0,i=[];for(let e=0;e<n.length;e+=2){let a=t?n[e]+(n[e+1]||``):n[e];i.push([a,r]),r+=n[e].length,r+=n[e+1]?.length||0}return i}var Nc={light:`#333333`,dark:`#bbbbbb`},Pc={light:`#fffffe`,dark:`#1e1e1e`},Fc=`__shiki_resolved`;function Ic(e){if(e?.[Fc])return e;let t={...e};t.tokenColors&&!t.settings&&(t.settings=t.tokenColors,delete t.tokenColors),t.type||=`dark`,t.colorReplacements={...t.colorReplacements},t.settings||=[];let{bg:n,fg:r}=t;if(!n||!r){let e=t.settings?t.settings.find(e=>!e.name&&!e.scope):void 0;e?.settings?.foreground&&(r=e.settings.foreground),e?.settings?.background&&(n=e.settings.background),!r&&t?.colors?.[`editor.foreground`]&&(r=t.colors[`editor.foreground`]),!n&&t?.colors?.[`editor.background`]&&(n=t.colors[`editor.background`]),r||=t.type===`light`?Nc.light:Nc.dark,n||=t.type===`light`?Pc.light:Pc.dark,t.fg=r,t.bg=n}t.settings[0]&&t.settings[0].settings&&!t.settings[0].scope||t.settings.unshift({settings:{foreground:t.fg,background:t.bg}});let i=0,a=new Map;function o(e){if(a.has(e))return a.get(e);i+=1;let n=`#${i.toString(16).padStart(8,`0`).toLowerCase()}`;return t.colorReplacements?.[`#${n}`]?o(e):(a.set(e,n),n)}t.settings=t.settings.map(e=>{let n=e.settings?.foreground&&!e.settings.foreground.startsWith(`#`),r=e.settings?.background&&!e.settings.background.startsWith(`#`);if(!n&&!r)return e;let i={...e,settings:{...e.settings}};if(n){let n=o(e.settings.foreground);t.colorReplacements[n]=e.settings.foreground,i.settings.foreground=n}if(r){let n=o(e.settings.background);t.colorReplacements[n]=e.settings.background,i.settings.background=n}return i});for(let e of Object.keys(t.colors||{}))if((e===`editor.foreground`||e===`editor.background`||e.startsWith(`terminal.ansi`))&&!t.colors[e]?.startsWith(`#`)){let n=o(t.colors[e]);t.colorReplacements[n]=t.colors[e],t.colors[e]=n}return Object.defineProperty(t,Fc,{enumerable:!1,writable:!1,value:!0}),t}async function Lc(e){return[...new Set((await Promise.all(e.filter(e=>!Oc(e)).map(async e=>await Ec(e).then(e=>Array.isArray(e)?e:[e])))).flat())]}async function Rc(e){return(await Promise.all(e.map(async e=>Ac(e)?null:Ic(await Ec(e))))).filter(e=>!!e)}function zc(e,t){if(!t)return e;if(t[e]){let n=new Set([e]);for(;t[e];){if(e=t[e],n.has(e))throw new Uo(`Circular alias \`${[...n].join(` -> `)} -> ${e}\``);n.add(e)}}return e}var Bc=class extends xc{_resolver;_themes;_langs;_alias;_resolvedThemes=new Map;_resolvedGrammars=new Map;_langMap=new Map;_langGraph=new Map;_textmateThemeCache=new WeakMap;_loadedThemesCache=null;_loadedLanguagesCache=null;constructor(e,t,n,r={}){super(e),this._resolver=e,this._themes=t,this._langs=n,this._alias=r,this._themes.map(e=>this.loadTheme(e)),this.loadLanguages(this._langs)}getTheme(e){return typeof e==`string`?this._resolvedThemes.get(e):this.loadTheme(e)}loadTheme(e){let t=Ic(e);return t.name&&(this._resolvedThemes.set(t.name,t),this._loadedThemesCache=null),t}getLoadedThemes(){return this._loadedThemesCache||=[...this._resolvedThemes.keys()],this._loadedThemesCache}setTheme(e){let t=this._textmateThemeCache.get(e);t||(t=rs.createFromRawTheme(e),this._textmateThemeCache.set(e,t)),this._syncRegistry.setTheme(t)}getGrammar(e){return e=zc(e,this._alias),this._resolvedGrammars.get(e)}loadLanguage(e){if(this.getGrammar(e.name))return;let t=new Set([...this._langMap.values()].filter(t=>t.embeddedLangsLazy?.includes(e.name)));this._resolver.addLanguage(e);let n={balancedBracketSelectors:e.balancedBracketSelectors||[`*`],unbalancedBracketSelectors:e.unbalancedBracketSelectors||[]};this._syncRegistry._rawGrammars.set(e.scopeName,e);let r=this.loadGrammarWithConfiguration(e.scopeName,1,n);r.name=e.name,this._resolvedGrammars.set(e.name,r),e.aliases&&e.aliases.forEach(t=>{this._alias[t]=e.name}),this._loadedLanguagesCache=null;for(let e of t)this.reloadLanguage(e);if(e.injectTo){let t=[...this._langMap.values()].filter(t=>t!==e&&this._resolvedGrammars.has(t.name)&&e.injectTo.some(e=>t.scopeName===e||t.scopeName.startsWith(`${e}.`))&&!this.hasCurrentInjections(t.scopeName));for(let e of t)this.reloadLanguage(e)}}hasCurrentInjections(e){let t=this._syncRegistry?._injectionGrammars?.get(e)||[],n=this._resolver.getInjections(e)||[];return t.length===n.length&&t.every((e,t)=>e===n[t])}reloadLanguage(e){this._syncRegistry?._grammars?.get(e.scopeName)?.dispose(),this._resolvedGrammars.delete(e.name),this._loadedLanguagesCache=null,this._syncRegistry?._grammars?.delete(e.scopeName),this._syncRegistry?._injectionGrammars?.set(e.scopeName,this._resolver.getInjections(e.scopeName)||[]),this.loadLanguage(this._langMap.get(e.name)||e)}dispose(){super.dispose(),this._resolvedThemes.clear(),this._resolvedGrammars.clear(),this._langMap.clear(),this._langGraph.clear(),this._loadedThemesCache=null}loadLanguages(e){for(let t of e)this.resolveEmbeddedLanguages(t);let t=[...this._langGraph.entries()],n=t.filter(([e,t])=>!t);if(n.length){let e=t.filter(([e,t])=>t?(t.embeddedLanguages||t.embeddedLangs)?.some(e=>n.map(([e])=>e).includes(e)):!1).filter(e=>!n.includes(e));throw new Uo(`Missing languages ${n.map(([e])=>`\`${e}\``).join(`, `)}, required by ${e.map(([e])=>`\`${e}\``).join(`, `)}`)}for(let[e,n]of t)this._resolver.addLanguage(n);for(let[e,n]of t)this.loadLanguage(n)}getLoadedLanguages(){return this._loadedLanguagesCache||=[...new Set([...this._resolvedGrammars.keys(),...Object.keys(this._alias)])],this._loadedLanguagesCache}resolveEmbeddedLanguages(e){this._langMap.set(e.name,e),this._langGraph.set(e.name,e);let t=e.embeddedLanguages??e.embeddedLangs;if(t)for(let e of t)this._langGraph.set(e,this._langMap.get(e))}},Vc=class{_langs=new Map;_scopeToLang=new Map;_injections=new Map;_onigLib;constructor(e,t){this._onigLib={createOnigScanner:t=>e.createScanner(t),createOnigString:t=>e.createString(t)},t.forEach(e=>this.addLanguage(e))}get onigLib(){return this._onigLib}getLangRegistration(e){return this._langs.get(e)}loadGrammar(e){return this._scopeToLang.get(e)}addLanguage(e){this._langs.set(e.name,e),e.aliases&&e.aliases.forEach(t=>{this._langs.set(t,e)}),this._scopeToLang.set(e.scopeName,e),e.injectTo&&e.injectTo.forEach(t=>{this._injections.get(t)||this._injections.set(t,[]),this._injections.get(t).includes(e.scopeName)||this._injections.get(t).push(e.scopeName)})}getInjections(e){let t=e.split(`.`),n=[];for(let e=1;e<=t.length;e++){let r=t.slice(0,e).join(`.`);n=[...n,...this._injections.get(r)||[]]}return n}},Hc=0;function Uc(e){Hc+=1,e.warnings!==!1&&Hc>=10&&Hc%10==0&&console.warn(`[Shiki] ${Hc} instances have been created. Shiki is supposed to be used as a singleton, consider refactoring your code to cache your highlighter instance; Or call \`highlighter.dispose()\` to release unused instances.`);let t=!1;if(!e.engine)throw new Uo("`engine` option is required for synchronous mode");let n=(e.langs||[]).flat(1),r=(e.themes||[]).flat(1).map(Ic),i=new Bc(new Vc(e.engine,n),r,n,e.langAlias),a;function o(t){return zc(t,e.langAlias)}function s(e){g();let t=i.getGrammar(typeof e==`string`?e:e.name);if(!t)throw new Uo(`Language \`${e}\` not found, you may need to load it first`);return t}function c(e){if(e===`none`)return{bg:``,fg:``,name:`none`,settings:[],type:`dark`};g();let t=i.getTheme(e);if(!t)throw new Uo(`Theme \`${e}\` not found, you may need to load it first`);return t}function l(e){g();let t=c(e);return a!==e&&(i.setTheme(t),a=e),{theme:t,colorMap:i.getColorMap()}}function u(){return g(),i.getLoadedThemes()}function d(){return g(),i.getLoadedLanguages()}function f(...e){g(),i.loadLanguages(e.flat(1))}async function p(...e){return f(await Lc(e))}function m(...e){g();for(let t of e.flat(1))i.loadTheme(t)}async function h(...e){return g(),m(await Rc(e))}function g(){if(t)throw new Uo(`Shiki instance has been disposed`)}function _(){t||(t=!0,i.dispose(),--Hc)}return{setTheme:l,getTheme:c,getLanguage:s,getLoadedThemes:u,getLoadedLanguages:d,resolveLangAlias:o,loadLanguage:p,loadLanguageSync:f,loadTheme:h,loadThemeSync:m,dispose:_,[Symbol.dispose]:_}}async function Wc(e){e.engine||console.warn("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");let[t,n,r]=await Promise.all([Rc(e.themes||[]),Lc(e.langs||[]),e.engine]);return Uc({...e,themes:t,langs:n,engine:r})}var Gc=new WeakMap;function Kc(e,t){Gc.set(e,t)}function qc(e){return Gc.get(e)}var Jc=class e{_stacks={};lang;get themes(){return Object.keys(this._stacks)}get theme(){return this.themes[0]}get _stack(){return this._stacks[this.theme]}static initial(t,n){return new e(Object.fromEntries(Tc(n).map(e=>[e,Sc])),t)}constructor(...e){if(e.length===2){let[t,n]=e;this.lang=n,this._stacks=t}else{let[t,n,r]=e;this.lang=n,this._stacks={[r]:t}}}getInternalStack(e=this.theme){return this._stacks[e]}getScopes(e=this.theme){return Yc(this._stacks[e])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}};function Yc(e){let t=[],n=new Set;function r(e){if(n.has(e))return;n.add(e);let i=e?.nameScopesList?.scopeName;i&&t.push(i),e.parent&&r(e.parent)}return r(e),t}function Xc(e,t){if(!(e instanceof Jc))throw new Uo(`Invalid grammar state`);return e.getInternalStack(t)}var Zc=/,/,Qc=/ /;function $c(e,t,n={}){let{theme:r=e.getLoadedThemes()[0]}=n;if(Dc(e.resolveLangAlias(n.lang||`text`))||kc(r))return Mc(t).map(e=>[{content:e[0],offset:e[1]}]);let{theme:i,colorMap:a}=e.setTheme(r),o=e.getLanguage(n.lang||`text`);if(n.grammarState){if(n.grammarState.lang!==o.name)throw new Uo(`Grammar state language "${n.grammarState.lang}" does not match highlight language "${o.name}"`);if(!n.grammarState.themes.includes(i.name))throw new Uo(`Grammar state themes "${n.grammarState.themes}" do not contain highlight theme "${i.name}"`)}return tl(t,o,i,a,n)}function el(...e){if(e.length===2)return qc(e[1]);let[t,n,r={}]=e,{lang:i=`text`,theme:a=t.getLoadedThemes()[0]}=r;if(Dc(i)||kc(a))throw new Uo(`Plain language does not have grammar state`);if(i===`ansi`)throw new Uo(`ANSI language does not have grammar state`);let{theme:o,colorMap:s}=t.setTheme(a),c=t.getLanguage(i);return new Jc(nl(n,c,o,s,r).stateStack,c.name,o.name)}function tl(e,t,n,r,i){let a=nl(e,t,n,r,i),o=new Jc(a.stateStack,t.name,n.name);return Kc(a.tokens,o),a.tokens}function nl(e,t,n,r,i){let a=Cc(n,i),{tokenizeMaxLineLength:o=0,tokenizeTimeLimit:s=500,includeExplanation:c=!1}=i,l=Mc(e),u=i.grammarState?Xc(i.grammarState,n.name)??Sc:i.grammarContextCode==null?Sc:nl(i.grammarContextCode,t,n,r,{...i,grammarState:void 0,grammarContextCode:void 0}).stateStack,d=[],f=[];for(let e=0,i=l.length;e<i;e++){let[i,p]=l[e];if(i===``){d=[],f.push([]);continue}if(o>0&&i.length>=o){d=[],f.push([{content:i,offset:p,color:``,fontStyle:0}]);continue}let m,h,g;c&&c!==`tokenType`&&(m=t.tokenizeLine(i,u,s),h=m.tokens,g=0);let _=t.tokenizeLine2(i,u,s),v=_.tokens.length/2;for(let e=0;e<v;e++){let t=_.tokens[2*e],o=e+1<v?_.tokens[2*e+2]:i.length;if(t===o)continue;let s=_.tokens[2*e+1],l=wc(r[_s.getForeground(s)],a),u=_s.getFontStyle(s),f={content:i.substring(t,o),offset:p+t,color:l,fontStyle:u};if(c===`tokenType`)f.type=_s.getTokenType(s);else if(c){let e=[];if(c!==`scopeName`)for(let t of n.settings){let n;switch(typeof t.scope){case`string`:n=t.scope.split(Zc).map(e=>e.trim());break;case`object`:n=t.scope;break;default:continue}e.push({settings:t,selectors:n.map(e=>e.split(Qc))})}f.explanation=[];let r=0;for(;t+r<o;){let t=h[g],n=i.substring(t.startIndex,t.endIndex);r+=n.length,f.explanation.push({content:n,scopes:c===`scopeName`?rl(t.scopes):il(e,t.scopes)}),g+=1}}d.push(f)}f.push(d),d=[],u=_.ruleStack}return{tokens:f,stateStack:u}}function rl(e){return e.map(e=>({scopeName:e}))}function il(e,t){let n=[];for(let r=0,i=t.length;r<i;r++){let i=t[r];n[r]={scopeName:i,themeMatches:sl(e,i,t.slice(0,r))}}return n}function al(e,t){return e===t||t.substring(0,e.length)===e&&t[e.length]===`.`}function ol(e,t,n){if(!al(e.at(-1),t))return!1;let r=e.length-2,i=n.length-1;for(;r>=0&&i>=0;)al(e[r],n[i])&&--r,--i;return r===-1}function sl(e,t,n){let r=[];for(let{selectors:i,settings:a}of e)for(let e of i)if(ol(e,t,n)){r.push(a);break}return r}function cl(e,t,n,r=$c){let i=Object.entries(n.themes).filter(e=>e[1]).map(e=>({color:e[0],theme:e[1]})),a=i.map(i=>{let a=r(e,t,{...n,theme:i.theme});return{tokens:a,state:qc(a),theme:typeof i.theme==`string`?i.theme:i.theme.name}}),o=ll(...a.map(e=>e.tokens)),s=o[0].map((e,t)=>e.map((e,r)=>{let a={content:e.content,variants:{},offset:e.offset};return`includeExplanation`in n&&n.includeExplanation&&(a.explanation=e.explanation),o.forEach((e,n)=>{let{content:o,explanation:s,offset:c,...l}=e[t][r];a.variants[i[n].color]=l}),a})),c=a[0].state?new Jc(Object.fromEntries(a.map(e=>[e.theme,e.state?.getInternalStack(e.theme)])),a[0].state.lang):void 0;return c&&Kc(s,c),s}function ll(...e){let t=e.map(()=>[]),n=e.length;for(let r=0;r<e[0].length;r++){let i=e.map(e=>e[r]),a=t.map(()=>[]);t.forEach((e,t)=>e.push(a[t]));let o=i.map(()=>0),s=i.map(e=>e[0]);for(;s.every(e=>e);){let e=Math.min(...s.map(e=>e.content.length));for(let t=0;t<n;t++){let n=s[t];n.content.length===e?(a[t].push(n),o[t]+=1,s[t]=i[t][o[t]]):(a[t].push({...n,content:n.content.slice(0,e)}),s[t]={...n,content:n.content.slice(e),offset:n.offset+e})}}}return t}var ul=/["&'<>`]/g,dl=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,fl=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,pl=/[|\\{}()[\]^$+*?.]/g,ml=new WeakMap;function hl(e,t){if(e=e.replace(t.subset?gl(t.subset):ul,r),t.subset||t.escapeOnly)return e;return e.replace(dl,n).replace(fl,r);function n(e,n,r){return t.format((e.charCodeAt(0)-55296)*1024+e.charCodeAt(1)-56320+65536,r.charCodeAt(n+2),t)}function r(e,n,r){return t.format(e.charCodeAt(0),r.charCodeAt(n+1),t)}}function gl(e){let t=ml.get(e);return t||(t=_l(e),ml.set(e,t)),t}function _l(e){let t=[],n=-1;for(;++n<e.length;)t.push(e[n].replace(pl,`\\$&`));return RegExp(`(?:`+t.join(`|`)+`)`,`g`)}var vl=/[\dA-Fa-f]/;function yl(e,t,n){let r=`&#x`+e.toString(16).toUpperCase();return n&&t&&!vl.test(String.fromCharCode(t))?r:r+`;`}var bl=/\d/;function xl(e,t,n){let r=`&#`+String(e);return n&&t&&!bl.test(String.fromCharCode(t))?r:r+`;`}var Sl=`AElig.AMP.Aacute.Acirc.Agrave.Aring.Atilde.Auml.COPY.Ccedil.ETH.Eacute.Ecirc.Egrave.Euml.GT.Iacute.Icirc.Igrave.Iuml.LT.Ntilde.Oacute.Ocirc.Ograve.Oslash.Otilde.Ouml.QUOT.REG.THORN.Uacute.Ucirc.Ugrave.Uuml.Yacute.aacute.acirc.acute.aelig.agrave.amp.aring.atilde.auml.brvbar.ccedil.cedil.cent.copy.curren.deg.divide.eacute.ecirc.egrave.eth.euml.frac12.frac14.frac34.gt.iacute.icirc.iexcl.igrave.iquest.iuml.laquo.lt.macr.micro.middot.nbsp.not.ntilde.oacute.ocirc.ograve.ordf.ordm.oslash.otilde.ouml.para.plusmn.pound.quot.raquo.reg.sect.shy.sup1.sup2.sup3.szlig.thorn.times.uacute.ucirc.ugrave.uml.uuml.yacute.yen.yuml`.split(`.`),Cl={nbsp:`\xA0`,iexcl:`¡`,cent:`¢`,pound:`£`,curren:`¤`,yen:`¥`,brvbar:`¦`,sect:`§`,uml:`¨`,copy:`©`,ordf:`ª`,laquo:`«`,not:`¬`,shy:``,reg:`®`,macr:`¯`,deg:`°`,plusmn:`±`,sup2:`²`,sup3:`³`,acute:`´`,micro:`µ`,para:`¶`,middot:`·`,cedil:`¸`,sup1:`¹`,ordm:`º`,raquo:`»`,frac14:`¼`,frac12:`½`,frac34:`¾`,iquest:`¿`,Agrave:`À`,Aacute:`Á`,Acirc:`Â`,Atilde:`Ã`,Auml:`Ä`,Aring:`Å`,AElig:`Æ`,Ccedil:`Ç`,Egrave:`È`,Eacute:`É`,Ecirc:`Ê`,Euml:`Ë`,Igrave:`Ì`,Iacute:`Í`,Icirc:`Î`,Iuml:`Ï`,ETH:`Ð`,Ntilde:`Ñ`,Ograve:`Ò`,Oacute:`Ó`,Ocirc:`Ô`,Otilde:`Õ`,Ouml:`Ö`,times:`×`,Oslash:`Ø`,Ugrave:`Ù`,Uacute:`Ú`,Ucirc:`Û`,Uuml:`Ü`,Yacute:`Ý`,THORN:`Þ`,szlig:`ß`,agrave:`à`,aacute:`á`,acirc:`â`,atilde:`ã`,auml:`ä`,aring:`å`,aelig:`æ`,ccedil:`ç`,egrave:`è`,eacute:`é`,ecirc:`ê`,euml:`ë`,igrave:`ì`,iacute:`í`,icirc:`î`,iuml:`ï`,eth:`ð`,ntilde:`ñ`,ograve:`ò`,oacute:`ó`,ocirc:`ô`,otilde:`õ`,ouml:`ö`,divide:`÷`,oslash:`ø`,ugrave:`ù`,uacute:`ú`,ucirc:`û`,uuml:`ü`,yacute:`ý`,thorn:`þ`,yuml:`ÿ`,fnof:`ƒ`,Alpha:`Α`,Beta:`Β`,Gamma:`Γ`,Delta:`Δ`,Epsilon:`Ε`,Zeta:`Ζ`,Eta:`Η`,Theta:`Θ`,Iota:`Ι`,Kappa:`Κ`,Lambda:`Λ`,Mu:`Μ`,Nu:`Ν`,Xi:`Ξ`,Omicron:`Ο`,Pi:`Π`,Rho:`Ρ`,Sigma:`Σ`,Tau:`Τ`,Upsilon:`Υ`,Phi:`Φ`,Chi:`Χ`,Psi:`Ψ`,Omega:`Ω`,alpha:`α`,beta:`β`,gamma:`γ`,delta:`δ`,epsilon:`ε`,zeta:`ζ`,eta:`η`,theta:`θ`,iota:`ι`,kappa:`κ`,lambda:`λ`,mu:`μ`,nu:`ν`,xi:`ξ`,omicron:`ο`,pi:`π`,rho:`ρ`,sigmaf:`ς`,sigma:`σ`,tau:`τ`,upsilon:`υ`,phi:`φ`,chi:`χ`,psi:`ψ`,omega:`ω`,thetasym:`ϑ`,upsih:`ϒ`,piv:`ϖ`,bull:`•`,hellip:`…`,prime:`′`,Prime:`″`,oline:`‾`,frasl:`⁄`,weierp:`℘`,image:`ℑ`,real:`ℜ`,trade:`™`,alefsym:`ℵ`,larr:`←`,uarr:`↑`,rarr:`→`,darr:`↓`,harr:`↔`,crarr:`↵`,lArr:`⇐`,uArr:`⇑`,rArr:`⇒`,dArr:`⇓`,hArr:`⇔`,forall:`∀`,part:`∂`,exist:`∃`,empty:`∅`,nabla:`∇`,isin:`∈`,notin:`∉`,ni:`∋`,prod:`∏`,sum:`∑`,minus:`−`,lowast:`∗`,radic:`√`,prop:`∝`,infin:`∞`,ang:`∠`,and:`∧`,or:`∨`,cap:`∩`,cup:`∪`,int:`∫`,there4:`∴`,sim:`∼`,cong:`≅`,asymp:`≈`,ne:`≠`,equiv:`≡`,le:`≤`,ge:`≥`,sub:`⊂`,sup:`⊃`,nsub:`⊄`,sube:`⊆`,supe:`⊇`,oplus:`⊕`,otimes:`⊗`,perp:`⊥`,sdot:`⋅`,lceil:`⌈`,rceil:`⌉`,lfloor:`⌊`,rfloor:`⌋`,lang:`〈`,rang:`〉`,loz:`◊`,spades:`♠`,clubs:`♣`,hearts:`♥`,diams:`♦`,quot:`"`,amp:`&`,lt:`<`,gt:`>`,OElig:`Œ`,oelig:`œ`,Scaron:`Š`,scaron:`š`,Yuml:`Ÿ`,circ:`ˆ`,tilde:`˜`,ensp:` `,emsp:` `,thinsp:` `,zwnj:``,zwj:``,lrm:``,rlm:``,ndash:`–`,mdash:`—`,lsquo:`‘`,rsquo:`’`,sbquo:`‚`,ldquo:`“`,rdquo:`”`,bdquo:`„`,dagger:`†`,Dagger:`‡`,permil:`‰`,lsaquo:`‹`,rsaquo:`›`,euro:`€`},wl=[`cent`,`copy`,`divide`,`gt`,`lt`,`not`,`para`,`times`],Tl={}.hasOwnProperty,El={},Dl;for(Dl in Cl)Tl.call(Cl,Dl)&&(El[Cl[Dl]]=Dl);var Ol=/[^\dA-Za-z]/;function kl(e,t,n,r){let i=String.fromCharCode(e);if(Tl.call(El,i)){let e=El[i],a=`&`+e;return n&&Sl.includes(e)&&!wl.includes(e)&&(!r||t&&t!==61&&Ol.test(String.fromCharCode(t)))?a:a+`;`}return``}function Al(e,t,n){let r=yl(e,t,n.omitOptionalSemicolons),i;if((n.useNamedReferences||n.useShortestReferences)&&(i=kl(e,t,n.omitOptionalSemicolons,n.attribute)),(n.useShortestReferences||!i)&&n.useShortestReferences){let i=xl(e,t,n.omitOptionalSemicolons);i.length<r.length&&(r=i)}return i&&(!n.useShortestReferences||i.length<r.length)?i:r}function jl(e){return`&#x`+e.toString(16).toUpperCase()+`;`}function Ml(e,t){return hl(e,Object.assign({format:Al},t))}function Nl(e,t){return hl(e,Object.assign({format:jl},t))}var Pl=/^>|^->|<!--|-->|--!>|<!-$/g,Fl=[`>`],Il=[`<`,`>`];function Ll(e,t,n,r){return r.settings.bogusComments?`<?`+Ml(e.value,Object.assign({},r.settings.characterReferences,{subset:Fl}))+`>`:`<!--`+e.value.replace(Pl,i)+`-->`;function i(e){return Ml(e,Object.assign({},r.settings.characterReferences,{subset:Il}))}}function Rl(e,t,n,r){return`<!`+(r.settings.upperDoctype?`DOCTYPE`:`doctype`)+(r.settings.tightDoctype?``:` `)+`html>`}var zl=Hl(1),Bl=Hl(-1),Vl=[];function Hl(e){return t;function t(t,n,r){let i=t?t.children:Vl,a=(n||0)+e,o=i[a];if(!r)for(;o&&Er(o);)a+=e,o=i[a];return o}}var Ul={}.hasOwnProperty;function Wl(e){return t;function t(t,n,r){return Ul.call(e,t.tagName)&&e[t.tagName](t,n,r)}}var Gl=Wl({body:Jl,caption:Kl,colgroup:Kl,dd:Ql,dt:Zl,head:Kl,html:ql,li:Xl,optgroup:eu,option:tu,p:Yl,rp:$l,rt:$l,tbody:ru,td:ou,tfoot:iu,th:ou,thead:nu,tr:au});function Kl(e,t,n){let r=zl(n,t,!0);return!r||r.type!==`comment`&&!(r.type===`text`&&Er(r.value.charAt(0)))}function ql(e,t,n){let r=zl(n,t);return!r||r.type!==`comment`}function Jl(e,t,n){let r=zl(n,t);return!r||r.type!==`comment`}function Yl(e,t,n){let r=zl(n,t);return r?r.type===`element`&&(r.tagName===`address`||r.tagName===`article`||r.tagName===`aside`||r.tagName===`blockquote`||r.tagName===`details`||r.tagName===`div`||r.tagName===`dl`||r.tagName===`fieldset`||r.tagName===`figcaption`||r.tagName===`figure`||r.tagName===`footer`||r.tagName===`form`||r.tagName===`h1`||r.tagName===`h2`||r.tagName===`h3`||r.tagName===`h4`||r.tagName===`h5`||r.tagName===`h6`||r.tagName===`header`||r.tagName===`hgroup`||r.tagName===`hr`||r.tagName===`main`||r.tagName===`menu`||r.tagName===`nav`||r.tagName===`ol`||r.tagName===`p`||r.tagName===`pre`||r.tagName===`section`||r.tagName===`table`||r.tagName===`ul`):!n||!(n.type===`element`&&(n.tagName===`a`||n.tagName===`audio`||n.tagName===`del`||n.tagName===`ins`||n.tagName===`map`||n.tagName===`noscript`||n.tagName===`video`||n.tagName.includes(`-`)))}function Xl(e,t,n){let r=zl(n,t);return!r||r.type===`element`&&r.tagName===`li`}function Zl(e,t,n){let r=zl(n,t);return!!(r&&r.type===`element`&&(r.tagName===`dt`||r.tagName===`dd`))}function Ql(e,t,n){let r=zl(n,t);return!r||r.type===`element`&&(r.tagName===`dt`||r.tagName===`dd`)}function $l(e,t,n){let r=zl(n,t);return!r||r.type===`element`&&(r.tagName===`rp`||r.tagName===`rt`)}function eu(e,t,n){let r=zl(n,t);return!r||r.type===`element`&&r.tagName===`optgroup`}function tu(e,t,n){let r=zl(n,t);return!r||r.type===`element`&&(r.tagName===`option`||r.tagName===`optgroup`)}function nu(e,t,n){let r=zl(n,t);return!!(r&&r.type===`element`&&(r.tagName===`tbody`||r.tagName===`tfoot`))}function ru(e,t,n){let r=zl(n,t);return!r||r.type===`element`&&(r.tagName===`tbody`||r.tagName===`tfoot`)}function iu(e,t,n){return!zl(n,t)}function au(e,t,n){let r=zl(n,t);return!r||r.type===`element`&&r.tagName===`tr`}function ou(e,t,n){let r=zl(n,t);return!r||r.type===`element`&&(r.tagName===`td`||r.tagName===`th`)}var su=Wl({body:uu,colgroup:du,head:lu,html:cu,tbody:fu});function cu(e){let t=zl(e,-1);return!t||t.type!==`comment`}function lu(e){let t=new Set;for(let n of e.children)if(n.type===`element`&&(n.tagName===`base`||n.tagName===`title`)){if(t.has(n.tagName))return!1;t.add(n.tagName)}let n=e.children[0];return!n||n.type===`element`}function uu(e){let t=zl(e,-1,!0);return!t||t.type!==`comment`&&!(t.type===`text`&&Er(t.value.charAt(0)))&&!(t.type===`element`&&(t.tagName===`meta`||t.tagName===`link`||t.tagName===`script`||t.tagName===`style`||t.tagName===`template`))}function du(e,t,n){let r=Bl(n,t);if(n&&r&&r.type===`element`&&r.tagName===`colgroup`&&Gl(r,n.children.indexOf(r),n))return!1;let i=zl(e,-1,!0);return!!(i&&i.type===`element`&&i.tagName===`col`)}function fu(e,t,n){let r=Bl(n,t);if(n&&r&&r.type===`element`&&(r.tagName===`thead`||r.tagName===`tbody`)&&Gl(r,n.children.indexOf(r),n))return!1;let i=zl(e,-1);return!!(i&&i.type===`element`&&i.tagName===`tr`)}var pu={name:[[`
|
|
7
7
|
\f\r &/=>`.split(``),`
|
|
8
8
|
\f\r "&'/=>\``.split(``)],[`\0
|
|
9
9
|
\f\r "&'/<=>`.split(``),`\0
|
|
@@ -11,10 +11,10 @@ import{a as e,c as t,d as n,i as r,l as i,o as a,r as o,s,t as c,u as l}from"./p
|
|
|
11
11
|
\f\r &>`.split(``),`\0
|
|
12
12
|
\f\r "&'<=>\``.split(``)],[`\0
|
|
13
13
|
\f\r "&'<=>\``.split(``),`\0
|
|
14
|
-
\f\r "&'<=>\``.split(``)]],single:[[`&'`.split(``),`"&'\``.split(``)],[`\0&'`.split(``),`\0"&'\``.split(``)]],double:[[`"&`.split(``),`"&'\``.split(``)],[`\0"&`.split(``),`\0"&'\``.split(``)]]},pu=new Set([`desc`,`foreignObject`,`title`]);function mu(e,t,n,r){let{schema:i}=r,a=i.space!==`svg`&&r.settings.omitOptionalTags,o=i.space===`svg`?r.settings.closeEmptyElements:r.settings.voids.includes(e.tagName.toLowerCase()),s=[];i.space===`html`&&e.tagName===`svg`&&(r.schema=Dr);let c=hu(r,e.properties);r.schema.space===`svg`&&pu.has(e.tagName)&&(r.schema=Tr);let l=r.all(i.space===`html`&&e.tagName===`template`?e.content:e);if(r.schema=i,l&&(o=!1),c||!a||!ou(e,t,n)){if(s.push(`<`,e.tagName,c?` `+c:``),o&&(i.space===`svg`||r.settings.closeSelfClosing)){let e=c.charAt(c.length-1);(!r.settings.tightSelfClosing||e===`/`||e&&e!==`"`&&e!==`'`)&&s.push(` `),s.push(`/`)}s.push(`>`)}return s.push(l),!o&&(!a||!Wl(e,t,n))&&s.push(`</`+e.tagName+`>`),s.join(``)}function hu(e,t){let n=[],r=-1,i;if(t){for(i in t)if(t[i]!==null&&t[i]!==void 0){let r=gu(e,i,t[i]);r&&n.push(r)}}for(;++r<n.length;){let t=e.settings.tightAttributes?n[r].charAt(n[r].length-1):void 0;r!==n.length-1&&t!==`"`&&t!==`'`&&(n[r]+=` `)}return n.join(``)}function gu(e,t,n){let r=Sr(e.schema,t),i=e.settings.allowParseErrors&&e.schema.space===`html`?0:1,a=+!e.settings.allowDangerousCharacters;if(r.overloadedBoolean&&(n===r.attribute||n===``)?n=!0:(r.boolean||r.overloadedBoolean)&&(typeof n!=`string`||n===r.attribute||n===``)&&(n=!!n),n==null||n===!1||typeof n==`number`&&Number.isNaN(n))return``;let o=jl(r.attribute,Object.assign({},e.settings.characterReferences,{subset:fu.name[i][a]}));if(n===!0||(n=Array.isArray(n)?(r.commaSeparated?vr:zr)(n,{padLeft:!e.settings.tightCommaSeparatedLists}):String(n),e.settings.collapseEmptyAttributes&&!n))return o;let s;if(e.settings.preferUnquoted&&(s=jl(n,Object.assign({},e.settings.characterReferences,{attribute:!0,subset:fu.unquoted[i][a]}))),s!==n){let{quote:t}=e;e.settings.quoteSmart&&Rr(n,t)>Rr(n,e.alternative)&&(t=e.alternative),s=t+jl(n,Object.assign({},e.settings.characterReferences,{subset:(t===`'`?fu.single:fu.double)[i][a],attribute:!0}))+t}return o+(s&&`=`+s)}var _u=[`<`,`&`],vu=new Set([`iframe`,`noembed`,`noframes`,`plaintext`,`script`,`style`,`xmp`]);function yu(e,t,n,r){return n&&n.type===`element`&&r.schema.space===`html`&&vu.has(n.tagName)?e.value:jl(e.value,Object.assign({},r.settings.characterReferences,{subset:_u}))}function bu(e,t,n,r){return r.settings.allowDangerousHtml?e.value:yu(e,t,n,r)}function xu(e,t,n,r){return r.all(e)}var Su=wr(`type`,{invalid:Cu,unknown:wu,handlers:{comment:Il,doctype:Ll,element:mu,raw:bu,root:xu,text:yu}});function Cu(e){throw Error("Expected node, not `"+e+"`")}function wu(e){throw Error("Cannot compile unknown node `"+e.type+"`")}var Tu={},Eu={},Du=[];function Ou(e,t){let n=t||Tu,r=n.quote||`"`;if(r!==`"`&&r!==`'`)throw Error("Invalid quote `"+r+"`, expected `'` or `\"`");let i=r===`"`?`'`:`"`;return{one:ku,all:Au,settings:{omitOptionalTags:n.omitOptionalTags||!1,allowParseErrors:n.allowParseErrors||!1,allowDangerousCharacters:n.allowDangerousCharacters||!1,quoteSmart:n.quoteSmart||!1,preferUnquoted:n.preferUnquoted||!1,tightAttributes:n.tightAttributes||!1,upperDoctype:n.upperDoctype||!1,tightDoctype:n.tightDoctype||!1,bogusComments:n.bogusComments||!1,tightCommaSeparatedLists:n.tightCommaSeparatedLists||!1,tightSelfClosing:n.tightSelfClosing||!1,collapseEmptyAttributes:n.collapseEmptyAttributes||!1,allowDangerousHtml:n.allowDangerousHtml||!1,voids:n.voids||Cr,characterReferences:n.characterReferences||Eu,closeSelfClosing:n.closeSelfClosing||!1,closeEmptyElements:n.closeEmptyElements||!1},schema:n.space===`svg`?Dr:Tr,quote:r,alternative:i}.one(Array.isArray(e)?{type:`root`,children:e}:e,void 0,void 0)}function ku(e,t,n){return Su(e,t,n,this)}function Au(e){let t=[],n=e&&e.children||Du,r=-1;for(;++r<n.length;)t[r]=this.one(n[r],r,e);return t.join(``)}var ju=/\s+/g;function Mu(e,t){if(!t)return e;e.properties||={},e.properties.class||=[],typeof e.properties.class==`string`&&(e.properties.class=e.properties.class.split(ju)),Array.isArray(e.properties.class)||(e.properties.class=[]);let n=Array.isArray(t)?t:t.split(ju);for(let t of n)t&&!e.properties.class.includes(t)&&e.properties.class.push(t);return e}function Nu(e){let t=jc(e,!0),n=t.map(([e])=>e),r=t.map(([,e])=>e);function i(t){if(t===e.length)return{line:n.length-1,character:n.at(-1).length};let i=0,a=n.length-1;for(;i<a;){let e=i+a+1>>>1;r[e]<=t?i=e:a=e-1}return{line:i,character:t-r[i]}}function a(e,t){return r[e]+t}return{lines:n,indexToPos:i,posToIndex:a}}var Pu=[`color`,`background-color`];function Fu(e,t){let n=0,r=[];for(let i of t)i>n&&r.push({...e,content:e.content.slice(n,i),offset:e.offset+n}),n=i;return n<e.content.length&&r.push({...e,content:e.content.slice(n),offset:e.offset+n}),r}function Iu(e,t){let n=0,r=e.length;for(;n<r;){let i=n+(r-n>>1);e[i]<=t?n=i+1:r=i}return n}function Lu(e,t){let n=[...t instanceof Set?t:new Set(t)].sort((e,t)=>e-t);return n.length?e.map(e=>e.flatMap(e=>{let t=e.offset+e.content.length,r=Iu(n,e.offset),i=r;for(;i<n.length&&n[i]<t;)i++;if(r===i)return e;let a=n.slice(r,i);for(let t=0;t<a.length;t++)a[t]-=e.offset;return Fu(e,a)})):e}function Ru(e,t,n,r,i=`css-vars`){let a={content:e.content,explanation:e.explanation,offset:e.offset},o=t.map(t=>zu(e.variants[t])),s=new Set(o.flatMap(e=>Object.keys(e))),c={},l=(e,r)=>{let i=r===`color`?``:r===`background-color`?`-bg`:`-${r}`;return n+t[e]+(r===`color`?``:i)};return o.forEach((e,n)=>{for(let a of s){let s=e[a]||`inherit`;if(n===0&&r&&Pu.includes(a))if(r===`light-dark()`&&o.length>1){let e=t.findIndex(e=>e===`light`),r=t.findIndex(e=>e===`dark`);if(e===-1||r===-1)throw new Ho('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');let u=o[e][a]||`inherit`,d=o[r][a]||`inherit`;c[a]=`light-dark(${u}, ${d})`,i===`css-vars`&&(c[l(n,a)]=s)}else c[a]=s;else i===`css-vars`&&(c[l(n,a)]=s)}}),a.htmlStyle=c,a}function zu(e){let t={};if(e.color&&(t.color=e.color),e.bgColor&&(t[`background-color`]=e.bgColor),e.fontStyle){e.fontStyle&us.Italic&&(t[`font-style`]=`italic`),e.fontStyle&us.Bold&&(t[`font-weight`]=`bold`);let n=[];e.fontStyle&us.Underline&&n.push(`underline`),e.fontStyle&us.Strikethrough&&n.push(`line-through`),n.length&&(t[`text-decoration`]=n.join(` `))}return t}function Bu(e){return typeof e==`string`?e:Object.entries(e).map(([e,t])=>`${e}:${t}`).join(`;`)}function Vu(){let e=new WeakMap;function t(t){if(!e.has(t.meta)){let n=Nu(t.source);function r(e){if(typeof e==`number`){if(e<0||e>t.source.length)throw new Ho(`Invalid decoration offset: ${e}. Code length: ${t.source.length}`);return{...n.indexToPos(e),offset:e}}else{let t=n.lines[e.line];if(t===void 0)throw new Ho(`Invalid decoration position ${JSON.stringify(e)}. Lines length: ${n.lines.length}`);let r=e.character;if(r<0&&(r=t.length+r),r<0||r>t.length)throw new Ho(`Invalid decoration position ${JSON.stringify(e)}. Line ${e.line} length: ${t.length}`);return{...e,character:r,offset:n.posToIndex(e.line,r)}}}let i=(t.options.decorations||[]).map(e=>({...e,start:r(e.start),end:r(e.end)}));Hu(i),e.set(t.meta,{decorations:i,converter:n,source:t.source})}return e.get(t.meta)}return{name:`shiki:decorations`,tokens(e){if(this.options.decorations?.length)return Lu(e,t(this).decorations.flatMap(e=>[e.start.offset,e.end.offset]))},code(e){if(!this.options.decorations?.length)return;let n=t(this),r=[...e.children].filter(e=>e.type===`element`&&e.tagName===`span`);if(r.length!==n.converter.lines.length)throw new Ho(`Number of lines in code element (${r.length}) does not match the number of lines in the source (${n.converter.lines.length}). Failed to apply decorations.`);function i(e,t,n,i){let a=r[e],s=``,c=-1,l=-1;if(t===0&&(c=0),n===0&&(l=0),n===1/0&&(l=a.children.length),c===-1||l===-1)for(let e=0;e<a.children.length;e++)s+=Wu(a.children[e]),c===-1&&s.length===t&&(c=e+1),l===-1&&s.length===n&&(l=e+1);if(c===-1)throw new Ho(`Failed to find start index for decoration ${JSON.stringify(i.start)}`);if(l===-1)throw new Ho(`Failed to find end index for decoration ${JSON.stringify(i.end)}`);let u=a.children.slice(c,l);if(!i.alwaysWrap&&u.length===a.children.length)o(a,i,`line`);else if(!i.alwaysWrap&&u.length===1&&u[0].type===`element`)o(u[0],i,`token`);else{let e={type:`element`,tagName:`span`,properties:{},children:u};o(e,i,`wrapper`),a.children.splice(c,u.length,e)}}function a(e,t){r[e]=o(r[e],t,`line`)}function o(e,t,n){let r=t.properties||{},i=t.transform||(e=>e);return e.tagName=t.tagName||`span`,e.properties={...e.properties,...r,class:e.properties.class},t.properties?.class&&Mu(e,t.properties.class),e=i(e,n)||e,e}let s=[],c=n.decorations.sort((e,t)=>t.start.offset-e.start.offset||e.end.offset-t.end.offset);for(let e of c){let{start:t,end:n}=e;if(t.line===n.line)i(t.line,t.character,n.character,e);else if(t.line<n.line){i(t.line,t.character,1/0,e);for(let r=t.line+1;r<n.line;r++)s.push(()=>a(r,e));i(n.line,0,n.character,e)}}for(let e=s.length-1;e>=0;e--)s[e]()}}}function Hu(e){if(!Uu(e))for(let t=0;t<e.length;t++){let n=e[t];if(n.start.offset>n.end.offset)throw new Ho(`Invalid decoration range: ${JSON.stringify(n.start)} - ${JSON.stringify(n.end)}`);for(let r=t+1;r<e.length;r++){let t=e[r],i=n.start.offset<=t.start.offset&&t.start.offset<n.end.offset,a=n.start.offset<t.end.offset&&t.end.offset<=n.end.offset,o=t.start.offset<=n.start.offset&&n.start.offset<t.end.offset,s=t.start.offset<n.end.offset&&n.end.offset<=t.end.offset;if(i||a||o||s){if(i&&a||o&&s||o&&n.start.offset===n.end.offset||a&&t.start.offset===t.end.offset)continue;throw new Ho(`Decorations ${JSON.stringify(n.start)} and ${JSON.stringify(t.start)} intersect.`)}}}}function Uu(e){let t=[],n=new Map,r=new Map;for(let i=0;i<e.length;i++){let{start:a,end:o}=e[i];if(a.offset>o.offset)return!1;a.offset!==o.offset&&(t.push(e[i]),n.has(a.offset)||n.set(a.offset,i),r.set(o.offset,i))}for(let t=0;t<e.length;t++){let{start:i,end:a}=e[t];if(i.offset===a.offset&&((n.get(i.offset)??t)<t||(r.get(i.offset)??t)>t))return!1}t.sort((e,t)=>e.start.offset-t.start.offset||t.end.offset-e.end.offset);let i=[];for(let{start:e,end:n}of t){for(;i.length&&i.at(-1)<=e.offset;)i.pop();if(i.length&&n.offset>i.at(-1))return!1;i.push(n.offset)}return!0}function Wu(e){return e.type===`text`?e.value:e.type===`element`?e.children.map(Wu).join(``):``}var Gu=[Vu()];function Ku(e){let t=qu(e.transformers||[]);return[...t.pre,...t.normal,...t.post,...Gu]}function qu(e){let t=[],n=[],r=[];for(let i of e)switch(i.enforce){case`pre`:t.push(i);break;case`post`:n.push(i);break;default:r.push(i)}return{pre:t,post:n,normal:r}}var Ju=[`black`,`red`,`green`,`yellow`,`blue`,`magenta`,`cyan`,`white`,`brightBlack`,`brightRed`,`brightGreen`,`brightYellow`,`brightBlue`,`brightMagenta`,`brightCyan`,`brightWhite`],Yu={1:`bold`,2:`dim`,3:`italic`,4:`underline`,7:`reverse`,8:`hidden`,9:`strikethrough`};function Xu(e,t){let n=e.indexOf(`\x1B`,t);if(n!==-1&&e[n+1]===`[`){let t=e.indexOf(`m`,n);if(t!==-1)return{sequence:e.substring(n+2,t).split(`;`),startPosition:n,position:t+1}}return{position:e.length}}function Zu(e){let t=e.shift();if(t===`2`){let t=e.splice(0,3).map(e=>Number.parseInt(e));return t.length!==3||t.some(e=>Number.isNaN(e))?void 0:{type:`rgb`,rgb:t}}else if(t===`5`){let t=e.shift();if(t)return{type:`table`,index:Number(t)}}}function Qu(e){let t=[];for(;e.length>0;){let n=e.shift();if(!n)continue;let r=Number.parseInt(n);if(!Number.isNaN(r))if(r===0)t.push({type:`resetAll`});else if(r<=9)Yu[r]&&t.push({type:`setDecoration`,value:Yu[r]});else if(r<=29){let e=Yu[r-20];e&&(t.push({type:`resetDecoration`,value:e}),e===`dim`&&t.push({type:`resetDecoration`,value:`bold`}))}else if(r<=37)t.push({type:`setForegroundColor`,value:{type:`named`,name:Ju[r-30]}});else if(r===38){let n=Zu(e);n&&t.push({type:`setForegroundColor`,value:n})}else if(r===39)t.push({type:`resetForegroundColor`});else if(r<=47)t.push({type:`setBackgroundColor`,value:{type:`named`,name:Ju[r-40]}});else if(r===48){let n=Zu(e);n&&t.push({type:`setBackgroundColor`,value:n})}else r===49?t.push({type:`resetBackgroundColor`}):r===53?t.push({type:`setDecoration`,value:`overline`}):r===55?t.push({type:`resetDecoration`,value:`overline`}):r>=90&&r<=97?t.push({type:`setForegroundColor`,value:{type:`named`,name:Ju[r-90+8]}}):r>=100&&r<=107&&t.push({type:`setBackgroundColor`,value:{type:`named`,name:Ju[r-100+8]}})}return t}function $u(){let e=null,t=null,n=new Set;return{parse(r){let i=[],a=0;do{let o=Xu(r,a),s=o.sequence?r.substring(a,o.startPosition):r.substring(a);if(s.length>0&&i.push({value:s,foreground:e,background:t,decorations:new Set(n)}),o.sequence){let r=Qu(o.sequence);for(let i of r)i.type===`resetAll`?(e=null,t=null,n.clear()):i.type===`resetForegroundColor`?e=null:i.type===`resetBackgroundColor`?t=null:i.type===`resetDecoration`&&n.delete(i.value);for(let i of r)i.type===`setForegroundColor`?e=i.value:i.type===`setBackgroundColor`?t=i.value:i.type===`setDecoration`&&n.add(i.value)}a=o.position}while(a<r.length);return i}}}var ed={black:`#000000`,red:`#bb0000`,green:`#00bb00`,yellow:`#bbbb00`,blue:`#0000bb`,magenta:`#ff00ff`,cyan:`#00bbbb`,white:`#eeeeee`,brightBlack:`#555555`,brightRed:`#ff5555`,brightGreen:`#00ff00`,brightYellow:`#ffff55`,brightBlue:`#5555ff`,brightMagenta:`#ff55ff`,brightCyan:`#55ffff`,brightWhite:`#ffffff`};function td(e=ed){function t(t){return e[t]}function n(e){return`#${e.map(e=>Math.max(0,Math.min(e,255)).toString(16).padStart(2,`0`)).join(``)}`}let r;function i(){if(r)return r;r=[];for(let e=0;e<Ju.length;e++)r.push(t(Ju[e]));let e=[0,95,135,175,215,255];for(let t=0;t<6;t++)for(let i=0;i<6;i++)for(let a=0;a<6;a++)r.push(n([e[t],e[i],e[a]]));let i=8;for(let e=0;e<24;e++,i+=10)r.push(n([i,i,i]));return r}function a(e){return i()[e]}function o(e){switch(e.type){case`named`:return t(e.name);case`rgb`:return n(e.rgb);case`table`:return a(e.index)}}return{value:o}}var nd=/#([0-9a-f]{3,8})/i,rd=/var\((--[\w-]+-ansi-[\w-]+)\)/,id={black:`#000000`,red:`#cd3131`,green:`#0DBC79`,yellow:`#E5E510`,blue:`#2472C8`,magenta:`#BC3FBC`,cyan:`#11A8CD`,white:`#E5E5E5`,brightBlack:`#666666`,brightRed:`#F14C4C`,brightGreen:`#23D18B`,brightYellow:`#F5F543`,brightBlue:`#3B8EEA`,brightMagenta:`#D670D6`,brightCyan:`#29B8DB`,brightWhite:`#FFFFFF`};function ad(e,t,n){let r=Sc(e,n),i=jc(t),a=td(Object.fromEntries(Ju.map(t=>{let n=`terminal.ansi${t[0].toUpperCase()}${t.substring(1)}`;return[t,e.colors?.[n]||id[t]]}))),o=$u();return i.map(t=>o.parse(t[0]).map(n=>{let i,o;n.decorations.has(`reverse`)?(i=n.background?a.value(n.background):e.bg,o=n.foreground?a.value(n.foreground):e.fg):(i=n.foreground?a.value(n.foreground):e.fg,o=n.background?a.value(n.background):void 0),i=Cc(i,r),o=Cc(o,r),n.decorations.has(`dim`)&&(i=od(i));let s=us.None;return n.decorations.has(`bold`)&&(s|=us.Bold),n.decorations.has(`italic`)&&(s|=us.Italic),n.decorations.has(`underline`)&&(s|=us.Underline),n.decorations.has(`strikethrough`)&&(s|=us.Strikethrough),{content:n.value,offset:t[1],color:i,bgColor:o,fontStyle:s}}))}function od(e){let t=e.match(nd);if(t){let e=t[1];if(e.length===8){let t=Math.round(Number.parseInt(e.slice(6,8),16)/2).toString(16).padStart(2,`0`);return`#${e.slice(0,6)}${t}`}else if(e.length===6)return`#${e}80`;else if(e.length===4){let t=e[0],n=e[1],r=e[2],i=e[3];return`#${t}${t}${n}${n}${r}${r}${Math.round(Number.parseInt(`${i}${i}`,16)/2).toString(16).padStart(2,`0`)}`}else if(e.length===3){let t=e[0],n=e[1],r=e[2];return`#${t}${t}${n}${n}${r}${r}80`}}let n=e.match(rd);return n?`var(${n[1]}-dim)`:e}function sd(e,t,n={}){let r=e.resolveLangAlias(n.lang||`text`),{theme:i=e.getLoadedThemes()[0]}=n;if(!Ec(r)&&!Oc(i)&&r===`ansi`){let{theme:r}=e.setTheme(i);return ad(r,t,n)}return Qc(e,t,n)}function cd(e,t,n){let r,i,a,o,s,c;if(`themes`in n){let{defaultColor:l=`light`,cssVariablePrefix:u=`--shiki-`,colorsRendering:d=`css-vars`}=n,f=Object.entries(n.themes).filter(e=>e[1]).map(e=>({color:e[0],theme:e[1]})).sort((e,t)=>e.color===l?-1:+(t.color===l));if(f.length===0)throw new Ho("`themes` option must not be empty");let p=sl(e,t,n,sd);if(c=Kc(p),l&&l!==`light-dark()`&&!f.some(e=>e.color===l))throw new Ho(`\`themes\` option must contain the defaultColor key \`${l}\``);let m=f.map(t=>e.getTheme(t.theme)),h=f.map(e=>e.color);a=p.map(e=>e.map(e=>Ru(e,h,u,l,d))),c&&Gc(a,c);let g=f.map(e=>Sc(e.theme,n));i=ld(f,m,g,u,l,`fg`,d),r=ld(f,m,g,u,l,`bg`,d),o=`shiki-themes ${m.map(e=>e.name).join(` `)}`,s=l?void 0:[i,r].join(`;`)}else if(`theme`in n){let s=Sc(n.theme,n);a=sd(e,t,n);let l=e.getTheme(n.theme);r=Cc(l.bg,s),i=Cc(l.fg,s),o=l.name,c=Kc(a)}else throw new Ho("Invalid options, either `theme` or `themes` must be provided");return{tokens:a,fg:i,bg:r,themeName:o,rootStyle:s,grammarState:c}}function ld(e,t,n,r,i,a,o){return e.map((s,c)=>{let l=Cc(t[c][a],n[c])||`inherit`,u=`${r+s.color}${a===`bg`?`-bg`:``}:${l}`;if(c===0&&i){if(i===`light-dark()`&&e.length>1){let r=e.findIndex(e=>e.color===`light`),i=e.findIndex(e=>e.color===`dark`);if(r===-1||i===-1)throw new Ho('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');return`light-dark(${Cc(t[r][a],n[r])||`inherit`}, ${Cc(t[i][a],n[i])||`inherit`});${u}`}return l}return o===`css-vars`?u:null}).filter(e=>!!e).join(`;`)}var ud=/^\s+$/,dd=/^(\s*)(.*?)(\s*)$/;function fd(e,t,n,r={meta:{},options:n,codeToHast:(t,n)=>fd(e,t,n),codeToTokens:(t,n)=>cd(e,t,n)}){let i=t;for(let e of Ku(n))i=e.preprocess?.call(r,i,n)||i;let{tokens:a,fg:o,bg:s,themeName:c,rootStyle:l,grammarState:u}=cd(e,i,n),{mergeWhitespaces:d=!0,mergeSameStyleTokens:f=!1}=n;d===!0?a=md(a):d===`never`&&(a=hd(a)),f&&(a=gd(a));let p={...r,get source(){return i}};for(let e of Ku(n))a=e.tokens?.call(p,a)||a;return pd(a,{...n,fg:o,bg:s,themeName:c,rootStyle:n.rootStyle===!1?!1:n.rootStyle??l},p,u)}function pd(e,t,n,r=Kc(e)){let i=Ku(t),a=[],o={type:`root`,children:[]},{structure:s=`classic`,tabindex:c=`0`}=t,l={class:`shiki ${t.themeName||``}`};t.rootStyle!==!1&&(t.rootStyle==null?l.style=`background-color:${t.bg};color:${t.fg}`:l.style=t.rootStyle),c!==!1&&c!=null&&(l.tabindex=c.toString());for(let[e,n]of Object.entries(t.meta||{}))e.startsWith(`_`)||(l[e]=n);let u={type:`element`,tagName:`pre`,properties:l,children:[],data:t.data},d={type:`element`,tagName:`code`,properties:{},children:a},f=[],p={...n,structure:s,addClassToHast:Mu,get source(){return n.source},get tokens(){return e},get options(){return t},get root(){return o},get pre(){return u},get code(){return d},get lines(){return f}};if(e.forEach((e,t)=>{t&&(s===`inline`?o.children.push({type:`element`,tagName:`br`,properties:{},children:[]}):s===`classic`&&a.push({type:`text`,value:`
|
|
15
|
-
`}));let n={type:`element`,tagName:`span`,properties:{class:`line`},children:[]},r=0;for(let a of e){let e={type:`element`,tagName:`span`,properties:{...a.htmlAttrs},children:[{type:`text`,value:a.content}]},c=
|
|
14
|
+
\f\r "&'<=>\``.split(``)]],single:[[`&'`.split(``),`"&'\``.split(``)],[`\0&'`.split(``),`\0"&'\``.split(``)]],double:[[`"&`.split(``),`"&'\``.split(``)],[`\0"&`.split(``),`\0"&'\``.split(``)]]},mu=new Set([`desc`,`foreignObject`,`title`]);function hu(e,t,n,r){let{schema:i}=r,a=i.space!==`svg`&&r.settings.omitOptionalTags,o=i.space===`svg`?r.settings.closeEmptyElements:r.settings.voids.includes(e.tagName.toLowerCase()),s=[];i.space===`html`&&e.tagName===`svg`&&(r.schema=Dr);let c=gu(r,e.properties);r.schema.space===`svg`&&mu.has(e.tagName)&&(r.schema=Tr);let l=r.all(i.space===`html`&&e.tagName===`template`?e.content:e);if(r.schema=i,l&&(o=!1),c||!a||!su(e,t,n)){if(s.push(`<`,e.tagName,c?` `+c:``),o&&(i.space===`svg`||r.settings.closeSelfClosing)){let e=c.charAt(c.length-1);(!r.settings.tightSelfClosing||e===`/`||e&&e!==`"`&&e!==`'`)&&s.push(` `),s.push(`/`)}s.push(`>`)}return s.push(l),!o&&(!a||!Gl(e,t,n))&&s.push(`</`+e.tagName+`>`),s.join(``)}function gu(e,t){let n=[],r=-1,i;if(t){for(i in t)if(t[i]!==null&&t[i]!==void 0){let r=_u(e,i,t[i]);r&&n.push(r)}}for(;++r<n.length;){let t=e.settings.tightAttributes?n[r].charAt(n[r].length-1):void 0;r!==n.length-1&&t!==`"`&&t!==`'`&&(n[r]+=` `)}return n.join(``)}function _u(e,t,n){let r=Sr(e.schema,t),i=e.settings.allowParseErrors&&e.schema.space===`html`?0:1,a=+!e.settings.allowDangerousCharacters;if(r.overloadedBoolean&&(n===r.attribute||n===``)?n=!0:(r.boolean||r.overloadedBoolean)&&(typeof n!=`string`||n===r.attribute||n===``)&&(n=!!n),n==null||n===!1||typeof n==`number`&&Number.isNaN(n))return``;let o=Ml(r.attribute,Object.assign({},e.settings.characterReferences,{subset:pu.name[i][a]}));if(n===!0||(n=Array.isArray(n)?(r.commaSeparated?vr:zr)(n,{padLeft:!e.settings.tightCommaSeparatedLists}):String(n),e.settings.collapseEmptyAttributes&&!n))return o;let s;if(e.settings.preferUnquoted&&(s=Ml(n,Object.assign({},e.settings.characterReferences,{attribute:!0,subset:pu.unquoted[i][a]}))),s!==n){let{quote:t}=e;e.settings.quoteSmart&&Rr(n,t)>Rr(n,e.alternative)&&(t=e.alternative),s=t+Ml(n,Object.assign({},e.settings.characterReferences,{subset:(t===`'`?pu.single:pu.double)[i][a],attribute:!0}))+t}return o+(s&&`=`+s)}var vu=[`<`,`&`],yu=new Set([`iframe`,`noembed`,`noframes`,`plaintext`,`script`,`style`,`xmp`]);function bu(e,t,n,r){return n&&n.type===`element`&&r.schema.space===`html`&&yu.has(n.tagName)?e.value:Ml(e.value,Object.assign({},r.settings.characterReferences,{subset:vu}))}function xu(e,t,n,r){return r.settings.allowDangerousHtml?e.value:bu(e,t,n,r)}function Su(e,t,n,r){return r.all(e)}var Cu=wr(`type`,{invalid:wu,unknown:Tu,handlers:{comment:Ll,doctype:Rl,element:hu,raw:xu,root:Su,text:bu}});function wu(e){throw Error("Expected node, not `"+e+"`")}function Tu(e){throw Error("Cannot compile unknown node `"+e.type+"`")}var Eu={},Du={},Ou=[];function ku(e,t){let n=t||Eu,r=n.quote||`"`;if(r!==`"`&&r!==`'`)throw Error("Invalid quote `"+r+"`, expected `'` or `\"`");let i=r===`"`?`'`:`"`;return{one:Au,all:ju,settings:{omitOptionalTags:n.omitOptionalTags||!1,allowParseErrors:n.allowParseErrors||!1,allowDangerousCharacters:n.allowDangerousCharacters||!1,quoteSmart:n.quoteSmart||!1,preferUnquoted:n.preferUnquoted||!1,tightAttributes:n.tightAttributes||!1,upperDoctype:n.upperDoctype||!1,tightDoctype:n.tightDoctype||!1,bogusComments:n.bogusComments||!1,tightCommaSeparatedLists:n.tightCommaSeparatedLists||!1,tightSelfClosing:n.tightSelfClosing||!1,collapseEmptyAttributes:n.collapseEmptyAttributes||!1,allowDangerousHtml:n.allowDangerousHtml||!1,voids:n.voids||Cr,characterReferences:n.characterReferences||Du,closeSelfClosing:n.closeSelfClosing||!1,closeEmptyElements:n.closeEmptyElements||!1},schema:n.space===`svg`?Dr:Tr,quote:r,alternative:i}.one(Array.isArray(e)?{type:`root`,children:e}:e,void 0,void 0)}function Au(e,t,n){return Cu(e,t,n,this)}function ju(e){let t=[],n=e&&e.children||Ou,r=-1;for(;++r<n.length;)t[r]=this.one(n[r],r,e);return t.join(``)}var Mu=/\s+/g;function Nu(e,t){if(!t)return e;e.properties||={},e.properties.class||=[],typeof e.properties.class==`string`&&(e.properties.class=e.properties.class.split(Mu)),Array.isArray(e.properties.class)||(e.properties.class=[]);let n=Array.isArray(t)?t:t.split(Mu);for(let t of n)t&&!e.properties.class.includes(t)&&e.properties.class.push(t);return e}function Pu(e){let t=Mc(e,!0),n=t.map(([e])=>e),r=t.map(([,e])=>e);function i(t){if(t===e.length)return{line:n.length-1,character:n.at(-1).length};let i=0,a=n.length-1;for(;i<a;){let e=i+a+1>>>1;r[e]<=t?i=e:a=e-1}return{line:i,character:t-r[i]}}function a(e,t){return r[e]+t}return{lines:n,indexToPos:i,posToIndex:a}}var Fu=[`color`,`background-color`];function Iu(e,t){let n=0,r=[];for(let i of t)i>n&&r.push({...e,content:e.content.slice(n,i),offset:e.offset+n}),n=i;return n<e.content.length&&r.push({...e,content:e.content.slice(n),offset:e.offset+n}),r}function Lu(e,t){let n=0,r=e.length;for(;n<r;){let i=n+(r-n>>1);e[i]<=t?n=i+1:r=i}return n}function Ru(e,t){let n=[...t instanceof Set?t:new Set(t)].sort((e,t)=>e-t);return n.length?e.map(e=>e.flatMap(e=>{let t=e.offset+e.content.length,r=Lu(n,e.offset),i=r;for(;i<n.length&&n[i]<t;)i++;if(r===i)return e;let a=n.slice(r,i);for(let t=0;t<a.length;t++)a[t]-=e.offset;return Iu(e,a)})):e}function zu(e,t,n,r,i=`css-vars`){let a={content:e.content,explanation:e.explanation,offset:e.offset},o=t.map(t=>Bu(e.variants[t])),s=new Set(o.flatMap(e=>Object.keys(e))),c={},l=(e,r)=>{let i=r===`color`?``:r===`background-color`?`-bg`:`-${r}`;return n+t[e]+(r===`color`?``:i)};return o.forEach((e,n)=>{for(let a of s){let s=e[a]||`inherit`;if(n===0&&r&&Fu.includes(a))if(r===`light-dark()`&&o.length>1){let e=t.findIndex(e=>e===`light`),r=t.findIndex(e=>e===`dark`);if(e===-1||r===-1)throw new Uo('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');let u=o[e][a]||`inherit`,d=o[r][a]||`inherit`;c[a]=`light-dark(${u}, ${d})`,i===`css-vars`&&(c[l(n,a)]=s)}else c[a]=s;else i===`css-vars`&&(c[l(n,a)]=s)}}),a.htmlStyle=c,a}function Bu(e){let t={};if(e.color&&(t.color=e.color),e.bgColor&&(t[`background-color`]=e.bgColor),e.fontStyle){e.fontStyle&ds.Italic&&(t[`font-style`]=`italic`),e.fontStyle&ds.Bold&&(t[`font-weight`]=`bold`);let n=[];e.fontStyle&ds.Underline&&n.push(`underline`),e.fontStyle&ds.Strikethrough&&n.push(`line-through`),n.length&&(t[`text-decoration`]=n.join(` `))}return t}function Vu(e){return typeof e==`string`?e:Object.entries(e).map(([e,t])=>`${e}:${t}`).join(`;`)}function Hu(){let e=new WeakMap;function t(t){if(!e.has(t.meta)){let n=Pu(t.source);function r(e){if(typeof e==`number`){if(e<0||e>t.source.length)throw new Uo(`Invalid decoration offset: ${e}. Code length: ${t.source.length}`);return{...n.indexToPos(e),offset:e}}else{let t=n.lines[e.line];if(t===void 0)throw new Uo(`Invalid decoration position ${JSON.stringify(e)}. Lines length: ${n.lines.length}`);let r=e.character;if(r<0&&(r=t.length+r),r<0||r>t.length)throw new Uo(`Invalid decoration position ${JSON.stringify(e)}. Line ${e.line} length: ${t.length}`);return{...e,character:r,offset:n.posToIndex(e.line,r)}}}let i=(t.options.decorations||[]).map(e=>({...e,start:r(e.start),end:r(e.end)}));Uu(i),e.set(t.meta,{decorations:i,converter:n,source:t.source})}return e.get(t.meta)}return{name:`shiki:decorations`,tokens(e){if(this.options.decorations?.length)return Ru(e,t(this).decorations.flatMap(e=>[e.start.offset,e.end.offset]))},code(e){if(!this.options.decorations?.length)return;let n=t(this),r=[...e.children].filter(e=>e.type===`element`&&e.tagName===`span`);if(r.length!==n.converter.lines.length)throw new Uo(`Number of lines in code element (${r.length}) does not match the number of lines in the source (${n.converter.lines.length}). Failed to apply decorations.`);function i(e,t,n,i){let a=r[e],s=``,c=-1,l=-1;if(t===0&&(c=0),n===0&&(l=0),n===1/0&&(l=a.children.length),c===-1||l===-1)for(let e=0;e<a.children.length;e++)s+=Gu(a.children[e]),c===-1&&s.length===t&&(c=e+1),l===-1&&s.length===n&&(l=e+1);if(c===-1)throw new Uo(`Failed to find start index for decoration ${JSON.stringify(i.start)}`);if(l===-1)throw new Uo(`Failed to find end index for decoration ${JSON.stringify(i.end)}`);let u=a.children.slice(c,l);if(!i.alwaysWrap&&u.length===a.children.length)o(a,i,`line`);else if(!i.alwaysWrap&&u.length===1&&u[0].type===`element`)o(u[0],i,`token`);else{let e={type:`element`,tagName:`span`,properties:{},children:u};o(e,i,`wrapper`),a.children.splice(c,u.length,e)}}function a(e,t){r[e]=o(r[e],t,`line`)}function o(e,t,n){let r=t.properties||{},i=t.transform||(e=>e);return e.tagName=t.tagName||`span`,e.properties={...e.properties,...r,class:e.properties.class},t.properties?.class&&Nu(e,t.properties.class),e=i(e,n)||e,e}let s=[],c=n.decorations.sort((e,t)=>t.start.offset-e.start.offset||e.end.offset-t.end.offset);for(let e of c){let{start:t,end:n}=e;if(t.line===n.line)i(t.line,t.character,n.character,e);else if(t.line<n.line){i(t.line,t.character,1/0,e);for(let r=t.line+1;r<n.line;r++)s.push(()=>a(r,e));i(n.line,0,n.character,e)}}for(let e=s.length-1;e>=0;e--)s[e]()}}}function Uu(e){if(!Wu(e))for(let t=0;t<e.length;t++){let n=e[t];if(n.start.offset>n.end.offset)throw new Uo(`Invalid decoration range: ${JSON.stringify(n.start)} - ${JSON.stringify(n.end)}`);for(let r=t+1;r<e.length;r++){let t=e[r],i=n.start.offset<=t.start.offset&&t.start.offset<n.end.offset,a=n.start.offset<t.end.offset&&t.end.offset<=n.end.offset,o=t.start.offset<=n.start.offset&&n.start.offset<t.end.offset,s=t.start.offset<n.end.offset&&n.end.offset<=t.end.offset;if(i||a||o||s){if(i&&a||o&&s||o&&n.start.offset===n.end.offset||a&&t.start.offset===t.end.offset)continue;throw new Uo(`Decorations ${JSON.stringify(n.start)} and ${JSON.stringify(t.start)} intersect.`)}}}}function Wu(e){let t=[],n=new Map,r=new Map;for(let i=0;i<e.length;i++){let{start:a,end:o}=e[i];if(a.offset>o.offset)return!1;a.offset!==o.offset&&(t.push(e[i]),n.has(a.offset)||n.set(a.offset,i),r.set(o.offset,i))}for(let t=0;t<e.length;t++){let{start:i,end:a}=e[t];if(i.offset===a.offset&&((n.get(i.offset)??t)<t||(r.get(i.offset)??t)>t))return!1}t.sort((e,t)=>e.start.offset-t.start.offset||t.end.offset-e.end.offset);let i=[];for(let{start:e,end:n}of t){for(;i.length&&i.at(-1)<=e.offset;)i.pop();if(i.length&&n.offset>i.at(-1))return!1;i.push(n.offset)}return!0}function Gu(e){return e.type===`text`?e.value:e.type===`element`?e.children.map(Gu).join(``):``}var Ku=[Hu()];function qu(e){let t=Ju(e.transformers||[]);return[...t.pre,...t.normal,...t.post,...Ku]}function Ju(e){let t=[],n=[],r=[];for(let i of e)switch(i.enforce){case`pre`:t.push(i);break;case`post`:n.push(i);break;default:r.push(i)}return{pre:t,post:n,normal:r}}var Yu=[`black`,`red`,`green`,`yellow`,`blue`,`magenta`,`cyan`,`white`,`brightBlack`,`brightRed`,`brightGreen`,`brightYellow`,`brightBlue`,`brightMagenta`,`brightCyan`,`brightWhite`],Xu={1:`bold`,2:`dim`,3:`italic`,4:`underline`,7:`reverse`,8:`hidden`,9:`strikethrough`};function Zu(e,t){let n=e.indexOf(`\x1B`,t);if(n!==-1&&e[n+1]===`[`){let t=e.indexOf(`m`,n);if(t!==-1)return{sequence:e.substring(n+2,t).split(`;`),startPosition:n,position:t+1}}return{position:e.length}}function Qu(e){let t=e.shift();if(t===`2`){let t=e.splice(0,3).map(e=>Number.parseInt(e));return t.length!==3||t.some(e=>Number.isNaN(e))?void 0:{type:`rgb`,rgb:t}}else if(t===`5`){let t=e.shift();if(t)return{type:`table`,index:Number(t)}}}function $u(e){let t=[];for(;e.length>0;){let n=e.shift();if(!n)continue;let r=Number.parseInt(n);if(!Number.isNaN(r))if(r===0)t.push({type:`resetAll`});else if(r<=9)Xu[r]&&t.push({type:`setDecoration`,value:Xu[r]});else if(r<=29){let e=Xu[r-20];e&&(t.push({type:`resetDecoration`,value:e}),e===`dim`&&t.push({type:`resetDecoration`,value:`bold`}))}else if(r<=37)t.push({type:`setForegroundColor`,value:{type:`named`,name:Yu[r-30]}});else if(r===38){let n=Qu(e);n&&t.push({type:`setForegroundColor`,value:n})}else if(r===39)t.push({type:`resetForegroundColor`});else if(r<=47)t.push({type:`setBackgroundColor`,value:{type:`named`,name:Yu[r-40]}});else if(r===48){let n=Qu(e);n&&t.push({type:`setBackgroundColor`,value:n})}else r===49?t.push({type:`resetBackgroundColor`}):r===53?t.push({type:`setDecoration`,value:`overline`}):r===55?t.push({type:`resetDecoration`,value:`overline`}):r>=90&&r<=97?t.push({type:`setForegroundColor`,value:{type:`named`,name:Yu[r-90+8]}}):r>=100&&r<=107&&t.push({type:`setBackgroundColor`,value:{type:`named`,name:Yu[r-100+8]}})}return t}function ed(){let e=null,t=null,n=new Set;return{parse(r){let i=[],a=0;do{let o=Zu(r,a),s=o.sequence?r.substring(a,o.startPosition):r.substring(a);if(s.length>0&&i.push({value:s,foreground:e,background:t,decorations:new Set(n)}),o.sequence){let r=$u(o.sequence);for(let i of r)i.type===`resetAll`?(e=null,t=null,n.clear()):i.type===`resetForegroundColor`?e=null:i.type===`resetBackgroundColor`?t=null:i.type===`resetDecoration`&&n.delete(i.value);for(let i of r)i.type===`setForegroundColor`?e=i.value:i.type===`setBackgroundColor`?t=i.value:i.type===`setDecoration`&&n.add(i.value)}a=o.position}while(a<r.length);return i}}}var td={black:`#000000`,red:`#bb0000`,green:`#00bb00`,yellow:`#bbbb00`,blue:`#0000bb`,magenta:`#ff00ff`,cyan:`#00bbbb`,white:`#eeeeee`,brightBlack:`#555555`,brightRed:`#ff5555`,brightGreen:`#00ff00`,brightYellow:`#ffff55`,brightBlue:`#5555ff`,brightMagenta:`#ff55ff`,brightCyan:`#55ffff`,brightWhite:`#ffffff`};function nd(e=td){function t(t){return e[t]}function n(e){return`#${e.map(e=>Math.max(0,Math.min(e,255)).toString(16).padStart(2,`0`)).join(``)}`}let r;function i(){if(r)return r;r=[];for(let e=0;e<Yu.length;e++)r.push(t(Yu[e]));let e=[0,95,135,175,215,255];for(let t=0;t<6;t++)for(let i=0;i<6;i++)for(let a=0;a<6;a++)r.push(n([e[t],e[i],e[a]]));let i=8;for(let e=0;e<24;e++,i+=10)r.push(n([i,i,i]));return r}function a(e){return i()[e]}function o(e){switch(e.type){case`named`:return t(e.name);case`rgb`:return n(e.rgb);case`table`:return a(e.index)}}return{value:o}}var rd=/#([0-9a-f]{3,8})/i,id=/var\((--[\w-]+-ansi-[\w-]+)\)/,ad={black:`#000000`,red:`#cd3131`,green:`#0DBC79`,yellow:`#E5E510`,blue:`#2472C8`,magenta:`#BC3FBC`,cyan:`#11A8CD`,white:`#E5E5E5`,brightBlack:`#666666`,brightRed:`#F14C4C`,brightGreen:`#23D18B`,brightYellow:`#F5F543`,brightBlue:`#3B8EEA`,brightMagenta:`#D670D6`,brightCyan:`#29B8DB`,brightWhite:`#FFFFFF`};function od(e,t,n){let r=Cc(e,n),i=Mc(t),a=nd(Object.fromEntries(Yu.map(t=>{let n=`terminal.ansi${t[0].toUpperCase()}${t.substring(1)}`;return[t,e.colors?.[n]||ad[t]]}))),o=ed();return i.map(t=>o.parse(t[0]).map(n=>{let i,o;n.decorations.has(`reverse`)?(i=n.background?a.value(n.background):e.bg,o=n.foreground?a.value(n.foreground):e.fg):(i=n.foreground?a.value(n.foreground):e.fg,o=n.background?a.value(n.background):void 0),i=wc(i,r),o=wc(o,r),n.decorations.has(`dim`)&&(i=sd(i));let s=ds.None;return n.decorations.has(`bold`)&&(s|=ds.Bold),n.decorations.has(`italic`)&&(s|=ds.Italic),n.decorations.has(`underline`)&&(s|=ds.Underline),n.decorations.has(`strikethrough`)&&(s|=ds.Strikethrough),{content:n.value,offset:t[1],color:i,bgColor:o,fontStyle:s}}))}function sd(e){let t=e.match(rd);if(t){let e=t[1];if(e.length===8){let t=Math.round(Number.parseInt(e.slice(6,8),16)/2).toString(16).padStart(2,`0`);return`#${e.slice(0,6)}${t}`}else if(e.length===6)return`#${e}80`;else if(e.length===4){let t=e[0],n=e[1],r=e[2],i=e[3];return`#${t}${t}${n}${n}${r}${r}${Math.round(Number.parseInt(`${i}${i}`,16)/2).toString(16).padStart(2,`0`)}`}else if(e.length===3){let t=e[0],n=e[1],r=e[2];return`#${t}${t}${n}${n}${r}${r}80`}}let n=e.match(id);return n?`var(${n[1]}-dim)`:e}function cd(e,t,n={}){let r=e.resolveLangAlias(n.lang||`text`),{theme:i=e.getLoadedThemes()[0]}=n;if(!Dc(r)&&!kc(i)&&r===`ansi`){let{theme:r}=e.setTheme(i);return od(r,t,n)}return $c(e,t,n)}function ld(e,t,n){let r,i,a,o,s,c;if(`themes`in n){let{defaultColor:l=`light`,cssVariablePrefix:u=`--shiki-`,colorsRendering:d=`css-vars`}=n,f=Object.entries(n.themes).filter(e=>e[1]).map(e=>({color:e[0],theme:e[1]})).sort((e,t)=>e.color===l?-1:+(t.color===l));if(f.length===0)throw new Uo("`themes` option must not be empty");let p=cl(e,t,n,cd);if(c=qc(p),l&&l!==`light-dark()`&&!f.some(e=>e.color===l))throw new Uo(`\`themes\` option must contain the defaultColor key \`${l}\``);let m=f.map(t=>e.getTheme(t.theme)),h=f.map(e=>e.color);a=p.map(e=>e.map(e=>zu(e,h,u,l,d))),c&&Kc(a,c);let g=f.map(e=>Cc(e.theme,n));i=ud(f,m,g,u,l,`fg`,d),r=ud(f,m,g,u,l,`bg`,d),o=`shiki-themes ${m.map(e=>e.name).join(` `)}`,s=l?void 0:[i,r].join(`;`)}else if(`theme`in n){let s=Cc(n.theme,n);a=cd(e,t,n);let l=e.getTheme(n.theme);r=wc(l.bg,s),i=wc(l.fg,s),o=l.name,c=qc(a)}else throw new Uo("Invalid options, either `theme` or `themes` must be provided");return{tokens:a,fg:i,bg:r,themeName:o,rootStyle:s,grammarState:c}}function ud(e,t,n,r,i,a,o){return e.map((s,c)=>{let l=wc(t[c][a],n[c])||`inherit`,u=`${r+s.color}${a===`bg`?`-bg`:``}:${l}`;if(c===0&&i){if(i===`light-dark()`&&e.length>1){let r=e.findIndex(e=>e.color===`light`),i=e.findIndex(e=>e.color===`dark`);if(r===-1||i===-1)throw new Uo('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');return`light-dark(${wc(t[r][a],n[r])||`inherit`}, ${wc(t[i][a],n[i])||`inherit`});${u}`}return l}return o===`css-vars`?u:null}).filter(e=>!!e).join(`;`)}var dd=/^\s+$/,fd=/^(\s*)(.*?)(\s*)$/;function pd(e,t,n,r={meta:{},options:n,codeToHast:(t,n)=>pd(e,t,n),codeToTokens:(t,n)=>ld(e,t,n)}){let i=t;for(let e of qu(n))i=e.preprocess?.call(r,i,n)||i;let{tokens:a,fg:o,bg:s,themeName:c,rootStyle:l,grammarState:u}=ld(e,i,n),{mergeWhitespaces:d=!0,mergeSameStyleTokens:f=!1}=n;d===!0?a=hd(a):d===`never`&&(a=gd(a)),f&&(a=_d(a));let p={...r,get source(){return i}};for(let e of qu(n))a=e.tokens?.call(p,a)||a;return md(a,{...n,fg:o,bg:s,themeName:c,rootStyle:n.rootStyle===!1?!1:n.rootStyle??l},p,u)}function md(e,t,n,r=qc(e)){let i=qu(t),a=[],o={type:`root`,children:[]},{structure:s=`classic`,tabindex:c=`0`}=t,l={class:`shiki ${t.themeName||``}`};t.rootStyle!==!1&&(t.rootStyle==null?l.style=`background-color:${t.bg};color:${t.fg}`:l.style=t.rootStyle),c!==!1&&c!=null&&(l.tabindex=c.toString());for(let[e,n]of Object.entries(t.meta||{}))e.startsWith(`_`)||(l[e]=n);let u={type:`element`,tagName:`pre`,properties:l,children:[],data:t.data},d={type:`element`,tagName:`code`,properties:{},children:a},f=[],p={...n,structure:s,addClassToHast:Nu,get source(){return n.source},get tokens(){return e},get options(){return t},get root(){return o},get pre(){return u},get code(){return d},get lines(){return f}};if(e.forEach((e,t)=>{t&&(s===`inline`?o.children.push({type:`element`,tagName:`br`,properties:{},children:[]}):s===`classic`&&a.push({type:`text`,value:`
|
|
15
|
+
`}));let n={type:`element`,tagName:`span`,properties:{class:`line`},children:[]},r=0;for(let a of e){let e={type:`element`,tagName:`span`,properties:{...a.htmlAttrs},children:[{type:`text`,value:a.content}]},c=Vu(a.htmlStyle||Bu(a));c&&(e.properties.style=c);for(let o of i)e=o?.span?.call(p,e,t+1,r,n,a)||e;s===`inline`?o.children.push(e):s===`classic`&&n.children.push(e),r+=a.content.length}if(s===`classic`){for(let e of i)n=e?.line?.call(p,n,t+1)||n;f.push(n),a.push(n)}else s===`inline`&&f.push(n)}),s===`classic`){for(let e of i)d=e?.code?.call(p,d)||d;u.children.push(d);for(let e of i)u=e?.pre?.call(p,u)||u;o.children.push(u)}else if(s===`inline`){let e=[],t={type:`element`,tagName:`span`,properties:{class:`line`},children:[]};for(let n of o.children)n.type===`element`&&n.tagName===`br`?(e.push(t),t={type:`element`,tagName:`span`,properties:{class:`line`},children:[]}):(n.type===`element`||n.type===`text`)&&t.children.push(n);e.push(t);let n={type:`element`,tagName:`code`,properties:{},children:e};for(let e of i)n=e?.code?.call(p,n)||n;o.children=[];for(let e=0;e<n.children.length;e++){e>0&&o.children.push({type:`element`,tagName:`br`,properties:{},children:[]});let t=n.children[e];t.type===`element`&&o.children.push(...t.children)}}let m=o;for(let e of i)m=e?.root?.call(p,m)||m;return r&&Kc(m,r),m}function hd(e){return e.map(e=>{let t=[],n=``,r;return e.forEach((i,a)=>{let o=!(i.fontStyle&&(i.fontStyle&ds.Underline||i.fontStyle&ds.Strikethrough));o&&dd.test(i.content)&&e[a+1]?(r===void 0&&(r=i.offset),n+=i.content):n?(o?t.push({...i,offset:r,content:n+i.content}):t.push({content:n,offset:r},i),r=void 0,n=``):t.push(i)}),t})}function gd(e){return e.map(e=>e.flatMap(e=>{if(dd.test(e.content))return e;let t=e.content.match(fd);if(!t)return e;let[,n,r,i]=t;if(!n&&!i)return e;let a=[{...e,offset:e.offset+n.length,content:r}];return n&&a.unshift({content:n,offset:e.offset}),i&&a.push({content:i,offset:e.offset+n.length+r.length}),a}))}function _d(e){return e.map(e=>{let t=[];for(let n of e){if(t.length===0){t.push({...n});continue}let e=t.at(-1),r=Vu(e.htmlStyle||Bu(e)),i=Vu(n.htmlStyle||Bu(n)),a=e.fontStyle&&(e.fontStyle&ds.Underline||e.fontStyle&ds.Strikethrough),o=n.fontStyle&&(n.fontStyle&ds.Underline||n.fontStyle&ds.Strikethrough);!a&&!o&&r===i?e.content+=n.content:t.push({...n})}return t})}var vd=ku;function yd(e,t,n){let r={meta:{},options:n,codeToHast:(t,n)=>pd(e,t,n),codeToTokens:(t,n)=>ld(e,t,n)},i=vd(pd(e,t,n,r));for(let e of qu(n))i=e.postprocess?.call(r,i,n)||i;return i}async function bd(e){let t=await Wc(e);return{getLastGrammarState:(...e)=>el(t,...e),codeToTokensBase:(e,n)=>cd(t,e,n),codeToTokensWithThemes:(e,n)=>cl(t,e,n),codeToTokens:(e,n)=>ld(t,e,n),codeToHast:(e,n)=>pd(t,e,n),codeToHtml:(e,n)=>yd(t,e,n),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...t,getInternalContext:()=>t}}var xd=4294967295;function Sd(e){return!e.sticky&&!e.rawOptions?.strategy}function Cd(e,t){return{index:e,captureIndices:t.map(e=>e==null?{start:xd,end:xd,length:0}:{start:e[0],end:e[1],length:e[1]-e[0]})}}var wd=class{patterns;options;regexps;lastSearches;constructor(e,t={}){this.patterns=e,this.options=t;let{forgiving:n=!1,cache:r,regexConstructor:i}=t;if(!i)throw Error("Option `regexConstructor` is not provided");this.regexps=e.map(e=>{if(typeof e!=`string`)return e;let t=r?.get(e);if(t){if(t instanceof RegExp)return t;if(n)return null;throw t}try{let t=i(e);return r?.set(e,t),t}catch(t){if(r?.set(e,t),n)return null;throw t}}),this.lastSearches=this.regexps.map(e=>e&&Sd(e)?{strId:0,searchedFrom:0,matchIndex:-1,indices:null}:null)}findNextMatchSync(e,t,n){let r=typeof e==`string`?e:e.content,i=typeof e==`string`?0:e.id||0,a=-1,o=0,s=null;for(let e=0;e<this.regexps.length;e++){let n=this.regexps[e];if(n)try{let c=i?this.lastSearches[e]:null,l,u;if(c&&c.strId===i&&c.searchedFrom<=t&&(c.matchIndex===-1||c.matchIndex>=t))l=c.matchIndex,u=c.indices;else{n.lastIndex=t;let e=n.exec(r);l=e?e.index:-1,u=e?e.indices:null,c&&(c.strId=i,c.searchedFrom=t,c.matchIndex=l,c.indices=u)}if(l===-1)continue;if(l===t)return Cd(e,u);(a===-1||l<o)&&(a=e,o=l,s=u)}catch(e){if(this.options.forgiving)continue;throw e}}return a===-1?null:Cd(a,s)}},Td=0;function Ed(e){return{content:e,id:++Td}}function Dd(e){if([...e].length!==1)throw Error(`Expected "${e}" to be a single code point`);return e.codePointAt(0)}function Od(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}var kd=new Set([`alnum`,`alpha`,`ascii`,`blank`,`cntrl`,`digit`,`graph`,`lower`,`print`,`punct`,`space`,`upper`,`word`,`xdigit`]),Ad=String.raw;function jd(e,t){if(e==null)throw Error(t??`Value expected`);return e}var Md=Ad`\[\^?`,Nd=`c.? | C(?:-.?)?|${Ad`[pP]\{(?:\^?[-\x20_]*[A-Za-z][-\x20\w]*\})?`}|${Ad`x[89A-Fa-f]\p{AHex}(?:\\x[89A-Fa-f]\p{AHex})*`}|${Ad`u(?:\p{AHex}{4})? | x\{[^\}]*\}? | x\p{AHex}{0,2}`}|${Ad`o\{[^\}]*\}?`}|${Ad`\d{1,3}`}`,Pd=/[?*+][?+]?|\{(?:\d+(?:,\d*)?|,\d+)\}\??/,Fd=new RegExp(Ad`
|
|
16
16
|
\\ (?:
|
|
17
|
-
${
|
|
17
|
+
${Nd}
|
|
18
18
|
| [gk]<[^>]*>?
|
|
19
19
|
| [gk]'[^']*'?
|
|
20
20
|
| .
|
|
@@ -31,20 +31,20 @@ import{a as e,c as t,d as n,i as r,l as i,o as a,r as o,s,t as c,u as l}from"./p
|
|
|
31
31
|
)?
|
|
32
32
|
| \*[^\)]*\)?
|
|
33
33
|
)?
|
|
34
|
-
| (?:${
|
|
35
|
-
| ${
|
|
34
|
+
| (?:${Pd.source})+
|
|
35
|
+
| ${Md}
|
|
36
36
|
| .
|
|
37
|
-
`.replace(/\s+/g,``),`gsu`),
|
|
37
|
+
`.replace(/\s+/g,``),`gsu`),Id=new RegExp(Ad`
|
|
38
38
|
\\ (?:
|
|
39
|
-
${
|
|
39
|
+
${Nd}
|
|
40
40
|
| .
|
|
41
41
|
)
|
|
42
42
|
| \[:(?:\^?\p{Alpha}+|\^):\]
|
|
43
|
-
| ${
|
|
43
|
+
| ${Md}
|
|
44
44
|
| &&
|
|
45
45
|
| .
|
|
46
|
-
`.replace(/\s+/g,``),`gsu`);function
|
|
47
|
-
`,r);return{lastIndex:e===-1?t.length:e}}if(/^\s$/.test(n)){let e=/\s+/y;return e.lastIndex=r,{lastIndex:e.exec(t)?e.lastIndex:r}}}return n===`.`?{token:Yd(`dot`,n)}:n===`^`||n===`$`?{token:Hd(e.singleline?{"^":kd`\A`,$:kd`\Z`}[n]:n,n)}:n===`|`?{token:Vd(n)}:Nd.test(n)?{tokens:gf(n)}:{token:Wd(Ed(n),n)}}function Rd(e,t,n){let r=[Jd(t[1]===`^`,t)],i=1,a;for(Fd.lastIndex=n;a=Fd.exec(e);){let e=a[0];if(e[0]===`[`&&e[1]!==`:`)i++,r.push(Jd(e[1]===`^`,e));else if(e===`]`){if(r.at(-1).type===`CharacterClassOpen`)r.push(Wd(93,e));else if(i--,r.push(Gd(e)),!i)break}else{let t=zd(e);Array.isArray(t)?r.push(...t):r.push(t)}}return{tokens:r,lastIndex:Fd.lastIndex||e.length}}function zd(e){if(e[0]===`\\`)return Bd(e,{inCharClass:!0});if(e[0]===`[`){let t=/\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(e);if(!t||!Od.has(t.groups.name))throw Error(`Invalid POSIX class "${e}"`);return Yd(`posix`,e,{value:t.groups.name,negate:!!t.groups.negate})}return e===`-`?Kd(e):e===`&&`?qd(e):Wd(Ed(e),e)}function Bd(e,{inCharClass:t}){let n=e[1];if(n===`c`||n===`C`)return of(e);if(`dDhHsSwW`.includes(n))return uf(e);if(e.startsWith(kd`\o{`))throw Error(`Incomplete, invalid, or unsupported octal code point "${e}"`);if(/^\\[pP]\{/.test(e)){if(e.length===3)throw Error(`Incomplete or invalid Unicode property "${e}"`);return df(e)}if(/^\\x[89A-Fa-f]\p{AHex}/u.test(e))try{let t=e.split(/\\x/).slice(1).map(e=>parseInt(e,16)),n=new TextDecoder(`utf-8`,{ignoreBOM:!0,fatal:!0}).decode(new Uint8Array(t)),r=new TextEncoder;return[...n].map(e=>{let t=[...r.encode(e)].map(e=>`\\x${e.toString(16)}`).join(``);return Wd(Ed(e),t)})}catch{throw Error(`Multibyte code "${e}" incomplete or invalid in Oniguruma`)}if(n===`u`||n===`x`)return Wd(mf(e),e);if(af.has(n))return Wd(af.get(n),e);if(/\d/.test(n))return Zd(t,e);if(e===`\\`)throw Error(kd`Incomplete escape "\"`);if(n===`M`)throw Error(`Unsupported meta "${e}"`);if([...e].length===2)return Wd(e.codePointAt(1),e);throw Error(`Unexpected escape "${e}"`)}function Vd(e){return{type:`Alternator`,raw:e}}function Hd(e,t){return{type:`Assertion`,kind:e,raw:t}}function Ud(e){return{type:`Backreference`,raw:e}}function Wd(e,t){return{type:`Character`,value:e,raw:t}}function Gd(e){return{type:`CharacterClassClose`,raw:e}}function Kd(e){return{type:`CharacterClassHyphen`,raw:e}}function qd(e){return{type:`CharacterClassIntersector`,raw:e}}function Jd(e,t){return{type:`CharacterClassOpen`,negate:e,raw:t}}function Yd(e,t,n={}){return{type:`CharacterSet`,kind:e,...n,raw:t}}function Xd(e,t,n={}){return e===`keep`?{type:`Directive`,kind:e,raw:t}:{type:`Directive`,kind:e,flags:Ad(n.flags),raw:t}}function Zd(e,t){return{type:`EscapedNumber`,inCharClass:e,raw:t}}function Qd(e){return{type:`GroupClose`,raw:e}}function $d(e,t,n={}){return{type:`GroupOpen`,kind:e,...n,raw:t}}function ef(e,t,n,r){return{type:`NamedCallout`,kind:e,tag:t,arguments:n,raw:r}}function tf(e,t,n,r){return{type:`Quantifier`,kind:e,min:t,max:n,raw:r}}function nf(e){return{type:`Subroutine`,raw:e}}var rf=new Set([`COUNT`,`CMP`,`ERROR`,`FAIL`,`MAX`,`MISMATCH`,`SKIP`,`TOTAL_COUNT`]),af=new Map([[`a`,7],[`b`,8],[`e`,27],[`f`,12],[`n`,10],[`r`,13],[`t`,9],[`v`,11]]);function of(e){let t=e[1]===`c`?e[2]:e[3];if(!t||!/[A-Za-z]/.test(t))throw Error(`Unsupported control character "${e}"`);return Wd(Ed(t.toUpperCase())-64,e)}function sf(e,t){let{on:n,off:r}=/^\(\?(?<on>[imx]*)(?:-(?<off>[-imx]*))?/.exec(e).groups;r??=``;let i=(t.getCurrentModX()||n.includes(`x`))&&!r.includes(`x`),a=ff(n),o=ff(r),s={};if(a&&(s.enable=a),o&&(s.disable=o),e.endsWith(`)`))return t.replaceCurrentModX(i),Xd(`flags`,e,{flags:s});if(e.endsWith(`:`))return t.pushModX(i),t.numOpenGroups++,$d(`group`,e,{...(a||o)&&{flags:s}});throw Error(`Unexpected flag modifier "${e}"`)}function cf(e){let t=/\(\*(?<name>[A-Za-z_]\w*)?(?:\[(?<tag>(?:[A-Za-z_]\w*)?)\])?(?:\{(?<args>[^}]*)\})?\)/.exec(e);if(!t)throw Error(`Incomplete or invalid named callout "${e}"`);let{name:n,tag:r,args:i}=t.groups;if(!n)throw Error(`Invalid named callout "${e}"`);if(r===``)throw Error(`Named callout tag with empty value not allowed "${e}"`);let a=i?i.split(`,`).filter(e=>e!==``).map(e=>/^[+-]?\d+$/.test(e)?+e:e):[],[o,s,c]=a,l=rf.has(n)?n.toLowerCase():`custom`;switch(l){case`fail`:case`mismatch`:case`skip`:if(a.length>0)throw Error(`Named callout arguments not allowed "${a}"`);break;case`error`:if(a.length>1)throw Error(`Named callout allows only one argument "${a}"`);if(typeof o==`string`)throw Error(`Named callout argument must be a number "${o}"`);break;case`max`:if(!a.length||a.length>2)throw Error(`Named callout must have one or two arguments "${a}"`);if(typeof o==`string`&&!/^[A-Za-z_]\w*$/.test(o))throw Error(`Named callout argument one must be a tag or number "${o}"`);if(a.length===2&&(typeof s==`number`||!/^[<>X]$/.test(s)))throw Error(`Named callout optional argument two must be '<', '>', or 'X' "${s}"`);break;case`count`:case`total_count`:if(a.length>1)throw Error(`Named callout allows only one argument "${a}"`);if(a.length===1&&(typeof o==`number`||!/^[<>X]$/.test(o)))throw Error(`Named callout optional argument must be '<', '>', or 'X' "${o}"`);break;case`cmp`:if(a.length!==3)throw Error(`Named callout must have three arguments "${a}"`);if(typeof o==`string`&&!/^[A-Za-z_]\w*$/.test(o))throw Error(`Named callout argument one must be a tag or number "${o}"`);if(typeof s==`number`||!/^(?:[<>!=]=|[<>])$/.test(s))throw Error(`Named callout argument two must be '==', '!=', '>', '<', '>=', or '<=' "${s}"`);if(typeof c==`string`&&!/^[A-Za-z_]\w*$/.test(c))throw Error(`Named callout argument three must be a tag or number "${c}"`);break;case`custom`:throw Error(`Undefined callout name "${n}"`);default:throw Error(`Unexpected named callout kind "${l}"`)}return ef(l,r??null,i?.split(`,`)??null,e)}function lf(e){let t=null,n,r;if(e[0]===`{`){let{minStr:i,maxStr:a}=/^\{(?<minStr>\d*)(?:,(?<maxStr>\d*))?/.exec(e).groups,o=1e5;if(+i>o||a&&+a>o)throw Error(`Quantifier value unsupported in Oniguruma`);if(n=+i,r=a===void 0?+i:a===``?1/0:+a,n>r&&(t=`possessive`,[n,r]=[r,n]),e.endsWith(`?`)){if(t===`possessive`)throw Error(`Unsupported possessive interval quantifier chain with "?"`);t=`lazy`}else t||=`greedy`}else n=+(e[0]===`+`),r=e[0]===`?`?1:1/0,t=e[1]===`+`?`possessive`:e[1]===`?`?`lazy`:`greedy`;return tf(t,n,r,e)}function uf(e){let t=e[1].toLowerCase();return Yd({d:`digit`,h:`hex`,s:`space`,w:`word`}[t],e,{negate:e[1]!==t})}function df(e){let{p:t,neg:n,value:r}=/^\\(?<p>[pP])\{(?<neg>\^?)(?<value>[^}]+)/.exec(e).groups;return Yd(`property`,e,{value:r,negate:t===`P`&&!n||t===`p`&&!!n})}function ff(e){let t={};return e.includes(`i`)&&(t.ignoreCase=!0),e.includes(`m`)&&(t.dotAll=!0),e.includes(`x`)&&(t.extended=!0),Object.keys(t).length?t:null}function pf(e){let t={ignoreCase:!1,dotAll:!1,extended:!1,digitIsAscii:!1,posixIsAscii:!1,spaceIsAscii:!1,wordIsAscii:!1,textSegmentMode:null};for(let n=0;n<e.length;n++){let r=e[n];if(!`imxDPSWy`.includes(r))throw Error(`Invalid flag "${r}"`);if(r===`y`){if(!/^y{[gw]}/.test(e.slice(n)))throw Error(`Invalid or unspecified flag "y" mode`);t.textSegmentMode=e[n+2]===`g`?`grapheme`:`word`,n+=3;continue}t[{i:`ignoreCase`,m:`dotAll`,x:`extended`,D:`digitIsAscii`,P:`posixIsAscii`,S:`spaceIsAscii`,W:`wordIsAscii`}[r]]=!0}return t}function mf(e){if(/^(?:\\u(?!\p{AHex}{4})|\\x(?!\p{AHex}{1,2}|\{\p{AHex}{1,8}\}))/u.test(e))throw Error(`Incomplete or invalid escape "${e}"`);let t=e[2]===`{`?/^\\x\{\s*(?<hex>\p{AHex}+)/u.exec(e).groups.hex:e.slice(2);return parseInt(t,16)}function hf(e,t){let{raw:n,inCharClass:r}=e,i=n.slice(1);if(!r&&(i!==`0`&&i.length===1||i[0]!==`0`&&+i<=t))return[Ud(n)];let a=[],o=i.match(/^[0-7]+|\d/g);for(let e=0;e<o.length;e++){let t=o[e],r;if(e===0&&t!==`8`&&t!==`9`){if(r=parseInt(t,8),r>127)throw Error(kd`Octal encoded byte above 177 unsupported "${n}"`)}else r=Ed(t);a.push(Wd(r,(e===0?`\\`:``)+t))}return a}function gf(e){let t=[],n=new RegExp(Nd,`gy`),r;for(;r=n.exec(e);){let e=r[0];if(e[0]===`{`){let r=/^\{(?<min>\d+),(?<max>\d+)\}\??$/.exec(e);if(r){let{min:i,max:a}=r.groups;if(+i>+a&&e.endsWith(`?`)){n.lastIndex--,t.push(lf(e.slice(0,-1)));continue}}}t.push(lf(e))}return t}function _f(e,t){if(!Array.isArray(e.body))throw Error(`Expected node with body array`);if(e.body.length!==1)return!1;let n=e.body[0];return!t||Object.keys(t).every(e=>t[e]===n[e])}function vf(e){return yf.has(e.type)}var yf=new Set([`AbsenceFunction`,`Backreference`,`CapturingGroup`,`Character`,`CharacterClass`,`CharacterSet`,`Group`,`Quantifier`,`Subroutine`]);function bf(e,t={}){let n={flags:``,normalizeUnknownPropertyNames:!1,skipBackrefValidation:!1,skipLookbehindValidation:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t,rules:{captureGroup:!1,singleline:!1,...t.rules}},r=Id(e,{flags:n.flags,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline}}),i=(e,t)=>{let n=r.tokens[a.nextIndex];switch(a.parent=e,a.nextIndex++,n.type){case`Alternator`:return Af();case`Assertion`:return xf(n);case`Backreference`:return Sf(n,a);case`Character`:return Pf(n.value,{useLastValid:!!t.isCheckingRangeEnd});case`CharacterClassHyphen`:return Cf(n,a,t);case`CharacterClassOpen`:return wf(n,a,t);case`CharacterSet`:return Tf(n,a);case`Directive`:return Rf(n.kind,{flags:n.flags});case`GroupOpen`:return Ef(n,a,t);case`NamedCallout`:return Hf(n.kind,n.tag,n.arguments);case`Quantifier`:return Df(n,a);case`Subroutine`:return Of(n,a);default:throw Error(`Unexpected token type "${n.type}"`)}},a={capturingGroups:[],hasNumberedRef:!1,namedGroupsByName:new Map,nextIndex:0,normalizeUnknownPropertyNames:n.normalizeUnknownPropertyNames,parent:null,skipBackrefValidation:n.skipBackrefValidation,skipLookbehindValidation:n.skipLookbehindValidation,skipPropertyNameValidation:n.skipPropertyNameValidation,subroutines:[],tokens:r.tokens,unicodePropertyMap:n.unicodePropertyMap,walk:i},o=Gf(zf(r.flags)),s=o.body[0];for(;a.nextIndex<r.tokens.length;){let e=i(s,{});e.type===`Alternative`?(o.body.push(e),s=e):s.body.push(e)}let{capturingGroups:c,hasNumberedRef:l,namedGroupsByName:u,subroutines:d}=a;if(l&&u.size&&!n.rules.captureGroup)throw Error(`Numbered backref/subroutine not allowed when using named capture`);for(let{ref:e}of d)if(typeof e==`number`){if(e>c.length)throw Error(`Subroutine uses a group number that's not defined`);e&&(c[e-1].isSubroutined=!0)}else if(u.has(e)){if(u.get(e).length>1)throw Error(kd`Subroutine uses a duplicate group name "\g<${e}>"`);u.get(e)[0].isSubroutined=!0}else throw Error(kd`Subroutine uses a group name that's not defined "\g<${e}>"`);return o}function xf({kind:e}){return jf(Ad({"^":`line_start`,$:`line_end`,"\\A":`string_start`,"\\b":`word_boundary`,"\\B":`word_boundary`,"\\G":`search_start`,"\\y":`text_segment_boundary`,"\\Y":`text_segment_boundary`,"\\z":`string_end`,"\\Z":`string_end_newline`}[e],`Unexpected assertion kind "${e}"`),{negate:e===kd`\B`||e===kd`\Y`})}function Sf({raw:e},t){let n=/^\\k[<']/.test(e),r=n?e.slice(3,-1):e.slice(1),i=(n,r=!1)=>{let i=t.capturingGroups.length,a=!1;if(n>i)if(t.skipBackrefValidation)a=!0;else throw Error(`Not enough capturing groups defined to the left "${e}"`);return t.hasNumberedRef=!0,Mf(r?i+1-n:n,{orphan:a})};if(n){let n=/^(?<sign>-?)0*(?<num>[1-9]\d*)$/.exec(r);if(n)return i(+n.groups.num,!!n.groups.sign);if(/[-+]/.test(r))throw Error(`Invalid backref name "${e}"`);if(!t.namedGroupsByName.has(r))throw Error(`Group name not defined to the left "${e}"`);return Mf(r)}return i(+r)}function Cf(e,t,n){let{tokens:r,walk:i}=t,a=t.parent,o=a.body.at(-1),s=r[t.nextIndex];if(!n.isCheckingRangeEnd&&o&&o.type!==`CharacterClass`&&o.type!==`CharacterClassRange`&&s&&s.type!==`CharacterClassOpen`&&s.type!==`CharacterClassClose`&&s.type!==`CharacterClassIntersector`){let e=i(a,{...n,isCheckingRangeEnd:!0});if(o.type===`Character`&&e.type===`Character`)return a.body.pop(),If(o,e);throw Error(`Invalid character class range`)}return Pf(Ed(`-`))}function wf({negate:e},t,n){let{tokens:r,walk:i}=t,a=[Ff()],o=r[t.nextIndex],s=np(o);for(;s.type!==`CharacterClassClose`;){if(s.type===`CharacterClassIntersector`)a.push(Ff()),t.nextIndex++;else{let e=a.at(-1);e.body.push(i(e,n))}s=np(r[t.nextIndex],o)}let c=Ff({negate:e});return a.length===1?c.body=a[0].body:(c.kind=`intersection`,c.body=a.map(e=>e.body.length===1?e.body[0]:e)),t.nextIndex++,c}function Tf({kind:e,negate:t,value:n},r){let{normalizeUnknownPropertyNames:i,skipPropertyNameValidation:a,unicodePropertyMap:o}=r;if(e===`property`){let r=tp(n);if(Od.has(r)&&!o?.has(r))e=`posix`,n=r;else return qf(n,{negate:t,normalizeUnknownPropertyNames:i,skipPropertyNameValidation:a,unicodePropertyMap:o})}return e===`posix`?Uf(n,{negate:t}):Lf(e,{negate:t})}function Ef(e,t,n){let{tokens:r,capturingGroups:i,namedGroupsByName:a,skipLookbehindValidation:o,walk:s}=t,c=Jf(e),l=c.type===`AbsenceFunction`,u=Qf(c),d=u&&c.negate;if(c.type===`CapturingGroup`&&(i.push(c),c.name&&Dd(a,c.name,[]).push(c)),l&&n.isInAbsenceFunction)throw Error(`Nested absence function not supported by Oniguruma`);let f=rp(r[t.nextIndex]);for(;f.type!==`GroupClose`;){if(f.type===`Alternator`)c.body.push(Af()),t.nextIndex++;else{let e=c.body.at(-1),t=s(e,{...n,isInAbsenceFunction:n.isInAbsenceFunction||l,isInLookbehind:n.isInLookbehind||u,isInNegLookbehind:n.isInNegLookbehind||d});if(e.body.push(t),(u||n.isInLookbehind)&&!o){let e=`Lookbehind includes a pattern not allowed by Oniguruma`;if(d||n.isInNegLookbehind){if(Zf(t)||t.type===`CapturingGroup`)throw Error(e)}else if(Zf(t)||Qf(t)&&t.negate)throw Error(e)}}f=rp(r[t.nextIndex])}return t.nextIndex++,c}function Df({kind:e,min:t,max:n},r){let i=r.parent,a=i.body.at(-1);if(!a||!vf(a))throw Error(`Quantifier requires a repeatable token`);let o=Wf(e,t,n,a);return i.body.pop(),o}function Of({raw:e},t){let{capturingGroups:n,subroutines:r}=t,i=e.slice(3,-1),a=/^(?<sign>[-+]?)0*(?<num>[1-9]\d*)$/.exec(i);if(a){let e=+a.groups.num,r=n.length;if(t.hasNumberedRef=!0,i={"":e,"+":r+e,"-":r+1-e}[a.groups.sign],i<1)throw Error(`Invalid subroutine number`)}else i===`0`&&(i=0);let o=Kf(i);return r.push(o),o}function kf(e,t){if(e!==`repeater`)throw Error(`Unexpected absence function kind "${e}"`);return{type:`AbsenceFunction`,kind:e,body:Yf(t?.body)}}function Af(e){return{type:`Alternative`,body:Xf(e?.body)}}function jf(e,t){let n={type:`Assertion`,kind:e};return(e===`word_boundary`||e===`text_segment_boundary`)&&(n.negate=!!t?.negate),n}function Mf(e,t){let n=!!t?.orphan;return{type:`Backreference`,ref:e,...n&&{orphan:n}}}function Nf(e,t){let n={name:void 0,isSubroutined:!1,...t};if(n.name!==void 0&&!$f(n.name))throw Error(`Group name "${n.name}" invalid in Oniguruma`);return{type:`CapturingGroup`,number:e,...n.name&&{name:n.name},...n.isSubroutined&&{isSubroutined:n.isSubroutined},body:Yf(t?.body)}}function Pf(e,t){let n={useLastValid:!1,...t};if(e>1114111){let t=e.toString(16);if(n.useLastValid)e=1114111;else throw Error(e>1310719?`Invalid code point out of range "\\x{${t}}"`:`Invalid code point out of range in JS "\\x{${t}}"`)}return{type:`Character`,value:e}}function Ff(e){let t={kind:`union`,negate:!1,...e};return{type:`CharacterClass`,kind:t.kind,negate:t.negate,body:Xf(e?.body)}}function If(e,t){if(t.value<e.value)throw Error(`Character class range out of order`);return{type:`CharacterClassRange`,min:e,max:t}}function Lf(e,t){let n=!!t?.negate,r={type:`CharacterSet`,kind:e};return(e===`digit`||e===`hex`||e===`newline`||e===`space`||e===`word`)&&(r.negate=n),(e===`text_segment`||e===`newline`&&!n)&&(r.variableLength=!0),r}function Rf(e,t={}){if(e===`keep`)return{type:`Directive`,kind:e};if(e===`flags`)return{type:`Directive`,kind:e,flags:Ad(t.flags)};throw Error(`Unexpected directive kind "${e}"`)}function zf(e){return{type:`Flags`,...e}}function Bf(e){let t=e?.atomic,n=e?.flags;if(t&&n)throw Error(`Atomic group cannot have flags`);return{type:`Group`,...t&&{atomic:t},...n&&{flags:n},body:Yf(e?.body)}}function Vf(e){let t={behind:!1,negate:!1,...e};return{type:`LookaroundAssertion`,kind:t.behind?`lookbehind`:`lookahead`,negate:t.negate,body:Yf(e?.body)}}function Hf(e,t,n){return{type:`NamedCallout`,kind:e,tag:t,arguments:n}}function Uf(e,t){let n=!!t?.negate;if(!Od.has(e))throw Error(`Invalid POSIX class "${e}"`);return{type:`CharacterSet`,kind:`posix`,value:e,negate:n}}function Wf(e,t,n,r){if(t>n)throw Error(`Invalid reversed quantifier range`);return{type:`Quantifier`,kind:e,min:t,max:n,body:r}}function Gf(e,t){return{type:`Regex`,body:Yf(t?.body),flags:e}}function Kf(e){return{type:`Subroutine`,ref:e}}function qf(e,t){let n={negate:!1,normalizeUnknownPropertyNames:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t},r=n.unicodePropertyMap?.get(tp(e));if(!r){if(n.normalizeUnknownPropertyNames)r=ep(e);else if(n.unicodePropertyMap&&!n.skipPropertyNameValidation)throw Error(kd`Invalid Unicode property "\p{${e}}"`)}return{type:`CharacterSet`,kind:`property`,value:r??e,negate:n.negate}}function Jf({flags:e,kind:t,name:n,negate:r,number:i}){switch(t){case`absence_repeater`:return kf(`repeater`);case`atomic`:return Bf({atomic:!0});case`capturing`:return Nf(i,{name:n});case`group`:return Bf({flags:e});case`lookahead`:case`lookbehind`:return Vf({behind:t===`lookbehind`,negate:r});default:throw Error(`Unexpected group kind "${t}"`)}}function Yf(e){if(e===void 0)e=[Af()];else if(!Array.isArray(e)||!e.length||!e.every(e=>e.type===`Alternative`))throw Error(`Invalid body; expected array of one or more Alternative nodes`);return e}function Xf(e){if(e===void 0)e=[];else if(!Array.isArray(e)||!e.every(e=>!!e.type))throw Error(`Invalid body; expected array of nodes`);return e}function Zf(e){return e.type===`LookaroundAssertion`&&e.kind===`lookahead`}function Qf(e){return e.type===`LookaroundAssertion`&&e.kind===`lookbehind`}function $f(e){return/^[\p{Alpha}\p{Pc}][^)]*$/u.test(e)}function ep(e){return e.trim().replace(/[- _]+/g,`_`).replace(/[A-Z][a-z]+(?=[A-Z])/g,`$&_`).replace(/[A-Za-z]+/g,e=>e[0].toUpperCase()+e.slice(1).toLowerCase())}function tp(e){return e.replace(/[- _]+/g,``).toLowerCase()}function np(e,t){let n=t;return Ad(e,`Unclosed character class${n?.type===`Character`&&n.value===93&&n.raw===`]`?` (started with "]")`:``}`)}function rp(e){return Ad(e,`Unclosed group`)}function ip(e,t,n=null){function r(e,t){for(let n=0;n<e.length;n++){let r=i(e[n],t,n,e);n=Math.max(-1,n+r)}}function i(a,o=null,s=null,c=null){let l=0,u=!1,d={node:a,parent:o,key:s,container:c,root:e,remove(){ap(c).splice(Math.max(0,op(s)+l),1),l--,u=!0},removeAllNextSiblings(){return ap(c).splice(op(s)+1)},removeAllPrevSiblings(){let e=op(s)+l;return l-=e,ap(c).splice(0,Math.max(0,e))},replaceWith(e,t={}){let n=!!t.traverse;c?c[Math.max(0,op(s)+l)]=e:Ad(o,`Can't replace root node`)[s]=e,n&&i(e,o,s,c),u=!0},replaceWithMultiple(e,t={}){let n=!!t.traverse;if(ap(c).splice(Math.max(0,op(s)+l),1,...e),l+=e.length-1,n){let t=0;for(let n=0;n<e.length;n++)t+=i(e[n],o,op(s)+n+t,c)}u=!0},skip(){u=!0}},{type:f}=a,p=t[`*`],m=t[f],h=typeof p==`function`?p:p?.enter,g=typeof m==`function`?m:m?.enter;if(h?.(d,n),g?.(d,n),!u)switch(f){case`AbsenceFunction`:case`Alternative`:case`CapturingGroup`:case`CharacterClass`:case`Group`:case`LookaroundAssertion`:r(a.body,a);break;case`Assertion`:case`Backreference`:case`Character`:case`CharacterSet`:case`Directive`:case`Flags`:case`NamedCallout`:case`Subroutine`:break;case`CharacterClassRange`:i(a.min,a,`min`),i(a.max,a,`max`);break;case`Quantifier`:i(a.body,a,`body`);break;case`Regex`:r(a.body,a),i(a.flags,a,`flags`);break;default:throw Error(`Unexpected node type "${f}"`)}return m?.exit?.(d,n),p?.exit?.(d,n),l}return i(e),e}function ap(e){if(!Array.isArray(e))throw Error(`Container expected`);return e}function op(e){if(typeof e!=`number`)throw Error(`Numeric key expected`);return e}var sp=String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;function cp(e,t){for(let n=0;n<e.length;n++)e[n]>=t&&e[n]++}function lp(e,t,n,r){return e.slice(0,t)+r+e.slice(t+n.length)}var up=Object.freeze({DEFAULT:`DEFAULT`,CHAR_CLASS:`CHAR_CLASS`});function dp(e,t,n,r){let i=new RegExp(String.raw`${t}|(?<$skip>\[\^?|\\?.)`,`gsu`),a=[!1],o=0,s=``;for(let t of e.matchAll(i)){let{0:e,groups:{$skip:i}}=t;if(!i&&(!r||r===up.DEFAULT==!o)){n instanceof Function?s+=n(t,{context:o?up.CHAR_CLASS:up.DEFAULT,negated:a[a.length-1]}):s+=n;continue}e[0]===`[`?(o++,a.push(e[1]===`^`)):e===`]`&&o&&(o--,a.pop()),s+=e}return s}function fp(e,t,n,r){dp(e,t,n,r)}function pp(e,t,n=0,r){if(!new RegExp(t,`su`).test(e))return null;let i=RegExp(`${t}|(?<$skip>\\\\?.)`,`gsu`);i.lastIndex=n;let a=0,o;for(;o=i.exec(e);){let{0:e,groups:{$skip:t}}=o;if(!t&&(!r||r===up.DEFAULT==!a))return o;e===`[`?a++:e===`]`&&a&&a--,i.lastIndex==o.index&&i.lastIndex++}return null}function mp(e,t,n){return!!pp(e,t,0,n)}function hp(e,t){let n=/\\?./gsu;n.lastIndex=t;let r=e.length,i=0,a=1,o;for(;o=n.exec(e);){let[e]=o;if(e===`[`)i++;else if(i)e===`]`&&i--;else if(e===`(`)a++;else if(e===`)`&&(a--,!a)){r=o.index;break}}return e.slice(t,r)}var gp=new RegExp(String.raw`(?<noncapturingStart>${sp})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`,`gsu`);function _p(e,t){let n=t?.hiddenCaptures??[],r=t?.captureTransfers??new Map;if(!/\(\?>/.test(e))return{pattern:e,captureTransfers:r,hiddenCaptures:n};let i=[0],a=[],o=0,s=0,c=NaN,l;do{l=!1;let t=0,u=0,d=!1,f;for(gp.lastIndex=Number.isNaN(c)?0:c+7;f=gp.exec(e);){let{0:p,index:m,groups:{capturingStart:h,noncapturingStart:g}}=f;if(p===`[`)t++;else if(t)p===`]`&&t--;else if(p===`(?>`&&!d)c=m,d=!0;else if(d&&g)u++;else if(h)d?u++:(o++,i.push(o+s));else if(p===`)`&&d){if(!u){s++;let t=o+s;if(e=`${e.slice(0,c)}(?:(?=(${e.slice(c+3,m)}))<$$${t}>)${e.slice(m+1)}`,l=!0,a.push(t),cp(n,t),r.size){let e=new Map;r.forEach((n,r)=>{e.set(r>=t?r+1:r,n.map(e=>e>=t?e+1:e))}),r=e}break}u--}}}while(l);return n.push(...a),e=dp(e,String.raw`\\(?<backrefNum>[1-9]\d*)|<\$\$(?<wrappedBackrefNum>\d+)>`,({0:e,groups:{backrefNum:t,wrappedBackrefNum:n}})=>{if(t){let n=+t;if(n>i.length-1)throw Error(`Backref "${e}" greater than number of captures`);return`\\${i[n]}`}return`\\${n}`},up.DEFAULT),{pattern:e,captureTransfers:r,hiddenCaptures:n}}var vp=String.raw`(?:[?*+]|\{\d+(?:,\d*)?\})`,yp=new RegExp(String.raw`
|
|
46
|
+
`.replace(/\s+/g,``),`gsu`);function Ld(e,t={}){let n={flags:``,...t,rules:{captureGroup:!1,singleline:!1,...t.rules}};if(typeof e!=`string`)throw Error(`String expected as pattern`);let r=mf(n.flags),i=[r.extended],a={captureGroup:n.rules.captureGroup,getCurrentModX(){return i.at(-1)},numOpenGroups:0,popModX(){i.pop()},pushModX(e){i.push(e)},replaceCurrentModX(e){i[i.length-1]=e},singleline:n.rules.singleline},o=[],s;for(Fd.lastIndex=0;s=Fd.exec(e);){let t=Rd(a,e,s[0],Fd.lastIndex);t.tokens?o.push(...t.tokens):t.token&&o.push(t.token),t.lastIndex!==void 0&&(Fd.lastIndex=t.lastIndex)}let c=[],l=0;o.filter(e=>e.type===`GroupOpen`).forEach(e=>{e.kind===`capturing`?e.number=++l:e.raw===`(`&&c.push(e)}),l||c.forEach((e,t)=>{e.kind=`capturing`,e.number=t+1});let u=l||c.length;return{tokens:o.map(e=>e.type===`EscapedNumber`?gf(e,u):e).flat(),flags:r}}function Rd(e,t,n,r){let[i,a]=n;if(n===`[`||n===`[^`){let e=zd(t,n,r);return{tokens:e.tokens,lastIndex:e.lastIndex}}if(i===`\\`){if(`AbBGyYzZ`.includes(a))return{token:Ud(n,n)};if(/^\\g[<']/.test(n)){if(!/^\\g(?:<[^>]+>|'[^']+')$/.test(n))throw Error(`Invalid group name "${n}"`);return{token:rf(n)}}if(/^\\k[<']/.test(n)){if(!/^\\k(?:<[^>]+>|'[^']+')$/.test(n))throw Error(`Invalid group name "${n}"`);return{token:Wd(n)}}if(a===`K`)return{token:Zd(`keep`,n)};if(a===`N`||a===`R`)return{token:Xd(`newline`,n,{negate:a===`N`})};if(a===`O`)return{token:Xd(`any`,n)};if(a===`X`)return{token:Xd(`text_segment`,n)};let e=Vd(n,{inCharClass:!1});return Array.isArray(e)?{tokens:e}:{token:e}}if(i===`(`){if(a===`*`)return{token:lf(n)};if(n===`(?{`)throw Error(`Unsupported callout "${n}"`);if(n.startsWith(`(?#`)){if(t[r]!==`)`)throw Error(`Unclosed comment group "(?#"`);return{lastIndex:r+1}}if(/^\(\?[-imx]+[:)]$/.test(n))return{token:cf(n,e)};if(e.pushModX(e.getCurrentModX()),e.numOpenGroups++,n===`(`&&!e.captureGroup||n===`(?:`)return{token:ef(`group`,n)};if(n===`(?>`)return{token:ef(`atomic`,n)};if(n===`(?=`||n===`(?!`||n===`(?<=`||n===`(?<!`)return{token:ef(n[2]===`<`?`lookbehind`:`lookahead`,n,{negate:n.endsWith(`!`)})};if(n===`(`&&e.captureGroup||n.startsWith(`(?<`)&&n.endsWith(`>`)||n.startsWith(`(?'`)&&n.endsWith(`'`))return{token:ef(`capturing`,n,{...n!==`(`&&{name:n.slice(3,-1)}})};if(n.startsWith(`(?~`)){if(n===`(?~|`)throw Error(`Unsupported absence function kind "${n}"`);return{token:ef(`absence_repeater`,n)}}throw Error(n===`(?(`?`Unsupported conditional "${n}"`:`Invalid or unsupported group option "${n}"`)}if(n===`)`){if(e.popModX(),e.numOpenGroups--,e.numOpenGroups<0)throw Error(`Unmatched ")"`);return{token:$d(n)}}if(e.getCurrentModX()){if(n===`#`){let e=t.indexOf(`
|
|
47
|
+
`,r);return{lastIndex:e===-1?t.length:e}}if(/^\s$/.test(n)){let e=/\s+/y;return e.lastIndex=r,{lastIndex:e.exec(t)?e.lastIndex:r}}}return n===`.`?{token:Xd(`dot`,n)}:n===`^`||n===`$`?{token:Ud(e.singleline?{"^":Ad`\A`,$:Ad`\Z`}[n]:n,n)}:n===`|`?{token:Hd(n)}:Pd.test(n)?{tokens:_f(n)}:{token:Gd(Dd(n),n)}}function zd(e,t,n){let r=[Yd(t[1]===`^`,t)],i=1,a;for(Id.lastIndex=n;a=Id.exec(e);){let e=a[0];if(e[0]===`[`&&e[1]!==`:`)i++,r.push(Yd(e[1]===`^`,e));else if(e===`]`){if(r.at(-1).type===`CharacterClassOpen`)r.push(Gd(93,e));else if(i--,r.push(Kd(e)),!i)break}else{let t=Bd(e);Array.isArray(t)?r.push(...t):r.push(t)}}return{tokens:r,lastIndex:Id.lastIndex||e.length}}function Bd(e){if(e[0]===`\\`)return Vd(e,{inCharClass:!0});if(e[0]===`[`){let t=/\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(e);if(!t||!kd.has(t.groups.name))throw Error(`Invalid POSIX class "${e}"`);return Xd(`posix`,e,{value:t.groups.name,negate:!!t.groups.negate})}return e===`-`?qd(e):e===`&&`?Jd(e):Gd(Dd(e),e)}function Vd(e,{inCharClass:t}){let n=e[1];if(n===`c`||n===`C`)return sf(e);if(`dDhHsSwW`.includes(n))return df(e);if(e.startsWith(Ad`\o{`))throw Error(`Incomplete, invalid, or unsupported octal code point "${e}"`);if(/^\\[pP]\{/.test(e)){if(e.length===3)throw Error(`Incomplete or invalid Unicode property "${e}"`);return ff(e)}if(/^\\x[89A-Fa-f]\p{AHex}/u.test(e))try{let t=e.split(/\\x/).slice(1).map(e=>parseInt(e,16)),n=new TextDecoder(`utf-8`,{ignoreBOM:!0,fatal:!0}).decode(new Uint8Array(t)),r=new TextEncoder;return[...n].map(e=>{let t=[...r.encode(e)].map(e=>`\\x${e.toString(16)}`).join(``);return Gd(Dd(e),t)})}catch{throw Error(`Multibyte code "${e}" incomplete or invalid in Oniguruma`)}if(n===`u`||n===`x`)return Gd(hf(e),e);if(of.has(n))return Gd(of.get(n),e);if(/\d/.test(n))return Qd(t,e);if(e===`\\`)throw Error(Ad`Incomplete escape "\"`);if(n===`M`)throw Error(`Unsupported meta "${e}"`);if([...e].length===2)return Gd(e.codePointAt(1),e);throw Error(`Unexpected escape "${e}"`)}function Hd(e){return{type:`Alternator`,raw:e}}function Ud(e,t){return{type:`Assertion`,kind:e,raw:t}}function Wd(e){return{type:`Backreference`,raw:e}}function Gd(e,t){return{type:`Character`,value:e,raw:t}}function Kd(e){return{type:`CharacterClassClose`,raw:e}}function qd(e){return{type:`CharacterClassHyphen`,raw:e}}function Jd(e){return{type:`CharacterClassIntersector`,raw:e}}function Yd(e,t){return{type:`CharacterClassOpen`,negate:e,raw:t}}function Xd(e,t,n={}){return{type:`CharacterSet`,kind:e,...n,raw:t}}function Zd(e,t,n={}){return e===`keep`?{type:`Directive`,kind:e,raw:t}:{type:`Directive`,kind:e,flags:jd(n.flags),raw:t}}function Qd(e,t){return{type:`EscapedNumber`,inCharClass:e,raw:t}}function $d(e){return{type:`GroupClose`,raw:e}}function ef(e,t,n={}){return{type:`GroupOpen`,kind:e,...n,raw:t}}function tf(e,t,n,r){return{type:`NamedCallout`,kind:e,tag:t,arguments:n,raw:r}}function nf(e,t,n,r){return{type:`Quantifier`,kind:e,min:t,max:n,raw:r}}function rf(e){return{type:`Subroutine`,raw:e}}var af=new Set([`COUNT`,`CMP`,`ERROR`,`FAIL`,`MAX`,`MISMATCH`,`SKIP`,`TOTAL_COUNT`]),of=new Map([[`a`,7],[`b`,8],[`e`,27],[`f`,12],[`n`,10],[`r`,13],[`t`,9],[`v`,11]]);function sf(e){let t=e[1]===`c`?e[2]:e[3];if(!t||!/[A-Za-z]/.test(t))throw Error(`Unsupported control character "${e}"`);return Gd(Dd(t.toUpperCase())-64,e)}function cf(e,t){let{on:n,off:r}=/^\(\?(?<on>[imx]*)(?:-(?<off>[-imx]*))?/.exec(e).groups;r??=``;let i=(t.getCurrentModX()||n.includes(`x`))&&!r.includes(`x`),a=pf(n),o=pf(r),s={};if(a&&(s.enable=a),o&&(s.disable=o),e.endsWith(`)`))return t.replaceCurrentModX(i),Zd(`flags`,e,{flags:s});if(e.endsWith(`:`))return t.pushModX(i),t.numOpenGroups++,ef(`group`,e,{...(a||o)&&{flags:s}});throw Error(`Unexpected flag modifier "${e}"`)}function lf(e){let t=/\(\*(?<name>[A-Za-z_]\w*)?(?:\[(?<tag>(?:[A-Za-z_]\w*)?)\])?(?:\{(?<args>[^}]*)\})?\)/.exec(e);if(!t)throw Error(`Incomplete or invalid named callout "${e}"`);let{name:n,tag:r,args:i}=t.groups;if(!n)throw Error(`Invalid named callout "${e}"`);if(r===``)throw Error(`Named callout tag with empty value not allowed "${e}"`);let a=i?i.split(`,`).filter(e=>e!==``).map(e=>/^[+-]?\d+$/.test(e)?+e:e):[],[o,s,c]=a,l=af.has(n)?n.toLowerCase():`custom`;switch(l){case`fail`:case`mismatch`:case`skip`:if(a.length>0)throw Error(`Named callout arguments not allowed "${a}"`);break;case`error`:if(a.length>1)throw Error(`Named callout allows only one argument "${a}"`);if(typeof o==`string`)throw Error(`Named callout argument must be a number "${o}"`);break;case`max`:if(!a.length||a.length>2)throw Error(`Named callout must have one or two arguments "${a}"`);if(typeof o==`string`&&!/^[A-Za-z_]\w*$/.test(o))throw Error(`Named callout argument one must be a tag or number "${o}"`);if(a.length===2&&(typeof s==`number`||!/^[<>X]$/.test(s)))throw Error(`Named callout optional argument two must be '<', '>', or 'X' "${s}"`);break;case`count`:case`total_count`:if(a.length>1)throw Error(`Named callout allows only one argument "${a}"`);if(a.length===1&&(typeof o==`number`||!/^[<>X]$/.test(o)))throw Error(`Named callout optional argument must be '<', '>', or 'X' "${o}"`);break;case`cmp`:if(a.length!==3)throw Error(`Named callout must have three arguments "${a}"`);if(typeof o==`string`&&!/^[A-Za-z_]\w*$/.test(o))throw Error(`Named callout argument one must be a tag or number "${o}"`);if(typeof s==`number`||!/^(?:[<>!=]=|[<>])$/.test(s))throw Error(`Named callout argument two must be '==', '!=', '>', '<', '>=', or '<=' "${s}"`);if(typeof c==`string`&&!/^[A-Za-z_]\w*$/.test(c))throw Error(`Named callout argument three must be a tag or number "${c}"`);break;case`custom`:throw Error(`Undefined callout name "${n}"`);default:throw Error(`Unexpected named callout kind "${l}"`)}return tf(l,r??null,i?.split(`,`)??null,e)}function uf(e){let t=null,n,r;if(e[0]===`{`){let{minStr:i,maxStr:a}=/^\{(?<minStr>\d*)(?:,(?<maxStr>\d*))?/.exec(e).groups,o=1e5;if(+i>o||a&&+a>o)throw Error(`Quantifier value unsupported in Oniguruma`);if(n=+i,r=a===void 0?+i:a===``?1/0:+a,n>r&&(t=`possessive`,[n,r]=[r,n]),e.endsWith(`?`)){if(t===`possessive`)throw Error(`Unsupported possessive interval quantifier chain with "?"`);t=`lazy`}else t||=`greedy`}else n=+(e[0]===`+`),r=e[0]===`?`?1:1/0,t=e[1]===`+`?`possessive`:e[1]===`?`?`lazy`:`greedy`;return nf(t,n,r,e)}function df(e){let t=e[1].toLowerCase();return Xd({d:`digit`,h:`hex`,s:`space`,w:`word`}[t],e,{negate:e[1]!==t})}function ff(e){let{p:t,neg:n,value:r}=/^\\(?<p>[pP])\{(?<neg>\^?)(?<value>[^}]+)/.exec(e).groups;return Xd(`property`,e,{value:r,negate:t===`P`&&!n||t===`p`&&!!n})}function pf(e){let t={};return e.includes(`i`)&&(t.ignoreCase=!0),e.includes(`m`)&&(t.dotAll=!0),e.includes(`x`)&&(t.extended=!0),Object.keys(t).length?t:null}function mf(e){let t={ignoreCase:!1,dotAll:!1,extended:!1,digitIsAscii:!1,posixIsAscii:!1,spaceIsAscii:!1,wordIsAscii:!1,textSegmentMode:null};for(let n=0;n<e.length;n++){let r=e[n];if(!`imxDPSWy`.includes(r))throw Error(`Invalid flag "${r}"`);if(r===`y`){if(!/^y{[gw]}/.test(e.slice(n)))throw Error(`Invalid or unspecified flag "y" mode`);t.textSegmentMode=e[n+2]===`g`?`grapheme`:`word`,n+=3;continue}t[{i:`ignoreCase`,m:`dotAll`,x:`extended`,D:`digitIsAscii`,P:`posixIsAscii`,S:`spaceIsAscii`,W:`wordIsAscii`}[r]]=!0}return t}function hf(e){if(/^(?:\\u(?!\p{AHex}{4})|\\x(?!\p{AHex}{1,2}|\{\p{AHex}{1,8}\}))/u.test(e))throw Error(`Incomplete or invalid escape "${e}"`);let t=e[2]===`{`?/^\\x\{\s*(?<hex>\p{AHex}+)/u.exec(e).groups.hex:e.slice(2);return parseInt(t,16)}function gf(e,t){let{raw:n,inCharClass:r}=e,i=n.slice(1);if(!r&&(i!==`0`&&i.length===1||i[0]!==`0`&&+i<=t))return[Wd(n)];let a=[],o=i.match(/^[0-7]+|\d/g);for(let e=0;e<o.length;e++){let t=o[e],r;if(e===0&&t!==`8`&&t!==`9`){if(r=parseInt(t,8),r>127)throw Error(Ad`Octal encoded byte above 177 unsupported "${n}"`)}else r=Dd(t);a.push(Gd(r,(e===0?`\\`:``)+t))}return a}function _f(e){let t=[],n=new RegExp(Pd,`gy`),r;for(;r=n.exec(e);){let e=r[0];if(e[0]===`{`){let r=/^\{(?<min>\d+),(?<max>\d+)\}\??$/.exec(e);if(r){let{min:i,max:a}=r.groups;if(+i>+a&&e.endsWith(`?`)){n.lastIndex--,t.push(uf(e.slice(0,-1)));continue}}}t.push(uf(e))}return t}function vf(e,t){if(!Array.isArray(e.body))throw Error(`Expected node with body array`);if(e.body.length!==1)return!1;let n=e.body[0];return!t||Object.keys(t).every(e=>t[e]===n[e])}function yf(e){return bf.has(e.type)}var bf=new Set([`AbsenceFunction`,`Backreference`,`CapturingGroup`,`Character`,`CharacterClass`,`CharacterSet`,`Group`,`Quantifier`,`Subroutine`]);function xf(e,t={}){let n={flags:``,normalizeUnknownPropertyNames:!1,skipBackrefValidation:!1,skipLookbehindValidation:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t,rules:{captureGroup:!1,singleline:!1,...t.rules}},r=Ld(e,{flags:n.flags,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline}}),i=(e,t)=>{let n=r.tokens[a.nextIndex];switch(a.parent=e,a.nextIndex++,n.type){case`Alternator`:return jf();case`Assertion`:return Sf(n);case`Backreference`:return Cf(n,a);case`Character`:return Ff(n.value,{useLastValid:!!t.isCheckingRangeEnd});case`CharacterClassHyphen`:return wf(n,a,t);case`CharacterClassOpen`:return Tf(n,a,t);case`CharacterSet`:return Ef(n,a);case`Directive`:return zf(n.kind,{flags:n.flags});case`GroupOpen`:return Df(n,a,t);case`NamedCallout`:return Uf(n.kind,n.tag,n.arguments);case`Quantifier`:return Of(n,a);case`Subroutine`:return kf(n,a);default:throw Error(`Unexpected token type "${n.type}"`)}},a={capturingGroups:[],hasNumberedRef:!1,namedGroupsByName:new Map,nextIndex:0,normalizeUnknownPropertyNames:n.normalizeUnknownPropertyNames,parent:null,skipBackrefValidation:n.skipBackrefValidation,skipLookbehindValidation:n.skipLookbehindValidation,skipPropertyNameValidation:n.skipPropertyNameValidation,subroutines:[],tokens:r.tokens,unicodePropertyMap:n.unicodePropertyMap,walk:i},o=Kf(Bf(r.flags)),s=o.body[0];for(;a.nextIndex<r.tokens.length;){let e=i(s,{});e.type===`Alternative`?(o.body.push(e),s=e):s.body.push(e)}let{capturingGroups:c,hasNumberedRef:l,namedGroupsByName:u,subroutines:d}=a;if(l&&u.size&&!n.rules.captureGroup)throw Error(`Numbered backref/subroutine not allowed when using named capture`);for(let{ref:e}of d)if(typeof e==`number`){if(e>c.length)throw Error(`Subroutine uses a group number that's not defined`);e&&(c[e-1].isSubroutined=!0)}else if(u.has(e)){if(u.get(e).length>1)throw Error(Ad`Subroutine uses a duplicate group name "\g<${e}>"`);u.get(e)[0].isSubroutined=!0}else throw Error(Ad`Subroutine uses a group name that's not defined "\g<${e}>"`);return o}function Sf({kind:e}){return Mf(jd({"^":`line_start`,$:`line_end`,"\\A":`string_start`,"\\b":`word_boundary`,"\\B":`word_boundary`,"\\G":`search_start`,"\\y":`text_segment_boundary`,"\\Y":`text_segment_boundary`,"\\z":`string_end`,"\\Z":`string_end_newline`}[e],`Unexpected assertion kind "${e}"`),{negate:e===Ad`\B`||e===Ad`\Y`})}function Cf({raw:e},t){let n=/^\\k[<']/.test(e),r=n?e.slice(3,-1):e.slice(1),i=(n,r=!1)=>{let i=t.capturingGroups.length,a=!1;if(n>i)if(t.skipBackrefValidation)a=!0;else throw Error(`Not enough capturing groups defined to the left "${e}"`);return t.hasNumberedRef=!0,Nf(r?i+1-n:n,{orphan:a})};if(n){let n=/^(?<sign>-?)0*(?<num>[1-9]\d*)$/.exec(r);if(n)return i(+n.groups.num,!!n.groups.sign);if(/[-+]/.test(r))throw Error(`Invalid backref name "${e}"`);if(!t.namedGroupsByName.has(r))throw Error(`Group name not defined to the left "${e}"`);return Nf(r)}return i(+r)}function wf(e,t,n){let{tokens:r,walk:i}=t,a=t.parent,o=a.body.at(-1),s=r[t.nextIndex];if(!n.isCheckingRangeEnd&&o&&o.type!==`CharacterClass`&&o.type!==`CharacterClassRange`&&s&&s.type!==`CharacterClassOpen`&&s.type!==`CharacterClassClose`&&s.type!==`CharacterClassIntersector`){let e=i(a,{...n,isCheckingRangeEnd:!0});if(o.type===`Character`&&e.type===`Character`)return a.body.pop(),Lf(o,e);throw Error(`Invalid character class range`)}return Ff(Dd(`-`))}function Tf({negate:e},t,n){let{tokens:r,walk:i}=t,a=[If()],o=r[t.nextIndex],s=rp(o);for(;s.type!==`CharacterClassClose`;){if(s.type===`CharacterClassIntersector`)a.push(If()),t.nextIndex++;else{let e=a.at(-1);e.body.push(i(e,n))}s=rp(r[t.nextIndex],o)}let c=If({negate:e});return a.length===1?c.body=a[0].body:(c.kind=`intersection`,c.body=a.map(e=>e.body.length===1?e.body[0]:e)),t.nextIndex++,c}function Ef({kind:e,negate:t,value:n},r){let{normalizeUnknownPropertyNames:i,skipPropertyNameValidation:a,unicodePropertyMap:o}=r;if(e===`property`){let r=np(n);if(kd.has(r)&&!o?.has(r))e=`posix`,n=r;else return Jf(n,{negate:t,normalizeUnknownPropertyNames:i,skipPropertyNameValidation:a,unicodePropertyMap:o})}return e===`posix`?Wf(n,{negate:t}):Rf(e,{negate:t})}function Df(e,t,n){let{tokens:r,capturingGroups:i,namedGroupsByName:a,skipLookbehindValidation:o,walk:s}=t,c=Yf(e),l=c.type===`AbsenceFunction`,u=$f(c),d=u&&c.negate;if(c.type===`CapturingGroup`&&(i.push(c),c.name&&Od(a,c.name,[]).push(c)),l&&n.isInAbsenceFunction)throw Error(`Nested absence function not supported by Oniguruma`);let f=ip(r[t.nextIndex]);for(;f.type!==`GroupClose`;){if(f.type===`Alternator`)c.body.push(jf()),t.nextIndex++;else{let e=c.body.at(-1),t=s(e,{...n,isInAbsenceFunction:n.isInAbsenceFunction||l,isInLookbehind:n.isInLookbehind||u,isInNegLookbehind:n.isInNegLookbehind||d});if(e.body.push(t),(u||n.isInLookbehind)&&!o){let e=`Lookbehind includes a pattern not allowed by Oniguruma`;if(d||n.isInNegLookbehind){if(Qf(t)||t.type===`CapturingGroup`)throw Error(e)}else if(Qf(t)||$f(t)&&t.negate)throw Error(e)}}f=ip(r[t.nextIndex])}return t.nextIndex++,c}function Of({kind:e,min:t,max:n},r){let i=r.parent,a=i.body.at(-1);if(!a||!yf(a))throw Error(`Quantifier requires a repeatable token`);let o=Gf(e,t,n,a);return i.body.pop(),o}function kf({raw:e},t){let{capturingGroups:n,subroutines:r}=t,i=e.slice(3,-1),a=/^(?<sign>[-+]?)0*(?<num>[1-9]\d*)$/.exec(i);if(a){let e=+a.groups.num,r=n.length;if(t.hasNumberedRef=!0,i={"":e,"+":r+e,"-":r+1-e}[a.groups.sign],i<1)throw Error(`Invalid subroutine number`)}else i===`0`&&(i=0);let o=qf(i);return r.push(o),o}function Af(e,t){if(e!==`repeater`)throw Error(`Unexpected absence function kind "${e}"`);return{type:`AbsenceFunction`,kind:e,body:Xf(t?.body)}}function jf(e){return{type:`Alternative`,body:Zf(e?.body)}}function Mf(e,t){let n={type:`Assertion`,kind:e};return(e===`word_boundary`||e===`text_segment_boundary`)&&(n.negate=!!t?.negate),n}function Nf(e,t){let n=!!t?.orphan;return{type:`Backreference`,ref:e,...n&&{orphan:n}}}function Pf(e,t){let n={name:void 0,isSubroutined:!1,...t};if(n.name!==void 0&&!ep(n.name))throw Error(`Group name "${n.name}" invalid in Oniguruma`);return{type:`CapturingGroup`,number:e,...n.name&&{name:n.name},...n.isSubroutined&&{isSubroutined:n.isSubroutined},body:Xf(t?.body)}}function Ff(e,t){let n={useLastValid:!1,...t};if(e>1114111){let t=e.toString(16);if(n.useLastValid)e=1114111;else throw Error(e>1310719?`Invalid code point out of range "\\x{${t}}"`:`Invalid code point out of range in JS "\\x{${t}}"`)}return{type:`Character`,value:e}}function If(e){let t={kind:`union`,negate:!1,...e};return{type:`CharacterClass`,kind:t.kind,negate:t.negate,body:Zf(e?.body)}}function Lf(e,t){if(t.value<e.value)throw Error(`Character class range out of order`);return{type:`CharacterClassRange`,min:e,max:t}}function Rf(e,t){let n=!!t?.negate,r={type:`CharacterSet`,kind:e};return(e===`digit`||e===`hex`||e===`newline`||e===`space`||e===`word`)&&(r.negate=n),(e===`text_segment`||e===`newline`&&!n)&&(r.variableLength=!0),r}function zf(e,t={}){if(e===`keep`)return{type:`Directive`,kind:e};if(e===`flags`)return{type:`Directive`,kind:e,flags:jd(t.flags)};throw Error(`Unexpected directive kind "${e}"`)}function Bf(e){return{type:`Flags`,...e}}function Vf(e){let t=e?.atomic,n=e?.flags;if(t&&n)throw Error(`Atomic group cannot have flags`);return{type:`Group`,...t&&{atomic:t},...n&&{flags:n},body:Xf(e?.body)}}function Hf(e){let t={behind:!1,negate:!1,...e};return{type:`LookaroundAssertion`,kind:t.behind?`lookbehind`:`lookahead`,negate:t.negate,body:Xf(e?.body)}}function Uf(e,t,n){return{type:`NamedCallout`,kind:e,tag:t,arguments:n}}function Wf(e,t){let n=!!t?.negate;if(!kd.has(e))throw Error(`Invalid POSIX class "${e}"`);return{type:`CharacterSet`,kind:`posix`,value:e,negate:n}}function Gf(e,t,n,r){if(t>n)throw Error(`Invalid reversed quantifier range`);return{type:`Quantifier`,kind:e,min:t,max:n,body:r}}function Kf(e,t){return{type:`Regex`,body:Xf(t?.body),flags:e}}function qf(e){return{type:`Subroutine`,ref:e}}function Jf(e,t){let n={negate:!1,normalizeUnknownPropertyNames:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t},r=n.unicodePropertyMap?.get(np(e));if(!r){if(n.normalizeUnknownPropertyNames)r=tp(e);else if(n.unicodePropertyMap&&!n.skipPropertyNameValidation)throw Error(Ad`Invalid Unicode property "\p{${e}}"`)}return{type:`CharacterSet`,kind:`property`,value:r??e,negate:n.negate}}function Yf({flags:e,kind:t,name:n,negate:r,number:i}){switch(t){case`absence_repeater`:return Af(`repeater`);case`atomic`:return Vf({atomic:!0});case`capturing`:return Pf(i,{name:n});case`group`:return Vf({flags:e});case`lookahead`:case`lookbehind`:return Hf({behind:t===`lookbehind`,negate:r});default:throw Error(`Unexpected group kind "${t}"`)}}function Xf(e){if(e===void 0)e=[jf()];else if(!Array.isArray(e)||!e.length||!e.every(e=>e.type===`Alternative`))throw Error(`Invalid body; expected array of one or more Alternative nodes`);return e}function Zf(e){if(e===void 0)e=[];else if(!Array.isArray(e)||!e.every(e=>!!e.type))throw Error(`Invalid body; expected array of nodes`);return e}function Qf(e){return e.type===`LookaroundAssertion`&&e.kind===`lookahead`}function $f(e){return e.type===`LookaroundAssertion`&&e.kind===`lookbehind`}function ep(e){return/^[\p{Alpha}\p{Pc}][^)]*$/u.test(e)}function tp(e){return e.trim().replace(/[- _]+/g,`_`).replace(/[A-Z][a-z]+(?=[A-Z])/g,`$&_`).replace(/[A-Za-z]+/g,e=>e[0].toUpperCase()+e.slice(1).toLowerCase())}function np(e){return e.replace(/[- _]+/g,``).toLowerCase()}function rp(e,t){let n=t;return jd(e,`Unclosed character class${n?.type===`Character`&&n.value===93&&n.raw===`]`?` (started with "]")`:``}`)}function ip(e){return jd(e,`Unclosed group`)}function ap(e,t,n=null){function r(e,t){for(let n=0;n<e.length;n++){let r=i(e[n],t,n,e);n=Math.max(-1,n+r)}}function i(a,o=null,s=null,c=null){let l=0,u=!1,d={node:a,parent:o,key:s,container:c,root:e,remove(){op(c).splice(Math.max(0,sp(s)+l),1),l--,u=!0},removeAllNextSiblings(){return op(c).splice(sp(s)+1)},removeAllPrevSiblings(){let e=sp(s)+l;return l-=e,op(c).splice(0,Math.max(0,e))},replaceWith(e,t={}){let n=!!t.traverse;c?c[Math.max(0,sp(s)+l)]=e:jd(o,`Can't replace root node`)[s]=e,n&&i(e,o,s,c),u=!0},replaceWithMultiple(e,t={}){let n=!!t.traverse;if(op(c).splice(Math.max(0,sp(s)+l),1,...e),l+=e.length-1,n){let t=0;for(let n=0;n<e.length;n++)t+=i(e[n],o,sp(s)+n+t,c)}u=!0},skip(){u=!0}},{type:f}=a,p=t[`*`],m=t[f],h=typeof p==`function`?p:p?.enter,g=typeof m==`function`?m:m?.enter;if(h?.(d,n),g?.(d,n),!u)switch(f){case`AbsenceFunction`:case`Alternative`:case`CapturingGroup`:case`CharacterClass`:case`Group`:case`LookaroundAssertion`:r(a.body,a);break;case`Assertion`:case`Backreference`:case`Character`:case`CharacterSet`:case`Directive`:case`Flags`:case`NamedCallout`:case`Subroutine`:break;case`CharacterClassRange`:i(a.min,a,`min`),i(a.max,a,`max`);break;case`Quantifier`:i(a.body,a,`body`);break;case`Regex`:r(a.body,a),i(a.flags,a,`flags`);break;default:throw Error(`Unexpected node type "${f}"`)}return m?.exit?.(d,n),p?.exit?.(d,n),l}return i(e),e}function op(e){if(!Array.isArray(e))throw Error(`Container expected`);return e}function sp(e){if(typeof e!=`number`)throw Error(`Numeric key expected`);return e}var cp=String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;function lp(e,t){for(let n=0;n<e.length;n++)e[n]>=t&&e[n]++}function up(e,t,n,r){return e.slice(0,t)+r+e.slice(t+n.length)}var dp=Object.freeze({DEFAULT:`DEFAULT`,CHAR_CLASS:`CHAR_CLASS`});function fp(e,t,n,r){let i=new RegExp(String.raw`${t}|(?<$skip>\[\^?|\\?.)`,`gsu`),a=[!1],o=0,s=``;for(let t of e.matchAll(i)){let{0:e,groups:{$skip:i}}=t;if(!i&&(!r||r===dp.DEFAULT==!o)){n instanceof Function?s+=n(t,{context:o?dp.CHAR_CLASS:dp.DEFAULT,negated:a[a.length-1]}):s+=n;continue}e[0]===`[`?(o++,a.push(e[1]===`^`)):e===`]`&&o&&(o--,a.pop()),s+=e}return s}function pp(e,t,n,r){fp(e,t,n,r)}function mp(e,t,n=0,r){if(!new RegExp(t,`su`).test(e))return null;let i=RegExp(`${t}|(?<$skip>\\\\?.)`,`gsu`);i.lastIndex=n;let a=0,o;for(;o=i.exec(e);){let{0:e,groups:{$skip:t}}=o;if(!t&&(!r||r===dp.DEFAULT==!a))return o;e===`[`?a++:e===`]`&&a&&a--,i.lastIndex==o.index&&i.lastIndex++}return null}function hp(e,t,n){return!!mp(e,t,0,n)}function gp(e,t){let n=/\\?./gsu;n.lastIndex=t;let r=e.length,i=0,a=1,o;for(;o=n.exec(e);){let[e]=o;if(e===`[`)i++;else if(i)e===`]`&&i--;else if(e===`(`)a++;else if(e===`)`&&(a--,!a)){r=o.index;break}}return e.slice(t,r)}var _p=new RegExp(String.raw`(?<noncapturingStart>${cp})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`,`gsu`);function vp(e,t){let n=t?.hiddenCaptures??[],r=t?.captureTransfers??new Map;if(!/\(\?>/.test(e))return{pattern:e,captureTransfers:r,hiddenCaptures:n};let i=[0],a=[],o=0,s=0,c=NaN,l;do{l=!1;let t=0,u=0,d=!1,f;for(_p.lastIndex=Number.isNaN(c)?0:c+7;f=_p.exec(e);){let{0:p,index:m,groups:{capturingStart:h,noncapturingStart:g}}=f;if(p===`[`)t++;else if(t)p===`]`&&t--;else if(p===`(?>`&&!d)c=m,d=!0;else if(d&&g)u++;else if(h)d?u++:(o++,i.push(o+s));else if(p===`)`&&d){if(!u){s++;let t=o+s;if(e=`${e.slice(0,c)}(?:(?=(${e.slice(c+3,m)}))<$$${t}>)${e.slice(m+1)}`,l=!0,a.push(t),lp(n,t),r.size){let e=new Map;r.forEach((n,r)=>{e.set(r>=t?r+1:r,n.map(e=>e>=t?e+1:e))}),r=e}break}u--}}}while(l);return n.push(...a),e=fp(e,String.raw`\\(?<backrefNum>[1-9]\d*)|<\$\$(?<wrappedBackrefNum>\d+)>`,({0:e,groups:{backrefNum:t,wrappedBackrefNum:n}})=>{if(t){let n=+t;if(n>i.length-1)throw Error(`Backref "${e}" greater than number of captures`);return`\\${i[n]}`}return`\\${n}`},dp.DEFAULT),{pattern:e,captureTransfers:r,hiddenCaptures:n}}var yp=String.raw`(?:[?*+]|\{\d+(?:,\d*)?\})`,bp=new RegExp(String.raw`
|
|
48
48
|
\\(?: \d+
|
|
49
49
|
| c[A-Za-z]
|
|
50
50
|
| [gk]<[^>]+>
|
|
@@ -57,9 +57,9 @@ import{a as e,c as t,d as n,i as r,l as i,o as a,r as o,s,t as c,u as l}from"./p
|
|
|
57
57
|
| [A-Za-z\-]+:
|
|
58
58
|
| \(DEFINE\)
|
|
59
59
|
))?
|
|
60
|
-
| (?<qBase>${
|
|
60
|
+
| (?<qBase>${yp})(?<qMod>[?+]?)(?<invalidQ>[?*+\{]?)
|
|
61
61
|
| \\?.
|
|
62
|
-
`.replace(/\s+/g,``),`gsu`);function
|
|
62
|
+
`.replace(/\s+/g,``),`gsu`);function xp(e){if(!RegExp(`${yp}\\+`).test(e))return{pattern:e};let t=[],n=null,r=null,i=``,a=0,o;for(bp.lastIndex=0;o=bp.exec(e);){let{0:s,index:c,groups:{qBase:l,qMod:u,invalidQ:d}}=o;if(s===`[`)a||(r=c),a++;else if(s===`]`)a?a--:r=null;else if(!a)if(u===`+`&&i&&!i.startsWith(`(`)){if(d)throw Error(`Invalid quantifier "${s}"`);let t=-1;if(/^\{\d+\}$/.test(l))e=up(e,c+l.length,u,``);else{if(i===`)`||i===`]`){let t=i===`)`?n:r;if(t===null)throw Error(`Invalid unmatched "${i}"`);e=`${e.slice(0,t)}(?>${e.slice(t,c)}${l})${e.slice(c+s.length)}`}else e=`${e.slice(0,c-i.length)}(?>${i}${l})${e.slice(c+s.length)}`;t+=4}bp.lastIndex+=t}else s[0]===`(`?t.push(c):s===`)`&&(n=t.length?t.pop():null);i=s}return{pattern:e}}var Sp=String.raw,Cp=Sp`\(\?R=(?<rDepth>[^\)]+)\)|${Sp`\\g<(?<gRNameOrNum>[^>&]+)&R=(?<gRDepth>[^>]+)>`}`,wp=Sp`\(\?<(?![=!])(?<captureName>[^>]+)>`,Tp=Sp`${wp}|(?<unnamed>\()(?!\?)`,Ep=new RegExp(Sp`${wp}|${Cp}|\(\?|\\?.`,`gsu`),Dp=`Cannot use multiple overlapping recursions`;function Op(e,t){let{hiddenCaptures:n,mode:r}={hiddenCaptures:[],mode:`plugin`,...t},i=t?.captureTransfers??new Map;if(!new RegExp(Cp,`su`).test(e))return{pattern:e,captureTransfers:i,hiddenCaptures:n};if(r===`plugin`&&hp(e,Sp`\(\?\(DEFINE\)`,dp.DEFAULT))throw Error(`DEFINE groups cannot be used with recursion`);let a=[],o=hp(e,Sp`\\[1-9]`,dp.DEFAULT),s=new Map,c=[],l=!1,u=0,d=0,f;for(Ep.lastIndex=0;f=Ep.exec(e);){let{0:t,groups:{captureName:p,rDepth:m,gRNameOrNum:h,gRDepth:g}}=f;if(t===`[`)u++;else if(u)t===`]`&&u--;else if(m){if(kp(m),l)throw Error(Dp);if(o)throw Error(`${r===`external`?`Backrefs`:`Numbered backrefs`} cannot be used with global recursion`);let t=e.slice(0,f.index),s=e.slice(Ep.lastIndex);if(hp(s,Cp,dp.DEFAULT))throw Error(Dp);let c=m-1;e=Ap(t,s,c,!1,n,a,d),i=Np(i,t,c,a.length,0,d);break}else if(h){kp(g);let u=!1;for(let e of c)if(e.name===h||e.num===+h){if(u=!0,e.hasRecursedWithin)throw Error(Dp);break}if(!u)throw Error(Sp`Recursive \g cannot be used outside the referenced group "${r===`external`?h:Sp`\g<${h}&R=${g}>`}"`);let p=s.get(h),m=gp(e,p);if(o&&hp(m,Sp`${wp}|\((?!\?)`,dp.DEFAULT))throw Error(`${r===`external`?`Backrefs`:`Numbered backrefs`} cannot be used with recursion of capturing groups`);let _=e.slice(p,f.index),v=m.slice(_.length+t.length),y=a.length,b=g-1,x=Ap(_,v,b,!0,n,a,d);i=Np(i,_,b,a.length-y,y,d),e=`${e.slice(0,p)}${x}${e.slice(p+m.length)}`,Ep.lastIndex+=x.length-t.length-_.length-v.length,c.forEach(e=>e.hasRecursedWithin=!0),l=!0}else if(p)d++,s.set(String(d),Ep.lastIndex),s.set(p,Ep.lastIndex),c.push({num:d,name:p});else if(t[0]===`(`){let e=t===`(`;e&&(d++,s.set(String(d),Ep.lastIndex)),c.push(e?{num:d}:{})}else t===`)`&&c.pop()}return n.push(...a),{pattern:e,captureTransfers:i,hiddenCaptures:n}}function kp(e){let t=`Max depth must be integer between 2 and 100; used ${e}`;if(!/^[1-9]\d*$/.test(e)||(e=+e,e<2||e>100))throw Error(t)}function Ap(e,t,n,r,i,a,o){let s=new Set;r&&pp(e+t,wp,({groups:{captureName:e}})=>{s.add(e)},dp.DEFAULT);let c=[n,r?s:null,i,a,o];return`${e}${jp(`(?:${e}`,`forward`,...c)}(?:)${jp(`${t})`,`backward`,...c)}${t}`}function jp(e,t,n,r,i,a,o){let s=e=>t===`forward`?e+2:n-e+2-1,c=``;for(let t=0;t<n;t++){let n=s(t);c+=fp(e,Sp`${Tp}|\\k<(?<backref>[^>]+)>`,({0:e,groups:{captureName:t,unnamed:s,backref:c}})=>{if(c&&r&&!r.has(c))return e;let l=`_$${n}`;if(s||t){let n=o+a.length+1;return a.push(n),Mp(i,n),s?e:`(?<${t}${l}>`}return Sp`\k<${c}${l}>`},dp.DEFAULT)}return c}function Mp(e,t){for(let n=0;n<e.length;n++)e[n]>=t&&e[n]++}function Np(e,t,n,r,i,a){if(e.size&&r){let o=0;pp(t,Tp,()=>o++,dp.DEFAULT);let s=a-o+i,c=new Map;return e.forEach((e,t)=>{let i=(r-o*n)/n,a=o*n,l=t>s+o?t+r:t,u=[];for(let t of e)if(t<=s)u.push(t);else if(t>s+o+i)u.push(t+r);else if(t<=s+o)for(let e=0;e<=n;e++)u.push(t+o*e);else for(let e=0;e<=n;e++)u.push(t+a+i*e);c.set(l,u)}),c}return e}var Pp=String.fromCodePoint,B=String.raw,Fp={},Ip=globalThis.RegExp;Fp.flagGroups=(()=>{try{new Ip(`(?i:)`)}catch{return!1}return!0})(),Fp.unicodeSets=(()=>{try{new Ip(`[[]]`,`v`)}catch{return!1}return!0})(),Fp.bugFlagVLiteralHyphenIsRange=Fp.unicodeSets?(()=>{try{new Ip(B`[\d\-a]`,`v`)}catch{return!0}return!1})():!1,Fp.bugNestedClassIgnoresNegation=Fp.unicodeSets&&new Ip(`[[^a]]`,`v`).test(`a`);function Lp(e,{enable:t,disable:n}){return{dotAll:!n?.dotAll&&!!(t?.dotAll||e.dotAll),ignoreCase:!n?.ignoreCase&&!!(t?.ignoreCase||e.ignoreCase)}}function Rp(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}function zp(e,t){return Vp[e]>=Vp[t]}function Bp(e,t){if(e==null)throw Error(t??`Value expected`);return e}var Vp={ES2025:2025,ES2024:2024,ES2018:2018},Hp={auto:`auto`,ES2025:`ES2025`,ES2024:`ES2024`,ES2018:`ES2018`};function Up(e={}){if({}.toString.call(e)!==`[object Object]`)throw Error(`Unexpected options`);if(e.target!==void 0&&!Hp[e.target])throw Error(`Unexpected target "${e.target}"`);let t={accuracy:`default`,avoidSubclass:!1,flags:``,global:!1,hasIndices:!1,lazyCompileLength:1/0,target:`auto`,verbose:!1,...e,rules:{allowOrphanBackrefs:!1,asciiWordBoundaries:!1,captureGroup:!1,recursionLimit:20,singleline:!1,...e.rules}};return t.target===`auto`&&(t.target=Fp.flagGroups?`ES2025`:Fp.unicodeSets?`ES2024`:`ES2018`),t}var Wp=`[ -\r ]`,Gp=new Set([Pp(304),Pp(305)]),Kp=B`[\p{L}\p{M}\p{N}\p{Pc}]`;function qp(e){if(Gp.has(e))return[e];let t=new Set,n=e.toLowerCase(),r=n.toUpperCase(),i=Zp.get(n),a=Yp.get(n),o=Xp.get(n);return[...r].length===1&&t.add(r),o&&t.add(o),i&&t.add(i),t.add(n),a&&t.add(a),[...t]}var Jp=new Map(`C Other
|
|
63
63
|
Cc Control cntrl
|
|
64
64
|
Cf Format
|
|
65
65
|
Cn Unassigned
|
|
@@ -149,25 +149,25 @@ Uppercase Upper
|
|
|
149
149
|
Variation_Selector VS
|
|
150
150
|
White_Space space
|
|
151
151
|
XID_Continue XIDC
|
|
152
|
-
XID_Start XIDS`.split(/\s/).map(e=>[
|
|
152
|
+
XID_Start XIDS`.split(/\s/).map(e=>[np(e),e])),Yp=new Map([[`s`,Pp(383)],[Pp(383),`s`]]),Xp=new Map([[Pp(223),Pp(7838)],[Pp(107),Pp(8490)],[Pp(229),Pp(8491)],[Pp(969),Pp(8486)]]),Zp=new Map([em(453),em(456),em(459),em(498),...tm(8072,8079),...tm(8088,8095),...tm(8104,8111),em(8124),em(8140),em(8188)]),Qp=new Map([[`alnum`,B`[\p{Alpha}\p{Nd}]`],[`alpha`,B`\p{Alpha}`],[`ascii`,B`\p{ASCII}`],[`blank`,B`[\p{Zs}\t]`],[`cntrl`,B`\p{Cc}`],[`digit`,B`\p{Nd}`],[`graph`,B`[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]`],[`lower`,B`\p{Lower}`],[`print`,B`[[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]\p{Zs}]`],[`punct`,B`[\p{P}\p{S}]`],[`space`,B`\p{space}`],[`upper`,B`\p{Upper}`],[`word`,B`[\p{Alpha}\p{M}\p{Nd}\p{Pc}]`],[`xdigit`,B`\p{AHex}`]]);function $p(e,t){let n=[];for(let r=e;r<=t;r++)n.push(r);return n}function em(e){let t=Pp(e);return[t.toLowerCase(),t]}function tm(e,t){return $p(e,t).map(e=>em(e))}var nm=new Set([`Lower`,`Lowercase`,`Upper`,`Uppercase`,`Ll`,`Lowercase_Letter`,`Lt`,`Titlecase_Letter`,`Lu`,`Uppercase_Letter`]);function rm(e,t){let n={accuracy:`default`,asciiWordBoundaries:!1,avoidSubclass:!1,bestEffortTarget:`ES2025`,...t};sm(e);let r={accuracy:n.accuracy,asciiWordBoundaries:n.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,flagDirectivesByAlt:new Map,jsGroupNameMap:new Map,minTargetEs2024:zp(n.bestEffortTarget,`ES2024`),passedLookbehind:!1,strategy:null,subroutineRefMap:new Map,supportedGNodes:new Set,digitIsAscii:e.flags.digitIsAscii,spaceIsAscii:e.flags.spaceIsAscii,wordIsAscii:e.flags.wordIsAscii};ap(e,im,r);let i={dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},a={currentFlags:i,prevFlags:null,globalFlags:i,groupOriginByCopy:new Map,groupsByName:new Map,multiplexCapturesToLeftByRef:new Map,openRefs:new Map,reffedNodesByReferencer:new Map,subroutineRefMap:r.subroutineRefMap};return ap(e,am,a),ap(e,om,{groupsByName:a.groupsByName,highestOrphanBackref:0,numCapturesToLeft:0,reffedNodesByReferencer:a.reffedNodesByReferencer}),e._originMap=a.groupOriginByCopy,e._strategy=r.strategy,e}var im={AbsenceFunction({node:e,parent:t,replaceWith:n}){let{body:r,kind:i}=e;if(i===`repeater`){let e=Vf();e.body[0].body.push(Hf({negate:!0,body:r}),Jf(`Any`));let i=Vf();i.body[0].body.push(Gf(`greedy`,0,1/0,e)),n(Em(i,t),{traverse:!0})}else throw Error(`Unsupported absence function "(?~|"`)},Alternative:{enter({node:e,parent:t,key:n},{flagDirectivesByAlt:r}){let i=e.body.filter(e=>e.kind===`flags`);for(let e=n+1;e<t.body.length;e++){let n=t.body[e];Rp(r,n,[]).push(...i)}},exit({node:e},{flagDirectivesByAlt:t}){if(t.get(e)?.length){let n=mm(t.get(e));if(n){let t=Vf({flags:n});t.body[0].body=e.body,e.body=[Em(t,e)]}}}},Assertion({node:e,parent:t,key:n,container:r,root:i,remove:a,replaceWith:o},s){let{kind:c,negate:l}=e,{asciiWordBoundaries:u,avoidSubclass:d,supportedGNodes:f,wordIsAscii:p}=s;if(c===`text_segment_boundary`)throw Error(`Unsupported text segment boundary "\\${l?`Y`:`y`}"`);if(c===`line_end`)o(Em(Hf({body:[jf({body:[Mf(`string_end`)]}),jf({body:[Ff(10)]})]}),t));else if(c===`line_start`)o(Em(Cm(B`(?<=\A|\n(?!\z))`,{skipLookbehindValidation:!0}),t));else if(c===`search_start`)if(f.has(e))i.flags.sticky=!0,a();else{let e=r[n-1];if(e&&bm(e))o(Em(Hf({negate:!0}),t));else if(d)throw Error(B`Uses "\G" in a way that requires a subclass`);else o(Tm(Mf(`string_start`),t)),s.strategy=`clip_search`}else if(!(c===`string_end`||c===`string_start`))if(c===`string_end_newline`)o(Em(Cm(B`(?=\n?\z)`),t));else if(c===`word_boundary`){if(!p&&!u){let e=`(?:(?<=${Kp})(?!${Kp})|(?<!${Kp})(?=${Kp}))`,n=`(?:(?<=${Kp})(?=${Kp})|(?<!${Kp})(?!${Kp}))`;o(Em(Cm(l?n:e),t))}}else throw Error(`Unexpected assertion kind "${c}"`)},Backreference({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n==`string`&&!Sm(n)&&(n=pm(n,t),e.ref=n)},CapturingGroup({node:e},{jsGroupNameMap:t,subroutineRefMap:n}){let{name:r}=e;r&&!Sm(r)&&(r=pm(r,t),e.name=r),n.set(e.number,e),r&&n.set(r,e)},CharacterClassRange({node:e,parent:t,replaceWith:n}){t.kind===`intersection`&&n(Em(If({body:[e]}),t),{traverse:!0})},CharacterSet({node:e,parent:t,replaceWith:n},{accuracy:r,minTargetEs2024:i,digitIsAscii:a,spaceIsAscii:o,wordIsAscii:s}){let{kind:c,negate:l,value:u}=e;if(a&&(c===`digit`||u===`digit`)){n(Tm(Rf(`digit`,{negate:l}),t));return}if(o&&(c===`space`||u===`space`)){n(Em(wm(Cm(Wp),l),t));return}if(s&&(c===`word`||u===`word`)){n(Tm(Rf(`word`,{negate:l}),t));return}if(c===`any`)n(Tm(Jf(`Any`),t));else if(c===`digit`)n(Tm(Jf(`Nd`,{negate:l}),t));else if(c!==`dot`)if(c===`text_segment`){if(r===`strict`)throw Error(B`Use of "\X" requires non-strict accuracy`);let e=`\\p{Emoji}(?:\\p{EMod}|\\uFE0F\\u20E3?|[\\x{E0020}-\\x{E007E}]+\\x{E007F})?`,a=B`\p{RI}{2}|${e}(?:\u200D${e})*`;n(Em(Cm(B`(?>\r\n|${i?B`\p{RGI_Emoji}`:a}|\P{M}\p{M}*)`,{skipPropertyNameValidation:!0}),t))}else if(c===`hex`)n(Tm(Jf(`AHex`,{negate:l}),t));else if(c===`newline`)n(Em(Cm(l?`[^
|
|
153
153
|
]`:`(?>\r
|
|
154
154
|
?|[
|
|
155
|
-
\v\f
\u2028\u2029])`),t));else if(c===`posix`)if(!i&&(u===`graph`||u===`print`)){if(r===`strict`)throw Error(`POSIX class "${u}" requires min target ES2024 or non-strict accuracy`);let e={graph:`!-~`,print:` -~`}[u];l&&(e=`\0-${Np(e.codePointAt(0)-1)}${Np(e.codePointAt(2)+1)}-\u{10FFFF}`),n(Tm(Sm(`[${e}]`),t))}else n(Tm(Cm(Sm(Zp.get(u)),l),t));else if(c===`property`)qp.has(tp(u))||(e.key=`sc`);else if(c===`space`)n(wm(qf(`space`,{negate:l}),t));else if(c===`word`)n(Tm(Cm(Sm(Gp),l),t));else throw Error(`Unexpected character set kind "${c}"`)},Directive({node:e,parent:t,root:n,remove:r,replaceWith:i,removeAllPrevSiblings:a,removeAllNextSiblings:o}){let{kind:s,flags:c}=e;if(s===`flags`)if(!c.enable&&!c.disable)r();else{let e=Bf({flags:c});e.body[0].body=o(),i(Tm(e,t),{traverse:!0})}else if(s===`keep`){let e=n.body[0],r=n.body.length===1&&_f(e,{type:`Group`})&&e.body[0].body.length===1?e.body[0]:n;if(t.parent!==r||r.body.length>1)throw Error(B`Uses "\K" in a way that's unsupported`);let o=Vf({behind:!0});o.body[0].body=a(),i(Tm(o,t))}else throw Error(`Unexpected directive kind "${s}"`)},Flags({node:e,parent:t}){if(e.posixIsAscii)throw Error(`Unsupported flag "P"`);if(e.textSegmentMode===`word`)throw Error(`Unsupported flag "y{w}"`);[`digitIsAscii`,`extended`,`posixIsAscii`,`spaceIsAscii`,`wordIsAscii`,`textSegmentMode`].forEach(t=>delete e[t]),Object.assign(e,{global:!1,hasIndices:!1,multiline:!1,sticky:e.sticky??!1}),t.options={disable:{x:!0,n:!0},force:{v:!0}}},Group({node:e}){if(!e.flags)return;let{enable:t,disable:n}=e.flags;t?.extended&&delete t.extended,n?.extended&&delete n.extended,t?.dotAll&&n?.dotAll&&delete t.dotAll,t?.ignoreCase&&n?.ignoreCase&&delete t.ignoreCase,t&&!Object.keys(t).length&&delete e.flags.enable,n&&!Object.keys(n).length&&delete e.flags.disable,!e.flags.enable&&!e.flags.disable&&delete e.flags},LookaroundAssertion({node:e},t){let{kind:n}=e;n===`lookbehind`&&(t.passedLookbehind=!0)},NamedCallout({node:e,parent:t,replaceWith:n}){let{kind:r}=e;if(r===`fail`)n(Tm(Vf({negate:!0}),t));else throw Error(`Unsupported named callout "(*${r.toUpperCase()}"`)},Quantifier({node:e}){if(e.body.type===`Quantifier`){let t=Bf();t.body[0].body.push(e.body),e.body=Tm(t,e)}},Regex:{enter({node:e},{supportedGNodes:t}){let n=[],r=!1,i=!1;for(let t of e.body)if(t.body.length===1&&t.body[0].kind===`search_start`)t.body.pop();else{let e=gm(t.body);e?(r=!0,Array.isArray(e)?n.push(...e):n.push(e)):i=!0}r&&!i&&n.forEach(e=>t.add(e))},exit(e,{accuracy:t,passedLookbehind:n,strategy:r}){if(t===`strict`&&n&&r)throw Error(B`Uses "\G" in a way that requires non-strict accuracy`)}},Subroutine({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n==`string`&&!xm(n)&&(n=fm(n,t),e.ref=n)}},im={Backreference({node:e},{multiplexCapturesToLeftByRef:t,reffedNodesByReferencer:n}){let{orphan:r,ref:i}=e;r||n.set(e,[...t.get(i).map(({node:e})=>e)])},CapturingGroup:{enter({node:e,parent:t,replaceWith:n,skip:r},{groupOriginByCopy:i,groupsByName:a,multiplexCapturesToLeftByRef:o,openRefs:s,reffedNodesByReferencer:c}){let l=i.get(e);if(l&&s.has(e.number)){let r=wm(um(e.number),t);c.set(r,s.get(e.number)),n(r);return}s.set(e.number,e),o.set(e.number,[]),e.name&&Lp(o,e.name,[]);let u=o.get(e.name??e.number);for(let t=0;t<u.length;t++){let n=u[t];if(l===n.node||l&&l===n.origin||e===n.origin){u.splice(t,1);break}}if(o.get(e.number).push({node:e,origin:l}),e.name&&o.get(e.name).push({node:e,origin:l}),e.name){let t=Lp(a,e.name,new Map),n=!1;if(l)n=!0;else for(let e of t.values())if(!e.hasDuplicateNameToRemove){n=!0;break}a.get(e.name).set(e,{node:e,hasDuplicateNameToRemove:n})}},exit({node:e},{openRefs:t}){t.get(e.number)===e&&t.delete(e.number)}},Group:{enter({node:e},t){t.prevFlags=t.currentFlags,e.flags&&(t.currentFlags=Ip(t.currentFlags,e.flags))},exit(e,t){t.currentFlags=t.prevFlags}},Subroutine({node:e,parent:t,replaceWith:n},r){let{isRecursive:i,ref:a}=e;if(i){let n=t;for(;(n=n.parent)&&!(n.type===`CapturingGroup`&&(n.name===a||n.number===a)););r.reffedNodesByReferencer.set(e,n);return}let o=r.subroutineRefMap.get(a),s=a===0,c=s?um(0):lm(o,r.groupOriginByCopy,null),l=c;if(!s){let e=pm(dm(o,e=>e.type===`Group`&&!!e.flags)),t=e?Ip(r.globalFlags,e):r.globalFlags;sm(t,r.currentFlags)||(l=Bf({flags:mm(t)}),l.body[0].body.push(c))}n(Tm(l,t),{traverse:!s})}},am={Backreference({node:e,parent:t,replaceWith:n},r){if(e.orphan){r.highestOrphanBackref=Math.max(r.highestOrphanBackref,e.ref);return}let i=r.reffedNodesByReferencer.get(e).filter(t=>cm(t,e));i.length?i.length>1?n(Tm(Bf({atomic:!0,body:i.reverse().map(e=>Af({body:[Mf(e.number)]}))}),t)):e.ref=i[0].number:n(Tm(Vf({negate:!0}),t))},CapturingGroup({node:e},t){e.number=++t.numCapturesToLeft,e.name&&t.groupsByName.get(e.name).get(e).hasDuplicateNameToRemove&&delete e.name},Regex:{exit({node:e},t){let n=Math.max(t.highestOrphanBackref-t.numCapturesToLeft,0);for(let t=0;t<n;t++){let t=Nf();e.body.at(-1).body.push(t)}}},Subroutine({node:e},t){!e.isRecursive||e.ref===0||(e.ref=t.reffedNodesByReferencer.get(e).number)}};function om(e){ip(e,{"*"({node:e,parent:t}){e.parent=t}})}function sm(e,t){return e.dotAll===t.dotAll&&e.ignoreCase===t.ignoreCase}function cm(e,t){let n=t;do{if(n.type===`Regex`)return!1;if(n.type===`Alternative`)continue;if(n===e)return!1;let t=hm(n.parent);for(let r of t){if(r===n)break;if(r===e||_m(r,e))return!0}}while(n=n.parent);throw Error(`Unexpected path`)}function lm(e,t,n,r){let i=Array.isArray(e)?[]:{};for(let[a,o]of Object.entries(e))a===`parent`?i.parent=Array.isArray(n)?r:n:o&&typeof o==`object`?i[a]=lm(o,t,i,n):(a===`type`&&o===`CapturingGroup`&&t.set(i,t.get(e)??e),i[a]=o);return i}function um(e){let t=Kf(e);return t.isRecursive=!0,t}function dm(e,t){let n=[];for(;e=e.parent;)(!t||t(e))&&n.push(e);return n}function fm(e,t){if(t.has(e))return t.get(e);let n=`$${t.size}_${e.replace(/^[^$_\p{IDS}]|[^$\u200C\u200D\p{IDC}]/gu,`_`)}`;return t.set(e,n),n}function pm(e){let t=[`dotAll`,`ignoreCase`],n={enable:{},disable:{}};return e.forEach(({flags:e})=>{t.forEach(t=>{e.enable?.[t]&&(delete n.disable[t],n.enable[t]=!0),e.disable?.[t]&&(n.disable[t]=!0)})}),Object.keys(n.enable).length||delete n.enable,Object.keys(n.disable).length||delete n.disable,n.enable||n.disable?n:null}function mm({dotAll:e,ignoreCase:t}){let n={};return(e||t)&&(n.enable={},e&&(n.enable.dotAll=!0),t&&(n.enable.ignoreCase=!0)),(!e||!t)&&(n.disable={},!e&&(n.disable.dotAll=!0),!t&&(n.disable.ignoreCase=!0)),n}function hm(e){if(!e)throw Error(`Node expected`);let{body:t}=e;return Array.isArray(t)?t:t?[t]:null}function gm(e){let t=e.find(e=>e.kind===`search_start`||bm(e,{negate:!1})||!vm(e));if(!t)return null;if(t.kind===`search_start`)return t;if(t.type===`LookaroundAssertion`)return t.body[0].body[0];if(t.type===`CapturingGroup`||t.type===`Group`){let e=[];for(let n of t.body){let t=gm(n.body);if(!t)return null;Array.isArray(t)?e.push(...t):e.push(t)}return e}return null}function _m(e,t){let n=hm(e)??[];for(let e of n)if(e===t||_m(e,t))return!0;return!1}function vm({type:e}){return e===`Assertion`||e===`Directive`||e===`LookaroundAssertion`}function ym(e){let t=[`Character`,`CharacterClass`,`CharacterSet`];return t.includes(e.type)||e.type===`Quantifier`&&e.min&&t.includes(e.body.type)}function bm(e,t){let n={negate:null,...t};return e.type===`LookaroundAssertion`&&(n.negate===null||e.negate===n.negate)&&e.body.length===1&&_f(e.body[0],{type:`Assertion`,kind:`search_start`})}function xm(e){return/^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(e)}function Sm(e,t){let n=bf(e,{...t,unicodePropertyMap:qp}).body;return n.length>1||n[0].body.length>1?Bf({body:n}):n[0].body[0]}function Cm(e,t){return e.negate=t,e}function wm(e,t){return e.parent=t,e}function Tm(e,t){return om(e),e.parent=t,e}function Em(e,t){let n=Hp(t),r=Rp(n.target,`ES2024`),i=Rp(n.target,`ES2025`),a=n.rules.recursionLimit;if(!Number.isInteger(a)||a<2||a>20)throw Error(`Invalid recursionLimit; use 2-20`);let o=null,s=null;if(!i){let t=[e.flags.ignoreCase];ip(e,Dm,{getCurrentModI:()=>t.at(-1),popModI(){t.pop()},pushModI(e){t.push(e)},setHasCasedChar(){t.at(-1)?o=!0:s=!0}})}let c={dotAll:e.flags.dotAll,ignoreCase:!!((e.flags.ignoreCase||o)&&!s)},l=e,u={accuracy:n.accuracy,appliedGlobalFlags:c,captureMap:new Map,currentFlags:{dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},inCharClass:!1,lastNode:l,originMap:e._originMap,recursionLimit:a,useAppliedIgnoreCase:!!(!i&&o&&s),useFlagMods:i,useFlagV:r,verbose:n.verbose};function d(e){return u.lastNode=l,l=e,zp(Om[e.type],`Unexpected node type "${e.type}"`)(e,u,d)}let f={pattern:e.body.map(d).join(`|`),flags:d(e.flags),options:{...e.options}};return r||(delete f.options.force.v,f.options.disable.v=!0,f.options.unicodeSetsPlugin=null),f._captureTransfers=new Map,f._hiddenCaptures=[],u.captureMap.forEach((e,t)=>{e.hidden&&f._hiddenCaptures.push(t),e.transferTo&&Lp(f._captureTransfers,e.transferTo,[]).push(t)}),f}var Dm={"*":{enter({node:e},t){if(Bm(e)){let n=t.getCurrentModI();t.pushModI(e.flags?Ip({ignoreCase:n},e.flags).ignoreCase:n)}},exit({node:e},t){Bm(e)&&t.popModI()}},Backreference(e,t){t.setHasCasedChar()},Character({node:e},t){Pm(Np(e.value))&&t.setHasCasedChar()},CharacterClassRange({node:e,skip:t},n){t(),Fm(e,{firstOnly:!0}).length&&n.setHasCasedChar()},CharacterSet({node:e},t){e.kind===`property`&&tm.has(e.value)&&t.setHasCasedChar()}},Om={Alternative({body:e},t,n){return e.map(n).join(``)},Assertion({kind:e,negate:t}){if(e===`string_end`)return`$`;if(e===`string_start`)return`^`;if(e===`word_boundary`)return t?B`\B`:B`\b`;throw Error(`Unexpected assertion kind "${e}"`)},Backreference({ref:e},t){if(typeof e!=`number`)throw Error(`Unexpected named backref in transformed AST`);if(!t.useFlagMods&&t.accuracy===`strict`&&t.currentFlags.ignoreCase&&!t.captureMap.get(e).ignoreCase)throw Error(`Use of case-insensitive backref to case-sensitive group requires target ES2025 or non-strict accuracy`);return`\\`+e},CapturingGroup(e,t,n){let{body:r,name:i,number:a}=e,o={ignoreCase:t.currentFlags.ignoreCase},s=t.originMap.get(e);return s&&(o.hidden=!0,a>s.number&&(o.transferTo=s.number)),t.captureMap.set(a,o),`(${i?`?<${i}>`:``}${r.map(n).join(`|`)})`},Character({value:e},t){let n=Np(e),r=Im(e,{escDigit:t.lastNode.type===`Backreference`,inCharClass:t.inCharClass,useFlagV:t.useFlagV});if(r!==n)return r;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&Pm(n)){let e=Kp(n);return t.inCharClass?e.join(``):e.length>1?`[${e.join(``)}]`:e[0]}return n},CharacterClass(e,t,n){let{kind:r,negate:i,parent:a}=e,{body:o}=e;if(r===`intersection`&&!t.useFlagV)throw Error(`Use of character class intersection requires min target ES2024`);Pp.bugFlagVLiteralHyphenIsRange&&t.useFlagV&&o.some(Hm)&&(o=[Pf(45),...o.filter(e=>!Hm(e))]);let s=()=>`[${i?`^`:``}${o.map(n).join(r===`intersection`?`&&`:``)}]`;if(!t.inCharClass){if((!t.useFlagV||Pp.bugNestedClassIgnoresNegation)&&!i){let t=o.filter(e=>e.type===`CharacterClass`&&e.kind===`union`&&e.negate);if(t.length){let r=Bf(),i=r.body[0];return r.parent=a,i.parent=r,o=o.filter(e=>!t.includes(e)),e.body=o,o.length?(e.parent=i,i.body.push(e)):r.body.pop(),t.forEach(e=>{let t=Af({body:[e]});e.parent=t,t.parent=r,r.body.push(t)}),n(r)}}t.inCharClass=!0;let r=s();return t.inCharClass=!1,r}let c=o[0];if(r===`union`&&!i&&c&&((!t.useFlagV||!t.verbose)&&a.kind===`union`&&!(Pp.bugFlagVLiteralHyphenIsRange&&t.useFlagV)||!t.verbose&&a.kind===`intersection`&&o.length===1&&c.type!==`CharacterClassRange`))return o.map(n).join(``);if(!t.useFlagV&&a.type===`CharacterClass`)throw Error(`Uses nested character class in a way that requires min target ES2024`);return s()},CharacterClassRange(e,t){let n=e.min.value,r=e.max.value,i={escDigit:!1,inCharClass:!0,useFlagV:t.useFlagV},a=Im(n,i),o=Im(r,i),s=new Set;return t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&Lm(Fm(e)).forEach(e=>{s.add(Array.isArray(e)?`${Im(e[0],i)}-${Im(e[1],i)}`:Im(e,i))}),`${a}-${o}${[...s].join(``)}`},CharacterSet({kind:e,negate:t,value:n,key:r},i){if(e===`dot`)return i.currentFlags.dotAll?i.appliedGlobalFlags.dotAll||i.useFlagMods?`.`:`[^]`:B`[^\n]`;if(e===`digit`)return t?B`\D`:B`\d`;if(e===`property`){if(i.useAppliedIgnoreCase&&i.currentFlags.ignoreCase&&tm.has(n))throw Error(`Unicode property "${n}" can't be case-insensitive when other chars have specific case`);return`${t?B`\P`:B`\p`}{${r?`${r}=`:``}${n}}`}if(e===`word`)return t?B`\W`:B`\w`;throw Error(`Unexpected character set kind "${e}"`)},Flags(e,t){return(t.appliedGlobalFlags.ignoreCase?`i`:``)+(e.dotAll?`s`:``)+(e.sticky?`y`:``)},Group({atomic:e,body:t,flags:n,parent:r},i,a){let o=i.currentFlags;n&&(i.currentFlags=Ip(o,n));let s=t.map(a).join(`|`),c=!i.verbose&&t.length===1&&r.type!==`Quantifier`&&!e&&(!i.useFlagMods||!n)?s:`(?${Rm(e,n,i.useFlagMods)}${s})`;return i.currentFlags=o,c},LookaroundAssertion({body:e,kind:t,negate:n},r,i){return`(?${`${t===`lookahead`?``:`<`}${n?`!`:`=`}`}${e.map(i).join(`|`)})`},Quantifier(e,t,n){return n(e.body)+zm(e)},Subroutine({isRecursive:e,ref:t},n){if(!e)throw Error(`Unexpected non-recursive subroutine in transformed AST`);let r=n.recursionLimit;return t===0?`(?R=${r})`:B`\g<${t}&R=${r}>`}},km=new Set([`$`,`(`,`)`,`*`,`+`,`.`,`?`,`[`,`\\`,`]`,`^`,`{`,`|`,`}`]),Am=new Set([`-`,`\\`,`]`,`^`,`[`]),jm=new Set("()-/[\\]^{|}!#$%&*+,.:;<=>?@`~".split(``)),Mm=new Map([[9,B`\t`],[10,B`\n`],[11,B`\v`],[12,B`\f`],[13,B`\r`],[8232,B`\u2028`],[8233,B`\u2029`],[65279,B`\uFEFF`]]),Nm=/^\p{Cased}$/u;function Pm(e){return Nm.test(e)}function Fm(e,t){let n=!!t?.firstOnly,r=e.min.value,i=e.max.value,a=[];if(r<65&&(i===65535||i>=131071)||r===65536&&i>=131071)return a;for(let e=r;e<=i;e++){let t=Np(e);if(!Pm(t))continue;let o=Kp(t).filter(e=>{let t=e.codePointAt(0);return t<r||t>i});if(o.length&&(a.push(...o),n))break}return a}function Im(e,{escDigit:t,inCharClass:n,useFlagV:r}){if(Mm.has(e))return Mm.get(e);if(e<32||e>126&&e<160||e>262143||t&&Vm(e))return e>255?`\\u{${e.toString(16).toUpperCase()}}`:`\\x${e.toString(16).toUpperCase().padStart(2,`0`)}`;let i=n?r?jm:Am:km,a=Np(e);return(i.has(a)?`\\`:``)+a}function Lm(e){let t=e.map(e=>e.codePointAt(0)).sort((e,t)=>e-t),n=[],r=null;for(let e=0;e<t.length;e++)t[e+1]===t[e]+1?r??=t[e]:r===null?n.push(t[e]):(n.push([r,t[e]]),r=null);return n}function Rm(e,t,n){if(e)return`>`;let r=``;if(t&&n){let{enable:e,disable:n}=t;r=(e?.ignoreCase?`i`:``)+(e?.dotAll?`s`:``)+(n?`-`:``)+(n?.ignoreCase?`i`:``)+(n?.dotAll?`s`:``)}return`${r}:`}function zm({kind:e,max:t,min:n}){let r;return r=!n&&t===1?`?`:!n&&t===1/0?`*`:n===1&&t===1/0?`+`:n===t?`{${n}}`:`{${n},${t===1/0?``:t}}`,r+{greedy:``,lazy:`?`,possessive:`+`}[e]}function Bm({type:e}){return e===`CapturingGroup`||e===`Group`||e===`LookaroundAssertion`}function Vm(e){return e>47&&e<58}function Hm({type:e,value:t}){return e===`Character`&&t===45}var Um=class e extends RegExp{#e=new Map;#t=null;#n;#r=null;#i=null;rawOptions={};get source(){return this.#n||`(?:)`}constructor(t,n,r){let i=!!r?.lazyCompile;if(t instanceof RegExp){if(r)throw Error(`Cannot provide options when copying a regexp`);let i=t;super(i,n),this.#n=i.source,i instanceof e&&(this.#e=i.#e,this.#r=i.#r,this.#i=i.#i,this.rawOptions=i.rawOptions)}else{let e={hiddenCaptures:[],strategy:null,transfers:[],...r};super(i?``:t,n),this.#n=t,this.#e=Gm(e.hiddenCaptures,e.transfers),this.#i=e.strategy,this.rawOptions=r??{}}i||(this.#t=this)}exec(t){if(!this.#t){let{lazyCompile:t,...n}=this.rawOptions;this.#t=new e(this.#n,this.flags,n)}let n=this.global||this.sticky,r=this.lastIndex;if(this.#i===`clip_search`&&n&&r){this.lastIndex=0;let e=this.#a(t.slice(r));return e&&(Wm(e,r,t,this.hasIndices),this.lastIndex+=r),e}return this.#a(t)}#a(e){this.#t.lastIndex=this.lastIndex;let t=super.exec.call(this.#t,e);if(this.lastIndex=this.#t.lastIndex,!t||!this.#e.size)return t;let n=[...t];t.length=1;let r;this.hasIndices&&(r=[...t.indices],t.indices.length=1);let i=[0];for(let e=1;e<n.length;e++){let{hidden:a,transferTo:o}=this.#e.get(e)??{};if(a?i.push(null):(i.push(t.length),t.push(n[e]),this.hasIndices&&t.indices.push(r[e])),o&&n[e]!==void 0){let a=i[o];if(!a)throw Error(`Invalid capture transfer to "${a}"`);if(t[a]=n[e],this.hasIndices&&(t.indices[a]=r[e]),t.groups){this.#r||=Km(this.source);let i=this.#r.get(o);i&&(t.groups[i]=n[e],this.hasIndices&&(t.indices.groups[i]=r[e]))}}}return t}};function Wm(e,t,n,r){if(e.index+=t,e.input=n,r){let n=e.indices;for(let e=0;e<n.length;e++){let r=n[e];r&&(n[e]=[r[0]+t,r[1]+t])}let r=n.groups;r&&Object.keys(r).forEach(e=>{let n=r[e];n&&(r[e]=[n[0]+t,n[1]+t])})}}function Gm(e,t){let n=new Map;for(let t of e)n.set(t,{hidden:!0});for(let[e,r]of t)for(let t of r)Lp(n,t,{}).transferTo=e;return n}function Km(e){let t=/(?<capture>\((?:\?<(?![=!])(?<name>[^>]+)>|(?!\?)))|\\?./gsu,n=new Map,r=0,i=0,a;for(;a=t.exec(e);){let{0:e,groups:{capture:t,name:o}}=a;e===`[`?r++:r?e===`]`&&r--:t&&(i++,o&&n.set(i,o))}return n}function qm(e,t){let n=Jm(e,t);return n.options?new Um(n.pattern,n.flags,n.options):new RegExp(n.pattern,n.flags)}function Jm(e,t){let n=Hp(t),r=nm(bf(e,{flags:n.flags,normalizeUnknownPropertyNames:!0,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline},skipBackrefValidation:n.rules.allowOrphanBackrefs,unicodePropertyMap:qp}),{accuracy:n.accuracy,asciiWordBoundaries:n.rules.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,bestEffortTarget:n.target}),i=Em(r,n),a=Dp(i.pattern,{captureTransfers:i._captureTransfers,hiddenCaptures:i._hiddenCaptures,mode:`external`}),o=_p(bp(a.pattern).pattern,{captureTransfers:a.captureTransfers,hiddenCaptures:a.hiddenCaptures}),s={pattern:o.pattern,flags:`${n.hasIndices?`d`:``}${n.global?`g`:``}${i.flags}${i.options.disable.v?`u`:`v`}`};if(n.avoidSubclass){if(n.lazyCompileLength!==1/0)throw Error(`Lazy compilation requires subclass`)}else{let e=o.hiddenCaptures.sort((e,t)=>e-t),t=Array.from(o.captureTransfers),i=r._strategy,a=s.pattern.length>=n.lazyCompileLength;(e.length||t.length||i||a)&&(s.options={...e.length&&{hiddenCaptures:e},...t.length&&{transfers:t},...i&&{strategy:i},...a&&{lazyCompile:a}})}return s}function Ym(e,t){return qm(e,{global:!0,hasIndices:!0,lazyCompileLength:3e3,rules:{allowOrphanBackrefs:!0,asciiWordBoundaries:!0,captureGroup:!0,recursionLimit:5,singleline:!0},...t})}function Xm(e={}){let t={target:`auto`,cache:new Map,...e};return t.regexConstructor||=e=>Ym(e,{target:t.target}),{createScanner(e){return new Cd(e,t)},createString:Td}}var Zm={bash:()=>c(()=>import(`./shellscript-CLZ0U2zV.js`),[],import.meta.url),css:()=>c(()=>import(`./css-DUjzNfgv.js`),__vite__mapDeps([0,1]),import.meta.url),diff:()=>c(()=>import(`./diff-woXpYk--.js`),[],import.meta.url),html:()=>c(()=>import(`./html-BHZv6uqE.js`),__vite__mapDeps([2,1,3]),import.meta.url),javascript:()=>c(()=>import(`./javascript-Yelw-5ZN.js`),__vite__mapDeps([4,3]),import.meta.url),json:()=>c(()=>import(`./json-qhed-kSA.js`),[],import.meta.url),jsx:()=>c(()=>import(`./jsx-Bz0zcwM4.js`),[],import.meta.url),markdown:()=>c(()=>import(`./markdown-BYOwaDjH.js`),[],import.meta.url),python:()=>c(()=>import(`./python-gzcpVVnB.js`),[],import.meta.url),sql:()=>c(()=>import(`./sql-CEbI0hMM.js`),[],import.meta.url),tsx:()=>c(()=>import(`./tsx-udAQXfEw.js`),[],import.meta.url),typescript:()=>c(()=>import(`./typescript-bsJCZSQ-.js`),[],import.meta.url),yaml:()=>c(()=>import(`./yaml-rwi0_p6S.js`),[],import.meta.url)},Qm={js:`javascript`,md:`markdown`,py:`python`,sh:`bash`,shell:`bash`,shellscript:`bash`,ts:`typescript`,yml:`yaml`,zsh:`bash`},$m;function eh(){return $m??=yd({themes:[c(()=>import(`./github-light-EUqPIrTm.js`),[],import.meta.url),c(()=>import(`./github-dark-C-LZuMrd.js`),[],import.meta.url)],langs:[],engine:Xm({forgiving:!0})}),$m}function th(e){let t=e.toLowerCase();return t===`ansi`||t in Zm?t:Qm[t]??null}async function nh(e){let t=th(e);if(!t)return null;let n=await eh();return t!==`ansi`&&!n.getLoadedLanguages().includes(t)&&await n.loadLanguage(Zm[t]),{highlight(e,r){let i=e=>n.codeToTokens(e,{lang:t,themes:{light:`github-light`,dark:`github-dark`},defaultColor:!1,grammarState:r}).tokens,a=t===`ansi`?e.split(`
|
|
156
|
-
`).flatMap(e=>i(e)):i(e);return{lines:a.map(e=>e.map((e,t)=>(0,z.jsx)(`span`,{style:e.htmlStyle,className:`text-(--shiki-light) dark:text-(--shiki-dark)`,children:e.content},t))),state:n.getLastGrammarState(a)}}}}function
|
|
157
|
-
`)?e.slice(0,-1):e,[r,i]=R.useState(null),a=r?.language===t?r.highlighter:null;R.useEffect(()=>{let e=!1;return
|
|
155
|
+
\v\f
\u2028\u2029])`),t));else if(c===`posix`)if(!i&&(u===`graph`||u===`print`)){if(r===`strict`)throw Error(`POSIX class "${u}" requires min target ES2024 or non-strict accuracy`);let e={graph:`!-~`,print:` -~`}[u];l&&(e=`\0-${Pp(e.codePointAt(0)-1)}${Pp(e.codePointAt(2)+1)}-\u{10FFFF}`),n(Em(Cm(`[${e}]`),t))}else n(Em(wm(Cm(Qp.get(u)),l),t));else if(c===`property`)Jp.has(np(u))||(e.key=`sc`);else if(c===`space`)n(Tm(Jf(`space`,{negate:l}),t));else if(c===`word`)n(Em(wm(Cm(Kp),l),t));else throw Error(`Unexpected character set kind "${c}"`)},Directive({node:e,parent:t,root:n,remove:r,replaceWith:i,removeAllPrevSiblings:a,removeAllNextSiblings:o}){let{kind:s,flags:c}=e;if(s===`flags`)if(!c.enable&&!c.disable)r();else{let e=Vf({flags:c});e.body[0].body=o(),i(Em(e,t),{traverse:!0})}else if(s===`keep`){let e=n.body[0],r=n.body.length===1&&vf(e,{type:`Group`})&&e.body[0].body.length===1?e.body[0]:n;if(t.parent!==r||r.body.length>1)throw Error(B`Uses "\K" in a way that's unsupported`);let o=Hf({behind:!0});o.body[0].body=a(),i(Em(o,t))}else throw Error(`Unexpected directive kind "${s}"`)},Flags({node:e,parent:t}){if(e.posixIsAscii)throw Error(`Unsupported flag "P"`);if(e.textSegmentMode===`word`)throw Error(`Unsupported flag "y{w}"`);[`digitIsAscii`,`extended`,`posixIsAscii`,`spaceIsAscii`,`wordIsAscii`,`textSegmentMode`].forEach(t=>delete e[t]),Object.assign(e,{global:!1,hasIndices:!1,multiline:!1,sticky:e.sticky??!1}),t.options={disable:{x:!0,n:!0},force:{v:!0}}},Group({node:e}){if(!e.flags)return;let{enable:t,disable:n}=e.flags;t?.extended&&delete t.extended,n?.extended&&delete n.extended,t?.dotAll&&n?.dotAll&&delete t.dotAll,t?.ignoreCase&&n?.ignoreCase&&delete t.ignoreCase,t&&!Object.keys(t).length&&delete e.flags.enable,n&&!Object.keys(n).length&&delete e.flags.disable,!e.flags.enable&&!e.flags.disable&&delete e.flags},LookaroundAssertion({node:e},t){let{kind:n}=e;n===`lookbehind`&&(t.passedLookbehind=!0)},NamedCallout({node:e,parent:t,replaceWith:n}){let{kind:r}=e;if(r===`fail`)n(Em(Hf({negate:!0}),t));else throw Error(`Unsupported named callout "(*${r.toUpperCase()}"`)},Quantifier({node:e}){if(e.body.type===`Quantifier`){let t=Vf();t.body[0].body.push(e.body),e.body=Em(t,e)}},Regex:{enter({node:e},{supportedGNodes:t}){let n=[],r=!1,i=!1;for(let t of e.body)if(t.body.length===1&&t.body[0].kind===`search_start`)t.body.pop();else{let e=_m(t.body);e?(r=!0,Array.isArray(e)?n.push(...e):n.push(e)):i=!0}r&&!i&&n.forEach(e=>t.add(e))},exit(e,{accuracy:t,passedLookbehind:n,strategy:r}){if(t===`strict`&&n&&r)throw Error(B`Uses "\G" in a way that requires non-strict accuracy`)}},Subroutine({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n==`string`&&!Sm(n)&&(n=pm(n,t),e.ref=n)}},am={Backreference({node:e},{multiplexCapturesToLeftByRef:t,reffedNodesByReferencer:n}){let{orphan:r,ref:i}=e;r||n.set(e,[...t.get(i).map(({node:e})=>e)])},CapturingGroup:{enter({node:e,parent:t,replaceWith:n,skip:r},{groupOriginByCopy:i,groupsByName:a,multiplexCapturesToLeftByRef:o,openRefs:s,reffedNodesByReferencer:c}){let l=i.get(e);if(l&&s.has(e.number)){let r=Tm(dm(e.number),t);c.set(r,s.get(e.number)),n(r);return}s.set(e.number,e),o.set(e.number,[]),e.name&&Rp(o,e.name,[]);let u=o.get(e.name??e.number);for(let t=0;t<u.length;t++){let n=u[t];if(l===n.node||l&&l===n.origin||e===n.origin){u.splice(t,1);break}}if(o.get(e.number).push({node:e,origin:l}),e.name&&o.get(e.name).push({node:e,origin:l}),e.name){let t=Rp(a,e.name,new Map),n=!1;if(l)n=!0;else for(let e of t.values())if(!e.hasDuplicateNameToRemove){n=!0;break}a.get(e.name).set(e,{node:e,hasDuplicateNameToRemove:n})}},exit({node:e},{openRefs:t}){t.get(e.number)===e&&t.delete(e.number)}},Group:{enter({node:e},t){t.prevFlags=t.currentFlags,e.flags&&(t.currentFlags=Lp(t.currentFlags,e.flags))},exit(e,t){t.currentFlags=t.prevFlags}},Subroutine({node:e,parent:t,replaceWith:n},r){let{isRecursive:i,ref:a}=e;if(i){let n=t;for(;(n=n.parent)&&!(n.type===`CapturingGroup`&&(n.name===a||n.number===a)););r.reffedNodesByReferencer.set(e,n);return}let o=r.subroutineRefMap.get(a),s=a===0,c=s?dm(0):um(o,r.groupOriginByCopy,null),l=c;if(!s){let e=mm(fm(o,e=>e.type===`Group`&&!!e.flags)),t=e?Lp(r.globalFlags,e):r.globalFlags;cm(t,r.currentFlags)||(l=Vf({flags:hm(t)}),l.body[0].body.push(c))}n(Em(l,t),{traverse:!s})}},om={Backreference({node:e,parent:t,replaceWith:n},r){if(e.orphan){r.highestOrphanBackref=Math.max(r.highestOrphanBackref,e.ref);return}let i=r.reffedNodesByReferencer.get(e).filter(t=>lm(t,e));i.length?i.length>1?n(Em(Vf({atomic:!0,body:i.reverse().map(e=>jf({body:[Nf(e.number)]}))}),t)):e.ref=i[0].number:n(Em(Hf({negate:!0}),t))},CapturingGroup({node:e},t){e.number=++t.numCapturesToLeft,e.name&&t.groupsByName.get(e.name).get(e).hasDuplicateNameToRemove&&delete e.name},Regex:{exit({node:e},t){let n=Math.max(t.highestOrphanBackref-t.numCapturesToLeft,0);for(let t=0;t<n;t++){let t=Pf();e.body.at(-1).body.push(t)}}},Subroutine({node:e},t){!e.isRecursive||e.ref===0||(e.ref=t.reffedNodesByReferencer.get(e).number)}};function sm(e){ap(e,{"*"({node:e,parent:t}){e.parent=t}})}function cm(e,t){return e.dotAll===t.dotAll&&e.ignoreCase===t.ignoreCase}function lm(e,t){let n=t;do{if(n.type===`Regex`)return!1;if(n.type===`Alternative`)continue;if(n===e)return!1;let t=gm(n.parent);for(let r of t){if(r===n)break;if(r===e||vm(r,e))return!0}}while(n=n.parent);throw Error(`Unexpected path`)}function um(e,t,n,r){let i=Array.isArray(e)?[]:{};for(let[a,o]of Object.entries(e))a===`parent`?i.parent=Array.isArray(n)?r:n:o&&typeof o==`object`?i[a]=um(o,t,i,n):(a===`type`&&o===`CapturingGroup`&&t.set(i,t.get(e)??e),i[a]=o);return i}function dm(e){let t=qf(e);return t.isRecursive=!0,t}function fm(e,t){let n=[];for(;e=e.parent;)(!t||t(e))&&n.push(e);return n}function pm(e,t){if(t.has(e))return t.get(e);let n=`$${t.size}_${e.replace(/^[^$_\p{IDS}]|[^$\u200C\u200D\p{IDC}]/gu,`_`)}`;return t.set(e,n),n}function mm(e){let t=[`dotAll`,`ignoreCase`],n={enable:{},disable:{}};return e.forEach(({flags:e})=>{t.forEach(t=>{e.enable?.[t]&&(delete n.disable[t],n.enable[t]=!0),e.disable?.[t]&&(n.disable[t]=!0)})}),Object.keys(n.enable).length||delete n.enable,Object.keys(n.disable).length||delete n.disable,n.enable||n.disable?n:null}function hm({dotAll:e,ignoreCase:t}){let n={};return(e||t)&&(n.enable={},e&&(n.enable.dotAll=!0),t&&(n.enable.ignoreCase=!0)),(!e||!t)&&(n.disable={},!e&&(n.disable.dotAll=!0),!t&&(n.disable.ignoreCase=!0)),n}function gm(e){if(!e)throw Error(`Node expected`);let{body:t}=e;return Array.isArray(t)?t:t?[t]:null}function _m(e){let t=e.find(e=>e.kind===`search_start`||xm(e,{negate:!1})||!ym(e));if(!t)return null;if(t.kind===`search_start`)return t;if(t.type===`LookaroundAssertion`)return t.body[0].body[0];if(t.type===`CapturingGroup`||t.type===`Group`){let e=[];for(let n of t.body){let t=_m(n.body);if(!t)return null;Array.isArray(t)?e.push(...t):e.push(t)}return e}return null}function vm(e,t){let n=gm(e)??[];for(let e of n)if(e===t||vm(e,t))return!0;return!1}function ym({type:e}){return e===`Assertion`||e===`Directive`||e===`LookaroundAssertion`}function bm(e){let t=[`Character`,`CharacterClass`,`CharacterSet`];return t.includes(e.type)||e.type===`Quantifier`&&e.min&&t.includes(e.body.type)}function xm(e,t){let n={negate:null,...t};return e.type===`LookaroundAssertion`&&(n.negate===null||e.negate===n.negate)&&e.body.length===1&&vf(e.body[0],{type:`Assertion`,kind:`search_start`})}function Sm(e){return/^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(e)}function Cm(e,t){let n=xf(e,{...t,unicodePropertyMap:Jp}).body;return n.length>1||n[0].body.length>1?Vf({body:n}):n[0].body[0]}function wm(e,t){return e.negate=t,e}function Tm(e,t){return e.parent=t,e}function Em(e,t){return sm(e),e.parent=t,e}function Dm(e,t){let n=Up(t),r=zp(n.target,`ES2024`),i=zp(n.target,`ES2025`),a=n.rules.recursionLimit;if(!Number.isInteger(a)||a<2||a>20)throw Error(`Invalid recursionLimit; use 2-20`);let o=null,s=null;if(!i){let t=[e.flags.ignoreCase];ap(e,Om,{getCurrentModI:()=>t.at(-1),popModI(){t.pop()},pushModI(e){t.push(e)},setHasCasedChar(){t.at(-1)?o=!0:s=!0}})}let c={dotAll:e.flags.dotAll,ignoreCase:!!((e.flags.ignoreCase||o)&&!s)},l=e,u={accuracy:n.accuracy,appliedGlobalFlags:c,captureMap:new Map,currentFlags:{dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},inCharClass:!1,lastNode:l,originMap:e._originMap,recursionLimit:a,useAppliedIgnoreCase:!!(!i&&o&&s),useFlagMods:i,useFlagV:r,verbose:n.verbose};function d(e){return u.lastNode=l,l=e,Bp(km[e.type],`Unexpected node type "${e.type}"`)(e,u,d)}let f={pattern:e.body.map(d).join(`|`),flags:d(e.flags),options:{...e.options}};return r||(delete f.options.force.v,f.options.disable.v=!0,f.options.unicodeSetsPlugin=null),f._captureTransfers=new Map,f._hiddenCaptures=[],u.captureMap.forEach((e,t)=>{e.hidden&&f._hiddenCaptures.push(t),e.transferTo&&Rp(f._captureTransfers,e.transferTo,[]).push(t)}),f}var Om={"*":{enter({node:e},t){if(Vm(e)){let n=t.getCurrentModI();t.pushModI(e.flags?Lp({ignoreCase:n},e.flags).ignoreCase:n)}},exit({node:e},t){Vm(e)&&t.popModI()}},Backreference(e,t){t.setHasCasedChar()},Character({node:e},t){Fm(Pp(e.value))&&t.setHasCasedChar()},CharacterClassRange({node:e,skip:t},n){t(),Im(e,{firstOnly:!0}).length&&n.setHasCasedChar()},CharacterSet({node:e},t){e.kind===`property`&&nm.has(e.value)&&t.setHasCasedChar()}},km={Alternative({body:e},t,n){return e.map(n).join(``)},Assertion({kind:e,negate:t}){if(e===`string_end`)return`$`;if(e===`string_start`)return`^`;if(e===`word_boundary`)return t?B`\B`:B`\b`;throw Error(`Unexpected assertion kind "${e}"`)},Backreference({ref:e},t){if(typeof e!=`number`)throw Error(`Unexpected named backref in transformed AST`);if(!t.useFlagMods&&t.accuracy===`strict`&&t.currentFlags.ignoreCase&&!t.captureMap.get(e).ignoreCase)throw Error(`Use of case-insensitive backref to case-sensitive group requires target ES2025 or non-strict accuracy`);return`\\`+e},CapturingGroup(e,t,n){let{body:r,name:i,number:a}=e,o={ignoreCase:t.currentFlags.ignoreCase},s=t.originMap.get(e);return s&&(o.hidden=!0,a>s.number&&(o.transferTo=s.number)),t.captureMap.set(a,o),`(${i?`?<${i}>`:``}${r.map(n).join(`|`)})`},Character({value:e},t){let n=Pp(e),r=Lm(e,{escDigit:t.lastNode.type===`Backreference`,inCharClass:t.inCharClass,useFlagV:t.useFlagV});if(r!==n)return r;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&Fm(n)){let e=qp(n);return t.inCharClass?e.join(``):e.length>1?`[${e.join(``)}]`:e[0]}return n},CharacterClass(e,t,n){let{kind:r,negate:i,parent:a}=e,{body:o}=e;if(r===`intersection`&&!t.useFlagV)throw Error(`Use of character class intersection requires min target ES2024`);Fp.bugFlagVLiteralHyphenIsRange&&t.useFlagV&&o.some(Um)&&(o=[Ff(45),...o.filter(e=>!Um(e))]);let s=()=>`[${i?`^`:``}${o.map(n).join(r===`intersection`?`&&`:``)}]`;if(!t.inCharClass){if((!t.useFlagV||Fp.bugNestedClassIgnoresNegation)&&!i){let t=o.filter(e=>e.type===`CharacterClass`&&e.kind===`union`&&e.negate);if(t.length){let r=Vf(),i=r.body[0];return r.parent=a,i.parent=r,o=o.filter(e=>!t.includes(e)),e.body=o,o.length?(e.parent=i,i.body.push(e)):r.body.pop(),t.forEach(e=>{let t=jf({body:[e]});e.parent=t,t.parent=r,r.body.push(t)}),n(r)}}t.inCharClass=!0;let r=s();return t.inCharClass=!1,r}let c=o[0];if(r===`union`&&!i&&c&&((!t.useFlagV||!t.verbose)&&a.kind===`union`&&!(Fp.bugFlagVLiteralHyphenIsRange&&t.useFlagV)||!t.verbose&&a.kind===`intersection`&&o.length===1&&c.type!==`CharacterClassRange`))return o.map(n).join(``);if(!t.useFlagV&&a.type===`CharacterClass`)throw Error(`Uses nested character class in a way that requires min target ES2024`);return s()},CharacterClassRange(e,t){let n=e.min.value,r=e.max.value,i={escDigit:!1,inCharClass:!0,useFlagV:t.useFlagV},a=Lm(n,i),o=Lm(r,i),s=new Set;return t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&Rm(Im(e)).forEach(e=>{s.add(Array.isArray(e)?`${Lm(e[0],i)}-${Lm(e[1],i)}`:Lm(e,i))}),`${a}-${o}${[...s].join(``)}`},CharacterSet({kind:e,negate:t,value:n,key:r},i){if(e===`dot`)return i.currentFlags.dotAll?i.appliedGlobalFlags.dotAll||i.useFlagMods?`.`:`[^]`:B`[^\n]`;if(e===`digit`)return t?B`\D`:B`\d`;if(e===`property`){if(i.useAppliedIgnoreCase&&i.currentFlags.ignoreCase&&nm.has(n))throw Error(`Unicode property "${n}" can't be case-insensitive when other chars have specific case`);return`${t?B`\P`:B`\p`}{${r?`${r}=`:``}${n}}`}if(e===`word`)return t?B`\W`:B`\w`;throw Error(`Unexpected character set kind "${e}"`)},Flags(e,t){return(t.appliedGlobalFlags.ignoreCase?`i`:``)+(e.dotAll?`s`:``)+(e.sticky?`y`:``)},Group({atomic:e,body:t,flags:n,parent:r},i,a){let o=i.currentFlags;n&&(i.currentFlags=Lp(o,n));let s=t.map(a).join(`|`),c=!i.verbose&&t.length===1&&r.type!==`Quantifier`&&!e&&(!i.useFlagMods||!n)?s:`(?${zm(e,n,i.useFlagMods)}${s})`;return i.currentFlags=o,c},LookaroundAssertion({body:e,kind:t,negate:n},r,i){return`(?${`${t===`lookahead`?``:`<`}${n?`!`:`=`}`}${e.map(i).join(`|`)})`},Quantifier(e,t,n){return n(e.body)+Bm(e)},Subroutine({isRecursive:e,ref:t},n){if(!e)throw Error(`Unexpected non-recursive subroutine in transformed AST`);let r=n.recursionLimit;return t===0?`(?R=${r})`:B`\g<${t}&R=${r}>`}},Am=new Set([`$`,`(`,`)`,`*`,`+`,`.`,`?`,`[`,`\\`,`]`,`^`,`{`,`|`,`}`]),jm=new Set([`-`,`\\`,`]`,`^`,`[`]),Mm=new Set("()-/[\\]^{|}!#$%&*+,.:;<=>?@`~".split(``)),Nm=new Map([[9,B`\t`],[10,B`\n`],[11,B`\v`],[12,B`\f`],[13,B`\r`],[8232,B`\u2028`],[8233,B`\u2029`],[65279,B`\uFEFF`]]),Pm=/^\p{Cased}$/u;function Fm(e){return Pm.test(e)}function Im(e,t){let n=!!t?.firstOnly,r=e.min.value,i=e.max.value,a=[];if(r<65&&(i===65535||i>=131071)||r===65536&&i>=131071)return a;for(let e=r;e<=i;e++){let t=Pp(e);if(!Fm(t))continue;let o=qp(t).filter(e=>{let t=e.codePointAt(0);return t<r||t>i});if(o.length&&(a.push(...o),n))break}return a}function Lm(e,{escDigit:t,inCharClass:n,useFlagV:r}){if(Nm.has(e))return Nm.get(e);if(e<32||e>126&&e<160||e>262143||t&&Hm(e))return e>255?`\\u{${e.toString(16).toUpperCase()}}`:`\\x${e.toString(16).toUpperCase().padStart(2,`0`)}`;let i=n?r?Mm:jm:Am,a=Pp(e);return(i.has(a)?`\\`:``)+a}function Rm(e){let t=e.map(e=>e.codePointAt(0)).sort((e,t)=>e-t),n=[],r=null;for(let e=0;e<t.length;e++)t[e+1]===t[e]+1?r??=t[e]:r===null?n.push(t[e]):(n.push([r,t[e]]),r=null);return n}function zm(e,t,n){if(e)return`>`;let r=``;if(t&&n){let{enable:e,disable:n}=t;r=(e?.ignoreCase?`i`:``)+(e?.dotAll?`s`:``)+(n?`-`:``)+(n?.ignoreCase?`i`:``)+(n?.dotAll?`s`:``)}return`${r}:`}function Bm({kind:e,max:t,min:n}){let r;return r=!n&&t===1?`?`:!n&&t===1/0?`*`:n===1&&t===1/0?`+`:n===t?`{${n}}`:`{${n},${t===1/0?``:t}}`,r+{greedy:``,lazy:`?`,possessive:`+`}[e]}function Vm({type:e}){return e===`CapturingGroup`||e===`Group`||e===`LookaroundAssertion`}function Hm(e){return e>47&&e<58}function Um({type:e,value:t}){return e===`Character`&&t===45}var Wm=class e extends RegExp{#e=new Map;#t=null;#n;#r=null;#i=null;rawOptions={};get source(){return this.#n||`(?:)`}constructor(t,n,r){let i=!!r?.lazyCompile;if(t instanceof RegExp){if(r)throw Error(`Cannot provide options when copying a regexp`);let i=t;super(i,n),this.#n=i.source,i instanceof e&&(this.#e=i.#e,this.#r=i.#r,this.#i=i.#i,this.rawOptions=i.rawOptions)}else{let e={hiddenCaptures:[],strategy:null,transfers:[],...r};super(i?``:t,n),this.#n=t,this.#e=Km(e.hiddenCaptures,e.transfers),this.#i=e.strategy,this.rawOptions=r??{}}i||(this.#t=this)}exec(t){if(!this.#t){let{lazyCompile:t,...n}=this.rawOptions;this.#t=new e(this.#n,this.flags,n)}let n=this.global||this.sticky,r=this.lastIndex;if(this.#i===`clip_search`&&n&&r){this.lastIndex=0;let e=this.#a(t.slice(r));return e&&(Gm(e,r,t,this.hasIndices),this.lastIndex+=r),e}return this.#a(t)}#a(e){this.#t.lastIndex=this.lastIndex;let t=super.exec.call(this.#t,e);if(this.lastIndex=this.#t.lastIndex,!t||!this.#e.size)return t;let n=[...t];t.length=1;let r;this.hasIndices&&(r=[...t.indices],t.indices.length=1);let i=[0];for(let e=1;e<n.length;e++){let{hidden:a,transferTo:o}=this.#e.get(e)??{};if(a?i.push(null):(i.push(t.length),t.push(n[e]),this.hasIndices&&t.indices.push(r[e])),o&&n[e]!==void 0){let a=i[o];if(!a)throw Error(`Invalid capture transfer to "${a}"`);if(t[a]=n[e],this.hasIndices&&(t.indices[a]=r[e]),t.groups){this.#r||=qm(this.source);let i=this.#r.get(o);i&&(t.groups[i]=n[e],this.hasIndices&&(t.indices.groups[i]=r[e]))}}}return t}};function Gm(e,t,n,r){if(e.index+=t,e.input=n,r){let n=e.indices;for(let e=0;e<n.length;e++){let r=n[e];r&&(n[e]=[r[0]+t,r[1]+t])}let r=n.groups;r&&Object.keys(r).forEach(e=>{let n=r[e];n&&(r[e]=[n[0]+t,n[1]+t])})}}function Km(e,t){let n=new Map;for(let t of e)n.set(t,{hidden:!0});for(let[e,r]of t)for(let t of r)Rp(n,t,{}).transferTo=e;return n}function qm(e){let t=/(?<capture>\((?:\?<(?![=!])(?<name>[^>]+)>|(?!\?)))|\\?./gsu,n=new Map,r=0,i=0,a;for(;a=t.exec(e);){let{0:e,groups:{capture:t,name:o}}=a;e===`[`?r++:r?e===`]`&&r--:t&&(i++,o&&n.set(i,o))}return n}function Jm(e,t){let n=Ym(e,t);return n.options?new Wm(n.pattern,n.flags,n.options):new RegExp(n.pattern,n.flags)}function Ym(e,t){let n=Up(t),r=rm(xf(e,{flags:n.flags,normalizeUnknownPropertyNames:!0,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline},skipBackrefValidation:n.rules.allowOrphanBackrefs,unicodePropertyMap:Jp}),{accuracy:n.accuracy,asciiWordBoundaries:n.rules.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,bestEffortTarget:n.target}),i=Dm(r,n),a=Op(i.pattern,{captureTransfers:i._captureTransfers,hiddenCaptures:i._hiddenCaptures,mode:`external`}),o=vp(xp(a.pattern).pattern,{captureTransfers:a.captureTransfers,hiddenCaptures:a.hiddenCaptures}),s={pattern:o.pattern,flags:`${n.hasIndices?`d`:``}${n.global?`g`:``}${i.flags}${i.options.disable.v?`u`:`v`}`};if(n.avoidSubclass){if(n.lazyCompileLength!==1/0)throw Error(`Lazy compilation requires subclass`)}else{let e=o.hiddenCaptures.sort((e,t)=>e-t),t=Array.from(o.captureTransfers),i=r._strategy,a=s.pattern.length>=n.lazyCompileLength;(e.length||t.length||i||a)&&(s.options={...e.length&&{hiddenCaptures:e},...t.length&&{transfers:t},...i&&{strategy:i},...a&&{lazyCompile:a}})}return s}function Xm(e,t){return Jm(e,{global:!0,hasIndices:!0,lazyCompileLength:3e3,rules:{allowOrphanBackrefs:!0,asciiWordBoundaries:!0,captureGroup:!0,recursionLimit:5,singleline:!0},...t})}function Zm(e={}){let t={target:`auto`,cache:new Map,...e};return t.regexConstructor||=e=>Xm(e,{target:t.target}),{createScanner(e){return new wd(e,t)},createString:Ed}}var Qm={bash:()=>c(()=>import(`./shellscript-CLZ0U2zV.js`),[],import.meta.url),css:()=>c(()=>import(`./css-DUjzNfgv.js`),__vite__mapDeps([0,1]),import.meta.url),diff:()=>c(()=>import(`./diff-woXpYk--.js`),[],import.meta.url),html:()=>c(()=>import(`./html-BHZv6uqE.js`),__vite__mapDeps([2,1,3]),import.meta.url),javascript:()=>c(()=>import(`./javascript-Yelw-5ZN.js`),__vite__mapDeps([4,3]),import.meta.url),json:()=>c(()=>import(`./json-qhed-kSA.js`),[],import.meta.url),jsx:()=>c(()=>import(`./jsx-Bz0zcwM4.js`),[],import.meta.url),markdown:()=>c(()=>import(`./markdown-BYOwaDjH.js`),[],import.meta.url),python:()=>c(()=>import(`./python-gzcpVVnB.js`),[],import.meta.url),sql:()=>c(()=>import(`./sql-CEbI0hMM.js`),[],import.meta.url),tsx:()=>c(()=>import(`./tsx-udAQXfEw.js`),[],import.meta.url),typescript:()=>c(()=>import(`./typescript-bsJCZSQ-.js`),[],import.meta.url),yaml:()=>c(()=>import(`./yaml-rwi0_p6S.js`),[],import.meta.url)},$m={js:`javascript`,md:`markdown`,py:`python`,sh:`bash`,shell:`bash`,shellscript:`bash`,ts:`typescript`,yml:`yaml`,zsh:`bash`},eh;function th(){return eh??=bd({themes:[c(()=>import(`./github-light-EUqPIrTm.js`),[],import.meta.url),c(()=>import(`./github-dark-C-LZuMrd.js`),[],import.meta.url)],langs:[],engine:Zm({forgiving:!0})}),eh}function nh(e){let t=e.toLowerCase();return t===`ansi`||t in Qm?t:$m[t]??null}async function rh(e){let t=nh(e);if(!t)return null;let n=await th();return t!==`ansi`&&!n.getLoadedLanguages().includes(t)&&await n.loadLanguage(Qm[t]),{highlight(e,r){let i=e=>n.codeToTokens(e,{lang:t,themes:{light:`github-light`,dark:`github-dark`},defaultColor:!1,grammarState:r}).tokens,a=t===`ansi`?e.split(`
|
|
156
|
+
`).flatMap(e=>i(e)):i(e);return{lines:a.map(e=>e.map((e,t)=>(0,z.jsx)(`span`,{style:e.htmlStyle,className:`text-(--shiki-light) dark:text-(--shiki-dark)`,children:e.content},t))),state:n.getLastGrammarState(a)}}}}function ih(e,t){let n=e.endsWith(`
|
|
157
|
+
`)?e.slice(0,-1):e,[r,i]=R.useState(null),a=r?.language===t?r.highlighter:null;R.useEffect(()=>{let e=!1;return rh(t).then(n=>{e||i({language:t,highlighter:n})}).catch(()=>{}),()=>{e=!0}},[t]);let[o,s]=R.useState({highlighter:null,text:``,lines:[]}),c=o;(c.highlighter!==a||!n.startsWith(c.text))&&(c={highlighter:a,text:``,lines:[]});let l=n.lastIndexOf(`
|
|
158
158
|
`)+1;if(a&&l>c.text.length){let e=a.highlight(n.slice(c.text.length,l-1),c.state);c={highlighter:a,text:n.slice(0,l),lines:[...c.lines,...e.lines],state:e.state}}c!==o&&s(c);let u=n.slice(l);return R.useMemo(()=>a?[...c.lines,a.highlight(u,c.state).lines[0]]:n.split(`
|
|
159
|
-
`),[n,a,c,u])}var
|
|
159
|
+
`),[n,a,c,u])}var ah=`vercel.ai.error`,oh=Symbol.for(ah),sh=class e extends Error{constructor({name:e,message:t,cause:n}){super(t),this[oh]=!0,this.name=e,this.cause=n}static isInstance(t){return e.hasMarker(t,ah)}static hasMarker(e,t){let n=Symbol.for(t);return typeof e==`object`&&!!e&&n in e&&typeof e[n]==`boolean`&&e[n]===!0}},ch=`AI_APICallError`,lh=`vercel.ai.error.${ch}`,uh=Symbol.for(lh),dh=class extends sh{constructor({message:e,url:t,requestBodyValues:n,statusCode:r,responseHeaders:i,responseBody:a,cause:o,isRetryable:s=r!=null&&(r===408||r===409||r===429||r>=500),data:c}){super({name:ch,message:e,cause:o}),this[uh]=!0,this.url=t,this.requestBodyValues=n,this.statusCode=r,this.responseHeaders=i,this.responseBody=a,this.isRetryable=s,this.data=c}static isInstance(e){return sh.hasMarker(e,lh)}},fh=`AI_EmptyResponseBodyError`,ph=`vercel.ai.error.${fh}`,mh=Symbol.for(ph),hh=class extends sh{constructor({message:e=`Empty response body`}={}){super({name:fh,message:e}),this[mh]=!0}static isInstance(e){return sh.hasMarker(e,ph)}};function gh(e){return e==null?`unknown error`:typeof e==`string`?e:e instanceof Error?e.toString():JSON.stringify(e)}var _h=`AI_InvalidArgumentError`,vh=`vercel.ai.error.${_h}`,yh=Symbol.for(vh),bh=class extends sh{constructor({message:e,cause:t,argument:n}){super({name:_h,message:e,cause:t}),this[yh]=!0,this.argument=n}static isInstance(e){return sh.hasMarker(e,vh)}},xh=`AI_JSONParseError`,Sh=`vercel.ai.error.${xh}`,Ch=Symbol.for(Sh),wh=class extends sh{constructor({text:e,cause:t}){super({name:xh,message:`JSON parsing failed: Text: ${e}.\nError message: ${gh(t)}`,cause:t}),this[Ch]=!0,this.text=e}static isInstance(e){return sh.hasMarker(e,Sh)}},Th=`AI_TypeValidationError`,Eh=`vercel.ai.error.${Th}`,Dh=Symbol.for(Eh),Oh=class e extends sh{constructor({value:e,cause:t,context:n}){let r=`Type validation failed`;if(n?.field&&(r+=` for ${n.field}`),n?.entityName||n?.entityId){r+=` (`;let e=[];n.entityName&&e.push(n.entityName),n.entityId&&e.push(`id: "${n.entityId}"`),r+=e.join(`, `),r+=`)`}super({name:Th,message:`${r}: Value: ${JSON.stringify(e)}.\nError message: ${gh(t)}`,cause:t}),this[Dh]=!0,this.value=e,this.context=n}static isInstance(e){return sh.hasMarker(e,Eh)}static wrap({value:t,cause:n,context:r}){return e.isInstance(n)&&n.value===t&&n.context?.field===r?.field&&n.context?.entityName===r?.entityName&&n.context?.entityId===r?.entityId?n:new e({value:t,cause:n,context:r})}},kh=`AI_UnsupportedFunctionalityError`,Ah=`vercel.ai.error.${kh}`,jh=Symbol.for(Ah),Mh=class extends sh{constructor({functionality:e,message:t=`'${e}' functionality not supported.`}){super({name:kh,message:t}),this[jh]=!0,this.functionality=e}static isInstance(e){return sh.hasMarker(e,Ah)}},Nh=class extends Error{constructor(e,t){super(e),this.name=`ParseError`,this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}},Ph=10,Fh=13,Ih=32;function Lh(e){}function Rh(e){if(typeof e==`function`)throw TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");let{onEvent:t=Lh,onError:n=Lh,onRetry:r=Lh,onComment:i}=e,a=[],o=!0,s,c=``,l=0,u;function d(e){if(o&&(o=!1,e.charCodeAt(0)===239&&e.charCodeAt(1)===187&&e.charCodeAt(2)===191&&(e=e.slice(3))),a.length===0){let t=f(e);t!==``&&a.push(t);return}if(e.indexOf(`
|
|
160
160
|
`)===-1&&e.indexOf(`\r`)===-1){a.push(e);return}a.push(e);let t=a.join(``);a.length=0;let n=f(t);n!==``&&a.push(n)}function f(e){let n=0;if(e.indexOf(`\r`)===-1){let r=e.indexOf(`
|
|
161
161
|
`,n);for(;r!==-1;){if(n===r){l>0&&t({id:s,event:u,data:c}),s=void 0,c=``,l=0,u=void 0,n=r+1,r=e.indexOf(`
|
|
162
|
-
`,n);continue}let i=e.charCodeAt(n);if(
|
|
162
|
+
`,n);continue}let i=e.charCodeAt(n);if(zh(e,n,i)){let i=e.charCodeAt(n+5)===Ih?n+6:n+5,a=e.slice(i,r);if(l===0&&e.charCodeAt(r+1)===Ph){t({id:s,event:u,data:a}),s=void 0,c=``,u=void 0,n=r+2,r=e.indexOf(`
|
|
163
163
|
`,n);continue}c=l===0?a:`${c}
|
|
164
|
-
${a}`,l++}else
|
|
164
|
+
${a}`,l++}else Bh(e,n,i)?u=e.slice(e.charCodeAt(n+6)===Ih?n+7:n+6,r)||void 0:p(e,n,r);n=r+1,r=e.indexOf(`
|
|
165
165
|
`,n)}return e.slice(n)}for(;n<e.length;){let t=e.indexOf(`\r`,n),r=e.indexOf(`
|
|
166
|
-
`,n),i=-1;if(t!==-1&&r!==-1?i=t<r?t:r:t===-1?r!==-1&&(i=r):i=t===e.length-1?-1:t,i===-1)break;p(e,n,i),n=i+1,e.charCodeAt(n-1)===
|
|
167
|
-
${i}`,l++;return}if(
|
|
168
|
-
${t}`,l++;break;case`id`:s=t.includes(`\0`)?void 0:t;break;case`retry`:/^\d+$/.test(t)?r(parseInt(t,10)):n(new Mh(`Invalid \`retry\` value: "${t}"`,{type:`invalid-retry`,value:t,line:i}));break;default:n(new Mh(`Unknown field "${e.length>20?`${e.slice(0,20)}\u2026`:e}"`,{type:`unknown-field`,field:e,value:t,line:i}));break}}function h(){l>0&&t({id:s,event:u,data:c}),s=void 0,c=``,l=0,u=void 0}function g(e={}){if(e.consume&&a.length>0){let e=a.join(``);p(e,0,e.length)}o=!0,s=void 0,c=``,l=0,u=void 0,a.length=0}return{feed:d,reset:g}}function Rh(e,t,n){return n===100&&e.charCodeAt(t+1)===97&&e.charCodeAt(t+2)===116&&e.charCodeAt(t+3)===97&&e.charCodeAt(t+4)===58}function zh(e,t,n){return n===101&&e.charCodeAt(t+1)===118&&e.charCodeAt(t+2)===101&&e.charCodeAt(t+3)===110&&e.charCodeAt(t+4)===116&&e.charCodeAt(t+5)===58}var Bh=class extends TransformStream{constructor({onError:e,onRetry:t,onComment:n}={}){let r;super({start(i){r=Lh({onEvent:e=>{i.enqueue(e)},onError(t){e===`terminate`?i.error(t):typeof e==`function`&&e(t)},onRetry:t,onComment:n})},transform(e){r.feed(e)}})}};new TextDecoder;var{btoa:oee,atob:see}=globalThis,Vh=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Uint8Array.prototype),Symbol.toStringTag).get,Hh=Object.getOwnPropertyDescriptor(ArrayBuffer.prototype,`byteLength`).get;function Uh(e){return ArrayBuffer.isView(e)&&Vh.call(e)===`Uint8Array`}function Wh(e){if(typeof e!=`object`||!e||!(`byteLength`in e))return!1;try{return Hh.call(e),!0}catch{return!1}}function Gh(e){if(e==null)return{};let t={};if(e instanceof Headers)e.forEach((e,n)=>{t[n.toLowerCase()]=e});else{Array.isArray(e)||(e=Object.entries(e));for(let[n,r]of e)r!=null&&(t[n.toLowerCase()]=r)}return t}var Kh=({prefix:e,size:t=16,alphabet:n=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,separator:r=`-`}={})=>{let i=()=>{let e=n.length,r=Array(t);for(let i=0;i<t;i++)r[i]=n[Math.random()*e|0];return r.join(``)};if(e==null)return i;if(n.includes(r))throw new yh({argument:`separator`,message:`The separator "${r}" must not be part of the alphabet "${n}".`});return()=>`${e}${r}${i()}`},cee=Kh();function lee(e){return globalThis.Buffer?.isBuffer(e)??!1}function qh(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var uee=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,dee=/"(?: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 Jh(e){let t=JSON.parse(e);return typeof t!=`object`||!t||uee.test(e)===!1&&dee.test(e)===!1?t:fee(t)}function fee(e){let t=[e];for(;t.length;){let e=t;t=[];for(let n of e){if(Object.prototype.hasOwnProperty.call(n,`__proto__`)||Object.prototype.hasOwnProperty.call(n,`constructor`)&&n.constructor!==null&&typeof n.constructor==`object`&&Object.prototype.hasOwnProperty.call(n.constructor,`prototype`))throw SyntaxError(`Object contains forbidden prototype property`);for(let e in n){let r=n[e];r&&typeof r==`object`&&t.push(r)}}}return e}function pee(e){let{stackTraceLimit:t}=Error;try{Error.stackTraceLimit=0}catch{return Jh(e)}try{return Jh(e)}finally{Error.stackTraceLimit=t}}function Yh(e){if(e.type===`object`||Array.isArray(e.type)&&e.type.includes(`object`)){let{additionalProperties:t}=e;e.additionalProperties=t!=null&&typeof t!=`boolean`&&Xh(t);let{properties:n}=e;if(n!=null)for(let e of Object.keys(n))n[e]=Xh(n[e])}e.items!=null&&(e.items=Array.isArray(e.items)?e.items.map(Xh):Xh(e.items)),e.anyOf!=null&&(e.anyOf=e.anyOf.map(Xh)),e.allOf!=null&&(e.allOf=e.allOf.map(Xh)),e.oneOf!=null&&(e.oneOf=e.oneOf.map(Xh));let{definitions:t}=e;if(t!=null)for(let e of Object.keys(t))t[e]=Xh(t[e]);return e}function Xh(e){return typeof e==`boolean`?e:Yh(e)}var mee=Symbol(`Let zodToJsonSchema decide on which parser to use`),Zh={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`},hee=e=>typeof e==`string`?{...Zh,name:e}:{...Zh,...e};function Qh(){return{}}function gee(e,t){let n={type:`array`};return e.type?._def&&e.type?._def?.typeName!==`ZodAny`&&(n.items=Ug(e.type._def,{...t,currentPath:[...t.currentPath,`items`]})),e.minLength&&(n.minItems=e.minLength.value),e.maxLength&&(n.maxItems=e.maxLength.value),e.exactLength&&(n.minItems=e.exactLength.value,n.maxItems=e.exactLength.value),n}function $h(e){let t={type:`integer`,format:`int64`};if(!e.checks)return t;for(let 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}return t}function eg(){return{type:`boolean`}}function tg(e,t){return Ug(e.type._def,t)}var ng=(e,t)=>Ug(e.innerType._def,t);function rg(e,t,n){let r=n??t.dateStrategy;if(Array.isArray(r))return{anyOf:r.map(n=>rg(e,t,n))};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 ig(e)}}var ig=e=>{let t={type:`integer`,format:`unix-time`};for(let n of e.checks)switch(n.kind){case`min`:t.minimum=n.value;break;case`max`:t.maximum=n.value}return t};function ag(e,t){return{...Ug(e.innerType._def,t),default:e.defaultValue()}}function og(e,t){return t.effectStrategy===`input`?Ug(e.schema._def,t):Qh()}function sg(e){return{type:`string`,enum:Array.from(e.values)}}var cg=e=>`type`in e&&e.type===`string`?!1:`allOf`in e;function lg(e,t){let n=[Ug(e.left._def,{...t,currentPath:[...t.currentPath,`allOf`,`0`]}),Ug(e.right._def,{...t,currentPath:[...t.currentPath,`allOf`,`1`]})].filter(e=>!!e),r=[];return n.forEach(e=>{if(cg(e))r.push(...e.allOf);else{let t=e;if(`additionalProperties`in e&&e.additionalProperties===!1){let{additionalProperties:n,...r}=e;t=r}r.push(t)}}),r.length?{allOf:r}:void 0}function ug(e){let 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 dg=void 0,fg={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:()=>(dg===void 0&&(dg=RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`)),dg),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 pg(e,t){let n={type:`string`};if(e.checks)for(let 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`:_g(n,`email`,r.message,t);break;case`format:idn-email`:_g(n,`idn-email`,r.message,t);break;case`pattern:zod`:vg(n,fg.email,r.message,t)}break;case`url`:_g(n,`uri`,r.message,t);break;case`uuid`:_g(n,`uuid`,r.message,t);break;case`regex`:vg(n,r.regex,r.message,t);break;case`cuid`:vg(n,fg.cuid,r.message,t);break;case`cuid2`:vg(n,fg.cuid2,r.message,t);break;case`startsWith`:vg(n,RegExp(`^${mg(r.value,t)}`),r.message,t);break;case`endsWith`:vg(n,RegExp(`${mg(r.value,t)}$`),r.message,t);break;case`datetime`:_g(n,`date-time`,r.message,t);break;case`date`:_g(n,`date`,r.message,t);break;case`time`:_g(n,`time`,r.message,t);break;case`duration`:_g(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`:vg(n,RegExp(mg(r.value,t)),r.message,t);break;case`ip`:r.version!==`v6`&&_g(n,`ipv4`,r.message,t),r.version!==`v4`&&_g(n,`ipv6`,r.message,t);break;case`base64url`:vg(n,fg.base64url,r.message,t);break;case`jwt`:vg(n,fg.jwt,r.message,t);break;case`cidr`:r.version!==`v6`&&vg(n,fg.ipv4Cidr,r.message,t),r.version!==`v4`&&vg(n,fg.ipv6Cidr,r.message,t);break;case`emoji`:vg(n,fg.emoji(),r.message,t);break;case`ulid`:vg(n,fg.ulid,r.message,t);break;case`base64`:switch(t.base64Strategy){case`format:binary`:_g(n,`binary`,r.message,t);break;case`contentEncoding:base64`:n.contentEncoding=`base64`;break;case`pattern:zod`:vg(n,fg.base64,r.message,t)}break;case`nanoid`:vg(n,fg.nanoid,r.message,t)}return n}function mg(e,t){return t.patternStrategy===`escape`?gg(e):e}var hg=new Set(`ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789`);function gg(e){let t=``;for(let n=0;n<e.length;n++)hg.has(e[n])||(t+=`\\`),t+=e[n];return t}function _g(e,t,n,r){e.format||e.anyOf?.some(e=>e.format)?(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 vg(e,t,n,r){e.pattern||e.allOf?.some(e=>e.pattern)?(e.allOf||=[],e.pattern&&(e.allOf.push({pattern:e.pattern}),delete e.pattern),e.allOf.push({pattern:yg(t,r),...n&&r.errorMessages&&{errorMessage:{pattern:n}}})):e.pattern=yg(t,r)}function yg(e,t){if(!t.applyRegexFlags||!e.flags)return e.source;let n={i:e.flags.includes(`i`),m:e.flags.includes(`m`),s:e.flags.includes(`s`)},r=n.i?e.source.toLowerCase():e.source,i=``,a=!1,o=!1,s=!1;for(let e=0;e<r.length;e++){if(a){i+=r[e],a=!1;continue}if(n.i){if(o){if(r[e].match(/[a-z]/)){s?(i+=r[e],i+=`${r[e-2]}-${r[e]}`.toUpperCase(),s=!1):r[e+1]===`-`&&r[e+2]?.match(/[a-z]/)?(i+=r[e],s=!0):i+=`${r[e]}${r[e].toUpperCase()}`;continue}}else if(r[e].match(/[a-z]/)){i+=`[${r[e]}${r[e].toUpperCase()}]`;continue}}if(n.m){if(r[e]===`^`){i+=`(^|(?<=[\r
|
|
166
|
+
`,n),i=-1;if(t!==-1&&r!==-1?i=t<r?t:r:t===-1?r!==-1&&(i=r):i=t===e.length-1?-1:t,i===-1)break;p(e,n,i),n=i+1,e.charCodeAt(n-1)===Fh&&e.charCodeAt(n)===Ph&&n++}return e.slice(n)}function p(e,t,n){if(t===n){h();return}let r=e.charCodeAt(t);if(zh(e,t,r)){let r=e.charCodeAt(t+5)===Ih?t+6:t+5,i=e.slice(r,n);c=l===0?i:`${c}
|
|
167
|
+
${i}`,l++;return}if(Bh(e,t,r)){u=e.slice(e.charCodeAt(t+6)===Ih?t+7:t+6,n)||void 0;return}if(r===105&&e.charCodeAt(t+1)===100&&e.charCodeAt(t+2)===58){let r=e.slice(e.charCodeAt(t+3)===Ih?t+4:t+3,n);s=r.includes(`\0`)?void 0:r;return}if(r===58){if(i){let r=e.slice(t,n);i(r.slice(e.charCodeAt(t+1)===Ih?2:1))}return}let a=e.slice(t,n),o=a.indexOf(`:`);if(o===-1){m(a,``,a);return}let d=a.slice(0,o),f=a.charCodeAt(o+1)===Ih?2:1;m(d,a.slice(o+f),a)}function m(e,t,i){switch(e){case`event`:u=t||void 0;break;case`data`:c=l===0?t:`${c}
|
|
168
|
+
${t}`,l++;break;case`id`:s=t.includes(`\0`)?void 0:t;break;case`retry`:/^\d+$/.test(t)?r(parseInt(t,10)):n(new Nh(`Invalid \`retry\` value: "${t}"`,{type:`invalid-retry`,value:t,line:i}));break;default:n(new Nh(`Unknown field "${e.length>20?`${e.slice(0,20)}\u2026`:e}"`,{type:`unknown-field`,field:e,value:t,line:i}));break}}function h(){l>0&&t({id:s,event:u,data:c}),s=void 0,c=``,l=0,u=void 0}function g(e={}){if(e.consume&&a.length>0){let e=a.join(``);p(e,0,e.length)}o=!0,s=void 0,c=``,l=0,u=void 0,a.length=0}return{feed:d,reset:g}}function zh(e,t,n){return n===100&&e.charCodeAt(t+1)===97&&e.charCodeAt(t+2)===116&&e.charCodeAt(t+3)===97&&e.charCodeAt(t+4)===58}function Bh(e,t,n){return n===101&&e.charCodeAt(t+1)===118&&e.charCodeAt(t+2)===101&&e.charCodeAt(t+3)===110&&e.charCodeAt(t+4)===116&&e.charCodeAt(t+5)===58}var Vh=class extends TransformStream{constructor({onError:e,onRetry:t,onComment:n}={}){let r;super({start(i){r=Rh({onEvent:e=>{i.enqueue(e)},onError(t){e===`terminate`?i.error(t):typeof e==`function`&&e(t)},onRetry:t,onComment:n})},transform(e){r.feed(e)}})}};new TextDecoder;var{btoa:aee,atob:oee}=globalThis,Hh=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Uint8Array.prototype),Symbol.toStringTag).get,Uh=Object.getOwnPropertyDescriptor(ArrayBuffer.prototype,`byteLength`).get;function Wh(e){return ArrayBuffer.isView(e)&&Hh.call(e)===`Uint8Array`}function Gh(e){if(typeof e!=`object`||!e||!(`byteLength`in e))return!1;try{return Uh.call(e),!0}catch{return!1}}function Kh(e){if(e==null)return{};let t={};if(e instanceof Headers)e.forEach((e,n)=>{t[n.toLowerCase()]=e});else{Array.isArray(e)||(e=Object.entries(e));for(let[n,r]of e)r!=null&&(t[n.toLowerCase()]=r)}return t}var qh=({prefix:e,size:t=16,alphabet:n=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,separator:r=`-`}={})=>{let i=()=>{let e=n.length,r=Array(t);for(let i=0;i<t;i++)r[i]=n[Math.random()*e|0];return r.join(``)};if(e==null)return i;if(n.includes(r))throw new bh({argument:`separator`,message:`The separator "${r}" must not be part of the alphabet "${n}".`});return()=>`${e}${r}${i()}`},Jh=qh();function see(e){return globalThis.Buffer?.isBuffer(e)??!1}function Yh(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var cee=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,lee=/"(?: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 Xh(e){let t=JSON.parse(e);return typeof t!=`object`||!t||cee.test(e)===!1&&lee.test(e)===!1?t:uee(t)}function uee(e){let t=[e];for(;t.length;){let e=t;t=[];for(let n of e){if(Object.prototype.hasOwnProperty.call(n,`__proto__`)||Object.prototype.hasOwnProperty.call(n,`constructor`)&&n.constructor!==null&&typeof n.constructor==`object`&&Object.prototype.hasOwnProperty.call(n.constructor,`prototype`))throw SyntaxError(`Object contains forbidden prototype property`);for(let e in n){let r=n[e];r&&typeof r==`object`&&t.push(r)}}}return e}function dee(e){let{stackTraceLimit:t}=Error;try{Error.stackTraceLimit=0}catch{return Xh(e)}try{return Xh(e)}finally{Error.stackTraceLimit=t}}function Zh(e){if(e.type===`object`||Array.isArray(e.type)&&e.type.includes(`object`)){let{additionalProperties:t}=e;e.additionalProperties=t!=null&&typeof t!=`boolean`&&Qh(t);let{properties:n}=e;if(n!=null)for(let e of Object.keys(n))n[e]=Qh(n[e])}e.items!=null&&(e.items=Array.isArray(e.items)?e.items.map(Qh):Qh(e.items)),e.anyOf!=null&&(e.anyOf=e.anyOf.map(Qh)),e.allOf!=null&&(e.allOf=e.allOf.map(Qh)),e.oneOf!=null&&(e.oneOf=e.oneOf.map(Qh));let{definitions:t}=e;if(t!=null)for(let e of Object.keys(t))t[e]=Qh(t[e]);return e}function Qh(e){return typeof e==`boolean`?e:Zh(e)}var fee=Symbol(`Let zodToJsonSchema decide on which parser to use`),$h={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`},pee=e=>typeof e==`string`?{...$h,name:e}:{...$h,...e};function eg(){return{}}function mee(e,t){let n={type:`array`};return e.type?._def&&e.type?._def?.typeName!==`ZodAny`&&(n.items=Hg(e.type._def,{...t,currentPath:[...t.currentPath,`items`]})),e.minLength&&(n.minItems=e.minLength.value),e.maxLength&&(n.maxItems=e.maxLength.value),e.exactLength&&(n.minItems=e.exactLength.value,n.maxItems=e.exactLength.value),n}function hee(e){let t={type:`integer`,format:`int64`};if(!e.checks)return t;for(let 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}return t}function gee(){return{type:`boolean`}}function tg(e,t){return Hg(e.type._def,t)}var ng=(e,t)=>Hg(e.innerType._def,t);function rg(e,t,n){let r=n??t.dateStrategy;if(Array.isArray(r))return{anyOf:r.map(n=>rg(e,t,n))};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 ig(e)}}var ig=e=>{let t={type:`integer`,format:`unix-time`};for(let n of e.checks)switch(n.kind){case`min`:t.minimum=n.value;break;case`max`:t.maximum=n.value}return t};function ag(e,t){return{...Hg(e.innerType._def,t),default:e.defaultValue()}}function og(e,t){return t.effectStrategy===`input`?Hg(e.schema._def,t):eg()}function sg(e){return{type:`string`,enum:Array.from(e.values)}}var cg=e=>`type`in e&&e.type===`string`?!1:`allOf`in e;function lg(e,t){let n=[Hg(e.left._def,{...t,currentPath:[...t.currentPath,`allOf`,`0`]}),Hg(e.right._def,{...t,currentPath:[...t.currentPath,`allOf`,`1`]})].filter(e=>!!e),r=[];return n.forEach(e=>{if(cg(e))r.push(...e.allOf);else{let t=e;if(`additionalProperties`in e&&e.additionalProperties===!1){let{additionalProperties:n,...r}=e;t=r}r.push(t)}}),r.length?{allOf:r}:void 0}function _ee(e){let 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 ug=void 0,dg={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:()=>(ug===void 0&&(ug=RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`)),ug),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 fg(e,t){let n={type:`string`};if(e.checks)for(let 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`:gg(n,`email`,r.message,t);break;case`format:idn-email`:gg(n,`idn-email`,r.message,t);break;case`pattern:zod`:_g(n,dg.email,r.message,t)}break;case`url`:gg(n,`uri`,r.message,t);break;case`uuid`:gg(n,`uuid`,r.message,t);break;case`regex`:_g(n,r.regex,r.message,t);break;case`cuid`:_g(n,dg.cuid,r.message,t);break;case`cuid2`:_g(n,dg.cuid2,r.message,t);break;case`startsWith`:_g(n,RegExp(`^${pg(r.value,t)}`),r.message,t);break;case`endsWith`:_g(n,RegExp(`${pg(r.value,t)}$`),r.message,t);break;case`datetime`:gg(n,`date-time`,r.message,t);break;case`date`:gg(n,`date`,r.message,t);break;case`time`:gg(n,`time`,r.message,t);break;case`duration`:gg(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`:_g(n,RegExp(pg(r.value,t)),r.message,t);break;case`ip`:r.version!==`v6`&&gg(n,`ipv4`,r.message,t),r.version!==`v4`&&gg(n,`ipv6`,r.message,t);break;case`base64url`:_g(n,dg.base64url,r.message,t);break;case`jwt`:_g(n,dg.jwt,r.message,t);break;case`cidr`:r.version!==`v6`&&_g(n,dg.ipv4Cidr,r.message,t),r.version!==`v4`&&_g(n,dg.ipv6Cidr,r.message,t);break;case`emoji`:_g(n,dg.emoji(),r.message,t);break;case`ulid`:_g(n,dg.ulid,r.message,t);break;case`base64`:switch(t.base64Strategy){case`format:binary`:gg(n,`binary`,r.message,t);break;case`contentEncoding:base64`:n.contentEncoding=`base64`;break;case`pattern:zod`:_g(n,dg.base64,r.message,t)}break;case`nanoid`:_g(n,dg.nanoid,r.message,t)}return n}function pg(e,t){return t.patternStrategy===`escape`?hg(e):e}var mg=new Set(`ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789`);function hg(e){let t=``;for(let n=0;n<e.length;n++)mg.has(e[n])||(t+=`\\`),t+=e[n];return t}function gg(e,t,n,r){e.format||e.anyOf?.some(e=>e.format)?(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 _g(e,t,n,r){e.pattern||e.allOf?.some(e=>e.pattern)?(e.allOf||=[],e.pattern&&(e.allOf.push({pattern:e.pattern}),delete e.pattern),e.allOf.push({pattern:vg(t,r),...n&&r.errorMessages&&{errorMessage:{pattern:n}}})):e.pattern=vg(t,r)}function vg(e,t){if(!t.applyRegexFlags||!e.flags)return e.source;let n={i:e.flags.includes(`i`),m:e.flags.includes(`m`),s:e.flags.includes(`s`)},r=n.i?e.source.toLowerCase():e.source,i=``,a=!1,o=!1,s=!1;for(let e=0;e<r.length;e++){if(a){i+=r[e],a=!1;continue}if(n.i){if(o){if(r[e].match(/[a-z]/)){s?(i+=r[e],i+=`${r[e-2]}-${r[e]}`.toUpperCase(),s=!1):r[e+1]===`-`&&r[e+2]?.match(/[a-z]/)?(i+=r[e],s=!0):i+=`${r[e]}${r[e].toUpperCase()}`;continue}}else if(r[e].match(/[a-z]/)){i+=`[${r[e]}${r[e].toUpperCase()}]`;continue}}if(n.m){if(r[e]===`^`){i+=`(^|(?<=[\r
|
|
169
169
|
]))`;continue}else if(r[e]===`$`){i+=`($|(?=[\r
|
|
170
|
-
]))`;continue}}if(n.s&&r[e]===`.`){i+=o?`${r[e]}\r\n`:`[${r[e]}\r\n]`;continue}i+=r[e],r[e]===`\\`?a=!0:o&&r[e]===`]`?o=!1:!o&&r[e]===`[`&&(o=!0)}try{new RegExp(i)}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 i}function bg(e,t){let n={type:`object`,additionalProperties:Ug(e.valueType._def,{...t,currentPath:[...t.currentPath,`additionalProperties`]})??t.allowedAdditionalProperties};if(e.keyType?._def.typeName===`ZodString`&&e.keyType._def.checks?.length){let{type:r,...i}=pg(e.keyType._def,t);return{...n,propertyNames:i}}else if(e.keyType?._def.typeName===`ZodEnum`)return{...n,propertyNames:{enum:e.keyType._def.values}};else if(e.keyType?._def.typeName===`ZodBranded`&&e.keyType._def.type._def.typeName===`ZodString`&&e.keyType._def.type._def.checks?.length){let{type:r,...i}=tg(e.keyType._def,t);return{...n,propertyNames:i}}return n}function xg(e,t){return t.mapStrategy===`record`?bg(e,t):{type:`array`,maxItems:125,items:{type:`array`,items:[Ug(e.keyType._def,{...t,currentPath:[...t.currentPath,`items`,`items`,`0`]})||Qh(),Ug(e.valueType._def,{...t,currentPath:[...t.currentPath,`items`,`items`,`1`]})||Qh()],minItems:2,maxItems:2}}}function Sg(e){let t=e.values,n=Object.keys(e.values).filter(e=>typeof t[t[e]]!=`number`).map(e=>t[e]),r=Array.from(new Set(n.map(e=>typeof e)));return{type:r.length===1?r[0]===`string`?`string`:`number`:[`string`,`number`],enum:n}}function Cg(){return{not:Qh()}}function wg(){return{type:`null`}}var Tg={ZodString:`string`,ZodNumber:`number`,ZodBigInt:`integer`,ZodBoolean:`boolean`,ZodNull:`null`};function Eg(e,t){let n=e.options instanceof Map?Array.from(e.options.values()):e.options;if(n.every(e=>e._def.typeName in Tg&&(!e._def.checks||!e._def.checks.length))){let e=n.reduce((e,t)=>{let n=Tg[t._def.typeName];return n&&!e.includes(n)?[...e,n]:e},[]);return{type:e.length>1?e:e[0]}}else if(n.every(e=>e._def.typeName===`ZodLiteral`&&!e.description)){let e=n.reduce((e,t)=>{let n=typeof t._def.value;switch(n){case`string`:case`number`:case`boolean`:return[...e,n];case`bigint`:return[...e,`integer`];case`object`:if(t._def.value===null)return[...e,`null`];default:return e}},[]);if(e.length===n.length){let t=e.filter((e,t,n)=>n.indexOf(e)===t);return{type:t.length>1?t:t[0],enum:n.reduce((e,t)=>e.includes(t._def.value)?e:[...e,t._def.value],[])}}}else if(n.every(e=>e._def.typeName===`ZodEnum`))return{type:`string`,enum:n.reduce((e,t)=>[...e,...t._def.values.filter(t=>!e.includes(t))],[])};return Dg(e,t)}var Dg=(e,t)=>{let n=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((e,n)=>Ug(e._def,{...t,currentPath:[...t.currentPath,`anyOf`,`${n}`]})).filter(e=>!!e&&(!t.strictUnions||typeof e==`object`&&Object.keys(e).length>0));return n.length?{anyOf:n}:void 0};function Og(e,t){if([`ZodString`,`ZodNumber`,`ZodBigInt`,`ZodBoolean`,`ZodNull`].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return{type:[Tg[e.innerType._def.typeName],`null`]};let n=Ug(e.innerType._def,{...t,currentPath:[...t.currentPath,`anyOf`,`0`]});return n&&{anyOf:[n,{type:`null`}]}}function kg(e){let t={type:`number`};if(!e.checks)return t;for(let 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}return t}function Ag(e,t){let n={type:`object`,properties:{}},r=[],i=e.shape();for(let e in i){let a=i[e];if(a===void 0||a._def===void 0)continue;let o=Mg(a),s=Ug(a._def,{...t,currentPath:[...t.currentPath,`properties`,e],propertyPath:[...t.currentPath,`properties`,e]});s!==void 0&&(n.properties[e]=s,o||r.push(e))}r.length&&(n.required=r);let a=jg(e,t);return a!==void 0&&(n.additionalProperties=a),n}function jg(e,t){if(e.catchall._def.typeName!==`ZodNever`)return Ug(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 Mg(e){try{return e.isOptional()}catch{return!0}}var Ng=(e,t)=>{if(t.currentPath.toString()===t.propertyPath?.toString())return Ug(e.innerType._def,t);let n=Ug(e.innerType._def,{...t,currentPath:[...t.currentPath,`anyOf`,`1`]});return n?{anyOf:[{not:Qh()},n]}:Qh()},Pg=(e,t)=>{if(t.pipeStrategy===`input`)return Ug(e.in._def,t);if(t.pipeStrategy===`output`)return Ug(e.out._def,t);let n=Ug(e.in._def,{...t,currentPath:[...t.currentPath,`allOf`,`0`]});return{allOf:[n,Ug(e.out._def,{...t,currentPath:[...t.currentPath,`allOf`,n?`1`:`0`]})].filter(e=>e!==void 0)}};function Fg(e,t){return Ug(e.type._def,t)}function Ig(e,t){let n={type:`array`,uniqueItems:!0,items:Ug(e.valueType._def,{...t,currentPath:[...t.currentPath,`items`]})};return e.minSize&&(n.minItems=e.minSize.value),e.maxSize&&(n.maxItems=e.maxSize.value),n}function Lg(e,t){return e.rest?{type:`array`,minItems:e.items.length,items:e.items.map((e,n)=>Ug(e._def,{...t,currentPath:[...t.currentPath,`items`,`${n}`]})).reduce((e,t)=>t===void 0?e:[...e,t],[]),additionalItems:Ug(e.rest._def,{...t,currentPath:[...t.currentPath,`additionalItems`]})}:{type:`array`,minItems:e.items.length,maxItems:e.items.length,items:e.items.map((e,n)=>Ug(e._def,{...t,currentPath:[...t.currentPath,`items`,`${n}`]})).reduce((e,t)=>t===void 0?e:[...e,t],[])}}function Rg(){return{not:Qh()}}function zg(){return Qh()}var Bg=(e,t)=>Ug(e.innerType._def,t),Vg=(e,t,n)=>{switch(t){case`ZodString`:return pg(e,n);case`ZodNumber`:return kg(e);case`ZodObject`:return Ag(e,n);case`ZodBigInt`:return $h(e);case`ZodBoolean`:return eg();case`ZodDate`:return rg(e,n);case`ZodUndefined`:return Rg();case`ZodNull`:return wg();case`ZodArray`:return gee(e,n);case`ZodUnion`:case`ZodDiscriminatedUnion`:return Eg(e,n);case`ZodIntersection`:return lg(e,n);case`ZodTuple`:return Lg(e,n);case`ZodRecord`:return bg(e,n);case`ZodLiteral`:return ug(e);case`ZodEnum`:return sg(e);case`ZodNativeEnum`:return Sg(e);case`ZodNullable`:return Og(e,n);case`ZodOptional`:return Ng(e,n);case`ZodMap`:return xg(e,n);case`ZodSet`:return Ig(e,n);case`ZodLazy`:return()=>e.getter()._def;case`ZodPromise`:return Fg(e,n);case`ZodNaN`:case`ZodNever`:return Cg();case`ZodEffects`:return og(e,n);case`ZodAny`:return Qh();case`ZodUnknown`:return zg();case`ZodDefault`:return ag(e,n);case`ZodBranded`:return tg(e,n);case`ZodReadonly`:return Bg(e,n);case`ZodCatch`:return ng(e,n);case`ZodPipeline`:return Pg(e,n);case`ZodFunction`:case`ZodVoid`:case`ZodSymbol`:return;default:return(e=>void 0)(t)}},Hg=(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 Ug(e,t,n=!1){let r=t.seen.get(e);if(t.override){let i=t.override?.(e,t,r,n);if(i!==mee)return i}if(r&&!n){let e=Wg(r,t);if(e!==void 0)return e}let i={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,i);let a=Vg(e,e.typeName,t),o=typeof a==`function`?Ug(a(),t):a;if(o&&Gg(e,t,o),t.postProcess){let n=t.postProcess(o,e,t);return i.jsonSchema=o,n}return i.jsonSchema=o,o}var Wg=(e,t)=>{switch(t.$refStrategy){case`root`:return{$ref:e.path.join(`/`)};case`relative`:return{$ref:Hg(t.currentPath,e.path)};case`none`:case`seen`:return e.path.length<t.currentPath.length&&e.path.every((e,n)=>t.currentPath[n]===e)?(console.warn(`Recursive reference detected at ${t.currentPath.join(`/`)}! Defaulting to any`),Qh()):t.$refStrategy===`seen`?Qh():void 0}},Gg=(e,t,n)=>(e.description&&(n.description=e.description),n),Kg=e=>{let t=hee(e),n=t.name===void 0?t.basePath:[...t.basePath,t.definitionPath,t.name];return{...t,currentPath:n,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([e,n])=>[n._def,{def:n._def,path:[...t.basePath,t.definitionPath,e],jsonSchema:void 0}]))}},qg=(e,t)=>{let n=Kg(t),r=typeof t==`object`&&t.definitions?Object.entries(t.definitions).reduce((e,[t,r])=>({...e,[t]:Ug(r._def,{...n,currentPath:[...n.basePath,n.definitionPath,t]},!0)??Qh()}),{}):void 0,i=typeof t==`string`?t:t?.nameStrategy===`title`?void 0:t?.name,a=Ug(e._def,i===void 0?n:{...n,currentPath:[...n.basePath,n.definitionPath,i]},!1)??Qh(),o=typeof t==`object`&&t.name!==void 0&&t.nameStrategy===`title`?t.name:void 0;o!==void 0&&(a.title=o);let s=i===void 0?r?{...a,[n.definitionPath]:r}:a:{$ref:[...n.$refStrategy===`relative`?[]:n.basePath,n.definitionPath,i].join(`/`),[n.definitionPath]:{...r,[i]:a}};return s.$schema=`http://json-schema.org/draft-07/schema#`,s},Jg=Symbol.for(`vercel.ai.schema`);function Yg(e){let t;return()=>(t??=e(),t)}function Xg(e,{validate:t}={}){return{[Jg]:!0,_type:void 0,get jsonSchema(){return typeof e==`function`&&(e=e()),e},validate:t}}function Zg(e){return typeof e==`object`&&!!e&&Jg in e&&e[Jg]===!0&&`jsonSchema`in e&&`validate`in e}function Qg(e){return e==null?Xg({type:`object`,properties:{},additionalProperties:!1}):Zg(e)?e:`~standard`in e?e[`~standard`].vendor===`zod`?r_(e):$g(e):e()}function $g(e){return Xg(()=>{if(!_ee(e))throw Error(`Standard schema vendor '${e[`~standard`].vendor}' does not support JSON Schema conversion.`);return Yh(e[`~standard`].jsonSchema.input({target:`draft-07`}))},{validate:async t=>{let n=await e[`~standard`].validate(t);return n.issues===void 0&&`value`in n?{success:!0,value:n.value}:{success:!1,error:new Dh({value:t,cause:n.issues})}}})}function _ee(e){return e[`~standard`].jsonSchema!=null}function e_(e,t){let n=t?.useReferences??!1;return Xg(()=>qg(e,{$refStrategy:n?`root`:`none`}),{validate:async t=>{let n=await e.safeParseAsync(t);return n.success?{success:!0,value:n.data}:{success:!1,error:n.error}}})}function t_(e,t){It().localeError||It(pe());let n=t?.useReferences??!1;return Xg(()=>Yh(Le(e,{target:`draft-7`,io:`input`,reused:n?`ref`:`inline`})),{validate:async t=>{let n=await Oe(e,t);return n.success?{success:!0,value:n.data}:{success:!1,error:n.error}}})}function n_(e){return`_zod`in e}function r_(e,t){return n_(e)?t_(e,t):e_(e,t)}async function i_({value:e,schema:t,context:n}){let r=await a_({value:e,schema:t,context:n});if(!r.success)throw Dh.wrap({value:e,cause:r.error,context:n});return r.value}async function a_({value:e,schema:t,context:n}){let r=Qg(t);try{if(r.validate==null)return{success:!0,value:e,rawValue:e};let t=await r.validate(e);return t.success?{success:!0,value:t.value,rawValue:e}:{success:!1,error:Dh.wrap({value:e,cause:t.error,context:n}),rawValue:e}}catch(t){return{success:!1,error:Dh.wrap({value:e,cause:t,context:n}),rawValue:e}}}async function o_({text:e,schema:t}){try{let n=pee(e);return t==null?{success:!0,value:n,rawValue:n}:await a_({value:n,schema:t})}catch(t){return{success:!1,error:Ch.isInstance(t)?t:new Ch({text:e,cause:t}),rawValue:void 0}}}function s_({stream:e,schema:t}){return e.pipeThrough(new TextDecoderStream).pipeThrough(new Bh).pipeThrough(new TransformStream({async transform({data:e},n){e!==`[DONE]`&&n.enqueue(await o_({text:e,schema:t}))}}))}async function c_(e){return typeof e==`function`&&(e=e()),e}new TextDecoder;var l_=er(`ZodMiniType`,(e,t)=>{if(!e._zod)throw Error(`Uninitialized schema in ZodMiniType.`);Zn.init(e,t),e.def=t,e.type=t.type},{get with(){return this.check},set with(e){nt(this,`with`,e)},parse(e,t){return In(this,e,t,{callee:this.parse})},parseAsync(e,t){return Cn(this,e,t,{callee:this.parseAsync})},safeParse(e,t){return an(this,e,t)},safeParseAsync(e,t){return en(this,e,t)},check(...e){let t=this.def;return this.clone({...t,checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]},{parent:!0})},clone(e,t){return cr(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},apply(e,...t){return t.length===0?e(this):e(this,...t)}}),vee=er(`ZodMiniString`,(e,t)=>{zt.init(e,t),l_.init(e,t)});function u_(e){return ve(vee,e)}var d_=er(`ZodMiniNumber`,(e,t)=>{On.init(e,t),l_.init(e,t)});function f_(e){return oe(d_,e)}var p_=er(`ZodMiniNumberFormat`,(e,t)=>{Un.init(e,t),d_.init(e,t)});function m_(e){return xe(p_,e)}var h_=er(`ZodMiniBoolean`,(e,t)=>{gt.init(e,t),l_.init(e,t)});function g_(e){return ne(h_,e)}var __=er(`ZodMiniUnknown`,(e,t)=>{Yt.init(e,t),l_.init(e,t)});function v_(){return Ln(__)}var y_=er(`ZodMiniNever`,(e,t)=>{Yn.init(e,t),l_.init(e,t)});function b_(e){return _(y_,e)}var x_=er(`ZodMiniArray`,(e,t)=>{vt.init(e,t),l_.init(e,t)});function S_(e,t){return new x_({type:`array`,element:e,...ir(t)})}var C_=er(`ZodMiniObject`,(e,t)=>{dn.init(e,t),l_.init(e,t),S(e,`shape`,e=>e._zod.def.shape,!1)});function w_(e,t){return new C_({type:`object`,shape:e??{},...ir(t)})}function T_(e,t){return new C_({type:`object`,shape:e,catchall:v_(),...ir(t)})}function E_(e,t){return Qe(e,t)}var D_=er(`ZodMiniUnion`,(e,t)=>{Vt.init(e,t),l_.init(e,t)});function O_(e,t){return new D_({type:`union`,options:e,...ir(t)})}var k_=er(`ZodMiniDiscriminatedUnion`,(e,t)=>{Ve.init(e,t),l_.init(e,t)});function A_(e,t,n){return new k_({type:`union`,options:t,discriminator:e,...ir(n)})}var j_=er(`ZodMiniRecord`,(e,t)=>{Gn.init(e,t),l_.init(e,t)});function M_(e,t,n){return!t||!t._zod?new j_({type:`record`,keyType:u_(),valueType:e,...ir(t)}):new j_({type:`record`,keyType:e,valueType:t,...ir(n)})}var N_=er(`ZodMiniEnum`,(e,t)=>{u.init(e,t),l_.init(e,t),e.options=[...e._zod.values]});function P_(e,t){return new N_({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...ir(t)})}var F_=er(`ZodMiniLiteral`,(e,t)=>{Kt.init(e,t),l_.init(e,t)});function I_(e,t){return new F_({type:`literal`,values:Array.isArray(e)?e:[e],...ir(t)})}var L_=er(`ZodMiniTransform`,(e,t)=>{vn.init(e,t),l_.init(e,t)});function R_(e){return new L_({type:`transform`,transform:e})}var z_=er(`ZodMiniOptional`,(e,t)=>{Mt.init(e,t),l_.init(e,t)});function B_(e){return new z_({type:`optional`,innerType:e})}var V_=er(`ZodMiniPipe`,(e,t)=>{jn.init(e,t),l_.init(e,t)});function H_(e,t){return new V_({type:`pipe`,in:e,out:t})}var U_=er(`ZodMiniCustom`,(e,t)=>{St.init(e,t),l_.init(e,t)});function W_(e,t){return le(U_,e??(()=>!0),t)}function G_(e,t={}){return pt(U_,e,t)}var K_=`AI_InvalidArgumentError`,q_=`vercel.ai.error.${K_}`,J_=Symbol.for(q_),Y_=class extends oh{constructor({parameter:e,value:t,message:n}){super({name:K_,message:`Invalid argument for parameter ${e}: ${n}`}),this[J_]=!0,this.parameter=e,this.value=t}static isInstance(e){return oh.hasMarker(e,q_)}},X_=new Map([[`generateObject`,`AISDK_DEP_GENERATE_OBJECT`],[`streamObject`,`AISDK_DEP_STREAM_OBJECT`],[`experimental_generateSpeech`,`AISDK_DEP_EXPERIMENTAL_GENERATE_SPEECH`],[`experimental_transcribe`,`AISDK_DEP_EXPERIMENTAL_TRANSCRIBE`],[`"image" content part`,`AISDK_DEP_IMAGE_CONTENT_PART`],[`"tool-result" content of type "file-data"`,`AISDK_DEP_TOOL_RESULT_FILE_DATA`],[`"tool-result" content of type "file-url"`,`AISDK_DEP_TOOL_RESULT_FILE_URL`],[`"tool-result" content of type "file-id"`,`AISDK_DEP_TOOL_RESULT_FILE_ID`],[`"tool-result" content of type "file-reference"`,`AISDK_DEP_TOOL_RESULT_FILE_REFERENCE`],[`"tool-result" content of type "image-data"`,`AISDK_DEP_TOOL_RESULT_IMAGE_DATA`],[`"tool-result" content of type "image-url"`,`AISDK_DEP_TOOL_RESULT_IMAGE_URL`],[`"tool-result" content of type "image-file-id"`,`AISDK_DEP_TOOL_RESULT_IMAGE_FILE_ID`],[`"tool-result" content of type "image-file-reference"`,`AISDK_DEP_TOOL_RESULT_IMAGE_FILE_REFERENCE`],[`rawInput in output-error UI message parts`,`AISDK_DEP_UI_MESSAGE_RAW_INPUT`]]);function Z_(e){return e.replace(/[^a-zA-Z0-9]/g,e=>`_${e.charCodeAt(0).toString(16).toUpperCase().padStart(4,`0`)}`)}function Q_({setting:e,provider:t}){return t==null?X_.get(e)??`AISDK_DEP_SETTING_${Z_(e)}`:`AISDK_DEP_PROVIDER_${Z_(t)}__${Z_(e)}`}function $_({warning:e,provider:t,model:n}){let r=`AI SDK Warning${t!=null&&n!=null?` (${t} / ${n})`:``}:`;switch(e.type){case`unsupported`:{let t=`${r} The feature "${e.feature}" is not supported.`;return e.details&&(t+=` ${e.details}`),t}case`compatibility`:{let t=`${r} The feature "${e.feature}" is used in a compatibility mode.`;return e.details&&(t+=` ${e.details}`),t}case`deprecated`:return`${r} Deprecated: "${e.setting}". ${e.message}`;case`other`:return`${r} ${e.message}`;default:return`${r} ${JSON.stringify(e,null,2)}`}}var ev=`AI SDK Warning System: To turn off warning logging, set the AI_SDK_LOG_WARNINGS global to false.`,tv=!1,nv=new Set;function rv({message:e,type:t,code:n}){typeof process<`u`&&typeof process.emitWarning==`function`?process.emitWarning(e,n==null?{type:t}:{type:t,code:n}):console.warn(n==null?e:`[${n}] ${e}`)}var iv=e=>{if(e.warnings.length===0)return;let t=globalThis.AI_SDK_LOG_WARNINGS;if(t!==!1){if(typeof t==`function`){t(e);return}tv||(tv=!0,rv({message:ev,type:`Warning`}));for(let t of e.warnings){let n=t.type===`deprecated`?Q_({setting:t.setting,provider:e.provider}):void 0;if(n!=null){if(nv.has(n))continue;nv.add(n)}rv({message:$_({warning:t,provider:e.provider,model:e.model}),type:t.type===`deprecated`?`DeprecationWarning`:`Warning`,code:n})}}};function av(e,t){if(e===void 0&&t===void 0)return;if(e===void 0)return t;if(t===void 0)return e;let n={...e};for(let r in t)if(!(r===`__proto__`||r===`constructor`||r===`prototype`)&&Object.prototype.hasOwnProperty.call(t,r)){let i=t[r];if(i===void 0)continue;let a=r in e?e[r]:void 0,o=typeof i==`object`&&!!i&&!Array.isArray(i)&&!(i instanceof Date)&&!(i instanceof RegExp),s=typeof a==`object`&&!!a&&!Array.isArray(a)&&!(a instanceof Date)&&!(a instanceof RegExp);o&&s?n[r]=av(a,i):n[r]=i}return n}function ov(e,t){return e!=null&&Object.hasOwn(e,t)?e[t]:void 0}function sv(e,t){if(e===t)return!0;if(e==null||t==null)return!1;if(typeof e!=`object`&&typeof t!=`object`)return e===t;if(e.constructor!==t.constructor)return!1;if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if(Array.isArray(e)){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!sv(e[n],t[n]))return!1;return!0}let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let i of n)if(!r.includes(i)||!sv(e[i],t[i]))return!1;return!0}new TextEncoder,new TextEncoder;var cv=`AI_UIMessageStreamError`,lv=`vercel.ai.error.${cv}`,uv=Symbol.for(lv),dv=class extends oh{constructor({chunkType:e,chunkId:t,message:n}){super({name:cv,message:n}),this[uv]=!0,this.chunkType=e,this.chunkId=t}static isInstance(e){return oh.hasMarker(e,lv)}};function fv(e){let t=[`ROOT`],n=-1,r=null,i=0;function a(e){return e>=`0`&&e<=`9`||e>=`A`&&e<=`F`||e>=`a`&&e<=`f`}function o(e,i,a){switch(e){case`"`:n=i,t.pop(),t.push(a),t.push(`INSIDE_STRING`);break;case`f`:case`t`:case`n`:n=i,r=i,t.pop(),t.push(a),t.push(`INSIDE_LITERAL`);break;case`-`:t.pop(),t.push(a),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=i,t.pop(),t.push(a),t.push(`INSIDE_NUMBER`);break;case`{`:n=i,t.pop(),t.push(a),t.push(`INSIDE_OBJECT_START`);break;case`[`:n=i,t.pop(),t.push(a),t.push(`INSIDE_ARRAY_START`)}}function s(e,r){switch(e){case`,`:t.pop(),t.push(`INSIDE_OBJECT_AFTER_COMMA`);break;case`}`:n=r,t.pop()}}function c(e,r){switch(e){case`,`:t.pop(),t.push(`INSIDE_ARRAY_AFTER_COMMA`);break;case`]`:n=r,t.pop()}}for(let l=0;l<e.length;l++){let u=e[l];switch(t[t.length-1]){case`ROOT`:o(u,l,`FINISH`);break;case`INSIDE_OBJECT_START`:switch(u){case`"`:t.pop(),t.push(`INSIDE_OBJECT_KEY`);break;case`}`:n=l,t.pop()}break;case`INSIDE_OBJECT_AFTER_COMMA`:switch(u){case`"`:t.pop(),t.push(`INSIDE_OBJECT_KEY`)}break;case`INSIDE_OBJECT_KEY`:switch(u){case`"`:t.pop(),t.push(`INSIDE_OBJECT_AFTER_KEY`)}break;case`INSIDE_OBJECT_AFTER_KEY`:switch(u){case`:`:t.pop(),t.push(`INSIDE_OBJECT_BEFORE_VALUE`)}break;case`INSIDE_OBJECT_BEFORE_VALUE`:o(u,l,`INSIDE_OBJECT_AFTER_VALUE`);break;case`INSIDE_OBJECT_AFTER_VALUE`:s(u,l);break;case`INSIDE_STRING`:switch(u){case`"`:t.pop(),n=l;break;case`\\`:t.push(`INSIDE_STRING_ESCAPE`);break;default:n=l}break;case`INSIDE_ARRAY_START`:switch(u){case`]`:n=l,t.pop();break;default:o(u,l,`INSIDE_ARRAY_AFTER_VALUE`)}break;case`INSIDE_ARRAY_AFTER_VALUE`:switch(u){case`,`:t.pop(),t.push(`INSIDE_ARRAY_AFTER_COMMA`);break;case`]`:n=l,t.pop();break;default:n=l}break;case`INSIDE_ARRAY_AFTER_COMMA`:o(u,l,`INSIDE_ARRAY_AFTER_VALUE`);break;case`INSIDE_STRING_ESCAPE`:t.pop(),u===`u`?(i=0,t.push(`INSIDE_STRING_UNICODE_ESCAPE`)):n=l;break;case`INSIDE_STRING_UNICODE_ESCAPE`:a(u)&&(i++,i===4&&(t.pop(),n=l));break;case`INSIDE_NUMBER`:switch(u){case`0`:case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:n=l;break;case`e`:case`E`:case`-`:case`.`:break;case`,`:t.pop(),t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&c(u,l),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`&&s(u,l);break;case`}`:t.pop(),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`&&s(u,l);break;case`]`:t.pop(),t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&c(u,l);break;default:t.pop()}break;case`INSIDE_LITERAL`:{let i=e.substring(r,l+1);!`false`.startsWith(i)&&!`true`.startsWith(i)&&!`null`.startsWith(i)?(t.pop(),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`?s(u,l):t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&c(u,l)):n=l;break}}}let l=e.slice(0,n+1);for(let n=t.length-1;n>=0;n--)switch(t[n]){case`INSIDE_STRING`:l+=`"`;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`:l+=`}`;break;case`INSIDE_ARRAY_START`:case`INSIDE_ARRAY_AFTER_COMMA`:case`INSIDE_ARRAY_AFTER_VALUE`:l+=`]`;break;case`INSIDE_LITERAL`:{let t=e.substring(r,e.length);`true`.startsWith(t)?l+=`true`.slice(t.length):`false`.startsWith(t)?l+=`false`.slice(t.length):`null`.startsWith(t)&&(l+=`null`.slice(t.length))}}return l}async function pv(e){if(e===void 0)return{value:void 0,state:`undefined-input`};let t=await o_({text:e});return t.success?{value:t.value,state:`successful-parse`}:(t=await o_({text:fv(e)}),t.success?{value:t.value,state:`repaired-parse`}:{value:void 0,state:`failed-parse`})}Kh({prefix:`steer`,size:24}),Kh({prefix:`aitxt`,size:24}),Kh({prefix:`call`,size:24}),TransformStream;var V={NEVER:fr,array:S_,boolean:g_,custom:W_,discriminatedUnion:A_,enum:P_,extend:E_,int:m_,literal:I_,looseObject:T_,maximum:Ge,minLength:pr,never:b_,nonnegative:ct,number:f_,object:w_,optional:B_,pipe:H_,positive:rt,record:M_,refine:G_,safeParse:an,startsWith:j,string:u_,transform:R_,union:O_,unknown:v_},H={array:Xt,boolean:Dt,custom:Qn,discriminatedUnion:lr,instanceof:yn,lazy:ar,literal:Ye,null:tn,number:tr,object:F,record:C,string:L,union:p,unknown:fn},mv=H.lazy(()=>H.union([H.null(),H.string(),H.number(),H.boolean(),H.record(H.string(),mv.optional()),H.array(mv)])),U=H.record(H.string(),H.record(H.string(),mv.optional()));function hv(e){return V.object({source:V.discriminatedUnion(`sourceType`,[V.object({type:V.literal(`source`),sourceType:V.literal(`url`),id:V.string(),url:V.string(),title:V.optional(V.string()),providerMetadata:V.optional(e)}),V.object({type:V.literal(`source`),sourceType:V.literal(`document`),id:V.string(),mediaType:V.string(),title:V.string(),filename:V.optional(V.string()),providerMetadata:V.optional(e)})]),startIndex:V.optional(V.number().check(V.int()).check(V.nonnegative())),endIndex:V.optional(V.number().check(V.int()).check(V.nonnegative())),citedText:V.optional(V.string())})}var gv=hv(U),_v=V.record(V.string(),V.optional(mv)),vv=Yg(()=>r_(V.union([V.looseObject({type:V.literal(`text-start`),id:V.string(),providerMetadata:V.optional(U)}),V.looseObject({type:V.literal(`text-delta`),id:V.string(),delta:V.string(),providerMetadata:V.optional(U)}),V.looseObject({type:V.literal(`text-end`),id:V.string(),citations:V.optional(V.array(gv)),providerMetadata:V.optional(U)}),V.looseObject({type:V.literal(`error`),errorText:V.string()}),V.looseObject({type:V.literal(`tool-input-start`),toolCallId:V.string(),toolName:V.string(),inputEncoding:V.optional(V.enum([`json`,`text`])),providerExecuted:V.optional(V.boolean()),providerMetadata:V.optional(U),toolMetadata:V.optional(_v),dynamic:V.optional(V.boolean()),title:V.optional(V.string())}),V.looseObject({type:V.literal(`tool-input-delta`),toolCallId:V.string(),inputTextDelta:V.string()}),V.looseObject({type:V.literal(`tool-input-available`),toolCallId:V.string(),toolName:V.string(),input:V.unknown(),providerExecuted:V.optional(V.boolean()),providerMetadata:V.optional(U),toolMetadata:V.optional(_v),dynamic:V.optional(V.boolean()),title:V.optional(V.string())}),V.looseObject({type:V.literal(`tool-input-error`),toolCallId:V.string(),toolName:V.string(),input:V.unknown(),providerExecuted:V.optional(V.boolean()),providerMetadata:V.optional(U),toolMetadata:V.optional(_v),dynamic:V.optional(V.boolean()),errorText:V.string(),title:V.optional(V.string())}),V.looseObject({type:V.literal(`tool-approval-request`),approvalId:V.string(),toolCallId:V.string(),approvalDescriptor:V.optional(V.unknown()),inputSchemaInput:V.optional(V.unknown()),reason:V.optional(V.string()),isAutomatic:V.optional(V.boolean()),signature:V.optional(V.string())}),V.looseObject({type:V.literal(`tool-approval-response`),approvalId:V.string(),approved:V.boolean(),reason:V.optional(V.string()),providerExecuted:V.optional(V.boolean()),providerMetadata:V.optional(U)}),V.looseObject({type:V.literal(`tool-output-available`),toolCallId:V.string(),output:V.unknown(),providerExecuted:V.optional(V.boolean()),providerMetadata:V.optional(U),toolMetadata:V.optional(_v),dynamic:V.optional(V.boolean()),preliminary:V.optional(V.boolean())}),V.looseObject({type:V.literal(`tool-output-error`),toolCallId:V.string(),errorText:V.string(),providerExecuted:V.optional(V.boolean()),providerMetadata:V.optional(U),toolMetadata:V.optional(_v),dynamic:V.optional(V.boolean())}),V.looseObject({type:V.literal(`tool-output-denied`),toolCallId:V.string()}),V.looseObject({type:V.literal(`reasoning-start`),id:V.string(),providerMetadata:V.optional(U)}),V.looseObject({type:V.literal(`reasoning-delta`),id:V.string(),delta:V.string(),providerMetadata:V.optional(U)}),V.looseObject({type:V.literal(`reasoning-end`),id:V.string(),providerMetadata:V.optional(U)}),V.looseObject({type:V.literal(`custom`),kind:V.pipe(V.string(),V.transform(e=>e)),providerMetadata:V.optional(U)}),V.looseObject({type:V.literal(`source-url`),sourceId:V.string(),url:V.string(),title:V.optional(V.string()),providerMetadata:V.optional(U)}),V.looseObject({type:V.literal(`source-document`),sourceId:V.string(),mediaType:V.string(),title:V.string(),filename:V.optional(V.string()),providerMetadata:V.optional(U)}),V.looseObject({type:V.literal(`file`),url:V.string(),mediaType:V.string(),providerMetadata:V.optional(U)}),V.looseObject({type:V.literal(`reasoning-file`),url:V.string(),mediaType:V.string(),providerMetadata:V.optional(U)}),V.looseObject({type:V.literal(`steering-message`),id:V.string(),parts:V.array(V.union([V.looseObject({type:V.literal(`text`),text:V.string(),providerMetadata:V.optional(U)}),V.looseObject({type:V.literal(`file`),mediaType:V.string(),url:V.string(),filename:V.optional(V.string()),providerReference:V.optional(V.record(V.string(),V.string())),providerMetadata:V.optional(U)})]))}),V.looseObject({type:V.custom(e=>typeof e==`string`&&e.startsWith(`data-`),{message:`Type must start with "data-"`}),id:V.optional(V.string()),data:V.unknown(),transient:V.optional(V.boolean())}),V.looseObject({type:V.literal(`start-step`)}),V.looseObject({type:V.literal(`finish-step`)}),V.looseObject({type:V.literal(`reset-step`)}),V.looseObject({type:V.literal(`start`),messageId:V.optional(V.string()),messageMetadata:V.optional(V.unknown())}),V.looseObject({type:V.literal(`finish`),finishReason:V.optional(V.enum([`stop`,`length`,`content-filter`,`tool-calls`,`error`,`interrupted`,`other`])),messageMetadata:V.optional(V.unknown())}),V.looseObject({type:V.literal(`abort`),reason:V.optional(V.string())}),V.looseObject({type:V.literal(`message-metadata`),messageMetadata:V.unknown()})])));function yv(e){return e.type.startsWith(`data-`)}function bv(){return Object.create(null)}function xv(e){return e.type===`text`}function Sv(e){return e.type===`reasoning`}function Cv(e){return e.type.startsWith(`tool-`)}function wv(e){return e.type===`dynamic-tool`}function Tv(e){return Cv(e)||wv(e)}function Ev(e){return e.type.split(`-`).slice(1).join(`-`)}function Dv(e){return wv(e)?e.toolName:Ev(e)}function Ov({lastMessage:e,messageId:t}){let n=e?.role===`assistant`?e:{id:t,metadata:void 0,role:`assistant`,parts:[]},r=bv(),i=n.parts.findLastIndex(e=>e.type===`step-start`),a=0;for(let e of n.parts.slice(i+1)){if(!Tv(e))continue;let t=a;Cv(e)&&a++,e.state===`input-streaming`&&(r[e.toolCallId]={text:e.rawInput??``,inputEncoding:e.inputEncoding,index:t,toolName:e.type===`dynamic-tool`?e.toolName:Ev(e),dynamic:e.type===`dynamic-tool`,title:e.title,toolMetadata:e.toolMetadata})}return{message:n,activeTextParts:bv(),activeReasoningParts:bv(),partialToolCalls:r}}function kv({stream:e,messageMetadataSchema:t,dataPartSchemas:n,runUpdateMessageJob:r,onError:i,onToolCall:a,onData:o,resetStateOnMessageIdChange:s=!1,resetStateOnFirstMessageStart:c=!1}){let l=!0;return e.pipeThrough(new TransformStream({async transform(e,u){await r(async({state:r,write:d})=>{function f(){let e=r.message.parts,t=e.length-1;for(;t>=0&&e[t].type!==`step-start`;)t--;return e.slice(t+1)}function p(){return f().filter(Tv)}function m(e){let t=p().find(t=>t.toolCallId===e);if(t==null){let n=r.message.parts;for(let r=n.length-1;r>=0;r--){let i=n[r];if(Tv(i)&&i.toolCallId===e){t=i;break}}}if(t==null)throw new dv({chunkType:`tool-invocation`,chunkId:e,message:`No tool invocation found for tool call ID "${e}".`});return t}function h(e){let t=r.message.parts.filter(Tv).find(t=>t.approval?.id===e);if(t==null)throw new dv({chunkType:`tool-approval-response`,chunkId:e,message:`No tool invocation found for approval ID "${e}".`});return t}function g(e,t){let n=t??f().find(t=>Cv(t)&&t.toolCallId===e.toolCallId),i=e,a=n;if(n!=null){n.state=e.state,a.type=`tool-${e.toolName}`,a.input=i.input,a.output=i.output,a.errorText=i.errorText,a.rawInput=i.rawInput,i.inputEncoding==null?delete a.inputEncoding:a.inputEncoding=i.inputEncoding,a.preliminary=i.preliminary,e.title!==void 0&&(a.title=e.title),e.toolMetadata!==void 0&&(a.toolMetadata=e.toolMetadata),a.providerExecuted=i.providerExecuted??n.providerExecuted;let t=i.providerMetadata;if(t!=null)if(e.state===`output-available`||e.state===`output-error`){let e=n;e.resultProviderMetadata=t}else n.callProviderMetadata=t}else r.message.parts.push({type:`tool-${e.toolName}`,toolCallId:e.toolCallId,state:e.state,title:e.title,...e.toolMetadata===void 0?{}:{toolMetadata:e.toolMetadata},input:i.input,...i.inputEncoding==null?{}:{inputEncoding:i.inputEncoding},output:i.output,rawInput:i.rawInput,errorText:i.errorText,providerExecuted:i.providerExecuted,preliminary:i.preliminary,...i.providerMetadata!=null&&(e.state===`output-available`||e.state===`output-error`)?{resultProviderMetadata:i.providerMetadata}:{},...i.providerMetadata!=null&&!(e.state===`output-available`||e.state===`output-error`)?{callProviderMetadata:i.providerMetadata}:{}})}function _(e,t){let n=t??f().find(t=>t.type===`dynamic-tool`&&t.toolCallId===e.toolCallId),i=e,a=n;if(n!=null){n.state=e.state,a.toolName=e.toolName,a.input=i.input,a.output=i.output,a.errorText=i.errorText,a.rawInput=i.rawInput,i.inputEncoding==null?delete a.inputEncoding:a.inputEncoding=i.inputEncoding,a.preliminary=i.preliminary,e.title!==void 0&&(a.title=e.title),e.toolMetadata!==void 0&&(a.toolMetadata=e.toolMetadata),a.providerExecuted=i.providerExecuted??n.providerExecuted;let t=i.providerMetadata;if(t!=null)if(e.state===`output-available`||e.state===`output-error`){let e=n;e.resultProviderMetadata=t}else n.callProviderMetadata=t}else r.message.parts.push({type:`dynamic-tool`,toolName:e.toolName,toolCallId:e.toolCallId,state:e.state,input:i.input,...i.inputEncoding==null?{}:{inputEncoding:i.inputEncoding},output:i.output,errorText:i.errorText,preliminary:i.preliminary,providerExecuted:i.providerExecuted,title:e.title,...e.toolMetadata===void 0?{}:{toolMetadata:e.toolMetadata},...i.providerMetadata!=null&&(e.state===`output-available`||e.state===`output-error`)?{resultProviderMetadata:i.providerMetadata}:{},...i.providerMetadata!=null&&!(e.state===`output-available`||e.state===`output-error`)?{callProviderMetadata:i.providerMetadata}:{}})}async function v(e){if(e!=null){let n=r.message.metadata==null?e:av(r.message.metadata,e);t!=null&&await i_({value:n,schema:t,context:{field:`message.metadata`,entityId:r.message.id}}),r.message.metadata=n}}switch(e.type){case`text-start`:{let t={type:`text`,text:``,providerMetadata:e.providerMetadata,state:`streaming`};r.activeTextParts[e.id]=t,r.message.parts.push(t),d();break}case`text-delta`:{let t=r.activeTextParts[e.id];if(t==null)throw new dv({chunkType:`text-delta`,chunkId:e.id,message:`Received text-delta for missing text part with ID "${e.id}". Ensure a "text-start" chunk is sent before any "text-delta" chunks.`});t.text+=e.delta,t.providerMetadata=e.providerMetadata??t.providerMetadata,d();break}case`text-end`:{let t=r.activeTextParts[e.id];if(t==null)throw new dv({chunkType:`text-end`,chunkId:e.id,message:`Received text-end for missing text part with ID "${e.id}". Ensure a "text-start" chunk is sent before any "text-end" chunks.`});t.state=`done`,e.citations!=null&&(t.citations=e.citations),t.providerMetadata=e.providerMetadata??t.providerMetadata,delete r.activeTextParts[e.id],d();break}case`custom`:{let t={type:`custom`,kind:e.kind,providerMetadata:e.providerMetadata};r.message.parts.push(t),d();break}case`reasoning-start`:{let t={type:`reasoning`,id:e.id,text:``,providerMetadata:e.providerMetadata,state:`streaming`};r.activeReasoningParts[e.id]=t,r.message.parts.push(t),d();break}case`reasoning-delta`:{let t=r.activeReasoningParts[e.id];if(t==null)throw new dv({chunkType:`reasoning-delta`,chunkId:e.id,message:`Received reasoning-delta for missing reasoning part with ID "${e.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-delta" chunks.`});t.text+=e.delta,t.providerMetadata=e.providerMetadata??t.providerMetadata,d();break}case`reasoning-end`:{let t=r.activeReasoningParts[e.id];if(t==null)throw new dv({chunkType:`reasoning-end`,chunkId:e.id,message:`Received reasoning-end for missing reasoning part with ID "${e.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-end" chunks.`});t.providerMetadata=e.providerMetadata??t.providerMetadata,t.state=`done`,delete r.activeReasoningParts[e.id],d();break}case`file`:case`reasoning-file`:r.message.parts.push({type:e.type,mediaType:e.mediaType,url:e.url,...e.providerMetadata==null?{}:{providerMetadata:e.providerMetadata}}),d();break;case`source-url`:r.message.parts.push({type:`source-url`,sourceId:e.sourceId,url:e.url,title:e.title,providerMetadata:e.providerMetadata}),d();break;case`source-document`:r.message.parts.push({type:`source-document`,sourceId:e.sourceId,mediaType:e.mediaType,title:e.title,filename:e.filename,providerMetadata:e.providerMetadata}),d();break;case`tool-input-start`:{let t=f().filter(Cv);r.partialToolCalls[e.toolCallId]={text:``,inputEncoding:e.inputEncoding,toolName:e.toolName,index:t.length,dynamic:e.dynamic,title:e.title,toolMetadata:e.toolMetadata},e.dynamic?_({toolCallId:e.toolCallId,toolName:e.toolName,state:`input-streaming`,inputEncoding:e.inputEncoding,input:void 0,providerExecuted:e.providerExecuted,title:e.title,toolMetadata:e.toolMetadata,providerMetadata:e.providerMetadata}):g({toolCallId:e.toolCallId,toolName:e.toolName,state:`input-streaming`,inputEncoding:e.inputEncoding,input:void 0,providerExecuted:e.providerExecuted,title:e.title,toolMetadata:e.toolMetadata,providerMetadata:e.providerMetadata}),d();break}case`tool-input-delta`:{let t=r.partialToolCalls[e.toolCallId];if(t==null)throw new dv({chunkType:`tool-input-delta`,chunkId:e.toolCallId,message:`Received tool-input-delta for missing tool call with ID "${e.toolCallId}". Ensure a "tool-input-start" chunk is sent before any "tool-input-delta" chunks.`});t.text+=e.inputTextDelta;let n=t.inputEncoding===`text`?t.text:(await pv(t.text)).value;t.dynamic?_({toolCallId:e.toolCallId,toolName:t.toolName,state:`input-streaming`,inputEncoding:t.inputEncoding,input:n,rawInput:t.text,title:t.title,toolMetadata:t.toolMetadata}):g({toolCallId:e.toolCallId,toolName:t.toolName,state:`input-streaming`,inputEncoding:t.inputEncoding,input:n,rawInput:t.text,title:t.title,toolMetadata:t.toolMetadata}),d();break}case`tool-input-available`:e.dynamic?_({toolCallId:e.toolCallId,toolName:e.toolName,state:`input-available`,input:e.input,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,title:e.title,toolMetadata:e.toolMetadata}):g({toolCallId:e.toolCallId,toolName:e.toolName,state:`input-available`,input:e.input,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,title:e.title,toolMetadata:e.toolMetadata}),d(),a&&!e.providerExecuted&&await a({toolCall:e});break;case`tool-input-error`:{let t=f().filter(Tv).find(t=>t.toolCallId===e.toolCallId);(t==null?e.dynamic:t.type===`dynamic-tool`)?_({toolCallId:e.toolCallId,toolName:e.toolName,state:`output-error`,input:e.input,errorText:e.errorText,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,toolMetadata:e.toolMetadata}):g({toolCallId:e.toolCallId,toolName:e.toolName,state:`output-error`,input:e.input,errorText:e.errorText,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,toolMetadata:e.toolMetadata}),d();break}case`tool-approval-request`:{let t=m(e.toolCallId);t.state=`approval-requested`,t.approval={id:e.approvalId,...e.approvalDescriptor==null?{}:{descriptor:e.approvalDescriptor},...Object.prototype.hasOwnProperty.call(e,`inputSchemaInput`)?{inputSchemaInput:e.inputSchemaInput}:{},...e.reason==null?{}:{requestReason:e.reason},...e.isAutomatic===!0?{isAutomatic:!0}:{},...e.signature==null?{}:{signature:e.signature}},d();break}case`tool-approval-response`:{let t=h(e.approvalId),n=t.approval==null?{id:e.approvalId}:t.approval;t.state=`approval-responded`,t.approval={...n,id:e.approvalId,approved:e.approved,...e.reason==null?{}:{reason:e.reason}},e.providerExecuted!=null&&(t.providerExecuted=e.providerExecuted),e.providerMetadata!=null&&(t.callProviderMetadata=e.providerMetadata),d();break}case`tool-output-denied`:{let t=m(e.toolCallId);t.state=`output-denied`,d();break}case`tool-output-available`:{let t=m(e.toolCallId);t.type===`dynamic-tool`?_({toolCallId:e.toolCallId,toolName:t.toolName,state:`output-available`,input:t.input,output:e.output,preliminary:e.preliminary,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,title:t.title,toolMetadata:e.toolMetadata??t.toolMetadata},t):g({toolCallId:e.toolCallId,toolName:Ev(t),state:`output-available`,input:t.input,output:e.output,providerExecuted:e.providerExecuted,preliminary:e.preliminary,providerMetadata:e.providerMetadata,title:t.title,toolMetadata:e.toolMetadata??t.toolMetadata},t),d();break}case`tool-output-error`:{let t=m(e.toolCallId);t.type===`dynamic-tool`?_({toolCallId:e.toolCallId,toolName:t.toolName,state:`output-error`,input:t.input,errorText:e.errorText,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,title:t.title,toolMetadata:e.toolMetadata??t.toolMetadata},t):g({toolCallId:e.toolCallId,toolName:Ev(t),state:`output-error`,input:t.input,rawInput:t.rawInput,errorText:e.errorText,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,title:t.title,toolMetadata:e.toolMetadata??t.toolMetadata},t),d();break}case`steering-message`:r.message.parts.push({type:`steering-message`,id:e.id,parts:e.parts}),d();break;case`start-step`:r.message.parts.push({type:`step-start`});break;case`finish-step`:break;case`reset-step`:{let e=f();r.activeTextParts=bv(),r.activeReasoningParts=bv(),r.partialToolCalls=bv(),e.length>0&&(r.message.parts.splice(r.message.parts.length-e.length,e.length),d());break}case`start`:{let t=c&&l||s&&e.messageId!=null&&e.messageId!==r.message.id;l=!1,t&&Object.assign(r,Ov({lastMessage:void 0,messageId:e.messageId??r.message.id}),{finishReason:void 0}),e.messageId!=null&&(r.message.id=e.messageId),await v(e.messageMetadata),(t||e.messageId!=null||e.messageMetadata!=null)&&d({updateStatus:!1});break}case`finish`:e.finishReason!=null&&(r.finishReason=e.finishReason),await v(e.messageMetadata),e.messageMetadata!=null&&d();break;case`message-metadata`:await v(e.messageMetadata),e.messageMetadata!=null&&d();break;case`error`:i?.(Error(e.errorText));break;default:if(yv(e)){let t=n?.[e.type.slice(5)];if(t!=null){let n=r.message.parts.findIndex(t=>`id`in t&&`data`in t&&t.id===e.id&&t.type===e.type),i=n>=0?n:r.message.parts.length;await i_({value:e.data,schema:t,context:{field:`message.parts[${i}].data`,entityName:e.type,entityId:e.id}})}let i=e;if(i.transient){o?.(i);break}let a=i.id==null?void 0:r.message.parts.find(e=>i.type===e.type&&i.id===e.id);a==null?r.message.parts.push(i):a.data=i.data,o?.(i),d()}}u.enqueue(e)})}}))}async function Av({stream:e,onError:t,abortSignal:n}){let r=e.getReader(),i=()=>{r.cancel().catch(()=>{})};n?.aborted?i():n?.addEventListener(`abort`,i,{once:!0});try{for(;;){let{done:e}=await r.read();if(e)break}}catch(e){t?.(e)}finally{n?.removeEventListener(`abort`,i),r.releaseLock()}}function jv(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}Kh({prefix:`aitxt`,size:24}),Kh({prefix:`call`,size:24}),Kh({prefix:`aitxt`,size:24}),Kh({prefix:`call`,size:24});function Mv(e){return e.dynamic=!1,e}var Nv={type:`deprecated`,setting:`rawInput in output-error UI message parts`,message:`Use the "input" field instead. The "rawInput" field will be removed in the next major version.`};function Pv(e){e.some(e=>e.parts.some(e=>typeof e==`object`&&!!e&&`type`in e&&typeof e.type==`string`&&(e.type===`dynamic-tool`||e.type.startsWith(`tool-`))&&`state`in e&&e.state===`output-error`&&Object.prototype.hasOwnProperty.call(e,`rawInput`)&&`rawInput`in e&&e.rawInput!==void 0))&&iv({warnings:[Nv]})}var Fv=Symbol(`invalid`);function Iv(e){let t=[],n=Lv(e,t,new Set);return n===Fv?{success:!1,path:t}:{success:!0,value:n}}function Lv(e,t,n){switch(typeof e){case`string`:case`boolean`:return e;case`number`:return Number.isFinite(e)?e:Fv;case`object`:{if(e===null)return e;if(n.has(e))return Fv;n.add(e);let r=Array.isArray(e)?Rv(e,t,n):zv(e,t,n);return n.delete(e),r}default:return Fv}}function Rv(e,t,n){let r;for(let i=0;i<e.length;i++){let a=e[i];t.push(i);let o=Lv(a,t,n);if(o===Fv)return Fv;t.pop(),r==null?o!==a&&(r=e.slice(0,i),r.push(o)):r.push(o)}return r??e}function zv(e,t,n){if(!Vv(e)||Hv(e))return Fv;let r=Object.keys(e),i;for(let a=0;a<r.length;a++){let o=r[a];if(o===`__proto__`){i??=Bv(e,r,a);continue}let s=e[o],c=s;if(s!==void 0){if(t.push(o),c=Lv(s,t,n),c===Fv)return Fv;t.pop()}i==null?c!==s&&(i=Bv(e,r,a),i[o]=c):i[o]=c}return i??e}function Bv(e,t,n){let r={};for(let i=0;i<n;i++)r[t[i]]=e[t[i]];return r}function Vv(e){let t=e.constructor;if(typeof t!=`function`)return!0;let n=t.prototype;return typeof n==`object`&&!!n&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)}function Hv(e){let t=Object.getOwnPropertySymbols(e);for(let n=0;n<t.length;n++)if(Object.prototype.propertyIsEnumerable.call(e,t[n]))return!0;return!1}var Uv=V.pipe(V.unknown(),V.transform((e,t)=>{let n=Iv(e);return n.success?n.value:(t.issues.push({code:`custom`,message:`Invalid JSON value. Expected null, a string, a finite number, a boolean, an array, or an object.`,input:e,path:n.path}),V.NEVER)})),Wv=V.custom(),Gv=V.pipe(Uv,V.record(V.string(),Wv)),Kv=V.pipe(Uv,V.record(V.string(),V.record(V.string(),Wv))),qv=V.record(V.string(),V.string()),Jv=hv(Kv);function Yv(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.keys(e).length===0}function Xv(e){let{type:t,...n}=e;return Mv({...n,type:`dynamic-tool`,toolName:t.slice(5)})}function Zv(e){return e.approval!=null&&Object.prototype.hasOwnProperty.call(e.approval,`inputSchemaInput`)?{value:e.approval.inputSchemaInput}:void 0}function Qv(e){return V.pipe(V.array(V.unknown()),V.transform((t,n)=>{let r=[];for(let[i,a]of t.entries()){let t=V.safeParse(e(a),a);if(!t.success){for(let e of t.error.issues)n.issues.push({...e,path:[i,...e.path]});return V.NEVER}r.push(t.data)}return r}))}var $v=Yg(()=>{let e=V.object({id:V.string(),approved:V.optional(V.never()),descriptor:V.optional(V.unknown()),requestReason:V.optional(V.string()),reason:V.optional(V.never()),isAutomatic:V.optional(V.boolean()),signature:V.optional(V.string()),inputSchemaInput:V.optional(V.unknown())}),t=V.extend(e,{approved:V.boolean(),reason:V.optional(V.string())}),n=V.extend(t,{approved:V.literal(!0)}),r=V.extend(t,{approved:V.literal(!1)}),i=V.discriminatedUnion(`type`,[V.object({type:V.literal(`text`),text:V.string(),providerMetadata:V.optional(Kv)}),V.object({type:V.literal(`file`),mediaType:V.string(),filename:V.optional(V.string()),url:V.string(),providerReference:V.optional(qv),providerMetadata:V.optional(Kv)})]),a=V.discriminatedUnion(`type`,[V.object({type:V.literal(`text`),text:V.string(),citations:V.optional(Qv(()=>Jv)),state:V.optional(V.enum([`streaming`,`done`])),providerMetadata:V.optional(Kv)}),V.object({type:V.literal(`reasoning`),id:V.optional(V.string()),text:V.string(),state:V.optional(V.enum([`streaming`,`done`])),providerMetadata:V.optional(Kv)}),V.object({type:V.literal(`custom`),kind:V.string(),providerMetadata:V.optional(Kv)}),V.object({type:V.literal(`source-url`),sourceId:V.string(),url:V.string(),title:V.optional(V.string()),providerMetadata:V.optional(Kv)}),V.object({type:V.literal(`source-document`),sourceId:V.string(),mediaType:V.string(),title:V.string(),filename:V.optional(V.string()),providerMetadata:V.optional(Kv)}),V.object({type:V.literal(`file`),mediaType:V.string(),filename:V.optional(V.string()),url:V.string(),providerReference:V.optional(qv),providerMetadata:V.optional(Kv)}),V.object({type:V.literal(`reasoning-file`),mediaType:V.string(),url:V.string(),providerMetadata:V.optional(Kv)}),V.object({type:V.literal(`steering-message`),id:V.string(),parts:Qv(()=>i)}),V.object({type:V.literal(`step-start`)})],{error:e=>e.code===`invalid_union`?`Invalid UI message part type. Expected a known part type (for example "text" or "dynamic-tool") or a type starting with "data-" or "tool-".`:void 0}),o=V.object({type:V.string().check(V.startsWith(`data-`)),id:V.optional(V.string()),data:V.unknown()}),s=V.discriminatedUnion(`state`,[V.object({type:V.literal(`dynamic-tool`),dynamic:V.optional(V.literal(!1)),toolName:V.string(),toolCallId:V.string(),title:V.optional(V.string()),toolMetadata:V.optional(Gv),state:V.literal(`input-streaming`),input:V.optional(V.unknown()),rawInput:V.optional(V.string()),inputEncoding:V.optional(V.enum([`json`,`text`])),providerExecuted:V.optional(V.boolean()),callProviderMetadata:V.optional(Kv),output:V.optional(V.never()),errorText:V.optional(V.never()),approval:V.optional(V.never())}),V.object({type:V.literal(`dynamic-tool`),dynamic:V.optional(V.literal(!1)),toolName:V.string(),toolCallId:V.string(),title:V.optional(V.string()),toolMetadata:V.optional(Gv),state:V.literal(`input-available`),input:V.unknown(),providerExecuted:V.optional(V.boolean()),output:V.optional(V.never()),errorText:V.optional(V.never()),callProviderMetadata:V.optional(Kv),approval:V.optional(V.never())}),V.object({type:V.literal(`dynamic-tool`),dynamic:V.optional(V.literal(!1)),toolName:V.string(),toolCallId:V.string(),title:V.optional(V.string()),toolMetadata:V.optional(Gv),state:V.literal(`approval-requested`),input:V.unknown(),providerExecuted:V.optional(V.boolean()),output:V.optional(V.never()),errorText:V.optional(V.never()),callProviderMetadata:V.optional(Kv),approval:e}),V.object({type:V.literal(`dynamic-tool`),dynamic:V.optional(V.literal(!1)),toolName:V.string(),toolCallId:V.string(),title:V.optional(V.string()),toolMetadata:V.optional(Gv),state:V.literal(`approval-responded`),input:V.unknown(),providerExecuted:V.optional(V.boolean()),output:V.optional(V.never()),errorText:V.optional(V.never()),callProviderMetadata:V.optional(Kv),approval:t}),V.object({type:V.literal(`dynamic-tool`),dynamic:V.optional(V.literal(!1)),toolName:V.string(),toolCallId:V.string(),title:V.optional(V.string()),toolMetadata:V.optional(Gv),state:V.literal(`output-available`),input:V.unknown(),providerExecuted:V.optional(V.boolean()),output:V.unknown(),errorText:V.optional(V.never()),callProviderMetadata:V.optional(Kv),resultProviderMetadata:V.optional(Kv),preliminary:V.optional(V.boolean()),approval:V.optional(n)}),V.object({type:V.literal(`dynamic-tool`),dynamic:V.optional(V.literal(!1)),toolName:V.string(),toolCallId:V.string(),title:V.optional(V.string()),toolMetadata:V.optional(Gv),state:V.literal(`output-error`),input:V.optional(V.unknown()),rawInput:V.optional(V.unknown()),providerExecuted:V.optional(V.boolean()),output:V.optional(V.never()),errorText:V.string(),callProviderMetadata:V.optional(Kv),resultProviderMetadata:V.optional(Kv),approval:V.optional(n)}),V.object({type:V.literal(`dynamic-tool`),dynamic:V.optional(V.literal(!1)),toolName:V.string(),toolCallId:V.string(),title:V.optional(V.string()),toolMetadata:V.optional(Gv),state:V.literal(`output-denied`),input:V.unknown(),providerExecuted:V.optional(V.boolean()),output:V.optional(V.never()),errorText:V.optional(V.never()),callProviderMetadata:V.optional(Kv),approval:r})]),c=V.discriminatedUnion(`state`,[V.object({type:V.string().check(V.startsWith(`tool-`)),toolCallId:V.string(),title:V.optional(V.string()),toolMetadata:V.optional(Gv),state:V.literal(`input-streaming`),providerExecuted:V.optional(V.boolean()),callProviderMetadata:V.optional(Kv),input:V.optional(V.unknown()),rawInput:V.optional(V.string()),inputEncoding:V.optional(V.enum([`json`,`text`])),output:V.optional(V.never()),errorText:V.optional(V.never()),approval:V.optional(V.never())}),V.object({type:V.string().check(V.startsWith(`tool-`)),toolCallId:V.string(),title:V.optional(V.string()),toolMetadata:V.optional(Gv),state:V.literal(`input-available`),providerExecuted:V.optional(V.boolean()),input:V.unknown(),output:V.optional(V.never()),errorText:V.optional(V.never()),callProviderMetadata:V.optional(Kv),approval:V.optional(V.never())}),V.object({type:V.string().check(V.startsWith(`tool-`)),toolCallId:V.string(),title:V.optional(V.string()),toolMetadata:V.optional(Gv),state:V.literal(`approval-requested`),input:V.unknown(),providerExecuted:V.optional(V.boolean()),output:V.optional(V.never()),errorText:V.optional(V.never()),callProviderMetadata:V.optional(Kv),approval:e}),V.object({type:V.string().check(V.startsWith(`tool-`)),toolCallId:V.string(),title:V.optional(V.string()),toolMetadata:V.optional(Gv),state:V.literal(`approval-responded`),input:V.unknown(),providerExecuted:V.optional(V.boolean()),output:V.optional(V.never()),errorText:V.optional(V.never()),callProviderMetadata:V.optional(Kv),approval:t}),V.object({type:V.string().check(V.startsWith(`tool-`)),toolCallId:V.string(),title:V.optional(V.string()),toolMetadata:V.optional(Gv),state:V.literal(`output-available`),providerExecuted:V.optional(V.boolean()),input:V.unknown(),output:V.unknown(),errorText:V.optional(V.never()),callProviderMetadata:V.optional(Kv),resultProviderMetadata:V.optional(Kv),preliminary:V.optional(V.boolean()),approval:V.optional(n)}),V.object({type:V.string().check(V.startsWith(`tool-`)),toolCallId:V.string(),title:V.optional(V.string()),toolMetadata:V.optional(Gv),state:V.literal(`output-error`),providerExecuted:V.optional(V.boolean()),input:V.optional(V.unknown()),rawInput:V.optional(V.unknown()),output:V.optional(V.never()),errorText:V.string(),callProviderMetadata:V.optional(Kv),resultProviderMetadata:V.optional(Kv),approval:V.optional(n)}),V.object({type:V.string().check(V.startsWith(`tool-`)),toolCallId:V.string(),title:V.optional(V.string()),toolMetadata:V.optional(Gv),state:V.literal(`output-denied`),providerExecuted:V.optional(V.boolean()),input:V.unknown(),output:V.optional(V.never()),errorText:V.optional(V.never()),callProviderMetadata:V.optional(Kv),approval:r})]),l=V.object({id:V.string(),role:V.enum([`system`,`user`,`assistant`]),metadata:V.optional(V.unknown()),parts:Qv(e=>{let t=e?.type;if(typeof t==`string`){if(t.startsWith(`data-`))return o;if(t.startsWith(`tool-`))return c;if(t===`dynamic-tool`)return s}return a})}).check(e=>{let t=e.value;t.role!==`assistant`&&t.parts.length===0&&e.issues.push({continue:!0,origin:`array`,code:`too_small`,minimum:1,inclusive:!0,input:t.parts,path:[`parts`],message:`Message must contain at least one part`})});return r_(Qv(()=>l).check(V.minLength(1,`Messages array must not be empty`)))});async function ey({messages:e,metadataSchema:t,dataSchemas:n,tools:r,experimental_refineToolInput:i},{convertMissingTerminalToolsToDynamic:a}){try{if(e==null)return{success:!1,error:new Y_({parameter:`messages`,value:e,message:`messages parameter must be provided`})};let o=await i_({value:e,schema:$v});if(Pv(o),t)for(let[e,n]of o.entries())n.metadata=await i_({value:n.metadata,schema:t,context:{field:`messages[${e}].metadata`,entityId:n.id}});let s=r!=null||a;if(n||s)for(let[e,t]of o.entries())for(let[o,c]of t.parts.entries()){if(n&&c.type.startsWith(`data-`)){let t=c,r=t.type.slice(5),i=n[r];if(!i)return{success:!1,error:new Dh({value:t.data,cause:`No data schema found for data part ${r}`,context:{field:`messages[${e}].parts[${o}].data`,entityName:r,entityId:t.id}})};t.data=await i_({value:t.data,schema:i,context:{field:`messages[${e}].parts[${o}].data`,entityName:r,entityId:t.id}})}if(s&&c.type.startsWith(`tool-`)){let n=c,s=n.type.slice(5),l=r==null?void 0:ov(r,s),u=n.state===`output-available`||n.state===`output-error`||n.state===`output-denied`;if(!l&&u){(r!=null||a)&&(t.parts[o]=Xv(n));continue}if(!l)return{success:!1,error:new Dh({value:n.input,cause:`No tool schema found for tool part ${s}`,context:{field:`messages[${e}].parts[${o}].input`,entityName:s,entityId:n.toolCallId}})};let d={field:`messages[${e}].parts[${o}].input`,entityName:s,entityId:n.toolCallId},f=Zv(n),p=f==null?n.input:f.value,m=!1;if(n.state!==`input-streaming`&&(n.state!==`output-error`||f!=null||n.input!==void 0)){let e=await a_({value:p,schema:l.inputSchema,context:d}),t;if(!e.success)t=e.error;else if(f!=null)try{let r=ov(i,s);sv(r==null?e.value:await r(e.value),n.input)||(t=new Dh({value:n.input,cause:`Tool input does not match the output reconstructed from inputSchemaInput.`,context:d}))}catch(e){t=new Dh({value:p,cause:e,context:d})}if(t!=null)if(n.state===`output-error`||n.state===`output-available`&&Yv(n.input))m=!0;else throw t}n.state===`output-available`&&l.outputSchema&&await i_({value:n.output,schema:l.outputSchema,context:{field:`messages[${e}].parts[${o}].output`,entityName:s,entityId:n.toolCallId}}),m&&(t.parts[o]=Xv(n))}}return{success:!0,data:o}}catch(e){return{success:!1,error:e}}}async function ty(e){return ey(e,{convertMissingTerminalToolsToDynamic:!1})}async function ny(e){let t=await ty(e);if(!t.success)throw t.error;return t.data}Kh({prefix:`call`,size:24}),Kh({prefix:`call`,size:24}),new TextEncoder,Kh({prefix:`call`,size:24}),Kh({prefix:`call`,size:24}),Kh({prefix:`aiobj`,size:24});var{atob:yee}=globalThis,ry=class{constructor(){this.queue=[],this.isProcessing=!1,this.idleWaiters=[]}async processQueue(){if(!this.isProcessing){this.isProcessing=!0;try{for(;this.queue.length>0;)await this.queue[0](),this.queue.shift()}finally{this.isProcessing=!1;for(let e of this.idleWaiters.splice(0))e()}}}async run(e){return new Promise((t,n)=>{this.queue.push(async()=>{try{await e(),t()}catch(e){n(e)}}),this.processQueue()})}async waitForIdle(){!this.isProcessing&&this.queue.length===0||await new Promise(e=>{this.idleWaiters.push(e)})}};Kh({prefix:`aiobj`,size:24}),Kh({prefix:`call`,size:24});var iy=H.union([H.string(),H.custom(Uh,{message:`Must be a Uint8Array`}),H.custom(Wh,{message:`Must be an ArrayBuffer`}),H.custom(lee,{message:`Must be a Buffer`})]),ay=H.record(H.string(),H.string()),oy=H.object({type:H.literal(`text`),text:H.string(),providerOptions:U.optional()}),sy=H.object({type:H.literal(`image`),image:H.union([iy,H.instanceof(URL),ay]),mediaType:H.string().optional(),providerOptions:U.optional()}),cy=H.discriminatedUnion(`type`,[H.object({type:H.literal(`data`),data:iy}),H.object({type:H.literal(`url`),url:H.instanceof(URL)}),H.object({type:H.literal(`reference`),reference:ay}),H.object({type:H.literal(`text`),text:H.string()})]),ly=H.discriminatedUnion(`type`,[H.object({type:H.literal(`data`),data:iy}),H.object({type:H.literal(`url`),url:H.instanceof(URL)})]),uy=H.object({type:H.literal(`file`),data:H.union([cy,iy,H.instanceof(URL),ay]),filename:H.string().optional(),mediaType:H.string(),providerOptions:U.optional()}),dy=H.object({type:H.literal(`reasoning`),text:H.string(),providerOptions:U.optional()}),fy=H.object({type:H.literal(`custom`),kind:H.string().transform(e=>e),providerOptions:U.optional()}),py=H.object({type:H.literal(`reasoning-file`),data:H.union([ly,iy,H.instanceof(URL)]),mediaType:H.string(),providerOptions:U.optional()}),my=H.object({type:H.literal(`tool-call`),toolCallId:H.string(),toolName:H.string(),input:H.unknown(),providerOptions:U.optional(),providerExecuted:H.boolean().optional()}),hy=H.discriminatedUnion(`type`,[H.object({type:H.literal(`text`),value:H.string(),providerOptions:U.optional()}),H.object({type:H.literal(`json`),value:mv,providerOptions:U.optional()}),H.object({type:H.literal(`execution-denied`),reason:H.string().optional(),providerOptions:U.optional()}),H.object({type:H.literal(`error-text`),value:H.string(),providerOptions:U.optional()}),H.object({type:H.literal(`error-json`),value:mv,providerOptions:U.optional()}),H.object({type:H.literal(`content`),value:H.array(H.union([H.object({type:H.literal(`text`),text:H.string(),providerOptions:U.optional()}),H.object({type:H.literal(`file`),data:cy,mediaType:H.string(),filename:H.string().optional(),providerOptions:U.optional()}),H.object({type:H.literal(`file-data`),data:H.string(),mediaType:H.string(),filename:H.string().optional(),providerOptions:U.optional()}),H.object({type:H.literal(`file-url`),url:H.string(),mediaType:H.string().optional(),providerOptions:U.optional()}),H.object({type:H.literal(`file-id`),fileId:H.union([H.string(),H.record(H.string(),H.string())]),providerOptions:U.optional()}),H.object({type:H.literal(`file-reference`),providerReference:H.record(H.string(),H.string()),providerOptions:U.optional()}),H.object({type:H.literal(`image-data`),data:H.string(),mediaType:H.string(),providerOptions:U.optional()}),H.object({type:H.literal(`image-url`),url:H.string(),providerOptions:U.optional()}),H.object({type:H.literal(`image-file-id`),fileId:H.union([H.string(),H.record(H.string(),H.string())]),providerOptions:U.optional()}),H.object({type:H.literal(`image-file-reference`),providerReference:H.record(H.string(),H.string()),providerOptions:U.optional()}),H.object({type:H.literal(`custom`),providerOptions:U.optional()})]))})]),gy=H.object({type:H.literal(`tool-result`),toolCallId:H.string(),toolName:H.string(),output:hy,providerOptions:U.optional()}),_y=H.object({type:H.literal(`tool-approval-request`),approvalId:H.string(),toolCallId:H.string(),reason:H.string().optional(),isAutomatic:H.boolean().optional(),signature:H.string().optional(),inputSchemaInput:H.unknown().optional()}),vy=H.object({type:H.literal(`tool-approval-response`),approvalId:H.string(),approved:H.boolean(),reason:H.string().optional()}),yy=H.object({role:H.literal(`system`),content:H.string(),providerOptions:U.optional()}),by=H.object({role:H.literal(`user`),content:H.union([H.string(),H.array(H.union([oy,sy,uy]))]),providerOptions:U.optional()}),xy=H.object({role:H.literal(`assistant`),content:H.union([H.string(),H.array(H.union([oy,fy,uy,dy,py,my,gy,_y]))]),providerOptions:U.optional()}),Sy=H.object({role:H.literal(`tool`),content:H.array(H.union([gy,vy])),providerOptions:U.optional()});H.union([yy,by,xy,Sy]),V.object({token:V.string().check(V.refine(e=>e.trim().length>0)),url:V.string().check(V.refine(e=>{try{let t=new URL(e);return(t.protocol===`ws:`||t.protocol===`wss:`)&&t.hostname!==``}catch{return!1}})),expiresAt:V.optional(V.number().check(V.positive()).check(V.maximum(2**53-1))),tools:V.optional(V.array(V.object({type:V.literal(`function`),name:V.string().check(V.minLength(1)),description:V.optional(V.string()),parameters:V.record(V.string(),V.unknown())})))}),Kh({prefix:`call`,size:24}),Kh({prefix:`call`,size:24}),Kh({prefix:`call`,size:24});async function Cy({response:e,url:t,fallbackMessage:n}){let r=await e.text();return new uh({message:r||n,url:t,requestBodyValues:void 0,statusCode:e.status,responseBody:r})}async function wy(e){if(e==null)return[];if(!globalThis.FileList||!(e instanceof globalThis.FileList))throw new jh({functionality:`FileList`,message:`FileList is not supported in the current environment`});return Promise.all(Array.from(e).map(async e=>{let{name:t,type:n}=e;return{type:`file`,mediaType:n,filename:t,url:await new Promise((t,n)=>{let r=new FileReader;r.onload=e=>{t(e.target?.result)},r.onerror=e=>n(e),r.readAsDataURL(e)})}}))}function Ty(e,t){let n=e.search(/[?#]/),r=n===-1?e:e.slice(0,n),i=n===-1?``:e.slice(n);return`${r.endsWith(`/`)&&t.startsWith(`/`)?r.slice(0,-1):r}${t}${i}`}var Ey=class{constructor({api:e=`/api/chat`,credentials:t,headers:n,body:r,fetch:i,prepareSendMessagesRequest:a,prepareReconnectToStreamRequest:o}){this.api=e,this.credentials=t,this.headers=n,this.body=r,this.fetch=i,this.prepareSendMessagesRequest=a,this.prepareReconnectToStreamRequest=o}async sendMessages({abortSignal:e,...t}){let n=await c_(this.body),r=await c_(this.headers),i=await c_(this.credentials),a={...Gh(r),...Gh(t.headers)},o=await this.prepareSendMessagesRequest?.({api:this.api,id:t.chatId,messages:t.messages,body:{...n,...t.body},headers:a,credentials:i,requestMetadata:t.metadata,trigger:t.trigger,messageId:t.messageId}),s=o?.api??this.api,c=o?.headers===void 0?a:Gh(o.headers),l=o?.body===void 0?{...n,...t.body,id:t.chatId,messages:t.messages,trigger:t.trigger,messageId:t.messageId}:o.body,u=o?.credentials??i,d=await(this.fetch??globalThis.fetch)(s,{method:`POST`,headers:{"content-type":`application/json`,...c},body:JSON.stringify(l),credentials:u,signal:e});if(!d.ok)throw await Cy({response:d,url:s,fallbackMessage:`Failed to fetch the chat response.`});if(!d.body)throw new mh({message:`The response body is empty.`});return this.processResponseStream(d.body)}async reconnectToStream(e){let t=await c_(this.body),n=await c_(this.headers),r=await c_(this.credentials),i={...Gh(n),...Gh(e.headers)},a=await this.prepareReconnectToStreamRequest?.({api:this.api,id:e.chatId,body:{...t,...e.body},headers:i,credentials:r,requestMetadata:e.metadata}),o=a?.api;if(o==null){if(e.chatId===`.`||e.chatId===`..`)throw new Y_({parameter:`chatId`,value:e.chatId,message:`Chat IDs must not be "." or ".." when using the default reconnect URL.`});o=Ty(this.api,`/${encodeURIComponent(e.chatId)}/stream`)}let s=a?.headers===void 0?i:Gh(a.headers),c=a?.credentials??r,l=await(this.fetch??globalThis.fetch)(o,{method:`GET`,headers:s,credentials:c,signal:e.abortSignal});if(l.status===204)return null;if(!l.ok)throw await Cy({response:l,url:o,fallbackMessage:`Failed to fetch the chat response.`});if(!l.body)throw new mh({message:`The response body is empty.`});return this.processResponseStream(l.body)}},Dy=class extends Ey{constructor({resumeStreamIsReplay:e=!0,...t}={}){super(t),this.resumeStreamIsReplay=e}processResponseStream(e){return s_({stream:e,schema:vv}).pipeThrough(new TransformStream({async transform(e,t){if(!e.success)throw e.error;t.enqueue(e.value)}}))}},Oy=class{get id(){return this._id??=this.generateId()}constructor({generateId:e=cee,id:t,transport:n=new Dy,messageMetadataSchema:r,dataPartSchemas:i,state:a,onError:o,onToolCall:s,onFinish:c,onData:l,sendAutomaticallyWhen:u,experimental_queue:d=!1}){this.queuedMessagesFallback=[],this.queuedMessageOptions=new Map,this.isQueuePaused=!1,this.pendingAutomaticDecisions=[],this.pendingMessagePreparations=new Set,this.interruptedMessageIds=new Set,this.activeResponse=void 0,this.activeResumeRequest=void 0,this.resumableStreamState=void 0,this.jobExecutor=new ry,this.activeStopCount=0,this.stopGeneration=0,this.experimental_removeQueuedMessage=e=>{this.queuedMessageOptions.delete(e),this.setQueuedMessages(this.experimental_queuedMessages.filter(t=>t.id!==e))},this.experimental_sendQueuedMessageNow=async e=>{let t=this.experimental_queuedMessages.find(t=>t.id===e);if(t==null)return;this.setQueuedMessages([t,...this.experimental_queuedMessages.filter(t=>t.id!==e)]);let n=this.stopGeneration+1;await this.stop(),n===this.stopGeneration&&await this.resumeQueue({skipWaitForUser:!0,options:this.queuedMessageOptions.get(e)})},this.sendMessage=async(e,t)=>{if(e==null){let e=this.pendingApprovalMessageId;if(e==null){e=this.lastMessage?.id;for(let t=this.state.messages.length-1;t>=0;t--){let n=this.state.messages[t];if(n.role===`assistant`&&n.parts.some(e=>Tv(e)&&e.state===`approval-responded`)){e=n.id;break}}}let n=e!=null&&e===this.pendingApprovalMessageId?this.state.messages.findIndex(t=>t.id===e):-1;await this.makeRequestForToolApproval({messageId:e,messageIndex:n,...t});return}let n;if(`text`in e||`files`in e){let t=new AbortController;this.pendingMessagePreparations.add(t);let r;try{r=Array.isArray(e.files)?e.files:await wy(e.files)}finally{this.pendingMessagePreparations.delete(t)}if(t.signal.aborted)return;n={parts:[...r,...`text`in e&&e.text!=null?[{type:`text`,text:e.text}]:[]]}}else n=e;if(this.queueEnabled&&e.messageId==null&&(this.isRequestInProgress()||this.isWaitingForUser()||this.experimental_queuedMessages.length>0)){let r={...n,id:n.id??this.generateId(),role:n.role??`user`,metadata:e.metadata};t!=null&&this.queuedMessageOptions.set(r.id,t),this.setQueuedMessages([...this.experimental_queuedMessages,r]),await this.resumeQueue({skipWaitForUser:this.isQueuePaused,options:t});return}if(e.messageId!=null){await this.clearQueueForHistoryChange();let t=this.state.messages.findIndex(t=>t.id===e.messageId);if(t===-1)throw new Y_({parameter:`message.messageId`,value:e.messageId,message:`message with id ${e.messageId} not found`});if(this.state.messages[t].role!==`user`)throw new Y_({parameter:`message.messageId`,value:e.messageId,message:`message with id ${e.messageId} is not a user message`});this.state.messages=this.state.messages.slice(0,t+1),this.state.replaceMessage(t,{id:e.messageId,...n,role:n.role??`user`,metadata:e.metadata})}else this.state.pushMessage({...n,id:n.id??this.generateId(),role:n.role??`user`,metadata:e.metadata});this.isQueuePaused=!1,await this.makeRequest({trigger:`submit-message`,messageId:e.messageId,...t})},this.regenerate=async({messageId:e,...t}={})=>{await this.clearQueueForHistoryChange();let n=e==null?this.state.messages.length-1:this.state.messages.findIndex(t=>t.id===e);if(n===-1)throw new Y_({parameter:`messageId`,value:e,message:`message ${e} not found`});this.state.messages=this.state.messages.slice(0,this.messages[n].role===`assistant`?n:n+1),await this.makeRequest({trigger:`regenerate-message`,messageId:e,...t})},this.resumeStream=async(e={})=>{await this.makeRequest({trigger:`resume-stream`,...e})},this[`~resumeStreamIfDisconnected`]=async({shouldResume:e=()=>!0}={})=>{let t=this.activeResponse;this.resumableStreamState==null&&t!=null&&(await t.completionPromise,this.resumableStreamState!==t.state)||this.resumableStreamState!=null&&e()&&await this.resumeStream()},this.clearError=()=>{this.status===`error`&&(this.state.error=void 0,this.setStatus({status:`ready`}))},this.addToolApprovalResponse=async({id:e,approved:t,reason:n,options:r})=>this.jobExecutor.run(async()=>{let i=this.stopGeneration,a=this.state.messages,o=r=>Tv(r)&&r.state===`approval-requested`&&r.approval.id===e?{...r,state:`approval-responded`,approval:{...r.approval,id:e,approved:t,reason:n}}:r,s=a.findIndex(t=>t.parts.some(t=>Tv(t)&&t.state===`approval-requested`&&t.approval.id===e));if(s!==-1){let e=a[s];this.state.replaceMessage(s,{...e,parts:e.parts.map(o)}),this.pendingApprovalMessageId=e.id}if(this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(o)),s!==-1&&this.status!==`streaming`&&this.status!==`submitted`&&this.sendAutomaticallyWhen){let e=await this.shouldSendAutomatically(a[s].id);if(e){this.runAutomaticRequest(()=>{let e=s===-1?this.lastMessage?.id:a[s].id;return this.makeRequestForToolApproval({messageId:e,messageIndex:s,...r})},e);return}}this.settleQueue({stopGeneration:i})}),this.addToolOutput=async({state:e,toolCallId:t,output:n,errorText:r,options:i})=>this.jobExecutor.run(async()=>{let a=this.stopGeneration,o=this.state.messages,s=i=>{if(!Tv(i)||i.toolCallId!==t)return i;let{approval:a,...o}=i,s=a?.approved===!0?{approval:{...a,approved:a.approved}}:{};return e===`output-error`?{...o,...s,state:e,input:i.input,output:void 0,errorText:r}:{...o,...s,state:`output-available`,input:i.input,output:n,errorText:void 0}},c=o.findIndex(e=>e.parts.some(e=>Tv(e)&&e.toolCallId===t));if(c!==-1){let e=o[c];this.state.replaceMessage(c,{...e,parts:e.parts.map(s)})}if(this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(s)),c!==-1&&this.status!==`streaming`&&this.status!==`submitted`&&this.sendAutomaticallyWhen){let e=await this.shouldSendAutomatically(o[c].id);if(e){this.runAutomaticRequest(()=>this.makeRequest({trigger:`submit-message`,messageId:o[c].id,...i}),e);return}}this.settleQueue({stopGeneration:a})}),this.addToolResult=this.addToolOutput,this.stop=async()=>{this.activeStopCount++,this.stopGeneration++,this.deferredApprovalSend=void 0;try{let e=this.activeResumeRequest,t=this.activeResponse;for(let e of this.pendingMessagePreparations)e.abort();e?.abortController.abort(),t?.abortController.abort(),await Promise.all([e?.completionPromise,t?.completionPromise]),await this.jobExecutor.waitForIdle(),this.isQueuePaused=!0}finally{this.activeStopCount--}},this.dispose=async()=>{await this.stop(),this.transport.close?.()},this._id=t,this.transport=n,this.generateId=e,this.messageMetadataSchema=r,this.dataPartSchemas=i,this.state=a,this.onError=o,this.onToolCall=s,this.onFinish=c,this.onData=l,this.sendAutomaticallyWhen=u,this.queueEnabled=d}get status(){return this.state.status}setStatus({status:e,error:t}){if(this.status===e){this.error!==t&&(this.state.error=t);return}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]}get experimental_queuedMessages(){return this.state.experimental_queuedMessages??this.queuedMessagesFallback}setQueuedMessages(e){`experimental_queuedMessages`in this.state?this.state.experimental_queuedMessages=e:this.queuedMessagesFallback=e}async resumeQueue({skipWaitForUser:e,options:t}){if(this.isQueuePaused=!1,this.hasUnsentApprovalResponse()){if(!this.isRequestInProgress()){await this.sendMessage(void 0,t);return}this.deferredApprovalSend={options:t}}await this.settleQueue({skipWaitForUser:e})}async clearQueueForHistoryChange(){this.queueEnabled&&(this.queuedMessageOptions.clear(),this.setQueuedMessages([]),this.deferredApprovalSend=void 0,this.isRequestInProgress()&&await this.stop())}isRequestInProgress(){return this.pendingAutomaticDecisions.includes(this.stopGeneration)||this.activeResponse!=null||this.status===`submitted`||this.status===`streaming`}isWaitingForUser(){let e=this.lastMessage;return e?.role===`assistant`&&e.parts.some(e=>Tv(e)&&(e.state===`approval-requested`||e.state===`approval-responded`||!e.providerExecuted&&(e.state===`input-streaming`||e.state===`input-available`)))}hasUnsentApprovalResponse(){let e=this.lastMessage;return e?.role===`assistant`&&e.parts.some(e=>Tv(e)&&e.state===`approval-responded`)&&!e.parts.some(e=>Tv(e)&&(e.state===`approval-requested`||!e.providerExecuted&&(e.state===`input-streaming`||e.state===`input-available`)))}async settleQueue({stopGeneration:e=this.stopGeneration,skipWaitForUser:t=!1}={}){if(this.isQueuePaused||this.isRequestInProgress()||this.activeStopCount>0||e!==this.stopGeneration)return;let n=this.deferredApprovalSend;if(this.deferredApprovalSend=void 0,n!=null&&this.hasUnsentApprovalResponse()){await this.sendMessage(void 0,n.options);return}let[r,...i]=this.experimental_queuedMessages;if(r==null||!t&&this.isWaitingForUser())return;let a=this.queuedMessageOptions.get(r.id);this.queuedMessageOptions.delete(r.id),this.setQueuedMessages(i),this.state.pushMessage(r),await this.makeRequest({trigger:`submit-message`,...a})}set messages(e){this.state.messages=e}async shouldSendAutomatically(e=this.lastMessage?.id){let t=e=>e!=null&&this.interruptedMessageIds.has(e);if(!this.sendAutomaticallyWhen||t(e)||t(this.lastMessage?.id))return!1;let n=this.stopGeneration;this.pendingAutomaticDecisions.push(n);let r;try{r=await this.sendAutomaticallyWhen({messages:this.state.messages})}finally{this.pendingAutomaticDecisions.splice(this.pendingAutomaticDecisions.indexOf(n),1)}return r&&!t(e)&&!t(this.lastMessage?.id)}async runAutomaticRequest(e,t){let n=this.stopGeneration,r=this.activeStopCount>0;return!(t??await this.shouldSendAutomatically())||r||n!==this.stopGeneration||this.activeStopCount>0?!1:(await e(),!0)}async makeRequestForToolApproval({messageId:e,messageIndex:t,...n}){this.deferredApprovalSend=void 0;let r=e!=null&&e===this.pendingApprovalMessageId;r&&(this.pendingApprovalMessageId=void 0),await this.makeRequest({trigger:`submit-message`,messageId:e,...n}),r&&this.status===`error`&&this.pendingApprovalMessageId==null&&(this.pendingApprovalMessageId=this.state.messages[t]?.id??e)}async makeRequest(e){let t=jv();try{await this.makeRequestImpl({...e,completionPromise:t.promise})}finally{t.resolve()}}async makeRequestImpl({trigger:e,metadata:t,headers:n,body:r,messageId:i,completionPromise:a}){e!==`resume-stream`&&(this.resumableStreamState=void 0);let o=new AbortController,s=e===`resume-stream`?{abortController:o,completionPromise:a}:void 0;s&&(this.activeResumeRequest?.abortController.abort(),this.activeResumeRequest=s);let c=()=>s==null||this.activeResumeRequest===s,l=()=>{this.activeResumeRequest===s&&(this.activeResumeRequest=void 0)},u;if(e===`resume-stream`)try{let e=await this.transport.reconnectToStream({chatId:this.id,abortSignal:o.signal,metadata:t,headers:n,body:r});if(o.signal.aborted||!c()){await e?.cancel().catch(()=>{}),c()&&(this.setStatus({status:`ready`}),this.resumableStreamState=void 0),l();return}if(e==null){this.setStatus({status:`ready`}),this.resumableStreamState=void 0,l();return}u=e}catch(e){if(o.signal.aborted||e.name===`AbortError`){c()&&(this.setStatus({status:`ready`}),this.resumableStreamState=void 0),l();return}if(!c())return;this.onError&&e instanceof Error&&this.onError(e),this.setStatus({status:`error`,error:e}),l();return}this.setStatus({status:`submitted`,error:void 0});let d=this.lastMessage,f=e===`submit-message`&&i!=null?this.state.messages.findIndex(e=>e.id===i):this.state.messages.length-1,p=f===-1?d:this.state.messages[f],m=p?.id,h=e===`resume-stream`&&p?.role===`assistant`&&p.parts.some(e=>Tv(e)&&(e.state===`input-streaming`||e.state===`input-available`&&e.providerExecuted||e.state===`approval-responded`))?this.state.snapshot(p):void 0,g=f!==-1&&f<this.state.messages.length-1&&p?.role===`assistant`,_=!1,v=!1,y=!1,b;try{let s={state:e===`resume-stream`&&this.resumableStreamState!=null?this.resumableStreamState:Ov({lastMessage:e===`resume-stream`?h:e===`regenerate-message`?void 0:this.state.snapshot(p),messageId:this.generateId()}),abortController:o,completionPromise:a};b=s,s.abortController.signal.addEventListener(`abort`,()=>{_=!0}),this.activeResponse=s;let l;if(l=e===`resume-stream`?u:await this.transport.sendMessages({chatId:this.id,messages:this.state.messages,abortSignal:s.abortController.signal,metadata:t,headers:n,body:r,trigger:e,messageId:i}),await Av({stream:kv({stream:l,resetStateOnMessageIdChange:e===`resume-stream`,resetStateOnFirstMessageStart:e===`resume-stream`&&this.transport.resumeStreamIsReplay,onToolCall:this.onToolCall,onData:this.onData,messageMetadataSchema:this.messageMetadataSchema,dataPartSchemas:this.dataPartSchemas,runUpdateMessageJob:e=>this.jobExecutor.run(()=>s.abortController.signal.aborted?Promise.resolve():e({state:s.state,write:({updateStatus:e=!0}={})=>{if(s.abortController.signal.aborted)return;e&&this.setStatus({status:`streaming`});let t=this.state.messages.findLastIndex(e=>e.id===s.state.message.id);if(t!==-1)this.state.replaceMessage(t,s.state.message);else if(g){let e=this.state.messages.findLastIndex(e=>e.id===m);e===-1?this.state.pushMessage(s.state.message):this.state.replaceMessage(e,s.state.message)}else this.state.pushMessage(s.state.message)}})),onError:e=>{throw e}}),abortSignal:s.abortController.signal,onError:e=>{throw e}}),_)return c()&&(this.setStatus({status:`ready`}),this.resumableStreamState===s.state&&(this.resumableStreamState=void 0)),null;c()&&(this.setStatus({status:`ready`}),this.resumableStreamState===s.state&&(this.resumableStreamState=void 0))}catch(e){if(_||e.name===`AbortError`)return _=!0,c()&&(this.setStatus({status:`ready`}),this.resumableStreamState===b?.state&&(this.resumableStreamState=void 0)),null;if(!c())return null;if(y=!0,e instanceof TypeError){let t=e.message.toLowerCase();v=t.includes(`fetch`)||t.includes(`network`)||t===`load failed`}v?this.resumableStreamState=b?.state:this.resumableStreamState===b?.state&&(this.resumableStreamState=void 0),this.onError&&e instanceof Error&&this.onError(e),this.setStatus({status:`error`,error:e})}finally{try{if(b){let{message:e,finishReason:t}=b.state;t===`interrupted`?this.interruptedMessageIds.add(e.id):!_&&!y&&this.interruptedMessageIds.delete(e.id),this.onFinish?.({message:b.state.message,messages:this.state.messages,isAbort:_,isDisconnect:v,isError:y,finishReason:b.state.finishReason})}}finally{(_||y||b?.state.finishReason===`interrupted`)&&(this.isQueuePaused=!0),this.activeResponse===b&&(this.activeResponse=void 0),l()}}if(!_&&!y&&b?.state.finishReason!==`interrupted`){let e=this.stopGeneration;await this.runAutomaticRequest(()=>this.makeRequest({trigger:`submit-message`,messageId:this.lastMessage?.id,metadata:t,headers:n,body:r}))||await this.settleQueue({stopGeneration:e})}}};function ky({messages:e}){let t=e[e.length-1];if(!t||t.role!==`assistant`)return!1;let n=t.parts.reduce((e,t,n)=>t.type===`step-start`?n:e,-1),r=t.parts.slice(n+1).filter(Tv);return r.filter(e=>e.state===`approval-responded`).length>0&&r.every(e=>e.state===`output-available`&&e.preliminary!==!0||e.state===`output-error`||e.state===`output-denied`||e.state===`approval-responded`)}function Ay({messages:e}){let t=e[e.length-1];if(!t||t.role!==`assistant`)return!1;let n=t.parts.reduce((e,t,n)=>t.type===`step-start`?n:e,-1),r=t.parts.slice(n+1),i=r.filter(Tv).filter(e=>!e.providerExecuted),a=r.reduce((e,t,n)=>Tv(t)&&!t.providerExecuted?n:e,-1);return i.length>0&&!r.slice(a+1).some(e=>e.type===`text`&&e.state!==`done`)&&i.every(e=>e.state===`output-available`&&e.preliminary!==!0||e.state===`output-error`)}var jy=n(a(((e,t)=>{function n(e,t){if(typeof e!=`function`)throw TypeError(`Expected the first argument to be a \`function\`, got \`${typeof e}\`.`);let n,r=0;return function(...i){clearTimeout(n);let a=Date.now(),o=t-(a-r);o<=0?(r=a,e.apply(this,i)):n=setTimeout(()=>{r=Date.now(),e.apply(this,i)},o)}}t.exports=n}))(),1);function My(e,t){return t==null?e:(0,jy.default)(e,t)}function Ny(e){return Array.isArray(e)?[...e]:typeof e==`object`&&e&&(Object.getPrototypeOf(e)===Object.prototype||Object.getPrototypeOf(e)===null)?{...e}:e}var Py=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e=[]){this.#t=`ready`,this.#n=void 0,this.#r=[],this.#i=new Set,this.#a=new Set,this.#o=new Set,this.#s=new Set,this.pushMessage=e=>{this.#e=this.#e.concat(e),this.#c()},this.popMessage=()=>{this.#e=this.#e.slice(0,-1),this.#c()},this.replaceMessage=(e,t)=>{this.#e=[...this.#e.slice(0,e),this.snapshot(t),...this.#e.slice(e+1)],this.#c()},this.snapshot=e=>{if(typeof e!=`object`||!e||!(`parts`in e)||!Array.isArray(e.parts))return e;let t=e,n={...t,parts:t.parts.map(e=>({...e}))};return`metadata`in t&&(n.metadata=Ny(t.metadata)),n},this[`~registerMessagesCallback`]=(e,t)=>{let n=t?My(e,t):e;return this.#i.add(n),()=>{this.#i.delete(n)}},this[`~registerStatusCallback`]=e=>(this.#o.add(e),()=>{this.#o.delete(e)}),this[`~registerErrorCallback`]=e=>(this.#s.add(e),()=>{this.#s.delete(e)}),this[`~registerQueuedMessagesCallback`]=e=>(this.#a.add(e),()=>{this.#a.delete(e)}),this.#c=()=>{this.#i.forEach(e=>e())},this.#l=()=>{this.#o.forEach(e=>e())},this.#u=()=>{this.#s.forEach(e=>e())},this.#e=e}get status(){return this.#t}set status(e){this.#t=e,this.#l()}get error(){return this.#n}set error(e){this.#n=e,this.#u()}get experimental_queuedMessages(){return this.#r}set experimental_queuedMessages(e){this.#r=e,this.#a.forEach(e=>e())}get messages(){return this.#e}set messages(e){this.#e=[...e],this.#c()}#c;#l;#u},Fy=class extends Oy{#e;constructor({messages:e,...t}){let n=new Py(e);super({...t,state:n}),this[`~registerMessagesCallback`]=(e,t)=>this.#e[`~registerMessagesCallback`](e,t),this[`~registerStatusCallback`]=e=>this.#e[`~registerStatusCallback`](e),this[`~registerErrorCallback`]=e=>this.#e[`~registerErrorCallback`](e),this[`~registerQueuedMessagesCallback`]=e=>this.#e[`~registerQueuedMessagesCallback`](e),this.#e=n}},Iy=new WeakMap;function Ly({chat:e,state:t}){if(document.visibilityState!==`visible`||t.pendingVisibilityResume!=null)return;let n=()=>Iy.get(e)===t&&t.registrations.size>0,r=()=>{t.pendingVisibilityResume=void 0};t.pendingVisibilityResume=e[`~resumeStreamIfDisconnected`]({shouldResume:()=>n()&&document.visibilityState===`visible`}).then(r,r)}function Ry({chat:e,registration:t}){let n=Iy.get(e);if(n==null){let t={registrations:new Set};if(Iy.set(e,t),n=t,typeof document<`u`){let n=()=>Ly({chat:e,state:t});document.addEventListener(`visibilitychange`,n),t.cleanupVisibilityListener=()=>{document.removeEventListener(`visibilitychange`,n)}}}let{registrations:r}=n,i=r.size===0;return r.add(t),i&&e.status!==`submitted`&&e.status!==`streaming`&&e.resumeStream(),()=>{r.delete(t),r.size===0&&(n.cleanupVisibilityListener?.(),Iy.delete(e))}}function zy(e){return{chat:e,messages:e.messages,status:e.status,error:e.error,experimental_queuedMessages:e.experimental_queuedMessages}}function By(e,t){return e.chat===t.chat&&e.messages===t.messages&&e.status===t.status&&e.error===t.error&&e.experimental_queuedMessages===t.experimental_queuedMessages}function Vy({throttle:e,experimental_throttle:t,resume:n=!1,...r}={}){let i=e??t,a=(0,R.useRef)({}),o=(0,R.useRef)({});`chat`in r||(o.current={onToolCall:r.onToolCall,onData:r.onData,onFinish:r.onFinish,onError:r.onError,sendAutomaticallyWhen:r.sendAutomaticallyWhen,transport:r.transport});let s,c=()=>o.current.transport??(s??=new Dy),l={...r,transport:{get resumeStreamIsReplay(){return c().resumeStreamIsReplay},sendMessages:e=>c().sendMessages(e),reconnectToStream:e=>c().reconnectToStream(e)},onToolCall:e=>o.current.onToolCall?.(e),onData:e=>o.current.onData?.(e),onFinish:e=>o.current.onFinish?.(e),onError:e=>o.current.onError?.(e),sendAutomaticallyWhen:e=>o.current.sendAutomaticallyWhen?.(e)??!1},{chat:u,isExternallyManaged:d}=(0,R.useMemo)(()=>({chat:`chat`in r?r.chat:new Fy(l),isExternallyManaged:`chat`in r}),[`chat`in r?r.chat:r.id]);(0,R.useEffect)(()=>{if(!d)return()=>{u.stop()}},[u,d]);let[f,p]=(0,R.useState)(()=>zy(u));f.chat!==u&&p(zy(u)),(0,R.useEffect)(()=>{let e=!0,t=()=>{if(!e)return;let t=zy(u);p(e=>e.chat!==u||By(e,t)?e:t)},n=[u[`~registerMessagesCallback`](t,i),u[`~registerStatusCallback`](t),u[`~registerErrorCallback`](t),u[`~registerQueuedMessagesCallback`](t)],r=zy(u);return p(e=>By(e,r)?e:r),()=>{e=!1,n.forEach(e=>e())}},[u,i]);let{messages:m,status:h,error:g,experimental_queuedMessages:_}=f,v=(0,R.useCallback)(e=>{typeof e==`function`&&(e=e(u.messages)),u.messages=e},[u]);return(0,R.useEffect)(()=>{if(n)return Ry({chat:u,registration:a.current})},[n,u]),{get id(){return u.id},messages:m,setMessages:v,sendMessage:u.sendMessage,regenerate:u.regenerate,clearError:u.clearError,stop:u.stop,error:g,resumeStream:u.resumeStream,status:h,addToolResult:u.addToolOutput,addToolOutput:u.addToolOutput,addToolApprovalResponse:u.addToolApprovalResponse,experimental_queuedMessages:_,experimental_removeQueuedMessage:u.experimental_removeQueuedMessage,experimental_sendQueuedMessageNow:u.experimental_sendQueuedMessageNow}}var Hy=a(((e,t)=>{(function(n,r){typeof i==`function`&&typeof e==`object`&&typeof t==`object`?t.exports=r():typeof define==`function`&&define.amd?define(function(){return r()}):n.pluralize=r()})(e,function(){var e=[],t=[],n={},r={},i={};function a(e){return typeof e==`string`?RegExp(`^`+e+`$`,`i`):e}function o(e,t){return e===t?t:e===e.toLowerCase()?t.toLowerCase():e===e.toUpperCase()?t.toUpperCase():e[0]===e[0].toUpperCase()?t.charAt(0).toUpperCase()+t.substr(1).toLowerCase():t.toLowerCase()}function s(e,t){return e.replace(/\$(\d{1,2})/g,function(e,n){return t[n]||``})}function c(e,t){return e.replace(t[0],function(n,r){var i=s(t[1],arguments);return o(n===``?e[r-1]:n,i)})}function l(e,t,r){if(!e.length||n.hasOwnProperty(e))return t;for(var i=r.length;i--;){var a=r[i];if(a[0].test(t))return c(t,a)}return t}function u(e,t,n){return function(r){var i=r.toLowerCase();return t.hasOwnProperty(i)?o(r,i):e.hasOwnProperty(i)?o(r,e[i]):l(i,r,n)}}function d(e,t,n,r){return function(r){var i=r.toLowerCase();return t.hasOwnProperty(i)?!0:!e.hasOwnProperty(i)&&l(i,i,n)===i}}function f(e,t,n){var r=t===1?f.singular(e):f.plural(e);return(n?t+` `:``)+r}return f.plural=u(i,r,e),f.isPlural=d(i,r,e),f.singular=u(r,i,t),f.isSingular=d(r,i,t),f.addPluralRule=function(t,n){e.push([a(t),n])},f.addSingularRule=function(e,n){t.push([a(e),n])},f.addUncountableRule=function(e){if(typeof e==`string`){n[e.toLowerCase()]=!0;return}f.addPluralRule(e,`$0`),f.addSingularRule(e,`$0`)},f.addIrregularRule=function(e,t){t=t.toLowerCase(),e=e.toLowerCase(),i[e]=t,r[t]=e},[[`I`,`we`],[`me`,`us`],[`he`,`they`],[`she`,`they`],[`them`,`them`],[`myself`,`ourselves`],[`yourself`,`yourselves`],[`itself`,`themselves`],[`herself`,`themselves`],[`himself`,`themselves`],[`themself`,`themselves`],[`is`,`are`],[`was`,`were`],[`has`,`have`],[`this`,`these`],[`that`,`those`],[`echo`,`echoes`],[`dingo`,`dingoes`],[`volcano`,`volcanoes`],[`tornado`,`tornadoes`],[`torpedo`,`torpedoes`],[`genus`,`genera`],[`viscus`,`viscera`],[`stigma`,`stigmata`],[`stoma`,`stomata`],[`dogma`,`dogmata`],[`lemma`,`lemmata`],[`schema`,`schemata`],[`anathema`,`anathemata`],[`ox`,`oxen`],[`axe`,`axes`],[`die`,`dice`],[`yes`,`yeses`],[`foot`,`feet`],[`eave`,`eaves`],[`goose`,`geese`],[`tooth`,`teeth`],[`quiz`,`quizzes`],[`human`,`humans`],[`proof`,`proofs`],[`carve`,`carves`],[`valve`,`valves`],[`looey`,`looies`],[`thief`,`thieves`],[`groove`,`grooves`],[`pickaxe`,`pickaxes`],[`passerby`,`passersby`]].forEach(function(e){return f.addIrregularRule(e[0],e[1])}),[[/s?$/i,`s`],[/[^\u0000-\u007F]$/i,`$0`],[/([^aeiou]ese)$/i,`$1`],[/(ax|test)is$/i,`$1es`],[/(alias|[^aou]us|t[lm]as|gas|ris)$/i,`$1es`],[/(e[mn]u)s?$/i,`$1s`],[/([^l]ias|[aeiou]las|[ejzr]as|[iu]am)$/i,`$1`],[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,`$1i`],[/(alumn|alg|vertebr)(?:a|ae)$/i,`$1ae`],[/(seraph|cherub)(?:im)?$/i,`$1im`],[/(her|at|gr)o$/i,`$1oes`],[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i,`$1a`],[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i,`$1a`],[/sis$/i,`ses`],[/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i,`$1$2ves`],[/([^aeiouy]|qu)y$/i,`$1ies`],[/([^ch][ieo][ln])ey$/i,`$1ies`],[/(x|ch|ss|sh|zz)$/i,`$1es`],[/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i,`$1ices`],[/\b((?:tit)?m|l)(?:ice|ouse)$/i,`$1ice`],[/(pe)(?:rson|ople)$/i,`$1ople`],[/(child)(?:ren)?$/i,`$1ren`],[/eaux$/i,`$0`],[/m[ae]n$/i,`men`],[`thou`,`you`]].forEach(function(e){return f.addPluralRule(e[0],e[1])}),[[/s$/i,``],[/(ss)$/i,`$1`],[/(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$/i,`$1fe`],[/(ar|(?:wo|[ae])l|[eo][ao])ves$/i,`$1f`],[/ies$/i,`y`],[/\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/i,`$1ie`],[/\b(mon|smil)ies$/i,`$1ey`],[/\b((?:tit)?m|l)ice$/i,`$1ouse`],[/(seraph|cherub)im$/i,`$1`],[/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$/i,`$1`],[/(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$/i,`$1sis`],[/(movie|twelve|abuse|e[mn]u)s$/i,`$1`],[/(test)(?:is|es)$/i,`$1is`],[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,`$1us`],[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i,`$1um`],[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i,`$1on`],[/(alumn|alg|vertebr)ae$/i,`$1a`],[/(cod|mur|sil|vert|ind)ices$/i,`$1ex`],[/(matr|append)ices$/i,`$1ix`],[/(pe)(rson|ople)$/i,`$1rson`],[/(child)ren$/i,`$1`],[/(eau)x?$/i,`$1`],[/men$/i,`man`]].forEach(function(e){return f.addSingularRule(e[0],e[1])}),[`adulthood`,`advice`,`agenda`,`aid`,`aircraft`,`alcohol`,`ammo`,`analytics`,`anime`,`athletics`,`audio`,`bison`,`blood`,`bream`,`buffalo`,`butter`,`carp`,`cash`,`chassis`,`chess`,`clothing`,`cod`,`commerce`,`cooperation`,`corps`,`debris`,`diabetes`,`digestion`,`elk`,`energy`,`equipment`,`excretion`,`expertise`,`firmware`,`flounder`,`fun`,`gallows`,`garbage`,`graffiti`,`hardware`,`headquarters`,`health`,`herpes`,`highjinks`,`homework`,`housework`,`information`,`jeans`,`justice`,`kudos`,`labour`,`literature`,`machinery`,`mackerel`,`mail`,`media`,`mews`,`moose`,`music`,`mud`,`manga`,`news`,`only`,`personnel`,`pike`,`plankton`,`pliers`,`police`,`pollution`,`premises`,`rain`,`research`,`rice`,`salmon`,`scissors`,`series`,`sewage`,`shambles`,`shrimp`,`software`,`species`,`staff`,`swine`,`tennis`,`traffic`,`transportation`,`trout`,`tuna`,`wealth`,`welfare`,`whiting`,`wildebeest`,`wildlife`,`you`,/pok[eé]mon$/i,/[^aeiou]ese$/i,/deer$/i,/fish$/i,/measles$/i,/o[iu]s$/i,/pox$/i,/sheep$/i].forEach(f.addUncountableRule),f})})),Uy=a(((e,t)=>{function n(e){return e=String(e),e&&e.toLowerCase()}n.isLowercase=function(e){return e&&!/[A-Z]+/.test(e)},t.exports=n})),Wy=a(((e,t)=>{function n(e){return e=String(e),e&&e.toUpperCase()}n.isUppercase=function(e){return e&&!/[a-z]+/.test(e)},t.exports=n})),Gy=a(((e,t)=>{var n=Uy(),r=Wy(),i={from:/[\-_:\.\s]([a-zA-Z])([a-zA-Z]*)/g,to:function(e,t,n,i,a){return t.length,r(t)+n}};function a(e){return a.isCamelcase(e)||(e=String(e).replace(/^[\-_:\.\s]/,``),!e)?e:(r.isUppercase(e)&&(e=n(e)),n(e[0])+e.replace(i.from,i.to).slice(1).replace(/^([A-Z]+)([A-Z])/,function(e,t,r){return n(t)+r}))}a.isCamelcase=function(e){return e&&/^[a-zA-Z]+$/.test(e)&&n(e[0])===e[0]},t.exports=a})),Ky=a(((e,t)=>{var n=Wy();function r(e){return e=String(e),e&&n(e[0])+e.slice(1)}t.exports=r})),qy=a(((e,t)=>{var n=Uy(),r=Wy(),i=`_`,a={from:/([A-Z]+)/g,to:function(e,t,a,o){var s=a===0?``:i,c=t.length;if(c===1)return s+n(t);var l=o.slice(a+t.length);return r.isUppercase(t)&&l[0]===i?s+n(t):s+(n(t.substr(0,c-1))+i+n(t[c-1]))}};function o(e){return o.isSnakecase(e)||(e=String(e).replace(/[\-.:\s]/g,i),!e)?e:(r.isUppercase(e)&&(e=n(e)),e.replace(a.from,a.to).replace(/_+/g,`_`))}o.isSnakecase=function(e){return e&&/^[a-z_]+$/.test(e)},t.exports=o})),Jy=a(((e,t)=>{var n=Wy(),r=qy();function i(e){return i.isConstcase(e)?e:n(r(e))}i.isConstcase=function(e){return e&&/^[A-Z_]+$/.test(e)},t.exports=i})),Yy=a(((e,t)=>{var n=qy();function r(e){return n(e).replace(/_/g,``)}t.exports=r})),Xy=a(((e,t)=>{var n=Uy();function r(e){return e=String(e),e&&n(e[0])+e.slice(1)}t.exports=r})),Zy=a(((e,t)=>{var n=qy();function r(e){return n(e).replace(/_/g,`.`)}t.exports=r})),Qy=a(((e,t)=>{var n=qy();function r(e){return n(e).replace(/_/g,`:`)}t.exports=r})),$y=a(((e,t)=>{var n=Gy(),r=Ky();function i(e){return r(n(e))}t.exports=i})),eb=a(((e,t)=>{var n=qy();function r(e){return n(e).replace(/_/g,`/`)}t.exports=r})),tb=a(((e,t)=>{function n(e){return String(e).trim()}t.exports=n})),nb=a(((e,t)=>{Uy();var n=tb(),r=qy(),i=Ky(),a=` `;function o(e){return e=String(e).replace(/^[\-_\.\s]/g,a),e&&i(r(n(e)).replace(/_/g,a))}t.exports=o})),rb=a(((e,t)=>{var n=qy();function r(e){return n(e).replace(/_/g,` `)}t.exports=r})),ib=a(((e,t)=>{var n=qy();function r(e){return n(e).replace(/_/g,`-`)}t.exports=r})),ab=a(((e,t)=>{var n=qy(),r=Uy(),i=tb(),a=Ky(),o=`a,the,and,or,not,but,for,of`.split(`,`);function s(e){return n(e).split(/_/g).map(i).map(function(e){return~o.indexOf(e)?r(e):a(e)}).join(` `)}t.exports=s})),ob=a(((e,t)=>{var n=Gy(),r=Ky(),i=Jy(),a=Yy(),o=Xy(),s=Zy(),c=Qy(),l=Uy(),u=$y(),d=eb(),f=nb(),p=qy(),m=rb(),h=ib(),g=ab(),_=tb(),v=Wy();e.camelcase=n,e.capitalcase=r,e.constcase=i,e.cramcase=a,e.decapitalcase=o,e.dotcase=s,e.enumcase=c,e.lowercase=l,e.pascalcase=u,e.pathcase=d,e.sentencecase=f,e.snakecase=p,e.spacecase=m,e.spinalcase=h,e.titlecase=g,e.trimcase=_,e.uppercase=v,t.exports={camelcase:n,capitalcase:r,constcase:i,cramcase:a,decapitalcase:o,dotcase:s,enumcase:c,lowercase:l,pascalcase:u,pathcase:d,sentencecase:f,snakecase:p,spacecase:m,spinalcase:h,titlecase:g,trimcase:_,uppercase:v}}));Hy(),ob();function sb(e){return typeof e==`object`&&!!e&&`name`in e&&(`data`in e||`codec`in e)&&typeof e.name==`string`}function cb(e){return lb(e,new WeakSet)}function lb(e,t){return typeof e==`object`?e===null||t.has(e)?!0:(t.add(e),Array.isArray(e)?e.every(e=>lb(e,t)):e instanceof Promise?!1:Symbol.asyncIterator in e||Symbol.iterator in e?!0:sb(e)?lb(e.data,t):Object.values(e).every(e=>lb(e,t))):typeof e!=`bigint`&&typeof e!=`symbol`}function ub(e){return!(typeof e!=`object`||!e||Array.isArray(e)||e instanceof Promise||Symbol.asyncIterator in e||Symbol.iterator in e||sb(e))}function db(e){return e.type===`message`}function fb(e){if(sb(e)){if(db(e))throw Error(`Message fragments are not supported by serialized fragment conversion`);if(!e.codec)throw Error(`Fragment "${e.name}" is missing codec`);return e.codec.encode()}return Array.isArray(e)?e.map(e=>fb(e)):ub(e)?Object.fromEntries(Object.entries(e).map(([e,t])=>[e,fb(t)])):e}function pb(e,t){return{name:`term`,data:{name:e,definition:t},codec:{encode(){return{type:`term`,name:e,definition:t}},decode(){return{name:e,definition:t}}}}}function mb(e){return{name:`hint`,data:e,codec:{encode(){return{type:`hint`,text:e}},decode(){return e}}}}function hb(e){return{name:`guardrail`,data:{rule:e.rule,...e.reason&&{reason:e.reason},...e.action&&{action:e.action}},codec:{encode(){return{type:`guardrail`,rule:e.rule,...e.reason&&{reason:e.reason},...e.action&&{action:e.action}}},decode(){return{rule:e.rule,...e.reason&&{reason:e.reason},...e.action&&{action:e.action}}}}}}function gb(e){return{name:`explain`,data:{concept:e.concept,explanation:e.explanation,...e.therefore&&{therefore:e.therefore}},codec:{encode(){return{type:`explain`,concept:e.concept,explanation:e.explanation,...e.therefore&&{therefore:e.therefore}}},decode(){return{concept:e.concept,explanation:e.explanation,...e.therefore&&{therefore:e.therefore}}}}}}function _b(e){return{name:`example`,data:{question:e.question,answer:e.answer,...e.note&&{note:e.note}},codec:{encode(){return{type:`example`,question:e.question,answer:e.answer,...e.note&&{note:e.note}}},decode(){return{question:e.question,answer:e.answer,...e.note&&{note:e.note}}}}}}function vb(e){return{name:`clarification`,data:{when:e.when,ask:e.ask,reason:e.reason},codec:{encode(){return{type:`clarification`,when:e.when,ask:e.ask,reason:e.reason}},decode(){return{when:e.when,ask:e.ask,reason:e.reason}}}}}function yb(e){return{name:`workflow`,data:{task:e.task,steps:e.steps,...e.triggers?.length&&{triggers:e.triggers},...e.notes&&{notes:e.notes}},codec:{encode(){return{type:`workflow`,task:e.task,steps:e.steps,...e.triggers?.length&&{triggers:e.triggers},...e.notes&&{notes:e.notes}}},decode(){return{task:e.task,steps:e.steps,...e.triggers?.length&&{triggers:e.triggers},...e.notes&&{notes:e.notes}}}}}}function bb(e){return{name:`quirk`,data:{issue:e.issue,workaround:e.workaround},codec:{encode(){return{type:`quirk`,issue:e.issue,workaround:e.workaround}},decode(){return{issue:e.issue,workaround:e.workaround}}}}}function xb(e){return{name:`styleGuide`,data:{prefer:e.prefer,...e.never&&{never:e.never},...e.always&&{always:e.always}},codec:{encode(){return{type:`styleGuide`,prefer:e.prefer,...e.never&&{never:e.never},...e.always&&{always:e.always}}},decode(){return{prefer:e.prefer,...e.never&&{never:e.never},...e.always&&{always:e.always}}}}}}function Sb(e){return{name:`analogy`,data:{concepts:e.concepts,relationship:e.relationship,...e.insight&&{insight:e.insight},...e.therefore&&{therefore:e.therefore},...e.pitfall&&{pitfall:e.pitfall}},codec:{encode(){return{type:`analogy`,concepts:e.concepts,relationship:e.relationship,...e.insight&&{insight:e.insight},...e.therefore&&{therefore:e.therefore},...e.pitfall&&{pitfall:e.pitfall}}},decode(){return{concepts:e.concepts,relationship:e.relationship,...e.insight&&{insight:e.insight},...e.therefore&&{therefore:e.therefore},...e.pitfall&&{pitfall:e.pitfall}}}}}}function Cb(e){return{name:`glossary`,data:Object.entries(e).map(([e,t])=>({term:e,expression:t})),codec:{encode(){return{type:`glossary`,entries:e}},decode(){return Object.entries(e).map(([e,t])=>({term:e,expression:t}))}}}}function wb(e){return{name:`role`,data:e,codec:{encode(){return{type:`role`,content:e}},decode(){return e}}}}function Tb(e){return{name:`principle`,data:{title:e.title,description:e.description,...e.policies?.length&&{policies:e.policies}},codec:{encode(){return{type:`principle`,title:e.title,description:e.description,...e.policies?.length&&{policies:e.policies.map(e=>fb(e))}}},decode(){return{title:e.title,description:e.description,...e.policies?.length&&{policies:e.policies}}}}}}function Eb(e){return{name:`policy`,data:{rule:e.rule,...e.before&&{before:e.before},...e.reason&&{reason:e.reason},...e.policies?.length&&{policies:e.policies}},codec:{encode(){return{type:`policy`,rule:e.rule,...e.before&&{before:e.before},...e.reason&&{reason:e.reason},...e.policies?.length&&{policies:e.policies.map(e=>fb(e))}}},decode(){return{rule:e.rule,...e.before&&{before:e.before},...e.reason&&{reason:e.reason},...e.policies?.length&&{policies:e.policies}}}}}}function Db(e){return{name:`identity`,data:{...e.name&&{name:e.name},...e.role&&{role:e.role}},codec:{encode(){return{type:`identity`,...e.name&&{name:e.name},...e.role&&{role:e.role}}},decode(){return{...e.name&&{name:e.name},...e.role&&{role:e.role}}}}}}function Ob(e){return{name:`persona`,data:{name:e.name,...e.role&&{role:e.role},...e.objective&&{objective:e.objective},...e.tone&&{tone:e.tone}},codec:{encode(){return{type:`persona`,name:e.name,...e.role&&{role:e.role},...e.objective&&{objective:e.objective},...e.tone&&{tone:e.tone}}},decode(){return{name:e.name,...e.role&&{role:e.role},...e.objective&&{objective:e.objective},...e.tone&&{tone:e.tone}}}}}}function kb(e,t){return{name:`alias`,data:{term:e,meaning:t},codec:{encode(){return{type:`alias`,term:e,meaning:t}},decode(){return{term:e,meaning:t}}}}}function Ab(e,t){return{name:`preference`,data:{aspect:e,value:t},codec:{encode(){return{type:`preference`,aspect:e,value:t}},decode(){return{aspect:e,value:t}}}}}function jb(e,t){return{name:`correction`,data:{subject:e,clarification:t},codec:{encode(){return{type:`correction`,subject:e,clarification:t}},decode(){return{subject:e,clarification:t}}}}}function Mb(e){return typeof e==`object`&&!!e&&`type`in e&&typeof e.type==`string`}function Nb(e,t){if(Mb(e))return See(e,t);if(Array.isArray(e))return e.map(e=>Nb(e,t));if(ub(e))return Object.fromEntries(Object.entries(e).map(([e,n])=>[e,Nb(n,t)]));if(!cb(e))throw Error(`Unsupported serialized value of type ${typeof e}`);return e}function Pb(e,t){return{toFragment:(n,r)=>{let i=e.safeParse(n);if(!i.success)throw Error(`Invalid serialized ${n.type} fragment: ${At(i.error)}`);return t(i.data,r)}}}var Fb=Xt(fn()).optional(),Ib={term:Pb(F({name:L(),definition:L()}),e=>pb(e.name,e.definition)),hint:Pb(F({text:L()}),e=>mb(e.text)),guardrail:Pb(F({rule:L(),reason:L().optional(),action:L().optional()}),e=>hb({rule:e.rule,reason:e.reason,action:e.action})),explain:Pb(F({concept:L(),explanation:L(),therefore:L().optional()}),e=>gb({concept:e.concept,explanation:e.explanation,therefore:e.therefore})),example:Pb(F({question:L(),answer:L(),note:L().optional()}),e=>_b({question:e.question,answer:e.answer,note:e.note})),clarification:Pb(F({when:L(),ask:L(),reason:L()}),e=>vb({when:e.when,ask:e.ask,reason:e.reason})),workflow:Pb(F({task:L(),steps:Xt(L()),triggers:Xt(L()).optional(),notes:L().optional()}),e=>yb({task:e.task,steps:e.steps,triggers:e.triggers,notes:e.notes})),quirk:Pb(F({issue:L(),workaround:L()}),e=>bb({issue:e.issue,workaround:e.workaround})),styleGuide:Pb(F({prefer:L(),never:L().optional(),always:L().optional()}),e=>xb({prefer:e.prefer,never:e.never,always:e.always})),analogy:Pb(F({concepts:Xt(L()),relationship:L(),insight:L().optional(),therefore:L().optional(),pitfall:L().optional()}),e=>Sb({concepts:e.concepts,relationship:e.relationship,insight:e.insight,therefore:e.therefore,pitfall:e.pitfall})),glossary:Pb(F({entries:C(L(),L())}),e=>Cb(e.entries)),role:Pb(F({content:L()}),e=>wb(e.content)),principle:Pb(F({title:L(),description:L(),policies:Fb}),(e,t)=>Tb({title:e.title,description:e.description,policies:e.policies?.map(e=>Nb(e,t))})),policy:Pb(F({rule:L(),before:L().optional(),reason:L().optional(),policies:Fb}),(e,t)=>Eb({rule:e.rule,before:e.before,reason:e.reason,policies:e.policies?.map(e=>Nb(e,t))})),identity:Pb(F({name:L().optional(),role:L().optional()}),e=>Db({name:e.name,role:e.role})),persona:Pb(F({name:L(),role:L().optional(),objective:L().optional(),tone:L().optional()}),e=>Ob({name:e.name,role:e.role,objective:e.objective,tone:e.tone})),alias:Pb(F({term:L(),meaning:L()}),e=>kb(e.term,e.meaning)),preference:Pb(F({aspect:L(),value:L()}),e=>Ab(e.aspect,e.value)),correction:Pb(F({subject:L(),clarification:L()}),e=>jb(e.subject,e.clarification))};function bee(e){return Object.hasOwn(Ib,e)}var xee=new Set([`user`,`assistant`,`message`]);function See(e,t){if(xee.has(e.type))throw Error(`Message fragments are not supported by serialized fragment conversion`);let n=t?.registry?.[e.type]??(bee(e.type)?Ib[e.type]:void 0);if(!n)throw Error(`Unsupported serialized fragment type: ${e.type}`);return n.toFragment(e,t)}function Cee(e){let t=e?.reminders;return Array.isArray(t)?t.filter(e=>qh(e)&&typeof e.partIndex==`number`&&typeof e.start==`number`&&typeof e.end==`number`):[]}function Lb(e,t){if(t.length===0)return e;let n=t.map(t=>({start:Math.max(0,Math.min(e.length,t.start)),end:Math.max(0,Math.min(e.length,t.end))})).filter(e=>e.end>e.start).sort((e,t)=>e.start-t.start);if(n.length===0)return e;let r=0,i=``;for(let t of n){if(t.start<r){t.end>r&&(r=t.end);continue}i+=e.slice(r,t.start),r=t.end}return i+=e.slice(r),i.trimEnd()}function Rb(e){if(zb(e))return Bb(e);let t=Cee(qh(e.metadata)?e.metadata:void 0),n=new Map;for(let e of t){let t=n.get(e.partIndex)??[];t.push({start:e.start,end:e.end}),n.set(e.partIndex,t)}let r=e.parts.flatMap((e,t)=>{let r={...e},i=n.get(t);if(r.type!==`text`||i===void 0)return[r];let a=Lb(r.text,i);return a.length===0?[]:[{...r,text:a}]}),i={...e,parts:r};if(qh(e.metadata)){let t={...e.metadata};delete t.reminders,Object.keys(t).length>0?i.metadata=t:delete i.metadata}return i}function zb(e){let t=e.metadata;if(!qh(t))return!1;let n=t.synthetic;return qh(n)?n.source===`reminder`:!1}function Bb(e){let t={...e,parts:e.parts.filter(e=>e.type!==`text`)};if(qh(e.metadata)){let n={...e.metadata};delete n.synthetic,Object.keys(n).length>0?t.metadata=n:delete t.metadata}return t}var Vb=(0,R.createContext)({});function Hb(e){let t=(0,R.useRef)(null);return t.current===null&&(t.current=e()),t.current}var Ub=typeof window<`u`?R.useLayoutEffect:R.useEffect,Wb=(0,R.createContext)(null);function Gb(e,t){e.indexOf(t)===-1&&e.push(t)}function Kb(e,t){let n=e.indexOf(t);n>-1&&e.splice(n,1)}var qb=(e,t,n)=>n>t?t:n<e?e:n,Jb={},Yb=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e),Xb=e=>typeof e==`object`&&!!e,Zb=e=>/^0[^.\s]+$/u.test(e);function Qb(e){let t;return()=>(t===void 0&&(t=e()),t)}var $b=e=>e,ex=(...e)=>e.reduce((e,t)=>n=>t(e(n))),tx=(e,t,n)=>{let r=t-e;return r?(n-e)/r:1},nx=class{constructor(){this.subscriptions=[]}add(e){return Gb(this.subscriptions,e),()=>Kb(this.subscriptions,e)}notify(e,t,n){let r=this.subscriptions.length;if(r)if(r===1)this.subscriptions[0](e,t,n);else for(let i=0;i<r;i++){let r=this.subscriptions[i];r&&r(e,t,n)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}},rx=e=>e*1e3,ix=e=>e/1e3,ax=(e,t)=>t?1e3/t*e:0,ox=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,sx=1e-7,cx=12;function lx(e,t,n,r,i){let a,o,s=0;do o=t+(n-t)/2,a=ox(o,r,i)-e,a>0?n=o:t=o;while(Math.abs(a)>sx&&++s<cx);return o}function ux(e,t,n,r){if(e===t&&n===r)return $b;let i=t=>lx(t,0,1,e,n);return e=>e===0||e===1?e:ox(i(e),t,r)}var dx=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,fx=e=>t=>1-e(1-t),px=ux(.33,1.53,.69,.99),mx=fx(px),hx=dx(mx),gx=e=>e>=1?1:(e*=2)<1?.5*mx(e):.5*(2-2**(-10*(e-1))),_x=e=>1-Math.sin(Math.acos(e)),vx=fx(_x),yx=dx(_x),bx=ux(.42,0,1,1),xx=ux(0,0,.58,1),Sx=ux(.42,0,.58,1),Cx=e=>Array.isArray(e)&&typeof e[0]!=`number`,wx=e=>Array.isArray(e)&&typeof e[0]==`number`,Tx={linear:$b,easeIn:bx,easeInOut:Sx,easeOut:xx,circIn:_x,circInOut:yx,circOut:vx,backIn:mx,backInOut:hx,backOut:px,anticipate:gx},Ex=e=>typeof e==`string`,Dx=e=>{if(wx(e)){e.length;let[t,n,r,i]=e;return ux(t,n,r,i)}else if(Ex(e))return Tx[e],`${e}`,Tx[e];return e},Ox=[`setup`,`read`,`resolveKeyframes`,`preUpdate`,`update`,`preRender`,`render`,`postRender`];function kx(e){let t=new Set,n=new Set,r=!1,i=!1,a=new WeakSet,o={delta:0,timestamp:0,isProcessing:!1};function s(t){a.has(t)&&(c.schedule(t),e()),t(o)}let c={schedule:(e,i=!1,o=!1)=>{let s=o&&r?t:n;return i&&a.add(e),s.add(e),e},cancel:e=>{n.delete(e),a.delete(e)},process:e=>{if(o=e,r){i=!0;return}r=!0;let a=t;t=n,n=a,t.forEach(s),t.clear(),r=!1,i&&(i=!1,c.process(e))}};return c}var Ax=40;function jx(e,t){let n=!1,r=!0,i={delta:0,timestamp:0,isProcessing:!1},a=()=>n=!0,o=Ox.reduce((e,t)=>(e[t]=kx(a),e),{}),{setup:s,read:c,resolveKeyframes:l,preUpdate:u,update:d,preRender:f,render:p,postRender:m}=o,h=()=>{let a=Jb.useManualTiming,o=a?i.timestamp:performance.now();n=!1,a||(i.delta=r?1e3/60:Math.max(Math.min(o-i.timestamp,Ax),1)),i.timestamp=o,i.isProcessing=!0,s.process(i),c.process(i),l.process(i),u.process(i),d.process(i),f.process(i),p.process(i),m.process(i),i.isProcessing=!1,n&&t&&(r=!1,e(h))},g=()=>{n=!0,r=!0,i.isProcessing||e(h)};return{schedule:Ox.reduce((e,t)=>{let r=o[t];return e[t]=(e,t=!1,i=!1)=>(n||g(),r.schedule(e,t,i)),e},{}),cancel:e=>{for(let t=0;t<Ox.length;t++)o[Ox[t]].cancel(e)},state:i,steps:o}}var{schedule:Mx,cancel:Nx,state:Px,steps:Fx}=jx(typeof requestAnimationFrame<`u`?requestAnimationFrame:$b,!0),Ix;function Lx(){Ix=void 0}var Rx={now:()=>(Ix===void 0&&Rx.set(Px.isProcessing||Jb.useManualTiming?Px.timestamp:performance.now()),Ix),set:e=>{Ix=e,queueMicrotask(Lx)}},zx=e=>t=>typeof t==`string`&&t.startsWith(e),Bx=zx(`--`),Vx=zx(`var(--`),Hx=e=>Vx(e)?Ux.test(e.split(`/*`)[0].trim()):!1,Ux=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function Wx(e){return typeof e==`string`&&e.split(`/*`)[0].includes(`var(--`)}var Gx={test:e=>typeof e==`number`,parse:parseFloat,transform:e=>e},Kx={...Gx,transform:e=>qb(0,1,e)},qx={...Gx,default:1},Jx=e=>Math.round(e*1e5)/1e5,Yx=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function Xx(e){return e==null}var Zx=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Qx=(e,t)=>n=>!!(typeof n==`string`&&Zx.test(n)&&n.startsWith(e)||t&&!Xx(n)&&Object.prototype.hasOwnProperty.call(n,t)),$x=(e,t,n)=>r=>{if(typeof r!=`string`)return r;let[i,a,o,s]=r.match(Yx);return{[e]:parseFloat(i),[t]:parseFloat(a),[n]:parseFloat(o),alpha:s===void 0?1:parseFloat(s)}},eS=e=>qb(0,255,e),tS={...Gx,transform:e=>Math.round(eS(e))},nS={test:Qx(`rgb`,`red`),parse:$x(`red`,`green`,`blue`),transform:({red:e,green:t,blue:n,alpha:r=1})=>`rgba(`+tS.transform(e)+`, `+tS.transform(t)+`, `+tS.transform(n)+`, `+Jx(Kx.transform(r))+`)`};function rS(e){let t=``,n=``,r=``,i=``;return e.length>5?(t=e.substring(1,3),n=e.substring(3,5),r=e.substring(5,7),i=e.substring(7,9)):(t=e.substring(1,2),n=e.substring(2,3),r=e.substring(3,4),i=e.substring(4,5),t+=t,n+=n,r+=r,i+=i),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(r,16),alpha:i?parseInt(i,16)/255:1}}var iS={test:Qx(`#`),parse:rS,transform:nS.transform},aS=e=>({test:t=>typeof t==`string`&&t.endsWith(e)&&t.split(` `).length===1,parse:parseFloat,transform:t=>`${t}${e}`}),oS=aS(`deg`),sS=aS(`%`),W=aS(`px`),cS=aS(`vh`),lS=aS(`vw`),uS={...sS,parse:e=>sS.parse(e)/100,transform:e=>sS.transform(e*100)},dS={test:Qx(`hsl`,`hue`),parse:$x(`hue`,`saturation`,`lightness`),transform:({hue:e,saturation:t,lightness:n,alpha:r=1})=>`hsla(`+Math.round(e)+`, `+sS.transform(Jx(t))+`, `+sS.transform(Jx(n))+`, `+Jx(Kx.transform(r))+`)`},fS={test:e=>nS.test(e)||iS.test(e)||dS.test(e),parse:e=>nS.test(e)?nS.parse(e):dS.test(e)?dS.parse(e):iS.parse(e),transform:e=>typeof e==`string`?e:e.hasOwnProperty(`red`)?nS.transform(e):dS.transform(e),getAnimatableNone:e=>{let t=fS.parse(e);return t.alpha=0,fS.transform(t)}},pS=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function mS(e){return isNaN(e)&&typeof e==`string`&&(e.match(Yx)?.length||0)+(e.match(pS)?.length||0)>0}var hS=`number`,gS=`color`,_S=`var`,vS=`var(`,yS="${}",bS=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function xS(e){let t=e.toString(),n=[],r={color:[],number:[],var:[]},i=[],a=0;return{values:n,split:t.replace(bS,e=>(fS.test(e)?(r.color.push(a),i.push(gS),n.push(fS.parse(e))):e.startsWith(vS)?(r.var.push(a),i.push(_S),n.push(e)):(r.number.push(a),i.push(hS),n.push(parseFloat(e))),++a,yS)).split(yS),indexes:r,types:i}}function SS(e){return xS(e).values}function CS({split:e,types:t}){let n=e.length;return r=>{let i=``;for(let a=0;a<n;a++)if(i+=e[a],r[a]!==void 0){let e=t[a];e===hS?i+=Jx(r[a]):e===gS?i+=fS.transform(r[a]):i+=r[a]}return i}}function wS(e){return CS(xS(e))}var TS=e=>typeof e==`number`?0:fS.test(e)?fS.getAnimatableNone(e):e,ES=(e,t)=>typeof e==`number`?t?.trim().endsWith(`/`)?e:0:TS(e);function DS(e){let t=xS(e);return CS(t)(t.values.map((e,n)=>ES(e,t.split[n])))}var OS={test:mS,parse:SS,createTransformer:wS,getAnimatableNone:DS};function kS(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function AS({hue:e,saturation:t,lightness:n,alpha:r}){e/=360,t/=100,n/=100;let i=0,a=0,o=0;if(!t)i=a=o=n;else{let r=n<.5?n*(1+t):n+t-n*t,s=2*n-r;i=kS(s,r,e+1/3),a=kS(s,r,e),o=kS(s,r,e-1/3)}return{red:Math.round(i*255),green:Math.round(a*255),blue:Math.round(o*255),alpha:r}}function jS(e,t){return n=>n>0?t:e}var MS=(e,t,n)=>e+(t-e)*n,NS=(e,t,n)=>{let r=e*e,i=n*(t*t-r)+r;return i<0?0:Math.sqrt(i)},PS=[iS,nS,dS],FS=e=>PS.find(t=>t.test(e));function IS(e){let t=FS(e);if(`${e}`,!t)return!1;let n=t.parse(e);return t===dS&&(n=AS(n)),n}var LS=(e,t)=>{let n=IS(e),r=IS(t);if(!n||!r)return jS(e,t);let i={...n};return e=>(i.red=NS(n.red,r.red,e),i.green=NS(n.green,r.green,e),i.blue=NS(n.blue,r.blue,e),i.alpha=MS(n.alpha,r.alpha,e),nS.transform(i))},RS=new Set([`none`,`hidden`]);function zS(e,t){return RS.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function BS(e,t){return n=>MS(e,t,n)}function VS(e){return typeof e==`number`?BS:typeof e==`string`?Hx(e)?jS:fS.test(e)?LS:GS:Array.isArray(e)?HS:typeof e==`object`?fS.test(e)?LS:US:jS}function HS(e,t){let n=[...e],r=n.length,i=e.map((e,n)=>VS(e)(e,t[n]));return e=>{for(let t=0;t<r;t++)n[t]=i[t](e);return n}}function US(e,t){let n={...e,...t},r={};for(let i in n)e[i]!==void 0&&t[i]!==void 0&&(r[i]=VS(e[i])(e[i],t[i]));return e=>{for(let t in r)n[t]=r[t](e);return n}}function WS(e,t){let n=[],r={color:0,var:0,number:0};for(let i=0;i<t.values.length;i++){let a=t.types[i],o=e.indexes[a][r[a]];n[i]=e.values[o]??0,r[a]++}return n}var GS=(e,t)=>{let n=OS.createTransformer(t),r=xS(e),i=xS(t);return r.indexes.var.length===i.indexes.var.length&&r.indexes.color.length===i.indexes.color.length&&r.indexes.number.length>=i.indexes.number.length?RS.has(e)&&!i.values.length||RS.has(t)&&!r.values.length?zS(e,t):ex(HS(WS(r,i),i.values),n):(`${e}${t}`,jS(e,t))};function KS(e,t,n){return typeof e==`number`&&typeof t==`number`&&typeof n==`number`?MS(e,t,n):VS(e)(e,t)}var qS=e=>{let t=({timestamp:t})=>e(t);return{start:(e=!0)=>Mx.update(t,e),stop:()=>Nx(t),now:()=>Px.isProcessing?Px.timestamp:Rx.now()}},JS=(e,t,n=10)=>{let r=``,i=Math.max(Math.round(t/n),2);for(let t=0;t<i;t++)r+=Math.round(e(t/(i-1))*1e4)/1e4+`, `;return`linear(${r.substring(0,r.length-2)})`},YS=2e4;function XS(e){let t=0,n=e.next(t);for(;!n.done&&t<2e4;)t+=50,n=e.next(t);return t>=2e4?1/0:t}function ZS(e,t=100,n){let r=n({...e,keyframes:[0,t]}),i=Math.min(XS(r),YS);return{type:`keyframes`,ease:e=>r.next(i*e).value/t,duration:ix(i)}}var QS={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1};function $S(e,t){return e*Math.sqrt(1-t*t)}var eC=12;function tC(e,t,n){let r=n;for(let n=1;n<eC;n++)r-=e(r)/t(r);return r}var nC=.001;function rC({duration:e=QS.duration,bounce:t=QS.bounce,velocity:n=QS.velocity,mass:r=QS.mass}){let i,a;QS.maxDuration;let o=1-t;o=qb(QS.minDamping,QS.maxDamping,o),e=qb(QS.minDuration,QS.maxDuration,ix(e)),o<1?(i=t=>{let r=t*o,i=r*e,a=r-n,s=$S(t,o),c=Math.exp(-i);return nC-a/s*c},a=t=>{let r=t*o*e,a=r*n+n,s=o**2*t**2*e,c=Math.exp(-r),l=$S(t**2,o);return(-i(t)+nC>0?-1:1)*((a-s)*c)/l}):(i=t=>-.001+Math.exp(-t*e)*((t-n)*e+1),a=t=>Math.exp(-t*e)*((n-t)*(e*e)));let s=5/e,c=tC(i,a,s);if(e=rx(e),isNaN(c))return{stiffness:QS.stiffness,damping:QS.damping,duration:e};{let t=c**2*r;return{stiffness:t,damping:o*2*Math.sqrt(r*t),duration:e}}}var iC=[`duration`,`bounce`],aC=[`stiffness`,`damping`,`mass`];function oC(e,t){return t.some(t=>e[t]!==void 0)}function sC(e){let t={velocity:QS.velocity,stiffness:QS.stiffness,damping:QS.damping,mass:QS.mass,isResolvedFromDuration:!1,...e};if(!oC(e,aC)&&oC(e,iC))if(t.velocity=0,e.visualDuration){let n=e.visualDuration,r=2*Math.PI/(n*1.2),i=r*r,a=2*qb(.05,1,1-(e.bounce||0))*Math.sqrt(i);t={...t,mass:QS.mass,stiffness:i,damping:a}}else{let n=rC({...e,velocity:0});t={...t,...n,mass:QS.mass},t.isResolvedFromDuration=!0}return t}function cC(e=QS.visualDuration,t=QS.bounce){let n=typeof e==`object`?e:{visualDuration:e,keyframes:[0,1],bounce:t},{restSpeed:r,restDelta:i}=n,a=n.keyframes[0],o=n.keyframes[n.keyframes.length-1],s={done:!1,value:a},{stiffness:c,damping:l,mass:u,duration:d,velocity:f,isResolvedFromDuration:p}=sC({...n,velocity:-ix(n.velocity||0)}),m=f||0,h=l/(2*Math.sqrt(c*u)),g=o-a,_=ix(Math.sqrt(c/u)),v=Math.abs(g)<5;r||=v?QS.restSpeed.granular:QS.restSpeed.default,i||=v?QS.restDelta.granular:QS.restDelta.default;let y,b,x,S,C,w;if(h<1)x=$S(_,h),S=(m+h*_*g)/x,y=e=>{let t=Math.exp(-h*_*e);return o-t*(S*Math.sin(x*e)+g*Math.cos(x*e))},C=h*_*S+g*x,w=h*_*g-S*x,b=e=>Math.exp(-h*_*e)*(C*Math.sin(x*e)+w*Math.cos(x*e));else if(h===1){y=e=>o-Math.exp(-_*e)*(g+(m+_*g)*e);let e=m+_*g;b=t=>Math.exp(-_*t)*(_*e*t-m)}else{let e=_*Math.sqrt(h*h-1);y=t=>{let n=Math.exp(-h*_*t),r=Math.min(e*t,300);return o-n*((m+h*_*g)*Math.sinh(r)+e*g*Math.cosh(r))/e};let t=(m+h*_*g)/e,n=h*_*t-g*e,r=h*_*g-t*e;b=t=>{let i=Math.exp(-h*_*t),a=Math.min(e*t,300);return i*(n*Math.sinh(a)+r*Math.cosh(a))}}let T={calculatedDuration:p&&d||null,velocity:e=>rx(b(e)),next:e=>{if(!p&&h<1){let t=Math.exp(-h*_*e),n=Math.sin(x*e),a=Math.cos(x*e),c=o-t*(S*n+g*a),l=rx(t*(C*n+w*a));return s.done=Math.abs(l)<=r&&Math.abs(o-c)<=i,s.value=s.done?o:c,s}let t=y(e);if(p)s.done=e>=d;else{let n=rx(b(e));s.done=Math.abs(n)<=r&&Math.abs(o-t)<=i}return s.value=s.done?o:t,s},toString:()=>{let e=Math.min(XS(T),YS),t=JS(t=>T.next(e*t).value,e,30);return e+`ms `+t},toTransition:()=>{}};return T}cC.applyToOptions=e=>{let t=ZS(e,100,cC);return e.ease=t.ease,e.duration=rx(t.duration),e.type=`keyframes`,e};var lC=5;function uC(e,t,n){let r=Math.max(t-lC,0);return ax(n-e(r),t-r)}function dC({keyframes:e,velocity:t=0,power:n=.8,timeConstant:r=325,bounceDamping:i=10,bounceStiffness:a=500,modifyTarget:o,min:s,max:c,restDelta:l=.5,restSpeed:u}){let d=e[0],f={done:!1,value:d},p=e=>s!==void 0&&e<s||c!==void 0&&e>c,m=e=>s===void 0?c:c===void 0||Math.abs(s-e)<Math.abs(c-e)?s:c,h=n*t,g=d+h,_=o===void 0?g:o(g);_!==g&&(h=_-d);let v=e=>-h*Math.exp(-e/r),y=e=>_+v(e),b=e=>{let t=v(e),n=y(e);f.done=Math.abs(t)<=l,f.value=f.done?_:n},x,S,C=e=>{p(f.value)&&(x=e,S=cC({keyframes:[f.value,m(f.value)],velocity:uC(y,e,f.value),damping:i,stiffness:a,restDelta:l,restSpeed:u}))};return C(0),{calculatedDuration:null,next:e=>{let t=!1;return!S&&x===void 0&&(t=!0,b(e),C(e)),x!==void 0&&e>=x?S.next(e-x):(!t&&b(e),f)}}}function fC(e,t,n){let r=[],i=n||Jb.mix||KS,a=e.length-1;for(let n=0;n<a;n++){let a=i(e[n],e[n+1]);t&&(a=ex(Array.isArray(t)?t[n]||$b:t,a)),r.push(a)}return r}function pC(e,t,{clamp:n=!0,ease:r,mixer:i}={}){let a=e.length;if(t.length,a===1)return()=>t[0];if(a===2&&t[0]===t[1])return()=>t[1];let o=e[0]===e[1];e[0]>e[a-1]&&(e=[...e].reverse(),t=[...t].reverse());let s=fC(t,r,i),c=s.length,l=n=>{if(o&&n<e[0])return t[0];let r=0;if(c>1)for(;r<e.length-2&&!(n<e[r+1]);r++);let i=tx(e[r],e[r+1],n);return s[r](i)};return n?t=>l(qb(e[0],e[a-1],t)):l}function mC(e,t){let n=e[e.length-1];for(let r=1;r<=t;r++){let i=tx(0,t,r);e.push(MS(n,1,i))}}function hC(e){let t=[0];return mC(t,e.length-1),t}function gC(e,t){return e.map(e=>e*t)}function _C(e,t){return e.map(()=>t||Sx).splice(0,e.length-1)}function vC({duration:e=300,keyframes:t,times:n,ease:r=`easeInOut`}){let i=Cx(r)?r.map(Dx):Dx(r),a={done:!1,value:t[0]},o=pC(gC(n&&n.length===t.length?n:hC(t),e),t,{ease:Array.isArray(i)?i:_C(t,i)});return{calculatedDuration:e,next:t=>(a.value=o(t),a.done=t>=e,a)}}var yC=e=>e!==null;function bC(e,{repeat:t,repeatType:n=`loop`},r,i=1){let a=e.filter(yC),o=i<0||t&&n!==`loop`&&t%2==1?0:a.length-1;return!o||r===void 0?a[o]:r}var xC={decay:dC,inertia:dC,tween:vC,keyframes:vC,spring:cC};function SC(e){typeof e.type==`string`&&(e.type=xC[e.type])}var CC=class{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(e=>{this.resolve=e})}notifyFinished(){this.resolve()}then(e,t){return this.finished.then(e,t)}},wC=e=>e/100,TC=class extends CC{constructor(e){super(),this.state=`idle`,this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.delayState={done:!1,value:void 0},this.stop=()=>{let{motionValue:e}=this.options;e&&e.updatedAt!==Rx.now()&&this.tick(Rx.now()),this.isStopped=!0,this.state!==`idle`&&(this.teardown(),this.options.onStop?.())},this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause()}initAnimation(){let{options:e}=this;SC(e);let{type:t=vC,repeat:n=0,repeatDelay:r=0,repeatType:i,velocity:a=0}=e,{keyframes:o}=e,s=t||vC;s!==vC&&typeof o[0]!=`number`&&(this.mixKeyframes=ex(wC,KS(o[0],o[1])),o=[0,100]);let c=s({...e,keyframes:o});i===`mirror`&&(this.mirroredGenerator=s({...e,keyframes:[...o].reverse(),velocity:-a})),c.calculatedDuration===null&&(c.calculatedDuration=XS(c));let{calculatedDuration:l}=c;this.calculatedDuration=l,this.resolvedDuration=l+r,this.totalDuration=this.resolvedDuration*(n+1)-r,this.generator=c}updateTime(e){let t=Math.round(e-this.startTime)*this.playbackSpeed;this.holdTime===null?this.currentTime=t:this.currentTime=this.holdTime}tick(e,t=!1){let{generator:n,totalDuration:r,mixKeyframes:i,mirroredGenerator:a,resolvedDuration:o,calculatedDuration:s}=this;if(this.startTime===null)return n.next(0);let{delay:c=0,keyframes:l,repeat:u,repeatType:d,repeatDelay:f,type:p,onUpdate:m,finalKeyframe:h}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-r/this.speed,this.startTime)),t?this.currentTime=e:this.updateTime(e);let g=this.currentTime-c*(this.playbackSpeed>=0?1:-1),_=this.playbackSpeed>=0?g<0:g>r;this.currentTime=Math.max(g,0),this.state===`finished`&&this.holdTime===null&&(this.currentTime=r);let v=this.currentTime,y=n;if(u){let e=Math.min(this.currentTime,r)/o,t=Math.floor(e),n=e%1;!n&&e>=1&&(n=1),n===1&&t--,t=Math.min(t,u+1),t%2&&(d===`reverse`?(n=1-n,f&&(n-=f/o)):d===`mirror`&&(y=a)),v=qb(0,1,n)*o}let b;_?(this.delayState.value=l[0],b=this.delayState):b=y.next(v),i&&!_&&(b.value=i(b.value));let{done:x}=b;!_&&s!==null&&(x=this.playbackSpeed>=0?this.currentTime>=r:this.currentTime<=0);let S=this.holdTime===null&&(this.state===`finished`||this.state===`running`&&x);return S&&p!==dC&&(b.value=bC(l,this.options,h,this.speed)),m&&m(b.value),S&&this.finish(),b}then(e,t){return this.finished.then(e,t)}get duration(){return ix(this.calculatedDuration)}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+ix(e)}get time(){return ix(this.currentTime)}set time(e){e=rx(e),this.currentTime=e,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.playbackSpeed),this.driver?this.driver.start(!1):(this.startTime=0,this.state=`paused`,this.holdTime=e,this.tick(e))}getGeneratorVelocity(){let e=this.currentTime;if(e<=0)return this.options.velocity||0;if(this.generator.velocity)return this.generator.velocity(e);let t=this.generator.next(e).value;return uC(e=>this.generator.next(e).value,e,t)}get speed(){return this.playbackSpeed}set speed(e){let t=this.playbackSpeed!==e;t&&this.driver&&this.updateTime(Rx.now()),this.playbackSpeed=e,t&&this.driver&&(this.time=ix(this.currentTime))}play(){if(this.isStopped)return;let{driver:e=qS,startTime:t}=this.options;this.driver||=e(e=>this.tick(e)),this.options.onPlay?.();let n=this.driver.now();this.state===`finished`?(this.updateFinished(),this.startTime=n):this.holdTime===null?this.startTime||=t??n:this.startTime=n-this.holdTime,this.state===`finished`&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state=`running`,this.driver.start()}pause(){this.state=`paused`,this.updateTime(Rx.now()),this.holdTime=this.currentTime}complete(){this.state!==`running`&&this.play(),this.state=`finished`,this.holdTime=null}finish(){this.notifyFinished(),this.teardown(),this.state=`finished`,this.options.onComplete?.()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),this.options.onCancel?.()}teardown(){this.state=`idle`,this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&=(this.driver.stop(),void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}attachTimeline(e){return this.options.allowFlatten&&(this.options.type=`keyframes`,this.options.ease=`linear`,this.initAnimation()),this.driver?.stop(),e.observe(this)}};function EC(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}var DC=e=>e*180/Math.PI,OC=e=>AC(DC(Math.atan2(e[1],e[0]))),kC={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:OC,rotateZ:OC,skewX:e=>DC(Math.atan(e[1])),skewY:e=>DC(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},AC=e=>(e%=360,e<0&&(e+=360),e),jC=OC,MC=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),NC=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),PC={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:MC,scaleY:NC,scale:e=>(MC(e)+NC(e))/2,rotateX:e=>AC(DC(Math.atan2(e[6],e[5]))),rotateY:e=>AC(DC(Math.atan2(-e[2],e[0]))),rotateZ:jC,rotate:jC,skewX:e=>DC(Math.atan(e[4])),skewY:e=>DC(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function FC(e){return+!!e.includes(`scale`)}function IC(e,t){if(!e||e===`none`)return FC(t);let n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u),r,i;if(n)r=PC,i=n;else{let t=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);r=kC,i=t}if(!i)return FC(t);let a=r[t],o=i[1].split(`,`).map(RC);return typeof a==`function`?a(o):o[a]}var LC=(e,t)=>{let{transform:n=`none`}=getComputedStyle(e);return IC(n,t)};function RC(e){return parseFloat(e.trim())}var zC=[`transformPerspective`,`x`,`y`,`z`,`translateX`,`translateY`,`translateZ`,`scale`,`scaleX`,`scaleY`,`rotate`,`rotateX`,`rotateY`,`rotateZ`,`skew`,`skewX`,`skewY`],BC=new Set([...zC,`pathRotation`]),VC=e=>e===Gx||e===W,HC=new Set([`x`,`y`,`z`]),UC=zC.filter(e=>!HC.has(e));function WC(e){let t=[];return UC.forEach(n=>{let r=e.getValue(n);r!==void 0&&(t.push([n,r.get()]),r.set(+!!n.startsWith(`scale`)))}),t}var GC={width:({x:e},{paddingLeft:t=`0`,paddingRight:n=`0`,boxSizing:r})=>{let i=e.max-e.min;return r===`border-box`?i:i-parseFloat(t)-parseFloat(n)},height:({y:e},{paddingTop:t=`0`,paddingBottom:n=`0`,boxSizing:r})=>{let i=e.max-e.min;return r===`border-box`?i:i-parseFloat(t)-parseFloat(n)},top:(e,{top:t})=>parseFloat(t),left:(e,{left:t})=>parseFloat(t),bottom:({y:e},{top:t})=>parseFloat(t)+(e.max-e.min),right:({x:e},{left:t})=>parseFloat(t)+(e.max-e.min),x:(e,{transform:t})=>IC(t,`x`),y:(e,{transform:t})=>IC(t,`y`)};GC.translateX=GC.x,GC.translateY=GC.y;var KC=new Set,qC=!1,JC=!1,YC=!1;function XC(){if(JC){let e=Array.from(KC).filter(e=>e.needsMeasurement),t=new Set(e.map(e=>e.element)),n=new Map;t.forEach(e=>{let t=WC(e);t.length&&(n.set(e,t),e.render())}),e.forEach(e=>e.measureInitialState()),t.forEach(e=>{e.render();let t=n.get(e);t&&t.forEach(([t,n])=>{e.getValue(t)?.set(n)})}),e.forEach(e=>e.measureEndState()),e.forEach(e=>{e.suspendedScrollY!==void 0&&window.scrollTo(0,e.suspendedScrollY)})}JC=!1,qC=!1,KC.forEach(e=>e.complete(YC)),KC.clear()}function ZC(){KC.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(JC=!0)})}function QC(){YC=!0,ZC(),XC(),YC=!1}var $C=class{constructor(e,t,n,r,i,a=!1){this.state=`pending`,this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=t,this.name=n,this.motionValue=r,this.element=i,this.isAsync=a}scheduleResolve(){this.state=`scheduled`,this.isAsync?(KC.add(this),qC||(qC=!0,Mx.read(ZC),Mx.resolveKeyframes(XC))):(this.readKeyframes(),this.complete())}readKeyframes(){let{unresolvedKeyframes:e,name:t,element:n,motionValue:r}=this;if(e[0]===null){let i=r?.get(),a=e[e.length-1];if(i!==void 0)e[0]=i;else if(n&&t){let r=n.readValue(t,a);r!=null&&(e[0]=r)}e[0]===void 0&&(e[0]=a),r&&i===void 0&&r.set(e[0])}EC(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state=`complete`,this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),KC.delete(this)}cancel(){this.state===`scheduled`&&(KC.delete(this),this.state=`pending`)}resume(){this.state===`pending`&&this.scheduleResolve()}},ew=e=>e.startsWith(`--`);function tw(e,t,n){ew(t)?e.style.setProperty(t,n):e.style[t]=n}var nw={};function rw(e,t){let n=Qb(e);return()=>nw[t]??n()}var iw=rw(()=>window.ScrollTimeline!==void 0,`scrollTimeline`),aw=rw(()=>{try{document.createElement(`div`).animate({opacity:0},{easing:`linear(0, 1)`})}catch{return!1}return!0},`linearEasing`),ow=([e,t,n,r])=>`cubic-bezier(${e}, ${t}, ${n}, ${r})`,sw={linear:`linear`,ease:`ease`,easeIn:`ease-in`,easeOut:`ease-out`,easeInOut:`ease-in-out`,circIn:ow([0,.65,.55,1]),circOut:ow([.55,0,1,.45]),backIn:ow([.31,.01,.66,-.59]),backOut:ow([.33,1.53,.69,.99])};function cw(e,t){if(e)return typeof e==`function`?aw()?JS(e,t):`ease-out`:wx(e)?ow(e):Array.isArray(e)?e.map(e=>cw(e,t)||sw.easeOut):sw[e]}function lw(e,t,n,{delay:r=0,duration:i=300,repeat:a=0,repeatType:o=`loop`,ease:s=`easeOut`,times:c}={},l=void 0){let u={[t]:n};c&&(u.offset=c);let d=cw(s,i);Array.isArray(d)&&(u.easing=d);let f={delay:r,duration:i,easing:Array.isArray(d)?`linear`:d,fill:`both`,iterations:a+1,direction:o===`reverse`?`alternate`:`normal`};return l&&(f.pseudoElement=l),e.animate(u,f)}function uw(e){return typeof e==`function`&&`applyToOptions`in e}function dw({type:e,...t}){return uw(e)&&aw()?e.applyToOptions(t):(t.duration??=300,t.ease??=`easeOut`,t)}var fw=class extends CC{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!e)return;let{element:t,name:n,keyframes:r,pseudoElement:i,allowFlatten:a=!1,finalKeyframe:o,onComplete:s}=e;this.isPseudoElement=!!i,this.allowFlatten=a,this.options=e,e.type;let c=dw(e);this.animation=lw(t,n,r,c,i),c.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!i){let e=bC(r,this.options,o,this.speed);this.updateMotionValue&&this.updateMotionValue(e),tw(t,n,e),this.animation.cancel()}s?.(),this.notifyFinished()}}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),this.state===`finished`&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;let{state:e}=this;e===`idle`||e===`finished`||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){let e=this.options?.element;!this.isPseudoElement&&e?.isConnected&&this.animation.commitStyles?.()}get duration(){let e=this.animation.effect?.getComputedTiming?.().duration||0;return ix(Number(e))}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+ix(e)}get time(){return ix(Number(this.animation.currentTime)||0)}set time(e){let t=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=rx(e),t&&this.animation.pause()}get speed(){return this.animation.playbackRate}set speed(e){e<0&&(this.finishedTime=null),this.animation.playbackRate=e}get state(){return this.finishedTime===null?this.animation.playState:`finished`}get startTime(){return this.manualStartTime??Number(this.animation.startTime)}set startTime(e){this.manualStartTime=this.animation.startTime=e}attachTimeline({timeline:e,rangeStart:t,rangeEnd:n,observe:r}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:`linear`}),this.animation.onfinish=null,e&&iw()?(this.animation.timeline=e,t&&(this.animation.rangeStart=t),n&&(this.animation.rangeEnd=n),$b):r(this)}},pw={anticipate:gx,backInOut:hx,circInOut:yx};function mw(e){return e in pw}function hw(e){typeof e.ease==`string`&&mw(e.ease)&&(e.ease=pw[e.ease])}var gw=10,_w=class extends fw{constructor(e){hw(e),SC(e),super(e),e.startTime!==void 0&&e.autoplay!==!1&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){let{motionValue:t,onUpdate:n,onComplete:r,element:i,...a}=this.options;if(!t)return;if(e!==void 0){t.set(e);return}let o=new TC({...a,autoplay:!1}),s=Math.max(gw,Rx.now()-this.startTime),c=qb(0,gw,s-gw),l=o.sample(s).value,{name:u}=this.options;i&&u&&tw(i,u,l),t.setWithVelocity(o.sample(Math.max(0,s-c)).value,l,c),o.stop()}},vw=(e,t)=>t!==`zIndex`&&!!(typeof e==`number`||Array.isArray(e)||typeof e==`string`&&(OS.test(e)||e===`0`)&&!e.startsWith(`url(`));function yw(e){let t=e[0];if(e.length===1)return!0;for(let n=0;n<e.length;n++)if(e[n]!==t)return!0}function bw(e,t,n,r){let i=e[0];if(i===null)return!1;if(t===`display`||t===`visibility`)return!0;let a=e[e.length-1],o=vw(i,t),s=vw(a,t);return`${t}${i}${a}${o?a:i}`,!o||!s?!1:yw(e)||(n===`spring`||uw(n))&&r}function xw(e){e.duration=0,e.type=`keyframes`}var Sw=new Set([`opacity`,`clipPath`,`filter`,`transform`]),Cw=/^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;function ww(e){for(let t=0;t<e.length;t++)if(typeof e[t]==`string`&&Cw.test(e[t]))return!0;return!1}var Tw=new Set([`color`,`backgroundColor`,`outlineColor`,`fill`,`stroke`,`borderColor`,`borderTopColor`,`borderRightColor`,`borderBottomColor`,`borderLeftColor`]),Ew=Qb(()=>Object.hasOwnProperty.call(Element.prototype,`animate`));function Dw(e){let{motionValue:t,name:n,repeatDelay:r,repeatType:i,damping:a,type:o,keyframes:s}=e;if(!(t?.owner?.current instanceof HTMLElement))return!1;let{onUpdate:c,transformTemplate:l}=t.owner.getProps();return Ew()&&n&&(Sw.has(n)||Tw.has(n)&&ww(s))&&(n!==`transform`||!l)&&!c&&!r&&i!==`mirror`&&a!==0&&o!==`inertia`}var Ow=40,kw=class extends CC{constructor({autoplay:e=!0,delay:t=0,type:n=`keyframes`,repeat:r=0,repeatDelay:i=0,repeatType:a=`loop`,keyframes:o,name:s,motionValue:c,element:l,...u}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=Rx.now();let d={autoplay:e,delay:t,type:n,repeat:r,repeatDelay:i,repeatType:a,name:s,motionValue:c,element:l,...u},f=l?.KeyframeResolver||$C;this.keyframeResolver=new f(o,(e,t,n)=>this.onKeyframesResolved(e,t,d,!n),s,c,l),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,t,n,r){this.keyframeResolver=void 0;let{name:i,type:a,velocity:o,delay:s,isHandoff:c,onUpdate:l}=n;this.resolvedAt=Rx.now();let u=!0;bw(e,i,a,o)||(u=!1,(Jb.instantAnimations||!s)&&l?.(bC(e,n,t)),e[0]=e[e.length-1],xw(n),n.repeat=0);let d={startTime:r?this.resolvedAt&&this.resolvedAt-this.createdAt>Ow?this.resolvedAt:this.createdAt:void 0,finalKeyframe:t,...n,keyframes:e},f=u&&!c&&Dw(d),p=d.motionValue?.owner?.current,m;if(f)try{m=new _w({...d,element:p})}catch{m=new TC(d)}else m=new TC(d);m.finished.then(()=>{this.notifyFinished()}).catch($b),this.pendingTimeline&&=(this.stopTimeline=m.attachTimeline(this.pendingTimeline),void 0),this._animation=m}get finished(){return this._animation?this.animation.finished:this._finished}then(e,t){return this.finished.finally(e).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),QC()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(e){this.animation.time=e}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(e){this.animation.speed=e}get startTime(){return this.animation.startTime}attachTimeline(e){return this._animation?this.stopTimeline=this.animation.attachTimeline(e):this.pendingTimeline=e,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation&&this.animation.cancel(),this.keyframeResolver?.cancel()}};function Aw(e,t,n,r=0,i=1){let a=Array.from(e).sort((e,t)=>e.sortNodePosition(t)).indexOf(t),o=e.size,s=(o-1)*r;return typeof n==`function`?n(a,o):i===1?a*r:s-a*r}var jw=30,Mw=e=>!isNaN(parseFloat(e)),Nw={current:void 0},Pw=class{constructor(e,t={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=e=>{let t=Rx.now();if(this.updatedAt!==t&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(e),this.current!==this.prev&&(this.events.change?.notify(this.current),this.dependents))for(let e of this.dependents)e.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=t.owner}setCurrent(e){this.current=e,this.updatedAt=Rx.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=Mw(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return this.on(`change`,e)}on(e,t){this.events[e]||(this.events[e]=new nx);let n=this.events[e].add(t);return e===`change`?()=>{n(),Mx.read(()=>{this.events.change.getSize()||this.stop()})}:n}clearListeners(){for(let e in this.events)this.events[e].clear()}attach(e,t){this.passiveEffect=e,this.stopPassiveEffect=t}set(e){this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e)}setWithVelocity(e,t,n){this.set(t),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-n}jump(e,t=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,t&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.events.change?.notify(this.current)}addDependent(e){this.dependents||=new Set,this.dependents.add(e)}removeDependent(e){this.dependents&&this.dependents.delete(e)}get(){return Nw.current&&Nw.current.push(this),this.current}getPrevious(){return this.prev}getVelocity(){let e=Rx.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>jw)return 0;let t=Math.min(this.updatedAt-this.prevUpdatedAt,jw);return ax(parseFloat(this.current)-parseFloat(this.prevFrameValue),t)}start(e){return this.stop(),new Promise(t=>{this.hasAnimated=!0,this.animation=e(t),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}};function Fw(e,t){return new Pw(e,t)}function Iw(e,t){if(e?.inherit&&t){let{inherit:n,...r}=e;return{...t,...r}}return e}function Lw(e,t){let n=e?.[t]??e?.default??e;return n===e?n:Iw(n,e)}var Rw={type:`spring`,stiffness:500,damping:25,restSpeed:10},zw=e=>({type:`spring`,stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),Bw={type:`keyframes`,duration:.8},Vw={type:`keyframes`,ease:[.25,.1,.35,1],duration:.3},Hw=(e,{keyframes:t})=>t.length>2?Bw:BC.has(e)?e.startsWith(`scale`)?zw(t[1]):Rw:Vw,Uw=new Set([`when`,`delay`,`delayChildren`,`staggerChildren`,`staggerDirection`,`repeat`,`repeatType`,`repeatDelay`,`from`,`elapsed`]);function Ww(e){for(let t in e)if(!Uw.has(t))return!0;return!1}var Gw=(e,t,n,r={},i,a)=>o=>{let s=Lw(r,e)||{},c=s.delay||r.delay||0,{elapsed:l=0}=r;l-=rx(c);let u={keyframes:Array.isArray(n)?n:[null,n],ease:`easeOut`,velocity:t.getVelocity(),...s,delay:-l,onUpdate:e=>{t.set(e),s.onUpdate&&s.onUpdate(e)},onComplete:()=>{o(),s.onComplete&&s.onComplete()},name:e,motionValue:t,element:a?void 0:i};Ww(s)||Object.assign(u,Hw(e,u)),u.duration&&=rx(u.duration),u.repeatDelay&&=rx(u.repeatDelay),u.from!==void 0&&(u.keyframes[0]=u.from);let d=!1;if((u.type===!1||u.duration===0&&!u.repeatDelay)&&(xw(u),u.delay===0&&(d=!0)),(Jb.instantAnimations||Jb.skipAnimations||i?.shouldSkipAnimations||s.skipAnimations)&&(d=!0,xw(u),u.delay=0),u.allowFlatten=!s.type&&!s.ease,d&&!a&&t.get()!==void 0){let e=bC(u.keyframes,s);if(e!==void 0){Mx.update(()=>{u.onUpdate(e),u.onComplete()});return}}return s.isSync?new TC(u):new kw(u)},Kw=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function qw(e){let t=Kw.exec(e);if(!t)return[,];let[,n,r,i]=t;return[`--${n??r}`,i]}function Jw(e,t,n=1){`${e}`;let[r,i]=qw(e);if(!r)return;let a=window.getComputedStyle(t).getPropertyValue(r);if(a){let e=a.trim();return Yb(e)?parseFloat(e):e}return Hx(i)?Jw(i,t,n+1):i}function Yw(e){let t=[{},{}];return e?.values.forEach((e,n)=>{t[0][n]=e.get(),t[1][n]=e.getVelocity()}),t}function Xw(e,t,n,r){if(typeof t==`function`){let[i,a]=Yw(r);t=t(n===void 0?e.custom:n,i,a)}if(typeof t==`string`&&(t=e.variants&&e.variants[t]),typeof t==`function`){let[i,a]=Yw(r);t=t(n===void 0?e.custom:n,i,a)}return t}function Zw(e,t,n){let r=e.getProps();return Xw(r,t,n===void 0?r.custom:n,e)}var Qw=new Set([`width`,`height`,`top`,`left`,`right`,`bottom`,...zC]),$w=e=>Array.isArray(e);function eT(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,Fw(n))}function tT(e){return $w(e)?e[e.length-1]||0:e}function nT(e,t){let{transitionEnd:n={},transition:r={},...i}=Zw(e,t)||{};i={...i,...n};for(let t in i)eT(e,t,tT(i[t]))}var rT=e=>!!(e&&e.getVelocity);function iT(e){return!!(rT(e)&&e.add)}function aT(e,t){let n=e.getValue(`willChange`);if(iT(n))return n.add(t);if(!n&&Jb.WillChange){let n=new Jb.WillChange(`auto`);e.addValue(`willChange`,n),n.add(t)}}function oT(e){return e.replace(/([A-Z])/g,e=>`-${e.toLowerCase()}`)}var sT=`data-`+oT(`framerAppearId`);function cT(e){return e.props[sT]}function lT({protectedKeys:e,needsAnimating:t},n){let r=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,r}function uT(e,t,{delay:n=0,transitionOverride:r,type:i}={}){let{transition:a,transitionEnd:o,...s}=t,c=e.getDefaultTransition();a=a?Iw(a,c):c;let l=a?.reduceMotion,u=a?.skipAnimations;r&&(a=r);let d=[],f=i&&e.animationState&&e.animationState.getState()[i],p=a?.path;p&&p.animateVisualElement(e,s,a,n,d);for(let t in s){let r=e.getValue(t,e.latestValues[t]??null),i=s[t];if(i===void 0||f&&lT(f,t))continue;let o={delay:n,...Lw(a||{},t)};u&&(o.skipAnimations=!0);let c=r.get();if(c!==void 0&&!r.isAnimating()&&!Array.isArray(i)&&i===c&&!o.velocity){Mx.update(()=>r.set(i));continue}let p=!1;if(window.MotionHandoffAnimation){let n=cT(e);if(n){let e=window.MotionHandoffAnimation(n,t,Mx);e!==null&&(o.startTime=e,p=!0)}}aT(e,t);let m=l??e.shouldReduceMotion;r.start(Gw(t,r,i,m&&Qw.has(t)?{type:!1}:o,e,p));let h=r.animation;h&&d.push(h)}if(o){let t=()=>Mx.update(()=>{o&&nT(e,o)});d.length?Promise.all(d).then(t):t()}return d}function dT(e,t,n={}){let r=Zw(e,t,n.type===`exit`?e.presenceContext?.custom:void 0),{transition:i=e.getDefaultTransition()||{}}=r||{};n.transitionOverride&&(i=n.transitionOverride);let a=r?()=>Promise.all(uT(e,r,n)):()=>Promise.resolve(),o=e.variantChildren&&e.variantChildren.size?(r=0)=>{let{delayChildren:a=0,staggerChildren:o,staggerDirection:s}=i;return fT(e,t,r,a,o,s,n)}:()=>Promise.resolve(),{when:s}=i;if(s){let[e,t]=s===`beforeChildren`?[a,o]:[o,a];return e().then(()=>t())}else return Promise.all([a(),o(n.delay)])}function fT(e,t,n=0,r=0,i=0,a=1,o){let s=[];for(let c of e.variantChildren)c.notify(`AnimationStart`,t),s.push(dT(c,t,{...o,delay:n+(typeof r==`function`?0:r)+Aw(e.variantChildren,c,r,i,a)}).then(()=>c.notify(`AnimationComplete`,t)));return Promise.all(s)}function pT(e,t,n={}){e.notify(`AnimationStart`,t);let r;if(Array.isArray(t)){let i=t.map(t=>dT(e,t,n));r=Promise.all(i)}else if(typeof t==`string`)r=dT(e,t,n);else{let i=typeof t==`function`?Zw(e,t,n.custom):t;r=Promise.all(uT(e,i,n))}return r.then(()=>{e.notify(`AnimationComplete`,t)})}var mT={test:e=>e===`auto`,parse:e=>e},hT=e=>t=>t.test(e),gT=[Gx,W,sS,oS,lS,cS,mT],_T=e=>gT.find(hT(e));function vT(e){return typeof e==`number`?e===0:e===null||e===`none`||e===`0`||Zb(e)}var yT=new Set([`brightness`,`contrast`,`saturate`,`opacity`]);function bT(e){let[t,n]=e.slice(0,-1).split(`(`);if(t===`drop-shadow`)return e;let[r]=n.match(Yx)||[];if(!r)return e;let i=n.replace(r,``),a=+!!yT.has(t);return r!==n&&(a*=100),t+`(`+a+i+`)`}var xT=/\b([a-z-]*)\(.*?\)/gu,ST={...OS,getAnimatableNone:e=>{let t=e.match(xT);return t?t.map(bT).join(` `):e}},CT={...OS,getAnimatableNone:e=>{let t=OS.parse(e);return OS.createTransformer(e)(t.map(e=>typeof e==`number`?0:typeof e==`object`?{...e,alpha:1}:e))}},wT={...Gx,transform:Math.round},TT={borderWidth:W,borderTopWidth:W,borderRightWidth:W,borderBottomWidth:W,borderLeftWidth:W,borderRadius:W,borderTopLeftRadius:W,borderTopRightRadius:W,borderBottomRightRadius:W,borderBottomLeftRadius:W,width:W,maxWidth:W,height:W,maxHeight:W,top:W,right:W,bottom:W,left:W,inset:W,insetBlock:W,insetBlockStart:W,insetBlockEnd:W,insetInline:W,insetInlineStart:W,insetInlineEnd:W,padding:W,paddingTop:W,paddingRight:W,paddingBottom:W,paddingLeft:W,paddingBlock:W,paddingBlockStart:W,paddingBlockEnd:W,paddingInline:W,paddingInlineStart:W,paddingInlineEnd:W,margin:W,marginTop:W,marginRight:W,marginBottom:W,marginLeft:W,marginBlock:W,marginBlockStart:W,marginBlockEnd:W,marginInline:W,marginInlineStart:W,marginInlineEnd:W,fontSize:W,backgroundPositionX:W,backgroundPositionY:W,rotate:oS,pathRotation:oS,rotateX:oS,rotateY:oS,rotateZ:oS,scale:qx,scaleX:qx,scaleY:qx,scaleZ:qx,skew:oS,skewX:oS,skewY:oS,distance:W,translateX:W,translateY:W,translateZ:W,x:W,y:W,z:W,perspective:W,transformPerspective:W,opacity:Kx,originX:uS,originY:uS,originZ:W,zIndex:wT,fillOpacity:Kx,strokeOpacity:Kx,numOctaves:wT},ET={...TT,color:fS,backgroundColor:fS,outlineColor:fS,fill:fS,stroke:fS,borderColor:fS,borderTopColor:fS,borderRightColor:fS,borderBottomColor:fS,borderLeftColor:fS,filter:ST,WebkitFilter:ST,mask:CT,WebkitMask:CT},DT=e=>ET[e],OT=new Set([ST,CT]);function kT(e,t){let n=DT(e);return OT.has(n)||(n=OS),n.getAnimatableNone?n.getAnimatableNone(t):void 0}var AT=new Set([`auto`,`none`,`0`]);function jT(e,t,n){let r=0,i;for(;r<e.length&&!i;){let t=e[r];typeof t==`string`&&!AT.has(t)&&xS(t).values.length&&(i=e[r]),r++}if(i&&n)for(let r of t)e[r]=kT(n,i)}var MT=class extends $C{constructor(e,t,n,r,i){super(e,t,n,r,i,!0)}readKeyframes(){let{unresolvedKeyframes:e,element:t,name:n}=this;if(!t||!t.current)return;super.readKeyframes();for(let n=0;n<e.length;n++){let r=e[n];if(typeof r==`string`&&(r=r.trim(),Hx(r))){let i=Jw(r,t.current);i!==void 0&&(e[n]=i),n===e.length-1&&(this.finalKeyframe=r)}}if(this.resolveNoneKeyframes(),!Qw.has(n)||e.length!==2)return;let[r,i]=e,a=_T(r),o=_T(i);if(Wx(r)!==Wx(i)&&GC[n]){this.needsMeasurement=!0;return}if(a!==o)if(VC(a)&&VC(o))for(let t=0;t<e.length;t++){let n=e[t];typeof n==`string`&&(e[t]=parseFloat(n))}else GC[n]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){let{unresolvedKeyframes:e,name:t}=this,n=[];for(let t=0;t<e.length;t++)(e[t]===null||vT(e[t]))&&n.push(t);n.length&&jT(e,n,t)}measureInitialState(){let{element:e,unresolvedKeyframes:t,name:n}=this;if(!e||!e.current)return;n===`height`&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=GC[n](e.measureViewportBox(),window.getComputedStyle(e.current)),t[0]=this.measuredOrigin;let r=t[t.length-1];r!==void 0&&e.getValue(n,r).jump(r,!1)}measureEndState(){let{element:e,name:t,unresolvedKeyframes:n}=this;if(!e||!e.current)return;let r=e.getValue(t);r&&r.jump(this.measuredOrigin,!1);let i=n.length-1,a=n[i];n[i]=GC[t](e.measureViewportBox(),window.getComputedStyle(e.current)),a!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=a),this.removedTransforms?.length&&this.removedTransforms.forEach(([t,n])=>{e.getValue(t).set(n)}),this.resolveNoneKeyframes()}},NT=[`borderTopLeftRadius`,`borderTopRightRadius`,`borderBottomRightRadius`,`borderBottomLeftRadius`];function PT(e,t,n){if(e==null)return[];if(e instanceof EventTarget)return[e];if(typeof e==`string`){let r=document;t&&(r=t.current);let i=n?.[e]??r.querySelectorAll(e);return i?Array.from(i):[]}return Array.from(e).filter(e=>e!=null)}var FT=(e,t)=>t&&typeof e==`number`?t.transform(e):e;function IT(e){return Xb(e)&&`offsetHeight`in e&&!(`ownerSVGElement`in e)}var{schedule:LT,cancel:wee}=jx(queueMicrotask,!1),RT={x:!1,y:!1};function zT(){return RT.x||RT.y}function BT(e){return e===`x`||e===`y`?RT[e]?null:(RT[e]=!0,()=>{RT[e]=!1}):RT.x||RT.y?null:(RT.x=RT.y=!0,()=>{RT.x=RT.y=!1})}function VT(e,t){let n=PT(e),r=new AbortController;return[n,{passive:!0,...t,signal:r.signal},()=>r.abort()]}function HT(e){return!(e.pointerType===`touch`||zT())}function UT(e,t,n={}){let[r,i,a]=VT(e,n);return r.forEach(e=>{let n=!1,r=!1,a,o=()=>{e.removeEventListener(`pointerleave`,u)},s=e=>{a&&=(a(e),void 0),o()},c=e=>{n=!1,window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,c),r&&(r=!1,s(e))},l=()=>{n=!0,window.addEventListener(`pointerup`,c,i),window.addEventListener(`pointercancel`,c,i)},u=e=>{if(e.pointerType!==`touch`){if(n){r=!0;return}s(e)}};e.addEventListener(`pointerenter`,n=>{if(!HT(n))return;r=!1;let o=t(e,n);typeof o==`function`&&(a=o,e.addEventListener(`pointerleave`,u,i))},i),e.addEventListener(`pointerdown`,l,i)}),a}var WT=(e,t)=>t?e===t||WT(e,t.parentElement):!1,GT=e=>e.pointerType===`mouse`?typeof e.button!=`number`||e.button<=0:e.isPrimary!==!1,KT=new Set([`BUTTON`,`INPUT`,`SELECT`,`TEXTAREA`,`A`]);function qT(e){return KT.has(e.tagName)||e.isContentEditable===!0}var JT=new Set([`INPUT`,`SELECT`,`TEXTAREA`]);function YT(e){return JT.has(e.tagName)||e.isContentEditable===!0}var XT=new WeakSet;function ZT(e){return t=>{t.key===`Enter`&&e(t)}}function QT(e,t){e.dispatchEvent(new PointerEvent(`pointer`+t,{isPrimary:!0,bubbles:!0}))}var $T=(e,t)=>{let n=e.currentTarget;if(!n)return;let r=ZT(()=>{if(XT.has(n))return;QT(n,`down`);let e=ZT(()=>{QT(n,`up`)});n.addEventListener(`keyup`,e,t),n.addEventListener(`blur`,()=>QT(n,`cancel`),t)});n.addEventListener(`keydown`,r,t),n.addEventListener(`blur`,()=>n.removeEventListener(`keydown`,r),t)};function eE(e){return GT(e)&&!zT()}var tE=new WeakSet;function nE(e,t,n={}){let[r,i,a]=VT(e,n),o=e=>{let r=e.currentTarget;if(!eE(e)||tE.has(e))return;XT.add(r),n.stopPropagation&&tE.add(e);let a=t(r,e),o={...i,capture:!0},s=(e,t)=>{window.removeEventListener(`pointerup`,c,o),window.removeEventListener(`pointercancel`,l,o),XT.has(r)&&XT.delete(r),eE(e)&&typeof a==`function`&&a(e,{success:t})},c=e=>{s(e,r===window||r===document||n.useGlobalTarget||WT(r,e.target))},l=e=>{s(e,!1)};window.addEventListener(`pointerup`,c,o),window.addEventListener(`pointercancel`,l,o)};return r.forEach(e=>{(n.useGlobalTarget?window:e).addEventListener(`pointerdown`,o,i),IT(e)&&(e.addEventListener(`focus`,e=>$T(e,i)),!qT(e)&&!e.hasAttribute(`tabindex`)&&(e.tabIndex=0))}),a}function rE(e){return Xb(e)&&`ownerSVGElement`in e}var iE=new WeakMap,aE,oE=(e,t,n)=>(r,i)=>i&&i[0]?i[0][e+`Size`]:rE(r)&&`getBBox`in r?r.getBBox()[t]:r[n],sE=oE(`inline`,`width`,`offsetWidth`),cE=oE(`block`,`height`,`offsetHeight`);function lE({target:e,borderBoxSize:t}){iE.get(e)?.forEach(n=>{n(e,{get width(){return sE(e,t)},get height(){return cE(e,t)}})})}function uE(e){e.forEach(lE)}function dE(){typeof ResizeObserver>`u`||(aE=new ResizeObserver(uE))}function fE(e,t){aE||dE();let n=PT(e);return n.forEach(e=>{let n=iE.get(e);n||(n=new Set,iE.set(e,n)),n.add(t),aE?.observe(e)}),()=>{n.forEach(e=>{let n=iE.get(e);n?.delete(t),n?.size||aE?.unobserve(e)})}}var pE=new Set,mE;function hE(){mE=()=>{let e={get width(){return window.innerWidth},get height(){return window.innerHeight}};pE.forEach(t=>t(e))},window.addEventListener(`resize`,mE)}function gE(e){return pE.add(e),mE||hE(),()=>{pE.delete(e),!pE.size&&typeof mE==`function`&&(window.removeEventListener(`resize`,mE),mE=void 0)}}function _E(e,t){return typeof e==`function`?gE(e):fE(e,t)}var vE={value:null,addProjectionMetrics:null};function yE(e){return rE(e)&&e.tagName===`svg`}var bE=[...gT,fS,OS],xE=e=>bE.find(hT(e)),SE=()=>({translate:0,scale:1,origin:0,originPoint:0}),CE=()=>({x:SE(),y:SE()}),wE=()=>({min:0,max:0}),TE=()=>({x:wE(),y:wE()}),EE=new WeakMap;function DE(e){return typeof e==`object`&&!!e&&typeof e.start==`function`}function OE(e){return typeof e==`string`||Array.isArray(e)}var kE=[`animate`,`whileInView`,`whileFocus`,`whileHover`,`whileTap`,`whileDrag`,`exit`],AE=[`initial`,...kE];function jE(e){return DE(e.animate)||AE.some(t=>OE(e[t]))}function ME(e){return!!(jE(e)||e.variants)}function NE(e,t,n){for(let r in t){let i=t[r],a=n[r];if(rT(i))e.addValue(r,i);else if(rT(a))e.addValue(r,Fw(i,{owner:e}));else if(a!==i)if(e.hasValue(r)){let t=e.getValue(r);t.liveStyle===!0?t.jump(i):t.hasAnimated||t.set(i)}else{let t=e.getStaticValue(r);e.addValue(r,Fw(t===void 0?i:t,{owner:e}))}}for(let r in n)t[r]===void 0&&e.removeValue(r);return t}var PE={current:null},FE={current:!1},IE=typeof window<`u`;function LE(){if(FE.current=!0,IE)if(window.matchMedia){let e=window.matchMedia(`(prefers-reduced-motion)`),t=()=>PE.current=e.matches;e.addEventListener(`change`,t),t()}else PE.current=!1}var RE=[`AnimationStart`,`AnimationComplete`,`Update`,`BeforeLayoutMeasure`,`LayoutMeasure`,`LayoutAnimationStart`,`LayoutAnimationComplete`],zE={};function BE(e){zE=e}function VE(){return zE}var HE=class{scrapeMotionValuesFromProps(e,t,n){return{}}constructor({parent:e,props:t,presenceContext:n,reducedMotionConfig:r,skipAnimations:i,blockInitialAnimation:a,visualState:o},s={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.shouldSkipAnimations=!1,this.values=new Map,this.KeyframeResolver=$C,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.hasBeenMounted=!1,this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify(`Update`,this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{let e=Rx.now();this.renderScheduledAt<e&&(this.renderScheduledAt=e,Mx.render(this.render,!1,!0))};let{latestValues:c,renderState:l}=o;this.latestValues=c,this.baseTarget={...c},this.initialValues=t.initial?{...c}:{},this.renderState=l,this.parent=e,this.props=t,this.presenceContext=n,this.depth=e?e.depth+1:0,this.reducedMotionConfig=r,this.skipAnimationsConfig=i,this.options=s,this.blockInitialAnimation=!!a,this.isControllingVariants=jE(t),this.isVariantNode=ME(t),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);let{willChange:u,...d}=this.scrapeMotionValuesFromProps(t,{},this);for(let e in d){let t=d[e];c[e]!==void 0&&rT(t)&&t.set(c[e])}}mount(e){if(this.hasBeenMounted)for(let e in this.initialValues)this.values.get(e)?.jump(this.initialValues[e]),this.latestValues[e]=this.initialValues[e];this.current=e,EE.set(e,this),this.projection&&!this.projection.instance&&this.projection.mount(e),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((e,t)=>this.bindToMotionValue(t,e)),this.reducedMotionConfig===`never`?this.shouldReduceMotion=!1:this.reducedMotionConfig===`always`?this.shouldReduceMotion=!0:(FE.current||LE(),this.shouldReduceMotion=PE.current),this.shouldSkipAnimations=this.skipAnimationsConfig??!1,this.parent?.addChild(this),this.update(this.props,this.presenceContext),this.hasBeenMounted=!0}unmount(){this.projection&&this.projection.unmount(),Nx(this.notifyUpdate),Nx(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this);for(let e in this.events)this.events[e].clear();for(let e in this.features){let t=this.features[e];t&&(t.unmount(),t.isMounted=!1)}this.current=null}addChild(e){this.children.add(e),this.enteringChildren??=new Set,this.enteringChildren.add(e)}removeChild(e){this.children.delete(e),this.enteringChildren&&this.enteringChildren.delete(e)}bindToMotionValue(e,t){if(this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)(),t.accelerate&&Sw.has(e)&&this.current instanceof HTMLElement){let{factory:n,keyframes:r,times:i,ease:a,duration:o}=t.accelerate,s=new fw({element:this.current,name:e,keyframes:r,times:i,ease:a,duration:rx(o)}),c=n(s);this.valueSubscriptions.set(e,()=>{c(),s.cancel()});return}let n=BC.has(e);n&&this.onBindTransform&&this.onBindTransform();let r=t.on(`change`,t=>{this.latestValues[e]=t,this.props.onUpdate&&Mx.preRender(this.notifyUpdate),n&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()}),i;typeof window<`u`&&window.MotionCheckAppearSync&&(i=window.MotionCheckAppearSync(this,e,t)),this.valueSubscriptions.set(e,()=>{r(),i&&i()})}sortNodePosition(e){return!this.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e=`animation`;for(e in zE){let t=zE[e];if(!t)continue;let{isEnabled:n,Feature:r}=t;if(!this.features[e]&&r&&n(this.props)&&(this.features[e]=new r(this)),this.features[e]){let t=this.features[e];t.isMounted?t.update():(t.mount(),t.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):TE()}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,t){this.latestValues[e]=t}update(e,t){(e.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=t;for(let t=0;t<RE.length;t++){let n=RE[t];this.propEventSubscriptions[n]&&(this.propEventSubscriptions[n](),delete this.propEventSubscriptions[n]);let r=e[`on`+n];r&&(this.propEventSubscriptions[n]=this.on(n,r))}this.prevMotionValues=NE(this,this.scrapeMotionValuesFromProps(e,this.prevProps||{},this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(e){return this.props.variants?this.props.variants[e]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(e){let t=this.getClosestVariantNode();if(t)return t.variantChildren&&t.variantChildren.add(e),()=>t.variantChildren.delete(e)}addValue(e,t){let n=this.values.get(e);t!==n&&(n&&this.removeValue(e),this.bindToMotionValue(e,t),this.values.set(e,t),this.latestValues[e]=t.get())}removeValue(e){this.values.delete(e);let t=this.valueSubscriptions.get(e);t&&(t(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,t){if(this.props.values&&this.props.values[e])return this.props.values[e];let n=this.values.get(e);return n===void 0&&t!==void 0&&(n=Fw(t===null?void 0:t,{owner:this}),this.addValue(e,n)),n}readValue(e,t){let n=this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:this.getBaseTargetFromProps(this.props,e)??this.readValueFromInstance(this.current,e,this.options);return n!=null&&(typeof n==`string`&&(Yb(n)||Zb(n))?n=parseFloat(n):!xE(n)&&OS.test(t)&&(n=kT(e,t)),this.setBaseTarget(e,rT(n)?n.get():n)),rT(n)?n.get():n}setBaseTarget(e,t){this.baseTarget[e]=t}getBaseTarget(e){let{initial:t}=this.props,n;if(typeof t==`string`||typeof t==`object`){let r=Xw(this.props,t,this.presenceContext?.custom);r&&(n=r[e])}if(t&&n!==void 0)return n;let r=this.getBaseTargetFromProps(this.props,e);return r!==void 0&&!rT(r)?r:this.initialValues[e]!==void 0&&n===void 0?void 0:this.baseTarget[e]}on(e,t){return this.events[e]||(this.events[e]=new nx),this.events[e].add(t)}notify(e,...t){this.events[e]&&this.events[e].notify(...t)}scheduleRenderMicrotask(){LT.render(this.render)}},UE=class extends HE{constructor(){super(...arguments),this.KeyframeResolver=MT}sortInstanceNodePosition(e,t){return e.compareDocumentPosition(t)&2?1:-1}getBaseTargetFromProps(e,t){let n=e.style;return n?n[t]:void 0}removeValueFromRenderState(e,{vars:t,style:n}){delete t[e],delete n[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);let{children:e}=this.props;rT(e)&&(this.childSubscription=e.on(`change`,e=>{this.current&&(this.current.textContent=`${e}`)}))}},WE=class{constructor(e){this.isMounted=!1,this.node=e}update(){}};function GE({top:e,left:t,right:n,bottom:r}){return{x:{min:t,max:n},y:{min:e,max:r}}}function KE({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function qE(e,t){if(!t)return e;let n=t({x:e.left,y:e.top}),r=t({x:e.right,y:e.bottom});return{top:n.y,left:n.x,bottom:r.y,right:r.x}}function JE(e){return e===void 0||e===1}function YE({scale:e,scaleX:t,scaleY:n}){return!JE(e)||!JE(t)||!JE(n)}function XE(e){return YE(e)||ZE(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function ZE(e){return QE(e.x)||QE(e.y)}function QE(e){return e&&e!==`0%`}function $E(e,t,n){return n+t*(e-n)}function eD(e,t,n,r,i){return i!==void 0&&(e=$E(e,i,r)),$E(e,n,r)+t}function tD(e,t=0,n=1,r,i){e.min=eD(e.min,t,n,r,i),e.max=eD(e.max,t,n,r,i)}function nD(e,{x:t,y:n}){tD(e.x,t.translate,t.scale,t.originPoint),tD(e.y,n.translate,n.scale,n.originPoint)}var rD=.999999999999,iD=1.0000000000001;function aD(e,t,n,r=!1){let i=n.length;if(!i)return;t.x=t.y=1;let a,o;for(let s=0;s<i;s++){a=n[s],o=a.projectionDelta;let{visualElement:i}=a.options;i&&i.props.style&&i.props.style.display===`contents`||(r&&a.options.layoutScroll&&a.scroll&&a!==a.root&&(oD(e.x,-a.scroll.offset.x),oD(e.y,-a.scroll.offset.y)),o&&(t.x*=o.x.scale,t.y*=o.y.scale,nD(e,o)),r&&XE(a.latestValues)&&lD(e,a.latestValues,a.layout?.layoutBox))}t.x<iD&&t.x>rD&&(t.x=1),t.y<iD&&t.y>rD&&(t.y=1)}function oD(e,t){e.min+=t,e.max+=t}function sD(e,t,n,r,i=.5){tD(e,t,n,MS(e.min,e.max,i),r)}function cD(e,t){return typeof e==`string`?parseFloat(e)/100*(t.max-t.min):e}function lD(e,t,n){let r=n??e;sD(e.x,cD(t.x,r.x),t.scaleX,t.scale,t.originX),sD(e.y,cD(t.y,r.y),t.scaleY,t.scale,t.originY)}function uD(e,t){return GE(qE(e.getBoundingClientRect(),t))}function dD(e,t,n){let r=uD(e,n),{scroll:i}=t;return i&&(oD(r.x,i.offset.x),oD(r.y,i.offset.y)),r}var fD={x:`translateX`,y:`translateY`,z:`translateZ`,transformPerspective:`perspective`},pD=zC.length;function mD(e,t,n){let r=``,i=!0;for(let a=0;a<pD;a++){let o=zC[a],s=e[o];if(s===void 0)continue;let c=!0;if(typeof s==`number`)c=s===+!!o.startsWith(`scale`);else{let e=parseFloat(s);c=o.startsWith(`scale`)?e===1:e===0}if(!c||n){let e=FT(s,TT[o]);if(!c){i=!1;let t=fD[o]||o;r+=`${t}(${e}) `}n&&(t[o]=e)}}let a=e.pathRotation;return a&&(i=!1,r+=`rotate(${FT(a,TT.pathRotation)}) `),r=r.trim(),n?r=n(t,i?``:r):i&&(r=`none`),r}function hD(e,t,n){let{style:r,vars:i,transformOrigin:a}=e,o=!1,s=!1;for(let e in t){let n=t[e];if(BC.has(e)){o=!0;continue}else if(Bx(e)){i[e]=n;continue}else{let t=FT(n,TT[e]);e.startsWith(`origin`)?(s=!0,a[e]=t):r[e]=t}}if(t.transform||(o||n?r.transform=mD(t,e.transform,n):r.transform&&=`none`),s){let{originX:e=`50%`,originY:t=`50%`,originZ:n=0}=a;r.transformOrigin=`${e} ${t} ${n}`}}function gD(e,{style:t,vars:n},r,i){let a=e.style,o;for(o in t)a[o]=t[o];for(o in i?.applyProjectionStyles(a,r),n)a.setProperty(o,n[o])}function _D(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}var vD={correct:(e,t)=>{if(!t.target)return e;if(typeof e==`string`)if(W.test(e))e=parseFloat(e);else return e;return`${_D(e,t.target.x)}% ${_D(e,t.target.y)}%`}},yD={correct:(e,{treeScale:t,projectionDelta:n})=>{let r=e,i=OS.parse(e);if(i.length>5)return r;let a=OS.createTransformer(e),o=typeof i[0]==`number`?0:1,s=n.x.scale*t.x,c=n.y.scale*t.y;i[0+o]/=s,i[1+o]/=c;let l=MS(s,c,.5);return typeof i[2+o]==`number`&&(i[2+o]/=l),typeof i[3+o]==`number`&&(i[3+o]/=l),a(i)}},bD={borderRadius:{...vD,applyTo:[...NT]},borderTopLeftRadius:vD,borderTopRightRadius:vD,borderBottomLeftRadius:vD,borderBottomRightRadius:vD,boxShadow:yD};function xD(e,{layout:t,layoutId:n}){return BC.has(e)||e.startsWith(`origin`)||(t||n!==void 0)&&(!!bD[e]||e===`opacity`)}function SD(e,t,n){let r=e.style,i=t?.style,a={};if(!r)return a;for(let t in r)(rT(r[t])||i&&rT(i[t])||xD(t,e)||n?.getValue(t)?.liveStyle!==void 0)&&(a[t]=r[t]);return a}function CD(e){return window.getComputedStyle(e)}var wD=class extends UE{constructor(){super(...arguments),this.type=`html`,this.renderInstance=gD}readValueFromInstance(e,t){if(BC.has(t))return this.projection?.isProjecting?FC(t):LC(e,t);{let n=CD(e),r=(Bx(t)?n.getPropertyValue(t):n[t])||0;return typeof r==`string`?r.trim():r}}measureInstanceViewportBox(e,{transformPagePoint:t}){return uD(e,t)}build(e,t,n){hD(e,t,n.transformTemplate)}scrapeMotionValuesFromProps(e,t,n){return SD(e,t,n)}},TD={offset:`stroke-dashoffset`,array:`stroke-dasharray`},ED={offset:`strokeDashoffset`,array:`strokeDasharray`};function DD(e,t,n=1,r=0,i=!0){e.pathLength=1;let a=i?TD:ED;e[a.offset]=`${-r}`,e[a.array]=`${t} ${n}`}var OD=[`offsetDistance`,`offsetPath`,`offsetRotate`,`offsetAnchor`];function kD(e,{attrX:t,attrY:n,attrScale:r,pathLength:i,pathSpacing:a=1,pathOffset:o=0,...s},c,l,u){if(hD(e,s,l),c){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};let{attrs:d,style:f}=e;d.transform&&(f.transform=d.transform,delete d.transform),(f.transform||d.transformOrigin)&&(f.transformOrigin=d.transformOrigin??`50% 50%`,delete d.transformOrigin),f.transform&&(f.transformBox=u?.transformBox??`fill-box`,delete d.transformBox);for(let e of OD)d[e]!==void 0&&(f[e]=d[e],delete d[e]);t!==void 0&&(d.x=t),n!==void 0&&(d.y=n),r!==void 0&&(d.scale=r),i!==void 0&&DD(d,i,a,o,!1)}var AD=new Set([`baseFrequency`,`diffuseConstant`,`kernelMatrix`,`kernelUnitLength`,`keySplines`,`keyTimes`,`limitingConeAngle`,`markerHeight`,`markerWidth`,`numOctaves`,`targetX`,`targetY`,`surfaceScale`,`specularConstant`,`specularExponent`,`stdDeviation`,`tableValues`,`viewBox`,`gradientTransform`,`pathLength`,`startOffset`,`textLength`,`lengthAdjust`]),jD=e=>typeof e==`string`&&e.toLowerCase()===`svg`;function MD(e,t,n,r){gD(e,t,void 0,r);for(let n in t.attrs)e.setAttribute(AD.has(n)?n:oT(n),t.attrs[n])}function ND(e,t,n){let r=SD(e,t,n);for(let n in e)if(rT(e[n])||rT(t[n])){let t=zC.indexOf(n)===-1?n:`attr`+n.charAt(0).toUpperCase()+n.substring(1);r[t]=e[n]}return r}var PD=class extends UE{constructor(){super(...arguments),this.type=`svg`,this.isSVGTag=!1,this.measureInstanceViewportBox=TE}getBaseTargetFromProps(e,t){return e[t]}readValueFromInstance(e,t){if(BC.has(t)){let e=DT(t);return e&&e.default||0}return t=AD.has(t)?t:oT(t),e.getAttribute(t)}scrapeMotionValuesFromProps(e,t,n){return ND(e,t,n)}build(e,t,n){kD(e,t,this.isSVGTag,n.transformTemplate,n.style)}renderInstance(e,t,n,r){MD(e,t,n,r)}mount(e){this.isSVGTag=jD(e.tagName),super.mount(e)}},FD=AE.length;function ID(e){if(!e)return;if(!e.isControllingVariants){let t=e.parent&&ID(e.parent)||{};return e.props.initial!==void 0&&(t.initial=e.props.initial),t}let t={};for(let n=0;n<FD;n++){let r=AE[n],i=e.props[r];(OE(i)||i===!1)&&(t[r]=i)}return t}function LD(e,t){if(!Array.isArray(t))return!1;let n=t.length;if(n!==e.length)return!1;for(let r=0;r<n;r++)if(t[r]!==e[r])return!1;return!0}var RD=[...kE].reverse(),zD=kE.length;function BD(e){return t=>Promise.all(t.map(({animation:t,options:n})=>pT(e,t,n)))}function VD(e){let t=BD(e),n=WD(),r=!0,i=!1,a=t=>(n,r)=>{let i=Zw(e,r,t===`exit`?e.presenceContext?.custom:void 0);if(i){let{transition:e,transitionEnd:t,...r}=i;n={...n,...r,...t}}return n};function o(n){t=n(e)}function s(o){let{props:s}=e,c=ID(e.parent)||{},l=[],u=new Set,d={},f=1/0;for(let t=0;t<zD;t++){let p=RD[t],m=n[p],h=s[p]===void 0?c[p]:s[p],g=OE(h),_=p===o?m.isActive:null;_===!1&&(f=t);let v=h===c[p]&&h!==s[p]&&g;if(v&&(r||i)&&e.manuallyAnimateOnMount&&(v=!1),m.protectedKeys={...d},!m.isActive&&_===null||!h&&!m.prevProp||DE(h)||typeof h==`boolean`)continue;if(p===`exit`&&m.isActive&&_!==!0){m.prevResolvedValues&&(d={...d,...m.prevResolvedValues});continue}let y=HD(m.prevProp,h),b=y||p===o&&m.isActive&&!v&&g||t>f&&g,x=!1,S=Array.isArray(h)?h:[h],C=S.reduce(a(p),{});_===!1&&(C={});let{prevResolvedValues:w={}}=m,T={...w,...C},E=t=>{b=!0,u.has(t)&&(x=!0,u.delete(t)),m.needsAnimating[t]=!0;let n=e.getValue(t);n&&(n.liveStyle=!1)};for(let e in T){let t=C[e],n=w[e];if(d.hasOwnProperty(e))continue;let r=!1;r=$w(t)&&$w(n)?!LD(t,n)||y:t!==n,r?t==null?u.add(e):E(e):t!==void 0&&u.has(e)?E(e):m.protectedKeys[e]=!0}m.prevProp=h,m.prevResolvedValues=C,m.isActive&&(d={...d,...C}),(r||i)&&e.blockInitialAnimation&&(b=!1);let D=v&&y;b&&(!D||x)&&l.push(...S.map(t=>{let n={type:p};if(typeof t==`string`&&(r||i)&&!D&&e.manuallyAnimateOnMount&&e.parent){let{parent:r}=e,i=Zw(r,t);if(r.enteringChildren&&i){let{delayChildren:t}=i.transition||{};n.delay=Aw(r.enteringChildren,e,t)}}return{animation:t,options:n}}))}if(u.size){let t={};if(typeof s.initial!=`boolean`){let n=Zw(e,Array.isArray(s.initial)?s.initial[0]:s.initial);n&&n.transition&&(t.transition=n.transition)}u.forEach(n=>{let r=e.getBaseTarget(n),i=e.getValue(n);i&&(i.liveStyle=!0),t[n]=r??null}),l.push({animation:t})}let p=!!l.length;return r&&(s.initial===!1||s.initial===s.animate)&&!e.manuallyAnimateOnMount&&(p=!1),r=!1,i=!1,p?t(l):Promise.resolve()}function c(t,r){if(n[t].isActive===r)return Promise.resolve();e.variantChildren?.forEach(e=>e.animationState?.setActive(t,r)),n[t].isActive=r;let i=s(t);for(let e in n)n[e].protectedKeys={};return i}return{animateChanges:s,setActive:c,setAnimateFunction:o,getState:()=>n,reset:()=>{n=WD(),i=!0}}}function HD(e,t){return typeof t==`string`?t!==e:Array.isArray(t)?!LD(t,e):!1}function UD(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function WD(){return{animate:UD(!0),whileInView:UD(),whileHover:UD(),whileTap:UD(),whileDrag:UD(),whileFocus:UD(),exit:UD()}}function GD(e,t){e.min=t.min,e.max=t.max}function KD(e,t){GD(e.x,t.x),GD(e.y,t.y)}function qD(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}var JD=.9999,YD=1.0001,XD=-.01,ZD=.01;function QD(e){return e.max-e.min}function $D(e,t,n){return Math.abs(e-t)<=n}function eO(e,t,n,r=.5){e.origin=r,e.originPoint=MS(t.min,t.max,e.origin),e.scale=QD(n)/QD(t),e.translate=MS(n.min,n.max,e.origin)-e.originPoint,(e.scale>=JD&&e.scale<=YD||isNaN(e.scale))&&(e.scale=1),(e.translate>=XD&&e.translate<=ZD||isNaN(e.translate))&&(e.translate=0)}function tO(e,t,n,r){eO(e.x,t.x,n.x,r?r.originX:void 0),eO(e.y,t.y,n.y,r?r.originY:void 0)}function nO(e,t,n,r=0){e.min=(r?MS(n.min,n.max,r):n.min)+t.min,e.max=e.min+QD(t)}function rO(e,t,n,r){nO(e.x,t.x,n.x,r?.x),nO(e.y,t.y,n.y,r?.y)}function iO(e,t,n,r=0){let i=r?MS(n.min,n.max,r):n.min;e.min=t.min-i,e.max=e.min+QD(t)}function aO(e,t,n,r){iO(e.x,t.x,n.x,r?.x),iO(e.y,t.y,n.y,r?.y)}function oO(e,t,n,r,i){return e-=t,e=$E(e,1/n,r),i!==void 0&&(e=$E(e,1/i,r)),e}function sO(e,t=0,n=1,r=.5,i,a=e,o=e){if(sS.test(t)&&(t=parseFloat(t),t=MS(o.min,o.max,t/100)-o.min),typeof t!=`number`)return;let s=MS(a.min,a.max,r);e===a&&(s-=t),e.min=oO(e.min,t,n,s,i),e.max=oO(e.max,t,n,s,i)}function cO(e,t,[n,r,i],a,o){sO(e,t[n],t[r],t[i],t.scale,a,o)}var lO=[`x`,`scaleX`,`originX`],uO=[`y`,`scaleY`,`originY`];function dO(e,t,n,r){cO(e.x,t,lO,n?n.x:void 0,r?r.x:void 0),cO(e.y,t,uO,n?n.y:void 0,r?r.y:void 0)}function fO(e){return e.translate===0&&e.scale===1}function pO(e){return fO(e.x)&&fO(e.y)}function mO(e,t){return e.min===t.min&&e.max===t.max}function hO(e,t){return mO(e.x,t.x)&&mO(e.y,t.y)}function gO(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function _O(e,t){return gO(e.x,t.x)&&gO(e.y,t.y)}function vO(e){return QD(e.x)/QD(e.y)}function yO(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}function bO(e){return[e(`x`),e(`y`)]}function xO(e,t,n){let r=``,i=e.x.translate/t.x,a=e.y.translate/t.y,o=n?.z||0;if((i||a||o)&&(r=`translate3d(${i}px, ${a}px, ${o}px) `),(t.x!==1||t.y!==1)&&(r+=`scale(${1/t.x}, ${1/t.y}) `),n){let{transformPerspective:e,rotate:t,pathRotation:i,rotateX:a,rotateY:o,skewX:s,skewY:c}=n;e&&(r=`perspective(${e}px) ${r}`),t&&(r+=`rotate(${t}deg) `),i&&(r+=`rotate(${i}deg) `),a&&(r+=`rotateX(${a}deg) `),o&&(r+=`rotateY(${o}deg) `),s&&(r+=`skewX(${s}deg) `),c&&(r+=`skewY(${c}deg) `)}let s=e.x.scale*t.x,c=e.y.scale*t.y;return(s!==1||c!==1)&&(r+=`scale(${s}, ${c})`),r||`none`}var SO=NT.length,CO=e=>typeof e==`string`?parseFloat(e):e,wO=e=>typeof e==`number`||W.test(e);function TO(e,t,n,r,i,a){i?(e.opacity=MS(0,n.opacity??1,DO(r)),e.opacityExit=MS(t.opacity??1,0,OO(r))):a&&(e.opacity=MS(t.opacity??1,n.opacity??1,r));for(let i=0;i<SO;i++){let a=NT[i],o=EO(t,a),s=EO(n,a);o===void 0&&s===void 0||(o||=0,s||=0,o===0||s===0||wO(o)===wO(s)?(e[a]=Math.max(MS(CO(o),CO(s),r),0),(sS.test(s)||sS.test(o))&&(e[a]+=`%`)):e[a]=s)}(t.rotate||n.rotate)&&(e.rotate=MS(t.rotate||0,n.rotate||0,r))}function EO(e,t){return e[t]===void 0?e.borderRadius:e[t]}var DO=kO(0,.5,vx),OO=kO(.5,.95,$b);function kO(e,t,n){return r=>r<e?0:r>t?1:n(tx(e,t,r))}function AO(e,t,n){let r=rT(e)?e:Fw(e);return r.start(Gw(``,r,t,n)),r.animation}function jO(e,t,n,r={passive:!0}){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}var MO=(e,t)=>e.depth-t.depth,NO=class{constructor(){this.children=[],this.isDirty=!1}add(e){Gb(this.children,e),this.isDirty=!0}remove(e){Kb(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(MO),this.isDirty=!1,this.children.forEach(e)}};function PO(e,t){let n=Rx.now(),r=({timestamp:i})=>{let a=i-n;a>=t&&(Nx(r),e(a-t))};return Mx.setup(r,!0),()=>Nx(r)}function FO(e){return rT(e)?e.get():e}var IO=class{constructor(){this.members=[]}add(e){Gb(this.members,e);for(let t=this.members.length-1;t>=0;t--){let n=this.members[t];if(n===e||n===this.lead||n===this.prevLead)continue;let r=n.instance;(!r||r.isConnected===!1)&&!n.snapshot&&(Kb(this.members,n),n.unmount())}e.scheduleRender()}remove(e){if(Kb(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){let e=this.members[this.members.length-1];e&&this.promote(e)}}relegate(e){for(let t=this.members.indexOf(e)-1;t>=0;t--){let e=this.members[t];if(e.isPresent!==!1&&e.instance?.isConnected!==!1)return this.promote(e),!0}return!1}promote(e,t){let n=this.lead;if(e!==n&&(this.prevLead=n,this.lead=e,e.show(),n)){n.updateSnapshot(),e.scheduleRender();let{layoutDependency:r}=n.options,{layoutDependency:i}=e.options;(r===void 0||r!==i)&&(e.resumeFrom=n,t&&(n.preserveOpacity=!0),n.snapshot&&(e.snapshot=n.snapshot,e.snapshot.latestValues=n.animationValues||n.latestValues),e.root?.isUpdating&&(e.isLayoutDirty=!0)),e.options.crossfade===!1&&n.hide()}}exitAnimationComplete(){this.members.forEach(e=>{e.options.onExitComplete?.(),e.resumingFrom?.options.onExitComplete?.()})}scheduleRender(){this.members.forEach(e=>e.instance&&e.scheduleRender(!1))}removeLeadSnapshot(){this.lead?.snapshot&&(this.lead.snapshot=void 0)}},LO={hasAnimatedSinceResize:!0,hasEverUpdated:!1},RO={nodes:0,calculatedTargetDeltas:0,calculatedProjections:0},zO=[``,`X`,`Y`,`Z`],BO=1e3,VO=0;function HO(e,t,n,r){let{latestValues:i}=t;i[e]&&(n[e]=i[e],t.setStaticValue(e,0),r&&(r[e]=0))}function UO(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;let{visualElement:t}=e.options;if(!t)return;let n=cT(t);if(window.MotionHasOptimisedAnimation(n,`transform`)){let{layout:t,layoutId:r}=e.options;window.MotionCancelOptimisedAnimation(n,`transform`,Mx,!(t||r))}let{parent:r}=e;r&&!r.hasCheckedOptimisedAppear&&UO(r)}function WO({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:r,resetTransform:i}){return class{constructor(e={},n=t?.()){this.id=VO++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.layoutVersion=0,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,vE.value&&(RO.nodes=RO.calculatedTargetDeltas=RO.calculatedProjections=0),this.nodes.forEach(qO),this.nodes.forEach(nk),this.nodes.forEach(rk),this.nodes.forEach(JO),vE.addProjectionMetrics&&vE.addProjectionMetrics(RO)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=e,this.root=n?n.root||n:this,this.path=n?[...n.path,n]:[],this.parent=n,this.depth=n?n.depth+1:0;for(let e=0;e<this.path.length;e++)this.path[e].shouldResetTransform=!0;this.root===this&&(this.nodes=new NO)}addEventListener(e,t){return this.eventHandlers.has(e)||this.eventHandlers.set(e,new nx),this.eventHandlers.get(e).add(t)}notifyListeners(e,...t){let n=this.eventHandlers.get(e);n&&n.notify(...t)}hasListeners(e){return this.eventHandlers.has(e)}mount(t){if(this.instance)return;this.isSVG=rE(t)&&!yE(t),this.instance=t;let{layoutId:n,layout:r,visualElement:i}=this.options;if(i&&!i.current&&i.mount(t),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(r||n)&&(this.isLayoutDirty=!0),e){let n,r=0,i=()=>this.root.updateBlockedByResize=!1;Mx.read(()=>{r=window.innerWidth}),e(t,()=>{let e=window.innerWidth;e!==r&&(r=e,this.root.updateBlockedByResize=!0,n&&n(),n=PO(i,250),LO.hasAnimatedSinceResize&&(LO.hasAnimatedSinceResize=!1,this.nodes.forEach(tk)))})}n&&this.root.registerSharedNode(n,this),this.options.animate!==!1&&i&&(n||r)&&this.addEventListener(`didUpdate`,({delta:e,hasLayoutChanged:t,hasRelativeLayoutChanged:n,layout:r})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}let a=this.options.transition||i.getDefaultTransition()||uk,{onLayoutAnimationStart:o,onLayoutAnimationComplete:s}=i.getProps(),c=!this.targetLayout||!_O(this.targetLayout,r),l=!t&&n;if(this.options.layoutRoot||this.resumeFrom||l||t&&(c||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);let t={...Lw(a,`layout`),onPlay:o,onComplete:s};(i.shouldReduceMotion||this.options.layoutRoot)&&(t.delay=0,t.type=!1),this.startAnimation(t),this.setAnimationOrigin(e,l,t.path)}else t||tk(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=r})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);let e=this.getStack();e&&e.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),Nx(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(ik),this.animationId++)}getTransformTemplate(){let{visualElement:e}=this.options;return e&&e.getProps().transformTemplate}willUpdate(e=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&UO(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let e=0;e<this.path.length;e++){let t=this.path[e];t.shouldResetTransform=!0,(typeof t.latestValues.x==`string`||typeof t.latestValues.y==`string`)&&(t.isLayoutDirty=!0),t.updateScroll(`snapshot`),t.options.layoutRoot&&t.willUpdate(!1)}let{layoutId:t,layout:n}=this.options;if(t===void 0&&!n)return;let r=this.getTransformTemplate();this.prevTransformTemplateValue=r?r(this.latestValues,``):void 0,this.updateSnapshot(),e&&this.notifyListeners(`willUpdate`)}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){let e=this.updateBlockedByResize;this.unblockUpdate(),this.updateBlockedByResize=!1,this.clearAllSnapshots(),e&&this.nodes.forEach(ZO),this.nodes.forEach(XO);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(QO);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach($O),this.nodes.forEach(ek),this.nodes.forEach(GO),this.nodes.forEach(KO)):this.nodes.forEach(QO),this.clearAllSnapshots();let e=Rx.now();Px.delta=qb(0,1e3/60,e-Px.timestamp),Px.timestamp=e,Px.isProcessing=!0,Fx.update.process(Px),Fx.preRender.process(Px),Fx.render.process(Px),Px.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,LT.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(YO),this.sharedNodes.forEach(ak)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,Mx.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){Mx.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!QD(this.snapshot.measuredBox.x)&&!QD(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let e=0;e<this.path.length;e++)this.path[e].updateScroll();let e=this.layout;this.layout=this.measure(!1),this.layoutVersion++,this.layoutCorrected||=TE(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners(`measure`,this.layout.layoutBox);let{visualElement:t}=this.options;t&&t.notify(`LayoutMeasure`,this.layout.layoutBox,e?e.layoutBox:void 0)}updateScroll(e=`measure`){let t=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===e&&(t=!1),t&&this.instance){let t=r(this.instance);this.scroll={animationId:this.root.animationId,phase:e,isRoot:t,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:t}}}resetTransform(){if(!i)return;let e=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,t=this.projectionDelta&&!pO(this.projectionDelta),n=this.getTransformTemplate(),r=n?n(this.latestValues,``):void 0,a=r!==this.prevTransformTemplateValue;e&&this.instance&&(t||XE(this.latestValues)||a)&&(i(this.instance,r),this.shouldResetTransform=!1,this.scheduleRender())}measure(e=!0){let t=this.measurePageBox(),n=this.removeElementScroll(t);return e&&(n=this.removeTransform(n)),mk(n),{animationId:this.root.animationId,measuredBox:t,layoutBox:n,latestValues:{},source:this.id}}measurePageBox(){let{visualElement:e}=this.options;if(!e)return TE();let t=e.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(gk))){let{scroll:e}=this.root;e&&(oD(t.x,e.offset.x),oD(t.y,e.offset.y))}return t}removeElementScroll(e){let t=TE();if(KD(t,e),this.scroll?.wasRoot)return t;for(let n=0;n<this.path.length;n++){let r=this.path[n],{scroll:i,options:a}=r;r!==this.root&&i&&a.layoutScroll&&(i.wasRoot&&KD(t,e),oD(t.x,i.offset.x),oD(t.y,i.offset.y))}return t}applyTransform(e,t=!1,n){let r=n||TE();KD(r,e);for(let e=0;e<this.path.length;e++){let n=this.path[e];!t&&n.options.layoutScroll&&n.scroll&&n!==n.root&&(oD(r.x,-n.scroll.offset.x),oD(r.y,-n.scroll.offset.y)),XE(n.latestValues)&&lD(r,n.latestValues,n.layout?.layoutBox)}return XE(this.latestValues)&&lD(r,this.latestValues,this.layout?.layoutBox),r}removeTransform(e){let t=TE();KD(t,e);for(let e=0;e<this.path.length;e++){let n=this.path[e];if(!XE(n.latestValues))continue;let r;n.instance&&(YE(n.latestValues)&&n.updateSnapshot(),r=TE(),KD(r,n.measurePageBox())),dO(t,n.latestValues,n.snapshot?.layoutBox,r)}return XE(this.latestValues)&&dO(t,this.latestValues),t}setTargetDelta(e){this.targetDelta=e,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(e){this.options={...this.options,...e,crossfade:e.crossfade===void 0||e.crossfade}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==Px.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(e=!1){let t=this.getLead();this.isProjectionDirty||=t.isProjectionDirty,this.isTransformDirty||=t.isTransformDirty,this.isSharedProjectionDirty||=t.isSharedProjectionDirty;let n=!!this.resumingFrom||this!==t;if(!(e||n&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;let{layout:r,layoutId:i}=this.options;if(!this.layout||!(r||i))return;this.resolvedRelativeTargetAt=Px.timestamp;let a=this.getClosestProjectingParent();a&&this.linkedParentVersion!==a.layoutVersion&&!a.options.layoutRoot&&this.removeRelativeTarget(),!this.targetDelta&&!this.relativeTarget&&(this.options.layoutAnchor!==!1&&a&&a.layout?this.createRelativeTarget(a,this.layout.layoutBox,a.layout.layoutBox):this.removeRelativeTarget()),!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=TE(),this.targetWithTransforms=TE()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),rO(this.target,this.relativeTarget,this.relativeParent.target,this.options.layoutAnchor||void 0)):this.targetDelta?(this.resumingFrom?this.applyTransform(this.layout.layoutBox,!1,this.target):KD(this.target,this.layout.layoutBox),nD(this.target,this.targetDelta)):KD(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget&&(this.attemptToResolveRelativeTarget=!1,this.options.layoutAnchor!==!1&&a&&!!a.resumingFrom==!!this.resumingFrom&&!a.options.layoutScroll&&a.target&&this.animationProgress!==1?this.createRelativeTarget(a,this.target,a.target):this.relativeParent=this.relativeTarget=void 0),vE.value&&RO.calculatedTargetDeltas++)}getClosestProjectingParent(){if(!(!this.parent||YE(this.parent.latestValues)||ZE(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}createRelativeTarget(e,t,n){this.relativeParent=e,this.linkedParentVersion=e.layoutVersion,this.forceRelativeParentToResolveTarget(),this.relativeTarget=TE(),this.relativeTargetOrigin=TE(),aO(this.relativeTargetOrigin,t,n,this.options.layoutAnchor||void 0),KD(this.relativeTarget,this.relativeTargetOrigin)}removeRelativeTarget(){this.relativeParent=this.relativeTarget=void 0}calcProjection(){let e=this.getLead(),t=!!this.resumingFrom||this!==e,n=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(n=!1),t&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(n=!1),this.resolvedRelativeTargetAt===Px.timestamp&&(n=!1),n)return;let{layout:r,layoutId:i}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(r||i))return;KD(this.layoutCorrected,this.layout.layoutBox);let a=this.treeScale.x,o=this.treeScale.y;aD(this.layoutCorrected,this.treeScale,this.path,t),e.layout&&!e.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(e.target=e.layout.layoutBox,e.targetWithTransforms=TE());let{target:s}=e;if(!s){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(qD(this.prevProjectionDelta.x,this.projectionDelta.x),qD(this.prevProjectionDelta.y,this.projectionDelta.y)),tO(this.projectionDelta,this.layoutCorrected,s,this.latestValues),(this.treeScale.x!==a||this.treeScale.y!==o||!yO(this.projectionDelta.x,this.prevProjectionDelta.x)||!yO(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners(`projectionUpdate`,s)),vE.value&&RO.calculatedProjections++}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(e=!0){if(this.options.visualElement?.scheduleRender(),e){let e=this.getStack();e&&e.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=CE(),this.projectionDelta=CE(),this.projectionDeltaWithTransform=CE()}setAnimationOrigin(e,t=!1,n){let r=this.snapshot,i=r?r.latestValues:{},a={...this.latestValues},o=CE();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!t;let s=TE(),c=(r?r.source:void 0)!==(this.layout?this.layout.source:void 0),l=this.getStack(),u=!l||l.members.length<=1,d=!!(c&&!u&&this.options.crossfade===!0&&!this.path.some(lk));this.animationProgress=0;let f,p=n?.interpolateProjection(e);this.mixTargetDelta=t=>{let n=t/1e3,r=p?.(n);r?(o.x.translate=r.x,o.x.scale=MS(e.x.scale,1,n),o.x.origin=e.x.origin,o.x.originPoint=e.x.originPoint,o.y.translate=r.y,o.y.scale=MS(e.y.scale,1,n),o.y.origin=e.y.origin,o.y.originPoint=e.y.originPoint):(ok(o.x,e.x,n),ok(o.y,e.y,n)),this.setTargetDelta(o),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(aO(s,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),ck(this.relativeTarget,this.relativeTargetOrigin,s,n),f&&hO(this.relativeTarget,f)&&(this.isProjectionDirty=!1),f||=TE(),KD(f,this.relativeTarget)),c&&(this.animationValues=a,TO(a,i,this.latestValues,n,d,u)),r&&r.rotate!==void 0&&(this.animationValues||=a,this.animationValues.pathRotation=r.rotate),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=n},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(e){this.notifyListeners(`animationStart`),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&=(Nx(this.pendingAnimation),void 0),this.pendingAnimation=Mx.update(()=>{LO.hasAnimatedSinceResize=!0,this.motionValue||=Fw(0),this.motionValue.jump(0,!1),this.currentAnimation=AO(this.motionValue,[0,1e3],{...e,velocity:0,isSync:!0,onUpdate:t=>{this.mixTargetDelta(t),e.onUpdate&&e.onUpdate(t)},onComplete:()=>{e.onComplete&&e.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);let e=this.getStack();e&&e.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners(`animationComplete`)}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(BO),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){let e=this.getLead(),{targetWithTransforms:t,target:n,layout:r,latestValues:i}=e;if(!(!t||!n||!r)){if(this!==e&&this.layout&&r&&hk(this.options.animationType,this.layout.layoutBox,r.layoutBox)){n=this.target||TE();let t=QD(this.layout.layoutBox.x);n.x.min=e.target.x.min,n.x.max=n.x.min+t;let r=QD(this.layout.layoutBox.y);n.y.min=e.target.y.min,n.y.max=n.y.min+r}KD(t,n),lD(t,i),tO(this.projectionDeltaWithTransform,this.layoutCorrected,t,i)}}registerSharedNode(e,t){this.sharedNodes.has(e)||this.sharedNodes.set(e,new IO),this.sharedNodes.get(e).add(t);let n=t.options.initialPromotionConfig;t.promote({transition:n?n.transition:void 0,preserveFollowOpacity:n&&n.shouldPreserveFollowOpacity?n.shouldPreserveFollowOpacity(t):void 0})}isLead(){let e=this.getStack();return!e||e.lead===this}getLead(){let{layoutId:e}=this.options;return e&&this.getStack()?.lead||this}getPrevLead(){let{layoutId:e}=this.options;return e?this.getStack()?.prevLead:void 0}getStack(){let{layoutId:e}=this.options;if(e)return this.root.sharedNodes.get(e)}promote({needsReset:e,transition:t,preserveFollowOpacity:n}={}){let r=this.getStack();r&&r.promote(this,n),e&&(this.projectionDelta=void 0,this.needsReset=!0),t&&this.setOptions({transition:t})}relegate(){let e=this.getStack();return e?e.relegate(this):!1}resetSkewAndRotation(){let{visualElement:e}=this.options;if(!e)return;let t=!1,{latestValues:n}=e;if((n.z||n.rotate||n.rotateX||n.rotateY||n.rotateZ||n.skewX||n.skewY)&&(t=!0),!t)return;let r={};n.z&&HO(`z`,e,r,this.animationValues);for(let t=0;t<zO.length;t++)HO(`rotate${zO[t]}`,e,r,this.animationValues),HO(`skew${zO[t]}`,e,r,this.animationValues);e.render();for(let t in r)e.setStaticValue(t,r[t]),this.animationValues&&(this.animationValues[t]=r[t]);e.scheduleRender()}applyProjectionStyles(e,t){if(!this.instance||this.isSVG)return;if(!this.isVisible){e.visibility=`hidden`;return}let n=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,e.visibility=``,e.opacity=``,e.pointerEvents=FO(t?.pointerEvents)||``,e.transform=n?n(this.latestValues,``):`none`;return}let r=this.getLead();if(!this.projectionDelta||!this.layout||!r.target){this.options.layoutId&&(e.opacity=this.latestValues.opacity===void 0?1:this.latestValues.opacity,e.pointerEvents=FO(t?.pointerEvents)||``),this.hasProjected&&!XE(this.latestValues)&&(e.transform=n?n({},``):`none`,this.hasProjected=!1);return}e.visibility=``;let i=r.animationValues||r.latestValues;this.applyTransformsToTarget();let a=xO(this.projectionDeltaWithTransform,this.treeScale,i);n&&(a=n(i,a)),e.transform=a;let{x:o,y:s}=this.projectionDelta;e.transformOrigin=`${o.origin*100}% ${s.origin*100}% 0`,r.animationValues?e.opacity=r===this?i.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:i.opacityExit:e.opacity=r===this?i.opacity===void 0?``:i.opacity:i.opacityExit===void 0?0:i.opacityExit;for(let t in bD){if(i[t]===void 0)continue;let{correct:n,applyTo:o,isCSSVariable:s}=bD[t],c=a===`none`?i[t]:n(i[t],r);if(o){let t=o.length;for(let n=0;n<t;n++)e[o[n]]=c}else s?this.options.visualElement.renderState.vars[t]=c:e[t]=c}this.options.layoutId&&(e.pointerEvents=r===this?FO(t?.pointerEvents)||``:`none`)}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(e=>e.currentAnimation?.stop()),this.root.nodes.forEach(XO),this.root.sharedNodes.clear()}}}function GO(e){e.updateLayout()}function KO(e){let t=e.resumeFrom?.snapshot||e.snapshot;if(e.isLead()&&e.layout&&t&&e.hasListeners(`didUpdate`)){let{layoutBox:n,measuredBox:r}=e.layout,{animationType:i}=e.options,a=t.source!==e.layout.source;if(i===`size`)bO(e=>{let r=a?t.measuredBox[e]:t.layoutBox[e],i=QD(r);r.min=n[e].min,r.max=r.min+i});else if(i===`x`||i===`y`){let e=i===`x`?`y`:`x`;GD(a?t.measuredBox[e]:t.layoutBox[e],n[e])}else hk(i,t.layoutBox,n)&&bO(r=>{let i=a?t.measuredBox[r]:t.layoutBox[r],o=QD(n[r]);i.max=i.min+o,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[r].max=e.relativeTarget[r].min+o)});let o=CE();tO(o,n,t.layoutBox);let s=CE();a?tO(s,e.applyTransform(r,!0),t.measuredBox):tO(s,n,t.layoutBox);let c=!pO(o),l=!1;if(!e.resumeFrom){let r=e.getClosestProjectingParent();if(r&&!r.resumeFrom){let{snapshot:i,layout:a}=r;if(i&&a){let o=e.options.layoutAnchor||void 0,s=TE();aO(s,t.layoutBox,i.layoutBox,o);let c=TE();aO(c,n,a.layoutBox,o),_O(s,c)||(l=!0),r.options.layoutRoot&&(e.relativeTarget=c,e.relativeTargetOrigin=s,e.relativeParent=r)}}}e.notifyListeners(`didUpdate`,{layout:n,snapshot:t,delta:s,layoutDelta:o,hasLayoutChanged:c,hasRelativeLayoutChanged:l})}else if(e.isLead()){let{onExitComplete:t}=e.options;t&&t()}e.options.transition=void 0}function qO(e){vE.value&&RO.nodes++,e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty),e.isTransformDirty||=e.parent.isTransformDirty)}function JO(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function YO(e){e.clearSnapshot()}function XO(e){e.clearMeasurements()}function ZO(e){e.isLayoutDirty=!0,e.updateLayout()}function QO(e){e.isLayoutDirty=!1}function $O(e){e.isAnimationBlocked&&e.layout&&!e.isLayoutDirty&&(e.snapshot=e.layout,e.isLayoutDirty=!0)}function ek(e){let{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify(`BeforeLayoutMeasure`),e.resetTransform()}function tk(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function nk(e){e.resolveTargetDelta()}function rk(e){e.calcProjection()}function ik(e){e.resetSkewAndRotation()}function ak(e){e.removeLeadSnapshot()}function ok(e,t,n){e.translate=MS(t.translate,0,n),e.scale=MS(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function sk(e,t,n,r){e.min=MS(t.min,n.min,r),e.max=MS(t.max,n.max,r)}function ck(e,t,n,r){sk(e.x,t.x,n.x,r),sk(e.y,t.y,n.y,r)}function lk(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}var uk={duration:.45,ease:[.4,0,.1,1]},dk=e=>typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),fk=dk(`applewebkit/`)&&!dk(`chrome/`)?Math.round:$b;function pk(e){e.min=fk(e.min),e.max=fk(e.max)}function mk(e){pk(e.x),pk(e.y)}function hk(e,t,n){return e===`position`||e===`preserve-aspect`&&!$D(vO(t),vO(n),.2)}function gk(e){return e!==e.root&&e.scroll?.wasRoot}var _k=WO({attachResizeListener:(e,t)=>jO(e,`resize`,t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body?.scrollLeft||0,y:document.documentElement.scrollTop||document.body?.scrollTop||0}),checkIsScrollRoot:()=>!0}),vk={current:void 0},yk=WO({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!vk.current){let e=new _k({});e.mount(window),e.setOptions({layoutScroll:!0}),vk.current=e}return vk.current},resetTransform:(e,t)=>{e.style.transform=t===void 0?`none`:t},checkIsScrollRoot:e=>window.getComputedStyle(e).position===`fixed`}),bk=(0,R.createContext)({transformPagePoint:e=>e,isStatic:!1,reducedMotion:`never`});function xk(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function Sk(...e){return t=>{let n=!1,r=e.map(e=>{let r=xk(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():xk(e[t],null)}}}}function Ck(...e){return R.useCallback(Sk(...e),e)}var wk=class extends R.Component{getSnapshotBeforeUpdate(e){let t=this.props.childRef.current;if(IT(t)&&e.isPresent&&!this.props.isPresent&&this.props.pop!==!1){let e=t.offsetParent,n=IT(e)&&e.offsetWidth||0,r=IT(e)&&e.offsetHeight||0,i=getComputedStyle(t),a=this.props.sizeRef.current;a.height=parseFloat(i.height),a.width=parseFloat(i.width),a.top=t.offsetTop,a.left=t.offsetLeft,a.right=n-a.width-a.left,a.bottom=r-a.height-a.top,a.direction=i.direction}return null}componentDidUpdate(){}render(){return this.props.children}};function Tk({children:e,isPresent:t,anchorX:n,anchorY:r,root:i,pop:a}){let o=(0,R.useId)(),s=(0,R.useRef)(null),c=(0,R.useRef)({width:0,height:0,top:0,left:0,right:0,bottom:0,direction:`ltr`}),{nonce:l}=(0,R.useContext)(bk),u=Ck(s,e.props?.ref??e?.ref);return(0,R.useInsertionEffect)(()=>{let{width:e,height:u,top:d,left:f,right:p,bottom:m,direction:h}=c.current;if(t||a===!1||!s.current||!e||!u)return;let g=h===`rtl`,_=n===`left`?g?`right: ${p}`:`left: ${f}`:g?`left: ${f}`:`right: ${p}`,v=r===`bottom`?`bottom: ${m}`:`top: ${d}`;s.current.dataset.motionPopId=o;let y=document.createElement(`style`);l&&(y.nonce=l);let b=i??document.head;return b.appendChild(y),y.sheet&&y.sheet.insertRule(`
|
|
170
|
+
]))`;continue}}if(n.s&&r[e]===`.`){i+=o?`${r[e]}\r\n`:`[${r[e]}\r\n]`;continue}i+=r[e],r[e]===`\\`?a=!0:o&&r[e]===`]`?o=!1:!o&&r[e]===`[`&&(o=!0)}try{new RegExp(i)}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 i}function yg(e,t){let n={type:`object`,additionalProperties:Hg(e.valueType._def,{...t,currentPath:[...t.currentPath,`additionalProperties`]})??t.allowedAdditionalProperties};if(e.keyType?._def.typeName===`ZodString`&&e.keyType._def.checks?.length){let{type:r,...i}=fg(e.keyType._def,t);return{...n,propertyNames:i}}else if(e.keyType?._def.typeName===`ZodEnum`)return{...n,propertyNames:{enum:e.keyType._def.values}};else if(e.keyType?._def.typeName===`ZodBranded`&&e.keyType._def.type._def.typeName===`ZodString`&&e.keyType._def.type._def.checks?.length){let{type:r,...i}=tg(e.keyType._def,t);return{...n,propertyNames:i}}return n}function bg(e,t){return t.mapStrategy===`record`?yg(e,t):{type:`array`,maxItems:125,items:{type:`array`,items:[Hg(e.keyType._def,{...t,currentPath:[...t.currentPath,`items`,`items`,`0`]})||eg(),Hg(e.valueType._def,{...t,currentPath:[...t.currentPath,`items`,`items`,`1`]})||eg()],minItems:2,maxItems:2}}}function xg(e){let t=e.values,n=Object.keys(e.values).filter(e=>typeof t[t[e]]!=`number`).map(e=>t[e]),r=Array.from(new Set(n.map(e=>typeof e)));return{type:r.length===1?r[0]===`string`?`string`:`number`:[`string`,`number`],enum:n}}function Sg(){return{not:eg()}}function Cg(){return{type:`null`}}var wg={ZodString:`string`,ZodNumber:`number`,ZodBigInt:`integer`,ZodBoolean:`boolean`,ZodNull:`null`};function Tg(e,t){let n=e.options instanceof Map?Array.from(e.options.values()):e.options;if(n.every(e=>e._def.typeName in wg&&(!e._def.checks||!e._def.checks.length))){let e=n.reduce((e,t)=>{let n=wg[t._def.typeName];return n&&!e.includes(n)?[...e,n]:e},[]);return{type:e.length>1?e:e[0]}}else if(n.every(e=>e._def.typeName===`ZodLiteral`&&!e.description)){let e=n.reduce((e,t)=>{let n=typeof t._def.value;switch(n){case`string`:case`number`:case`boolean`:return[...e,n];case`bigint`:return[...e,`integer`];case`object`:if(t._def.value===null)return[...e,`null`];default:return e}},[]);if(e.length===n.length){let t=e.filter((e,t,n)=>n.indexOf(e)===t);return{type:t.length>1?t:t[0],enum:n.reduce((e,t)=>e.includes(t._def.value)?e:[...e,t._def.value],[])}}}else if(n.every(e=>e._def.typeName===`ZodEnum`))return{type:`string`,enum:n.reduce((e,t)=>[...e,...t._def.values.filter(t=>!e.includes(t))],[])};return Eg(e,t)}var Eg=(e,t)=>{let n=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((e,n)=>Hg(e._def,{...t,currentPath:[...t.currentPath,`anyOf`,`${n}`]})).filter(e=>!!e&&(!t.strictUnions||typeof e==`object`&&Object.keys(e).length>0));return n.length?{anyOf:n}:void 0};function Dg(e,t){if([`ZodString`,`ZodNumber`,`ZodBigInt`,`ZodBoolean`,`ZodNull`].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return{type:[wg[e.innerType._def.typeName],`null`]};let n=Hg(e.innerType._def,{...t,currentPath:[...t.currentPath,`anyOf`,`0`]});return n&&{anyOf:[n,{type:`null`}]}}function Og(e){let t={type:`number`};if(!e.checks)return t;for(let 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}return t}function kg(e,t){let n={type:`object`,properties:{}},r=[],i=e.shape();for(let e in i){let a=i[e];if(a===void 0||a._def===void 0)continue;let o=jg(a),s=Hg(a._def,{...t,currentPath:[...t.currentPath,`properties`,e],propertyPath:[...t.currentPath,`properties`,e]});s!==void 0&&(n.properties[e]=s,o||r.push(e))}r.length&&(n.required=r);let a=Ag(e,t);return a!==void 0&&(n.additionalProperties=a),n}function Ag(e,t){if(e.catchall._def.typeName!==`ZodNever`)return Hg(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 jg(e){try{return e.isOptional()}catch{return!0}}var Mg=(e,t)=>{if(t.currentPath.toString()===t.propertyPath?.toString())return Hg(e.innerType._def,t);let n=Hg(e.innerType._def,{...t,currentPath:[...t.currentPath,`anyOf`,`1`]});return n?{anyOf:[{not:eg()},n]}:eg()},Ng=(e,t)=>{if(t.pipeStrategy===`input`)return Hg(e.in._def,t);if(t.pipeStrategy===`output`)return Hg(e.out._def,t);let n=Hg(e.in._def,{...t,currentPath:[...t.currentPath,`allOf`,`0`]});return{allOf:[n,Hg(e.out._def,{...t,currentPath:[...t.currentPath,`allOf`,n?`1`:`0`]})].filter(e=>e!==void 0)}};function Pg(e,t){return Hg(e.type._def,t)}function Fg(e,t){let n={type:`array`,uniqueItems:!0,items:Hg(e.valueType._def,{...t,currentPath:[...t.currentPath,`items`]})};return e.minSize&&(n.minItems=e.minSize.value),e.maxSize&&(n.maxItems=e.maxSize.value),n}function Ig(e,t){return e.rest?{type:`array`,minItems:e.items.length,items:e.items.map((e,n)=>Hg(e._def,{...t,currentPath:[...t.currentPath,`items`,`${n}`]})).reduce((e,t)=>t===void 0?e:[...e,t],[]),additionalItems:Hg(e.rest._def,{...t,currentPath:[...t.currentPath,`additionalItems`]})}:{type:`array`,minItems:e.items.length,maxItems:e.items.length,items:e.items.map((e,n)=>Hg(e._def,{...t,currentPath:[...t.currentPath,`items`,`${n}`]})).reduce((e,t)=>t===void 0?e:[...e,t],[])}}function Lg(){return{not:eg()}}function Rg(){return eg()}var zg=(e,t)=>Hg(e.innerType._def,t),Bg=(e,t,n)=>{switch(t){case`ZodString`:return fg(e,n);case`ZodNumber`:return Og(e);case`ZodObject`:return kg(e,n);case`ZodBigInt`:return hee(e);case`ZodBoolean`:return gee();case`ZodDate`:return rg(e,n);case`ZodUndefined`:return Lg();case`ZodNull`:return Cg();case`ZodArray`:return mee(e,n);case`ZodUnion`:case`ZodDiscriminatedUnion`:return Tg(e,n);case`ZodIntersection`:return lg(e,n);case`ZodTuple`:return Ig(e,n);case`ZodRecord`:return yg(e,n);case`ZodLiteral`:return _ee(e);case`ZodEnum`:return sg(e);case`ZodNativeEnum`:return xg(e);case`ZodNullable`:return Dg(e,n);case`ZodOptional`:return Mg(e,n);case`ZodMap`:return bg(e,n);case`ZodSet`:return Fg(e,n);case`ZodLazy`:return()=>e.getter()._def;case`ZodPromise`:return Pg(e,n);case`ZodNaN`:case`ZodNever`:return Sg();case`ZodEffects`:return og(e,n);case`ZodAny`:return eg();case`ZodUnknown`:return Rg();case`ZodDefault`:return ag(e,n);case`ZodBranded`:return tg(e,n);case`ZodReadonly`:return zg(e,n);case`ZodCatch`:return ng(e,n);case`ZodPipeline`:return Ng(e,n);case`ZodFunction`:case`ZodVoid`:case`ZodSymbol`:return;default:return(e=>void 0)(t)}},Vg=(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 Hg(e,t,n=!1){let r=t.seen.get(e);if(t.override){let i=t.override?.(e,t,r,n);if(i!==fee)return i}if(r&&!n){let e=Ug(r,t);if(e!==void 0)return e}let i={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,i);let a=Bg(e,e.typeName,t),o=typeof a==`function`?Hg(a(),t):a;if(o&&Wg(e,t,o),t.postProcess){let n=t.postProcess(o,e,t);return i.jsonSchema=o,n}return i.jsonSchema=o,o}var Ug=(e,t)=>{switch(t.$refStrategy){case`root`:return{$ref:e.path.join(`/`)};case`relative`:return{$ref:Vg(t.currentPath,e.path)};case`none`:case`seen`:return e.path.length<t.currentPath.length&&e.path.every((e,n)=>t.currentPath[n]===e)?(console.warn(`Recursive reference detected at ${t.currentPath.join(`/`)}! Defaulting to any`),eg()):t.$refStrategy===`seen`?eg():void 0}},Wg=(e,t,n)=>(e.description&&(n.description=e.description),n),Gg=e=>{let t=pee(e),n=t.name===void 0?t.basePath:[...t.basePath,t.definitionPath,t.name];return{...t,currentPath:n,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([e,n])=>[n._def,{def:n._def,path:[...t.basePath,t.definitionPath,e],jsonSchema:void 0}]))}},Kg=(e,t)=>{let n=Gg(t),r=typeof t==`object`&&t.definitions?Object.entries(t.definitions).reduce((e,[t,r])=>({...e,[t]:Hg(r._def,{...n,currentPath:[...n.basePath,n.definitionPath,t]},!0)??eg()}),{}):void 0,i=typeof t==`string`?t:t?.nameStrategy===`title`?void 0:t?.name,a=Hg(e._def,i===void 0?n:{...n,currentPath:[...n.basePath,n.definitionPath,i]},!1)??eg(),o=typeof t==`object`&&t.name!==void 0&&t.nameStrategy===`title`?t.name:void 0;o!==void 0&&(a.title=o);let s=i===void 0?r?{...a,[n.definitionPath]:r}:a:{$ref:[...n.$refStrategy===`relative`?[]:n.basePath,n.definitionPath,i].join(`/`),[n.definitionPath]:{...r,[i]:a}};return s.$schema=`http://json-schema.org/draft-07/schema#`,s},qg=Symbol.for(`vercel.ai.schema`);function Jg(e){let t;return()=>(t??=e(),t)}function Yg(e,{validate:t}={}){return{[qg]:!0,_type:void 0,get jsonSchema(){return typeof e==`function`&&(e=e()),e},validate:t}}function Xg(e){return typeof e==`object`&&!!e&&qg in e&&e[qg]===!0&&`jsonSchema`in e&&`validate`in e}function Zg(e){return e==null?Yg({type:`object`,properties:{},additionalProperties:!1}):Xg(e)?e:`~standard`in e?e[`~standard`].vendor===`zod`?r_(e):Qg(e):e()}function Qg(e){return Yg(()=>{if(!$g(e))throw Error(`Standard schema vendor '${e[`~standard`].vendor}' does not support JSON Schema conversion.`);return Zh(e[`~standard`].jsonSchema.input({target:`draft-07`}))},{validate:async t=>{let n=await e[`~standard`].validate(t);return n.issues===void 0&&`value`in n?{success:!0,value:n.value}:{success:!1,error:new Oh({value:t,cause:n.issues})}}})}function $g(e){return e[`~standard`].jsonSchema!=null}function e_(e,t){let n=t?.useReferences??!1;return Yg(()=>Kg(e,{$refStrategy:n?`root`:`none`}),{validate:async t=>{let n=await e.safeParseAsync(t);return n.success?{success:!0,value:n.data}:{success:!1,error:n.error}}})}function t_(e,t){Lt().localeError||Lt(pe());let n=t?.useReferences??!1;return Yg(()=>Zh(Le(e,{target:`draft-7`,io:`input`,reused:n?`ref`:`inline`})),{validate:async t=>{let n=await Oe(e,t);return n.success?{success:!0,value:n.data}:{success:!1,error:n.error}}})}function n_(e){return`_zod`in e}function r_(e,t){return n_(e)?t_(e,t):e_(e,t)}async function i_({value:e,schema:t,context:n}){let r=await a_({value:e,schema:t,context:n});if(!r.success)throw Oh.wrap({value:e,cause:r.error,context:n});return r.value}async function a_({value:e,schema:t,context:n}){let r=Zg(t);try{if(r.validate==null)return{success:!0,value:e,rawValue:e};let t=await r.validate(e);return t.success?{success:!0,value:t.value,rawValue:e}:{success:!1,error:Oh.wrap({value:e,cause:t.error,context:n}),rawValue:e}}catch(t){return{success:!1,error:Oh.wrap({value:e,cause:t,context:n}),rawValue:e}}}async function o_({text:e,schema:t}){try{let n=dee(e);return t==null?{success:!0,value:n,rawValue:n}:await a_({value:n,schema:t})}catch(t){return{success:!1,error:wh.isInstance(t)?t:new wh({text:e,cause:t}),rawValue:void 0}}}function s_({stream:e,schema:t}){return e.pipeThrough(new TextDecoderStream).pipeThrough(new Vh).pipeThrough(new TransformStream({async transform({data:e},n){e!==`[DONE]`&&n.enqueue(await o_({text:e,schema:t}))}}))}async function c_(e){return typeof e==`function`&&(e=e()),e}new TextDecoder;var l_=er(`ZodMiniType`,(e,t)=>{if(!e._zod)throw Error(`Uninitialized schema in ZodMiniType.`);Zn.init(e,t),e.def=t,e.type=t.type},{get with(){return this.check},set with(e){nt(this,`with`,e)},parse(e,t){return In(this,e,t,{callee:this.parse})},parseAsync(e,t){return Cn(this,e,t,{callee:this.parseAsync})},safeParse(e,t){return an(this,e,t)},safeParseAsync(e,t){return en(this,e,t)},check(...e){let t=this.def;return this.clone({...t,checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]},{parent:!0})},clone(e,t){return cr(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},apply(e,...t){return t.length===0?e(this):e(this,...t)}}),vee=er(`ZodMiniString`,(e,t)=>{eee.init(e,t),l_.init(e,t)});function u_(e){return ve(vee,e)}var d_=er(`ZodMiniNumber`,(e,t)=>{On.init(e,t),l_.init(e,t)});function f_(e){return oe(d_,e)}var p_=er(`ZodMiniNumberFormat`,(e,t)=>{Un.init(e,t),d_.init(e,t)});function m_(e){return xe(p_,e)}var h_=er(`ZodMiniBoolean`,(e,t)=>{gt.init(e,t),l_.init(e,t)});function g_(e){return ne(h_,e)}var __=er(`ZodMiniUnknown`,(e,t)=>{Yt.init(e,t),l_.init(e,t)});function v_(){return Ln(__)}var y_=er(`ZodMiniNever`,(e,t)=>{Yn.init(e,t),l_.init(e,t)});function b_(e){return _(y_,e)}var x_=er(`ZodMiniArray`,(e,t)=>{vt.init(e,t),l_.init(e,t)});function S_(e,t){return new x_({type:`array`,element:e,...ir(t)})}var C_=er(`ZodMiniObject`,(e,t)=>{dn.init(e,t),l_.init(e,t),S(e,`shape`,e=>e._zod.def.shape,!1)});function w_(e,t){return new C_({type:`object`,shape:e??{},...ir(t)})}function T_(e,t){return new C_({type:`object`,shape:e,catchall:v_(),...ir(t)})}function E_(e,t){return Qe(e,t)}var D_=er(`ZodMiniUnion`,(e,t)=>{Vt.init(e,t),l_.init(e,t)});function O_(e,t){return new D_({type:`union`,options:e,...ir(t)})}var k_=er(`ZodMiniDiscriminatedUnion`,(e,t)=>{Ve.init(e,t),l_.init(e,t)});function A_(e,t,n){return new k_({type:`union`,options:t,discriminator:e,...ir(n)})}var j_=er(`ZodMiniRecord`,(e,t)=>{Gn.init(e,t),l_.init(e,t)});function M_(e,t,n){return!t||!t._zod?new j_({type:`record`,keyType:u_(),valueType:e,...ir(t)}):new j_({type:`record`,keyType:e,valueType:t,...ir(n)})}var N_=er(`ZodMiniEnum`,(e,t)=>{u.init(e,t),l_.init(e,t),e.options=[...e._zod.values]});function P_(e,t){return new N_({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...ir(t)})}var F_=er(`ZodMiniLiteral`,(e,t)=>{Kt.init(e,t),l_.init(e,t)});function I_(e,t){return new F_({type:`literal`,values:Array.isArray(e)?e:[e],...ir(t)})}var L_=er(`ZodMiniTransform`,(e,t)=>{vn.init(e,t),l_.init(e,t)});function R_(e){return new L_({type:`transform`,transform:e})}var z_=er(`ZodMiniOptional`,(e,t)=>{Mt.init(e,t),l_.init(e,t)});function B_(e){return new z_({type:`optional`,innerType:e})}var V_=er(`ZodMiniPipe`,(e,t)=>{jn.init(e,t),l_.init(e,t)});function H_(e,t){return new V_({type:`pipe`,in:e,out:t})}var U_=er(`ZodMiniCustom`,(e,t)=>{St.init(e,t),l_.init(e,t)});function W_(e,t){return le(U_,e??(()=>!0),t)}function G_(e,t={}){return pt(U_,e,t)}var K_=`AI_InvalidArgumentError`,q_=`vercel.ai.error.${K_}`,J_=Symbol.for(q_),Y_=class extends sh{constructor({parameter:e,value:t,message:n}){super({name:K_,message:`Invalid argument for parameter ${e}: ${n}`}),this[J_]=!0,this.parameter=e,this.value=t}static isInstance(e){return sh.hasMarker(e,q_)}},X_=new Map([[`generateObject`,`AISDK_DEP_GENERATE_OBJECT`],[`streamObject`,`AISDK_DEP_STREAM_OBJECT`],[`experimental_generateSpeech`,`AISDK_DEP_EXPERIMENTAL_GENERATE_SPEECH`],[`experimental_transcribe`,`AISDK_DEP_EXPERIMENTAL_TRANSCRIBE`],[`"image" content part`,`AISDK_DEP_IMAGE_CONTENT_PART`],[`"tool-result" content of type "file-data"`,`AISDK_DEP_TOOL_RESULT_FILE_DATA`],[`"tool-result" content of type "file-url"`,`AISDK_DEP_TOOL_RESULT_FILE_URL`],[`"tool-result" content of type "file-id"`,`AISDK_DEP_TOOL_RESULT_FILE_ID`],[`"tool-result" content of type "file-reference"`,`AISDK_DEP_TOOL_RESULT_FILE_REFERENCE`],[`"tool-result" content of type "image-data"`,`AISDK_DEP_TOOL_RESULT_IMAGE_DATA`],[`"tool-result" content of type "image-url"`,`AISDK_DEP_TOOL_RESULT_IMAGE_URL`],[`"tool-result" content of type "image-file-id"`,`AISDK_DEP_TOOL_RESULT_IMAGE_FILE_ID`],[`"tool-result" content of type "image-file-reference"`,`AISDK_DEP_TOOL_RESULT_IMAGE_FILE_REFERENCE`],[`rawInput in output-error UI message parts`,`AISDK_DEP_UI_MESSAGE_RAW_INPUT`]]);function Z_(e){return e.replace(/[^a-zA-Z0-9]/g,e=>`_${e.charCodeAt(0).toString(16).toUpperCase().padStart(4,`0`)}`)}function Q_({setting:e,provider:t}){return t==null?X_.get(e)??`AISDK_DEP_SETTING_${Z_(e)}`:`AISDK_DEP_PROVIDER_${Z_(t)}__${Z_(e)}`}function $_({warning:e,provider:t,model:n}){let r=`AI SDK Warning${t!=null&&n!=null?` (${t} / ${n})`:``}:`;switch(e.type){case`unsupported`:{let t=`${r} The feature "${e.feature}" is not supported.`;return e.details&&(t+=` ${e.details}`),t}case`compatibility`:{let t=`${r} The feature "${e.feature}" is used in a compatibility mode.`;return e.details&&(t+=` ${e.details}`),t}case`deprecated`:return`${r} Deprecated: "${e.setting}". ${e.message}`;case`other`:return`${r} ${e.message}`;default:return`${r} ${JSON.stringify(e,null,2)}`}}var ev=`AI SDK Warning System: To turn off warning logging, set the AI_SDK_LOG_WARNINGS global to false.`,tv=!1,nv=new Set;function rv({message:e,type:t,code:n}){typeof process<`u`&&typeof process.emitWarning==`function`?process.emitWarning(e,n==null?{type:t}:{type:t,code:n}):console.warn(n==null?e:`[${n}] ${e}`)}var iv=e=>{if(e.warnings.length===0)return;let t=globalThis.AI_SDK_LOG_WARNINGS;if(t!==!1){if(typeof t==`function`){t(e);return}tv||(tv=!0,rv({message:ev,type:`Warning`}));for(let t of e.warnings){let n=t.type===`deprecated`?Q_({setting:t.setting,provider:e.provider}):void 0;if(n!=null){if(nv.has(n))continue;nv.add(n)}rv({message:$_({warning:t,provider:e.provider,model:e.model}),type:t.type===`deprecated`?`DeprecationWarning`:`Warning`,code:n})}}};function av(e,t){if(e===void 0&&t===void 0)return;if(e===void 0)return t;if(t===void 0)return e;let n={...e};for(let r in t)if(!(r===`__proto__`||r===`constructor`||r===`prototype`)&&Object.prototype.hasOwnProperty.call(t,r)){let i=t[r];if(i===void 0)continue;let a=r in e?e[r]:void 0,o=typeof i==`object`&&!!i&&!Array.isArray(i)&&!(i instanceof Date)&&!(i instanceof RegExp),s=typeof a==`object`&&!!a&&!Array.isArray(a)&&!(a instanceof Date)&&!(a instanceof RegExp);o&&s?n[r]=av(a,i):n[r]=i}return n}function ov(e,t){return e!=null&&Object.hasOwn(e,t)?e[t]:void 0}function sv(e,t){if(e===t)return!0;if(e==null||t==null)return!1;if(typeof e!=`object`&&typeof t!=`object`)return e===t;if(e.constructor!==t.constructor)return!1;if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if(Array.isArray(e)){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!sv(e[n],t[n]))return!1;return!0}let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let i of n)if(!r.includes(i)||!sv(e[i],t[i]))return!1;return!0}new TextEncoder,new TextEncoder;var cv=`AI_UIMessageStreamError`,lv=`vercel.ai.error.${cv}`,uv=Symbol.for(lv),dv=class extends sh{constructor({chunkType:e,chunkId:t,message:n}){super({name:cv,message:n}),this[uv]=!0,this.chunkType=e,this.chunkId=t}static isInstance(e){return sh.hasMarker(e,lv)}};function fv(e){let t=[`ROOT`],n=-1,r=null,i=0;function a(e){return e>=`0`&&e<=`9`||e>=`A`&&e<=`F`||e>=`a`&&e<=`f`}function o(e,i,a){switch(e){case`"`:n=i,t.pop(),t.push(a),t.push(`INSIDE_STRING`);break;case`f`:case`t`:case`n`:n=i,r=i,t.pop(),t.push(a),t.push(`INSIDE_LITERAL`);break;case`-`:t.pop(),t.push(a),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=i,t.pop(),t.push(a),t.push(`INSIDE_NUMBER`);break;case`{`:n=i,t.pop(),t.push(a),t.push(`INSIDE_OBJECT_START`);break;case`[`:n=i,t.pop(),t.push(a),t.push(`INSIDE_ARRAY_START`)}}function s(e,r){switch(e){case`,`:t.pop(),t.push(`INSIDE_OBJECT_AFTER_COMMA`);break;case`}`:n=r,t.pop()}}function c(e,r){switch(e){case`,`:t.pop(),t.push(`INSIDE_ARRAY_AFTER_COMMA`);break;case`]`:n=r,t.pop()}}for(let l=0;l<e.length;l++){let u=e[l];switch(t[t.length-1]){case`ROOT`:o(u,l,`FINISH`);break;case`INSIDE_OBJECT_START`:switch(u){case`"`:t.pop(),t.push(`INSIDE_OBJECT_KEY`);break;case`}`:n=l,t.pop()}break;case`INSIDE_OBJECT_AFTER_COMMA`:switch(u){case`"`:t.pop(),t.push(`INSIDE_OBJECT_KEY`)}break;case`INSIDE_OBJECT_KEY`:switch(u){case`"`:t.pop(),t.push(`INSIDE_OBJECT_AFTER_KEY`)}break;case`INSIDE_OBJECT_AFTER_KEY`:switch(u){case`:`:t.pop(),t.push(`INSIDE_OBJECT_BEFORE_VALUE`)}break;case`INSIDE_OBJECT_BEFORE_VALUE`:o(u,l,`INSIDE_OBJECT_AFTER_VALUE`);break;case`INSIDE_OBJECT_AFTER_VALUE`:s(u,l);break;case`INSIDE_STRING`:switch(u){case`"`:t.pop(),n=l;break;case`\\`:t.push(`INSIDE_STRING_ESCAPE`);break;default:n=l}break;case`INSIDE_ARRAY_START`:switch(u){case`]`:n=l,t.pop();break;default:o(u,l,`INSIDE_ARRAY_AFTER_VALUE`)}break;case`INSIDE_ARRAY_AFTER_VALUE`:switch(u){case`,`:t.pop(),t.push(`INSIDE_ARRAY_AFTER_COMMA`);break;case`]`:n=l,t.pop();break;default:n=l}break;case`INSIDE_ARRAY_AFTER_COMMA`:o(u,l,`INSIDE_ARRAY_AFTER_VALUE`);break;case`INSIDE_STRING_ESCAPE`:t.pop(),u===`u`?(i=0,t.push(`INSIDE_STRING_UNICODE_ESCAPE`)):n=l;break;case`INSIDE_STRING_UNICODE_ESCAPE`:a(u)&&(i++,i===4&&(t.pop(),n=l));break;case`INSIDE_NUMBER`:switch(u){case`0`:case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:n=l;break;case`e`:case`E`:case`-`:case`.`:break;case`,`:t.pop(),t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&c(u,l),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`&&s(u,l);break;case`}`:t.pop(),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`&&s(u,l);break;case`]`:t.pop(),t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&c(u,l);break;default:t.pop()}break;case`INSIDE_LITERAL`:{let i=e.substring(r,l+1);!`false`.startsWith(i)&&!`true`.startsWith(i)&&!`null`.startsWith(i)?(t.pop(),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`?s(u,l):t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&c(u,l)):n=l;break}}}let l=e.slice(0,n+1);for(let n=t.length-1;n>=0;n--)switch(t[n]){case`INSIDE_STRING`:l+=`"`;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`:l+=`}`;break;case`INSIDE_ARRAY_START`:case`INSIDE_ARRAY_AFTER_COMMA`:case`INSIDE_ARRAY_AFTER_VALUE`:l+=`]`;break;case`INSIDE_LITERAL`:{let t=e.substring(r,e.length);`true`.startsWith(t)?l+=`true`.slice(t.length):`false`.startsWith(t)?l+=`false`.slice(t.length):`null`.startsWith(t)&&(l+=`null`.slice(t.length))}}return l}async function pv(e){if(e===void 0)return{value:void 0,state:`undefined-input`};let t=await o_({text:e});return t.success?{value:t.value,state:`successful-parse`}:(t=await o_({text:fv(e)}),t.success?{value:t.value,state:`repaired-parse`}:{value:void 0,state:`failed-parse`})}qh({prefix:`steer`,size:24}),qh({prefix:`aitxt`,size:24}),qh({prefix:`call`,size:24}),TransformStream;var V={NEVER:fr,array:S_,boolean:g_,custom:W_,discriminatedUnion:A_,enum:P_,extend:E_,int:m_,literal:I_,looseObject:T_,maximum:Ge,minLength:pr,never:b_,nonnegative:ct,number:f_,object:w_,optional:B_,pipe:H_,positive:rt,record:M_,refine:G_,safeParse:an,startsWith:j,string:u_,transform:R_,union:O_,unknown:v_},H={array:Xt,boolean:Dt,custom:Qn,discriminatedUnion:lr,instanceof:yn,lazy:ar,literal:Ye,null:tn,number:tr,object:F,record:C,string:L,union:p,unknown:fn},mv=H.lazy(()=>H.union([H.null(),H.string(),H.number(),H.boolean(),H.record(H.string(),mv.optional()),H.array(mv)])),U=H.record(H.string(),H.record(H.string(),mv.optional()));function hv(e){return V.object({source:V.discriminatedUnion(`sourceType`,[V.object({type:V.literal(`source`),sourceType:V.literal(`url`),id:V.string(),url:V.string(),title:V.optional(V.string()),providerMetadata:V.optional(e)}),V.object({type:V.literal(`source`),sourceType:V.literal(`document`),id:V.string(),mediaType:V.string(),title:V.string(),filename:V.optional(V.string()),providerMetadata:V.optional(e)})]),startIndex:V.optional(V.number().check(V.int()).check(V.nonnegative())),endIndex:V.optional(V.number().check(V.int()).check(V.nonnegative())),citedText:V.optional(V.string())})}var gv=hv(U),_v=V.record(V.string(),V.optional(mv)),vv=Jg(()=>r_(V.union([V.looseObject({type:V.literal(`text-start`),id:V.string(),providerMetadata:V.optional(U)}),V.looseObject({type:V.literal(`text-delta`),id:V.string(),delta:V.string(),providerMetadata:V.optional(U)}),V.looseObject({type:V.literal(`text-end`),id:V.string(),citations:V.optional(V.array(gv)),providerMetadata:V.optional(U)}),V.looseObject({type:V.literal(`error`),errorText:V.string()}),V.looseObject({type:V.literal(`tool-input-start`),toolCallId:V.string(),toolName:V.string(),inputEncoding:V.optional(V.enum([`json`,`text`])),providerExecuted:V.optional(V.boolean()),providerMetadata:V.optional(U),toolMetadata:V.optional(_v),dynamic:V.optional(V.boolean()),title:V.optional(V.string())}),V.looseObject({type:V.literal(`tool-input-delta`),toolCallId:V.string(),inputTextDelta:V.string()}),V.looseObject({type:V.literal(`tool-input-available`),toolCallId:V.string(),toolName:V.string(),input:V.unknown(),providerExecuted:V.optional(V.boolean()),providerMetadata:V.optional(U),toolMetadata:V.optional(_v),dynamic:V.optional(V.boolean()),title:V.optional(V.string())}),V.looseObject({type:V.literal(`tool-input-error`),toolCallId:V.string(),toolName:V.string(),input:V.unknown(),providerExecuted:V.optional(V.boolean()),providerMetadata:V.optional(U),toolMetadata:V.optional(_v),dynamic:V.optional(V.boolean()),errorText:V.string(),title:V.optional(V.string())}),V.looseObject({type:V.literal(`tool-approval-request`),approvalId:V.string(),toolCallId:V.string(),approvalDescriptor:V.optional(V.unknown()),inputSchemaInput:V.optional(V.unknown()),reason:V.optional(V.string()),isAutomatic:V.optional(V.boolean()),signature:V.optional(V.string())}),V.looseObject({type:V.literal(`tool-approval-response`),approvalId:V.string(),approved:V.boolean(),reason:V.optional(V.string()),providerExecuted:V.optional(V.boolean()),providerMetadata:V.optional(U)}),V.looseObject({type:V.literal(`tool-output-available`),toolCallId:V.string(),output:V.unknown(),providerExecuted:V.optional(V.boolean()),providerMetadata:V.optional(U),toolMetadata:V.optional(_v),dynamic:V.optional(V.boolean()),preliminary:V.optional(V.boolean())}),V.looseObject({type:V.literal(`tool-output-error`),toolCallId:V.string(),errorText:V.string(),providerExecuted:V.optional(V.boolean()),providerMetadata:V.optional(U),toolMetadata:V.optional(_v),dynamic:V.optional(V.boolean())}),V.looseObject({type:V.literal(`tool-output-denied`),toolCallId:V.string()}),V.looseObject({type:V.literal(`reasoning-start`),id:V.string(),providerMetadata:V.optional(U)}),V.looseObject({type:V.literal(`reasoning-delta`),id:V.string(),delta:V.string(),providerMetadata:V.optional(U)}),V.looseObject({type:V.literal(`reasoning-end`),id:V.string(),providerMetadata:V.optional(U)}),V.looseObject({type:V.literal(`custom`),kind:V.pipe(V.string(),V.transform(e=>e)),providerMetadata:V.optional(U)}),V.looseObject({type:V.literal(`source-url`),sourceId:V.string(),url:V.string(),title:V.optional(V.string()),providerMetadata:V.optional(U)}),V.looseObject({type:V.literal(`source-document`),sourceId:V.string(),mediaType:V.string(),title:V.string(),filename:V.optional(V.string()),providerMetadata:V.optional(U)}),V.looseObject({type:V.literal(`file`),url:V.string(),mediaType:V.string(),providerMetadata:V.optional(U)}),V.looseObject({type:V.literal(`reasoning-file`),url:V.string(),mediaType:V.string(),providerMetadata:V.optional(U)}),V.looseObject({type:V.literal(`steering-message`),id:V.string(),parts:V.array(V.union([V.looseObject({type:V.literal(`text`),text:V.string(),providerMetadata:V.optional(U)}),V.looseObject({type:V.literal(`file`),mediaType:V.string(),url:V.string(),filename:V.optional(V.string()),providerReference:V.optional(V.record(V.string(),V.string())),providerMetadata:V.optional(U)})]))}),V.looseObject({type:V.custom(e=>typeof e==`string`&&e.startsWith(`data-`),{message:`Type must start with "data-"`}),id:V.optional(V.string()),data:V.unknown(),transient:V.optional(V.boolean())}),V.looseObject({type:V.literal(`start-step`)}),V.looseObject({type:V.literal(`finish-step`)}),V.looseObject({type:V.literal(`reset-step`)}),V.looseObject({type:V.literal(`start`),messageId:V.optional(V.string()),messageMetadata:V.optional(V.unknown())}),V.looseObject({type:V.literal(`finish`),finishReason:V.optional(V.enum([`stop`,`length`,`content-filter`,`tool-calls`,`error`,`interrupted`,`other`])),messageMetadata:V.optional(V.unknown())}),V.looseObject({type:V.literal(`abort`),reason:V.optional(V.string())}),V.looseObject({type:V.literal(`message-metadata`),messageMetadata:V.unknown()})])));function yv(e){return e.type.startsWith(`data-`)}function bv(){return Object.create(null)}function xv(e){return e.type===`text`}function Sv(e){return e.type===`reasoning`}function Cv(e){return e.type.startsWith(`tool-`)}function wv(e){return e.type===`dynamic-tool`}function Tv(e){return Cv(e)||wv(e)}function Ev(e){return e.type.split(`-`).slice(1).join(`-`)}function Dv(e){return wv(e)?e.toolName:Ev(e)}function Ov({lastMessage:e,messageId:t}){let n=e?.role===`assistant`?e:{id:t,metadata:void 0,role:`assistant`,parts:[]},r=bv(),i=n.parts.findLastIndex(e=>e.type===`step-start`),a=0;for(let e of n.parts.slice(i+1)){if(!Tv(e))continue;let t=a;Cv(e)&&a++,e.state===`input-streaming`&&(r[e.toolCallId]={text:e.rawInput??``,inputEncoding:e.inputEncoding,index:t,toolName:e.type===`dynamic-tool`?e.toolName:Ev(e),dynamic:e.type===`dynamic-tool`,title:e.title,toolMetadata:e.toolMetadata})}return{message:n,activeTextParts:bv(),activeReasoningParts:bv(),partialToolCalls:r}}function kv({stream:e,messageMetadataSchema:t,dataPartSchemas:n,runUpdateMessageJob:r,onError:i,onToolCall:a,onData:o,resetStateOnMessageIdChange:s=!1,resetStateOnFirstMessageStart:c=!1}){let l=!0;return e.pipeThrough(new TransformStream({async transform(e,u){await r(async({state:r,write:d})=>{function f(){let e=r.message.parts,t=e.length-1;for(;t>=0&&e[t].type!==`step-start`;)t--;return e.slice(t+1)}function p(){return f().filter(Tv)}function m(e){let t=p().find(t=>t.toolCallId===e);if(t==null){let n=r.message.parts;for(let r=n.length-1;r>=0;r--){let i=n[r];if(Tv(i)&&i.toolCallId===e){t=i;break}}}if(t==null)throw new dv({chunkType:`tool-invocation`,chunkId:e,message:`No tool invocation found for tool call ID "${e}".`});return t}function h(e){let t=r.message.parts.filter(Tv).find(t=>t.approval?.id===e);if(t==null)throw new dv({chunkType:`tool-approval-response`,chunkId:e,message:`No tool invocation found for approval ID "${e}".`});return t}function g(e,t){let n=t??f().find(t=>Cv(t)&&t.toolCallId===e.toolCallId),i=e,a=n;if(n!=null){n.state=e.state,a.type=`tool-${e.toolName}`,a.input=i.input,a.output=i.output,a.errorText=i.errorText,a.rawInput=i.rawInput,i.inputEncoding==null?delete a.inputEncoding:a.inputEncoding=i.inputEncoding,a.preliminary=i.preliminary,e.title!==void 0&&(a.title=e.title),e.toolMetadata!==void 0&&(a.toolMetadata=e.toolMetadata),a.providerExecuted=i.providerExecuted??n.providerExecuted;let t=i.providerMetadata;if(t!=null)if(e.state===`output-available`||e.state===`output-error`){let e=n;e.resultProviderMetadata=t}else n.callProviderMetadata=t}else r.message.parts.push({type:`tool-${e.toolName}`,toolCallId:e.toolCallId,state:e.state,title:e.title,...e.toolMetadata===void 0?{}:{toolMetadata:e.toolMetadata},input:i.input,...i.inputEncoding==null?{}:{inputEncoding:i.inputEncoding},output:i.output,rawInput:i.rawInput,errorText:i.errorText,providerExecuted:i.providerExecuted,preliminary:i.preliminary,...i.providerMetadata!=null&&(e.state===`output-available`||e.state===`output-error`)?{resultProviderMetadata:i.providerMetadata}:{},...i.providerMetadata!=null&&!(e.state===`output-available`||e.state===`output-error`)?{callProviderMetadata:i.providerMetadata}:{}})}function _(e,t){let n=t??f().find(t=>t.type===`dynamic-tool`&&t.toolCallId===e.toolCallId),i=e,a=n;if(n!=null){n.state=e.state,a.toolName=e.toolName,a.input=i.input,a.output=i.output,a.errorText=i.errorText,a.rawInput=i.rawInput,i.inputEncoding==null?delete a.inputEncoding:a.inputEncoding=i.inputEncoding,a.preliminary=i.preliminary,e.title!==void 0&&(a.title=e.title),e.toolMetadata!==void 0&&(a.toolMetadata=e.toolMetadata),a.providerExecuted=i.providerExecuted??n.providerExecuted;let t=i.providerMetadata;if(t!=null)if(e.state===`output-available`||e.state===`output-error`){let e=n;e.resultProviderMetadata=t}else n.callProviderMetadata=t}else r.message.parts.push({type:`dynamic-tool`,toolName:e.toolName,toolCallId:e.toolCallId,state:e.state,input:i.input,...i.inputEncoding==null?{}:{inputEncoding:i.inputEncoding},output:i.output,errorText:i.errorText,preliminary:i.preliminary,providerExecuted:i.providerExecuted,title:e.title,...e.toolMetadata===void 0?{}:{toolMetadata:e.toolMetadata},...i.providerMetadata!=null&&(e.state===`output-available`||e.state===`output-error`)?{resultProviderMetadata:i.providerMetadata}:{},...i.providerMetadata!=null&&!(e.state===`output-available`||e.state===`output-error`)?{callProviderMetadata:i.providerMetadata}:{}})}async function v(e){if(e!=null){let n=r.message.metadata==null?e:av(r.message.metadata,e);t!=null&&await i_({value:n,schema:t,context:{field:`message.metadata`,entityId:r.message.id}}),r.message.metadata=n}}switch(e.type){case`text-start`:{let t={type:`text`,text:``,providerMetadata:e.providerMetadata,state:`streaming`};r.activeTextParts[e.id]=t,r.message.parts.push(t),d();break}case`text-delta`:{let t=r.activeTextParts[e.id];if(t==null)throw new dv({chunkType:`text-delta`,chunkId:e.id,message:`Received text-delta for missing text part with ID "${e.id}". Ensure a "text-start" chunk is sent before any "text-delta" chunks.`});t.text+=e.delta,t.providerMetadata=e.providerMetadata??t.providerMetadata,d();break}case`text-end`:{let t=r.activeTextParts[e.id];if(t==null)throw new dv({chunkType:`text-end`,chunkId:e.id,message:`Received text-end for missing text part with ID "${e.id}". Ensure a "text-start" chunk is sent before any "text-end" chunks.`});t.state=`done`,e.citations!=null&&(t.citations=e.citations),t.providerMetadata=e.providerMetadata??t.providerMetadata,delete r.activeTextParts[e.id],d();break}case`custom`:{let t={type:`custom`,kind:e.kind,providerMetadata:e.providerMetadata};r.message.parts.push(t),d();break}case`reasoning-start`:{let t={type:`reasoning`,id:e.id,text:``,providerMetadata:e.providerMetadata,state:`streaming`};r.activeReasoningParts[e.id]=t,r.message.parts.push(t),d();break}case`reasoning-delta`:{let t=r.activeReasoningParts[e.id];if(t==null)throw new dv({chunkType:`reasoning-delta`,chunkId:e.id,message:`Received reasoning-delta for missing reasoning part with ID "${e.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-delta" chunks.`});t.text+=e.delta,t.providerMetadata=e.providerMetadata??t.providerMetadata,d();break}case`reasoning-end`:{let t=r.activeReasoningParts[e.id];if(t==null)throw new dv({chunkType:`reasoning-end`,chunkId:e.id,message:`Received reasoning-end for missing reasoning part with ID "${e.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-end" chunks.`});t.providerMetadata=e.providerMetadata??t.providerMetadata,t.state=`done`,delete r.activeReasoningParts[e.id],d();break}case`file`:case`reasoning-file`:r.message.parts.push({type:e.type,mediaType:e.mediaType,url:e.url,...e.providerMetadata==null?{}:{providerMetadata:e.providerMetadata}}),d();break;case`source-url`:r.message.parts.push({type:`source-url`,sourceId:e.sourceId,url:e.url,title:e.title,providerMetadata:e.providerMetadata}),d();break;case`source-document`:r.message.parts.push({type:`source-document`,sourceId:e.sourceId,mediaType:e.mediaType,title:e.title,filename:e.filename,providerMetadata:e.providerMetadata}),d();break;case`tool-input-start`:{let t=f().filter(Cv);r.partialToolCalls[e.toolCallId]={text:``,inputEncoding:e.inputEncoding,toolName:e.toolName,index:t.length,dynamic:e.dynamic,title:e.title,toolMetadata:e.toolMetadata},e.dynamic?_({toolCallId:e.toolCallId,toolName:e.toolName,state:`input-streaming`,inputEncoding:e.inputEncoding,input:void 0,providerExecuted:e.providerExecuted,title:e.title,toolMetadata:e.toolMetadata,providerMetadata:e.providerMetadata}):g({toolCallId:e.toolCallId,toolName:e.toolName,state:`input-streaming`,inputEncoding:e.inputEncoding,input:void 0,providerExecuted:e.providerExecuted,title:e.title,toolMetadata:e.toolMetadata,providerMetadata:e.providerMetadata}),d();break}case`tool-input-delta`:{let t=r.partialToolCalls[e.toolCallId];if(t==null)throw new dv({chunkType:`tool-input-delta`,chunkId:e.toolCallId,message:`Received tool-input-delta for missing tool call with ID "${e.toolCallId}". Ensure a "tool-input-start" chunk is sent before any "tool-input-delta" chunks.`});t.text+=e.inputTextDelta;let n=t.inputEncoding===`text`?t.text:(await pv(t.text)).value;t.dynamic?_({toolCallId:e.toolCallId,toolName:t.toolName,state:`input-streaming`,inputEncoding:t.inputEncoding,input:n,rawInput:t.text,title:t.title,toolMetadata:t.toolMetadata}):g({toolCallId:e.toolCallId,toolName:t.toolName,state:`input-streaming`,inputEncoding:t.inputEncoding,input:n,rawInput:t.text,title:t.title,toolMetadata:t.toolMetadata}),d();break}case`tool-input-available`:e.dynamic?_({toolCallId:e.toolCallId,toolName:e.toolName,state:`input-available`,input:e.input,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,title:e.title,toolMetadata:e.toolMetadata}):g({toolCallId:e.toolCallId,toolName:e.toolName,state:`input-available`,input:e.input,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,title:e.title,toolMetadata:e.toolMetadata}),d(),a&&!e.providerExecuted&&await a({toolCall:e});break;case`tool-input-error`:{let t=f().filter(Tv).find(t=>t.toolCallId===e.toolCallId);(t==null?e.dynamic:t.type===`dynamic-tool`)?_({toolCallId:e.toolCallId,toolName:e.toolName,state:`output-error`,input:e.input,errorText:e.errorText,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,toolMetadata:e.toolMetadata}):g({toolCallId:e.toolCallId,toolName:e.toolName,state:`output-error`,input:e.input,errorText:e.errorText,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,toolMetadata:e.toolMetadata}),d();break}case`tool-approval-request`:{let t=m(e.toolCallId);t.state=`approval-requested`,t.approval={id:e.approvalId,...e.approvalDescriptor==null?{}:{descriptor:e.approvalDescriptor},...Object.prototype.hasOwnProperty.call(e,`inputSchemaInput`)?{inputSchemaInput:e.inputSchemaInput}:{},...e.reason==null?{}:{requestReason:e.reason},...e.isAutomatic===!0?{isAutomatic:!0}:{},...e.signature==null?{}:{signature:e.signature}},d();break}case`tool-approval-response`:{let t=h(e.approvalId),n=t.approval==null?{id:e.approvalId}:t.approval;t.state=`approval-responded`,t.approval={...n,id:e.approvalId,approved:e.approved,...e.reason==null?{}:{reason:e.reason}},e.providerExecuted!=null&&(t.providerExecuted=e.providerExecuted),e.providerMetadata!=null&&(t.callProviderMetadata=e.providerMetadata),d();break}case`tool-output-denied`:{let t=m(e.toolCallId);t.state=`output-denied`,d();break}case`tool-output-available`:{let t=m(e.toolCallId);t.type===`dynamic-tool`?_({toolCallId:e.toolCallId,toolName:t.toolName,state:`output-available`,input:t.input,output:e.output,preliminary:e.preliminary,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,title:t.title,toolMetadata:e.toolMetadata??t.toolMetadata},t):g({toolCallId:e.toolCallId,toolName:Ev(t),state:`output-available`,input:t.input,output:e.output,providerExecuted:e.providerExecuted,preliminary:e.preliminary,providerMetadata:e.providerMetadata,title:t.title,toolMetadata:e.toolMetadata??t.toolMetadata},t),d();break}case`tool-output-error`:{let t=m(e.toolCallId);t.type===`dynamic-tool`?_({toolCallId:e.toolCallId,toolName:t.toolName,state:`output-error`,input:t.input,errorText:e.errorText,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,title:t.title,toolMetadata:e.toolMetadata??t.toolMetadata},t):g({toolCallId:e.toolCallId,toolName:Ev(t),state:`output-error`,input:t.input,rawInput:t.rawInput,errorText:e.errorText,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,title:t.title,toolMetadata:e.toolMetadata??t.toolMetadata},t),d();break}case`steering-message`:r.message.parts.push({type:`steering-message`,id:e.id,parts:e.parts}),d();break;case`start-step`:r.message.parts.push({type:`step-start`});break;case`finish-step`:break;case`reset-step`:{let e=f();r.activeTextParts=bv(),r.activeReasoningParts=bv(),r.partialToolCalls=bv(),e.length>0&&(r.message.parts.splice(r.message.parts.length-e.length,e.length),d());break}case`start`:{let t=c&&l||s&&e.messageId!=null&&e.messageId!==r.message.id;l=!1,t&&Object.assign(r,Ov({lastMessage:void 0,messageId:e.messageId??r.message.id}),{finishReason:void 0}),e.messageId!=null&&(r.message.id=e.messageId),await v(e.messageMetadata),(t||e.messageId!=null||e.messageMetadata!=null)&&d({updateStatus:!1});break}case`finish`:e.finishReason!=null&&(r.finishReason=e.finishReason),await v(e.messageMetadata),e.messageMetadata!=null&&d();break;case`message-metadata`:await v(e.messageMetadata),e.messageMetadata!=null&&d();break;case`error`:i?.(Error(e.errorText));break;default:if(yv(e)){let t=n?.[e.type.slice(5)];if(t!=null){let n=r.message.parts.findIndex(t=>`id`in t&&`data`in t&&t.id===e.id&&t.type===e.type),i=n>=0?n:r.message.parts.length;await i_({value:e.data,schema:t,context:{field:`message.parts[${i}].data`,entityName:e.type,entityId:e.id}})}let i=e;if(i.transient){o?.(i);break}let a=i.id==null?void 0:r.message.parts.find(e=>i.type===e.type&&i.id===e.id);a==null?r.message.parts.push(i):a.data=i.data,o?.(i),d()}}u.enqueue(e)})}}))}async function Av({stream:e,onError:t,abortSignal:n}){let r=e.getReader(),i=()=>{r.cancel().catch(()=>{})};n?.aborted?i():n?.addEventListener(`abort`,i,{once:!0});try{for(;;){let{done:e}=await r.read();if(e)break}}catch(e){t?.(e)}finally{n?.removeEventListener(`abort`,i),r.releaseLock()}}function jv(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}qh({prefix:`aitxt`,size:24}),qh({prefix:`call`,size:24}),qh({prefix:`aitxt`,size:24}),qh({prefix:`call`,size:24});function Mv(e){return e.dynamic=!1,e}var Nv={type:`deprecated`,setting:`rawInput in output-error UI message parts`,message:`Use the "input" field instead. The "rawInput" field will be removed in the next major version.`};function Pv(e){e.some(e=>e.parts.some(e=>typeof e==`object`&&!!e&&`type`in e&&typeof e.type==`string`&&(e.type===`dynamic-tool`||e.type.startsWith(`tool-`))&&`state`in e&&e.state===`output-error`&&Object.prototype.hasOwnProperty.call(e,`rawInput`)&&`rawInput`in e&&e.rawInput!==void 0))&&iv({warnings:[Nv]})}var Fv=Symbol(`invalid`);function Iv(e){let t=[],n=Lv(e,t,new Set);return n===Fv?{success:!1,path:t}:{success:!0,value:n}}function Lv(e,t,n){switch(typeof e){case`string`:case`boolean`:return e;case`number`:return Number.isFinite(e)?e:Fv;case`object`:{if(e===null)return e;if(n.has(e))return Fv;n.add(e);let r=Array.isArray(e)?Rv(e,t,n):zv(e,t,n);return n.delete(e),r}default:return Fv}}function Rv(e,t,n){let r;for(let i=0;i<e.length;i++){let a=e[i];t.push(i);let o=Lv(a,t,n);if(o===Fv)return Fv;t.pop(),r==null?o!==a&&(r=e.slice(0,i),r.push(o)):r.push(o)}return r??e}function zv(e,t,n){if(!Vv(e)||Hv(e))return Fv;let r=Object.keys(e),i;for(let a=0;a<r.length;a++){let o=r[a];if(o===`__proto__`){i??=Bv(e,r,a);continue}let s=e[o],c=s;if(s!==void 0){if(t.push(o),c=Lv(s,t,n),c===Fv)return Fv;t.pop()}i==null?c!==s&&(i=Bv(e,r,a),i[o]=c):i[o]=c}return i??e}function Bv(e,t,n){let r={};for(let i=0;i<n;i++)r[t[i]]=e[t[i]];return r}function Vv(e){let t=e.constructor;if(typeof t!=`function`)return!0;let n=t.prototype;return typeof n==`object`&&!!n&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)}function Hv(e){let t=Object.getOwnPropertySymbols(e);for(let n=0;n<t.length;n++)if(Object.prototype.propertyIsEnumerable.call(e,t[n]))return!0;return!1}var Uv=V.pipe(V.unknown(),V.transform((e,t)=>{let n=Iv(e);return n.success?n.value:(t.issues.push({code:`custom`,message:`Invalid JSON value. Expected null, a string, a finite number, a boolean, an array, or an object.`,input:e,path:n.path}),V.NEVER)})),Wv=V.custom(),Gv=V.pipe(Uv,V.record(V.string(),Wv)),Kv=V.pipe(Uv,V.record(V.string(),V.record(V.string(),Wv))),qv=V.record(V.string(),V.string()),Jv=hv(Kv);function Yv(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.keys(e).length===0}function Xv(e){let{type:t,...n}=e;return Mv({...n,type:`dynamic-tool`,toolName:t.slice(5)})}function Zv(e){return e.approval!=null&&Object.prototype.hasOwnProperty.call(e.approval,`inputSchemaInput`)?{value:e.approval.inputSchemaInput}:void 0}function Qv(e){return V.pipe(V.array(V.unknown()),V.transform((t,n)=>{let r=[];for(let[i,a]of t.entries()){let t=V.safeParse(e(a),a);if(!t.success){for(let e of t.error.issues)n.issues.push({...e,path:[i,...e.path]});return V.NEVER}r.push(t.data)}return r}))}var $v=Jg(()=>{let e=V.object({id:V.string(),approved:V.optional(V.never()),descriptor:V.optional(V.unknown()),requestReason:V.optional(V.string()),reason:V.optional(V.never()),isAutomatic:V.optional(V.boolean()),signature:V.optional(V.string()),inputSchemaInput:V.optional(V.unknown())}),t=V.extend(e,{approved:V.boolean(),reason:V.optional(V.string())}),n=V.extend(t,{approved:V.literal(!0)}),r=V.extend(t,{approved:V.literal(!1)}),i=V.discriminatedUnion(`type`,[V.object({type:V.literal(`text`),text:V.string(),providerMetadata:V.optional(Kv)}),V.object({type:V.literal(`file`),mediaType:V.string(),filename:V.optional(V.string()),url:V.string(),providerReference:V.optional(qv),providerMetadata:V.optional(Kv)})]),a=V.discriminatedUnion(`type`,[V.object({type:V.literal(`text`),text:V.string(),citations:V.optional(Qv(()=>Jv)),state:V.optional(V.enum([`streaming`,`done`])),providerMetadata:V.optional(Kv)}),V.object({type:V.literal(`reasoning`),id:V.optional(V.string()),text:V.string(),state:V.optional(V.enum([`streaming`,`done`])),providerMetadata:V.optional(Kv)}),V.object({type:V.literal(`custom`),kind:V.string(),providerMetadata:V.optional(Kv)}),V.object({type:V.literal(`source-url`),sourceId:V.string(),url:V.string(),title:V.optional(V.string()),providerMetadata:V.optional(Kv)}),V.object({type:V.literal(`source-document`),sourceId:V.string(),mediaType:V.string(),title:V.string(),filename:V.optional(V.string()),providerMetadata:V.optional(Kv)}),V.object({type:V.literal(`file`),mediaType:V.string(),filename:V.optional(V.string()),url:V.string(),providerReference:V.optional(qv),providerMetadata:V.optional(Kv)}),V.object({type:V.literal(`reasoning-file`),mediaType:V.string(),url:V.string(),providerMetadata:V.optional(Kv)}),V.object({type:V.literal(`steering-message`),id:V.string(),parts:Qv(()=>i)}),V.object({type:V.literal(`step-start`)})],{error:e=>e.code===`invalid_union`?`Invalid UI message part type. Expected a known part type (for example "text" or "dynamic-tool") or a type starting with "data-" or "tool-".`:void 0}),o=V.object({type:V.string().check(V.startsWith(`data-`)),id:V.optional(V.string()),data:V.unknown()}),s=V.discriminatedUnion(`state`,[V.object({type:V.literal(`dynamic-tool`),dynamic:V.optional(V.literal(!1)),toolName:V.string(),toolCallId:V.string(),title:V.optional(V.string()),toolMetadata:V.optional(Gv),state:V.literal(`input-streaming`),input:V.optional(V.unknown()),rawInput:V.optional(V.string()),inputEncoding:V.optional(V.enum([`json`,`text`])),providerExecuted:V.optional(V.boolean()),callProviderMetadata:V.optional(Kv),output:V.optional(V.never()),errorText:V.optional(V.never()),approval:V.optional(V.never())}),V.object({type:V.literal(`dynamic-tool`),dynamic:V.optional(V.literal(!1)),toolName:V.string(),toolCallId:V.string(),title:V.optional(V.string()),toolMetadata:V.optional(Gv),state:V.literal(`input-available`),input:V.unknown(),providerExecuted:V.optional(V.boolean()),output:V.optional(V.never()),errorText:V.optional(V.never()),callProviderMetadata:V.optional(Kv),approval:V.optional(V.never())}),V.object({type:V.literal(`dynamic-tool`),dynamic:V.optional(V.literal(!1)),toolName:V.string(),toolCallId:V.string(),title:V.optional(V.string()),toolMetadata:V.optional(Gv),state:V.literal(`approval-requested`),input:V.unknown(),providerExecuted:V.optional(V.boolean()),output:V.optional(V.never()),errorText:V.optional(V.never()),callProviderMetadata:V.optional(Kv),approval:e}),V.object({type:V.literal(`dynamic-tool`),dynamic:V.optional(V.literal(!1)),toolName:V.string(),toolCallId:V.string(),title:V.optional(V.string()),toolMetadata:V.optional(Gv),state:V.literal(`approval-responded`),input:V.unknown(),providerExecuted:V.optional(V.boolean()),output:V.optional(V.never()),errorText:V.optional(V.never()),callProviderMetadata:V.optional(Kv),approval:t}),V.object({type:V.literal(`dynamic-tool`),dynamic:V.optional(V.literal(!1)),toolName:V.string(),toolCallId:V.string(),title:V.optional(V.string()),toolMetadata:V.optional(Gv),state:V.literal(`output-available`),input:V.unknown(),providerExecuted:V.optional(V.boolean()),output:V.unknown(),errorText:V.optional(V.never()),callProviderMetadata:V.optional(Kv),resultProviderMetadata:V.optional(Kv),preliminary:V.optional(V.boolean()),approval:V.optional(n)}),V.object({type:V.literal(`dynamic-tool`),dynamic:V.optional(V.literal(!1)),toolName:V.string(),toolCallId:V.string(),title:V.optional(V.string()),toolMetadata:V.optional(Gv),state:V.literal(`output-error`),input:V.optional(V.unknown()),rawInput:V.optional(V.unknown()),providerExecuted:V.optional(V.boolean()),output:V.optional(V.never()),errorText:V.string(),callProviderMetadata:V.optional(Kv),resultProviderMetadata:V.optional(Kv),approval:V.optional(n)}),V.object({type:V.literal(`dynamic-tool`),dynamic:V.optional(V.literal(!1)),toolName:V.string(),toolCallId:V.string(),title:V.optional(V.string()),toolMetadata:V.optional(Gv),state:V.literal(`output-denied`),input:V.unknown(),providerExecuted:V.optional(V.boolean()),output:V.optional(V.never()),errorText:V.optional(V.never()),callProviderMetadata:V.optional(Kv),approval:r})]),c=V.discriminatedUnion(`state`,[V.object({type:V.string().check(V.startsWith(`tool-`)),toolCallId:V.string(),title:V.optional(V.string()),toolMetadata:V.optional(Gv),state:V.literal(`input-streaming`),providerExecuted:V.optional(V.boolean()),callProviderMetadata:V.optional(Kv),input:V.optional(V.unknown()),rawInput:V.optional(V.string()),inputEncoding:V.optional(V.enum([`json`,`text`])),output:V.optional(V.never()),errorText:V.optional(V.never()),approval:V.optional(V.never())}),V.object({type:V.string().check(V.startsWith(`tool-`)),toolCallId:V.string(),title:V.optional(V.string()),toolMetadata:V.optional(Gv),state:V.literal(`input-available`),providerExecuted:V.optional(V.boolean()),input:V.unknown(),output:V.optional(V.never()),errorText:V.optional(V.never()),callProviderMetadata:V.optional(Kv),approval:V.optional(V.never())}),V.object({type:V.string().check(V.startsWith(`tool-`)),toolCallId:V.string(),title:V.optional(V.string()),toolMetadata:V.optional(Gv),state:V.literal(`approval-requested`),input:V.unknown(),providerExecuted:V.optional(V.boolean()),output:V.optional(V.never()),errorText:V.optional(V.never()),callProviderMetadata:V.optional(Kv),approval:e}),V.object({type:V.string().check(V.startsWith(`tool-`)),toolCallId:V.string(),title:V.optional(V.string()),toolMetadata:V.optional(Gv),state:V.literal(`approval-responded`),input:V.unknown(),providerExecuted:V.optional(V.boolean()),output:V.optional(V.never()),errorText:V.optional(V.never()),callProviderMetadata:V.optional(Kv),approval:t}),V.object({type:V.string().check(V.startsWith(`tool-`)),toolCallId:V.string(),title:V.optional(V.string()),toolMetadata:V.optional(Gv),state:V.literal(`output-available`),providerExecuted:V.optional(V.boolean()),input:V.unknown(),output:V.unknown(),errorText:V.optional(V.never()),callProviderMetadata:V.optional(Kv),resultProviderMetadata:V.optional(Kv),preliminary:V.optional(V.boolean()),approval:V.optional(n)}),V.object({type:V.string().check(V.startsWith(`tool-`)),toolCallId:V.string(),title:V.optional(V.string()),toolMetadata:V.optional(Gv),state:V.literal(`output-error`),providerExecuted:V.optional(V.boolean()),input:V.optional(V.unknown()),rawInput:V.optional(V.unknown()),output:V.optional(V.never()),errorText:V.string(),callProviderMetadata:V.optional(Kv),resultProviderMetadata:V.optional(Kv),approval:V.optional(n)}),V.object({type:V.string().check(V.startsWith(`tool-`)),toolCallId:V.string(),title:V.optional(V.string()),toolMetadata:V.optional(Gv),state:V.literal(`output-denied`),providerExecuted:V.optional(V.boolean()),input:V.unknown(),output:V.optional(V.never()),errorText:V.optional(V.never()),callProviderMetadata:V.optional(Kv),approval:r})]),l=V.object({id:V.string(),role:V.enum([`system`,`user`,`assistant`]),metadata:V.optional(V.unknown()),parts:Qv(e=>{let t=e?.type;if(typeof t==`string`){if(t.startsWith(`data-`))return o;if(t.startsWith(`tool-`))return c;if(t===`dynamic-tool`)return s}return a})}).check(e=>{let t=e.value;t.role!==`assistant`&&t.parts.length===0&&e.issues.push({continue:!0,origin:`array`,code:`too_small`,minimum:1,inclusive:!0,input:t.parts,path:[`parts`],message:`Message must contain at least one part`})});return r_(Qv(()=>l).check(V.minLength(1,`Messages array must not be empty`)))});async function ey({messages:e,metadataSchema:t,dataSchemas:n,tools:r,experimental_refineToolInput:i},{convertMissingTerminalToolsToDynamic:a}){try{if(e==null)return{success:!1,error:new Y_({parameter:`messages`,value:e,message:`messages parameter must be provided`})};let o=await i_({value:e,schema:$v});if(Pv(o),t)for(let[e,n]of o.entries())n.metadata=await i_({value:n.metadata,schema:t,context:{field:`messages[${e}].metadata`,entityId:n.id}});let s=r!=null||a;if(n||s)for(let[e,t]of o.entries())for(let[o,c]of t.parts.entries()){if(n&&c.type.startsWith(`data-`)){let t=c,r=t.type.slice(5),i=n[r];if(!i)return{success:!1,error:new Oh({value:t.data,cause:`No data schema found for data part ${r}`,context:{field:`messages[${e}].parts[${o}].data`,entityName:r,entityId:t.id}})};t.data=await i_({value:t.data,schema:i,context:{field:`messages[${e}].parts[${o}].data`,entityName:r,entityId:t.id}})}if(s&&c.type.startsWith(`tool-`)){let n=c,s=n.type.slice(5),l=r==null?void 0:ov(r,s),u=n.state===`output-available`||n.state===`output-error`||n.state===`output-denied`;if(!l&&u){(r!=null||a)&&(t.parts[o]=Xv(n));continue}if(!l)return{success:!1,error:new Oh({value:n.input,cause:`No tool schema found for tool part ${s}`,context:{field:`messages[${e}].parts[${o}].input`,entityName:s,entityId:n.toolCallId}})};let d={field:`messages[${e}].parts[${o}].input`,entityName:s,entityId:n.toolCallId},f=Zv(n),p=f==null?n.input:f.value,m=!1;if(n.state!==`input-streaming`&&(n.state!==`output-error`||f!=null||n.input!==void 0)){let e=await a_({value:p,schema:l.inputSchema,context:d}),t;if(!e.success)t=e.error;else if(f!=null)try{let r=ov(i,s);sv(r==null?e.value:await r(e.value),n.input)||(t=new Oh({value:n.input,cause:`Tool input does not match the output reconstructed from inputSchemaInput.`,context:d}))}catch(e){t=new Oh({value:p,cause:e,context:d})}if(t!=null)if(n.state===`output-error`||n.state===`output-available`&&Yv(n.input))m=!0;else throw t}n.state===`output-available`&&l.outputSchema&&await i_({value:n.output,schema:l.outputSchema,context:{field:`messages[${e}].parts[${o}].output`,entityName:s,entityId:n.toolCallId}}),m&&(t.parts[o]=Xv(n))}}return{success:!0,data:o}}catch(e){return{success:!1,error:e}}}async function ty(e){return ey(e,{convertMissingTerminalToolsToDynamic:!1})}async function ny(e){let t=await ty(e);if(!t.success)throw t.error;return t.data}qh({prefix:`call`,size:24}),qh({prefix:`call`,size:24}),new TextEncoder,qh({prefix:`call`,size:24}),qh({prefix:`call`,size:24}),qh({prefix:`aiobj`,size:24});var{atob:yee}=globalThis,ry=class{constructor(){this.queue=[],this.isProcessing=!1,this.idleWaiters=[]}async processQueue(){if(!this.isProcessing){this.isProcessing=!0;try{for(;this.queue.length>0;)await this.queue[0](),this.queue.shift()}finally{this.isProcessing=!1;for(let e of this.idleWaiters.splice(0))e()}}}async run(e){return new Promise((t,n)=>{this.queue.push(async()=>{try{await e(),t()}catch(e){n(e)}}),this.processQueue()})}async waitForIdle(){!this.isProcessing&&this.queue.length===0||await new Promise(e=>{this.idleWaiters.push(e)})}};qh({prefix:`aiobj`,size:24}),qh({prefix:`call`,size:24});var iy=H.union([H.string(),H.custom(Wh,{message:`Must be a Uint8Array`}),H.custom(Gh,{message:`Must be an ArrayBuffer`}),H.custom(see,{message:`Must be a Buffer`})]),ay=H.record(H.string(),H.string()),oy=H.object({type:H.literal(`text`),text:H.string(),providerOptions:U.optional()}),sy=H.object({type:H.literal(`image`),image:H.union([iy,H.instanceof(URL),ay]),mediaType:H.string().optional(),providerOptions:U.optional()}),cy=H.discriminatedUnion(`type`,[H.object({type:H.literal(`data`),data:iy}),H.object({type:H.literal(`url`),url:H.instanceof(URL)}),H.object({type:H.literal(`reference`),reference:ay}),H.object({type:H.literal(`text`),text:H.string()})]),ly=H.discriminatedUnion(`type`,[H.object({type:H.literal(`data`),data:iy}),H.object({type:H.literal(`url`),url:H.instanceof(URL)})]),uy=H.object({type:H.literal(`file`),data:H.union([cy,iy,H.instanceof(URL),ay]),filename:H.string().optional(),mediaType:H.string(),providerOptions:U.optional()}),dy=H.object({type:H.literal(`reasoning`),text:H.string(),providerOptions:U.optional()}),fy=H.object({type:H.literal(`custom`),kind:H.string().transform(e=>e),providerOptions:U.optional()}),py=H.object({type:H.literal(`reasoning-file`),data:H.union([ly,iy,H.instanceof(URL)]),mediaType:H.string(),providerOptions:U.optional()}),my=H.object({type:H.literal(`tool-call`),toolCallId:H.string(),toolName:H.string(),input:H.unknown(),providerOptions:U.optional(),providerExecuted:H.boolean().optional()}),hy=H.discriminatedUnion(`type`,[H.object({type:H.literal(`text`),value:H.string(),providerOptions:U.optional()}),H.object({type:H.literal(`json`),value:mv,providerOptions:U.optional()}),H.object({type:H.literal(`execution-denied`),reason:H.string().optional(),providerOptions:U.optional()}),H.object({type:H.literal(`error-text`),value:H.string(),providerOptions:U.optional()}),H.object({type:H.literal(`error-json`),value:mv,providerOptions:U.optional()}),H.object({type:H.literal(`content`),value:H.array(H.union([H.object({type:H.literal(`text`),text:H.string(),providerOptions:U.optional()}),H.object({type:H.literal(`file`),data:cy,mediaType:H.string(),filename:H.string().optional(),providerOptions:U.optional()}),H.object({type:H.literal(`file-data`),data:H.string(),mediaType:H.string(),filename:H.string().optional(),providerOptions:U.optional()}),H.object({type:H.literal(`file-url`),url:H.string(),mediaType:H.string().optional(),providerOptions:U.optional()}),H.object({type:H.literal(`file-id`),fileId:H.union([H.string(),H.record(H.string(),H.string())]),providerOptions:U.optional()}),H.object({type:H.literal(`file-reference`),providerReference:H.record(H.string(),H.string()),providerOptions:U.optional()}),H.object({type:H.literal(`image-data`),data:H.string(),mediaType:H.string(),providerOptions:U.optional()}),H.object({type:H.literal(`image-url`),url:H.string(),providerOptions:U.optional()}),H.object({type:H.literal(`image-file-id`),fileId:H.union([H.string(),H.record(H.string(),H.string())]),providerOptions:U.optional()}),H.object({type:H.literal(`image-file-reference`),providerReference:H.record(H.string(),H.string()),providerOptions:U.optional()}),H.object({type:H.literal(`custom`),providerOptions:U.optional()})]))})]),gy=H.object({type:H.literal(`tool-result`),toolCallId:H.string(),toolName:H.string(),output:hy,providerOptions:U.optional()}),_y=H.object({type:H.literal(`tool-approval-request`),approvalId:H.string(),toolCallId:H.string(),reason:H.string().optional(),isAutomatic:H.boolean().optional(),signature:H.string().optional(),inputSchemaInput:H.unknown().optional()}),vy=H.object({type:H.literal(`tool-approval-response`),approvalId:H.string(),approved:H.boolean(),reason:H.string().optional()}),yy=H.object({role:H.literal(`system`),content:H.string(),providerOptions:U.optional()}),by=H.object({role:H.literal(`user`),content:H.union([H.string(),H.array(H.union([oy,sy,uy]))]),providerOptions:U.optional()}),xy=H.object({role:H.literal(`assistant`),content:H.union([H.string(),H.array(H.union([oy,fy,uy,dy,py,my,gy,_y]))]),providerOptions:U.optional()}),Sy=H.object({role:H.literal(`tool`),content:H.array(H.union([gy,vy])),providerOptions:U.optional()});H.union([yy,by,xy,Sy]),V.object({token:V.string().check(V.refine(e=>e.trim().length>0)),url:V.string().check(V.refine(e=>{try{let t=new URL(e);return(t.protocol===`ws:`||t.protocol===`wss:`)&&t.hostname!==``}catch{return!1}})),expiresAt:V.optional(V.number().check(V.positive()).check(V.maximum(2**53-1))),tools:V.optional(V.array(V.object({type:V.literal(`function`),name:V.string().check(V.minLength(1)),description:V.optional(V.string()),parameters:V.record(V.string(),V.unknown())})))}),qh({prefix:`call`,size:24}),qh({prefix:`call`,size:24}),qh({prefix:`call`,size:24});async function Cy({response:e,url:t,fallbackMessage:n}){let r=await e.text();return new dh({message:r||n,url:t,requestBodyValues:void 0,statusCode:e.status,responseBody:r})}async function wy(e){if(e==null)return[];if(!globalThis.FileList||!(e instanceof globalThis.FileList))throw new Mh({functionality:`FileList`,message:`FileList is not supported in the current environment`});return Promise.all(Array.from(e).map(async e=>{let{name:t,type:n}=e;return{type:`file`,mediaType:n,filename:t,url:await new Promise((t,n)=>{let r=new FileReader;r.onload=e=>{t(e.target?.result)},r.onerror=e=>n(e),r.readAsDataURL(e)})}}))}function Ty(e,t){let n=e.search(/[?#]/),r=n===-1?e:e.slice(0,n),i=n===-1?``:e.slice(n);return`${r.endsWith(`/`)&&t.startsWith(`/`)?r.slice(0,-1):r}${t}${i}`}var Ey=class{constructor({api:e=`/api/chat`,credentials:t,headers:n,body:r,fetch:i,prepareSendMessagesRequest:a,prepareReconnectToStreamRequest:o}){this.api=e,this.credentials=t,this.headers=n,this.body=r,this.fetch=i,this.prepareSendMessagesRequest=a,this.prepareReconnectToStreamRequest=o}async sendMessages({abortSignal:e,...t}){let n=await c_(this.body),r=await c_(this.headers),i=await c_(this.credentials),a={...Kh(r),...Kh(t.headers)},o=await this.prepareSendMessagesRequest?.({api:this.api,id:t.chatId,messages:t.messages,body:{...n,...t.body},headers:a,credentials:i,requestMetadata:t.metadata,trigger:t.trigger,messageId:t.messageId}),s=o?.api??this.api,c=o?.headers===void 0?a:Kh(o.headers),l=o?.body===void 0?{...n,...t.body,id:t.chatId,messages:t.messages,trigger:t.trigger,messageId:t.messageId}:o.body,u=o?.credentials??i,d=await(this.fetch??globalThis.fetch)(s,{method:`POST`,headers:{"content-type":`application/json`,...c},body:JSON.stringify(l),credentials:u,signal:e});if(!d.ok)throw await Cy({response:d,url:s,fallbackMessage:`Failed to fetch the chat response.`});if(!d.body)throw new hh({message:`The response body is empty.`});return this.processResponseStream(d.body)}async reconnectToStream(e){let t=await c_(this.body),n=await c_(this.headers),r=await c_(this.credentials),i={...Kh(n),...Kh(e.headers)},a=await this.prepareReconnectToStreamRequest?.({api:this.api,id:e.chatId,body:{...t,...e.body},headers:i,credentials:r,requestMetadata:e.metadata}),o=a?.api;if(o==null){if(e.chatId===`.`||e.chatId===`..`)throw new Y_({parameter:`chatId`,value:e.chatId,message:`Chat IDs must not be "." or ".." when using the default reconnect URL.`});o=Ty(this.api,`/${encodeURIComponent(e.chatId)}/stream`)}let s=a?.headers===void 0?i:Kh(a.headers),c=a?.credentials??r,l=await(this.fetch??globalThis.fetch)(o,{method:`GET`,headers:s,credentials:c,signal:e.abortSignal});if(l.status===204)return null;if(!l.ok)throw await Cy({response:l,url:o,fallbackMessage:`Failed to fetch the chat response.`});if(!l.body)throw new hh({message:`The response body is empty.`});return this.processResponseStream(l.body)}},Dy=class extends Ey{constructor({resumeStreamIsReplay:e=!0,...t}={}){super(t),this.resumeStreamIsReplay=e}processResponseStream(e){return s_({stream:e,schema:vv}).pipeThrough(new TransformStream({async transform(e,t){if(!e.success)throw e.error;t.enqueue(e.value)}}))}},Oy=class{get id(){return this._id??=this.generateId()}constructor({generateId:e=Jh,id:t,transport:n=new Dy,messageMetadataSchema:r,dataPartSchemas:i,state:a,onError:o,onToolCall:s,onFinish:c,onData:l,sendAutomaticallyWhen:u,experimental_queue:d=!1}){this.queuedMessagesFallback=[],this.queuedMessageOptions=new Map,this.isQueuePaused=!1,this.pendingAutomaticDecisions=[],this.pendingMessagePreparations=new Set,this.interruptedMessageIds=new Set,this.activeResponse=void 0,this.activeResumeRequest=void 0,this.resumableStreamState=void 0,this.jobExecutor=new ry,this.activeStopCount=0,this.stopGeneration=0,this.experimental_removeQueuedMessage=e=>{this.queuedMessageOptions.delete(e),this.setQueuedMessages(this.experimental_queuedMessages.filter(t=>t.id!==e))},this.experimental_sendQueuedMessageNow=async e=>{let t=this.experimental_queuedMessages.find(t=>t.id===e);if(t==null)return;this.setQueuedMessages([t,...this.experimental_queuedMessages.filter(t=>t.id!==e)]);let n=this.stopGeneration+1;await this.stop(),n===this.stopGeneration&&await this.resumeQueue({skipWaitForUser:!0,options:this.queuedMessageOptions.get(e)})},this.sendMessage=async(e,t)=>{if(e==null){let e=this.pendingApprovalMessageId;if(e==null){e=this.lastMessage?.id;for(let t=this.state.messages.length-1;t>=0;t--){let n=this.state.messages[t];if(n.role===`assistant`&&n.parts.some(e=>Tv(e)&&e.state===`approval-responded`)){e=n.id;break}}}let n=e!=null&&e===this.pendingApprovalMessageId?this.state.messages.findIndex(t=>t.id===e):-1;await this.makeRequestForToolApproval({messageId:e,messageIndex:n,...t});return}let n;if(`text`in e||`files`in e){let t=new AbortController;this.pendingMessagePreparations.add(t);let r;try{r=Array.isArray(e.files)?e.files:await wy(e.files)}finally{this.pendingMessagePreparations.delete(t)}if(t.signal.aborted)return;n={parts:[...r,...`text`in e&&e.text!=null?[{type:`text`,text:e.text}]:[]]}}else n=e;if(this.queueEnabled&&e.messageId==null&&(this.isRequestInProgress()||this.isWaitingForUser()||this.experimental_queuedMessages.length>0)){let r={...n,id:n.id??this.generateId(),role:n.role??`user`,metadata:e.metadata};t!=null&&this.queuedMessageOptions.set(r.id,t),this.setQueuedMessages([...this.experimental_queuedMessages,r]),await this.resumeQueue({skipWaitForUser:this.isQueuePaused,options:t});return}if(e.messageId!=null){await this.clearQueueForHistoryChange();let t=this.state.messages.findIndex(t=>t.id===e.messageId);if(t===-1)throw new Y_({parameter:`message.messageId`,value:e.messageId,message:`message with id ${e.messageId} not found`});if(this.state.messages[t].role!==`user`)throw new Y_({parameter:`message.messageId`,value:e.messageId,message:`message with id ${e.messageId} is not a user message`});this.state.messages=this.state.messages.slice(0,t+1),this.state.replaceMessage(t,{id:e.messageId,...n,role:n.role??`user`,metadata:e.metadata})}else this.state.pushMessage({...n,id:n.id??this.generateId(),role:n.role??`user`,metadata:e.metadata});this.isQueuePaused=!1,await this.makeRequest({trigger:`submit-message`,messageId:e.messageId,...t})},this.regenerate=async({messageId:e,...t}={})=>{await this.clearQueueForHistoryChange();let n=e==null?this.state.messages.length-1:this.state.messages.findIndex(t=>t.id===e);if(n===-1)throw new Y_({parameter:`messageId`,value:e,message:`message ${e} not found`});this.state.messages=this.state.messages.slice(0,this.messages[n].role===`assistant`?n:n+1),await this.makeRequest({trigger:`regenerate-message`,messageId:e,...t})},this.resumeStream=async(e={})=>{await this.makeRequest({trigger:`resume-stream`,...e})},this[`~resumeStreamIfDisconnected`]=async({shouldResume:e=()=>!0}={})=>{let t=this.activeResponse;this.resumableStreamState==null&&t!=null&&(await t.completionPromise,this.resumableStreamState!==t.state)||this.resumableStreamState!=null&&e()&&await this.resumeStream()},this.clearError=()=>{this.status===`error`&&(this.state.error=void 0,this.setStatus({status:`ready`}))},this.addToolApprovalResponse=async({id:e,approved:t,reason:n,options:r})=>this.jobExecutor.run(async()=>{let i=this.stopGeneration,a=this.state.messages,o=r=>Tv(r)&&r.state===`approval-requested`&&r.approval.id===e?{...r,state:`approval-responded`,approval:{...r.approval,id:e,approved:t,reason:n}}:r,s=a.findIndex(t=>t.parts.some(t=>Tv(t)&&t.state===`approval-requested`&&t.approval.id===e));if(s!==-1){let e=a[s];this.state.replaceMessage(s,{...e,parts:e.parts.map(o)}),this.pendingApprovalMessageId=e.id}if(this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(o)),s!==-1&&this.status!==`streaming`&&this.status!==`submitted`&&this.sendAutomaticallyWhen){let e=await this.shouldSendAutomatically(a[s].id);if(e){this.runAutomaticRequest(()=>{let e=s===-1?this.lastMessage?.id:a[s].id;return this.makeRequestForToolApproval({messageId:e,messageIndex:s,...r})},e);return}}this.settleQueue({stopGeneration:i})}),this.addToolOutput=async({state:e,toolCallId:t,output:n,errorText:r,options:i})=>this.jobExecutor.run(async()=>{let a=this.stopGeneration,o=this.state.messages,s=i=>{if(!Tv(i)||i.toolCallId!==t)return i;let{approval:a,...o}=i,s=a?.approved===!0?{approval:{...a,approved:a.approved}}:{};return e===`output-error`?{...o,...s,state:e,input:i.input,output:void 0,errorText:r}:{...o,...s,state:`output-available`,input:i.input,output:n,errorText:void 0}},c=o.findIndex(e=>e.parts.some(e=>Tv(e)&&e.toolCallId===t));if(c!==-1){let e=o[c];this.state.replaceMessage(c,{...e,parts:e.parts.map(s)})}if(this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(s)),c!==-1&&this.status!==`streaming`&&this.status!==`submitted`&&this.sendAutomaticallyWhen){let e=await this.shouldSendAutomatically(o[c].id);if(e){this.runAutomaticRequest(()=>this.makeRequest({trigger:`submit-message`,messageId:o[c].id,...i}),e);return}}this.settleQueue({stopGeneration:a})}),this.addToolResult=this.addToolOutput,this.stop=async()=>{this.activeStopCount++,this.stopGeneration++,this.deferredApprovalSend=void 0;try{let e=this.activeResumeRequest,t=this.activeResponse;for(let e of this.pendingMessagePreparations)e.abort();e?.abortController.abort(),t?.abortController.abort(),await Promise.all([e?.completionPromise,t?.completionPromise]),await this.jobExecutor.waitForIdle(),this.isQueuePaused=!0}finally{this.activeStopCount--}},this.dispose=async()=>{await this.stop(),this.transport.close?.()},this._id=t,this.transport=n,this.generateId=e,this.messageMetadataSchema=r,this.dataPartSchemas=i,this.state=a,this.onError=o,this.onToolCall=s,this.onFinish=c,this.onData=l,this.sendAutomaticallyWhen=u,this.queueEnabled=d}get status(){return this.state.status}setStatus({status:e,error:t}){if(this.status===e){this.error!==t&&(this.state.error=t);return}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]}get experimental_queuedMessages(){return this.state.experimental_queuedMessages??this.queuedMessagesFallback}setQueuedMessages(e){`experimental_queuedMessages`in this.state?this.state.experimental_queuedMessages=e:this.queuedMessagesFallback=e}async resumeQueue({skipWaitForUser:e,options:t}){if(this.isQueuePaused=!1,this.hasUnsentApprovalResponse()){if(!this.isRequestInProgress()){await this.sendMessage(void 0,t);return}this.deferredApprovalSend={options:t}}await this.settleQueue({skipWaitForUser:e})}async clearQueueForHistoryChange(){this.queueEnabled&&(this.queuedMessageOptions.clear(),this.setQueuedMessages([]),this.deferredApprovalSend=void 0,this.isRequestInProgress()&&await this.stop())}isRequestInProgress(){return this.pendingAutomaticDecisions.includes(this.stopGeneration)||this.activeResponse!=null||this.status===`submitted`||this.status===`streaming`}isWaitingForUser(){let e=this.lastMessage;return e?.role===`assistant`&&e.parts.some(e=>Tv(e)&&(e.state===`approval-requested`||e.state===`approval-responded`||!e.providerExecuted&&(e.state===`input-streaming`||e.state===`input-available`)))}hasUnsentApprovalResponse(){let e=this.lastMessage;return e?.role===`assistant`&&e.parts.some(e=>Tv(e)&&e.state===`approval-responded`)&&!e.parts.some(e=>Tv(e)&&(e.state===`approval-requested`||!e.providerExecuted&&(e.state===`input-streaming`||e.state===`input-available`)))}async settleQueue({stopGeneration:e=this.stopGeneration,skipWaitForUser:t=!1}={}){if(this.isQueuePaused||this.isRequestInProgress()||this.activeStopCount>0||e!==this.stopGeneration)return;let n=this.deferredApprovalSend;if(this.deferredApprovalSend=void 0,n!=null&&this.hasUnsentApprovalResponse()){await this.sendMessage(void 0,n.options);return}let[r,...i]=this.experimental_queuedMessages;if(r==null||!t&&this.isWaitingForUser())return;let a=this.queuedMessageOptions.get(r.id);this.queuedMessageOptions.delete(r.id),this.setQueuedMessages(i),this.state.pushMessage(r),await this.makeRequest({trigger:`submit-message`,...a})}set messages(e){this.state.messages=e}async shouldSendAutomatically(e=this.lastMessage?.id){let t=e=>e!=null&&this.interruptedMessageIds.has(e);if(!this.sendAutomaticallyWhen||t(e)||t(this.lastMessage?.id))return!1;let n=this.stopGeneration;this.pendingAutomaticDecisions.push(n);let r;try{r=await this.sendAutomaticallyWhen({messages:this.state.messages})}finally{this.pendingAutomaticDecisions.splice(this.pendingAutomaticDecisions.indexOf(n),1)}return r&&!t(e)&&!t(this.lastMessage?.id)}async runAutomaticRequest(e,t){let n=this.stopGeneration,r=this.activeStopCount>0;return!(t??await this.shouldSendAutomatically())||r||n!==this.stopGeneration||this.activeStopCount>0?!1:(await e(),!0)}async makeRequestForToolApproval({messageId:e,messageIndex:t,...n}){this.deferredApprovalSend=void 0;let r=e!=null&&e===this.pendingApprovalMessageId;r&&(this.pendingApprovalMessageId=void 0),await this.makeRequest({trigger:`submit-message`,messageId:e,...n}),r&&this.status===`error`&&this.pendingApprovalMessageId==null&&(this.pendingApprovalMessageId=this.state.messages[t]?.id??e)}async makeRequest(e){let t=jv();try{await this.makeRequestImpl({...e,completionPromise:t.promise})}finally{t.resolve()}}async makeRequestImpl({trigger:e,metadata:t,headers:n,body:r,messageId:i,completionPromise:a}){e!==`resume-stream`&&(this.resumableStreamState=void 0);let o=new AbortController,s=e===`resume-stream`?{abortController:o,completionPromise:a}:void 0;s&&(this.activeResumeRequest?.abortController.abort(),this.activeResumeRequest=s);let c=()=>s==null||this.activeResumeRequest===s,l=()=>{this.activeResumeRequest===s&&(this.activeResumeRequest=void 0)},u;if(e===`resume-stream`)try{let e=await this.transport.reconnectToStream({chatId:this.id,abortSignal:o.signal,metadata:t,headers:n,body:r});if(o.signal.aborted||!c()){await e?.cancel().catch(()=>{}),c()&&(this.setStatus({status:`ready`}),this.resumableStreamState=void 0),l();return}if(e==null){this.setStatus({status:`ready`}),this.resumableStreamState=void 0,l();return}u=e}catch(e){if(o.signal.aborted||e.name===`AbortError`){c()&&(this.setStatus({status:`ready`}),this.resumableStreamState=void 0),l();return}if(!c())return;this.onError&&e instanceof Error&&this.onError(e),this.setStatus({status:`error`,error:e}),l();return}this.setStatus({status:`submitted`,error:void 0});let d=this.lastMessage,f=e===`submit-message`&&i!=null?this.state.messages.findIndex(e=>e.id===i):this.state.messages.length-1,p=f===-1?d:this.state.messages[f],m=p?.id,h=e===`resume-stream`&&p?.role===`assistant`&&p.parts.some(e=>Tv(e)&&(e.state===`input-streaming`||e.state===`input-available`&&e.providerExecuted||e.state===`approval-responded`))?this.state.snapshot(p):void 0,g=f!==-1&&f<this.state.messages.length-1&&p?.role===`assistant`,_=!1,v=!1,y=!1,b;try{let s={state:e===`resume-stream`&&this.resumableStreamState!=null?this.resumableStreamState:Ov({lastMessage:e===`resume-stream`?h:e===`regenerate-message`?void 0:this.state.snapshot(p),messageId:this.generateId()}),abortController:o,completionPromise:a};b=s,s.abortController.signal.addEventListener(`abort`,()=>{_=!0}),this.activeResponse=s;let l;if(l=e===`resume-stream`?u:await this.transport.sendMessages({chatId:this.id,messages:this.state.messages,abortSignal:s.abortController.signal,metadata:t,headers:n,body:r,trigger:e,messageId:i}),await Av({stream:kv({stream:l,resetStateOnMessageIdChange:e===`resume-stream`,resetStateOnFirstMessageStart:e===`resume-stream`&&this.transport.resumeStreamIsReplay,onToolCall:this.onToolCall,onData:this.onData,messageMetadataSchema:this.messageMetadataSchema,dataPartSchemas:this.dataPartSchemas,runUpdateMessageJob:e=>this.jobExecutor.run(()=>s.abortController.signal.aborted?Promise.resolve():e({state:s.state,write:({updateStatus:e=!0}={})=>{if(s.abortController.signal.aborted)return;e&&this.setStatus({status:`streaming`});let t=this.state.messages.findLastIndex(e=>e.id===s.state.message.id);if(t!==-1)this.state.replaceMessage(t,s.state.message);else if(g){let e=this.state.messages.findLastIndex(e=>e.id===m);e===-1?this.state.pushMessage(s.state.message):this.state.replaceMessage(e,s.state.message)}else this.state.pushMessage(s.state.message)}})),onError:e=>{throw e}}),abortSignal:s.abortController.signal,onError:e=>{throw e}}),_)return c()&&(this.setStatus({status:`ready`}),this.resumableStreamState===s.state&&(this.resumableStreamState=void 0)),null;c()&&(this.setStatus({status:`ready`}),this.resumableStreamState===s.state&&(this.resumableStreamState=void 0))}catch(e){if(_||e.name===`AbortError`)return _=!0,c()&&(this.setStatus({status:`ready`}),this.resumableStreamState===b?.state&&(this.resumableStreamState=void 0)),null;if(!c())return null;if(y=!0,e instanceof TypeError){let t=e.message.toLowerCase();v=t.includes(`fetch`)||t.includes(`network`)||t===`load failed`}v?this.resumableStreamState=b?.state:this.resumableStreamState===b?.state&&(this.resumableStreamState=void 0),this.onError&&e instanceof Error&&this.onError(e),this.setStatus({status:`error`,error:e})}finally{try{if(b){let{message:e,finishReason:t}=b.state;t===`interrupted`?this.interruptedMessageIds.add(e.id):!_&&!y&&this.interruptedMessageIds.delete(e.id),this.onFinish?.({message:b.state.message,messages:this.state.messages,isAbort:_,isDisconnect:v,isError:y,finishReason:b.state.finishReason})}}finally{(_||y||b?.state.finishReason===`interrupted`)&&(this.isQueuePaused=!0),this.activeResponse===b&&(this.activeResponse=void 0),l()}}if(!_&&!y&&b?.state.finishReason!==`interrupted`){let e=this.stopGeneration;await this.runAutomaticRequest(()=>this.makeRequest({trigger:`submit-message`,messageId:this.lastMessage?.id,metadata:t,headers:n,body:r}))||await this.settleQueue({stopGeneration:e})}}};function ky({messages:e}){let t=e[e.length-1];if(!t||t.role!==`assistant`)return!1;let n=t.parts.reduce((e,t,n)=>t.type===`step-start`?n:e,-1),r=t.parts.slice(n+1).filter(Tv);return r.filter(e=>e.state===`approval-responded`).length>0&&r.every(e=>e.state===`output-available`&&e.preliminary!==!0||e.state===`output-error`||e.state===`output-denied`||e.state===`approval-responded`)}function Ay({messages:e}){let t=e[e.length-1];if(!t||t.role!==`assistant`)return!1;let n=t.parts.reduce((e,t,n)=>t.type===`step-start`?n:e,-1),r=t.parts.slice(n+1),i=r.filter(Tv).filter(e=>!e.providerExecuted),a=r.reduce((e,t,n)=>Tv(t)&&!t.providerExecuted?n:e,-1);return i.length>0&&!r.slice(a+1).some(e=>e.type===`text`&&e.state!==`done`)&&i.every(e=>e.state===`output-available`&&e.preliminary!==!0||e.state===`output-error`)}var jy=n(a(((e,t)=>{function n(e,t){if(typeof e!=`function`)throw TypeError(`Expected the first argument to be a \`function\`, got \`${typeof e}\`.`);let n,r=0;return function(...i){clearTimeout(n);let a=Date.now(),o=t-(a-r);o<=0?(r=a,e.apply(this,i)):n=setTimeout(()=>{r=Date.now(),e.apply(this,i)},o)}}t.exports=n}))(),1);function My(e,t){return t==null?e:(0,jy.default)(e,t)}function Ny(e){return Array.isArray(e)?[...e]:typeof e==`object`&&e&&(Object.getPrototypeOf(e)===Object.prototype||Object.getPrototypeOf(e)===null)?{...e}:e}var Py=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e=[]){this.#t=`ready`,this.#n=void 0,this.#r=[],this.#i=new Set,this.#a=new Set,this.#o=new Set,this.#s=new Set,this.pushMessage=e=>{this.#e=this.#e.concat(e),this.#c()},this.popMessage=()=>{this.#e=this.#e.slice(0,-1),this.#c()},this.replaceMessage=(e,t)=>{this.#e=[...this.#e.slice(0,e),this.snapshot(t),...this.#e.slice(e+1)],this.#c()},this.snapshot=e=>{if(typeof e!=`object`||!e||!(`parts`in e)||!Array.isArray(e.parts))return e;let t=e,n={...t,parts:t.parts.map(e=>({...e}))};return`metadata`in t&&(n.metadata=Ny(t.metadata)),n},this[`~registerMessagesCallback`]=(e,t)=>{let n=t?My(e,t):e;return this.#i.add(n),()=>{this.#i.delete(n)}},this[`~registerStatusCallback`]=e=>(this.#o.add(e),()=>{this.#o.delete(e)}),this[`~registerErrorCallback`]=e=>(this.#s.add(e),()=>{this.#s.delete(e)}),this[`~registerQueuedMessagesCallback`]=e=>(this.#a.add(e),()=>{this.#a.delete(e)}),this.#c=()=>{this.#i.forEach(e=>e())},this.#l=()=>{this.#o.forEach(e=>e())},this.#u=()=>{this.#s.forEach(e=>e())},this.#e=e}get status(){return this.#t}set status(e){this.#t=e,this.#l()}get error(){return this.#n}set error(e){this.#n=e,this.#u()}get experimental_queuedMessages(){return this.#r}set experimental_queuedMessages(e){this.#r=e,this.#a.forEach(e=>e())}get messages(){return this.#e}set messages(e){this.#e=[...e],this.#c()}#c;#l;#u},Fy=class extends Oy{#e;constructor({messages:e,...t}){let n=new Py(e);super({...t,state:n}),this[`~registerMessagesCallback`]=(e,t)=>this.#e[`~registerMessagesCallback`](e,t),this[`~registerStatusCallback`]=e=>this.#e[`~registerStatusCallback`](e),this[`~registerErrorCallback`]=e=>this.#e[`~registerErrorCallback`](e),this[`~registerQueuedMessagesCallback`]=e=>this.#e[`~registerQueuedMessagesCallback`](e),this.#e=n}},Iy=new WeakMap;function Ly({chat:e,state:t}){if(document.visibilityState!==`visible`||t.pendingVisibilityResume!=null)return;let n=()=>Iy.get(e)===t&&t.registrations.size>0,r=()=>{t.pendingVisibilityResume=void 0};t.pendingVisibilityResume=e[`~resumeStreamIfDisconnected`]({shouldResume:()=>n()&&document.visibilityState===`visible`}).then(r,r)}function Ry({chat:e,registration:t}){let n=Iy.get(e);if(n==null){let t={registrations:new Set};if(Iy.set(e,t),n=t,typeof document<`u`){let n=()=>Ly({chat:e,state:t});document.addEventListener(`visibilitychange`,n),t.cleanupVisibilityListener=()=>{document.removeEventListener(`visibilitychange`,n)}}}let{registrations:r}=n,i=r.size===0;return r.add(t),i&&e.status!==`submitted`&&e.status!==`streaming`&&e.resumeStream(),()=>{r.delete(t),r.size===0&&(n.cleanupVisibilityListener?.(),Iy.delete(e))}}function zy(e){return{chat:e,messages:e.messages,status:e.status,error:e.error,experimental_queuedMessages:e.experimental_queuedMessages}}function By(e,t){return e.chat===t.chat&&e.messages===t.messages&&e.status===t.status&&e.error===t.error&&e.experimental_queuedMessages===t.experimental_queuedMessages}function Vy({throttle:e,experimental_throttle:t,resume:n=!1,...r}={}){let i=e??t,a=(0,R.useRef)({}),o=(0,R.useRef)({});`chat`in r||(o.current={onToolCall:r.onToolCall,onData:r.onData,onFinish:r.onFinish,onError:r.onError,sendAutomaticallyWhen:r.sendAutomaticallyWhen,transport:r.transport});let s,c=()=>o.current.transport??(s??=new Dy),l={...r,transport:{get resumeStreamIsReplay(){return c().resumeStreamIsReplay},sendMessages:e=>c().sendMessages(e),reconnectToStream:e=>c().reconnectToStream(e)},onToolCall:e=>o.current.onToolCall?.(e),onData:e=>o.current.onData?.(e),onFinish:e=>o.current.onFinish?.(e),onError:e=>o.current.onError?.(e),sendAutomaticallyWhen:e=>o.current.sendAutomaticallyWhen?.(e)??!1},{chat:u,isExternallyManaged:d}=(0,R.useMemo)(()=>({chat:`chat`in r?r.chat:new Fy(l),isExternallyManaged:`chat`in r}),[`chat`in r?r.chat:r.id]);(0,R.useEffect)(()=>{if(!d)return()=>{u.stop()}},[u,d]);let[f,p]=(0,R.useState)(()=>zy(u));f.chat!==u&&p(zy(u)),(0,R.useEffect)(()=>{let e=!0,t=()=>{if(!e)return;let t=zy(u);p(e=>e.chat!==u||By(e,t)?e:t)},n=[u[`~registerMessagesCallback`](t,i),u[`~registerStatusCallback`](t),u[`~registerErrorCallback`](t),u[`~registerQueuedMessagesCallback`](t)],r=zy(u);return p(e=>By(e,r)?e:r),()=>{e=!1,n.forEach(e=>e())}},[u,i]);let{messages:m,status:h,error:g,experimental_queuedMessages:_}=f,v=(0,R.useCallback)(e=>{typeof e==`function`&&(e=e(u.messages)),u.messages=e},[u]);return(0,R.useEffect)(()=>{if(n)return Ry({chat:u,registration:a.current})},[n,u]),{get id(){return u.id},messages:m,setMessages:v,sendMessage:u.sendMessage,regenerate:u.regenerate,clearError:u.clearError,stop:u.stop,error:g,resumeStream:u.resumeStream,status:h,addToolResult:u.addToolOutput,addToolOutput:u.addToolOutput,addToolApprovalResponse:u.addToolApprovalResponse,experimental_queuedMessages:_,experimental_removeQueuedMessage:u.experimental_removeQueuedMessage,experimental_sendQueuedMessageNow:u.experimental_sendQueuedMessageNow}}var Hy=a(((e,t)=>{(function(n,r){typeof i==`function`&&typeof e==`object`&&typeof t==`object`?t.exports=r():typeof define==`function`&&define.amd?define(function(){return r()}):n.pluralize=r()})(e,function(){var e=[],t=[],n={},r={},i={};function a(e){return typeof e==`string`?RegExp(`^`+e+`$`,`i`):e}function o(e,t){return e===t?t:e===e.toLowerCase()?t.toLowerCase():e===e.toUpperCase()?t.toUpperCase():e[0]===e[0].toUpperCase()?t.charAt(0).toUpperCase()+t.substr(1).toLowerCase():t.toLowerCase()}function s(e,t){return e.replace(/\$(\d{1,2})/g,function(e,n){return t[n]||``})}function c(e,t){return e.replace(t[0],function(n,r){var i=s(t[1],arguments);return o(n===``?e[r-1]:n,i)})}function l(e,t,r){if(!e.length||n.hasOwnProperty(e))return t;for(var i=r.length;i--;){var a=r[i];if(a[0].test(t))return c(t,a)}return t}function u(e,t,n){return function(r){var i=r.toLowerCase();return t.hasOwnProperty(i)?o(r,i):e.hasOwnProperty(i)?o(r,e[i]):l(i,r,n)}}function d(e,t,n,r){return function(r){var i=r.toLowerCase();return t.hasOwnProperty(i)?!0:!e.hasOwnProperty(i)&&l(i,i,n)===i}}function f(e,t,n){var r=t===1?f.singular(e):f.plural(e);return(n?t+` `:``)+r}return f.plural=u(i,r,e),f.isPlural=d(i,r,e),f.singular=u(r,i,t),f.isSingular=d(r,i,t),f.addPluralRule=function(t,n){e.push([a(t),n])},f.addSingularRule=function(e,n){t.push([a(e),n])},f.addUncountableRule=function(e){if(typeof e==`string`){n[e.toLowerCase()]=!0;return}f.addPluralRule(e,`$0`),f.addSingularRule(e,`$0`)},f.addIrregularRule=function(e,t){t=t.toLowerCase(),e=e.toLowerCase(),i[e]=t,r[t]=e},[[`I`,`we`],[`me`,`us`],[`he`,`they`],[`she`,`they`],[`them`,`them`],[`myself`,`ourselves`],[`yourself`,`yourselves`],[`itself`,`themselves`],[`herself`,`themselves`],[`himself`,`themselves`],[`themself`,`themselves`],[`is`,`are`],[`was`,`were`],[`has`,`have`],[`this`,`these`],[`that`,`those`],[`echo`,`echoes`],[`dingo`,`dingoes`],[`volcano`,`volcanoes`],[`tornado`,`tornadoes`],[`torpedo`,`torpedoes`],[`genus`,`genera`],[`viscus`,`viscera`],[`stigma`,`stigmata`],[`stoma`,`stomata`],[`dogma`,`dogmata`],[`lemma`,`lemmata`],[`schema`,`schemata`],[`anathema`,`anathemata`],[`ox`,`oxen`],[`axe`,`axes`],[`die`,`dice`],[`yes`,`yeses`],[`foot`,`feet`],[`eave`,`eaves`],[`goose`,`geese`],[`tooth`,`teeth`],[`quiz`,`quizzes`],[`human`,`humans`],[`proof`,`proofs`],[`carve`,`carves`],[`valve`,`valves`],[`looey`,`looies`],[`thief`,`thieves`],[`groove`,`grooves`],[`pickaxe`,`pickaxes`],[`passerby`,`passersby`]].forEach(function(e){return f.addIrregularRule(e[0],e[1])}),[[/s?$/i,`s`],[/[^\u0000-\u007F]$/i,`$0`],[/([^aeiou]ese)$/i,`$1`],[/(ax|test)is$/i,`$1es`],[/(alias|[^aou]us|t[lm]as|gas|ris)$/i,`$1es`],[/(e[mn]u)s?$/i,`$1s`],[/([^l]ias|[aeiou]las|[ejzr]as|[iu]am)$/i,`$1`],[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,`$1i`],[/(alumn|alg|vertebr)(?:a|ae)$/i,`$1ae`],[/(seraph|cherub)(?:im)?$/i,`$1im`],[/(her|at|gr)o$/i,`$1oes`],[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i,`$1a`],[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i,`$1a`],[/sis$/i,`ses`],[/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i,`$1$2ves`],[/([^aeiouy]|qu)y$/i,`$1ies`],[/([^ch][ieo][ln])ey$/i,`$1ies`],[/(x|ch|ss|sh|zz)$/i,`$1es`],[/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i,`$1ices`],[/\b((?:tit)?m|l)(?:ice|ouse)$/i,`$1ice`],[/(pe)(?:rson|ople)$/i,`$1ople`],[/(child)(?:ren)?$/i,`$1ren`],[/eaux$/i,`$0`],[/m[ae]n$/i,`men`],[`thou`,`you`]].forEach(function(e){return f.addPluralRule(e[0],e[1])}),[[/s$/i,``],[/(ss)$/i,`$1`],[/(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$/i,`$1fe`],[/(ar|(?:wo|[ae])l|[eo][ao])ves$/i,`$1f`],[/ies$/i,`y`],[/\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/i,`$1ie`],[/\b(mon|smil)ies$/i,`$1ey`],[/\b((?:tit)?m|l)ice$/i,`$1ouse`],[/(seraph|cherub)im$/i,`$1`],[/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$/i,`$1`],[/(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$/i,`$1sis`],[/(movie|twelve|abuse|e[mn]u)s$/i,`$1`],[/(test)(?:is|es)$/i,`$1is`],[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,`$1us`],[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i,`$1um`],[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i,`$1on`],[/(alumn|alg|vertebr)ae$/i,`$1a`],[/(cod|mur|sil|vert|ind)ices$/i,`$1ex`],[/(matr|append)ices$/i,`$1ix`],[/(pe)(rson|ople)$/i,`$1rson`],[/(child)ren$/i,`$1`],[/(eau)x?$/i,`$1`],[/men$/i,`man`]].forEach(function(e){return f.addSingularRule(e[0],e[1])}),[`adulthood`,`advice`,`agenda`,`aid`,`aircraft`,`alcohol`,`ammo`,`analytics`,`anime`,`athletics`,`audio`,`bison`,`blood`,`bream`,`buffalo`,`butter`,`carp`,`cash`,`chassis`,`chess`,`clothing`,`cod`,`commerce`,`cooperation`,`corps`,`debris`,`diabetes`,`digestion`,`elk`,`energy`,`equipment`,`excretion`,`expertise`,`firmware`,`flounder`,`fun`,`gallows`,`garbage`,`graffiti`,`hardware`,`headquarters`,`health`,`herpes`,`highjinks`,`homework`,`housework`,`information`,`jeans`,`justice`,`kudos`,`labour`,`literature`,`machinery`,`mackerel`,`mail`,`media`,`mews`,`moose`,`music`,`mud`,`manga`,`news`,`only`,`personnel`,`pike`,`plankton`,`pliers`,`police`,`pollution`,`premises`,`rain`,`research`,`rice`,`salmon`,`scissors`,`series`,`sewage`,`shambles`,`shrimp`,`software`,`species`,`staff`,`swine`,`tennis`,`traffic`,`transportation`,`trout`,`tuna`,`wealth`,`welfare`,`whiting`,`wildebeest`,`wildlife`,`you`,/pok[eé]mon$/i,/[^aeiou]ese$/i,/deer$/i,/fish$/i,/measles$/i,/o[iu]s$/i,/pox$/i,/sheep$/i].forEach(f.addUncountableRule),f})})),Uy=a(((e,t)=>{function n(e){return e=String(e),e&&e.toLowerCase()}n.isLowercase=function(e){return e&&!/[A-Z]+/.test(e)},t.exports=n})),Wy=a(((e,t)=>{function n(e){return e=String(e),e&&e.toUpperCase()}n.isUppercase=function(e){return e&&!/[a-z]+/.test(e)},t.exports=n})),Gy=a(((e,t)=>{var n=Uy(),r=Wy(),i={from:/[\-_:\.\s]([a-zA-Z])([a-zA-Z]*)/g,to:function(e,t,n,i,a){return t.length,r(t)+n}};function a(e){return a.isCamelcase(e)||(e=String(e).replace(/^[\-_:\.\s]/,``),!e)?e:(r.isUppercase(e)&&(e=n(e)),n(e[0])+e.replace(i.from,i.to).slice(1).replace(/^([A-Z]+)([A-Z])/,function(e,t,r){return n(t)+r}))}a.isCamelcase=function(e){return e&&/^[a-zA-Z]+$/.test(e)&&n(e[0])===e[0]},t.exports=a})),Ky=a(((e,t)=>{var n=Wy();function r(e){return e=String(e),e&&n(e[0])+e.slice(1)}t.exports=r})),qy=a(((e,t)=>{var n=Uy(),r=Wy(),i=`_`,a={from:/([A-Z]+)/g,to:function(e,t,a,o){var s=a===0?``:i,c=t.length;if(c===1)return s+n(t);var l=o.slice(a+t.length);return r.isUppercase(t)&&l[0]===i?s+n(t):s+(n(t.substr(0,c-1))+i+n(t[c-1]))}};function o(e){return o.isSnakecase(e)||(e=String(e).replace(/[\-.:\s]/g,i),!e)?e:(r.isUppercase(e)&&(e=n(e)),e.replace(a.from,a.to).replace(/_+/g,`_`))}o.isSnakecase=function(e){return e&&/^[a-z_]+$/.test(e)},t.exports=o})),Jy=a(((e,t)=>{var n=Wy(),r=qy();function i(e){return i.isConstcase(e)?e:n(r(e))}i.isConstcase=function(e){return e&&/^[A-Z_]+$/.test(e)},t.exports=i})),Yy=a(((e,t)=>{var n=qy();function r(e){return n(e).replace(/_/g,``)}t.exports=r})),Xy=a(((e,t)=>{var n=Uy();function r(e){return e=String(e),e&&n(e[0])+e.slice(1)}t.exports=r})),Zy=a(((e,t)=>{var n=qy();function r(e){return n(e).replace(/_/g,`.`)}t.exports=r})),Qy=a(((e,t)=>{var n=qy();function r(e){return n(e).replace(/_/g,`:`)}t.exports=r})),$y=a(((e,t)=>{var n=Gy(),r=Ky();function i(e){return r(n(e))}t.exports=i})),eb=a(((e,t)=>{var n=qy();function r(e){return n(e).replace(/_/g,`/`)}t.exports=r})),tb=a(((e,t)=>{function n(e){return String(e).trim()}t.exports=n})),nb=a(((e,t)=>{Uy();var n=tb(),r=qy(),i=Ky(),a=` `;function o(e){return e=String(e).replace(/^[\-_\.\s]/g,a),e&&i(r(n(e)).replace(/_/g,a))}t.exports=o})),rb=a(((e,t)=>{var n=qy();function r(e){return n(e).replace(/_/g,` `)}t.exports=r})),ib=a(((e,t)=>{var n=qy();function r(e){return n(e).replace(/_/g,`-`)}t.exports=r})),ab=a(((e,t)=>{var n=qy(),r=Uy(),i=tb(),a=Ky(),o=`a,the,and,or,not,but,for,of`.split(`,`);function s(e){return n(e).split(/_/g).map(i).map(function(e){return~o.indexOf(e)?r(e):a(e)}).join(` `)}t.exports=s})),ob=a(((e,t)=>{var n=Gy(),r=Ky(),i=Jy(),a=Yy(),o=Xy(),s=Zy(),c=Qy(),l=Uy(),u=$y(),d=eb(),f=nb(),p=qy(),m=rb(),h=ib(),g=ab(),_=tb(),v=Wy();e.camelcase=n,e.capitalcase=r,e.constcase=i,e.cramcase=a,e.decapitalcase=o,e.dotcase=s,e.enumcase=c,e.lowercase=l,e.pascalcase=u,e.pathcase=d,e.sentencecase=f,e.snakecase=p,e.spacecase=m,e.spinalcase=h,e.titlecase=g,e.trimcase=_,e.uppercase=v,t.exports={camelcase:n,capitalcase:r,constcase:i,cramcase:a,decapitalcase:o,dotcase:s,enumcase:c,lowercase:l,pascalcase:u,pathcase:d,sentencecase:f,snakecase:p,spacecase:m,spinalcase:h,titlecase:g,trimcase:_,uppercase:v}}));Hy(),ob();function sb(e){return typeof e==`object`&&!!e&&`name`in e&&(`data`in e||`codec`in e)&&typeof e.name==`string`}function cb(e){return lb(e,new WeakSet)}function lb(e,t){return typeof e==`object`?e===null||t.has(e)?!0:(t.add(e),Array.isArray(e)?e.every(e=>lb(e,t)):e instanceof Promise?!1:Symbol.asyncIterator in e||Symbol.iterator in e?!0:sb(e)?lb(e.data,t):Object.values(e).every(e=>lb(e,t))):typeof e!=`bigint`&&typeof e!=`symbol`}function ub(e){return!(typeof e!=`object`||!e||Array.isArray(e)||e instanceof Promise||Symbol.asyncIterator in e||Symbol.iterator in e||sb(e))}function db(e){return e.type===`message`}function fb(e){if(sb(e)){if(db(e))throw Error(`Message fragments are not supported by serialized fragment conversion`);if(!e.codec)throw Error(`Fragment "${e.name}" is missing codec`);return e.codec.encode()}return Array.isArray(e)?e.map(e=>fb(e)):ub(e)?Object.fromEntries(Object.entries(e).map(([e,t])=>[e,fb(t)])):e}function pb(e,t){return{name:`term`,data:{name:e,definition:t},codec:{encode(){return{type:`term`,name:e,definition:t}},decode(){return{name:e,definition:t}}}}}function mb(e){return{name:`hint`,data:e,codec:{encode(){return{type:`hint`,text:e}},decode(){return e}}}}function hb(e){return{name:`guardrail`,data:{rule:e.rule,...e.reason&&{reason:e.reason},...e.action&&{action:e.action}},codec:{encode(){return{type:`guardrail`,rule:e.rule,...e.reason&&{reason:e.reason},...e.action&&{action:e.action}}},decode(){return{rule:e.rule,...e.reason&&{reason:e.reason},...e.action&&{action:e.action}}}}}}function gb(e){return{name:`explain`,data:{concept:e.concept,explanation:e.explanation,...e.therefore&&{therefore:e.therefore}},codec:{encode(){return{type:`explain`,concept:e.concept,explanation:e.explanation,...e.therefore&&{therefore:e.therefore}}},decode(){return{concept:e.concept,explanation:e.explanation,...e.therefore&&{therefore:e.therefore}}}}}}function _b(e){return{name:`example`,data:{question:e.question,answer:e.answer,...e.note&&{note:e.note}},codec:{encode(){return{type:`example`,question:e.question,answer:e.answer,...e.note&&{note:e.note}}},decode(){return{question:e.question,answer:e.answer,...e.note&&{note:e.note}}}}}}function vb(e){return{name:`clarification`,data:{when:e.when,ask:e.ask,reason:e.reason},codec:{encode(){return{type:`clarification`,when:e.when,ask:e.ask,reason:e.reason}},decode(){return{when:e.when,ask:e.ask,reason:e.reason}}}}}function yb(e){return{name:`workflow`,data:{task:e.task,steps:e.steps,...e.triggers?.length&&{triggers:e.triggers},...e.notes&&{notes:e.notes}},codec:{encode(){return{type:`workflow`,task:e.task,steps:e.steps,...e.triggers?.length&&{triggers:e.triggers},...e.notes&&{notes:e.notes}}},decode(){return{task:e.task,steps:e.steps,...e.triggers?.length&&{triggers:e.triggers},...e.notes&&{notes:e.notes}}}}}}function bb(e){return{name:`quirk`,data:{issue:e.issue,workaround:e.workaround},codec:{encode(){return{type:`quirk`,issue:e.issue,workaround:e.workaround}},decode(){return{issue:e.issue,workaround:e.workaround}}}}}function xb(e){return{name:`styleGuide`,data:{prefer:e.prefer,...e.never&&{never:e.never},...e.always&&{always:e.always}},codec:{encode(){return{type:`styleGuide`,prefer:e.prefer,...e.never&&{never:e.never},...e.always&&{always:e.always}}},decode(){return{prefer:e.prefer,...e.never&&{never:e.never},...e.always&&{always:e.always}}}}}}function Sb(e){return{name:`analogy`,data:{concepts:e.concepts,relationship:e.relationship,...e.insight&&{insight:e.insight},...e.therefore&&{therefore:e.therefore},...e.pitfall&&{pitfall:e.pitfall}},codec:{encode(){return{type:`analogy`,concepts:e.concepts,relationship:e.relationship,...e.insight&&{insight:e.insight},...e.therefore&&{therefore:e.therefore},...e.pitfall&&{pitfall:e.pitfall}}},decode(){return{concepts:e.concepts,relationship:e.relationship,...e.insight&&{insight:e.insight},...e.therefore&&{therefore:e.therefore},...e.pitfall&&{pitfall:e.pitfall}}}}}}function Cb(e){return{name:`glossary`,data:Object.entries(e).map(([e,t])=>({term:e,expression:t})),codec:{encode(){return{type:`glossary`,entries:e}},decode(){return Object.entries(e).map(([e,t])=>({term:e,expression:t}))}}}}function wb(e){return{name:`role`,data:e,codec:{encode(){return{type:`role`,content:e}},decode(){return e}}}}function Tb(e){return{name:`principle`,data:{title:e.title,description:e.description,...e.policies?.length&&{policies:e.policies}},codec:{encode(){return{type:`principle`,title:e.title,description:e.description,...e.policies?.length&&{policies:e.policies.map(e=>fb(e))}}},decode(){return{title:e.title,description:e.description,...e.policies?.length&&{policies:e.policies}}}}}}function Eb(e){return{name:`policy`,data:{rule:e.rule,...e.before&&{before:e.before},...e.reason&&{reason:e.reason},...e.policies?.length&&{policies:e.policies}},codec:{encode(){return{type:`policy`,rule:e.rule,...e.before&&{before:e.before},...e.reason&&{reason:e.reason},...e.policies?.length&&{policies:e.policies.map(e=>fb(e))}}},decode(){return{rule:e.rule,...e.before&&{before:e.before},...e.reason&&{reason:e.reason},...e.policies?.length&&{policies:e.policies}}}}}}function Db(e){return{name:`identity`,data:{...e.name&&{name:e.name},...e.role&&{role:e.role}},codec:{encode(){return{type:`identity`,...e.name&&{name:e.name},...e.role&&{role:e.role}}},decode(){return{...e.name&&{name:e.name},...e.role&&{role:e.role}}}}}}function Ob(e){return{name:`persona`,data:{name:e.name,...e.role&&{role:e.role},...e.objective&&{objective:e.objective},...e.tone&&{tone:e.tone}},codec:{encode(){return{type:`persona`,name:e.name,...e.role&&{role:e.role},...e.objective&&{objective:e.objective},...e.tone&&{tone:e.tone}}},decode(){return{name:e.name,...e.role&&{role:e.role},...e.objective&&{objective:e.objective},...e.tone&&{tone:e.tone}}}}}}function kb(e,t){return{name:`alias`,data:{term:e,meaning:t},codec:{encode(){return{type:`alias`,term:e,meaning:t}},decode(){return{term:e,meaning:t}}}}}function Ab(e,t){return{name:`preference`,data:{aspect:e,value:t},codec:{encode(){return{type:`preference`,aspect:e,value:t}},decode(){return{aspect:e,value:t}}}}}function jb(e,t){return{name:`correction`,data:{subject:e,clarification:t},codec:{encode(){return{type:`correction`,subject:e,clarification:t}},decode(){return{subject:e,clarification:t}}}}}function Mb(e){return typeof e==`object`&&!!e&&`type`in e&&typeof e.type==`string`}function Nb(e,t){if(Mb(e))return See(e,t);if(Array.isArray(e))return e.map(e=>Nb(e,t));if(ub(e))return Object.fromEntries(Object.entries(e).map(([e,n])=>[e,Nb(n,t)]));if(!cb(e))throw Error(`Unsupported serialized value of type ${typeof e}`);return e}function Pb(e,t){return{toFragment:(n,r)=>{let i=e.safeParse(n);if(!i.success)throw Error(`Invalid serialized ${n.type} fragment: ${At(i.error)}`);return t(i.data,r)}}}var Fb=Xt(fn()).optional(),Ib={term:Pb(F({name:L(),definition:L()}),e=>pb(e.name,e.definition)),hint:Pb(F({text:L()}),e=>mb(e.text)),guardrail:Pb(F({rule:L(),reason:L().optional(),action:L().optional()}),e=>hb({rule:e.rule,reason:e.reason,action:e.action})),explain:Pb(F({concept:L(),explanation:L(),therefore:L().optional()}),e=>gb({concept:e.concept,explanation:e.explanation,therefore:e.therefore})),example:Pb(F({question:L(),answer:L(),note:L().optional()}),e=>_b({question:e.question,answer:e.answer,note:e.note})),clarification:Pb(F({when:L(),ask:L(),reason:L()}),e=>vb({when:e.when,ask:e.ask,reason:e.reason})),workflow:Pb(F({task:L(),steps:Xt(L()),triggers:Xt(L()).optional(),notes:L().optional()}),e=>yb({task:e.task,steps:e.steps,triggers:e.triggers,notes:e.notes})),quirk:Pb(F({issue:L(),workaround:L()}),e=>bb({issue:e.issue,workaround:e.workaround})),styleGuide:Pb(F({prefer:L(),never:L().optional(),always:L().optional()}),e=>xb({prefer:e.prefer,never:e.never,always:e.always})),analogy:Pb(F({concepts:Xt(L()),relationship:L(),insight:L().optional(),therefore:L().optional(),pitfall:L().optional()}),e=>Sb({concepts:e.concepts,relationship:e.relationship,insight:e.insight,therefore:e.therefore,pitfall:e.pitfall})),glossary:Pb(F({entries:C(L(),L())}),e=>Cb(e.entries)),role:Pb(F({content:L()}),e=>wb(e.content)),principle:Pb(F({title:L(),description:L(),policies:Fb}),(e,t)=>Tb({title:e.title,description:e.description,policies:e.policies?.map(e=>Nb(e,t))})),policy:Pb(F({rule:L(),before:L().optional(),reason:L().optional(),policies:Fb}),(e,t)=>Eb({rule:e.rule,before:e.before,reason:e.reason,policies:e.policies?.map(e=>Nb(e,t))})),identity:Pb(F({name:L().optional(),role:L().optional()}),e=>Db({name:e.name,role:e.role})),persona:Pb(F({name:L(),role:L().optional(),objective:L().optional(),tone:L().optional()}),e=>Ob({name:e.name,role:e.role,objective:e.objective,tone:e.tone})),alias:Pb(F({term:L(),meaning:L()}),e=>kb(e.term,e.meaning)),preference:Pb(F({aspect:L(),value:L()}),e=>Ab(e.aspect,e.value)),correction:Pb(F({subject:L(),clarification:L()}),e=>jb(e.subject,e.clarification))};function bee(e){return Object.hasOwn(Ib,e)}var xee=new Set([`user`,`assistant`,`message`]);function See(e,t){if(xee.has(e.type))throw Error(`Message fragments are not supported by serialized fragment conversion`);let n=t?.registry?.[e.type]??(bee(e.type)?Ib[e.type]:void 0);if(!n)throw Error(`Unsupported serialized fragment type: ${e.type}`);return n.toFragment(e,t)}function Cee(e){let t=e?.reminders;return Array.isArray(t)?t.filter(e=>Yh(e)&&typeof e.partIndex==`number`&&typeof e.start==`number`&&typeof e.end==`number`):[]}function Lb(e,t){if(t.length===0)return e;let n=t.map(t=>({start:Math.max(0,Math.min(e.length,t.start)),end:Math.max(0,Math.min(e.length,t.end))})).filter(e=>e.end>e.start).sort((e,t)=>e.start-t.start);if(n.length===0)return e;let r=0,i=``;for(let t of n){if(t.start<r){t.end>r&&(r=t.end);continue}i+=e.slice(r,t.start),r=t.end}return i+=e.slice(r),i.trimEnd()}function Rb(e){if(zb(e))return Bb(e);let t=Cee(Yh(e.metadata)?e.metadata:void 0),n=new Map;for(let e of t){let t=n.get(e.partIndex)??[];t.push({start:e.start,end:e.end}),n.set(e.partIndex,t)}let r=e.parts.flatMap((e,t)=>{let r={...e},i=n.get(t);if(r.type!==`text`||i===void 0)return[r];let a=Lb(r.text,i);return a.length===0?[]:[{...r,text:a}]}),i={...e,parts:r};if(Yh(e.metadata)){let t={...e.metadata};delete t.reminders,Object.keys(t).length>0?i.metadata=t:delete i.metadata}return i}function zb(e){let t=e.metadata;if(!Yh(t))return!1;let n=t.synthetic;return Yh(n)?n.source===`reminder`:!1}function Bb(e){let t={...e,parts:e.parts.filter(e=>e.type!==`text`)};if(Yh(e.metadata)){let n={...e.metadata};delete n.synthetic,Object.keys(n).length>0?t.metadata=n:delete t.metadata}return t}var Vb=(0,R.createContext)({});function Hb(e){let t=(0,R.useRef)(null);return t.current===null&&(t.current=e()),t.current}var Ub=typeof window<`u`?R.useLayoutEffect:R.useEffect,Wb=(0,R.createContext)(null);function Gb(e,t){e.indexOf(t)===-1&&e.push(t)}function Kb(e,t){let n=e.indexOf(t);n>-1&&e.splice(n,1)}var qb=(e,t,n)=>n>t?t:n<e?e:n,Jb={},Yb=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e),Xb=e=>typeof e==`object`&&!!e,Zb=e=>/^0[^.\s]+$/u.test(e);function Qb(e){let t;return()=>(t===void 0&&(t=e()),t)}var $b=e=>e,ex=(...e)=>e.reduce((e,t)=>n=>t(e(n))),tx=(e,t,n)=>{let r=t-e;return r?(n-e)/r:1},nx=class{constructor(){this.subscriptions=[]}add(e){return Gb(this.subscriptions,e),()=>Kb(this.subscriptions,e)}notify(e,t,n){let r=this.subscriptions.length;if(r)if(r===1)this.subscriptions[0](e,t,n);else for(let i=0;i<r;i++){let r=this.subscriptions[i];r&&r(e,t,n)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}},rx=e=>e*1e3,ix=e=>e/1e3,ax=(e,t)=>t?1e3/t*e:0,ox=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,sx=1e-7,cx=12;function lx(e,t,n,r,i){let a,o,s=0;do o=t+(n-t)/2,a=ox(o,r,i)-e,a>0?n=o:t=o;while(Math.abs(a)>sx&&++s<cx);return o}function ux(e,t,n,r){if(e===t&&n===r)return $b;let i=t=>lx(t,0,1,e,n);return e=>e===0||e===1?e:ox(i(e),t,r)}var dx=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,fx=e=>t=>1-e(1-t),px=ux(.33,1.53,.69,.99),mx=fx(px),hx=dx(mx),gx=e=>e>=1?1:(e*=2)<1?.5*mx(e):.5*(2-2**(-10*(e-1))),_x=e=>1-Math.sin(Math.acos(e)),vx=fx(_x),yx=dx(_x),bx=ux(.42,0,1,1),xx=ux(0,0,.58,1),Sx=ux(.42,0,.58,1),Cx=e=>Array.isArray(e)&&typeof e[0]!=`number`,wx=e=>Array.isArray(e)&&typeof e[0]==`number`,Tx={linear:$b,easeIn:bx,easeInOut:Sx,easeOut:xx,circIn:_x,circInOut:yx,circOut:vx,backIn:mx,backInOut:hx,backOut:px,anticipate:gx},Ex=e=>typeof e==`string`,Dx=e=>{if(wx(e)){e.length;let[t,n,r,i]=e;return ux(t,n,r,i)}else if(Ex(e))return Tx[e],`${e}`,Tx[e];return e},Ox=[`setup`,`read`,`resolveKeyframes`,`preUpdate`,`update`,`preRender`,`render`,`postRender`];function kx(e){let t=new Set,n=new Set,r=!1,i=!1,a=new WeakSet,o={delta:0,timestamp:0,isProcessing:!1};function s(t){a.has(t)&&(c.schedule(t),e()),t(o)}let c={schedule:(e,i=!1,o=!1)=>{let s=o&&r?t:n;return i&&a.add(e),s.add(e),e},cancel:e=>{n.delete(e),a.delete(e)},process:e=>{if(o=e,r){i=!0;return}r=!0;let a=t;t=n,n=a,t.forEach(s),t.clear(),r=!1,i&&(i=!1,c.process(e))}};return c}var Ax=40;function jx(e,t){let n=!1,r=!0,i={delta:0,timestamp:0,isProcessing:!1},a=()=>n=!0,o=Ox.reduce((e,t)=>(e[t]=kx(a),e),{}),{setup:s,read:c,resolveKeyframes:l,preUpdate:u,update:d,preRender:f,render:p,postRender:m}=o,h=()=>{let a=Jb.useManualTiming,o=a?i.timestamp:performance.now();n=!1,a||(i.delta=r?1e3/60:Math.max(Math.min(o-i.timestamp,Ax),1)),i.timestamp=o,i.isProcessing=!0,s.process(i),c.process(i),l.process(i),u.process(i),d.process(i),f.process(i),p.process(i),m.process(i),i.isProcessing=!1,n&&t&&(r=!1,e(h))},g=()=>{n=!0,r=!0,i.isProcessing||e(h)};return{schedule:Ox.reduce((e,t)=>{let r=o[t];return e[t]=(e,t=!1,i=!1)=>(n||g(),r.schedule(e,t,i)),e},{}),cancel:e=>{for(let t=0;t<Ox.length;t++)o[Ox[t]].cancel(e)},state:i,steps:o}}var{schedule:Mx,cancel:Nx,state:Px,steps:Fx}=jx(typeof requestAnimationFrame<`u`?requestAnimationFrame:$b,!0),Ix;function Lx(){Ix=void 0}var Rx={now:()=>(Ix===void 0&&Rx.set(Px.isProcessing||Jb.useManualTiming?Px.timestamp:performance.now()),Ix),set:e=>{Ix=e,queueMicrotask(Lx)}},zx=e=>t=>typeof t==`string`&&t.startsWith(e),Bx=zx(`--`),Vx=zx(`var(--`),Hx=e=>Vx(e)?Ux.test(e.split(`/*`)[0].trim()):!1,Ux=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function Wx(e){return typeof e==`string`&&e.split(`/*`)[0].includes(`var(--`)}var Gx={test:e=>typeof e==`number`,parse:parseFloat,transform:e=>e},Kx={...Gx,transform:e=>qb(0,1,e)},qx={...Gx,default:1},Jx=e=>Math.round(e*1e5)/1e5,Yx=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function Xx(e){return e==null}var Zx=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Qx=(e,t)=>n=>!!(typeof n==`string`&&Zx.test(n)&&n.startsWith(e)||t&&!Xx(n)&&Object.prototype.hasOwnProperty.call(n,t)),$x=(e,t,n)=>r=>{if(typeof r!=`string`)return r;let[i,a,o,s]=r.match(Yx);return{[e]:parseFloat(i),[t]:parseFloat(a),[n]:parseFloat(o),alpha:s===void 0?1:parseFloat(s)}},eS=e=>qb(0,255,e),tS={...Gx,transform:e=>Math.round(eS(e))},nS={test:Qx(`rgb`,`red`),parse:$x(`red`,`green`,`blue`),transform:({red:e,green:t,blue:n,alpha:r=1})=>`rgba(`+tS.transform(e)+`, `+tS.transform(t)+`, `+tS.transform(n)+`, `+Jx(Kx.transform(r))+`)`};function rS(e){let t=``,n=``,r=``,i=``;return e.length>5?(t=e.substring(1,3),n=e.substring(3,5),r=e.substring(5,7),i=e.substring(7,9)):(t=e.substring(1,2),n=e.substring(2,3),r=e.substring(3,4),i=e.substring(4,5),t+=t,n+=n,r+=r,i+=i),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(r,16),alpha:i?parseInt(i,16)/255:1}}var iS={test:Qx(`#`),parse:rS,transform:nS.transform},aS=e=>({test:t=>typeof t==`string`&&t.endsWith(e)&&t.split(` `).length===1,parse:parseFloat,transform:t=>`${t}${e}`}),oS=aS(`deg`),sS=aS(`%`),W=aS(`px`),cS=aS(`vh`),lS=aS(`vw`),uS={...sS,parse:e=>sS.parse(e)/100,transform:e=>sS.transform(e*100)},dS={test:Qx(`hsl`,`hue`),parse:$x(`hue`,`saturation`,`lightness`),transform:({hue:e,saturation:t,lightness:n,alpha:r=1})=>`hsla(`+Math.round(e)+`, `+sS.transform(Jx(t))+`, `+sS.transform(Jx(n))+`, `+Jx(Kx.transform(r))+`)`},fS={test:e=>nS.test(e)||iS.test(e)||dS.test(e),parse:e=>nS.test(e)?nS.parse(e):dS.test(e)?dS.parse(e):iS.parse(e),transform:e=>typeof e==`string`?e:e.hasOwnProperty(`red`)?nS.transform(e):dS.transform(e),getAnimatableNone:e=>{let t=fS.parse(e);return t.alpha=0,fS.transform(t)}},pS=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function mS(e){return isNaN(e)&&typeof e==`string`&&(e.match(Yx)?.length||0)+(e.match(pS)?.length||0)>0}var hS=`number`,gS=`color`,_S=`var`,vS=`var(`,yS="${}",bS=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function xS(e){let t=e.toString(),n=[],r={color:[],number:[],var:[]},i=[],a=0;return{values:n,split:t.replace(bS,e=>(fS.test(e)?(r.color.push(a),i.push(gS),n.push(fS.parse(e))):e.startsWith(vS)?(r.var.push(a),i.push(_S),n.push(e)):(r.number.push(a),i.push(hS),n.push(parseFloat(e))),++a,yS)).split(yS),indexes:r,types:i}}function SS(e){return xS(e).values}function CS({split:e,types:t}){let n=e.length;return r=>{let i=``;for(let a=0;a<n;a++)if(i+=e[a],r[a]!==void 0){let e=t[a];e===hS?i+=Jx(r[a]):e===gS?i+=fS.transform(r[a]):i+=r[a]}return i}}function wS(e){return CS(xS(e))}var TS=e=>typeof e==`number`?0:fS.test(e)?fS.getAnimatableNone(e):e,ES=(e,t)=>typeof e==`number`?t?.trim().endsWith(`/`)?e:0:TS(e);function DS(e){let t=xS(e);return CS(t)(t.values.map((e,n)=>ES(e,t.split[n])))}var OS={test:mS,parse:SS,createTransformer:wS,getAnimatableNone:DS};function kS(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function AS({hue:e,saturation:t,lightness:n,alpha:r}){e/=360,t/=100,n/=100;let i=0,a=0,o=0;if(!t)i=a=o=n;else{let r=n<.5?n*(1+t):n+t-n*t,s=2*n-r;i=kS(s,r,e+1/3),a=kS(s,r,e),o=kS(s,r,e-1/3)}return{red:Math.round(i*255),green:Math.round(a*255),blue:Math.round(o*255),alpha:r}}function jS(e,t){return n=>n>0?t:e}var MS=(e,t,n)=>e+(t-e)*n,NS=(e,t,n)=>{let r=e*e,i=n*(t*t-r)+r;return i<0?0:Math.sqrt(i)},PS=[iS,nS,dS],FS=e=>PS.find(t=>t.test(e));function IS(e){let t=FS(e);if(`${e}`,!t)return!1;let n=t.parse(e);return t===dS&&(n=AS(n)),n}var LS=(e,t)=>{let n=IS(e),r=IS(t);if(!n||!r)return jS(e,t);let i={...n};return e=>(i.red=NS(n.red,r.red,e),i.green=NS(n.green,r.green,e),i.blue=NS(n.blue,r.blue,e),i.alpha=MS(n.alpha,r.alpha,e),nS.transform(i))},RS=new Set([`none`,`hidden`]);function zS(e,t){return RS.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function BS(e,t){return n=>MS(e,t,n)}function VS(e){return typeof e==`number`?BS:typeof e==`string`?Hx(e)?jS:fS.test(e)?LS:GS:Array.isArray(e)?HS:typeof e==`object`?fS.test(e)?LS:US:jS}function HS(e,t){let n=[...e],r=n.length,i=e.map((e,n)=>VS(e)(e,t[n]));return e=>{for(let t=0;t<r;t++)n[t]=i[t](e);return n}}function US(e,t){let n={...e,...t},r={};for(let i in n)e[i]!==void 0&&t[i]!==void 0&&(r[i]=VS(e[i])(e[i],t[i]));return e=>{for(let t in r)n[t]=r[t](e);return n}}function WS(e,t){let n=[],r={color:0,var:0,number:0};for(let i=0;i<t.values.length;i++){let a=t.types[i],o=e.indexes[a][r[a]];n[i]=e.values[o]??0,r[a]++}return n}var GS=(e,t)=>{let n=OS.createTransformer(t),r=xS(e),i=xS(t);return r.indexes.var.length===i.indexes.var.length&&r.indexes.color.length===i.indexes.color.length&&r.indexes.number.length>=i.indexes.number.length?RS.has(e)&&!i.values.length||RS.has(t)&&!r.values.length?zS(e,t):ex(HS(WS(r,i),i.values),n):(`${e}${t}`,jS(e,t))};function KS(e,t,n){return typeof e==`number`&&typeof t==`number`&&typeof n==`number`?MS(e,t,n):VS(e)(e,t)}var qS=e=>{let t=({timestamp:t})=>e(t);return{start:(e=!0)=>Mx.update(t,e),stop:()=>Nx(t),now:()=>Px.isProcessing?Px.timestamp:Rx.now()}},JS=(e,t,n=10)=>{let r=``,i=Math.max(Math.round(t/n),2);for(let t=0;t<i;t++)r+=Math.round(e(t/(i-1))*1e4)/1e4+`, `;return`linear(${r.substring(0,r.length-2)})`},YS=2e4;function XS(e){let t=0,n=e.next(t);for(;!n.done&&t<2e4;)t+=50,n=e.next(t);return t>=2e4?1/0:t}function ZS(e,t=100,n){let r=n({...e,keyframes:[0,t]}),i=Math.min(XS(r),YS);return{type:`keyframes`,ease:e=>r.next(i*e).value/t,duration:ix(i)}}var QS={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1};function $S(e,t){return e*Math.sqrt(1-t*t)}var eC=12;function tC(e,t,n){let r=n;for(let n=1;n<eC;n++)r-=e(r)/t(r);return r}var nC=.001;function rC({duration:e=QS.duration,bounce:t=QS.bounce,velocity:n=QS.velocity,mass:r=QS.mass}){let i,a;QS.maxDuration;let o=1-t;o=qb(QS.minDamping,QS.maxDamping,o),e=qb(QS.minDuration,QS.maxDuration,ix(e)),o<1?(i=t=>{let r=t*o,i=r*e,a=r-n,s=$S(t,o),c=Math.exp(-i);return nC-a/s*c},a=t=>{let r=t*o*e,a=r*n+n,s=o**2*t**2*e,c=Math.exp(-r),l=$S(t**2,o);return(-i(t)+nC>0?-1:1)*((a-s)*c)/l}):(i=t=>-.001+Math.exp(-t*e)*((t-n)*e+1),a=t=>Math.exp(-t*e)*((n-t)*(e*e)));let s=5/e,c=tC(i,a,s);if(e=rx(e),isNaN(c))return{stiffness:QS.stiffness,damping:QS.damping,duration:e};{let t=c**2*r;return{stiffness:t,damping:o*2*Math.sqrt(r*t),duration:e}}}var iC=[`duration`,`bounce`],aC=[`stiffness`,`damping`,`mass`];function oC(e,t){return t.some(t=>e[t]!==void 0)}function sC(e){let t={velocity:QS.velocity,stiffness:QS.stiffness,damping:QS.damping,mass:QS.mass,isResolvedFromDuration:!1,...e};if(!oC(e,aC)&&oC(e,iC))if(t.velocity=0,e.visualDuration){let n=e.visualDuration,r=2*Math.PI/(n*1.2),i=r*r,a=2*qb(.05,1,1-(e.bounce||0))*Math.sqrt(i);t={...t,mass:QS.mass,stiffness:i,damping:a}}else{let n=rC({...e,velocity:0});t={...t,...n,mass:QS.mass},t.isResolvedFromDuration=!0}return t}function cC(e=QS.visualDuration,t=QS.bounce){let n=typeof e==`object`?e:{visualDuration:e,keyframes:[0,1],bounce:t},{restSpeed:r,restDelta:i}=n,a=n.keyframes[0],o=n.keyframes[n.keyframes.length-1],s={done:!1,value:a},{stiffness:c,damping:l,mass:u,duration:d,velocity:f,isResolvedFromDuration:p}=sC({...n,velocity:-ix(n.velocity||0)}),m=f||0,h=l/(2*Math.sqrt(c*u)),g=o-a,_=ix(Math.sqrt(c/u)),v=Math.abs(g)<5;r||=v?QS.restSpeed.granular:QS.restSpeed.default,i||=v?QS.restDelta.granular:QS.restDelta.default;let y,b,x,S,C,w;if(h<1)x=$S(_,h),S=(m+h*_*g)/x,y=e=>{let t=Math.exp(-h*_*e);return o-t*(S*Math.sin(x*e)+g*Math.cos(x*e))},C=h*_*S+g*x,w=h*_*g-S*x,b=e=>Math.exp(-h*_*e)*(C*Math.sin(x*e)+w*Math.cos(x*e));else if(h===1){y=e=>o-Math.exp(-_*e)*(g+(m+_*g)*e);let e=m+_*g;b=t=>Math.exp(-_*t)*(_*e*t-m)}else{let e=_*Math.sqrt(h*h-1);y=t=>{let n=Math.exp(-h*_*t),r=Math.min(e*t,300);return o-n*((m+h*_*g)*Math.sinh(r)+e*g*Math.cosh(r))/e};let t=(m+h*_*g)/e,n=h*_*t-g*e,r=h*_*g-t*e;b=t=>{let i=Math.exp(-h*_*t),a=Math.min(e*t,300);return i*(n*Math.sinh(a)+r*Math.cosh(a))}}let T={calculatedDuration:p&&d||null,velocity:e=>rx(b(e)),next:e=>{if(!p&&h<1){let t=Math.exp(-h*_*e),n=Math.sin(x*e),a=Math.cos(x*e),c=o-t*(S*n+g*a),l=rx(t*(C*n+w*a));return s.done=Math.abs(l)<=r&&Math.abs(o-c)<=i,s.value=s.done?o:c,s}let t=y(e);if(p)s.done=e>=d;else{let n=rx(b(e));s.done=Math.abs(n)<=r&&Math.abs(o-t)<=i}return s.value=s.done?o:t,s},toString:()=>{let e=Math.min(XS(T),YS),t=JS(t=>T.next(e*t).value,e,30);return e+`ms `+t},toTransition:()=>{}};return T}cC.applyToOptions=e=>{let t=ZS(e,100,cC);return e.ease=t.ease,e.duration=rx(t.duration),e.type=`keyframes`,e};var lC=5;function uC(e,t,n){let r=Math.max(t-lC,0);return ax(n-e(r),t-r)}function dC({keyframes:e,velocity:t=0,power:n=.8,timeConstant:r=325,bounceDamping:i=10,bounceStiffness:a=500,modifyTarget:o,min:s,max:c,restDelta:l=.5,restSpeed:u}){let d=e[0],f={done:!1,value:d},p=e=>s!==void 0&&e<s||c!==void 0&&e>c,m=e=>s===void 0?c:c===void 0||Math.abs(s-e)<Math.abs(c-e)?s:c,h=n*t,g=d+h,_=o===void 0?g:o(g);_!==g&&(h=_-d);let v=e=>-h*Math.exp(-e/r),y=e=>_+v(e),b=e=>{let t=v(e),n=y(e);f.done=Math.abs(t)<=l,f.value=f.done?_:n},x,S,C=e=>{p(f.value)&&(x=e,S=cC({keyframes:[f.value,m(f.value)],velocity:uC(y,e,f.value),damping:i,stiffness:a,restDelta:l,restSpeed:u}))};return C(0),{calculatedDuration:null,next:e=>{let t=!1;return!S&&x===void 0&&(t=!0,b(e),C(e)),x!==void 0&&e>=x?S.next(e-x):(!t&&b(e),f)}}}function fC(e,t,n){let r=[],i=n||Jb.mix||KS,a=e.length-1;for(let n=0;n<a;n++){let a=i(e[n],e[n+1]);t&&(a=ex(Array.isArray(t)?t[n]||$b:t,a)),r.push(a)}return r}function pC(e,t,{clamp:n=!0,ease:r,mixer:i}={}){let a=e.length;if(t.length,a===1)return()=>t[0];if(a===2&&t[0]===t[1])return()=>t[1];let o=e[0]===e[1];e[0]>e[a-1]&&(e=[...e].reverse(),t=[...t].reverse());let s=fC(t,r,i),c=s.length,l=n=>{if(o&&n<e[0])return t[0];let r=0;if(c>1)for(;r<e.length-2&&!(n<e[r+1]);r++);let i=tx(e[r],e[r+1],n);return s[r](i)};return n?t=>l(qb(e[0],e[a-1],t)):l}function mC(e,t){let n=e[e.length-1];for(let r=1;r<=t;r++){let i=tx(0,t,r);e.push(MS(n,1,i))}}function hC(e){let t=[0];return mC(t,e.length-1),t}function gC(e,t){return e.map(e=>e*t)}function _C(e,t){return e.map(()=>t||Sx).splice(0,e.length-1)}function vC({duration:e=300,keyframes:t,times:n,ease:r=`easeInOut`}){let i=Cx(r)?r.map(Dx):Dx(r),a={done:!1,value:t[0]},o=pC(gC(n&&n.length===t.length?n:hC(t),e),t,{ease:Array.isArray(i)?i:_C(t,i)});return{calculatedDuration:e,next:t=>(a.value=o(t),a.done=t>=e,a)}}var yC=e=>e!==null;function bC(e,{repeat:t,repeatType:n=`loop`},r,i=1){let a=e.filter(yC),o=i<0||t&&n!==`loop`&&t%2==1?0:a.length-1;return!o||r===void 0?a[o]:r}var xC={decay:dC,inertia:dC,tween:vC,keyframes:vC,spring:cC};function SC(e){typeof e.type==`string`&&(e.type=xC[e.type])}var CC=class{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(e=>{this.resolve=e})}notifyFinished(){this.resolve()}then(e,t){return this.finished.then(e,t)}},wC=e=>e/100,TC=class extends CC{constructor(e){super(),this.state=`idle`,this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.delayState={done:!1,value:void 0},this.stop=()=>{let{motionValue:e}=this.options;e&&e.updatedAt!==Rx.now()&&this.tick(Rx.now()),this.isStopped=!0,this.state!==`idle`&&(this.teardown(),this.options.onStop?.())},this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause()}initAnimation(){let{options:e}=this;SC(e);let{type:t=vC,repeat:n=0,repeatDelay:r=0,repeatType:i,velocity:a=0}=e,{keyframes:o}=e,s=t||vC;s!==vC&&typeof o[0]!=`number`&&(this.mixKeyframes=ex(wC,KS(o[0],o[1])),o=[0,100]);let c=s({...e,keyframes:o});i===`mirror`&&(this.mirroredGenerator=s({...e,keyframes:[...o].reverse(),velocity:-a})),c.calculatedDuration===null&&(c.calculatedDuration=XS(c));let{calculatedDuration:l}=c;this.calculatedDuration=l,this.resolvedDuration=l+r,this.totalDuration=this.resolvedDuration*(n+1)-r,this.generator=c}updateTime(e){let t=Math.round(e-this.startTime)*this.playbackSpeed;this.holdTime===null?this.currentTime=t:this.currentTime=this.holdTime}tick(e,t=!1){let{generator:n,totalDuration:r,mixKeyframes:i,mirroredGenerator:a,resolvedDuration:o,calculatedDuration:s}=this;if(this.startTime===null)return n.next(0);let{delay:c=0,keyframes:l,repeat:u,repeatType:d,repeatDelay:f,type:p,onUpdate:m,finalKeyframe:h}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-r/this.speed,this.startTime)),t?this.currentTime=e:this.updateTime(e);let g=this.currentTime-c*(this.playbackSpeed>=0?1:-1),_=this.playbackSpeed>=0?g<0:g>r;this.currentTime=Math.max(g,0),this.state===`finished`&&this.holdTime===null&&(this.currentTime=r);let v=this.currentTime,y=n;if(u){let e=Math.min(this.currentTime,r)/o,t=Math.floor(e),n=e%1;!n&&e>=1&&(n=1),n===1&&t--,t=Math.min(t,u+1),t%2&&(d===`reverse`?(n=1-n,f&&(n-=f/o)):d===`mirror`&&(y=a)),v=qb(0,1,n)*o}let b;_?(this.delayState.value=l[0],b=this.delayState):b=y.next(v),i&&!_&&(b.value=i(b.value));let{done:x}=b;!_&&s!==null&&(x=this.playbackSpeed>=0?this.currentTime>=r:this.currentTime<=0);let S=this.holdTime===null&&(this.state===`finished`||this.state===`running`&&x);return S&&p!==dC&&(b.value=bC(l,this.options,h,this.speed)),m&&m(b.value),S&&this.finish(),b}then(e,t){return this.finished.then(e,t)}get duration(){return ix(this.calculatedDuration)}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+ix(e)}get time(){return ix(this.currentTime)}set time(e){e=rx(e),this.currentTime=e,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.playbackSpeed),this.driver?this.driver.start(!1):(this.startTime=0,this.state=`paused`,this.holdTime=e,this.tick(e))}getGeneratorVelocity(){let e=this.currentTime;if(e<=0)return this.options.velocity||0;if(this.generator.velocity)return this.generator.velocity(e);let t=this.generator.next(e).value;return uC(e=>this.generator.next(e).value,e,t)}get speed(){return this.playbackSpeed}set speed(e){let t=this.playbackSpeed!==e;t&&this.driver&&this.updateTime(Rx.now()),this.playbackSpeed=e,t&&this.driver&&(this.time=ix(this.currentTime))}play(){if(this.isStopped)return;let{driver:e=qS,startTime:t}=this.options;this.driver||=e(e=>this.tick(e)),this.options.onPlay?.();let n=this.driver.now();this.state===`finished`?(this.updateFinished(),this.startTime=n):this.holdTime===null?this.startTime||=t??n:this.startTime=n-this.holdTime,this.state===`finished`&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state=`running`,this.driver.start()}pause(){this.state=`paused`,this.updateTime(Rx.now()),this.holdTime=this.currentTime}complete(){this.state!==`running`&&this.play(),this.state=`finished`,this.holdTime=null}finish(){this.notifyFinished(),this.teardown(),this.state=`finished`,this.options.onComplete?.()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),this.options.onCancel?.()}teardown(){this.state=`idle`,this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&=(this.driver.stop(),void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}attachTimeline(e){return this.options.allowFlatten&&(this.options.type=`keyframes`,this.options.ease=`linear`,this.initAnimation()),this.driver?.stop(),e.observe(this)}};function EC(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}var DC=e=>e*180/Math.PI,OC=e=>AC(DC(Math.atan2(e[1],e[0]))),kC={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:OC,rotateZ:OC,skewX:e=>DC(Math.atan(e[1])),skewY:e=>DC(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},AC=e=>(e%=360,e<0&&(e+=360),e),jC=OC,MC=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),NC=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),PC={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:MC,scaleY:NC,scale:e=>(MC(e)+NC(e))/2,rotateX:e=>AC(DC(Math.atan2(e[6],e[5]))),rotateY:e=>AC(DC(Math.atan2(-e[2],e[0]))),rotateZ:jC,rotate:jC,skewX:e=>DC(Math.atan(e[4])),skewY:e=>DC(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function FC(e){return+!!e.includes(`scale`)}function IC(e,t){if(!e||e===`none`)return FC(t);let n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u),r,i;if(n)r=PC,i=n;else{let t=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);r=kC,i=t}if(!i)return FC(t);let a=r[t],o=i[1].split(`,`).map(RC);return typeof a==`function`?a(o):o[a]}var LC=(e,t)=>{let{transform:n=`none`}=getComputedStyle(e);return IC(n,t)};function RC(e){return parseFloat(e.trim())}var zC=[`transformPerspective`,`x`,`y`,`z`,`translateX`,`translateY`,`translateZ`,`scale`,`scaleX`,`scaleY`,`rotate`,`rotateX`,`rotateY`,`rotateZ`,`skew`,`skewX`,`skewY`],BC=new Set([...zC,`pathRotation`]),VC=e=>e===Gx||e===W,HC=new Set([`x`,`y`,`z`]),UC=zC.filter(e=>!HC.has(e));function WC(e){let t=[];return UC.forEach(n=>{let r=e.getValue(n);r!==void 0&&(t.push([n,r.get()]),r.set(+!!n.startsWith(`scale`)))}),t}var GC={width:({x:e},{paddingLeft:t=`0`,paddingRight:n=`0`,boxSizing:r})=>{let i=e.max-e.min;return r===`border-box`?i:i-parseFloat(t)-parseFloat(n)},height:({y:e},{paddingTop:t=`0`,paddingBottom:n=`0`,boxSizing:r})=>{let i=e.max-e.min;return r===`border-box`?i:i-parseFloat(t)-parseFloat(n)},top:(e,{top:t})=>parseFloat(t),left:(e,{left:t})=>parseFloat(t),bottom:({y:e},{top:t})=>parseFloat(t)+(e.max-e.min),right:({x:e},{left:t})=>parseFloat(t)+(e.max-e.min),x:(e,{transform:t})=>IC(t,`x`),y:(e,{transform:t})=>IC(t,`y`)};GC.translateX=GC.x,GC.translateY=GC.y;var KC=new Set,qC=!1,JC=!1,YC=!1;function XC(){if(JC){let e=Array.from(KC).filter(e=>e.needsMeasurement),t=new Set(e.map(e=>e.element)),n=new Map;t.forEach(e=>{let t=WC(e);t.length&&(n.set(e,t),e.render())}),e.forEach(e=>e.measureInitialState()),t.forEach(e=>{e.render();let t=n.get(e);t&&t.forEach(([t,n])=>{e.getValue(t)?.set(n)})}),e.forEach(e=>e.measureEndState()),e.forEach(e=>{e.suspendedScrollY!==void 0&&window.scrollTo(0,e.suspendedScrollY)})}JC=!1,qC=!1,KC.forEach(e=>e.complete(YC)),KC.clear()}function ZC(){KC.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(JC=!0)})}function QC(){YC=!0,ZC(),XC(),YC=!1}var $C=class{constructor(e,t,n,r,i,a=!1){this.state=`pending`,this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=t,this.name=n,this.motionValue=r,this.element=i,this.isAsync=a}scheduleResolve(){this.state=`scheduled`,this.isAsync?(KC.add(this),qC||(qC=!0,Mx.read(ZC),Mx.resolveKeyframes(XC))):(this.readKeyframes(),this.complete())}readKeyframes(){let{unresolvedKeyframes:e,name:t,element:n,motionValue:r}=this;if(e[0]===null){let i=r?.get(),a=e[e.length-1];if(i!==void 0)e[0]=i;else if(n&&t){let r=n.readValue(t,a);r!=null&&(e[0]=r)}e[0]===void 0&&(e[0]=a),r&&i===void 0&&r.set(e[0])}EC(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state=`complete`,this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),KC.delete(this)}cancel(){this.state===`scheduled`&&(KC.delete(this),this.state=`pending`)}resume(){this.state===`pending`&&this.scheduleResolve()}},ew=e=>e.startsWith(`--`);function tw(e,t,n){ew(t)?e.style.setProperty(t,n):e.style[t]=n}var nw={};function rw(e,t){let n=Qb(e);return()=>nw[t]??n()}var iw=rw(()=>window.ScrollTimeline!==void 0,`scrollTimeline`),aw=rw(()=>{try{document.createElement(`div`).animate({opacity:0},{easing:`linear(0, 1)`})}catch{return!1}return!0},`linearEasing`),ow=([e,t,n,r])=>`cubic-bezier(${e}, ${t}, ${n}, ${r})`,sw={linear:`linear`,ease:`ease`,easeIn:`ease-in`,easeOut:`ease-out`,easeInOut:`ease-in-out`,circIn:ow([0,.65,.55,1]),circOut:ow([.55,0,1,.45]),backIn:ow([.31,.01,.66,-.59]),backOut:ow([.33,1.53,.69,.99])};function cw(e,t){if(e)return typeof e==`function`?aw()?JS(e,t):`ease-out`:wx(e)?ow(e):Array.isArray(e)?e.map(e=>cw(e,t)||sw.easeOut):sw[e]}function lw(e,t,n,{delay:r=0,duration:i=300,repeat:a=0,repeatType:o=`loop`,ease:s=`easeOut`,times:c}={},l=void 0){let u={[t]:n};c&&(u.offset=c);let d=cw(s,i);Array.isArray(d)&&(u.easing=d);let f={delay:r,duration:i,easing:Array.isArray(d)?`linear`:d,fill:`both`,iterations:a+1,direction:o===`reverse`?`alternate`:`normal`};return l&&(f.pseudoElement=l),e.animate(u,f)}function uw(e){return typeof e==`function`&&`applyToOptions`in e}function dw({type:e,...t}){return uw(e)&&aw()?e.applyToOptions(t):(t.duration??=300,t.ease??=`easeOut`,t)}var fw=class extends CC{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!e)return;let{element:t,name:n,keyframes:r,pseudoElement:i,allowFlatten:a=!1,finalKeyframe:o,onComplete:s}=e;this.isPseudoElement=!!i,this.allowFlatten=a,this.options=e,e.type;let c=dw(e);this.animation=lw(t,n,r,c,i),c.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!i){let e=bC(r,this.options,o,this.speed);this.updateMotionValue&&this.updateMotionValue(e),tw(t,n,e),this.animation.cancel()}s?.(),this.notifyFinished()}}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),this.state===`finished`&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;let{state:e}=this;e===`idle`||e===`finished`||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){let e=this.options?.element;!this.isPseudoElement&&e?.isConnected&&this.animation.commitStyles?.()}get duration(){let e=this.animation.effect?.getComputedTiming?.().duration||0;return ix(Number(e))}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+ix(e)}get time(){return ix(Number(this.animation.currentTime)||0)}set time(e){let t=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=rx(e),t&&this.animation.pause()}get speed(){return this.animation.playbackRate}set speed(e){e<0&&(this.finishedTime=null),this.animation.playbackRate=e}get state(){return this.finishedTime===null?this.animation.playState:`finished`}get startTime(){return this.manualStartTime??Number(this.animation.startTime)}set startTime(e){this.manualStartTime=this.animation.startTime=e}attachTimeline({timeline:e,rangeStart:t,rangeEnd:n,observe:r}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:`linear`}),this.animation.onfinish=null,e&&iw()?(this.animation.timeline=e,t&&(this.animation.rangeStart=t),n&&(this.animation.rangeEnd=n),$b):r(this)}},pw={anticipate:gx,backInOut:hx,circInOut:yx};function mw(e){return e in pw}function hw(e){typeof e.ease==`string`&&mw(e.ease)&&(e.ease=pw[e.ease])}var gw=10,_w=class extends fw{constructor(e){hw(e),SC(e),super(e),e.startTime!==void 0&&e.autoplay!==!1&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){let{motionValue:t,onUpdate:n,onComplete:r,element:i,...a}=this.options;if(!t)return;if(e!==void 0){t.set(e);return}let o=new TC({...a,autoplay:!1}),s=Math.max(gw,Rx.now()-this.startTime),c=qb(0,gw,s-gw),l=o.sample(s).value,{name:u}=this.options;i&&u&&tw(i,u,l),t.setWithVelocity(o.sample(Math.max(0,s-c)).value,l,c),o.stop()}},vw=(e,t)=>t!==`zIndex`&&!!(typeof e==`number`||Array.isArray(e)||typeof e==`string`&&(OS.test(e)||e===`0`)&&!e.startsWith(`url(`));function yw(e){let t=e[0];if(e.length===1)return!0;for(let n=0;n<e.length;n++)if(e[n]!==t)return!0}function bw(e,t,n,r){let i=e[0];if(i===null)return!1;if(t===`display`||t===`visibility`)return!0;let a=e[e.length-1],o=vw(i,t),s=vw(a,t);return`${t}${i}${a}${o?a:i}`,!o||!s?!1:yw(e)||(n===`spring`||uw(n))&&r}function xw(e){e.duration=0,e.type=`keyframes`}var Sw=new Set([`opacity`,`clipPath`,`filter`,`transform`]),Cw=/^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;function ww(e){for(let t=0;t<e.length;t++)if(typeof e[t]==`string`&&Cw.test(e[t]))return!0;return!1}var Tw=new Set([`color`,`backgroundColor`,`outlineColor`,`fill`,`stroke`,`borderColor`,`borderTopColor`,`borderRightColor`,`borderBottomColor`,`borderLeftColor`]),Ew=Qb(()=>Object.hasOwnProperty.call(Element.prototype,`animate`));function Dw(e){let{motionValue:t,name:n,repeatDelay:r,repeatType:i,damping:a,type:o,keyframes:s}=e;if(!(t?.owner?.current instanceof HTMLElement))return!1;let{onUpdate:c,transformTemplate:l}=t.owner.getProps();return Ew()&&n&&(Sw.has(n)||Tw.has(n)&&ww(s))&&(n!==`transform`||!l)&&!c&&!r&&i!==`mirror`&&a!==0&&o!==`inertia`}var Ow=40,kw=class extends CC{constructor({autoplay:e=!0,delay:t=0,type:n=`keyframes`,repeat:r=0,repeatDelay:i=0,repeatType:a=`loop`,keyframes:o,name:s,motionValue:c,element:l,...u}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=Rx.now();let d={autoplay:e,delay:t,type:n,repeat:r,repeatDelay:i,repeatType:a,name:s,motionValue:c,element:l,...u},f=l?.KeyframeResolver||$C;this.keyframeResolver=new f(o,(e,t,n)=>this.onKeyframesResolved(e,t,d,!n),s,c,l),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,t,n,r){this.keyframeResolver=void 0;let{name:i,type:a,velocity:o,delay:s,isHandoff:c,onUpdate:l}=n;this.resolvedAt=Rx.now();let u=!0;bw(e,i,a,o)||(u=!1,(Jb.instantAnimations||!s)&&l?.(bC(e,n,t)),e[0]=e[e.length-1],xw(n),n.repeat=0);let d={startTime:r?this.resolvedAt&&this.resolvedAt-this.createdAt>Ow?this.resolvedAt:this.createdAt:void 0,finalKeyframe:t,...n,keyframes:e},f=u&&!c&&Dw(d),p=d.motionValue?.owner?.current,m;if(f)try{m=new _w({...d,element:p})}catch{m=new TC(d)}else m=new TC(d);m.finished.then(()=>{this.notifyFinished()}).catch($b),this.pendingTimeline&&=(this.stopTimeline=m.attachTimeline(this.pendingTimeline),void 0),this._animation=m}get finished(){return this._animation?this.animation.finished:this._finished}then(e,t){return this.finished.finally(e).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),QC()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(e){this.animation.time=e}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(e){this.animation.speed=e}get startTime(){return this.animation.startTime}attachTimeline(e){return this._animation?this.stopTimeline=this.animation.attachTimeline(e):this.pendingTimeline=e,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation&&this.animation.cancel(),this.keyframeResolver?.cancel()}};function Aw(e,t,n,r=0,i=1){let a=Array.from(e).sort((e,t)=>e.sortNodePosition(t)).indexOf(t),o=e.size,s=(o-1)*r;return typeof n==`function`?n(a,o):i===1?a*r:s-a*r}var jw=30,Mw=e=>!isNaN(parseFloat(e)),Nw={current:void 0},Pw=class{constructor(e,t={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=e=>{let t=Rx.now();if(this.updatedAt!==t&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(e),this.current!==this.prev&&(this.events.change?.notify(this.current),this.dependents))for(let e of this.dependents)e.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=t.owner}setCurrent(e){this.current=e,this.updatedAt=Rx.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=Mw(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return this.on(`change`,e)}on(e,t){this.events[e]||(this.events[e]=new nx);let n=this.events[e].add(t);return e===`change`?()=>{n(),Mx.read(()=>{this.events.change.getSize()||this.stop()})}:n}clearListeners(){for(let e in this.events)this.events[e].clear()}attach(e,t){this.passiveEffect=e,this.stopPassiveEffect=t}set(e){this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e)}setWithVelocity(e,t,n){this.set(t),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-n}jump(e,t=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,t&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.events.change?.notify(this.current)}addDependent(e){this.dependents||=new Set,this.dependents.add(e)}removeDependent(e){this.dependents&&this.dependents.delete(e)}get(){return Nw.current&&Nw.current.push(this),this.current}getPrevious(){return this.prev}getVelocity(){let e=Rx.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>jw)return 0;let t=Math.min(this.updatedAt-this.prevUpdatedAt,jw);return ax(parseFloat(this.current)-parseFloat(this.prevFrameValue),t)}start(e){return this.stop(),new Promise(t=>{this.hasAnimated=!0,this.animation=e(t),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}};function Fw(e,t){return new Pw(e,t)}function Iw(e,t){if(e?.inherit&&t){let{inherit:n,...r}=e;return{...t,...r}}return e}function Lw(e,t){let n=e?.[t]??e?.default??e;return n===e?n:Iw(n,e)}var Rw={type:`spring`,stiffness:500,damping:25,restSpeed:10},zw=e=>({type:`spring`,stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),Bw={type:`keyframes`,duration:.8},Vw={type:`keyframes`,ease:[.25,.1,.35,1],duration:.3},Hw=(e,{keyframes:t})=>t.length>2?Bw:BC.has(e)?e.startsWith(`scale`)?zw(t[1]):Rw:Vw,Uw=new Set([`when`,`delay`,`delayChildren`,`staggerChildren`,`staggerDirection`,`repeat`,`repeatType`,`repeatDelay`,`from`,`elapsed`]);function Ww(e){for(let t in e)if(!Uw.has(t))return!0;return!1}var Gw=(e,t,n,r={},i,a)=>o=>{let s=Lw(r,e)||{},c=s.delay||r.delay||0,{elapsed:l=0}=r;l-=rx(c);let u={keyframes:Array.isArray(n)?n:[null,n],ease:`easeOut`,velocity:t.getVelocity(),...s,delay:-l,onUpdate:e=>{t.set(e),s.onUpdate&&s.onUpdate(e)},onComplete:()=>{o(),s.onComplete&&s.onComplete()},name:e,motionValue:t,element:a?void 0:i};Ww(s)||Object.assign(u,Hw(e,u)),u.duration&&=rx(u.duration),u.repeatDelay&&=rx(u.repeatDelay),u.from!==void 0&&(u.keyframes[0]=u.from);let d=!1;if((u.type===!1||u.duration===0&&!u.repeatDelay)&&(xw(u),u.delay===0&&(d=!0)),(Jb.instantAnimations||Jb.skipAnimations||i?.shouldSkipAnimations||s.skipAnimations)&&(d=!0,xw(u),u.delay=0),u.allowFlatten=!s.type&&!s.ease,d&&!a&&t.get()!==void 0){let e=bC(u.keyframes,s);if(e!==void 0){Mx.update(()=>{u.onUpdate(e),u.onComplete()});return}}return s.isSync?new TC(u):new kw(u)},Kw=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function qw(e){let t=Kw.exec(e);if(!t)return[,];let[,n,r,i]=t;return[`--${n??r}`,i]}function Jw(e,t,n=1){`${e}`;let[r,i]=qw(e);if(!r)return;let a=window.getComputedStyle(t).getPropertyValue(r);if(a){let e=a.trim();return Yb(e)?parseFloat(e):e}return Hx(i)?Jw(i,t,n+1):i}function Yw(e){let t=[{},{}];return e?.values.forEach((e,n)=>{t[0][n]=e.get(),t[1][n]=e.getVelocity()}),t}function Xw(e,t,n,r){if(typeof t==`function`){let[i,a]=Yw(r);t=t(n===void 0?e.custom:n,i,a)}if(typeof t==`string`&&(t=e.variants&&e.variants[t]),typeof t==`function`){let[i,a]=Yw(r);t=t(n===void 0?e.custom:n,i,a)}return t}function Zw(e,t,n){let r=e.getProps();return Xw(r,t,n===void 0?r.custom:n,e)}var Qw=new Set([`width`,`height`,`top`,`left`,`right`,`bottom`,...zC]),$w=e=>Array.isArray(e);function eT(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,Fw(n))}function tT(e){return $w(e)?e[e.length-1]||0:e}function nT(e,t){let{transitionEnd:n={},transition:r={},...i}=Zw(e,t)||{};i={...i,...n};for(let t in i)eT(e,t,tT(i[t]))}var rT=e=>!!(e&&e.getVelocity);function iT(e){return!!(rT(e)&&e.add)}function aT(e,t){let n=e.getValue(`willChange`);if(iT(n))return n.add(t);if(!n&&Jb.WillChange){let n=new Jb.WillChange(`auto`);e.addValue(`willChange`,n),n.add(t)}}function oT(e){return e.replace(/([A-Z])/g,e=>`-${e.toLowerCase()}`)}var sT=`data-`+oT(`framerAppearId`);function cT(e){return e.props[sT]}function lT({protectedKeys:e,needsAnimating:t},n){let r=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,r}function uT(e,t,{delay:n=0,transitionOverride:r,type:i}={}){let{transition:a,transitionEnd:o,...s}=t,c=e.getDefaultTransition();a=a?Iw(a,c):c;let l=a?.reduceMotion,u=a?.skipAnimations;r&&(a=r);let d=[],f=i&&e.animationState&&e.animationState.getState()[i],p=a?.path;p&&p.animateVisualElement(e,s,a,n,d);for(let t in s){let r=e.getValue(t,e.latestValues[t]??null),i=s[t];if(i===void 0||f&&lT(f,t))continue;let o={delay:n,...Lw(a||{},t)};u&&(o.skipAnimations=!0);let c=r.get();if(c!==void 0&&!r.isAnimating()&&!Array.isArray(i)&&i===c&&!o.velocity){Mx.update(()=>r.set(i));continue}let p=!1;if(window.MotionHandoffAnimation){let n=cT(e);if(n){let e=window.MotionHandoffAnimation(n,t,Mx);e!==null&&(o.startTime=e,p=!0)}}aT(e,t);let m=l??e.shouldReduceMotion;r.start(Gw(t,r,i,m&&Qw.has(t)?{type:!1}:o,e,p));let h=r.animation;h&&d.push(h)}if(o){let t=()=>Mx.update(()=>{o&&nT(e,o)});d.length?Promise.all(d).then(t):t()}return d}function dT(e,t,n={}){let r=Zw(e,t,n.type===`exit`?e.presenceContext?.custom:void 0),{transition:i=e.getDefaultTransition()||{}}=r||{};n.transitionOverride&&(i=n.transitionOverride);let a=r?()=>Promise.all(uT(e,r,n)):()=>Promise.resolve(),o=e.variantChildren&&e.variantChildren.size?(r=0)=>{let{delayChildren:a=0,staggerChildren:o,staggerDirection:s}=i;return fT(e,t,r,a,o,s,n)}:()=>Promise.resolve(),{when:s}=i;if(s){let[e,t]=s===`beforeChildren`?[a,o]:[o,a];return e().then(()=>t())}else return Promise.all([a(),o(n.delay)])}function fT(e,t,n=0,r=0,i=0,a=1,o){let s=[];for(let c of e.variantChildren)c.notify(`AnimationStart`,t),s.push(dT(c,t,{...o,delay:n+(typeof r==`function`?0:r)+Aw(e.variantChildren,c,r,i,a)}).then(()=>c.notify(`AnimationComplete`,t)));return Promise.all(s)}function pT(e,t,n={}){e.notify(`AnimationStart`,t);let r;if(Array.isArray(t)){let i=t.map(t=>dT(e,t,n));r=Promise.all(i)}else if(typeof t==`string`)r=dT(e,t,n);else{let i=typeof t==`function`?Zw(e,t,n.custom):t;r=Promise.all(uT(e,i,n))}return r.then(()=>{e.notify(`AnimationComplete`,t)})}var mT={test:e=>e===`auto`,parse:e=>e},hT=e=>t=>t.test(e),gT=[Gx,W,sS,oS,lS,cS,mT],_T=e=>gT.find(hT(e));function vT(e){return typeof e==`number`?e===0:e===null||e===`none`||e===`0`||Zb(e)}var yT=new Set([`brightness`,`contrast`,`saturate`,`opacity`]);function bT(e){let[t,n]=e.slice(0,-1).split(`(`);if(t===`drop-shadow`)return e;let[r]=n.match(Yx)||[];if(!r)return e;let i=n.replace(r,``),a=+!!yT.has(t);return r!==n&&(a*=100),t+`(`+a+i+`)`}var xT=/\b([a-z-]*)\(.*?\)/gu,ST={...OS,getAnimatableNone:e=>{let t=e.match(xT);return t?t.map(bT).join(` `):e}},CT={...OS,getAnimatableNone:e=>{let t=OS.parse(e);return OS.createTransformer(e)(t.map(e=>typeof e==`number`?0:typeof e==`object`?{...e,alpha:1}:e))}},wT={...Gx,transform:Math.round},TT={borderWidth:W,borderTopWidth:W,borderRightWidth:W,borderBottomWidth:W,borderLeftWidth:W,borderRadius:W,borderTopLeftRadius:W,borderTopRightRadius:W,borderBottomRightRadius:W,borderBottomLeftRadius:W,width:W,maxWidth:W,height:W,maxHeight:W,top:W,right:W,bottom:W,left:W,inset:W,insetBlock:W,insetBlockStart:W,insetBlockEnd:W,insetInline:W,insetInlineStart:W,insetInlineEnd:W,padding:W,paddingTop:W,paddingRight:W,paddingBottom:W,paddingLeft:W,paddingBlock:W,paddingBlockStart:W,paddingBlockEnd:W,paddingInline:W,paddingInlineStart:W,paddingInlineEnd:W,margin:W,marginTop:W,marginRight:W,marginBottom:W,marginLeft:W,marginBlock:W,marginBlockStart:W,marginBlockEnd:W,marginInline:W,marginInlineStart:W,marginInlineEnd:W,fontSize:W,backgroundPositionX:W,backgroundPositionY:W,rotate:oS,pathRotation:oS,rotateX:oS,rotateY:oS,rotateZ:oS,scale:qx,scaleX:qx,scaleY:qx,scaleZ:qx,skew:oS,skewX:oS,skewY:oS,distance:W,translateX:W,translateY:W,translateZ:W,x:W,y:W,z:W,perspective:W,transformPerspective:W,opacity:Kx,originX:uS,originY:uS,originZ:W,zIndex:wT,fillOpacity:Kx,strokeOpacity:Kx,numOctaves:wT},ET={...TT,color:fS,backgroundColor:fS,outlineColor:fS,fill:fS,stroke:fS,borderColor:fS,borderTopColor:fS,borderRightColor:fS,borderBottomColor:fS,borderLeftColor:fS,filter:ST,WebkitFilter:ST,mask:CT,WebkitMask:CT},DT=e=>ET[e],OT=new Set([ST,CT]);function kT(e,t){let n=DT(e);return OT.has(n)||(n=OS),n.getAnimatableNone?n.getAnimatableNone(t):void 0}var AT=new Set([`auto`,`none`,`0`]);function jT(e,t,n){let r=0,i;for(;r<e.length&&!i;){let t=e[r];typeof t==`string`&&!AT.has(t)&&xS(t).values.length&&(i=e[r]),r++}if(i&&n)for(let r of t)e[r]=kT(n,i)}var MT=class extends $C{constructor(e,t,n,r,i){super(e,t,n,r,i,!0)}readKeyframes(){let{unresolvedKeyframes:e,element:t,name:n}=this;if(!t||!t.current)return;super.readKeyframes();for(let n=0;n<e.length;n++){let r=e[n];if(typeof r==`string`&&(r=r.trim(),Hx(r))){let i=Jw(r,t.current);i!==void 0&&(e[n]=i),n===e.length-1&&(this.finalKeyframe=r)}}if(this.resolveNoneKeyframes(),!Qw.has(n)||e.length!==2)return;let[r,i]=e,a=_T(r),o=_T(i);if(Wx(r)!==Wx(i)&&GC[n]){this.needsMeasurement=!0;return}if(a!==o)if(VC(a)&&VC(o))for(let t=0;t<e.length;t++){let n=e[t];typeof n==`string`&&(e[t]=parseFloat(n))}else GC[n]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){let{unresolvedKeyframes:e,name:t}=this,n=[];for(let t=0;t<e.length;t++)(e[t]===null||vT(e[t]))&&n.push(t);n.length&&jT(e,n,t)}measureInitialState(){let{element:e,unresolvedKeyframes:t,name:n}=this;if(!e||!e.current)return;n===`height`&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=GC[n](e.measureViewportBox(),window.getComputedStyle(e.current)),t[0]=this.measuredOrigin;let r=t[t.length-1];r!==void 0&&e.getValue(n,r).jump(r,!1)}measureEndState(){let{element:e,name:t,unresolvedKeyframes:n}=this;if(!e||!e.current)return;let r=e.getValue(t);r&&r.jump(this.measuredOrigin,!1);let i=n.length-1,a=n[i];n[i]=GC[t](e.measureViewportBox(),window.getComputedStyle(e.current)),a!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=a),this.removedTransforms?.length&&this.removedTransforms.forEach(([t,n])=>{e.getValue(t).set(n)}),this.resolveNoneKeyframes()}},NT=[`borderTopLeftRadius`,`borderTopRightRadius`,`borderBottomRightRadius`,`borderBottomLeftRadius`];function PT(e,t,n){if(e==null)return[];if(e instanceof EventTarget)return[e];if(typeof e==`string`){let r=document;t&&(r=t.current);let i=n?.[e]??r.querySelectorAll(e);return i?Array.from(i):[]}return Array.from(e).filter(e=>e!=null)}var FT=(e,t)=>t&&typeof e==`number`?t.transform(e):e;function IT(e){return Xb(e)&&`offsetHeight`in e&&!(`ownerSVGElement`in e)}var{schedule:LT,cancel:wee}=jx(queueMicrotask,!1),RT={x:!1,y:!1};function zT(){return RT.x||RT.y}function BT(e){return e===`x`||e===`y`?RT[e]?null:(RT[e]=!0,()=>{RT[e]=!1}):RT.x||RT.y?null:(RT.x=RT.y=!0,()=>{RT.x=RT.y=!1})}function VT(e,t){let n=PT(e),r=new AbortController;return[n,{passive:!0,...t,signal:r.signal},()=>r.abort()]}function HT(e){return!(e.pointerType===`touch`||zT())}function UT(e,t,n={}){let[r,i,a]=VT(e,n);return r.forEach(e=>{let n=!1,r=!1,a,o=()=>{e.removeEventListener(`pointerleave`,u)},s=e=>{a&&=(a(e),void 0),o()},c=e=>{n=!1,window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,c),r&&(r=!1,s(e))},l=()=>{n=!0,window.addEventListener(`pointerup`,c,i),window.addEventListener(`pointercancel`,c,i)},u=e=>{if(e.pointerType!==`touch`){if(n){r=!0;return}s(e)}};e.addEventListener(`pointerenter`,n=>{if(!HT(n))return;r=!1;let o=t(e,n);typeof o==`function`&&(a=o,e.addEventListener(`pointerleave`,u,i))},i),e.addEventListener(`pointerdown`,l,i)}),a}var WT=(e,t)=>t?e===t||WT(e,t.parentElement):!1,GT=e=>e.pointerType===`mouse`?typeof e.button!=`number`||e.button<=0:e.isPrimary!==!1,KT=new Set([`BUTTON`,`INPUT`,`SELECT`,`TEXTAREA`,`A`]);function qT(e){return KT.has(e.tagName)||e.isContentEditable===!0}var JT=new Set([`INPUT`,`SELECT`,`TEXTAREA`]);function YT(e){return JT.has(e.tagName)||e.isContentEditable===!0}var XT=new WeakSet;function ZT(e){return t=>{t.key===`Enter`&&e(t)}}function QT(e,t){e.dispatchEvent(new PointerEvent(`pointer`+t,{isPrimary:!0,bubbles:!0}))}var $T=(e,t)=>{let n=e.currentTarget;if(!n)return;let r=ZT(()=>{if(XT.has(n))return;QT(n,`down`);let e=ZT(()=>{QT(n,`up`)});n.addEventListener(`keyup`,e,t),n.addEventListener(`blur`,()=>QT(n,`cancel`),t)});n.addEventListener(`keydown`,r,t),n.addEventListener(`blur`,()=>n.removeEventListener(`keydown`,r),t)};function eE(e){return GT(e)&&!zT()}var tE=new WeakSet;function nE(e,t,n={}){let[r,i,a]=VT(e,n),o=e=>{let r=e.currentTarget;if(!eE(e)||tE.has(e))return;XT.add(r),n.stopPropagation&&tE.add(e);let a=t(r,e),o={...i,capture:!0},s=(e,t)=>{window.removeEventListener(`pointerup`,c,o),window.removeEventListener(`pointercancel`,l,o),XT.has(r)&&XT.delete(r),eE(e)&&typeof a==`function`&&a(e,{success:t})},c=e=>{s(e,r===window||r===document||n.useGlobalTarget||WT(r,e.target))},l=e=>{s(e,!1)};window.addEventListener(`pointerup`,c,o),window.addEventListener(`pointercancel`,l,o)};return r.forEach(e=>{(n.useGlobalTarget?window:e).addEventListener(`pointerdown`,o,i),IT(e)&&(e.addEventListener(`focus`,e=>$T(e,i)),!qT(e)&&!e.hasAttribute(`tabindex`)&&(e.tabIndex=0))}),a}function rE(e){return Xb(e)&&`ownerSVGElement`in e}var iE=new WeakMap,aE,oE=(e,t,n)=>(r,i)=>i&&i[0]?i[0][e+`Size`]:rE(r)&&`getBBox`in r?r.getBBox()[t]:r[n],sE=oE(`inline`,`width`,`offsetWidth`),cE=oE(`block`,`height`,`offsetHeight`);function lE({target:e,borderBoxSize:t}){iE.get(e)?.forEach(n=>{n(e,{get width(){return sE(e,t)},get height(){return cE(e,t)}})})}function uE(e){e.forEach(lE)}function dE(){typeof ResizeObserver>`u`||(aE=new ResizeObserver(uE))}function fE(e,t){aE||dE();let n=PT(e);return n.forEach(e=>{let n=iE.get(e);n||(n=new Set,iE.set(e,n)),n.add(t),aE?.observe(e)}),()=>{n.forEach(e=>{let n=iE.get(e);n?.delete(t),n?.size||aE?.unobserve(e)})}}var pE=new Set,mE;function hE(){mE=()=>{let e={get width(){return window.innerWidth},get height(){return window.innerHeight}};pE.forEach(t=>t(e))},window.addEventListener(`resize`,mE)}function gE(e){return pE.add(e),mE||hE(),()=>{pE.delete(e),!pE.size&&typeof mE==`function`&&(window.removeEventListener(`resize`,mE),mE=void 0)}}function _E(e,t){return typeof e==`function`?gE(e):fE(e,t)}var vE={value:null,addProjectionMetrics:null};function yE(e){return rE(e)&&e.tagName===`svg`}var bE=[...gT,fS,OS],xE=e=>bE.find(hT(e)),SE=()=>({translate:0,scale:1,origin:0,originPoint:0}),CE=()=>({x:SE(),y:SE()}),wE=()=>({min:0,max:0}),TE=()=>({x:wE(),y:wE()}),EE=new WeakMap;function DE(e){return typeof e==`object`&&!!e&&typeof e.start==`function`}function OE(e){return typeof e==`string`||Array.isArray(e)}var kE=[`animate`,`whileInView`,`whileFocus`,`whileHover`,`whileTap`,`whileDrag`,`exit`],AE=[`initial`,...kE];function jE(e){return DE(e.animate)||AE.some(t=>OE(e[t]))}function ME(e){return!!(jE(e)||e.variants)}function NE(e,t,n){for(let r in t){let i=t[r],a=n[r];if(rT(i))e.addValue(r,i);else if(rT(a))e.addValue(r,Fw(i,{owner:e}));else if(a!==i)if(e.hasValue(r)){let t=e.getValue(r);t.liveStyle===!0?t.jump(i):t.hasAnimated||t.set(i)}else{let t=e.getStaticValue(r);e.addValue(r,Fw(t===void 0?i:t,{owner:e}))}}for(let r in n)t[r]===void 0&&e.removeValue(r);return t}var PE={current:null},FE={current:!1},IE=typeof window<`u`;function LE(){if(FE.current=!0,IE)if(window.matchMedia){let e=window.matchMedia(`(prefers-reduced-motion)`),t=()=>PE.current=e.matches;e.addEventListener(`change`,t),t()}else PE.current=!1}var RE=[`AnimationStart`,`AnimationComplete`,`Update`,`BeforeLayoutMeasure`,`LayoutMeasure`,`LayoutAnimationStart`,`LayoutAnimationComplete`],zE={};function BE(e){zE=e}function VE(){return zE}var HE=class{scrapeMotionValuesFromProps(e,t,n){return{}}constructor({parent:e,props:t,presenceContext:n,reducedMotionConfig:r,skipAnimations:i,blockInitialAnimation:a,visualState:o},s={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.shouldSkipAnimations=!1,this.values=new Map,this.KeyframeResolver=$C,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.hasBeenMounted=!1,this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify(`Update`,this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{let e=Rx.now();this.renderScheduledAt<e&&(this.renderScheduledAt=e,Mx.render(this.render,!1,!0))};let{latestValues:c,renderState:l}=o;this.latestValues=c,this.baseTarget={...c},this.initialValues=t.initial?{...c}:{},this.renderState=l,this.parent=e,this.props=t,this.presenceContext=n,this.depth=e?e.depth+1:0,this.reducedMotionConfig=r,this.skipAnimationsConfig=i,this.options=s,this.blockInitialAnimation=!!a,this.isControllingVariants=jE(t),this.isVariantNode=ME(t),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);let{willChange:u,...d}=this.scrapeMotionValuesFromProps(t,{},this);for(let e in d){let t=d[e];c[e]!==void 0&&rT(t)&&t.set(c[e])}}mount(e){if(this.hasBeenMounted)for(let e in this.initialValues)this.values.get(e)?.jump(this.initialValues[e]),this.latestValues[e]=this.initialValues[e];this.current=e,EE.set(e,this),this.projection&&!this.projection.instance&&this.projection.mount(e),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((e,t)=>this.bindToMotionValue(t,e)),this.reducedMotionConfig===`never`?this.shouldReduceMotion=!1:this.reducedMotionConfig===`always`?this.shouldReduceMotion=!0:(FE.current||LE(),this.shouldReduceMotion=PE.current),this.shouldSkipAnimations=this.skipAnimationsConfig??!1,this.parent?.addChild(this),this.update(this.props,this.presenceContext),this.hasBeenMounted=!0}unmount(){this.projection&&this.projection.unmount(),Nx(this.notifyUpdate),Nx(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this);for(let e in this.events)this.events[e].clear();for(let e in this.features){let t=this.features[e];t&&(t.unmount(),t.isMounted=!1)}this.current=null}addChild(e){this.children.add(e),this.enteringChildren??=new Set,this.enteringChildren.add(e)}removeChild(e){this.children.delete(e),this.enteringChildren&&this.enteringChildren.delete(e)}bindToMotionValue(e,t){if(this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)(),t.accelerate&&Sw.has(e)&&this.current instanceof HTMLElement){let{factory:n,keyframes:r,times:i,ease:a,duration:o}=t.accelerate,s=new fw({element:this.current,name:e,keyframes:r,times:i,ease:a,duration:rx(o)}),c=n(s);this.valueSubscriptions.set(e,()=>{c(),s.cancel()});return}let n=BC.has(e);n&&this.onBindTransform&&this.onBindTransform();let r=t.on(`change`,t=>{this.latestValues[e]=t,this.props.onUpdate&&Mx.preRender(this.notifyUpdate),n&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()}),i;typeof window<`u`&&window.MotionCheckAppearSync&&(i=window.MotionCheckAppearSync(this,e,t)),this.valueSubscriptions.set(e,()=>{r(),i&&i()})}sortNodePosition(e){return!this.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e=`animation`;for(e in zE){let t=zE[e];if(!t)continue;let{isEnabled:n,Feature:r}=t;if(!this.features[e]&&r&&n(this.props)&&(this.features[e]=new r(this)),this.features[e]){let t=this.features[e];t.isMounted?t.update():(t.mount(),t.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):TE()}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,t){this.latestValues[e]=t}update(e,t){(e.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=t;for(let t=0;t<RE.length;t++){let n=RE[t];this.propEventSubscriptions[n]&&(this.propEventSubscriptions[n](),delete this.propEventSubscriptions[n]);let r=e[`on`+n];r&&(this.propEventSubscriptions[n]=this.on(n,r))}this.prevMotionValues=NE(this,this.scrapeMotionValuesFromProps(e,this.prevProps||{},this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(e){return this.props.variants?this.props.variants[e]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(e){let t=this.getClosestVariantNode();if(t)return t.variantChildren&&t.variantChildren.add(e),()=>t.variantChildren.delete(e)}addValue(e,t){let n=this.values.get(e);t!==n&&(n&&this.removeValue(e),this.bindToMotionValue(e,t),this.values.set(e,t),this.latestValues[e]=t.get())}removeValue(e){this.values.delete(e);let t=this.valueSubscriptions.get(e);t&&(t(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,t){if(this.props.values&&this.props.values[e])return this.props.values[e];let n=this.values.get(e);return n===void 0&&t!==void 0&&(n=Fw(t===null?void 0:t,{owner:this}),this.addValue(e,n)),n}readValue(e,t){let n=this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:this.getBaseTargetFromProps(this.props,e)??this.readValueFromInstance(this.current,e,this.options);return n!=null&&(typeof n==`string`&&(Yb(n)||Zb(n))?n=parseFloat(n):!xE(n)&&OS.test(t)&&(n=kT(e,t)),this.setBaseTarget(e,rT(n)?n.get():n)),rT(n)?n.get():n}setBaseTarget(e,t){this.baseTarget[e]=t}getBaseTarget(e){let{initial:t}=this.props,n;if(typeof t==`string`||typeof t==`object`){let r=Xw(this.props,t,this.presenceContext?.custom);r&&(n=r[e])}if(t&&n!==void 0)return n;let r=this.getBaseTargetFromProps(this.props,e);return r!==void 0&&!rT(r)?r:this.initialValues[e]!==void 0&&n===void 0?void 0:this.baseTarget[e]}on(e,t){return this.events[e]||(this.events[e]=new nx),this.events[e].add(t)}notify(e,...t){this.events[e]&&this.events[e].notify(...t)}scheduleRenderMicrotask(){LT.render(this.render)}},UE=class extends HE{constructor(){super(...arguments),this.KeyframeResolver=MT}sortInstanceNodePosition(e,t){return e.compareDocumentPosition(t)&2?1:-1}getBaseTargetFromProps(e,t){let n=e.style;return n?n[t]:void 0}removeValueFromRenderState(e,{vars:t,style:n}){delete t[e],delete n[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);let{children:e}=this.props;rT(e)&&(this.childSubscription=e.on(`change`,e=>{this.current&&(this.current.textContent=`${e}`)}))}},WE=class{constructor(e){this.isMounted=!1,this.node=e}update(){}};function GE({top:e,left:t,right:n,bottom:r}){return{x:{min:t,max:n},y:{min:e,max:r}}}function KE({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function qE(e,t){if(!t)return e;let n=t({x:e.left,y:e.top}),r=t({x:e.right,y:e.bottom});return{top:n.y,left:n.x,bottom:r.y,right:r.x}}function JE(e){return e===void 0||e===1}function YE({scale:e,scaleX:t,scaleY:n}){return!JE(e)||!JE(t)||!JE(n)}function XE(e){return YE(e)||ZE(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function ZE(e){return QE(e.x)||QE(e.y)}function QE(e){return e&&e!==`0%`}function $E(e,t,n){return n+t*(e-n)}function eD(e,t,n,r,i){return i!==void 0&&(e=$E(e,i,r)),$E(e,n,r)+t}function tD(e,t=0,n=1,r,i){e.min=eD(e.min,t,n,r,i),e.max=eD(e.max,t,n,r,i)}function nD(e,{x:t,y:n}){tD(e.x,t.translate,t.scale,t.originPoint),tD(e.y,n.translate,n.scale,n.originPoint)}var rD=.999999999999,iD=1.0000000000001;function aD(e,t,n,r=!1){let i=n.length;if(!i)return;t.x=t.y=1;let a,o;for(let s=0;s<i;s++){a=n[s],o=a.projectionDelta;let{visualElement:i}=a.options;i&&i.props.style&&i.props.style.display===`contents`||(r&&a.options.layoutScroll&&a.scroll&&a!==a.root&&(oD(e.x,-a.scroll.offset.x),oD(e.y,-a.scroll.offset.y)),o&&(t.x*=o.x.scale,t.y*=o.y.scale,nD(e,o)),r&&XE(a.latestValues)&&lD(e,a.latestValues,a.layout?.layoutBox))}t.x<iD&&t.x>rD&&(t.x=1),t.y<iD&&t.y>rD&&(t.y=1)}function oD(e,t){e.min+=t,e.max+=t}function sD(e,t,n,r,i=.5){tD(e,t,n,MS(e.min,e.max,i),r)}function cD(e,t){return typeof e==`string`?parseFloat(e)/100*(t.max-t.min):e}function lD(e,t,n){let r=n??e;sD(e.x,cD(t.x,r.x),t.scaleX,t.scale,t.originX),sD(e.y,cD(t.y,r.y),t.scaleY,t.scale,t.originY)}function uD(e,t){return GE(qE(e.getBoundingClientRect(),t))}function dD(e,t,n){let r=uD(e,n),{scroll:i}=t;return i&&(oD(r.x,i.offset.x),oD(r.y,i.offset.y)),r}var fD={x:`translateX`,y:`translateY`,z:`translateZ`,transformPerspective:`perspective`},pD=zC.length;function mD(e,t,n){let r=``,i=!0;for(let a=0;a<pD;a++){let o=zC[a],s=e[o];if(s===void 0)continue;let c=!0;if(typeof s==`number`)c=s===+!!o.startsWith(`scale`);else{let e=parseFloat(s);c=o.startsWith(`scale`)?e===1:e===0}if(!c||n){let e=FT(s,TT[o]);if(!c){i=!1;let t=fD[o]||o;r+=`${t}(${e}) `}n&&(t[o]=e)}}let a=e.pathRotation;return a&&(i=!1,r+=`rotate(${FT(a,TT.pathRotation)}) `),r=r.trim(),n?r=n(t,i?``:r):i&&(r=`none`),r}function hD(e,t,n){let{style:r,vars:i,transformOrigin:a}=e,o=!1,s=!1;for(let e in t){let n=t[e];if(BC.has(e)){o=!0;continue}else if(Bx(e)){i[e]=n;continue}else{let t=FT(n,TT[e]);e.startsWith(`origin`)?(s=!0,a[e]=t):r[e]=t}}if(t.transform||(o||n?r.transform=mD(t,e.transform,n):r.transform&&=`none`),s){let{originX:e=`50%`,originY:t=`50%`,originZ:n=0}=a;r.transformOrigin=`${e} ${t} ${n}`}}function gD(e,{style:t,vars:n},r,i){let a=e.style,o;for(o in t)a[o]=t[o];for(o in i?.applyProjectionStyles(a,r),n)a.setProperty(o,n[o])}function _D(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}var vD={correct:(e,t)=>{if(!t.target)return e;if(typeof e==`string`)if(W.test(e))e=parseFloat(e);else return e;return`${_D(e,t.target.x)}% ${_D(e,t.target.y)}%`}},yD={correct:(e,{treeScale:t,projectionDelta:n})=>{let r=e,i=OS.parse(e);if(i.length>5)return r;let a=OS.createTransformer(e),o=typeof i[0]==`number`?0:1,s=n.x.scale*t.x,c=n.y.scale*t.y;i[0+o]/=s,i[1+o]/=c;let l=MS(s,c,.5);return typeof i[2+o]==`number`&&(i[2+o]/=l),typeof i[3+o]==`number`&&(i[3+o]/=l),a(i)}},bD={borderRadius:{...vD,applyTo:[...NT]},borderTopLeftRadius:vD,borderTopRightRadius:vD,borderBottomLeftRadius:vD,borderBottomRightRadius:vD,boxShadow:yD};function xD(e,{layout:t,layoutId:n}){return BC.has(e)||e.startsWith(`origin`)||(t||n!==void 0)&&(!!bD[e]||e===`opacity`)}function SD(e,t,n){let r=e.style,i=t?.style,a={};if(!r)return a;for(let t in r)(rT(r[t])||i&&rT(i[t])||xD(t,e)||n?.getValue(t)?.liveStyle!==void 0)&&(a[t]=r[t]);return a}function CD(e){return window.getComputedStyle(e)}var wD=class extends UE{constructor(){super(...arguments),this.type=`html`,this.renderInstance=gD}readValueFromInstance(e,t){if(BC.has(t))return this.projection?.isProjecting?FC(t):LC(e,t);{let n=CD(e),r=(Bx(t)?n.getPropertyValue(t):n[t])||0;return typeof r==`string`?r.trim():r}}measureInstanceViewportBox(e,{transformPagePoint:t}){return uD(e,t)}build(e,t,n){hD(e,t,n.transformTemplate)}scrapeMotionValuesFromProps(e,t,n){return SD(e,t,n)}},TD={offset:`stroke-dashoffset`,array:`stroke-dasharray`},ED={offset:`strokeDashoffset`,array:`strokeDasharray`};function DD(e,t,n=1,r=0,i=!0){e.pathLength=1;let a=i?TD:ED;e[a.offset]=`${-r}`,e[a.array]=`${t} ${n}`}var OD=[`offsetDistance`,`offsetPath`,`offsetRotate`,`offsetAnchor`];function kD(e,{attrX:t,attrY:n,attrScale:r,pathLength:i,pathSpacing:a=1,pathOffset:o=0,...s},c,l,u){if(hD(e,s,l),c){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};let{attrs:d,style:f}=e;d.transform&&(f.transform=d.transform,delete d.transform),(f.transform||d.transformOrigin)&&(f.transformOrigin=d.transformOrigin??`50% 50%`,delete d.transformOrigin),f.transform&&(f.transformBox=u?.transformBox??`fill-box`,delete d.transformBox);for(let e of OD)d[e]!==void 0&&(f[e]=d[e],delete d[e]);t!==void 0&&(d.x=t),n!==void 0&&(d.y=n),r!==void 0&&(d.scale=r),i!==void 0&&DD(d,i,a,o,!1)}var AD=new Set([`baseFrequency`,`diffuseConstant`,`kernelMatrix`,`kernelUnitLength`,`keySplines`,`keyTimes`,`limitingConeAngle`,`markerHeight`,`markerWidth`,`numOctaves`,`targetX`,`targetY`,`surfaceScale`,`specularConstant`,`specularExponent`,`stdDeviation`,`tableValues`,`viewBox`,`gradientTransform`,`pathLength`,`startOffset`,`textLength`,`lengthAdjust`]),jD=e=>typeof e==`string`&&e.toLowerCase()===`svg`;function MD(e,t,n,r){gD(e,t,void 0,r);for(let n in t.attrs)e.setAttribute(AD.has(n)?n:oT(n),t.attrs[n])}function ND(e,t,n){let r=SD(e,t,n);for(let n in e)if(rT(e[n])||rT(t[n])){let t=zC.indexOf(n)===-1?n:`attr`+n.charAt(0).toUpperCase()+n.substring(1);r[t]=e[n]}return r}var PD=class extends UE{constructor(){super(...arguments),this.type=`svg`,this.isSVGTag=!1,this.measureInstanceViewportBox=TE}getBaseTargetFromProps(e,t){return e[t]}readValueFromInstance(e,t){if(BC.has(t)){let e=DT(t);return e&&e.default||0}return t=AD.has(t)?t:oT(t),e.getAttribute(t)}scrapeMotionValuesFromProps(e,t,n){return ND(e,t,n)}build(e,t,n){kD(e,t,this.isSVGTag,n.transformTemplate,n.style)}renderInstance(e,t,n,r){MD(e,t,n,r)}mount(e){this.isSVGTag=jD(e.tagName),super.mount(e)}},FD=AE.length;function ID(e){if(!e)return;if(!e.isControllingVariants){let t=e.parent&&ID(e.parent)||{};return e.props.initial!==void 0&&(t.initial=e.props.initial),t}let t={};for(let n=0;n<FD;n++){let r=AE[n],i=e.props[r];(OE(i)||i===!1)&&(t[r]=i)}return t}function LD(e,t){if(!Array.isArray(t))return!1;let n=t.length;if(n!==e.length)return!1;for(let r=0;r<n;r++)if(t[r]!==e[r])return!1;return!0}var RD=[...kE].reverse(),zD=kE.length;function BD(e){return t=>Promise.all(t.map(({animation:t,options:n})=>pT(e,t,n)))}function VD(e){let t=BD(e),n=WD(),r=!0,i=!1,a=t=>(n,r)=>{let i=Zw(e,r,t===`exit`?e.presenceContext?.custom:void 0);if(i){let{transition:e,transitionEnd:t,...r}=i;n={...n,...r,...t}}return n};function o(n){t=n(e)}function s(o){let{props:s}=e,c=ID(e.parent)||{},l=[],u=new Set,d={},f=1/0;for(let t=0;t<zD;t++){let p=RD[t],m=n[p],h=s[p]===void 0?c[p]:s[p],g=OE(h),_=p===o?m.isActive:null;_===!1&&(f=t);let v=h===c[p]&&h!==s[p]&&g;if(v&&(r||i)&&e.manuallyAnimateOnMount&&(v=!1),m.protectedKeys={...d},!m.isActive&&_===null||!h&&!m.prevProp||DE(h)||typeof h==`boolean`)continue;if(p===`exit`&&m.isActive&&_!==!0){m.prevResolvedValues&&(d={...d,...m.prevResolvedValues});continue}let y=HD(m.prevProp,h),b=y||p===o&&m.isActive&&!v&&g||t>f&&g,x=!1,S=Array.isArray(h)?h:[h],C=S.reduce(a(p),{});_===!1&&(C={});let{prevResolvedValues:w={}}=m,T={...w,...C},E=t=>{b=!0,u.has(t)&&(x=!0,u.delete(t)),m.needsAnimating[t]=!0;let n=e.getValue(t);n&&(n.liveStyle=!1)};for(let e in T){let t=C[e],n=w[e];if(d.hasOwnProperty(e))continue;let r=!1;r=$w(t)&&$w(n)?!LD(t,n)||y:t!==n,r?t==null?u.add(e):E(e):t!==void 0&&u.has(e)?E(e):m.protectedKeys[e]=!0}m.prevProp=h,m.prevResolvedValues=C,m.isActive&&(d={...d,...C}),(r||i)&&e.blockInitialAnimation&&(b=!1);let D=v&&y;b&&(!D||x)&&l.push(...S.map(t=>{let n={type:p};if(typeof t==`string`&&(r||i)&&!D&&e.manuallyAnimateOnMount&&e.parent){let{parent:r}=e,i=Zw(r,t);if(r.enteringChildren&&i){let{delayChildren:t}=i.transition||{};n.delay=Aw(r.enteringChildren,e,t)}}return{animation:t,options:n}}))}if(u.size){let t={};if(typeof s.initial!=`boolean`){let n=Zw(e,Array.isArray(s.initial)?s.initial[0]:s.initial);n&&n.transition&&(t.transition=n.transition)}u.forEach(n=>{let r=e.getBaseTarget(n),i=e.getValue(n);i&&(i.liveStyle=!0),t[n]=r??null}),l.push({animation:t})}let p=!!l.length;return r&&(s.initial===!1||s.initial===s.animate)&&!e.manuallyAnimateOnMount&&(p=!1),r=!1,i=!1,p?t(l):Promise.resolve()}function c(t,r){if(n[t].isActive===r)return Promise.resolve();e.variantChildren?.forEach(e=>e.animationState?.setActive(t,r)),n[t].isActive=r;let i=s(t);for(let e in n)n[e].protectedKeys={};return i}return{animateChanges:s,setActive:c,setAnimateFunction:o,getState:()=>n,reset:()=>{n=WD(),i=!0}}}function HD(e,t){return typeof t==`string`?t!==e:Array.isArray(t)?!LD(t,e):!1}function UD(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function WD(){return{animate:UD(!0),whileInView:UD(),whileHover:UD(),whileTap:UD(),whileDrag:UD(),whileFocus:UD(),exit:UD()}}function GD(e,t){e.min=t.min,e.max=t.max}function KD(e,t){GD(e.x,t.x),GD(e.y,t.y)}function qD(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}var JD=.9999,YD=1.0001,XD=-.01,ZD=.01;function QD(e){return e.max-e.min}function $D(e,t,n){return Math.abs(e-t)<=n}function eO(e,t,n,r=.5){e.origin=r,e.originPoint=MS(t.min,t.max,e.origin),e.scale=QD(n)/QD(t),e.translate=MS(n.min,n.max,e.origin)-e.originPoint,(e.scale>=JD&&e.scale<=YD||isNaN(e.scale))&&(e.scale=1),(e.translate>=XD&&e.translate<=ZD||isNaN(e.translate))&&(e.translate=0)}function tO(e,t,n,r){eO(e.x,t.x,n.x,r?r.originX:void 0),eO(e.y,t.y,n.y,r?r.originY:void 0)}function nO(e,t,n,r=0){e.min=(r?MS(n.min,n.max,r):n.min)+t.min,e.max=e.min+QD(t)}function rO(e,t,n,r){nO(e.x,t.x,n.x,r?.x),nO(e.y,t.y,n.y,r?.y)}function iO(e,t,n,r=0){let i=r?MS(n.min,n.max,r):n.min;e.min=t.min-i,e.max=e.min+QD(t)}function aO(e,t,n,r){iO(e.x,t.x,n.x,r?.x),iO(e.y,t.y,n.y,r?.y)}function oO(e,t,n,r,i){return e-=t,e=$E(e,1/n,r),i!==void 0&&(e=$E(e,1/i,r)),e}function sO(e,t=0,n=1,r=.5,i,a=e,o=e){if(sS.test(t)&&(t=parseFloat(t),t=MS(o.min,o.max,t/100)-o.min),typeof t!=`number`)return;let s=MS(a.min,a.max,r);e===a&&(s-=t),e.min=oO(e.min,t,n,s,i),e.max=oO(e.max,t,n,s,i)}function cO(e,t,[n,r,i],a,o){sO(e,t[n],t[r],t[i],t.scale,a,o)}var lO=[`x`,`scaleX`,`originX`],uO=[`y`,`scaleY`,`originY`];function dO(e,t,n,r){cO(e.x,t,lO,n?n.x:void 0,r?r.x:void 0),cO(e.y,t,uO,n?n.y:void 0,r?r.y:void 0)}function fO(e){return e.translate===0&&e.scale===1}function pO(e){return fO(e.x)&&fO(e.y)}function mO(e,t){return e.min===t.min&&e.max===t.max}function hO(e,t){return mO(e.x,t.x)&&mO(e.y,t.y)}function gO(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function _O(e,t){return gO(e.x,t.x)&&gO(e.y,t.y)}function vO(e){return QD(e.x)/QD(e.y)}function yO(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}function bO(e){return[e(`x`),e(`y`)]}function xO(e,t,n){let r=``,i=e.x.translate/t.x,a=e.y.translate/t.y,o=n?.z||0;if((i||a||o)&&(r=`translate3d(${i}px, ${a}px, ${o}px) `),(t.x!==1||t.y!==1)&&(r+=`scale(${1/t.x}, ${1/t.y}) `),n){let{transformPerspective:e,rotate:t,pathRotation:i,rotateX:a,rotateY:o,skewX:s,skewY:c}=n;e&&(r=`perspective(${e}px) ${r}`),t&&(r+=`rotate(${t}deg) `),i&&(r+=`rotate(${i}deg) `),a&&(r+=`rotateX(${a}deg) `),o&&(r+=`rotateY(${o}deg) `),s&&(r+=`skewX(${s}deg) `),c&&(r+=`skewY(${c}deg) `)}let s=e.x.scale*t.x,c=e.y.scale*t.y;return(s!==1||c!==1)&&(r+=`scale(${s}, ${c})`),r||`none`}var SO=NT.length,CO=e=>typeof e==`string`?parseFloat(e):e,wO=e=>typeof e==`number`||W.test(e);function TO(e,t,n,r,i,a){i?(e.opacity=MS(0,n.opacity??1,DO(r)),e.opacityExit=MS(t.opacity??1,0,OO(r))):a&&(e.opacity=MS(t.opacity??1,n.opacity??1,r));for(let i=0;i<SO;i++){let a=NT[i],o=EO(t,a),s=EO(n,a);o===void 0&&s===void 0||(o||=0,s||=0,o===0||s===0||wO(o)===wO(s)?(e[a]=Math.max(MS(CO(o),CO(s),r),0),(sS.test(s)||sS.test(o))&&(e[a]+=`%`)):e[a]=s)}(t.rotate||n.rotate)&&(e.rotate=MS(t.rotate||0,n.rotate||0,r))}function EO(e,t){return e[t]===void 0?e.borderRadius:e[t]}var DO=kO(0,.5,vx),OO=kO(.5,.95,$b);function kO(e,t,n){return r=>r<e?0:r>t?1:n(tx(e,t,r))}function AO(e,t,n){let r=rT(e)?e:Fw(e);return r.start(Gw(``,r,t,n)),r.animation}function jO(e,t,n,r={passive:!0}){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}var MO=(e,t)=>e.depth-t.depth,NO=class{constructor(){this.children=[],this.isDirty=!1}add(e){Gb(this.children,e),this.isDirty=!0}remove(e){Kb(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(MO),this.isDirty=!1,this.children.forEach(e)}};function PO(e,t){let n=Rx.now(),r=({timestamp:i})=>{let a=i-n;a>=t&&(Nx(r),e(a-t))};return Mx.setup(r,!0),()=>Nx(r)}function FO(e){return rT(e)?e.get():e}var IO=class{constructor(){this.members=[]}add(e){Gb(this.members,e);for(let t=this.members.length-1;t>=0;t--){let n=this.members[t];if(n===e||n===this.lead||n===this.prevLead)continue;let r=n.instance;(!r||r.isConnected===!1)&&!n.snapshot&&(Kb(this.members,n),n.unmount())}e.scheduleRender()}remove(e){if(Kb(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){let e=this.members[this.members.length-1];e&&this.promote(e)}}relegate(e){for(let t=this.members.indexOf(e)-1;t>=0;t--){let e=this.members[t];if(e.isPresent!==!1&&e.instance?.isConnected!==!1)return this.promote(e),!0}return!1}promote(e,t){let n=this.lead;if(e!==n&&(this.prevLead=n,this.lead=e,e.show(),n)){n.updateSnapshot(),e.scheduleRender();let{layoutDependency:r}=n.options,{layoutDependency:i}=e.options;(r===void 0||r!==i)&&(e.resumeFrom=n,t&&(n.preserveOpacity=!0),n.snapshot&&(e.snapshot=n.snapshot,e.snapshot.latestValues=n.animationValues||n.latestValues),e.root?.isUpdating&&(e.isLayoutDirty=!0)),e.options.crossfade===!1&&n.hide()}}exitAnimationComplete(){this.members.forEach(e=>{e.options.onExitComplete?.(),e.resumingFrom?.options.onExitComplete?.()})}scheduleRender(){this.members.forEach(e=>e.instance&&e.scheduleRender(!1))}removeLeadSnapshot(){this.lead?.snapshot&&(this.lead.snapshot=void 0)}},LO={hasAnimatedSinceResize:!0,hasEverUpdated:!1},RO={nodes:0,calculatedTargetDeltas:0,calculatedProjections:0},zO=[``,`X`,`Y`,`Z`],BO=1e3,VO=0;function HO(e,t,n,r){let{latestValues:i}=t;i[e]&&(n[e]=i[e],t.setStaticValue(e,0),r&&(r[e]=0))}function UO(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;let{visualElement:t}=e.options;if(!t)return;let n=cT(t);if(window.MotionHasOptimisedAnimation(n,`transform`)){let{layout:t,layoutId:r}=e.options;window.MotionCancelOptimisedAnimation(n,`transform`,Mx,!(t||r))}let{parent:r}=e;r&&!r.hasCheckedOptimisedAppear&&UO(r)}function WO({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:r,resetTransform:i}){return class{constructor(e={},n=t?.()){this.id=VO++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.layoutVersion=0,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,vE.value&&(RO.nodes=RO.calculatedTargetDeltas=RO.calculatedProjections=0),this.nodes.forEach(qO),this.nodes.forEach(nk),this.nodes.forEach(rk),this.nodes.forEach(JO),vE.addProjectionMetrics&&vE.addProjectionMetrics(RO)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=e,this.root=n?n.root||n:this,this.path=n?[...n.path,n]:[],this.parent=n,this.depth=n?n.depth+1:0;for(let e=0;e<this.path.length;e++)this.path[e].shouldResetTransform=!0;this.root===this&&(this.nodes=new NO)}addEventListener(e,t){return this.eventHandlers.has(e)||this.eventHandlers.set(e,new nx),this.eventHandlers.get(e).add(t)}notifyListeners(e,...t){let n=this.eventHandlers.get(e);n&&n.notify(...t)}hasListeners(e){return this.eventHandlers.has(e)}mount(t){if(this.instance)return;this.isSVG=rE(t)&&!yE(t),this.instance=t;let{layoutId:n,layout:r,visualElement:i}=this.options;if(i&&!i.current&&i.mount(t),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(r||n)&&(this.isLayoutDirty=!0),e){let n,r=0,i=()=>this.root.updateBlockedByResize=!1;Mx.read(()=>{r=window.innerWidth}),e(t,()=>{let e=window.innerWidth;e!==r&&(r=e,this.root.updateBlockedByResize=!0,n&&n(),n=PO(i,250),LO.hasAnimatedSinceResize&&(LO.hasAnimatedSinceResize=!1,this.nodes.forEach(tk)))})}n&&this.root.registerSharedNode(n,this),this.options.animate!==!1&&i&&(n||r)&&this.addEventListener(`didUpdate`,({delta:e,hasLayoutChanged:t,hasRelativeLayoutChanged:n,layout:r})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}let a=this.options.transition||i.getDefaultTransition()||uk,{onLayoutAnimationStart:o,onLayoutAnimationComplete:s}=i.getProps(),c=!this.targetLayout||!_O(this.targetLayout,r),l=!t&&n;if(this.options.layoutRoot||this.resumeFrom||l||t&&(c||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);let t={...Lw(a,`layout`),onPlay:o,onComplete:s};(i.shouldReduceMotion||this.options.layoutRoot)&&(t.delay=0,t.type=!1),this.startAnimation(t),this.setAnimationOrigin(e,l,t.path)}else t||tk(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=r})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);let e=this.getStack();e&&e.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),Nx(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(ik),this.animationId++)}getTransformTemplate(){let{visualElement:e}=this.options;return e&&e.getProps().transformTemplate}willUpdate(e=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&UO(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let e=0;e<this.path.length;e++){let t=this.path[e];t.shouldResetTransform=!0,(typeof t.latestValues.x==`string`||typeof t.latestValues.y==`string`)&&(t.isLayoutDirty=!0),t.updateScroll(`snapshot`),t.options.layoutRoot&&t.willUpdate(!1)}let{layoutId:t,layout:n}=this.options;if(t===void 0&&!n)return;let r=this.getTransformTemplate();this.prevTransformTemplateValue=r?r(this.latestValues,``):void 0,this.updateSnapshot(),e&&this.notifyListeners(`willUpdate`)}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){let e=this.updateBlockedByResize;this.unblockUpdate(),this.updateBlockedByResize=!1,this.clearAllSnapshots(),e&&this.nodes.forEach(ZO),this.nodes.forEach(XO);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(QO);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach($O),this.nodes.forEach(ek),this.nodes.forEach(GO),this.nodes.forEach(KO)):this.nodes.forEach(QO),this.clearAllSnapshots();let e=Rx.now();Px.delta=qb(0,1e3/60,e-Px.timestamp),Px.timestamp=e,Px.isProcessing=!0,Fx.update.process(Px),Fx.preRender.process(Px),Fx.render.process(Px),Px.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,LT.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(YO),this.sharedNodes.forEach(ak)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,Mx.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){Mx.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!QD(this.snapshot.measuredBox.x)&&!QD(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let e=0;e<this.path.length;e++)this.path[e].updateScroll();let e=this.layout;this.layout=this.measure(!1),this.layoutVersion++,this.layoutCorrected||=TE(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners(`measure`,this.layout.layoutBox);let{visualElement:t}=this.options;t&&t.notify(`LayoutMeasure`,this.layout.layoutBox,e?e.layoutBox:void 0)}updateScroll(e=`measure`){let t=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===e&&(t=!1),t&&this.instance){let t=r(this.instance);this.scroll={animationId:this.root.animationId,phase:e,isRoot:t,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:t}}}resetTransform(){if(!i)return;let e=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,t=this.projectionDelta&&!pO(this.projectionDelta),n=this.getTransformTemplate(),r=n?n(this.latestValues,``):void 0,a=r!==this.prevTransformTemplateValue;e&&this.instance&&(t||XE(this.latestValues)||a)&&(i(this.instance,r),this.shouldResetTransform=!1,this.scheduleRender())}measure(e=!0){let t=this.measurePageBox(),n=this.removeElementScroll(t);return e&&(n=this.removeTransform(n)),mk(n),{animationId:this.root.animationId,measuredBox:t,layoutBox:n,latestValues:{},source:this.id}}measurePageBox(){let{visualElement:e}=this.options;if(!e)return TE();let t=e.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(gk))){let{scroll:e}=this.root;e&&(oD(t.x,e.offset.x),oD(t.y,e.offset.y))}return t}removeElementScroll(e){let t=TE();if(KD(t,e),this.scroll?.wasRoot)return t;for(let n=0;n<this.path.length;n++){let r=this.path[n],{scroll:i,options:a}=r;r!==this.root&&i&&a.layoutScroll&&(i.wasRoot&&KD(t,e),oD(t.x,i.offset.x),oD(t.y,i.offset.y))}return t}applyTransform(e,t=!1,n){let r=n||TE();KD(r,e);for(let e=0;e<this.path.length;e++){let n=this.path[e];!t&&n.options.layoutScroll&&n.scroll&&n!==n.root&&(oD(r.x,-n.scroll.offset.x),oD(r.y,-n.scroll.offset.y)),XE(n.latestValues)&&lD(r,n.latestValues,n.layout?.layoutBox)}return XE(this.latestValues)&&lD(r,this.latestValues,this.layout?.layoutBox),r}removeTransform(e){let t=TE();KD(t,e);for(let e=0;e<this.path.length;e++){let n=this.path[e];if(!XE(n.latestValues))continue;let r;n.instance&&(YE(n.latestValues)&&n.updateSnapshot(),r=TE(),KD(r,n.measurePageBox())),dO(t,n.latestValues,n.snapshot?.layoutBox,r)}return XE(this.latestValues)&&dO(t,this.latestValues),t}setTargetDelta(e){this.targetDelta=e,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(e){this.options={...this.options,...e,crossfade:e.crossfade===void 0||e.crossfade}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==Px.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(e=!1){let t=this.getLead();this.isProjectionDirty||=t.isProjectionDirty,this.isTransformDirty||=t.isTransformDirty,this.isSharedProjectionDirty||=t.isSharedProjectionDirty;let n=!!this.resumingFrom||this!==t;if(!(e||n&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;let{layout:r,layoutId:i}=this.options;if(!this.layout||!(r||i))return;this.resolvedRelativeTargetAt=Px.timestamp;let a=this.getClosestProjectingParent();a&&this.linkedParentVersion!==a.layoutVersion&&!a.options.layoutRoot&&this.removeRelativeTarget(),!this.targetDelta&&!this.relativeTarget&&(this.options.layoutAnchor!==!1&&a&&a.layout?this.createRelativeTarget(a,this.layout.layoutBox,a.layout.layoutBox):this.removeRelativeTarget()),!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=TE(),this.targetWithTransforms=TE()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),rO(this.target,this.relativeTarget,this.relativeParent.target,this.options.layoutAnchor||void 0)):this.targetDelta?(this.resumingFrom?this.applyTransform(this.layout.layoutBox,!1,this.target):KD(this.target,this.layout.layoutBox),nD(this.target,this.targetDelta)):KD(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget&&(this.attemptToResolveRelativeTarget=!1,this.options.layoutAnchor!==!1&&a&&!!a.resumingFrom==!!this.resumingFrom&&!a.options.layoutScroll&&a.target&&this.animationProgress!==1?this.createRelativeTarget(a,this.target,a.target):this.relativeParent=this.relativeTarget=void 0),vE.value&&RO.calculatedTargetDeltas++)}getClosestProjectingParent(){if(!(!this.parent||YE(this.parent.latestValues)||ZE(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}createRelativeTarget(e,t,n){this.relativeParent=e,this.linkedParentVersion=e.layoutVersion,this.forceRelativeParentToResolveTarget(),this.relativeTarget=TE(),this.relativeTargetOrigin=TE(),aO(this.relativeTargetOrigin,t,n,this.options.layoutAnchor||void 0),KD(this.relativeTarget,this.relativeTargetOrigin)}removeRelativeTarget(){this.relativeParent=this.relativeTarget=void 0}calcProjection(){let e=this.getLead(),t=!!this.resumingFrom||this!==e,n=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(n=!1),t&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(n=!1),this.resolvedRelativeTargetAt===Px.timestamp&&(n=!1),n)return;let{layout:r,layoutId:i}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(r||i))return;KD(this.layoutCorrected,this.layout.layoutBox);let a=this.treeScale.x,o=this.treeScale.y;aD(this.layoutCorrected,this.treeScale,this.path,t),e.layout&&!e.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(e.target=e.layout.layoutBox,e.targetWithTransforms=TE());let{target:s}=e;if(!s){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(qD(this.prevProjectionDelta.x,this.projectionDelta.x),qD(this.prevProjectionDelta.y,this.projectionDelta.y)),tO(this.projectionDelta,this.layoutCorrected,s,this.latestValues),(this.treeScale.x!==a||this.treeScale.y!==o||!yO(this.projectionDelta.x,this.prevProjectionDelta.x)||!yO(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners(`projectionUpdate`,s)),vE.value&&RO.calculatedProjections++}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(e=!0){if(this.options.visualElement?.scheduleRender(),e){let e=this.getStack();e&&e.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=CE(),this.projectionDelta=CE(),this.projectionDeltaWithTransform=CE()}setAnimationOrigin(e,t=!1,n){let r=this.snapshot,i=r?r.latestValues:{},a={...this.latestValues},o=CE();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!t;let s=TE(),c=(r?r.source:void 0)!==(this.layout?this.layout.source:void 0),l=this.getStack(),u=!l||l.members.length<=1,d=!!(c&&!u&&this.options.crossfade===!0&&!this.path.some(lk));this.animationProgress=0;let f,p=n?.interpolateProjection(e);this.mixTargetDelta=t=>{let n=t/1e3,r=p?.(n);r?(o.x.translate=r.x,o.x.scale=MS(e.x.scale,1,n),o.x.origin=e.x.origin,o.x.originPoint=e.x.originPoint,o.y.translate=r.y,o.y.scale=MS(e.y.scale,1,n),o.y.origin=e.y.origin,o.y.originPoint=e.y.originPoint):(ok(o.x,e.x,n),ok(o.y,e.y,n)),this.setTargetDelta(o),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(aO(s,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),ck(this.relativeTarget,this.relativeTargetOrigin,s,n),f&&hO(this.relativeTarget,f)&&(this.isProjectionDirty=!1),f||=TE(),KD(f,this.relativeTarget)),c&&(this.animationValues=a,TO(a,i,this.latestValues,n,d,u)),r&&r.rotate!==void 0&&(this.animationValues||=a,this.animationValues.pathRotation=r.rotate),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=n},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(e){this.notifyListeners(`animationStart`),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&=(Nx(this.pendingAnimation),void 0),this.pendingAnimation=Mx.update(()=>{LO.hasAnimatedSinceResize=!0,this.motionValue||=Fw(0),this.motionValue.jump(0,!1),this.currentAnimation=AO(this.motionValue,[0,1e3],{...e,velocity:0,isSync:!0,onUpdate:t=>{this.mixTargetDelta(t),e.onUpdate&&e.onUpdate(t)},onComplete:()=>{e.onComplete&&e.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);let e=this.getStack();e&&e.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners(`animationComplete`)}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(BO),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){let e=this.getLead(),{targetWithTransforms:t,target:n,layout:r,latestValues:i}=e;if(!(!t||!n||!r)){if(this!==e&&this.layout&&r&&hk(this.options.animationType,this.layout.layoutBox,r.layoutBox)){n=this.target||TE();let t=QD(this.layout.layoutBox.x);n.x.min=e.target.x.min,n.x.max=n.x.min+t;let r=QD(this.layout.layoutBox.y);n.y.min=e.target.y.min,n.y.max=n.y.min+r}KD(t,n),lD(t,i),tO(this.projectionDeltaWithTransform,this.layoutCorrected,t,i)}}registerSharedNode(e,t){this.sharedNodes.has(e)||this.sharedNodes.set(e,new IO),this.sharedNodes.get(e).add(t);let n=t.options.initialPromotionConfig;t.promote({transition:n?n.transition:void 0,preserveFollowOpacity:n&&n.shouldPreserveFollowOpacity?n.shouldPreserveFollowOpacity(t):void 0})}isLead(){let e=this.getStack();return!e||e.lead===this}getLead(){let{layoutId:e}=this.options;return e&&this.getStack()?.lead||this}getPrevLead(){let{layoutId:e}=this.options;return e?this.getStack()?.prevLead:void 0}getStack(){let{layoutId:e}=this.options;if(e)return this.root.sharedNodes.get(e)}promote({needsReset:e,transition:t,preserveFollowOpacity:n}={}){let r=this.getStack();r&&r.promote(this,n),e&&(this.projectionDelta=void 0,this.needsReset=!0),t&&this.setOptions({transition:t})}relegate(){let e=this.getStack();return e?e.relegate(this):!1}resetSkewAndRotation(){let{visualElement:e}=this.options;if(!e)return;let t=!1,{latestValues:n}=e;if((n.z||n.rotate||n.rotateX||n.rotateY||n.rotateZ||n.skewX||n.skewY)&&(t=!0),!t)return;let r={};n.z&&HO(`z`,e,r,this.animationValues);for(let t=0;t<zO.length;t++)HO(`rotate${zO[t]}`,e,r,this.animationValues),HO(`skew${zO[t]}`,e,r,this.animationValues);e.render();for(let t in r)e.setStaticValue(t,r[t]),this.animationValues&&(this.animationValues[t]=r[t]);e.scheduleRender()}applyProjectionStyles(e,t){if(!this.instance||this.isSVG)return;if(!this.isVisible){e.visibility=`hidden`;return}let n=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,e.visibility=``,e.opacity=``,e.pointerEvents=FO(t?.pointerEvents)||``,e.transform=n?n(this.latestValues,``):`none`;return}let r=this.getLead();if(!this.projectionDelta||!this.layout||!r.target){this.options.layoutId&&(e.opacity=this.latestValues.opacity===void 0?1:this.latestValues.opacity,e.pointerEvents=FO(t?.pointerEvents)||``),this.hasProjected&&!XE(this.latestValues)&&(e.transform=n?n({},``):`none`,this.hasProjected=!1);return}e.visibility=``;let i=r.animationValues||r.latestValues;this.applyTransformsToTarget();let a=xO(this.projectionDeltaWithTransform,this.treeScale,i);n&&(a=n(i,a)),e.transform=a;let{x:o,y:s}=this.projectionDelta;e.transformOrigin=`${o.origin*100}% ${s.origin*100}% 0`,r.animationValues?e.opacity=r===this?i.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:i.opacityExit:e.opacity=r===this?i.opacity===void 0?``:i.opacity:i.opacityExit===void 0?0:i.opacityExit;for(let t in bD){if(i[t]===void 0)continue;let{correct:n,applyTo:o,isCSSVariable:s}=bD[t],c=a===`none`?i[t]:n(i[t],r);if(o){let t=o.length;for(let n=0;n<t;n++)e[o[n]]=c}else s?this.options.visualElement.renderState.vars[t]=c:e[t]=c}this.options.layoutId&&(e.pointerEvents=r===this?FO(t?.pointerEvents)||``:`none`)}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(e=>e.currentAnimation?.stop()),this.root.nodes.forEach(XO),this.root.sharedNodes.clear()}}}function GO(e){e.updateLayout()}function KO(e){let t=e.resumeFrom?.snapshot||e.snapshot;if(e.isLead()&&e.layout&&t&&e.hasListeners(`didUpdate`)){let{layoutBox:n,measuredBox:r}=e.layout,{animationType:i}=e.options,a=t.source!==e.layout.source;if(i===`size`)bO(e=>{let r=a?t.measuredBox[e]:t.layoutBox[e],i=QD(r);r.min=n[e].min,r.max=r.min+i});else if(i===`x`||i===`y`){let e=i===`x`?`y`:`x`;GD(a?t.measuredBox[e]:t.layoutBox[e],n[e])}else hk(i,t.layoutBox,n)&&bO(r=>{let i=a?t.measuredBox[r]:t.layoutBox[r],o=QD(n[r]);i.max=i.min+o,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[r].max=e.relativeTarget[r].min+o)});let o=CE();tO(o,n,t.layoutBox);let s=CE();a?tO(s,e.applyTransform(r,!0),t.measuredBox):tO(s,n,t.layoutBox);let c=!pO(o),l=!1;if(!e.resumeFrom){let r=e.getClosestProjectingParent();if(r&&!r.resumeFrom){let{snapshot:i,layout:a}=r;if(i&&a){let o=e.options.layoutAnchor||void 0,s=TE();aO(s,t.layoutBox,i.layoutBox,o);let c=TE();aO(c,n,a.layoutBox,o),_O(s,c)||(l=!0),r.options.layoutRoot&&(e.relativeTarget=c,e.relativeTargetOrigin=s,e.relativeParent=r)}}}e.notifyListeners(`didUpdate`,{layout:n,snapshot:t,delta:s,layoutDelta:o,hasLayoutChanged:c,hasRelativeLayoutChanged:l})}else if(e.isLead()){let{onExitComplete:t}=e.options;t&&t()}e.options.transition=void 0}function qO(e){vE.value&&RO.nodes++,e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty),e.isTransformDirty||=e.parent.isTransformDirty)}function JO(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function YO(e){e.clearSnapshot()}function XO(e){e.clearMeasurements()}function ZO(e){e.isLayoutDirty=!0,e.updateLayout()}function QO(e){e.isLayoutDirty=!1}function $O(e){e.isAnimationBlocked&&e.layout&&!e.isLayoutDirty&&(e.snapshot=e.layout,e.isLayoutDirty=!0)}function ek(e){let{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify(`BeforeLayoutMeasure`),e.resetTransform()}function tk(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function nk(e){e.resolveTargetDelta()}function rk(e){e.calcProjection()}function ik(e){e.resetSkewAndRotation()}function ak(e){e.removeLeadSnapshot()}function ok(e,t,n){e.translate=MS(t.translate,0,n),e.scale=MS(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function sk(e,t,n,r){e.min=MS(t.min,n.min,r),e.max=MS(t.max,n.max,r)}function ck(e,t,n,r){sk(e.x,t.x,n.x,r),sk(e.y,t.y,n.y,r)}function lk(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}var uk={duration:.45,ease:[.4,0,.1,1]},dk=e=>typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),fk=dk(`applewebkit/`)&&!dk(`chrome/`)?Math.round:$b;function pk(e){e.min=fk(e.min),e.max=fk(e.max)}function mk(e){pk(e.x),pk(e.y)}function hk(e,t,n){return e===`position`||e===`preserve-aspect`&&!$D(vO(t),vO(n),.2)}function gk(e){return e!==e.root&&e.scroll?.wasRoot}var _k=WO({attachResizeListener:(e,t)=>jO(e,`resize`,t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body?.scrollLeft||0,y:document.documentElement.scrollTop||document.body?.scrollTop||0}),checkIsScrollRoot:()=>!0}),vk={current:void 0},yk=WO({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!vk.current){let e=new _k({});e.mount(window),e.setOptions({layoutScroll:!0}),vk.current=e}return vk.current},resetTransform:(e,t)=>{e.style.transform=t===void 0?`none`:t},checkIsScrollRoot:e=>window.getComputedStyle(e).position===`fixed`}),bk=(0,R.createContext)({transformPagePoint:e=>e,isStatic:!1,reducedMotion:`never`});function xk(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function Sk(...e){return t=>{let n=!1,r=e.map(e=>{let r=xk(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():xk(e[t],null)}}}}function Ck(...e){return R.useCallback(Sk(...e),e)}var wk=class extends R.Component{getSnapshotBeforeUpdate(e){let t=this.props.childRef.current;if(IT(t)&&e.isPresent&&!this.props.isPresent&&this.props.pop!==!1){let e=t.offsetParent,n=IT(e)&&e.offsetWidth||0,r=IT(e)&&e.offsetHeight||0,i=getComputedStyle(t),a=this.props.sizeRef.current;a.height=parseFloat(i.height),a.width=parseFloat(i.width),a.top=t.offsetTop,a.left=t.offsetLeft,a.right=n-a.width-a.left,a.bottom=r-a.height-a.top,a.direction=i.direction}return null}componentDidUpdate(){}render(){return this.props.children}};function Tk({children:e,isPresent:t,anchorX:n,anchorY:r,root:i,pop:a}){let o=(0,R.useId)(),s=(0,R.useRef)(null),c=(0,R.useRef)({width:0,height:0,top:0,left:0,right:0,bottom:0,direction:`ltr`}),{nonce:l}=(0,R.useContext)(bk),u=Ck(s,e.props?.ref??e?.ref);return(0,R.useInsertionEffect)(()=>{let{width:e,height:u,top:d,left:f,right:p,bottom:m,direction:h}=c.current;if(t||a===!1||!s.current||!e||!u)return;let g=h===`rtl`,_=n===`left`?g?`right: ${p}`:`left: ${f}`:g?`left: ${f}`:`right: ${p}`,v=r===`bottom`?`bottom: ${m}`:`top: ${d}`;s.current.dataset.motionPopId=o;let y=document.createElement(`style`);l&&(y.nonce=l);let b=i??document.head;return b.appendChild(y),y.sheet&&y.sheet.insertRule(`
|
|
171
171
|
[data-motion-pop-id="${o}"] {
|
|
172
172
|
position: absolute !important;
|
|
173
173
|
width: ${e}px !important;
|
|
@@ -176,11 +176,11 @@ ${t}`,l++;break;case`id`:s=t.includes(`\0`)?void 0:t;break;case`retry`:/^\d+$/.t
|
|
|
176
176
|
${v}px !important;
|
|
177
177
|
}
|
|
178
178
|
`),()=>{s.current?.removeAttribute(`data-motion-pop-id`),b.contains(y)&&b.removeChild(y)}},[t]),(0,z.jsx)(wk,{isPresent:t,childRef:s,sizeRef:c,pop:a,children:a===!1?e:R.cloneElement(e,{ref:u})})}var Ek=({children:e,initial:t,isPresent:n,onExitComplete:r,custom:i,presenceAffectsLayout:a,mode:o,anchorX:s,anchorY:c,root:l})=>{let u=Hb(Dk),d=(0,R.useId)(),f=(0,R.useRef)(n),p=(0,R.useRef)(r);Ub(()=>{f.current=n,p.current=r});let m=!0,h=(0,R.useMemo)(()=>(m=!1,{id:d,initial:t,isPresent:n,custom:i,onExitComplete:e=>{u.set(e,!0);for(let e of u.values())if(!e)return;r&&r()},register:e=>(u.set(e,!1),()=>{u.delete(e),!f.current&&!u.size&&p.current?.()})}),[n,u,r]);return a&&m&&(h={...h}),(0,R.useMemo)(()=>{u.forEach((e,t)=>u.set(t,!1))},[n]),R.useEffect(()=>{!n&&!u.size&&r&&r()},[n]),e=(0,z.jsx)(Tk,{pop:o===`popLayout`,isPresent:n,anchorX:s,anchorY:c,root:l,children:e}),(0,z.jsx)(Wb.Provider,{value:h,children:e})};function Dk(){return new Map}function Ok(e=!0){let t=(0,R.useContext)(Wb);if(t===null)return[!0,null];let{isPresent:n,onExitComplete:r,register:i}=t,a=(0,R.useId)();(0,R.useEffect)(()=>{if(e)return i(a)},[e]);let o=(0,R.useCallback)(()=>e&&r&&r(a),[a,r,e]);return!n&&r?[!1,o]:[!0]}var kk=e=>e.key||``;function Ak(e){let t=[];return R.Children.forEach(e,e=>{(0,R.isValidElement)(e)&&t.push(e)}),t}var jk=({children:e,custom:t,initial:n=!0,onExitComplete:r,presenceAffectsLayout:i=!0,mode:a=`sync`,propagate:o=!1,anchorX:s=`left`,anchorY:c=`top`,root:l})=>{let[u,d]=Ok(o),f=(0,R.useMemo)(()=>Ak(e),[e]),p=o&&!u?[]:f.map(kk),m=(0,R.useRef)(!0),h=(0,R.useRef)(f),g=Hb(()=>new Map),_=(0,R.useRef)(new Set),[v,y]=(0,R.useState)(f),[b,x]=(0,R.useState)(f);Ub(()=>{m.current=!1,h.current=f;for(let e=0;e<b.length;e++){let t=kk(b[e]);p.includes(t)?(g.delete(t),_.current.delete(t)):g.get(t)!==!0&&g.set(t,!1)}},[b,p.length,p.join(`-`)]);let S=[];if(f!==v){let e=[...f];for(let t=0;t<b.length;t++){let n=b[t],r=kk(n);p.includes(r)||(e.splice(t,0,n),S.push(n))}return a===`wait`&&S.length&&(e=S),x(Ak(e)),y(f),null}let{forceRender:C}=(0,R.useContext)(Vb);return(0,z.jsx)(z.Fragment,{children:b.map(e=>{let v=kk(e),y=o&&!u?!1:f===b||p.includes(v);return(0,z.jsx)(Ek,{isPresent:y,initial:!m.current||n?void 0:!1,custom:t,presenceAffectsLayout:i,mode:a,root:l,onExitComplete:y?void 0:()=>{if(_.current.has(v))return;if(g.has(v))_.current.add(v),g.set(v,!0);else return;let e=!0;g.forEach(t=>{t||(e=!1)}),e&&(C?.(),x(h.current),o&&d?.(),r&&r())},anchorX:s,anchorY:c,children:e},v)})})},Mk=(0,R.createContext)({strict:!1}),Nk={animation:[`animate`,`variants`,`whileHover`,`whileTap`,`exit`,`whileInView`,`whileFocus`,`whileDrag`],exit:[`exit`],drag:[`drag`,`dragControls`],focus:[`whileFocus`],hover:[`whileHover`,`onHoverStart`,`onHoverEnd`],tap:[`whileTap`,`onTap`,`onTapStart`,`onTapCancel`],pan:[`onPan`,`onPanStart`,`onPanSessionStart`,`onPanEnd`],inView:[`whileInView`,`onViewportEnter`,`onViewportLeave`],layout:[`layout`,`layoutId`]},Pk=!1;function Fk(){if(Pk)return;let e={};for(let t in Nk)e[t]={isEnabled:e=>Nk[t].some(t=>!!e[t])};BE(e),Pk=!0}function Ik(){return Fk(),VE()}function Lk(e){let t=Ik();for(let n in e)t[n]={...t[n],...e[n]};BE(t)}var Rk=new Set(`animate.exit.variants.initial.style.values.variants.transition.transformTemplate.custom.inherit.onBeforeLayoutMeasure.onAnimationStart.onAnimationComplete.onUpdate.onDragStart.onDrag.onDragEnd.onMeasureDragConstraints.onDirectionLock.onDragTransitionEnd._dragX._dragY.onHoverStart.onHoverEnd.onViewportEnter.onViewportLeave.globalTapTarget.propagate.ignoreStrict.viewport`.split(`.`));function zk(e){return e.startsWith(`while`)||e.startsWith(`drag`)&&e!==`draggable`||e.startsWith(`layout`)||e.startsWith(`onTap`)||e.startsWith(`onPan`)||e.startsWith(`onLayout`)||Rk.has(e)}var Bk=t({default:()=>Vk}),Vk,Hk=s((()=>{throw Vk={},Error(`Could not resolve "@emotion/is-prop-valid" imported by "framer-motion". Is it installed?`)})),Uk=e=>!zk(e);function Wk(e){typeof e==`function`&&(Uk=t=>t.startsWith(`on`)?!zk(t):e(t))}try{Wk((Hk(),l(Bk)).default)}catch{}function Gk(e,t,n){let r={};for(let i in e)i===`values`&&typeof e.values==`object`||rT(e[i])||(Uk(i)||n===!0&&zk(i)||!t&&!zk(i)||e.draggable&&i.startsWith(`onDrag`))&&(r[i]=e[i]);return r}var Kk=(0,R.createContext)({});function qk(e,t){if(jE(e)){let{initial:t,animate:n}=e;return{initial:t===!1||OE(t)?t:void 0,animate:OE(n)?n:void 0}}return e.inherit===!1?{}:t}function Jk(e){let{initial:t,animate:n}=qk(e,(0,R.useContext)(Kk));return(0,R.useMemo)(()=>({initial:t,animate:n}),[Yk(t),Yk(n)])}function Yk(e){return Array.isArray(e)?e.join(` `):e}var Xk=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function Zk(e,t,n){for(let r in t)!rT(t[r])&&!xD(r,n)&&(e[r]=t[r])}function Qk({transformTemplate:e},t){return(0,R.useMemo)(()=>{let n=Xk();return hD(n,t,e),Object.assign({},n.vars,n.style)},[t])}function $k(e,t){let n=e.style||{},r={};return Zk(r,n,e),Object.assign(r,Qk(e,t)),r}function eA(e,t){let n={},r=$k(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,r.userSelect=r.WebkitUserSelect=r.WebkitTouchCallout=`none`,r.touchAction=e.drag===!0?`none`:`pan-${e.drag===`x`?`y`:`x`}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=r,n}var tA=()=>({...Xk(),attrs:{}});function nA(e,t,n,r){let i=(0,R.useMemo)(()=>{let n=tA();return kD(n,t,jD(r),e.transformTemplate,e.style),{...n.attrs,style:{...n.style}}},[t]);if(e.style){let t={};Zk(t,e.style,e),i.style={...t,...i.style}}return i}var rA=[`animate`,`circle`,`defs`,`desc`,`ellipse`,`g`,`image`,`line`,`filter`,`marker`,`mask`,`metadata`,`path`,`pattern`,`polygon`,`polyline`,`rect`,`stop`,`switch`,`symbol`,`svg`,`text`,`tspan`,`use`,`view`];function iA(e){return typeof e!=`string`||e.includes(`-`)?!1:!!(rA.indexOf(e)>-1||/[A-Z]/u.test(e))}function aA(e,t,n,{latestValues:r},i,a=!1,o){let s=(o??iA(e)?nA:eA)(t,r,i,e),c=Gk(t,typeof e==`string`,a),l=e===R.Fragment?{}:{...c,...s,ref:n},{children:u}=t,d=(0,R.useMemo)(()=>rT(u)?u.get():u,[u]);return(0,R.createElement)(e,{...l,children:d})}function oA({scrapeMotionValuesFromProps:e,createRenderState:t},n,r,i){return{latestValues:sA(n,r,i,e),renderState:t()}}function sA(e,t,n,r){let i={},a=r(e,{});for(let e in a)i[e]=FO(a[e]);let{initial:o,animate:s}=e,c=jE(e),l=ME(e);t&&l&&!c&&e.inherit!==!1&&(o===void 0&&(o=t.initial),s===void 0&&(s=t.animate));let u=n?n.initial===!1:!1;u||=o===!1;let d=u?s:o;if(d&&typeof d!=`boolean`&&!DE(d)){let t=Array.isArray(d)?d:[d];for(let n=0;n<t.length;n++){let r=Xw(e,t[n]);if(r){let{transitionEnd:e,transition:t,...n}=r;for(let e in n){let t=n[e];if(Array.isArray(t)){let e=u?t.length-1:0;t=t[e]}t!==null&&(i[e]=t)}for(let t in e)i[t]=e[t]}}}return i}var cA=e=>(t,n)=>{let r=(0,R.useContext)(Kk),i=(0,R.useContext)(Wb),a=()=>oA(e,t,r,i);return n?a():Hb(a)},lA=cA({scrapeMotionValuesFromProps:SD,createRenderState:Xk}),uA=cA({scrapeMotionValuesFromProps:ND,createRenderState:tA}),dA=Symbol.for(`motionComponentSymbol`);function fA(e,t,n){let r=(0,R.useRef)(n);(0,R.useInsertionEffect)(()=>{r.current=n});let i=(0,R.useRef)(null);return(0,R.useCallback)(n=>{n&&e.onMount?.(n),t&&(n?t.mount(n):t.unmount());let a=r.current;if(typeof a==`function`)if(n){let e=a(n);typeof e==`function`&&(i.current=e)}else i.current?(i.current(),i.current=null):a(n);else a&&(a.current=n)},[t])}var pA=(0,R.createContext)({});function mA(e){return e&&typeof e==`object`&&Object.prototype.hasOwnProperty.call(e,`current`)}function hA(e,t,n,r,i,a){let{visualElement:o}=(0,R.useContext)(Kk),s=(0,R.useContext)(Mk),c=(0,R.useContext)(Wb),l=(0,R.useContext)(bk),u=l.reducedMotion,d=l.skipAnimations,f=(0,R.useRef)(null),p=(0,R.useRef)(!1);r||=s.renderer,!f.current&&r&&(f.current=r(e,{visualState:t,parent:o,props:n,presenceContext:c,blockInitialAnimation:c?c.initial===!1:!1,reducedMotionConfig:u,skipAnimations:d,isSVG:a}),p.current&&f.current&&(f.current.manuallyAnimateOnMount=!0));let m=f.current,h=(0,R.useContext)(pA);m&&!m.projection&&i&&(m.type===`html`||m.type===`svg`)&&gA(f.current,n,i,h);let g=(0,R.useRef)(!1);(0,R.useInsertionEffect)(()=>{m&&g.current&&m.update(n,c)});let _=n[sT],v=(0,R.useRef)(!!_&&typeof window<`u`&&!window.MotionHandoffIsComplete?.(_)&&window.MotionHasOptimisedAnimation?.(_));return Ub(()=>{p.current=!0,m&&(g.current=!0,window.MotionIsMounted=!0,m.updateFeatures(),m.scheduleRenderMicrotask(),v.current&&m.animationState&&m.animationState.animateChanges())}),(0,R.useEffect)(()=>{m&&(!v.current&&m.animationState&&m.animationState.animateChanges(),v.current&&=(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(_)}),!1),m.enteringChildren=void 0)}),m}function gA(e,t,n,r){let{layoutId:i,layout:a,drag:o,dragConstraints:s,layoutScroll:c,layoutRoot:l,layoutAnchor:u,layoutCrossfade:d}=t;e.projection=new n(e.latestValues,t[`data-framer-portal-id`]?void 0:_A(e.parent)),e.projection.setOptions({layoutId:i,layout:a,alwaysMeasureLayout:!!o||s&&mA(s),visualElement:e,animationType:typeof a==`string`?a:`both`,initialPromotionConfig:r,crossfade:d,layoutScroll:c,layoutRoot:l,layoutAnchor:u})}function _A(e){if(e)return e.options.allowProjection===!1?_A(e.parent):e.projection}function vA(e,{forwardMotionProps:t=!1,type:n}={},r,i){r&&Lk(r);let a=n?n===`svg`:iA(e),o=a?uA:lA;function s(n,s){let c,l={...(0,R.useContext)(bk),...n,layoutId:yA(n)},{isStatic:u}=l,d=Jk(n),f=o(n,u);if(!u&&typeof window<`u`){bA(l,r);let t=xA(l);c=t.MeasureLayout,d.visualElement=hA(e,f,l,i,t.ProjectionNode,a)}return(0,z.jsxs)(Kk.Provider,{value:d,children:[c&&d.visualElement?(0,z.jsx)(c,{visualElement:d.visualElement,...l}):null,aA(e,n,fA(f,d.visualElement,s),f,u,t,a)]})}s.displayName=`motion.${typeof e==`string`?e:`create(${e.displayName??e.name??``})`}`;let c=(0,R.forwardRef)(s);return c[dA]=e,c}function yA({layoutId:e}){let t=(0,R.useContext)(Vb).id;return t&&e!==void 0?t+`-`+e:e}function bA(e,t){(0,R.useContext)(Mk).strict}function xA(e){let{drag:t,layout:n}=Ik();if(!t&&!n)return{};let r={...t,...n};return{MeasureLayout:t?.isEnabled(e)||n?.isEnabled(e)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}function SA(e,t){if(typeof Proxy>`u`)return vA;let n=new Map,r=(n,r)=>vA(n,r,e,t);return new Proxy((e,t)=>r(e,t),{get:(i,a)=>a===`create`?r:(n.has(a)||n.set(a,vA(a,void 0,e,t)),n.get(a))})}var CA=(e,t)=>t.isSVG??iA(e)?new PD(t):new wD(t,{allowProjection:e!==R.Fragment}),wA=class extends WE{constructor(e){super(e),e.animationState||=VD(e)}updateAnimationControlsSubscription(){let{animate:e}=this.node.getProps();DE(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){let{animate:e}=this.node.getProps(),{animate:t}=this.node.prevProps||{};e!==t&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}},TA=0,EA={animation:{Feature:wA},exit:{Feature:class extends WE{constructor(){super(...arguments),this.id=TA++,this.isExitComplete=!1}update(){if(!this.node.presenceContext)return;let{isPresent:e,onExitComplete:t}=this.node.presenceContext,{isPresent:n}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===n)return;if(e&&n===!1){if(this.isExitComplete){let{initial:e,custom:t}=this.node.getProps();if(typeof e==`string`||typeof e==`object`&&e&&!Array.isArray(e)){let n=Zw(this.node,e,t);if(n){let{transition:e,transitionEnd:t,...r}=n;for(let e in r)this.node.getValue(e)?.jump(r[e])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive(`exit`,!1);this.isExitComplete=!1;return}let r=this.node.animationState.setActive(`exit`,!e);t&&!e&&r.then(()=>{this.isExitComplete=!0,t(this.id)})}mount(){let{register:e,onExitComplete:t}=this.node.presenceContext||{};t&&t(this.id),e&&(this.unmount=e(this.id))}unmount(){}}}};function DA(e){return{point:{x:e.pageX,y:e.pageY}}}var OA=e=>t=>GT(t)&&e(t,DA(t));function kA(e,t,n,r){return jO(e,t,OA(n),r)}var AA=({current:e})=>e?e.ownerDocument.defaultView:null,jA=(e,t)=>Math.abs(e-t);function MA(e,t){let n=jA(e.x,t.x),r=jA(e.y,t.y);return Math.sqrt(n**2+r**2)}var NA=new Set([`auto`,`scroll`]),PA=class{constructor(e,t,{transformPagePoint:n,contextWindow:r=window,dragSnapToOrigin:i=!1,distanceThreshold:a=3,element:o}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=e=>{this.handleScroll(e.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=FA(this.lastRawMoveEventInfo,this.transformPagePoint));let e=LA(this.lastMoveEventInfo,this.history),t=this.startEvent!==null,n=MA(e.offset,{x:0,y:0})>=this.distanceThreshold;if(!t&&!n)return;let{point:r}=e,{timestamp:i}=Px;this.history.push({...r,timestamp:i});let{onStart:a,onMove:o}=this.handlers;t||(a&&a(this.lastMoveEvent,e),this.startEvent=this.lastMoveEvent),o&&o(this.lastMoveEvent,e)},this.handlePointerMove=(e,t)=>{this.lastMoveEvent=e,this.lastRawMoveEventInfo=t,this.lastMoveEventInfo=FA(t,this.transformPagePoint),Mx.update(this.updatePoint,!0)},this.handlePointerUp=(e,t)=>{this.end();let{onEnd:n,onSessionEnd:r,resumeAnimation:i}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&i&&i(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;let a=LA(e.type===`pointercancel`?this.lastMoveEventInfo:FA(t,this.transformPagePoint),this.history);this.startEvent&&n&&n(e,a),r&&r(e,a)},!GT(e))return;this.dragSnapToOrigin=i,this.handlers=t,this.transformPagePoint=n,this.distanceThreshold=a,this.contextWindow=r||window;let s=FA(DA(e),this.transformPagePoint),{point:c}=s,{timestamp:l}=Px;this.history=[{...c,timestamp:l}];let{onSessionStart:u}=t;u&&u(e,LA(s,this.history));let d={passive:!0,capture:!0};this.removeListeners=ex(kA(this.contextWindow,`pointermove`,this.handlePointerMove,d),kA(this.contextWindow,`pointerup`,this.handlePointerUp,d),kA(this.contextWindow,`pointercancel`,this.handlePointerUp,d)),o&&this.startScrollTracking(o)}startScrollTracking(e){let t=e.parentElement;for(;t;){let e=getComputedStyle(t);(NA.has(e.overflowX)||NA.has(e.overflowY))&&this.scrollPositions.set(t,{x:t.scrollLeft,y:t.scrollTop}),t=t.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener(`scroll`,this.onElementScroll,{capture:!0}),window.addEventListener(`scroll`,this.onWindowScroll),this.removeScrollListeners=()=>{window.removeEventListener(`scroll`,this.onElementScroll,{capture:!0}),window.removeEventListener(`scroll`,this.onWindowScroll)}}handleScroll(e){let t=this.scrollPositions.get(e);if(!t)return;let n=e===window,r=n?{x:window.scrollX,y:window.scrollY}:{x:e.scrollLeft,y:e.scrollTop},i={x:r.x-t.x,y:r.y-t.y};i.x===0&&i.y===0||(n?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=i.x,this.lastMoveEventInfo.point.y+=i.y):this.history.length>0&&(this.history[0].x-=i.x,this.history[0].y-=i.y),this.scrollPositions.set(e,r),Mx.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),Nx(this.updatePoint)}};function FA(e,t){return t?{point:t(e.point)}:e}function IA(e,t){return{x:e.x-t.x,y:e.y-t.y}}function LA({point:e},t){return{point:e,delta:IA(e,RA(t)),offset:IA(e,Tee(t)),velocity:Eee(t,.1)}}function Tee(e){return e[0]}function RA(e){return e[e.length-1]}function Eee(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,r=null,i=RA(e);for(;n>=0&&(r=e[n],!(i.timestamp-r.timestamp>rx(t)));)n--;if(!r)return{x:0,y:0};r===e[0]&&e.length>2&&i.timestamp-r.timestamp>rx(t)*2&&(r=e[1]);let a=ix(i.timestamp-r.timestamp);if(a===0)return{x:0,y:0};let o={x:(i.x-r.x)/a,y:(i.y-r.y)/a};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}function Dee(e,{min:t,max:n},r){return t!==void 0&&e<t?e=r?MS(t,e,r.min):Math.max(e,t):n!==void 0&&e>n&&(e=r?MS(n,e,r.max):Math.min(e,n)),e}function zA(e,t,n){return{min:t===void 0?void 0:e.min+t,max:n===void 0?void 0:e.max+n-(e.max-e.min)}}function Oee(e,{top:t,left:n,bottom:r,right:i}){return{x:zA(e.x,n,i),y:zA(e.y,t,r)}}function BA(e,t){let n=t.min-e.min,r=t.max-e.max;return t.max-t.min<e.max-e.min&&([n,r]=[r,n]),{min:n,max:r}}function kee(e,t){return{x:BA(e.x,t.x),y:BA(e.y,t.y)}}function Aee(e,t){let n=.5,r=QD(e),i=QD(t);return i>r?n=tx(t.min,t.max-r,e.min):r>i&&(n=tx(e.min,e.max-i,t.min)),qb(0,1,n)}function jee(e,t){let n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}var VA=.35;function Mee(e=VA){return e===!1?e=0:e===!0&&(e=VA),{x:HA(e,`left`,`right`),y:HA(e,`top`,`bottom`)}}function HA(e,t,n){return{min:UA(e,t),max:UA(e,n)}}function UA(e,t){return typeof e==`number`?e:e[t]||0}var Nee=new WeakMap,Pee=class{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=TE(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:t=!1,distanceThreshold:n}={}){let{presenceContext:r}=this.visualElement;if(r&&r.isPresent===!1)return;let i=e=>{t&&this.snapToCursor(DA(e).point),this.stopAnimation()},a=(e,t)=>{let{drag:n,dragPropagation:r,onDragStart:i}=this.getProps();if(n&&!r&&(this.openDragLock&&this.openDragLock(),this.openDragLock=BT(n),!this.openDragLock))return;this.latestPointerEvent=e,this.latestPanInfo=t,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),bO(e=>{let t=this.getAxisMotionValue(e).get()||0;if(sS.test(t)){let{projection:n}=this.visualElement;if(n&&n.layout){let r=n.layout.layoutBox[e];r&&(t=QD(r)*(parseFloat(t)/100))}}this.originPoint[e]=t}),i&&Mx.update(()=>i(e,t),!1,!0),aT(this.visualElement,`transform`);let{animationState:a}=this.visualElement;a&&a.setActive(`whileDrag`,!0)},o=(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t;let{dragPropagation:n,dragDirectionLock:r,onDirectionLock:i,onDrag:a}=this.getProps();if(!n&&!this.openDragLock)return;let{offset:o}=t;if(r&&this.currentDirection===null){this.currentDirection=qA(o),this.currentDirection!==null&&i&&i(this.currentDirection);return}this.updateAxis(`x`,t.point,o),this.updateAxis(`y`,t.point,o),this.visualElement.render(),a&&Mx.update(()=>a(e,t),!1,!0)},s=(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t,this.stop(e,t),this.latestPointerEvent=null,this.latestPanInfo=null},c=()=>{let{dragSnapToOrigin:e}=this.getProps();(e||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:l}=this.getProps();this.panSession=new PA(e,{onSessionStart:i,onStart:a,onMove:o,onSessionEnd:s,resumeAnimation:c},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:l,distanceThreshold:n,contextWindow:AA(this.visualElement),element:this.visualElement.current})}stop(e,t){let n=e||this.latestPointerEvent,r=t||this.latestPanInfo,i=this.isDragging;if(this.cancel(),!i||!r||!n)return;let{velocity:a}=r;this.startAnimation(a);let{onDragEnd:o}=this.getProps();o&&Mx.postRender(()=>o(n,r))}cancel(){this.isDragging=!1;let{projection:e,animationState:t}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.endPanSession();let{dragPropagation:n}=this.getProps();!n&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),t&&t.setActive(`whileDrag`,!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(e,t,n){let{drag:r}=this.getProps();if(!n||!KA(e,r,this.currentDirection))return;let i=this.getAxisMotionValue(e),a=this.originPoint[e]+n[e];this.constraints&&this.constraints[e]&&(a=Dee(a,this.constraints[e],this.elastic[e])),i.set(a)}resolveConstraints(){let{dragConstraints:e,dragElastic:t}=this.getProps(),n=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,r=this.constraints;e&&mA(e)?this.constraints||=this.resolveRefConstraints():e&&n?this.constraints=Oee(n.layoutBox,e):this.constraints=!1,this.elastic=Mee(t),r!==this.constraints&&!mA(e)&&n&&this.constraints&&!this.hasMutatedConstraints&&bO(e=>{this.constraints!==!1&&this.getAxisMotionValue(e)&&(this.constraints[e]=jee(n.layoutBox[e],this.constraints[e]))})}resolveRefConstraints(){let{dragConstraints:e,onMeasureDragConstraints:t}=this.getProps();if(!e||!mA(e))return!1;let n=e.current,{projection:r}=this.visualElement;if(!r||!r.layout)return!1;r.root&&(r.root.scroll=void 0,r.root.updateScroll());let i=dD(n,r.root,this.visualElement.getTransformPagePoint()),a=kee(r.layout.layoutBox,i);if(t){let e=t(KE(a));this.hasMutatedConstraints=!!e,e&&(a=GE(e))}return a}startAnimation(e){let{drag:t,dragMomentum:n,dragElastic:r,dragTransition:i,dragSnapToOrigin:a,onDragTransitionEnd:o}=this.getProps(),s=this.constraints||{},c=bO(o=>{if(!KA(o,t,this.currentDirection))return;let c=s&&s[o]||{};(a===!0||a===o)&&(c={min:0,max:0});let l=r?200:1e6,u=r?40:1e7,d={type:`inertia`,velocity:n?e[o]:0,bounceStiffness:l,bounceDamping:u,timeConstant:750,restDelta:1,restSpeed:10,...i,...c};return this.startAxisValueAnimation(o,d)});return Promise.all(c).then(o)}startAxisValueAnimation(e,t){let n=this.getAxisMotionValue(e);return aT(this.visualElement,e),n.start(Gw(e,n,0,t,this.visualElement,!1))}stopAnimation(){bO(e=>this.getAxisMotionValue(e).stop())}getAxisMotionValue(e){let t=`_drag${e.toUpperCase()}`;return this.visualElement.getProps()[t]||this.visualElement.getValue(e,this.visualElement.latestValues[e]??0)}snapToCursor(e){bO(t=>{let{drag:n}=this.getProps();if(!KA(t,n,this.currentDirection))return;let{projection:r}=this.visualElement,i=this.getAxisMotionValue(t);if(r&&r.layout){let{min:n,max:a}=r.layout.layoutBox[t],o=i.get()||0;i.set(e[t]-MS(n,a,.5)+o)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;let{drag:e,dragConstraints:t}=this.getProps(),{projection:n}=this.visualElement;if(!mA(t)||!n||!this.constraints)return;this.stopAnimation();let r={x:0,y:0};bO(e=>{let t=this.getAxisMotionValue(e);if(t&&this.constraints!==!1){let n=t.get();r[e]=Aee({min:n,max:n},this.constraints[e])}});let{transformTemplate:i}=this.visualElement.getProps();this.visualElement.current.style.transform=i?i({},``):`none`,n.root&&n.root.updateScroll(),n.updateLayout(),this.constraints=!1,this.resolveConstraints(),bO(t=>{if(!KA(t,e,null))return;let n=this.getAxisMotionValue(t),{min:i,max:a}=this.constraints[t];n.set(MS(i,a,r[t]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;Nee.set(this.visualElement,this);let e=this.visualElement.current,t=kA(e,`pointerdown`,t=>{let{drag:n,dragListener:r=!0}=this.getProps(),i=t.target,a=i!==e&&YT(i);n&&r&&!a&&this.start(t)}),n,r=()=>{let{dragConstraints:t}=this.getProps();mA(t)&&t.current&&(this.constraints=this.resolveRefConstraints(),n||=GA(e,t.current,()=>this.scalePositionWithinConstraints()))},{projection:i}=this.visualElement,a=i.addEventListener(`measure`,r);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),Mx.read(r);let o=jO(window,`resize`,()=>this.scalePositionWithinConstraints()),s=i.addEventListener(`didUpdate`,(({delta:e,hasLayoutChanged:t})=>{this.isDragging&&t&&(bO(t=>{let n=this.getAxisMotionValue(t);n&&(this.originPoint[t]+=e[t].translate,n.set(n.get()+e[t].translate))}),this.visualElement.render())}));return()=>{o(),t(),a(),s&&s(),n&&n()}}getProps(){let e=this.visualElement.getProps(),{drag:t=!1,dragDirectionLock:n=!1,dragPropagation:r=!1,dragConstraints:i=!1,dragElastic:a=VA,dragMomentum:o=!0}=e;return{...e,drag:t,dragDirectionLock:n,dragPropagation:r,dragConstraints:i,dragElastic:a,dragMomentum:o}}};function WA(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function GA(e,t,n){let r=_E(e,WA(n)),i=_E(t,WA(n));return()=>{r(),i()}}function KA(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function qA(e,t=10){let n=null;return Math.abs(e.y)>t?n=`y`:Math.abs(e.x)>t&&(n=`x`),n}var JA=class extends WE{constructor(e){super(e),this.removeGroupControls=$b,this.removeListeners=$b,this.controls=new Pee(e)}mount(){let{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||$b}update(){let{dragControls:e}=this.node.getProps(),{dragControls:t}=this.node.prevProps||{};e!==t&&(this.removeGroupControls(),e&&(this.removeGroupControls=e.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}},YA=e=>(t,n)=>{e&&Mx.update(()=>e(t,n),!1,!0)},XA=class extends WE{constructor(){super(...arguments),this.removePointerDownListener=$b}onPointerDown(e){this.session=new PA(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:AA(this.node)})}createPanHandlers(){let{onPanSessionStart:e,onPanStart:t,onPan:n,onPanEnd:r}=this.node.getProps();return{onSessionStart:YA(e),onStart:YA(t),onMove:YA(n),onEnd:(e,t)=>{delete this.session,r&&Mx.postRender(()=>r(e,t))}}}mount(){this.removePointerDownListener=kA(this.node.current,`pointerdown`,e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}},ZA=!1,QA=class extends R.Component{componentDidMount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n,layoutId:r}=this.props,{projection:i}=e;i&&(t.group&&t.group.add(i),n&&n.register&&r&&n.register(i),ZA&&i.root.didUpdate(),i.addEventListener(`animationComplete`,()=>{this.safeToRemove()}),i.setOptions({...i.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),LO.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){let{layoutDependency:t,visualElement:n,drag:r,isPresent:i}=this.props,{projection:a}=n;return a?(a.isPresent=i,e.layoutDependency!==t&&a.setOptions({...a.options,layoutDependency:t}),ZA=!0,r||e.layoutDependency!==t||t===void 0||e.isPresent!==i?a.willUpdate():this.safeToRemove(),e.isPresent!==i&&(i?a.promote():a.relegate()||Mx.postRender(()=>{let e=a.getStack();(!e||!e.members.length)&&this.safeToRemove()})),null):null}componentDidUpdate(){let{visualElement:e,layoutAnchor:t}=this.props,{projection:n}=e;n&&(n.options.layoutAnchor=t,n.root.didUpdate(),LT.postRender(()=>{!n.currentAnimation&&n.isLead()&&this.safeToRemove()}))}componentWillUnmount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n}=this.props,{projection:r}=e;ZA=!0,r&&(r.scheduleCheckAfterUnmount(),t&&t.group&&t.group.remove(r),n&&n.deregister&&n.deregister(r))}safeToRemove(){let{safeToRemove:e}=this.props;e&&e()}render(){return null}};function $A(e){let[t,n]=Ok(),r=(0,R.useContext)(Vb);return(0,z.jsx)(QA,{...e,layoutGroup:r,switchLayoutGroup:(0,R.useContext)(pA),isPresent:t,safeToRemove:n})}var ej={pan:{Feature:XA},drag:{Feature:JA,ProjectionNode:yk,MeasureLayout:$A}};function tj(e,t,n){let{props:r}=e;e.animationState&&r.whileHover&&e.animationState.setActive(`whileHover`,n===`Start`);let i=r[`onHover`+n];i&&Mx.postRender(()=>i(t,DA(t)))}var nj=class extends WE{mount(){let{current:e}=this.node;e&&(this.unmount=UT(e,(e,t)=>(tj(this.node,t,`Start`),e=>tj(this.node,e,`End`))))}unmount(){}},rj=class extends WE{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(`:focus-visible`)}catch{e=!0}!e||!this.node.animationState||(this.node.animationState.setActive(`whileFocus`,!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive(`whileFocus`,!1),this.isActive=!1)}mount(){this.unmount=ex(jO(this.node.current,`focus`,()=>this.onFocus()),jO(this.node.current,`blur`,()=>this.onBlur()))}unmount(){}};function ij(e,t,n){let{props:r}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&r.whileTap&&e.animationState.setActive(`whileTap`,n===`Start`);let i=r[`onTap`+(n===`End`?``:n)];i&&Mx.postRender(()=>i(t,DA(t)))}var aj=class extends WE{mount(){let{current:e}=this.node;if(!e)return;let{globalTapTarget:t,propagate:n}=this.node.props;this.unmount=nE(e,(e,t)=>(ij(this.node,t,`Start`),(e,{success:t})=>ij(this.node,e,t?`End`:`Cancel`)),{useGlobalTarget:t,stopPropagation:n?.tap===!1})}unmount(){}},oj=new WeakMap,sj=new WeakMap,cj=e=>{let t=oj.get(e.target);t&&t(e)},lj=e=>{e.forEach(cj)};function uj({root:e,...t}){let n=e||document;sj.has(n)||sj.set(n,{});let r=sj.get(n),i=JSON.stringify(t);return r[i]||(r[i]=new IntersectionObserver(lj,{root:e,...t})),r[i]}function dj(e,t,n){let r=uj(t);return oj.set(e,n),r.observe(e),()=>{oj.delete(e),r.unobserve(e)}}var fj={some:0,all:1},pj=class extends WE{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.stopObserver?.();let{viewport:e={}}=this.node.getProps(),{root:t,margin:n,amount:r=`some`,once:i}=e,a={root:t?t.current:void 0,rootMargin:n,threshold:typeof r==`number`?r:fj[r]},o=e=>{let{isIntersecting:t}=e;if(this.isInView===t||(this.isInView=t,i&&!t&&this.hasEnteredView))return;t&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive(`whileInView`,t);let{onViewportEnter:n,onViewportLeave:r}=this.node.getProps(),a=t?n:r;a&&a(e)};this.stopObserver=dj(this.node.current,a,o)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>`u`)return;let{props:e,prevProps:t}=this.node;[`amount`,`margin`,`root`].some(mj(e,t))&&this.startObserver()}unmount(){this.stopObserver?.(),this.hasEnteredView=!1,this.isInView=!1}};function mj({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}var hj={inView:{Feature:pj},tap:{Feature:aj},focus:{Feature:rj},hover:{Feature:nj}},gj={layout:{ProjectionNode:yk,MeasureLayout:$A}},_j=SA({...EA,...hj,...ej,...gj},CA);function vj(){!FE.current&&LE();let[e]=(0,R.useState)(PE.current);return e}function yj(e){e.values.forEach(e=>e.stop())}function bj(e,t){[...t].reverse().forEach(n=>{let r=e.getVariant(n);r&&nT(e,r),e.variantChildren&&e.variantChildren.forEach(e=>{bj(e,t)})})}function xj(e,t){if(Array.isArray(t))return bj(e,t);if(typeof t==`string`)return bj(e,[t]);nT(e,t)}function Sj(){let e=new Set,t={subscribe(t){return e.add(t),()=>void e.delete(t)},start(t,n){let r=[];return e.forEach(e=>{r.push(pT(e,t,{transitionOverride:n}))}),Promise.all(r)},set(t){return e.forEach(e=>{xj(e,t)})},stop(){e.forEach(e=>{yj(e)})},mount(){return()=>{t.stop()}}};return t}function Cj(){let e=Hb(Sj);return Ub(e.mount,[]),e}var wj=Cj,G=jt(),Tj=_j,Ej={damping:.7,stiffness:.05,mass:1.25},Dj=70,Oj=1e3/60,kj=350,Aj=!1;globalThis.document?.addEventListener(`mousedown`,()=>{Aj=!0}),globalThis.document?.addEventListener(`mouseup`,()=>{Aj=!1}),globalThis.document?.addEventListener(`click`,()=>{Aj=!1});var jj=(e={})=>{let[t,n]=(0,R.useState)(!1),[r,i]=(0,R.useState)(e.initial!==!1),[a,o]=(0,R.useState)(!1),s=(0,R.useRef)(null);s.current=e;let c=(0,R.useCallback)(()=>{if(!Aj)return!1;let e=window.getSelection();if(!e||!e.rangeCount)return!1;let t=e.getRangeAt(0);return t.commonAncestorContainer.contains(g.current)||g.current?.contains(t.commonAncestorContainer)},[]),l=(0,R.useCallback)(e=>{d.isAtBottom=e,i(e)},[]),u=(0,R.useCallback)(e=>{d.escapedFromLock=e,n(e)},[]),d=(0,R.useMemo)(()=>{let n;return{escapedFromLock:t,isAtBottom:r,resizeDifference:0,accumulated:0,velocity:0,listeners:new Set,get scrollTop(){return g.current?.scrollTop??0},set scrollTop(e){if(g.current){let{scrollBehavior:t}=getComputedStyle(g.current);t!==`auto`&&(g.current.style.scrollBehavior=`auto`),g.current.scrollTop=e,d.ignoreScrollToTop=g.current.scrollTop,t!==`auto`&&(g.current.style.scrollBehavior=t)}},get targetScrollTop(){return!g.current||!_.current?0:g.current.scrollHeight-1-g.current.clientHeight},get calculatedTargetScrollTop(){if(!g.current||!_.current)return 0;let{targetScrollTop:t}=this;if(!e.targetScrollTop)return t;if(n?.targetScrollTop===t)return n.calculatedScrollTop;let r=Math.max(Math.min(e.targetScrollTop(t,{scrollElement:g.current,contentElement:_.current}),t),0);return n={targetScrollTop:t,calculatedScrollTop:r},requestAnimationFrame(()=>{n=void 0}),r},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=Dj}}},[]),f=(0,R.useCallback)((e={})=>{typeof e==`string`&&(e={animation:e}),e.preserveScrollPosition||l(!0);let t=Date.now()+(Number(e.wait)||0),n=Pj(s.current,e.animation),{ignoreEscapes:r=!1}=e,i,a=d.calculatedTargetScrollTop;e.duration instanceof Promise?e.duration.finally(()=>{i=Date.now()}):i=t+(e.duration??0);let o=async()=>{let e=new Promise(requestAnimationFrame).then(()=>{if(!d.isAtBottom)return d.animation=void 0,!1;let{scrollTop:l}=d,u=performance.now(),p=(u-(d.lastTick??u))/Oj;if(d.animation||={behavior:n,promise:e,ignoreEscapes:r},d.animation.behavior===n&&(d.lastTick=u),c()||t>Date.now())return o();if(l<Math.min(a,d.calculatedTargetScrollTop)){if(d.animation?.behavior===n){if(n===`instant`)return d.scrollTop=d.calculatedTargetScrollTop,o();d.velocity=(n.damping*d.velocity+n.stiffness*d.scrollDifference)/n.mass,d.accumulated+=d.velocity*p,d.scrollTop+=d.accumulated,d.scrollTop!==l&&(d.accumulated=0)}return o()}return i>Date.now()?(a=d.calculatedTargetScrollTop,o()):(d.animation=void 0,d.scrollTop<d.calculatedTargetScrollTop?f({animation:Pj(s.current,s.current.resize),ignoreEscapes:r,duration:Math.max(0,i-Date.now())||void 0}):d.isAtBottom)});return e.then(e=>(requestAnimationFrame(()=>{d.animation||(d.lastTick=void 0,d.velocity=0)}),e))};return e.wait!==!0&&(d.animation=void 0),d.animation?.behavior===n?d.animation.promise:o()},[l,c,d]),p=(0,R.useCallback)(()=>{u(!0),l(!1)},[u,l]),m=(0,R.useCallback)(({target:e})=>{if(e!==g.current)return;let{scrollTop:t,ignoreScrollToTop:n}=d,{lastScrollTop:r=t}=d;d.lastScrollTop=t,d.ignoreScrollToTop=void 0,n&&n>t&&(r=n),o(d.isNearBottom),setTimeout(()=>{if(d.resizeDifference||t===n)return;if(c()){u(!0),l(!1);return}let e=t>r,i=t<r;if(d.animation?.ignoreEscapes){d.scrollTop=r;return}i&&(u(!0),l(!1)),e&&u(!1),!d.escapedFromLock&&d.isNearBottom&&l(!0)},1)},[u,l,c,d]),h=(0,R.useCallback)(({target:e,deltaY:t})=>{let n=e;for(;![`scroll`,`auto`].includes(getComputedStyle(n).overflow);){if(!n.parentElement)return;n=n.parentElement}n===g.current&&t<0&&g.current.scrollHeight>g.current.clientHeight&&!d.animation?.ignoreEscapes&&(u(!0),l(!1))},[u,l,d]),g=Mj(e=>{g.current?.removeEventListener(`scroll`,m),g.current?.removeEventListener(`wheel`,h),e?.addEventListener(`scroll`,m,{passive:!0}),e?.addEventListener(`wheel`,h,{passive:!0})},[]),_=Mj(e=>{if(d.resizeObserver?.disconnect(),d.resizeObserver=void 0,!e)return;let t;d.resizeObserver=new ResizeObserver(([e])=>{let{height:n}=e.contentRect,r=n-(t??n);if(d.resizeDifference=r,d.scrollTop>d.targetScrollTop&&(d.scrollTop=d.targetScrollTop),o(d.isNearBottom),r>=0){let e=Pj(s.current,t?s.current.resize:s.current.initial);f({animation:e,wait:!0,preserveScrollPosition:!0,duration:e===`instant`?void 0:kj})}else d.isNearBottom&&(u(!1),l(!0));t=n,requestAnimationFrame(()=>{setTimeout(()=>{d.resizeDifference===r&&(d.resizeDifference=0)},1)})}),d.resizeObserver?.observe(e)},[]);return{contentRef:_,scrollRef:g,scrollToBottom:f,stopScroll:p,isAtBottom:r||a,isNearBottom:a,escapedFromLock:t,state:d}};function Mj(e,t){let n=(0,R.useCallback)(t=>(n.current=t,e(t)),t);return n}var Nj=new Map;function Pj(...e){let t={...Ej},n=!1;for(let r of e){if(r===`instant`){n=!0;continue}typeof r==`object`&&(n=!1,t.damping=r.damping??t.damping,t.stiffness=r.stiffness??t.stiffness,t.mass=r.mass??t.mass)}let r=JSON.stringify(t);return Nj.has(r)||Nj.set(r,Object.freeze(t)),n?`instant`:Nj.get(r)}var Fj=new Set([`name`,`id`,`aria-describedby`,`aria-labelledby`]);function Ij(e){let t=new Set;for(let{name:n}of e){if(t.has(n))return n;t.add(n)}}function Lj(e){let t=e.allowedAttributes.filter(e=>Fj.has(e));if(t.length>0)throw Error(`Interactive element <${e.name}> declares reserved attribute(s) ${t.join(`, `)}. The markdown sanitizer rewrites these to "user-content-<value>" (DOM-clobbering protection), so the component would receive a mangled value. Use a domain attribute instead (e.g. "param").`)}var Rj=/^[a-z][a-z0-9]*(-[a-z0-9]+)*$/,zj=L().min(1).max(64).regex(Rj).refine(e=>!Fj.has(e),{error:`Attribute is reserved: the markdown sanitizer rewrites it to "user-content-<value>". Use a domain attribute instead (e.g. "param").`}),Bj=Me({name:L().min(1).max(64).regex(Rj),description:L().max(512).optional(),allowedAttributes:Xt(zj).max(20)});Xt(Bj).max(100).superRefine((e,t)=>{let n=Ij(e);n!==void 0&&t.addIssue({code:`custom`,message:`Duplicate element name "${n}": a catalog must map each tag to exactly one element.`})}).optional();function Vj(e){let{name:t,allowedAttributes:n,description:r}=e;return{name:t,allowedAttributes:n,description:r}}function Hj(e){for(let t of e){let e=Bj.safeParse(Vj(t));if(!e.success)throw Error(`Interactive element <${t.name}> is invalid:
|
|
179
|
-
${At(e.error)}`)}let t=Ij(e);if(t!==void 0)throw Error(`Duplicate element name <${t}>: a catalog must map each tag to exactly one element.`);return[...e]}var Uj={0:`�`,128:`€`,130:`‚`,131:`ƒ`,132:`„`,133:`…`,134:`†`,135:`‡`,136:`ˆ`,137:`‰`,138:`Š`,139:`‹`,140:`Œ`,142:`Ž`,145:`‘`,146:`’`,147:`“`,148:`”`,149:`•`,150:`–`,151:`—`,152:`˜`,153:`™`,154:`š`,155:`›`,156:`œ`,158:`ž`,159:`Ÿ`};function Wj(e){let t=typeof e==`string`?e.charCodeAt(0):e;return t>=48&&t<=57}function Gj(e){let t=typeof e==`string`?e.charCodeAt(0):e;return t>=97&&t<=102||t>=65&&t<=70||t>=48&&t<=57}function Kj(e){let t=typeof e==`string`?e.charCodeAt(0):e;return t>=97&&t<=122||t>=65&&t<=90}function qj(e){return Kj(e)||Wj(e)}var Jj=[``,`Named character references must be terminated by a semicolon`,`Numeric character references must be terminated by a semicolon`,`Named character references cannot be empty`,`Numeric character references cannot be empty`,`Named character references must be known`,`Numeric character references cannot be disallowed`,`Numeric character references cannot be outside the permissible Unicode range`];function Yj(e,t){let n=t||{},r=typeof n.additional==`string`?n.additional.charCodeAt(0):n.additional,i=[],a=0,o=-1,s=``,c,l;n.position&&(`start`in n.position||`indent`in n.position?(l=n.position.indent,c=n.position.start):c=n.position);let u=(c?c.line:0)||1,d=(c?c.column:0)||1,f=m(),p;for(a--;++a<=e.length;)if(p===10&&(d=(l?l[o]:0)||1),p=e.charCodeAt(a),p===38){let t=e.charCodeAt(a+1);if(t===9||t===10||t===12||t===32||t===38||t===60||Number.isNaN(t)||r&&t===r){s+=String.fromCharCode(p),d++;continue}let o=a+1,c=o,l=o,u;if(t===35){l=++c;let t=e.charCodeAt(l);t===88||t===120?(u=`hexadecimal`,l=++c):u=`decimal`}else u=`named`;let _=``,v=``,y=``,b=u===`named`?qj:u===`decimal`?Wj:Gj;for(l--;++l<=e.length;){let t=e.charCodeAt(l);if(!b(t))break;y+=String.fromCharCode(t),u===`named`&&
|
|
179
|
+
${At(e.error)}`)}let t=Ij(e);if(t!==void 0)throw Error(`Duplicate element name <${t}>: a catalog must map each tag to exactly one element.`);return[...e]}var Uj={0:`�`,128:`€`,130:`‚`,131:`ƒ`,132:`„`,133:`…`,134:`†`,135:`‡`,136:`ˆ`,137:`‰`,138:`Š`,139:`‹`,140:`Œ`,142:`Ž`,145:`‘`,146:`’`,147:`“`,148:`”`,149:`•`,150:`–`,151:`—`,152:`˜`,153:`™`,154:`š`,155:`›`,156:`œ`,158:`ž`,159:`Ÿ`};function Wj(e){let t=typeof e==`string`?e.charCodeAt(0):e;return t>=48&&t<=57}function Gj(e){let t=typeof e==`string`?e.charCodeAt(0):e;return t>=97&&t<=102||t>=65&&t<=70||t>=48&&t<=57}function Kj(e){let t=typeof e==`string`?e.charCodeAt(0):e;return t>=97&&t<=122||t>=65&&t<=90}function qj(e){return Kj(e)||Wj(e)}var Jj=[``,`Named character references must be terminated by a semicolon`,`Numeric character references must be terminated by a semicolon`,`Named character references cannot be empty`,`Numeric character references cannot be empty`,`Named character references must be known`,`Numeric character references cannot be disallowed`,`Numeric character references cannot be outside the permissible Unicode range`];function Yj(e,t){let n=t||{},r=typeof n.additional==`string`?n.additional.charCodeAt(0):n.additional,i=[],a=0,o=-1,s=``,c,l;n.position&&(`start`in n.position||`indent`in n.position?(l=n.position.indent,c=n.position.start):c=n.position);let u=(c?c.line:0)||1,d=(c?c.column:0)||1,f=m(),p;for(a--;++a<=e.length;)if(p===10&&(d=(l?l[o]:0)||1),p=e.charCodeAt(a),p===38){let t=e.charCodeAt(a+1);if(t===9||t===10||t===12||t===32||t===38||t===60||Number.isNaN(t)||r&&t===r){s+=String.fromCharCode(p),d++;continue}let o=a+1,c=o,l=o,u;if(t===35){l=++c;let t=e.charCodeAt(l);t===88||t===120?(u=`hexadecimal`,l=++c):u=`decimal`}else u=`named`;let _=``,v=``,y=``,b=u===`named`?qj:u===`decimal`?Wj:Gj;for(l--;++l<=e.length;){let t=e.charCodeAt(l);if(!b(t))break;y+=String.fromCharCode(t),u===`named`&&Sl.includes(y)&&(_=y,v=br(y))}let x=e.charCodeAt(l)===59;if(x){l++;let e=u===`named`&&br(y);e&&(_=y,v=e)}let S=1+l-o,C=``;if(!(!x&&n.nonTerminated===!1))if(!y)u!==`named`&&h(4,S);else if(u===`named`){if(x&&!v)h(5,1);else if(_!==y&&(l=c+_.length,S=1+l-c,x=!1),!x){let t=_?1:3;if(n.attribute){let n=e.charCodeAt(l);n===61?(h(t,S),v=``):qj(n)?v=``:h(t,S)}else h(t,S)}C=v}else{x||h(2,S);let e=Number.parseInt(y,u===`hexadecimal`?16:10);if(Xj(e))h(7,S),C=`�`;else if(e in Uj)h(6,S),C=Uj[e];else{let t=``;Zj(e)&&h(6,S),e>65535&&(e-=65536,t+=String.fromCharCode(e>>>10|55296),e=56320|e&1023),C=t+String.fromCharCode(e)}}if(C){g(),f=m(),a=l-1,d+=l-o+1,i.push(C);let t=m();t.offset++,n.reference&&n.reference.call(n.referenceContext||void 0,C,{start:f,end:t},e.slice(o-1,l)),f=t}else y=e.slice(o-1,l),s+=y,d+=y.length,a=l-1}else p===10&&(u++,o++,d=0),Number.isNaN(p)?g():(s+=String.fromCharCode(p),d++);return i.join(``);function m(){return{line:u,column:d,offset:a+((c?c.offset:0)||0)}}function h(e,t){let r;n.warning&&(r=m(),r.column+=t,r.offset+=t,n.warning.call(n.warningContext||void 0,Jj[e],r,e))}function g(){s&&=(i.push(s),n.text&&n.text.call(n.textContext||void 0,s,{start:f,end:m()}),``)}}function Xj(e){return e>=55296&&e<=57343||e>1114111}function Zj(e){return e>=1&&e<=8||e===11||e>=13&&e<=31||e>=127&&e<=159||e>=64976&&e<=65007||(e&65535)==65535||(e&65535)==65534}var Qj={}.hasOwnProperty,$j={},eM={},tM=/^[^\t\n\r "#'.<=>`}]+$/,nM=/^[^\t\n\r "'<=>`}]+$/;function rM(e){let t=e||$j;return{canContainEols:[`textDirective`],enter:{directiveContainer:aM,directiveContainerAttributes:pM,directiveContainerLabel:uM,directiveLeaf:oM,directiveLeafAttributes:pM,directiveText:sM,directiveTextAttributes:pM},exit:{directiveContainer:wM,directiveContainerAttributeClass:mM,directiveContainerAttributeClassValue:_M,directiveContainerAttributeId:mM,directiveContainerAttributeIdValue:gM,directiveContainerAttributeName:yM,directiveContainerAttributeValue:vM,directiveContainerAttributeValueLiteral:hM,directiveContainerAttributes:bM,directiveContainerLabel:dM,directiveContainerName:lM,directiveContainerSequence:n,directiveLeaf:wM,directiveLeafAttributeClass:mM,directiveLeafAttributeClassValue:_M,directiveLeafAttributeId:mM,directiveLeafAttributeIdValue:gM,directiveLeafAttributeName:yM,directiveLeafAttributeValue:vM,directiveLeafAttributeValueLiteral:hM,directiveLeafAttributes:bM,directiveLeafLabel:fM,directiveLeafName:lM,directiveLeafSequence:n,directiveText:wM,directiveTextAttributeClass:mM,directiveTextAttributeClassValue:_M,directiveTextAttributeId:mM,directiveTextAttributeIdValue:gM,directiveTextAttributeName:yM,directiveTextAttributeValue:vM,directiveTextAttributeValueLiteral:hM,directiveTextAttributes:bM,directiveTextLabel:fM,directiveTextMarker:n,directiveTextName:lM}};function n(e){if(!t.verbose)return;let n=this.stack[this.stack.length-1];n.type===`containerDirective`||n.type===`leafDirective`||n.type;let r={start:CM(e.start),end:CM(e.end)};n.data&&n.data.position?(n.type,n.data.position.closing=r):n.data={position:{opening:r}}}}function iM(e){let t=e||eM;if(t.quote!==`"`&&t.quote!==`'`&&t.quote!==null&&t.quote!==void 0)throw Error("Invalid quote `"+t.quote+"`, expected `'` or `\"`");return n.peek=TM,{handlers:{containerDirective:n,leafDirective:n,textDirective:n},unsafe:[{character:`\r`,inConstruct:[`leafDirectiveLabel`,`containerDirectiveLabel`]},{character:`
|
|
180
180
|
`,inConstruct:[`leafDirectiveLabel`,`containerDirectiveLabel`]},{after:`[^\\s\\p{P}\\p{S}]`,before:`[^:]`,character:`:`,inConstruct:[`phrasing`],unicode:!0},{afterNode:`textDirective`,character:`:`,inConstruct:[`phrasing`]},{atBreak:!0,before:`:+`,character:`:`}]};function n(e,t,n,i){let a=n.createTracker(i),o=n.enter(e.type),s;if(e.type===`containerDirective`){let t=(e.children||[])[0],r=DM(t)?e.children.slice(1):e.children;if(r&&r.length>0){let t=a.current();s=n.containerFlow({...e,children:r},{now:{line:t.now.line+1,column:1+t.lineShift},lineShift:t.lineShift})}}let c=OM(e,s?kM(s):0),l=a.move(c+(e.name||``)),u=r(e,n),d=i.after.charCodeAt(0),f;if(e.type===`containerDirective`){let t=(e.children||[])[0];f=DM(t)?t:void 0}else f=e;if(f&&f.children&&f.children.length>0){let t=n.enter(`label`),r=`${e.type}Label`,i=n.enter(r);l+=a.move(`[`),l+=a.move(n.containerPhrasing(f,{...a.current(),before:l,after:`]`})),l+=a.move(`]`),i(),t()}else!u&&(d===45||d===58||d===95||!(Or(d)||yr(d)))&&(l+=a.move(`[]`));return l+=a.move(u||(d===123?`{}`:``)),e.type===`containerDirective`&&(s&&(l+=a.move(`
|
|
181
181
|
`+s)),l+=a.move(`
|
|
182
182
|
`+c)),o(),l}function r(e,n){let r=e.attributes||{},a=[],o,s,c,l;for(l in r)if(Qj.call(r,l)&&r[l]!==void 0&&r[l]!==null){let u=EM(String(r[l]));if(l===`id`)c=t.preferShortcut!==!1&&tM.test(u)?`#`+u:i(`id`,u,e,n);else if(l===`class`){let r=u.split(/[\t\n\r ]+/),a=[],c=[];for(let e of r)(t.preferShortcut!==!1&&tM.test(e)?c:a).push(e);o=a.length>0?i(`class`,a.join(` `),e,n):``,s=c.length>0?`.`+c.join(`.`):``}else a.push(i(l,u,e,n))}return o&&a.unshift(o),s&&a.unshift(s),c&&a.unshift(c),a.length>0?`{`+a.join(` `)+`}`:``}function i(e,n,r,i){if(t.collapseEmptyAttributes!==!1&&!n)return e;if(t.preferUnquoted&&nM.test(n))return e+`=`+n;let a=t.quote||i.options.quote||`"`,o=a===`"`?`'`:`"`,s=t.quoteSmart&&Rr(n,a)>Rr(n,o)?o:a,c=r.type===`textDirective`?[s]:[s,`
|
|
183
|
-
`,`\r`];return e+`=`+s+Ml(n,{subset:c})+s}}function aM(e){cM.call(this,`containerDirective`,e)}function oM(e){cM.call(this,`leafDirective`,e)}function sM(e){cM.call(this,`textDirective`,e)}function cM(e,t){this.enter({type:e,name:``,attributes:{},children:[]},t)}function lM(e){let t=this.stack[this.stack.length-1];t.type===`containerDirective`||t.type===`leafDirective`||t.type,t.name=this.sliceSerialize(e),xM(t,e)}function uM(e){this.enter({type:`paragraph`,data:{directiveLabel:!0},children:[]},e)}function dM(e){this.exit(e);let t=this.stack[this.stack.length-1];t.type,xM(t,e)}function fM(e){let t=this.stack[this.stack.length-1];t.type===`leafDirective`||t.type,xM(t,e)}function pM(){let e=this.stack[this.stack.length-1];e.type===`containerDirective`||e.type===`leafDirective`||e.type,e.data&&e.data.position&&(this.data.directiveAttributePositions={}),this.data.directiveAttributes=[],this.buffer()}function mM(e){let t=this.data.directiveAttributePositions;if(t){let n=this.data.directiveAttributes,r=n[n.length-1];t[r[0]]={start:CM(e.start),end:CM(e.end)}}}function hM(e){SM(this,e)}function gM(e){this.data.directiveAttributes.push([`id`,Yj(this.sliceSerialize(e),{attribute:!0})])}function _M(e){this.data.directiveAttributes.push([`class`,Yj(this.sliceSerialize(e),{attribute:!0})])}function vM(e){let t=this.data.directiveAttributes,n=t[t.length-1];n[1]=Yj(this.sliceSerialize(e),{attribute:!0}),SM(this,e)}function yM(e){let t=this.data.directiveAttributes,n=this.sliceSerialize(e);t.push([n,``]);let r=this.data.directiveAttributePositions;r&&(r[n]={start:CM(e.start),end:CM(e.end)})}function bM(e){let t=this.data.directiveAttributes,n={};for(let e of t)e[0]===`class`&&n.class?n.class+=` `+e[1]:n[e[0]]=e[1];let r=this.data.directiveAttributePositions;this.data.directiveAttributePositions=void 0,this.data.directiveAttributes=void 0,this.resume();let i=this.stack[this.stack.length-1];i.type===`containerDirective`||i.type===`leafDirective`||i.type,i.attributes=n,r&&(i.data&&i.data.position,i.data.position.attributes=r),xM(i,e)}function xM(e,t){if(e.data&&e.data.position){let{opening:n}=e.data.position;n.end=CM(t.end)}}function SM(e,t){let n=e.data.directiveAttributePositions;if(n){let r=e.data.directiveAttributes,i=n[r[r.length-1][0]];i.end=CM(t.end)}}function CM(e){return{line:e.line,column:e.column,offset:e.offset}}function wM(e){this.exit(e)}function TM(){return`:`}function EM(e){let t=[],n=0,r=e.indexOf(`&`);for(;r!==-1;){let i=e.charCodeAt(r+1);(i===35||Kr(i))&&(t.push(e.slice(n,r),`&`),n=r+1),r=e.indexOf(`&`,r+1)}return t.push(e.slice(n)),t.join(``)}function DM(e){return!!(e&&e.type===`paragraph`&&e.data&&e.data.directiveLabel)}function OM(e,t){let n=0;return n=e.type===`containerDirective`?Math.max(3,t+1):e.type===`leafDirective`?2:1,`:`.repeat(n)}function kM(e){let t=0,n=0;for(;n<e.length;){let r=0,i=e.charCodeAt(n);for(;i===9||i===32;)i=e.charCodeAt(++n);for(;i===58;)r++,i=e.charCodeAt(++n);for(;i===9||i===32;)i=e.charCodeAt(++n);for(;!(i===10||i===13||Number.isNaN(i));)r=0,i=e.charCodeAt(++n);r>t&&(t=r),n++}return t}function AM(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m){let h,g;return _;function _(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),v}function v(t){return t===35?(h=o,y(t)):t===46?(h=s,y(t)):m&&qr(t)?Ir(e,v,`whitespace`)(t):!m&&Mr(t)?Lr(e,v)(t):t===null||Jr(t)||yr(t)||Or(t)&&t!==45&&t!==95?O(t):(e.enter(a),e.enter(c),e.consume(t),S)}function y(t){let n=h+`Marker`;return e.enter(a),e.enter(h),e.enter(n),e.consume(t),e.exit(n),b}function b(t){if(t===null||t===34||t===35||t===39||t===46||t===60||t===61||t===62||t===96||t===125||Mr(t))return n(t);let r=h+`Value`;return e.enter(r),e.consume(t),x}function x(t){if(t===null||t===34||t===39||t===60||t===61||t===62||t===96)return n(t);if(t===35||t===46||t===125||Mr(t)){let n=h+`Value`;return e.exit(n),e.exit(h),e.exit(a),v(t)}return e.consume(t),x}function S(t){return t===null||Jr(t)||yr(t)||Or(t)&&t!==45&&t!==46&&t!==58&&t!==95?(e.exit(c),m&&qr(t)?Ir(e,C,`whitespace`)(t):!m&&Mr(t)?Lr(e,C)(t):C(t)):(e.consume(t),S)}function C(t){return t===61?(e.enter(l),e.consume(t),e.exit(l),w):(e.exit(a),v(t))}function w(t){return t===null||t===60||t===61||t===62||t===96||t===125||m&&Jr(t)?n(t):t===34||t===39?(e.enter(u),e.enter(f),e.consume(t),e.exit(f),g=t,E):m&&qr(t)?Ir(e,w,`whitespace`)(t):!m&&Mr(t)?Lr(e,w)(t):(e.enter(d),e.enter(p),e.consume(t),g=void 0,T)}function T(t){return t===null||t===34||t===39||t===60||t===61||t===62||t===96?n(t):t===125||Mr(t)?(e.exit(p),e.exit(d),e.exit(a),v(t)):(e.consume(t),T)}function E(t){return t===g?(e.enter(f),e.consume(t),e.exit(f),e.exit(u),e.exit(a),te):(e.enter(d),D(t))}function D(t){return t===g?(e.exit(d),E(t)):t===null?n(t):Jr(t)?m?n(t):Lr(e,D)(t):(e.enter(p),e.consume(t),ee)}function ee(t){return t===g||t===null||Jr(t)?(e.exit(p),D(t)):(e.consume(t),ee)}function te(e){return e===125||Mr(e)?v(e):O(e)}function O(a){return a===125?(e.enter(i),e.consume(a),e.exit(i),e.exit(r),t):n(a)}}function jM(e,t,n,r,i,a,o){let s=0,c=0,l;return u;function u(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),d}function d(n){return n===93?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),f(n))}function f(t){if(t===93&&!c)return h(t);let n=e.enter(`chunkText`,{_contentTypeTextTrailing:!0,contentType:`text`,previous:l});return l&&(l.next=n),l=n,p(t)}function p(t){return t===null||s>999||t===91&&++c>32?n(t):t===93&&!c--?(e.exit(`chunkText`),h(t)):Jr(t)?o?n(t):(e.consume(t),e.exit(`chunkText`),f):(e.consume(t),t===92?m:p)}function m(t){return t===91||t===92||t===93?(e.consume(t),s++,p):p(t)}function h(n){return e.exit(a),e.enter(i),e.consume(n),e.exit(i),e.exit(r),t}}function MM(e,t,n,r){let i=this;return a;function a(t){return t===null||Jr(t)||Or(t)||yr(t)?n(t):(e.enter(r),e.consume(t),o)}function o(a){return a===null||Jr(a)||yr(a)||Or(a)&&a!==45&&a!==95?(e.exit(r),i.previous===45||i.previous===95?n(a):t(a)):(e.consume(a),o)}}var NM={tokenize:LM,concrete:!0},PM={tokenize:RM,partial:!0},FM={tokenize:zM,partial:!0},IM={tokenize:BM,partial:!0};function LM(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0,s;return c;function c(t){return e.enter(`directiveContainer`),e.enter(`directiveContainerFence`),e.enter(`directiveContainerSequence`),l(t)}function l(t){return t===58?(e.consume(t),o++,l):o<3?n(t):(e.exit(`directiveContainerSequence`),MM.call(r,e,u,n,`directiveContainerName`)(t))}function u(t){return t===91?e.attempt(PM,d,d)(t):d(t)}function d(t){return t===123?e.attempt(FM,f,f)(t):f(t)}function f(t){return Ir(e,p,`whitespace`)(t)}function p(i){return e.exit(`directiveContainerFence`),i===null?C(i):Jr(i)?r.interrupt?t(i):e.attempt(IM,m,C)(i):n(i)}function m(t){return t===null?C(t):Jr(t)?e.check(IM,y,C)(t):(e.enter(`directiveContainerContent`),h(t))}function h(t){return e.attempt({tokenize:w,partial:!0},S,a?Ir(e,g,`linePrefix`,a+1):g)(t)}function g(t){return t===null?S(t):Jr(t)?e.check(IM,v,S)(t):v(t)}function _(t){if(t===null){let n=e.exit(`chunkDocument`);return r.parser.lazy[n.start.line]=!1,S(t)}return Jr(t)?e.check(IM,b,x)(t):(e.consume(t),_)}function v(t){let n=e.enter(`chunkDocument`,{contentType:`document`,previous:s});return s&&(s.next=n),s=n,_(t)}function y(t){return e.enter(`directiveContainerContent`),h(t)}function b(t){e.consume(t);let n=e.exit(`chunkDocument`);return r.parser.lazy[n.start.line]=!1,h}function x(t){let n=e.exit(`chunkDocument`);return r.parser.lazy[n.start.line]=!1,S(t)}function S(t){return e.exit(`directiveContainerContent`),C(t)}function C(n){return e.exit(`directiveContainer`),t(n)}function w(e,t,n){let i=0;return Ir(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4);function a(t){return e.enter(`directiveContainerFence`),e.enter(`directiveContainerSequence`),s(t)}function s(t){return t===58?(e.consume(t),i++,s):i<o?n(t):(e.exit(`directiveContainerSequence`),Ir(e,c,`whitespace`)(t))}function c(r){return r===null||Jr(r)?(e.exit(`directiveContainerFence`),t(r)):n(r)}}}function RM(e,t,n){return jM(e,t,n,`directiveContainerLabel`,`directiveContainerLabelMarker`,`directiveContainerLabelString`,!0)}function zM(e,t,n){return AM(e,t,n,`directiveContainerAttributes`,`directiveContainerAttributesMarker`,`directiveContainerAttribute`,`directiveContainerAttributeId`,`directiveContainerAttributeClass`,`directiveContainerAttributeName`,`directiveContainerAttributeInitializerMarker`,`directiveContainerAttributeValueLiteral`,`directiveContainerAttributeValue`,`directiveContainerAttributeValueMarker`,`directiveContainerAttributeValueData`,!0)}function BM(e,t,n){let r=this;return i;function i(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}var VM={tokenize:WM},HM={tokenize:GM,partial:!0},UM={tokenize:KM,partial:!0};function WM(e,t,n){let r=this;return i;function i(t){return e.enter(`directiveLeaf`),e.enter(`directiveLeafSequence`),e.consume(t),a}function a(t){return t===58?(e.consume(t),e.exit(`directiveLeafSequence`),MM.call(r,e,o,n,`directiveLeafName`)):n(t)}function o(t){return t===91?e.attempt(HM,s,s)(t):s(t)}function s(t){return t===123?e.attempt(UM,c,c)(t):c(t)}function c(t){return Ir(e,l,`whitespace`)(t)}function l(r){return r===null||Jr(r)?(e.exit(`directiveLeaf`),t(r)):n(r)}}function GM(e,t,n){return jM(e,t,n,`directiveLeafLabel`,`directiveLeafLabelMarker`,`directiveLeafLabelString`,!0)}function KM(e,t,n){return AM(e,t,n,`directiveLeafAttributes`,`directiveLeafAttributesMarker`,`directiveLeafAttribute`,`directiveLeafAttributeId`,`directiveLeafAttributeClass`,`directiveLeafAttributeName`,`directiveLeafAttributeInitializerMarker`,`directiveLeafAttributeValueLiteral`,`directiveLeafAttributeValue`,`directiveLeafAttributeValueMarker`,`directiveLeafAttributeValueData`,!0)}var qM={tokenize:ZM,previous:XM},JM={tokenize:QM,partial:!0},YM={tokenize:$M,partial:!0};function XM(e){return e!==58||this.events[this.events.length-1][1].type===`characterEscape`}function ZM(e,t,n){let r=this;return i;function i(t){return e.enter(`directiveText`),e.enter(`directiveTextMarker`),e.consume(t),e.exit(`directiveTextMarker`),MM.call(r,e,a,n,`directiveTextName`)}function a(t){return t===58?n(t):t===91?e.attempt(JM,o,o)(t):o(t)}function o(t){return t===123?e.attempt(YM,s,s)(t):s(t)}function s(n){return e.exit(`directiveText`),t(n)}}function QM(e,t,n){return jM(e,t,n,`directiveTextLabel`,`directiveTextLabelMarker`,`directiveTextLabelString`)}function $M(e,t,n){return AM(e,t,n,`directiveTextAttributes`,`directiveTextAttributesMarker`,`directiveTextAttribute`,`directiveTextAttributeId`,`directiveTextAttributeClass`,`directiveTextAttributeName`,`directiveTextAttributeInitializerMarker`,`directiveTextAttributeValueLiteral`,`directiveTextAttributeValue`,`directiveTextAttributeValueMarker`,`directiveTextAttributeValueData`)}function eN(){return{text:{58:qM},flow:{58:[NM,VM]}}}function tN(){let e=this.data(),t=e.micromarkExtensions||=[],n=e.fromMarkdownExtensions||=[],r=e.toMarkdownExtensions||=[];t.push(eN()),n.push(rM()),r.push(iM())}var nN=/```([^\r\n`]*)\r?\n?([\s\S]*?)```|`([^`\r\n]+)`/g,rN=/\$\[[^\]\r\n]+\]|\$[A-Za-z0-9][\w.-]*/g,iN=`skill://`,aN=`mention://`;function oN(e,t){return`[${pN(e,`[]`)}](${pN(t,`()`)})`}function sN(e){let t=[],n=0;for(let r of e.matchAll(nN)){let i=r.index;i>n&&t.push(...cN(e.slice(n,i),n));let a=r[0],o=i+a.length,s=r[2];s===void 0?t.push({kind:`inline-code`,source:a,start:i,end:o,value:r[3]??``}):t.push({kind:`code-block`,source:a,start:i,end:o,language:r[1]??``,value:s}),n=o}return n<e.length&&t.push(...cN(e.slice(n),n)),t}function cN(e,t){let n=[],r=fN(e),i=0;for(let a of r)a.start>i&&n.push(...uN(e.slice(i,a.start),t+i)),n.push(lN(a,e,t)),i=a.end;return i<e.length&&n.push(...uN(e.slice(i),t+i)),n}function lN(e,t,n){let r=n+e.start,i=n+e.end,a=t.slice(e.start,e.end);if(e.href.startsWith(aN)){let t=e.href.slice(10);if(t)return{kind:`mention`,source:a,start:r,end:i,label:e.label,href:e.href,name:t}}if(e.label.startsWith(`$`)&&e.href.startsWith(iN)){let t=e.label.slice(1),n=e.href.slice(8);if(t&&n)return{kind:`skill-link`,source:a,start:r,end:i,label:e.label,href:e.href,name:t,skillId:n}}return{kind:`link`,source:a,start:r,end:i,label:e.label,href:e.href}}function uN(e,t){let n=[],r=0;for(let i of e.matchAll(rN)){let a=i.index,o=e[a-1];if(o&&/[\w$]/.test(o))continue;a>r&&n.push(dN(e.slice(r,a),t+r));let s=i[0],c=t+a;n.push({kind:`standalone-skill`,source:s,start:c,end:c+s.length,name:s.startsWith(`$[`)?s.slice(2,-1):s.slice(1)}),r=a+s.length}return r<e.length&&n.push(dN(e.slice(r),t+r)),n}function dN(e,t){return{kind:`text`,source:e,start:t,end:t+e.length,value:e}}function fN(e){let t=[];for(let n=0;n<e.length;n+=1){if(e[n]!==`[`)continue;let r=mN(e,n+1,`]`);if(!r||e[r.end+1]!==`(`)continue;let i=hN(e,r.end+2);i&&(t.push({label:r.value,href:i.value,start:n,end:i.end+1}),n=i.end)}return t}function pN(e,t){let n=``;for(let r of e)n+=r===`\\`||t.includes(r)?`\\${r}`:r;return n}function mN(e,t,n){let r=``;for(let i=t;i<e.length;i+=1){let t=e[i];if(t===`\\`&&i+1<e.length){r+=e[i+1],i+=1;continue}if(t===n)return{value:r,end:i};r+=t}return null}function hN(e,t){let n=``,r=0;for(let i=t;i<e.length;i+=1){let t=e[i];if(t===`\\`&&i+1<e.length){n+=e[i+1],i+=1;continue}if(t===`(`){r+=1,n+=t;continue}if(t===`)`){if(r===0)return{value:n,end:i};--r,n+=t;continue}n+=t}return null}var gN=Sn(),_N=Object.defineProperty,vN=(e,t)=>{let n={};for(var r in e)_N(n,r,{get:e[r],enumerable:!0});return t||_N(n,Symbol.toStringTag,{value:`Module`}),n};function yN(e){this.content=e}yN.prototype={constructor:yN,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return t==-1?void 0:this.content[t+1]},update:function(e,t,n){var r=n&&n!=e?this.remove(n):this,i=r.find(e),a=r.content.slice();return i==-1?a.push(n||e,t):(a[i+1]=t,n&&(a[i]=n)),new yN(a)},remove:function(e){var t=this.find(e);if(t==-1)return this;var n=this.content.slice();return n.splice(t,2),new yN(n)},addToStart:function(e,t){return new yN([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new yN(n)},addBefore:function(e,t,n){var r=this.remove(t),i=r.content.slice(),a=r.find(e);return i.splice(a==-1?i.length:a,0,t,n),new yN(i)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return e=yN.from(e),e.size?new yN(e.content.concat(this.subtract(e).content)):this},append:function(e){return e=yN.from(e),e.size?new yN(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=yN.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},yN.from=function(e){if(e instanceof yN)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new yN(t)};function bN(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let i=e.child(r),a=t.child(r);if(i==a){n+=i.nodeSize;continue}if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){let e=i.text,t=a.text,r=0;for(;e[r]==t[r];r++)n++;return r&&r<e.length&&r<t.length&&CN(e.charCodeAt(r-1))&&SN(e.charCodeAt(r))&&n--,n}if(i.content.size||a.content.size){let e=bN(i.content,a.content,n+1);if(e!=null)return e}n+=i.nodeSize}}function xN(e,t,n,r){for(let i=e.childCount,a=t.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let o=e.child(--i),s=t.child(--a),c=o.nodeSize;if(o==s){n-=c,r-=c;continue}if(!o.sameMarkup(s))return{a:n,b:r};if(o.isText&&o.text!=s.text){let e=o.text,t=s.text,i=e.length,a=t.length;for(;i>0&&a>0&&e[i-1]==t[a-1];)i--,a--,n--,r--;return i&&a&&i<e.length&&CN(e.charCodeAt(i-1))&&SN(e.charCodeAt(i))&&(n++,r++),{a:n,b:r}}if(o.content.size||s.content.size){let e=xN(o.content,s.content,n-1,r-1);if(e)return e}n-=c,r-=c}}function SN(e){return e>=56320&&e<57344}function CN(e){return e>=55296&&e<56320}var K=class e{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,r=0,i){for(let a=0,o=0;o<t;a++){let s=this.content[a],c=o+s.nodeSize;if(c>e&&n(s,r+o,i||null,a)!==!1&&s.content.size){let i=o+1;s.nodesBetween(Math.max(0,e-i),Math.min(s.content.size,t-i),n,r+i)}o=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i=``,a=!0;return this.nodesBetween(e,t,(o,s)=>{let c=o.isText?o.text.slice(Math.max(e,s)-s,t-s):o.isLeaf?r?typeof r==`function`?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):``:``;o.isBlock&&(o.isLeaf&&c||o.isTextblock)&&n&&(a?a=!1:i+=n),i+=c},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);a<t.content.length;a++)i.push(t.content[a]);return new e(i,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let r=[],i=0;if(n>t)for(let e=0,a=0;a<n;e++){let o=this.content[e],s=a+o.nodeSize;s>t&&((a<t||s>n)&&(o=o.isText?o.cut(Math.max(0,t-a),Math.min(o.text.length,n-a)):o.cut(Math.max(0,t-a-1),Math.min(o.content.size,n-a-1))),r.push(o),i+=o.nodeSize),a=s}return new e(r,i)}cutByIndex(t,n){return t==n?e.empty:t==0&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[t]=n,new e(i,a)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw RangeError(`Index `+e+` out of range for `+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return bN(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return xN(this,e,t,n)}findIndex(e){if(e==0)return TN(0,e);if(e==this.size)return TN(this.content.length,e);if(e>this.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=this.child(t),i=n+r.nodeSize;if(i>=e)return i==e?TN(t+1,i):TN(t,n);n=i}}toString(){return`<`+this.toStringInner()+`>`}toStringInner(){return this.content.join(`, `)}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw RangeError(`Invalid input for Fragment.fromJSON`);return e.fromArray(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,r=0;for(let e=0;e<t.length;e++){let i=t[e];r+=i.nodeSize,e&&i.isText&&t[e-1].sameMarkup(i)?(n||=t.slice(0,e),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new e(n||t,r)}static from(t){if(!t)return e.empty;if(t instanceof e)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new e([t],t.nodeSize);throw RangeError(`Can not convert `+t+` to a Fragment`+(t.nodesBetween?` (looks like multiple versions of prosemirror-model were loaded)`:``))}};K.empty=new K([],0);var wN={index:0,offset:0};function TN(e,t){return wN.index=e,wN.offset=t,wN}function EN(e,t){if(e===t)return!0;if(!(e&&typeof e==`object`)||!(t&&typeof t==`object`))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!EN(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!EN(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}var DN=class e{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(this.eq(i))return e;if(this.type.excludes(i.type))t||=e.slice(0,r);else if(i.type.excludes(this.type))return e;else!n&&i.type.rank>this.type.rank&&(t||=e.slice(0,r),t.push(this),n=!0),t&&t.push(i)}return t||=e.slice(),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&EN(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Mark.fromJSON`);let n=e.marks[t.type];if(!n)throw RangeError(`There is no mark type ${t.type} in this schema`);let r=n.create(t.attrs);return n.checkAttrs(r.attrs),r}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return e.none;if(t instanceof e)return[t];let n=t.slice();return n.sort((e,t)=>e.type.rank-t.type.rank),n}};DN.none=[];var ON=class extends Error{},q=class e{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=AN(this.content,t+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new e(r,this.openStart,this.openEnd)}removeBetween(t,n){return new e(kN(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+`(`+this.openStart+`,`+this.openEnd+`)`}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(t,n){if(!n)return e.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid input for Slice.fromJSON`);return new e(K.fromJSON(t,n.content),r,i)}static maxOpen(t,n=!0){let r=0,i=0;for(let e=t.firstChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.firstChild)r++;for(let e=t.lastChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.lastChild)i++;return new e(t,r,i)}};q.empty=new q(K.empty,0,0);function kN(e,t,n){let{index:r,offset:i}=e.findIndex(t),a=e.maybeChild(r),{index:o,offset:s}=e.findIndex(n);if(i==t||a.isText){if(s!=n&&!e.child(o).isText)throw RangeError(`Removing non-flat range`);return e.cut(0,t).append(e.cut(n))}if(r!=o)throw RangeError(`Removing non-flat range`);return e.replaceChild(r,a.copy(kN(a.content,t-i-1,n-i-1)))}function AN(e,t,n,r,i,a){let{index:o,offset:s}=e.findIndex(t),c=e.maybeChild(o);if(s==t||c.isText)return a&&r<=0&&i<=0&&!a.canReplace(o,o,n)?null:e.cut(0,t).append(n).append(e.cut(t));let l=AN(c.content,t-s-1,n,o==0?r-1:0,o==e.childCount-1?i-1:0,c);return l&&e.replaceChild(o,c.copy(l))}function jN(e,t,n){if(n.openStart>e.depth)throw new ON(`Inserted content deeper than insertion position`);if(e.depth-n.openStart!=t.depth-n.openEnd)throw new ON(`Inconsistent open depths`);return MN(e,t,n,0)}function MN(e,t,n,r){let i=e.index(r),a=e.node(r);if(i==t.index(r)&&r<e.depth-n.openStart){let o=MN(e,t,n,r+1);return a.copy(a.content.replaceChild(i,o))}else if(!n.content.size)return LN(a,zN(e,t,r));else if(!n.openStart&&!n.openEnd&&e.depth==r&&t.depth==r){let r=e.parent,i=r.content;return LN(r,i.cut(0,e.parentOffset).append(n.content).append(i.cut(t.parentOffset)))}else{let{start:i,end:o}=BN(n,e);return LN(a,RN(e,i,o,t,r))}}function NN(e,t){if(!t.type.compatibleContent(e.type))throw new ON(`Cannot join `+t.type.name+` onto `+e.type.name)}function PN(e,t,n){let r=e.node(n);return NN(r,t.node(n)),r}function FN(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function IN(e,t,n,r){let i=(t||e).node(n),a=0,o=t?t.index(n):i.childCount;e&&(a=e.index(n),e.depth>n?a++:e.textOffset&&(FN(e.nodeAfter,r),a++));for(let e=a;e<o;e++)FN(i.child(e),r);t&&t.depth==n&&t.textOffset&&FN(t.nodeBefore,r)}function LN(e,t){if(!e.type.validContent(t))throw new ON(`Invalid content for node `+e.type.name);return e.copy(t)}function RN(e,t,n,r,i){let a=e.depth>i&&PN(e,t,i+1),o=r.depth>i&&PN(n,r,i+1),s=[];return IN(null,e,i,s),a&&o&&t.index(i)==n.index(i)?(NN(a,o),FN(LN(a,RN(e,t,n,r,i+1)),s)):(a&&FN(LN(a,zN(e,t,i+1)),s),IN(t,n,i,s),o&&FN(LN(o,zN(n,r,i+1)),s)),IN(r,null,i,s),new K(s)}function zN(e,t,n){let r=[];return IN(null,e,n,r),e.depth>n&&FN(LN(PN(e,t,n+1),zN(e,t,n+1)),r),IN(t,null,n,r),new K(r)}function BN(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(K.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}var VN=class e{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position before the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position after the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return DN.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let i=n.marks;for(var a=0;a<i.length;a++)i[a].type.spec.inclusive===!1&&(!r||!i[a].isInSet(r.marks))&&(i=i[a--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var i=0;i<n.length;i++)n[i].type.spec.inclusive===!1&&(!r||!n[i].isInSet(r.marks))&&(n=n[i--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new GN(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e=``;for(let t=1;t<=this.depth;t++)e+=(e?`/`:``)+this.node(t).type.name+`_`+this.index(t-1);return e+`:`+this.parentOffset}static resolve(t,n){if(!(n>=0&&n<=t.content.size))throw RangeError(`Position `+n+` out of range`);let r=[],i=0,a=n;for(let e=t;;){let{index:t,offset:n}=e.content.findIndex(a),o=a-n;if(r.push(e,t,i+n),!o||(e=e.child(t),e.isText))break;a=o-1,i+=n+1}return new e(n,r,a)}static resolveCached(t,n){let r=WN.get(t);if(r)for(let e=0;e<r.elts.length;e++){let t=r.elts[e];if(t.pos==n)return t}else WN.set(t,r=new HN);let i=r.elts[r.i]=e.resolve(t,n);return r.i=(r.i+1)%UN,i}},HN=class{constructor(){this.elts=[],this.i=0}},UN=12,WN=new WeakMap,GN=class{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}},KN=Object.create(null),qN=class e{constructor(e,t,n,r=DN.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||K.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,r=0){this.content.nodesBetween(e,t,n,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,``)}textBetween(e,t,n,r){return this.content.textBetween(e,t,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&EN(this.attrs,t||e.defaultAttrs||KN)&&DN.sameSet(this.marks,n||DN.none)}copy(t=null){return t==this.content?this:new e(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.content,t)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return q.empty;let r=this.resolve(e),i=this.resolve(t),a=n?0:r.sharedDepth(t),o=r.start(a);return new q(r.node(a).content.cut(r.pos-o,i.pos-o),r.depth-a,i.depth-a)}replace(e,t,n){return jN(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return VN.resolveCached(this,e)}resolveNoCache(e){return VN.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+=`(`+this.content.toStringInner()+`)`),YN(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw Error(`Called contentMatchAt on a node with invalid content`);return t}canReplace(e,t,n=K.empty,r=0,i=n.childCount){let a=this.contentMatchAt(e).matchFragment(n,r,i),o=a&&a.matchFragment(this.content,t);if(!o||!o.validEnd)return!1;for(let e=r;e<i;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let i=this.contentMatchAt(e).matchType(n),a=i&&i.matchFragment(this.content,t);return a?a.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=DN.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!DN.sameSet(e,this.marks))throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Node.fromJSON`);let n;if(t.marks){if(!Array.isArray(t.marks))throw RangeError(`Invalid mark data for Node.fromJSON`);n=t.marks.map(e.markFromJSON)}if(t.type==`text`){if(typeof t.text!=`string`)throw RangeError(`Invalid text node in JSON`);return e.text(t.text,n)}let r=K.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,r,n);return i.type.checkAttrs(i.attrs),i}};qN.prototype.text=void 0;var JN=class e extends qN{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw RangeError(`Empty text nodes are not allowed`);this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):YN(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function YN(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+`(`+t+`)`;return t}var XN=class e{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new ZN(t,n);if(r.next==null)return e.empty;let i=QN(r);r.next&&r.err(`Unexpected trailing text`);let a=cP(aP(i));return lP(a,r),a}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let r=this;for(let i=t;r&&i<n;i++)r=r.matchType(e.child(i).type);return r}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let r=[this];function i(a,o){let s=a.matchFragment(e,n);if(s&&(!t||s.validEnd))return K.from(o.map(e=>e.createAndFill()));for(let e=0;e<a.next.length;e++){let{type:t,next:n}=a.next[e];if(!(t.isText||t.hasRequiredAttrs())&&r.indexOf(n)==-1){r.push(n);let e=i(n,o.concat(t));if(e)return e}}return null}return i(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),i=r.match;if(i.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<i.next.length;e++){let{type:a,next:o}=i.next[e];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in t)&&(!r.type||o.validEnd)&&(n.push({match:a.contentMatch,type:a,via:r}),t[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let r=0;r<n.next.length;r++)e.indexOf(n.next[r].next)==-1&&t(n.next[r].next)}return t(this),e.map((t,n)=>{let r=n+(t.validEnd?`*`:` `)+` `;for(let n=0;n<t.next.length;n++)r+=(n?`, `:``)+t.next[n].type.name+`->`+e.indexOf(t.next[n].next);return r}).join(`
|
|
183
|
+
`,`\r`];return e+`=`+s+Nl(n,{subset:c})+s}}function aM(e){cM.call(this,`containerDirective`,e)}function oM(e){cM.call(this,`leafDirective`,e)}function sM(e){cM.call(this,`textDirective`,e)}function cM(e,t){this.enter({type:e,name:``,attributes:{},children:[]},t)}function lM(e){let t=this.stack[this.stack.length-1];t.type===`containerDirective`||t.type===`leafDirective`||t.type,t.name=this.sliceSerialize(e),xM(t,e)}function uM(e){this.enter({type:`paragraph`,data:{directiveLabel:!0},children:[]},e)}function dM(e){this.exit(e);let t=this.stack[this.stack.length-1];t.type,xM(t,e)}function fM(e){let t=this.stack[this.stack.length-1];t.type===`leafDirective`||t.type,xM(t,e)}function pM(){let e=this.stack[this.stack.length-1];e.type===`containerDirective`||e.type===`leafDirective`||e.type,e.data&&e.data.position&&(this.data.directiveAttributePositions={}),this.data.directiveAttributes=[],this.buffer()}function mM(e){let t=this.data.directiveAttributePositions;if(t){let n=this.data.directiveAttributes,r=n[n.length-1];t[r[0]]={start:CM(e.start),end:CM(e.end)}}}function hM(e){SM(this,e)}function gM(e){this.data.directiveAttributes.push([`id`,Yj(this.sliceSerialize(e),{attribute:!0})])}function _M(e){this.data.directiveAttributes.push([`class`,Yj(this.sliceSerialize(e),{attribute:!0})])}function vM(e){let t=this.data.directiveAttributes,n=t[t.length-1];n[1]=Yj(this.sliceSerialize(e),{attribute:!0}),SM(this,e)}function yM(e){let t=this.data.directiveAttributes,n=this.sliceSerialize(e);t.push([n,``]);let r=this.data.directiveAttributePositions;r&&(r[n]={start:CM(e.start),end:CM(e.end)})}function bM(e){let t=this.data.directiveAttributes,n={};for(let e of t)e[0]===`class`&&n.class?n.class+=` `+e[1]:n[e[0]]=e[1];let r=this.data.directiveAttributePositions;this.data.directiveAttributePositions=void 0,this.data.directiveAttributes=void 0,this.resume();let i=this.stack[this.stack.length-1];i.type===`containerDirective`||i.type===`leafDirective`||i.type,i.attributes=n,r&&(i.data&&i.data.position,i.data.position.attributes=r),xM(i,e)}function xM(e,t){if(e.data&&e.data.position){let{opening:n}=e.data.position;n.end=CM(t.end)}}function SM(e,t){let n=e.data.directiveAttributePositions;if(n){let r=e.data.directiveAttributes,i=n[r[r.length-1][0]];i.end=CM(t.end)}}function CM(e){return{line:e.line,column:e.column,offset:e.offset}}function wM(e){this.exit(e)}function TM(){return`:`}function EM(e){let t=[],n=0,r=e.indexOf(`&`);for(;r!==-1;){let i=e.charCodeAt(r+1);(i===35||Kr(i))&&(t.push(e.slice(n,r),`&`),n=r+1),r=e.indexOf(`&`,r+1)}return t.push(e.slice(n)),t.join(``)}function DM(e){return!!(e&&e.type===`paragraph`&&e.data&&e.data.directiveLabel)}function OM(e,t){let n=0;return n=e.type===`containerDirective`?Math.max(3,t+1):e.type===`leafDirective`?2:1,`:`.repeat(n)}function kM(e){let t=0,n=0;for(;n<e.length;){let r=0,i=e.charCodeAt(n);for(;i===9||i===32;)i=e.charCodeAt(++n);for(;i===58;)r++,i=e.charCodeAt(++n);for(;i===9||i===32;)i=e.charCodeAt(++n);for(;!(i===10||i===13||Number.isNaN(i));)r=0,i=e.charCodeAt(++n);r>t&&(t=r),n++}return t}function AM(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m){let h,g;return _;function _(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),v}function v(t){return t===35?(h=o,y(t)):t===46?(h=s,y(t)):m&&qr(t)?Ir(e,v,`whitespace`)(t):!m&&Mr(t)?Lr(e,v)(t):t===null||Jr(t)||yr(t)||Or(t)&&t!==45&&t!==95?O(t):(e.enter(a),e.enter(c),e.consume(t),S)}function y(t){let n=h+`Marker`;return e.enter(a),e.enter(h),e.enter(n),e.consume(t),e.exit(n),b}function b(t){if(t===null||t===34||t===35||t===39||t===46||t===60||t===61||t===62||t===96||t===125||Mr(t))return n(t);let r=h+`Value`;return e.enter(r),e.consume(t),x}function x(t){if(t===null||t===34||t===39||t===60||t===61||t===62||t===96)return n(t);if(t===35||t===46||t===125||Mr(t)){let n=h+`Value`;return e.exit(n),e.exit(h),e.exit(a),v(t)}return e.consume(t),x}function S(t){return t===null||Jr(t)||yr(t)||Or(t)&&t!==45&&t!==46&&t!==58&&t!==95?(e.exit(c),m&&qr(t)?Ir(e,C,`whitespace`)(t):!m&&Mr(t)?Lr(e,C)(t):C(t)):(e.consume(t),S)}function C(t){return t===61?(e.enter(l),e.consume(t),e.exit(l),w):(e.exit(a),v(t))}function w(t){return t===null||t===60||t===61||t===62||t===96||t===125||m&&Jr(t)?n(t):t===34||t===39?(e.enter(u),e.enter(f),e.consume(t),e.exit(f),g=t,E):m&&qr(t)?Ir(e,w,`whitespace`)(t):!m&&Mr(t)?Lr(e,w)(t):(e.enter(d),e.enter(p),e.consume(t),g=void 0,T)}function T(t){return t===null||t===34||t===39||t===60||t===61||t===62||t===96?n(t):t===125||Mr(t)?(e.exit(p),e.exit(d),e.exit(a),v(t)):(e.consume(t),T)}function E(t){return t===g?(e.enter(f),e.consume(t),e.exit(f),e.exit(u),e.exit(a),te):(e.enter(d),D(t))}function D(t){return t===g?(e.exit(d),E(t)):t===null?n(t):Jr(t)?m?n(t):Lr(e,D)(t):(e.enter(p),e.consume(t),ee)}function ee(t){return t===g||t===null||Jr(t)?(e.exit(p),D(t)):(e.consume(t),ee)}function te(e){return e===125||Mr(e)?v(e):O(e)}function O(a){return a===125?(e.enter(i),e.consume(a),e.exit(i),e.exit(r),t):n(a)}}function jM(e,t,n,r,i,a,o){let s=0,c=0,l;return u;function u(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),d}function d(n){return n===93?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),f(n))}function f(t){if(t===93&&!c)return h(t);let n=e.enter(`chunkText`,{_contentTypeTextTrailing:!0,contentType:`text`,previous:l});return l&&(l.next=n),l=n,p(t)}function p(t){return t===null||s>999||t===91&&++c>32?n(t):t===93&&!c--?(e.exit(`chunkText`),h(t)):Jr(t)?o?n(t):(e.consume(t),e.exit(`chunkText`),f):(e.consume(t),t===92?m:p)}function m(t){return t===91||t===92||t===93?(e.consume(t),s++,p):p(t)}function h(n){return e.exit(a),e.enter(i),e.consume(n),e.exit(i),e.exit(r),t}}function MM(e,t,n,r){let i=this;return a;function a(t){return t===null||Jr(t)||Or(t)||yr(t)?n(t):(e.enter(r),e.consume(t),o)}function o(a){return a===null||Jr(a)||yr(a)||Or(a)&&a!==45&&a!==95?(e.exit(r),i.previous===45||i.previous===95?n(a):t(a)):(e.consume(a),o)}}var NM={tokenize:LM,concrete:!0},PM={tokenize:RM,partial:!0},FM={tokenize:zM,partial:!0},IM={tokenize:BM,partial:!0};function LM(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0,s;return c;function c(t){return e.enter(`directiveContainer`),e.enter(`directiveContainerFence`),e.enter(`directiveContainerSequence`),l(t)}function l(t){return t===58?(e.consume(t),o++,l):o<3?n(t):(e.exit(`directiveContainerSequence`),MM.call(r,e,u,n,`directiveContainerName`)(t))}function u(t){return t===91?e.attempt(PM,d,d)(t):d(t)}function d(t){return t===123?e.attempt(FM,f,f)(t):f(t)}function f(t){return Ir(e,p,`whitespace`)(t)}function p(i){return e.exit(`directiveContainerFence`),i===null?C(i):Jr(i)?r.interrupt?t(i):e.attempt(IM,m,C)(i):n(i)}function m(t){return t===null?C(t):Jr(t)?e.check(IM,y,C)(t):(e.enter(`directiveContainerContent`),h(t))}function h(t){return e.attempt({tokenize:w,partial:!0},S,a?Ir(e,g,`linePrefix`,a+1):g)(t)}function g(t){return t===null?S(t):Jr(t)?e.check(IM,v,S)(t):v(t)}function _(t){if(t===null){let n=e.exit(`chunkDocument`);return r.parser.lazy[n.start.line]=!1,S(t)}return Jr(t)?e.check(IM,b,x)(t):(e.consume(t),_)}function v(t){let n=e.enter(`chunkDocument`,{contentType:`document`,previous:s});return s&&(s.next=n),s=n,_(t)}function y(t){return e.enter(`directiveContainerContent`),h(t)}function b(t){e.consume(t);let n=e.exit(`chunkDocument`);return r.parser.lazy[n.start.line]=!1,h}function x(t){let n=e.exit(`chunkDocument`);return r.parser.lazy[n.start.line]=!1,S(t)}function S(t){return e.exit(`directiveContainerContent`),C(t)}function C(n){return e.exit(`directiveContainer`),t(n)}function w(e,t,n){let i=0;return Ir(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4);function a(t){return e.enter(`directiveContainerFence`),e.enter(`directiveContainerSequence`),s(t)}function s(t){return t===58?(e.consume(t),i++,s):i<o?n(t):(e.exit(`directiveContainerSequence`),Ir(e,c,`whitespace`)(t))}function c(r){return r===null||Jr(r)?(e.exit(`directiveContainerFence`),t(r)):n(r)}}}function RM(e,t,n){return jM(e,t,n,`directiveContainerLabel`,`directiveContainerLabelMarker`,`directiveContainerLabelString`,!0)}function zM(e,t,n){return AM(e,t,n,`directiveContainerAttributes`,`directiveContainerAttributesMarker`,`directiveContainerAttribute`,`directiveContainerAttributeId`,`directiveContainerAttributeClass`,`directiveContainerAttributeName`,`directiveContainerAttributeInitializerMarker`,`directiveContainerAttributeValueLiteral`,`directiveContainerAttributeValue`,`directiveContainerAttributeValueMarker`,`directiveContainerAttributeValueData`,!0)}function BM(e,t,n){let r=this;return i;function i(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}var VM={tokenize:WM},HM={tokenize:GM,partial:!0},UM={tokenize:KM,partial:!0};function WM(e,t,n){let r=this;return i;function i(t){return e.enter(`directiveLeaf`),e.enter(`directiveLeafSequence`),e.consume(t),a}function a(t){return t===58?(e.consume(t),e.exit(`directiveLeafSequence`),MM.call(r,e,o,n,`directiveLeafName`)):n(t)}function o(t){return t===91?e.attempt(HM,s,s)(t):s(t)}function s(t){return t===123?e.attempt(UM,c,c)(t):c(t)}function c(t){return Ir(e,l,`whitespace`)(t)}function l(r){return r===null||Jr(r)?(e.exit(`directiveLeaf`),t(r)):n(r)}}function GM(e,t,n){return jM(e,t,n,`directiveLeafLabel`,`directiveLeafLabelMarker`,`directiveLeafLabelString`,!0)}function KM(e,t,n){return AM(e,t,n,`directiveLeafAttributes`,`directiveLeafAttributesMarker`,`directiveLeafAttribute`,`directiveLeafAttributeId`,`directiveLeafAttributeClass`,`directiveLeafAttributeName`,`directiveLeafAttributeInitializerMarker`,`directiveLeafAttributeValueLiteral`,`directiveLeafAttributeValue`,`directiveLeafAttributeValueMarker`,`directiveLeafAttributeValueData`,!0)}var qM={tokenize:ZM,previous:XM},JM={tokenize:QM,partial:!0},YM={tokenize:$M,partial:!0};function XM(e){return e!==58||this.events[this.events.length-1][1].type===`characterEscape`}function ZM(e,t,n){let r=this;return i;function i(t){return e.enter(`directiveText`),e.enter(`directiveTextMarker`),e.consume(t),e.exit(`directiveTextMarker`),MM.call(r,e,a,n,`directiveTextName`)}function a(t){return t===58?n(t):t===91?e.attempt(JM,o,o)(t):o(t)}function o(t){return t===123?e.attempt(YM,s,s)(t):s(t)}function s(n){return e.exit(`directiveText`),t(n)}}function QM(e,t,n){return jM(e,t,n,`directiveTextLabel`,`directiveTextLabelMarker`,`directiveTextLabelString`)}function $M(e,t,n){return AM(e,t,n,`directiveTextAttributes`,`directiveTextAttributesMarker`,`directiveTextAttribute`,`directiveTextAttributeId`,`directiveTextAttributeClass`,`directiveTextAttributeName`,`directiveTextAttributeInitializerMarker`,`directiveTextAttributeValueLiteral`,`directiveTextAttributeValue`,`directiveTextAttributeValueMarker`,`directiveTextAttributeValueData`)}function eN(){return{text:{58:qM},flow:{58:[NM,VM]}}}function tN(){let e=this.data(),t=e.micromarkExtensions||=[],n=e.fromMarkdownExtensions||=[],r=e.toMarkdownExtensions||=[];t.push(eN()),n.push(rM()),r.push(iM())}var nN=/```([^\r\n`]*)\r?\n?([\s\S]*?)```|`([^`\r\n]+)`/g,rN=/\$\[[^\]\r\n]+\]|\$[A-Za-z0-9][\w.-]*/g,iN=`skill://`,aN=`mention://`;function oN(e,t){return`[${pN(e,`[]`)}](${pN(t,`()`)})`}function sN(e){let t=[],n=0;for(let r of e.matchAll(nN)){let i=r.index;i>n&&t.push(...cN(e.slice(n,i),n));let a=r[0],o=i+a.length,s=r[2];s===void 0?t.push({kind:`inline-code`,source:a,start:i,end:o,value:r[3]??``}):t.push({kind:`code-block`,source:a,start:i,end:o,language:r[1]??``,value:s}),n=o}return n<e.length&&t.push(...cN(e.slice(n),n)),t}function cN(e,t){let n=[],r=fN(e),i=0;for(let a of r)a.start>i&&n.push(...uN(e.slice(i,a.start),t+i)),n.push(lN(a,e,t)),i=a.end;return i<e.length&&n.push(...uN(e.slice(i),t+i)),n}function lN(e,t,n){let r=n+e.start,i=n+e.end,a=t.slice(e.start,e.end);if(e.href.startsWith(aN)){let t=e.href.slice(10);if(t)return{kind:`mention`,source:a,start:r,end:i,label:e.label,href:e.href,name:t}}if(e.label.startsWith(`$`)&&e.href.startsWith(iN)){let t=e.label.slice(1),n=e.href.slice(8);if(t&&n)return{kind:`skill-link`,source:a,start:r,end:i,label:e.label,href:e.href,name:t,skillId:n}}return{kind:`link`,source:a,start:r,end:i,label:e.label,href:e.href}}function uN(e,t){let n=[],r=0;for(let i of e.matchAll(rN)){let a=i.index,o=e[a-1];if(o&&/[\w$]/.test(o))continue;a>r&&n.push(dN(e.slice(r,a),t+r));let s=i[0],c=t+a;n.push({kind:`standalone-skill`,source:s,start:c,end:c+s.length,name:s.startsWith(`$[`)?s.slice(2,-1):s.slice(1)}),r=a+s.length}return r<e.length&&n.push(dN(e.slice(r),t+r)),n}function dN(e,t){return{kind:`text`,source:e,start:t,end:t+e.length,value:e}}function fN(e){let t=[];for(let n=0;n<e.length;n+=1){if(e[n]!==`[`)continue;let r=mN(e,n+1,`]`);if(!r||e[r.end+1]!==`(`)continue;let i=hN(e,r.end+2);i&&(t.push({label:r.value,href:i.value,start:n,end:i.end+1}),n=i.end)}return t}function pN(e,t){let n=``;for(let r of e)n+=r===`\\`||t.includes(r)?`\\${r}`:r;return n}function mN(e,t,n){let r=``;for(let i=t;i<e.length;i+=1){let t=e[i];if(t===`\\`&&i+1<e.length){r+=e[i+1],i+=1;continue}if(t===n)return{value:r,end:i};r+=t}return null}function hN(e,t){let n=``,r=0;for(let i=t;i<e.length;i+=1){let t=e[i];if(t===`\\`&&i+1<e.length){n+=e[i+1],i+=1;continue}if(t===`(`){r+=1,n+=t;continue}if(t===`)`){if(r===0)return{value:n,end:i};--r,n+=t;continue}n+=t}return null}var gN=Sn(),_N=Object.defineProperty,vN=(e,t)=>{let n={};for(var r in e)_N(n,r,{get:e[r],enumerable:!0});return t||_N(n,Symbol.toStringTag,{value:`Module`}),n};function yN(e){this.content=e}yN.prototype={constructor:yN,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return t==-1?void 0:this.content[t+1]},update:function(e,t,n){var r=n&&n!=e?this.remove(n):this,i=r.find(e),a=r.content.slice();return i==-1?a.push(n||e,t):(a[i+1]=t,n&&(a[i]=n)),new yN(a)},remove:function(e){var t=this.find(e);if(t==-1)return this;var n=this.content.slice();return n.splice(t,2),new yN(n)},addToStart:function(e,t){return new yN([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new yN(n)},addBefore:function(e,t,n){var r=this.remove(t),i=r.content.slice(),a=r.find(e);return i.splice(a==-1?i.length:a,0,t,n),new yN(i)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return e=yN.from(e),e.size?new yN(e.content.concat(this.subtract(e).content)):this},append:function(e){return e=yN.from(e),e.size?new yN(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=yN.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},yN.from=function(e){if(e instanceof yN)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new yN(t)};function bN(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let i=e.child(r),a=t.child(r);if(i==a){n+=i.nodeSize;continue}if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){let e=i.text,t=a.text,r=0;for(;e[r]==t[r];r++)n++;return r&&r<e.length&&r<t.length&&CN(e.charCodeAt(r-1))&&SN(e.charCodeAt(r))&&n--,n}if(i.content.size||a.content.size){let e=bN(i.content,a.content,n+1);if(e!=null)return e}n+=i.nodeSize}}function xN(e,t,n,r){for(let i=e.childCount,a=t.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let o=e.child(--i),s=t.child(--a),c=o.nodeSize;if(o==s){n-=c,r-=c;continue}if(!o.sameMarkup(s))return{a:n,b:r};if(o.isText&&o.text!=s.text){let e=o.text,t=s.text,i=e.length,a=t.length;for(;i>0&&a>0&&e[i-1]==t[a-1];)i--,a--,n--,r--;return i&&a&&i<e.length&&CN(e.charCodeAt(i-1))&&SN(e.charCodeAt(i))&&(n++,r++),{a:n,b:r}}if(o.content.size||s.content.size){let e=xN(o.content,s.content,n-1,r-1);if(e)return e}n-=c,r-=c}}function SN(e){return e>=56320&&e<57344}function CN(e){return e>=55296&&e<56320}var K=class e{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,r=0,i){for(let a=0,o=0;o<t;a++){let s=this.content[a],c=o+s.nodeSize;if(c>e&&n(s,r+o,i||null,a)!==!1&&s.content.size){let i=o+1;s.nodesBetween(Math.max(0,e-i),Math.min(s.content.size,t-i),n,r+i)}o=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i=``,a=!0;return this.nodesBetween(e,t,(o,s)=>{let c=o.isText?o.text.slice(Math.max(e,s)-s,t-s):o.isLeaf?r?typeof r==`function`?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):``:``;o.isBlock&&(o.isLeaf&&c||o.isTextblock)&&n&&(a?a=!1:i+=n),i+=c},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);a<t.content.length;a++)i.push(t.content[a]);return new e(i,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let r=[],i=0;if(n>t)for(let e=0,a=0;a<n;e++){let o=this.content[e],s=a+o.nodeSize;s>t&&((a<t||s>n)&&(o=o.isText?o.cut(Math.max(0,t-a),Math.min(o.text.length,n-a)):o.cut(Math.max(0,t-a-1),Math.min(o.content.size,n-a-1))),r.push(o),i+=o.nodeSize),a=s}return new e(r,i)}cutByIndex(t,n){return t==n?e.empty:t==0&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[t]=n,new e(i,a)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw RangeError(`Index `+e+` out of range for `+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return bN(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return xN(this,e,t,n)}findIndex(e){if(e==0)return TN(0,e);if(e==this.size)return TN(this.content.length,e);if(e>this.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=this.child(t),i=n+r.nodeSize;if(i>=e)return i==e?TN(t+1,i):TN(t,n);n=i}}toString(){return`<`+this.toStringInner()+`>`}toStringInner(){return this.content.join(`, `)}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw RangeError(`Invalid input for Fragment.fromJSON`);return e.fromArray(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,r=0;for(let e=0;e<t.length;e++){let i=t[e];r+=i.nodeSize,e&&i.isText&&t[e-1].sameMarkup(i)?(n||=t.slice(0,e),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new e(n||t,r)}static from(t){if(!t)return e.empty;if(t instanceof e)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new e([t],t.nodeSize);throw RangeError(`Can not convert `+t+` to a Fragment`+(t.nodesBetween?` (looks like multiple versions of prosemirror-model were loaded)`:``))}};K.empty=new K([],0);var wN={index:0,offset:0};function TN(e,t){return wN.index=e,wN.offset=t,wN}function EN(e,t){if(e===t)return!0;if(!(e&&typeof e==`object`)||!(t&&typeof t==`object`))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!EN(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!EN(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}var DN=class e{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(this.eq(i))return e;if(this.type.excludes(i.type))t||=e.slice(0,r);else if(i.type.excludes(this.type))return e;else!n&&i.type.rank>this.type.rank&&(t||=e.slice(0,r),t.push(this),n=!0),t&&t.push(i)}return t||=e.slice(),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&EN(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Mark.fromJSON`);let n=e.marks[t.type];if(!n)throw RangeError(`There is no mark type ${t.type} in this schema`);let r=n.create(t.attrs);return n.checkAttrs(r.attrs),r}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return e.none;if(t instanceof e)return[t];let n=t.slice();return n.sort((e,t)=>e.type.rank-t.type.rank),n}};DN.none=[];var ON=class extends Error{},q=class e{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=AN(this.content,t+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new e(r,this.openStart,this.openEnd)}removeBetween(t,n){return new e(kN(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+`(`+this.openStart+`,`+this.openEnd+`)`}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(t,n){if(!n)return e.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid input for Slice.fromJSON`);return new e(K.fromJSON(t,n.content),r,i)}static maxOpen(t,n=!0){let r=0,i=0;for(let e=t.firstChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.firstChild)r++;for(let e=t.lastChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.lastChild)i++;return new e(t,r,i)}};q.empty=new q(K.empty,0,0);function kN(e,t,n){let{index:r,offset:i}=e.findIndex(t),a=e.maybeChild(r),{index:o,offset:s}=e.findIndex(n);if(i==t||a.isText){if(s!=n&&!e.child(o).isText)throw RangeError(`Removing non-flat range`);return e.cut(0,t).append(e.cut(n))}if(r!=o)throw RangeError(`Removing non-flat range`);return e.replaceChild(r,a.copy(kN(a.content,t-i-1,n-i-1)))}function AN(e,t,n,r,i,a){let{index:o,offset:s}=e.findIndex(t),c=e.maybeChild(o);if(s==t||c.isText)return a&&r<=0&&i<=0&&!a.canReplace(o,o,n)?null:e.cut(0,t).append(n).append(e.cut(t));let l=AN(c.content,t-s-1,n,o==0?r-1:0,o==e.childCount-1?i-1:0,c);return l&&e.replaceChild(o,c.copy(l))}function jN(e,t,n){if(n.openStart>e.depth)throw new ON(`Inserted content deeper than insertion position`);if(e.depth-n.openStart!=t.depth-n.openEnd)throw new ON(`Inconsistent open depths`);return MN(e,t,n,0)}function MN(e,t,n,r){let i=e.index(r),a=e.node(r);if(i==t.index(r)&&r<e.depth-n.openStart){let o=MN(e,t,n,r+1);return a.copy(a.content.replaceChild(i,o))}else if(!n.content.size)return LN(a,zN(e,t,r));else if(!n.openStart&&!n.openEnd&&e.depth==r&&t.depth==r){let r=e.parent,i=r.content;return LN(r,i.cut(0,e.parentOffset).append(n.content).append(i.cut(t.parentOffset)))}else{let{start:i,end:o}=BN(n,e);return LN(a,RN(e,i,o,t,r))}}function NN(e,t){if(!t.type.compatibleContent(e.type))throw new ON(`Cannot join `+t.type.name+` onto `+e.type.name)}function PN(e,t,n){let r=e.node(n);return NN(r,t.node(n)),r}function FN(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function IN(e,t,n,r){let i=(t||e).node(n),a=0,o=t?t.index(n):i.childCount;e&&(a=e.index(n),e.depth>n?a++:e.textOffset&&(FN(e.nodeAfter,r),a++));for(let e=a;e<o;e++)FN(i.child(e),r);t&&t.depth==n&&t.textOffset&&FN(t.nodeBefore,r)}function LN(e,t){if(!e.type.validContent(t))throw new ON(`Invalid content for node `+e.type.name);return e.copy(t)}function RN(e,t,n,r,i){let a=e.depth>i&&PN(e,t,i+1),o=r.depth>i&&PN(n,r,i+1),s=[];return IN(null,e,i,s),a&&o&&t.index(i)==n.index(i)?(NN(a,o),FN(LN(a,RN(e,t,n,r,i+1)),s)):(a&&FN(LN(a,zN(e,t,i+1)),s),IN(t,n,i,s),o&&FN(LN(o,zN(n,r,i+1)),s)),IN(r,null,i,s),new K(s)}function zN(e,t,n){let r=[];return IN(null,e,n,r),e.depth>n&&FN(LN(PN(e,t,n+1),zN(e,t,n+1)),r),IN(t,null,n,r),new K(r)}function BN(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(K.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}var VN=class e{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position before the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position after the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return DN.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let i=n.marks;for(var a=0;a<i.length;a++)i[a].type.spec.inclusive===!1&&(!r||!i[a].isInSet(r.marks))&&(i=i[a--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var i=0;i<n.length;i++)n[i].type.spec.inclusive===!1&&(!r||!n[i].isInSet(r.marks))&&(n=n[i--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new GN(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e=``;for(let t=1;t<=this.depth;t++)e+=(e?`/`:``)+this.node(t).type.name+`_`+this.index(t-1);return e+`:`+this.parentOffset}static resolve(t,n){if(!(n>=0&&n<=t.content.size))throw RangeError(`Position `+n+` out of range`);let r=[],i=0,a=n;for(let e=t;;){let{index:t,offset:n}=e.content.findIndex(a),o=a-n;if(r.push(e,t,i+n),!o||(e=e.child(t),e.isText))break;a=o-1,i+=n+1}return new e(n,r,a)}static resolveCached(t,n){let r=WN.get(t);if(r)for(let e=0;e<r.elts.length;e++){let t=r.elts[e];if(t.pos==n)return t}else WN.set(t,r=new HN);let i=r.elts[r.i]=e.resolve(t,n);return r.i=(r.i+1)%UN,i}},HN=class{constructor(){this.elts=[],this.i=0}},UN=12,WN=new WeakMap,GN=class{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}},KN=Object.create(null),qN=class e{constructor(e,t,n,r=DN.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||K.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,r=0){this.content.nodesBetween(e,t,n,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,``)}textBetween(e,t,n,r){return this.content.textBetween(e,t,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&EN(this.attrs,t||e.defaultAttrs||KN)&&DN.sameSet(this.marks,n||DN.none)}copy(t=null){return t==this.content?this:new e(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.content,t)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return q.empty;let r=this.resolve(e),i=this.resolve(t),a=n?0:r.sharedDepth(t),o=r.start(a);return new q(r.node(a).content.cut(r.pos-o,i.pos-o),r.depth-a,i.depth-a)}replace(e,t,n){return jN(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return VN.resolveCached(this,e)}resolveNoCache(e){return VN.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+=`(`+this.content.toStringInner()+`)`),YN(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw Error(`Called contentMatchAt on a node with invalid content`);return t}canReplace(e,t,n=K.empty,r=0,i=n.childCount){let a=this.contentMatchAt(e).matchFragment(n,r,i),o=a&&a.matchFragment(this.content,t);if(!o||!o.validEnd)return!1;for(let e=r;e<i;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let i=this.contentMatchAt(e).matchType(n),a=i&&i.matchFragment(this.content,t);return a?a.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=DN.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!DN.sameSet(e,this.marks))throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Node.fromJSON`);let n;if(t.marks){if(!Array.isArray(t.marks))throw RangeError(`Invalid mark data for Node.fromJSON`);n=t.marks.map(e.markFromJSON)}if(t.type==`text`){if(typeof t.text!=`string`)throw RangeError(`Invalid text node in JSON`);return e.text(t.text,n)}let r=K.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,r,n);return i.type.checkAttrs(i.attrs),i}};qN.prototype.text=void 0;var JN=class e extends qN{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw RangeError(`Empty text nodes are not allowed`);this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):YN(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function YN(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+`(`+t+`)`;return t}var XN=class e{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new ZN(t,n);if(r.next==null)return e.empty;let i=QN(r);r.next&&r.err(`Unexpected trailing text`);let a=cP(aP(i));return lP(a,r),a}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let r=this;for(let i=t;r&&i<n;i++)r=r.matchType(e.child(i).type);return r}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let r=[this];function i(a,o){let s=a.matchFragment(e,n);if(s&&(!t||s.validEnd))return K.from(o.map(e=>e.createAndFill()));for(let e=0;e<a.next.length;e++){let{type:t,next:n}=a.next[e];if(!(t.isText||t.hasRequiredAttrs())&&r.indexOf(n)==-1){r.push(n);let e=i(n,o.concat(t));if(e)return e}}return null}return i(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),i=r.match;if(i.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<i.next.length;e++){let{type:a,next:o}=i.next[e];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in t)&&(!r.type||o.validEnd)&&(n.push({match:a.contentMatch,type:a,via:r}),t[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let r=0;r<n.next.length;r++)e.indexOf(n.next[r].next)==-1&&t(n.next[r].next)}return t(this),e.map((t,n)=>{let r=n+(t.validEnd?`*`:` `)+` `;for(let n=0;n<t.next.length;n++)r+=(n?`, `:``)+t.next[n].type.name+`->`+e.indexOf(t.next[n].next);return r}).join(`
|
|
184
184
|
`)}};XN.empty=new XN(!0);var ZN=class{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==``&&this.tokens.pop(),this.tokens[0]==``&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw SyntaxError(e+` (in content expression '`+this.string+`')`)}};function QN(e){let t=[];do t.push($N(e));while(e.eat(`|`));return t.length==1?t[0]:{type:`choice`,exprs:t}}function $N(e){let t=[];do t.push(eP(e));while(e.next&&e.next!=`)`&&e.next!=`|`);return t.length==1?t[0]:{type:`seq`,exprs:t}}function eP(e){let t=iP(e);for(;;)if(e.eat(`+`))t={type:`plus`,expr:t};else if(e.eat(`*`))t={type:`star`,expr:t};else if(e.eat(`?`))t={type:`opt`,expr:t};else if(e.eat(`{`))t=nP(e,t);else break;return t}function tP(e){/\D/.test(e.next)&&e.err(`Expected number, got '`+e.next+`'`);let t=Number(e.next);return e.pos++,t}function nP(e,t){let n=tP(e),r=n;return e.eat(`,`)&&(r=e.next==`}`?-1:tP(e)),e.eat(`}`)||e.err(`Unclosed braced range`),{type:`range`,min:n,max:r,expr:t}}function rP(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let i=[];for(let e in n){let r=n[e];r.isInGroup(t)&&i.push(r)}return i.length==0&&e.err(`No node type or group '`+t+`' found`),i}function iP(e){if(e.eat(`(`)){let t=QN(e);return e.eat(`)`)||e.err(`Missing closing paren`),t}else if(/\W/.test(e.next))e.err(`Unexpected token '`+e.next+`'`);else{let t=rP(e,e.next).map(t=>(e.inline==null?e.inline=t.isInline:e.inline!=t.isInline&&e.err(`Mixing inline and block content`),{type:`name`,value:t}));return e.pos++,t.length==1?t[0]:{type:`choice`,exprs:t}}}function aP(e){let t=[[]];return i(a(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){let i={term:r,to:n};return t[e].push(i),i}function i(e,t){e.forEach(e=>e.to=t)}function a(e,t){if(e.type==`choice`)return e.exprs.reduce((e,n)=>e.concat(a(n,t)),[]);if(e.type==`seq`)for(let r=0;;r++){let o=a(e.exprs[r],t);if(r==e.exprs.length-1)return o;i(o,t=n())}else if(e.type==`star`){let o=n();return r(t,o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`plus`){let o=n();return i(a(e.expr,t),o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`opt`)return[r(t)].concat(a(e.expr,t));else if(e.type==`range`){let o=t;for(let t=0;t<e.min;t++){let t=n();i(a(e.expr,o),t),o=t}if(e.max==-1)i(a(e.expr,o),o);else for(let t=e.min;t<e.max;t++){let t=n();r(o,t),i(a(e.expr,o),t),o=t}return[r(o)]}else if(e.type==`name`)return[r(t,void 0,e.value)];else throw Error(`Unknown expr type`)}}function oP(e,t){return t-e}function sP(e,t){let n=[];return r(t),n.sort(oP);function r(t){let i=e[t];if(i.length==1&&!i[0].term)return r(i[0].to);n.push(t);for(let e=0;e<i.length;e++){let{term:t,to:a}=i[e];!t&&n.indexOf(a)==-1&&r(a)}}}function cP(e){let t=Object.create(null);return n(sP(e,0));function n(r){let i=[];r.forEach(t=>{e[t].forEach(({term:t,to:n})=>{if(!t)return;let r;for(let e=0;e<i.length;e++)i[e][0]==t&&(r=i[e][1]);sP(e,n).forEach(e=>{r||i.push([t,r=[]]),r.indexOf(e)==-1&&r.push(e)})})});let a=t[r.join(`,`)]=new XN(r.indexOf(e.length-1)>-1);for(let e=0;e<i.length;e++){let r=i[e][1].sort(oP);a.next.push({type:i[e][0],next:t[r.join(`,`)]||n(r)})}return a}}function lP(e,t){for(let n=0,r=[e];n<r.length;n++){let e=r[n],i=!e.validEnd,a=[];for(let t=0;t<e.next.length;t++){let{type:n,next:o}=e.next[t];a.push(n.name),i&&!(n.isText||n.hasRequiredAttrs())&&(i=!1),r.indexOf(o)==-1&&r.push(o)}i&&t.err(`Only non-generatable nodes (`+a.join(`, `)+`) in a required position (see https://prosemirror.net/docs/guide/#generatable)`)}}function uP(e){let t=Object.create(null);for(let n in e){let r=e[n];if(!r.hasDefault)return null;t[n]=r.default}return t}function dP(e,t){let n=Object.create(null);for(let r in e){let i=t&&t[r];if(i===void 0){let t=e[r];if(t.hasDefault)i=t.default;else throw RangeError(`No value supplied for attribute `+r)}n[r]=i}return n}function fP(e,t,n,r){for(let i in t)if(!(i in e))throw RangeError(`Unsupported attribute ${i} for ${n} of type ${r}`);for(let n in e)e[n].validate&&e[n].validate(t[n])}function pP(e,t){let n=Object.create(null);if(t)for(let r in t)n[r]=new gP(e,r,t[r]);return n}var mP=class e{constructor(e,t,n){this.name=e,this.schema=t,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(` `):[],this.attrs=pP(e,n.attrs),this.defaultAttrs=uP(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||e==`text`),this.isText=e==`text`}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==XN.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?`pre`:`normal`)}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:dP(this.attrs,e)}create(e=null,t,n){if(this.isText)throw Error(`NodeType.create can't construct text nodes`);return new qN(this,this.computeAttrs(e),K.from(t),DN.setFrom(n))}createChecked(e=null,t,n){return t=K.from(t),this.checkContent(t),new qN(this,this.computeAttrs(e),t,DN.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),t=K.from(t),t.size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let r=this.contentMatch.matchFragment(t),i=r&&r.fillBefore(K.empty,!0);return i?new qN(this,e,t.append(i),DN.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let t=0;t<e.childCount;t++)if(!this.allowsMarks(e.child(t).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){fP(this.attrs,e,`node`,this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||=e.slice(0,n);return t?t.length?t:DN.none:e}static compile(t,n){let r=Object.create(null);t.forEach((t,i)=>r[t]=new e(t,n,i));let i=n.spec.topNode||`doc`;if(!r[i])throw RangeError(`Schema is missing its top node type ('`+i+`')`);if(!r.text)throw RangeError(`Every schema needs a 'text' type`);for(let e in r.text.attrs)throw RangeError(`The text node type should not have attributes`);return r}};function hP(e,t,n){let r=n.split(`|`);return n=>{let i=n===null?`null`:typeof n;if(r.indexOf(i)<0)throw RangeError(`Expected value of type ${r} for attribute ${t} on type ${e}, got ${i}`)}}var gP=class{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,`default`),this.default=n.default,this.validate=typeof n.validate==`string`?hP(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}},_P=class e{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=pP(e,r.attrs),this.excluded=null;let i=uP(this.attrs);this.instance=i?new DN(this,i):null}create(e=null){return!e&&this.instance?this.instance:new DN(this,dP(this.attrs,e))}static compile(t,n){let r=Object.create(null),i=0;return t.forEach((t,a)=>r[t]=new e(t,i++,n,a)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){fP(this.attrs,e,`mark`,this.name)}excludes(e){return this.excluded.indexOf(e)>-1}},vP=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let n in e)t[n]=e[n];t.nodes=yN.from(e.nodes),t.marks=yN.from(e.marks||{}),this.nodes=mP.compile(this.spec.nodes,this),this.marks=_P.compile(this.spec.marks,this);let n=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw RangeError(e+` can not be both a node and a mark`);let t=this.nodes[e],r=t.spec.content||``,i=t.spec.marks;if(t.contentMatch=n[r]||(n[r]=XN.parse(r,this.nodes)),t.inlineContent=t.contentMatch.inlineContent,t.spec.linebreakReplacement){if(this.linebreakReplacement)throw RangeError(`Multiple linebreak nodes defined`);if(!t.isInline||!t.isLeaf)throw RangeError(`Linebreak replacement nodes must be inline leaf nodes`);this.linebreakReplacement=t}t.markSet=i==`_`?null:i?yP(this,i.split(` `)):i==``||!t.inlineContent?[]:null}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=n==null?[t]:n==``?[]:yP(this,n.split(` `))}this.nodeFromJSON=e=>qN.fromJSON(this,e),this.markFromJSON=e=>DN.fromJSON(this,e),this.topNodeType=this.nodes[this.spec.topNode||`doc`],this.cached.wrappings=Object.create(null)}node(e,t=null,n,r){if(typeof e==`string`)e=this.nodeType(e);else if(!(e instanceof mP))throw RangeError(`Invalid node type: `+e);else if(e.schema!=this)throw RangeError(`Node type from different schema used (`+e.name+`)`);return e.createChecked(t,n,r)}text(e,t){let n=this.nodes.text;return new JN(n,n.defaultAttrs,e,DN.setFrom(t))}mark(e,t){return typeof e==`string`&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw RangeError(`Unknown node type: `+e);return t}};function yP(e,t){let n=[];for(let r=0;r<t.length;r++){let i=t[r],a=e.marks[i],o=a;if(a)n.push(a);else for(let t in e.marks){let r=e.marks[t];(i==`_`||r.spec.group&&r.spec.group.split(` `).indexOf(i)>-1)&&n.push(o=r)}if(!o)throw SyntaxError(`Unknown mark type: '`+t[r]+`'`)}return n}function bP(e){return e.tag!=null}function xP(e){return e.style!=null}var SP=class e{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(e=>{if(bP(e))this.tags.push(e);else if(xP(e)){let t=/[^=]*/.exec(e.style)[0];n.indexOf(t)<0&&n.push(t),this.styles.push(e)}}),this.normalizeLists=!this.tags.some(t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)})}parse(e,t={}){let n=new jP(this,t,!1);return n.addAll(e,DN.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new jP(this,t,!0);return n.addAll(e,DN.none,t.from,t.to),q.maxOpen(n.finish())}matchTag(e,t,n){for(let r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){let n=this.tags[r];if(NP(e,n.tag)&&(n.namespace===void 0||e.namespaceURI==n.namespace)&&(!n.context||t.matchesContext(n.context))){if(n.getAttrs){let t=n.getAttrs(e);if(t===!1)continue;n.attrs=t||void 0}return n}}}matchStyle(e,t,n,r){for(let i=r?this.styles.indexOf(r)+1:0;i<this.styles.length;i++){let r=this.styles[i],a=r.style;if(!(a.indexOf(e)!=0||r.context&&!n.matchesContext(r.context)||a.length>e.length&&(a.charCodeAt(e.length)!=61||a.slice(e.length+1)!=t))){if(r.getAttrs){let e=r.getAttrs(t);if(e===!1)continue;r.attrs=e||void 0}return r}}}static schemaRules(e){let t=[];function n(e){let n=e.priority==null?50:e.priority,r=0;for(;r<t.length;r++){let e=t[r];if((e.priority==null?50:e.priority)<n)break}t.splice(r,0,e)}for(let t in e.marks){let r=e.marks[t].spec.parseDOM;r&&r.forEach(e=>{n(e=PP(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)})}for(let t in e.nodes){let r=e.nodes[t].spec.parseDOM;r&&r.forEach(e=>{n(e=PP(e)),e.node||e.ignore||e.mark||(e.node=t)})}return t}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new e(t,e.schemaRules(t)))}},CP={address:!0,article:!0,aside:!0,blockquote:!0,body:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},wP={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},TP={ol:!0,ul:!0},EP=1,DP=2,OP=4;function kP(e,t,n){return t==null?e&&e.whitespace==`pre`?3:n&-5:(t?EP:0)|(t===`full`?DP:0)}var AP=class{constructor(e,t,n,r,i,a){this.type=e,this.attrs=t,this.marks=n,this.solid=r,this.options=a,this.content=[],this.activeMarks=DN.none,this.match=i||(a&OP?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(K.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let t=this.type.contentMatch,n;return(n=t.findWrapping(e.type))?(this.match=t,n):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&EP)){let e=this.content[this.content.length-1],t;if(e&&e.isText&&(t=/[ \t\r\n\u000c]+$/.exec(e.text))){let n=e;e.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-t[0].length))}}let t=K.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(K.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!CP.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},jP=class{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let r=t.topNode,i,a=kP(null,t.preserveWhitespace,0)|(n?OP:0);i=r?new AP(r.type,r.attrs,DN.none,!0,t.topMatch||r.type.contentMatch,a):n?new AP(null,null,DN.none,!0,null,a):new AP(e.schema.topNodeType,null,DN.none,!0,null,a),this.nodes=[i],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,r=this.top,i=r.options&DP?`full`:this.localPreserveWS||(r.options&EP)>0,{schema:a}=this.parser;if(i===`full`||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(!i){if(n=n.replace(/[ \t\r\n\u000c]+/g,` `),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let t=r.content[r.content.length-1],i=e.previousSibling;(!t||i&&i.nodeName==`BR`||t.isText&&/[ \t\r\n\u000c]$/.test(t.text))&&(n=n.slice(1))}}else if(i===`full`)n=n.replace(/\r\n?/g,`
|
|
185
185
|
`);else if(a.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(a.linebreakReplacement.create())){let e=n.split(/\r?\n|\r/);for(let n=0;n<e.length;n++)n&&this.insertNode(a.linebreakReplacement.create(),t,!0),e[n]&&this.insertNode(a.text(e[n]),t,!/\S/.test(e[n]));n=``}else n=n.replace(/\r?\n|\r/g,` `);n&&this.insertNode(a.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let r=this.localPreserveWS,i=this.top;(e.tagName==`PRE`||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let a=e.nodeName.toLowerCase(),o;TP.hasOwnProperty(a)&&this.parser.normalizeLists&&MP(e);let s=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,n));out:if(s?s.ignore:wP.hasOwnProperty(a))this.findInside(e),this.ignoreFallback(e,t);else if(!s||s.skip||s.closeParent){s&&s.closeParent?this.open=Math.max(0,this.open-1):s&&s.skip.nodeType&&(e=s.skip);let n,r=this.needsBlock;if(CP.hasOwnProperty(a))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),n=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break out}let o=s&&s.skip?t:this.readStyles(e,t);o&&this.addAll(e,o),n&&this.sync(i),this.needsBlock=r}else{let n=this.readStyles(e,t);n&&this.addElementByRule(e,s,n,s.consuming===!1?o:void 0)}this.localPreserveWS=r}leafFallback(e,t){e.nodeName==`BR`&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
|
|
186
186
|
`),t)}ignoreFallback(e,t){e.nodeName==`BR`&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text(`-`),t,!0)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let e=0;e<this.parser.matchedStyles.length;e++){let r=this.parser.matchedStyles[e],i=n.getPropertyValue(r);if(i)for(let e;;){let n=this.parser.matchStyle(r,i,this,e);if(!n)break;if(n.ignore)return null;if(t=n.clearMark?t.filter(e=>!n.clearMark(e)):t.concat(this.parser.schema.marks[n.mark].create(n.attrs)),n.consuming===!1)e=n;else break}}return t}addElementByRule(e,t,n,r){let i,a;if(t.node)if(a=this.parser.schema.nodes[t.node],a.isLeaf)this.insertNode(a.create(t.attrs),n,e.nodeName==`BR`)||this.leafFallback(e,n);else{let e=this.enter(a,t.attrs||null,n,t.preserveWhitespace);e&&(i=!0,n=e)}else{let e=this.parser.schema.marks[t.mark];n=n.concat(e.create(t.attrs))}let o=this.top;if(a&&a.isLeaf)this.findInside(e);else if(r)this.addElement(e,n,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(e=>this.insertNode(e,n,!1));else{let r=e;typeof t.contentElement==`string`?r=e.querySelector(t.contentElement):typeof t.contentElement==`function`?r=t.contentElement(e):t.contentElement&&(r=t.contentElement),this.findAround(e,r,!0),this.addAll(r,n),this.findAround(e,r,!1)}i&&this.sync(o)&&this.open--}addAll(e,t,n,r){let i=n||0;for(let a=n?e.childNodes[n]:e.firstChild,o=r==null?null:e.childNodes[r];a!=o;a=a.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(a,t);this.findAtPoint(e,i)}findPlace(e,t,n){let r,i;for(let t=this.open,a=0;t>=0;t--){let o=this.nodes[t],s=o.findWrapping(e);if(s&&(!r||r.length>s.length+a)&&(r=s,i=o,!s.length))break;if(o.solid){if(n)break;a+=2}}if(!r)return null;this.sync(i);for(let e=0;e<r.length;e++)t=this.enterInner(r[e],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let e=this.textblockFromContext();e&&(t=this.enterInner(e,null,t))}let r=this.findPlace(e,t,n);if(r){this.closeExtra();let t=this.top;t.match&&=t.match.matchType(e.type);let n=DN.none;for(let i of r.concat(e.marks))(t.type?t.type.allowsMarkType(i.type):FP(i.type,e.type))&&(n=i.addToSet(n));return t.content.push(e.mark(n)),!0}return!1}enter(e,t,n,r){let i=this.findPlace(e.create(t),n,!1);return i&&=this.enterInner(e,t,n,!0,r),i}enterInner(e,t,n,r=!1,i){this.closeExtra();let a=this.top;a.match=a.match&&a.match.matchType(e);let o=kP(e,i,a.options);a.options&OP&&a.content.length==0&&(o|=OP);let s=DN.none;return n=n.filter(t=>(a.type?a.type.allowsMarkType(t.type):FP(t.type,e))?(s=t.addToSet(s),!1):!0),this.nodes.push(new AP(e,t,s,r,null,o)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;else this.localPreserveWS&&(this.nodes[t].options|=EP);return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let r=0;r<this.find.length;r++)this.find[r].pos==null&&e.nodeType==1&&e.contains(this.find[r].node)&&t.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf(`|`)>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split(`/`),n=this.options.context,r=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),i=-(n?n.depth+1:0)+ +!r,a=(e,o)=>{for(;e>=0;e--){let s=t[e];if(s==``){if(e==t.length-1||e==0)continue;for(;o>=i;o--)if(a(e-1,o))return!0;return!1}else{let e=o>0||o==0&&r?this.nodes[o].type:n&&o>=i?n.node(o-i).type:null;if(!e||e.name!=s&&!e.isInGroup(s))return!1;o--}}return!0};return a(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}};function MP(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=t.nodeType==1?t.nodeName.toLowerCase():null;e&&TP.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):e==`li`?n=t:e&&(n=null)}}function NP(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function PP(e){let t={};for(let n in e)t[n]=e[n];return t}function FP(e,t){let n=t.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(e))continue;let a=[],o=e=>{a.push(e);for(let n=0;n<e.edgeCount;n++){let{type:r,next:i}=e.edge(n);if(r==t||a.indexOf(i)<0&&o(i))return!0}};if(o(i.contentMatch))return!0}}var IP=class e{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||=RP(t).createDocumentFragment();let r=n,i=[];return e.forEach(e=>{if(i.length||e.marks.length){let n=0,a=0;for(;n<i.length&&a<e.marks.length;){let t=e.marks[a];if(!this.marks[t.type.name]){a++;continue}if(!t.eq(i[n][0])||t.type.spec.spanning===!1)break;n++,a++}for(;n<i.length;)r=i.pop()[1];for(;a<e.marks.length;){let n=e.marks[a++],o=this.serializeMark(n,e.isInline,t);o&&(i.push([n,r]),r.appendChild(o.dom),r=o.contentDOM||o.dom)}}r.appendChild(this.serializeNodeInner(e,t))}),n}serializeNodeInner(e,t){if(e.isText)return RP(t).createTextNode(e.text);let{dom:n,contentDOM:r}=HP(RP(t),this.nodes[e.type.name](e),null,e.attrs);if(r){if(e.isLeaf)throw RangeError(`Content hole not allowed in a leaf node spec`);this.serializeFragment(e.content,t,r)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let r=e.marks.length-1;r>=0;r--){let i=this.serializeMark(e.marks[r],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(n),n=i.dom)}return n}serializeMark(e,t,n={}){let r=this.marks[e.type.name];return r&&HP(RP(n),r(e,t),null,e.attrs)}static renderSpec(e,t,n=null,r){return typeof t==`string`?{dom:e.createTextNode(t)}:HP(e,t,n,r)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new e(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(e){let t=LP(e.nodes);return t.text||=e=>e.text,t}static marksFromSchema(e){return LP(e.marks)}};function LP(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function RP(e){return e.document||window.document}var zP=new WeakMap;function BP(e){let t=zP.get(e);return t===void 0&&zP.set(e,t=VP(e)),t}function VP(e){let t=null;function n(e){if(e&&typeof e==`object`)if(Array.isArray(e))if(typeof e[0]==`string`)t||=[],t.push(e);else for(let t=0;t<e.length;t++)n(e[t]);else for(let t in e)n(e[t])}return n(e),t}function HP(e,t,n,r){if(t.nodeType==1)return{dom:t};if(t.dom&&t.dom.nodeType==1)return t;let i=t[0],a;if(typeof i!=`string`)throw RangeError(`Invalid array passed to renderSpec`);if(r&&(a=BP(r))&&a.indexOf(t)>-1)throw RangeError(`Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.`);let o=i.indexOf(` `);o>0&&(n=i.slice(0,o),i=i.slice(o+1));let s,c=n?e.createElementNS(n,i):e.createElement(i),l=t[1],u=1;if(l&&typeof l==`object`&&l.nodeType==null&&!Array.isArray(l)){u=2;for(let e in l)if(l[e]!=null){let t=e.indexOf(` `);t>0?c.setAttributeNS(e.slice(0,t),e.slice(t+1),l[e]):e==`style`&&c.style?c.style.cssText=l[e]:c.setAttribute(e,l[e])}}for(let i=u;i<t.length;i++){let a=t[i];if(a===0){if(i<t.length-1||i>u)throw RangeError(`Content hole must be the only child of its parent node`);return{dom:c,contentDOM:c}}else if(typeof a==`string`)c.appendChild(e.createTextNode(a));else{let{dom:t,contentDOM:i}=HP(e,a,n,r);if(c.appendChild(t),i){if(s)throw RangeError(`Multiple content holes`);s=i}}}return{dom:c,contentDOM:s}}var UP=65535,WP=2**16;function GP(e,t){return e+t*WP}function KP(e){return e&UP}function qP(e){return(e-(e&UP))/WP}var JP=1,YP=2,XP=4,ZP=8,QP=class{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&ZP)>0}get deletedBefore(){return(this.delInfo&5)>0}get deletedAfter(){return(this.delInfo&6)>0}get deletedAcross(){return(this.delInfo&XP)>0}},$P=class e{constructor(t,n=!1){if(this.ranges=t,this.inverted=n,!t.length&&e.empty)return e.empty}recover(e){let t=0,n=KP(e);if(!this.inverted)for(let e=0;e<n;e++)t+=this.ranges[e*3+2]-this.ranges[e*3+1];return this.ranges[n*3]+t+qP(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let r=0,i=this.inverted?2:1,a=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let s=this.ranges[o]-(this.inverted?r:0);if(s>e)break;let c=this.ranges[o+i],l=this.ranges[o+a],u=s+c;if(e<=u){let i=c?e==s?-1:e==u?1:t:t,a=s+r+(i<0?0:l);if(n)return a;let d=e==(t<0?s:u)?null:GP(o/3,e-s),f=e==s?YP:e==u?JP:XP;return(t<0?e!=s:e!=u)&&(f|=ZP),new QP(a,f,d)}r+=l-c}return n?e+r:new QP(e+r,0,null)}touches(e,t){let n=0,r=KP(t),i=this.inverted?2:1,a=this.inverted?1:2;for(let t=0;t<this.ranges.length;t+=3){let o=this.ranges[t]-(this.inverted?n:0);if(o>e)break;let s=this.ranges[t+i];if(e<=o+s&&t==r*3)return!0;n+=this.ranges[t+a]-s}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,i=0;r<this.ranges.length;r+=3){let a=this.ranges[r],o=a-(this.inverted?i:0),s=a+(this.inverted?0:i),c=this.ranges[r+t],l=this.ranges[r+n];e(o,o+c,s,s+l),i+=l-c}}invert(){return new e(this.ranges,!this.inverted)}toString(){return(this.inverted?`-`:``)+JSON.stringify(this.ranges)}static offset(t){return t==0?e.empty:new e(t<0?[0,-t,0]:[0,0,t])}};$P.empty=new $P([]);var eF=class e{constructor(e,t,n=0,r=e?e.length:0){this.mirror=t,this.from=n,this.to=r,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(t=0,n=this.maps.length){return new e(this._maps,this.mirror,t,n)}appendMap(e,t){this.ownData||=(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,n=this._maps.length;t<e._maps.length;t++){let r=e.getMirror(t);this.appendMap(e._maps[t],r!=null&&r<t?n+r:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||=[],this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this._maps.length+e._maps.length;t>=0;t--){let r=e.getMirror(t);this.appendMap(e._maps[t].invert(),r!=null&&r>t?n-r-1:void 0)}}invert(){let t=new e;return t.appendMappingInverted(this),t}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this._maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let r=0;for(let n=this.from;n<this.to;n++){let i=this._maps[n].mapResult(e,t);if(i.recover!=null){let t=this.getMirror(n);if(t!=null&&t>n&&t<this.to){n=t,e=this._maps[t].recover(i.recover);continue}}r|=i.delInfo,e=i.pos}return n?e:new QP(e,r,null)}},tF=Object.create(null),nF=class{getMap(){return $P.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw RangeError(`Invalid input for Step.fromJSON`);let n=tF[t.stepType];if(!n)throw RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in tF)throw RangeError(`Duplicate use of step JSON ID `+e);return tF[e]=t,t.prototype.jsonID=e,t}},rF=class e{constructor(e,t){this.doc=e,this.failed=t}static ok(t){return new e(t,null)}static fail(t){return new e(null,t)}static fromReplace(t,n,r,i){try{return e.ok(t.replace(n,r,i))}catch(t){if(t instanceof ON)return e.fail(t.message);throw t}}};function iF(e,t,n){let r=[];for(let i=0;i<e.childCount;i++){let a=e.child(i);a.content.size&&(a=a.copy(iF(a.content,t,a))),a.isInline&&(a=t(a,n,i)),r.push(a)}return K.fromArray(r)}var aF=class e extends nF{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),r=n.node(n.sharedDepth(this.to)),i=new q(iF(t.content,(e,t)=>!e.isAtom||!t.type.allowsMarkType(this.mark.type)?e:e.mark(this.mark.addToSet(e.marks)),r),t.openStart,t.openEnd);return rF.fromReplace(e,this.from,this.to,i)}invert(){return new oF(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`addMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for AddMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};nF.jsonID(`addMark`,aF);var oF=class e extends nF{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new q(iF(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return rF.fromReplace(e,this.from,this.to,n)}invert(){return new aF(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`removeMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for RemoveMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};nF.jsonID(`removeMark`,oF);var sF=class e extends nF{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return rF.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return rF.fromReplace(e,this.pos,this.pos+1,new q(K.from(n),0,+!t.isLeaf))}invert(t){let n=t.nodeAt(this.pos);if(n){let t=this.mark.addToSet(n.marks);if(t.length==n.marks.length){for(let r=0;r<n.marks.length;r++)if(!n.marks[r].isInSet(t))return new e(this.pos,n.marks[r]);return new e(this.pos,this.mark)}}return new cF(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:`addNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for AddNodeMarkStep.fromJSON`);return new e(n.pos,t.markFromJSON(n.mark))}};nF.jsonID(`addNodeMark`,sF);var cF=class e extends nF{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return rF.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return rF.fromReplace(e,this.pos,this.pos+1,new q(K.from(n),0,+!t.isLeaf))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new sF(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:`removeNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for RemoveNodeMarkStep.fromJSON`);return new e(n.pos,t.markFromJSON(n.mark))}};nF.jsonID(`removeNodeMark`,cF);var lF=class e extends nF{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&dF(e,this.from,this.to)?rF.fail(`Structure replace would overwrite content`):rF.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new $P([this.from,this.to-this.from,this.slice.size])}invert(t){return new e(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let n=t.mapResult(this.to,-1),r=this.from==this.to&&e.MAP_BIAS<0?n:t.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new e(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(t){if(!(t instanceof e)||t.structure||this.structure)return null;if(this.from+this.slice.size==t.from&&!this.slice.openEnd&&!t.slice.openStart){let n=this.slice.size+t.slice.size==0?q.empty:new q(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new e(this.from,this.to+(t.to-t.from),n,this.structure)}else if(t.to==this.from&&!this.slice.openStart&&!t.slice.openEnd){let n=this.slice.size+t.slice.size==0?q.empty:new q(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new e(t.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:`replace`,from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for ReplaceStep.fromJSON`);return new e(n.from,n.to,q.fromJSON(t,n.slice),!!n.structure)}};lF.MAP_BIAS=1,nF.jsonID(`replace`,lF);var uF=class e extends nF{constructor(e,t,n,r,i,a,o=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=r,this.slice=i,this.insert=a,this.structure=o}apply(e){if(this.structure&&(dF(e,this.from,this.gapFrom)||dF(e,this.gapTo,this.to)))return rF.fail(`Structure gap-replace would overwrite content`);let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return rF.fail(`Gap is not a flat range`);let n=this.slice.insertAt(this.insert,t.content);return n?rF.fromReplace(e,this.from,this.to,n):rF.fail(`Content does not fit in gap`)}getMap(){return new $P([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let n=this.gapTo-this.gapFrom;return new e(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:t.map(this.gapFrom,-1),a=this.to==this.gapTo?r.pos:t.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||a>r.pos?null:new e(n.pos,r.pos,i,a,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:`replaceAround`,from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`||typeof n.gapFrom!=`number`||typeof n.gapTo!=`number`||typeof n.insert!=`number`)throw RangeError(`Invalid input for ReplaceAroundStep.fromJSON`);return new e(n.from,n.to,n.gapFrom,n.gapTo,q.fromJSON(t,n.slice),n.insert,!!n.structure)}};nF.jsonID(`replaceAround`,uF);function dF(e,t,n){let r=e.resolve(t),i=n-t,a=r.depth;for(;i>0&&a>0&&r.indexAfter(a)==r.node(a).childCount;)a--,i--;if(i>0){let e=r.node(a).maybeChild(r.indexAfter(a));for(;i>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,i--}}return!1}function fF(e,t,n,r){let i=[],a=[],o,s;e.doc.nodesBetween(t,n,(e,c,l)=>{if(!e.isInline)return;let u=e.marks;if(!r.isInSet(u)&&l.type.allowsMarkType(r.type)){let l=Math.max(c,t),d=Math.min(c+e.nodeSize,n),f=r.addToSet(u);for(let e=0;e<u.length;e++)u[e].isInSet(f)||(o&&o.to==l&&o.mark.eq(u[e])?o.to=d:i.push(o=new oF(l,d,u[e])));s&&s.to==l?s.to=d:a.push(s=new aF(l,d,r))}}),i.forEach(t=>e.step(t)),a.forEach(t=>e.step(t))}function pF(e,t,n,r){let i=[],a=0;e.doc.nodesBetween(t,n,(e,o)=>{if(!e.isInline)return;a++;let s=null;if(r instanceof _P){let t=e.marks,n;for(;n=r.isInSet(t);)(s||=[]).push(n),t=n.removeFromSet(t)}else r?r.isInSet(e.marks)&&(s=[r]):s=e.marks;if(s&&s.length){let r=Math.min(o+e.nodeSize,n);for(let e=0;e<s.length;e++){let n=s[e],c;for(let e=0;e<i.length;e++){let t=i[e];t.step==a-1&&n.eq(i[e].style)&&(c=t)}c?(c.to=r,c.step=a):i.push({style:n,from:Math.max(o,t),to:r,step:a})}}}),i.forEach(t=>e.step(new oF(t.from,t.to,t.style)))}function mF(e,t,n,r=n.contentMatch,i=!0){let a=e.doc.nodeAt(t),o=[],s=t+1;for(let t=0;t<a.childCount;t++){let c=a.child(t),l=s+c.nodeSize,u=r.matchType(c.type);if(!u)o.push(new lF(s,l,q.empty));else{r=u;for(let t=0;t<c.marks.length;t++)n.allowsMarkType(c.marks[t].type)||e.step(new oF(s,l,c.marks[t]));if(i&&c.isText&&n.whitespace!=`pre`){let e,t=/\r?\n|\r/g,r;for(;e=t.exec(c.text);)r||=new q(K.from(n.schema.text(` `,n.allowedMarks(c.marks))),0,0),o.push(new lF(s+e.index,s+e.index+e[0].length,r))}}s=l}if(!r.validEnd){let t=r.fillBefore(K.empty,!0);e.replace(s,s,new q(t,0,0))}for(let t=o.length-1;t>=0;t--)e.step(o[t])}function hF(e,t,n){return(t==0||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function gF(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth,r=0,i=0;;--n){let a=e.$from.node(n),o=e.$from.index(n)+r,s=e.$to.indexAfter(n)-i;if(n<e.depth&&a.canReplace(o,s,t))return n;if(n==0||a.type.spec.isolating||!hF(a,o,s))break;o&&(r=1),s<a.childCount&&(i=1)}return null}function _F(e,t,n){let{$from:r,$to:i,depth:a}=t,o=r.before(a+1),s=i.after(a+1),c=o,l=s,u=K.empty,d=0;for(let e=a,t=!1;e>n;e--)t||r.index(e)>0?(t=!0,u=K.from(r.node(e).copy(u)),d++):c--;let f=K.empty,p=0;for(let e=a,t=!1;e>n;e--)t||i.after(e+1)<i.end(e)?(t=!0,f=K.from(i.node(e).copy(f)),p++):l++;e.step(new uF(c,l,o,s,new q(u.append(f),d,p),u.size-d,!0))}function vF(e,t,n=null,r=e){let i=bF(e,t),a=i&&xF(r,t);return a?i.map(yF).concat({type:t,attrs:n}).concat(a.map(yF)):null}function yF(e){return{type:e,attrs:null}}function bF(e,t){let{parent:n,startIndex:r,endIndex:i}=e,a=n.contentMatchAt(r).findWrapping(t);if(!a)return null;let o=a.length?a[0]:t;return n.canReplaceWith(r,i,o)?a:null}function xF(e,t){let{parent:n,startIndex:r,endIndex:i}=e,a=n.child(r),o=t.contentMatch.findWrapping(a.type);if(!o)return null;let s=(o.length?o[o.length-1]:t).contentMatch;for(let e=r;s&&e<i;e++)s=s.matchType(n.child(e).type);return!s||!s.validEnd?null:o}function SF(e,t,n){let r=K.empty;for(let e=n.length-1;e>=0;e--){if(r.size){let t=n[e].type.contentMatch.matchFragment(r);if(!t||!t.validEnd)throw RangeError(`Wrapper type given to Transform.wrap does not form valid content of its parent wrapper`)}r=K.from(n[e].type.create(n[e].attrs,r))}let i=t.start,a=t.end;e.step(new uF(i,a,i,a,new q(r,0,0),n.length,!0))}function CF(e,t,n,r,i){if(!r.isTextblock)throw RangeError(`Type given to setBlockType should be a textblock`);let a=e.steps.length;e.doc.nodesBetween(t,n,(t,n)=>{let o=typeof i==`function`?i(t):i;if(t.isTextblock&&!t.hasMarkup(r,o)&&EF(e.doc,e.mapping.slice(a).map(n),r)){let i=null;if(r.schema.linebreakReplacement){let e=r.whitespace==`pre`,t=!!r.contentMatch.matchType(r.schema.linebreakReplacement);e&&!t?i=!1:!e&&t&&(i=!0)}i===!1&&TF(e,t,n,a),mF(e,e.mapping.slice(a).map(n,1),r,void 0,i===null);let s=e.mapping.slice(a),c=s.map(n,1),l=s.map(n+t.nodeSize,1);return e.step(new uF(c,l,c+1,l-1,new q(K.from(r.create(o,null,t.marks)),0,0),1,!0)),i===!0&&wF(e,t,n,a),!1}})}function wF(e,t,n,r){t.forEach((i,a)=>{if(i.isText){let o,s=/\r?\n|\r/g;for(;o=s.exec(i.text);){let i=e.mapping.slice(r).map(n+1+a+o.index);e.replaceWith(i,i+1,t.type.schema.linebreakReplacement.create())}}})}function TF(e,t,n,r){t.forEach((i,a)=>{if(i.type==i.type.schema.linebreakReplacement){let i=e.mapping.slice(r).map(n+1+a);e.replaceWith(i,i+1,t.type.schema.text(`
|
|
@@ -270,20 +270,20 @@ img.ProseMirror-separator {
|
|
|
270
270
|
display: block;
|
|
271
271
|
}`,XG=class extends GW{constructor(e={}){super(),this.css=null,this.className=`tiptap`,this.editorView=null,this.isFocused=!1,this.destroyed=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.hasWarnedStaleDecorationRead=!1,this.options={element:typeof document<`u`?document.createElement(`div`):null,content:``,injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:e})=>{throw e},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:uW,createMappablePosition:dW},this.setOptions(e),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on(`beforeCreate`,this.options.onBeforeCreate),this.emit(`beforeCreate`,{editor:this}),this.on(`mount`,this.options.onMount),this.on(`unmount`,this.options.onUnmount),this.on(`contentError`,this.options.onContentError),this.on(`create`,this.options.onCreate),this.on(`update`,this.options.onUpdate),this.on(`selectionUpdate`,this.options.onSelectionUpdate),this.on(`transaction`,this.options.onTransaction),this.on(`focus`,this.options.onFocus),this.on(`blur`,this.options.onBlur),this.on(`destroy`,this.options.onDestroy),this.on(`drop`,({event:e,slice:t,moved:n})=>this.options.onDrop(e,t,n)),this.on(`paste`,({event:e,slice:t})=>this.options.onPaste(e,t)),this.on(`delete`,this.options.onDelete);let t=this.createDoc();if(!this.editorState){let e=DH(t,this.options.autofocus);this.editorState=bI.create({doc:t,schema:this.schema,selection:e||void 0})}qG(this.schema),this.options.element&&this.mount(this.options.element)}mount(e){if(typeof document>`u`)throw Error(`[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.`);this.createView(e),this.emit(`mount`,{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.options.autofocus!==!1&&this.options.autofocus!==null&&this.commands.focus(this.options.autofocus),this.emit(`create`,{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){this.editorState=this.editorView.state;let e=this.editorView.dom;e?.editor&&delete e.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{typeof this.css.remove==`function`?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(e){console.warn(`Failed to remove CSS element:`,e)}this.css=null,this.emit(`unmount`,{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager?this.commandManager.chain():eH.createFakeChain()}can(){return this.commandManager?this.commandManager.can():eH.createFallbackCan()}injectCSS(){this.options.injectCSS&&typeof document<`u`&&(this.css=pG(YG,this.options.injectNonce))}setOptions(e={}){this.options={...this.options,...e},!(!this.editorView||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(e,t=!0){this.setOptions({editable:e}),t&&this.emit(`update`,{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:e=>{this.editorState=e},dispatch:e=>{this.dispatchTransaction(e)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(e,t)=>{if(this.editorView)return this.editorView[t];if(t===`state`)return this.editorState;if(t in e)return Reflect.get(e,t);throw Error(`[tiptap error]: The editor view is not available. Cannot access view['${t}']. The editor may not be mounted yet.`)}})}get state(){return KW&&!this.hasWarnedStaleDecorationRead&&WW(this)&&(this.hasWarnedStaleDecorationRead=!0,console.warn("[tiptap warn]: `editor.state` was read while decoration `create()` was running. It returns the pre-transaction document. Use the `state` argument passed to `create()` instead. Helpers like `editor.isActive()` read `editor.state` too, so pass `state` to their standalone versions instead of calling them on the editor.")),this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(e,t){let n=wU(t)?t(e,[...this.state.plugins]):[...this.state.plugins,e],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(e){if(this.isDestroyed)return;let t=this.state.plugins,n=t;if([].concat(e).forEach(e=>{let t=typeof e==`string`?`${e}$`:e.key;n=n.filter(e=>!e.key.startsWith(t))}),t.length===n.length)return;let r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){var e,t;let n=[...this.options.enableCoreExtensions?[zG,FG.configure({blockSeparator:(e=this.options.coreExtensionOptions)==null||(e=e.clipboardTextSerializer)==null?void 0:e.blockSeparator}),IG,VG,HG,WG.configure({value:(t=this.options.coreExtensionOptions)==null||(t=t.tabindex)==null?void 0:t.value}),RG,UG,LG,GG.configure({direction:this.options.textDirection})].filter(e=>typeof this.options.enableCoreExtensions!=`object`||this.options.enableCoreExtensions[e.name]!==!1):[],...this.options.extensions].filter(e=>[`extension`,`node`,`mark`].includes(e?.type));this.extensionManager=new NG(n,this)}createCommandManager(){this.commandManager=new eH({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let e;try{e=hU(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(e){if(!(e instanceof Error)||![`[tiptap error]: Invalid JSON content`,`[tiptap error]: Invalid HTML content`].includes(e.message))throw e;let t=hU(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1});return this.editorState=bI.create({doc:t,schema:this.schema,selection:DH(t,this.options.autofocus)||void 0}),this.emit(`contentError`,{editor:this,error:e,disableCollaboration:()=>{`collaboration`in this.storage&&typeof this.storage.collaboration==`object`&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(e=>e.name!==`collaboration`),this.createExtensionManager()}}),this.editorState.doc}return e}createView(e){let{editorProps:t,enableExtensionDispatchTransaction:n}=this.options,r=t.dispatchTransaction||this.dispatchTransaction.bind(this),i=n?this.extensionManager.dispatchTransaction(r):r,a=t.transformPastedHTML,o=this.extensionManager.transformPastedHTML(a);this.editorView=new jV(e,{...t,attributes:{role:`textbox`,...t?.attributes},dispatchTransaction:i,transformPastedHTML:o,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});let s=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(s),this.prependClass(),this.injectCSS();let c=this.view.dom;c.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;let t=this.capturedTransaction;return this.capturedTransaction=null,t}dispatchTransaction(e){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=e;return}e.steps.forEach(e=>this.capturedTransaction?.step(e));return}let{state:t,transactions:n}=this.state.applyTransaction(e),r=!this.state.selection.eq(t.selection),i=n.includes(e),a=this.state;if(this.emit(`beforeTransaction`,{editor:this,transaction:e,nextState:t}),!i)return;this.view.updateState(t),this.emit(`transaction`,{editor:this,transaction:e,appendedTransactions:n.slice(1)}),r&&this.emit(`selectionUpdate`,{editor:this,transaction:e});let o=n.findLast(e=>e.getMeta(`focus`)||e.getMeta(`blur`)),s=o?.getMeta(`focus`),c=o?.getMeta(`blur`);s&&this.emit(`focus`,{editor:this,event:s.event,transaction:o}),c&&this.emit(`blur`,{editor:this,event:c.event,transaction:o}),!(e.getMeta(`preventUpdate`)||!n.some(e=>e.docChanged)||a.doc.eq(t.doc))&&this.emit(`update`,{editor:this,transaction:e,appendedTransactions:n.slice(1)})}getAttributes(e){return GU(this.state,e)}isActive(e,t){let n=typeof e==`string`?e:null,r=typeof e==`string`?t:e;return nW(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return CU(this.state.doc.content,this.schema)}getText(e){let{blockSeparator:t=`
|
|
272
272
|
|
|
273
|
-
`,textSerializers:n={}}=e||{};return HU(this.state.doc,{blockSeparator:t,textSerializers:{...UU(this.schema),...n}})}get isEmpty(){return sW(this.state.doc)}destroy(){this.destroyed||(this.destroyed=!0,this.emit(`destroy`),this.unmount(),this.removeAllListeners(),this.extensionManager.destroy(),this.extensionManager=null,this.schema=null,this.commandManager=null,this.extensionStorage={})}get isDestroyed(){return this.editorView?.isDestroyed??!0}$node(e,t){return this.$doc?.querySelector(e,t)||null}$nodes(e,t){return this.$doc?.querySelectorAll(e,t)||null}$pos(e){let t=this.state.doc.resolve(e),n=e>0&&t.nodeAfter&&!t.nodeAfter.isText&&t.nodeAfter.isAtom?t.nodeAfter:null;return new JG(t,this,!1,n)}get $doc(){return this.$pos(0)}};function ZG(e){return new xG({find:e.find,handler:({state:t,range:n,match:r})=>{let i=TU(e.getAttributes,void 0,r);if(i===!1||i===null)return null;let{tr:a}=t,o=r[r.length-1],s=r[0];if(o){let r=s.search(/\S/),c=n.from+s.indexOf(o),l=c+o.length;if(YU(n.from,n.to,t.doc).filter(t=>t.mark.type.excluded.find(n=>n===e.type&&n!==t.mark.type)).filter(e=>e.to>c).length)return null;l<n.to&&a.delete(l,n.to),c>n.from&&a.delete(n.from+r,c);let u=n.from+r+o.length;a.addMark(n.from+r,u,e.type.create(i||{})),a.removeStoredMark(e.type)}},undoable:e.undoable})}function QG(e){return new xG({find:e.find,handler:({state:t,range:n,match:r})=>{let i=TU(e.getAttributes,void 0,r)||{},{tr:a}=t,o=n.from,s=n.to,c=e.type.create(i);if(r[1]){let e=o+r[0].lastIndexOf(r[1]);e>s?e=s:s=e+r[1].length;let t=r[0][r[0].length-1];a.insertText(t,o+r[0].length-1),a.replaceWith(e,s,c)}else if(r[0]){let t=e.type.isInline?o:o-1;a.insert(t,e.type.create(i)).delete(a.mapping.map(o),a.mapping.map(s))}a.scrollIntoView()},undoable:e.undoable})}function $G(e){return new xG({find:e.find,handler:({state:t,range:n,match:r})=>{let i=t.doc.resolve(n.from),a=TU(e.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),e.type))return null;t.tr.delete(n.from,n.to).setBlockType(n.from,n.from,e.type,a)},undoable:e.undoable})}function eK(e){return new xG({find:e.find,handler:({state:t,range:n,match:r,chain:i})=>{let a=TU(e.getAttributes,void 0,r)||{},o=t.tr.delete(n.from,n.to),s=o.doc.resolve(n.from).blockRange(),c=s&&vF(s,e.type,a);if(!c)return null;if(o.wrap(s,c),e.keepMarks&&e.editor){let{selection:n,storedMarks:r}=t,{splittableMarks:i}=e.editor.extensionManager,a=r||n.$to.parentOffset&&n.$from.marks();if(a){let e=a.filter(e=>i.includes(e.type.name));o.ensureMarks(e)}}if(e.keepAttributes){let t=e.type.name===`bulletList`||e.type.name===`orderedList`?`listItem`:`taskList`;i().updateAttributes(t,a).run()}let l=o.doc.resolve(n.from-1).nodeBefore;l&&l.type===e.type&&AF(o.doc,n.from-1)&&(!e.joinPredicate||e.joinPredicate(r,l))&&o.join(n.from-1)},undoable:e.undoable})}var tK=class e extends TG{constructor(...e){super(...e),this.type=`node`}static create(t={}){let n=typeof t==`function`?t():t;return new e(n)}configure(e){return super.configure(e)}extend(e){let t=typeof e==`function`?e():e;return super.extend(t)}};function nK(e){return new DG({find:e.find,handler:({state:t,range:n,match:r,pasteEvent:i})=>{let a=TU(e.getAttributes,void 0,r,i);if(a===!1||a===null)return null;let{tr:o}=t,s=r[r.length-1],c=r[0],l=n.to;if(s){let i=c.search(/\S/),u=n.from+c.indexOf(s),d=u+s.length;if(YU(n.from,n.to,t.doc).filter(t=>t.mark.type.excluded.find(n=>n===e.type&&n!==t.mark.type)).filter(e=>e.to>u).length)return null;d<n.to&&o.delete(d,n.to),u>n.from&&o.delete(n.from+i,u),l=n.from+i+s.length,o.addMark(n.from+i,l,e.type.create(a||{})),r.index!==void 0&&r.input!==void 0&&r.index+r[0].length>=r.input.length||o.removeStoredMark(e.type)}}})}var{getOwnPropertyNames:rK,getOwnPropertySymbols:iK}=Object,{hasOwnProperty:aK}=Object.prototype;function oK(e,t){return function(n,r,i){return e(n,r,i)&&t(n,r,i)}}function sK(e){return function(t,n,r){if(!t||!n||typeof t!=`object`||typeof n!=`object`)return e(t,n,r);let{cache:i}=r,a=i.get(t),o=i.get(n);if(a&&o)return a===n&&o===t;i.set(t,n),i.set(n,t);let s=e(t,n,r);return i.delete(t),i.delete(n),s}}function cK(e){return e?.[Symbol.toStringTag]}function lK(e){return rK(e).concat(iK(e))}var uK=Object.hasOwn||((e,t)=>aK.call(e,t));function dK(e,t){return e===t||!e&&!t&&e!==e&&t!==t}var fK=`__v`,pK=`__o`,mK=`_owner`,{getOwnPropertyDescriptor:hK,keys:gK}=Object;function _K(e,t){return e.byteLength===t.byteLength&&AK(new Uint8Array(e),new Uint8Array(t))}function vK(e,t,n){let r=e.length;if(t.length!==r)return!1;for(;r-->0;)if(!n.equals(e[r],t[r],r,r,e,t,n))return!1;return!0}function yK(e,t){return e.byteLength===t.byteLength&&AK(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}function bK(e,t){return dK(e.getTime(),t.getTime())}function xK(e,t){return e.name===t.name&&e.message===t.message&&e.cause===t.cause&&e.stack===t.stack}function SK(e,t){return e===t}function CK(e,t,n){let r=e.size;if(r!==t.size)return!1;if(!r)return!0;let i=Array(r),a=e.entries(),o,s,c=0;for(;(o=a.next())&&!o.done;){let r=t.entries(),a=!1,l=0;for(;(s=r.next())&&!s.done;){if(i[l]){l++;continue}let r=o.value,u=s.value;if(n.equals(r[0],u[0],c,l,e,t,n)&&n.equals(r[1],u[1],r[0],u[0],e,t,n)){a=i[l]=!0;break}l++}if(!a)return!1;c++}return!0}var wK=dK;function TK(e,t,n){let r=gK(e),i=r.length;if(gK(t).length!==i)return!1;for(;i-->0;)if(!MK(e,t,n,r[i]))return!1;return!0}function EK(e,t,n){let r=lK(e),i=r.length;if(lK(t).length!==i)return!1;let a,o,s;for(;i-->0;)if(a=r[i],!MK(e,t,n,a)||(o=hK(e,a),s=hK(t,a),(o||s)&&(!o||!s||o.configurable!==s.configurable||o.enumerable!==s.enumerable||o.writable!==s.writable)))return!1;return!0}function DK(e,t){return dK(e.valueOf(),t.valueOf())}function OK(e,t){return e.source===t.source&&e.flags===t.flags}function kK(e,t,n){let r=e.size;if(r!==t.size)return!1;if(!r)return!0;let i=Array(r),a=e.values(),o,s;for(;(o=a.next())&&!o.done;){let r=t.values(),a=!1,c=0;for(;(s=r.next())&&!s.done;){if(!i[c]&&n.equals(o.value,s.value,o.value,s.value,e,t,n)){a=i[c]=!0;break}c++}if(!a)return!1}return!0}function AK(e,t){let n=e.byteLength;if(t.byteLength!==n||e.byteOffset!==t.byteOffset)return!1;for(;n-->0;)if(e[n]!==t[n])return!1;return!0}function jK(e,t){return e.hostname===t.hostname&&e.pathname===t.pathname&&e.protocol===t.protocol&&e.port===t.port&&e.hash===t.hash&&e.username===t.username&&e.password===t.password}function MK(e,t,n,r){return(r===mK||r===pK||r===fK)&&(e.$$typeof||t.$$typeof)?!0:uK(t,r)&&n.equals(e[r],t[r],r,r,e,t,n)}var NK=`[object ArrayBuffer]`,PK=`[object Arguments]`,FK=`[object Boolean]`,IK=`[object DataView]`,LK=`[object Date]`,RK=`[object Error]`,zK=`[object Map]`,BK=`[object Number]`,VK=`[object Object]`,HK=`[object RegExp]`,UK=`[object Set]`,WK=`[object String]`,GK={"[object Int8Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Int16Array]":!0,"[object Uint16Array]":!0,"[object Int32Array]":!0,"[object Uint32Array]":!0,"[object Float16Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0,"[object BigInt64Array]":!0,"[object BigUint64Array]":!0},KK=`[object URL]`,qK=Object.prototype.toString;function JK({areArrayBuffersEqual:e,areArraysEqual:t,areDataViewsEqual:n,areDatesEqual:r,areErrorsEqual:i,areFunctionsEqual:a,areMapsEqual:o,areNumbersEqual:s,areObjectsEqual:c,arePrimitiveWrappersEqual:l,areRegExpsEqual:u,areSetsEqual:d,areTypedArraysEqual:f,areUrlsEqual:p,unknownTagComparators:m}){return function(h,g,_){if(h===g)return!0;if(h==null||g==null)return!1;let v=typeof h;if(v!==typeof g)return!1;if(v!==`object`)return v===`number`?s(h,g,_):v===`function`&&a(h,g,_);let y=h.constructor;if(y!==g.constructor)return!1;if(y===Object)return c(h,g,_);if(Array.isArray(h))return t(h,g,_);if(y===Date)return r(h,g,_);if(y===RegExp)return u(h,g,_);if(y===Map)return o(h,g,_);if(y===Set)return d(h,g,_);let b=qK.call(h);if(b===LK)return r(h,g,_);if(b===HK)return u(h,g,_);if(b===zK)return o(h,g,_);if(b===UK)return d(h,g,_);if(b===VK)return typeof h.then!=`function`&&typeof g.then!=`function`&&c(h,g,_);if(b===KK)return p(h,g,_);if(b===RK)return i(h,g,_);if(b===PK)return c(h,g,_);if(GK[b])return f(h,g,_);if(b===NK)return e(h,g,_);if(b===IK)return n(h,g,_);if(b===FK||b===BK||b===WK)return l(h,g,_);if(m){let e=m[b];if(!e){let t=cK(h);t&&(e=m[t])}if(e)return e(h,g,_)}return!1}}function YK({circular:e,createCustomConfig:t,strict:n}){let r={areArrayBuffersEqual:_K,areArraysEqual:n?EK:vK,areDataViewsEqual:yK,areDatesEqual:bK,areErrorsEqual:xK,areFunctionsEqual:SK,areMapsEqual:n?oK(CK,EK):CK,areNumbersEqual:wK,areObjectsEqual:n?EK:TK,arePrimitiveWrappersEqual:DK,areRegExpsEqual:OK,areSetsEqual:n?oK(kK,EK):kK,areTypedArraysEqual:n?oK(AK,EK):AK,areUrlsEqual:jK,unknownTagComparators:void 0};if(t&&(r=Object.assign({},r,t(r))),e){let e=sK(r.areArraysEqual),t=sK(r.areMapsEqual),n=sK(r.areObjectsEqual),i=sK(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:e,areMapsEqual:t,areObjectsEqual:n,areSetsEqual:i})}return r}function XK(e){return function(t,n,r,i,a,o,s){return e(t,n,s)}}function ZK({circular:e,comparator:t,createState:n,equals:r,strict:i}){if(n)return function(a,o){let{cache:s=e?new WeakMap:void 0,meta:c}=n();return t(a,o,{cache:s,equals:r,meta:c,strict:i})};if(e)return function(e,n){return t(e,n,{cache:new WeakMap,equals:r,meta:void 0,strict:i})};let a={cache:void 0,equals:r,meta:void 0,strict:i};return function(e,n){return t(e,n,a)}}var QK=$K();$K({strict:!0}),$K({circular:!0}),$K({circular:!0,strict:!0}),$K({createInternalComparator:()=>dK}),$K({strict:!0,createInternalComparator:()=>dK}),$K({circular:!0,createInternalComparator:()=>dK}),$K({circular:!0,createInternalComparator:()=>dK,strict:!0});function $K(e={}){let{circular:t=!1,createInternalComparator:n,createState:r,strict:i=!1}=e,a=JK(YK(e));return ZK({circular:t,comparator:a,createState:r,equals:n?n(a):XK(a),strict:i})}var eq=Fn(),tq=(...e)=>t=>{e.forEach(e=>{typeof e==`function`?e(t):e&&(e.current=t)})},nq=({contentComponent:e})=>{let t=(0,gN.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getServerSnapshot);return(0,z.jsx)(z.Fragment,{children:Object.values(t)})};function rq(){let e=new Set,t={},n=!1,r=()=>{n||!e.size||(n=!0,queueMicrotask(()=>{n=!1,e.forEach(e=>e())}))};return{subscribe(t){return e.add(t),()=>{e.delete(t)}},getSnapshot(){return t},getServerSnapshot(){return t},setRenderer(e,n){t={...t,[e]:qa.createPortal(n.reactElement,n.element,e)},r()},removeRenderer(e){let n={...t};delete n[e],t=n,r()}}}var iq=class extends R.Component{constructor(e){super(e),this.editorContentRef=R.createRef()}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){let e=this.props.editor;if(e&&!e.isDestroyed&&e.view.dom?.parentNode){if(e.contentComponent)return;let t=this.editorContentRef.current;t.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:t}),e.contentComponent=rq(),e.createNodeViews(),e.isEditorContentInitialized=!0,this.forceUpdate()}}componentWillUnmount(){let e=this.props.editor;if(e){e.isEditorContentInitialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),e.contentComponent=null;try{if(!e.view.dom?.parentNode)return;let t=document.createElement(`div`);t.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:t})}catch{}}}render(){let{editor:e,innerRef:t,...n}=this.props;return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{ref:tq(t,this.editorContentRef),...n}),e?.contentComponent&&(0,z.jsx)(nq,{contentComponent:e.contentComponent})]})}},aq=(0,R.forwardRef)((e,t)=>{let n=R.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[e.editor]);return R.createElement(iq,{key:n,innerRef:t,...e})}),oq=R.memo(aq),sq=typeof window<`u`?R.useLayoutEffect:R.useEffect,cq=class{constructor(e){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=e,this.lastSnapshot={editor:e,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}watch(e){if(this.editor=e,this.editor){let e,t=t=>{t?.transaction!==void 0&&t.transaction===e||(e=t?.transaction,this.transactionNumber+=1,this.subscribers.forEach(e=>e()))},n=this.editor;return n.on(`transaction`,t),n.on(`update`,t),()=>{n.off(`transaction`,t),n.off(`update`,t)}}}};function lq(e){let[t]=(0,R.useState)(()=>new cq(e.editor)),n=(0,eq.useSyncExternalStoreWithSelector)(t.subscribe,t.getSnapshot,t.getServerSnapshot,e.selector,e.equalityFn??QK);return sq(()=>t.watch(e.editor),[e.editor,t]),(0,R.useDebugValue)(n),n}var uq=typeof window>`u`,dq=uq||!!(typeof window<`u`&&window.next),fq=class e{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId=``,this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(e=>e())}getInitialEditor(){let e=this.options.current.immediatelyRender,t=e??!0;return(uq||dq&&e===void 0)&&(t=!1),t?this.createEditor():null}createEditor(){return new XG({...this.options.current,onBeforeCreate:(...e)=>{var t;return(t=this.options.current).onBeforeCreate?.call(t,...e)},onBlur:(...e)=>{var t;return(t=this.options.current).onBlur?.call(t,...e)},onCreate:(...e)=>{var t;return(t=this.options.current).onCreate?.call(t,...e)},onDestroy:(...e)=>{var t;return(t=this.options.current).onDestroy?.call(t,...e)},onFocus:(...e)=>{var t;return(t=this.options.current).onFocus?.call(t,...e)},onSelectionUpdate:(...e)=>{var t;return(t=this.options.current).onSelectionUpdate?.call(t,...e)},onTransaction:(...e)=>{var t;return(t=this.options.current).onTransaction?.call(t,...e)},onUpdate:(...e)=>{var t;return(t=this.options.current).onUpdate?.call(t,...e)},onContentError:(...e)=>{var t;return(t=this.options.current).onContentError?.call(t,...e)},onDrop:(...e)=>{var t;return(t=this.options.current).onDrop?.call(t,...e)},onPaste:(...e)=>{var t;return(t=this.options.current).onPaste?.call(t,...e)},onDelete:(...e)=>{var t;return(t=this.options.current).onDelete?.call(t,...e)},onMount:(...e)=>{var t;return(t=this.options.current).onMount?.call(t,...e)},onUnmount:(...e)=>{var t;return(t=this.options.current).onUnmount?.call(t,...e)}})}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,t){return Object.keys(e).every(n=>[`onCreate`,`onBeforeCreate`,`onDestroy`,`onUpdate`,`onTransaction`,`onFocus`,`onBlur`,`onSelectionUpdate`,`onContentError`,`onDrop`,`onPaste`].includes(n)?!0:n===`extensions`&&e.extensions&&t.extensions?e.extensions.length===t.extensions.length&&e.extensions.every((e,n)=>e===t.extensions?.[n]):e[n]===t[n])}onRender(t){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&t.length===0?e.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(t),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=e;return}if(this.previousDeps.length===e.length&&this.previousDeps.every((t,n)=>t===e[n]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){let e=this.instanceId,t=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){t&&t.setOptions(this.options.current);return}t&&!t.isDestroyed&&(t.destroy(),this.instanceId===e&&this.setEditor(null))},1)}};function pq(e={},t=[]){let n=(0,R.useRef)(e);n.current=e;let[r]=(0,R.useState)(()=>new fq(n)),i=(0,gN.useSyncExternalStore)(r.subscribe,r.getEditor,r.getServerSnapshot);return(0,R.useDebugValue)(i),(0,R.useEffect)(r.onRender(t)),lq({editor:i,selector:({transactionNumber:t})=>e.shouldRerenderOnTransaction===!1||e.shouldRerenderOnTransaction===void 0?null:e.immediatelyRender&&t===0?0:t+1}),i}var mq=(0,R.createContext)({editor:null});mq.Consumer;var hq=(0,R.createContext)({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),gq=()=>(0,R.useContext)(hq);R.forwardRef((e,t)=>{let{onDragStart:n}=gq();return(0,z.jsx)(e.as||`div`,{...e,ref:t,"data-node-view-wrapper":``,onDragStart:n,style:{whiteSpace:`normal`,...e.style}})}),R.createContext({markViewContentRef:()=>{}});var _q=(0,R.createContext)({get editor(){throw Error(`useTiptap must be used within a <Tiptap> provider`)}});_q.displayName=`TiptapContext`;var vq=()=>(0,R.useContext)(_q);function yq({children:e,...t}){let n=`editor`in t?t.editor:t.instance;if(!n)throw Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");let r=(0,R.useMemo)(()=>({editor:n}),[n]),i=(0,R.useMemo)(()=>({editor:n}),[n]);return(0,z.jsx)(mq.Provider,{value:i,children:(0,z.jsx)(_q.Provider,{value:r,children:e})})}yq.displayName=`Tiptap`;function bq({...e}){let{editor:t}=vq();return(0,z.jsx)(oq,{editor:t,...e})}bq.displayName=`Tiptap.Content`,Object.assign(yq,{Content:bq});var xq=`aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2`,Sq=`ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2`,Cq=`numeric`,wq=`ascii`,Tq=`alpha`,Eq=`asciinumeric`,Dq=`alphanumeric`,Oq=`domain`,kq=`emoji`,Aq=`scheme`,jq=`slashscheme`,Mq=`whitespace`;function Nq(e,t){return e in t||(t[e]=[]),t[e]}function Pq(e,t,n){t[Cq]&&(t[Eq]=!0,t[Dq]=!0),t[wq]&&(t[Eq]=!0,t[Tq]=!0),t[Eq]&&(t[Dq]=!0),t[Tq]&&(t[Dq]=!0),t[Dq]&&(t[Oq]=!0),t[kq]&&(t[Oq]=!0);for(let r in t){let t=Nq(r,n);t.indexOf(e)<0&&t.push(e)}}function Fq(e,t){let n={};for(let r in t)t[r].indexOf(e)>=0&&(n[r]=!0);return n}function Iq(e=null){this.j={},this.jr=[],this.jd=null,this.t=e}Iq.groups={},Iq.prototype={accepts(){return!!this.t},go(e){let t=this,n=t.j[e];if(n)return n;for(let n=0;n<t.jr.length;n++){let r=t.jr[n][0],i=t.jr[n][1];if(i&&r.test(e))return i}return t.jd},has(e,t=!1){return t?e in this.j:!!this.go(e)},ta(e,t,n,r){for(let i=0;i<e.length;i++)this.tt(e[i],t,n,r)},tr(e,t,n,r){r||=Iq.groups;let i;return t&&t.j?i=t:(i=new Iq(t),n&&r&&Pq(t,n,r)),this.jr.push([e,i]),i},ts(e,t,n,r){let i=this,a=e.length;if(!a)return i;for(let t=0;t<a-1;t++)i=i.tt(e[t]);return i.tt(e[a-1],t,n,r)},tt(e,t,n,r){r||=Iq.groups;let i=this;if(t&&t.j)return i.j[e]=t,t;let a=t,o,s=i.go(e);return s?(o=new Iq,Object.assign(o.j,s.j),o.jr.push.apply(o.jr,s.jr),o.jd=s.jd,o.t=s.t):o=new Iq,a&&(r&&(o.t&&typeof o.t==`string`?Pq(a,Object.assign(Fq(o.t,r),n),r):n&&Pq(a,n,r)),o.t=a),i.j[e]=o,o}};var Q=(e,t,n,r,i)=>e.ta(t,n,r,i),Lq=(e,t,n,r,i)=>e.tr(t,n,r,i),Rq=(e,t,n,r,i)=>e.ts(t,n,r,i),$=(e,t,n,r,i)=>e.tt(t,n,r,i),zq=`WORD`,Bq=`UWORD`,Vq=`ASCIINUMERICAL`,Hq=`ALPHANUMERICAL`,Uq=`LOCALHOST`,Wq=`TLD`,Gq=`UTLD`,Kq=`SCHEME`,qq=`SLASH_SCHEME`,Jq=`NUM`,Yq=`WS`,Xq=`NL`,Zq=`OPENBRACE`,Qq=`CLOSEBRACE`,$q=`OPENBRACKET`,eJ=`CLOSEBRACKET`,tJ=`OPENPAREN`,nJ=`CLOSEPAREN`,rJ=`OPENANGLEBRACKET`,iJ=`CLOSEANGLEBRACKET`,aJ=`FULLWIDTHLEFTPAREN`,oJ=`FULLWIDTHRIGHTPAREN`,sJ=`LEFTCORNERBRACKET`,cJ=`RIGHTCORNERBRACKET`,lJ=`LEFTWHITECORNERBRACKET`,uJ=`RIGHTWHITECORNERBRACKET`,dJ=`FULLWIDTHLESSTHAN`,fJ=`FULLWIDTHGREATERTHAN`,pJ=`AMPERSAND`,mJ=`APOSTROPHE`,hJ=`ASTERISK`,gJ=`AT`,_J=`BACKSLASH`,vJ=`BACKTICK`,yJ=`CARET`,bJ=`COLON`,xJ=`COMMA`,SJ=`DOLLAR`,CJ=`DOT`,wJ=`EQUALS`,TJ=`EXCLAMATION`,EJ=`HYPHEN`,DJ=`PERCENT`,OJ=`PIPE`,kJ=`PLUS`,AJ=`POUND`,jJ=`QUERY`,MJ=`QUOTE`,NJ=`FULLWIDTHMIDDLEDOT`,PJ=`SEMI`,FJ=`SLASH`,IJ=`TILDE`,LJ=`UNDERSCORE`,RJ=`EMOJI`,zJ=`SYM`,BJ=Object.freeze({__proto__:null,ALPHANUMERICAL:Hq,AMPERSAND:pJ,APOSTROPHE:mJ,ASCIINUMERICAL:Vq,ASTERISK:hJ,AT:gJ,BACKSLASH:_J,BACKTICK:vJ,CARET:yJ,CLOSEANGLEBRACKET:iJ,CLOSEBRACE:Qq,CLOSEBRACKET:eJ,CLOSEPAREN:nJ,COLON:bJ,COMMA:xJ,DOLLAR:SJ,DOT:CJ,EMOJI:RJ,EQUALS:wJ,EXCLAMATION:TJ,FULLWIDTHGREATERTHAN:fJ,FULLWIDTHLEFTPAREN:aJ,FULLWIDTHLESSTHAN:dJ,FULLWIDTHMIDDLEDOT:NJ,FULLWIDTHRIGHTPAREN:oJ,HYPHEN:EJ,LEFTCORNERBRACKET:sJ,LEFTWHITECORNERBRACKET:lJ,LOCALHOST:Uq,NL:Xq,NUM:Jq,OPENANGLEBRACKET:rJ,OPENBRACE:Zq,OPENBRACKET:$q,OPENPAREN:tJ,PERCENT:DJ,PIPE:OJ,PLUS:kJ,POUND:AJ,QUERY:jJ,QUOTE:MJ,RIGHTCORNERBRACKET:cJ,RIGHTWHITECORNERBRACKET:uJ,SCHEME:Kq,SEMI:PJ,SLASH:FJ,SLASH_SCHEME:qq,SYM:zJ,TILDE:IJ,TLD:Wq,UNDERSCORE:LJ,UTLD:Gq,UWORD:Bq,WORD:zq,WS:Yq}),VJ=/[a-z]/,HJ=/\p{L}/u,UJ=/\p{Emoji}/u,WJ=/\d/,GJ=/\s/,KJ=`\r`,qJ=`
|
|
273
|
+
`,textSerializers:n={}}=e||{};return HU(this.state.doc,{blockSeparator:t,textSerializers:{...UU(this.schema),...n}})}get isEmpty(){return sW(this.state.doc)}destroy(){this.destroyed||(this.destroyed=!0,this.emit(`destroy`),this.unmount(),this.removeAllListeners(),this.extensionManager.destroy(),this.extensionManager=null,this.schema=null,this.commandManager=null,this.extensionStorage={})}get isDestroyed(){return this.editorView?.isDestroyed??!0}$node(e,t){return this.$doc?.querySelector(e,t)||null}$nodes(e,t){return this.$doc?.querySelectorAll(e,t)||null}$pos(e){let t=this.state.doc.resolve(e),n=e>0&&t.nodeAfter&&!t.nodeAfter.isText&&t.nodeAfter.isAtom?t.nodeAfter:null;return new JG(t,this,!1,n)}get $doc(){return this.$pos(0)}};function ZG(e){return new xG({find:e.find,handler:({state:t,range:n,match:r})=>{let i=TU(e.getAttributes,void 0,r);if(i===!1||i===null)return null;let{tr:a}=t,o=r[r.length-1],s=r[0];if(o){let r=s.search(/\S/),c=n.from+s.indexOf(o),l=c+o.length;if(YU(n.from,n.to,t.doc).filter(t=>t.mark.type.excluded.find(n=>n===e.type&&n!==t.mark.type)).filter(e=>e.to>c).length)return null;l<n.to&&a.delete(l,n.to),c>n.from&&a.delete(n.from+r,c);let u=n.from+r+o.length;a.addMark(n.from+r,u,e.type.create(i||{})),a.removeStoredMark(e.type)}},undoable:e.undoable})}function QG(e){return new xG({find:e.find,handler:({state:t,range:n,match:r})=>{let i=TU(e.getAttributes,void 0,r)||{},{tr:a}=t,o=n.from,s=n.to,c=e.type.create(i);if(r[1]){let e=o+r[0].lastIndexOf(r[1]);e>s?e=s:s=e+r[1].length;let t=r[0][r[0].length-1];a.insertText(t,o+r[0].length-1),a.replaceWith(e,s,c)}else if(r[0]){let t=e.type.isInline?o:o-1;a.insert(t,e.type.create(i)).delete(a.mapping.map(o),a.mapping.map(s))}a.scrollIntoView()},undoable:e.undoable})}function $G(e){return new xG({find:e.find,handler:({state:t,range:n,match:r})=>{let i=t.doc.resolve(n.from),a=TU(e.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),e.type))return null;t.tr.delete(n.from,n.to).setBlockType(n.from,n.from,e.type,a)},undoable:e.undoable})}function eK(e){return new xG({find:e.find,handler:({state:t,range:n,match:r,chain:i})=>{let a=TU(e.getAttributes,void 0,r)||{},o=t.tr.delete(n.from,n.to),s=o.doc.resolve(n.from).blockRange(),c=s&&vF(s,e.type,a);if(!c)return null;if(o.wrap(s,c),e.keepMarks&&e.editor){let{selection:n,storedMarks:r}=t,{splittableMarks:i}=e.editor.extensionManager,a=r||n.$to.parentOffset&&n.$from.marks();if(a){let e=a.filter(e=>i.includes(e.type.name));o.ensureMarks(e)}}if(e.keepAttributes){let t=e.type.name===`bulletList`||e.type.name===`orderedList`?`listItem`:`taskList`;i().updateAttributes(t,a).run()}let l=o.doc.resolve(n.from-1).nodeBefore;l&&l.type===e.type&&AF(o.doc,n.from-1)&&(!e.joinPredicate||e.joinPredicate(r,l))&&o.join(n.from-1)},undoable:e.undoable})}var tK=class e extends TG{constructor(...e){super(...e),this.type=`node`}static create(t={}){let n=typeof t==`function`?t():t;return new e(n)}configure(e){return super.configure(e)}extend(e){let t=typeof e==`function`?e():e;return super.extend(t)}};function nK(e){return new DG({find:e.find,handler:({state:t,range:n,match:r,pasteEvent:i})=>{let a=TU(e.getAttributes,void 0,r,i);if(a===!1||a===null)return null;let{tr:o}=t,s=r[r.length-1],c=r[0],l=n.to;if(s){let i=c.search(/\S/),u=n.from+c.indexOf(s),d=u+s.length;if(YU(n.from,n.to,t.doc).filter(t=>t.mark.type.excluded.find(n=>n===e.type&&n!==t.mark.type)).filter(e=>e.to>u).length)return null;d<n.to&&o.delete(d,n.to),u>n.from&&o.delete(n.from+i,u),l=n.from+i+s.length,o.addMark(n.from+i,l,e.type.create(a||{})),r.index!==void 0&&r.input!==void 0&&r.index+r[0].length>=r.input.length||o.removeStoredMark(e.type)}}})}var{getOwnPropertyNames:rK,getOwnPropertySymbols:iK}=Object,{hasOwnProperty:aK}=Object.prototype;function oK(e,t){return function(n,r,i){return e(n,r,i)&&t(n,r,i)}}function sK(e){return function(t,n,r){if(!t||!n||typeof t!=`object`||typeof n!=`object`)return e(t,n,r);let{cache:i}=r,a=i.get(t),o=i.get(n);if(a&&o)return a===n&&o===t;i.set(t,n),i.set(n,t);let s=e(t,n,r);return i.delete(t),i.delete(n),s}}function cK(e){return e?.[Symbol.toStringTag]}function lK(e){return rK(e).concat(iK(e))}var uK=Object.hasOwn||((e,t)=>aK.call(e,t));function dK(e,t){return e===t||!e&&!t&&e!==e&&t!==t}var fK=`__v`,pK=`__o`,mK=`_owner`,{getOwnPropertyDescriptor:hK,keys:gK}=Object;function _K(e,t){return e.byteLength===t.byteLength&&AK(new Uint8Array(e),new Uint8Array(t))}function vK(e,t,n){let r=e.length;if(t.length!==r)return!1;for(;r-->0;)if(!n.equals(e[r],t[r],r,r,e,t,n))return!1;return!0}function yK(e,t){return e.byteLength===t.byteLength&&AK(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}function bK(e,t){return dK(e.getTime(),t.getTime())}function xK(e,t){return e.name===t.name&&e.message===t.message&&e.cause===t.cause&&e.stack===t.stack}function SK(e,t){return e===t}function CK(e,t,n){let r=e.size;if(r!==t.size)return!1;if(!r)return!0;let i=Array(r),a=e.entries(),o,s,c=0;for(;(o=a.next())&&!o.done;){let r=t.entries(),a=!1,l=0;for(;(s=r.next())&&!s.done;){if(i[l]){l++;continue}let r=o.value,u=s.value;if(n.equals(r[0],u[0],c,l,e,t,n)&&n.equals(r[1],u[1],r[0],u[0],e,t,n)){a=i[l]=!0;break}l++}if(!a)return!1;c++}return!0}var wK=dK;function TK(e,t,n){let r=gK(e),i=r.length;if(gK(t).length!==i)return!1;for(;i-->0;)if(!MK(e,t,n,r[i]))return!1;return!0}function EK(e,t,n){let r=lK(e),i=r.length;if(lK(t).length!==i)return!1;let a,o,s;for(;i-->0;)if(a=r[i],!MK(e,t,n,a)||(o=hK(e,a),s=hK(t,a),(o||s)&&(!o||!s||o.configurable!==s.configurable||o.enumerable!==s.enumerable||o.writable!==s.writable)))return!1;return!0}function DK(e,t){return dK(e.valueOf(),t.valueOf())}function OK(e,t){return e.source===t.source&&e.flags===t.flags}function kK(e,t,n){let r=e.size;if(r!==t.size)return!1;if(!r)return!0;let i=Array(r),a=e.values(),o,s;for(;(o=a.next())&&!o.done;){let r=t.values(),a=!1,c=0;for(;(s=r.next())&&!s.done;){if(!i[c]&&n.equals(o.value,s.value,o.value,s.value,e,t,n)){a=i[c]=!0;break}c++}if(!a)return!1}return!0}function AK(e,t){let n=e.byteLength;if(t.byteLength!==n||e.byteOffset!==t.byteOffset)return!1;for(;n-->0;)if(e[n]!==t[n])return!1;return!0}function jK(e,t){return e.hostname===t.hostname&&e.pathname===t.pathname&&e.protocol===t.protocol&&e.port===t.port&&e.hash===t.hash&&e.username===t.username&&e.password===t.password}function MK(e,t,n,r){return(r===mK||r===pK||r===fK)&&(e.$$typeof||t.$$typeof)?!0:uK(t,r)&&n.equals(e[r],t[r],r,r,e,t,n)}var NK=`[object ArrayBuffer]`,PK=`[object Arguments]`,FK=`[object Boolean]`,IK=`[object DataView]`,LK=`[object Date]`,RK=`[object Error]`,zK=`[object Map]`,BK=`[object Number]`,VK=`[object Object]`,HK=`[object RegExp]`,UK=`[object Set]`,WK=`[object String]`,GK={"[object Int8Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Int16Array]":!0,"[object Uint16Array]":!0,"[object Int32Array]":!0,"[object Uint32Array]":!0,"[object Float16Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0,"[object BigInt64Array]":!0,"[object BigUint64Array]":!0},KK=`[object URL]`,qK=Object.prototype.toString;function JK({areArrayBuffersEqual:e,areArraysEqual:t,areDataViewsEqual:n,areDatesEqual:r,areErrorsEqual:i,areFunctionsEqual:a,areMapsEqual:o,areNumbersEqual:s,areObjectsEqual:c,arePrimitiveWrappersEqual:l,areRegExpsEqual:u,areSetsEqual:d,areTypedArraysEqual:f,areUrlsEqual:p,unknownTagComparators:m}){return function(h,g,_){if(h===g)return!0;if(h==null||g==null)return!1;let v=typeof h;if(v!==typeof g)return!1;if(v!==`object`)return v===`number`?s(h,g,_):v===`function`&&a(h,g,_);let y=h.constructor;if(y!==g.constructor)return!1;if(y===Object)return c(h,g,_);if(Array.isArray(h))return t(h,g,_);if(y===Date)return r(h,g,_);if(y===RegExp)return u(h,g,_);if(y===Map)return o(h,g,_);if(y===Set)return d(h,g,_);let b=qK.call(h);if(b===LK)return r(h,g,_);if(b===HK)return u(h,g,_);if(b===zK)return o(h,g,_);if(b===UK)return d(h,g,_);if(b===VK)return typeof h.then!=`function`&&typeof g.then!=`function`&&c(h,g,_);if(b===KK)return p(h,g,_);if(b===RK)return i(h,g,_);if(b===PK)return c(h,g,_);if(GK[b])return f(h,g,_);if(b===NK)return e(h,g,_);if(b===IK)return n(h,g,_);if(b===FK||b===BK||b===WK)return l(h,g,_);if(m){let e=m[b];if(!e){let t=cK(h);t&&(e=m[t])}if(e)return e(h,g,_)}return!1}}function YK({circular:e,createCustomConfig:t,strict:n}){let r={areArrayBuffersEqual:_K,areArraysEqual:n?EK:vK,areDataViewsEqual:yK,areDatesEqual:bK,areErrorsEqual:xK,areFunctionsEqual:SK,areMapsEqual:n?oK(CK,EK):CK,areNumbersEqual:wK,areObjectsEqual:n?EK:TK,arePrimitiveWrappersEqual:DK,areRegExpsEqual:OK,areSetsEqual:n?oK(kK,EK):kK,areTypedArraysEqual:n?oK(AK,EK):AK,areUrlsEqual:jK,unknownTagComparators:void 0};if(t&&(r=Object.assign({},r,t(r))),e){let e=sK(r.areArraysEqual),t=sK(r.areMapsEqual),n=sK(r.areObjectsEqual),i=sK(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:e,areMapsEqual:t,areObjectsEqual:n,areSetsEqual:i})}return r}function XK(e){return function(t,n,r,i,a,o,s){return e(t,n,s)}}function ZK({circular:e,comparator:t,createState:n,equals:r,strict:i}){if(n)return function(a,o){let{cache:s=e?new WeakMap:void 0,meta:c}=n();return t(a,o,{cache:s,equals:r,meta:c,strict:i})};if(e)return function(e,n){return t(e,n,{cache:new WeakMap,equals:r,meta:void 0,strict:i})};let a={cache:void 0,equals:r,meta:void 0,strict:i};return function(e,n){return t(e,n,a)}}var QK=$K();$K({strict:!0}),$K({circular:!0}),$K({circular:!0,strict:!0}),$K({createInternalComparator:()=>dK}),$K({strict:!0,createInternalComparator:()=>dK}),$K({circular:!0,createInternalComparator:()=>dK}),$K({circular:!0,createInternalComparator:()=>dK,strict:!0});function $K(e={}){let{circular:t=!1,createInternalComparator:n,createState:r,strict:i=!1}=e,a=JK(YK(e));return ZK({circular:t,comparator:a,createState:r,equals:n?n(a):XK(a),strict:i})}var eq=Fn(),tq=(...e)=>t=>{e.forEach(e=>{typeof e==`function`?e(t):e&&(e.current=t)})},nq=({contentComponent:e})=>{let t=(0,gN.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getServerSnapshot);return(0,z.jsx)(z.Fragment,{children:Object.values(t)})};function rq(){let e=new Set,t={},n=!1,r=()=>{n||!e.size||(n=!0,queueMicrotask(()=>{n=!1,e.forEach(e=>e())}))};return{subscribe(t){return e.add(t),()=>{e.delete(t)}},getSnapshot(){return t},getServerSnapshot(){return t},setRenderer(e,n){t={...t,[e]:Ja.createPortal(n.reactElement,n.element,e)},r()},removeRenderer(e){let n={...t};delete n[e],t=n,r()}}}var iq=class extends R.Component{constructor(e){super(e),this.editorContentRef=R.createRef()}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){let e=this.props.editor;if(e&&!e.isDestroyed&&e.view.dom?.parentNode){if(e.contentComponent)return;let t=this.editorContentRef.current;t.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:t}),e.contentComponent=rq(),e.createNodeViews(),e.isEditorContentInitialized=!0,this.forceUpdate()}}componentWillUnmount(){let e=this.props.editor;if(e){e.isEditorContentInitialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),e.contentComponent=null;try{if(!e.view.dom?.parentNode)return;let t=document.createElement(`div`);t.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:t})}catch{}}}render(){let{editor:e,innerRef:t,...n}=this.props;return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{ref:tq(t,this.editorContentRef),...n}),e?.contentComponent&&(0,z.jsx)(nq,{contentComponent:e.contentComponent})]})}},aq=(0,R.forwardRef)((e,t)=>{let n=R.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[e.editor]);return R.createElement(iq,{key:n,innerRef:t,...e})}),oq=R.memo(aq),sq=typeof window<`u`?R.useLayoutEffect:R.useEffect,cq=class{constructor(e){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=e,this.lastSnapshot={editor:e,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}watch(e){if(this.editor=e,this.editor){let e,t=t=>{t?.transaction!==void 0&&t.transaction===e||(e=t?.transaction,this.transactionNumber+=1,this.subscribers.forEach(e=>e()))},n=this.editor;return n.on(`transaction`,t),n.on(`update`,t),()=>{n.off(`transaction`,t),n.off(`update`,t)}}}};function lq(e){let[t]=(0,R.useState)(()=>new cq(e.editor)),n=(0,eq.useSyncExternalStoreWithSelector)(t.subscribe,t.getSnapshot,t.getServerSnapshot,e.selector,e.equalityFn??QK);return sq(()=>t.watch(e.editor),[e.editor,t]),(0,R.useDebugValue)(n),n}var uq=typeof window>`u`,dq=uq||!!(typeof window<`u`&&window.next),fq=class e{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId=``,this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(e=>e())}getInitialEditor(){let e=this.options.current.immediatelyRender,t=e??!0;return(uq||dq&&e===void 0)&&(t=!1),t?this.createEditor():null}createEditor(){return new XG({...this.options.current,onBeforeCreate:(...e)=>{var t;return(t=this.options.current).onBeforeCreate?.call(t,...e)},onBlur:(...e)=>{var t;return(t=this.options.current).onBlur?.call(t,...e)},onCreate:(...e)=>{var t;return(t=this.options.current).onCreate?.call(t,...e)},onDestroy:(...e)=>{var t;return(t=this.options.current).onDestroy?.call(t,...e)},onFocus:(...e)=>{var t;return(t=this.options.current).onFocus?.call(t,...e)},onSelectionUpdate:(...e)=>{var t;return(t=this.options.current).onSelectionUpdate?.call(t,...e)},onTransaction:(...e)=>{var t;return(t=this.options.current).onTransaction?.call(t,...e)},onUpdate:(...e)=>{var t;return(t=this.options.current).onUpdate?.call(t,...e)},onContentError:(...e)=>{var t;return(t=this.options.current).onContentError?.call(t,...e)},onDrop:(...e)=>{var t;return(t=this.options.current).onDrop?.call(t,...e)},onPaste:(...e)=>{var t;return(t=this.options.current).onPaste?.call(t,...e)},onDelete:(...e)=>{var t;return(t=this.options.current).onDelete?.call(t,...e)},onMount:(...e)=>{var t;return(t=this.options.current).onMount?.call(t,...e)},onUnmount:(...e)=>{var t;return(t=this.options.current).onUnmount?.call(t,...e)}})}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,t){return Object.keys(e).every(n=>[`onCreate`,`onBeforeCreate`,`onDestroy`,`onUpdate`,`onTransaction`,`onFocus`,`onBlur`,`onSelectionUpdate`,`onContentError`,`onDrop`,`onPaste`].includes(n)?!0:n===`extensions`&&e.extensions&&t.extensions?e.extensions.length===t.extensions.length&&e.extensions.every((e,n)=>e===t.extensions?.[n]):e[n]===t[n])}onRender(t){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&t.length===0?e.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(t),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=e;return}if(this.previousDeps.length===e.length&&this.previousDeps.every((t,n)=>t===e[n]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){let e=this.instanceId,t=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){t&&t.setOptions(this.options.current);return}t&&!t.isDestroyed&&(t.destroy(),this.instanceId===e&&this.setEditor(null))},1)}};function pq(e={},t=[]){let n=(0,R.useRef)(e);n.current=e;let[r]=(0,R.useState)(()=>new fq(n)),i=(0,gN.useSyncExternalStore)(r.subscribe,r.getEditor,r.getServerSnapshot);return(0,R.useDebugValue)(i),(0,R.useEffect)(r.onRender(t)),lq({editor:i,selector:({transactionNumber:t})=>e.shouldRerenderOnTransaction===!1||e.shouldRerenderOnTransaction===void 0?null:e.immediatelyRender&&t===0?0:t+1}),i}var mq=(0,R.createContext)({editor:null});mq.Consumer;var hq=(0,R.createContext)({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),gq=()=>(0,R.useContext)(hq);R.forwardRef((e,t)=>{let{onDragStart:n}=gq();return(0,z.jsx)(e.as||`div`,{...e,ref:t,"data-node-view-wrapper":``,onDragStart:n,style:{whiteSpace:`normal`,...e.style}})}),R.createContext({markViewContentRef:()=>{}});var _q=(0,R.createContext)({get editor(){throw Error(`useTiptap must be used within a <Tiptap> provider`)}});_q.displayName=`TiptapContext`;var vq=()=>(0,R.useContext)(_q);function yq({children:e,...t}){let n=`editor`in t?t.editor:t.instance;if(!n)throw Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");let r=(0,R.useMemo)(()=>({editor:n}),[n]),i=(0,R.useMemo)(()=>({editor:n}),[n]);return(0,z.jsx)(mq.Provider,{value:i,children:(0,z.jsx)(_q.Provider,{value:r,children:e})})}yq.displayName=`Tiptap`;function bq({...e}){let{editor:t}=vq();return(0,z.jsx)(oq,{editor:t,...e})}bq.displayName=`Tiptap.Content`,Object.assign(yq,{Content:bq});var xq=`aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2`,Sq=`ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2`,Cq=`numeric`,wq=`ascii`,Tq=`alpha`,Eq=`asciinumeric`,Dq=`alphanumeric`,Oq=`domain`,kq=`emoji`,Aq=`scheme`,jq=`slashscheme`,Mq=`whitespace`;function Nq(e,t){return e in t||(t[e]=[]),t[e]}function Pq(e,t,n){t[Cq]&&(t[Eq]=!0,t[Dq]=!0),t[wq]&&(t[Eq]=!0,t[Tq]=!0),t[Eq]&&(t[Dq]=!0),t[Tq]&&(t[Dq]=!0),t[Dq]&&(t[Oq]=!0),t[kq]&&(t[Oq]=!0);for(let r in t){let t=Nq(r,n);t.indexOf(e)<0&&t.push(e)}}function Fq(e,t){let n={};for(let r in t)t[r].indexOf(e)>=0&&(n[r]=!0);return n}function Iq(e=null){this.j={},this.jr=[],this.jd=null,this.t=e}Iq.groups={},Iq.prototype={accepts(){return!!this.t},go(e){let t=this,n=t.j[e];if(n)return n;for(let n=0;n<t.jr.length;n++){let r=t.jr[n][0],i=t.jr[n][1];if(i&&r.test(e))return i}return t.jd},has(e,t=!1){return t?e in this.j:!!this.go(e)},ta(e,t,n,r){for(let i=0;i<e.length;i++)this.tt(e[i],t,n,r)},tr(e,t,n,r){r||=Iq.groups;let i;return t&&t.j?i=t:(i=new Iq(t),n&&r&&Pq(t,n,r)),this.jr.push([e,i]),i},ts(e,t,n,r){let i=this,a=e.length;if(!a)return i;for(let t=0;t<a-1;t++)i=i.tt(e[t]);return i.tt(e[a-1],t,n,r)},tt(e,t,n,r){r||=Iq.groups;let i=this;if(t&&t.j)return i.j[e]=t,t;let a=t,o,s=i.go(e);return s?(o=new Iq,Object.assign(o.j,s.j),o.jr.push.apply(o.jr,s.jr),o.jd=s.jd,o.t=s.t):o=new Iq,a&&(r&&(o.t&&typeof o.t==`string`?Pq(a,Object.assign(Fq(o.t,r),n),r):n&&Pq(a,n,r)),o.t=a),i.j[e]=o,o}};var Q=(e,t,n,r,i)=>e.ta(t,n,r,i),Lq=(e,t,n,r,i)=>e.tr(t,n,r,i),Rq=(e,t,n,r,i)=>e.ts(t,n,r,i),$=(e,t,n,r,i)=>e.tt(t,n,r,i),zq=`WORD`,Bq=`UWORD`,Vq=`ASCIINUMERICAL`,Hq=`ALPHANUMERICAL`,Uq=`LOCALHOST`,Wq=`TLD`,Gq=`UTLD`,Kq=`SCHEME`,qq=`SLASH_SCHEME`,Jq=`NUM`,Yq=`WS`,Xq=`NL`,Zq=`OPENBRACE`,Qq=`CLOSEBRACE`,$q=`OPENBRACKET`,eJ=`CLOSEBRACKET`,tJ=`OPENPAREN`,nJ=`CLOSEPAREN`,rJ=`OPENANGLEBRACKET`,iJ=`CLOSEANGLEBRACKET`,aJ=`FULLWIDTHLEFTPAREN`,oJ=`FULLWIDTHRIGHTPAREN`,sJ=`LEFTCORNERBRACKET`,cJ=`RIGHTCORNERBRACKET`,lJ=`LEFTWHITECORNERBRACKET`,uJ=`RIGHTWHITECORNERBRACKET`,dJ=`FULLWIDTHLESSTHAN`,fJ=`FULLWIDTHGREATERTHAN`,pJ=`AMPERSAND`,mJ=`APOSTROPHE`,hJ=`ASTERISK`,gJ=`AT`,_J=`BACKSLASH`,vJ=`BACKTICK`,yJ=`CARET`,bJ=`COLON`,xJ=`COMMA`,SJ=`DOLLAR`,CJ=`DOT`,wJ=`EQUALS`,TJ=`EXCLAMATION`,EJ=`HYPHEN`,DJ=`PERCENT`,OJ=`PIPE`,kJ=`PLUS`,AJ=`POUND`,jJ=`QUERY`,MJ=`QUOTE`,NJ=`FULLWIDTHMIDDLEDOT`,PJ=`SEMI`,FJ=`SLASH`,IJ=`TILDE`,LJ=`UNDERSCORE`,RJ=`EMOJI`,zJ=`SYM`,BJ=Object.freeze({__proto__:null,ALPHANUMERICAL:Hq,AMPERSAND:pJ,APOSTROPHE:mJ,ASCIINUMERICAL:Vq,ASTERISK:hJ,AT:gJ,BACKSLASH:_J,BACKTICK:vJ,CARET:yJ,CLOSEANGLEBRACKET:iJ,CLOSEBRACE:Qq,CLOSEBRACKET:eJ,CLOSEPAREN:nJ,COLON:bJ,COMMA:xJ,DOLLAR:SJ,DOT:CJ,EMOJI:RJ,EQUALS:wJ,EXCLAMATION:TJ,FULLWIDTHGREATERTHAN:fJ,FULLWIDTHLEFTPAREN:aJ,FULLWIDTHLESSTHAN:dJ,FULLWIDTHMIDDLEDOT:NJ,FULLWIDTHRIGHTPAREN:oJ,HYPHEN:EJ,LEFTCORNERBRACKET:sJ,LEFTWHITECORNERBRACKET:lJ,LOCALHOST:Uq,NL:Xq,NUM:Jq,OPENANGLEBRACKET:rJ,OPENBRACE:Zq,OPENBRACKET:$q,OPENPAREN:tJ,PERCENT:DJ,PIPE:OJ,PLUS:kJ,POUND:AJ,QUERY:jJ,QUOTE:MJ,RIGHTCORNERBRACKET:cJ,RIGHTWHITECORNERBRACKET:uJ,SCHEME:Kq,SEMI:PJ,SLASH:FJ,SLASH_SCHEME:qq,SYM:zJ,TILDE:IJ,TLD:Wq,UNDERSCORE:LJ,UTLD:Gq,UWORD:Bq,WORD:zq,WS:Yq}),VJ=/[a-z]/,HJ=/\p{L}/u,UJ=/\p{Emoji}/u,WJ=/\d/,GJ=/\s/,KJ=`\r`,qJ=`
|
|
274
274
|
`,JJ=`️`,YJ=``,XJ=``,ZJ=null,QJ=null;function $J(e=[]){let t={};Iq.groups=t;let n=new Iq;ZJ??=rY(xq),QJ??=rY(Sq),$(n,`'`,mJ),$(n,`{`,Zq),$(n,`}`,Qq),$(n,`[`,$q),$(n,`]`,eJ),$(n,`(`,tJ),$(n,`)`,nJ),$(n,`<`,rJ),$(n,`>`,iJ),$(n,`(`,aJ),$(n,`)`,oJ),$(n,`「`,sJ),$(n,`」`,cJ),$(n,`『`,lJ),$(n,`』`,uJ),$(n,`<`,dJ),$(n,`>`,fJ),$(n,`&`,pJ),$(n,`*`,hJ),$(n,`@`,gJ),$(n,"`",vJ),$(n,`^`,yJ),$(n,`:`,bJ),$(n,`,`,xJ),$(n,`$`,SJ),$(n,`.`,CJ),$(n,`=`,wJ),$(n,`!`,TJ),$(n,`-`,EJ),$(n,`%`,DJ),$(n,`|`,OJ),$(n,`+`,kJ),$(n,`#`,AJ),$(n,`?`,jJ),$(n,`"`,MJ),$(n,`/`,FJ),$(n,`;`,PJ),$(n,`~`,IJ),$(n,`_`,LJ),$(n,`\\`,_J),$(n,`・`,NJ);let r=Lq(n,WJ,Jq,{[Cq]:!0});Lq(r,WJ,r);let i=Lq(r,VJ,Vq,{[Eq]:!0}),a=Lq(r,HJ,Hq,{[Dq]:!0}),o=Lq(n,VJ,zq,{[wq]:!0});Lq(o,WJ,i),Lq(o,VJ,o),Lq(i,WJ,i),Lq(i,VJ,i);let s=Lq(n,HJ,Bq,{[Tq]:!0});Lq(s,VJ),Lq(s,WJ,a),Lq(s,HJ,s),Lq(a,WJ,a),Lq(a,VJ),Lq(a,HJ,a);let c=$(n,qJ,Xq,{[Mq]:!0}),l=$(n,KJ,Yq,{[Mq]:!0}),u=Lq(n,GJ,Yq,{[Mq]:!0});$(n,XJ,u),$(l,qJ,c),$(l,XJ,u),Lq(l,GJ,u),$(u,KJ),$(u,qJ),Lq(u,GJ,u),$(u,XJ,u);let d=Lq(n,UJ,RJ,{[kq]:!0});$(d,`#`),Lq(d,UJ,d),$(d,JJ,d);let f=$(d,YJ);$(f,`#`),Lq(f,UJ,d);let p=[[VJ,o],[WJ,i]],m=[[VJ,null],[HJ,s],[WJ,a]];for(let e=0;e<ZJ.length;e++)nY(n,ZJ[e],Wq,zq,p);for(let e=0;e<QJ.length;e++)nY(n,QJ[e],Gq,Bq,m);Pq(Wq,{tld:!0,ascii:!0},t),Pq(Gq,{utld:!0,alpha:!0},t),nY(n,`file`,Kq,zq,p),nY(n,`mailto`,Kq,zq,p),nY(n,`http`,qq,zq,p),nY(n,`https`,qq,zq,p),nY(n,`ftp`,qq,zq,p),nY(n,`ftps`,qq,zq,p),Pq(Kq,{scheme:!0,ascii:!0},t),Pq(qq,{slashscheme:!0,ascii:!0},t),e=e.sort((e,t)=>e[0]>t[0]?1:-1);for(let t=0;t<e.length;t++){let r=e[t][0],i=e[t][1]?{[Aq]:!0}:{[jq]:!0};r.indexOf(`-`)>=0?i[Oq]=!0:VJ.test(r)?WJ.test(r)?i[Eq]=!0:i[wq]=!0:i[Cq]=!0,Rq(n,r,r,i)}return Rq(n,`localhost`,Uq,{ascii:!0}),n.jd=new Iq(zJ),{start:n,tokens:Object.assign({groups:t},BJ)}}function eY(e,t){let n=tY(t.replace(/[A-Z]/g,e=>e.toLowerCase())),r=n.length,i=[],a=0,o=0;for(;o<r;){let s=e,c=null,l=0,u=null,d=-1,f=-1;for(;o<r&&(c=s.go(n[o]));)s=c,s.accepts()?(d=0,f=0,u=s):d>=0&&(d+=n[o].length,f++),l+=n[o].length,a+=n[o].length,o++;a-=d,o-=f,l-=d,i.push({t:u.t,v:t.slice(a-l,a),s:a-l,e:a})}return i}function tY(e){let t=[],n=e.length,r=0;for(;r<n;){let i=e.charCodeAt(r),a,o=i<55296||i>56319||r+1===n||(a=e.charCodeAt(r+1))<56320||a>57343?e[r]:e.slice(r,r+2);t.push(o),r+=o.length}return t}function nY(e,t,n,r,i){let a,o=t.length;for(let n=0;n<o-1;n++){let o=t[n];e.j[o]?a=e.j[o]:(a=new Iq(r),a.jr=i.slice(),e.j[o]=a),e=a}return a=new Iq(n),a.jr=i.slice(),e.j[t[o-1]]=a,a}function rY(e){let t=[],n=[],r=0;for(;r<e.length;){let i=0;for(;`0123456789`.indexOf(e[r+i])>=0;)i++;if(i>0){t.push(n.join(``));for(let t=parseInt(e.substring(r,r+i),10);t>0;t--)n.pop();r+=i}else n.push(e[r]),r++}return t}var iY={defaultProtocol:`http`,events:null,format:oY,formatHref:oY,nl2br:!1,tagName:`a`,target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function aY(e,t=null){let n=Object.assign({},iY);e&&(n=Object.assign(n,e instanceof aY?e.o:e));let r=n.ignoreTags,i=[];for(let e=0;e<r.length;e++)i.push(r[e].toUpperCase());this.o=n,t&&(this.defaultRender=t),this.ignoreTags=i}aY.prototype={o:iY,ignoreTags:[],defaultRender(e){return e},check(e){return this.get(`validate`,e.toString(),e)},get(e,t,n){let r=t!=null,i=this.o[e];return i&&(typeof i==`object`?(i=n.t in i?i[n.t]:iY[e],typeof i==`function`&&r&&(i=i(t,n))):typeof i==`function`&&r&&(i=i(t,n.t,n)),i)},getObj(e,t,n){let r=this.o[e];return typeof r==`function`&&t!=null&&(r=r(t,n.t,n)),r},render(e){let t=e.render(this);return(this.get(`render`,null,e)||this.defaultRender)(t,e.t,e)}};function oY(e){return e}function sY(e,t){this.t=`token`,this.v=e,this.tk=t}sY.prototype={isLink:!1,toString(){return this.v},toHref(e){return this.toString()},toFormattedString(e){let t=this.toString(),n=e.get(`truncate`,t,this),r=e.get(`format`,t,this);return n&&r.length>n?r.substring(0,n)+`…`:r},toFormattedHref(e){return e.get(`formatHref`,this.toHref(e.get(`defaultProtocol`)),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(e=iY.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(e),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(e){return{type:this.t,value:this.toFormattedString(e),isLink:this.isLink,href:this.toFormattedHref(e),start:this.startIndex(),end:this.endIndex()}},validate(e){return e.get(`validate`,this.toString(),this)},render(e){let t=this,n=this.toHref(e.get(`defaultProtocol`)),r=e.get(`formatHref`,n,this),i=e.get(`tagName`,n,t),a=this.toFormattedString(e),o={},s=e.get(`className`,n,t),c=e.get(`target`,n,t),l=e.get(`rel`,n,t),u=e.getObj(`attributes`,n,t),d=e.getObj(`events`,n,t);return o.href=r,s&&(o.class=s),c&&(o.target=c),l&&(o.rel=l),u&&Object.assign(o,u),{tagName:i,attributes:o,content:a,eventListeners:d}}};function cY(e,t){class n extends sY{constructor(t,n){super(t,n),this.t=e}}for(let e in t)n.prototype[e]=t[e];return n.t=e,n}var lY=cY(`email`,{isLink:!0,toHref(){return`mailto:`+this.toString()}}),uY=cY(`text`),dY=cY(`nl`),fY=cY(`url`,{isLink:!0,toHref(e=iY.defaultProtocol){return this.hasProtocol()?this.v:`${e}://${this.v}`},hasProtocol(){let e=this.tk;return e.length>=2&&e[0].t!==Uq&&e[1].t===bJ}}),pY=e=>new Iq(e);function mY({groups:e}){let t=e.domain.concat([pJ,hJ,gJ,_J,vJ,yJ,SJ,wJ,EJ,Jq,DJ,OJ,kJ,AJ,FJ,zJ,IJ,LJ]),n=[mJ,bJ,xJ,CJ,TJ,DJ,jJ,MJ,PJ,rJ,iJ,Zq,Qq,eJ,$q,tJ,nJ,aJ,oJ,sJ,cJ,lJ,uJ,dJ,fJ],r=[pJ,mJ,hJ,_J,vJ,yJ,SJ,wJ,EJ,Zq,Qq,DJ,OJ,kJ,AJ,jJ,FJ,zJ,IJ,LJ],i=pY(),a=$(i,IJ);Q(a,r,a),Q(a,e.domain,a);let o=pY(),s=pY(),c=pY();Q(i,e.domain,o),Q(i,e.scheme,s),Q(i,e.slashscheme,c),Q(o,r,a),Q(o,e.domain,o);let l=$(o,gJ);$(a,gJ,l),$(s,gJ,l),$(c,gJ,l);let u=$(a,CJ);Q(u,r,a),Q(u,e.domain,a);let d=pY();Q(l,e.domain,d),Q(d,e.domain,d);let f=$(d,CJ);Q(f,e.domain,d);let p=pY(lY);Q(f,e.tld,p),Q(f,e.utld,p),$(l,Uq,p);let m=$(d,EJ);$(m,EJ,m),Q(m,e.domain,d),Q(p,e.domain,d),$(p,CJ,f),$(p,EJ,m);let h=$(o,EJ),g=$(o,CJ);$(h,EJ,h),Q(h,e.domain,o),Q(g,r,a),Q(g,e.domain,o);let _=pY(fY);Q(g,e.tld,_),Q(g,e.utld,_),Q(_,e.domain,o),Q(_,r,a),$(_,CJ,g),$(_,EJ,h),$(_,gJ,l);let v=$(_,bJ),y=pY(fY);Q(v,e.numeric,y);let b=pY(fY),x=pY();Q(b,t,b),Q(b,n,x),Q(x,t,b),Q(x,n,x),$(_,FJ,b),$(y,FJ,b);let S=$(s,bJ),C=$($($(c,bJ),FJ),FJ);Q(s,e.domain,o),$(s,CJ,g),$(s,EJ,h),Q(c,e.domain,o),$(c,CJ,g),$(c,EJ,h),Q(S,e.domain,b),$(S,FJ,b),$(S,jJ,b),Q(C,e.domain,b),Q(C,t,b),$(C,FJ,b);let w=[[Zq,Qq],[$q,eJ],[tJ,nJ],[rJ,iJ],[aJ,oJ],[sJ,cJ],[lJ,uJ],[dJ,fJ]];for(let e=0;e<w.length;e++){let[r,i]=w[e],a=$(b,r);$(x,r,a);let o=pY(fY);Q(a,t,o);let s=pY();Q(a,n,s),$(a,i,b),Q(o,t,o),Q(o,n,s),Q(s,t,o),Q(s,n,s),$(o,i,b),$(s,i,b)}return $(i,Uq,_),$(i,Xq,dY),{start:i,tokens:BJ}}function hY(e,t,n){let r=n.length,i=0,a=[],o=[];for(;i<r;){let s=e,c=null,l=null,u=0,d=null,f=-1;for(;i<r&&!(c=s.go(n[i].t));)o.push(n[i++]);for(;i<r&&(l=c||s.go(n[i].t));)c=null,s=l,s.accepts()?(f=0,d=s):f>=0&&f++,i++,u++;if(f<0)i-=u,i<r&&(o.push(n[i]),i++);else{o.length>0&&(a.push(gY(uY,t,o)),o=[]),i-=f,u-=f;let e=d.t,r=n.slice(i-u,i);a.push(gY(e,t,r))}}return o.length>0&&a.push(gY(uY,t,o)),a}function gY(e,t,n){let r=n[0].s,i=n[n.length-1].e;return new e(t.slice(r,i),n)}var _Y=typeof console<`u`&&console&&console.warn||(()=>{}),vY=`until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.`,yY={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function bY(){return Iq.groups={},yY.scanner=null,yY.parser=null,yY.tokenQueue=[],yY.pluginQueue=[],yY.customSchemes=[],yY.initialized=!1,yY}function xY(e,t=!1){if(yY.initialized&&_Y(`linkifyjs: already initialized - will not register custom scheme "${e}" ${vY}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(e))throw Error(`linkifyjs: incorrect scheme format.
|
|
275
275
|
1. Must only contain digits, lowercase ASCII letters or "-"
|
|
276
276
|
2. Cannot start or end with "-"
|
|
277
|
-
3. "-" cannot repeat`);yY.customSchemes.push([e,t])}function SY(){yY.scanner=$J(yY.customSchemes);for(let e=0;e<yY.tokenQueue.length;e++)yY.tokenQueue[e][1]({scanner:yY.scanner});yY.parser=mY(yY.scanner.tokens);for(let e=0;e<yY.pluginQueue.length;e++)yY.pluginQueue[e][1]({scanner:yY.scanner,parser:yY.parser});return yY.initialized=!0,yY}function CY(e){return yY.initialized||SY(),hY(yY.parser.start,e,eY(yY.scanner.start,e))}CY.scan=eY;function wY(e,t=null,n=null){if(t&&typeof t==`object`){if(n)throw Error(`linkifyjs: Invalid link type ${t}; must be a string`);n=t,t=null}let r=new aY(n),i=CY(e),a=[];for(let e=0;e<i.length;e++){let n=i[e];n.isLink&&(!t||n.t===t)&&r.check(n)&&a.push(n.toFormattedObject(r))}return a}var TY=`[\0- \xA0 -\u2029 ]`,EY=new RegExp(TY),DY=RegExp(`${TY}$`),OY=new RegExp(TY,`g`);function kY(e){return e.length===1?e[0].isLink:e.length===3&&e[1].isLink?[`()`,`[]`].includes(e[0].value+e[2].value):!1}function AY(e){return new SI({key:new TI(`autolink`),appendTransaction:(t,n,r)=>{let i=t.some(e=>e.docChanged)&&!n.doc.eq(r.doc),a=t.some(e=>e.getMeta(`preventAutolink`));if(!i||a)return;let{tr:o}=r;if(JU(vU(n.doc,[...t])).forEach(({newRange:t})=>{let n=yU(r.doc,t,e=>e.isTextblock),i,a;if(n.length>1)i=n[0],a=r.doc.textBetween(i.pos,i.pos+i.node.nodeSize,void 0,` `);else if(n.length){let e=r.doc.textBetween(t.from,t.to,` `,` `);if(!DY.test(e))return;i=n[0],a=r.doc.textBetween(i.pos,t.to,void 0,` `)}if(i&&a){let t=a.split(EY).filter(Boolean);if(t.length<=0)return!1;let n=t[t.length-1],s=i.pos+a.lastIndexOf(n);if(!n)return!1;let c=CY(n).map(t=>t.toObject(e.defaultProtocol));if(!kY(c))return!1;c.filter(e=>e.isLink).map(e=>({...e,from:s+e.start+1,to:s+e.end+1})).filter(e=>!r.schema.marks.code||!r.doc.rangeHasMark(e.from,e.to,r.schema.marks.code)).filter(t=>e.validate(t.value)).filter(t=>e.shouldAutoLink(t.value)).forEach(t=>{YU(t.from,t.to,r.doc).some(t=>t.mark.type===e.type)||o.addMark(t.from,t.to,e.type.create({href:t.href}))})}}),o.steps.length)return o}})}function jY(e){return new SI({key:new TI(`handleClickLink`),props:{handleClick:(t,n,r)=>{if(r.button!==0||!t.editable)return!1;let i=null;if(r.target instanceof HTMLAnchorElement)i=r.target;else{let t=r.target;if(!t)return!1;let n=e.editor.view.dom;i=t.closest(`a`),i&&!n.contains(i)&&(i=null)}if(!i)return!1;let a=!1;if(e.enableClickSelection&&(a=e.editor.commands.extendMarkRange(e.type.name)),e.openOnClick){let n=GU(t.state,e.type.name),r=i.href??n.href,o=i.target??n.target;r&&(window.open(r,o),a=!0)}return a}}})}var MY=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)$/,NY=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)/g;function PY(e,t){let n=0;for(let r=t-1;r>=0&&e[r]===`\\`;--r)n+=1;return n%2==1}function FY(e,t){let n=0,r=0;for(;r<t;){if(e[r]!=="`"){r+=1;continue}if(n===0&&PY(e,r)){r+=1;continue}let i=0;for(;r<t&&e[r]==="`";)i+=1,r+=1;n===0?n=i:i===n&&(n=0)}return n>0}function IY(e,t,n){let[,r,i]=t;return(t.index?e[t.index-1]:void 0)===`!`||PY(e,t.index??0)||FY(e,t.index??0)?!1:!!r.trim()&&n(i)}function LY(e){let[t,n,r,,i,a,o]=e,s=i??a??o;return{index:e.index??0,text:t,replaceWith:n,data:{href:r,title:s||null,markdown:!0}}}function RY(e,t){return e.index<t.index+t.text.length&&t.index<e.index+e.text.length}function zY(e){return{href:e.data?.href,title:e.data?.title??null}}function BY(e){let t=ZG({find:t=>{let n=MY.exec(t);return!n||!IY(t,n,e.isAllowedHref)?null:LY(n)},type:e.type,getAttributes:zY});return new xG({find:t.find,handler:e=>{let n=t.handler(e);return n!==null&&e.state.tr.steps.length&&e.state.tr.setMeta(`preventAutolink`,!0),n}})}function VY(e){let t=nK({find:t=>{let n=[];for(let r of t.matchAll(NY))IY(t,r,e.isAllowedHref)&&n.push(LY(r));let r=(e.findPlainUrls?.call(e,t)??[]).filter(e=>!n.some(t=>RY(t,e)));return[...n,...r]},type:e.type,getAttributes:zY});return new DG({find:t.find,handler:e=>{let n=t.handler(e);return n!==null&&e.state.tr.steps.length&&e.match.data?.markdown&&e.state.tr.setMeta(`preventAutolink`,!0),n}})}function HY(e){return new SI({key:new TI(`handlePasteLink`),props:{handlePaste:(t,n,r)=>{let{shouldAutoLink:i}=e,{state:a}=t,{selection:o}=a,{empty:s}=o;if(s)return!1;let c=``;r.content.forEach(e=>{c+=e.textContent});let l=wY(c,{defaultProtocol:e.defaultProtocol}).find(e=>e.isLink&&e.value===c);return!c||!l||i!==void 0&&!i(l.value)?!1:e.editor.commands.setMark(e.type,{href:l.href})}}})}function UY(e,t){let n=[`http`,`https`,`ftp`,`ftps`,`mailto`,`tel`,`callto`,`sms`,`cid`,`xmpp`];return t&&t.forEach(e=>{let t=typeof e==`string`?e:e.scheme;t&&n.push(t)}),!e||e.replace(OY,``).match(RegExp(`^(?:(?:${n.map(e=>e.replace(/[-/\\^$*+?.()|[\]{}]/g,`\\$&`)).join(`|`)}):|[^a-z]|[a-z0-9+.\\-]+(?:[^a-z+.\\-:]|$))`,`i`))}var WY=EG.create({name:`link`,priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(e=>{if(typeof e==`string`){xY(e);return}xY(e.scheme,e.optionalSlashes)})},onDestroy(){bY()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,markdownLinks:!1,autolink:!0,protocols:[],defaultProtocol:`http`,HTMLAttributes:{target:`_blank`,rel:`noopener noreferrer nofollow`,class:null},isAllowedUri:(e,t)=>!!UY(e,t.protocols),validate:e=>!!e,shouldAutoLink:e=>{let t=/^[a-z][a-z0-9+.-]*:\/\//i.test(e),n=/^[a-z][a-z0-9+.-]*:/i.test(e);if(t||n&&!e.includes(`@`))return!0;let r=(e.includes(`@`)?e.split(`@`).pop():e).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(r)||!/\./.test(r))}}},addAttributes(){return{href:{default:null,parseHTML(e){return e.getAttribute(`href`)}},target:{default:this.options.HTMLAttributes.target??null},rel:{default:this.options.HTMLAttributes.rel??null},class:{default:this.options.HTMLAttributes.class??null},title:{default:null}}},parseHTML(){return[{tag:`a[href]`,getAttrs:e=>{let t=e.getAttribute(`href`);return!t||!this.options.isAllowedUri(t,{defaultValidate:e=>!!UY(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:e}){return this.options.isAllowedUri(e.href,{defaultValidate:e=>!!UY(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?[`a`,jU(this.options.HTMLAttributes,e),0]:[`a`,jU(this.options.HTMLAttributes,{...e,href:``}),0]},markdownTokenName:`link`,parseMarkdown:(e,t)=>t.applyMark(`link`,t.parseInline(e.tokens||[]),{href:e.href,title:e.title||null}),renderMarkdown:(e,t)=>{let n=e.attrs?.href??``,r=e.attrs?.title??``,i=t.renderChildren(e);return r?`[${i}](${n} "${r}")`:`[${i}](${n})`},addCommands(){return{setLink:e=>({chain:t})=>{let{href:n}=e;return this.options.isAllowedUri(n,{defaultValidate:e=>!!UY(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?t().setMark(this.name,e).setMeta(`preventAutolink`,!0).run():!1},toggleLink:e=>({chain:t})=>{let{href:n}=e||{};return n&&!this.options.isAllowedUri(n,{defaultValidate:e=>!!UY(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:t().toggleMark(this.name,e,{extendEmptyMarkRange:!0}).setMeta(`preventAutolink`,!0).run()},unsetLink:()=>({chain:e})=>e().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta(`preventAutolink`,!0).run()}},addInputRules(){return this.options.markdownLinks?[BY({type:this.type,isAllowedHref:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!UY(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})})]:[]},addPasteRules(){let e=e=>{let t=[];if(e){let{protocols:n,defaultProtocol:r}=this.options;wY(e).filter(e=>e.isLink&&this.options.isAllowedUri(e.value,{defaultValidate:e=>!!UY(e,n),protocols:n,defaultProtocol:r})).forEach(e=>{this.options.shouldAutoLink(e.value)&&t.push({text:e.value,data:{href:e.href},index:e.start})})}return t};return this.options.markdownLinks?[VY({type:this.type,isAllowedHref:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!UY(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol}),findPlainUrls:e})]:[nK({find:e,type:this.type,getAttributes:e=>({href:e.data?.href})})]},addProseMirrorPlugins(){let e=[],{protocols:t,defaultProtocol:n}=this.options;return this.options.autolink&&e.push(AY({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!UY(e,t),protocols:t,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),e.push(jY({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick===`whenNotEditable`||this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&e.push(HY({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),e}}),GY=WY;function KY(e={}){return new SI({view(t){return new qY(t,e)}})}var qY=class{constructor(e,t){this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.lastDragEvent=null,this.width=t.width??1,this.color=t.color===!1?void 0:t.color||`black`,this.class=t.class,this.handlers=[`dragover`,`dragend`,`drop`,`dragleave`].map(t=>{let n=e=>{this[t](e)};return e.dom.addEventListener(t,n),{name:t,handler:n}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){if(this.cursorPos!=null&&t.doc!=e.state.doc)if(this.lastDragEvent){let e=this.computeTarget(this.lastDragEvent);e==this.cursorPos?this.updateOverlay():this.setCursor(e)}else this.updateOverlay()}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,n,r=this.editorView.dom,i=r.getBoundingClientRect(),a=i.width/r.offsetWidth,o=i.height/r.offsetHeight;if(t){let t=e.nodeBefore,r=e.nodeAfter;if(t||r){let e=this.editorView.nodeDOM(this.cursorPos-(t?t.nodeSize:0));if(e){let i=e.getBoundingClientRect(),a=t?i.bottom:i.top;t&&r&&(a=(a+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let s=this.width/2*o;n={left:i.left,right:i.right,top:a-s,bottom:a+s}}}}if(!n){let e=this.editorView.coordsAtPos(this.cursorPos),t=this.width/2*a;n={left:e.left-t,right:e.left+t,top:e.top,bottom:e.bottom}}let s=this.editorView.dom.offsetParent;this.element||(this.element=s.appendChild(document.createElement(`div`)),this.class&&(this.element.className=this.class),this.element.style.cssText=`position: absolute; z-index: 50; pointer-events: none;`,this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle(`prosemirror-dropcursor-block`,t),this.element.classList.toggle(`prosemirror-dropcursor-inline`,!t);let c,l;if(!s||s==document.body&&getComputedStyle(s).position==`static`)c=-pageXOffset,l=-pageYOffset;else{let e=s.getBoundingClientRect(),t=e.width/s.offsetWidth,n=e.height/s.offsetHeight;c=e.left-s.scrollLeft*t,l=e.top-s.scrollTop*n}this.element.style.left=(n.left-c)/a+`px`,this.element.style.top=(n.top-l)/o+`px`,this.element.style.width=(n.right-n.left)/a+`px`,this.element.style.height=(n.bottom-n.top)/o+`px`}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}computeTarget(e){let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),r=n&&n.type.spec.disableDropCursor,i=typeof r==`function`?r(this.editorView,t,e):r;if(!t||i)return null;let a=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let e=IF(this.editorView.state.doc,a,this.editorView.dragging.slice);e!=null&&(a=e)}return a}dragover(e){if(!this.editorView.editable)return;this.lastDragEvent=e;let t=this.computeTarget(e);t!=null&&(this.setCursor(t),this.scheduleRemoval(5e3))}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}},JY=class e extends J{constructor(e){super(e,e)}map(t,n){let r=t.resolve(n.map(this.head));return e.valid(r)?new e(r):J.near(r)}content(){return q.empty}eq(t){return t instanceof e&&t.head==this.head}toJSON(){return{type:`gapcursor`,pos:this.head}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for GapCursor.fromJSON`);return new e(t.resolve(n.pos))}getBookmark(){return new YY(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!ZY(e)||!QY(e))return!1;let n=t.type.spec.allowGapCursor;if(n!=null)return n;let r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(t,n,r=!1){search:for(;;){if(!r&&e.valid(t))return t;let i=t.pos,a=null;for(let r=t.depth;;r--){let o=t.node(r);if(n>0?t.indexAfter(r)<o.childCount:t.index(r)>0){a=o.child(n>0?t.indexAfter(r):t.index(r)-1);break}else if(r==0)return null;i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}for(;;){let o=n>0?a.firstChild:a.lastChild;if(!o){if(a.isAtom&&!a.isText&&!X.isSelectable(a)){t=t.doc.resolve(i+a.nodeSize*n),r=!1;continue search}break}a=o,i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}return null}}};JY.prototype.visible=!1,JY.findFrom=JY.findGapCursorFrom,J.jsonID(`gapcursor`,JY);var YY=class e{constructor(e){this.pos=e}map(t){return new e(t.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return JY.valid(t)?new JY(t):J.near(t)}};function XY(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function ZY(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n-1);;e=e.lastChild){if(e.childCount==0&&!e.inlineContent||XY(e.type))return!0;if(e.inlineContent)return!1}}return!0}function QY(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n);;e=e.firstChild){if(e.childCount==0&&!e.inlineContent||XY(e.type))return!0;if(e.inlineContent)return!1}}return!0}function $Y(){return new SI({props:{decorations:iX,createSelectionBetween(e,t,n){return t.pos==n.pos&&JY.valid(n)?new JY(n):null},handleClick:nX,handleKeyDown:eX,handleDOMEvents:{beforeinput:rX}}})}var eX=QV({ArrowLeft:tX(`horiz`,-1),ArrowRight:tX(`horiz`,1),ArrowUp:tX(`vert`,-1),ArrowDown:tX(`vert`,1)});function tX(e,t){let n=e==`vert`?t>0?`down`:`up`:t>0?`right`:`left`;return function(e,r,i){let a=e.selection,o=t>0?a.$to:a.$from,s=a.empty;if(a instanceof Y){if(!i.endOfTextblock(n)||o.depth==0)return!1;s=!1,o=e.doc.resolve(t>0?o.after():o.before())}let c=JY.findGapCursorFrom(o,t,s);return c?(r&&r(e.tr.setSelection(new JY(c))),!0):!1}}function nX(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!JY.valid(r))return!1;let i=e.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&X.isSelectable(e.state.doc.nodeAt(i.inside))?!1:(e.dispatch(e.state.tr.setSelection(new JY(r))),!0)}function rX(e,t){if(t.inputType!=`insertCompositionText`||!(e.state.selection instanceof JY))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let i=K.empty;for(let e=r.length-1;e>=0;e--)i=K.from(r[e].createAndFill(null,i));let a=e.state.tr.replace(n.pos,n.pos,new q(i,0,0));return a.setSelection(Y.near(a.doc.resolve(n.pos+1))),e.dispatch(a),!1}function iX(e){if(!(e.selection instanceof JY))return null;let t=document.createElement(`div`);return t.className=`ProseMirror-gapcursor`,QB.create(e.doc,[YB.widget(e.selection.head,t,{key:`gapcursor`})])}var aX=200,oX=function(){};oX.prototype.append=function(e){return e.length?(e=oX.from(e),!this.length&&e||e.length<aX&&this.leafAppend(e)||this.length<aX&&e.leafPrepend(this)||this.appendInner(e)):this},oX.prototype.prepend=function(e){return e.length?oX.from(e).append(this):this},oX.prototype.appendInner=function(e){return new cX(this,e)},oX.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?oX.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},oX.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},oX.prototype.forEach=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},oX.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var r=[];return this.forEach(function(t,n){return r.push(e(t,n))},t,n),r},oX.from=function(e){return e instanceof oX?e:e&&e.length?new sX(e):oX.empty};var sX=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return e==0&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,r){for(var i=t;i<n;i++)if(e(this.values[i],r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){for(var i=t-1;i>=n;i--)if(e(this.values[i],r+i)===!1)return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=aX)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=aX)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(oX);oX.empty=new sX([]);var cX=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,t,n,r){var i=this.left.length;if(t<i&&this.left.forEachInner(e,t,Math.min(n,i),r)===!1||n>i&&this.right.forEachInner(e,Math.max(t-i,0),Math.min(this.length,n)-i,r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){var i=this.left.length;if(t>i&&this.right.forEachInvertedInner(e,t-i,Math.max(n,i)-i,r+i)===!1||n<i&&this.left.forEachInvertedInner(e,Math.min(t,i),n,r)===!1)return!1},t.prototype.sliceInner=function(e,t){if(e==0&&t==this.length)return this;var n=this.left.length;return t<=n?this.left.slice(e,t):e>=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(oX),lX=500,uX=class e{constructor(e,t){this.items=e,this.eventCount=t}popEvent(t,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,a;n&&(i=this.remapping(r,this.items.length),a=i.maps.length);let o=t.tr,s,c,l=[],u=[];return this.items.forEach((t,n)=>{if(!t.step){i||(i=this.remapping(r,n+1),a=i.maps.length),a--,u.push(t);return}if(i){u.push(new fX(t.map));let e=t.step.map(i.slice(a)),n;e&&o.maybeStep(e).doc&&(n=o.mapping.maps[o.mapping.maps.length-1],l.push(new fX(n,void 0,void 0,l.length+u.length))),a--,n&&i.appendMap(n,a)}else o.maybeStep(t.step);if(t.selection)return s=i?t.selection.map(i.slice(a)):t.selection,c=new e(this.items.slice(0,r).append(u.reverse().concat(l)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:o,selection:s}}addTransform(t,n,r,i){let a=[],o=this.eventCount,s=this.items,c=!i&&s.length?s.get(s.length-1):null;for(let e=0;e<t.steps.length;e++){let r=t.steps[e].invert(t.docs[e]),l=new fX(t.mapping.maps[e],r,n),u;(u=c&&c.merge(l))&&(l=u,e?a.pop():s=s.slice(0,s.length-1)),a.push(l),n&&=(o++,void 0),i||(c=l)}let l=o-r.depth;return l>mX&&(s=dX(s,l),o-=l),new e(s.append(a),o)}remapping(e,t){let n=new eF;return this.items.forEach((t,r)=>{let i=t.mirrorOffset!=null&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,i)},e,t),n}addMaps(t){return this.eventCount==0?this:new e(this.items.append(t.map(e=>new fX(e))),this.eventCount)}rebased(t,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),a=t.mapping,o=t.steps.length,s=this.eventCount;this.items.forEach(e=>{e.selection&&s--},i);let c=n;this.items.forEach(e=>{let n=a.getMirror(--c);if(n==null)return;o=Math.min(o,n);let i=a.maps[n];if(e.step){let o=t.steps[n].invert(t.docs[n]),l=e.selection&&e.selection.map(a.slice(c+1,n));l&&s++,r.push(new fX(i,o,l))}else r.push(new fX(i))},i);let l=[];for(let e=n;e<o;e++)l.push(new fX(a.maps[e]));let u=this.items.slice(0,i).append(l).append(r),d=new e(u,s);return d.emptyItemCount()>lX&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(t=this.items.length){let n=this.remapping(0,t),r=n.maps.length,i=[],a=0;return this.items.forEach((e,o)=>{if(o>=t)i.push(e),e.selection&&a++;else if(e.step){let t=e.step.map(n.slice(r)),o=t&&t.getMap();if(r--,o&&n.appendMap(o,r),t){let s=e.selection&&e.selection.map(n.slice(r));s&&a++;let c=new fX(o.invert(),t,s),l,u=i.length-1;(l=i.length&&i[u].merge(c))?i[u]=l:i.push(c)}}else e.map&&r--},this.items.length,0),new e(oX.from(i.reverse()),a)}};uX.empty=new uX(oX.empty,0);function dX(e,t){let n;return e.forEach((e,r)=>{if(e.selection&&t--==0)return n=r,!1}),e.slice(n)}var fX=class e{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(t){if(this.step&&t.step&&!t.selection){let n=t.step.merge(this.step);if(n)return new e(n.getMap().invert(),n,this.selection)}}},pX=class{constructor(e,t,n,r,i){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=i}},mX=20;function hX(e,t,n,r){let i=n.getMeta(CX),a;if(i)return i.historyState;n.getMeta(wX)&&(e=new pX(e.done,e.undone,null,0,-1));let o=n.getMeta(`appendedTransaction`);if(n.steps.length==0)return e;if(o&&o.getMeta(CX))return o.getMeta(CX).redo?new pX(e.done.addTransform(n,void 0,r,SX(t)),e.undone,_X(n.mapping.maps),e.prevTime,e.prevComposition):new pX(e.done,e.undone.addTransform(n,void 0,r,SX(t)),null,e.prevTime,e.prevComposition);if(n.getMeta(`addToHistory`)!==!1&&!(o&&o.getMeta(`addToHistory`)===!1)){let i=n.getMeta(`composition`),a=e.prevTime==0||!o&&e.prevComposition!=i&&(e.prevTime<(n.time||0)-r.newGroupDelay||!gX(n,e.prevRanges)),s=o?vX(e.prevRanges,n.mapping):_X(n.mapping.maps);return new pX(e.done.addTransform(n,a?t.selection.getBookmark():void 0,r,SX(t)),uX.empty,s,n.time,i??e.prevComposition)}else if(a=n.getMeta(`rebased`))return new pX(e.done.rebased(n,a),e.undone.rebased(n,a),vX(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);else return new pX(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),vX(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}function gX(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((e,r)=>{for(let i=0;i<t.length;i+=2)e<=t[i+1]&&r>=t[i]&&(n=!0)}),n}function _X(e){let t=[];for(let n=e.length-1;n>=0&&t.length==0;n--)e[n].forEach((e,n,r,i)=>t.push(r,i));return t}function vX(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let i=t.map(e[r],1),a=t.map(e[r+1],-1);i<=a&&n.push(i,a)}return n}function yX(e,t,n){let r=SX(t),i=CX.get(t).spec.config,a=(n?e.undone:e.done).popEvent(t,r);if(!a)return null;let o=a.selection.resolve(a.transform.doc),s=(n?e.done:e.undone).addTransform(a.transform,t.selection.getBookmark(),i,r),c=new pX(n?s:a.remaining,n?a.remaining:s,null,0,-1);return a.transform.setSelection(o).setMeta(CX,{redo:n,historyState:c})}var bX=!1,xX=null;function SX(e){let t=e.plugins;if(xX!=t){bX=!1,xX=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){bX=!0;break}}return bX}var CX=new TI(`history`),wX=new TI(`closeHistory`);function TX(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new SI({key:CX,state:{init(){return new pX(uX.empty,uX.empty,null,0,-1)},apply(t,n,r){return hX(n,r,t,e)}},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,r=n==`historyUndo`?DX:n==`historyRedo`?OX:null;return!r||!e.editable?!1:(t.preventDefault(),r(e.state,e.dispatch))}}}})}function EX(e,t){return(n,r)=>{let i=CX.getState(n);if(!i||(e?i.undone:i.done).eventCount==0)return!1;if(r){let a=yX(i,n,e);a&&r(t?a.scrollIntoView():a)}return!0}}var DX=EX(!1,!0),OX=EX(!0,!0);PG.create({name:`characterCount`,addOptions(){return{limit:null,autoTrim:!0,mode:`textSize`,textCounter:e=>e.length,wordCounter:e=>e.split(` `).filter(e=>e!==``).length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=e=>{let t=e?.node||this.editor.state.doc;if((e?.mode||this.options.mode)===`textSize`){let e=t.textBetween(0,t.content.size,void 0,` `);return this.options.textCounter(e)}return t.nodeSize},this.storage.words=e=>{let t=e?.node||this.editor.state.doc,n=t.textBetween(0,t.content.size,` `,` `);return this.options.wordCounter(n)}},addProseMirrorPlugins(){let e=!1;return[new SI({key:new TI(`characterCount`),appendTransaction:(t,n,r)=>{if(e)return;let i=this.options.limit,a=this.options.autoTrim;if(i==null||i===0||a===!1){e=!0;return}let o=this.storage.characters({node:r.doc});if(o>i){let t=o-i;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);let n=r.tr.deleteRange(0,t);return e=!0,n}e=!0},filterTransaction:(e,t)=>{let n=this.options.limit;if(!e.docChanged||n===0||n==null)return!0;let r=this.storage.characters({node:t.doc}),i=this.storage.characters({node:e.doc});if(i<=n||r>n&&i>n&&i<=r)return!0;if(r>n&&i>n&&i>r||!e.getMeta(`paste`))return!1;let a=e.selection.$head.pos,o=a-(i-n),s=a;return e.deleteRange(o,s),!(this.storage.characters({node:e.doc})>n)}})]}});var kX=PG.create({name:`dropCursor`,addOptions(){return{color:`currentColor`,width:1,class:void 0}},addProseMirrorPlugins(){return[KY(this.options)]}});PG.create({name:`focus`,addOptions(){return{className:`has-focus`,mode:`all`}},addProseMirrorPlugins(){return[new SI({key:new TI(`focus`),props:{decorations:({doc:e,selection:t})=>{let{isEditable:n,isFocused:r}=this.editor,{anchor:i}=t,a=[];if(!n||!r)return QB.create(e,[]);let o=0;this.options.mode===`deepest`&&e.descendants((e,t)=>{if(!e.isText){if(!(i>=t&&i<=t+e.nodeSize-1))return!1;o+=1}});let s=0;return e.descendants((e,t)=>{if(e.isText||!(i>=t&&i<=t+e.nodeSize-1))return!1;if(s+=1,this.options.mode===`deepest`&&o-s>0||this.options.mode===`shallowest`&&s>1)return this.options.mode===`deepest`;a.push(YB.node(t,t+e.nodeSize,{class:this.options.className}))}),QB.create(e,a)}}})]}});var AX=PG.create({name:`gapCursor`,addProseMirrorPlugins(){return[$Y()]},extendNodeSchema(e){return{allowGapCursor:TU(Z(e,`allowGapCursor`,{name:e.name,options:e.options,storage:e.storage}))??null}}}),jX=`placeholder`,MX=new TI(`tiptap__placeholder`);function NX(e){let{editor:t,placeholder:n,dataAttribute:r,pos:i,node:a,isEmptyDoc:o,hasAnchor:s,classes:{emptyNode:c,emptyEditor:l}}=e,u=[c];return o&&u.push(l),YB.node(i,i+a.nodeSize,{class:u.join(` `),[r]:typeof n==`function`?n({editor:t,node:a,pos:i,hasAnchor:s}):n})}function PX(e,t){return typeof e==`function`?e(t):e}function FX({editor:e,options:t,dataAttribute:n,doc:r,selection:i,from:a,to:o}){let{anchor:s}=i,c=[],l=e.isEmpty;return r.nodesBetween(a,o,(r,i)=>{let a=s>=i&&s<=i+r.nodeSize,o=!r.isLeaf&&sW(r);return r.type.isTextblock&&(a||!t.showOnlyCurrent)&&o&&c.push(NX({editor:e,isEmptyDoc:l,dataAttribute:n,hasAnchor:a,placeholder:t.placeholder,classes:{emptyEditor:t.emptyEditorClass,emptyNode:PX(t.emptyNodeClass,{editor:e,node:r,pos:i,hasAnchor:a})},node:r,pos:i})),t.includeChildren}),c}function IX({editor:e,options:t,dataAttribute:n,doc:r,selection:i}){if(!(e.isEditable||!t.showOnlyWhenEditable))return null;let{anchor:a}=i,o=[],s=e.isEmpty;if(t.showOnlyCurrent&&!t.includeChildren){let i=r.resolve(a),c=i.depth>0?i.node(1):i.nodeAfter,l=i.depth>0?i.before(1):a;if(c&&c.type.isTextblock&&sW(c)){let r=a>=l&&a<=l+c.nodeSize;o.push(NX({editor:e,isEmptyDoc:s,dataAttribute:n,hasAnchor:r,placeholder:t.placeholder,classes:{emptyEditor:t.emptyEditorClass,emptyNode:PX(t.emptyNodeClass,{editor:e,node:c,pos:l,hasAnchor:r})},node:c,pos:l}))}}else o.push(...FX({editor:e,options:t,dataAttribute:n,doc:r,selection:i,from:0,to:r.content.size}));return QB.create(r,o)}function LX(e,t){let n=e.resolve(t);if(n.depth===0){let e=n.nodeAfter??n.nodeBefore;if(!e)return{from:t,to:t};let r=n.nodeAfter?t:t-e.nodeSize;return{from:r,to:r+e.nodeSize}}let r=n.before(1);return{from:r,to:r+n.node(1).nodeSize}}function RX(e,t){return{from:Math.max(0,t.from-1),to:Math.min(e.content.size,t.to-1)}}function zX(e,t,n){let r=[];return e.forEach((e,i)=>{let a=i,o=a+e.nodeSize,s=a+1,c=o+1;s<n&&c>t&&r.push({from:a,to:o})}),r}function BX(e){if(e.length===0)return[];let t=[...e].sort((e,t)=>e.from-t.from),n=[{...t[0]}];for(let e=1;e<t.length;e+=1){let r=n[n.length-1],i=t[e];i.from<=r.to?r.to=Math.max(r.to,i.to):n.push({...i})}return n}function VX(e,t){let n=zX(e,t.from,t.to);return n.push(RX(e,LX(e,t.from))),t.to>t.from?n.push(RX(e,LX(e,Math.min(t.to,e.content.size+1)-1))):t.from<e.content.size+1&&n.push(RX(e,LX(e,Math.min(t.from+1,e.content.size)))),n}function HX(e,t,n){let r=[];if(e.docChanged){let t=JU(e);for(let e of t)r.push(...VX(n.doc,e.newRange))}return e.selectionSet&&(r.push(RX(n.doc,LX(n.doc,e.mapping.map(t.selection.anchor)))),r.push(RX(n.doc,LX(n.doc,n.selection.anchor)))),BX(r)}function UX(e,t,n){let r=Math.max(0,Math.min(e,n.content.size));return{from:r,to:Math.max(r,Math.min(t,n.content.size))}}function WX({decorations:e,ranges:t,editor:n,options:r,dataAttribute:i,doc:a,selection:o}){let s=e;for(let e of t){let{from:t,to:c}=UX(e.from,e.to,a),l=s.find(t,c).filter(e=>e.from>=t&&e.to<=c);l.length&&(s=s.remove(l));let u=FX({editor:n,options:r,dataAttribute:i,doc:a,selection:o,from:t,to:c});u.length&&(s=s.add(a,u))}return s}function GX({editor:e,options:t,dataAttribute:n}){return{init(r,i){return IX({editor:e,options:t,dataAttribute:n,doc:i.doc,selection:i.selection})??QB.empty},apply(r,i,a,o){return!r.docChanged&&!r.selectionSet?i:WX({decorations:i.map(r.mapping,r.doc),ranges:HX(r,a,o),editor:e,options:t,dataAttribute:n,doc:o.doc,selection:o.selection})}}}function KX(e){return e.replace(/\s+/g,`-`).replace(/[^a-zA-Z0-9-]/g,``).replace(/^[0-9-]+/,``).replace(/^-+/,``).toLowerCase()}function qX({editor:e,options:t}){let n=t.dataAttribute?`data-${KX(t.dataAttribute)}`:`data-${jX}`,r=t.showOnlyCurrent&&!t.includeChildren;return new SI({key:MX,...r?{}:{state:GX({editor:e,options:t,dataAttribute:n})},props:{decorations:r?({doc:r,selection:i})=>IX({editor:e,options:t,dataAttribute:n,doc:r,selection:i}):n=>t.showOnlyWhenEditable&&!e.isEditable?QB.empty:MX.getState(n)??QB.empty}})}var JX=PG.create({name:`placeholder`,addOptions(){return{emptyEditorClass:`is-editor-empty`,emptyNodeClass:`is-empty`,dataAttribute:jX,placeholder:`Write something …`,showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[qX({editor:this.editor,options:this.options})]}});function YX(e,t){return!e.selection.empty&&!cW(e.selection)&&t.isEditable}function XX(e,t){return YX(e,t)&&!t.isFocused&&!t.view.dragging}function ZX(){var e;(e=window.getSelection())==null||e.removeAllRanges()}function QX(e){e.focus()}PG.create({name:`selection`,addOptions(){return{className:`selection`}},addProseMirrorPlugins(){let{editor:e,options:t}=this;return[new SI({key:new TI(`selection`),props:{decorations(n){return XX(n,e)?QB.create(n.doc,[YB.inline(n.selection.from,n.selection.to,{class:t.className})]):null},handleDOMEvents:{blur(t){return YX(t.state,e)&&ZX(),!1},focus(t){return YX(t.state,e)&&requestAnimationFrame(()=>{!e.isDestroyed&&t.hasFocus()&&QX(t)}),!1}}}})]}});function $X({types:e,node:t}){return t&&Array.isArray(e)&&e.includes(t.type)||t?.type===e}var eZ=PG.create({name:`trailingNode`,addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){let e=new TI(this.name),t=this.options.node||this.editor.schema.topNodeType.contentMatch.defaultType?.name||`paragraph`,n=Object.entries(this.editor.schema.nodes).map(([,e])=>e).filter(e=>(this.options.notAfter||[]).concat(t).includes(e.name));return[new SI({key:e,appendTransaction:(n,r,i)=>{let{doc:a,tr:o,schema:s}=i,c=e.getState(i),l=a.content.size,u=s.nodes[t];if(!n.some(e=>e.getMeta(`skipTrailingNode`))&&c)return o.insert(l,u.create())},state:{init:(e,t)=>{let r=t.tr.doc.lastChild;return!$X({node:r,types:n})},apply:(e,t)=>{if(!e.docChanged||e.getMeta(`__uniqueIDTransaction`))return t;let r=e.doc.lastChild;return!$X({node:r,types:n})}}})]}}),tZ=PG.create({name:`undoRedo`,addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>DX(e,t),redo:()=>({state:e,dispatch:t})=>OX(e,t)}},addProseMirrorPlugins(){return[TX(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),nZ=new WeakSet,rZ=new WeakSet;function iZ(e){let t=e;return nZ.add(t),t}function aZ(e){return Array.isArray(e)&&nZ.has(e)}function oZ(e){return e.flatMap(e=>e==null?[]:Array.isArray(e)&&rZ.has(e)&&!aZ(e)?oZ(e):[e])}function sZ(e,t){if(e===`slot`)return 0;if(e instanceof Function){let n=e(t);return Array.isArray(n)&&!aZ(n)&&!rZ.has(n)?iZ(n):n}let{children:n,...r}=t??{};if(e===`svg`)throw Error(`SVG elements are not supported in the JSX syntax, use the array syntax instead`);if(Array.isArray(n)){if(aZ(n))return iZ([e,r,n]);if(n.length===0)return iZ([e,r]);let t=oZ(n);return t.length===0?iZ([e,r]):iZ([e,r,...t])}return iZ(n==null?[e,r]:[e,r,n])}var cZ=(e,t)=>sZ(e,t),lZ=(e,t)=>{let{state:n}=e,{selection:r}=n;if(!r.empty)return!1;let{$from:i}=r;if(i.parentOffset!==0)return!1;let a=i.depth-1;if(a<0)return!1;let o=i.node(a),s=i.index(a);if(s===0)return!1;if(o.type===t)return e.commands.lift(t.name);let c=o.child(s-1);if(c.type!==t||!c.lastChild?.isTextblock)return!1;let l=i.before()-1-1;return e.commands.command(({tr:e,dispatch:t})=>{if(!t)return!0;let n=i.parent.content,r=new q(n,0,0);return e.replace(l,i.after(),r),e.setSelection(Y.create(e.doc,l+n.size)),e.scrollIntoView(),t(e),!0})},uZ=/^\s*>\s$/,dZ=tK.create({name:`blockquote`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,group:`block`,defining:!0,parseHTML(){return[{tag:`blockquote`}]},renderHTML({HTMLAttributes:e}){return cZ(`blockquote`,{...jU(this.options.HTMLAttributes,e),children:cZ(`slot`,{})})},parseMarkdown:(e,t)=>{let n=t.parseBlockChildren??t.parseChildren;return t.createNode(`blockquote`,void 0,n(e.tokens||[]))},renderMarkdown:(e,t)=>{if(!e.content)return``;let n=[];return e.content.forEach((e,r)=>{let i=(t.renderChild?.call(t,e,r)??t.renderChildren([e])).split(`
|
|
277
|
+
3. "-" cannot repeat`);yY.customSchemes.push([e,t])}function SY(){yY.scanner=$J(yY.customSchemes);for(let e=0;e<yY.tokenQueue.length;e++)yY.tokenQueue[e][1]({scanner:yY.scanner});yY.parser=mY(yY.scanner.tokens);for(let e=0;e<yY.pluginQueue.length;e++)yY.pluginQueue[e][1]({scanner:yY.scanner,parser:yY.parser});return yY.initialized=!0,yY}function CY(e){return yY.initialized||SY(),hY(yY.parser.start,e,eY(yY.scanner.start,e))}CY.scan=eY;function wY(e,t=null,n=null){if(t&&typeof t==`object`){if(n)throw Error(`linkifyjs: Invalid link type ${t}; must be a string`);n=t,t=null}let r=new aY(n),i=CY(e),a=[];for(let e=0;e<i.length;e++){let n=i[e];n.isLink&&(!t||n.t===t)&&r.check(n)&&a.push(n.toFormattedObject(r))}return a}var TY=`[\0- \xA0 -\u2029 ]`,EY=new RegExp(TY),DY=RegExp(`${TY}$`),OY=new RegExp(TY,`g`);function kY(e){return e.length===1?e[0].isLink:e.length===3&&e[1].isLink?[`()`,`[]`].includes(e[0].value+e[2].value):!1}function AY(e){return new SI({key:new TI(`autolink`),appendTransaction:(t,n,r)=>{let i=t.some(e=>e.docChanged)&&!n.doc.eq(r.doc),a=t.some(e=>e.getMeta(`preventAutolink`));if(!i||a)return;let{tr:o}=r;if(JU(vU(n.doc,[...t])).forEach(({newRange:t})=>{let n=yU(r.doc,t,e=>e.isTextblock),i,a;if(n.length>1)i=n[0],a=r.doc.textBetween(i.pos,i.pos+i.node.nodeSize,void 0,` `);else if(n.length){let e=r.doc.textBetween(t.from,t.to,` `,` `);if(!DY.test(e))return;i=n[0],a=r.doc.textBetween(i.pos,t.to,void 0,` `)}if(i&&a){let t=a.split(EY).filter(Boolean);if(t.length<=0)return!1;let n=t[t.length-1],s=i.pos+a.lastIndexOf(n);if(!n)return!1;let c=CY(n).map(t=>t.toObject(e.defaultProtocol));if(!kY(c))return!1;c.filter(e=>e.isLink).map(e=>({...e,from:s+e.start+1,to:s+e.end+1})).filter(e=>!r.schema.marks.code||!r.doc.rangeHasMark(e.from,e.to,r.schema.marks.code)).filter(t=>e.validate(t.value)).filter(t=>e.shouldAutoLink(t.value)).forEach(t=>{YU(t.from,t.to,r.doc).some(t=>t.mark.type===e.type)||o.addMark(t.from,t.to,e.type.create({href:t.href}))})}}),o.steps.length)return o}})}function jY(e){return new SI({key:new TI(`handleClickLink`),props:{handleClick:(t,n,r)=>{if(r.button!==0||!t.editable)return!1;let i=null;if(r.target instanceof HTMLAnchorElement)i=r.target;else{let t=r.target;if(!t)return!1;let n=e.editor.view.dom;i=t.closest(`a`),i&&!n.contains(i)&&(i=null)}if(!i)return!1;let a=!1;if(e.enableClickSelection&&(a=e.editor.commands.extendMarkRange(e.type.name)),e.openOnClick){let n=GU(t.state,e.type.name),r=i.href??n.href,o=i.target??n.target;r&&(window.open(r,o),a=!0)}return a}}})}var MY=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)$/,NY=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)/g;function PY(e,t){let n=0;for(let r=t-1;r>=0&&e[r]===`\\`;--r)n+=1;return n%2==1}function FY(e,t){let n=0,r=0;for(;r<t;){if(e[r]!=="`"){r+=1;continue}if(n===0&&PY(e,r)){r+=1;continue}let i=0;for(;r<t&&e[r]==="`";)i+=1,r+=1;n===0?n=i:i===n&&(n=0)}return n>0}function IY(e,t,n){let[,r,i]=t;return(t.index?e[t.index-1]:void 0)===`!`||PY(e,t.index??0)||FY(e,t.index??0)?!1:!!r.trim()&&n(i)}function LY(e){let[t,n,r,,i,a,o]=e,s=i??a??o;return{index:e.index??0,text:t,replaceWith:n,data:{href:r,title:s||null,markdown:!0}}}function RY(e,t){return e.index<t.index+t.text.length&&t.index<e.index+e.text.length}function zY(e){return{href:e.data?.href,title:e.data?.title??null}}function BY(e){let t=ZG({find:t=>{let n=MY.exec(t);return!n||!IY(t,n,e.isAllowedHref)?null:LY(n)},type:e.type,getAttributes:zY});return new xG({find:t.find,handler:e=>{let n=t.handler(e);return n!==null&&e.state.tr.steps.length&&e.state.tr.setMeta(`preventAutolink`,!0),n}})}function VY(e){let t=nK({find:t=>{let n=[];for(let r of t.matchAll(NY))IY(t,r,e.isAllowedHref)&&n.push(LY(r));let r=(e.findPlainUrls?.call(e,t)??[]).filter(e=>!n.some(t=>RY(t,e)));return[...n,...r]},type:e.type,getAttributes:zY});return new DG({find:t.find,handler:e=>{let n=t.handler(e);return n!==null&&e.state.tr.steps.length&&e.match.data?.markdown&&e.state.tr.setMeta(`preventAutolink`,!0),n}})}function HY(e){return new SI({key:new TI(`handlePasteLink`),props:{handlePaste:(t,n,r)=>{let{shouldAutoLink:i}=e,{state:a}=t,{selection:o}=a,{empty:s}=o;if(s)return!1;let c=``;r.content.forEach(e=>{c+=e.textContent});let l=wY(c,{defaultProtocol:e.defaultProtocol}).find(e=>e.isLink&&e.value===c);return!c||!l||i!==void 0&&!i(l.value)?!1:e.editor.commands.setMark(e.type,{href:l.href})}}})}function UY(e,t){let n=[`http`,`https`,`ftp`,`ftps`,`mailto`,`tel`,`callto`,`sms`,`cid`,`xmpp`];return t&&t.forEach(e=>{let t=typeof e==`string`?e:e.scheme;t&&n.push(t)}),!e||e.replace(OY,``).match(RegExp(`^(?:(?:${n.map(e=>e.replace(/[-/\\^$*+?.()|[\]{}]/g,`\\$&`)).join(`|`)}):|[^a-z]|[a-z0-9+.\\-]+(?:[^a-z+.\\-:]|$))`,`i`))}var WY=EG.create({name:`link`,priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(e=>{if(typeof e==`string`){xY(e);return}xY(e.scheme,e.optionalSlashes)})},onDestroy(){bY()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,markdownLinks:!1,autolink:!0,protocols:[],defaultProtocol:`http`,HTMLAttributes:{target:`_blank`,rel:`noopener noreferrer nofollow`,class:null},isAllowedUri:(e,t)=>!!UY(e,t.protocols),validate:e=>!!e,shouldAutoLink:e=>{let t=/^[a-z][a-z0-9+.-]*:\/\//i.test(e),n=/^[a-z][a-z0-9+.-]*:/i.test(e);if(t||n&&!e.includes(`@`))return!0;let r=(e.includes(`@`)?e.split(`@`).pop():e).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(r)||!/\./.test(r))}}},addAttributes(){return{href:{default:null,parseHTML(e){return e.getAttribute(`href`)}},target:{default:this.options.HTMLAttributes.target??null},rel:{default:this.options.HTMLAttributes.rel??null},class:{default:this.options.HTMLAttributes.class??null},title:{default:null}}},parseHTML(){return[{tag:`a[href]`,getAttrs:e=>{let t=e.getAttribute(`href`);return!t||!this.options.isAllowedUri(t,{defaultValidate:e=>!!UY(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:e}){return this.options.isAllowedUri(e.href,{defaultValidate:e=>!!UY(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?[`a`,jU(this.options.HTMLAttributes,e),0]:[`a`,jU(this.options.HTMLAttributes,{...e,href:``}),0]},markdownTokenName:`link`,parseMarkdown:(e,t)=>t.applyMark(`link`,t.parseInline(e.tokens||[]),{href:e.href,title:e.title||null}),renderMarkdown:(e,t)=>{let n=e.attrs?.href??``,r=e.attrs?.title??``,i=t.renderChildren(e);return r?`[${i}](${n} "${r}")`:`[${i}](${n})`},addCommands(){return{setLink:e=>({chain:t})=>{let{href:n}=e;return this.options.isAllowedUri(n,{defaultValidate:e=>!!UY(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?t().setMark(this.name,e).setMeta(`preventAutolink`,!0).run():!1},toggleLink:e=>({chain:t})=>{let{href:n}=e||{};return n&&!this.options.isAllowedUri(n,{defaultValidate:e=>!!UY(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:t().toggleMark(this.name,e,{extendEmptyMarkRange:!0}).setMeta(`preventAutolink`,!0).run()},unsetLink:()=>({chain:e})=>e().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta(`preventAutolink`,!0).run()}},addInputRules(){return this.options.markdownLinks?[BY({type:this.type,isAllowedHref:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!UY(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})})]:[]},addPasteRules(){let e=e=>{let t=[];if(e){let{protocols:n,defaultProtocol:r}=this.options;wY(e).filter(e=>e.isLink&&this.options.isAllowedUri(e.value,{defaultValidate:e=>!!UY(e,n),protocols:n,defaultProtocol:r})).forEach(e=>{this.options.shouldAutoLink(e.value)&&t.push({text:e.value,data:{href:e.href},index:e.start})})}return t};return this.options.markdownLinks?[VY({type:this.type,isAllowedHref:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!UY(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol}),findPlainUrls:e})]:[nK({find:e,type:this.type,getAttributes:e=>({href:e.data?.href})})]},addProseMirrorPlugins(){let e=[],{protocols:t,defaultProtocol:n}=this.options;return this.options.autolink&&e.push(AY({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!UY(e,t),protocols:t,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),e.push(jY({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick===`whenNotEditable`||this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&e.push(HY({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),e}}),GY=WY;function KY(e={}){return new SI({view(t){return new qY(t,e)}})}var qY=class{constructor(e,t){this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.lastDragEvent=null,this.width=t.width??1,this.color=t.color===!1?void 0:t.color||`black`,this.class=t.class,this.handlers=[`dragover`,`dragend`,`drop`,`dragleave`].map(t=>{let n=e=>{this[t](e)};return e.dom.addEventListener(t,n),{name:t,handler:n}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){if(this.cursorPos!=null&&t.doc!=e.state.doc)if(this.lastDragEvent){let e=this.computeTarget(this.lastDragEvent);e==this.cursorPos?this.updateOverlay():this.setCursor(e)}else this.updateOverlay()}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,n,r=this.editorView.dom,i=r.getBoundingClientRect(),a=i.width/r.offsetWidth,o=i.height/r.offsetHeight;if(t){let t=e.nodeBefore,r=e.nodeAfter;if(t||r){let e=this.editorView.nodeDOM(this.cursorPos-(t?t.nodeSize:0));if(e){let i=e.getBoundingClientRect(),a=t?i.bottom:i.top;t&&r&&(a=(a+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let s=this.width/2*o;n={left:i.left,right:i.right,top:a-s,bottom:a+s}}}}if(!n){let e=this.editorView.coordsAtPos(this.cursorPos),t=this.width/2*a;n={left:e.left-t,right:e.left+t,top:e.top,bottom:e.bottom}}let s=this.editorView.dom.offsetParent;this.element||(this.element=s.appendChild(document.createElement(`div`)),this.class&&(this.element.className=this.class),this.element.style.cssText=`position: absolute; z-index: 50; pointer-events: none;`,this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle(`prosemirror-dropcursor-block`,t),this.element.classList.toggle(`prosemirror-dropcursor-inline`,!t);let c,l;if(!s||s==document.body&&getComputedStyle(s).position==`static`)c=-pageXOffset,l=-pageYOffset;else{let e=s.getBoundingClientRect(),t=e.width/s.offsetWidth,n=e.height/s.offsetHeight;c=e.left-s.scrollLeft*t,l=e.top-s.scrollTop*n}this.element.style.left=(n.left-c)/a+`px`,this.element.style.top=(n.top-l)/o+`px`,this.element.style.width=(n.right-n.left)/a+`px`,this.element.style.height=(n.bottom-n.top)/o+`px`}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}computeTarget(e){let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),r=n&&n.type.spec.disableDropCursor,i=typeof r==`function`?r(this.editorView,t,e):r;if(!t||i)return null;let a=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let e=IF(this.editorView.state.doc,a,this.editorView.dragging.slice);e!=null&&(a=e)}return a}dragover(e){if(!this.editorView.editable)return;this.lastDragEvent=e;let t=this.computeTarget(e);t!=null&&(this.setCursor(t),this.scheduleRemoval(5e3))}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}},JY=class e extends J{constructor(e){super(e,e)}map(t,n){let r=t.resolve(n.map(this.head));return e.valid(r)?new e(r):J.near(r)}content(){return q.empty}eq(t){return t instanceof e&&t.head==this.head}toJSON(){return{type:`gapcursor`,pos:this.head}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for GapCursor.fromJSON`);return new e(t.resolve(n.pos))}getBookmark(){return new YY(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!ZY(e)||!QY(e))return!1;let n=t.type.spec.allowGapCursor;if(n!=null)return n;let r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(t,n,r=!1){search:for(;;){if(!r&&e.valid(t))return t;let i=t.pos,a=null;for(let r=t.depth;;r--){let o=t.node(r);if(n>0?t.indexAfter(r)<o.childCount:t.index(r)>0){a=o.child(n>0?t.indexAfter(r):t.index(r)-1);break}else if(r==0)return null;i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}for(;;){let o=n>0?a.firstChild:a.lastChild;if(!o){if(a.isAtom&&!a.isText&&!X.isSelectable(a)){t=t.doc.resolve(i+a.nodeSize*n),r=!1;continue search}break}a=o,i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}return null}}};JY.prototype.visible=!1,JY.findFrom=JY.findGapCursorFrom,J.jsonID(`gapcursor`,JY);var YY=class e{constructor(e){this.pos=e}map(t){return new e(t.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return JY.valid(t)?new JY(t):J.near(t)}};function XY(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function ZY(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n-1);;e=e.lastChild){if(e.childCount==0&&!e.inlineContent||XY(e.type))return!0;if(e.inlineContent)return!1}}return!0}function QY(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n);;e=e.firstChild){if(e.childCount==0&&!e.inlineContent||XY(e.type))return!0;if(e.inlineContent)return!1}}return!0}function $Y(){return new SI({props:{decorations:iX,createSelectionBetween(e,t,n){return t.pos==n.pos&&JY.valid(n)?new JY(n):null},handleClick:nX,handleKeyDown:eX,handleDOMEvents:{beforeinput:rX}}})}var eX=QV({ArrowLeft:tX(`horiz`,-1),ArrowRight:tX(`horiz`,1),ArrowUp:tX(`vert`,-1),ArrowDown:tX(`vert`,1)});function tX(e,t){let n=e==`vert`?t>0?`down`:`up`:t>0?`right`:`left`;return function(e,r,i){let a=e.selection,o=t>0?a.$to:a.$from,s=a.empty;if(a instanceof Y){if(!i.endOfTextblock(n)||o.depth==0)return!1;s=!1,o=e.doc.resolve(t>0?o.after():o.before())}let c=JY.findGapCursorFrom(o,t,s);return c?(r&&r(e.tr.setSelection(new JY(c))),!0):!1}}function nX(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!JY.valid(r))return!1;let i=e.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&X.isSelectable(e.state.doc.nodeAt(i.inside))?!1:(e.dispatch(e.state.tr.setSelection(new JY(r))),!0)}function rX(e,t){if(t.inputType!=`insertCompositionText`||!(e.state.selection instanceof JY))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let i=K.empty;for(let e=r.length-1;e>=0;e--)i=K.from(r[e].createAndFill(null,i));let a=e.state.tr.replace(n.pos,n.pos,new q(i,0,0));return a.setSelection(Y.near(a.doc.resolve(n.pos+1))),e.dispatch(a),!1}function iX(e){if(!(e.selection instanceof JY))return null;let t=document.createElement(`div`);return t.className=`ProseMirror-gapcursor`,QB.create(e.doc,[YB.widget(e.selection.head,t,{key:`gapcursor`})])}var aX=200,oX=function(){};oX.prototype.append=function(e){return e.length?(e=oX.from(e),!this.length&&e||e.length<aX&&this.leafAppend(e)||this.length<aX&&e.leafPrepend(this)||this.appendInner(e)):this},oX.prototype.prepend=function(e){return e.length?oX.from(e).append(this):this},oX.prototype.appendInner=function(e){return new cX(this,e)},oX.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?oX.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},oX.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},oX.prototype.forEach=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},oX.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var r=[];return this.forEach(function(t,n){return r.push(e(t,n))},t,n),r},oX.from=function(e){return e instanceof oX?e:e&&e.length?new sX(e):oX.empty};var sX=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return e==0&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,r){for(var i=t;i<n;i++)if(e(this.values[i],r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){for(var i=t-1;i>=n;i--)if(e(this.values[i],r+i)===!1)return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=aX)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=aX)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(oX);oX.empty=new sX([]);var cX=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,t,n,r){var i=this.left.length;if(t<i&&this.left.forEachInner(e,t,Math.min(n,i),r)===!1||n>i&&this.right.forEachInner(e,Math.max(t-i,0),Math.min(this.length,n)-i,r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){var i=this.left.length;if(t>i&&this.right.forEachInvertedInner(e,t-i,Math.max(n,i)-i,r+i)===!1||n<i&&this.left.forEachInvertedInner(e,Math.min(t,i),n,r)===!1)return!1},t.prototype.sliceInner=function(e,t){if(e==0&&t==this.length)return this;var n=this.left.length;return t<=n?this.left.slice(e,t):e>=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(oX),lX=500,uX=class e{constructor(e,t){this.items=e,this.eventCount=t}popEvent(t,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,a;n&&(i=this.remapping(r,this.items.length),a=i.maps.length);let o=t.tr,s,c,l=[],u=[];return this.items.forEach((t,n)=>{if(!t.step){i||(i=this.remapping(r,n+1),a=i.maps.length),a--,u.push(t);return}if(i){u.push(new fX(t.map));let e=t.step.map(i.slice(a)),n;e&&o.maybeStep(e).doc&&(n=o.mapping.maps[o.mapping.maps.length-1],l.push(new fX(n,void 0,void 0,l.length+u.length))),a--,n&&i.appendMap(n,a)}else o.maybeStep(t.step);if(t.selection)return s=i?t.selection.map(i.slice(a)):t.selection,c=new e(this.items.slice(0,r).append(u.reverse().concat(l)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:o,selection:s}}addTransform(t,n,r,i){let a=[],o=this.eventCount,s=this.items,c=!i&&s.length?s.get(s.length-1):null;for(let e=0;e<t.steps.length;e++){let r=t.steps[e].invert(t.docs[e]),l=new fX(t.mapping.maps[e],r,n),u;(u=c&&c.merge(l))&&(l=u,e?a.pop():s=s.slice(0,s.length-1)),a.push(l),n&&=(o++,void 0),i||(c=l)}let l=o-r.depth;return l>mX&&(s=dX(s,l),o-=l),new e(s.append(a),o)}remapping(e,t){let n=new eF;return this.items.forEach((t,r)=>{let i=t.mirrorOffset!=null&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,i)},e,t),n}addMaps(t){return this.eventCount==0?this:new e(this.items.append(t.map(e=>new fX(e))),this.eventCount)}rebased(t,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),a=t.mapping,o=t.steps.length,s=this.eventCount;this.items.forEach(e=>{e.selection&&s--},i);let c=n;this.items.forEach(e=>{let n=a.getMirror(--c);if(n==null)return;o=Math.min(o,n);let i=a.maps[n];if(e.step){let o=t.steps[n].invert(t.docs[n]),l=e.selection&&e.selection.map(a.slice(c+1,n));l&&s++,r.push(new fX(i,o,l))}else r.push(new fX(i))},i);let l=[];for(let e=n;e<o;e++)l.push(new fX(a.maps[e]));let u=this.items.slice(0,i).append(l).append(r),d=new e(u,s);return d.emptyItemCount()>lX&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(t=this.items.length){let n=this.remapping(0,t),r=n.maps.length,i=[],a=0;return this.items.forEach((e,o)=>{if(o>=t)i.push(e),e.selection&&a++;else if(e.step){let t=e.step.map(n.slice(r)),o=t&&t.getMap();if(r--,o&&n.appendMap(o,r),t){let s=e.selection&&e.selection.map(n.slice(r));s&&a++;let c=new fX(o.invert(),t,s),l,u=i.length-1;(l=i.length&&i[u].merge(c))?i[u]=l:i.push(c)}}else e.map&&r--},this.items.length,0),new e(oX.from(i.reverse()),a)}};uX.empty=new uX(oX.empty,0);function dX(e,t){let n;return e.forEach((e,r)=>{if(e.selection&&t--==0)return n=r,!1}),e.slice(n)}var fX=class e{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(t){if(this.step&&t.step&&!t.selection){let n=t.step.merge(this.step);if(n)return new e(n.getMap().invert(),n,this.selection)}}},pX=class{constructor(e,t,n,r,i){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=i}},mX=20;function hX(e,t,n,r){let i=n.getMeta(CX),a;if(i)return i.historyState;n.getMeta(Fee)&&(e=new pX(e.done,e.undone,null,0,-1));let o=n.getMeta(`appendedTransaction`);if(n.steps.length==0)return e;if(o&&o.getMeta(CX))return o.getMeta(CX).redo?new pX(e.done.addTransform(n,void 0,r,SX(t)),e.undone,_X(n.mapping.maps),e.prevTime,e.prevComposition):new pX(e.done,e.undone.addTransform(n,void 0,r,SX(t)),null,e.prevTime,e.prevComposition);if(n.getMeta(`addToHistory`)!==!1&&!(o&&o.getMeta(`addToHistory`)===!1)){let i=n.getMeta(`composition`),a=e.prevTime==0||!o&&e.prevComposition!=i&&(e.prevTime<(n.time||0)-r.newGroupDelay||!gX(n,e.prevRanges)),s=o?vX(e.prevRanges,n.mapping):_X(n.mapping.maps);return new pX(e.done.addTransform(n,a?t.selection.getBookmark():void 0,r,SX(t)),uX.empty,s,n.time,i??e.prevComposition)}else if(a=n.getMeta(`rebased`))return new pX(e.done.rebased(n,a),e.undone.rebased(n,a),vX(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);else return new pX(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),vX(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}function gX(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((e,r)=>{for(let i=0;i<t.length;i+=2)e<=t[i+1]&&r>=t[i]&&(n=!0)}),n}function _X(e){let t=[];for(let n=e.length-1;n>=0&&t.length==0;n--)e[n].forEach((e,n,r,i)=>t.push(r,i));return t}function vX(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let i=t.map(e[r],1),a=t.map(e[r+1],-1);i<=a&&n.push(i,a)}return n}function yX(e,t,n){let r=SX(t),i=CX.get(t).spec.config,a=(n?e.undone:e.done).popEvent(t,r);if(!a)return null;let o=a.selection.resolve(a.transform.doc),s=(n?e.done:e.undone).addTransform(a.transform,t.selection.getBookmark(),i,r),c=new pX(n?s:a.remaining,n?a.remaining:s,null,0,-1);return a.transform.setSelection(o).setMeta(CX,{redo:n,historyState:c})}var bX=!1,xX=null;function SX(e){let t=e.plugins;if(xX!=t){bX=!1,xX=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){bX=!0;break}}return bX}var CX=new TI(`history`),Fee=new TI(`closeHistory`);function wX(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new SI({key:CX,state:{init(){return new pX(uX.empty,uX.empty,null,0,-1)},apply(t,n,r){return hX(n,r,t,e)}},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,r=n==`historyUndo`?EX:n==`historyRedo`?DX:null;return!r||!e.editable?!1:(t.preventDefault(),r(e.state,e.dispatch))}}}})}function TX(e,t){return(n,r)=>{let i=CX.getState(n);if(!i||(e?i.undone:i.done).eventCount==0)return!1;if(r){let a=yX(i,n,e);a&&r(t?a.scrollIntoView():a)}return!0}}var EX=TX(!1,!0),DX=TX(!0,!0);PG.create({name:`characterCount`,addOptions(){return{limit:null,autoTrim:!0,mode:`textSize`,textCounter:e=>e.length,wordCounter:e=>e.split(` `).filter(e=>e!==``).length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=e=>{let t=e?.node||this.editor.state.doc;if((e?.mode||this.options.mode)===`textSize`){let e=t.textBetween(0,t.content.size,void 0,` `);return this.options.textCounter(e)}return t.nodeSize},this.storage.words=e=>{let t=e?.node||this.editor.state.doc,n=t.textBetween(0,t.content.size,` `,` `);return this.options.wordCounter(n)}},addProseMirrorPlugins(){let e=!1;return[new SI({key:new TI(`characterCount`),appendTransaction:(t,n,r)=>{if(e)return;let i=this.options.limit,a=this.options.autoTrim;if(i==null||i===0||a===!1){e=!0;return}let o=this.storage.characters({node:r.doc});if(o>i){let t=o-i;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);let n=r.tr.deleteRange(0,t);return e=!0,n}e=!0},filterTransaction:(e,t)=>{let n=this.options.limit;if(!e.docChanged||n===0||n==null)return!0;let r=this.storage.characters({node:t.doc}),i=this.storage.characters({node:e.doc});if(i<=n||r>n&&i>n&&i<=r)return!0;if(r>n&&i>n&&i>r||!e.getMeta(`paste`))return!1;let a=e.selection.$head.pos,o=a-(i-n),s=a;return e.deleteRange(o,s),!(this.storage.characters({node:e.doc})>n)}})]}});var OX=PG.create({name:`dropCursor`,addOptions(){return{color:`currentColor`,width:1,class:void 0}},addProseMirrorPlugins(){return[KY(this.options)]}});PG.create({name:`focus`,addOptions(){return{className:`has-focus`,mode:`all`}},addProseMirrorPlugins(){return[new SI({key:new TI(`focus`),props:{decorations:({doc:e,selection:t})=>{let{isEditable:n,isFocused:r}=this.editor,{anchor:i}=t,a=[];if(!n||!r)return QB.create(e,[]);let o=0;this.options.mode===`deepest`&&e.descendants((e,t)=>{if(!e.isText){if(!(i>=t&&i<=t+e.nodeSize-1))return!1;o+=1}});let s=0;return e.descendants((e,t)=>{if(e.isText||!(i>=t&&i<=t+e.nodeSize-1))return!1;if(s+=1,this.options.mode===`deepest`&&o-s>0||this.options.mode===`shallowest`&&s>1)return this.options.mode===`deepest`;a.push(YB.node(t,t+e.nodeSize,{class:this.options.className}))}),QB.create(e,a)}}})]}});var kX=PG.create({name:`gapCursor`,addProseMirrorPlugins(){return[$Y()]},extendNodeSchema(e){return{allowGapCursor:TU(Z(e,`allowGapCursor`,{name:e.name,options:e.options,storage:e.storage}))??null}}}),AX=`placeholder`,jX=new TI(`tiptap__placeholder`);function MX(e){let{editor:t,placeholder:n,dataAttribute:r,pos:i,node:a,isEmptyDoc:o,hasAnchor:s,classes:{emptyNode:c,emptyEditor:l}}=e,u=[c];return o&&u.push(l),YB.node(i,i+a.nodeSize,{class:u.join(` `),[r]:typeof n==`function`?n({editor:t,node:a,pos:i,hasAnchor:s}):n})}function NX(e,t){return typeof e==`function`?e(t):e}function PX({editor:e,options:t,dataAttribute:n,doc:r,selection:i,from:a,to:o}){let{anchor:s}=i,c=[],l=e.isEmpty;return r.nodesBetween(a,o,(r,i)=>{let a=s>=i&&s<=i+r.nodeSize,o=!r.isLeaf&&sW(r);return r.type.isTextblock&&(a||!t.showOnlyCurrent)&&o&&c.push(MX({editor:e,isEmptyDoc:l,dataAttribute:n,hasAnchor:a,placeholder:t.placeholder,classes:{emptyEditor:t.emptyEditorClass,emptyNode:NX(t.emptyNodeClass,{editor:e,node:r,pos:i,hasAnchor:a})},node:r,pos:i})),t.includeChildren}),c}function FX({editor:e,options:t,dataAttribute:n,doc:r,selection:i}){if(!(e.isEditable||!t.showOnlyWhenEditable))return null;let{anchor:a}=i,o=[],s=e.isEmpty;if(t.showOnlyCurrent&&!t.includeChildren){let i=r.resolve(a),c=i.depth>0?i.node(1):i.nodeAfter,l=i.depth>0?i.before(1):a;if(c&&c.type.isTextblock&&sW(c)){let r=a>=l&&a<=l+c.nodeSize;o.push(MX({editor:e,isEmptyDoc:s,dataAttribute:n,hasAnchor:r,placeholder:t.placeholder,classes:{emptyEditor:t.emptyEditorClass,emptyNode:NX(t.emptyNodeClass,{editor:e,node:c,pos:l,hasAnchor:r})},node:c,pos:l}))}}else o.push(...PX({editor:e,options:t,dataAttribute:n,doc:r,selection:i,from:0,to:r.content.size}));return QB.create(r,o)}function IX(e,t){let n=e.resolve(t);if(n.depth===0){let e=n.nodeAfter??n.nodeBefore;if(!e)return{from:t,to:t};let r=n.nodeAfter?t:t-e.nodeSize;return{from:r,to:r+e.nodeSize}}let r=n.before(1);return{from:r,to:r+n.node(1).nodeSize}}function LX(e,t){return{from:Math.max(0,t.from-1),to:Math.min(e.content.size,t.to-1)}}function RX(e,t,n){let r=[];return e.forEach((e,i)=>{let a=i,o=a+e.nodeSize,s=a+1,c=o+1;s<n&&c>t&&r.push({from:a,to:o})}),r}function zX(e){if(e.length===0)return[];let t=[...e].sort((e,t)=>e.from-t.from),n=[{...t[0]}];for(let e=1;e<t.length;e+=1){let r=n[n.length-1],i=t[e];i.from<=r.to?r.to=Math.max(r.to,i.to):n.push({...i})}return n}function BX(e,t){let n=RX(e,t.from,t.to);return n.push(LX(e,IX(e,t.from))),t.to>t.from?n.push(LX(e,IX(e,Math.min(t.to,e.content.size+1)-1))):t.from<e.content.size+1&&n.push(LX(e,IX(e,Math.min(t.from+1,e.content.size)))),n}function VX(e,t,n){let r=[];if(e.docChanged){let t=JU(e);for(let e of t)r.push(...BX(n.doc,e.newRange))}return e.selectionSet&&(r.push(LX(n.doc,IX(n.doc,e.mapping.map(t.selection.anchor)))),r.push(LX(n.doc,IX(n.doc,n.selection.anchor)))),zX(r)}function HX(e,t,n){let r=Math.max(0,Math.min(e,n.content.size));return{from:r,to:Math.max(r,Math.min(t,n.content.size))}}function UX({decorations:e,ranges:t,editor:n,options:r,dataAttribute:i,doc:a,selection:o}){let s=e;for(let e of t){let{from:t,to:c}=HX(e.from,e.to,a),l=s.find(t,c).filter(e=>e.from>=t&&e.to<=c);l.length&&(s=s.remove(l));let u=PX({editor:n,options:r,dataAttribute:i,doc:a,selection:o,from:t,to:c});u.length&&(s=s.add(a,u))}return s}function WX({editor:e,options:t,dataAttribute:n}){return{init(r,i){return FX({editor:e,options:t,dataAttribute:n,doc:i.doc,selection:i.selection})??QB.empty},apply(r,i,a,o){return!r.docChanged&&!r.selectionSet?i:UX({decorations:i.map(r.mapping,r.doc),ranges:VX(r,a,o),editor:e,options:t,dataAttribute:n,doc:o.doc,selection:o.selection})}}}function GX(e){return e.replace(/\s+/g,`-`).replace(/[^a-zA-Z0-9-]/g,``).replace(/^[0-9-]+/,``).replace(/^-+/,``).toLowerCase()}function KX({editor:e,options:t}){let n=t.dataAttribute?`data-${GX(t.dataAttribute)}`:`data-${AX}`,r=t.showOnlyCurrent&&!t.includeChildren;return new SI({key:jX,...r?{}:{state:WX({editor:e,options:t,dataAttribute:n})},props:{decorations:r?({doc:r,selection:i})=>FX({editor:e,options:t,dataAttribute:n,doc:r,selection:i}):n=>t.showOnlyWhenEditable&&!e.isEditable?QB.empty:jX.getState(n)??QB.empty}})}var qX=PG.create({name:`placeholder`,addOptions(){return{emptyEditorClass:`is-editor-empty`,emptyNodeClass:`is-empty`,dataAttribute:AX,placeholder:`Write something …`,showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[KX({editor:this.editor,options:this.options})]}});function JX(e,t){return!e.selection.empty&&!cW(e.selection)&&t.isEditable}function YX(e,t){return JX(e,t)&&!t.isFocused&&!t.view.dragging}function XX(){var e;(e=window.getSelection())==null||e.removeAllRanges()}function ZX(e){e.focus()}PG.create({name:`selection`,addOptions(){return{className:`selection`}},addProseMirrorPlugins(){let{editor:e,options:t}=this;return[new SI({key:new TI(`selection`),props:{decorations(n){return YX(n,e)?QB.create(n.doc,[YB.inline(n.selection.from,n.selection.to,{class:t.className})]):null},handleDOMEvents:{blur(t){return JX(t.state,e)&&XX(),!1},focus(t){return JX(t.state,e)&&requestAnimationFrame(()=>{!e.isDestroyed&&t.hasFocus()&&ZX(t)}),!1}}}})]}});function QX({types:e,node:t}){return t&&Array.isArray(e)&&e.includes(t.type)||t?.type===e}var $X=PG.create({name:`trailingNode`,addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){let e=new TI(this.name),t=this.options.node||this.editor.schema.topNodeType.contentMatch.defaultType?.name||`paragraph`,n=Object.entries(this.editor.schema.nodes).map(([,e])=>e).filter(e=>(this.options.notAfter||[]).concat(t).includes(e.name));return[new SI({key:e,appendTransaction:(n,r,i)=>{let{doc:a,tr:o,schema:s}=i,c=e.getState(i),l=a.content.size,u=s.nodes[t];if(!n.some(e=>e.getMeta(`skipTrailingNode`))&&c)return o.insert(l,u.create())},state:{init:(e,t)=>{let r=t.tr.doc.lastChild;return!QX({node:r,types:n})},apply:(e,t)=>{if(!e.docChanged||e.getMeta(`__uniqueIDTransaction`))return t;let r=e.doc.lastChild;return!QX({node:r,types:n})}}})]}}),eZ=PG.create({name:`undoRedo`,addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>EX(e,t),redo:()=>({state:e,dispatch:t})=>DX(e,t)}},addProseMirrorPlugins(){return[wX(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),tZ=new WeakSet,nZ=new WeakSet;function rZ(e){let t=e;return tZ.add(t),t}function iZ(e){return Array.isArray(e)&&tZ.has(e)}function aZ(e){return e.flatMap(e=>e==null?[]:Array.isArray(e)&&nZ.has(e)&&!iZ(e)?aZ(e):[e])}function oZ(e,t){if(e===`slot`)return 0;if(e instanceof Function){let n=e(t);return Array.isArray(n)&&!iZ(n)&&!nZ.has(n)?rZ(n):n}let{children:n,...r}=t??{};if(e===`svg`)throw Error(`SVG elements are not supported in the JSX syntax, use the array syntax instead`);if(Array.isArray(n)){if(iZ(n))return rZ([e,r,n]);if(n.length===0)return rZ([e,r]);let t=aZ(n);return t.length===0?rZ([e,r]):rZ([e,r,...t])}return rZ(n==null?[e,r]:[e,r,n])}var sZ=(e,t)=>oZ(e,t),cZ=(e,t)=>{let{state:n}=e,{selection:r}=n;if(!r.empty)return!1;let{$from:i}=r;if(i.parentOffset!==0)return!1;let a=i.depth-1;if(a<0)return!1;let o=i.node(a),s=i.index(a);if(s===0)return!1;if(o.type===t)return e.commands.lift(t.name);let c=o.child(s-1);if(c.type!==t||!c.lastChild?.isTextblock)return!1;let l=i.before()-1-1;return e.commands.command(({tr:e,dispatch:t})=>{if(!t)return!0;let n=i.parent.content,r=new q(n,0,0);return e.replace(l,i.after(),r),e.setSelection(Y.create(e.doc,l+n.size)),e.scrollIntoView(),t(e),!0})},lZ=/^\s*>\s$/,uZ=tK.create({name:`blockquote`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,group:`block`,defining:!0,parseHTML(){return[{tag:`blockquote`}]},renderHTML({HTMLAttributes:e}){return sZ(`blockquote`,{...jU(this.options.HTMLAttributes,e),children:sZ(`slot`,{})})},parseMarkdown:(e,t)=>{let n=t.parseBlockChildren??t.parseChildren;return t.createNode(`blockquote`,void 0,n(e.tokens||[]))},renderMarkdown:(e,t)=>{if(!e.content)return``;let n=[];return e.content.forEach((e,r)=>{let i=(t.renderChild?.call(t,e,r)??t.renderChildren([e])).split(`
|
|
278
278
|
`).map(e=>e.trim()===``?`>`:`> ${e}`);n.push(i.join(`
|
|
279
279
|
`))}),n.join(`
|
|
280
280
|
>
|
|
281
|
-
`)},addCommands(){return{setBlockquote:()=>({commands:e})=>e.wrapIn(this.name),toggleBlockquote:()=>({commands:e})=>e.toggleWrap(this.name),unsetBlockquote:()=>({commands:e})=>e.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote(),Backspace:()=>
|
|
282
|
-
`):`\`\`\`${r}\n\n\`\`\``,n},addCommands(){return{setCodeBlock:e=>({commands:t})=>t.setNode(this.name,e),toggleCodeBlock:e=>({commands:t})=>t.toggleNode(this.name,`paragraph`,e)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{let{empty:e,$anchor:t}=this.editor.state.selection,n=t.pos===1;return!e||t.parent.type.name!==this.name?!1:n||!t.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:e})=>{if(!this.options.enableTabIndentation)return!1;let t=this.options.tabSize??
|
|
281
|
+
`)},addCommands(){return{setBlockquote:()=>({commands:e})=>e.wrapIn(this.name),toggleBlockquote:()=>({commands:e})=>e.toggleWrap(this.name),unsetBlockquote:()=>({commands:e})=>e.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote(),Backspace:()=>cZ(this.editor,this.type)}},addInputRules(){return[eK({find:lZ,type:this.type})]}}),dZ=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,fZ=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,pZ=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,mZ=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,hZ=EG.create({name:`bold`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`strong`},{tag:`b`,getAttrs:e=>e.style.fontWeight!==`normal`&&null},{style:`font-weight=400`,clearMark:e=>e.type.name===this.name},{style:`font-weight`,getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}]},renderHTML({HTMLAttributes:e}){return sZ(`strong`,{...jU(this.options.HTMLAttributes,e),children:sZ(`slot`,{})})},markdownTokenName:`strong`,parseMarkdown:(e,t)=>t.applyMark(`bold`,t.parseInline(e.tokens||[])),markdownOptions:{htmlReopen:{open:`<strong>`,close:`</strong>`}},renderMarkdown:(e,t)=>`**${t.renderChildren(e)}**`,addCommands(){return{setBold:()=>({commands:e})=>e.setMark(this.name),toggleBold:()=>({commands:e})=>e.toggleMark(this.name),unsetBold:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[ZG({find:dZ,type:this.type}),ZG({find:pZ,type:this.type})]},addPasteRules(){return[nK({find:fZ,type:this.type}),nK({find:mZ,type:this.type})]}}),gZ=e=>{let t=/`([^`]+)`(?!`)$/.exec(e);return!t||t.index>0&&e[t.index-1]==="`"?null:{index:t.index,text:t[0],replaceWith:t[1]}},_Z=e=>{let t=/`([^`]+)`(?!`)/g,n=[],r;for(;(r=t.exec(e))!==null;)r.index>0&&e[r.index-1]==="`"||n.push({index:r.index,text:r[0],replaceWith:r[1]});return n},vZ=EG.create({name:`code`,addOptions(){return{HTMLAttributes:{}}},excludes:`_`,code:!0,exitable:!0,parseHTML(){return[{tag:`code`}]},renderHTML({HTMLAttributes:e}){return[`code`,jU(this.options.HTMLAttributes,e),0]},markdownTokenName:`codespan`,parseMarkdown:(e,t)=>t.applyMark(`code`,[{type:`text`,text:e.text||``}]),renderMarkdown:(e,t)=>e.content?`\`${t.renderChildren(e.content)}\``:``,addCommands(){return{setCode:()=>({commands:e})=>e.setMark(this.name),toggleCode:()=>({commands:e})=>e.toggleMark(this.name),unsetCode:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[ZG({find:gZ,type:this.type})]},addPasteRules(){return[nK({find:_Z,type:this.type})]}}),yZ=4,bZ=/^```([a-z]+)?[\s\n]$/,xZ=/^~~~([a-z]+)?[\s\n]$/,SZ=tK.create({name:`codeBlock`,addOptions(){return{languageClassPrefix:`language-`,exitOnTripleEnter:!0,exitOnArrowDown:!0,exitOnArrowUp:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:yZ,HTMLAttributes:{}}},content:`text*`,marks:``,group:`block`,code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:e=>{let{languageClassPrefix:t}=this.options;return t&&[...e.firstElementChild?.classList||[]].filter(e=>e.startsWith(t)).map(e=>e.replace(t,``))[0]||null},rendered:!1}}},parseHTML(){return[{tag:`pre`,preserveWhitespace:`full`}]},renderHTML({node:e,HTMLAttributes:t}){return[`pre`,jU(this.options.HTMLAttributes,t),[`code`,{class:e.attrs.language?this.options.languageClassPrefix+e.attrs.language:null},0]]},markdownTokenName:`code`,parseMarkdown:(e,t)=>e.raw?.startsWith("```")===!1&&e.raw?.startsWith(`~~~`)===!1&&e.codeBlockStyle!==`indented`?[]:t.createNode(`codeBlock`,{language:e.lang||null},e.text?[t.createTextNode(e.text)]:[]),renderMarkdown:(e,t)=>{let n=``,r=e.attrs?.language||``;return n=e.content?[`\`\`\`${r}`,t.renderChildren(e.content),"```"].join(`
|
|
282
|
+
`):`\`\`\`${r}\n\n\`\`\``,n},addCommands(){return{setCodeBlock:e=>({commands:t})=>t.setNode(this.name,e),toggleCodeBlock:e=>({commands:t})=>t.toggleNode(this.name,`paragraph`,e)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{let{empty:e,$anchor:t}=this.editor.state.selection,n=t.pos===1;return!e||t.parent.type.name!==this.name?!1:n||!t.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:e})=>{if(!this.options.enableTabIndentation)return!1;let t=this.options.tabSize??yZ,{state:n}=e,{selection:r}=n,{$from:i,empty:a}=r;if(i.parent.type!==this.type)return!1;let o=` `.repeat(t);return a?e.commands.insertContent(o):e.commands.command(({tr:e})=>{let{from:t,to:i}=r,a=n.doc.textBetween(t,i,`
|
|
283
283
|
`,`
|
|
284
284
|
`).split(`
|
|
285
285
|
`).map(e=>o+e).join(`
|
|
286
|
-
`);return e.replaceWith(t,i,n.schema.text(a)),!0})},"Shift-Tab":({editor:e})=>{if(!this.options.enableTabIndentation)return!1;let t=this.options.tabSize??
|
|
286
|
+
`);return e.replaceWith(t,i,n.schema.text(a)),!0})},"Shift-Tab":({editor:e})=>{if(!this.options.enableTabIndentation)return!1;let t=this.options.tabSize??yZ,{state:n}=e,{selection:r}=n,{$from:i,empty:a}=r;return i.parent.type===this.type?a?e.commands.command(({tr:e})=>{let{pos:r}=i,a=i.start(),o=i.end(),s=n.doc.textBetween(a,o,`
|
|
287
287
|
`,`
|
|
288
288
|
`).split(`
|
|
289
289
|
`),c=0,l=0,u=r-a;for(let e=0;e<s.length;e+=1){if(l+s[e].length>=u){c=e;break}l+=s[e].length+1}let d=s[c].match(/^ */)?.[0]||``,f=Math.min(d.length,t);if(f===0)return!0;let p=a;for(let e=0;e<c;e+=1)p+=s[e].length+1;return e.delete(p,p+f),r-p<=f&&e.setSelection(Y.create(e.doc,p)),!0}):e.commands.command(({tr:e})=>{let{from:i,to:a}=r,o=n.doc.textBetween(i,a,`
|
|
@@ -292,38 +292,38 @@ img.ProseMirror-separator {
|
|
|
292
292
|
`).map(e=>{let n=e.match(/^ */)?.[0]||``,r=Math.min(n.length,t);return e.slice(r)}).join(`
|
|
293
293
|
`);return e.replaceWith(i,a,n.schema.text(o)),!0}):!1},Enter:({editor:e})=>{if(!this.options.exitOnTripleEnter)return!1;let{state:t}=e,{selection:n}=t,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type)return!1;let a=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(`
|
|
294
294
|
|
|
295
|
-
`);return!a||!o?!1:e.chain().command(({tr:e})=>(e.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowUp:({editor:e})=>{if(!this.options.exitOnArrowUp)return!1;let{state:t}=e,{selection:n}=t,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type||r.parentOffset!==0)return!1;let a=r.before();return a>0?!1:e.commands.insertDefaultBlock({pos:a})},ArrowDown:({editor:e})=>{if(!this.options.exitOnArrowDown)return!1;let{state:t}=e,{selection:n,doc:r}=t,{$from:i,empty:a}=n;if(!a||i.parent.type!==this.type||i.parentOffset!==i.parent.nodeSize-2)return!1;let o=i.after();return o===void 0?!1:r.nodeAt(o)?e.commands.command(({tr:e})=>(e.setSelection(J.near(r.resolve(o))),!0)):e.commands.exitCode()}}},addInputRules(){return[$G({find:
|
|
296
|
-
`));return a.replaceSelectionWith(this.type.create({language:i},s)),a.selection.$from.parent.type!==this.type&&a.setSelection(Y.near(a.doc.resolve(Math.max(0,a.selection.from-2)))),a.setMeta(`paste`,!0),e.dispatch(a),!0}}})]}}),
|
|
295
|
+
`);return!a||!o?!1:e.chain().command(({tr:e})=>(e.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowUp:({editor:e})=>{if(!this.options.exitOnArrowUp)return!1;let{state:t}=e,{selection:n}=t,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type||r.parentOffset!==0)return!1;let a=r.before();return a>0?!1:e.commands.insertDefaultBlock({pos:a})},ArrowDown:({editor:e})=>{if(!this.options.exitOnArrowDown)return!1;let{state:t}=e,{selection:n,doc:r}=t,{$from:i,empty:a}=n;if(!a||i.parent.type!==this.type||i.parentOffset!==i.parent.nodeSize-2)return!1;let o=i.after();return o===void 0?!1:r.nodeAt(o)?e.commands.command(({tr:e})=>(e.setSelection(J.near(r.resolve(o))),!0)):e.commands.exitCode()}}},addInputRules(){return[$G({find:bZ,type:this.type,getAttributes:e=>({language:e[1]})}),$G({find:xZ,type:this.type,getAttributes:e=>({language:e[1]})})]},addProseMirrorPlugins(){return[new SI({key:new TI(`codeBlockVSCodeHandler`),props:{handlePaste:(e,t)=>{if(!t.clipboardData||this.editor.isActive(this.type.name))return!1;let n=t.clipboardData.getData(`text/plain`),r=t.clipboardData.getData(`vscode-editor-data`),i=(r?JSON.parse(r):void 0)?.mode;if(!n||!i)return!1;let{tr:a,schema:o}=e.state,s=o.text(n.replace(/\r\n?/g,`
|
|
296
|
+
`));return a.replaceSelectionWith(this.type.create({language:i},s)),a.selection.$from.parent.type!==this.type&&a.setSelection(Y.near(a.doc.resolve(Math.max(0,a.selection.from-2)))),a.setMeta(`paste`,!0),e.dispatch(a),!0}}})]}}),CZ=tK.create({name:`doc`,topNode:!0,content:`block+`,renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,`
|
|
297
297
|
|
|
298
|
-
`):``}),
|
|
298
|
+
`):``}),wZ=tK.create({name:`hardBreak`,markdownTokenName:`br`,addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:`inline`,selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:`br`}]},renderHTML({HTMLAttributes:e}){return[`br`,jU(this.options.HTMLAttributes,e)]},renderText(){return`
|
|
299
299
|
`},renderMarkdown:()=>`
|
|
300
|
-
`,parseMarkdown:()=>({type:`hardBreak`}),addCommands(){return{setHardBreak:()=>({commands:e,chain:t,state:n,editor:r})=>e.first([()=>e.exitCode(),()=>e.command(()=>{let{selection:e,storedMarks:i}=n;if(e.$from.parent.type.spec.isolating)return!1;let{keepMarks:a}=this.options,{splittableMarks:o}=r.extensionManager,s=i||e.$to.parentOffset&&e.$from.marks();return t().insertContent({type:this.name}).command(({tr:e,dispatch:t})=>{if(t&&s&&a){let t=s.filter(e=>o.includes(e.type.name));e.ensureMarks(t)}return!0}).scrollIntoView().run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),
|
|
301
|
-
`):``,markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(
|
|
300
|
+
`,parseMarkdown:()=>({type:`hardBreak`}),addCommands(){return{setHardBreak:()=>({commands:e,chain:t,state:n,editor:r})=>e.first([()=>e.exitCode(),()=>e.command(()=>{let{selection:e,storedMarks:i}=n;if(e.$from.parent.type.spec.isolating)return!1;let{keepMarks:a}=this.options,{splittableMarks:o}=r.extensionManager,s=i||e.$to.parentOffset&&e.$from.marks();return t().insertContent({type:this.name}).command(({tr:e,dispatch:t})=>{if(t&&s&&a){let t=s.filter(e=>o.includes(e.type.name));e.ensureMarks(t)}return!0}).scrollIntoView().run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),TZ=tK.create({name:`heading`,addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:`inline*`,group:`block`,defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(e=>({tag:`h${e}`,attrs:{level:e}}))},renderHTML({node:e,HTMLAttributes:t}){return[`h${this.options.levels.includes(e.attrs.level)?e.attrs.level:this.options.levels[0]}`,jU(this.options.HTMLAttributes,t),0]},parseMarkdown:(e,t)=>t.createNode(`heading`,{level:e.depth||1},t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>{let n=e.attrs?.level?parseInt(e.attrs.level,10):1,r=`#`.repeat(n);return e.content?`${r} ${t.renderChildren(e.content)}`:``},addCommands(){return{setHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.setNode(this.name,e):!1,toggleHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.toggleNode(this.name,`paragraph`,e):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((e,t)=>({...e,[`Mod-Alt-${t}`]:()=>this.editor.commands.toggleHeading({level:t})}),{})},addInputRules(){return this.options.levels.map(e=>$G({find:RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}}),EZ=tK.create({name:`horizontalRule`,addOptions(){return{HTMLAttributes:{},nextNodeType:`paragraph`}},group:`block`,parseHTML(){return[{tag:`hr`}]},renderHTML({HTMLAttributes:e}){return[`hr`,jU(this.options.HTMLAttributes,e)]},markdownTokenName:`hr`,parseMarkdown:(e,t)=>t.createNode(`horizontalRule`),renderMarkdown:()=>`---`,addCommands(){return{setHorizontalRule:()=>({chain:e,state:t})=>{if(!fG(t,t.schema.nodes[this.name]))return!1;let{selection:n}=t,{$to:r}=n,i=e();return cW(n)?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({state:e,tr:t,dispatch:n})=>{if(n){let{$to:n}=t.selection,r=n.end();if(n.nodeAfter)n.nodeAfter.isTextblock?t.setSelection(Y.create(t.doc,n.pos+1)):n.nodeAfter.isBlock?t.setSelection(X.create(t.doc,n.pos)):t.setSelection(Y.create(t.doc,n.pos));else{let i=(e.schema.nodes[this.options.nextNodeType]||n.parent.type.contentMatch.defaultType)?.create();i&&(t.insert(r,i),t.setSelection(Y.create(t.doc,r+1)))}t.scrollIntoView()}return!0}).run()}}},addInputRules(){return[QG({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),DZ=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,OZ=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,kZ=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,AZ=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,jZ=EG.create({name:`italic`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`em`},{tag:`i`,getAttrs:e=>e.style.fontStyle!==`normal`&&null},{style:`font-style=normal`,clearMark:e=>e.type.name===this.name},{style:`font-style=italic`}]},renderHTML({HTMLAttributes:e}){return[`em`,jU(this.options.HTMLAttributes,e),0]},addCommands(){return{setItalic:()=>({commands:e})=>e.setMark(this.name),toggleItalic:()=>({commands:e})=>e.toggleMark(this.name),unsetItalic:()=>({commands:e})=>e.unsetMark(this.name)}},markdownTokenName:`em`,parseMarkdown:(e,t)=>t.applyMark(`italic`,t.parseInline(e.tokens||[])),markdownOptions:{htmlReopen:{open:`<em>`,close:`</em>`}},renderMarkdown:(e,t)=>`*${t.renderChildren(e)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[ZG({find:DZ,type:this.type}),ZG({find:kZ,type:this.type})]},addPasteRules(){return[nK({find:OZ,type:this.type}),nK({find:AZ,type:this.type})]}}),MZ=`listItem`,NZ=`textStyle`,PZ=/^\s*([-+*])\s$/,FZ=tK.create({name:`bulletList`,addOptions(){return{itemTypeName:`listItem`,HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:`block list`,content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul`}]},renderHTML({HTMLAttributes:e}){return[`ul`,jU(this.options.HTMLAttributes,e),0]},markdownTokenName:`list`,parseMarkdown:(e,t)=>e.type!==`list`||e.ordered?[]:{type:`bulletList`,content:e.items?t.parseChildren(e.items):[]},renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,`
|
|
301
|
+
`):``,markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(MZ,this.editor.getAttributes(NZ)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let e=eK({find:PZ,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(e=eK({find:PZ,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(NZ),editor:this.editor})),[e]}}),IZ=(e,t,n)=>{let{selection:r}=e;if(!r.empty)return null;let{$from:i}=r;if(!i.parent.isTextblock||i.parentOffset!==i.parent.content.size)return null;let a=-1;for(let e=i.depth;e>0;--e)if(i.node(e).type.name===t){a=e;break}if(a<0)return null;let o=i.node(a),s=i.index(a);if(s+1>=o.childCount)return null;let c=o.child(s+1);if(!n.includes(c.type.name))return null;let l=e.schema.nodes[t],u=!1;if(c.forEach(e=>{e.type===l&&e.childCount>1&&(u=!0)}),!u)return null;let d=e.doc.resolve(i.after()).nodeAfter;if(!d||!n.includes(d.type.name))return null;let f=[];return d.forEach(e=>{f.push(e)}),f.length===0?null:{listItemDepth:a,nestedList:d,nestedListPos:i.after(),insertPos:i.after(a),items:f}},LZ=(e,t,n,r)=>{let i=IZ(e,n,r);if(!i)return!1;let{selection:a}=e,{nestedList:o,nestedListPos:s,insertPos:c,items:l}=i,u=e.tr;u.delete(s,s+o.nodeSize);let d=u.mapping.map(c);return u.insert(d,K.from(l)),u.setSelection(a.map(u.doc,u.mapping)),t&&t(u),!0},RZ=(e,t,n)=>LZ(e.state,e.view.dispatch,t,n),zZ=(e,t)=>PG.create({name:`${e}BranchingDeleteKeymap`,priority:101,addKeyboardShortcuts(){let n=()=>RZ(this.editor,e,t);return{Delete:n,"Mod-Delete":n}}}),BZ=[[1e3,`m`],[900,`cm`],[500,`d`],[400,`cd`],[100,`c`],[90,`xc`],[50,`l`],[40,`xl`],[10,`x`],[9,`ix`],[5,`v`],[4,`iv`],[1,`i`]],VZ=`abcdefghijklmnopqrstuvwxyz`,HZ=String.raw`\d+|[ivxlcdmIVXLCDM]+|${`[a-zA-Z]{1,2}`}`;function UZ(e){let t=e,n=``;for(let[e,r]of BZ)for(;t>=e;)n+=r,t-=e;return n}function WZ(e){return UZ(e).toUpperCase()}function GZ(e){let t=e.toLowerCase(),n=0,r=0;for(;n<t.length;){let e=!1;for(let[i,a]of BZ)if(t.startsWith(a,n)){r+=i,n+=a.length,e=!0;break}if(!e)return 0}return r}function KZ(e){if(!/^[ivxlcdmIVXLCDM]+$/.test(e))return!1;let t=GZ(e);return t<=0?!1:(e===e.toLowerCase()?UZ(t):WZ(t))===e}function qZ(e){let t=e.toLowerCase();if(t.length===1)return t.charCodeAt(0)-97+1;if(t.length===2){let e=t.charCodeAt(0)-97,n=t.charCodeAt(1)-97;return(e+1)*26+n+1}return 0}function JZ(e){if(e<=26)return VZ[e-1];let t=Math.floor((e-1)/26)-1,n=(e-1)%26;return t<0?VZ[n]:VZ[t]+VZ[n]}function YZ(e){if(!(!e||/^\d+$/.test(e))){if(KZ(e))return e===e.toLowerCase()?`i`:`I`;if(/^[a-z]{1,2}$/.test(e))return`a`;if(/^[A-Z]{1,2}$/.test(e))return`A`}}function XZ(e){if(/^\d+$/.test(e))return parseInt(e,10);let t=YZ(e);if(t===`i`||t===`I`)return GZ(e);if(t===`a`||t===`A`){let t=qZ(e);return t>0?t:1}let n=parseInt(e,10);return Number.isNaN(n)?1:n}function ZZ(e,t){if(e===`numeric`)return String(t);switch(e){case`a`:return JZ(t);case`A`:return JZ(t).toUpperCase();case`i`:return UZ(t);case`I`:return WZ(t);default:return String(t)}}function QZ(e){if(e.length===0)return!1;let t=YZ(e[0])??`numeric`,n=XZ(e[0]);if(n<1)return!1;for(let r=0;r<e.length;r++){let i=ZZ(t,n+r);if(e[r]!==i)return!1}return!0}function $Z(e){return{type:YZ(e),start:XZ(e)}}function eQ(e){let{type:t,start:n}=$Z(e),r={};return t&&(r.type=t),n!==1&&(r.start=n),r}function tQ(e,t,n=`. `){let r=t+1;if(!e||e===`1`)return`${r}${n}`;switch(e){case`a`:return`${JZ(r)}${n}`;case`A`:return`${JZ(r).toUpperCase()}${n}`;case`i`:return`${UZ(r)}${n}`;case`I`:return`${WZ(r)}${n}`;default:return`${r}${n}`}}function nQ(e){let t=e.tokens?.[0];return!!(e.text&&e.tokens?.length===1&&t?.type===`list`&&t.ordered&&t.raw===e.text)}function rQ(e,t){return t.tokenizeInline?t.parseInline(t.tokenizeInline(e)):t.parseInline([{type:`text`,raw:e,text:e}])}var iQ=tK.create({name:`listItem`,addOptions(){return{HTMLAttributes:{},bulletListTypeName:`bulletList`,orderedListTypeName:`orderedList`}},content:`paragraph block*`,defining:!0,parseHTML(){return[{tag:`li`}]},renderHTML({HTMLAttributes:e}){return[`li`,jU(this.options.HTMLAttributes,e),0]},markdownTokenName:`list_item`,parseMarkdown:(e,t)=>{if(e.type!==`list_item`)return[];let n=t.parseBlockChildren??t.parseChildren,r=[];if(e.tokens&&e.tokens.length>0){if(nQ(e))return{type:`listItem`,content:[{type:`paragraph`,content:rQ(e.text||``,t)}]};if(e.tokens.some(e=>e.type===`paragraph`))r=n(e.tokens);else{let i=e.tokens[0];if(i&&i.type===`text`&&i.tokens&&i.tokens.length>0){if(r=[{type:`paragraph`,content:t.parseInline(i.tokens)}],e.tokens.length>1){let t=n(e.tokens.slice(1));r.push(...t)}}else r=n(e.tokens)}}return r.length===0&&(r=[{type:`paragraph`,content:[]}]),{type:`listItem`,content:r}},renderMarkdown:(e,t,n)=>vG(e,t,e=>{if(e.parentType===`bulletList`)return`- `;if(e.parentType===`orderedList`){var t,n;let r=((t=e.meta)==null||(t=t.parentAttrs)==null?void 0:t.start)||1;return tQ((n=e.meta)==null||(n=n.parentAttrs)==null?void 0:n.type,r-1+(e.index||0),`. `)}return`- `},n),addExtensions(){return[zZ(this.name,[this.options.bulletListTypeName,this.options.orderedListTypeName])]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),aQ=(e,t)=>{let{$from:n}=t.selection,r=cH(e,t.schema),i=null,a=n.depth,o=n.pos,s=null;for(;a>0&&s===null;)i=n.node(a),i.type===r?s=a:(--a,--o);return s===null?null:{$pos:t.doc.resolve(o),depth:s}},oQ=(e,t)=>{let n=aQ(e,t);if(!n)return!1;let[,r]=XU(t,e,n.$pos.pos+4);return r},sQ=(e,t,n)=>{let{$anchor:r}=e.selection,i=Math.max(0,r.pos-2),a=e.doc.resolve(i).node();return!(!a||!n.includes(a.type.name))},cQ=(e,t,n)=>{if(e.commands.undoInputRule())return!0;if(e.state.selection.from!==e.state.selection.to)return!1;if(!eU(e.state,t)&&sQ(e.state,t,n)){let{$anchor:n}=e.state.selection,r=e.state.doc.resolve(n.before()-1),i=[];r.node().descendants((e,n)=>{e.type.name===t&&i.push({node:e,pos:n})});let a=i.at(-1);if(!a)return!1;let o=e.state.doc.resolve(r.start()+a.pos+1);return e.chain().cut({from:n.start()-1,to:n.end()+1},o.end()).joinForward().run()}if(!eU(e.state,t)||!iW(e.state))return!1;let{$from:r}=e.state.selection,i=r.depth-1;return r.node(i).type!==e.schema.nodes[t]||r.index(i)!==0?!1:e.chain().liftListItem(t).run()},lQ=(e,t)=>{let n=oQ(e,t),r=aQ(e,t);return!r||!n?!1:n>r.depth},uQ=(e,t)=>{let n=oQ(e,t),r=aQ(e,t);return!r||!n?!1:n<r.depth},dQ=(e,t)=>{if(!eU(e.state,t)||!rW(e.state,t))return!1;let{selection:n}=e.state,{$from:r,$to:i}=n;return!n.empty&&r.sameParent(i)?!1:lQ(t,e.state)?e.chain().focus(e.state.selection.from+4).lift(t).joinBackward().run():uQ(t,e.state)?e.chain().joinForward().joinBackward().run():e.commands.joinItemForward()},fQ=(e,t,n)=>{let{state:r}=e,{selection:i}=r;if(!i.empty)return!1;let{$from:a}=i;if(a.parentOffset!==0||!a.parent.isTextblock||eU(r,t))return!1;let o=ZU(a);if(!o||!n.includes(o.type.name))return!1;let s=o.lastChild;if(!s||s.type.name!==t)return!1;let c=a.parent;if(!s.canReplace(s.childCount,s.childCount,K.from(c)))return!1;let l=a.before(),u=a.after(),d=l-2;return e.commands.command(({tr:e,dispatch:t})=>(t&&(e.delete(l,u).insert(d,K.from(c)),e.setSelection(Y.create(e.doc,d+1)),e.scrollIntoView()),!0))},pQ=PG.create({name:`listKeymap`,addOptions(){return{listTypes:[{itemName:`listItem`,wrapperNames:[`bulletList`,`orderedList`]},{itemName:`taskItem`,wrapperNames:[`taskList`]}]}},addKeyboardShortcuts(){return{Delete:({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n})=>{e.state.schema.nodes[n]!==void 0&&dQ(e,n)&&(t=!0)}),t},"Mod-Delete":({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n})=>{e.state.schema.nodes[n]!==void 0&&dQ(e,n)&&(t=!0)}),t},Backspace:({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{e.state.schema.nodes[n]!==void 0&&cQ(e,n,r)&&(t=!0)}),t},"Mod-Backspace":({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{e.state.schema.nodes[n]!==void 0&&cQ(e,n,r)&&(t=!0)}),t},Tab:({editor:e})=>{for(let{itemName:t,wrapperNames:n}of this.options.listTypes)if(e.state.schema.nodes[t]!==void 0&&fQ(e,t,n))return!0;return!1}}}}),mQ=RegExp(`^(\\s*)(${HZ})([.)])\\s+(.*)$`),hQ=/^\s/,gQ={heading:/^#{1,6}(?:\s|$)/,bulletItem:/^[-+*]\s+/,codeFence:/^(?:```|~~~)/,blockMath:/^\$\$/,thematicBreak:/^(?:(?:-[ \t]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})$/};function _Q(e){return mQ.test(e.trimStart())}function vQ(e){let t=e.trimStart();return gQ.bulletItem.test(t)||_Q(t)||gQ.heading.test(t)||gQ.thematicBreak.test(t)&&!t.startsWith(`-`)||/^>\s?/.test(t)||gQ.codeFence.test(t)||gQ.blockMath.test(t)}function yQ(e){return Object.values(gQ).some(t=>t.test(e))}function bQ(e){let t=[],n=[],r=!1;return e.forEach(e=>{if(r){n.push(e);return}if(e.trim()===``){r=!0,n.push(e);return}if(t.length>0&&vQ(e)){r=!0,n.push(e);return}t.push(e)}),{paragraphLines:t,blockLines:n}}function xQ(e){let t=[],n=0,r=0;for(;n<e.length;){let i=e[n],a=i.match(mQ);if(!a)break;let[,o,s,c,l]=a,u=o.length,d=parseInt(s,10),f=isNaN(d)?YZ(s):void 0,p=isNaN(d)?XZ(s):d,m=[l],h=n+1,g=[i],_=!1;for(;h<e.length;){let t=e[h];if(t.match(mQ))break;if(t.trim()===``)g.push(t),m.push(``),_=!0,h+=1;else if(t.match(hQ)){let e=t.length-t.trimStart().length,n=u+s.length+1;g.push(t),m.push(t.slice(Math.min(e,n))),h+=1}else{if(_||yQ(t))break;g.push(t),m.push(t),h+=1}}t.push({indent:u,number:p,type:f,content:m.join(`
|
|
302
302
|
`).trim(),contentLines:m,raw:g.join(`
|
|
303
|
-
`)}),r=h,n=h}return[t,r]}var
|
|
304
|
-
`).filter(e=>e.trim().length>0);if(t.length===0)return null;let n=[];for(let e of t){let t=e.trim().match(
|
|
303
|
+
`)}),r=h,n=h}return[t,r]}var SQ=RegExp(`^(${HZ})([.)])\\s+(.+)$`);function CQ(e){let t=e.split(`
|
|
304
|
+
`).filter(e=>e.trim().length>0);if(t.length===0)return null;let n=[];for(let e of t){let t=e.trim().match(SQ);if(!t)return null;n.push({marker:t[1],content:t[3]})}return QZ(n.map(e=>e.marker))?{type:`orderedList`,attrs:eQ(n[0].marker),content:n.map(e=>({type:`listItem`,content:[{type:`paragraph`,content:[{type:`text`,text:e.content}]}]}))}:null}function wQ(e,t,n){let r=[],i=0;for(;i<e.length;){let a=e[i];if(a.indent===t){let{paragraphLines:o,blockLines:s}=bQ(a.contentLines),c=o.join(`
|
|
305
305
|
`).trim(),l=[];c&&l.push({type:`paragraph`,raw:c,tokens:n.inlineTokens(c)});let u=s.join(`
|
|
306
|
-
`).trim();if(u){let e=n.blockTokens(u);l.push(...e)}let d=i+1,f=[];for(;d<e.length&&e[d].indent>t;)f.push(e[d]),d+=1;if(f.length>0){let e=
|
|
307
|
-
`)})}r.push({type:`list_item`,raw:a.raw,tokens:l}),i=d}else i+=1}return r}function
|
|
306
|
+
`).trim();if(u){let e=n.blockTokens(u);l.push(...e)}let d=i+1,f=[];for(;d<e.length&&e[d].indent>t;)f.push(e[d]),d+=1;if(f.length>0){let e=wQ(f,Math.min(...f.map(e=>e.indent)),n);l.push({type:`list`,ordered:!0,start:f[0].number,typeMarker:f[0].type,items:e,raw:f.map(e=>e.raw).join(`
|
|
307
|
+
`)})}r.push({type:`list_item`,raw:a.raw,tokens:l}),i=d}else i+=1}return r}function TQ(e,t){return e.map(e=>{if(e.type!==`list_item`)return t.parseChildren([e])[0];let n=[];return e.tokens&&e.tokens.length>0&&e.tokens.forEach(e=>{if(e.type===`paragraph`||e.type===`list`||e.type===`blockquote`||e.type===`code`)n.push(...t.parseChildren([e]));else if(e.type===`text`&&e.tokens){let r=t.parseChildren([e]);n.push({type:`paragraph`,content:r})}else{let r=t.parseChildren([e]);r.length>0&&n.push(...r)}}),{type:`listItem`,content:n}})}var EQ=`listItem`,DQ=`textStyle`,OQ=/^(\d+)\.\s$/;function kQ(e){let t=e.match(/list-style-type\s*:\s*([^;]+)/i);if(!t)return null;switch(t[1].trim().toLowerCase()){case`upper-roman`:return`I`;case`lower-roman`:return`i`;case`upper-alpha`:case`upper-latin`:return`A`;case`lower-alpha`:case`lower-latin`:return`a`;default:return null}}var AQ=tK.create({name:`orderedList`,addOptions(){return{itemTypeName:`listItem`,HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:`block list`,content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:e=>e.hasAttribute(`start`)?parseInt(e.getAttribute(`start`)||``,10):1},type:{default:null,parseHTML:e=>{let t=e.getAttribute(`type`);if(t)return t;let n=e.getAttribute(`style`);if(n){let e=kQ(n);if(e)return e}let r=e.querySelector(`li`);if(r){let e=r.getAttribute(`style`);if(e){let t=kQ(e);if(t)return t}}return null}}}},parseHTML(){return[{tag:`ol`}]},renderHTML({HTMLAttributes:e}){let{start:t,type:n,...r}=e,i=jU(this.options.HTMLAttributes,r);return t!==1&&(i.start=t),n&&n!==`1`&&(i.type=n),[`ol`,i,0]},markdownTokenName:`list`,parseMarkdown:(e,t)=>{if(e.type!==`list`||!e.ordered)return[];let n=e.start||1,r=e.typeMarker,i=e.items?TQ(e.items,t):[],a={};return n!==1&&(a.start=n),r&&(a.type=r),Object.keys(a).length>0?{type:`orderedList`,attrs:a,content:i}:{type:`orderedList`,content:i}},renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,`
|
|
308
308
|
`):``,markdownTokenizer:{name:`orderedList`,level:`block`,start:()=>-1,tokenize:(e,t,n)=>{let r=e.split(`
|
|
309
|
-
`),[i,a]=
|
|
310
|
-
`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(
|
|
311
|
-
`):``,markdownTokenizer:{name:`taskList`,level:`block`,start(e){let t=e.match(/^\s*[-+*]\s+\[([ xX])\]\s+/)?.index;return t===void 0?-1:t},tokenize(e,t,n){let r=e=>{let t=_G(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:e[3].toLowerCase()===`x`}),createToken:(e,t)=>({type:`taskItem`,raw:``,mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);if(t){let r={type:`taskList`,raw:t.raw,items:t.items},i=e.slice(t.raw.length);return i.trim()?[r,...n.blockTokens(i)]:[r]}return n.blockTokens(e)},i=_G(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:e[3].toLowerCase()===`x`}),createToken:(e,t)=>({type:`taskItem`,raw:``,mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);if(i)return{type:`taskList`,raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:e})=>e.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});PG.create({name:`listKit`,addExtensions(){let e=[];return this.options.bulletList!==!1&&e.push(IZ.configure(this.options.bulletList)),this.options.listItem!==!1&&e.push(aQ.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(mQ.configure(this.options.listKeymap)),this.options.orderedList!==!1&&e.push(jQ.configure(this.options.orderedList)),this.options.taskItem!==!1&&e.push(FQ.configure(this.options.taskItem)),this.options.taskList!==!1&&e.push(IQ.configure(this.options.taskList)),e}});var LQ=` `,RQ=`\xA0`,zQ=tK.create({name:`paragraph`,priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:`block`,content:`inline*`,parseHTML(){return[{tag:`p`}]},renderHTML({HTMLAttributes:e}){return[`p`,jU(this.options.HTMLAttributes,e),0]},parseMarkdown:(e,t)=>{let n=e.tokens||[];if(n.length===1&&n[0].type===`image`)return t.parseChildren([n[0]]);let r=t.parseInline(n);return n.length===1&&n[0].type===`text`&&(n[0].raw===LQ||n[0].text===LQ||n[0].raw===RQ||n[0].text===RQ)&&r.length===1&&r[0].type===`text`&&(r[0].text===LQ||r[0].text===RQ)?t.createNode(`paragraph`,void 0,[]):t.createNode(`paragraph`,void 0,r)},renderMarkdown:(e,t,n)=>{if(!e)return``;let r=Array.isArray(e.content)?e.content:[];if(r.length===0){var i,a;let e=Array.isArray(n==null||(i=n.previousNode)==null?void 0:i.content)?n.previousNode.content:[];return(n==null||(a=n.previousNode)==null?void 0:a.type)===`paragraph`&&e.length===0?LQ:``}return t.renderChildren(r)},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),BQ=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,VQ=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,HQ=EG.create({name:`strike`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`s`},{tag:`del`},{tag:`strike`},{style:`text-decoration`,consuming:!1,getAttrs:e=>e.includes(`line-through`)?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`s`,jU(this.options.HTMLAttributes,e),0]},markdownTokenName:`del`,parseMarkdown:(e,t)=>t.applyMark(`strike`,t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>`~~${t.renderChildren(e)}~~`,addCommands(){return{setStrike:()=>({commands:e})=>e.setMark(this.name),toggleStrike:()=>({commands:e})=>e.toggleMark(this.name),unsetStrike:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[ZG({find:BQ,type:this.type})]},addPasteRules(){return[nK({find:VQ,type:this.type})]}}),UQ=tK.create({name:`text`,group:`inline`,parseMarkdown:e=>({type:`text`,text:e.text||``}),renderMarkdown:e=>e.text||``}),WQ=EG.create({name:`underline`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`u`},{style:`text-decoration`,consuming:!1,getAttrs:e=>e.includes(`underline`)?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`u`,jU(this.options.HTMLAttributes,e),0]},parseMarkdown(e,t){return t.applyMark(this.name||`underline`,t.parseInline(e.tokens||[]))},renderMarkdown(e,t){return`++${t.renderChildren(e)}++`},markdownTokenizer:{name:`underline`,level:`inline`,start(e){return e.indexOf(`++`)},tokenize(e,t,n){let r=/^(\+\+)([\s\S]+?)(\+\+)/.exec(e);if(!r)return;let i=r[2].trim();return{type:`underline`,raw:r[0],text:i,tokens:n.inlineTokens(i)}}},addCommands(){return{setUnderline:()=>({commands:e})=>e.setMark(this.name),toggleUnderline:()=>({commands:e})=>e.toggleMark(this.name),unsetUnderline:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),GQ=PG.create({name:`starterKit`,addExtensions(){let e=[];return this.options.bold!==!1&&e.push(gZ.configure(this.options.bold)),this.options.blockquote!==!1&&e.push(dZ.configure(this.options.blockquote)),this.options.bulletList!==!1&&e.push(IZ.configure(this.options.bulletList)),this.options.code!==!1&&e.push(yZ.configure(this.options.code)),this.options.codeBlock!==!1&&e.push(CZ.configure(this.options.codeBlock)),this.options.document!==!1&&e.push(wZ.configure(this.options.document)),this.options.dropcursor!==!1&&e.push(kX.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&e.push(AX.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&e.push(TZ.configure(this.options.hardBreak)),this.options.heading!==!1&&e.push(EZ.configure(this.options.heading)),this.options.undoRedo!==!1&&e.push(tZ.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&e.push(DZ.configure(this.options.horizontalRule)),this.options.italic!==!1&&e.push(MZ.configure(this.options.italic)),this.options.listItem!==!1&&e.push(aQ.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(mQ.configure(this.options?.listKeymap)),this.options.link!==!1&&e.push(WY.configure(this.options?.link)),this.options.orderedList!==!1&&e.push(jQ.configure(this.options.orderedList)),this.options.paragraph!==!1&&e.push(zQ.configure(this.options.paragraph)),this.options.strike!==!1&&e.push(HQ.configure(this.options.strike)),this.options.text!==!1&&e.push(UQ.configure(this.options.text)),this.options.underline!==!1&&e.push(WQ.configure(this.options?.underline)),this.options.trailingNode!==!1&&e.push(eZ.configure(this.options?.trailingNode)),e}}),KQ=(0,R.createContext)(null);function qQ(e){let t=(0,R.use)(KQ);if(!t)throw Error(`${e} must be used inside Composer.Root.`);return t}function JQ(e){let t=(0,G.c)(9),n=qQ(e===void 0?`useComposer`:e),r;t[0]!==n.activePopup||t[1]!==n.disabled||t[2]!==n.meta||t[3]!==n.suggestions?(r={...n.meta,disabled:n.disabled,activePopup:n.activePopup,suggestions:n.suggestions},t[0]=n.activePopup,t[1]=n.disabled,t[2]=n.meta,t[3]=n.suggestions,t[4]=r):r=t[4];let i;return t[5]!==n.actions||t[6]!==n.state||t[7]!==r?(i={state:n.state,actions:n.actions,meta:r},t[5]=n.actions,t[6]=n.state,t[7]=r,t[8]=i):i=t[8],i}function YQ(e){let t=(0,G.c)(23),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let{state:i,attachedImages:a}=qQ(`Composer.Attachments`),o=i.imageAttachments,s,c,l,u,d,f;if(t[3]!==a||t[4]!==n||t[5]!==r||t[6]!==i.imageAttachments){f=Symbol.for(`react.early_return_sentinel`);bb0:{let e;t[13]===a?e=t[14]:(e=e=>a.has(e.id),t[13]=a,t[14]=e);let i=o.filter(e);if(i.length===0){f=null;break bb0}s=`list`,c=`Attached files`,t[15]===n?l=t[16]:(l=I(`flex flex-wrap gap-2`,n),t[15]=n,t[16]=l),u=r,d=i.map(XQ)}t[3]=a,t[4]=n,t[5]=r,t[6]=i.imageAttachments,t[7]=s,t[8]=c,t[9]=l,t[10]=u,t[11]=d,t[12]=f}else s=t[7],c=t[8],l=t[9],u=t[10],d=t[11],f=t[12];if(f!==Symbol.for(`react.early_return_sentinel`))return f;let p;return t[17]!==s||t[18]!==c||t[19]!==l||t[20]!==u||t[21]!==d?(p=(0,z.jsx)(`div`,{role:s,"aria-label":c,className:l,...u,children:d}),t[17]=s,t[18]=c,t[19]=l,t[20]=u,t[21]=d,t[22]=p):p=t[22],p}function XQ(e){return(0,z.jsx)(ZQ,{attachment:e},e.id)}function ZQ(e){let t=(0,G.c)(18),{attachment:n}=e,{id:r,placeholder:i,media:a}=n,{attachedImages:o,disabled:s,actions:c}=qQ(`Composer.Attachments`),l;t[0]!==o||t[1]!==r?(l=o.get(r),t[0]=o,t[1]=r,t[2]=l):l=t[2];let u=l;if(!u)return null;let d;t[3]!==u||t[4]!==a||t[5]!==i?(d=a===`video`?(0,z.jsx)(e$,{placeholder:i,file:u}):a===`audio`?(0,z.jsx)(n$,{placeholder:i,file:u,glyph:`♪`}):(0,z.jsx)($Q,{placeholder:i,file:u}),t[3]=u,t[4]=a,t[5]=i,t[6]=d):d=t[6];let f=`Remove ${i}`,p;t[7]!==c||t[8]!==r?(p=()=>c.removeImageAttachment(r),t[7]=c,t[8]=r,t[9]=p):p=t[9];let m;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,z.jsx)(ye,{"aria-hidden":!0,className:`size-3`}),t[10]=m):m=t[10];let h;t[11]!==s||t[12]!==f||t[13]!==p?(h=(0,z.jsx)(y,{type:`button`,"aria-label":f,disabled:s,onClick:p,className:`bg-background text-foreground border-border hover:bg-muted absolute -top-1.5 -right-1.5 flex size-5 items-center justify-center rounded-full border disabled:opacity-50`,children:m}),t[11]=s,t[12]=f,t[13]=p,t[14]=h):h=t[14];let g;return t[15]!==d||t[16]!==h?(g=(0,z.jsxs)(`div`,{role:`listitem`,className:`relative`,children:[d,h]}),t[15]=d,t[16]=h,t[17]=g):g=t[17],g}function QQ(e){let t=(0,G.c)(3),[n,r]=(0,R.useState)(null),i,a;return t[0]===e?(i=t[1],a=t[2]):(i=()=>{let t=URL.createObjectURL(e);return r(t),()=>URL.revokeObjectURL(t)},a=[e],t[0]=e,t[1]=i,t[2]=a),(0,R.useEffect)(i,a),n}function $Q(e){let t=(0,G.c)(5),{placeholder:n,file:r}=e,i=QQ(r),[a,o]=(0,R.useState)(null),s;return t[0]!==a||t[1]!==r||t[2]!==i||t[3]!==n?(s=i===null?null:i===a?(0,z.jsx)(n$,{placeholder:n,file:r,glyph:`🖼`}):(0,z.jsx)(`img`,{src:i,alt:n,title:r.name,className:`border-border size-16 rounded-md border object-cover`,onError:()=>o(i)}),t[0]=a,t[1]=r,t[2]=i,t[3]=n,t[4]=s):s=t[4],s}function e$(e){let t=(0,G.c)(11),{placeholder:n,file:r}=e,i=QQ(r),[a,o]=(0,R.useState)(null),s=i??void 0,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=e=>o(e.currentTarget.duration),t[0]=c):c=t[0];let l;t[1]===s?l=t[2]:(l=(0,z.jsx)(`video`,{src:s,muted:!0,playsInline:!0,preload:`metadata`,className:`size-full object-cover`,onLoadedMetadata:c}),t[1]=s,t[2]=l);let u;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,z.jsx)(`span`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-0 flex items-center justify-center text-lg text-white drop-shadow`,children:`▶`}),t[3]=u):u=t[3];let d;t[4]===a?d=t[5]:(d=a!==null&&Number.isFinite(a)?(0,z.jsx)(`span`,{className:`absolute right-0.5 bottom-0.5 rounded bg-black/70 px-1 text-[10px] leading-4 text-white`,children:t$(a)}):null,t[4]=a,t[5]=d);let f;return t[6]!==r.name||t[7]!==n||t[8]!==l||t[9]!==d?(f=(0,z.jsxs)(`div`,{role:`img`,"aria-label":n,title:r.name,className:`border-border bg-muted relative size-16 overflow-hidden rounded-md border`,children:[l,u,d]}),t[6]=r.name,t[7]=n,t[8]=l,t[9]=d,t[10]=f):f=t[10],f}function t$(e){let t=Math.round(e);return`${Math.floor(t/60)}:${String(t%60).padStart(2,`0`)}`}function n$(e){let t=(0,G.c)(12),{placeholder:n,file:r,glyph:i}=e,a;t[0]===i?a=t[1]:(a=(0,z.jsxs)(`span`,{"aria-hidden":!0,children:[i,` `]}),t[0]=i,t[1]=a);let o=r.name||n,s;t[2]!==a||t[3]!==o?(s=(0,z.jsxs)(`span`,{className:`text-foreground truncate`,children:[a,o]}),t[2]=a,t[3]=o,t[4]=s):s=t[4];let c=r.type||`file`,l;t[5]===c?l=t[6]:(l=(0,z.jsx)(`span`,{className:`truncate`,children:c}),t[5]=c,t[6]=l);let u;return t[7]!==r.name||t[8]!==n||t[9]!==s||t[10]!==l?(u=(0,z.jsxs)(`div`,{role:`img`,"aria-label":n,title:r.name,className:`border-border bg-muted text-muted-foreground flex h-16 max-w-48 flex-col justify-center gap-0.5 rounded-md border px-2 text-xs`,children:[s,l]}),t[7]=r.name,t[8]=n,t[9]=s,t[10]=l,t[11]=u):u=t[11],u}function r$(e,t){return e===`hidden`?!1:e===`before-interaction`?!t:e!==`after-interaction`||t}function i$(e,t,n){let r=o$(e),i=t.filter(e=>s$(e)&&r$(e.visibility,n));return r?i.map((e,t)=>{let n=l$(r,e);return n===null?null:{command:e,rank:n,index:t}}).filter(e=>!!e).sort((e,t)=>e.rank-t.rank||e.index-t.index).map(e=>e.command).slice(0,10):i.slice(0,10)}function a$(e,t){let n=e.toLowerCase();return t.find(e=>s$(e)&&(e.value.toLowerCase()===n||c$(e).some(e=>e===n)))}function o$(e){return e.slice(1).toLowerCase()}function s$(e){return e.availability!==`disabled`}function c$(e){return(e.aliases??[]).map(e=>e.toLowerCase())}function l$(e,t){let n=t.value.toLowerCase(),r=c$(t),i=[t.label.toLowerCase(),...(t.searchTerms??[]).map(e=>e.toLowerCase())];return n===e?0:r.some(t=>t===e)?1:n.startsWith(e)?2:r.some(t=>t.startsWith(e))?3:i.some(t=>t.startsWith(e))?4:null}function u$(e){return e.map(RegExp.escape).join(`|`)}function d$(e){return`(?:${u$(e)})[A-Za-z0-9_:-]+`}function f$(e){return`(?:${u$(e)})[^\\s]+`}function p$(e,t){let n=[];return t.length>0&&n.push(f$(t)),e.length>0&&n.push(d$(e)),n.length>0?new RegExp(n.join(`|`),`g`):null}function m$(e,t){return t.some(t=>e.startsWith(t))}function h$(e){return`${e.trigger}${e.value}`}function g$({initialDraft:e,text:t=``,slashCommands:n=[],mentionCandidates:r=[],commandTriggers:i=[],remoteImageUrls:a=[],isTaskRunning:o=!1,queueSubmissions:s=!1}={}){let c=e?.text??t,l=r.flatMap(e=>{let t=z$(`mention`,h$(e),c,{detail:e.detail});return t?[t]:[]}),u=l.flatMap(e=>{let t=r.find(t=>h$(t)===e.label);return t?[{id:e.id,trigger:t.trigger,value:t.value,payload:t.payload,persistsAs:t.persistsAs}]:[]}),d=e?.remoteImages??(e?.remoteImageUrls??a).map((e,t)=>({id:_1(`remote-image`,e,t),url:e}));return{text:c,cursor:c.length,elements:B$(e?.elements??[...S$(c,n,i),...l]),mentionBindings:e?.mentionBindings??u,imageAttachments:[],remoteImages:d,pendingPastes:e?.pendingPastes??[],selectedRemoteImageId:null,isTaskRunning:o,queueSubmissions:s,error:null,reverseSearch:null,shortcutsOpen:!1,history:[],historyCursor:null,killBuffer:``}}function _$(e){return e.text.length===0&&e.imageAttachments.length===0&&e.remoteImages.length===0&&e.pendingPastes.length===0}function v$(e,t,n){return x$(e,t,n)}function y$(e,t){if(!t||t<1)return null;let n=q$(e.prompt);return n<=t?null:`Prompt is too long after expanding pasted content (${n} chars; max ${t} chars).`}function b$(e,t,n){let r=N$(e.elements,e.text);r=[...r.filter(e=>e.kind!==`slash-command`),...S$(e.text,t,n)];let i=e.mentionBindings.filter(e=>r.some(t=>t.id===e.id)),a=e.imageAttachments.filter(e=>r.some(t=>t.kind===`image`&&t.label===e.placeholder)),o=e.pendingPastes.filter(e=>r.some(t=>t.kind===`paste`&&t.label===e.placeholder));return{...e,elements:B$(r),mentionBindings:i,imageAttachments:G$(a,e.remoteImages.length),pendingPastes:o}}function x$(e,t,n){let r=e.text.trim(),i=k$(e.text,r,e.elements),a=D$(e.text,e.elements,e.pendingPastes),o=a.text,s=o.trim(),c=k$(o,s,a.elements),l=e.imageAttachments.filter(t=>e.text.includes(t.placeholder)),u=A$(r,i),d=$$({text:u.text,elements:u.elements,mentionBindings:e.mentionBindings}),f=$$({text:s,elements:c,mentionBindings:e.mentionBindings});if(!s&&l.length===0&&e.remoteImages.length===0)return null;let p=m$(o,n)?C$(s,c,t,n):null,m=p?.prompt===void 0?null:p.args?`${p.prompt}\n\n${$$({text:p.args,elements:p.argsElements,mentionBindings:e.mentionBindings})}`:p.prompt,h=p?.prompt===void 0?null:p.args?(()=>{let t=A$(p.args,p.argsElements);return`${p.prompt}\n\n${$$({text:t.text,elements:t.elements,mentionBindings:e.mentionBindings})}`})():p.prompt,g=m??f,_=p?.args===void 0?p?`command`:`submitted`:`command-with-args`,v=[...e.remoteImages.map(e=>({type:`remote_image`,url:e.url}))];!p&&s&&v.push({type:`text`,text:s,textElements:c});let y=p?.args??s;for(let t of e.mentionBindings){let e=`${t.trigger}${t.value}`;!e||!y.includes(e)||v.push({type:`item`,id:t.id,trigger:t.trigger,value:t.value,payload:t.payload})}for(let e of c)e.kind===`link`&&e.detail&&v.push({type:`link`,text:e.label,href:e.detail}),e.kind===`rich-link`&&e.detail&&v.push({type:`rich_link`,text:e.label,href:e.detail,metadata:e.metadata});return{mode:_,prompt:g,persistedPrompt:d,historyPrompt:h??d,action:p?.args===void 0?p?`Command`:`Plain`:`CommandWithArgs`,command:p?.command,args:p?.args,items:v,elements:i,payloadElements:c,mentionBindings:e.mentionBindings}}function S$(e,t,n){let r=[];if(n.length===0)return r;let i=e.matchAll(RegExp(`(^|\\s)((?:${u$(n)})([A-Za-z0-9_:-]+))(?=\\s|$)`,`g`));for(let e of i){let n=a$(e[3],t);if(!n)continue;let i=e[2],a=e.index+e[1].length;r.push({id:_1(`slash-command`,i,a),kind:`slash-command`,label:i,range:{start:a,end:a+i.length},detail:n.detail})}return r}function C$(e,t,n,r){let i=e.match(RegExp(`^(?:${u$(r)})([A-Za-z0-9_:-]+)(?:\\s+([\\s\\S]+))?$`));if(!i)return null;let a=a$(i[1],n);if(!a)return null;let o=i[2]??``;if(!o.trim())return{command:a.value,prompt:a.expandsTo};if(!a.supportsArgs)return null;let s=a.trigger.length+a.value.length,c=e.slice(s).search(/\S/),l=c===-1?s:s+c,u=o.trim();return{command:a.value,prompt:a.expandsTo,args:u,argsElements:O$(t,l,l+u.length)}}function w$(e,t,n){if(n.length===0)return null;let r=e.match(RegExp(`^(?:${u$(n)})([A-Za-z0-9_:-]+)(?:\\s+[\\s\\S]*)?$`));return!r||a$(r[1],t)||E$(r[1])?null:r[1]}var T$=new Set([`Applications`,`Library`,`System`,`Users`,`Volumes`,`bin`,`dev`,`etc`,`home`,`mnt`,`opt`,`private`,`sbin`,`tmp`,`usr`,`var`,`workspace`]);function E$(e){return T$.has(e)}function D$(e,t,n){if(n.length===0||t.length===0)return{text:e,elements:t};let r=new Map;for(let e of n){let t=r.get(e.placeholder)??[];t.push(e.content),r.set(e.placeholder,t)}let i=``,a=[],o=0;for(let n of B$(t)){let t=Math.min(n.range.start,e.length),s=Math.min(n.range.end,e.length);if(t>s)continue;t>o&&(i+=e.slice(o,t));let c=e.slice(t,s),l=r.get(n.label)?.shift();if(l!==void 0)i+=l;else{let e=i.length;i+=c,a.push({...n,range:{start:e,end:i.length}})}o=s}return o<e.length&&(i+=e.slice(o)),{text:i,elements:a}}function O$(e,t,n){return e.filter(e=>e.range.end>t&&e.range.start<n).map(e=>({...e,range:{start:Math.max(0,e.range.start-t),end:Math.min(n,e.range.end)-t}})).filter(e=>e.range.start<e.range.end)}function k$(e,t,n){let r=e.indexOf(t);return r<=0?n:n.filter(e=>e.range.end>r).map(e=>({...e,range:{start:Math.max(0,e.range.start-r),end:Math.max(0,e.range.end-r)}}))}function A$(e,t){let n=B$(t.filter(e=>e.kind===`image`));for(let t of n.toReversed())e=M$(e,t.range,``);let r=e=>n.reduce((t,n)=>t+Math.max(0,Math.min(e,n.range.end)-n.range.start),0);return{text:e,elements:B$(t.filter(e=>e.kind!==`image`)).map(e=>({...e,range:{start:e.range.start-r(e.range.start),end:e.range.end-r(e.range.end)}}))}}function j$(e,t,n,r){return e<r&&t>n}function M$(e,t,n){return e.slice(0,t.start)+n+e.slice(t.end)}function N$(e,t){let n=new Map;return B$(e).map(e=>{let r=P$(t,e.label);if(r.length===0)return null;let i=`${e.kind}:${e.label}`,a=n.get(i)??[],o=F$(r,e,a)??I$(r,e,a)??L$(r,e);return n.set(i,[...a,o]),{...e,range:o}}).filter(e=>!!e)}function P$(e,t){if(!t)return[];let n=[],r=e.indexOf(t);for(;r!==-1;)n.push({start:r,end:r+t.length}),r=e.indexOf(t,r+t.length);return n}function F$(e,t,n){return e.find(e=>e.start===t.range.start&&e.end===t.range.end&&!R$(e,n))}function I$(e,t,n){return L$(e.filter(e=>!R$(e,n)),t)}function L$(e,t){return[...e].sort((e,n)=>Math.abs(e.start-t.range.start)-Math.abs(n.start-t.range.start)||e.start-n.start)[0]}function R$(e,t){return t.some(t=>e.start===t.start&&e.end===t.end&&j$(e.start,e.end,t.start,t.end))}function z$(e,t,n,r={}){let i=n.indexOf(t);return i===-1?null:{id:_1(e,t,i),kind:e,label:t,range:{start:i,end:i+t.length},detail:r.detail}}function B$(e){return[...e].sort((e,t)=>e.range.start-t.range.start)}var V$={image:`Image`,video:`Video`,audio:`Audio`};function H$(e){let t=e.type.split(`/`)[0];return t===`image`||t===`video`||t===`audio`?t:null}function U$(e){return e===`video`||e===`audio`?e:`image`}function W$(e,t){return`[${V$[e]} #${t}]`}function G$(e,t){return e.map((e,n)=>({...e,placeholder:W$(e.media,t+n+1)}))}function K$(e,t){if(!t)return null;let n=e.remoteImages.findIndex(e=>e.id===t);return n===-1?null:n}function q$(e){return Array.from(e).length}function J$(e){let t=A$(e.text,e.elements);return{text:t.text,elements:l1(t.elements),mentionBindings:u1(e.mentionBindings),remoteImages:e.remoteImages.map(e=>({...e})),pendingPastes:d1(e.pendingPastes)}}function Y$(e,t){return{persistedPrompt:t,remoteImages:e.remoteImages.map(e=>({...e})),pendingPastes:d1(e.pendingPastes)}}function X$(e,t){let n=Y$(e,t);return!n.persistedPrompt.trim()&&n.remoteImages.length===0&&n.pendingPastes.length===0?e.history:[n,...e.history].slice(0,8)}function Z$({text:e,slashCommands:t=[],commandTriggers:n=[],mentionCandidates:r=[]}){let i=t1(e,r),a=o1(i.text,i.elements,i.protectedRanges,t,r);return J$(b$(g$({initialDraft:{text:i.text,elements:B$([...i.elements,...a.elements]),mentionBindings:[...i.mentionBindings,...a.mentionBindings]},slashCommands:t}),t,n))}function Q$({source:e,slashCommands:t=[],mentionCandidates:n=[]}){let r=Z$({text:e.persistedPrompt,slashCommands:t,mentionCandidates:n}),i=[...e.pendingPastes.flatMap(e=>{let t=z$(`paste`,e.placeholder,r.text??``,{detail:`${q$(e.content)} chars`});return t?[t]:[]})];return{...r,elements:B$([...r.elements??[],...i]),remoteImages:e.remoteImages.map(e=>({...e})),pendingPastes:d1(e.pendingPastes)}}function $$(e){let t=e.text??``,n=B$(e.elements??[]).map(t=>c1(t,e)).filter(e=>!!e).sort((e,t)=>t.range.start-e.range.start);for(let e of n)t=M$(t,e.range,e.text);return t}function e1(e){return e.startsWith(`composer-text-link://`)?decodeURIComponent(e.replace(/^composer-text-link:\/\//,``)):e}function t1(e,t){let n=[],r=[],i=[],a=``;for(let o of sN(e)){if(o.kind===`inline-code`||o.kind===`code-block`){let e=a.length;a+=o.source,i.push({start:e,end:a.length});continue}if(o.kind!==`link`&&o.kind!==`skill-link`&&o.kind!==`mention`){a+=o.source;continue}let e=o.label,s=o.href,c=e1(s),l=n1(e,t),u=l?h$(l):e,d=a.length;if(a+=u,l){let e=_1(`mention`,u,d);n.push({id:e,kind:`mention`,label:u,range:{start:d,end:d+u.length},detail:l.detail}),r.push({id:e,trigger:l.trigger,value:l.value,payload:l.payload,persistsAs:l.persistsAs})}else n.push({id:_1(`link`,u,d),kind:`link`,label:u,range:{start:d,end:d+u.length},detail:c})}return{text:a,elements:n,mentionBindings:r,protectedRanges:i}}function n1(e,t){return t.find(t=>h$(t)===e)??null}function r1(e){return[...new Set(e.map(e=>e.trigger).filter(Boolean))].sort((e,t)=>t.length-e.length)}function i1(e){let t=r1(e);return t.length===0?null:RegExp(`(?:${u$(t)})[A-Za-z0-9_:-]+`,`g`)}function a1(e,t){return r1(t).find(t=>e.startsWith(t))?.length??0}function o1(e,t,n,r,i){let a=[],o=[],s=[],c=(r,i)=>{let a=r+i.length;return(r===0||/\s/.test(e[r-1]??``))&&!s1(r,i,t)&&!s.some(e=>r<e.end&&a>e.start)&&!n.some(e=>r<e.end&&a>e.start)},l=[...i].sort((e,t)=>h$(t).length-h$(e).length);for(let t of l){let n=h$(t);if(n)for(let r=e.indexOf(n);r!==-1;r=e.indexOf(n,r+n.length)){let i=r+n.length;if(/[\w-]/.test(e[i]??``)||!c(r,n))continue;let l=_1(`mention`,n,r);s.push({start:r,end:i}),a.push({id:l,kind:`mention`,label:n,range:{start:r,end:i},detail:t.detail}),o.push({id:l,trigger:t.trigger,value:t.value,payload:t.payload,persistsAs:t.persistsAs})}}let u=i1(r);for(let t of u?e.matchAll(u):[]){let e=t.index??0,n=t[0];if(!c(e,n))continue;let i=a$(n.slice(a1(n,r)),r);i&&(s.push({start:e,end:e+n.length}),a.push({id:_1(`slash-command`,n,e),kind:`slash-command`,label:n,range:{start:e,end:e+n.length},detail:i.detail}))}return{elements:a,mentionBindings:o}}function s1(e,t,n){let r=e+t.length;return n.some(t=>e<t.range.end&&r>t.range.start)}function c1(e,t){if(e.kind===`mention`){let n=(t.mentionBindings??[]).find(t=>t.id===e.id||`${t.trigger}${t.value}`===e.label);return n?{range:e.range,text:n.persistsAs??e.label}:null}return(e.kind===`link`||e.kind===`rich-link`)&&e.detail?{range:e.range,text:oN(e.label,e.detail)}:null}function l1(e){return e.map(e=>{let t={...e,range:{...e.range}};return e.metadata?{...t,metadata:{...e.metadata}}:t})}function u1(e){return e.map(e=>({...e}))}function d1(e){return e.map(e=>({...e}))}function f1(e,t,n,r=1){if(t.length===0)return null;let i=t.toLowerCase(),a=e.map((e,t)=>({index:t,entry:e})).filter(e=>e.entry.persistedPrompt.toLowerCase().includes(i));if(a.length===0)return null;if(n===null)return a[0];let o=a.findIndex(e=>e.index===n);return o===-1?a[0]:a[g1(o+r,a.length)]}function p1(e,t,n){return n===-1?t===0||!e.slice(0,t).includes(`
|
|
309
|
+
`),[i,a]=xQ(r);if(i.length===0)return;let o=wQ(i,i[0].indent,n);if(o.length!==0)return{type:`list`,ordered:!0,start:i[0]?.number||1,typeMarker:i[0]?.type,items:o,raw:r.slice(0,a).join(`
|
|
310
|
+
`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(EQ,this.editor.getAttributes(DQ)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addProseMirrorPlugins(){return[new SI({props:{handlePaste:(e,t)=>{if((t.clipboardData?.getData(`text/html`))?.trim())return!1;let n=t.clipboardData?.getData(`text/plain`);if(!n)return!1;let r=CQ(n);if(!r)return!1;try{let t=e.state.schema.nodeFromJSON(r),n=e.state.tr.replaceSelectionWith(t);return e.dispatch(n),!0}catch{return!1}}}})]},addInputRules(){let e=(e,t)=>(!t.attrs.type||t.attrs.type===`1`)&&t.childCount+t.attrs.start===+e[1],t=eK({find:OQ,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:e});return(this.options.keepMarks||this.options.keepAttributes)&&(t=eK({find:OQ,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(DQ)}),joinPredicate:e,editor:this.editor})),[t]}}),jQ=/^\s*(\[([( |x])?\])\s$/,MQ=`position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0`,NQ=(e,t,n)=>{var r;return(n==null||(r=n.checkboxLabel)==null?void 0:r.call(n,e,t))||`Task item checkbox for ${e.textContent||`empty task item`}`},PQ=tK.create({name:`taskItem`,addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:`taskList`,a11y:void 0}},content(){return this.options.nested?`paragraph block*`:`paragraph+`},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:e=>{let t=e.getAttribute(`data-checked`);return t===``||t===`true`},renderHTML:e=>({"data-checked":e.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51,contentElement:e=>e.querySelector(`div`)??e}]},renderHTML({node:e,HTMLAttributes:t}){return[`li`,jU(this.options.HTMLAttributes,t,{"data-type":this.name}),[`label`,[`input`,{type:`checkbox`,checked:e.attrs.checked?`checked`:null}],[`span`]],[`div`,0]]},parseMarkdown:(e,t)=>{let n=[];if(e.tokens&&e.tokens.length>0?n.push(t.createNode(`paragraph`,{},t.parseInline(e.tokens))):e.text?n.push(t.createNode(`paragraph`,{},[t.createNode(`text`,{text:e.text})])):n.push(t.createNode(`paragraph`,{},[])),e.nestedTokens&&e.nestedTokens.length>0){let r=t.parseChildren(e.nestedTokens);n.push(...r)}return t.createNode(`taskItem`,{checked:e.checked||!1},n)},renderMarkdown:(e,t)=>vG(e,t,`- [${e.attrs?.checked?`x`:` `}] `),addExtensions(){return this.options.nested?[zZ(this.name,[this.options.taskListTypeName])]:[]},addKeyboardShortcuts(){let e={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...e,Tab:()=>this.editor.commands.sinkListItem(this.name)}:e},addNodeView(){return({node:e,HTMLAttributes:t,getPos:n,editor:r})=>{let i=document.createElement(`li`),a=document.createElement(`label`),o=document.createElement(`span`),s=document.createElement(`input`),c=document.createElement(`div`);o.style.cssText=MQ;let l=e=>{let t=NQ(e,e.attrs.checked,this.options.a11y);s.setAttribute(`aria-label`,t),o.textContent=t};l(e),a.contentEditable=`false`,s.type=`checkbox`,s.addEventListener(`mousedown`,e=>e.preventDefault()),s.addEventListener(`change`,t=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){s.checked=!s.checked;return}let{checked:i}=t.target;r.isEditable&&typeof n==`function`&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:e})=>{let t=n();if(typeof t!=`number`)return!1;let r=e.doc.nodeAt(t);return e.setNodeMarkup(t,void 0,{...r?.attrs,checked:i}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(e,i)||(s.checked=!s.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([e,t])=>{i.setAttribute(e,t)}),i.dataset.checked=e.attrs.checked,s.checked=e.attrs.checked,a.append(s,o),i.append(a,c),Object.entries(t).forEach(([e,t])=>{i.setAttribute(e,t)});let u=new Set(Object.keys(t));return{dom:i,contentDOM:c,update:e=>{if(e.type!==this.type)return!1;i.dataset.checked=e.attrs.checked,s.checked=e.attrs.checked,l(e);let t=r.extensionManager.attributes,n=MU(e,t),a=new Set(Object.keys(n)),o=this.options.HTMLAttributes;return u.forEach(e=>{a.has(e)||(e in o?i.setAttribute(e,o[e]):i.removeAttribute(e))}),Object.entries(n).forEach(([e,t])=>{t==null?e in o?i.setAttribute(e,o[e]):i.removeAttribute(e):i.setAttribute(e,t)}),u=a,!0}}}},addInputRules(){return[eK({find:jQ,type:this.type,getAttributes:e=>({checked:e[e.length-1]===`x`})})]}}),FQ=tK.create({name:`taskList`,addOptions(){return{itemTypeName:`taskItem`,HTMLAttributes:{}}},group:`block list`,content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:e}){return[`ul`,jU(this.options.HTMLAttributes,e,{"data-type":this.name}),0]},parseMarkdown:(e,t)=>t.createNode(`taskList`,{},t.parseChildren(e.items||[])),renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,`
|
|
311
|
+
`):``,markdownTokenizer:{name:`taskList`,level:`block`,start(e){let t=e.match(/^\s*[-+*]\s+\[([ xX])\]\s+/)?.index;return t===void 0?-1:t},tokenize(e,t,n){let r=e=>{let t=_G(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:e[3].toLowerCase()===`x`}),createToken:(e,t)=>({type:`taskItem`,raw:``,mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);if(t){let r={type:`taskList`,raw:t.raw,items:t.items},i=e.slice(t.raw.length);return i.trim()?[r,...n.blockTokens(i)]:[r]}return n.blockTokens(e)},i=_G(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:e[3].toLowerCase()===`x`}),createToken:(e,t)=>({type:`taskItem`,raw:``,mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);if(i)return{type:`taskList`,raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:e})=>e.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});PG.create({name:`listKit`,addExtensions(){let e=[];return this.options.bulletList!==!1&&e.push(FZ.configure(this.options.bulletList)),this.options.listItem!==!1&&e.push(iQ.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(pQ.configure(this.options.listKeymap)),this.options.orderedList!==!1&&e.push(AQ.configure(this.options.orderedList)),this.options.taskItem!==!1&&e.push(PQ.configure(this.options.taskItem)),this.options.taskList!==!1&&e.push(FQ.configure(this.options.taskList)),e}});var IQ=` `,LQ=`\xA0`,RQ=tK.create({name:`paragraph`,priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:`block`,content:`inline*`,parseHTML(){return[{tag:`p`}]},renderHTML({HTMLAttributes:e}){return[`p`,jU(this.options.HTMLAttributes,e),0]},parseMarkdown:(e,t)=>{let n=e.tokens||[];if(n.length===1&&n[0].type===`image`)return t.parseChildren([n[0]]);let r=t.parseInline(n);return n.length===1&&n[0].type===`text`&&(n[0].raw===IQ||n[0].text===IQ||n[0].raw===LQ||n[0].text===LQ)&&r.length===1&&r[0].type===`text`&&(r[0].text===IQ||r[0].text===LQ)?t.createNode(`paragraph`,void 0,[]):t.createNode(`paragraph`,void 0,r)},renderMarkdown:(e,t,n)=>{if(!e)return``;let r=Array.isArray(e.content)?e.content:[];if(r.length===0){var i,a;let e=Array.isArray(n==null||(i=n.previousNode)==null?void 0:i.content)?n.previousNode.content:[];return(n==null||(a=n.previousNode)==null?void 0:a.type)===`paragraph`&&e.length===0?IQ:``}return t.renderChildren(r)},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),zQ=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,BQ=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,VQ=EG.create({name:`strike`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`s`},{tag:`del`},{tag:`strike`},{style:`text-decoration`,consuming:!1,getAttrs:e=>e.includes(`line-through`)?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`s`,jU(this.options.HTMLAttributes,e),0]},markdownTokenName:`del`,parseMarkdown:(e,t)=>t.applyMark(`strike`,t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>`~~${t.renderChildren(e)}~~`,addCommands(){return{setStrike:()=>({commands:e})=>e.setMark(this.name),toggleStrike:()=>({commands:e})=>e.toggleMark(this.name),unsetStrike:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[ZG({find:zQ,type:this.type})]},addPasteRules(){return[nK({find:BQ,type:this.type})]}}),HQ=tK.create({name:`text`,group:`inline`,parseMarkdown:e=>({type:`text`,text:e.text||``}),renderMarkdown:e=>e.text||``}),UQ=EG.create({name:`underline`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`u`},{style:`text-decoration`,consuming:!1,getAttrs:e=>e.includes(`underline`)?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`u`,jU(this.options.HTMLAttributes,e),0]},parseMarkdown(e,t){return t.applyMark(this.name||`underline`,t.parseInline(e.tokens||[]))},renderMarkdown(e,t){return`++${t.renderChildren(e)}++`},markdownTokenizer:{name:`underline`,level:`inline`,start(e){return e.indexOf(`++`)},tokenize(e,t,n){let r=/^(\+\+)([\s\S]+?)(\+\+)/.exec(e);if(!r)return;let i=r[2].trim();return{type:`underline`,raw:r[0],text:i,tokens:n.inlineTokens(i)}}},addCommands(){return{setUnderline:()=>({commands:e})=>e.setMark(this.name),toggleUnderline:()=>({commands:e})=>e.toggleMark(this.name),unsetUnderline:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),WQ=PG.create({name:`starterKit`,addExtensions(){let e=[];return this.options.bold!==!1&&e.push(hZ.configure(this.options.bold)),this.options.blockquote!==!1&&e.push(uZ.configure(this.options.blockquote)),this.options.bulletList!==!1&&e.push(FZ.configure(this.options.bulletList)),this.options.code!==!1&&e.push(vZ.configure(this.options.code)),this.options.codeBlock!==!1&&e.push(SZ.configure(this.options.codeBlock)),this.options.document!==!1&&e.push(CZ.configure(this.options.document)),this.options.dropcursor!==!1&&e.push(OX.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&e.push(kX.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&e.push(wZ.configure(this.options.hardBreak)),this.options.heading!==!1&&e.push(TZ.configure(this.options.heading)),this.options.undoRedo!==!1&&e.push(eZ.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&e.push(EZ.configure(this.options.horizontalRule)),this.options.italic!==!1&&e.push(jZ.configure(this.options.italic)),this.options.listItem!==!1&&e.push(iQ.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(pQ.configure(this.options?.listKeymap)),this.options.link!==!1&&e.push(WY.configure(this.options?.link)),this.options.orderedList!==!1&&e.push(AQ.configure(this.options.orderedList)),this.options.paragraph!==!1&&e.push(RQ.configure(this.options.paragraph)),this.options.strike!==!1&&e.push(VQ.configure(this.options.strike)),this.options.text!==!1&&e.push(HQ.configure(this.options.text)),this.options.underline!==!1&&e.push(UQ.configure(this.options?.underline)),this.options.trailingNode!==!1&&e.push($X.configure(this.options?.trailingNode)),e}}),GQ=(0,R.createContext)(null);function KQ(e){let t=(0,R.use)(GQ);if(!t)throw Error(`${e} must be used inside Composer.Root.`);return t}function qQ(e){let t=(0,G.c)(9),n=KQ(e===void 0?`useComposer`:e),r;t[0]!==n.activePopup||t[1]!==n.disabled||t[2]!==n.meta||t[3]!==n.suggestions?(r={...n.meta,disabled:n.disabled,activePopup:n.activePopup,suggestions:n.suggestions},t[0]=n.activePopup,t[1]=n.disabled,t[2]=n.meta,t[3]=n.suggestions,t[4]=r):r=t[4];let i;return t[5]!==n.actions||t[6]!==n.state||t[7]!==r?(i={state:n.state,actions:n.actions,meta:r},t[5]=n.actions,t[6]=n.state,t[7]=r,t[8]=i):i=t[8],i}function JQ(e){let t=(0,G.c)(23),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let{state:i,attachedImages:a}=KQ(`Composer.Attachments`),o=i.imageAttachments,s,c,l,u,d,f;if(t[3]!==a||t[4]!==n||t[5]!==r||t[6]!==i.imageAttachments){f=Symbol.for(`react.early_return_sentinel`);bb0:{let e;t[13]===a?e=t[14]:(e=e=>a.has(e.id),t[13]=a,t[14]=e);let i=o.filter(e);if(i.length===0){f=null;break bb0}s=`list`,c=`Attached files`,t[15]===n?l=t[16]:(l=I(`flex flex-wrap gap-2`,n),t[15]=n,t[16]=l),u=r,d=i.map(YQ)}t[3]=a,t[4]=n,t[5]=r,t[6]=i.imageAttachments,t[7]=s,t[8]=c,t[9]=l,t[10]=u,t[11]=d,t[12]=f}else s=t[7],c=t[8],l=t[9],u=t[10],d=t[11],f=t[12];if(f!==Symbol.for(`react.early_return_sentinel`))return f;let p;return t[17]!==s||t[18]!==c||t[19]!==l||t[20]!==u||t[21]!==d?(p=(0,z.jsx)(`div`,{role:s,"aria-label":c,className:l,...u,children:d}),t[17]=s,t[18]=c,t[19]=l,t[20]=u,t[21]=d,t[22]=p):p=t[22],p}function YQ(e){return(0,z.jsx)(XQ,{attachment:e},e.id)}function XQ(e){let t=(0,G.c)(18),{attachment:n}=e,{id:r,placeholder:i,media:a}=n,{attachedImages:o,disabled:s,actions:c}=KQ(`Composer.Attachments`),l;t[0]!==o||t[1]!==r?(l=o.get(r),t[0]=o,t[1]=r,t[2]=l):l=t[2];let u=l;if(!u)return null;let d;t[3]!==u||t[4]!==a||t[5]!==i?(d=a===`video`?(0,z.jsx)($Q,{placeholder:i,file:u}):a===`audio`?(0,z.jsx)(t$,{placeholder:i,file:u,glyph:`♪`}):(0,z.jsx)(QQ,{placeholder:i,file:u}),t[3]=u,t[4]=a,t[5]=i,t[6]=d):d=t[6];let f=`Remove ${i}`,p;t[7]!==c||t[8]!==r?(p=()=>c.removeImageAttachment(r),t[7]=c,t[8]=r,t[9]=p):p=t[9];let m;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,z.jsx)(ye,{"aria-hidden":!0,className:`size-3`}),t[10]=m):m=t[10];let h;t[11]!==s||t[12]!==f||t[13]!==p?(h=(0,z.jsx)(y,{type:`button`,"aria-label":f,disabled:s,onClick:p,className:`bg-background text-foreground border-border hover:bg-muted absolute -top-1.5 -right-1.5 flex size-5 items-center justify-center rounded-full border disabled:opacity-50`,children:m}),t[11]=s,t[12]=f,t[13]=p,t[14]=h):h=t[14];let g;return t[15]!==d||t[16]!==h?(g=(0,z.jsxs)(`div`,{role:`listitem`,className:`relative`,children:[d,h]}),t[15]=d,t[16]=h,t[17]=g):g=t[17],g}function ZQ(e){let t=(0,G.c)(3),[n,r]=(0,R.useState)(null),i,a;return t[0]===e?(i=t[1],a=t[2]):(i=()=>{let t=URL.createObjectURL(e);return r(t),()=>URL.revokeObjectURL(t)},a=[e],t[0]=e,t[1]=i,t[2]=a),(0,R.useEffect)(i,a),n}function QQ(e){let t=(0,G.c)(5),{placeholder:n,file:r}=e,i=ZQ(r),[a,o]=(0,R.useState)(null),s;return t[0]!==a||t[1]!==r||t[2]!==i||t[3]!==n?(s=i===null?null:i===a?(0,z.jsx)(t$,{placeholder:n,file:r,glyph:`🖼`}):(0,z.jsx)(`img`,{src:i,alt:n,title:r.name,className:`border-border size-16 rounded-md border object-cover`,onError:()=>o(i)}),t[0]=a,t[1]=r,t[2]=i,t[3]=n,t[4]=s):s=t[4],s}function $Q(e){let t=(0,G.c)(11),{placeholder:n,file:r}=e,i=ZQ(r),[a,o]=(0,R.useState)(null),s=i??void 0,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=e=>o(e.currentTarget.duration),t[0]=c):c=t[0];let l;t[1]===s?l=t[2]:(l=(0,z.jsx)(`video`,{src:s,muted:!0,playsInline:!0,preload:`metadata`,className:`size-full object-cover`,onLoadedMetadata:c}),t[1]=s,t[2]=l);let u;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,z.jsx)(`span`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-0 flex items-center justify-center text-lg text-white drop-shadow`,children:`▶`}),t[3]=u):u=t[3];let d;t[4]===a?d=t[5]:(d=a!==null&&Number.isFinite(a)?(0,z.jsx)(`span`,{className:`absolute right-0.5 bottom-0.5 rounded bg-black/70 px-1 text-[10px] leading-4 text-white`,children:e$(a)}):null,t[4]=a,t[5]=d);let f;return t[6]!==r.name||t[7]!==n||t[8]!==l||t[9]!==d?(f=(0,z.jsxs)(`div`,{role:`img`,"aria-label":n,title:r.name,className:`border-border bg-muted relative size-16 overflow-hidden rounded-md border`,children:[l,u,d]}),t[6]=r.name,t[7]=n,t[8]=l,t[9]=d,t[10]=f):f=t[10],f}function e$(e){let t=Math.round(e);return`${Math.floor(t/60)}:${String(t%60).padStart(2,`0`)}`}function t$(e){let t=(0,G.c)(12),{placeholder:n,file:r,glyph:i}=e,a;t[0]===i?a=t[1]:(a=(0,z.jsxs)(`span`,{"aria-hidden":!0,children:[i,` `]}),t[0]=i,t[1]=a);let o=r.name||n,s;t[2]!==a||t[3]!==o?(s=(0,z.jsxs)(`span`,{className:`text-foreground truncate`,children:[a,o]}),t[2]=a,t[3]=o,t[4]=s):s=t[4];let c=r.type||`file`,l;t[5]===c?l=t[6]:(l=(0,z.jsx)(`span`,{className:`truncate`,children:c}),t[5]=c,t[6]=l);let u;return t[7]!==r.name||t[8]!==n||t[9]!==s||t[10]!==l?(u=(0,z.jsxs)(`div`,{role:`img`,"aria-label":n,title:r.name,className:`border-border bg-muted text-muted-foreground flex h-16 max-w-48 flex-col justify-center gap-0.5 rounded-md border px-2 text-xs`,children:[s,l]}),t[7]=r.name,t[8]=n,t[9]=s,t[10]=l,t[11]=u):u=t[11],u}function n$(e,t){return e===`hidden`?!1:e===`before-interaction`?!t:e!==`after-interaction`||t}function r$(e,t,n){let r=a$(e),i=t.filter(e=>o$(e)&&n$(e.visibility,n));return r?i.map((e,t)=>{let n=c$(r,e);return n===null?null:{command:e,rank:n,index:t}}).filter(e=>!!e).sort((e,t)=>e.rank-t.rank||e.index-t.index).map(e=>e.command).slice(0,10):i.slice(0,10)}function i$(e,t){let n=e.toLowerCase();return t.find(e=>o$(e)&&(e.value.toLowerCase()===n||s$(e).some(e=>e===n)))}function a$(e){return e.slice(1).toLowerCase()}function o$(e){return e.availability!==`disabled`}function s$(e){return(e.aliases??[]).map(e=>e.toLowerCase())}function c$(e,t){let n=t.value.toLowerCase(),r=s$(t),i=[t.label.toLowerCase(),...(t.searchTerms??[]).map(e=>e.toLowerCase())];return n===e?0:r.some(t=>t===e)?1:n.startsWith(e)?2:r.some(t=>t.startsWith(e))?3:i.some(t=>t.startsWith(e))?4:null}function l$(e){return e.map(RegExp.escape).join(`|`)}function u$(e){return`(?:${l$(e)})[A-Za-z0-9_:-]+`}function d$(e){return`(?:${l$(e)})[^\\s]+`}function f$(e,t){let n=[];return t.length>0&&n.push(d$(t)),e.length>0&&n.push(u$(e)),n.length>0?new RegExp(n.join(`|`),`g`):null}function p$(e,t){return t.some(t=>e.startsWith(t))}function m$(e){return`${e.trigger}${e.value}`}function h$({initialDraft:e,text:t=``,slashCommands:n=[],mentionCandidates:r=[],commandTriggers:i=[],remoteImageUrls:a=[],isTaskRunning:o=!1,queueSubmissions:s=!1}={}){let c=e?.text??t,l=r.flatMap(e=>{let t=R$(`mention`,m$(e),c,{detail:e.detail});return t?[t]:[]}),u=l.flatMap(e=>{let t=r.find(t=>m$(t)===e.label);return t?[{id:e.id,trigger:t.trigger,value:t.value,payload:t.payload,persistsAs:t.persistsAs}]:[]}),d=e?.remoteImages??(e?.remoteImageUrls??a).map((e,t)=>({id:g1(`remote-image`,e,t),url:e}));return{text:c,cursor:c.length,elements:z$(e?.elements??[...x$(c,n,i),...l]),mentionBindings:e?.mentionBindings??u,imageAttachments:[],remoteImages:d,pendingPastes:e?.pendingPastes??[],selectedRemoteImageId:null,isTaskRunning:o,queueSubmissions:s,error:null,reverseSearch:null,shortcutsOpen:!1,history:[],historyCursor:null,killBuffer:``}}function g$(e){return e.text.length===0&&e.imageAttachments.length===0&&e.remoteImages.length===0&&e.pendingPastes.length===0}function _$(e,t,n){return b$(e,t,n)}function v$(e,t){if(!t||t<1)return null;let n=K$(e.prompt);return n<=t?null:`Prompt is too long after expanding pasted content (${n} chars; max ${t} chars).`}function y$(e,t,n){let r=M$(e.elements,e.text);r=[...r.filter(e=>e.kind!==`slash-command`),...x$(e.text,t,n)];let i=e.mentionBindings.filter(e=>r.some(t=>t.id===e.id)),a=e.imageAttachments.filter(e=>r.some(t=>t.kind===`image`&&t.label===e.placeholder)),o=e.pendingPastes.filter(e=>r.some(t=>t.kind===`paste`&&t.label===e.placeholder));return{...e,elements:z$(r),mentionBindings:i,imageAttachments:W$(a,e.remoteImages.length),pendingPastes:o}}function b$(e,t,n){let r=e.text.trim(),i=O$(e.text,r,e.elements),a=E$(e.text,e.elements,e.pendingPastes),o=a.text,s=o.trim(),c=O$(o,s,a.elements),l=e.imageAttachments.filter(t=>e.text.includes(t.placeholder)),u=k$(r,i),d=Q$({text:u.text,elements:u.elements,mentionBindings:e.mentionBindings}),f=Q$({text:s,elements:c,mentionBindings:e.mentionBindings});if(!s&&l.length===0&&e.remoteImages.length===0)return null;let p=p$(o,n)?S$(s,c,t,n):null,m=p?.prompt===void 0?null:p.args?`${p.prompt}\n\n${Q$({text:p.args,elements:p.argsElements,mentionBindings:e.mentionBindings})}`:p.prompt,h=p?.prompt===void 0?null:p.args?(()=>{let t=k$(p.args,p.argsElements);return`${p.prompt}\n\n${Q$({text:t.text,elements:t.elements,mentionBindings:e.mentionBindings})}`})():p.prompt,g=m??f,_=p?.args===void 0?p?`command`:`submitted`:`command-with-args`,v=[...e.remoteImages.map(e=>({type:`remote_image`,url:e.url}))];!p&&s&&v.push({type:`text`,text:s,textElements:c});let y=p?.args??s;for(let t of e.mentionBindings){let e=`${t.trigger}${t.value}`;!e||!y.includes(e)||v.push({type:`item`,id:t.id,trigger:t.trigger,value:t.value,payload:t.payload})}for(let e of c)e.kind===`link`&&e.detail&&v.push({type:`link`,text:e.label,href:e.detail}),e.kind===`rich-link`&&e.detail&&v.push({type:`rich_link`,text:e.label,href:e.detail,metadata:e.metadata});return{mode:_,prompt:g,persistedPrompt:d,historyPrompt:h??d,action:p?.args===void 0?p?`Command`:`Plain`:`CommandWithArgs`,command:p?.command,args:p?.args,items:v,elements:i,payloadElements:c,mentionBindings:e.mentionBindings}}function x$(e,t,n){let r=[];if(n.length===0)return r;let i=e.matchAll(RegExp(`(^|\\s)((?:${l$(n)})([A-Za-z0-9_:-]+))(?=\\s|$)`,`g`));for(let e of i){let n=i$(e[3],t);if(!n)continue;let i=e[2],a=e.index+e[1].length;r.push({id:g1(`slash-command`,i,a),kind:`slash-command`,label:i,range:{start:a,end:a+i.length},detail:n.detail})}return r}function S$(e,t,n,r){let i=e.match(RegExp(`^(?:${l$(r)})([A-Za-z0-9_:-]+)(?:\\s+([\\s\\S]+))?$`));if(!i)return null;let a=i$(i[1],n);if(!a)return null;let o=i[2]??``;if(!o.trim())return{command:a.value,prompt:a.expandsTo};if(!a.supportsArgs)return null;let s=a.trigger.length+a.value.length,c=e.slice(s).search(/\S/),l=c===-1?s:s+c,u=o.trim();return{command:a.value,prompt:a.expandsTo,args:u,argsElements:D$(t,l,l+u.length)}}function C$(e,t,n){if(n.length===0)return null;let r=e.match(RegExp(`^(?:${l$(n)})([A-Za-z0-9_:-]+)(?:\\s+[\\s\\S]*)?$`));return!r||i$(r[1],t)||T$(r[1])?null:r[1]}var w$=new Set([`Applications`,`Library`,`System`,`Users`,`Volumes`,`bin`,`dev`,`etc`,`home`,`mnt`,`opt`,`private`,`sbin`,`tmp`,`usr`,`var`,`workspace`]);function T$(e){return w$.has(e)}function E$(e,t,n){if(n.length===0||t.length===0)return{text:e,elements:t};let r=new Map;for(let e of n){let t=r.get(e.placeholder)??[];t.push(e.content),r.set(e.placeholder,t)}let i=``,a=[],o=0;for(let n of z$(t)){let t=Math.min(n.range.start,e.length),s=Math.min(n.range.end,e.length);if(t>s)continue;t>o&&(i+=e.slice(o,t));let c=e.slice(t,s),l=r.get(n.label)?.shift();if(l!==void 0)i+=l;else{let e=i.length;i+=c,a.push({...n,range:{start:e,end:i.length}})}o=s}return o<e.length&&(i+=e.slice(o)),{text:i,elements:a}}function D$(e,t,n){return e.filter(e=>e.range.end>t&&e.range.start<n).map(e=>({...e,range:{start:Math.max(0,e.range.start-t),end:Math.min(n,e.range.end)-t}})).filter(e=>e.range.start<e.range.end)}function O$(e,t,n){let r=e.indexOf(t);return r<=0?n:n.filter(e=>e.range.end>r).map(e=>({...e,range:{start:Math.max(0,e.range.start-r),end:Math.max(0,e.range.end-r)}}))}function k$(e,t){let n=z$(t.filter(e=>e.kind===`image`));for(let t of n.toReversed())e=j$(e,t.range,``);let r=e=>n.reduce((t,n)=>t+Math.max(0,Math.min(e,n.range.end)-n.range.start),0);return{text:e,elements:z$(t.filter(e=>e.kind!==`image`)).map(e=>({...e,range:{start:e.range.start-r(e.range.start),end:e.range.end-r(e.range.end)}}))}}function A$(e,t,n,r){return e<r&&t>n}function j$(e,t,n){return e.slice(0,t.start)+n+e.slice(t.end)}function M$(e,t){let n=new Map;return z$(e).map(e=>{let r=N$(t,e.label);if(r.length===0)return null;let i=`${e.kind}:${e.label}`,a=n.get(i)??[],o=P$(r,e,a)??F$(r,e,a)??I$(r,e);return n.set(i,[...a,o]),{...e,range:o}}).filter(e=>!!e)}function N$(e,t){if(!t)return[];let n=[],r=e.indexOf(t);for(;r!==-1;)n.push({start:r,end:r+t.length}),r=e.indexOf(t,r+t.length);return n}function P$(e,t,n){return e.find(e=>e.start===t.range.start&&e.end===t.range.end&&!L$(e,n))}function F$(e,t,n){return I$(e.filter(e=>!L$(e,n)),t)}function I$(e,t){return[...e].sort((e,n)=>Math.abs(e.start-t.range.start)-Math.abs(n.start-t.range.start)||e.start-n.start)[0]}function L$(e,t){return t.some(t=>e.start===t.start&&e.end===t.end&&A$(e.start,e.end,t.start,t.end))}function R$(e,t,n,r={}){let i=n.indexOf(t);return i===-1?null:{id:g1(e,t,i),kind:e,label:t,range:{start:i,end:i+t.length},detail:r.detail}}function z$(e){return[...e].sort((e,t)=>e.range.start-t.range.start)}var B$={image:`Image`,video:`Video`,audio:`Audio`};function V$(e){let t=e.type.split(`/`)[0];return t===`image`||t===`video`||t===`audio`?t:null}function H$(e){return e===`video`||e===`audio`?e:`image`}function U$(e,t){return`[${B$[e]} #${t}]`}function W$(e,t){return e.map((e,n)=>({...e,placeholder:U$(e.media,t+n+1)}))}function G$(e,t){if(!t)return null;let n=e.remoteImages.findIndex(e=>e.id===t);return n===-1?null:n}function K$(e){return Array.from(e).length}function q$(e){let t=k$(e.text,e.elements);return{text:t.text,elements:c1(t.elements),mentionBindings:l1(e.mentionBindings),remoteImages:e.remoteImages.map(e=>({...e})),pendingPastes:u1(e.pendingPastes)}}function J$(e,t){return{persistedPrompt:t,remoteImages:e.remoteImages.map(e=>({...e})),pendingPastes:u1(e.pendingPastes)}}function Y$(e,t){let n=J$(e,t);return!n.persistedPrompt.trim()&&n.remoteImages.length===0&&n.pendingPastes.length===0?e.history:[n,...e.history].slice(0,8)}function X$({text:e,slashCommands:t=[],commandTriggers:n=[],mentionCandidates:r=[]}){let i=e1(e,r),a=a1(i.text,i.elements,i.protectedRanges,t,r);return q$(y$(h$({initialDraft:{text:i.text,elements:z$([...i.elements,...a.elements]),mentionBindings:[...i.mentionBindings,...a.mentionBindings]},slashCommands:t}),t,n))}function Z$({source:e,slashCommands:t=[],mentionCandidates:n=[]}){let r=X$({text:e.persistedPrompt,slashCommands:t,mentionCandidates:n}),i=[...e.pendingPastes.flatMap(e=>{let t=R$(`paste`,e.placeholder,r.text??``,{detail:`${K$(e.content)} chars`});return t?[t]:[]})];return{...r,elements:z$([...r.elements??[],...i]),remoteImages:e.remoteImages.map(e=>({...e})),pendingPastes:u1(e.pendingPastes)}}function Q$(e){let t=e.text??``,n=z$(e.elements??[]).map(t=>s1(t,e)).filter(e=>!!e).sort((e,t)=>t.range.start-e.range.start);for(let e of n)t=j$(t,e.range,e.text);return t}function $$(e){return e.startsWith(`composer-text-link://`)?decodeURIComponent(e.replace(/^composer-text-link:\/\//,``)):e}function e1(e,t){let n=[],r=[],i=[],a=``;for(let o of sN(e)){if(o.kind===`inline-code`||o.kind===`code-block`){let e=a.length;a+=o.source,i.push({start:e,end:a.length});continue}if(o.kind!==`link`&&o.kind!==`skill-link`&&o.kind!==`mention`){a+=o.source;continue}let e=o.label,s=o.href,c=$$(s),l=t1(e,t),u=l?m$(l):e,d=a.length;if(a+=u,l){let e=g1(`mention`,u,d);n.push({id:e,kind:`mention`,label:u,range:{start:d,end:d+u.length},detail:l.detail}),r.push({id:e,trigger:l.trigger,value:l.value,payload:l.payload,persistsAs:l.persistsAs})}else n.push({id:g1(`link`,u,d),kind:`link`,label:u,range:{start:d,end:d+u.length},detail:c})}return{text:a,elements:n,mentionBindings:r,protectedRanges:i}}function t1(e,t){return t.find(t=>m$(t)===e)??null}function n1(e){return[...new Set(e.map(e=>e.trigger).filter(Boolean))].sort((e,t)=>t.length-e.length)}function r1(e){let t=n1(e);return t.length===0?null:RegExp(`(?:${l$(t)})[A-Za-z0-9_:-]+`,`g`)}function i1(e,t){return n1(t).find(t=>e.startsWith(t))?.length??0}function a1(e,t,n,r,i){let a=[],o=[],s=[],c=(r,i)=>{let a=r+i.length;return(r===0||/\s/.test(e[r-1]??``))&&!o1(r,i,t)&&!s.some(e=>r<e.end&&a>e.start)&&!n.some(e=>r<e.end&&a>e.start)},l=[...i].sort((e,t)=>m$(t).length-m$(e).length);for(let t of l){let n=m$(t);if(n)for(let r=e.indexOf(n);r!==-1;r=e.indexOf(n,r+n.length)){let i=r+n.length;if(/[\w-]/.test(e[i]??``)||!c(r,n))continue;let l=g1(`mention`,n,r);s.push({start:r,end:i}),a.push({id:l,kind:`mention`,label:n,range:{start:r,end:i},detail:t.detail}),o.push({id:l,trigger:t.trigger,value:t.value,payload:t.payload,persistsAs:t.persistsAs})}}let u=r1(r);for(let t of u?e.matchAll(u):[]){let e=t.index??0,n=t[0];if(!c(e,n))continue;let i=i$(n.slice(i1(n,r)),r);i&&(s.push({start:e,end:e+n.length}),a.push({id:g1(`slash-command`,n,e),kind:`slash-command`,label:n,range:{start:e,end:e+n.length},detail:i.detail}))}return{elements:a,mentionBindings:o}}function o1(e,t,n){let r=e+t.length;return n.some(t=>e<t.range.end&&r>t.range.start)}function s1(e,t){if(e.kind===`mention`){let n=(t.mentionBindings??[]).find(t=>t.id===e.id||`${t.trigger}${t.value}`===e.label);return n?{range:e.range,text:n.persistsAs??e.label}:null}return(e.kind===`link`||e.kind===`rich-link`)&&e.detail?{range:e.range,text:oN(e.label,e.detail)}:null}function c1(e){return e.map(e=>{let t={...e,range:{...e.range}};return e.metadata?{...t,metadata:{...e.metadata}}:t})}function l1(e){return e.map(e=>({...e}))}function u1(e){return e.map(e=>({...e}))}function d1(e,t,n,r=1){if(t.length===0)return null;let i=t.toLowerCase(),a=e.map((e,t)=>({index:t,entry:e})).filter(e=>e.entry.persistedPrompt.toLowerCase().includes(i));if(a.length===0)return null;if(n===null)return a[0];let o=a.findIndex(e=>e.index===n);return o===-1?a[0]:a[h1(o+r,a.length)]}function f1(e,t,n){return n===-1?t===0||!e.slice(0,t).includes(`
|
|
312
312
|
`):t===e.length||!e.slice(t).includes(`
|
|
313
|
-
`)}function m1(e,t){let n=v1(e,t);for(;n>0&&T1(x1(e,n));)n=y1(e,n);if(n===0)return 0;let r=O1(x1(e,n));if(r===`cjk`)return y1(e,n);for(;n>0&&O1(x1(e,n))===r;)n=y1(e,n);return n}function h1(e,t){let n=v1(e,t);for(;n<e.length&&T1(S1(e,n));)n=b1(e,n);if(n>=e.length)return e.length;let r=O1(S1(e,n));if(r===`cjk`)return b1(e,n);for(;n<e.length&&O1(S1(e,n))===r;)n=b1(e,n);return n}function g1(e,t){return(e%t+t)%t}function _1(e,t,n){return`${e}:${n}:${t}`}function v1(e,t){let n=Math.max(0,Math.min(t,e.length));return n>0&&n<e.length&&w1(e.charCodeAt(n))&&--n,n}function y1(e,t){let n=t-1;return n>0&&w1(e.charCodeAt(n))?n-1:Math.max(n,0)}function b1(e,t){let n=t+(C1(e.charCodeAt(t))?2:1);return Math.min(n,e.length)}function x1(e,t){let n=y1(e,t);return e.slice(n,t)}function S1(e,t){return e.slice(t,b1(e,t))}function C1(e){return e>=55296&&e<=56319}function w1(e){return e>=56320&&e<=57343}function T1(e){return/\s/u.test(e)}function E1(e){return!D1(e)&&/[\p{Letter}\p{Number}_]/u.test(e)}function D1(e){return/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]/u.test(e)}function O1(e){return D1(e)?`cjk`:E1(e)?`word`:`separator`}var k1=`composer-draft:v1:`;function A1(e){let t=localStorage.getItem(`${k1}${e}`);if(!t)return null;try{let e=JSON.parse(t);return N1(e)?e:null}catch{return null}}function j1(e,t){let n=`${k1}${e}`;if(!t||M1(t)){localStorage.removeItem(n);return}try{localStorage.setItem(n,JSON.stringify(t))}catch(e){if(!(e instanceof DOMException&&e.name===`QuotaExceededError`))throw e}}function M1(e){return!e.persistedPrompt.trim()&&e.remoteImages.length===0&&e.pendingPastes.length===0}function N1(e){return P1(e)&&Object.keys(e).every(e=>[`persistedPrompt`,`remoteImages`,`pendingPastes`].includes(e))&&typeof e.persistedPrompt==`string`&&Array.isArray(e.remoteImages)&&Array.isArray(e.pendingPastes)}function P1(e){return typeof e==`object`&&!!e}var F1=Symbol.for(`composer.registry.trigger`),I1=Symbol.for(`composer.registry.command`),L1=Symbol.for(`composer.registry.mention`);function R1(e){return null}R1.role=F1;function z1(e){return null}z1.role=I1;function B1(e){return null}B1.role=L1;function V1(e){let t=[],n=[],r=new Set,i=new Set,a=!1,o=e=>{for(let s of R.Children.toArray(e)){if(!(0,R.isValidElement)(s)){a=!0;continue}if(s.type===R.Fragment){(0,R.isValidElement)(s)&&o(s.props.children);continue}if(K1(s.type,F1)){(0,R.isValidElement)(s)&&W1(s.props,{slashCommands:t,mentionCandidates:n,commandTriggers:r,mentionTriggers:i});continue}if(K1(s.type,I1)||K1(s.type,L1))throw Error(`Composer.Command and Composer.Mention must be placed inside a <Composer.Trigger>.`);a=!0}};return o(e),{slashCommands:t,mentionCandidates:n,commandTriggers:[...r],mentionTriggers:[...i],hasLayoutChildren:a}}function H1(e){return JSON.stringify([e.slashCommands.map(U1),e.mentionCandidates.map(U1),e.commandTriggers,e.mentionTriggers])}function U1(e){let{icon:t,...n}=e;return n}function W1(e,t){let{trigger:n}=e;for(let r of R.Children.toArray(e.children))if((0,R.isValidElement)(r)){if(r.type===R.Fragment){(0,R.isValidElement)(r)&&W1({trigger:n,children:r.props.children},t);continue}if(K1(r.type,I1)){if(t.mentionTriggers.has(n))throw Error(`Composer.Trigger "${n}" already holds mentions; a trigger carries either commands or mentions, not both.`);t.commandTriggers.add(n),(0,R.isValidElement)(r)&&t.slashCommands.push({...r.props,atomic:!1,trigger:n});continue}if(K1(r.type,L1)){if(t.commandTriggers.has(n))throw Error(`Composer.Trigger "${n}" already holds commands; a trigger carries either commands or mentions, not both.`);t.mentionTriggers.add(n),(0,R.isValidElement)(r)&&t.mentionCandidates.push(G1(r.props,n));continue}throw Error(`<Composer.Trigger trigger="${n}"> accepts only <Composer.Command> and <Composer.Mention> children; wrap them in a fragment rather than a component, which the registry cannot see through.`)}}function G1(e,t){return{id:e.id,trigger:t,value:e.value,label:e.label,detail:e.detail,atomic:!0,icon:e.icon,payload:e.payload,persistsAs:e.persistsAs,visibility:e.visibility}}function K1(e,t){return typeof e==`function`&&`role`in e&&e.role===t}function q1(e,t,n,r){return[...i$(e.query,t.filter(t=>t.trigger===e.trigger),r),...J1(e.query,n.filter(t=>t.trigger===e.trigger),r)]}function J1(e,t,n){let r=e.slice(1).toLowerCase();return t.filter(e=>r$(e.visibility,n)&&(e.label.toLowerCase().includes(r)||h$(e).slice(1).toLowerCase().includes(r))).slice(0,10)}var Y1=(0,R.createContext)(null);function X1(e){let t=e===void 0?`useComposerDictation`:e;qQ(t);let n=(0,R.use)(Y1);if(!n)throw Error(`${t} needs the dictation prop of Composer.Root.`);return n}function Z1(e,t){return typeof e==`function`?n=>e(n,t):e}function Q1(e){let t=(0,G.c)(15),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({dictation:a,refusesStart:r,render:i,...n}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let{state:o,start:s,stop:c}=a,l=o.status===`recording`,u=(o.status===`idle`||o.status===`failed`)&&!r,d=o.status,f=!l&&!u,p=l?c:s,m;t[5]!==i||t[6]!==o?(m=Z1(i,o),t[5]=i,t[6]=o,t[7]=m):m=t[7];let h;return t[8]!==n||t[9]!==l||t[10]!==o.status||t[11]!==f||t[12]!==p||t[13]!==m?(h=(0,z.jsx)(y,{...n,"data-status":d,"aria-pressed":l,disabled:f,onClick:p,render:m}),t[8]=n,t[9]=l,t[10]=o.status,t[11]=f,t[12]=p,t[13]=m,t[14]=h):h=t[14],h}function $1(e){let t=(0,G.c)(14),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({dictation:a,render:i,disabled:n,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let{state:o,cancel:s}=a,c=o.status===`starting`||o.status===`recording`||o.status===`finishing`,l=o.status,u=!c||n===!0,d;t[5]!==i||t[6]!==o?(d=Z1(i,o),t[5]=i,t[6]=o,t[7]=d):d=t[7];let f;return t[8]!==s||t[9]!==r||t[10]!==o.status||t[11]!==u||t[12]!==d?(f=(0,z.jsx)(y,{...r,"data-status":l,disabled:u,onClick:s,render:d}),t[8]=s,t[9]=r,t[10]=o.status,t[11]=u,t[12]=d,t[13]=f):f=t[13],f}function e0(e){let t=(0,G.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({disabled:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let{disabled:i}=qQ(`Composer.Dictate`),a=X1(`Composer.Dictate`),{state:o}=a,s=o.status===`finishing`?o.end:void 0,c=n===!0||i,l;return t[3]!==a||t[4]!==r||t[5]!==s||t[6]!==c?(l=(0,z.jsx)(Q1,{...r,"data-end":s,dictation:a,refusesStart:c}),t[3]=a,t[4]=r,t[5]=s,t[6]=c,t[7]=l):l=t[7],l}function t0(e){let t=(0,G.c)(3),n=X1(`Composer.CancelDictation`),r;return t[0]!==n||t[1]!==e?(r=(0,z.jsx)($1,{...e,dictation:n}),t[0]=n,t[1]=e,t[2]=r):r=t[2],r}var n0=class extends Error{code;constructor(e,t){super(`Dictation failed: ${e}`,t),this.name=`DictationError`,this.code=e}},r0=new Map([[`NotAllowedError`,`permission-denied`],[`NotFoundError`,`no-microphone`],[`NotReadableError`,`microphone-in-use`]]);function i0(e){switch(e.status){case`starting`:case`ended`:return{status:e.status};case`recording`:return{status:`recording`};case`stopping`:case`transcribing`:return{status:`finishing`};case`failed`:return{status:`failed`,error:e.error}}}var a0=class e{#e={status:`starting`};#t={status:`starting`};#n=new AbortController;#r=new Set;#i=new Set;#a;constructor(e){this.#a=e}static start(t){let n=new e(t);return n.#o(),n}subscribe=e=>(this.#r.add(e),()=>{this.#r.delete(e)});getSnapshot=()=>this.#t;onTranscript(e){return this.#i.add(e),()=>{this.#i.delete(e)}}stop(){let e=this.#e;if(e.status===`starting`){this.cancel();return}e.status===`recording`&&(this.#u({...e,status:`stopping`}),e.recorder.stop())}cancel(){this.#l({status:`ended`})}async#o(){let e;try{e=await navigator.mediaDevices.getUserMedia({audio:!0})}catch(e){let t=e instanceof DOMException?r0.get(e.name):void 0;if(!t)throw e;this.#l({status:`failed`,error:new n0(t,{cause:e})});return}let{signal:t}=this.#n;if(t.aborted){for(let t of e.getTracks())t.stop();return}let n=new MediaRecorder(e),r=[];n.addEventListener(`dataavailable`,e=>{r.push(e.data)},{signal:t}),n.addEventListener(`stop`,()=>{this.#e.status===`stopping`&&this.#s(new Blob(r,{type:n.mimeType}))},{signal:t}),n.addEventListener(`error`,e=>{this.#l({status:`failed`,error:new n0(`interrupted`,{cause:e})})},{signal:t});for(let n of e.getAudioTracks())n.addEventListener(`ended`,()=>{this.#l({status:`failed`,error:new n0(`interrupted`)})},{signal:t});n.start(),this.#u({status:`recording`,stream:e,recorder:n})}async#s(e){this.#c(),this.#u({status:`transcribing`});let{signal:t}=this.#n;try{let{text:n}=await this.#a(e,{signal:t});if(t.aborted)return;for(let e of this.#i)e(n)}catch(e){if(t.aborted)return;this.#l({status:`failed`,error:new n0(`transcription-failed`,{cause:e})});return}this.#l({status:`ended`})}#c(){let e=this.#e;if(!(e.status!==`recording`&&e.status!==`stopping`)){e.recorder.state!==`inactive`&&e.recorder.stop();for(let t of e.stream.getTracks())t.stop()}}#l(e){let{status:t}=this.#e;t===`ended`||t===`failed`||(this.#n.abort(),this.#c(),this.#u(e))}#u(e){this.#e=e,this.#t=i0(e);for(let e of this.#r)e()}},o0=class{#e=`unknown`;subscribe=e=>{let t=new AbortController;return navigator.permissions.query({name:`microphone`}).then(n=>{if(t.signal.aborted)return;let r=()=>{this.#e=n.state,e()};r(),n.addEventListener(`change`,r,{signal:t.signal})},e=>{if(!(e instanceof TypeError))throw e}),()=>{t.abort()}};getSnapshot=()=>this.#e},s0=()=>()=>void 0,c0=()=>null,l0=()=>`unknown`;function u0(e){let t=(0,G.c)(29),{offered:n,disabled:r,onTranscript:i}=e,a=`MediaRecorder`in globalThis&&`mediaDevices`in navigator,[o]=(0,R.useState)(d0),s=(0,R.useSyncExternalStore)(n&&a?o.subscribe:s0,o.getSnapshot,l0),[c,l]=(0,R.useState)(null),u=(0,R.useSyncExternalStore)(c?c.subscribe:s0,c?c.getSnapshot:c0,c0),d;t[0]===i?d=t[1]:(d=e=>{i(e)},t[0]=i,t[1]=d);let f=(0,R.useEffectEvent)(d),p;t[2]!==f||t[3]!==c?(p=()=>{if(!c)return;let e=c.onTranscript(e=>{f(e)});return()=>{e(),c.cancel()}},t[2]=f,t[3]=c,t[4]=p):p=t[4];let m;t[5]===c?m=t[6]:(m=[c],t[5]=c,t[6]=m),(0,R.useEffect)(p,m);let h,g;t[7]!==r||t[8]!==n||t[9]!==c?(h=()=>{(r||!n)&&c?.cancel()},g=[r,n,c],t[7]=r,t[8]=n,t[9]=c,t[10]=h,t[11]=g):(h=t[10],g=t[11]),(0,R.useEffect)(h,g);let _,v;if(t[12]!==s||t[13]!==u){v=e(),_=v.status===`starting`||v.status===`recording`||v.status===`finishing`;function e(){if(!a)return{status:`unavailable`,reason:`unsupported`};switch(u?.status){case`starting`:case`recording`:case`finishing`:return{status:u.status};case`ended`:case`failed`:case void 0:}return s===`denied`?{status:`unavailable`,reason:`blocked`}:u?.status===`failed`?{status:`failed`,error:u.error}:{status:`idle`}}t[12]=s,t[13]=u,t[14]=_,t[15]=v}else _=t[14],v=t[15];let y;t[16]!==_||t[17]!==r||t[18]!==v?(y=function(e){return r||_||v.status===`unavailable`?!1:(l(a0.start(e)),!0)},t[16]=_,t[17]=r,t[18]=v,t[19]=y):y=t[19];let b=y,x;t[20]===c?x=t[21]:(x=function(){c?.stop()},t[20]=c,t[21]=x);let S=x,C;t[22]===c?C=t[23]:(C=function(){c?.cancel()},t[22]=c,t[23]=C);let w=C,T;return t[24]!==w||t[25]!==b||t[26]!==v||t[27]!==S?(T={state:v,start:b,stop:S,cancel:w},t[24]=w,t[25]=b,t[26]=v,t[27]=S,t[28]=T):T=t[28],T}function d0(){return new o0}function f0(e){let t=(0,G.c)(25),{dictation:n,disabled:r,insertTranscript:i,submitDraft:a}=e,[o,s]=(0,R.useState)(`insert`),c=n!==void 0,l;t[0]!==o||t[1]!==i||t[2]!==a?(l=e=>{let t=e.trim();t&&i(t),o===`send`&&a()},t[0]=o,t[1]=i,t[2]=a,t[3]=l):l=t[3];let u;t[4]!==r||t[5]!==c||t[6]!==l?(u={offered:c,disabled:r,onTranscript:l},t[4]=r,t[5]=c,t[6]=l,t[7]=u):u=t[7];let d=u0(u);if(!n)return null;let{transcribe:f}=n,p;t[8]!==o||t[9]!==d.state?(p=d.state.status===`finishing`?{status:`finishing`,end:o}:d.state,t[8]=o,t[9]=d.state,t[10]=p):p=t[10];let m=p,h;t[11]!==d||t[12]!==f?(h=function(){d.start(f)&&s(`insert`)},t[11]=d,t[12]=f,t[13]=h):h=t[13];let g=h,_;t[14]!==d||t[15]!==m?(_=function(){switch(m.status){case`starting`:return d.cancel(),!1;case`recording`:return s(`send`),d.stop(),!0;case`finishing`:return s(`send`),!0;default:return!1}},t[14]=d,t[15]=m,t[16]=_):_=t[16];let v=_,y;t[17]!==d.cancel||t[18]!==d.stop||t[19]!==g||t[20]!==m?(y={state:m,start:g,stop:d.stop,cancel:d.cancel},t[17]=d.cancel,t[18]=d.stop,t[19]=g,t[20]=m,t[21]=y):y=t[21];let b;return t[22]!==v||t[23]!==y?(b={api:y,endWithSend:v},t[22]=v,t[23]=y,t[24]=b):b=t[24],b}function p0({getPlaceholder:e,...t}){return[GQ.configure({link:!1}),GY.configure({autolink:!0,linkOnPaste:!1,openOnClick:!1,HTMLAttributes:{"data-token":`link`}}),g0,_0,v0,JX.configure({placeholder:e,showOnlyWhenEditable:!1}),y0(t)]}var m0=1e3;function h0(e,t){return{default:t,parseHTML:n=>n.getAttribute(e)??t}}var g0=EG.create({name:`composerSlashCommand`,inclusive:!1,addAttributes(){return{value:{default:null},detail:{default:null}}},parseHTML(){return[{tag:`span[data-composer-slash-command]`}]},renderHTML({HTMLAttributes:e}){return[`span`,jU(e,{"data-token":`slash-command`,"data-composer-slash-command":e.value}),0]}}),_0=tK.create({name:`composerMention`,group:`inline`,inline:!0,atom:!0,selectable:!0,addAttributes(){return{id:h0(`id`,null),trigger:h0(`trigger`,``),value:h0(`value`,``),label:h0(`label`,``),detail:h0(`detail`,``),persistsAs:h0(`persistsAs`,null),payload:{default:null,renderHTML:e=>e.payload===null||e.payload===void 0?{}:{payload:JSON.stringify(e.payload)},parseHTML:e=>{let t=e.getAttribute(`payload`);if(t===null)return null;try{return JSON.parse(t)}catch{return null}}}}},parseHTML(){return[{tag:`span[data-composer-mention]`}]},renderHTML({node:e,HTMLAttributes:t}){let n=e.attrs.label||`${e.attrs.trigger??``}${e.attrs.value??``}`;return[`span`,jU(t,{"data-token":`mention`,"data-composer-mention":e.attrs.value,"data-composer-mention-trigger":e.attrs.trigger}),n]},renderText({node:e}){return e.attrs.label||`${e.attrs.trigger??``}${e.attrs.value??``}`}}),v0=tK.create({name:`composerAtom`,group:`inline`,inline:!0,atom:!0,selectable:!0,addAttributes(){return{kind:{default:`paste`},label:{default:``},detail:{default:``},content:{default:``},href:{default:``},attachmentId:{default:``,rendered:!1},media:{default:`image`,rendered:!1},metadata:{default:null}}},parseHTML(){return[{tag:`span[data-composer-atom]`}]},renderHTML({node:e,HTMLAttributes:t}){let n=String(e.attrs.kind??`paste`),r=String(e.attrs.label??``);return[`span`,jU(t,{"data-token":n,"data-composer-atom":n,"data-composer-atom-detail":e.attrs.detail}),r]},renderText({node:e}){return String(e.attrs.label??``)}});function y0(e){return PG.create({name:`composerClipboard`,addProseMirrorPlugins(){return[new SI({props:{handlePaste(t,n){let r=n.clipboardData;if(!r)return!1;let i=Array.from(r.files).find(e=>H$(e)!==null);if(i)return n.preventDefault(),J0(t,e.getRemoteImageCount(),i,e.attachImageFile),!0;let a=Array.from(r.files).find(e=>H$(e)===null);if(a)return n.preventDefault(),Y0(t,a.name||`pasted-file`,e.getMentionTrigger()),!0;let o=C2(O2(r.getData(`text/uri-list`))||k2(r.getData(`DownloadURL`))||r.getData(`text/plain`)||r.getData(`text`)),s=o.trim();if(!o)return!1;let c=V0(t);if(c&&A2(s)){n.preventDefault();let e=j2(s),r=t.state.schema.marks.link;return r?U0(t,c,e,r):!1}return w2(s)&&!s.includes(`
|
|
314
|
-
`)?(n.preventDefault(),
|
|
315
|
-
`)?(n.preventDefault(),
|
|
316
|
-
`)&&
|
|
317
|
-
`)?(
|
|
318
|
-
`)?(
|
|
319
|
-
`).map(e=>({type:`paragraph`,content:
|
|
320
|
-
`),
|
|
321
|
-
`;return}if(e.type===`text`){let r=e.text??``,i=t.text.length;t.text+=r;for(let a of e.marks??[])if(a.type===`link`&&a.attrs?.href&&t.elements.push({id:
|
|
322
|
-
`,!1):!0}),r.replace(/\n+/g,` `).trim()}function
|
|
323
|
-
`:e.type.name===`composerMention`||e.type.name===`composerAtom`?
|
|
324
|
-
`,
|
|
325
|
-
`,``).length}catch{return 0}}function
|
|
326
|
-
`)}function w2(e){return e.startsWith(`file://`)||e.startsWith(`/`)||e.startsWith(`./`)||e.startsWith(`../`)||/^[A-Za-z]:[\\/]/.test(e)}function T2(e){let t=e.trim();if(!t.startsWith(`file://`))return t;let n=URL.parse(t);if(!n)return t;try{return decodeURIComponent(n.pathname)}catch{return n.pathname}}function E2(e){return e.replace(/[\\/]+$/,``).split(/[\\/]/).filter(Boolean).pop()??e}function D2(e){return/[\\/]$/.test(e)}function O2(e){return e.split(/\r?\n/).map(e=>e.trim()).find(e=>e&&!e.startsWith(`#`))??``}function k2(e){let t=O2(e);return t?t.match(/^[\w.+-]+\/[\w.+-]+:[^:\n]+:(.+)$/)?.[1]?.trim()??t:``}function A2(e){try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`}catch{return!1}}function j2(e){return e1(e.trim())}function M2(e){let t=(0,G.c)(3),n=e.draftKey??``,r;return t[0]!==e||t[1]!==n?(r=(0,z.jsx)(P2,{...e},n),t[0]=e,t[1]=n,t[2]=r):r=t[2],r}function N2(e){return typeof e==`object`&&!!e&&`then`in e&&typeof e.then==`function`}function P2({initialDraft:e,draftKey:t,disabled:n=!1,isTaskRunning:r=!1,queueSubmissions:i=!1,hasInteracted:a=!1,maxExpandedTextChars:o,editorAriaLabel:s=`Rich prompt composer`,className:c,children:l,dictation:u,validateSubmission:d,onSubmit:f,onStateChange:p}){let m=ln(),h=V1(l),g=(0,R.useRef)({signature:H1(h),slashCommands:h.slashCommands,mentionCandidates:h.mentionCandidates,commandTriggers:h.commandTriggers,mentionTriggers:h.mentionTriggers}),_=H1(h);_!==g.current.signature&&(g.current={signature:_,slashCommands:h.slashCommands,mentionCandidates:h.mentionCandidates,commandTriggers:h.commandTriggers,mentionTriggers:h.mentionTriggers});let{slashCommands:v,mentionCandidates:y,commandTriggers:b,mentionTriggers:x}=g.current,S=(0,R.useMemo)(()=>({commandTriggers:b,mentionTriggers:x}),[b,x]),C=(0,R.useRef)(x);C.current=x;let[w]=(0,R.useState)(()=>{if(e)return e;if(t===void 0)return;let n=A1(t);return n?Q$({source:n,slashCommands:v,mentionCandidates:y}):void 0}),T=(0,R.useRef)(w?.remoteImages??[]),E=(0,R.useRef)(x0({state:w,slashCommands:v,mentionCandidates:y,triggers:S})),D=(0,R.useRef)(0),ee=(0,R.useRef)(!0);(0,R.useEffect)(()=>(ee.current=!0,()=>{ee.current=!1}),[]);let[te,O]=(0,R.useState)(T.current),[ne,k]=(0,R.useState)(null),[re,A]=(0,R.useState)(()=>E0(E.current,T.current,v,r,i,0)),j=(0,R.useRef)(re),ie=(0,R.useRef)(te),M=(0,R.useRef)(ne),ae=(0,R.useRef)(null),oe=(0,R.useRef)(null),se=(0,R.useRef)(void 0),N=(0,R.useRef)(null),ce=(0,R.useRef)(null),le=(0,R.useRef)(null),ue=(0,R.useEffectEvent)((e,t)=>{p?.(e,t)}),de=(0,R.useRef)(d),fe=(0,R.useRef)(f),pe=(0,R.useRef)(new Map),me=(0,R.useRef)(()=>null),he=(0,R.useRef)(()=>void 0),ge=(0,R.useRef)(()=>void 0),_e=(0,R.useRef)(()=>!1),[ve,ye]=(0,R.useState)(``),be=(0,R.useRef)(ve);be.current=ve;let P=pq({extensions:(0,R.useMemo)(()=>p0({getPlaceholder:()=>be.current,getMentionTrigger:()=>C.current[0]??`@`,getRemoteImageCount:()=>ie.current.length,attachImageFile:e=>me.current(e)}),[]),content:E.current,editable:!n,editorProps:{attributes:{"data-slot":`composer-editor`,role:`textbox`,"aria-label":s,"aria-placeholder":ve,"aria-disabled":n?`true`:`false`,dir:`auto`,spellcheck:`false`},handleKeyDown(e,t){return _e.current(t)}},immediatelyRender:!1,onUpdate({editor:e}){he.current(e),ge.current(e)},onSelectionUpdate({editor:e}){he.current(e),ge.current(e)}}),xe=(0,R.useMemo)(()=>ne?q1(ne,v,y,a):[],[ne,a,y,v]),Se=(0,R.useMemo)(()=>v$(re,v,b),[b,re,v]);(0,R.useEffect)(()=>{j.current=re},[re]),(0,R.useEffect)(()=>{ie.current=te},[te]),(0,R.useEffect)(()=>{M.current=ne},[ne]),(0,R.useEffect)(()=>{re.shortcutsOpen&&(ne||re.reverseSearch!==null||!_$(re))&&A(e=>e.shortcutsOpen?{...e,shortcutsOpen:!1}:e)},[ne,re]),(0,R.useEffect)(()=>{de.current=d},[d]),(0,R.useEffect)(()=>{fe.current=f},[f]),(0,R.useEffect)(()=>{P&&(P.setEditable(!n),n&&k(null))},[n,P]),(0,R.useEffect)(()=>{ue(re,Se),t!==void 0&&(Se?j1(t,Y$(re,Se.persistedPrompt)):D.current===0&&j1(t,null))},[re,t,Se]),(0,R.useEffect)(()=>{A(e=>e.isTaskRunning===r&&e.queueSubmissions===i?e:{...e,isTaskRunning:r,queueSubmissions:i})},[r,i]),he.current=e=>{if(n)return;let t=E0(e.getJSON(),ie.current,v,r,i,_2(e)),a=oe.current,o=se.current;oe.current=null,se.current=void 0,A(e=>{let n=o===void 0?N.current:o;N.current=n;let r=e.shortcutsOpen&&_$(t);return{...t,error:e.error,history:e.history,historyCursor:n,killBuffer:e.killBuffer,reverseSearch:e.reverseSearch,shortcutsOpen:r,selectedRemoteImageId:a}})},ge.current=e=>{if(n){k(null);return}let t=R0(e,S);if(!t){k(null);return}if(b.includes(t.trigger)){let e={trigger:t.trigger,query:t.query,selectedIndex:0},n=q1(e,v,y,a);k(t=>n.length===0?null:{...e,selectedIndex:t?.trigger===e.trigger?Math.min(t.selectedIndex,n.length-1):0});return}k(e=>{let n=t.trigger,r={trigger:n,query:t.query,selectedIndex:e?.trigger===n?e.selectedIndex:0},i=q1(r,v,y,a);return{...r,selectedIndex:e?.trigger===n?Math.min(e.selectedIndex,Math.max(i.length-1,0)):0}})};function Ce(e){P?.commands.setContent(e),P&&(he.current(P),ge.current(P))}function we(e){if(n||!P)return;let t=R0(P,S),r=[{type:`text`,text:`${e.trigger}${e.value}`,marks:[{type:`composerSlashCommand`,attrs:{value:e.value,detail:e.detail}}]},{type:`text`,text:` `}];t&&t.trigger===e.trigger?P.chain().focus().deleteRange({from:t.from,to:t.to}).insertContent(r).run():P.chain().focus().insertContent(r).run(),k(null)}function Te({index:e=M.current?.selectedIndex??0}={}){let t=M.current;if(n||!P||!t)return;let r=q1(t,v,y,a),i=r[e]??r[0];if(!i)return;if(!i.atomic){we(i);return}let o=R0(P,S),s=o?.trigger===t.trigger,c=P.chain().focus();s&&o&&c.deleteRange({from:o.from,to:o.to}),c.insertContent([P0(i),{type:`text`,text:` `}]).run(),k(null)}function Ee(){if(n||!P)return;P.commands.focus();let e=b[0];e&&k(t=>t?.trigger===e?null:{trigger:e,query:``,selectedIndex:0})}function De(e){return _$(e)&&e.reverseSearch===null&&M.current===null}function Oe(){n||A(e=>De(e)&&!e.shortcutsOpen?{...e,shortcutsOpen:!0,selectedRemoteImageId:null,error:null}:e)}function ke(){A(e=>e.shortcutsOpen?{...e,shortcutsOpen:!1}:e)}function Ae(){n||A(e=>e.shortcutsOpen?{...e,shortcutsOpen:!1}:De(e)?{...e,shortcutsOpen:!0,selectedRemoteImageId:null,error:null}:e)}function je(e){n||!P||!e||P.chain().focus().insertContent(e).run()}function Me(e){if(H$(e)===null)return A(t=>({...t,error:`Only image, video, or audio files can be attached: ${e.name||`unnamed file`}`,shortcutsOpen:!1})),k(null),null;let t=crypto.randomUUID();return pe.current.set(t,e),t}function Ne(e,t){let n=Me(t);if(n===null)return;let r=Ge(),i=r.remoteImages.length+r.imageAttachments.length+1,a=H$(t)??`image`;e.chain().focus().insertContent([L0(n,W$(a,i),a),{type:`text`,text:` `}]).run()}function Pe(e){if(!(n||!P))for(let t of e)Ne(P,t)}function Fe(e){n||!P||(pe.current.delete(e),Ce(X0(Q0(P.getJSON(),e),ie.current.length)))}function Ie(e){if(n||!P)return;let t=[...ie.current,{id:_1(`remote-image`,e,m.Date.now()),url:e}];ie.current=t,O(t),Ce(X0(P.getJSON(),t.length))}function Le(e){return n||!P?!1:b0(P.view,e,ie.current.length,x[0]??`@`,Me)}function Re(e){if(n)return;let t=ie.current[e]??j.current.remoteImages[e];t&&(oe.current=t.id,A(e=>({...e,selectedRemoteImageId:t.id,shortcutsOpen:!1})))}function ze(){n||(oe.current=null,A(e=>e.selectedRemoteImageId?{...e,selectedRemoteImageId:null,shortcutsOpen:!1}:e))}function Be(e){return j.current.selectedRemoteImageId?e.key===`ArrowLeft`||e.key===`ArrowRight`||e.key===`Escape`||(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`a`?(ze(),k(null),!0):e.key.length===1&&!e.metaKey&&!e.ctrlKey&&!e.altKey?(ze(),!0):!1:!1}function Ve(e){if(n)return e.preventDefault(),!0;if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`a`)return e.preventDefault(),ze(),k(null),P?.commands.selectAll(),!0;let t=Ge(),r=j.current.selectedRemoteImageId;if(!M.current&&e.key===`ArrowUp`){let n=K$({...t,selectedRemoteImageId:r},r);if(n!==null)return e.preventDefault(),Re(Math.max(0,n-1)),!0;if((P&&v2(P)||t.cursor===0)&&t.remoteImages.length>0)return e.preventDefault(),Re(t.remoteImages.length-1),!0}if(!M.current&&r&&e.key===`ArrowDown`){e.preventDefault();let n=K$({...t,selectedRemoteImageId:r},r);return n!==null&&n+1<t.remoteImages.length?Re(n+1):ze(),!0}return!M.current&&r&&(e.key===`Backspace`||e.key===`Delete`)?(e.preventDefault(),He(r),!0):(Be(e),!1)}function He(e){if(n||!P)return;let t=Ge(),r=t.remoteImages.findIndex(t=>t.id===e),i=t.remoteImages.filter(t=>t.id!==e),a=r===-1?null:i[r]??i[r-1]??null;oe.current=a?.id??null,ie.current=i,O(i),Ce(X0(P.getJSON(),i.length)),A(e=>({...e,remoteImages:i,selectedRemoteImageId:a?.id??null,shortcutsOpen:!1}))}function Ue(e){if(n||!P)return;let t=e2(P.getJSON(),q$(e));P.chain().focus().insertContent(I0({kind:`paste`,label:t,detail:`${q$(e)} chars`,content:e})).run()}function We(e,t=e,r){n||P?.chain().focus().insertContent(I0({kind:`rich-link`,label:t,detail:e,href:e,metadata:r})).run()}function Ge(){return P?{...E0(P.getJSON(),ie.current,v,r,i,_2(P)),error:j.current.error,history:j.current.history,historyCursor:N.current??j.current.historyCursor,killBuffer:j.current.killBuffer,reverseSearch:j.current.reverseSearch,shortcutsOpen:j.current.shortcutsOpen,selectedRemoteImageId:j.current.selectedRemoteImageId}:j.current}function Ke(e){let t=de.current?.(e);return t?(A(e=>({...e,error:t,shortcutsOpen:!1})),k(null),!0):!1}function qe(e){let t=Ge(),n=t.text.slice(0,t.cursor);je(n&&!/\s$/.test(n)?` ${e}`:e)}function Je(){ct?.endWithSend()||Ye()}function Ye(){if(n)return;let e=Ge(),r=P?.getJSON()??j0(),i=e.isTaskRunning||e.queueSubmissions,a=i?null:w$(e.text,v,b);if(a){A(e=>({...e,error:`Unrecognized command: /${a}`,shortcutsOpen:!1})),k(null);return}let s=v$(e,v,b),c=s??{mode:`submitted`,prompt:``,persistedPrompt:``,historyPrompt:``,action:`Plain`,command:void 0,args:void 0,items:[],elements:[],payloadElements:[],mentionBindings:[]},l=y$(c,o);if(l){A(e=>({...e,error:l,shortcutsOpen:!1})),k(null);return}let u=new Map,d=[];for(let t of e.imageAttachments){let e=pe.current.get(t.id);if(!e){A(e=>({...e,error:`Attached image is no longer available: ${t.placeholder}`,shortcutsOpen:!1})),k(null);return}u.set(t.id,e),d.push({type:t.media,placeholder:t.placeholder,file:e})}let f=[...c.items.filter(e=>e.type===`remote_image`),...d,...c.items.filter(e=>e.type!==`remote_image`)],p={id:crypto.randomUUID(),at:new Date(m.Date.now()).toLocaleTimeString(),mode:i?`queued`:c.mode,prompt:c.prompt,persistedPrompt:c.persistedPrompt,action:i?y2(c,b):c.action,command:c.command,args:c.args,items:f};if(Ke(p))return;for(let e of u.keys())pe.current.delete(e);let h=Y$(e,c.persistedPrompt),g=fe.current?.(p,{editableSource:h});N2(g)&&(D.current+=1,g.then(()=>{t!==void 0&&j1(t,null)}).catch(e=>{for(let[e,t]of u)pe.current.set(e,t);t!==void 0&&j1(t,h),ee.current&&(Ce(r),P?.commands.focus(`end`),A(t=>({...t,error:e instanceof Error?e.message:`Could not send prompt`})))}).finally(()=>{--D.current}));let _=s?X$(e,c.historyPrompt):e.history;N.current=null,ie.current=[],O([]),k(null),Ce(j0()),A(e=>({...e,text:``,cursor:0,elements:[],mentionBindings:[],imageAttachments:[],remoteImages:[],pendingPastes:[],selectedRemoteImageId:null,error:null,shortcutsOpen:!1,history:_,historyCursor:null}))}function Xe(){if(n)return;let e=j.current.history,t=j.current.killBuffer;N.current=null,le.current=null,pe.current.clear(),ie.current=T.current,O(T.current),k(null),Ce(E.current),P?.commands.focus(`end`),A(n=>({...n,history:e,historyCursor:null,killBuffer:t,reverseSearch:null,selectedRemoteImageId:null,error:null,shortcutsOpen:!1}))}function Ze(e){if(n||!P||j.current.history.length===0)return;let t=j.current,r=N.current??t.historyCursor;if(e>0&&r===0&&ce.current){F(ce.current,null),ce.current=null;return}let i=r===null?e<0?0:t.history.length-1:g1(r+e,t.history.length);r===null&&(ce.current=J$(Ge()));let a=t.history[i];Qe(a,i)}function Qe(e,t){F(Q$({source:e,slashCommands:v,mentionCandidates:y}),t)}function F(e,t){let n=e.remoteImages??[];ie.current=n,j.current={...j.current,historyCursor:t,shortcutsOpen:!1},N.current=t,se.current=t,O(n),Ce(x0({state:e,slashCommands:v,mentionCandidates:y,triggers:S})),P?.commands.focus(`end`),A(e=>({...e,historyCursor:t,shortcutsOpen:!1}))}function $e(){n||(k(null),N.current=null,le.current=Ge(),A(e=>({...e,reverseSearch:``,historyCursor:null,shortcutsOpen:!1})))}function et(e){if(n){e.preventDefault();return}if(e.preventDefault(),e.key===`Escape`){it(null),le.current=null;return}if(e.key===`Enter`){le.current=null,A(e=>({...e,reverseSearch:null,shortcutsOpen:!1}));return}if(e.key===`Backspace`){tt(e=>e.slice(0,-1));return}if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`r`){nt(1);return}if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`s`){nt(-1);return}e.key.length===1&&!e.metaKey&&!e.altKey&&!e.ctrlKey&&tt(t=>`${t}${e.key}`)}function tt(e){if(n)return;let t=j.current,r=e(t.reverseSearch??``),i=f1(t.history,r,null);if(!P||!i){it(r);return}rt(i.entry,i.index,r)}function nt(e){if(n||!P)return;let t=j.current,r=t.reverseSearch??``,i=f1(t.history,r,t.historyCursor,e);i&&rt(i.entry,i.index,r)}function rt(e,t,n){let r=P;if(!r)return;let i=Q$({source:e,slashCommands:v,mentionCandidates:y}),a=i.remoteImages??[];ie.current=a,O(a),Ce(x0({state:i,slashCommands:v,mentionCandidates:y,triggers:S})),r.commands.focus(`end`),A(e=>({...e,historyCursor:t,reverseSearch:n,selectedRemoteImageId:null,shortcutsOpen:!1}))}function it(e){if(n)return;let t=le.current;if(!t||!P){A(t=>({...t,reverseSearch:e,shortcutsOpen:!1}));return}let r={...t,history:j.current.history,killBuffer:j.current.killBuffer,reverseSearch:e,historyCursor:null,selectedRemoteImageId:null,shortcutsOpen:!1};N.current=null,ie.current=r.remoteImages,O(r.remoteImages),Ce(x0({state:r,slashCommands:v,mentionCandidates:y,triggers:S})),P.commands.focus(`end`),A(r)}_e.current=n?e=>(e.preventDefault(),!0):Ve,me.current=Me;function at(e){if(!(e.target instanceof Element)||!e.target.closest(`[data-slot="composer-editor"]`))return;if(n){e.preventDefault();return}if(!P||Ve(e))return;if(j.current.reverseSearch!==null){et(e);return}if(j.current.shortcutsOpen&&e.key===`Escape`){e.preventDefault(),ke();return}if(e.key===`?`&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&De(Ge())){e.preventDefault(),Ae();return}if(i4(e)){e.preventDefault(),P.chain().focus().setHardBreak().run(),N.current=null,k(null);return}if(M.current){if(b2(e)||x2(e)){e.preventDefault(),st(b2(e)?-1:1);return}if(e.key===`Tab`){e.preventDefault(),Te();return}if(e.key===`Enter`&&!e.shiftKey){if(e.preventDefault(),xe.length===0){k(null),Je();return}Te();return}if(e.key===`Escape`){e.preventDefault(),k(null);return}}if(a4(e)){let t=a2(P);t&&(e.preventDefault(),ae.current=t,A(e=>({...e,killBuffer:t.text}))),N.current=null;return}let t=o4(e);if(t!==null){e.preventDefault(),s2(P,t),N.current=null;return}if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`e`){e.preventDefault(),o2(P),N.current=null;return}if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`k`){let t=r2(P);t&&(e.preventDefault(),ae.current=t,A(e=>({...e,killBuffer:t.text})));return}if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`u`){let t=i2(P);t&&(e.preventDefault(),ae.current=t,A(e=>({...e,killBuffer:t.text})));return}if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`y`&&j.current.killBuffer){e.preventDefault(),m2(P,ae.current??j.current.killBuffer);return}if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`r`){e.preventDefault(),$e();return}if((e.key===`Backspace`||e.key===`Delete`)&&c4(P)){e.preventDefault(),N.current=null,k(null);return}if((e.key===`Backspace`||e.key===`Delete`)&&h2(P,e.key)){e.preventDefault(),N.current=null;return}if((e.key===`Backspace`||e.key===`Delete`||e.key.length===1&&!e.metaKey&&!e.ctrlKey&&!e.altKey)&&(N.current=null),e.key===`Enter`&&!e.shiftKey&&!e.altKey){e.preventDefault(),Je();return}let r=s4(e);if(r!==null&&!M.current){let t=Ge();if(e.key===`ArrowUp`&&(v2(P)||t.cursor===0)&&t.remoteImages.length>0){e.preventDefault(),Re(t.remoteImages.length-1);return}p1(t.text,t.cursor,r)&&(e.preventDefault(),Ze(r))}}function ot(e){if(n){e.preventDefault();return}e.target instanceof Element&&e.target.closest(`[data-slot="composer-editor"]`)&&ze()}function st(e){n||k(t=>{if(!t)return t;let n=q1(t,v,y,a).length;return n===0?t:{...t,selectedIndex:g1(t.selectedIndex+e,n)}})}let ct=f0({dictation:u,disabled:n,insertTranscript:qe,submitDraft:Ye});return(0,z.jsx)(KQ,{value:{state:re,disabled:n,commandTriggers:b,activePopup:ne,suggestions:xe,attachedImages:pe.current,setEditorPlaceholder:ye,actions:{acceptSuggestion:Te,toggleSlashMenu:Ee,insertText:je,attachImageFiles:Pe,removeImageAttachment:Fe,addRemoteImage:Ie,handleDrop:Le,insertPaste:Ue,insertRichLink:We,openShortcuts:Oe,closeShortcuts:ke,toggleShortcuts:Ae,submit:Je,reset:Xe},meta:{editor:P}},children:(0,z.jsx)(Y1,{value:ct?.api??null,children:(0,z.jsx)(`section`,{"data-slot":`composer`,className:I(`border-border bg-card relative border font-[inherit]`,c),children:(0,z.jsxs)(`div`,{onKeyDownCapture:at,onMouseDownCapture:ot,children:[l,h.hasLayoutChildren?null:(0,z.jsx)(F2,{})]})})})})}function F2(){let e=(0,G.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,z.jsx)(H2,{}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,z.jsxs)(z.Fragment,{children:[t,(0,z.jsxs)(I2,{children:[(0,z.jsx)(R2,{}),(0,z.jsx)(YQ,{}),(0,z.jsx)(B2,{}),(0,z.jsx)(V2,{})]}),(0,z.jsx)(K2,{}),(0,z.jsx)(Y2,{})]}),e[1]=n):n=e[1],n}function I2(e){let t=(0,G.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=I(`space-y-2`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,z.jsx)(`div`,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function L2(e){let t=(0,G.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=I(`flex flex-wrap items-center gap-1.5`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,z.jsx)(`div`,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function R2(e){let t=(0,G.c)(14),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let{state:i}=qQ(`Composer.RemoteImages`);if(i.remoteImages.length===0)return null;let a;t[3]===n?a=t[4]:(a=I(`border-border space-y-1 border-b pb-2 text-sm`,n),t[3]=n,t[4]=a);let o;if(t[5]!==i.remoteImages||t[6]!==i.selectedRemoteImageId){let e;t[8]===i.selectedRemoteImageId?e=t[9]:(e=(e,t)=>(0,z.jsxs)(`div`,{className:I(`flex h-6 items-center gap-2 rounded-sm px-2`,i.selectedRemoteImageId===e.id?`bg-primary text-primary-foreground`:`text-sky-500`),children:[(0,z.jsxs)(`span`,{className:`shrink-0`,children:[`[Image #`,t+1,`]`]}),(0,z.jsx)(`span`,{className:`truncate text-xs opacity-70`,children:e.url})]},e.id),t[8]=i.selectedRemoteImageId,t[9]=e),o=i.remoteImages.map(e),t[5]=i.remoteImages,t[6]=i.selectedRemoteImageId,t[7]=o}else o=t[7];let s;return t[10]!==r||t[11]!==a||t[12]!==o?(s=(0,z.jsx)(`div`,{className:a,...r,children:o}),t[10]=r,t[11]=a,t[12]=o,t[13]=s):s=t[13],s}function z2(e){e.dataTransfer.types.includes(`Files`)&&e.preventDefault()}function B2(e){let t=(0,G.c)(29),n,r,i,a,o,s;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6]):({className:n,onDragEnter:r,onDragOver:i,onDrop:a,placeholder:s,...o}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s);let c=s===void 0?`Type a message or / for commands`:s,{disabled:l,meta:u,actions:d,setEditorPlaceholder:f}=qQ(`Composer.Editor`),p,m;t[7]!==c||t[8]!==f?(p=()=>{f(c)},m=[c,f],t[7]=c,t[8]=f,t[9]=p,t[10]=m):(p=t[9],m=t[10]),(0,R.useLayoutEffect)(p,m);let h=l?``:void 0,g;t[11]===r?g=t[12]:(g=e=>{r?.(e),z2(e)},t[11]=r,t[12]=g);let _;t[13]===i?_=t[14]:(_=e=>{i?.(e),z2(e)},t[13]=i,t[14]=_);let v;t[15]!==d||t[16]!==a?(v=e=>{a?.(e),!e.defaultPrevented&&d.handleDrop(e.dataTransfer)&&e.preventDefault()},t[15]=d,t[16]=a,t[17]=v):v=t[17];let y;t[18]===u.editor?y=t[19]:(y=(0,z.jsx)(oq,{editor:u.editor}),t[18]=u.editor,t[19]=y);let b;return t[20]!==n||t[21]!==l||t[22]!==o||t[23]!==h||t[24]!==g||t[25]!==_||t[26]!==v||t[27]!==y?(b=(0,z.jsx)(`div`,{"data-slot":`composer-frame`,className:n,"aria-disabled":l,"data-disabled":h,onDragEnter:g,onDragOver:_,onDrop:v,...o,children:y}),t[20]=n,t[21]=l,t[22]=o,t[23]=h,t[24]=g,t[25]=_,t[26]=v,t[27]=y,t[28]=b):b=t[28],b}function V2(e){let t=(0,G.c)(9),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let{state:i}=qQ(`Composer.Error`);if(!i.error)return null;let a;t[3]===n?a=t[4]:(a=I(`border-primary/30 bg-primary/10 text-primary rounded-md border px-3 py-2 text-xs`,n),t[3]=n,t[4]=a);let o;return t[5]!==r||t[6]!==i.error||t[7]!==a?(o=(0,z.jsx)(`div`,{role:`alert`,className:a,...r,children:i.error}),t[5]=r,t[6]=i.error,t[7]=a,t[8]=o):o=t[8],o}function H2(e){let t=(0,G.c)(25),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let{activePopup:i,suggestions:a,actions:o}=qQ(`Composer.Popup`),{acceptSuggestion:s}=o;if(!i)return null;let c;t[3]===a?c=t[4]:(c=a.some(U2),t[3]=a,t[4]=c);let l=c,u;t[5]===n?u=t[6]:(u=I(`border-border bg-popover absolute inset-x-0 bottom-[calc(100%+0.5rem)] z-10 rounded-xl border shadow-lg`,n),t[5]=n,t[6]=u);let d;if(t[7]!==s||t[8]!==i||t[9]!==a||t[10]!==l){let e;t[12]!==s||t[13]!==i||t[14]!==l?(e=(e,t)=>(0,z.jsx)(W2,{selected:t===i.selectedIndex,icon:l?e.icon:null,token:h$(e),takesArgs:e.supportsArgs===!0,description:e.detail,onMouseDown:()=>s({index:t})},`item:${e.id}`),t[12]=s,t[13]=i,t[14]=l,t[15]=e):e=t[15],d=a.map(e),t[7]=s,t[8]=i,t[9]=a,t[10]=l,t[11]=d}else d=t[11];let f;t[16]===a.length?f=t[17]:(f=a.length===0?(0,z.jsx)(`div`,{className:`text-muted-foreground px-2 py-1 text-[13px] leading-4`,children:`no matches`}):null,t[16]=a.length,t[17]=f);let p;t[18]!==d||t[19]!==f?(p=(0,z.jsxs)(`div`,{className:`flex max-h-72 flex-col gap-1 overflow-y-auto p-1`,role:`listbox`,"aria-label":`Suggestions`,children:[d,f]}),t[18]=d,t[19]=f,t[20]=p):p=t[20];let m;return t[21]!==r||t[22]!==u||t[23]!==p?(m=(0,z.jsx)(`div`,{className:u,...r,children:p}),t[21]=r,t[22]=u,t[23]=p,t[24]=m):m=t[24],m}function U2(e){return e.icon}function W2(e){let t=(0,G.c)(23),{selected:n,icon:r,token:i,takesArgs:a,description:o,onMouseDown:s}=e,c=(0,R.useRef)(null),l,u;t[0]===n?(l=t[1],u=t[2]):(l=()=>{n&&c.current?.scrollIntoView({block:`nearest`})},u=[n],t[0]=n,t[1]=l,t[2]=u),(0,R.useEffect)(l,u);let d=n?`bg-accent text-foreground`:`text-foreground/80 hover:bg-accent/60`,f;t[3]===d?f=t[4]:(f=I(`flex w-full items-center gap-2 rounded-md px-2 py-1 text-start text-[13px] leading-4 [&_svg]:size-4 [&_svg]:shrink-0`,d),t[3]=d,t[4]=f);let p;t[5]===s?p=t[6]:(p=e=>{e.preventDefault(),s()},t[5]=s,t[6]=p);let m;t[7]===r?m=t[8]:(m=r===null?null:(0,z.jsx)(`span`,{className:`flex size-4 shrink-0 items-center justify-center`,children:r}),t[7]=r,t[8]=m);let h;t[9]===i?h=t[10]:(h=(0,z.jsx)(`span`,{className:`truncate`,children:i}),t[9]=i,t[10]=h);let g;t[11]===a?g=t[12]:(g=a?(0,z.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:`args`}):null,t[11]=a,t[12]=g);let _;t[13]===o?_=t[14]:(_=(0,z.jsx)(`span`,{className:`text-muted-foreground truncate`,children:o}),t[13]=o,t[14]=_);let v;return t[15]!==n||t[16]!==f||t[17]!==p||t[18]!==m||t[19]!==h||t[20]!==g||t[21]!==_?(v=(0,z.jsxs)(`button`,{ref:c,type:`button`,role:`option`,"aria-selected":n,className:f,onMouseDown:p,children:[m,h,g,_]}),t[15]=n,t[16]=f,t[17]=p,t[18]=m,t[19]=h,t[20]=g,t[21]=_,t[22]=v):v=t[22],v}var G2=[{title:`Send`,items:[[`Enter`,`send or queue`],[`Shift Enter`,`newline`],[`Alt Enter`,`newline`]]},{title:`Edit`,items:[[`Ctrl K`,`kill to end`],[`Ctrl U`,`kill to start`],[`Ctrl W`,`kill word`],[`Ctrl Y`,`yank`]]},{title:`Navigate`,items:[[`Ctrl P/N`,`history`],[`Ctrl R`,`reverse search`],[`Ctrl E`,`line end`],[`Alt B/F`,`word move`]]}];function K2(e){let t=(0,G.c)(13),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let{state:i,actions:a}=qQ(`Composer.Shortcuts`),{closeShortcuts:o}=a;if(!i.shortcutsOpen||!_$(i))return null;let s;t[3]===n?s=t[4]:(s=I(`border-border bg-popover border-t px-3 py-3 text-xs`,n),t[3]=n,t[4]=s);let c;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,z.jsx)(`div`,{className:`text-foreground font-medium`,children:`Keyboard shortcuts`}),t[5]=c):c=t[5];let l;t[6]===o?l=t[7]:(l=(0,z.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[c,(0,z.jsx)(`button`,{type:`button`,className:`text-muted-foreground hover:bg-muted hover:text-foreground rounded-sm px-2 py-1`,onClick:o,children:`close`})]}),t[6]=o,t[7]=l);let u;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,z.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:G2.map(q2)}),t[8]=u):u=t[8];let d;return t[9]!==r||t[10]!==s||t[11]!==l?(d=(0,z.jsxs)(`div`,{role:`dialog`,"aria-label":`Keyboard shortcuts`,className:s,...r,children:[l,u]}),t[9]=r,t[10]=s,t[11]=l,t[12]=d):d=t[12],d}function q2(e){return(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(`div`,{className:`text-muted-foreground text-[11px]`,children:e.title}),(0,z.jsx)(`div`,{className:`space-y-1`,children:e.items.map(J2)})]},e.title)}function J2(e){let[t,n]=e;return(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,z.jsx)(`kbd`,{className:`border-border bg-muted text-foreground rounded border px-1.5 py-0.5 font-[inherit]`,children:t}),(0,z.jsx)(`span`,{className:`text-muted-foreground text-right`,children:n})]},`${t}-${n}`)}function Y2(e){let t=(0,G.c)(29),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let{activePopup:i,state:a}=qQ(`Composer.Footer`);if(a.reverseSearch!==null){let e;t[3]===n?e=t[4]:(e=I(`border-border text-muted-foreground flex items-center gap-2 border-t px-3 py-2 text-[11px]`,n),t[3]=n,t[4]=e);let i,o;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,z.jsx)(`kbd`,{className:`border-border bg-muted text-foreground rounded border px-1.5 py-0.5 font-[inherit]`,children:`Ctrl R`}),o=(0,z.jsx)(`span`,{children:`reverse-i-search:`}),t[5]=i,t[6]=o):(i=t[5],o=t[6]);let s=a.reverseSearch||`_`,c;t[7]===s?c=t[8]:(c=(0,z.jsx)(`span`,{className:`text-foreground`,children:s}),t[7]=s,t[8]=c);let l,u,d,f;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,z.jsx)(`span`,{children:`Ctrl R previous`}),u=(0,z.jsx)(`span`,{children:`Ctrl S next`}),d=(0,z.jsx)(`span`,{children:`Enter accept`}),f=(0,z.jsx)(`span`,{children:`Esc cancel`}),t[9]=l,t[10]=u,t[11]=d,t[12]=f):(l=t[9],u=t[10],d=t[11],f=t[12]);let p;return t[13]!==r||t[14]!==e||t[15]!==c?(p=(0,z.jsxs)(`div`,{className:e,...r,children:[i,o,c,l,u,d,f]}),t[13]=r,t[14]=e,t[15]=c,t[16]=p):p=t[16],p}let o;t[17]!==i||t[18]!==a.isTaskRunning||t[19]!==a.queueSubmissions?(o=i?[[`Enter`,`insert`],[`Tab`,`insert`],[`Esc`,`dismiss`]]:[[`Enter`,a.isTaskRunning||a.queueSubmissions?`queue`:`send`],[`Shift Enter`,`newline`],[`Alt Enter`,`newline`],[`Ctrl J/M`,`newline`],[`Ctrl P/N`,`history`],[`Ctrl E`,`line end`],[`Ctrl K`,`kill`],[`Ctrl U`,`kill back`],[`Ctrl W`,`word kill`],[`Alt B/F`,`word move`],[`Ctrl Y`,`yank`]],t[17]=i,t[18]=a.isTaskRunning,t[19]=a.queueSubmissions,t[20]=o):o=t[20];let s=o,c;t[21]===n?c=t[22]:(c=I(`border-border text-muted-foreground flex flex-wrap items-center gap-x-4 gap-y-1 border-t px-3 py-2 text-[11px]`,n),t[21]=n,t[22]=c);let l;t[23]===s?l=t[24]:(l=s.map(X2),t[23]=s,t[24]=l);let u;return t[25]!==r||t[26]!==c||t[27]!==l?(u=(0,z.jsx)(`div`,{className:c,...r,children:l}),t[25]=r,t[26]=c,t[27]=l,t[28]=u):u=t[28],u}function X2(e){let[t,n]=e;return(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,z.jsx)(`kbd`,{className:`border-border bg-muted text-foreground rounded border px-1.5 py-0.5 font-[inherit]`,children:t}),n]},`${t}-${n}`)}function Z2(e){let t=(0,G.c)(19),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({accept:i,multiple:a,disabled:n,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=i===void 0?`image/*,video/*,audio/*`:i,s=a===void 0||a,{actions:c,disabled:l}=qQ(`Composer.AttachFiles`),u=(0,R.useRef)(null),d;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>u.current?.click(),t[5]=d):d=t[5];let f;t[6]!==n||t[7]!==r?(f=(0,z.jsx)(r4,{action:d,disabled:n,...r}),t[6]=n,t[7]=r,t[8]=f):f=t[8];let p=l||n,m;t[9]===c?m=t[10]:(m=e=>{let t=e.currentTarget;t.files&&c.attachImageFiles(t.files),t.value=``},t[9]=c,t[10]=m);let h;t[11]!==o||t[12]!==s||t[13]!==p||t[14]!==m?(h=(0,z.jsx)(`input`,{ref:u,type:`file`,accept:o,multiple:s,"aria-label":`Attach media files`,hidden:!0,disabled:p,onChange:m}),t[11]=o,t[12]=s,t[13]=p,t[14]=m,t[15]=h):h=t[15];let g;return t[16]!==f||t[17]!==h?(g=(0,z.jsxs)(z.Fragment,{children:[f,h]}),t[16]=f,t[17]=h,t[18]=g):g=t[18],g}function Q2(e){let t=(0,G.c)(9),n,r;t[0]===e?(n=t[1],r=t[2]):({url:r,...n}=e,t[0]=e,t[1]=n,t[2]=r);let{actions:i}=qQ(`Composer.AddRemoteImage`),a;t[3]!==i||t[4]!==r?(a=()=>i.addRemoteImage(r),t[3]=i,t[4]=r,t[5]=a):a=t[5];let o;return t[6]!==n||t[7]!==a?(o=(0,z.jsx)(r4,{action:a,...n}),t[6]=n,t[7]=a,t[8]=o):o=t[8],o}function $2(e){let t=(0,G.c)(9),n,r;t[0]===e?(n=t[1],r=t[2]):({content:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let{actions:i}=qQ(`Composer.InsertPaste`),a;t[3]!==i||t[4]!==n?(a=()=>i.insertPaste(n),t[3]=i,t[4]=n,t[5]=a):a=t[5];let o;return t[6]!==r||t[7]!==a?(o=(0,z.jsx)(r4,{action:a,...r}),t[6]=r,t[7]=a,t[8]=o):o=t[8],o}function e4(e){let t=(0,G.c)(13),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({href:n,label:r,metadata:i,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let{actions:o}=qQ(`Composer.InsertRichLink`),s;t[5]!==o||t[6]!==n||t[7]!==r||t[8]!==i?(s=()=>o.insertRichLink(n,r,i),t[5]=o,t[6]=n,t[7]=r,t[8]=i,t[9]=s):s=t[9];let c;return t[10]!==a||t[11]!==s?(c=(0,z.jsx)(r4,{action:s,...a}),t[10]=a,t[11]=s,t[12]=c):c=t[12],c}function t4(e){let t=(0,G.c)(3),{actions:n}=qQ(`Composer.Submit`),r;return t[0]!==n.submit||t[1]!==e?(r=(0,z.jsx)(r4,{action:n.submit,...e}),t[0]=n.submit,t[1]=e,t[2]=r):r=t[2],r}function n4(e){let t=(0,G.c)(3),{actions:n}=qQ(`Composer.Reset`),r;return t[0]!==n.reset||t[1]!==e?(r=(0,z.jsx)(r4,{action:n.reset,...e}),t[0]=n.reset,t[1]=e,t[2]=r):r=t[2],r}function r4(e){let t=(0,G.c)(12),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({action:n,onClick:i,disabled:r,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let{disabled:o}=qQ(`Composer.ActionTrigger`),s=o||r,c;t[5]!==n||t[6]!==i?(c=e=>{i?.(e),e.defaultPrevented||n()},t[5]=n,t[6]=i,t[7]=c):c=t[7];let l;return t[8]!==a||t[9]!==s||t[10]!==c?(l=(0,z.jsx)(y,{...a,disabled:s,onClick:c}),t[8]=a,t[9]=s,t[10]=c,t[11]=l):l=t[11],l}function i4(e){if(e.metaKey)return!1;if(e.key===`Enter`)return e.altKey&&!e.ctrlKey;let t=e.key.toLowerCase();return e.ctrlKey&&!e.altKey&&(t===`j`||t===`m`)}function a4(e){if(e.metaKey)return!1;if(e.key===`Backspace`)return e.ctrlKey||e.altKey;let t=e.key.toLowerCase();return e.ctrlKey&&!e.altKey&&t===`w`||e.ctrlKey&&e.altKey&&t===`h`}function o4(e){if(e.metaKey||e.shiftKey)return null;if(e.key===`ArrowLeft`&&(e.altKey||e.ctrlKey))return-1;if(e.key===`ArrowRight`&&(e.altKey||e.ctrlKey))return 1;if(!e.altKey||e.ctrlKey)return null;let t=e.key.toLowerCase();return t===`b`?-1:t===`f`?1:null}function s4(e){if(e.key===`ArrowUp`)return-1;if(e.key===`ArrowDown`)return 1;if(e.metaKey||e.altKey||e.shiftKey||!e.ctrlKey)return null;let t=e.key.toLowerCase();return t===`p`?-1:t===`n`?1:null}function c4(e){let{doc:t,selection:n}=e.state;return n.empty||n.from>1||n.to<t.content.size-1?!1:(e.commands.setContent(j0(),{emitUpdate:!0}),e.commands.focus(`start`),e.commands.setTextSelection(1),!0)}var l4={Root:M2,Trigger:R1,Command:z1,Mention:B1,Content:I2,Toolbar:L2,RemoteImages:R2,Attachments:YQ,Editor:B2,Error:V2,Popup:H2,Shortcuts:K2,Footer:Y2,AttachFiles:Z2,AddRemoteImage:Q2,InsertPaste:$2,InsertRichLink:e4,Dictate:e0,CancelDictation:t0,Submit:t4,Reset:n4};(0,R.createContext)(null);function u4(e,t){if(!t||t.isCollapsed||t.rangeCount===0)return null;let n=t.getRangeAt(0);if(!e.contains(n.commonAncestorContainer))return null;let r=n.cloneContents();for(let e of r.querySelectorAll(`[data-persisted-source]`)){let t=e.getAttribute(`data-persisted-source`);t!==null&&e.replaceWith(t)}return r.textContent??``}function d4(e){let t=(0,G.c)(6),{text:n}=e,r,i;if(t[0]!==n){let e=sN(n);r=m4,i=e.map(f4),t[0]=n,t[1]=r,t[2]=i}else r=t[1],i=t[2];let a;return t[3]!==r||t[4]!==i?(a=(0,z.jsx)(`span`,{onCopy:r,children:i}),t[3]=r,t[4]=i,t[5]=a):a=t[5],a}function f4(e){switch(e.kind){case`text`:return e.value;case`inline-code`:return(0,z.jsx)(`code`,{"data-persisted-source":e.source,className:`bg-muted rounded px-1 py-0.5 font-mono text-[0.9em]`,children:e.value},e.start);case`code-block`:return(0,z.jsx)(`span`,{"data-persisted-source":e.source,className:`bg-muted my-2 block overflow-x-auto rounded-md px-3 py-2`,children:(0,z.jsx)(`code`,{className:`font-mono text-[0.9em]`,children:e.value})},e.start);case`skill-link`:return(0,z.jsx)(p4,{name:e.name,source:e.source,skillId:e.skillId,title:e.href},e.start);case`standalone-skill`:return(0,z.jsx)(p4,{name:e.name,source:e.source},e.start);case`mention`:return(0,z.jsx)(`span`,{"data-token":`mention`,"data-persisted-source":e.source,className:`bg-foreground/10 rounded-sm px-0.5 font-medium`,children:e.label},e.start);case`link`:return/^(?:https?:|mailto:)/.test(e.href)?(0,z.jsx)(`a`,{href:e.href,"data-persisted-source":e.source,className:`text-primary underline underline-offset-2`,target:`_blank`,rel:`noreferrer`,children:e.label},e.start):e.source}}function p4(e){let t=(0,G.c)(9),{name:n,source:r,skillId:i,title:a}=e,o=i?void 0:n,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,z.jsx)(_i,{"aria-hidden":`true`,className:`size-3.5 self-center`}),t[0]=s):s=t[0];let c;t[1]===n?c=t[2]:(c=(0,z.jsx)(`span`,{children:n}),t[1]=n,t[2]=c);let l;return t[3]!==i||t[4]!==r||t[5]!==o||t[6]!==c||t[7]!==a?(l=(0,z.jsxs)(`span`,{"data-skill-id":i,"data-skill-name":o,"data-persisted-source":r,title:a,className:`text-primary inline-flex items-baseline gap-1`,children:[s,c]}),t[3]=i,t[4]=r,t[5]=o,t[6]=c,t[7]=a,t[8]=l):l=t[8],l}function m4(e){let t=u4(e.currentTarget,window.getSelection());t!==null&&(e.clipboardData.setData(`text/plain`,t),e.preventDefault())}var h4=typeof global==`object`&&global&&global.Object===Object&&global,g4=typeof self==`object`&&self&&self.Object===Object&&self,_4=h4||g4||Function(`return this`)(),v4=_4.Symbol,y4=Object.prototype,b4=y4.hasOwnProperty,x4=y4.toString,S4=v4?v4.toStringTag:void 0;function C4(e){var t=b4.call(e,S4),n=e[S4];try{e[S4]=void 0;var r=!0}catch{}var i=x4.call(e);return r&&(t?e[S4]=n:delete e[S4]),i}var w4=Object.prototype.toString;function T4(e){return w4.call(e)}var E4=`[object Null]`,D4=`[object Undefined]`,O4=v4?v4.toStringTag:void 0;function k4(e){return e==null?e===void 0?D4:E4:O4&&O4 in Object(e)?C4(e):T4(e)}function A4(e){return typeof e==`object`&&!!e}var j4=`[object Symbol]`;function M4(e){return typeof e==`symbol`||A4(e)&&k4(e)==j4}function N4(e,t){for(var n=-1,r=e==null?0:e.length,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i}var P4=Array.isArray,F4=1/0,I4=v4?v4.prototype:void 0,L4=I4?I4.toString:void 0;function R4(e){if(typeof e==`string`)return e;if(P4(e))return N4(e,R4)+``;if(M4(e))return L4?L4.call(e):``;var t=e+``;return t==`0`&&1/e==-F4?`-0`:t}function z4(e){var t=typeof e;return e!=null&&(t==`object`||t==`function`)}var B4=`[object AsyncFunction]`,V4=`[object Function]`,H4=`[object GeneratorFunction]`,U4=`[object Proxy]`;function W4(e){if(!z4(e))return!1;var t=k4(e);return t==V4||t==H4||t==B4||t==U4}var G4=_4[`__core-js_shared__`],K4=function(){var e=/[^.]+$/.exec(G4&&G4.keys&&G4.keys.IE_PROTO||``);return e?`Symbol(src)_1.`+e:``}();function q4(e){return!!K4&&K4 in e}var J4=Function.prototype.toString;function Y4(e){if(e!=null){try{return J4.call(e)}catch{}try{return e+``}catch{}}return``}var X4=/[\\^$.*+?()[\]{}|]/g,Z4=/^\[object .+?Constructor\]$/,Q4=Function.prototype,$4=Object.prototype,e3=Q4.toString,t3=$4.hasOwnProperty,n3=RegExp(`^`+e3.call(t3).replace(X4,`\\$&`).replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,`$1.*?`)+`$`);function r3(e){return!z4(e)||q4(e)?!1:(W4(e)?n3:Z4).test(Y4(e))}function i3(e,t){return e?.[t]}function a3(e,t){var n=i3(e,t);return r3(n)?n:void 0}function o3(e,t){return e===t||e!==e&&t!==t}var s3=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,c3=/^\w*$/;function l3(e,t){if(P4(e))return!1;var n=typeof e;return n==`number`||n==`symbol`||n==`boolean`||e==null||M4(e)?!0:c3.test(e)||!s3.test(e)||t!=null&&e in Object(t)}var u3=a3(Object,`create`);function d3(){this.__data__=u3?u3(null):{},this.size=0}function f3(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=+!!t,t}var p3=`__lodash_hash_undefined__`,m3=Object.prototype.hasOwnProperty;function h3(e){var t=this.__data__;if(u3){var n=t[e];return n===p3?void 0:n}return m3.call(t,e)?t[e]:void 0}var g3=Object.prototype.hasOwnProperty;function _3(e){var t=this.__data__;return u3?t[e]!==void 0:g3.call(t,e)}var v3=`__lodash_hash_undefined__`;function y3(e,t){var n=this.__data__;return this.size+=+!this.has(e),n[e]=u3&&t===void 0?v3:t,this}function b3(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}b3.prototype.clear=d3,b3.prototype.delete=f3,b3.prototype.get=h3,b3.prototype.has=_3,b3.prototype.set=y3;function x3(){this.__data__=[],this.size=0}function S3(e,t){for(var n=e.length;n--;)if(o3(e[n][0],t))return n;return-1}var C3=Array.prototype.splice;function w3(e){var t=this.__data__,n=S3(t,e);return n<0?!1:(n==t.length-1?t.pop():C3.call(t,n,1),--this.size,!0)}function T3(e){var t=this.__data__,n=S3(t,e);return n<0?void 0:t[n][1]}function E3(e){return S3(this.__data__,e)>-1}function D3(e,t){var n=this.__data__,r=S3(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}function O3(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}O3.prototype.clear=x3,O3.prototype.delete=w3,O3.prototype.get=T3,O3.prototype.has=E3,O3.prototype.set=D3;var k3=a3(_4,`Map`);function A3(){this.size=0,this.__data__={hash:new b3,map:new(k3||O3),string:new b3}}function j3(e){var t=typeof e;return t==`string`||t==`number`||t==`symbol`||t==`boolean`?e!==`__proto__`:e===null}function M3(e,t){var n=e.__data__;return j3(t)?n[typeof t==`string`?`string`:`hash`]:n.map}function N3(e){var t=M3(this,e).delete(e);return this.size-=+!!t,t}function P3(e){return M3(this,e).get(e)}function F3(e){return M3(this,e).has(e)}function I3(e,t){var n=M3(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}function L3(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}L3.prototype.clear=A3,L3.prototype.delete=N3,L3.prototype.get=P3,L3.prototype.has=F3,L3.prototype.set=I3;var R3=`Expected a function`;function z3(e,t){if(typeof e!=`function`||t!=null&&typeof t!=`function`)throw TypeError(R3);var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],a=n.cache;if(a.has(i))return a.get(i);var o=e.apply(this,r);return n.cache=a.set(i,o)||a,o};return n.cache=new(z3.Cache||L3),n}z3.Cache=L3;var B3=500;function V3(e){var t=z3(e,function(e){return n.size===B3&&n.clear(),e}),n=t.cache;return t}var H3=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,U3=/\\(\\)?/g,W3=V3(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(``),e.replace(H3,function(e,n,r,i){t.push(r?i.replace(U3,`$1`):n||e)}),t});function G3(e){return e==null?``:R4(e)}function K3(e,t){return P4(e)?e:l3(e,t)?[e]:W3(G3(e))}var q3=1/0;function J3(e){if(typeof e==`string`||M4(e))return e;var t=e+``;return t==`0`&&1/e==-q3?`-0`:t}function Y3(e,t){t=K3(t,e);for(var n=0,r=t.length;e!=null&&n<r;)e=e[J3(t[n++])];return n&&n==r?e:void 0}function X3(e,t,n){var r=e==null?void 0:Y3(e,t);return r===void 0?n:r}function Z3(e){if(!e)return{};let t={...e};return delete t.whenNullish,delete t.locale,t}function Q3(e,t){return e==null||Number.isNaN(e)?t?.whenNullish??`—`:new Intl.NumberFormat(t?.locale??`en-US`,Z3(t)).format(e)}var $3=Q3;function e6(e,t){return Q3(e,{notation:`compact`,maximumFractionDigits:1,...t})}var t6=`pending-chat-prefill`;function n6(){try{let e=sessionStorage.getItem(t6);return e?JSON.parse(e):null}catch{return sessionStorage.removeItem(t6),null}}function r6(e){sessionStorage.setItem(t6,JSON.stringify(e))}function i6(){sessionStorage.removeItem(t6)}function a6(e){let t=qh(e.metadata)?e.metadata.persistedPrompt:void 0;if(typeof t!=`string`)throw Error(`Message ${e.id} has no persistedPrompt: send it with useAgent().submit.`);return t}var o6=class{chat;uploadFile;submissions=new ry;onResetChat;constructor(e){this.chat=e.chat,this.uploadFile=e.uploadFile,this.onResetChat=e.onResetChat}bind(e){this.chat=e}initialize(e){let t=new AbortController;return queueMicrotask(()=>{t.signal.aborted||this.consumePrefill(e)}),()=>t.abort()}submit(e){this.chat.clearError();let{files:t=[],...n}=e,r=this.chat.id;return this.submissions.run(async()=>{if(t.length===0){this.assertCurrentChat(r),this.send(n);return}let e=await this.uploadFiles(r,t);this.assertCurrentChat(r),this.send({...n,metadata:{...n.metadata,uploads:e}})})}async uploadFiles(e,t){return Promise.all(t.map(t=>this.uploadFile(e,t)))}assertCurrentChat(e){if(this.chat.id!==e)throw Error(`The chat changed before the submission was sent.`)}send({prompt:e,persistedPrompt:t,metadata:n}){this.chat.sendMessage({role:`user`,parts:[{type:`text`,text:e}],metadata:{...n,persistedPrompt:t}})}clearChat(){for(let{id:e}of this.chat.experimental_queuedMessages)this.chat.experimental_removeQueuedMessage(e);this.chat.setMessages([])}setChat(e){this.chat.setMessages(e)}stop(){this.chat.stop()}resetChat(e){let t=crypto.randomUUID();e&&r6({prompt:e,targetChatId:t}),this.onResetChat(t)}consumePrefill(e){let t=n6();!t||t.targetChatId!==e||(i6(),this.submit({prompt:t.prompt,persistedPrompt:t.prompt}))}getTriggeringUserMessage(e){let{messages:t}=this.chat,n=t.findIndex(t=>t.role===`assistant`&&t.parts.some(t=>`toolCallId`in t&&t.toolCallId===e));if(n<=0)return null;let r=t[n-1];return r?.role===`user`?r:null}getLastUserMessageId(){let{messages:e}=this.chat;for(let t=e.length-1;t>=0;t--)if(e[t].role===`user`)return e[t].id;return null}getLastAssistantMessage(){let{messages:e}=this.chat;for(let t=e.length-1;t>=0;t--)if(e[t].role===`assistant`)return e[t];return null}get hasSubmitted(){return this.chat.messages.length>0}};async function s6(e,t,n){let r=t?.[n.toolName];n.toolName.startsWith(`render`)&&r?.static===!1&&r.requiresUserInput!==!0&&await e.addToolOutput({toolCallId:n.toolCallId,tool:n.toolName,output:`rendered`,state:`output-available`})}function c6(e){let t=Vy({id:e.chatId,messages:e.initialMessages,transport:e.transport,throttle:50,experimental_queue:!0,resume:e.resume,onData:e.onData,onFinish:e.onFinish,sendAutomaticallyWhen:l6,onToolCall(n){let{toolCall:r}=n;s6(t,e.registry,r)}});return t}function l6(e){return Ay(e)||ky(e)}function u6(e){let t=(0,G.c)(2),n;return t[0]===e?n=t[1]:(n=(0,z.jsx)(d6,{...e}),t[0]=e,t[1]=n),n}function d6(e){let t=(0,G.c)(13),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n={initial:`smooth`},t[0]=n):n=t[0];let{scrollRef:r,contentRef:i}=jj(n),{hasSubmitted:a}=T6(),o;t[1]===e.className?o=t[2]:(o=I(`@container mx-auto h-full w-full overflow-y-auto`,e.className),t[1]=e.className,t[2]=o);let s=a?`min-h-full`:`h-full justify-center`,c;t[3]===s?c=t[4]:(c=I(`relative mx-auto flex w-full flex-col`,s),t[3]=s,t[4]=c);let l;t[5]!==i||t[6]!==e.children||t[7]!==c?(l=(0,z.jsx)(`div`,{ref:i,"data-slot":`content`,className:c,children:e.children}),t[5]=i,t[6]=e.children,t[7]=c,t[8]=l):l=t[8];let u;return t[9]!==r||t[10]!==o||t[11]!==l?(u=(0,z.jsx)(`div`,{id:`agent`,"data-slot":`agent`,className:o,ref:r,children:l}),t[9]=r,t[10]=o,t[11]=l,t[12]=u):u=t[12],u}function f6(e){let t=(0,G.c)(12),{hasSubmitted:n}=T6(),r;t[0]!==n||t[1]!==e.className?(r=I(n?I(`bg-background sticky top-0 z-10 shrink-0 space-y-1 backdrop-blur-md`,e.className):`relative flex justify-center py-4`),t[0]=n,t[1]=e.className,t[2]=r):r=t[2];let i;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(i={layout:{type:`tween`,ease:[.4,0,.2,1],duration:.4}},t[3]=i):i=t[3];let a=n?`text-left`:`space-y-3 text-center`,o;t[4]===a?o=t[5]:(o=I(a),t[4]=a,t[5]=o);let s;t[6]!==e.children||t[7]!==o?(s=(0,z.jsx)(`div`,{className:o,children:e.children}),t[6]=e.children,t[7]=o,t[8]=s):s=t[8];let c;return t[9]!==r||t[10]!==s?(c=(0,z.jsx)(Tj.div,{layout:!0,className:r,transition:i,children:s}),t[9]=r,t[10]=s,t[11]=c):c=t[11],c}f6.displayName=`AgentHeader.Root`;function p6(e){let t=(0,G.c)(6),{hasSubmitted:n}=T6(),r;t[0]!==n||t[1]!==e.children||t[2]!==e.icon?(r=!n&&(0,z.jsx)(Tj.div,{exit:{opacity:0},transition:{duration:.2},children:(0,z.jsxs)(`h1`,{className:`flex items-center justify-center gap-2 text-2xl font-medium tracking-tight`,children:[e.icon,e.children??`How can I help today?`]})},`agent-header-initial`),t[0]=n,t[1]=e.children,t[2]=e.icon,t[3]=r):r=t[3];let i;return t[4]===r?i=t[5]:(i=(0,z.jsx)(jk,{mode:`sync`,children:r}),t[4]=r,t[5]=i),i}p6.displayName=`AgentHeader.Hero`;function m6(e){let t=(0,G.c)(2),n;return t[0]===e.children?n=t[1]:(n=(0,z.jsx)(Tj.h2,{layout:`position`,className:`text-muted-foreground text-sm font-medium`,children:e.children}),t[0]=e.children,t[1]=n),n}m6.displayName=`AgentHeader.Title`;function h6(e){let t=(0,G.c)(5),{hasSubmitted:n}=T6(),r;t[0]!==n||t[1]!==e.children?(r=n&&!!e.children&&(0,z.jsx)(Tj.p,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.25},className:`text-muted-foreground text-sm`,children:e.children}),t[0]=n,t[1]=e.children,t[2]=r):r=t[2];let i;return t[3]===r?i=t[4]:(i=(0,z.jsx)(jk,{children:r}),t[3]=r,t[4]=i),i}h6.displayName=`AgentHeader.Description`;var g6={Root:f6,Hero:p6,Title:m6,Description:h6},_6=(0,R.createContext)(void 0),v6=(0,R.createContext)(`ready`),y6=(0,R.createContext)(void 0),b6=(0,R.createContext)(null),x6=(0,R.createContext)(void 0);function S6({chatId:e,children:t,skipInitialView:n,debugMode:r,registry:i,initialMessages:a,transport:o,resume:s,onData:c,onFinish:l,onResetChat:u}){let d=c6({chatId:e,transport:o,registry:i,initialMessages:a,resume:s,onData:c,onFinish:l}),[f,p]=(0,R.useState)(r),m=(0,R.useCallback)(()=>p(e=>!e),[]),h=(0,R.useRef)(u);(0,R.useEffect)(()=>{h.current=u},[u]);let g=(0,R.useCallback)(e=>{h.current(e)},[]),[_]=(0,R.useState)(()=>new o6({chat:d,uploadFile:o.uploadFile.bind(o),onResetChat:g}));_.bind(d),(0,R.useEffect)(()=>_.initialize(e),[_,e]);let v=(0,R.useMemo)(()=>({clearChat:()=>_.clearChat(),resetChat:e=>_.resetChat(e),submit:e=>_.submit(e),setChat:e=>_.setChat(e),getTriggeringUserMessage:e=>_.getTriggeringUserMessage(e),getLastUserMessageId:()=>_.getLastUserMessageId(),stop:()=>_.stop()}),[_]),y=(0,R.useMemo)(()=>({chatId:e,registry:i,debugMode:f,toggleDebugMode:m,...v}),[e,i,f,m,v]),b=(0,R.useMemo)(()=>d,[d.id,d.messages,d.status,d.error,d.experimental_queuedMessages]),x=!!n||d.messages.length>0,S=(0,R.useMemo)(()=>({hasSubmitted:x}),[x]);return(0,z.jsx)(b6,{value:_,children:(0,z.jsx)(_6,{value:y,children:(0,z.jsx)(v6,{value:d.status,children:(0,z.jsx)(y6,{value:b,children:(0,z.jsx)(x6,{value:S,children:t})})})})})}function C6(){let e=(0,R.use)(_6);if(e===void 0)throw Error(`useAgent must be used within an AgentProvider`);return e}function w6(){return{status:(0,R.use)(v6)}}function T6(){let e=(0,R.use)(x6);if(e===void 0)throw Error(`useAgentMeta must be used within an AgentProvider`);return e}function E6(){let e=(0,R.use)(y6);if(e===void 0)throw Error(`useAgentMessages must be used within an AgentProvider`);return e}function D6(e){return(e??[]).filter(e=>e.source.sourceType===`url`)}function O6(e){let t=new Set,n=[],r=(e,r)=>{t.has(e)||(t.add(e),n.push({url:e,title:r}))};for(let t of e)for(let e of t.parts){if(e.type===`text`)for(let{source:t}of D6(e.citations))r(t.url,t.title);e.type===`source-url`&&r(e.url,e.title)}return n}function k6(e,t){let n=e.findIndex(e=>e.url===t);return n===-1?null:n+1}function A6(e,t){return t===`streaming`||t===`submitted`?!1:e===`input-streaming`||e===`input-available`}function j6(e,t){return A6(e.state,t)}function M6(e){return Object.entries(e).reduce((e,[t,n])=>(n.static||(e[t]={inputSchema:Le(n.inputSchema,{io:`input`,unrepresentable:`any`}),description:n.description}),e),{})}function N6(e){let t=(0,G.c)(11),{children:n,as:r,className:i,duration:a,enabled:o}=e,s=r===void 0?`p`:r,c=o===void 0||o,l=c&&`shimmer`,u;t[0]!==i||t[1]!==l?(u=I(l,i),t[0]=i,t[1]=l,t[2]=u):u=t[2];let d;t[3]!==a||t[4]!==c?(d=c&&a!==void 0?{animationDuration:`${a}s`}:void 0,t[3]=a,t[4]=c,t[5]=d):d=t[5];let f;return t[6]!==s||t[7]!==n||t[8]!==u||t[9]!==d?(f=(0,z.jsx)(s,{className:u,style:d,children:n}),t[6]=s,t[7]=n,t[8]=u,t[9]=d,t[10]=f):f=t[10],f}function P6(e){let t=(0,G.c)(4),{className:n}=e,r;t[0]===n?r=t[1]:(r=I(`size-3.5 shrink-0 transition-transform group-data-[panel-open]:rotate-90`,n),t[0]=n,t[1]=r);let i;return t[2]===r?i=t[3]:(i=(0,z.jsx)(Ct,{"aria-hidden":!0,className:r}),t[2]=r,t[3]=i),i}function F6(e){return I(`group hover:bg-muted/30 flex min-h-7 w-full gap-2 rounded-sm py-1 text-left transition-colors`,e)}(0,R.createContext)(null);var I6=(0,R.createContext)(void 0),L6=(0,R.createContext)(void 0);function R6(){let e=(0,R.use)(I6);if(!e)throw Error(`useMessagesContext must be used within <Messages>`);return e}function z6(){let e=(0,R.use)(I6),{status:t}=w6();return e?.status??t}function B6(){let e=(0,R.use)(L6);if(!e)throw Error(`useMessageItem must be used within <Messages.Item>`);return e}function V6({source:e,index:t,labels:n={source:`Source ${t}`,open:`Open the source`},children:r}){let i=URL.parse(e.url)?.hostname??e.url;return(0,z.jsx)(`sup`,{className:`ml-0.5 inline-block`,children:(0,z.jsxs)(No,{children:[(0,z.jsx)(Po,{openOnHover:!0,"aria-label":n.source,className:`text-primary bg-primary/10 hover:bg-primary/20 focus-visible:ring-ring focus-visible:ring-offset-background inline-block rounded px-1 font-mono text-[10px] leading-tight transition-colors focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:outline-none`,children:t}),(0,z.jsxs)(Fo,{className:`w-72 gap-2 text-sm`,children:[(0,z.jsxs)(Io,{children:[(0,z.jsx)(Lo,{dir:`auto`,title:e.title??i,className:`truncate`,children:e.title??i}),e.title?(0,z.jsx)(Ro,{dir:`auto`,title:i,className:`truncate`,children:i}):null]}),r,(0,z.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`text-primary underline`,children:n.open})]})]})})}function H6(e){let t=(0,G.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({ref:i,className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===n?a=t[5]:(a=I(`border-border bg-background relative min-w-0 gap-0 overflow-visible rounded-md border py-0 text-sm/normal ring-0`,n),t[4]=n,t[5]=a);let o;return t[6]!==r||t[7]!==i||t[8]!==a?(o=(0,z.jsx)(Zi,{ref:i,"data-slot":`table-panel`,size:`default`,className:a,...r}),t[6]=r,t[7]=i,t[8]=a,t[9]=o):o=t[9],o}H6.displayName=`TablePanel.Root`;function U6(e){let t=(0,G.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=I(`border-border flex items-center justify-between gap-4 border-b px-4 py-3`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,z.jsx)(Qi,{"data-slot":`table-panel-header`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function W6(e){let t=(0,G.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=I(`min-w-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,z.jsx)(`div`,{"data-slot":`table-panel-heading`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function G6(e){let t=(0,G.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=I(`text-base font-medium text-balance wrap-anywhere`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,z.jsx)($i,{"data-slot":`table-panel-title`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function K6(e){let t=(0,G.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=I(`text-muted-foreground text-xs text-pretty wrap-anywhere`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,z.jsx)(ea,{"data-slot":`table-panel-description`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function q6(e){let t=(0,G.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=I(`flex shrink-0 items-center gap-1`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,z.jsx)(ta,{"data-slot":`table-panel-actions`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function J6(e){let t=(0,G.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=I(`min-w-0 flex-1 overflow-auto rounded-b-[inherit] p-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,z.jsx)(na,{"data-slot":`table-panel-content`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var Y6=Object.assign(H6,{Header:U6,Heading:W6,Title:G6,Description:K6,Actions:q6,Content:J6}),X6=/<\w[\w-]*(?:"(?:\\.|[^"])*"|[^>"])*>/g,Z6=/\b([\w-]+)="((?:\\.|[^"])*)"/g;function Q6(e){return e.replace(X6,e=>e.replace(Z6,(e,t,n)=>`${t}="${n.replace(/\\"/g,`"`)}"`))}function $6(e,t){if(typeof e!=`string`)return e;let n=Q6(o8(e,n8(t))).replace(/<(\w[\w-]*)((?:\s+[\w-]+="[^"]*")+)\s*(\/?>)/g,(e,t,n,r)=>`<${t}${n.replace(/\s+/g,` `)}${r}`);return n=n.replace(/\/>(\s*)</g,(e,t,n,r)=>!t.includes(`
|
|
313
|
+
`)}function p1(e,t){let n=_1(e,t);for(;n>0&&w1(b1(e,n));)n=v1(e,n);if(n===0)return 0;let r=D1(b1(e,n));if(r===`cjk`)return v1(e,n);for(;n>0&&D1(b1(e,n))===r;)n=v1(e,n);return n}function m1(e,t){let n=_1(e,t);for(;n<e.length&&w1(x1(e,n));)n=y1(e,n);if(n>=e.length)return e.length;let r=D1(x1(e,n));if(r===`cjk`)return y1(e,n);for(;n<e.length&&D1(x1(e,n))===r;)n=y1(e,n);return n}function h1(e,t){return(e%t+t)%t}function g1(e,t,n){return`${e}:${n}:${t}`}function _1(e,t){let n=Math.max(0,Math.min(t,e.length));return n>0&&n<e.length&&C1(e.charCodeAt(n))&&--n,n}function v1(e,t){let n=t-1;return n>0&&C1(e.charCodeAt(n))?n-1:Math.max(n,0)}function y1(e,t){let n=t+(S1(e.charCodeAt(t))?2:1);return Math.min(n,e.length)}function b1(e,t){let n=v1(e,t);return e.slice(n,t)}function x1(e,t){return e.slice(t,y1(e,t))}function S1(e){return e>=55296&&e<=56319}function C1(e){return e>=56320&&e<=57343}function w1(e){return/\s/u.test(e)}function T1(e){return!E1(e)&&/[\p{Letter}\p{Number}_]/u.test(e)}function E1(e){return/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]/u.test(e)}function D1(e){return E1(e)?`cjk`:T1(e)?`word`:`separator`}var O1=`composer-draft:v1:`;function k1(e){let t=localStorage.getItem(`${O1}${e}`);if(!t)return null;try{let e=JSON.parse(t);return M1(e)?e:null}catch{return null}}function A1(e,t){let n=`${O1}${e}`;if(!t||j1(t)){localStorage.removeItem(n);return}try{localStorage.setItem(n,JSON.stringify(t))}catch(e){if(!(e instanceof DOMException&&e.name===`QuotaExceededError`))throw e}}function j1(e){return!e.persistedPrompt.trim()&&e.remoteImages.length===0&&e.pendingPastes.length===0}function M1(e){return N1(e)&&Object.keys(e).every(e=>[`persistedPrompt`,`remoteImages`,`pendingPastes`].includes(e))&&typeof e.persistedPrompt==`string`&&Array.isArray(e.remoteImages)&&Array.isArray(e.pendingPastes)}function N1(e){return typeof e==`object`&&!!e}var P1=Symbol.for(`composer.registry.trigger`),F1=Symbol.for(`composer.registry.command`),I1=Symbol.for(`composer.registry.mention`);function L1(e){return null}L1.role=P1;function R1(e){return null}R1.role=F1;function z1(e){return null}z1.role=I1;function B1(e){let t=[],n=[],r=new Set,i=new Set,a=!1,o=e=>{for(let s of R.Children.toArray(e)){if(!(0,R.isValidElement)(s)){a=!0;continue}if(s.type===R.Fragment){(0,R.isValidElement)(s)&&o(s.props.children);continue}if(G1(s.type,P1)){(0,R.isValidElement)(s)&&U1(s.props,{slashCommands:t,mentionCandidates:n,commandTriggers:r,mentionTriggers:i});continue}if(G1(s.type,F1)||G1(s.type,I1))throw Error(`Composer.Command and Composer.Mention must be placed inside a <Composer.Trigger>.`);a=!0}};return o(e),{slashCommands:t,mentionCandidates:n,commandTriggers:[...r],mentionTriggers:[...i],hasLayoutChildren:a}}function V1(e){return JSON.stringify([e.slashCommands.map(H1),e.mentionCandidates.map(H1),e.commandTriggers,e.mentionTriggers])}function H1(e){let{icon:t,...n}=e;return n}function U1(e,t){let{trigger:n}=e;for(let r of R.Children.toArray(e.children))if((0,R.isValidElement)(r)){if(r.type===R.Fragment){(0,R.isValidElement)(r)&&U1({trigger:n,children:r.props.children},t);continue}if(G1(r.type,F1)){if(t.mentionTriggers.has(n))throw Error(`Composer.Trigger "${n}" already holds mentions; a trigger carries either commands or mentions, not both.`);t.commandTriggers.add(n),(0,R.isValidElement)(r)&&t.slashCommands.push({...r.props,atomic:!1,trigger:n});continue}if(G1(r.type,I1)){if(t.commandTriggers.has(n))throw Error(`Composer.Trigger "${n}" already holds commands; a trigger carries either commands or mentions, not both.`);t.mentionTriggers.add(n),(0,R.isValidElement)(r)&&t.mentionCandidates.push(W1(r.props,n));continue}throw Error(`<Composer.Trigger trigger="${n}"> accepts only <Composer.Command> and <Composer.Mention> children; wrap them in a fragment rather than a component, which the registry cannot see through.`)}}function W1(e,t){return{id:e.id,trigger:t,value:e.value,label:e.label,detail:e.detail,atomic:!0,icon:e.icon,payload:e.payload,persistsAs:e.persistsAs,visibility:e.visibility}}function G1(e,t){return typeof e==`function`&&`role`in e&&e.role===t}function K1(e,t,n,r){return[...r$(e.query,t.filter(t=>t.trigger===e.trigger),r),...q1(e.query,n.filter(t=>t.trigger===e.trigger),r)]}function q1(e,t,n){let r=e.slice(1).toLowerCase();return t.filter(e=>n$(e.visibility,n)&&(e.label.toLowerCase().includes(r)||m$(e).slice(1).toLowerCase().includes(r))).slice(0,10)}var J1=(0,R.createContext)(null);function Y1(e){let t=e===void 0?`useComposerDictation`:e;KQ(t);let n=(0,R.use)(J1);if(!n)throw Error(`${t} needs the dictation prop of Composer.Root.`);return n}function X1(e,t){return typeof e==`function`?n=>e(n,t):e}function Z1(e){let t=(0,G.c)(15),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({dictation:a,refusesStart:r,render:i,...n}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let{state:o,start:s,stop:c}=a,l=o.status===`recording`,u=(o.status===`idle`||o.status===`failed`)&&!r,d=o.status,f=!l&&!u,p=l?c:s,m;t[5]!==i||t[6]!==o?(m=X1(i,o),t[5]=i,t[6]=o,t[7]=m):m=t[7];let h;return t[8]!==n||t[9]!==l||t[10]!==o.status||t[11]!==f||t[12]!==p||t[13]!==m?(h=(0,z.jsx)(y,{...n,"data-status":d,"aria-pressed":l,disabled:f,onClick:p,render:m}),t[8]=n,t[9]=l,t[10]=o.status,t[11]=f,t[12]=p,t[13]=m,t[14]=h):h=t[14],h}function Q1(e){let t=(0,G.c)(14),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({dictation:a,render:i,disabled:n,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let{state:o,cancel:s}=a,c=o.status===`starting`||o.status===`recording`||o.status===`finishing`,l=o.status,u=!c||n===!0,d;t[5]!==i||t[6]!==o?(d=X1(i,o),t[5]=i,t[6]=o,t[7]=d):d=t[7];let f;return t[8]!==s||t[9]!==r||t[10]!==o.status||t[11]!==u||t[12]!==d?(f=(0,z.jsx)(y,{...r,"data-status":l,disabled:u,onClick:s,render:d}),t[8]=s,t[9]=r,t[10]=o.status,t[11]=u,t[12]=d,t[13]=f):f=t[13],f}function $1(e){let t=(0,G.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({disabled:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let{disabled:i}=KQ(`Composer.Dictate`),a=Y1(`Composer.Dictate`),{state:o}=a,s=o.status===`finishing`?o.end:void 0,c=n===!0||i,l;return t[3]!==a||t[4]!==r||t[5]!==s||t[6]!==c?(l=(0,z.jsx)(Z1,{...r,"data-end":s,dictation:a,refusesStart:c}),t[3]=a,t[4]=r,t[5]=s,t[6]=c,t[7]=l):l=t[7],l}function e0(e){let t=(0,G.c)(3),n=Y1(`Composer.CancelDictation`),r;return t[0]!==n||t[1]!==e?(r=(0,z.jsx)(Q1,{...e,dictation:n}),t[0]=n,t[1]=e,t[2]=r):r=t[2],r}var t0=class extends Error{code;constructor(e,t){super(`Dictation failed: ${e}`,t),this.name=`DictationError`,this.code=e}},n0=new Map([[`NotAllowedError`,`permission-denied`],[`NotFoundError`,`no-microphone`],[`NotReadableError`,`microphone-in-use`]]);function r0(e){switch(e.status){case`starting`:case`ended`:return{status:e.status};case`recording`:return{status:`recording`};case`stopping`:case`transcribing`:return{status:`finishing`};case`failed`:return{status:`failed`,error:e.error}}}var i0=class e{#e={status:`starting`};#t={status:`starting`};#n=new AbortController;#r=new Set;#i=new Set;#a;constructor(e){this.#a=e}static start(t){let n=new e(t);return n.#o(),n}subscribe=e=>(this.#r.add(e),()=>{this.#r.delete(e)});getSnapshot=()=>this.#t;onTranscript(e){return this.#i.add(e),()=>{this.#i.delete(e)}}stop(){let e=this.#e;if(e.status===`starting`){this.cancel();return}e.status===`recording`&&(this.#u({...e,status:`stopping`}),e.recorder.stop())}cancel(){this.#l({status:`ended`})}async#o(){let e;try{e=await navigator.mediaDevices.getUserMedia({audio:!0})}catch(e){let t=e instanceof DOMException?n0.get(e.name):void 0;if(!t)throw e;this.#l({status:`failed`,error:new t0(t,{cause:e})});return}let{signal:t}=this.#n;if(t.aborted){for(let t of e.getTracks())t.stop();return}let n=new MediaRecorder(e),r=[];n.addEventListener(`dataavailable`,e=>{r.push(e.data)},{signal:t}),n.addEventListener(`stop`,()=>{this.#e.status===`stopping`&&this.#s(new Blob(r,{type:n.mimeType}))},{signal:t}),n.addEventListener(`error`,e=>{this.#l({status:`failed`,error:new t0(`interrupted`,{cause:e})})},{signal:t});for(let n of e.getAudioTracks())n.addEventListener(`ended`,()=>{this.#l({status:`failed`,error:new t0(`interrupted`)})},{signal:t});n.start(),this.#u({status:`recording`,stream:e,recorder:n})}async#s(e){this.#c(),this.#u({status:`transcribing`});let{signal:t}=this.#n;try{let{text:n}=await this.#a(e,{signal:t});if(t.aborted)return;for(let e of this.#i)e(n)}catch(e){if(t.aborted)return;this.#l({status:`failed`,error:new t0(`transcription-failed`,{cause:e})});return}this.#l({status:`ended`})}#c(){let e=this.#e;if(!(e.status!==`recording`&&e.status!==`stopping`)){e.recorder.state!==`inactive`&&e.recorder.stop();for(let t of e.stream.getTracks())t.stop()}}#l(e){let{status:t}=this.#e;t===`ended`||t===`failed`||(this.#n.abort(),this.#c(),this.#u(e))}#u(e){this.#e=e,this.#t=r0(e);for(let e of this.#r)e()}},a0=class{#e=`unknown`;subscribe=e=>{let t=new AbortController;return navigator.permissions.query({name:`microphone`}).then(n=>{if(t.signal.aborted)return;let r=()=>{this.#e=n.state,e()};r(),n.addEventListener(`change`,r,{signal:t.signal})},e=>{if(!(e instanceof TypeError))throw e}),()=>{t.abort()}};getSnapshot=()=>this.#e},o0=()=>()=>void 0,s0=()=>null,c0=()=>`unknown`;function l0(e){let t=(0,G.c)(29),{offered:n,disabled:r,onTranscript:i}=e,a=`MediaRecorder`in globalThis&&`mediaDevices`in navigator,[o]=(0,R.useState)(u0),s=(0,R.useSyncExternalStore)(n&&a?o.subscribe:o0,o.getSnapshot,c0),[c,l]=(0,R.useState)(null),u=(0,R.useSyncExternalStore)(c?c.subscribe:o0,c?c.getSnapshot:s0,s0),d;t[0]===i?d=t[1]:(d=e=>{i(e)},t[0]=i,t[1]=d);let f=(0,R.useEffectEvent)(d),p;t[2]!==f||t[3]!==c?(p=()=>{if(!c)return;let e=c.onTranscript(e=>{f(e)});return()=>{e(),c.cancel()}},t[2]=f,t[3]=c,t[4]=p):p=t[4];let m;t[5]===c?m=t[6]:(m=[c],t[5]=c,t[6]=m),(0,R.useEffect)(p,m);let h,g;t[7]!==r||t[8]!==n||t[9]!==c?(h=()=>{(r||!n)&&c?.cancel()},g=[r,n,c],t[7]=r,t[8]=n,t[9]=c,t[10]=h,t[11]=g):(h=t[10],g=t[11]),(0,R.useEffect)(h,g);let _,v;if(t[12]!==s||t[13]!==u){v=e(),_=v.status===`starting`||v.status===`recording`||v.status===`finishing`;function e(){if(!a)return{status:`unavailable`,reason:`unsupported`};switch(u?.status){case`starting`:case`recording`:case`finishing`:return{status:u.status};case`ended`:case`failed`:case void 0:}return s===`denied`?{status:`unavailable`,reason:`blocked`}:u?.status===`failed`?{status:`failed`,error:u.error}:{status:`idle`}}t[12]=s,t[13]=u,t[14]=_,t[15]=v}else _=t[14],v=t[15];let y;t[16]!==_||t[17]!==r||t[18]!==v?(y=function(e){return r||_||v.status===`unavailable`?!1:(l(i0.start(e)),!0)},t[16]=_,t[17]=r,t[18]=v,t[19]=y):y=t[19];let b=y,x;t[20]===c?x=t[21]:(x=function(){c?.stop()},t[20]=c,t[21]=x);let S=x,C;t[22]===c?C=t[23]:(C=function(){c?.cancel()},t[22]=c,t[23]=C);let w=C,T;return t[24]!==w||t[25]!==b||t[26]!==v||t[27]!==S?(T={state:v,start:b,stop:S,cancel:w},t[24]=w,t[25]=b,t[26]=v,t[27]=S,t[28]=T):T=t[28],T}function u0(){return new a0}function d0(e){let t=(0,G.c)(25),{dictation:n,disabled:r,insertTranscript:i,submitDraft:a}=e,[o,s]=(0,R.useState)(`insert`),c=n!==void 0,l;t[0]!==o||t[1]!==i||t[2]!==a?(l=e=>{let t=e.trim();t&&i(t),o===`send`&&a()},t[0]=o,t[1]=i,t[2]=a,t[3]=l):l=t[3];let u;t[4]!==r||t[5]!==c||t[6]!==l?(u={offered:c,disabled:r,onTranscript:l},t[4]=r,t[5]=c,t[6]=l,t[7]=u):u=t[7];let d=l0(u);if(!n)return null;let{transcribe:f}=n,p;t[8]!==o||t[9]!==d.state?(p=d.state.status===`finishing`?{status:`finishing`,end:o}:d.state,t[8]=o,t[9]=d.state,t[10]=p):p=t[10];let m=p,h;t[11]!==d||t[12]!==f?(h=function(){d.start(f)&&s(`insert`)},t[11]=d,t[12]=f,t[13]=h):h=t[13];let g=h,_;t[14]!==d||t[15]!==m?(_=function(){switch(m.status){case`starting`:return d.cancel(),!1;case`recording`:return s(`send`),d.stop(),!0;case`finishing`:return s(`send`),!0;default:return!1}},t[14]=d,t[15]=m,t[16]=_):_=t[16];let v=_,y;t[17]!==d.cancel||t[18]!==d.stop||t[19]!==g||t[20]!==m?(y={state:m,start:g,stop:d.stop,cancel:d.cancel},t[17]=d.cancel,t[18]=d.stop,t[19]=g,t[20]=m,t[21]=y):y=t[21];let b;return t[22]!==v||t[23]!==y?(b={api:y,endWithSend:v},t[22]=v,t[23]=y,t[24]=b):b=t[24],b}function f0({getPlaceholder:e,...t}){return[WQ.configure({link:!1}),GY.configure({autolink:!0,linkOnPaste:!1,openOnClick:!1,HTMLAttributes:{"data-token":`link`}}),h0,g0,_0,qX.configure({placeholder:e,showOnlyWhenEditable:!1}),v0(t)]}var p0=1e3;function m0(e,t){return{default:t,parseHTML:n=>n.getAttribute(e)??t}}var h0=EG.create({name:`composerSlashCommand`,inclusive:!1,addAttributes(){return{value:{default:null},detail:{default:null}}},parseHTML(){return[{tag:`span[data-composer-slash-command]`}]},renderHTML({HTMLAttributes:e}){return[`span`,jU(e,{"data-token":`slash-command`,"data-composer-slash-command":e.value}),0]}}),g0=tK.create({name:`composerMention`,group:`inline`,inline:!0,atom:!0,selectable:!0,addAttributes(){return{id:m0(`id`,null),trigger:m0(`trigger`,``),value:m0(`value`,``),label:m0(`label`,``),detail:m0(`detail`,``),persistsAs:m0(`persistsAs`,null),payload:{default:null,renderHTML:e=>e.payload===null||e.payload===void 0?{}:{payload:JSON.stringify(e.payload)},parseHTML:e=>{let t=e.getAttribute(`payload`);if(t===null)return null;try{return JSON.parse(t)}catch{return null}}}}},parseHTML(){return[{tag:`span[data-composer-mention]`}]},renderHTML({node:e,HTMLAttributes:t}){let n=e.attrs.label||`${e.attrs.trigger??``}${e.attrs.value??``}`;return[`span`,jU(t,{"data-token":`mention`,"data-composer-mention":e.attrs.value,"data-composer-mention-trigger":e.attrs.trigger}),n]},renderText({node:e}){return e.attrs.label||`${e.attrs.trigger??``}${e.attrs.value??``}`}}),_0=tK.create({name:`composerAtom`,group:`inline`,inline:!0,atom:!0,selectable:!0,addAttributes(){return{kind:{default:`paste`},label:{default:``},detail:{default:``},content:{default:``},href:{default:``},attachmentId:{default:``,rendered:!1},media:{default:`image`,rendered:!1},metadata:{default:null}}},parseHTML(){return[{tag:`span[data-composer-atom]`}]},renderHTML({node:e,HTMLAttributes:t}){let n=String(e.attrs.kind??`paste`),r=String(e.attrs.label??``);return[`span`,jU(t,{"data-token":n,"data-composer-atom":n,"data-composer-atom-detail":e.attrs.detail}),r]},renderText({node:e}){return String(e.attrs.label??``)}});function v0(e){return PG.create({name:`composerClipboard`,addProseMirrorPlugins(){return[new SI({props:{handlePaste(t,n){let r=n.clipboardData;if(!r)return!1;let i=Array.from(r.files).find(e=>V$(e)!==null);if(i)return n.preventDefault(),q0(t,e.getRemoteImageCount(),i,e.attachImageFile),!0;let a=Array.from(r.files).find(e=>V$(e)===null);if(a)return n.preventDefault(),J0(t,a.name||`pasted-file`,e.getMentionTrigger()),!0;let o=S2(D2(r.getData(`text/uri-list`))||O2(r.getData(`DownloadURL`))||r.getData(`text/plain`)||r.getData(`text`)),s=o.trim();if(!o)return!1;let c=B0(t);if(c&&k2(s)){n.preventDefault();let e=A2(s),r=t.state.schema.marks.link;return r?H0(t,c,e,r):!1}return C2(s)&&!s.includes(`
|
|
314
|
+
`)?(n.preventDefault(),J0(t,s,e.getMentionTrigger()),!0):k2(s)&&!s.includes(`
|
|
315
|
+
`)?(n.preventDefault(),G0(t,s,A2(s))):c&&o&&!o.includes(`
|
|
316
|
+
`)&&K$(o)<=p0?(n.preventDefault(),K0(t,o,c),!0):K$(o)>p0?(n.preventDefault(),z0(t,o),!0):!1},handleDrop(t,n){let r=n.dataTransfer;return r&&y0(t,r,e.getRemoteImageCount(),e.getMentionTrigger(),e.attachImageFile)?(n.preventDefault(),!0):!1}}})]}})}function y0(e,t,n,r,i){let a=Array.from(t.files).find(e=>V$(e)!==null);if(a)return q0(e,n,a,i),!0;let o=Array.from(t.files).find(e=>V$(e)===null);if(o)return J0(e,o.name||`dropped-file`,r),!0;let s=S2(D2(t.getData(`text/uri-list`))||O2(t.getData(`DownloadURL`))||t.getData(`text/plain`)).trim();return s?C2(s)&&!s.includes(`
|
|
317
|
+
`)?(J0(e,s,r),!0):k2(s)&&!s.includes(`
|
|
318
|
+
`)?(G0(e,s,A2(s)),!0):!1:!1}function b0({state:e,text:t,slashCommands:n,mentionCandidates:r,triggers:i}){return e?x0(h$({initialDraft:e,slashCommands:n,commandTriggers:i.commandTriggers,mentionCandidates:r}),n,r,i):S0(t??``,n,r,i)}function x0(e,t,n,r){if(e.elements.length===0)return S0(e.text,t,n,r);let i=[],a=0;for(let o of z$(e.elements)){o.range.start>a&&i.push(...C0(e.text.slice(a,o.range.start),t,n,r.commandTriggers,r.mentionTriggers));let s=e.mentionBindings.find(e=>e.id===o.id||`${e.trigger}${e.value}`===o.label),c=e.pendingPastes.find(e=>e.placeholder===o.label);o.kind===`mention`&&s?i.push(N0(P0(s,o,n))):o.kind===`paste`&&c?i.push(F0({kind:`paste`,label:c.placeholder,detail:o.detail??`${K$(c.content)} chars`,content:c.content})):o.kind===`rich-link`?i.push(F0({kind:`rich-link`,label:o.label,detail:o.detail??``,href:o.detail??``,metadata:o.metadata})):o.kind===`link`?i.push(j0(o.label,[M0(o.detail??``)])):i.push(...C0(e.text.slice(o.range.start,o.range.end),t,n,r.commandTriggers,r.mentionTriggers)),a=o.range.end}return a<e.text.length&&i.push(...C0(e.text.slice(a),t,n,r.commandTriggers,r.mentionTriggers)),k0(i)}function S0(e,t,n,r){let i=X$({text:e,slashCommands:t,commandTriggers:r.commandTriggers,mentionCandidates:n});return(i.elements?.length??0)>0?x0(h$({initialDraft:i,slashCommands:t,commandTriggers:r.commandTriggers,mentionCandidates:n}),t,n,r):{type:`doc`,content:e.split(`
|
|
319
|
+
`).map(e=>({type:`paragraph`,content:C0(e,t,n,r.commandTriggers,r.mentionTriggers)}))}}function C0(e,t,n,r,i){return sN(e).flatMap(e=>e.kind===`inline-code`||e.kind===`code-block`||e.kind===`link`||e.kind===`skill-link`?[j0(e.source)]:w0(e.source,t,n,r,i))}function w0(e,t,n,r,i){let a=[],o=f$(r,i);if(!o)return[j0(e)];let s=0;for(let r of e.matchAll(o)){let o=r.index??0,c=r[0];if(o===0||/\s/.test(e[o-1]??``)){if(o>s&&a.push(j0(e.slice(s,o))),p$(c,i)){let e=n.find(e=>m$(e)===c);a.push(e?N0(e):j0(c))}else{let e=i$(c.replace(/^\//,``),t);a.push(e?j0(c,[{type:`composerSlashCommand`,attrs:{value:e.value,detail:e.detail}}]):j0(c))}s=o+c.length}}return s<e.length&&a.push(j0(e.slice(s))),a}function T0(e,t,n,r,i,a){let o={text:``,elements:[],mentionBindings:[],imageAttachments:[],pendingPastes:[]};E0(e,o,n);let s=h$({text:o.text,slashCommands:n,isTaskRunning:r,queueSubmissions:i});return{...s,cursor:a,elements:x2([...s.elements,...o.elements]),mentionBindings:o.mentionBindings,imageAttachments:o.imageAttachments,remoteImages:t,pendingPastes:o.pendingPastes}}function E0(e,t,n){if(e.type===`doc`){e.content?.forEach((e,r)=>{r>0&&t.text.length>0&&(t.text+=`
|
|
320
|
+
`),E0(e,t,n)});return}if(e.type===`paragraph`){e.content?.forEach(e=>E0(e,t,n));return}if(e.type===`hardBreak`){t.text+=`
|
|
321
|
+
`;return}if(e.type===`text`){let r=e.text??``,i=t.text.length;t.text+=r;for(let a of e.marks??[])if(a.type===`link`&&a.attrs?.href&&t.elements.push({id:g1(`link`,r,i),kind:`link`,label:r,range:{start:i,end:i+r.length},detail:String(a.attrs.href)}),a.type===`composerSlashCommand`){let e=i$(r.replace(/^\//,``),n);if(!e)continue;t.elements.push({id:g1(`slash-command`,r,i),kind:`slash-command`,label:r,range:{start:i,end:i+r.length},detail:e.detail})}return}if(e.type===`composerMention`){let n=String(e.attrs?.label??``)||`${String(e.attrs?.trigger??``)}${String(e.attrs?.value??``)}`,r=t.text.length,i=String(e.attrs?.id??g1(`mention`,n,r));t.text+=n,t.elements.push({id:i,kind:`mention`,label:n,range:{start:r,end:r+n.length},detail:String(e.attrs?.detail??``)});let a=e.attrs?.persistsAs;t.mentionBindings.push({id:i,trigger:String(e.attrs?.trigger??``),value:String(e.attrs?.value??``),payload:e.attrs?.payload,persistsAs:typeof a==`string`?a:void 0});return}if(e.type===`composerAtom`){let n=String(e.attrs?.label??``),r=O0(e.attrs?.kind),i=t.text.length,a=String(e.attrs?.attachmentId??``);if(r===`image`&&!a)return;let o=r===`image`?a:g1(r,n,i);t.text+=n;let s=r===`rich-link`?D0(e.attrs?.metadata):void 0;t.elements.push({id:o,kind:r,label:n,range:{start:i,end:i+n.length},detail:String(e.attrs?.detail||e.attrs?.href||``),...s?{metadata:s}:{}}),r===`image`&&t.imageAttachments.push({id:o,placeholder:n,media:H$(e.attrs?.media)}),r===`paste`&&t.pendingPastes.push({id:o,placeholder:n,content:String(e.attrs?.content??``)})}}function D0(e){if(!e||typeof e!=`object`)return;let t={};for(let n of[`title`,`description`,`siteName`,`domain`,`imageUrl`,`faviconUrl`]){let r=Object.entries(e).find(([e])=>e===n)?.[1];typeof r==`string`&&r.length>0&&(t[n]=r)}return Object.keys(t).length>0?t:void 0}function O0(e){switch(e){case`slash-command`:case`mention`:case`image`:case`paste`:case`link`:case`rich-link`:return e;default:return`paste`}}function k0(e){return{type:`doc`,content:[{type:`paragraph`,content:e}]}}function A0(){return{type:`doc`,content:[{type:`paragraph`}]}}function j0(e,t){return t&&t.length>0?{type:`text`,text:e,marks:t}:{type:`text`,text:e}}function M0(e){return{type:`link`,attrs:{href:e}}}function N0(e){return{type:`composerMention`,attrs:{id:e.id,trigger:e.trigger,value:e.value,label:m$(e),detail:e.detail,payload:e.payload,persistsAs:e.persistsAs}}}function P0(e,t,n){let r=`${e.trigger}${e.value}`;return n.find(e=>m$(e)===t.label||m$(e)===r)||{id:e.id,trigger:e.trigger,value:e.value,label:e.value,detail:``,atomic:!0,payload:e.payload}}function F0({kind:e,label:t,detail:n=``,content:r=``,href:i=``,metadata:a}){return{type:`composerAtom`,attrs:{kind:e,label:t,detail:n,content:r,href:i,metadata:a??null}}}function I0(e,t,n=`image`){return{type:`composerAtom`,attrs:{kind:`image`,attachmentId:e,label:t,media:n}}}function L0(e,t){let{selection:n}=e.state;if(!n.empty)return null;let r=n.$from,i=r.parent.textBetween(0,r.parentOffset,void 0,``),a=r.parent.textBetween(r.parentOffset,r.parent.content.size,void 0,``),o=[...t.commandTriggers,...t.mentionTriggers];if(o.length===0)return null;let s=R0(i,a,o);if(!s)return null;let c=o.find(e=>s.token.startsWith(e));return!c||s.token.slice(c.length).includes(c)?null:{trigger:c,query:s.token,from:n.from-(i.length-s.start),to:n.from+s.tail.length}}function R0(e,t,n){let r=`(?:${l$(n)})`,i=e.search(RegExp(`(?:^|\\s|\\ufffc)(${r}[^\\s\\ufffc]*)$`));if(i===-1)return null;let a=/[\s\ufffc]/.test(e[i]??``)?i+1:i,o=t.match(/^[^\s\ufffc]*/)?.[0]??``;return{start:a,token:e.slice(a)+o,tail:o}}function z0(e,t){let n=$0(e.state.doc.toJSON(),K$(t)),r=e.state.schema.nodes.composerAtom?.create({kind:`paste`,label:n,detail:`${K$(t)} chars`,content:t});r&&e.dispatch(e.state.tr.replaceSelectionWith(r).scrollIntoView())}function B0(e){let t=e.dom.ownerDocument.getSelection();if(t&&t.rangeCount>0&&!t.isCollapsed){let n=t.getRangeAt(0);if(e.dom.contains(n.commonAncestorContainer)){let r=e.posAtDOM(n.startContainer,n.startOffset),i=e.posAtDOM(n.endContainer,n.endOffset);if(r!==i)return{from:Math.min(r,i),to:Math.max(r,i),selectedAtomLabels:V0(n,e.dom),selectedText:t.toString()}}}return e.state.selection.empty?null:{from:e.state.selection.from,to:e.state.selection.to}}function V0(e,t){return Array.from(t.querySelectorAll(`[data-composer-atom]`)).filter(t=>e.intersectsNode(t)).map(e=>e.textContent??``).filter(Boolean)}function H0(e,t,n,r){let i=U0(e.state.doc,t),a=W0(e.state.doc,i.from,i.to)||n,o=e.state.schema.text(a,[r.create({href:n})]),s=e.state.tr.replaceWith(i.from,i.to,o),c=i.from+a.length;return e.dispatch(s.setSelection(Y.create(s.doc,c)).scrollIntoView()),!0}function U0(e,t){if(!t.selectedText&&!t.selectedAtomLabels?.length)return t;let n={from:t.from,to:t.to},r=!0;for(;r;)r=!1,e.nodesBetween(0,e.content.size,(e,i)=>{if(e.type.name!==`composerAtom`)return!0;let a=String(e.attrs.label??``),o=t.selectedText?.includes(a)||t.selectedAtomLabels?.includes(a);if(!a||!o)return!1;let s={from:i,to:i+e.nodeSize};if(!(s.from<=n.to+1&&s.to>=n.from-1))return!1;let c=Math.min(n.from,s.from),l=Math.max(n.to,s.to);return(c!==n.from||l!==n.to)&&(n={from:c,to:l},r=!0),!1});return n}function W0(e,t,n){let r=``;return e.nodesBetween(t,n,(e,i)=>{if(e.isText){let a=e.text??``,o=Math.max(t-i,0),s=Math.min(n-i,a.length);return r+=a.slice(o,s),!1}return e.type.name===`composerMention`?(r+=String(e.attrs.label??``),!1):e.type.name===`composerAtom`?(e.attrs.kind===`rich-link`&&(r+=String(e.attrs.label??``)),!1):e.type.name===`hardBreak`?(r+=`
|
|
322
|
+
`,!1):!0}),r.replace(/\n+/g,` `).trim()}function G0(e,t,n){let r=e.state.schema.marks.link;if(!r)return!1;let{from:i,to:a}=e.state.selection,o=e.state.tr.insertText(t,i,a);return o.addMark(i,i+t.length,r.create({href:n})),e.dispatch(o.scrollIntoView()),!0}function K0(e,t,n){e.dispatch(e.state.tr.replaceWith(n.from,n.to,e.state.schema.text(t)).scrollIntoView())}function q0(e,t,n,r){let i=r(n);if(i===null)return;let a=t+e2(e.state.doc.toJSON(),`image`)+1,o=V$(n)??`image`,s=e.state.schema.nodeFromJSON(I0(i,U$(o,a),o));if(!s)return;let c=e.state.tr.replaceSelectionWith(s);c=c.insertText(` `,c.selection.from),e.dispatch(c.scrollIntoView())}function J0(e,t,n){let r=w2(t),i=T2(r),a=`${n}${i}`,o=e.state.schema.nodes.composerMention?.create({id:g1(`mention`,a,e.state.selection.from),trigger:n,value:i,label:a,detail:E2(r)?`directory`:`file`,payload:{path:r,type:E2(r)?`directory`:`file`}});if(!o)return;let s=e.state.tr.replaceSelectionWith(o);s=s.insertText(` `,s.selection.from),e.dispatch(s.scrollIntoView())}function Y0(e,t){let n=0;return X0(e,e=>e.type!==`composerAtom`||e.attrs?.kind!==`image`?e:(n+=1,{...e,attrs:{...e.attrs,label:U$(H$(e.attrs?.media),t+n)}}))}function X0(e,t){let n=t(e);return{...n,content:n.content?.map(e=>X0(e,t))}}function Z0(e,t){return Q0(e,e=>e.type!==`composerAtom`||e.attrs?.kind!==`image`||e.attrs?.attachmentId!==t)}function Q0(e,t){return{...e,content:e.content?.filter(t).map(e=>Q0(e,t))}}function $0(e,t){let n=`[Pasted Content ${t} chars]`,r=new Set;if(t2(e,e=>{e.type===`composerAtom`&&e.attrs?.kind===`paste`&&r.add(String(e.attrs.label??``))}),!r.has(n))return n;let i=2;for(;r.has(`${n} #${i}`);)i+=1;return`${n} #${i}`}function e2(e,t){let n=0;return t2(e,e=>{e.type===`composerAtom`&&e.attrs?.kind===t&&(n+=1)}),n}function t2(e,t){t(e),e.content?.forEach(e=>t2(e,t))}function n2(e){let{selection:t}=e.state,n=t.from;return d2(e,n,t.empty?t.$from.end():t.to)}function r2(e){let{selection:t}=e.state,n=t.empty?s2(e,t.from):t.from,r=t.to;return d2(e,n,r)}function i2(e){let{selection:t}=e.state;if(!t.empty)return d2(e,t.from,t.to);let n=t.$from.parent.textBetween(0,t.$from.parentOffset,void 0,f2),r=p1(n,n.length);return d2(e,l2(t.$from.parent,t.$from.start(),r),t.from)}function a2(e){let t=e.state.selection.to,n=c2(e,t),r=e.state.tr.setSelection(Y.create(e.state.doc,n)).scrollIntoView();e.view.dispatch(r),e.view.focus()}function o2(e,t){let{selection:n}=e.state,r=t===-1?n.from:n.to,i=e.state.doc.resolve(r),a=i.parent.textBetween(0,i.parent.content.size,void 0,f2),o=i.parent.textBetween(0,i.parentOffset,void 0,f2).length,s=t===-1?p1(a,o):m1(a,o),c=l2(i.parent,i.start(),s),l=e.state.tr.setSelection(Y.create(e.state.doc,c)).scrollIntoView();e.view.dispatch(l),e.view.focus()}function s2(e,t){let{selection:n}=e.state,r=n.$from.start();return e.state.doc.nodesBetween(r,t,(e,t)=>{e.type.name===`hardBreak`&&(r=t+e.nodeSize)}),r}function c2(e,t){let n=e.state.doc.resolve(t).end();return e.state.doc.nodesBetween(t,n,(e,r)=>e.type.name===`hardBreak`&&r>=t?(n=r,!1):!0),n}function l2(e,t,n){let r=0,i=t;for(let t=0;t<e.childCount;t+=1){let a=e.child(t),o=u2(a);if(o===null){i+=a.nodeSize;continue}let s=r+o.length;if(n<=s)return a.isText?i+n-r:n===s?i+a.nodeSize:i;r=s,i+=a.nodeSize}return i}function u2(e){return e.isText?e.text??``:e.type.name===`hardBreak`?`
|
|
323
|
+
`:e.type.name===`composerMention`||e.type.name===`composerAtom`?f2(e):null}function d2(e,t,n){if(n<=t)return null;let r=e.state.doc.slice(t,n),i={text:e.state.doc.textBetween(t,n,`
|
|
324
|
+
`,f2),slice:r.toJSON()};return e.chain().focus().deleteRange({from:t,to:n}).run(),i}function f2(e){return e.type.name===`composerMention`?String(e.attrs.label??``)||`${String(e.attrs.trigger??``)}${String(e.attrs.value??``)}`:e.type.name===`composerAtom`?String(e.attrs.label??``):``}function p2(e,t){let{selection:n}=e.state;if(typeof t==`string`){if(!n.empty){e.chain().focus().deleteSelection().insertContent(t).run();return}e.chain().focus().insertContent(t).run();return}let r=q.fromJSON(e.state.schema,t.slice);e.view.dispatch(e.state.tr.replaceSelection(r).scrollIntoView()),e.view.focus()}function m2(e,t){let{selection:n}=e.state;if(!n.empty)return!1;let r=n.$from,i=t===`Backspace`?r.nodeBefore:r.nodeAfter;if(!i||!h2(i))return!1;let a=t===`Backspace`?n.from-i.nodeSize:n.from,o=t===`Backspace`?n.from:n.from+i.nodeSize;return e.chain().focus().deleteRange({from:a,to:o}).run(),!0}function h2(e){return e.isAtom&&(e.type.name===`composerMention`||e.type.name===`composerAtom`)}function g2(e){try{return e.state.doc.textBetween(0,e.state.selection.from,`
|
|
325
|
+
`,``).length}catch{return 0}}function _2(e){return e.state.selection.empty&&g2(e)===0}function v2(e,t){return p$(e.persistedPrompt,t)?`ParseSlash`:e.action}function y2(e){return e.key===`ArrowUp`||(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`p`}function b2(e){return e.key===`ArrowDown`||(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`n`}function x2(e){let t=new Map;for(let n of e)t.set(`${n.kind}:${n.range.start}:${n.range.end}:${n.label}`,n);return z$([...t.values()])}function S2(e){return e.replace(/\r\n?/g,`
|
|
326
|
+
`)}function C2(e){return e.startsWith(`file://`)||e.startsWith(`/`)||e.startsWith(`./`)||e.startsWith(`../`)||/^[A-Za-z]:[\\/]/.test(e)}function w2(e){let t=e.trim();if(!t.startsWith(`file://`))return t;let n=URL.parse(t);if(!n)return t;try{return decodeURIComponent(n.pathname)}catch{return n.pathname}}function T2(e){return e.replace(/[\\/]+$/,``).split(/[\\/]/).filter(Boolean).pop()??e}function E2(e){return/[\\/]$/.test(e)}function D2(e){return e.split(/\r?\n/).map(e=>e.trim()).find(e=>e&&!e.startsWith(`#`))??``}function O2(e){let t=D2(e);return t?t.match(/^[\w.+-]+\/[\w.+-]+:[^:\n]+:(.+)$/)?.[1]?.trim()??t:``}function k2(e){try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`}catch{return!1}}function A2(e){return $$(e.trim())}function j2(e){let t=(0,G.c)(3),n=e.draftKey??``,r;return t[0]!==e||t[1]!==n?(r=(0,z.jsx)(N2,{...e},n),t[0]=e,t[1]=n,t[2]=r):r=t[2],r}function M2(e){return typeof e==`object`&&!!e&&`then`in e&&typeof e.then==`function`}function N2({initialDraft:e,draftKey:t,disabled:n=!1,isTaskRunning:r=!1,queueSubmissions:i=!1,hasInteracted:a=!1,maxExpandedTextChars:o,editorAriaLabel:s=`Rich prompt composer`,className:c,children:l,dictation:u,validateSubmission:d,onSubmit:f,onStateChange:p}){let m=ln(),h=B1(l),g=(0,R.useRef)({signature:V1(h),slashCommands:h.slashCommands,mentionCandidates:h.mentionCandidates,commandTriggers:h.commandTriggers,mentionTriggers:h.mentionTriggers}),_=V1(h);_!==g.current.signature&&(g.current={signature:_,slashCommands:h.slashCommands,mentionCandidates:h.mentionCandidates,commandTriggers:h.commandTriggers,mentionTriggers:h.mentionTriggers});let{slashCommands:v,mentionCandidates:y,commandTriggers:b,mentionTriggers:x}=g.current,S=(0,R.useMemo)(()=>({commandTriggers:b,mentionTriggers:x}),[b,x]),C=(0,R.useRef)(x);C.current=x;let[w]=(0,R.useState)(()=>{if(e)return e;if(t===void 0)return;let n=k1(t);return n?Z$({source:n,slashCommands:v,mentionCandidates:y}):void 0}),T=(0,R.useRef)(w?.remoteImages??[]),E=(0,R.useRef)(b0({state:w,slashCommands:v,mentionCandidates:y,triggers:S})),D=(0,R.useRef)(0),ee=(0,R.useRef)(!0);(0,R.useEffect)(()=>(ee.current=!0,()=>{ee.current=!1}),[]);let[te,O]=(0,R.useState)(T.current),[ne,k]=(0,R.useState)(null),[re,A]=(0,R.useState)(()=>T0(E.current,T.current,v,r,i,0)),j=(0,R.useRef)(re),ie=(0,R.useRef)(te),M=(0,R.useRef)(ne),ae=(0,R.useRef)(null),oe=(0,R.useRef)(null),se=(0,R.useRef)(void 0),N=(0,R.useRef)(null),ce=(0,R.useRef)(null),le=(0,R.useRef)(null),ue=(0,R.useEffectEvent)((e,t)=>{p?.(e,t)}),de=(0,R.useRef)(d),fe=(0,R.useRef)(f),pe=(0,R.useRef)(new Map),me=(0,R.useRef)(()=>null),he=(0,R.useRef)(()=>void 0),ge=(0,R.useRef)(()=>void 0),_e=(0,R.useRef)(()=>!1),[ve,ye]=(0,R.useState)(``),be=(0,R.useRef)(ve);be.current=ve;let P=pq({extensions:(0,R.useMemo)(()=>f0({getPlaceholder:()=>be.current,getMentionTrigger:()=>C.current[0]??`@`,getRemoteImageCount:()=>ie.current.length,attachImageFile:e=>me.current(e)}),[]),content:E.current,editable:!n,editorProps:{attributes:{"data-slot":`composer-editor`,role:`textbox`,"aria-label":s,"aria-placeholder":ve,"aria-disabled":n?`true`:`false`,dir:`auto`,spellcheck:`false`},handleKeyDown(e,t){return _e.current(t)}},immediatelyRender:!1,onUpdate({editor:e}){he.current(e),ge.current(e)},onSelectionUpdate({editor:e}){he.current(e),ge.current(e)}}),xe=(0,R.useMemo)(()=>ne?K1(ne,v,y,a):[],[ne,a,y,v]),Se=(0,R.useMemo)(()=>_$(re,v,b),[b,re,v]);(0,R.useEffect)(()=>{j.current=re},[re]),(0,R.useEffect)(()=>{ie.current=te},[te]),(0,R.useEffect)(()=>{M.current=ne},[ne]),(0,R.useEffect)(()=>{re.shortcutsOpen&&(ne||re.reverseSearch!==null||!g$(re))&&A(e=>e.shortcutsOpen?{...e,shortcutsOpen:!1}:e)},[ne,re]),(0,R.useEffect)(()=>{de.current=d},[d]),(0,R.useEffect)(()=>{fe.current=f},[f]),(0,R.useEffect)(()=>{P&&(P.setEditable(!n),n&&k(null))},[n,P]),(0,R.useEffect)(()=>{ue(re,Se),t!==void 0&&(Se?A1(t,J$(re,Se.persistedPrompt)):D.current===0&&A1(t,null))},[re,t,Se]),(0,R.useEffect)(()=>{A(e=>e.isTaskRunning===r&&e.queueSubmissions===i?e:{...e,isTaskRunning:r,queueSubmissions:i})},[r,i]),he.current=e=>{if(n)return;let t=T0(e.getJSON(),ie.current,v,r,i,g2(e)),a=oe.current,o=se.current;oe.current=null,se.current=void 0,A(e=>{let n=o===void 0?N.current:o;N.current=n;let r=e.shortcutsOpen&&g$(t);return{...t,error:e.error,history:e.history,historyCursor:n,killBuffer:e.killBuffer,reverseSearch:e.reverseSearch,shortcutsOpen:r,selectedRemoteImageId:a}})},ge.current=e=>{if(n){k(null);return}let t=L0(e,S);if(!t){k(null);return}if(b.includes(t.trigger)){let e={trigger:t.trigger,query:t.query,selectedIndex:0},n=K1(e,v,y,a);k(t=>n.length===0?null:{...e,selectedIndex:t?.trigger===e.trigger?Math.min(t.selectedIndex,n.length-1):0});return}k(e=>{let n=t.trigger,r={trigger:n,query:t.query,selectedIndex:e?.trigger===n?e.selectedIndex:0},i=K1(r,v,y,a);return{...r,selectedIndex:e?.trigger===n?Math.min(e.selectedIndex,Math.max(i.length-1,0)):0}})};function Ce(e){P?.commands.setContent(e),P&&(he.current(P),ge.current(P))}function we(e){if(n||!P)return;let t=L0(P,S),r=[{type:`text`,text:`${e.trigger}${e.value}`,marks:[{type:`composerSlashCommand`,attrs:{value:e.value,detail:e.detail}}]},{type:`text`,text:` `}];t&&t.trigger===e.trigger?P.chain().focus().deleteRange({from:t.from,to:t.to}).insertContent(r).run():P.chain().focus().insertContent(r).run(),k(null)}function Te({index:e=M.current?.selectedIndex??0}={}){let t=M.current;if(n||!P||!t)return;let r=K1(t,v,y,a),i=r[e]??r[0];if(!i)return;if(!i.atomic){we(i);return}let o=L0(P,S),s=o?.trigger===t.trigger,c=P.chain().focus();s&&o&&c.deleteRange({from:o.from,to:o.to}),c.insertContent([N0(i),{type:`text`,text:` `}]).run(),k(null)}function Ee(){if(n||!P)return;P.commands.focus();let e=b[0];e&&k(t=>t?.trigger===e?null:{trigger:e,query:``,selectedIndex:0})}function De(e){return g$(e)&&e.reverseSearch===null&&M.current===null}function Oe(){n||A(e=>De(e)&&!e.shortcutsOpen?{...e,shortcutsOpen:!0,selectedRemoteImageId:null,error:null}:e)}function ke(){A(e=>e.shortcutsOpen?{...e,shortcutsOpen:!1}:e)}function Ae(){n||A(e=>e.shortcutsOpen?{...e,shortcutsOpen:!1}:De(e)?{...e,shortcutsOpen:!0,selectedRemoteImageId:null,error:null}:e)}function je(e){n||!P||!e||P.chain().focus().insertContent(e).run()}function Me(e){if(V$(e)===null)return A(t=>({...t,error:`Only image, video, or audio files can be attached: ${e.name||`unnamed file`}`,shortcutsOpen:!1})),k(null),null;let t=crypto.randomUUID();return pe.current.set(t,e),t}function Ne(e,t){let n=Me(t);if(n===null)return;let r=Ge(),i=r.remoteImages.length+r.imageAttachments.length+1,a=V$(t)??`image`;e.chain().focus().insertContent([I0(n,U$(a,i),a),{type:`text`,text:` `}]).run()}function Pe(e){if(!(n||!P))for(let t of e)Ne(P,t)}function Fe(e){n||!P||(pe.current.delete(e),Ce(Y0(Z0(P.getJSON(),e),ie.current.length)))}function Ie(e){if(n||!P)return;let t=[...ie.current,{id:g1(`remote-image`,e,m.Date.now()),url:e}];ie.current=t,O(t),Ce(Y0(P.getJSON(),t.length))}function Le(e){return n||!P?!1:y0(P.view,e,ie.current.length,x[0]??`@`,Me)}function Re(e){if(n)return;let t=ie.current[e]??j.current.remoteImages[e];t&&(oe.current=t.id,A(e=>({...e,selectedRemoteImageId:t.id,shortcutsOpen:!1})))}function ze(){n||(oe.current=null,A(e=>e.selectedRemoteImageId?{...e,selectedRemoteImageId:null,shortcutsOpen:!1}:e))}function Be(e){return j.current.selectedRemoteImageId?e.key===`ArrowLeft`||e.key===`ArrowRight`||e.key===`Escape`||(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`a`?(ze(),k(null),!0):e.key.length===1&&!e.metaKey&&!e.ctrlKey&&!e.altKey?(ze(),!0):!1:!1}function Ve(e){if(n)return e.preventDefault(),!0;if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`a`)return e.preventDefault(),ze(),k(null),P?.commands.selectAll(),!0;let t=Ge(),r=j.current.selectedRemoteImageId;if(!M.current&&e.key===`ArrowUp`){let n=G$({...t,selectedRemoteImageId:r},r);if(n!==null)return e.preventDefault(),Re(Math.max(0,n-1)),!0;if((P&&_2(P)||t.cursor===0)&&t.remoteImages.length>0)return e.preventDefault(),Re(t.remoteImages.length-1),!0}if(!M.current&&r&&e.key===`ArrowDown`){e.preventDefault();let n=G$({...t,selectedRemoteImageId:r},r);return n!==null&&n+1<t.remoteImages.length?Re(n+1):ze(),!0}return!M.current&&r&&(e.key===`Backspace`||e.key===`Delete`)?(e.preventDefault(),He(r),!0):(Be(e),!1)}function He(e){if(n||!P)return;let t=Ge(),r=t.remoteImages.findIndex(t=>t.id===e),i=t.remoteImages.filter(t=>t.id!==e),a=r===-1?null:i[r]??i[r-1]??null;oe.current=a?.id??null,ie.current=i,O(i),Ce(Y0(P.getJSON(),i.length)),A(e=>({...e,remoteImages:i,selectedRemoteImageId:a?.id??null,shortcutsOpen:!1}))}function Ue(e){if(n||!P)return;let t=$0(P.getJSON(),K$(e));P.chain().focus().insertContent(F0({kind:`paste`,label:t,detail:`${K$(e)} chars`,content:e})).run()}function We(e,t=e,r){n||P?.chain().focus().insertContent(F0({kind:`rich-link`,label:t,detail:e,href:e,metadata:r})).run()}function Ge(){return P?{...T0(P.getJSON(),ie.current,v,r,i,g2(P)),error:j.current.error,history:j.current.history,historyCursor:N.current??j.current.historyCursor,killBuffer:j.current.killBuffer,reverseSearch:j.current.reverseSearch,shortcutsOpen:j.current.shortcutsOpen,selectedRemoteImageId:j.current.selectedRemoteImageId}:j.current}function Ke(e){let t=de.current?.(e);return t?(A(e=>({...e,error:t,shortcutsOpen:!1})),k(null),!0):!1}function qe(e){let t=Ge(),n=t.text.slice(0,t.cursor);je(n&&!/\s$/.test(n)?` ${e}`:e)}function Je(){ct?.endWithSend()||Ye()}function Ye(){if(n)return;let e=Ge(),r=P?.getJSON()??A0(),i=e.isTaskRunning||e.queueSubmissions,a=i?null:C$(e.text,v,b);if(a){A(e=>({...e,error:`Unrecognized command: /${a}`,shortcutsOpen:!1})),k(null);return}let s=_$(e,v,b),c=s??{mode:`submitted`,prompt:``,persistedPrompt:``,historyPrompt:``,action:`Plain`,command:void 0,args:void 0,items:[],elements:[],payloadElements:[],mentionBindings:[]},l=v$(c,o);if(l){A(e=>({...e,error:l,shortcutsOpen:!1})),k(null);return}let u=new Map,d=[];for(let t of e.imageAttachments){let e=pe.current.get(t.id);if(!e){A(e=>({...e,error:`Attached image is no longer available: ${t.placeholder}`,shortcutsOpen:!1})),k(null);return}u.set(t.id,e),d.push({type:t.media,placeholder:t.placeholder,file:e})}let f=[...c.items.filter(e=>e.type===`remote_image`),...d,...c.items.filter(e=>e.type!==`remote_image`)],p={id:crypto.randomUUID(),at:new Date(m.Date.now()).toLocaleTimeString(),mode:i?`queued`:c.mode,prompt:c.prompt,persistedPrompt:c.persistedPrompt,action:i?v2(c,b):c.action,command:c.command,args:c.args,items:f};if(Ke(p))return;for(let e of u.keys())pe.current.delete(e);let h=J$(e,c.persistedPrompt),g=fe.current?.(p,{editableSource:h});M2(g)&&(D.current+=1,g.then(()=>{t!==void 0&&A1(t,null)}).catch(e=>{for(let[e,t]of u)pe.current.set(e,t);t!==void 0&&A1(t,h),ee.current&&(Ce(r),P?.commands.focus(`end`),A(t=>({...t,error:e instanceof Error?e.message:`Could not send prompt`})))}).finally(()=>{--D.current}));let _=s?Y$(e,c.historyPrompt):e.history;N.current=null,ie.current=[],O([]),k(null),Ce(A0()),A(e=>({...e,text:``,cursor:0,elements:[],mentionBindings:[],imageAttachments:[],remoteImages:[],pendingPastes:[],selectedRemoteImageId:null,error:null,shortcutsOpen:!1,history:_,historyCursor:null}))}function Xe(){if(n)return;let e=j.current.history,t=j.current.killBuffer;N.current=null,le.current=null,pe.current.clear(),ie.current=T.current,O(T.current),k(null),Ce(E.current),P?.commands.focus(`end`),A(n=>({...n,history:e,historyCursor:null,killBuffer:t,reverseSearch:null,selectedRemoteImageId:null,error:null,shortcutsOpen:!1}))}function Ze(e){if(n||!P||j.current.history.length===0)return;let t=j.current,r=N.current??t.historyCursor;if(e>0&&r===0&&ce.current){F(ce.current,null),ce.current=null;return}let i=r===null?e<0?0:t.history.length-1:h1(r+e,t.history.length);r===null&&(ce.current=q$(Ge()));let a=t.history[i];Qe(a,i)}function Qe(e,t){F(Z$({source:e,slashCommands:v,mentionCandidates:y}),t)}function F(e,t){let n=e.remoteImages??[];ie.current=n,j.current={...j.current,historyCursor:t,shortcutsOpen:!1},N.current=t,se.current=t,O(n),Ce(b0({state:e,slashCommands:v,mentionCandidates:y,triggers:S})),P?.commands.focus(`end`),A(e=>({...e,historyCursor:t,shortcutsOpen:!1}))}function $e(){n||(k(null),N.current=null,le.current=Ge(),A(e=>({...e,reverseSearch:``,historyCursor:null,shortcutsOpen:!1})))}function et(e){if(n){e.preventDefault();return}if(e.preventDefault(),e.key===`Escape`){it(null),le.current=null;return}if(e.key===`Enter`){le.current=null,A(e=>({...e,reverseSearch:null,shortcutsOpen:!1}));return}if(e.key===`Backspace`){tt(e=>e.slice(0,-1));return}if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`r`){nt(1);return}if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`s`){nt(-1);return}e.key.length===1&&!e.metaKey&&!e.altKey&&!e.ctrlKey&&tt(t=>`${t}${e.key}`)}function tt(e){if(n)return;let t=j.current,r=e(t.reverseSearch??``),i=d1(t.history,r,null);if(!P||!i){it(r);return}rt(i.entry,i.index,r)}function nt(e){if(n||!P)return;let t=j.current,r=t.reverseSearch??``,i=d1(t.history,r,t.historyCursor,e);i&&rt(i.entry,i.index,r)}function rt(e,t,n){let r=P;if(!r)return;let i=Z$({source:e,slashCommands:v,mentionCandidates:y}),a=i.remoteImages??[];ie.current=a,O(a),Ce(b0({state:i,slashCommands:v,mentionCandidates:y,triggers:S})),r.commands.focus(`end`),A(e=>({...e,historyCursor:t,reverseSearch:n,selectedRemoteImageId:null,shortcutsOpen:!1}))}function it(e){if(n)return;let t=le.current;if(!t||!P){A(t=>({...t,reverseSearch:e,shortcutsOpen:!1}));return}let r={...t,history:j.current.history,killBuffer:j.current.killBuffer,reverseSearch:e,historyCursor:null,selectedRemoteImageId:null,shortcutsOpen:!1};N.current=null,ie.current=r.remoteImages,O(r.remoteImages),Ce(b0({state:r,slashCommands:v,mentionCandidates:y,triggers:S})),P.commands.focus(`end`),A(r)}_e.current=n?e=>(e.preventDefault(),!0):Ve,me.current=Me;function at(e){if(!(e.target instanceof Element)||!e.target.closest(`[data-slot="composer-editor"]`))return;if(n){e.preventDefault();return}if(!P||Ve(e))return;if(j.current.reverseSearch!==null){et(e);return}if(j.current.shortcutsOpen&&e.key===`Escape`){e.preventDefault(),ke();return}if(e.key===`?`&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&De(Ge())){e.preventDefault(),Ae();return}if(r4(e)){e.preventDefault(),P.chain().focus().setHardBreak().run(),N.current=null,k(null);return}if(M.current){if(y2(e)||b2(e)){e.preventDefault(),st(y2(e)?-1:1);return}if(e.key===`Tab`){e.preventDefault(),Te();return}if(e.key===`Enter`&&!e.shiftKey){if(e.preventDefault(),xe.length===0){k(null),Je();return}Te();return}if(e.key===`Escape`){e.preventDefault(),k(null);return}}if(i4(e)){let t=i2(P);t&&(e.preventDefault(),ae.current=t,A(e=>({...e,killBuffer:t.text}))),N.current=null;return}let t=a4(e);if(t!==null){e.preventDefault(),o2(P,t),N.current=null;return}if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`e`){e.preventDefault(),a2(P),N.current=null;return}if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`k`){let t=n2(P);t&&(e.preventDefault(),ae.current=t,A(e=>({...e,killBuffer:t.text})));return}if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`u`){let t=r2(P);t&&(e.preventDefault(),ae.current=t,A(e=>({...e,killBuffer:t.text})));return}if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`y`&&j.current.killBuffer){e.preventDefault(),p2(P,ae.current??j.current.killBuffer);return}if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`r`){e.preventDefault(),$e();return}if((e.key===`Backspace`||e.key===`Delete`)&&s4(P)){e.preventDefault(),N.current=null,k(null);return}if((e.key===`Backspace`||e.key===`Delete`)&&m2(P,e.key)){e.preventDefault(),N.current=null;return}if((e.key===`Backspace`||e.key===`Delete`||e.key.length===1&&!e.metaKey&&!e.ctrlKey&&!e.altKey)&&(N.current=null),e.key===`Enter`&&!e.shiftKey&&!e.altKey){e.preventDefault(),Je();return}let r=o4(e);if(r!==null&&!M.current){let t=Ge();if(e.key===`ArrowUp`&&(_2(P)||t.cursor===0)&&t.remoteImages.length>0){e.preventDefault(),Re(t.remoteImages.length-1);return}f1(t.text,t.cursor,r)&&(e.preventDefault(),Ze(r))}}function ot(e){if(n){e.preventDefault();return}e.target instanceof Element&&e.target.closest(`[data-slot="composer-editor"]`)&&ze()}function st(e){n||k(t=>{if(!t)return t;let n=K1(t,v,y,a).length;return n===0?t:{...t,selectedIndex:h1(t.selectedIndex+e,n)}})}let ct=d0({dictation:u,disabled:n,insertTranscript:qe,submitDraft:Ye});return(0,z.jsx)(GQ,{value:{state:re,disabled:n,commandTriggers:b,activePopup:ne,suggestions:xe,attachedImages:pe.current,setEditorPlaceholder:ye,actions:{acceptSuggestion:Te,toggleSlashMenu:Ee,insertText:je,attachImageFiles:Pe,removeImageAttachment:Fe,addRemoteImage:Ie,handleDrop:Le,insertPaste:Ue,insertRichLink:We,openShortcuts:Oe,closeShortcuts:ke,toggleShortcuts:Ae,submit:Je,reset:Xe},meta:{editor:P}},children:(0,z.jsx)(J1,{value:ct?.api??null,children:(0,z.jsx)(`section`,{"data-slot":`composer`,className:I(`border-border bg-card relative border font-[inherit]`,c),children:(0,z.jsxs)(`div`,{onKeyDownCapture:at,onMouseDownCapture:ot,children:[l,h.hasLayoutChildren?null:(0,z.jsx)(P2,{})]})})})})}function P2(){let e=(0,G.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,z.jsx)(V2,{}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,z.jsxs)(z.Fragment,{children:[t,(0,z.jsxs)(F2,{children:[(0,z.jsx)(L2,{}),(0,z.jsx)(JQ,{}),(0,z.jsx)(z2,{}),(0,z.jsx)(B2,{})]}),(0,z.jsx)(G2,{}),(0,z.jsx)(J2,{})]}),e[1]=n):n=e[1],n}function F2(e){let t=(0,G.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=I(`space-y-2`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,z.jsx)(`div`,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function I2(e){let t=(0,G.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=I(`flex flex-wrap items-center gap-1.5`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,z.jsx)(`div`,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function L2(e){let t=(0,G.c)(14),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let{state:i}=KQ(`Composer.RemoteImages`);if(i.remoteImages.length===0)return null;let a;t[3]===n?a=t[4]:(a=I(`border-border space-y-1 border-b pb-2 text-sm`,n),t[3]=n,t[4]=a);let o;if(t[5]!==i.remoteImages||t[6]!==i.selectedRemoteImageId){let e;t[8]===i.selectedRemoteImageId?e=t[9]:(e=(e,t)=>(0,z.jsxs)(`div`,{className:I(`flex h-6 items-center gap-2 rounded-sm px-2`,i.selectedRemoteImageId===e.id?`bg-primary text-primary-foreground`:`text-sky-500`),children:[(0,z.jsxs)(`span`,{className:`shrink-0`,children:[`[Image #`,t+1,`]`]}),(0,z.jsx)(`span`,{className:`truncate text-xs opacity-70`,children:e.url})]},e.id),t[8]=i.selectedRemoteImageId,t[9]=e),o=i.remoteImages.map(e),t[5]=i.remoteImages,t[6]=i.selectedRemoteImageId,t[7]=o}else o=t[7];let s;return t[10]!==r||t[11]!==a||t[12]!==o?(s=(0,z.jsx)(`div`,{className:a,...r,children:o}),t[10]=r,t[11]=a,t[12]=o,t[13]=s):s=t[13],s}function R2(e){e.dataTransfer.types.includes(`Files`)&&e.preventDefault()}function z2(e){let t=(0,G.c)(29),n,r,i,a,o,s;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6]):({className:n,onDragEnter:r,onDragOver:i,onDrop:a,placeholder:s,...o}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s);let c=s===void 0?`Type a message or / for commands`:s,{disabled:l,meta:u,actions:d,setEditorPlaceholder:f}=KQ(`Composer.Editor`),p,m;t[7]!==c||t[8]!==f?(p=()=>{f(c)},m=[c,f],t[7]=c,t[8]=f,t[9]=p,t[10]=m):(p=t[9],m=t[10]),(0,R.useLayoutEffect)(p,m);let h=l?``:void 0,g;t[11]===r?g=t[12]:(g=e=>{r?.(e),R2(e)},t[11]=r,t[12]=g);let _;t[13]===i?_=t[14]:(_=e=>{i?.(e),R2(e)},t[13]=i,t[14]=_);let v;t[15]!==d||t[16]!==a?(v=e=>{a?.(e),!e.defaultPrevented&&d.handleDrop(e.dataTransfer)&&e.preventDefault()},t[15]=d,t[16]=a,t[17]=v):v=t[17];let y;t[18]===u.editor?y=t[19]:(y=(0,z.jsx)(oq,{editor:u.editor}),t[18]=u.editor,t[19]=y);let b;return t[20]!==n||t[21]!==l||t[22]!==o||t[23]!==h||t[24]!==g||t[25]!==_||t[26]!==v||t[27]!==y?(b=(0,z.jsx)(`div`,{"data-slot":`composer-frame`,className:n,"aria-disabled":l,"data-disabled":h,onDragEnter:g,onDragOver:_,onDrop:v,...o,children:y}),t[20]=n,t[21]=l,t[22]=o,t[23]=h,t[24]=g,t[25]=_,t[26]=v,t[27]=y,t[28]=b):b=t[28],b}function B2(e){let t=(0,G.c)(9),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let{state:i}=KQ(`Composer.Error`);if(!i.error)return null;let a;t[3]===n?a=t[4]:(a=I(`border-primary/30 bg-primary/10 text-primary rounded-md border px-3 py-2 text-xs`,n),t[3]=n,t[4]=a);let o;return t[5]!==r||t[6]!==i.error||t[7]!==a?(o=(0,z.jsx)(`div`,{role:`alert`,className:a,...r,children:i.error}),t[5]=r,t[6]=i.error,t[7]=a,t[8]=o):o=t[8],o}function V2(e){let t=(0,G.c)(25),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let{activePopup:i,suggestions:a,actions:o}=KQ(`Composer.Popup`),{acceptSuggestion:s}=o;if(!i)return null;let c;t[3]===a?c=t[4]:(c=a.some(H2),t[3]=a,t[4]=c);let l=c,u;t[5]===n?u=t[6]:(u=I(`border-border bg-popover absolute inset-x-0 bottom-[calc(100%+0.5rem)] z-10 rounded-xl border shadow-lg`,n),t[5]=n,t[6]=u);let d;if(t[7]!==s||t[8]!==i||t[9]!==a||t[10]!==l){let e;t[12]!==s||t[13]!==i||t[14]!==l?(e=(e,t)=>(0,z.jsx)(U2,{selected:t===i.selectedIndex,icon:l?e.icon:null,token:m$(e),takesArgs:e.supportsArgs===!0,description:e.detail,onMouseDown:()=>s({index:t})},`item:${e.id}`),t[12]=s,t[13]=i,t[14]=l,t[15]=e):e=t[15],d=a.map(e),t[7]=s,t[8]=i,t[9]=a,t[10]=l,t[11]=d}else d=t[11];let f;t[16]===a.length?f=t[17]:(f=a.length===0?(0,z.jsx)(`div`,{className:`text-muted-foreground px-2 py-1 text-[13px] leading-4`,children:`no matches`}):null,t[16]=a.length,t[17]=f);let p;t[18]!==d||t[19]!==f?(p=(0,z.jsxs)(`div`,{className:`flex max-h-72 flex-col gap-1 overflow-y-auto p-1`,role:`listbox`,"aria-label":`Suggestions`,children:[d,f]}),t[18]=d,t[19]=f,t[20]=p):p=t[20];let m;return t[21]!==r||t[22]!==u||t[23]!==p?(m=(0,z.jsx)(`div`,{className:u,...r,children:p}),t[21]=r,t[22]=u,t[23]=p,t[24]=m):m=t[24],m}function H2(e){return e.icon}function U2(e){let t=(0,G.c)(23),{selected:n,icon:r,token:i,takesArgs:a,description:o,onMouseDown:s}=e,c=(0,R.useRef)(null),l,u;t[0]===n?(l=t[1],u=t[2]):(l=()=>{n&&c.current?.scrollIntoView({block:`nearest`})},u=[n],t[0]=n,t[1]=l,t[2]=u),(0,R.useEffect)(l,u);let d=n?`bg-accent text-foreground`:`text-foreground/80 hover:bg-accent/60`,f;t[3]===d?f=t[4]:(f=I(`flex w-full items-center gap-2 rounded-md px-2 py-1 text-start text-[13px] leading-4 [&_svg]:size-4 [&_svg]:shrink-0`,d),t[3]=d,t[4]=f);let p;t[5]===s?p=t[6]:(p=e=>{e.preventDefault(),s()},t[5]=s,t[6]=p);let m;t[7]===r?m=t[8]:(m=r===null?null:(0,z.jsx)(`span`,{className:`flex size-4 shrink-0 items-center justify-center`,children:r}),t[7]=r,t[8]=m);let h;t[9]===i?h=t[10]:(h=(0,z.jsx)(`span`,{className:`truncate`,children:i}),t[9]=i,t[10]=h);let g;t[11]===a?g=t[12]:(g=a?(0,z.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:`args`}):null,t[11]=a,t[12]=g);let _;t[13]===o?_=t[14]:(_=(0,z.jsx)(`span`,{className:`text-muted-foreground truncate`,children:o}),t[13]=o,t[14]=_);let v;return t[15]!==n||t[16]!==f||t[17]!==p||t[18]!==m||t[19]!==h||t[20]!==g||t[21]!==_?(v=(0,z.jsxs)(`button`,{ref:c,type:`button`,role:`option`,"aria-selected":n,className:f,onMouseDown:p,children:[m,h,g,_]}),t[15]=n,t[16]=f,t[17]=p,t[18]=m,t[19]=h,t[20]=g,t[21]=_,t[22]=v):v=t[22],v}var W2=[{title:`Send`,items:[[`Enter`,`send or queue`],[`Shift Enter`,`newline`],[`Alt Enter`,`newline`]]},{title:`Edit`,items:[[`Ctrl K`,`kill to end`],[`Ctrl U`,`kill to start`],[`Ctrl W`,`kill word`],[`Ctrl Y`,`yank`]]},{title:`Navigate`,items:[[`Ctrl P/N`,`history`],[`Ctrl R`,`reverse search`],[`Ctrl E`,`line end`],[`Alt B/F`,`word move`]]}];function G2(e){let t=(0,G.c)(13),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let{state:i,actions:a}=KQ(`Composer.Shortcuts`),{closeShortcuts:o}=a;if(!i.shortcutsOpen||!g$(i))return null;let s;t[3]===n?s=t[4]:(s=I(`border-border bg-popover border-t px-3 py-3 text-xs`,n),t[3]=n,t[4]=s);let c;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,z.jsx)(`div`,{className:`text-foreground font-medium`,children:`Keyboard shortcuts`}),t[5]=c):c=t[5];let l;t[6]===o?l=t[7]:(l=(0,z.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[c,(0,z.jsx)(`button`,{type:`button`,className:`text-muted-foreground hover:bg-muted hover:text-foreground rounded-sm px-2 py-1`,onClick:o,children:`close`})]}),t[6]=o,t[7]=l);let u;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,z.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:W2.map(K2)}),t[8]=u):u=t[8];let d;return t[9]!==r||t[10]!==s||t[11]!==l?(d=(0,z.jsxs)(`div`,{role:`dialog`,"aria-label":`Keyboard shortcuts`,className:s,...r,children:[l,u]}),t[9]=r,t[10]=s,t[11]=l,t[12]=d):d=t[12],d}function K2(e){return(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(`div`,{className:`text-muted-foreground text-[11px]`,children:e.title}),(0,z.jsx)(`div`,{className:`space-y-1`,children:e.items.map(q2)})]},e.title)}function q2(e){let[t,n]=e;return(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,z.jsx)(`kbd`,{className:`border-border bg-muted text-foreground rounded border px-1.5 py-0.5 font-[inherit]`,children:t}),(0,z.jsx)(`span`,{className:`text-muted-foreground text-right`,children:n})]},`${t}-${n}`)}function J2(e){let t=(0,G.c)(29),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let{activePopup:i,state:a}=KQ(`Composer.Footer`);if(a.reverseSearch!==null){let e;t[3]===n?e=t[4]:(e=I(`border-border text-muted-foreground flex items-center gap-2 border-t px-3 py-2 text-[11px]`,n),t[3]=n,t[4]=e);let i,o;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,z.jsx)(`kbd`,{className:`border-border bg-muted text-foreground rounded border px-1.5 py-0.5 font-[inherit]`,children:`Ctrl R`}),o=(0,z.jsx)(`span`,{children:`reverse-i-search:`}),t[5]=i,t[6]=o):(i=t[5],o=t[6]);let s=a.reverseSearch||`_`,c;t[7]===s?c=t[8]:(c=(0,z.jsx)(`span`,{className:`text-foreground`,children:s}),t[7]=s,t[8]=c);let l,u,d,f;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,z.jsx)(`span`,{children:`Ctrl R previous`}),u=(0,z.jsx)(`span`,{children:`Ctrl S next`}),d=(0,z.jsx)(`span`,{children:`Enter accept`}),f=(0,z.jsx)(`span`,{children:`Esc cancel`}),t[9]=l,t[10]=u,t[11]=d,t[12]=f):(l=t[9],u=t[10],d=t[11],f=t[12]);let p;return t[13]!==r||t[14]!==e||t[15]!==c?(p=(0,z.jsxs)(`div`,{className:e,...r,children:[i,o,c,l,u,d,f]}),t[13]=r,t[14]=e,t[15]=c,t[16]=p):p=t[16],p}let o;t[17]!==i||t[18]!==a.isTaskRunning||t[19]!==a.queueSubmissions?(o=i?[[`Enter`,`insert`],[`Tab`,`insert`],[`Esc`,`dismiss`]]:[[`Enter`,a.isTaskRunning||a.queueSubmissions?`queue`:`send`],[`Shift Enter`,`newline`],[`Alt Enter`,`newline`],[`Ctrl J/M`,`newline`],[`Ctrl P/N`,`history`],[`Ctrl E`,`line end`],[`Ctrl K`,`kill`],[`Ctrl U`,`kill back`],[`Ctrl W`,`word kill`],[`Alt B/F`,`word move`],[`Ctrl Y`,`yank`]],t[17]=i,t[18]=a.isTaskRunning,t[19]=a.queueSubmissions,t[20]=o):o=t[20];let s=o,c;t[21]===n?c=t[22]:(c=I(`border-border text-muted-foreground flex flex-wrap items-center gap-x-4 gap-y-1 border-t px-3 py-2 text-[11px]`,n),t[21]=n,t[22]=c);let l;t[23]===s?l=t[24]:(l=s.map(Y2),t[23]=s,t[24]=l);let u;return t[25]!==r||t[26]!==c||t[27]!==l?(u=(0,z.jsx)(`div`,{className:c,...r,children:l}),t[25]=r,t[26]=c,t[27]=l,t[28]=u):u=t[28],u}function Y2(e){let[t,n]=e;return(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,z.jsx)(`kbd`,{className:`border-border bg-muted text-foreground rounded border px-1.5 py-0.5 font-[inherit]`,children:t}),n]},`${t}-${n}`)}function X2(e){let t=(0,G.c)(19),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({accept:i,multiple:a,disabled:n,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=i===void 0?`image/*,video/*,audio/*`:i,s=a===void 0||a,{actions:c,disabled:l}=KQ(`Composer.AttachFiles`),u=(0,R.useRef)(null),d;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>u.current?.click(),t[5]=d):d=t[5];let f;t[6]!==n||t[7]!==r?(f=(0,z.jsx)(n4,{action:d,disabled:n,...r}),t[6]=n,t[7]=r,t[8]=f):f=t[8];let p=l||n,m;t[9]===c?m=t[10]:(m=e=>{let t=e.currentTarget;t.files&&c.attachImageFiles(t.files),t.value=``},t[9]=c,t[10]=m);let h;t[11]!==o||t[12]!==s||t[13]!==p||t[14]!==m?(h=(0,z.jsx)(`input`,{ref:u,type:`file`,accept:o,multiple:s,"aria-label":`Attach media files`,hidden:!0,disabled:p,onChange:m}),t[11]=o,t[12]=s,t[13]=p,t[14]=m,t[15]=h):h=t[15];let g;return t[16]!==f||t[17]!==h?(g=(0,z.jsxs)(z.Fragment,{children:[f,h]}),t[16]=f,t[17]=h,t[18]=g):g=t[18],g}function Z2(e){let t=(0,G.c)(9),n,r;t[0]===e?(n=t[1],r=t[2]):({url:r,...n}=e,t[0]=e,t[1]=n,t[2]=r);let{actions:i}=KQ(`Composer.AddRemoteImage`),a;t[3]!==i||t[4]!==r?(a=()=>i.addRemoteImage(r),t[3]=i,t[4]=r,t[5]=a):a=t[5];let o;return t[6]!==n||t[7]!==a?(o=(0,z.jsx)(n4,{action:a,...n}),t[6]=n,t[7]=a,t[8]=o):o=t[8],o}function Q2(e){let t=(0,G.c)(9),n,r;t[0]===e?(n=t[1],r=t[2]):({content:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let{actions:i}=KQ(`Composer.InsertPaste`),a;t[3]!==i||t[4]!==n?(a=()=>i.insertPaste(n),t[3]=i,t[4]=n,t[5]=a):a=t[5];let o;return t[6]!==r||t[7]!==a?(o=(0,z.jsx)(n4,{action:a,...r}),t[6]=r,t[7]=a,t[8]=o):o=t[8],o}function $2(e){let t=(0,G.c)(13),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({href:n,label:r,metadata:i,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let{actions:o}=KQ(`Composer.InsertRichLink`),s;t[5]!==o||t[6]!==n||t[7]!==r||t[8]!==i?(s=()=>o.insertRichLink(n,r,i),t[5]=o,t[6]=n,t[7]=r,t[8]=i,t[9]=s):s=t[9];let c;return t[10]!==a||t[11]!==s?(c=(0,z.jsx)(n4,{action:s,...a}),t[10]=a,t[11]=s,t[12]=c):c=t[12],c}function e4(e){let t=(0,G.c)(3),{actions:n}=KQ(`Composer.Submit`),r;return t[0]!==n.submit||t[1]!==e?(r=(0,z.jsx)(n4,{action:n.submit,...e}),t[0]=n.submit,t[1]=e,t[2]=r):r=t[2],r}function t4(e){let t=(0,G.c)(3),{actions:n}=KQ(`Composer.Reset`),r;return t[0]!==n.reset||t[1]!==e?(r=(0,z.jsx)(n4,{action:n.reset,...e}),t[0]=n.reset,t[1]=e,t[2]=r):r=t[2],r}function n4(e){let t=(0,G.c)(12),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({action:n,onClick:i,disabled:r,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let{disabled:o}=KQ(`Composer.ActionTrigger`),s=o||r,c;t[5]!==n||t[6]!==i?(c=e=>{i?.(e),e.defaultPrevented||n()},t[5]=n,t[6]=i,t[7]=c):c=t[7];let l;return t[8]!==a||t[9]!==s||t[10]!==c?(l=(0,z.jsx)(y,{...a,disabled:s,onClick:c}),t[8]=a,t[9]=s,t[10]=c,t[11]=l):l=t[11],l}function r4(e){if(e.metaKey)return!1;if(e.key===`Enter`)return e.altKey&&!e.ctrlKey;let t=e.key.toLowerCase();return e.ctrlKey&&!e.altKey&&(t===`j`||t===`m`)}function i4(e){if(e.metaKey)return!1;if(e.key===`Backspace`)return e.ctrlKey||e.altKey;let t=e.key.toLowerCase();return e.ctrlKey&&!e.altKey&&t===`w`||e.ctrlKey&&e.altKey&&t===`h`}function a4(e){if(e.metaKey||e.shiftKey)return null;if(e.key===`ArrowLeft`&&(e.altKey||e.ctrlKey))return-1;if(e.key===`ArrowRight`&&(e.altKey||e.ctrlKey))return 1;if(!e.altKey||e.ctrlKey)return null;let t=e.key.toLowerCase();return t===`b`?-1:t===`f`?1:null}function o4(e){if(e.key===`ArrowUp`)return-1;if(e.key===`ArrowDown`)return 1;if(e.metaKey||e.altKey||e.shiftKey||!e.ctrlKey)return null;let t=e.key.toLowerCase();return t===`p`?-1:t===`n`?1:null}function s4(e){let{doc:t,selection:n}=e.state;return n.empty||n.from>1||n.to<t.content.size-1?!1:(e.commands.setContent(A0(),{emitUpdate:!0}),e.commands.focus(`start`),e.commands.setTextSelection(1),!0)}var c4={Root:j2,Trigger:L1,Command:R1,Mention:z1,Content:F2,Toolbar:I2,RemoteImages:L2,Attachments:JQ,Editor:z2,Error:B2,Popup:V2,Shortcuts:G2,Footer:J2,AttachFiles:X2,AddRemoteImage:Z2,InsertPaste:Q2,InsertRichLink:$2,Dictate:$1,CancelDictation:e0,Submit:e4,Reset:t4};(0,R.createContext)(null);function l4(e,t){if(!t||t.isCollapsed||t.rangeCount===0)return null;let n=t.getRangeAt(0);if(!e.contains(n.commonAncestorContainer))return null;let r=n.cloneContents();for(let e of r.querySelectorAll(`[data-persisted-source]`)){let t=e.getAttribute(`data-persisted-source`);t!==null&&e.replaceWith(t)}return r.textContent??``}function u4(e){let t=(0,G.c)(6),{text:n}=e,r,i;if(t[0]!==n){let e=sN(n);r=p4,i=e.map(d4),t[0]=n,t[1]=r,t[2]=i}else r=t[1],i=t[2];let a;return t[3]!==r||t[4]!==i?(a=(0,z.jsx)(`span`,{onCopy:r,children:i}),t[3]=r,t[4]=i,t[5]=a):a=t[5],a}function d4(e){switch(e.kind){case`text`:return e.value;case`inline-code`:return(0,z.jsx)(`code`,{"data-persisted-source":e.source,className:`bg-muted rounded px-1 py-0.5 font-mono text-[0.9em]`,children:e.value},e.start);case`code-block`:return(0,z.jsx)(`span`,{"data-persisted-source":e.source,className:`bg-muted my-2 block overflow-x-auto rounded-md px-3 py-2`,children:(0,z.jsx)(`code`,{className:`font-mono text-[0.9em]`,children:e.value})},e.start);case`skill-link`:return(0,z.jsx)(f4,{name:e.name,source:e.source,skillId:e.skillId,title:e.href},e.start);case`standalone-skill`:return(0,z.jsx)(f4,{name:e.name,source:e.source},e.start);case`mention`:return(0,z.jsx)(`span`,{"data-token":`mention`,"data-persisted-source":e.source,className:`bg-foreground/10 rounded-sm px-0.5 font-medium`,children:e.label},e.start);case`link`:return/^(?:https?:|mailto:)/.test(e.href)?(0,z.jsx)(`a`,{href:e.href,"data-persisted-source":e.source,className:`text-primary underline underline-offset-2`,target:`_blank`,rel:`noreferrer`,children:e.label},e.start):e.source}}function f4(e){let t=(0,G.c)(9),{name:n,source:r,skillId:i,title:a}=e,o=i?void 0:n,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,z.jsx)(_i,{"aria-hidden":`true`,className:`size-3.5 self-center`}),t[0]=s):s=t[0];let c;t[1]===n?c=t[2]:(c=(0,z.jsx)(`span`,{children:n}),t[1]=n,t[2]=c);let l;return t[3]!==i||t[4]!==r||t[5]!==o||t[6]!==c||t[7]!==a?(l=(0,z.jsxs)(`span`,{"data-skill-id":i,"data-skill-name":o,"data-persisted-source":r,title:a,className:`text-primary inline-flex items-baseline gap-1`,children:[s,c]}),t[3]=i,t[4]=r,t[5]=o,t[6]=c,t[7]=a,t[8]=l):l=t[8],l}function p4(e){let t=l4(e.currentTarget,window.getSelection());t!==null&&(e.clipboardData.setData(`text/plain`,t),e.preventDefault())}var m4=typeof global==`object`&&global&&global.Object===Object&&global,h4=typeof self==`object`&&self&&self.Object===Object&&self,g4=m4||h4||Function(`return this`)(),_4=g4.Symbol,v4=Object.prototype,y4=v4.hasOwnProperty,b4=v4.toString,x4=_4?_4.toStringTag:void 0;function S4(e){var t=y4.call(e,x4),n=e[x4];try{e[x4]=void 0;var r=!0}catch{}var i=b4.call(e);return r&&(t?e[x4]=n:delete e[x4]),i}var C4=Object.prototype.toString;function w4(e){return C4.call(e)}var T4=`[object Null]`,E4=`[object Undefined]`,D4=_4?_4.toStringTag:void 0;function O4(e){return e==null?e===void 0?E4:T4:D4&&D4 in Object(e)?S4(e):w4(e)}function k4(e){return typeof e==`object`&&!!e}var A4=`[object Symbol]`;function j4(e){return typeof e==`symbol`||k4(e)&&O4(e)==A4}function M4(e,t){for(var n=-1,r=e==null?0:e.length,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i}var N4=Array.isArray,P4=1/0,F4=_4?_4.prototype:void 0,I4=F4?F4.toString:void 0;function L4(e){if(typeof e==`string`)return e;if(N4(e))return M4(e,L4)+``;if(j4(e))return I4?I4.call(e):``;var t=e+``;return t==`0`&&1/e==-P4?`-0`:t}function R4(e){var t=typeof e;return e!=null&&(t==`object`||t==`function`)}var z4=`[object AsyncFunction]`,B4=`[object Function]`,V4=`[object GeneratorFunction]`,H4=`[object Proxy]`;function U4(e){if(!R4(e))return!1;var t=O4(e);return t==B4||t==V4||t==z4||t==H4}var W4=g4[`__core-js_shared__`],G4=function(){var e=/[^.]+$/.exec(W4&&W4.keys&&W4.keys.IE_PROTO||``);return e?`Symbol(src)_1.`+e:``}();function K4(e){return!!G4&&G4 in e}var q4=Function.prototype.toString;function J4(e){if(e!=null){try{return q4.call(e)}catch{}try{return e+``}catch{}}return``}var Y4=/[\\^$.*+?()[\]{}|]/g,X4=/^\[object .+?Constructor\]$/,Z4=Function.prototype,Q4=Object.prototype,$4=Z4.toString,e3=Q4.hasOwnProperty,t3=RegExp(`^`+$4.call(e3).replace(Y4,`\\$&`).replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,`$1.*?`)+`$`);function n3(e){return!R4(e)||K4(e)?!1:(U4(e)?t3:X4).test(J4(e))}function r3(e,t){return e?.[t]}function i3(e,t){var n=r3(e,t);return n3(n)?n:void 0}function a3(e,t){return e===t||e!==e&&t!==t}var o3=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,s3=/^\w*$/;function c3(e,t){if(N4(e))return!1;var n=typeof e;return n==`number`||n==`symbol`||n==`boolean`||e==null||j4(e)?!0:s3.test(e)||!o3.test(e)||t!=null&&e in Object(t)}var l3=i3(Object,`create`);function u3(){this.__data__=l3?l3(null):{},this.size=0}function d3(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=+!!t,t}var f3=`__lodash_hash_undefined__`,p3=Object.prototype.hasOwnProperty;function m3(e){var t=this.__data__;if(l3){var n=t[e];return n===f3?void 0:n}return p3.call(t,e)?t[e]:void 0}var h3=Object.prototype.hasOwnProperty;function g3(e){var t=this.__data__;return l3?t[e]!==void 0:h3.call(t,e)}var _3=`__lodash_hash_undefined__`;function v3(e,t){var n=this.__data__;return this.size+=+!this.has(e),n[e]=l3&&t===void 0?_3:t,this}function y3(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}y3.prototype.clear=u3,y3.prototype.delete=d3,y3.prototype.get=m3,y3.prototype.has=g3,y3.prototype.set=v3;function b3(){this.__data__=[],this.size=0}function x3(e,t){for(var n=e.length;n--;)if(a3(e[n][0],t))return n;return-1}var S3=Array.prototype.splice;function C3(e){var t=this.__data__,n=x3(t,e);return n<0?!1:(n==t.length-1?t.pop():S3.call(t,n,1),--this.size,!0)}function w3(e){var t=this.__data__,n=x3(t,e);return n<0?void 0:t[n][1]}function T3(e){return x3(this.__data__,e)>-1}function E3(e,t){var n=this.__data__,r=x3(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}function D3(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}D3.prototype.clear=b3,D3.prototype.delete=C3,D3.prototype.get=w3,D3.prototype.has=T3,D3.prototype.set=E3;var O3=i3(g4,`Map`);function k3(){this.size=0,this.__data__={hash:new y3,map:new(O3||D3),string:new y3}}function A3(e){var t=typeof e;return t==`string`||t==`number`||t==`symbol`||t==`boolean`?e!==`__proto__`:e===null}function j3(e,t){var n=e.__data__;return A3(t)?n[typeof t==`string`?`string`:`hash`]:n.map}function M3(e){var t=j3(this,e).delete(e);return this.size-=+!!t,t}function N3(e){return j3(this,e).get(e)}function P3(e){return j3(this,e).has(e)}function F3(e,t){var n=j3(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}function I3(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}I3.prototype.clear=k3,I3.prototype.delete=M3,I3.prototype.get=N3,I3.prototype.has=P3,I3.prototype.set=F3;var L3=`Expected a function`;function R3(e,t){if(typeof e!=`function`||t!=null&&typeof t!=`function`)throw TypeError(L3);var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],a=n.cache;if(a.has(i))return a.get(i);var o=e.apply(this,r);return n.cache=a.set(i,o)||a,o};return n.cache=new(R3.Cache||I3),n}R3.Cache=I3;var z3=500;function B3(e){var t=R3(e,function(e){return n.size===z3&&n.clear(),e}),n=t.cache;return t}var V3=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,H3=/\\(\\)?/g,U3=B3(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(``),e.replace(V3,function(e,n,r,i){t.push(r?i.replace(H3,`$1`):n||e)}),t});function W3(e){return e==null?``:L4(e)}function G3(e,t){return N4(e)?e:c3(e,t)?[e]:U3(W3(e))}var K3=1/0;function q3(e){if(typeof e==`string`||j4(e))return e;var t=e+``;return t==`0`&&1/e==-K3?`-0`:t}function J3(e,t){t=G3(t,e);for(var n=0,r=t.length;e!=null&&n<r;)e=e[q3(t[n++])];return n&&n==r?e:void 0}function Y3(e,t,n){var r=e==null?void 0:J3(e,t);return r===void 0?n:r}function X3(e){if(!e)return{};let t={...e};return delete t.whenNullish,delete t.locale,t}function Z3(e,t){return e==null||Number.isNaN(e)?t?.whenNullish??`—`:new Intl.NumberFormat(t?.locale??`en-US`,X3(t)).format(e)}var Q3=Z3;function $3(e,t){return Z3(e,{notation:`compact`,maximumFractionDigits:1,...t})}var e6=`pending-chat-prefill`;function t6(){try{let e=sessionStorage.getItem(e6);return e?JSON.parse(e):null}catch{return sessionStorage.removeItem(e6),null}}function n6(e){sessionStorage.setItem(e6,JSON.stringify(e))}function r6(){sessionStorage.removeItem(e6)}function i6(e){let t=Yh(e.metadata)?e.metadata.persistedPrompt:void 0;if(typeof t!=`string`)throw Error(`Message ${e.id} has no persistedPrompt: send it with useAgent().submit.`);return t}var a6=class{chat;uploadFile;submissions=new ry;onResetChat;constructor(e){this.chat=e.chat,this.uploadFile=e.uploadFile,this.onResetChat=e.onResetChat}bind(e){this.chat=e}initialize(e){let t=new AbortController;return queueMicrotask(()=>{t.signal.aborted||this.consumePrefill(e)}),()=>t.abort()}submit(e){this.chat.clearError();let{files:t=[],...n}=e,r=this.chat.id;return this.submissions.run(async()=>{if(t.length===0){this.assertCurrentChat(r),this.send(n);return}let e=await this.uploadFiles(r,t);this.assertCurrentChat(r),this.send({...n,metadata:{...n.metadata,uploads:e}})})}async uploadFiles(e,t){return Promise.all(t.map(t=>this.uploadFile(e,t)))}assertCurrentChat(e){if(this.chat.id!==e)throw Error(`The chat changed before the submission was sent.`)}send({prompt:e,persistedPrompt:t,metadata:n}){this.chat.sendMessage({role:`user`,parts:[{type:`text`,text:e}],metadata:{...n,persistedPrompt:t}})}clearChat(){for(let{id:e}of this.chat.experimental_queuedMessages)this.chat.experimental_removeQueuedMessage(e);this.chat.setMessages([])}setChat(e){this.chat.setMessages(e)}stop(){this.chat.stop()}resetChat(e){let t=crypto.randomUUID();e&&n6({prompt:e,targetChatId:t}),this.onResetChat(t)}consumePrefill(e){let t=t6();!t||t.targetChatId!==e||(r6(),this.submit({prompt:t.prompt,persistedPrompt:t.prompt}))}getTriggeringUserMessage(e){let{messages:t}=this.chat,n=t.findIndex(t=>t.role===`assistant`&&t.parts.some(t=>`toolCallId`in t&&t.toolCallId===e));if(n<=0)return null;let r=t[n-1];return r?.role===`user`?r:null}getLastUserMessageId(){let{messages:e}=this.chat;for(let t=e.length-1;t>=0;t--)if(e[t].role===`user`)return e[t].id;return null}getLastAssistantMessage(){let{messages:e}=this.chat;for(let t=e.length-1;t>=0;t--)if(e[t].role===`assistant`)return e[t];return null}get hasSubmitted(){return this.chat.messages.length>0}};async function o6(e,t,n){let r=t?.[n.toolName];n.toolName.startsWith(`render`)&&r?.static===!1&&r.requiresUserInput!==!0&&await e.addToolOutput({toolCallId:n.toolCallId,tool:n.toolName,output:`rendered`,state:`output-available`})}function s6(e){let t=Vy({id:e.chatId,messages:e.initialMessages,transport:e.transport,throttle:50,experimental_queue:!0,resume:e.resume,onData:e.onData,onFinish:e.onFinish,sendAutomaticallyWhen:c6,onToolCall(n){let{toolCall:r}=n;o6(t,e.registry,r)}});return t}function c6(e){return Ay(e)||ky(e)}function l6(e){let t=(0,G.c)(2),n;return t[0]===e?n=t[1]:(n=(0,z.jsx)(u6,{...e}),t[0]=e,t[1]=n),n}function u6(e){let t=(0,G.c)(13),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n={initial:`smooth`},t[0]=n):n=t[0];let{scrollRef:r,contentRef:i}=jj(n),{hasSubmitted:a}=w6(),o;t[1]===e.className?o=t[2]:(o=I(`@container mx-auto h-full w-full overflow-y-auto`,e.className),t[1]=e.className,t[2]=o);let s=a?`min-h-full`:`h-full justify-center`,c;t[3]===s?c=t[4]:(c=I(`relative mx-auto flex w-full flex-col`,s),t[3]=s,t[4]=c);let l;t[5]!==i||t[6]!==e.children||t[7]!==c?(l=(0,z.jsx)(`div`,{ref:i,"data-slot":`content`,className:c,children:e.children}),t[5]=i,t[6]=e.children,t[7]=c,t[8]=l):l=t[8];let u;return t[9]!==r||t[10]!==o||t[11]!==l?(u=(0,z.jsx)(`div`,{id:`agent`,"data-slot":`agent`,className:o,ref:r,children:l}),t[9]=r,t[10]=o,t[11]=l,t[12]=u):u=t[12],u}function d6(e){let t=(0,G.c)(12),{hasSubmitted:n}=w6(),r;t[0]!==n||t[1]!==e.className?(r=I(n?I(`bg-background sticky top-0 z-10 shrink-0 space-y-1 backdrop-blur-md`,e.className):`relative flex justify-center py-4`),t[0]=n,t[1]=e.className,t[2]=r):r=t[2];let i;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(i={layout:{type:`tween`,ease:[.4,0,.2,1],duration:.4}},t[3]=i):i=t[3];let a=n?`text-left`:`space-y-3 text-center`,o;t[4]===a?o=t[5]:(o=I(a),t[4]=a,t[5]=o);let s;t[6]!==e.children||t[7]!==o?(s=(0,z.jsx)(`div`,{className:o,children:e.children}),t[6]=e.children,t[7]=o,t[8]=s):s=t[8];let c;return t[9]!==r||t[10]!==s?(c=(0,z.jsx)(Tj.div,{layout:!0,className:r,transition:i,children:s}),t[9]=r,t[10]=s,t[11]=c):c=t[11],c}d6.displayName=`AgentHeader.Root`;function f6(e){let t=(0,G.c)(6),{hasSubmitted:n}=w6(),r;t[0]!==n||t[1]!==e.children||t[2]!==e.icon?(r=!n&&(0,z.jsx)(Tj.div,{exit:{opacity:0},transition:{duration:.2},children:(0,z.jsxs)(`h1`,{className:`flex items-center justify-center gap-2 text-2xl font-medium tracking-tight`,children:[e.icon,e.children??`How can I help today?`]})},`agent-header-initial`),t[0]=n,t[1]=e.children,t[2]=e.icon,t[3]=r):r=t[3];let i;return t[4]===r?i=t[5]:(i=(0,z.jsx)(jk,{mode:`sync`,children:r}),t[4]=r,t[5]=i),i}f6.displayName=`AgentHeader.Hero`;function p6(e){let t=(0,G.c)(2),n;return t[0]===e.children?n=t[1]:(n=(0,z.jsx)(Tj.h2,{layout:`position`,className:`text-muted-foreground text-sm font-medium`,children:e.children}),t[0]=e.children,t[1]=n),n}p6.displayName=`AgentHeader.Title`;function m6(e){let t=(0,G.c)(5),{hasSubmitted:n}=w6(),r;t[0]!==n||t[1]!==e.children?(r=n&&!!e.children&&(0,z.jsx)(Tj.p,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.25},className:`text-muted-foreground text-sm`,children:e.children}),t[0]=n,t[1]=e.children,t[2]=r):r=t[2];let i;return t[3]===r?i=t[4]:(i=(0,z.jsx)(jk,{children:r}),t[3]=r,t[4]=i),i}m6.displayName=`AgentHeader.Description`;var h6={Root:d6,Hero:f6,Title:p6,Description:m6},g6=(0,R.createContext)(void 0),_6=(0,R.createContext)(`ready`),v6=(0,R.createContext)(void 0),y6=(0,R.createContext)(null),b6=(0,R.createContext)(void 0);function x6({chatId:e,children:t,skipInitialView:n,debugMode:r,registry:i,initialMessages:a,transport:o,resume:s,onData:c,onFinish:l,onResetChat:u}){let d=s6({chatId:e,transport:o,registry:i,initialMessages:a,resume:s,onData:c,onFinish:l}),[f,p]=(0,R.useState)(r),m=(0,R.useCallback)(()=>p(e=>!e),[]),h=(0,R.useRef)(u);(0,R.useEffect)(()=>{h.current=u},[u]);let g=(0,R.useCallback)(e=>{h.current(e)},[]),[_]=(0,R.useState)(()=>new a6({chat:d,uploadFile:o.uploadFile.bind(o),onResetChat:g}));_.bind(d),(0,R.useEffect)(()=>_.initialize(e),[_,e]);let v=(0,R.useMemo)(()=>({clearChat:()=>_.clearChat(),resetChat:e=>_.resetChat(e),submit:e=>_.submit(e),setChat:e=>_.setChat(e),getTriggeringUserMessage:e=>_.getTriggeringUserMessage(e),getLastUserMessageId:()=>_.getLastUserMessageId(),stop:()=>_.stop()}),[_]),y=(0,R.useMemo)(()=>({chatId:e,registry:i,debugMode:f,toggleDebugMode:m,...v}),[e,i,f,m,v]),b=(0,R.useMemo)(()=>d,[d.id,d.messages,d.status,d.error,d.experimental_queuedMessages]),x=!!n||d.messages.length>0,S=(0,R.useMemo)(()=>({hasSubmitted:x}),[x]);return(0,z.jsx)(y6,{value:_,children:(0,z.jsx)(g6,{value:y,children:(0,z.jsx)(_6,{value:d.status,children:(0,z.jsx)(v6,{value:b,children:(0,z.jsx)(b6,{value:S,children:t})})})})})}function S6(){let e=(0,R.use)(g6);if(e===void 0)throw Error(`useAgent must be used within an AgentProvider`);return e}function C6(){return{status:(0,R.use)(_6)}}function w6(){let e=(0,R.use)(b6);if(e===void 0)throw Error(`useAgentMeta must be used within an AgentProvider`);return e}function T6(){let e=(0,R.use)(v6);if(e===void 0)throw Error(`useAgentMessages must be used within an AgentProvider`);return e}function E6(e,t){return t.map((t,n)=>({citation:t,order:n,at:t.endIndex??e.length})).sort((e,t)=>e.at-t.at||e.order-t.order)}function D6(e){return(e??[]).filter(e=>e.source.sourceType===`url`)}function O6(e){let t=new Set(e.parts.flatMap(e=>e.type===`text`?D6(e.citations).map(({source:e})=>e.url):[])),n=new Map,r=(e,t)=>{n.has(e)||n.set(e,{url:e,title:t})};for(let n of e.parts){if(n.type===`text`)for(let{citation:e}of E6(n.text,D6(n.citations)))r(e.source.url,e.source.title);n.type===`source-url`&&!t.has(n.url)&&r(n.url,n.title)}return[...n.values()]}function k6(e,t){let n=e.findIndex(e=>e.url===t);return n===-1?null:n+1}function A6(e,t){return t===`streaming`||t===`submitted`?!1:e===`input-streaming`||e===`input-available`}function j6(e,t){return A6(e.state,t)}function M6(e){return Object.entries(e).reduce((e,[t,n])=>(n.static||(e[t]={inputSchema:Le(n.inputSchema,{io:`input`,unrepresentable:`any`}),description:n.description}),e),{})}function N6(e){let t=(0,G.c)(11),{children:n,as:r,className:i,duration:a,enabled:o}=e,s=r===void 0?`p`:r,c=o===void 0||o,l=c&&`shimmer`,u;t[0]!==i||t[1]!==l?(u=I(l,i),t[0]=i,t[1]=l,t[2]=u):u=t[2];let d;t[3]!==a||t[4]!==c?(d=c&&a!==void 0?{animationDuration:`${a}s`}:void 0,t[3]=a,t[4]=c,t[5]=d):d=t[5];let f;return t[6]!==s||t[7]!==n||t[8]!==u||t[9]!==d?(f=(0,z.jsx)(s,{className:u,style:d,children:n}),t[6]=s,t[7]=n,t[8]=u,t[9]=d,t[10]=f):f=t[10],f}function P6(e){let t=(0,G.c)(4),{className:n}=e,r;t[0]===n?r=t[1]:(r=I(`size-3.5 shrink-0 transition-transform group-data-[panel-open]:rotate-90`,n),t[0]=n,t[1]=r);let i;return t[2]===r?i=t[3]:(i=(0,z.jsx)(Ct,{"aria-hidden":!0,className:r}),t[2]=r,t[3]=i),i}function F6(e){return I(`group hover:bg-muted/30 flex min-h-7 w-full gap-2 rounded-sm py-1 text-left transition-colors`,e)}(0,R.createContext)(null);var I6=(0,R.createContext)(void 0),L6=(0,R.createContext)(void 0);function R6(){let e=(0,R.use)(I6);if(!e)throw Error(`useMessagesContext must be used within <Messages>`);return e}function z6(){let e=(0,R.use)(I6),{status:t}=C6();return e?.status??t}function B6(){let e=(0,R.use)(L6);if(!e)throw Error(`useMessageItem must be used within <Messages.Item>`);return e}function V6({source:e,index:t,labels:n={source:`Source ${t}`,open:`Open the source`},children:r}){let i=URL.parse(e.url)?.hostname??e.url;return(0,z.jsx)(`sup`,{className:`ml-0.5 inline-block`,children:(0,z.jsxs)(Po,{children:[(0,z.jsx)(Fo,{openOnHover:!0,"aria-label":n.source,className:`text-primary bg-primary/10 hover:bg-primary/20 focus-visible:ring-ring focus-visible:ring-offset-background inline-block rounded px-1 font-mono text-[10px] leading-tight transition-colors focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:outline-none`,children:t}),(0,z.jsxs)(Io,{className:`w-72 gap-2 text-sm`,children:[(0,z.jsxs)(Lo,{children:[(0,z.jsx)(Ro,{dir:`auto`,title:e.title??i,className:`truncate`,children:e.title??i}),e.title?(0,z.jsx)(zo,{dir:`auto`,title:i,className:`truncate`,children:i}):null]}),r,(0,z.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`text-primary underline`,children:n.open})]})]})})}function H6(e){let t=(0,G.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({ref:i,className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===n?a=t[5]:(a=I(`border-border bg-background relative min-w-0 gap-0 overflow-visible rounded-md border py-0 text-sm/normal ring-0`,n),t[4]=n,t[5]=a);let o;return t[6]!==r||t[7]!==i||t[8]!==a?(o=(0,z.jsx)(Qi,{ref:i,"data-slot":`table-panel`,size:`default`,className:a,...r}),t[6]=r,t[7]=i,t[8]=a,t[9]=o):o=t[9],o}H6.displayName=`TablePanel.Root`;function U6(e){let t=(0,G.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=I(`border-border flex items-center justify-between gap-4 border-b px-4 py-3`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,z.jsx)($i,{"data-slot":`table-panel-header`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function W6(e){let t=(0,G.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=I(`min-w-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,z.jsx)(`div`,{"data-slot":`table-panel-heading`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function G6(e){let t=(0,G.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=I(`text-base font-medium text-balance wrap-anywhere`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,z.jsx)(ea,{"data-slot":`table-panel-title`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function K6(e){let t=(0,G.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=I(`text-muted-foreground text-xs text-pretty wrap-anywhere`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,z.jsx)(ta,{"data-slot":`table-panel-description`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function q6(e){let t=(0,G.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=I(`flex shrink-0 items-center gap-1`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,z.jsx)(na,{"data-slot":`table-panel-actions`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function J6(e){let t=(0,G.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=I(`min-w-0 flex-1 overflow-auto rounded-b-[inherit] p-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,z.jsx)(ra,{"data-slot":`table-panel-content`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var Y6=Object.assign(H6,{Header:U6,Heading:W6,Title:G6,Description:K6,Actions:q6,Content:J6}),X6=/<\w[\w-]*(?:"(?:\\.|[^"])*"|[^>"])*>/g,Z6=/\b([\w-]+)="((?:\\.|[^"])*)"/g;function Q6(e){return e.replace(X6,e=>e.replace(Z6,(e,t,n)=>`${t}="${n.replace(/\\"/g,`"`)}"`))}function $6(e,t){if(typeof e!=`string`)return e;let n=Q6(o8(e,n8(t))).replace(/<(\w[\w-]*)((?:\s+[\w-]+="[^"]*")+)\s*(\/?>)/g,(e,t,n,r)=>`<${t}${n.replace(/\s+/g,` `)}${r}`);return n=n.replace(/\/>(\s*)</g,(e,t,n,r)=>!t.includes(`
|
|
327
327
|
`)&&t8(r,n)?e:`/>
|
|
328
328
|
|
|
329
329
|
<`),s8(n,t)}var e8=/<\w[\w-]*(?:"(?:\\.|[^"])*"|[^>"])*>|<\/[\w-]+\s*>/g;function t8(e,t){let n=e.lastIndexOf(`
|
|
@@ -344,14 +344,15 @@ img.ProseMirror-separator {
|
|
|
344
344
|
`)?e+`
|
|
345
345
|
`:e+`
|
|
346
346
|
|
|
347
|
-
`}var d8=`response-table-panel`,f8=[`title`,`description`],p8=I(qe({variant:`ghost`,size:`icon-sm`})),m8=Fr().use(Ur).use(Vr).use(tN),h8=e=>{let t=Nr(e),n=v8(e);if(n.length===0)return t;let r=0,i=t.map(e=>{let t={start:r,end:r+e.length};return r=t.end,t}),a=new Set;for(let e of n){let t=!1;for(let[n,r]of i.entries())r.start<e.end&&r.end>e.start&&(t&&a.add(n),t=!0)}return t.reduce((e,t,n)=>(a.has(n)&&e.length>0?e[e.length-1]+=t:e.push(t),e),[])};function g8(e){return e?.type===`leafDirective`&&`name`in e&&e.name===`table`}function _8(e,t){if(t===void 0)return;let n=e[t-1];return g8(n)?n:void 0}function v8(e){let t=[];return kr(m8.parse(e),`table`,(e,n,r)=>{if(!r)return;let i=_8(r.children,n)?.position?.start.offset,a=e.position?.end.offset;i!==void 0&&a!==void 0&&t.push({start:i,end:a})}),t}function y8(e,t){return e.attributes?.[t]?.trim()||void 0}function b8(e){let t=m8.parse(e),n=!1;if(kr(t,`leafDirective`,(e,t,r)=>{let i=t===void 0?void 0:r?.children[t+1];if(e.name!==`table`||i?.type!==`table`)return;n=!0;let a=[y8(e,`title`),y8(e,`description`)].filter(Boolean).join(` `);e.children=a?[{type:`text`,value:a}]:[]}),n)return Hr(Ar(t,{includeHtml:!1}))}function x8(e){let t=(0,G.c)(2),n;return t[0]===e?n=t[1]:(n=(0,z.jsx)(Pr,{...e}),t[0]=e,t[1]=n),n}function S8(e){function t(t){let n=(0,G.c)(6),r;n[0]!==t.content||n[1]!==t.dir?(r=b8(t.content)??t.dir,n[0]=t.content,n[1]=t.dir,n[2]=r):r=n[2];let i=r,a;return n[3]!==i||n[4]!==t?(a=(0,z.jsx)(e,{...t,dir:i}),n[3]=i,n[4]=t,n[5]=a):a=n[5],a}return t.displayName=`DirectionAwareTableBlock`,t}function C8(e,t){let n=t&&y8(t,`title`),r=t&&y8(t,`description`),i={...n?{title:n}:{},...r?{description:r}:{}};return{type:`tablePanel`,data:{hName:d8,...Object.keys(i).length>0?{hProperties:i}:{}},children:[e]}}function w8(){return e=>{kr(e,`table`,(e,t,n)=>{if(t===void 0||!n)return;let r=_8(n.children,t),i=r?t-1:t,a=r?2:1;return n.children.splice(i,a,C8(e,r)),[xr,i+1]})}}var T8=[...Object.values(Br),tN,w8],E8=R.createContext({actions:null,controls:!0});function D8(e,t){if(e===!1)return!1;if(e===!0||e===void 0)return!0;let n=e.table;return n===!1?!1:n===!0||n===void 0||n[t]!==!1}function O8(e){return e===!1?!1:e===!0||e===void 0?{table:!1}:{...e,table:!1}}function k8(e){let t=(0,G.c)(21),{children:n,className:r,title:i,description:a}=e,{actions:o,controls:s}=R.use(E8),c;t[0]===s?c=t[1]:(c=D8(s,`copy`),t[0]=s,t[1]=c);let l=c,u;t[2]===s?u=t[3]:(u=D8(s,`download`),t[2]=s,t[3]=u);let d=u,f=!!(i||a),p=!!(l||d||o);if(!n)return null;let m;t[4]===r?m=t[5]:(m=I(`my-4`,r),t[4]=r,t[5]=m);let h;t[6]!==o||t[7]!==a||t[8]!==p||t[9]!==f||t[10]!==l||t[11]!==d||t[12]!==i?(h=(f||p)&&(0,z.jsxs)(Y6.Header,{className:I(!f&&`justify-end`),children:[f&&(0,z.jsxs)(Y6.Heading,{children:[i&&(0,z.jsx)(Y6.Title,{children:i}),a&&(0,z.jsx)(Y6.Description,{className:I(i&&`mt-1`),children:a})]}),p&&(0,z.jsxs)(Y6.Actions,{"data-copy-exclude":`assistant-snapshot`,children:[l&&(0,z.jsx)(Wr,{className:p8}),d&&(0,z.jsx)(jr,{className:p8}),o]})]}),t[6]=o,t[7]=a,t[8]=p,t[9]=f,t[10]=l,t[11]=d,t[12]=i,t[13]=h):h=t[13];let g;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(g=I(`overflow-hidden`,`[&>[data-streamdown=table-wrapper]]:m-0 [&>[data-streamdown=table-wrapper]]:gap-0 [&>[data-streamdown=table-wrapper]]:rounded-none [&>[data-streamdown=table-wrapper]]:border-0 [&>[data-streamdown=table-wrapper]]:bg-transparent [&>[data-streamdown=table-wrapper]]:p-0`,`[&>[data-streamdown=table-wrapper]>div:last-child]:rounded-none [&>[data-streamdown=table-wrapper]>div:last-child]:border-0`,`[&_[data-streamdown=table]]:tabular-nums`,`[&_[data-streamdown=table-header]]:bg-muted/30`,`[&_[data-streamdown=table-header-cell]]:text-muted-foreground [&_[data-streamdown=table-header-cell]]:text-xs [&_[data-streamdown=table-header-cell]]:font-medium`,`[&_[data-streamdown=table-cell]]:py-2`,`[&_[data-streamdown=table-row]]:hover:bg-muted/30`),t[14]=g):g=t[14];let _;t[15]===n?_=t[16]:(_=(0,z.jsx)(Y6.Content,{className:g,children:n}),t[15]=n,t[16]=_);let v;return t[17]!==m||t[18]!==h||t[19]!==_?(v=(0,z.jsxs)(Y6,{"data-streamdown":`table-wrapper`,className:m,children:[h,_]}),t[17]=m,t[18]=h,t[19]=_,t[20]=v):v=t[20],v}function A8(e){let t=(0,G.c)(43),n,r,i,a,o,s,c,l,u,d;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7],l=t[8],u=t[9],d=t[10]):({allowedTags:r,BlockComponent:n,children:i,components:a,controls:o,dir:s,mode:c,remarkPlugins:u,tableActions:d,...l}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c,t[8]=l,t[9]=u,t[10]=d);let f;bb0:{if(!u){f=T8;break bb0}let e;t[11]===u?e=t[12]:(e=[...u,tN,w8],t[11]=u,t[12]=e),f=e}let p=f,m;t[13]===r?m=t[14]:(m={...r,[d8]:f8},t[13]=r,t[14]=m);let h=m,g;t[15]===a?g=t[16]:(g={...a,[d8]:k8},t[15]=a,t[16]=g);let _=g,v;t[17]!==o||t[18]!==d?(v={actions:d,controls:o},t[17]=o,t[18]=d,t[19]=v):v=t[19];let y=v,b;bb1:{if(s!==`auto`||c===`static`){b=n;break bb1}let e=n??x8,r;t[20]===e?r=t[21]:(r=S8(e),t[20]=e,t[21]=r),b=r}let x=b,S;bb2:{if(s!==`auto`||c!==`static`||typeof i!=`string`){S=s;break bb2}let e;t[22]!==i||t[23]!==s?(e=b8(i)??s,t[22]=i,t[23]=s,t[24]=e):e=t[24],S=e}let C=S,w;t[25]===o?w=t[26]:(w=O8(o),t[25]=o,t[26]=w);let T;t[27]!==i||t[28]!==h?(T=$6(i,Object.keys(h)),t[27]=i,t[28]=h,t[29]=T):T=t[29];let E;t[30]!==c||t[31]!==l||t[32]!==C||t[33]!==w||t[34]!==T||t[35]!==h||t[36]!==x||t[37]!==_||t[38]!==p?(E=(0,z.jsx)(Gr,{allowedTags:h,BlockComponent:x,components:_,controls:w,dir:C,mode:c,parseMarkdownIntoBlocksFn:h8,remarkPlugins:p,...l,children:T}),t[30]=c,t[31]=l,t[32]=C,t[33]=w,t[34]=T,t[35]=h,t[36]=x,t[37]=_,t[38]=p,t[39]=E):E=t[39];let D;return t[40]!==E||t[41]!==y?(D=(0,z.jsx)(E8,{value:y,children:E}),t[40]=E,t[41]=y,t[42]=D):D=t[42],D}var j8=class extends R.Component{state={hasError:!1,error:null};static getDerivedStateFromError(e){return{hasError:!0,error:e}}render(){return this.state.hasError?this.props.fallback||(0,z.jsxs)(`div`,{className:`text-destructive p-2 text-sm`,children:[`Failed to render content: `,this.state.error?.message]}):this.props.children}},M8=(0,R.memo)(e=>{let t=(0,G.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=I(`size-full space-y-2 [&>*:first-child]:mt-0 [&>*:last-child]:mb-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,z.jsx)(j8,{children:(0,z.jsx)(A8,{className:i,dir:`auto`,...r})}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a});M8.displayName=`Response`;function N8(e){let t=(0,G.c)(9),n=e===void 0?2e3:e,r=ln(),[i,a]=(0,R.useState)(!1),o=(0,R.useRef)(null),s,c;t[0]===r?(s=t[1],c=t[2]):(s=()=>()=>{o.current&&r.clearTimeout(o.current)},c=[r],t[0]=r,t[1]=s,t[2]=c),(0,R.useEffect)(s,c);let l;t[3]!==r||t[4]!==n?(l=async e=>{await navigator.clipboard.writeText(e),a(!0),o.current&&r.clearTimeout(o.current),o.current=r.setTimeout(()=>a(!1),n)},t[3]=r,t[4]=n,t[5]=l):l=t[5];let u=l,d;return t[6]!==i||t[7]!==u?(d=[i,u],t[6]=i,t[7]=u,t[8]=d):d=t[8],d}var P8=(0,R.createContext)({code:``}),F8=e=>{let t=(0,G.c)(24),n,r,i,a,o,s;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6]):({code:r,language:i,showLineNumbers:o,wrap:s,children:n,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s);let c=o!==void 0&&o,l=s!==void 0&&s,u=rh(r,i),d;t[7]===r?d=t[8]:(d={code:r},t[7]=r,t[8]=d);let f;t[9]===u?f=t[10]:(f=u.map(L8),t[9]=u,t[10]=f);let p;t[11]!==c||t[12]!==f||t[13]!==l?(p=(0,z.jsx)(wa,{lineNumbers:c,wrap:l,children:f}),t[11]=c,t[12]=f,t[13]=l,t[14]=p):p=t[14];let m;t[15]===n?m=t[16]:(m=!!n&&(0,z.jsx)(Ca,{children:n}),t[15]=n,t[16]=m);let h;t[17]!==a||t[18]!==p||t[19]!==m?(h=(0,z.jsxs)(Sa,{size:`sm`,...a,children:[p,m]}),t[17]=a,t[18]=p,t[19]=m,t[20]=h):h=t[20];let g;return t[21]!==d||t[22]!==h?(g=(0,z.jsx)(P8,{value:d,children:h}),t[21]=d,t[22]=h,t[23]=g):g=t[23],g},I8=({onCopy:e,onError:t,timeout:n=2e3,children:r,className:i,...a})=>{let[o,s]=N8(n),{code:c}=(0,R.use)(P8),l=async()=>{if(typeof window>`u`||!navigator.clipboard.writeText){t?.(Error(`Clipboard API not available`));return}try{await s(c),e?.()}catch(e){t?.(e instanceof Error?e:Error(String(e)))}},u=o?d:ii;return(0,z.jsx)(Ce,{className:I(`shrink-0`,i),onClick:()=>void l(),size:`icon-xs`,variant:`ghost`,...a,children:r??(0,z.jsx)(u,{})})};function L8(e,t){return(0,z.jsx)(Ea,{children:e},t)}var R8=e=>{let t=(0,G.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=I(`not-prose mb-4 w-full rounded-md border`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,z.jsx)(Pa,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a},z8=e=>(0,z.jsxs)(re,{className:`gap-1.5 rounded-full text-xs`,variant:`secondary`,children:[{"input-streaming":(0,z.jsx)(yt,{className:`size-4`}),"input-available":(0,z.jsx)(ni,{className:`size-4 animate-pulse`}),"approval-requested":(0,z.jsx)(ni,{className:`size-4 text-yellow-600`}),"approval-responded":(0,z.jsx)(Xr,{className:`size-4 text-blue-600`}),"output-available":(0,z.jsx)(Xr,{className:`size-4 text-green-600`}),"output-error":(0,z.jsx)(ei,{className:`size-4 text-red-600`}),"output-denied":(0,z.jsx)(ei,{className:`size-4 text-orange-600`})}[e],{"input-streaming":`Pending`,"input-available":`Running`,"approval-requested":`Awaiting Approval`,"approval-responded":`Responded`,"output-available":`Completed`,"output-error":`Error`,"output-denied":`Denied`}[e]]}),B8=e=>{let t=(0,G.c)(23),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,title:a,part:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o;t[5]===n?o=t[6]:(o=I(`group flex w-full items-center justify-between gap-4 p-3`,n),t[5]=n,t[6]=o);let s;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,z.jsx)(Di,{className:`text-muted-foreground size-4`}),t[7]=s):s=t[7];let c;t[8]!==r||t[9]!==a?(c=a??Dv(r),t[8]=r,t[9]=a,t[10]=c):c=t[10];let l;t[11]===c?l=t[12]:(l=(0,z.jsx)(`span`,{className:`text-sm font-medium`,children:c}),t[11]=c,t[12]=l);let u;t[13]===r.state?u=t[14]:(u=z8(r.state),t[13]=r.state,t[14]=u);let d;t[15]!==l||t[16]!==u?(d=(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[s,l,u]}),t[15]=l,t[16]=u,t[17]=d):d=t[17];let f;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,z.jsx)(He,{className:`text-muted-foreground size-4 transition-transform group-data-[panel-open]:rotate-180`}),t[18]=f):f=t[18];let p;return t[19]!==i||t[20]!==o||t[21]!==d?(p=(0,z.jsxs)(Fa,{className:o,...i,children:[d,f]}),t[19]=i,t[20]=o,t[21]=d,t[22]=p):p=t[22],p},V8=e=>{let t=(0,G.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=I(`data-closed:fade-out-0 data-closed:slide-out-to-top-2 data-open:slide-in-from-top-2 text-popover-foreground data-closed:animate-out data-open:animate-in outline-none`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,z.jsx)(Ia,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a},H8=e=>{let t=(0,G.c)(15),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,input:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===n?a=t[5]:(a=I(`space-y-2 overflow-hidden p-4`,n),t[4]=n,t[5]=a);let o;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,z.jsx)(`h4`,{className:`text-muted-foreground text-xs font-medium tracking-wide uppercase`,children:`Parameters`}),t[6]=o):o=t[6];let s;t[7]===r?s=t[8]:(s=JSON.stringify(r,null,2),t[7]=r,t[8]=s);let c;t[9]===s?c=t[10]:(c=(0,z.jsx)(`div`,{className:`bg-muted/50 rounded-md`,children:(0,z.jsx)(F8,{code:s,language:`json`})}),t[9]=s,t[10]=c);let l;return t[11]!==i||t[12]!==a||t[13]!==c?(l=(0,z.jsxs)(`div`,{className:a,...i,children:[o,c]}),t[11]=i,t[12]=a,t[13]=c,t[14]=l):l=t[14],l},U8=e=>{let t=(0,G.c)(24),n,r,i,a;if(t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,output:i,errorText:r,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a),!(i||r))return null;let o;t[5]===n?o=t[6]:(o=I(`space-y-2 p-4`,n),t[5]=n,t[6]=o);let s=r?`Error`:`Result`,c;t[7]===s?c=t[8]:(c=(0,z.jsx)(`h4`,{className:`text-muted-foreground text-xs font-medium tracking-wide uppercase`,children:s}),t[7]=s,t[8]=c);let l=r?`bg-destructive/10 text-destructive`:`bg-muted/50 text-foreground`,u;t[9]===l?u=t[10]:(u=I(`overflow-x-auto rounded-md text-xs [&_table]:w-full`,l),t[9]=l,t[10]=u);let d;t[11]===r?d=t[12]:(d=r&&(0,z.jsx)(`div`,{children:r}),t[11]=r,t[12]=d);let f;t[13]===i?f=t[14]:(f=W8(i),t[13]=i,t[14]=f);let p;t[15]!==u||t[16]!==d||t[17]!==f?(p=(0,z.jsxs)(`div`,{className:u,children:[d,f]}),t[15]=u,t[16]=d,t[17]=f,t[18]=p):p=t[18];let m;return t[19]!==a||t[20]!==o||t[21]!==c||t[22]!==p?(m=(0,z.jsxs)(`div`,{className:o,...a,children:[c,p]}),t[19]=a,t[20]=o,t[21]=c,t[22]=p,t[23]=m):m=t[23],m};function W8(e){return typeof e==`string`?(0,z.jsx)(F8,{code:e,language:`json`}):(0,R.isValidElement)(e)?(0,z.jsx)(`div`,{children:e}):typeof e==`object`?(0,z.jsx)(F8,{code:JSON.stringify(e,null,2),language:`json`}):typeof e==`number`||typeof e==`bigint`?(0,z.jsx)(`div`,{children:e}):(0,z.jsx)(`div`,{})}function G8(e){let t=(0,G.c)(20),{part:n}=e,r;t[0]===n?r=t[1]:(r=Dv(n),t[0]=n,t[1]=r);let i=`Executing ${r}`,a;t[2]!==n||t[3]!==i?(a=(0,z.jsx)(B8,{title:i,part:n}),t[2]=n,t[3]=i,t[4]=a):a=t[4];let o;t[5]===n.input?o=t[6]:(o=(0,z.jsx)(H8,{input:n.input}),t[5]=n.input,t[6]=o);let s;t[7]===n.output?s=t[8]:(s=typeof n.output==`string`?n.output:JSON.stringify(n.output,null,2),t[7]=n.output,t[8]=s);let c;t[9]===s?c=t[10]:(c=(0,z.jsx)(M8,{className:`break-all`,children:s}),t[9]=s,t[10]=c);let l;t[11]!==n.errorText||t[12]!==c?(l=(0,z.jsx)(U8,{output:c,errorText:n.errorText}),t[11]=n.errorText,t[12]=c,t[13]=l):l=t[13];let u;t[14]!==o||t[15]!==l?(u=(0,z.jsxs)(V8,{children:[o,l]}),t[14]=o,t[15]=l,t[16]=u):u=t[16];let d;return t[17]!==a||t[18]!==u?(d=(0,z.jsxs)(R8,{"data-copy-exclude":`assistant-snapshot`,children:[a,u]}),t[17]=a,t[18]=u,t[19]=d):d=t[19],d}function K8(e){let t=(0,G.c)(18),{part:n}=e,r=`Executing ${n.toolName}`,i;t[0]!==n||t[1]!==r?(i=(0,z.jsx)(B8,{title:r,part:n}),t[0]=n,t[1]=r,t[2]=i):i=t[2];let a;t[3]===n.input?a=t[4]:(a=(0,z.jsx)(H8,{input:n.input}),t[3]=n.input,t[4]=a);let o;t[5]===n.output?o=t[6]:(o=typeof n.output==`string`?n.output:JSON.stringify(n.output,null,2),t[5]=n.output,t[6]=o);let s;t[7]===o?s=t[8]:(s=(0,z.jsx)(M8,{className:`break-all`,children:o}),t[7]=o,t[8]=s);let c;t[9]!==n.errorText||t[10]!==s?(c=(0,z.jsx)(U8,{output:s,errorText:n.errorText}),t[9]=n.errorText,t[10]=s,t[11]=c):c=t[11];let l;t[12]!==a||t[13]!==c?(l=(0,z.jsxs)(V8,{children:[a,c]}),t[12]=a,t[13]=c,t[14]=l):l=t[14];let u;return t[15]!==i||t[16]!==l?(u=(0,z.jsxs)(R8,{"data-copy-exclude":`assistant-snapshot`,children:[i,l]}),t[15]=i,t[16]=l,t[17]=u):u=t[17],u}var q8=(0,R.createContext)(!1);function J8(e){return e.parts.filter(xv).map(e=>e.text).join(`
|
|
348
|
-
`)}function Y8(){return(0,R.use)(q8)}function X8(e){return Tv(e)&&e.toolMetadata?.kind===`subagent`}function Z8(e,t){let n=Ev(e);return{toolKey:n,toolEntry:t?.[n]}}function Q8(e,t){return e?.static===!1&&!!e?.requiresUserInput&&t===`input-available`}var $8=new Set(`a.abbr.b.bdi.bdo.br.cite.code.data.del.dfn.em.i.ins.kbd.mark.q.s.samp.small.span.strong.sub.sup.time.u.var.wbr`.split(`.`));function e5(e){if(!R.isValidElement(e))return!1;let t=typeof e.type==`string`?e.type:e.props.node?.tagName;return t===void 0||!$8.has(t)}function t5(e){let t=(0,G.c)(6),{children:n,dir:r}=e,i=R.Children.toArray(n);if(!i.some(e5)){let e;return t[0]!==n||t[1]!==r?(e=(0,z.jsx)(`p`,{dir:r,children:n}),t[0]=n,t[1]=r,t[2]=e):e=t[2],e}if(i.every(e5))return n;let a;return t[3]!==n||t[4]!==r?(a=(0,z.jsx)(`div`,{dir:r,children:n}),t[3]=n,t[4]=r,t[5]=a):a=t[5],a}var n5={p:({children:e,dir:t})=>(0,z.jsx)(t5,{dir:t,children:e})};function r5(e){let t={...n5},n={};for(let r of e)Lj(r),t[r.name]=r.component,n[r.name]=r.allowedAttributes;return{components:t,allowedTags:n}}function i5(e){let t=(0,G.c)(10),n,r;t[0]===e?(n=t[1],r=t[2]):({elements:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=n??[],t[3]=n,t[4]=i);let a;t[5]===i?a=t[6]:(a=r5(i),t[5]=i,t[6]=a);let o=a,s;return t[7]!==r||t[8]!==o?(s=(0,z.jsx)(M8,{...o,...r}),t[7]=r,t[8]=o,t[9]=s):s=t[9],s}function a5(e){let t=(0,G.c)(22),{part:n}=e,{addToolApprovalResponse:r}=E6();if(n.state!==`approval-requested`)return null;let i;t[0]===n?i=t[1]:(i=n.title??Ev(n),t[0]=n,t[1]=i);let a=i,o=`${a} approval`,s;t[2]===a?s=t[3]:(s=(0,z.jsx)(`p`,{className:`text-sm font-medium`,children:a}),t[2]=a,t[3]=s);let c;t[4]===n.approval.requestReason?c=t[5]:(c=n.approval.requestReason&&(0,z.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:n.approval.requestReason}),t[4]=n.approval.requestReason,t[5]=c);let l;t[6]!==s||t[7]!==c?(l=(0,z.jsxs)(`div`,{className:`space-y-1`,children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;t[9]!==r||t[10]!==n.approval.id?(u=(0,z.jsx)(Ce,{type:`button`,variant:`destructive`,onClick:()=>void r({id:n.approval.id,approved:!1}),children:`Deny`}),t[9]=r,t[10]=n.approval.id,t[11]=u):u=t[11];let d;t[12]!==r||t[13]!==n.approval.id?(d=(0,z.jsx)(Ce,{type:`button`,onClick:()=>void r({id:n.approval.id,approved:!0}),children:`Approve`}),t[12]=r,t[13]=n.approval.id,t[14]=d):d=t[14];let f;t[15]!==u||t[16]!==d?(f=(0,z.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[u,d]}),t[15]=u,t[16]=d,t[17]=f):f=t[17];let p;return t[18]!==o||t[19]!==l||t[20]!==f?(p=(0,z.jsxs)(`div`,{"aria-label":o,className:`border-border bg-muted/30 space-y-3 rounded-lg border p-3`,"data-copy-exclude":`assistant-snapshot`,role:`group`,children:[l,f]}),t[18]=o,t[19]=l,t[20]=f,t[21]=p):p=t[21],p}function o5(e){let t=(0,G.c)(25),{part:n}=e,{registry:r}=C6();if(n.input===void 0){let e;return t[0]!==n.errorText||t[1]!==n.output||t[2]!==n.state?(e=n.state===`output-error`?(0,z.jsx)(U8,{output:n.output,errorText:n.errorText}):(0,z.jsx)(tee,{className:`size-4 animate-spin`}),t[0]=n.errorText,t[1]=n.output,t[2]=n.state,t[3]=e):e=t[3],e}let i;t[4]===n?i=t[5]:(i=(0,z.jsx)(a5,{part:n}),t[4]=n,t[5]=i);let a=i;if(!r)return a;let o;t[6]!==n||t[7]!==r?(o=Z8(n,r),t[6]=n,t[7]=r,t[8]=o):o=t[8];let{toolEntry:s}=o;if(s){let e=s.component,i;t[9]!==n||t[10]!==r.progress?(i=r.progress&&(0,z.jsx)(r.progress.component,{part:n}),t[9]=n,t[10]=r.progress,t[11]=i):i=t[11];let o;t[12]!==e||t[13]!==n?(o=(0,z.jsx)(e,{part:n}),t[12]=e,t[13]=n,t[14]=o):o=t[14];let c;return t[15]!==a||t[16]!==i||t[17]!==o?(c=(0,z.jsxs)(`div`,{className:`space-y-2`,children:[i,o,a]}),t[15]=a,t[16]=i,t[17]=o,t[18]=c):c=t[18],c}else{let e;t[19]!==n||t[20]!==r.progress?(e=r.progress&&(0,z.jsx)(r.progress.component,{part:n}),t[19]=n,t[20]=r.progress,t[21]=e):e=t[21];let i;return t[22]!==a||t[23]!==e?(i=(0,z.jsxs)(z.Fragment,{children:[e,a]}),t[22]=a,t[23]=e,t[24]=i):i=t[24],i}}var s5={animation:`slideUp`};function c5(e){let t=(0,G.c)(3),{filename:n,url:r}=e,i=n??`Attached image`,a;return t[0]!==i||t[1]!==r?(a=(0,z.jsx)(`img`,{src:r,alt:i,className:`max-h-64 rounded-md border object-contain`}),t[0]=i,t[1]=r,t[2]=a):a=t[2],a}function l5(e){let t=(0,G.c)(16),{filename:n,mediaType:r,url:i}=e,a=n||`Untitled`,o;t[0]!==r||t[1]!==a||t[2]!==i?(o=i?.startsWith(`data:`)?null:i&&r.startsWith(`video/`)?(0,z.jsx)(`video`,{controls:!0,playsInline:!0,preload:`metadata`,src:i,"aria-label":a,className:`max-h-96 w-full rounded-md bg-black`,children:(0,z.jsx)(`track`,{kind:`captions`})}):i&&r.startsWith(`audio/`)?(0,z.jsx)(`audio`,{controls:!0,preload:`metadata`,src:i,"aria-label":a,className:`w-full`,children:(0,z.jsx)(`track`,{kind:`captions`})}):null,t[0]=r,t[1]=a,t[2]=i,t[3]=o):o=t[3];let s=o,c=s?`mt-2`:void 0,l;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,z.jsx)(`strong`,{children:`File:`}),t[4]=l):l=t[4];let u;t[5]!==n||t[6]!==i?(u=i?(0,z.jsxs)(z.Fragment,{children:[` `,(0,z.jsx)(`a`,{href:i,download:n,className:`underline`,children:`Download`})]}):null,t[5]=n,t[6]=i,t[7]=u):u=t[7];let d;t[8]!==r||t[9]!==a||t[10]!==c||t[11]!==u?(d=(0,z.jsxs)(`div`,{className:c,children:[l,` `,a,` (`,r,`)`,u]}),t[8]=r,t[9]=a,t[10]=c,t[11]=u,t[12]=d):d=t[12];let f;return t[13]!==s||t[14]!==d?(f=(0,z.jsxs)(Ki,{className:`bg-muted/30 block w-full rounded-md p-3 text-sm text-inherit`,children:[s,d]}),t[13]=s,t[14]=d,t[15]=f):f=t[15],f}function u5(e){let t=(0,G.c)(4),{filename:n,mediaType:r,url:i}=e,a;return t[0]!==n||t[1]!==r||t[2]!==i?(a=r.split(`/`)[0]===`image`?(0,z.jsx)(c5,{filename:n,url:i}):(0,z.jsx)(l5,{filename:n,mediaType:r,url:i}),t[0]=n,t[1]=r,t[2]=i,t[3]=a):a=t[3],a}var d5=`genai-citation`;function f5(e,t){return t.map((t,n)=>({at:t.endIndex??e.length,order:n})).sort((e,t)=>t.at-e.at||t.order-e.order).reduce((e,{at:t,order:n})=>`${e.slice(0,t)}<${d5} citation="${n}" />${e.slice(t)}`,e)}var p5=(0,R.createContext)(null);function m5(e){let t=(0,G.c)(16),n=(0,R.use)(p5),r=n?.citations[Number(e.citation)];if(!n||!r)return null;let i;t[0]!==r.source.url||t[1]!==n.sources?(i=k6(n.sources,r.source.url),t[0]=r.source.url,t[1]=n.sources,t[2]=i):i=t[2];let a=i;if(a===null)return null;if(n.HostCitation){let e;return t[3]!==r||t[4]!==n.HostCitation||t[5]!==a?(e=(0,z.jsx)(n.HostCitation,{citation:r,index:a}),t[3]=r,t[4]=n.HostCitation,t[5]=a,t[6]=e):e=t[6],e}let o;t[7]!==r.source.title||t[8]!==r.source.url?(o={url:r.source.url,title:r.source.title},t[7]=r.source.title,t[8]=r.source.url,t[9]=o):o=t[9];let s;t[10]===r.citedText?s=t[11]:(s=r.citedText?(0,z.jsx)(`blockquote`,{dir:`auto`,children:r.citedText}):null,t[10]=r.citedText,t[11]=s);let c;return t[12]!==a||t[13]!==o||t[14]!==s?(c=(0,z.jsx)(V6,{source:o,index:a,children:s}),t[12]=a,t[13]=o,t[14]=s,t[15]=c):c=t[15],c}var h5={name:d5,allowedAttributes:[`citation`],component:m5};function g5(e){let t=(0,G.c)(27),{text:n,citations:r,elements:i,className:a}=e,{status:o}=w6(),s=Y8(),{messages:c,citation:l}=R6(),u;t[0]===r?u=t[1]:(u=D6(r),t[0]=r,t[1]=u);let d=u,f;t[2]===c?f=t[3]:(f=O6(c),t[2]=c,t[3]=f);let p;t[4]!==l||t[5]!==f||t[6]!==d?(p={citations:d,sources:f,HostCitation:l},t[4]=l,t[5]=f,t[6]=d,t[7]=p):p=t[7];let m=p,h=d.length>0,g;t[8]!==i||t[9]!==h?(g=h?[...i??[],h5]:i,t[8]=i,t[9]=h,t[10]=g):g=t[10];let _=g,v;t[11]===a?v=t[12]:(v=I(`text-sm`,a),t[11]=a,t[12]=v);let y=!s&&o===`streaming`,b;t[13]!==h||t[14]!==n||t[15]!==d?(b=h?f5(n,d):n,t[13]=h,t[14]=n,t[15]=d,t[16]=b):b=t[16];let x;t[17]!==y||t[18]!==b||t[19]!==_?(x=(0,z.jsx)(i5,{elements:_,animated:s5,isAnimating:y,children:b}),t[17]=y,t[18]=b,t[19]=_,t[20]=x):x=t[20];let S;t[21]!==v||t[22]!==x?(S=(0,z.jsx)(`div`,{className:v,children:x}),t[21]=v,t[22]=x,t[23]=S):S=t[23];let C;return t[24]!==m||t[25]!==S?(C=(0,z.jsx)(p5,{value:m,children:S}),t[24]=m,t[25]=S,t[26]=C):C=t[26],C}function _5(e){let t=(0,G.c)(8),{part:n}=e,r=v5(),i;t[0]!==n||t[1]!==r?(i=r&&(0,z.jsx)(G8,{part:n}),t[0]=n,t[1]=r,t[2]=i):i=t[2];let a;t[3]===n?a=t[4]:(a=(0,z.jsx)(o5,{part:n}),t[3]=n,t[4]=a);let o;return t[5]!==i||t[6]!==a?(o=(0,z.jsxs)(z.Fragment,{children:[i,a]}),t[5]=i,t[6]=a,t[7]=o):o=t[7],o}function v5(){let{debugMode:e}=C6(),t=Y8();return!!e&&!t}function y5(e){return!!e&&e!==`output-available`}function b5(e){let t=(0,G.c)(5),{label:n,part:r,state:i}=e,a=Y8(),o;return t[0]!==a||t[1]!==n||t[2]!==r||t[3]!==i?(o=!a&&!!n.actions&&!!r&&!y5(i),t[0]=a,t[1]=n,t[2]=r,t[3]=i,t[4]=o):o=t[4],o}function x5(e){let t=(0,G.c)(18),{label:n,part:r}=e,i=n.icon,a=n.actions,o;t[0]!==n||t[1]!==r?(o={label:n,part:r,state:r.state},t[0]=n,t[1]=r,t[2]=o):o=t[2];let s=b5(o),c;t[3]!==i||t[4]!==n.isError?(c=i&&(0,z.jsx)(i,{className:I(`size-3.5`,n.isError?`text-destructive`:`text-muted-foreground`)}),t[3]=i,t[4]=n.isError,t[5]=c):c=t[5];let l;t[6]===n.name?l=t[7]:(l=(0,z.jsx)(`span`,{className:`font-mono`,children:n.name}),t[6]=n.name,t[7]=l);let u;t[8]!==c||t[9]!==l?(u=(0,z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[c,l]}),t[8]=c,t[9]=l,t[10]=u):u=t[10];let d;t[11]!==a||t[12]!==r||t[13]!==s?(d=s&&a&&(0,z.jsx)(a,{part:r}),t[11]=a,t[12]=r,t[13]=s,t[14]=d):d=t[14];let f;return t[15]!==u||t[16]!==d?(f=(0,z.jsxs)(`div`,{className:`text-muted-foreground flex items-center justify-between gap-1.5 text-xs`,children:[u,d]}),t[15]=u,t[16]=d,t[17]=f):f=t[17],f}function S5(e){let t=(0,G.c)(3),{name:n,value:r}=e,i;return t[0]!==n||t[1]!==r?(i=(0,z.jsxs)(`span`,{"data-slot":`tool-arg`,children:[n,`: "`,r,`"`]}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i}function C5(e){let t=(0,G.c)(23),{label:n,state:r,part:i,children:a}=e,o=n.actions,s;t[0]!==n||t[1]!==i||t[2]!==r?(s={label:n,part:i,state:r},t[0]=n,t[1]=i,t[2]=r,t[3]=s):s=t[3];let c=b5(s),l;t[4]===n.args?l=t[5]:(l=n.args?Object.entries(n.args).map(w5):`...`,t[4]=n.args,t[5]=l);let u;t[6]!==a||t[7]!==n.name||t[8]!==l?(u=(0,z.jsxs)(`span`,{className:`text-muted-foreground min-w-0 truncate font-mono text-xs [&>[data-slot=tool-arg]+[data-slot=tool-arg]]:before:mr-1 [&>[data-slot=tool-arg]+[data-slot=tool-arg]]:before:content-[',']`,children:[n.name,`(`,a,l,`)`]}),t[6]=a,t[7]=n.name,t[8]=l,t[9]=u):u=t[9];let d;t[10]!==o||t[11]!==i||t[12]!==c?(d=c&&o&&i&&(0,z.jsx)(`span`,{className:`shrink-0`,children:(0,z.jsx)(o,{part:i})}),t[10]=o,t[11]=i,t[12]=c,t[13]=d):d=t[13];let f;t[14]!==u||t[15]!==d?(f=(0,z.jsxs)(`span`,{className:`flex items-start justify-between gap-2`,children:[u,d]}),t[14]=u,t[15]=d,t[16]=f):f=t[16];let p;t[17]!==n.detail||t[18]!==n.isError?(p=n.detail&&(0,z.jsx)(`span`,{className:I(`line-clamp-3 text-start font-mono text-[10px] leading-relaxed whitespace-pre-wrap`,n.isError?`text-destructive/80`:`text-muted-foreground`),children:n.detail}),t[17]=n.detail,t[18]=n.isError,t[19]=p):p=t[19];let m;return t[20]!==f||t[21]!==p?(m=(0,z.jsxs)(`span`,{className:`mb-2 flex flex-col gap-1`,children:[f,p]}),t[20]=f,t[21]=p,t[22]=m):m=t[22],m}function w5(e){let[t,n]=e;return(0,z.jsx)(S5,{name:t,value:n},t)}function T5(e){return e.type===`text`&&e.providerMetadata?.openai?.phase===`commentary`}function E5(e){let t=(0,G.c)(9),{segment:n,elements:r,className:i}=e,a;if(t[0]!==i||t[1]!==r||t[2]!==n.parts){let e;t[4]!==i||t[5]!==r?(e=e=>{let{part:t,idx:n}=e;return t.type===`text`?(0,z.jsx)(g5,{text:t.text,citations:t.citations,elements:r,className:i},`${n}-text`):null},t[4]=i,t[5]=r,t[6]=e):e=t[6],a=n.parts.map(e),t[0]=i,t[1]=r,t[2]=n.parts,t[3]=a}else a=t[3];let o;return t[7]===a?o=t[8]:(o=(0,z.jsx)(z.Fragment,{children:a}),t[7]=a,t[8]=o),o}function D5(e){let t=(0,G.c)(4),{segment:n}=e,{part:r}=n;if(r.type!==`file`)return null;let i;return t[0]!==r.filename||t[1]!==r.mediaType||t[2]!==r.url?(i=(0,z.jsx)(u5,{filename:r.filename,mediaType:r.mediaType,url:r.url}),t[0]=r.filename,t[1]=r.mediaType,t[2]=r.url,t[3]=i):i=t[3],i}function O5(e){let t=(0,G.c)(9),{segment:n}=e,{messages:r}=R6(),i;t[0]===r?i=t[1]:(i=O6(r),t[0]=r,t[1]=i);let a=i,o;if(t[2]!==n.parts||t[3]!==a){let e;t[5]===a?e=t[6]:(e=e=>{let{part:t,idx:n}=e;if(t.type!==`source-url`)return null;let r=k6(a,t.url);return r===null?null:(0,z.jsx)(V6,{source:{url:t.url,title:t.title},index:r},`source-${n}`)},t[5]=a,t[6]=e),o=n.parts.map(e),t[2]=n.parts,t[3]=a,t[4]=o}else o=t[4];let s;return t[7]===o?s=t[8]:(s=(0,z.jsx)(`span`,{children:o}),t[7]=o,t[8]=s),s}function k5(e){let t=(0,G.c)(3),{segment:n}=e,r=z6();if(Y8())return null;let{part:i}=n;if(i.type!==`reasoning`)return null;let a=r===`streaming`,o;return t[0]!==i.text||t[1]!==a?(o=(0,z.jsx)(`div`,{className:`text-muted-foreground text-xs`,children:(0,z.jsx)(M8,{animated:s5,isAnimating:a,children:i.text})}),t[0]=i.text,t[1]=a,t[2]=o):o=t[2],o}function A5(e){let t=(0,G.c)(2),{segment:n}=e;if(!v5())return null;let{part:r}=n;if(r.type!==`dynamic-tool`)return null;let i;return t[0]===r?i=t[1]:(i=(0,z.jsx)(K8,{part:r}),t[0]=r,t[1]=i),i}var j5=(0,R.createContext)(null),M5=(0,R.createContext)(null);function N5(){let e=(0,R.use)(j5);if(!e)throw Error(`Segment.Tool* parts must be rendered within Segment.Tool`);return e}function P5(e){let t=(0,G.c)(29),{segment:n,children:r}=e,i=C6(),a=z6(),{part:o}=n;if(!Cv(o))return null;let s,c,l,u;t[0]!==i.registry||t[1]!==a||t[2]!==o?({toolEntry:u}=Z8(o,i.registry),c=Q8(u,o.state),s=!c&&j6(o,a),l=u?.label?.(o),t[0]=i.registry,t[1]=a,t[2]=o,t[3]=s,t[4]=c,t[5]=l,t[6]=u):(s=t[3],c=t[4],l=t[5],u=t[6]);let d=l,f;t[7]!==s||t[8]!==d||t[9]!==o?(f=s?{...d??{name:Ev(o)},isError:!0,detail:`Cancelled by user`}:d,t[7]=s,t[8]=d,t[9]=o,t[10]=f):f=t[10];let p=f,m=u?.static===!1&&!!u?.requiresUserInput&&!c,h;t[11]!==s||t[12]!==c||t[13]!==m||t[14]!==p||t[15]!==o?(h={part:o,label:p,aborted:s,activeClientInput:c,defaultOpen:m},t[11]=s,t[12]=c,t[13]=m,t[14]=p,t[15]=o,t[16]=h):h=t[16];let g;t[17]!==s||t[18]!==p||t[19]!==o.state?(g={label:p,state:o.state,aborted:s},t[17]=s,t[18]=p,t[19]=o.state,t[20]=g):g=t[20];let _;t[21]===r?_=t[22]:(_=r??(0,z.jsx)(I5,{}),t[21]=r,t[22]=_);let v;t[23]!==g||t[24]!==_?(v=(0,z.jsx)(M5,{value:g,children:_}),t[23]=g,t[24]=_,t[25]=v):v=t[25];let y;return t[26]!==h||t[27]!==v?(y=(0,z.jsx)(j5,{value:h,children:v}),t[26]=h,t[27]=v,t[28]=y):y=t[28],y}function F5(){let e=(0,G.c)(2),{part:t,activeClientInput:n}=N5();if(n)return null;let r;return e[0]===t?r=e[1]:(r=(0,z.jsx)(_5,{part:t}),e[0]=t,e[1]=r),r}function I5(e){let t=(0,G.c)(9),{children:n}=e,{part:r,label:i,defaultOpen:a}=N5();if(!i){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,z.jsx)(F5,{})}),t[0]=e):e=t[0],e}let o;t[1]!==n||t[2]!==i||t[3]!==r?(o=(0,z.jsx)(Fa,{className:`cursor-pointer`,children:(0,z.jsx)(C5,{label:i,state:r.state,part:r,children:n})}),t[1]=n,t[2]=i,t[3]=r,t[4]=o):o=t[4];let s;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,z.jsx)(Ia,{className:`mb-2`,children:(0,z.jsx)(F5,{})}),t[5]=s):s=t[5];let c;return t[6]!==a||t[7]!==o?(c=(0,z.jsxs)(Pa,{defaultOpen:a,className:`flex min-w-0 flex-1 flex-col`,children:[o,s]}),t[6]=a,t[7]=o,t[8]=c):c=t[8],c}var L5={Text:E5,File:D5,Source:O5,Reasoning:k5,DynamicTool:A5,Tool:P5,ToolDisclosure:I5,ToolContent:F5};function R5(e){return Cv(e)?`tool`:e.type===`dynamic-tool`?`dynamic-tool`:e.type===`reasoning`&&`text`in e&&e.text?`reasoning`:null}function z5(e,t){return e.kind===`text`||e.kind===`file`||e.kind===`source`?!1:e.kind===`reasoning`||e.kind!==`dynamic-tool`||!!t}function B5(e,t,n){let r=e[t+1];return!!r&&z5(r,n)}function V5(e){let t=[],n=new Set(e.flatMap(e=>e.type===`text`?D6(e.citations).map(({source:e})=>e.url):[]));for(let r=0;r<e.length;r++){let i=e[r],a=R5(i);if(a)t.push({kind:a,part:i,idx:r});else if(i.type===`text`){let e=t[t.length-1];e&&e.kind===`text`?e.parts.push({part:i,idx:r}):t.push({kind:`text`,parts:[{part:i,idx:r}]})}else if(i.type===`file`)t.push({kind:`file`,part:i,idx:r});else if(i.type===`source-url`&&!n.has(i.url)){let e=t[t.length-1];e&&e.kind===`source`?e.parts.push({part:i,idx:r}):t.push({kind:`source`,parts:[{part:i,idx:r}]})}}return t}function H5(e,t){return e.kind===`text`||e.kind===`source`?e.parts[0]?.idx??t:e.idx}(0,R.memo)(function(e){let t=(0,G.c)(8),{segment:n}=e;if(n.kind===`tool`){let e;return t[0]===n?e=t[1]:(e=(0,z.jsx)(L5.Tool,{segment:n}),t[0]=n,t[1]=e),e}if(n.kind===`reasoning`){let e;return t[2]===n?e=t[3]:(e=(0,z.jsx)(L5.Reasoning,{segment:n}),t[2]=n,t[3]=e),e}if(n.kind===`text`){let e;return t[4]===n?e=t[5]:(e=(0,z.jsx)(L5.Text,{segment:n,className:`text-xs`}),t[4]=n,t[5]=e),e}if(n.kind===`file`){let e;return t[6]===n?e=t[7]:(e=(0,z.jsx)(L5.File,{segment:n}),t[6]=n,t[7]=e),e}return null},U5);function U5(e,t){return e.complete&&t.complete&&e.cacheKey===t.cacheKey}function W5(e){let t=(0,G.c)(12),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({icon:r,className:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(a={scale:.94},t[4]=a):a=t[4];let o;t[5]===n?o=t[6]:(o=I(`group text-muted-foreground hover:text-foreground relative rounded-lg p-2 transition-colors`,n),t[5]=n,t[6]=o);let s;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,z.jsx)(`span`,{className:`bg-primary/10 absolute inset-0 rounded-lg opacity-0 transition-opacity group-hover:opacity-100`}),t[7]=s):s=t[7];let c;return t[8]!==r||t[9]!==i||t[10]!==o?(c=(0,z.jsxs)(Tj.button,{type:`button`,whileTap:a,className:o,...i,children:[r,s]}),t[8]=r,t[9]=i,t[10]=o,t[11]=c):c=t[11],c}function G5(){let{index:e}=B6(),{messages:t}=R6(),n=z6();return!(e===t.length-1&&(n===`submitted`||n===`streaming`||n===`error`))}function K5(e){let t=(0,G.c)(5),{className:n,children:r}=e;if(!G5()||R.Children.toArray(r).length===0)return null;let i;t[0]===n?i=t[1]:(i=I(`mt-1 flex items-center gap-0.5`,n),t[0]=n,t[1]=i);let a;return t[2]!==r||t[3]!==i?(a=(0,z.jsx)(`div`,{"data-copy-exclude":`assistant-snapshot`,className:i,children:r}),t[2]=r,t[3]=i,t[4]=a):a=t[4],a}function q5(e){let t=(0,G.c)(12),{className:n}=e,{message:r}=B6(),[i,a]=N8(),o=i?`Copied`:`Copy message`,s;t[0]===n?s=t[1]:(s=I(`p-1.5`,n),t[0]=n,t[1]=s);let c;t[2]!==a||t[3]!==r?(c=()=>void a(J8(r)),t[2]=a,t[3]=r,t[4]=c):c=t[4];let l;t[5]===i?l=t[6]:(l=(0,z.jsx)(i?d:ii,{className:`size-3.5`}),t[5]=i,t[6]=l);let u;return t[7]!==o||t[8]!==s||t[9]!==c||t[10]!==l?(u=(0,z.jsx)(W5,{"aria-label":o,className:s,onClick:c,icon:l}),t[7]=o,t[8]=s,t[9]=c,t[10]=l,t[11]=u):u=t[11],u}function J5(e){let t=(0,G.c)(9),{className:n}=e,{message:r}=B6(),{regenerate:i}=E6(),a;t[0]===n?a=t[1]:(a=I(`p-1.5`,n),t[0]=n,t[1]=a);let o;t[2]!==r.id||t[3]!==i?(o=()=>void i({messageId:r.id}),t[2]=r.id,t[3]=i,t[4]=o):o=t[4];let s;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,z.jsx)(Ci,{className:`size-3.5`}),t[5]=s):s=t[5];let c;return t[6]!==a||t[7]!==o?(c=(0,z.jsx)(W5,{"aria-label":`Regenerate response`,className:a,onClick:o,icon:s}),t[6]=a,t[7]=o,t[8]=c):c=t[8],c}function Y5(e){let t=(0,G.c)(12),{className:n}=e,{message:r}=B6(),[i,a]=N8(),o=i?`Copied`:`Copy debug JSON`,s;t[0]===n?s=t[1]:(s=I(`p-1.5`,n),t[0]=n,t[1]=s);let c;t[2]!==a||t[3]!==r?(c=()=>void a(JSON.stringify(r,null,2)),t[2]=a,t[3]=r,t[4]=c):c=t[4];let l;t[5]===i?l=t[6]:(l=(0,z.jsx)(i?d:Wt,{className:`size-3.5`}),t[5]=i,t[6]=l);let u;return t[7]!==o||t[8]!==s||t[9]!==c||t[10]!==l?(u=(0,z.jsx)(W5,{"aria-label":o,className:s,onClick:c,icon:l}),t[7]=o,t[8]=s,t[9]=c,t[10]=l,t[11]=u):u=t[11],u}function X5(e){let t=(0,G.c)(7),{onTryAgain:n,error:r}=e,i=r instanceof Error?r.message:`An error occurred. Please try again.`,a;t[0]===i?a=t[1]:(a=(0,z.jsx)(`div`,{className:`text-destructive text-sm`,children:(0,z.jsx)(M8,{mode:`static`,children:i})}),t[0]=i,t[1]=a);let o;t[2]===n?o=t[3]:(o=(0,z.jsx)(Ce,{type:`button`,onClick:n,size:`sm`,variant:`outline`,children:`Try Again`}),t[2]=n,t[3]=o);let s;return t[4]!==a||t[5]!==o?(s=(0,z.jsx)(`div`,{className:`mt-3 flex justify-start`,children:(0,z.jsxs)(`div`,{className:`max-w-[80%] space-y-2`,children:[a,o]})}),t[4]=a,t[5]=o,t[6]=s):s=t[6],s}function Z5(e){let t=(0,G.c)(3),{error:n,onRetry:r}=e;if(!n||!r)return null;let i;return t[0]!==n||t[1]!==r?(i=(0,z.jsx)(X5,{onTryAgain:r,error:n}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i}function Q5(e){let t=(0,G.c)(15),{messages:n,className:r,elements:i,citation:a,status:o,children:s}=e,c;t[0]!==a||t[1]!==i||t[2]!==n||t[3]!==o?(c={messages:n,elements:i,citation:a,status:o},t[0]=a,t[1]=i,t[2]=n,t[3]=o,t[4]=c):c=t[4];let l=c,u;t[5]===r?u=t[6]:(u=I(`flex h-full flex-col`,r),t[5]=r,t[6]=u);let d;t[7]===s?d=t[8]:(d=(0,z.jsx)(`div`,{className:`flex h-full min-h-0 flex-1 flex-col`,children:s}),t[7]=s,t[8]=d);let f;t[9]!==u||t[10]!==d?(f=(0,z.jsx)(`div`,{className:u,children:d}),t[9]=u,t[10]=d,t[11]=f):f=t[11];let p;return t[12]!==f||t[13]!==l?(p=(0,z.jsx)(I6,{value:l,children:f}),t[12]=f,t[13]=l,t[14]=p):p=t[14],p}function $5(e){let t=(0,G.c)(5),{className:n,children:r}=e,i;t[0]===n?i=t[1]:(i=I(`flex flex-col gap-4`,n),t[0]=n,t[1]=i);let a;return t[2]!==r||t[3]!==i?(a=(0,z.jsx)(`div`,{className:i,children:r}),t[2]=r,t[3]=i,t[4]=a):a=t[4],a}function e7(e){let t=(0,G.c)(9),{message:n,index:r,className:i,children:a}=e,o;t[0]!==r||t[1]!==n?(o={message:n,index:r},t[0]=r,t[1]=n,t[2]=o):o=t[2];let s=o,c;t[3]!==a||t[4]!==i?(c=(0,z.jsx)(`div`,{className:i,children:a}),t[3]=a,t[4]=i,t[5]=c):c=t[5];let l;return t[6]!==c||t[7]!==s?(l=(0,z.jsx)(L6,{value:s,children:c}),t[6]=c,t[7]=s,t[8]=l):l=t[8],l}function t7(){let e=(0,G.c)(5),{registry:t}=C6(),n=E6().messages,r;if(e[0]!==n||e[1]!==t){bb0:{if(!t){r=null;break bb0}let i=n.findLast(n7);if(!i){r=null;break bb0}let a;e[3]===t?a=e[4]:(a=e=>{if(!Cv(e)||e.state!==`input-available`)return[];let n=t[Ev(e)];return!n||n.static!==!1||!n.requiresUserInput?[]:[{part:e,entry:n}]},e[3]=t,e[4]=a),r=i.parts.flatMap(a).at(0)??null}e[0]=n,e[1]=t,e[2]=r}else r=e[2];return r}function n7(e){let{role:t}=e;return t===`assistant`}function r7(e){let t=(0,G.c)(10),{children:n,className:r}=e,i=t7(),a=i?.entry.component,o=i?`hidden`:`visible`,s;t[0]!==n||t[1]!==o?(s=(0,z.jsx)(R.Activity,{mode:o,children:n}),t[0]=n,t[1]=o,t[2]=s):s=t[2];let c;t[3]!==a||t[4]!==i||t[5]!==r?(c=i&&a?(0,z.jsx)(`div`,{className:I(`sticky bottom-0 mt-auto`,r),children:(0,z.jsx)(a,{part:i.part},i.part.toolCallId)}):null,t[3]=a,t[4]=i,t[5]=r,t[6]=c):c=t[6];let l;return t[7]!==s||t[8]!==c?(l=(0,z.jsxs)(z.Fragment,{children:[s,c]}),t[7]=s,t[8]=c,t[9]=l):l=t[9],l}function i7(e,t){if(e===`error`||e===`ready`||!t)return null;if(t.role!==`assistant`)return`Thinking...`;for(let e=t.parts.length-1;e>=0;e--){let n=t.parts[e];if(xv(n)&&T5(n)&&n.text)return n.text}for(let e=t.parts.length-1;e>=0;e--){let n=t.parts[e];if(Sv(n)&&n.text)return n.text;if(Tv(n)){let e=n.input;if(qh(e))for(let t of[`reasoning`,`thoughts`,`thought`,`hint`]){let n=e[t];if(typeof n==`string`&&n.length>0)return n}return n.toolCallId}if(xv(n)&&n.text)return``}return`Thinking...`}function a7(e){let t=(0,G.c)(5),{isLast:n}=e,r=n!==void 0&&n,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,z.jsx)(`span`,{className:`bg-muted-foreground/50 z-10 mt-1 size-2 shrink-0 rounded-full`}),t[0]=i):i=t[0];let a;t[1]===r?a=t[2]:(a=!r&&(0,z.jsx)(`span`,{className:`bg-border w-px flex-1`}),t[1]=r,t[2]=a);let o;return t[3]===a?o=t[4]:(o=(0,z.jsxs)(`div`,{className:`absolute top-0 left-0 flex size-3.5 h-full flex-col items-center`,children:[i,a]}),t[3]=a,t[4]=o),o}function o7(e){let t=(0,G.c)(6),{marker:n,children:r,className:i}=e,a;t[0]===i?a=t[1]:(a=I(`relative z-0 flex gap-3 pl-5`,i),t[0]=i,t[1]=a);let o;return t[2]!==r||t[3]!==n||t[4]!==a?(o=(0,z.jsxs)(`div`,{className:a,children:[n,r]}),t[2]=r,t[3]=n,t[4]=a,t[5]=o):o=t[5],o}function s7(){let e=(0,G.c)(6),t=z6(),{messages:n}=R6(),r=t7(),i=n[n.length-1],a;e[0]!==t||e[1]!==i?(a=i7(t,i),e[0]=t,e[1]=i,e[2]=a):a=e[2];let o=a;if(!o||r)return null;let s;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,z.jsx)(a7,{isLast:!0}),e[3]=s):s=e[3];let c;return e[4]===o?c=e[5]:(c=(0,z.jsx)(o7,{className:`mt-2`,marker:s,children:(0,z.jsx)(`span`,{role:`status`,children:(0,z.jsx)(N6,{as:`span`,className:`text-muted-foreground line-clamp-2 font-mono text-xs`,children:o})})}),e[4]=o,e[5]=c),c}var c7=[`inputTokens`,`outputTokens`,`reasoningTokens`,`cachedInputTokens`,`totalTokens`],l7={inputTokens:[[`inputTokens`],[`raw`,`prompt_tokens`]],outputTokens:[[`outputTokens`],[`raw`,`completion_tokens`]],reasoningTokens:[[`reasoningTokens`],[`outputTokenDetails`,`reasoningTokens`],[`raw`,`completion_tokens_details`,`reasoning_tokens`]],cachedInputTokens:[[`inputTokenDetails`,`cacheReadTokens`],[`cachedInputTokens`],[`inputTokenDetails`,`cachedTokens`],[`raw`,`prompt_tokens_details`,`cached_tokens`]],totalTokens:[[`totalTokens`],[`raw`,`total_tokens`]]};function u7(e){if(typeof e==`number`&&Number.isFinite(e)&&e>=0)return e;if(typeof e==`string`&&e.trim().length>0){let t=Number(e);if(Number.isFinite(t)&&t>=0)return t}return null}function d7(e){if(!e||typeof e!=`object`)return null;let t={inputTokens:null,outputTokens:null,reasoningTokens:null,cachedInputTokens:null,totalTokens:null};for(let n of c7)for(let r of l7[n]){let i=u7(X3(e,r));if(i!==null){t[n]=i;break}}return c7.some(e=>t[e]!==null)?t:null}function f7(e){return qh(e)?d7(e.totalUsage??e.usage):null}function p7(e){let t=[`↑ ${e6(e.inputTokens)}`,`↓ ${e6(e.outputTokens)}`];return e.totalTokens!==null&&t.push(`· ${$3(e.totalTokens)} tokens`),e.cachedInputTokens!==null&&e.cachedInputTokens>0&&t.push(`(${e6(e.cachedInputTokens)} cached)`),t.join(` `)}var m7=`x-upload-filename`,h7=Me({path:L().startsWith(`/`),name:L().min(1),mediaType:Mn([`image/png`,`image/jpeg`,`image/webp`,`image/gif`,`image/heic`,`image/heif`,`video/mp4`,`video/quicktime`,`audio/mpeg`,`audio/mp4`,`audio/wav`]),size:eee().nonnegative(),url:Te()}),g7=class extends Dy{sessionsApi;request;constructor({api:e,fetch:t=(e,t)=>globalThis.fetch(e,t),tools:n={},elements:r=[]}){let i=b7(e),a=r.map(Vj);super({api:i,fetch:async(e,n)=>{let r=await t(e,n);if((n?.method??`GET`).toUpperCase()!==`POST`||!r.ok)return r;let i=await r.json();if(!x7(i))throw Error(`Zukhruf returned an invalid accepted-turn response`);let a=b7(String(e)),o=decodeURIComponent(a.slice(a.lastIndexOf(`/`)+1));if(i.sessionId!==o)throw Error(`Zukhruf returned a different session ID`);let s=n?.signal;return s?.addEventListener(`abort`,()=>{t(`${a}/cancel`,{method:`POST`})},{once:!0}),t(`${a}/stream`,{headers:{accept:`text/event-stream`},method:`GET`,signal:s})},prepareSendMessagesRequest:({id:e,messages:t,trigger:r})=>{let o=t[t.length-1];if(!o)throw Error(`A message is required`);return{api:_7(i,e),body:{sessionId:e,message:o,trigger:r,...Object.keys(n).length>0?{tools:n}:{},...a.length>0?{elements:a}:{}}}},prepareReconnectToStreamRequest:({headers:e,id:t})=>({api:`${_7(i,t)}/stream`,headers:e})}),this.sessionsApi=i,this.request=t}async uploadFile(e,t){let n=await this.request(`${_7(this.sessionsApi,e)}/uploads`,{method:`POST`,headers:{"content-type":t.type,[m7]:encodeURIComponent(t.name)},body:t});if(!n.ok)throw Error(await v7(n,t));let r=h7.safeParse(await n.json());if(!r.success)throw Error(`Zukhruf returned an invalid upload response`);return r.data}};function _7(e,t){return`${e}/${encodeURIComponent(t)}`}async function v7(e,t){let n=`Uploading ${t.name} failed with HTTP ${e.status}`,r=y7(await e.json().catch(e=>{if(e instanceof SyntaxError)return null;throw e}));return r?`${n}: ${r}`:n}function y7(e){if(typeof e!=`object`||!e)return null;let t=`cause`in e&&typeof e.cause==`object`&&e.cause!==null?e.cause:null;return[t&&`code`in t&&typeof t.code==`string`?t.code:null,t&&`detail`in t&&typeof t.detail==`string`?t.detail:`error`in e&&typeof e.error==`string`?e.error:null].filter(e=>e!==null).join(` — `)||null}function b7(e){return e.replace(/\/$/,``)}function x7(e){return typeof e==`object`&&!!e&&`ok`in e&&e.ok===!0&&`sessionId`in e&&typeof e.sessionId==`string`&&`turnId`in e&&typeof e.turnId==`string`}function S7(e){let t=(0,G.c)(24),{label:n,open:r,onOpenChange:i,children:a,className:o,triggerClassName:s,contentClassName:c,chevronClassName:l}=e,u;t[0]===s?u=t[1]:(u=I(`flex items-center font-mono`,s),t[0]=s,t[1]=u);let d;t[2]===u?d=t[3]:(d=(0,z.jsx)(`button`,{type:`button`,className:u}),t[2]=u,t[3]=d);let f=r&&`rotate-180`,p;t[4]!==l||t[5]!==f?(p=I(`size-4 transition-transform`,l,f),t[4]=l,t[5]=f,t[6]=p):p=t[6];let m;t[7]===p?m=t[8]:(m=(0,z.jsx)(He,{className:p}),t[7]=p,t[8]=m);let h;t[9]===n?h=t[10]:(h=(0,z.jsx)(`span`,{children:n}),t[9]=n,t[10]=h);let g;t[11]!==d||t[12]!==m||t[13]!==h?(g=(0,z.jsxs)(Fa,{render:d,children:[m,h]}),t[11]=d,t[12]=m,t[13]=h,t[14]=g):g=t[14];let _;t[15]!==a||t[16]!==c?(_=(0,z.jsx)(Ia,{className:c,children:a}),t[15]=a,t[16]=c,t[17]=_):_=t[17];let v;return t[18]!==o||t[19]!==i||t[20]!==r||t[21]!==g||t[22]!==_?(v=(0,z.jsxs)(Pa,{open:r,onOpenChange:i,className:o,children:[g,_]}),t[18]=o,t[19]=i,t[20]=r,t[21]=g,t[22]=_,t[23]=v):v=t[23],v}function C7(e){let t=(0,G.c)(7),{metadata:n}=e;if(!n)return null;let r,i,a;if(t[0]!==n){a=Symbol.for(`react.early_return_sentinel`);bb0:{let e=f7(n);if(!e){a=null;break bb0}r=`text-muted-foreground mt-2 text-xs tabular-nums opacity-60`,i=p7(e)}t[0]=n,t[1]=r,t[2]=i,t[3]=a}else r=t[1],i=t[2],a=t[3];if(a!==Symbol.for(`react.early_return_sentinel`))return a;let o;return t[4]!==r||t[5]!==i?(o=(0,z.jsx)(`div`,{className:r,children:i}),t[4]=r,t[5]=i,t[6]=o):o=t[6],o}function w7(e,t){return qh(e.metadata)?e.metadata[t]:void 0}function T7(e){let t=w7(e,`reminders`);return Array.isArray(t)?t.filter(e=>{if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.id==`string`&&t.id.length>0&&typeof t.text==`string`&&t.text.trim().length>0}):[]}function E7(e){let t=w7(e,`uploads`);return Array.isArray(t)?t.flatMap(e=>{let t=h7.safeParse(e);return t.success?[t.data]:[]}):[]}function D7(e){let t=(0,G.c)(7),{text:n}=e,[r,i]=(0,R.useState)(!1),a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=()=>i(O7),t[0]=a):a=t[0];let o=!r&&`line-clamp-3`,s;t[1]===o?s=t[2]:(s=I(`hover:text-foreground w-full cursor-pointer text-left whitespace-pre-wrap`,o),t[1]=o,t[2]=s);let c;return t[3]!==r||t[4]!==s||t[5]!==n?(c=(0,z.jsx)(`li`,{children:(0,z.jsx)(`button`,{type:`button`,onClick:a,"aria-pressed":r,className:s,children:n})}),t[3]=r,t[4]=s,t[5]=n,t[6]=c):c=t[6],c}function O7(e){return!e}function k7(e){let t=(0,G.c)(8),{reminders:n}=e,[r,i]=(0,R.useState)(!1);if(n.length===0)return null;let a=`${n.length} reminder${n.length===1?``:`s`} attached`,o;t[0]===n?o=t[1]:(o=n.map(A7),t[0]=n,t[1]=o);let s;t[2]===o?s=t[3]:(s=(0,z.jsx)(`ul`,{className:`border-ink-12 text-muted-foreground space-y-1 border-l pl-3 text-xs`,children:o}),t[2]=o,t[3]=s);let c;return t[4]!==a||t[5]!==r||t[6]!==s?(c=(0,z.jsx)(S7,{label:a,open:r,onOpenChange:i,className:`mt-1`,triggerClassName:`text-muted-foreground hover:text-foreground gap-1.5 text-xs`,contentClassName:`mt-1.5`,chevronClassName:`size-3.5`,children:s}),t[4]=a,t[5]=r,t[6]=s,t[7]=c):c=t[7],c}function A7(e){return(0,z.jsx)(D7,{text:e.text},e.id)}function j7(e){let t=(0,G.c)(19),{upload:n}=e;if(n.mediaType.startsWith(`video/`)){let e;t[0]!==n.name||t[1]!==n.url?(e=(0,z.jsx)(`video`,{src:n.url,"aria-label":n.name,muted:!0,playsInline:!0,preload:`metadata`,className:`size-full object-cover`}),t[0]=n.name,t[1]=n.url,t[2]=e):e=t[2];let r;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,z.jsx)(`span`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-0 flex items-center justify-center text-2xl text-white drop-shadow`,children:`▶`}),t[3]=r):r=t[3];let i;return t[4]!==e||t[5]!==n.name?(i=(0,z.jsxs)(Ji,{variant:`image`,className:`size-36 rounded-2xl`,title:n.name,children:[e,r]}),t[4]=e,t[5]=n.name,t[6]=i):i=t[6],i}if(n.mediaType.startsWith(`audio/`)){let e;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,z.jsx)(`span`,{"aria-hidden":!0,className:`text-2xl`,children:`♪`}),t[7]=e):e=t[7];let r;t[8]===n.name?r=t[9]:(r=(0,z.jsx)(`span`,{className:`text-foreground w-full truncate text-center`,children:n.name}),t[8]=n.name,t[9]=r);let i;t[10]===n.mediaType?i=t[11]:(i=(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:n.mediaType}),t[10]=n.mediaType,t[11]=i);let a;return t[12]!==r||t[13]!==i||t[14]!==n.name?(a=(0,z.jsxs)(Ji,{variant:`icon`,className:`h-36 w-48 flex-col gap-1 rounded-2xl px-3 text-xs`,title:n.name,"aria-label":n.name,children:[e,r,i]}),t[12]=r,t[13]=i,t[14]=n.name,t[15]=a):a=t[15],a}let r;return t[16]!==n.name||t[17]!==n.url?(r=(0,z.jsx)(Ji,{variant:`image`,className:`size-36 rounded-2xl`,children:(0,z.jsx)(`img`,{src:n.url,alt:n.name})}),t[16]=n.name,t[17]=n.url,t[18]=r):r=t[18],r}function M7(e){let t=(0,G.c)(13),{message:n}=e,r,i,a,o,s,c;if(t[0]!==n){c=Symbol.for(`react.early_return_sentinel`);bb0:{let e=E7(n);if(e.length===0){c=null;break bb0}r=Yi,i=`list`,a=`Attached files`,o=`max-w-full gap-2 py-0`,s=e.map(N7)}t[0]=n,t[1]=r,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c}else r=t[1],i=t[2],a=t[3],o=t[4],s=t[5],c=t[6];if(c!==Symbol.for(`react.early_return_sentinel`))return c;let l;return t[7]!==r||t[8]!==i||t[9]!==a||t[10]!==o||t[11]!==s?(l=(0,z.jsx)(r,{role:i,"aria-label":a,className:o,children:s}),t[7]=r,t[8]=i,t[9]=a,t[10]=o,t[11]=s,t[12]=l):l=t[12],l}function N7(e){return(0,z.jsx)(`div`,{role:`listitem`,"data-slot":`attachment`,children:(0,z.jsx)(j7,{upload:e})},e.path)}function P7(e){let t=(0,G.c)(10),{body:n,reminders:r,metadata:i}=e,a;t[0]===n?a=t[1]:(a=(0,z.jsx)(`div`,{className:`flex-1 space-y-3`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=(0,z.jsx)(k7,{reminders:r}),t[2]=r,t[3]=o);let s;t[4]===i?s=t[5]:(s=i!==void 0&&(0,z.jsx)(C7,{metadata:i}),t[4]=i,t[5]=s);let c;return t[6]!==a||t[7]!==o||t[8]!==s?(c=(0,z.jsxs)(`div`,{className:`bg-secondary flex max-w-[80%] flex-col gap-3 rounded-lg p-3`,children:[a,o,s]}),t[6]=a,t[7]=o,t[8]=s,t[9]=c):c=t[9],c}function F7(e){let t=(0,G.c)(28),{message:n}=e;w7(n,`reminders`);let r;t[0]===n?r=t[1]:(r=Rb(n),t[0]=n,t[1]=r);let i;t[2]===n?i=t[3]:(i=T7(n),t[2]=n,t[3]=i);let a;t[4]!==r||t[5]!==i?(a={message:r,reminders:i},t[4]=r,t[5]=i,t[6]=a):a=t[6];let{message:o,reminders:s}=a,c;if(t[7]!==n){let e=w7(n,`alias`);c=typeof e==`string`&&e.trim().length>0?e:void 0,t[7]=n,t[8]=c}else c=t[8];let l=c;if(l){let e;t[9]===l?e=t[10]:(e=(0,z.jsx)(`div`,{dir:`auto`,className:`text-sm whitespace-pre-wrap`,children:l}),t[9]=l,t[10]=e);let n;return t[11]!==s||t[12]!==e?(n=(0,z.jsx)(P7,{reminders:s,body:e}),t[11]=s,t[12]=e,t[13]=n):n=t[13],n}let u;t[14]===o?u=t[15]:(u=(0,z.jsx)(M7,{message:o}),t[14]=o,t[15]=u);let d=o.metadata,f;if(t[16]!==o.id||t[17]!==o.parts){let e;t[19]===o.id?e=t[20]:(e=(e,t)=>e.type===`text`?(0,z.jsx)(`div`,{dir:`auto`,className:`text-sm whitespace-pre-wrap`,children:(0,z.jsx)(d4,{text:e.text})},`${o.id}-${t}-text`):null,t[19]=o.id,t[20]=e),f=o.parts.map(e),t[16]=o.id,t[17]=o.parts,t[18]=f}else f=t[18];let p;t[21]!==o.metadata||t[22]!==s||t[23]!==f?(p=(0,z.jsx)(P7,{reminders:s,metadata:d,body:f}),t[21]=o.metadata,t[22]=s,t[23]=f,t[24]=p):p=t[24];let m;return t[25]!==u||t[26]!==p?(m=(0,z.jsxs)(`div`,{className:`flex w-full min-w-0 flex-col items-end gap-3`,children:[u,p]}),t[25]=u,t[26]=p,t[27]=m):m=t[27],m}var I7=(0,R.memo)(function(e){let t=(0,G.c)(7),{className:n}=e,{message:r}=B6(),i;t[0]===n?i=t[1]:(i=I(`flex justify-end`,n),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=(0,z.jsx)(F7,{message:r}),t[2]=r,t[3]=a);let o;return t[4]!==i||t[5]!==a?(o=(0,z.jsx)(`div`,{className:i,children:a}),t[4]=i,t[5]=a,t[6]=o):o=t[6],o});function L7(e){return e.kind===`tool`?!X8(e.part):e.kind===`dynamic-tool`||e.kind===`reasoning`}function R7(e,t){return e.kind===`tool`?!0:e.kind===`reasoning`||e.kind===`dynamic-tool`?!!t:!1}function z7(e){return e.kind===`text`&&e.parts.some(({part:e})=>e.type===`text`&&!T5(e))}function B7(e,t){let n=[];for(let r=0;r<e.length;r++){let i=e[r];if(!L7(i)){n.push({kind:`segment`,segment:i,segmentIndex:r});continue}let a=[],o=r;for(;r<e.length&&L7(e[r]);){let n=e[r];R7(n,t)&&a.push({segment:n}),r++}r--,a.length>0&&n.push({kind:`group`,items:a,hasLaterText:e.slice(r+1).some(e=>z7(e)),firstIndex:o})}return n}function V7(e){if(e.kind!==`tool`&&e.kind!==`dynamic-tool`)return;let{part:t}=e;return Tv(t)?t.state:void 0}function H7({groupStatus:e,labelCount:t}){return e===`running`?{title:`text-info`,detail:`text-info/80`,chevron:`text-info`}:e===`aborted`?{title:`text-destructive`,detail:`text-destructive/80`,chevron:`text-destructive`}:e===`error`?t===1?{title:`text-destructive`,detail:`text-destructive/80`,chevron:`text-destructive`}:{title:`text-warning`,detail:`text-warning/80`,chevron:`text-warning`}:{title:`text-muted-foreground`,detail:`text-muted-foreground`,chevron:`text-muted-foreground`}}function U7(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function W7(e,t=80){let n=e.replace(/\s+/g,` `).trim();return n.length<=t?n:`${n.slice(0,t-3).trimEnd()}...`}function G7(e){if(typeof e==`string`)return W7(e,48);if(typeof e==`number`||typeof e==`boolean`)return String(e);if(Array.isArray(e))return`${e.length} items`}function K7(e){if(!U7(e))return;let t=[`command`,`query`,`path`,`file`,`table`,`metric`,`dimension`,`checks`],n=[...t.filter(t=>t in e).map(t=>[t,e[t]]),...Object.entries(e).filter(([e])=>!t.includes(e))],r={};for(let[e,t]of n){let n=G7(t);if(n&&(r[e]=n,Object.keys(r).length>=2))break}return Object.keys(r).length>0?r:void 0}function q7(e){if(U7(e))for(let t of[`reasoning`,`thoughts`,`thought`,`hint`,`detail`]){let n=e[t];if(typeof n==`string`&&n.trim().length>0)return W7(n)}}function J7(e){if(e.kind!==`reasoning`)return;let{part:t}=e;if(t.type===`reasoning`)return W7(t.text,96)}function Y7(e,t){if(e.kind===`reasoning`)return{kind:`reasoning`,name:`reasoning`,detail:J7(e)};if(e.kind===`dynamic-tool`&&e.part.type===`dynamic-tool`){let t=e.part;return{kind:`dynamic-tool`,name:t.toolName||`Tool`,args:K7(t.input),detail:q7(t.input)}}if(e.kind===`tool`&&Cv(e.part)){let n=e.part,{toolEntry:r,toolKey:i}=Z8(n,t),a=r?.label?.(n);return{kind:`tool`,name:a?.name??i,args:a?.args??K7(n.input),detail:a?.detail??q7(n.input),isError:a?.isError}}return{kind:`tool`,name:`Step`}}function X7(e){if(!e)return;let t=Object.entries(e).filter(e=>typeof e[1]==`string`&&e[1].trim().length>0);if(t.length!==0)return t.slice(0,2).map(([e,t])=>`${e}: ${W7(t,36)}`).join(`, `)}function Z7(e){let t=X7(e.args);return t?`${e.name}(${t})`:e.name}function Q7(e){return e===`output-available`||e===`output-error`||e===`output-denied`}function $7(e){return!!e&&!Q7(e)}function e9(e,t){return A6(e,t)}function t9({items:e,labels:t,status:n,hasLaterText:r}){return e.some(({segment:e})=>e9(V7(e),n))?`aborted`:!r&&(n===`streaming`||n===`submitted`)?`running`:t.some(e=>e.isError)||e.some(({segment:e})=>{let t=V7(e);return t===`output-error`||t===`output-denied`})?`error`:e.some(({segment:e})=>$7(V7(e)))||!r&&t.every(e=>e.kind===`reasoning`)&&(n===`streaming`||n===`submitted`)?`running`:`complete`}function n9(e){return e&&`${e[0].toUpperCase()}${e.slice(1)}`}function r9(e){return e.filter(e=>e.kind!==`reasoning`).length}function i9(e,t){let n=r9(e);if(n!==0)return`${t===`running`||t===`aborted`?`running`:`ran`} ${n} ${n===1?`tool`:`tools`}`}function a9(e,t){let n=i9(e,t);if(n)return n9(t===`error`?`${n} with issues`:t===`aborted`?`cancelled after ${n}`:n)}function o9(e,t,n){let r=e.length===1?e[0]:void 0;if(t===`running`)return n||(r?.kind===`reasoning`?`Reasoning${r.detail?` ${r.detail}`:``}`:e.every(e=>e.kind===`reasoning`)?`Reasoning`:`Working...`);if(r){let e=Z7(r);return t===`error`?`Failed ${e}`:t===`aborted`?`Cancelled ${e}`:r.kind===`reasoning`?`Reasoned${r.detail?` ${r.detail}`:``}`:`Called ${e}`}return e.every(e=>e.kind===`reasoning`)?`Reasoned`:a9(e,t)??`Ran tools`}function s9(e,t){if(t!==`running`){if(e.length===1){let t=e[0];return t.kind===`reasoning`?void 0:t.detail}return Array.from(new Set([...e].sort((e,t)=>e.kind===`reasoning`&&t.kind!==`reasoning`?1:e.kind!==`reasoning`&&t.kind===`reasoning`?-1:0).map(e=>e.name))).slice(0,3).join(`, `)||void 0}}function c9(e){let t;for(let n=e.length-1;n>=0;n--){let r=e[n].segment;if(r.kind===`dynamic-tool`&&r.part.type===`dynamic-tool`){let e=q7(r.part.input);if(e)return e}if(r.kind===`tool`&&Cv(r.part)){let e=q7(r.part.input);if(e)return e}r.kind===`reasoning`&&(t??=J7(r))}return t}function l9(e,t){return!e||e.role!==`assistant`?!1:B7(V5(e.parts),t).some(e=>e.kind===`group`&&!e.hasLaterText)}function u9(){let e=(0,G.c)(8),{message:t}=B6(),{debugMode:n}=C6(),r;e[0]===t.parts?r=e[1]:(r=V5(t.parts),e[0]=t.parts,e[1]=r);let i=r,a;if(e[2]!==n||e[3]!==t.id||e[4]!==i){let r;e[6]===t.id?r=e[7]:(r=e=>e.kind===`group`?{...e,key:`${t.id}-${e.firstIndex}-group-${e.hasLaterText?`past`:`current`}`}:{...e,key:`${t.id}-${H5(e.segment,e.segmentIndex)}-${e.segment.kind}`},e[6]=t.id,e[7]=r),a=B7(i,n).map(r),e[2]=n,e[3]=t.id,e[4]=i,e[5]=a}else a=e[5];return a}var d9=(0,R.createContext)(null);function f9(){let e=(0,R.use)(d9);if(!e)throw Error(`CompactTrajectory group parts must be rendered within CompactTrajectory.Group`);return e}function p9(e){let t=(0,G.c)(21),{group:n,children:r}=e,{registry:i}=C6(),{message:a}=B6(),o=z6(),[s,c]=(0,R.useState)(!n.hasLaterText),l,u,d;if(t[0]!==n.hasLaterText||t[1]!==n.items||t[2]!==i||t[3]!==o){let e;t[7]===i?e=t[8]:(e=e=>{let{segment:t}=e;return Y7(t,i)},t[7]=i,t[8]=e),u=n.items.map(e),l=t9({items:n.items,labels:u,status:o,hasLaterText:n.hasLaterText}),d=H7({groupStatus:l,labelCount:u.length}),t[0]=n.hasLaterText,t[1]=n.items,t[2]=i,t[3]=o,t[4]=l,t[5]=u,t[6]=d}else l=t[4],u=t[5],d=t[6];let f=d,p;t[9]!==n.items||t[10]!==l||t[11]!==u||t[12]!==a.id||t[13]!==f?(p={items:n.items,labels:u,groupStatus:l,tone:f,messageId:a.id},t[9]=n.items,t[10]=l,t[11]=u,t[12]=a.id,t[13]=f,t[14]=p):p=t[14];let m;t[15]!==r||t[16]!==s?(m=(0,z.jsx)(Pa,{open:s,onOpenChange:c,className:`my-2 min-w-0`,children:r}),t[15]=r,t[16]=s,t[17]=m):m=t[17];let h;return t[18]!==p||t[19]!==m?(h=(0,z.jsx)(d9,{value:p,children:m}),t[18]=p,t[19]=m,t[20]=h):h=t[20],h}function m9(e){let t=(0,G.c)(3),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,z.jsx)(`button`,{type:`button`,className:F6(`items-start`)}),t[0]=r):r=t[0];let i;return t[1]===n?i=t[2]:(i=(0,z.jsx)(Fa,{render:r,children:(0,z.jsx)(`span`,{className:`min-w-0 flex-1 text-left text-sm`,children:n})}),t[1]=n,t[2]=i),i}function h9(){let e=(0,G.c)(12),{items:t,labels:n,groupStatus:r,tone:i}=f9(),a;e[0]!==r||e[1]!==t||e[2]!==n?(a=o9(n,r,c9(t)),e[0]=r,e[1]=t,e[2]=n,e[3]=a):a=e[3];let o=a,s;e[4]!==r||e[5]!==n?(s=s9(n,r),e[4]=r,e[5]=n,e[6]=s):s=e[6];let c=s,l;return e[7]!==c||e[8]!==r||e[9]!==o||e[10]!==i?(l={title:o,detail:c,tone:i,groupStatus:r},e[7]=c,e[8]=r,e[9]=o,e[10]=i,e[11]=l):l=e[11],l}function g9(e){let t=(0,G.c)(9),{title:n,suffix:r,children:i}=e,{title:a,tone:o,groupStatus:s}=h9(),c=n??a,l=r?`${c} · ${r}`:c,u=s===`running`,d=s===`running`?`text-info`:o.title,f;t[0]===d?f=t[1]:(f=I(`max-w-full min-w-0 truncate`,d),t[0]=d,t[1]=f);let p;t[2]!==u||t[3]!==f||t[4]!==l?(p=(0,z.jsx)(N6,{as:`span`,enabled:u,className:f,children:l}),t[2]=u,t[3]=f,t[4]=l,t[5]=p):p=t[5];let m;return t[6]!==i||t[7]!==p?(m=(0,z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[p,i]}),t[6]=i,t[7]=p,t[8]=m):m=t[8],m}function _9(){let e=(0,G.c)(2),{tone:t}=f9(),n;return e[0]===t.chevron?n=e[1]:(n=(0,z.jsx)(P6,{className:t.chevron}),e[0]=t.chevron,e[1]=n),n}function v9(e){let t=(0,G.c)(5),{detail:n}=e,{title:r,detail:i,tone:a}=h9();if(n===null)return null;let o=n??i;if(!o||o===r)return null;let s;t[0]===a.detail?s=t[1]:(s=I(`block truncate text-xs`,a.detail),t[0]=a.detail,t[1]=s);let c;return t[2]!==o||t[3]!==s?(c=(0,z.jsx)(`span`,{className:s,children:o}),t[2]=o,t[3]=s,t[4]=c):c=t[4],c}function y9(e){let t=(0,G.c)(14),{children:n}=e,{items:r,messageId:i,groupStatus:a}=f9(),o=a===`running`,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s={initial:`instant`,resize:`instant`},t[0]=s):s=t[0];let{scrollRef:c,contentRef:l}=jj(s),u=o?c:void 0,d=o&&`max-h-64 overflow-y-auto`,f;t[1]===d?f=t[2]:(f=I(`mt-2`,d),t[1]=d,t[2]=f);let p=o?l:void 0,m;t[3]!==n||t[4]!==r||t[5]!==i?(m=n??r.map((e,t)=>{let{segment:n}=e,r=`${i}-${H5(n,t)}-${n.kind}`;return n.kind===`tool`?(0,z.jsx)(L5.Tool,{segment:n},r):n.kind===`reasoning`?(0,z.jsx)(L5.Reasoning,{segment:n},r):n.kind===`dynamic-tool`?(0,z.jsx)(L5.DynamicTool,{segment:n},r):null}),t[3]=n,t[4]=r,t[5]=i,t[6]=m):m=t[6];let h;t[7]!==p||t[8]!==m?(h=(0,z.jsx)(`div`,{ref:p,children:m}),t[7]=p,t[8]=m,t[9]=h):h=t[9];let g;return t[10]!==u||t[11]!==f||t[12]!==h?(g=(0,z.jsx)(Ia,{ref:u,className:f,children:h}),t[10]=u,t[11]=f,t[12]=h,t[13]=g):g=t[13],g}function b9(e){let t=(0,G.c)(19),{item:n,textClassName:r}=e,i=r===void 0?`my-4`:r,{elements:a}=R6(),{segment:o}=n;if(o.kind===`text`){let e;t[0]===o.parts?e=t[1]:(e=o.parts.filter(x9),t[0]=o.parts,t[1]=e);let n=e;if(n.length===0)return null;let r;t[2]!==o||t[3]!==n?(r={...o,parts:n},t[2]=o,t[3]=n,t[4]=r):r=t[4];let s;return t[5]!==a||t[6]!==r||t[7]!==i?(s=(0,z.jsx)(L5.Text,{segment:r,elements:a,className:i}),t[5]=a,t[6]=r,t[7]=i,t[8]=s):s=t[8],s}if(o.kind===`file`){let e;return t[9]===o?e=t[10]:(e=(0,z.jsx)(L5.File,{segment:o}),t[9]=o,t[10]=e),e}if(o.kind===`source`){let e;return t[11]===o?e=t[12]:(e=(0,z.jsx)(L5.Source,{segment:o}),t[11]=o,t[12]=e),e}if(o.kind===`tool`){let e;return t[13]===o?e=t[14]:(e=(0,z.jsx)(L5.Tool,{segment:o}),t[13]=o,t[14]=e),e}if(o.kind===`reasoning`){let e;return t[15]===o?e=t[16]:(e=(0,z.jsx)(L5.Reasoning,{segment:o}),t[15]=o,t[16]=e),e}if(o.kind===`dynamic-tool`){let e;return t[17]===o?e=t[18]:(e=(0,z.jsx)(L5.DynamicTool,{segment:o}),t[17]=o,t[18]=e),e}return null}function x9(e){let{part:t}=e;return!T5(t)}function S9(){let e=(0,G.c)(1),t=z6(),{messages:n}=R6(),{debugMode:r}=C6(),i=n[n.length-1];if(t!==`ready`&&t!==`error`&&l9(i,r))return null;let a;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,z.jsx)(s7,{}),e[0]=a):a=e[0],a}var C9={Root:Q5,List:$5,Item:e7,UserBubble:I7,AssistantContent:(0,R.memo)(function(e){let t=(0,G.c)(5),{className:n}=e,r=u9(),i;t[0]===r?i=t[1]:(i=r.map(Fee),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,z.jsx)(`div`,{className:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a}),Actions:K5,CopyAction:q5,RegenerateAction:J5,CopyDebugJsonAction:Y5,Thinking:S9,Error:Z5};function Fee(e){return e.kind===`group`?(0,z.jsxs)(p9,{group:e,children:[(0,z.jsxs)(m9,{children:[(0,z.jsx)(g9,{children:(0,z.jsx)(_9,{})}),(0,z.jsx)(v9,{})]}),(0,z.jsx)(y9,{})]},e.key):(0,z.jsx)(b9,{item:e},e.key)}function Iee(e){let t=(0,G.c)(8),{message:n,className:r}=e,i;t[0]===r?i=t[1]:(i=I(`text-destructive/90 bg-destructive/10 flex items-start gap-2 rounded-md px-3 py-2 text-sm`,r),t[0]=r,t[1]=i);let a;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,z.jsx)(_t,{className:`text-destructive mt-0.5 size-4 shrink-0`}),t[2]=a):a=t[2];let o;t[3]===n?o=t[4]:(o=(0,z.jsx)(`span`,{children:n}),t[3]=n,t[4]=o);let s;return t[5]!==i||t[6]!==o?(s=(0,z.jsxs)(`div`,{className:i,children:[a,o]}),t[5]=i,t[6]=o,t[7]=s):s=t[7],s}function Lee(e){let t=(0,G.c)(15),{part:n}=e,r=C6(),i,a;if(t[0]!==r.registry||t[1]!==n){a=Symbol.for(`react.early_return_sentinel`);bb0:{let{toolEntry:e}=Z8(n,r.registry);if(e&&Q8(e,n.state)){let t=e.label?.(n);if(!t){a=null;break bb0}let r=t.icon,i=t.args?Object.values(t.args)[0]:void 0;a=(0,z.jsxs)(`div`,{className:`text-muted-foreground flex items-center text-xs`,children:[r&&(0,z.jsx)(r,{className:`size-3.5`}),(0,z.jsx)(`span`,{className:`ms-2 font-mono`,children:t.name}),i&&(0,z.jsxs)(`span`,{className:`truncate`,children:[`(`,i,`)`]})]});break bb0}i=e?.label?.(n)}t[0]=r.registry,t[1]=n,t[2]=i,t[3]=a}else i=t[2],a=t[3];if(a!==Symbol.for(`react.early_return_sentinel`))return a;let o=i,s;t[4]!==o||t[5]!==n?(s=o&&(0,z.jsx)(x5,{label:o,part:n}),t[4]=o,t[5]=n,t[6]=s):s=t[6];let c;t[7]===o?c=t[8]:(c=o?.isError&&o.detail&&(0,z.jsx)(Iee,{message:o.detail}),t[7]=o,t[8]=c);let l;t[9]===n?l=t[10]:(l=(0,z.jsx)(_5,{part:n}),t[9]=n,t[10]=l);let u;return t[11]!==s||t[12]!==c||t[13]!==l?(u=(0,z.jsxs)(z.Fragment,{children:[s,c,l]}),t[11]=s,t[12]=c,t[13]=l,t[14]=u):u=t[14],u}function Ree(e){let t=(0,G.c)(5),{part:n}=e,[r,i]=(0,R.useState)(!1),a;t[0]===n.text?a=t[1]:(a=(0,z.jsx)(M8,{mode:`static`,children:n.text}),t[0]=n.text,t[1]=a);let o;return t[2]!==r||t[3]!==a?(o=(0,z.jsx)(`div`,{"data-copy-exclude":`assistant-snapshot`,className:`bg-muted/30 prose max-w-auto prose-sm text-muted-foreground border-border mb-4 w-full min-w-full rounded-lg p-3`,children:(0,z.jsx)(S7,{label:`Reasoning`,open:r,onOpenChange:i,className:`text-xs`,triggerClassName:`w-full gap-x-2 text-sm hover:opacity-80`,contentClassName:`mt-2`,children:a})}),t[2]=r,t[3]=a,t[4]=o):o=t[4],o}function zee(e){let t=(0,G.c)(16),{part:n}=e,{elements:r}=R6(),i=v5();if(n.type===`text`){if(T5(n))return null;let e;return t[0]!==r||t[1]!==n.citations||t[2]!==n.text?(e=(0,z.jsx)(g5,{text:n.text,citations:n.citations,elements:r}),t[0]=r,t[1]=n.citations,t[2]=n.text,t[3]=e):e=t[3],e}if(n.type===`dynamic-tool`){let e;return t[4]!==i||t[5]!==n?(e=i?(0,z.jsx)(K8,{part:n}):null,t[4]=i,t[5]=n,t[6]=e):e=t[6],e}if(Cv(n)){let e;return t[7]===n?e=t[8]:(e=(0,z.jsx)(Lee,{part:n}),t[7]=n,t[8]=e),e}if(n.type===`reasoning`&&n.text){let e;return t[9]!==i||t[10]!==n?(e=i?(0,z.jsx)(Ree,{part:n}):null,t[9]=i,t[10]=n,t[11]=e):e=t[11],e}if(n.type===`file`){let e;return t[12]!==n.filename||t[13]!==n.mediaType||t[14]!==n.url?(e=(0,z.jsx)(u5,{filename:n.filename,mediaType:n.mediaType,url:n.url}),t[12]=n.filename,t[13]=n.mediaType,t[14]=n.url,t[15]=e):e=t[15],e}return null}(0,R.memo)(function(e){let t=(0,G.c)(10),{className:n}=e,{message:r}=B6(),i;t[0]===n?i=t[1]:(i=I(`flex-1 space-y-3`,n),t[0]=n,t[1]=i);let a;if(t[2]!==r.id||t[3]!==r.parts){let e;t[5]===r.id?e=t[6]:(e=(e,t)=>(0,z.jsx)(zee,{part:e},`${r.id}-${t}`),t[5]=r.id,t[6]=e),a=r.parts.map(e),t[2]=r.id,t[3]=r.parts,t[4]=a}else a=t[4];let o;return t[7]!==i||t[8]!==a?(o=(0,z.jsx)(`div`,{className:i,children:a}),t[7]=i,t[8]=a,t[9]=o):o=t[9],o});var Bee={braille:{frames:[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`],interval:80},pulse:{frames:[`⠁`,`⠉`,`⠋`,`⠛`,`⠟`,`⠿`,`⡿`,`⣿`,`⡿`,`⠿`,`⠟`,`⠛`,`⠋`,`⠉`,`⠁`,`⠀`],interval:80},clock:{frames:[`⠁`,`⠈`,`⠐`,`⠠`,`⢀`,`⡀`,`⠄`,`⠂`],interval:100},limerence:{frames:[`⠁`,`⠃`,`⠇`,`⡇`,`⣇`,`⣇`,`⣆`,`⣄`,`⣀`,`⢀`,`⠀`],interval:100}};function Vee(e){let t=(0,G.c)(15),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,variant:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0?`braille`:i,o=ln(),{frames:s,interval:c}=Bee[a],[l,u]=(0,R.useState)(0),d,f;t[4]!==o||t[5]!==s.length||t[6]!==c?(d=()=>{if(window.matchMedia(`(prefers-reduced-motion: reduce)`).matches)return;let e=o.setInterval(()=>{u(e=>(e+1)%s.length)},c);return()=>o.clearInterval(e)},f=[o,s.length,c],t[4]=o,t[5]=s.length,t[6]=c,t[7]=d,t[8]=f):(d=t[7],f=t[8]),(0,R.useEffect)(d,f);let p;t[9]===n?p=t[10]:(p=I(`inline-block`,n),t[9]=n,t[10]=p);let m=s[l],h;return t[11]!==r||t[12]!==p||t[13]!==m?(h=(0,z.jsx)(`span`,{role:`status`,"aria-label":`Loading`,className:p,...r,children:m}),t[11]=r,t[12]=p,t[13]=m,t[14]=h):h=t[14],h}function Hee(e){let t=(0,G.c)(11),{Icon:n,isLast:r,isLoading:i,aborted:a,state:o,isError:s}=e,c;t[0]!==n||t[1]!==a||t[2]!==s||t[3]!==i||t[4]!==o?(c=i?(0,z.jsx)(Vee,{className:`text-muted-foreground z-10 shrink-0 text-sm`}):a?(0,z.jsx)(Jn,{className:`text-destructive z-10 size-3.5 shrink-0`}):(0,z.jsx)(n,{className:I(`z-10 size-3.5 shrink-0`,o===`output-error`||s?`text-destructive`:`text-muted-foreground`)}),t[0]=n,t[1]=a,t[2]=s,t[3]=i,t[4]=o,t[5]=c):c=t[5];let l;t[6]===r?l=t[7]:(l=!r&&(0,z.jsx)(`span`,{className:`bg-border w-px flex-1`}),t[6]=r,t[7]=l);let u;return t[8]!==c||t[9]!==l?(u=(0,z.jsxs)(`div`,{className:`absolute top-0 left-0 flex h-full flex-col items-center`,children:[c,l]}),t[8]=c,t[9]=l,t[10]=u):u=t[10],u}function Uee(e){let t=(0,G.c)(15),{isLast:n,label:r,state:i,aborted:a,children:o}=e,s=(0,R.use)(M5),c=r??s?.label,l=i??s?.state,u=a??s?.aborted??!1,d=c?.icon,f=!!l&&!u&&l!==`output-available`&&l!==`output-error`,p;t[0]!==d||t[1]!==u||t[2]!==c?.isError||t[3]!==l||t[4]!==n||t[5]!==f?(p=d?(0,z.jsx)(Hee,{Icon:d,isLast:n,isLoading:f,aborted:u,state:l,isError:c?.isError??!1}):(0,z.jsx)(a7,{isLast:n}),t[0]=d,t[1]=u,t[2]=c?.isError,t[3]=l,t[4]=n,t[5]=f,t[6]=p):p=t[6];let m=p,h=n?``:`pb-3.5`,g;t[7]===h?g=t[8]:(g=I(`min-w-0 flex-1`,h),t[7]=h,t[8]=g);let _;t[9]!==o||t[10]!==g?(_=(0,z.jsx)(`div`,{className:g,children:o}),t[9]=o,t[10]=g,t[11]=_):_=t[11];let v;return t[12]!==m||t[13]!==_?(v=(0,z.jsx)(o7,{marker:m,children:_}),t[12]=m,t[13]=_,t[14]=v):v=t[14],v}function Wee(e){let t=(0,G.c)(10),{label:n,state:r,part:i,defaultOpen:a,children:o}=e,s=a!==void 0&&a,c;t[0]!==n||t[1]!==i||t[2]!==r?(c=(0,z.jsx)(Fa,{className:`cursor-pointer`,children:(0,z.jsx)(C5,{label:n,state:r,part:i})}),t[0]=n,t[1]=i,t[2]=r,t[3]=c):c=t[3];let l;t[4]===o?l=t[5]:(l=(0,z.jsx)(Ia,{children:o}),t[4]=o,t[5]=l);let u;return t[6]!==s||t[7]!==c||t[8]!==l?(u=(0,z.jsxs)(Pa,{defaultOpen:s,className:`flex min-w-0 flex-1 flex-col`,children:[c,l]}),t[6]=s,t[7]=c,t[8]=l,t[9]=u):u=t[9],u}var w9={Item:Uee,Disclosure:Wee};(0,R.memo)(function(e){let t=(0,G.c)(12),{className:n}=e,{message:r}=B6(),{elements:i}=R6(),{debugMode:a}=C6(),o=v5(),s=Y8(),c;t[0]===r.parts?c=t[1]:(c=V5(r.parts),t[0]=r.parts,t[1]=c);let l=c,u;t[2]!==a||t[3]!==i||t[4]!==s||t[5]!==r.id||t[6]!==l||t[7]!==o?(u=l.map((e,t)=>{let n=`${r.id}-${H5(e,t)}-${e.kind}`;if(e.kind===`text`)return(0,z.jsx)(L5.Text,{segment:e,elements:i,className:`my-4`},n);if(e.kind===`file`)return(0,z.jsx)(L5.File,{segment:e},n);if(e.kind===`source`)return(0,z.jsx)(L5.Source,{segment:e},n);if(e.kind===`dynamic-tool`){if(!o)return null;let r=!B5(l,t,!0);return(0,z.jsx)(w9.Item,{isLast:r,children:(0,z.jsx)(L5.DynamicTool,{segment:e})},n)}if(e.kind===`reasoning`){if(s||e.part.type!==`reasoning`)return null;let r=!B5(l,t,a),i={name:`Reasoning`,icon:ci,args:{text:[...e.part.text].slice(0,60).join(``)}};return(0,z.jsx)(w9.Item,{isLast:r,label:i,children:(0,z.jsx)(w9.Disclosure,{label:i,children:(0,z.jsx)(L5.Reasoning,{segment:e})})},n)}if(e.kind===`tool`){let r=!B5(l,t,a);return(0,z.jsx)(L5.Tool,{segment:e,children:(0,z.jsx)(w9.Item,{isLast:r,children:(0,z.jsx)(L5.ToolDisclosure,{})})},n)}return null}),t[2]=a,t[3]=i,t[4]=s,t[5]=r.id,t[6]=l,t[7]=o,t[8]=u):u=t[8];let d;return t[9]!==n||t[10]!==u?(d=(0,z.jsx)(`div`,{className:n,children:u}),t[9]=n,t[10]=u,t[11]=d):d=t[11],d});function Gee(e){let t=(0,G.c)(9),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let{hasSubmitted:i}=T6(),a;t[3]===n?a=t[4]:(a=I(`bg-background sticky bottom-0 rounded-t-2xl border-0 **:data-[slot=composer-editor]:!min-h-15`,n),t[3]=n,t[4]=a);let o;return t[5]!==i||t[6]!==r||t[7]!==a?(o=(0,z.jsx)(l4.Root,{hasInteracted:i,className:a,...r}),t[5]=i,t[6]=r,t[7]=a,t[8]=o):o=t[8],o}function Kee(e){let t=(0,G.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=I(`border-border bg-card focus-within:border-primary/80 focus-within:ring-primary/15 relative rounded-2xl border`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,z.jsx)(`div`,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function qee(e){let t=(0,G.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=I(`space-y-1 px-3.5 pt-3`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,z.jsx)(l4.Content,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Jee(e){let t=(0,G.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=I(`!min-h-15 !rounded-none !border-0 !bg-transparent !shadow-none **:data-[slot=composer-editor]:!p-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,z.jsx)(l4.Editor,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Yee(e){let t=(0,G.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=I(`pb-1.5`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,z.jsx)(l4.Attachments,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Xee(e){let t=(0,G.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=I(`p-1.5 pt-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,z.jsx)(l4.Toolbar,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Zee(e){let t=(0,G.c)(3),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,z.jsx)(W5,{icon:(0,z.jsx)(yi,{className:`size-4`})}),t[0]=n):n=t[0];let r;return t[1]===e?r=t[2]:(r=(0,z.jsx)(l4.AttachFiles,{"aria-label":`Attach files`,render:n,...e}),t[1]=e,t[2]=r),r}function Qee(){let e=(0,G.c)(6),{actions:t,meta:n}=JQ(`ChatComposer.CommandButton`),r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,z.jsx)(xi,{className:`size-4`}),e[0]=r):r=e[0];let i=n.activePopup?.trigger===`/`,a;e[1]===t?a=e[2]:(a=e=>{e.stopPropagation(),t.toggleSlashMenu()},e[1]=t,e[2]=a);let o;return e[3]!==i||e[4]!==a?(o=(0,z.jsx)(W5,{"data-command-button":!0,icon:r,"aria-label":`Toggle command menu`,"aria-expanded":i,onClick:a}),e[3]=i,e[4]=a,e[5]=o):o=e[5],o}function $ee(e){switch(e){case`permission-denied`:return`Allow microphone access to use dictation`;case`no-microphone`:return`Connect a microphone to use dictation`;case`microphone-in-use`:return`Close other apps using the microphone`;case`interrupted`:return`Recording interrupted`;case`transcription-failed`:return`Unable to transcribe audio`}}function ete(e){switch(e.status){case`unavailable`:return e.reason===`blocked`?`Allow microphone access in your browser settings to use dictation`:`Dictation is not available in this browser`;case`idle`:return`Start dictation`;case`starting`:return`Starting dictation`;case`recording`:return`Stop dictation`;case`finishing`:return`Transcribing…`;case`failed`:return $ee(e.error.code)}}function tte(e){switch(e.status){case`recording`:return(0,z.jsx)(Ti,{className:`size-4 fill-current`});case`starting`:case`finishing`:return(0,z.jsx)(me,{className:`size-4 animate-spin`});case`unavailable`:case`idle`:case`failed`:return(0,z.jsx)(pi,{className:`size-4`})}}function nte(){let e=(0,G.c)(20),{status:t}=w6(),{state:n}=X1(`ChatComposer.Dictate`),r;e[0]===n?r=e[1]:(r=ete(n),e[0]=n,e[1]=r);let i=r,a=n.status===`starting`||n.status===`recording`||n.status===`finishing`,o=t===`streaming`||t===`submitted`,s;e[2]===n?s=e[3]:(s=tte(n),e[2]=n,e[3]=s);let c;e[4]!==i||e[5]!==s?(c=(0,z.jsx)(W5,{icon:s,"aria-label":i,title:i}),e[4]=i,e[5]=s,e[6]=c):c=e[6];let l;e[7]!==o||e[8]!==c?(l=(0,z.jsx)(l4.Dictate,{disabled:o,render:c}),e[7]=o,e[8]=c,e[9]=l):l=e[9];let u;e[10]!==a||e[11]!==n.status?(u=a?(0,z.jsx)(l4.CancelDictation,{render:(0,z.jsx)(W5,{icon:(0,z.jsx)(ye,{className:`size-4`}),"aria-label":n.status===`finishing`?`Cancel transcription`:`Cancel dictation`})}):null,e[10]=a,e[11]=n.status,e[12]=u):u=e[12];let d;e[13]!==i||e[14]!==n.status?(d=n.status===`failed`?(0,z.jsx)(`span`,{role:`status`,className:`text-destructive max-w-48 truncate text-xs`,children:i}):null,e[13]=i,e[14]=n.status,e[15]=d):d=e[15];let f;return e[16]!==l||e[17]!==u||e[18]!==d?(f=(0,z.jsxs)(z.Fragment,{children:[l,u,d]}),e[16]=l,e[17]=u,e[18]=d,e[19]=f):f=e[19],f}var T9={Provider:Gee,Root:Kee,Popup:l4.Popup,Content:qee,Attachments:Yee,Editor:Jee,Error:l4.Error,Toolbar:Xee,CommandButton:Qee,AttachFiles:Zee,Dictate:nte};function rte(e){let t=(0,G.c)(5),{children:n,className:r}=e,i;t[0]===r?i=t[1]:(i=I(`border-border flex flex-col border-b px-2 py-1.5`,r),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,z.jsx)(`div`,{className:i,children:n}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a}function ite(e){let t=(0,G.c)(5),{children:n,className:r}=e,i;t[0]===r?i=t[1]:(i=I(`flex items-center gap-2 px-2 py-1.5`,r),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,z.jsx)(`div`,{className:i,children:n}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a}function ate(e){let t=(0,G.c)(4),{className:n}=e,r;t[0]===n?r=t[1]:(r=I(`text-muted-foreground size-3.5 shrink-0`,n),t[0]=n,t[1]=r);let i;return t[2]===r?i=t[3]:(i=(0,z.jsx)(ui,{className:r}),t[2]=r,t[3]=i),i}function ote(e){let t=(0,G.c)(7),{children:n,className:r}=e,i;t[0]===r?i=t[1]:(i=I(`min-w-0 flex-1 truncate text-sm`,r),t[0]=r,t[1]=i);let a;t[2]===n?a=t[3]:(a=typeof n==`string`?(0,z.jsx)(d4,{text:n}):n,t[2]=n,t[3]=a);let o;return t[4]!==i||t[5]!==a?(o=(0,z.jsx)(`span`,{className:i,children:a}),t[4]=i,t[5]=a,t[6]=o):o=t[6],o}function ste(e){let t=(0,G.c)(6),{onClick:n,className:r}=e,i;t[0]===r?i=t[1]:(i=I(`text-muted-foreground hover:text-foreground shrink-0 rounded p-1 transition-colors`,r),t[0]=r,t[1]=i);let a;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,z.jsx)(Rn,{className:`size-3.5`}),t[2]=a):a=t[2];let o;return t[3]!==n||t[4]!==i?(o=(0,z.jsx)(`button`,{type:`button`,onClick:n,className:i,"aria-label":`Remove queued message`,children:a}),t[3]=n,t[4]=i,t[5]=o):o=t[5],o}var E9={Root:rte,Item:ite,Icon:ate,Text:ote,Remove:ste},cte={normal:{d:`m5 12 7-7 7 7`,translateY:0},animate:{d:`m5 12 7-7 7 7`,translateY:[0,3,0],transition:{duration:.4}}},lte={normal:{d:`M12 19V5`},animate:{d:[`M12 19V5`,`M12 19V10`,`M12 19V5`],transition:{duration:.4}}},D9=e=>{let t=(0,G.c)(30),n,r,i,a,o,s;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6]):({ref:o,onMouseEnter:r,onMouseLeave:i,className:n,size:s,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s);let c=s===void 0?20:s,l=wj(),u=(0,R.useRef)(!1),d;t[7]===l?d=t[8]:(d=()=>(u.current=!0,{startAnimation:()=>l.start(`animate`),stopAnimation:()=>l.start(`normal`)}),t[7]=l,t[8]=d),(0,R.useImperativeHandle)(o,d);let f;t[9]!==l||t[10]!==r?(f=e=>{u.current?r?.(e):l.start(`animate`)},t[9]=l,t[10]=r,t[11]=f):f=t[11];let p=f,m;t[12]!==l||t[13]!==i?(m=e=>{u.current?i?.(e):l.start(`normal`)},t[12]=l,t[13]=i,t[14]=m):m=t[14];let h=m,g;t[15]===n?g=t[16]:(g=I(n),t[15]=n,t[16]=g);let _,v;t[17]===l?(_=t[18],v=t[19]):(_=(0,z.jsx)(Tj.path,{animate:l,d:`m5 12 7-7 7 7`,variants:cte}),v=(0,z.jsx)(Tj.path,{animate:l,d:`M12 19V5`,variants:lte}),t[17]=l,t[18]=_,t[19]=v);let y;t[20]!==c||t[21]!==_||t[22]!==v?(y=(0,z.jsxs)(`svg`,{fill:`none`,height:c,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`2`,viewBox:`0 0 24 24`,width:c,xmlns:`http://www.w3.org/2000/svg`,children:[_,v]}),t[20]=c,t[21]=_,t[22]=v,t[23]=y):y=t[23];let b;return t[24]!==p||t[25]!==h||t[26]!==a||t[27]!==g||t[28]!==y?(b=(0,z.jsx)(`div`,{className:g,onMouseEnter:p,onMouseLeave:h,...a,children:y}),t[24]=p,t[25]=h,t[26]=a,t[27]=g,t[28]=y,t[29]=b):b=t[29],b};D9.displayName=`ArrowUpIcon`;var ute={duration:.15,ease:[0,0,.2,1]},dte={duration:.12,ease:[0,0,.2,1]};function O9(e){let t=(0,G.c)(40),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({variant:a,className:n,disabled:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=vj(),s=a===`stop`,c;t[5]===o?c=t[6]:(c=!o&&{opacity:0,scale:.9},t[5]=o,t[6]=c);let l;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(l={opacity:1,scale:1},t[7]=l):l=t[7];let u;t[8]===o?u=t[9]:(u=o?void 0:{opacity:0,scale:.9},t[8]=o,t[9]=u);let d;t[10]!==r||t[11]!==o?(d=r||o?void 0:{scale:1.04},t[10]=r,t[11]=o,t[12]=d):d=t[12];let f;t[13]!==r||t[14]!==o?(f=r||o?void 0:{scale:.96},t[13]=r,t[14]=o,t[15]=f):f=t[15];let p=s?`Stop streaming`:`Send prompt`,m;t[16]===n?m=t[17]:(m=I(`relative flex size-8 items-center justify-center rounded-full`,`bg-primary text-primary-foreground`,`transition-opacity hover:opacity-90 active:opacity-80`,`disabled:cursor-not-allowed disabled:opacity-35 disabled:hover:opacity-35`,`focus-visible:outline-[1.5px] focus-visible:outline-offset-[2.5px] focus-visible:outline-current`,n),t[16]=n,t[17]=m);let h=s?`stop`:`send`,g;t[18]===o?g=t[19]:(g=!o&&{opacity:0,scale:.7},t[18]=o,t[19]=g);let _;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(_={opacity:1,scale:1},t[20]=_):_=t[20];let v;t[21]===o?v=t[22]:(v=o?void 0:{opacity:0,scale:.7},t[21]=o,t[22]=v);let y;t[23]===s?y=t[24]:(y=(0,z.jsx)(s?mte:pte,{}),t[23]=s,t[24]=y);let b;t[25]!==v||t[26]!==y||t[27]!==h||t[28]!==g?(b=(0,z.jsx)(jk,{initial:!1,children:(0,z.jsx)(Tj.span,{initial:g,animate:_,exit:v,transition:dte,className:`absolute flex items-center justify-center`,children:y},h)}),t[25]=v,t[26]=y,t[27]=h,t[28]=g,t[29]=b):b=t[29];let x;return t[30]!==r||t[31]!==i||t[32]!==c||t[33]!==b||t[34]!==u||t[35]!==d||t[36]!==f||t[37]!==p||t[38]!==m?(x=(0,z.jsx)(Tj.button,{initial:c,animate:l,exit:u,transition:ute,whileHover:d,whileTap:f,"aria-label":p,...i,disabled:r,className:m,children:b}),t[30]=r,t[31]=i,t[32]=c,t[33]=b,t[34]=u,t[35]=d,t[36]=f,t[37]=p,t[38]=m,t[39]=x):x=t[39],x}function fte(e){let t=(0,G.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,z.jsx)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 20 20`,fill:`currentColor`,"aria-hidden":`true`,children:n}),t[0]=n,t[1]=r),r}function pte(){let e=(0,G.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,z.jsx)(D9,{}),e[0]=t):t=e[0],t}function mte(){let e=(0,G.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,z.jsx)(fte,{children:(0,z.jsx)(`rect`,{x:`5`,y:`5`,width:`10`,height:`10`,rx:`1.5`})}),e[0]=t):t=e[0],t}function hte(e){let t=(0,G.c)(25),{title:n,detail:r,detailLabel:i,part:a,error:o}=e,s=n===void 0?`Failed to render tool`:n,c=i===void 0?`View details`:i,l=E6(),u;t[0]===o.issues?u=t[1]:(u=o.issues.map(gte).join(`
|
|
349
|
-
`),t[0]=o.issues,t[1]=u);let d=u,f;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,z.jsx)(_t,{className:`size-5`}),t[2]=f):f=t[2];let p;t[3]===s?p=t[4]:(p=(0,z.jsx)(Qi,{children:(0,z.jsxs)($i,{className:`text-destructive flex items-center gap-2`,children:[f,s]})}),t[3]=s,t[4]=p);let m,h;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,z.jsx)(_t,{className:`size-4`}),h=(0,z.jsx)(gr,{children:`Error`}),t[5]=m,t[6]=h):(m=t[5],h=t[6]);let g;t[7]===d?g=t[8]:(g=(0,z.jsxs)(we,{variant:`destructive`,children:[m,h,(0,z.jsx)(Je,{children:d})]}),t[7]=d,t[8]=g);let _;t[9]!==r||t[10]!==c?(_=r&&(0,z.jsxs)(`details`,{className:`text-sm`,children:[(0,z.jsx)(`summary`,{className:`text-muted-foreground hover:text-foreground cursor-pointer`,children:c}),(0,z.jsx)(`pre`,{className:`bg-muted mt-2 max-h-48 overflow-auto rounded-md p-3 text-xs`,children:(0,z.jsx)(`code`,{children:r})})]}),t[9]=r,t[10]=c,t[11]=_):_=t[11];let v;t[12]!==g||t[13]!==_?(v=(0,z.jsxs)(na,{className:`space-y-4`,children:[g,_]}),t[12]=g,t[13]=_,t[14]=v):v=t[14];let y;t[15]!==l||t[16]!==a?(y=()=>{let e=[`The model tried to call the tool "${Dv(a)}" with the following inputs:`,JSON.stringify(a.input),`Please fix the inputs.`];l.addToolOutput({toolCallId:a.toolCallId,tool:Dv(a),output:e,state:`output-available`})},t[15]=l,t[16]=a,t[17]=y):y=t[17];let b;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,z.jsx)(Ci,{className:`size-4`}),t[18]=b):b=t[18];let x;t[19]===y?x=t[20]:(x=(0,z.jsx)(ra,{children:(0,z.jsxs)(Ce,{variant:`outline`,onClick:y,className:`gap-2`,children:[b,`Ask AI to fix this`]})}),t[19]=y,t[20]=x);let S;return t[21]!==v||t[22]!==x||t[23]!==p?(S=(0,z.jsxs)(Zi,{className:`border-destructive/50 bg-destructive/5`,children:[p,v,x]}),t[21]=v,t[22]=x,t[23]=p,t[24]=S):S=t[24],S}function gte(e){return`${e.path.join(`.`)}: ${e.message}`}(0,R.createContext)(``);function _te({question:e}){let{submit:t}=C6();return typeof e!=`string`||e===``?null:(0,z.jsxs)(`button`,{type:`button`,className:`text-muted-foreground hover:bg-accent hover:text-accent-foreground my-1 inline-flex items-center gap-1.5 rounded-full border px-3 py-1 text-sm transition-colors`,onClick:()=>void t({prompt:e,persistedPrompt:e}),children:[(0,z.jsx)(oi,{className:`size-3.5`}),e]})}var k9=Hj([{name:`followup`,description:`Suggest a follow-up question the user is likely to ask next. Renders as a clickable chip that sends the question as the next message. Example: <followup question="How do I undo this?" />`,allowedAttributes:[`question`],component:_te}]),vte=F({label:L().describe(`Display text for the option`),value:L().optional().describe(`Machine value; defaults to label`),description:L().optional().describe(`Helper text for the option`)}),A9=D(e=>typeof e==`object`&&e&&`questions`in e&&Array.isArray(e.questions)?{...e,questions:e.questions.map(e=>typeof e==`object`&&e?{...e,type:`choice`}:e)}:e,F({questions:Xt(F({type:Ye(`choice`).describe(`Selection from predefined options`),question:L().describe(`The question text displayed to the user`),header:L().optional().describe(`Short context label`),multiSelect:Dt().default(!1).describe(`Whether multiple options can be selected`),options:Xt(vte).min(1).describe(`Available choices`)})).min(1).describe(`Questions to present as a wizard`)})),j9=F({label:L(),value:L()}),yte=F({answers:Xt(F({type:L(),question:L(),freeText:L().optional(),notes:L().optional(),choice:j9.optional(),choices:Xt(j9).optional(),multiSelect:Dt().optional(),answer:L().optional()}))});function M9(e){if(e.multiSelect){if(e.selectedMulti.length===0&&!e.customText.trim())return`Pick at least one option or add your own answer.`}else{if(!e.selected&&!e.isOther)return`Select an option or add your own answer.`;if(e.isOther&&!e.customText.trim())return`Add your custom answer for the "Other" option.`}return null}function bte(e){return{type:`choice`,multiSelect:e.multiSelect??!1,selected:null,selectedMulti:[],isOther:!1,customText:``,notes:``}}function N9(e){return e.options.filter(e=>(e.value??e.label).toLowerCase()!==`other`&&e.label.toLowerCase()!==`other`).map(e=>({label:e.label,value:e.value??e.label,description:e.description}))}function xte(e,t,n){let r=e=>{let t=n.find(t=>t.value===e);return t?{label:t.label,value:t.value}:{label:e,value:e}},i=t.notes.trim()||void 0,a=t.customText.trim()||void 0;if(t.multiSelect){let n=t.selectedMulti.map(r);return a&&n.push({label:`Other`,value:a}),{type:`choice`,question:e.question,multiSelect:!0,choices:n,freeText:a,notes:i}}return{type:`choice`,question:e.question,multiSelect:!1,choice:t.isOther?{label:`Other`,value:a??``}:r(t.selected??``),freeText:t.isOther?a:void 0,notes:i}}function P9({checked:e,children:t,disabled:n}){return(0,z.jsx)(`div`,{className:I(`border-border/60 relative flex items-start gap-2 rounded-lg border px-3 py-1.5 transition-all duration-150`,!n&&`hover:bg-muted/40`,e&&`border-primary/50 bg-primary/5`,n&&`opacity-60`),children:t})}function F9({htmlFor:e,label:t,description:n}){return(0,z.jsxs)(Pn,{htmlFor:e,className:`min-w-0 flex-1 cursor-pointer flex-col items-start gap-0`,children:[(0,z.jsx)(`span`,{className:`text-sm font-medium`,children:t}),n?(0,z.jsx)(`p`,{className:`text-muted-foreground text-xs leading-relaxed text-pretty`,children:n}):null]})}function Ste({id:e,value:t,label:n,description:r,checked:i,disabled:a}){return(0,z.jsxs)(P9,{checked:i,disabled:a,children:[(0,z.jsx)(Bo,{id:e,value:t,disabled:a,className:`mt-0.5`}),(0,z.jsx)(F9,{htmlFor:e,label:n,description:r})]})}function Cte({id:e,label:t,description:n,checked:r,disabled:i,onCheckedChange:a}){return(0,z.jsxs)(P9,{checked:r,disabled:i,children:[(0,z.jsx)(ba,{id:e,checked:r,disabled:i,onCheckedChange:e=>a(e===!0),className:`mt-0.5`}),(0,z.jsx)(F9,{htmlFor:e,label:t,description:n})]})}function wte({id:e,checked:t,disabled:n,customText:r,onCustomTextChange:i}){let a=(0,R.useRef)(null);return(0,z.jsxs)(P9,{checked:t,disabled:n,children:[(0,z.jsx)(Bo,{ref:a,id:e,value:`other`,disabled:n,className:`mt-0.5`}),(0,z.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),placeholder:`Type your answer...`,disabled:n,onFocus:()=>{t||a.current?.click()},className:`placeholder:text-muted-foreground min-w-0 flex-1 bg-transparent text-sm outline-none disabled:cursor-not-allowed`})]})}function Tte({hasCustom:e,disabled:t,customText:n,onCustomTextChange:r,onClear:i}){let a=(0,R.useRef)(null);return(0,z.jsxs)(P9,{checked:e,disabled:t,children:[(0,z.jsx)(ba,{ref:a,checked:e,disabled:t,onCheckedChange:e=>{e||i()},className:`mt-0.5`}),(0,z.jsx)(`input`,{value:n,onChange:e=>r(e.target.value),placeholder:`Type your answer...`,disabled:t,onFocus:()=>{e||a.current?.click()},className:`placeholder:text-muted-foreground min-w-0 flex-1 bg-transparent text-sm outline-none disabled:cursor-not-allowed`})]})}function Ete({value:e,onChange:t,disabled:n}){return(0,z.jsx)(`div`,{className:`mt-2.5 border-t border-dashed pt-2.5`,children:(0,z.jsx)(et,{value:e,onChange:e=>t(e.target.value),placeholder:`Add notes (optional)...`,disabled:n,rows:2,className:`resize-none text-sm`})})}function Dte({value:e,onChange:t,options:n,disabled:r,fieldId:i}){if(e.multiSelect){let a=e.customText.trim().length>0,o=(n,r)=>{let i=new Set(e.selectedMulti);r?i.add(n):i.delete(n),t({...e,selectedMulti:[...i]})};return(0,z.jsxs)(`div`,{className:`space-y-1.5`,children:[n.map(t=>(0,z.jsx)(Cte,{id:`${i}-multi-${t.value}`,label:t.label,description:t.description,checked:e.selectedMulti.includes(t.value),disabled:r,onCheckedChange:e=>o(t.value,e)},t.value)),(0,z.jsx)(Tte,{hasCustom:a,disabled:r,customText:e.customText,onCustomTextChange:n=>t({...e,customText:n}),onClear:()=>t({...e,customText:``})})]})}return(0,z.jsxs)(zo,{value:e.isOther?`other`:e.selected??``,onValueChange:n=>t(n===`other`?{...e,selected:null,isOther:!0}:{...e,selected:n,isOther:!1,customText:``}),children:[n.map(t=>(0,z.jsx)(Ste,{id:`${i}-single-${t.value}`,value:t.value,label:t.label,description:t.description,checked:!e.isOther&&e.selected===t.value,disabled:r},t.value)),(0,z.jsx)(wte,{id:`${i}-single-other`,checked:e.isOther,disabled:r,customText:e.customText,onCustomTextChange:n=>t({...e,customText:n})})]})}function Ote({current:e,total:t}){return t<=1?null:(0,z.jsx)(`div`,{className:`flex items-center gap-1`,children:Array.from({length:t},(t,n)=>(0,z.jsx)(`div`,{className:I(`h-1 w-3 rounded-full transition-colors duration-200`,n<=e?`bg-primary`:`bg-muted`)},n))})}function kte({onBack:e,onNext:t,isFirst:n,isLast:r,canProceed:i,isSubmitting:a,isSubmitted:o,currentStep:s,totalSteps:c}){return o?null:(0,z.jsxs)(`div`,{className:`flex items-center justify-between border-t border-dashed px-3 py-1.5`,children:[(0,z.jsx)(`div`,{className:`w-16`,children:n?null:(0,z.jsx)(`button`,{type:`button`,onClick:e,disabled:a,className:`text-muted-foreground hover:text-foreground text-xs transition-colors disabled:opacity-50`,children:`← Back`})}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(Ote,{current:s,total:c}),c>1?(0,z.jsxs)(`span`,{className:`text-muted-foreground text-[11px] tabular-nums`,children:[s+1,`/`,c]}):null]}),(0,z.jsx)(`div`,{className:`flex w-16 justify-end`,children:(0,z.jsxs)(Ce,{type:`button`,size:`sm`,onClick:t,disabled:!i||a,children:[a?(0,z.jsx)(Vo,{}):null,a?`Sending...`:r?`Submit`:`Next`]})})]})}function Ate({question:e}){return(0,z.jsxs)(`div`,{className:`px-3 pt-2.5 pb-2`,children:[(0,z.jsxs)(`div`,{className:`text-muted-foreground mb-2 flex items-center gap-2 text-[11px]`,children:[(0,z.jsx)(Ct,{className:`size-3`}),(0,z.jsx)(`span`,{children:e.header??`Clarification`})]}),(0,z.jsx)(Xi,{className:`mb-2`}),(0,z.jsx)(`p`,{className:`text-sm font-medium text-pretty`,children:e.question})]})}function jte({question:e,answer:t,options:n,onChange:r,disabled:i,fieldId:a}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Dte,{value:t,onChange:r,options:n,disabled:i,fieldId:a}),(0,z.jsx)(Ete,{value:t.notes,onChange:e=>r({...t,notes:e}),disabled:i})]})}function Mte({question:e,answer:t,options:n}){let r=t.multiSelect?[...t.selectedMulti.map(e=>n.find(t=>t.value===e)?.label??e),...t.customText.trim()?[`Other: ${t.customText.trim()}`]:[]].join(`, `):t.isOther?`Other: ${t.customText.trim()}`:n.find(e=>e.value===t.selected)?.label??t.selected??``,i=t.notes.trim()||void 0;return(0,z.jsxs)(`div`,{className:`px-3 py-2.5`,children:[(0,z.jsx)(`p`,{className:`text-muted-foreground text-sm text-pretty`,children:e.question}),(0,z.jsx)(`p`,{className:`mt-1 text-sm font-medium text-pretty`,children:r}),i?(0,z.jsxs)(`p`,{className:`text-muted-foreground mt-1 text-xs text-pretty italic`,children:[`Note: `,i]}):null]})}function Nte(e){return e.type===`free_form`?e.answer??``:e.multiSelect&&e.choices?e.choices.map(({label:e,value:t})=>e===`Other`?`Other: ${t}`:e).join(`, `):e.freeText?`Other: ${e.freeText}`:e.choice?.label??``}function Pte({answers:e}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:`px-3 pt-2.5 pb-2`,children:(0,z.jsxs)(`div`,{className:`text-muted-foreground flex items-center gap-2 text-xs`,children:[(0,z.jsx)(d,{className:`size-3`}),(0,z.jsx)(`span`,{children:`Answered`})]})}),(0,z.jsx)(Xi,{}),e.map((e,t)=>(0,z.jsxs)(`div`,{className:`px-3 py-2.5`,children:[(0,z.jsx)(`p`,{className:`text-muted-foreground text-sm text-pretty`,children:e.question}),(0,z.jsx)(`p`,{className:`mt-1 text-sm font-medium text-pretty`,children:Nte(e)}),e.notes?(0,z.jsxs)(`p`,{className:`text-muted-foreground mt-1 text-xs text-pretty italic`,children:[`Note: `,e.notes]}):null]},t))]})}function Fte({questions:e,answers:t}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:`px-3 pt-2.5 pb-2`,children:(0,z.jsxs)(`div`,{className:`text-muted-foreground flex items-center gap-2 text-xs`,children:[(0,z.jsx)(d,{className:`size-3`}),(0,z.jsx)(`span`,{children:`Answered`})]})}),(0,z.jsx)(Xi,{}),e.map((e,n)=>(0,z.jsx)(Mte,{question:e,answer:t[n],options:N9(e)},n))]})}var I9=(0,R.createContext)(void 0);function L9(){let e=(0,R.use)(I9);if(!e)throw Error(`useWizard must be used within <ClarificationWizard.Root>`);return e}function Ite({questions:e,onSubmit:t,disabled:n,fieldId:r,children:i}){let[a,o]=(0,R.useState)(0),[s,c]=(0,R.useState)(()=>e.map(bte)),[l,u]=(0,R.useState)(null),[d,f]=(0,R.useState)(!1),[p,m]=(0,R.useState)(!1),h=e[a],g=s[a],_=a===0,v=a===e.length-1,y={questions:e,currentStep:a,currentQuestion:h,currentAnswer:g,options:N9(h),answers:s,updateAnswer:e=>{c(t=>{let n=[...t];return n[a]=e,n}),u(null)},handleBack:()=>{_||(o(e=>e-1),u(null))},handleNext:async()=>{let n=M9(g);if(n){u(n);return}if(!v){o(e=>e+1),u(null);return}for(let t=0;t<e.length;t++){let e=M9(s[t]);if(e){o(t),u(e);return}}f(!0);try{await t(e.map((e,t)=>xte(e,s[t],N9(e)))),m(!0)}catch(e){u(e instanceof Error?e.message:`Failed to send your answers.`)}finally{f(!1)}},error:l,isFirst:_,isLast:v,canProceed:!n&&!p,isSubmitting:d,isSubmitted:p,disabled:n,fieldId:r,totalSteps:e.length};return(0,z.jsx)(I9,{value:y,children:i})}function Lte(){let{currentQuestion:e,isSubmitted:t}=L9();return t?null:(0,z.jsx)(Ate,{question:e})}function Rte(){let{currentQuestion:e,currentAnswer:t,options:n,updateAnswer:r,disabled:i,isSubmitting:a,isSubmitted:o,fieldId:s,currentStep:c}=L9();return o?null:(0,z.jsx)(jte,{question:e,answer:t,options:n,onChange:r,disabled:i||a,fieldId:`${s}-step-${c}`})}function zte(){let{error:e,isSubmitted:t}=L9();return t||!e?null:(0,z.jsx)(`p`,{className:`text-destructive text-xs`,role:`alert`,children:e})}function Bte(){let{handleBack:e,handleNext:t,isFirst:n,isLast:r,canProceed:i,isSubmitting:a,isSubmitted:o,currentStep:s,totalSteps:c}=L9();return(0,z.jsx)(kte,{onBack:e,onNext:()=>void t(),isFirst:n,isLast:r,canProceed:i,isSubmitting:a,isSubmitted:o,currentStep:s,totalSteps:c})}function Vte({children:e,className:t}){let{isSubmitted:n}=L9();return n?null:(0,z.jsx)(`div`,{className:t,children:e})}function Hte(){let{questions:e,answers:t,isSubmitted:n}=L9();return n?(0,z.jsx)(Fte,{questions:e,answers:t}):null}var R9={Root:Ite,Header:Lte,Content:Vte,Field:Rte,Error:zte,Navigation:Bte,Submitted:Hte};function Ute({part:e}){let t=E6(),[n,r]=(0,R.useState)(!1),i=(0,R.useId)();if(e.state===`output-available`){let t=yte.safeParse(e.output);return t.success?(0,z.jsx)(`div`,{className:I(`border-border/60 bg-muted/20 mb-2 rounded-lg border border-dashed`),children:(0,z.jsx)(Pte,{answers:t.data.answers})}):null}if(e.state!==`input-available`)return null;let a=A9.safeParse(e.input);return a.success?(0,z.jsx)(`div`,{className:I(`border-border/60 bg-muted/20 rounded-lg border border-dashed`,`animate-in fade-in-0 duration-200`),children:(0,z.jsxs)(R9.Root,{questions:a.data.questions,onSubmit:async n=>{await t.addToolOutput({toolCallId:e.toolCallId,tool:Dv(e),output:{answers:n},state:`output-available`}),r(!0)},disabled:n,fieldId:i,children:[(0,z.jsx)(R9.Submitted,{}),(0,z.jsx)(R9.Header,{}),(0,z.jsxs)(R9.Content,{className:`space-y-2 px-3 pb-2`,children:[(0,z.jsx)(R9.Field,{}),(0,z.jsx)(R9.Error,{})]}),(0,z.jsx)(R9.Navigation,{})]})}):(0,z.jsx)(hte,{error:a.error,title:`Failed to render clarification`,detail:JSON.stringify(e.input,null,2),detailLabel:`View input`,part:e})}var Wte={component:Ute,label:e=>{let t=e.state===`input-available`||e.state===`output-available`?A9.safeParse(e.input):void 0,n=t?.success?t.data.questions[0]:void 0;return{name:`AskUserQuestion`,icon:Qr,args:n?{question:n.header??n.question}:void 0}},requiresUserInput:!0,static:!1,inputSchema:A9,description:`Tool to collect information from the user via a multi-step wizard. Use when you need to clarify requirements, gather preferences, or resolve ambiguity before proceeding.
|
|
347
|
+
`}var d8=`response-table-panel`,f8=[`title`,`description`],p8=I(qe({variant:`ghost`,size:`icon-sm`})),m8=Fr().use(Ur).use(Vr).use(tN),h8=e=>{let t=Nr(e),n=v8(e);if(n.length===0)return t;let r=0,i=t.map(e=>{let t={start:r,end:r+e.length};return r=t.end,t}),a=new Set;for(let e of n){let t=!1;for(let[n,r]of i.entries())r.start<e.end&&r.end>e.start&&(t&&a.add(n),t=!0)}return t.reduce((e,t,n)=>(a.has(n)&&e.length>0?e[e.length-1]+=t:e.push(t),e),[])};function g8(e){return e?.type===`leafDirective`&&`name`in e&&e.name===`table`}function _8(e,t){if(t===void 0)return;let n=e[t-1];return g8(n)?n:void 0}function v8(e){let t=[];return kr(m8.parse(e),`table`,(e,n,r)=>{if(!r)return;let i=_8(r.children,n)?.position?.start.offset,a=e.position?.end.offset;i!==void 0&&a!==void 0&&t.push({start:i,end:a})}),t}function y8(e,t){return e.attributes?.[t]?.trim()||void 0}function b8(e){let t=m8.parse(e),n=!1;if(kr(t,`leafDirective`,(e,t,r)=>{let i=t===void 0?void 0:r?.children[t+1];if(e.name!==`table`||i?.type!==`table`)return;n=!0;let a=[y8(e,`title`),y8(e,`description`)].filter(Boolean).join(` `);e.children=a?[{type:`text`,value:a}]:[]}),n)return Hr(Ar(t,{includeHtml:!1}))}function x8(e){let t=(0,G.c)(2),n;return t[0]===e?n=t[1]:(n=(0,z.jsx)(Pr,{...e}),t[0]=e,t[1]=n),n}function S8(e){function t(t){let n=(0,G.c)(6),r;n[0]!==t.content||n[1]!==t.dir?(r=b8(t.content)??t.dir,n[0]=t.content,n[1]=t.dir,n[2]=r):r=n[2];let i=r,a;return n[3]!==i||n[4]!==t?(a=(0,z.jsx)(e,{...t,dir:i}),n[3]=i,n[4]=t,n[5]=a):a=n[5],a}return t.displayName=`DirectionAwareTableBlock`,t}function C8(e,t){let n=t&&y8(t,`title`),r=t&&y8(t,`description`),i={...n?{title:n}:{},...r?{description:r}:{}};return{type:`tablePanel`,data:{hName:d8,...Object.keys(i).length>0?{hProperties:i}:{}},children:[e]}}function w8(){return e=>{kr(e,`table`,(e,t,n)=>{if(t===void 0||!n)return;let r=_8(n.children,t),i=r?t-1:t,a=r?2:1;return n.children.splice(i,a,C8(e,r)),[xr,i+1]})}}var T8=[...Object.values(Br),tN,w8],E8=R.createContext({actions:null,controls:!0});function D8(e,t){if(e===!1)return!1;if(e===!0||e===void 0)return!0;let n=e.table;return n===!1?!1:n===!0||n===void 0||n[t]!==!1}function O8(e){return e===!1?!1:e===!0||e===void 0?{table:!1}:{...e,table:!1}}function k8(e){let t=(0,G.c)(21),{children:n,className:r,title:i,description:a}=e,{actions:o,controls:s}=R.use(E8),c;t[0]===s?c=t[1]:(c=D8(s,`copy`),t[0]=s,t[1]=c);let l=c,u;t[2]===s?u=t[3]:(u=D8(s,`download`),t[2]=s,t[3]=u);let d=u,f=!!(i||a),p=!!(l||d||o);if(!n)return null;let m;t[4]===r?m=t[5]:(m=I(`my-4`,r),t[4]=r,t[5]=m);let h;t[6]!==o||t[7]!==a||t[8]!==p||t[9]!==f||t[10]!==l||t[11]!==d||t[12]!==i?(h=(f||p)&&(0,z.jsxs)(Y6.Header,{className:I(!f&&`justify-end`),children:[f&&(0,z.jsxs)(Y6.Heading,{children:[i&&(0,z.jsx)(Y6.Title,{children:i}),a&&(0,z.jsx)(Y6.Description,{className:I(i&&`mt-1`),children:a})]}),p&&(0,z.jsxs)(Y6.Actions,{"data-copy-exclude":`assistant-snapshot`,children:[l&&(0,z.jsx)(Wr,{className:p8}),d&&(0,z.jsx)(jr,{className:p8}),o]})]}),t[6]=o,t[7]=a,t[8]=p,t[9]=f,t[10]=l,t[11]=d,t[12]=i,t[13]=h):h=t[13];let g;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(g=I(`overflow-hidden`,`[&>[data-streamdown=table-wrapper]]:m-0 [&>[data-streamdown=table-wrapper]]:gap-0 [&>[data-streamdown=table-wrapper]]:rounded-none [&>[data-streamdown=table-wrapper]]:border-0 [&>[data-streamdown=table-wrapper]]:bg-transparent [&>[data-streamdown=table-wrapper]]:p-0`,`[&>[data-streamdown=table-wrapper]>div:last-child]:rounded-none [&>[data-streamdown=table-wrapper]>div:last-child]:border-0`,`[&_[data-streamdown=table]]:tabular-nums`,`[&_[data-streamdown=table-header]]:bg-muted/30`,`[&_[data-streamdown=table-header-cell]]:text-muted-foreground [&_[data-streamdown=table-header-cell]]:text-xs [&_[data-streamdown=table-header-cell]]:font-medium`,`[&_[data-streamdown=table-cell]]:py-2`,`[&_[data-streamdown=table-row]]:hover:bg-muted/30`),t[14]=g):g=t[14];let _;t[15]===n?_=t[16]:(_=(0,z.jsx)(Y6.Content,{className:g,children:n}),t[15]=n,t[16]=_);let v;return t[17]!==m||t[18]!==h||t[19]!==_?(v=(0,z.jsxs)(Y6,{"data-streamdown":`table-wrapper`,className:m,children:[h,_]}),t[17]=m,t[18]=h,t[19]=_,t[20]=v):v=t[20],v}function A8(e){let t=(0,G.c)(43),n,r,i,a,o,s,c,l,u,d;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7],l=t[8],u=t[9],d=t[10]):({allowedTags:r,BlockComponent:n,children:i,components:a,controls:o,dir:s,mode:c,remarkPlugins:u,tableActions:d,...l}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c,t[8]=l,t[9]=u,t[10]=d);let f;bb0:{if(!u){f=T8;break bb0}let e;t[11]===u?e=t[12]:(e=[...u,tN,w8],t[11]=u,t[12]=e),f=e}let p=f,m;t[13]===r?m=t[14]:(m={...r,[d8]:f8},t[13]=r,t[14]=m);let h=m,g;t[15]===a?g=t[16]:(g={...a,[d8]:k8},t[15]=a,t[16]=g);let _=g,v;t[17]!==o||t[18]!==d?(v={actions:d,controls:o},t[17]=o,t[18]=d,t[19]=v):v=t[19];let y=v,b;bb1:{if(s!==`auto`||c===`static`){b=n;break bb1}let e=n??x8,r;t[20]===e?r=t[21]:(r=S8(e),t[20]=e,t[21]=r),b=r}let x=b,S;bb2:{if(s!==`auto`||c!==`static`||typeof i!=`string`){S=s;break bb2}let e;t[22]!==i||t[23]!==s?(e=b8(i)??s,t[22]=i,t[23]=s,t[24]=e):e=t[24],S=e}let C=S,w;t[25]===o?w=t[26]:(w=O8(o),t[25]=o,t[26]=w);let T;t[27]!==i||t[28]!==h?(T=$6(i,Object.keys(h)),t[27]=i,t[28]=h,t[29]=T):T=t[29];let E;t[30]!==c||t[31]!==l||t[32]!==C||t[33]!==w||t[34]!==T||t[35]!==h||t[36]!==x||t[37]!==_||t[38]!==p?(E=(0,z.jsx)(Gr,{allowedTags:h,BlockComponent:x,components:_,controls:w,dir:C,mode:c,parseMarkdownIntoBlocksFn:h8,remarkPlugins:p,...l,children:T}),t[30]=c,t[31]=l,t[32]=C,t[33]=w,t[34]=T,t[35]=h,t[36]=x,t[37]=_,t[38]=p,t[39]=E):E=t[39];let D;return t[40]!==E||t[41]!==y?(D=(0,z.jsx)(E8,{value:y,children:E}),t[40]=E,t[41]=y,t[42]=D):D=t[42],D}var j8=class extends R.Component{state={hasError:!1,error:null};static getDerivedStateFromError(e){return{hasError:!0,error:e}}render(){return this.state.hasError?this.props.fallback||(0,z.jsxs)(`div`,{className:`text-destructive p-2 text-sm`,children:[`Failed to render content: `,this.state.error?.message]}):this.props.children}},M8=(0,R.memo)(e=>{let t=(0,G.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=I(`size-full space-y-2 [&>*:first-child]:mt-0 [&>*:last-child]:mb-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,z.jsx)(j8,{children:(0,z.jsx)(A8,{className:i,dir:`auto`,...r})}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a});M8.displayName=`Response`;function N8(e){let t=(0,G.c)(9),n=e===void 0?2e3:e,r=ln(),[i,a]=(0,R.useState)(!1),o=(0,R.useRef)(null),s,c;t[0]===r?(s=t[1],c=t[2]):(s=()=>()=>{o.current&&r.clearTimeout(o.current)},c=[r],t[0]=r,t[1]=s,t[2]=c),(0,R.useEffect)(s,c);let l;t[3]!==r||t[4]!==n?(l=async e=>{await navigator.clipboard.writeText(e),a(!0),o.current&&r.clearTimeout(o.current),o.current=r.setTimeout(()=>a(!1),n)},t[3]=r,t[4]=n,t[5]=l):l=t[5];let u=l,d;return t[6]!==i||t[7]!==u?(d=[i,u],t[6]=i,t[7]=u,t[8]=d):d=t[8],d}var P8=(0,R.createContext)({code:``}),F8=e=>{let t=(0,G.c)(24),n,r,i,a,o,s;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6]):({code:r,language:i,showLineNumbers:o,wrap:s,children:n,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s);let c=o!==void 0&&o,l=s!==void 0&&s,u=ih(r,i),d;t[7]===r?d=t[8]:(d={code:r},t[7]=r,t[8]=d);let f;t[9]===u?f=t[10]:(f=u.map(L8),t[9]=u,t[10]=f);let p;t[11]!==c||t[12]!==f||t[13]!==l?(p=(0,z.jsx)(Ta,{lineNumbers:c,wrap:l,children:f}),t[11]=c,t[12]=f,t[13]=l,t[14]=p):p=t[14];let m;t[15]===n?m=t[16]:(m=!!n&&(0,z.jsx)(wa,{children:n}),t[15]=n,t[16]=m);let h;t[17]!==a||t[18]!==p||t[19]!==m?(h=(0,z.jsxs)(Ca,{size:`sm`,...a,children:[p,m]}),t[17]=a,t[18]=p,t[19]=m,t[20]=h):h=t[20];let g;return t[21]!==d||t[22]!==h?(g=(0,z.jsx)(P8,{value:d,children:h}),t[21]=d,t[22]=h,t[23]=g):g=t[23],g},I8=({onCopy:e,onError:t,timeout:n=2e3,children:r,className:i,...a})=>{let[o,s]=N8(n),{code:c}=(0,R.use)(P8),l=async()=>{if(typeof window>`u`||!navigator.clipboard.writeText){t?.(Error(`Clipboard API not available`));return}try{await s(c),e?.()}catch(e){t?.(e instanceof Error?e:Error(String(e)))}},u=o?d:ri;return(0,z.jsx)(Ce,{className:I(`shrink-0`,i),onClick:()=>void l(),size:`icon-xs`,variant:`ghost`,...a,children:r??(0,z.jsx)(u,{})})};function L8(e,t){return(0,z.jsx)(Da,{children:e},t)}var R8=e=>{let t=(0,G.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=I(`not-prose mb-4 w-full rounded-md border`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,z.jsx)(Fa,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a},z8=e=>(0,z.jsxs)(re,{className:`gap-1.5 rounded-full text-xs`,variant:`secondary`,children:[{"input-streaming":(0,z.jsx)(yt,{className:`size-4`}),"input-available":(0,z.jsx)(ti,{className:`size-4 animate-pulse`}),"approval-requested":(0,z.jsx)(ti,{className:`size-4 text-yellow-600`}),"approval-responded":(0,z.jsx)(Xr,{className:`size-4 text-blue-600`}),"output-available":(0,z.jsx)(Xr,{className:`size-4 text-green-600`}),"output-error":(0,z.jsx)($r,{className:`size-4 text-red-600`}),"output-denied":(0,z.jsx)($r,{className:`size-4 text-orange-600`})}[e],{"input-streaming":`Pending`,"input-available":`Running`,"approval-requested":`Awaiting Approval`,"approval-responded":`Responded`,"output-available":`Completed`,"output-error":`Error`,"output-denied":`Denied`}[e]]}),B8=e=>{let t=(0,G.c)(23),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,title:a,part:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o;t[5]===n?o=t[6]:(o=I(`group flex w-full items-center justify-between gap-4 p-3`,n),t[5]=n,t[6]=o);let s;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,z.jsx)(Di,{className:`text-muted-foreground size-4`}),t[7]=s):s=t[7];let c;t[8]!==r||t[9]!==a?(c=a??Dv(r),t[8]=r,t[9]=a,t[10]=c):c=t[10];let l;t[11]===c?l=t[12]:(l=(0,z.jsx)(`span`,{className:`text-sm font-medium`,children:c}),t[11]=c,t[12]=l);let u;t[13]===r.state?u=t[14]:(u=z8(r.state),t[13]=r.state,t[14]=u);let d;t[15]!==l||t[16]!==u?(d=(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[s,l,u]}),t[15]=l,t[16]=u,t[17]=d):d=t[17];let f;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,z.jsx)(He,{className:`text-muted-foreground size-4 transition-transform group-data-[panel-open]:rotate-180`}),t[18]=f):f=t[18];let p;return t[19]!==i||t[20]!==o||t[21]!==d?(p=(0,z.jsxs)(Ia,{className:o,...i,children:[d,f]}),t[19]=i,t[20]=o,t[21]=d,t[22]=p):p=t[22],p},V8=e=>{let t=(0,G.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=I(`data-closed:fade-out-0 data-closed:slide-out-to-top-2 data-open:slide-in-from-top-2 text-popover-foreground data-closed:animate-out data-open:animate-in outline-none`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,z.jsx)(La,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a},H8=e=>{let t=(0,G.c)(15),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,input:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===n?a=t[5]:(a=I(`space-y-2 overflow-hidden p-4`,n),t[4]=n,t[5]=a);let o;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,z.jsx)(`h4`,{className:`text-muted-foreground text-xs font-medium tracking-wide uppercase`,children:`Parameters`}),t[6]=o):o=t[6];let s;t[7]===r?s=t[8]:(s=JSON.stringify(r,null,2),t[7]=r,t[8]=s);let c;t[9]===s?c=t[10]:(c=(0,z.jsx)(`div`,{className:`bg-muted/50 rounded-md`,children:(0,z.jsx)(F8,{code:s,language:`json`})}),t[9]=s,t[10]=c);let l;return t[11]!==i||t[12]!==a||t[13]!==c?(l=(0,z.jsxs)(`div`,{className:a,...i,children:[o,c]}),t[11]=i,t[12]=a,t[13]=c,t[14]=l):l=t[14],l},U8=e=>{let t=(0,G.c)(24),n,r,i,a;if(t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,output:i,errorText:r,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a),!(i||r))return null;let o;t[5]===n?o=t[6]:(o=I(`space-y-2 p-4`,n),t[5]=n,t[6]=o);let s=r?`Error`:`Result`,c;t[7]===s?c=t[8]:(c=(0,z.jsx)(`h4`,{className:`text-muted-foreground text-xs font-medium tracking-wide uppercase`,children:s}),t[7]=s,t[8]=c);let l=r?`bg-destructive/10 text-destructive`:`bg-muted/50 text-foreground`,u;t[9]===l?u=t[10]:(u=I(`overflow-x-auto rounded-md text-xs [&_table]:w-full`,l),t[9]=l,t[10]=u);let d;t[11]===r?d=t[12]:(d=r&&(0,z.jsx)(`div`,{children:r}),t[11]=r,t[12]=d);let f;t[13]===i?f=t[14]:(f=W8(i),t[13]=i,t[14]=f);let p;t[15]!==u||t[16]!==d||t[17]!==f?(p=(0,z.jsxs)(`div`,{className:u,children:[d,f]}),t[15]=u,t[16]=d,t[17]=f,t[18]=p):p=t[18];let m;return t[19]!==a||t[20]!==o||t[21]!==c||t[22]!==p?(m=(0,z.jsxs)(`div`,{className:o,...a,children:[c,p]}),t[19]=a,t[20]=o,t[21]=c,t[22]=p,t[23]=m):m=t[23],m};function W8(e){return typeof e==`string`?(0,z.jsx)(F8,{code:e,language:`json`}):(0,R.isValidElement)(e)?(0,z.jsx)(`div`,{children:e}):typeof e==`object`?(0,z.jsx)(F8,{code:JSON.stringify(e,null,2),language:`json`}):typeof e==`number`||typeof e==`bigint`?(0,z.jsx)(`div`,{children:e}):(0,z.jsx)(`div`,{})}function G8(e){let t=(0,G.c)(20),{part:n}=e,r;t[0]===n?r=t[1]:(r=Dv(n),t[0]=n,t[1]=r);let i=`Executing ${r}`,a;t[2]!==n||t[3]!==i?(a=(0,z.jsx)(B8,{title:i,part:n}),t[2]=n,t[3]=i,t[4]=a):a=t[4];let o;t[5]===n.input?o=t[6]:(o=(0,z.jsx)(H8,{input:n.input}),t[5]=n.input,t[6]=o);let s;t[7]===n.output?s=t[8]:(s=typeof n.output==`string`?n.output:JSON.stringify(n.output,null,2),t[7]=n.output,t[8]=s);let c;t[9]===s?c=t[10]:(c=(0,z.jsx)(M8,{className:`break-all`,children:s}),t[9]=s,t[10]=c);let l;t[11]!==n.errorText||t[12]!==c?(l=(0,z.jsx)(U8,{output:c,errorText:n.errorText}),t[11]=n.errorText,t[12]=c,t[13]=l):l=t[13];let u;t[14]!==o||t[15]!==l?(u=(0,z.jsxs)(V8,{children:[o,l]}),t[14]=o,t[15]=l,t[16]=u):u=t[16];let d;return t[17]!==a||t[18]!==u?(d=(0,z.jsxs)(R8,{"data-copy-exclude":`assistant-snapshot`,children:[a,u]}),t[17]=a,t[18]=u,t[19]=d):d=t[19],d}function K8(e){let t=(0,G.c)(18),{part:n}=e,r=`Executing ${n.toolName}`,i;t[0]!==n||t[1]!==r?(i=(0,z.jsx)(B8,{title:r,part:n}),t[0]=n,t[1]=r,t[2]=i):i=t[2];let a;t[3]===n.input?a=t[4]:(a=(0,z.jsx)(H8,{input:n.input}),t[3]=n.input,t[4]=a);let o;t[5]===n.output?o=t[6]:(o=typeof n.output==`string`?n.output:JSON.stringify(n.output,null,2),t[5]=n.output,t[6]=o);let s;t[7]===o?s=t[8]:(s=(0,z.jsx)(M8,{className:`break-all`,children:o}),t[7]=o,t[8]=s);let c;t[9]!==n.errorText||t[10]!==s?(c=(0,z.jsx)(U8,{output:s,errorText:n.errorText}),t[9]=n.errorText,t[10]=s,t[11]=c):c=t[11];let l;t[12]!==a||t[13]!==c?(l=(0,z.jsxs)(V8,{children:[a,c]}),t[12]=a,t[13]=c,t[14]=l):l=t[14];let u;return t[15]!==i||t[16]!==l?(u=(0,z.jsxs)(R8,{"data-copy-exclude":`assistant-snapshot`,children:[i,l]}),t[15]=i,t[16]=l,t[17]=u):u=t[17],u}var q8=(0,R.createContext)(!1);function J8(e){let t=O6(e),n=e.parts.filter(xv).map(e=>E6(e.text,D6(e.citations)).reverse().reduce((e,{at:n,citation:r})=>`${e.slice(0,n)}[${k6(t,r.source.url)}]${e.slice(n)}`,e.text)).join(`
|
|
348
|
+
`);return t.length===0?n:`${n}\n\n${t.map(({url:e,title:t},n)=>`[${n+1}] ${t?`${t} — `:``}${e}`).join(`
|
|
349
|
+
`)}`}function Y8(){return(0,R.use)(q8)}function X8(e){return Tv(e)&&e.toolMetadata?.kind===`subagent`}function Z8(e,t){let n=Ev(e);return{toolKey:n,toolEntry:t?.[n]}}function Q8(e,t){return e?.static===!1&&!!e?.requiresUserInput&&t===`input-available`}var $8=new Set(`a.abbr.b.bdi.bdo.br.cite.code.data.del.dfn.em.i.ins.kbd.mark.q.s.samp.small.span.strong.sub.sup.time.u.var.wbr`.split(`.`));function e5(e){if(!R.isValidElement(e))return!1;let t=typeof e.type==`string`?e.type:e.props.node?.tagName;return t===void 0||!$8.has(t)}function t5(e){let t=(0,G.c)(6),{children:n,dir:r}=e,i=R.Children.toArray(n);if(!i.some(e5)){let e;return t[0]!==n||t[1]!==r?(e=(0,z.jsx)(`p`,{dir:r,children:n}),t[0]=n,t[1]=r,t[2]=e):e=t[2],e}if(i.every(e5))return n;let a;return t[3]!==n||t[4]!==r?(a=(0,z.jsx)(`div`,{dir:r,children:n}),t[3]=n,t[4]=r,t[5]=a):a=t[5],a}var n5={p:({children:e,dir:t})=>(0,z.jsx)(t5,{dir:t,children:e})};function r5(e){let t={...n5},n={};for(let r of e)Lj(r),t[r.name]=r.component,n[r.name]=r.allowedAttributes;return{components:t,allowedTags:n}}function i5(e){let t=(0,G.c)(10),n,r;t[0]===e?(n=t[1],r=t[2]):({elements:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=n??[],t[3]=n,t[4]=i);let a;t[5]===i?a=t[6]:(a=r5(i),t[5]=i,t[6]=a);let o=a,s;return t[7]!==r||t[8]!==o?(s=(0,z.jsx)(M8,{...o,...r}),t[7]=r,t[8]=o,t[9]=s):s=t[9],s}function a5(e){let t=(0,G.c)(22),{part:n}=e,{addToolApprovalResponse:r}=T6();if(n.state!==`approval-requested`)return null;let i;t[0]===n?i=t[1]:(i=n.title??Ev(n),t[0]=n,t[1]=i);let a=i,o=`${a} approval`,s;t[2]===a?s=t[3]:(s=(0,z.jsx)(`p`,{className:`text-sm font-medium`,children:a}),t[2]=a,t[3]=s);let c;t[4]===n.approval.requestReason?c=t[5]:(c=n.approval.requestReason&&(0,z.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:n.approval.requestReason}),t[4]=n.approval.requestReason,t[5]=c);let l;t[6]!==s||t[7]!==c?(l=(0,z.jsxs)(`div`,{className:`space-y-1`,children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;t[9]!==r||t[10]!==n.approval.id?(u=(0,z.jsx)(Ce,{type:`button`,variant:`destructive`,onClick:()=>void r({id:n.approval.id,approved:!1}),children:`Deny`}),t[9]=r,t[10]=n.approval.id,t[11]=u):u=t[11];let d;t[12]!==r||t[13]!==n.approval.id?(d=(0,z.jsx)(Ce,{type:`button`,onClick:()=>void r({id:n.approval.id,approved:!0}),children:`Approve`}),t[12]=r,t[13]=n.approval.id,t[14]=d):d=t[14];let f;t[15]!==u||t[16]!==d?(f=(0,z.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[u,d]}),t[15]=u,t[16]=d,t[17]=f):f=t[17];let p;return t[18]!==o||t[19]!==l||t[20]!==f?(p=(0,z.jsxs)(`div`,{"aria-label":o,className:`border-border bg-muted/30 space-y-3 rounded-lg border p-3`,"data-copy-exclude":`assistant-snapshot`,role:`group`,children:[l,f]}),t[18]=o,t[19]=l,t[20]=f,t[21]=p):p=t[21],p}function o5(e){let t=(0,G.c)(25),{part:n}=e,{registry:r}=S6();if(n.input===void 0){let e;return t[0]!==n.errorText||t[1]!==n.output||t[2]!==n.state?(e=n.state===`output-error`?(0,z.jsx)(U8,{output:n.output,errorText:n.errorText}):(0,z.jsx)(di,{className:`size-4 animate-spin`}),t[0]=n.errorText,t[1]=n.output,t[2]=n.state,t[3]=e):e=t[3],e}let i;t[4]===n?i=t[5]:(i=(0,z.jsx)(a5,{part:n}),t[4]=n,t[5]=i);let a=i;if(!r)return a;let o;t[6]!==n||t[7]!==r?(o=Z8(n,r),t[6]=n,t[7]=r,t[8]=o):o=t[8];let{toolEntry:s}=o;if(s){let e=s.component,i;t[9]!==n||t[10]!==r.progress?(i=r.progress&&(0,z.jsx)(r.progress.component,{part:n}),t[9]=n,t[10]=r.progress,t[11]=i):i=t[11];let o;t[12]!==e||t[13]!==n?(o=(0,z.jsx)(e,{part:n}),t[12]=e,t[13]=n,t[14]=o):o=t[14];let c;return t[15]!==a||t[16]!==i||t[17]!==o?(c=(0,z.jsxs)(`div`,{className:`space-y-2`,children:[i,o,a]}),t[15]=a,t[16]=i,t[17]=o,t[18]=c):c=t[18],c}else{let e;t[19]!==n||t[20]!==r.progress?(e=r.progress&&(0,z.jsx)(r.progress.component,{part:n}),t[19]=n,t[20]=r.progress,t[21]=e):e=t[21];let i;return t[22]!==a||t[23]!==e?(i=(0,z.jsxs)(z.Fragment,{children:[e,a]}),t[22]=a,t[23]=e,t[24]=i):i=t[24],i}}var s5={animation:`slideUp`};function c5(e){let t=(0,G.c)(3),{filename:n,url:r}=e,i=n??`Attached image`,a;return t[0]!==i||t[1]!==r?(a=(0,z.jsx)(`img`,{src:r,alt:i,className:`max-h-64 rounded-md border object-contain`}),t[0]=i,t[1]=r,t[2]=a):a=t[2],a}function l5(e){let t=(0,G.c)(16),{filename:n,mediaType:r,url:i}=e,a=n||`Untitled`,o;t[0]!==r||t[1]!==a||t[2]!==i?(o=i?.startsWith(`data:`)?null:i&&r.startsWith(`video/`)?(0,z.jsx)(`video`,{controls:!0,playsInline:!0,preload:`metadata`,src:i,"aria-label":a,className:`max-h-96 w-full rounded-md bg-black`,children:(0,z.jsx)(`track`,{kind:`captions`})}):i&&r.startsWith(`audio/`)?(0,z.jsx)(`audio`,{controls:!0,preload:`metadata`,src:i,"aria-label":a,className:`w-full`,children:(0,z.jsx)(`track`,{kind:`captions`})}):null,t[0]=r,t[1]=a,t[2]=i,t[3]=o):o=t[3];let s=o,c=s?`mt-2`:void 0,l;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,z.jsx)(`strong`,{children:`File:`}),t[4]=l):l=t[4];let u;t[5]!==n||t[6]!==i?(u=i?(0,z.jsxs)(z.Fragment,{children:[` `,(0,z.jsx)(`a`,{href:i,download:n,className:`underline`,children:`Download`})]}):null,t[5]=n,t[6]=i,t[7]=u):u=t[7];let d;t[8]!==r||t[9]!==a||t[10]!==c||t[11]!==u?(d=(0,z.jsxs)(`div`,{className:c,children:[l,` `,a,` (`,r,`)`,u]}),t[8]=r,t[9]=a,t[10]=c,t[11]=u,t[12]=d):d=t[12];let f;return t[13]!==s||t[14]!==d?(f=(0,z.jsxs)(qi,{className:`bg-muted/30 block w-full rounded-md p-3 text-sm text-inherit`,children:[s,d]}),t[13]=s,t[14]=d,t[15]=f):f=t[15],f}function u5(e){let t=(0,G.c)(4),{filename:n,mediaType:r,url:i}=e,a;return t[0]!==n||t[1]!==r||t[2]!==i?(a=r.split(`/`)[0]===`image`?(0,z.jsx)(c5,{filename:n,url:i}):(0,z.jsx)(l5,{filename:n,mediaType:r,url:i}),t[0]=n,t[1]=r,t[2]=i,t[3]=a):a=t[3],a}var d5=`genai-citation`;function f5(e,t){return E6(e,t).reverse().reduce((e,{at:t,order:n})=>`${e.slice(0,t)}<${d5} citation="${n}" />${e.slice(t)}`,e)}var p5=(0,R.createContext)(null);function m5(e){let t=(0,G.c)(16),n=(0,R.use)(p5),r=n?.citations[Number(e.citation)];if(!n||!r)return null;let i;t[0]!==r.source.url||t[1]!==n.sources?(i=k6(n.sources,r.source.url),t[0]=r.source.url,t[1]=n.sources,t[2]=i):i=t[2];let a=i;if(a===null)return null;if(n.HostCitation){let e;return t[3]!==r||t[4]!==n.HostCitation||t[5]!==a?(e=(0,z.jsx)(n.HostCitation,{citation:r,index:a}),t[3]=r,t[4]=n.HostCitation,t[5]=a,t[6]=e):e=t[6],e}let o;t[7]!==r.source.title||t[8]!==r.source.url?(o={url:r.source.url,title:r.source.title},t[7]=r.source.title,t[8]=r.source.url,t[9]=o):o=t[9];let s;t[10]===r.citedText?s=t[11]:(s=r.citedText?(0,z.jsx)(`blockquote`,{dir:`auto`,children:r.citedText}):null,t[10]=r.citedText,t[11]=s);let c;return t[12]!==a||t[13]!==o||t[14]!==s?(c=(0,z.jsx)(V6,{source:o,index:a,children:s}),t[12]=a,t[13]=o,t[14]=s,t[15]=c):c=t[15],c}var h5={name:d5,allowedAttributes:[`citation`],component:m5};function g5(e){let t=(0,G.c)(27),{text:n,citations:r,elements:i,className:a}=e,{status:o}=C6(),s=Y8(),{citation:c}=R6(),{message:l}=B6(),u;t[0]===r?u=t[1]:(u=D6(r),t[0]=r,t[1]=u);let d=u,f;t[2]===l?f=t[3]:(f=O6(l),t[2]=l,t[3]=f);let p;t[4]!==c||t[5]!==f||t[6]!==d?(p={citations:d,sources:f,HostCitation:c},t[4]=c,t[5]=f,t[6]=d,t[7]=p):p=t[7];let m=p,h=d.length>0,g;t[8]!==i||t[9]!==h?(g=h?[...i??[],h5]:i,t[8]=i,t[9]=h,t[10]=g):g=t[10];let _=g,v;t[11]===a?v=t[12]:(v=I(`text-sm`,a),t[11]=a,t[12]=v);let y=!s&&o===`streaming`,b;t[13]!==h||t[14]!==n||t[15]!==d?(b=h?f5(n,d):n,t[13]=h,t[14]=n,t[15]=d,t[16]=b):b=t[16];let x;t[17]!==y||t[18]!==b||t[19]!==_?(x=(0,z.jsx)(i5,{elements:_,animated:s5,isAnimating:y,children:b}),t[17]=y,t[18]=b,t[19]=_,t[20]=x):x=t[20];let S;t[21]!==v||t[22]!==x?(S=(0,z.jsx)(`div`,{className:v,children:x}),t[21]=v,t[22]=x,t[23]=S):S=t[23];let C;return t[24]!==m||t[25]!==S?(C=(0,z.jsx)(p5,{value:m,children:S}),t[24]=m,t[25]=S,t[26]=C):C=t[26],C}function _5(e){let t=(0,G.c)(8),{part:n}=e,r=v5(),i;t[0]!==n||t[1]!==r?(i=r&&(0,z.jsx)(G8,{part:n}),t[0]=n,t[1]=r,t[2]=i):i=t[2];let a;t[3]===n?a=t[4]:(a=(0,z.jsx)(o5,{part:n}),t[3]=n,t[4]=a);let o;return t[5]!==i||t[6]!==a?(o=(0,z.jsxs)(z.Fragment,{children:[i,a]}),t[5]=i,t[6]=a,t[7]=o):o=t[7],o}function v5(){let{debugMode:e}=S6(),t=Y8();return!!e&&!t}function y5(e){return!!e&&e!==`output-available`}function b5(e){let t=(0,G.c)(5),{label:n,part:r,state:i}=e,a=Y8(),o;return t[0]!==a||t[1]!==n||t[2]!==r||t[3]!==i?(o=!a&&!!n.actions&&!!r&&!y5(i),t[0]=a,t[1]=n,t[2]=r,t[3]=i,t[4]=o):o=t[4],o}function x5(e){let t=(0,G.c)(18),{label:n,part:r}=e,i=n.icon,a=n.actions,o;t[0]!==n||t[1]!==r?(o={label:n,part:r,state:r.state},t[0]=n,t[1]=r,t[2]=o):o=t[2];let s=b5(o),c;t[3]!==i||t[4]!==n.isError?(c=i&&(0,z.jsx)(i,{className:I(`size-3.5`,n.isError?`text-destructive`:`text-muted-foreground`)}),t[3]=i,t[4]=n.isError,t[5]=c):c=t[5];let l;t[6]===n.name?l=t[7]:(l=(0,z.jsx)(`span`,{className:`font-mono`,children:n.name}),t[6]=n.name,t[7]=l);let u;t[8]!==c||t[9]!==l?(u=(0,z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[c,l]}),t[8]=c,t[9]=l,t[10]=u):u=t[10];let d;t[11]!==a||t[12]!==r||t[13]!==s?(d=s&&a&&(0,z.jsx)(a,{part:r}),t[11]=a,t[12]=r,t[13]=s,t[14]=d):d=t[14];let f;return t[15]!==u||t[16]!==d?(f=(0,z.jsxs)(`div`,{className:`text-muted-foreground flex items-center justify-between gap-1.5 text-xs`,children:[u,d]}),t[15]=u,t[16]=d,t[17]=f):f=t[17],f}function S5(e){let t=(0,G.c)(3),{name:n,value:r}=e,i;return t[0]!==n||t[1]!==r?(i=(0,z.jsxs)(`span`,{"data-slot":`tool-arg`,children:[n,`: "`,r,`"`]}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i}function C5(e){let t=(0,G.c)(23),{label:n,state:r,part:i,children:a}=e,o=n.actions,s;t[0]!==n||t[1]!==i||t[2]!==r?(s={label:n,part:i,state:r},t[0]=n,t[1]=i,t[2]=r,t[3]=s):s=t[3];let c=b5(s),l;t[4]===n.args?l=t[5]:(l=n.args?Object.entries(n.args).map(w5):`...`,t[4]=n.args,t[5]=l);let u;t[6]!==a||t[7]!==n.name||t[8]!==l?(u=(0,z.jsxs)(`span`,{className:`text-muted-foreground min-w-0 truncate font-mono text-xs [&>[data-slot=tool-arg]+[data-slot=tool-arg]]:before:mr-1 [&>[data-slot=tool-arg]+[data-slot=tool-arg]]:before:content-[',']`,children:[n.name,`(`,a,l,`)`]}),t[6]=a,t[7]=n.name,t[8]=l,t[9]=u):u=t[9];let d;t[10]!==o||t[11]!==i||t[12]!==c?(d=c&&o&&i&&(0,z.jsx)(`span`,{className:`shrink-0`,children:(0,z.jsx)(o,{part:i})}),t[10]=o,t[11]=i,t[12]=c,t[13]=d):d=t[13];let f;t[14]!==u||t[15]!==d?(f=(0,z.jsxs)(`span`,{className:`flex items-start justify-between gap-2`,children:[u,d]}),t[14]=u,t[15]=d,t[16]=f):f=t[16];let p;t[17]!==n.detail||t[18]!==n.isError?(p=n.detail&&(0,z.jsx)(`span`,{className:I(`line-clamp-3 text-start font-mono text-[10px] leading-relaxed whitespace-pre-wrap`,n.isError?`text-destructive/80`:`text-muted-foreground`),children:n.detail}),t[17]=n.detail,t[18]=n.isError,t[19]=p):p=t[19];let m;return t[20]!==f||t[21]!==p?(m=(0,z.jsxs)(`span`,{className:`mb-2 flex flex-col gap-1`,children:[f,p]}),t[20]=f,t[21]=p,t[22]=m):m=t[22],m}function w5(e){let[t,n]=e;return(0,z.jsx)(S5,{name:t,value:n},t)}function T5(e){return e.type===`text`&&e.providerMetadata?.openai?.phase===`commentary`}function E5(e){let t=(0,G.c)(9),{segment:n,elements:r,className:i}=e,a;if(t[0]!==i||t[1]!==r||t[2]!==n.parts){let e;t[4]!==i||t[5]!==r?(e=e=>{let{part:t,idx:n}=e;return t.type===`text`?(0,z.jsx)(g5,{text:t.text,citations:t.citations,elements:r,className:i},`${n}-text`):null},t[4]=i,t[5]=r,t[6]=e):e=t[6],a=n.parts.map(e),t[0]=i,t[1]=r,t[2]=n.parts,t[3]=a}else a=t[3];let o;return t[7]===a?o=t[8]:(o=(0,z.jsx)(z.Fragment,{children:a}),t[7]=a,t[8]=o),o}function D5(e){let t=(0,G.c)(4),{segment:n}=e,{part:r}=n;if(r.type!==`file`)return null;let i;return t[0]!==r.filename||t[1]!==r.mediaType||t[2]!==r.url?(i=(0,z.jsx)(u5,{filename:r.filename,mediaType:r.mediaType,url:r.url}),t[0]=r.filename,t[1]=r.mediaType,t[2]=r.url,t[3]=i):i=t[3],i}function O5(e){let t=(0,G.c)(9),{segment:n}=e,{message:r}=B6(),i;t[0]===r?i=t[1]:(i=O6(r),t[0]=r,t[1]=i);let a=i,o;if(t[2]!==n.parts||t[3]!==a){let e;t[5]===a?e=t[6]:(e=e=>{let{part:t,idx:n}=e;if(t.type!==`source-url`)return null;let r=k6(a,t.url);return r===null?null:(0,z.jsx)(V6,{source:{url:t.url,title:t.title},index:r},`source-${n}`)},t[5]=a,t[6]=e),o=n.parts.map(e),t[2]=n.parts,t[3]=a,t[4]=o}else o=t[4];let s;return t[7]===o?s=t[8]:(s=(0,z.jsx)(`span`,{children:o}),t[7]=o,t[8]=s),s}function k5(e){let t=(0,G.c)(3),{segment:n}=e,r=z6();if(Y8())return null;let{part:i}=n;if(i.type!==`reasoning`)return null;let a=r===`streaming`,o;return t[0]!==i.text||t[1]!==a?(o=(0,z.jsx)(`div`,{className:`text-muted-foreground text-xs`,children:(0,z.jsx)(M8,{animated:s5,isAnimating:a,children:i.text})}),t[0]=i.text,t[1]=a,t[2]=o):o=t[2],o}function A5(e){let t=(0,G.c)(2),{segment:n}=e;if(!v5())return null;let{part:r}=n;if(r.type!==`dynamic-tool`)return null;let i;return t[0]===r?i=t[1]:(i=(0,z.jsx)(K8,{part:r}),t[0]=r,t[1]=i),i}var j5=(0,R.createContext)(null),M5=(0,R.createContext)(null);function N5(){let e=(0,R.use)(j5);if(!e)throw Error(`Segment.Tool* parts must be rendered within Segment.Tool`);return e}function P5(e){let t=(0,G.c)(29),{segment:n,children:r}=e,i=S6(),a=z6(),{part:o}=n;if(!Cv(o))return null;let s,c,l,u;t[0]!==i.registry||t[1]!==a||t[2]!==o?({toolEntry:u}=Z8(o,i.registry),c=Q8(u,o.state),s=!c&&j6(o,a),l=u?.label?.(o),t[0]=i.registry,t[1]=a,t[2]=o,t[3]=s,t[4]=c,t[5]=l,t[6]=u):(s=t[3],c=t[4],l=t[5],u=t[6]);let d=l,f;t[7]!==s||t[8]!==d||t[9]!==o?(f=s?{...d??{name:Ev(o)},isError:!0,detail:`Cancelled by user`}:d,t[7]=s,t[8]=d,t[9]=o,t[10]=f):f=t[10];let p=f,m=u?.static===!1&&!!u?.requiresUserInput&&!c,h;t[11]!==s||t[12]!==c||t[13]!==m||t[14]!==p||t[15]!==o?(h={part:o,label:p,aborted:s,activeClientInput:c,defaultOpen:m},t[11]=s,t[12]=c,t[13]=m,t[14]=p,t[15]=o,t[16]=h):h=t[16];let g;t[17]!==s||t[18]!==p||t[19]!==o.state?(g={label:p,state:o.state,aborted:s},t[17]=s,t[18]=p,t[19]=o.state,t[20]=g):g=t[20];let _;t[21]===r?_=t[22]:(_=r??(0,z.jsx)(I5,{}),t[21]=r,t[22]=_);let v;t[23]!==g||t[24]!==_?(v=(0,z.jsx)(M5,{value:g,children:_}),t[23]=g,t[24]=_,t[25]=v):v=t[25];let y;return t[26]!==h||t[27]!==v?(y=(0,z.jsx)(j5,{value:h,children:v}),t[26]=h,t[27]=v,t[28]=y):y=t[28],y}function F5(){let e=(0,G.c)(2),{part:t,activeClientInput:n}=N5();if(n)return null;let r;return e[0]===t?r=e[1]:(r=(0,z.jsx)(_5,{part:t}),e[0]=t,e[1]=r),r}function I5(e){let t=(0,G.c)(9),{children:n}=e,{part:r,label:i,defaultOpen:a}=N5();if(!i){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,z.jsx)(F5,{})}),t[0]=e):e=t[0],e}let o;t[1]!==n||t[2]!==i||t[3]!==r?(o=(0,z.jsx)(Ia,{className:`cursor-pointer`,children:(0,z.jsx)(C5,{label:i,state:r.state,part:r,children:n})}),t[1]=n,t[2]=i,t[3]=r,t[4]=o):o=t[4];let s;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,z.jsx)(La,{className:`mb-2`,children:(0,z.jsx)(F5,{})}),t[5]=s):s=t[5];let c;return t[6]!==a||t[7]!==o?(c=(0,z.jsxs)(Fa,{defaultOpen:a,className:`flex min-w-0 flex-1 flex-col`,children:[o,s]}),t[6]=a,t[7]=o,t[8]=c):c=t[8],c}var L5={Text:E5,File:D5,Source:O5,Reasoning:k5,DynamicTool:A5,Tool:P5,ToolDisclosure:I5,ToolContent:F5};function R5(e){return Cv(e)?`tool`:e.type===`dynamic-tool`?`dynamic-tool`:e.type===`reasoning`&&`text`in e&&e.text?`reasoning`:null}function z5(e,t){return e.kind===`text`||e.kind===`file`||e.kind===`source`?!1:e.kind===`reasoning`||e.kind!==`dynamic-tool`||!!t}function B5(e,t,n){let r=e[t+1];return!!r&&z5(r,n)}function V5(e){let t=[],n=new Set(e.flatMap(e=>e.type===`text`?D6(e.citations).map(({source:e})=>e.url):[]));for(let r=0;r<e.length;r++){let i=e[r],a=R5(i);if(a)t.push({kind:a,part:i,idx:r});else if(i.type===`text`){let e=t[t.length-1];e&&e.kind===`text`?e.parts.push({part:i,idx:r}):t.push({kind:`text`,parts:[{part:i,idx:r}]})}else if(i.type===`file`)t.push({kind:`file`,part:i,idx:r});else if(i.type===`source-url`&&!n.has(i.url)){let e=t[t.length-1];e&&e.kind===`source`?e.parts.push({part:i,idx:r}):t.push({kind:`source`,parts:[{part:i,idx:r}]})}}return t}function H5(e,t){return e.kind===`text`||e.kind===`source`?e.parts[0]?.idx??t:e.idx}(0,R.memo)(function(e){let t=(0,G.c)(8),{segment:n}=e;if(n.kind===`tool`){let e;return t[0]===n?e=t[1]:(e=(0,z.jsx)(L5.Tool,{segment:n}),t[0]=n,t[1]=e),e}if(n.kind===`reasoning`){let e;return t[2]===n?e=t[3]:(e=(0,z.jsx)(L5.Reasoning,{segment:n}),t[2]=n,t[3]=e),e}if(n.kind===`text`){let e;return t[4]===n?e=t[5]:(e=(0,z.jsx)(L5.Text,{segment:n,className:`text-xs`}),t[4]=n,t[5]=e),e}if(n.kind===`file`){let e;return t[6]===n?e=t[7]:(e=(0,z.jsx)(L5.File,{segment:n}),t[6]=n,t[7]=e),e}return null},U5);function U5(e,t){return e.complete&&t.complete&&e.cacheKey===t.cacheKey}function W5(e){let t=(0,G.c)(12),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({icon:r,className:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(a={scale:.94},t[4]=a):a=t[4];let o;t[5]===n?o=t[6]:(o=I(`group text-muted-foreground hover:text-foreground relative rounded-lg p-2 transition-colors`,n),t[5]=n,t[6]=o);let s;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,z.jsx)(`span`,{className:`bg-primary/10 absolute inset-0 rounded-lg opacity-0 transition-opacity group-hover:opacity-100`}),t[7]=s):s=t[7];let c;return t[8]!==r||t[9]!==i||t[10]!==o?(c=(0,z.jsxs)(Tj.button,{type:`button`,whileTap:a,className:o,...i,children:[r,s]}),t[8]=r,t[9]=i,t[10]=o,t[11]=c):c=t[11],c}function G5(){let{index:e}=B6(),{messages:t}=R6(),n=z6();return!(e===t.length-1&&(n===`submitted`||n===`streaming`||n===`error`))}function K5(e){let t=(0,G.c)(5),{className:n,children:r}=e;if(!G5()||R.Children.toArray(r).length===0)return null;let i;t[0]===n?i=t[1]:(i=I(`mt-1 flex items-center gap-0.5`,n),t[0]=n,t[1]=i);let a;return t[2]!==r||t[3]!==i?(a=(0,z.jsx)(`div`,{"data-copy-exclude":`assistant-snapshot`,className:i,children:r}),t[2]=r,t[3]=i,t[4]=a):a=t[4],a}function q5(e){let t=(0,G.c)(12),{className:n}=e,{message:r}=B6(),[i,a]=N8(),o=i?`Copied`:`Copy message`,s;t[0]===n?s=t[1]:(s=I(`p-1.5`,n),t[0]=n,t[1]=s);let c;t[2]!==a||t[3]!==r?(c=()=>void a(J8(r)),t[2]=a,t[3]=r,t[4]=c):c=t[4];let l;t[5]===i?l=t[6]:(l=(0,z.jsx)(i?d:ri,{className:`size-3.5`}),t[5]=i,t[6]=l);let u;return t[7]!==o||t[8]!==s||t[9]!==c||t[10]!==l?(u=(0,z.jsx)(W5,{"aria-label":o,className:s,onClick:c,icon:l}),t[7]=o,t[8]=s,t[9]=c,t[10]=l,t[11]=u):u=t[11],u}function J5(e){let t=(0,G.c)(9),{className:n}=e,{message:r}=B6(),{regenerate:i}=T6(),a;t[0]===n?a=t[1]:(a=I(`p-1.5`,n),t[0]=n,t[1]=a);let o;t[2]!==r.id||t[3]!==i?(o=()=>void i({messageId:r.id}),t[2]=r.id,t[3]=i,t[4]=o):o=t[4];let s;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,z.jsx)(Ci,{className:`size-3.5`}),t[5]=s):s=t[5];let c;return t[6]!==a||t[7]!==o?(c=(0,z.jsx)(W5,{"aria-label":`Regenerate response`,className:a,onClick:o,icon:s}),t[6]=a,t[7]=o,t[8]=c):c=t[8],c}function Y5(e){let t=(0,G.c)(12),{className:n}=e,{message:r}=B6(),[i,a]=N8(),o=i?`Copied`:`Copy debug JSON`,s;t[0]===n?s=t[1]:(s=I(`p-1.5`,n),t[0]=n,t[1]=s);let c;t[2]!==a||t[3]!==r?(c=()=>void a(JSON.stringify(r,null,2)),t[2]=a,t[3]=r,t[4]=c):c=t[4];let l;t[5]===i?l=t[6]:(l=(0,z.jsx)(i?d:Wt,{className:`size-3.5`}),t[5]=i,t[6]=l);let u;return t[7]!==o||t[8]!==s||t[9]!==c||t[10]!==l?(u=(0,z.jsx)(W5,{"aria-label":o,className:s,onClick:c,icon:l}),t[7]=o,t[8]=s,t[9]=c,t[10]=l,t[11]=u):u=t[11],u}function X5(e){let t=(0,G.c)(7),{onTryAgain:n,error:r}=e,i=r instanceof Error?r.message:`An error occurred. Please try again.`,a;t[0]===i?a=t[1]:(a=(0,z.jsx)(`div`,{className:`text-destructive text-sm`,children:(0,z.jsx)(M8,{mode:`static`,children:i})}),t[0]=i,t[1]=a);let o;t[2]===n?o=t[3]:(o=(0,z.jsx)(Ce,{type:`button`,onClick:n,size:`sm`,variant:`outline`,children:`Try Again`}),t[2]=n,t[3]=o);let s;return t[4]!==a||t[5]!==o?(s=(0,z.jsx)(`div`,{className:`mt-3 flex justify-start`,children:(0,z.jsxs)(`div`,{className:`max-w-[80%] space-y-2`,children:[a,o]})}),t[4]=a,t[5]=o,t[6]=s):s=t[6],s}function Z5(e){let t=(0,G.c)(3),{error:n,onRetry:r}=e;if(!n||!r)return null;let i;return t[0]!==n||t[1]!==r?(i=(0,z.jsx)(X5,{onTryAgain:r,error:n}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i}function Q5(e){let t=(0,G.c)(15),{messages:n,className:r,elements:i,citation:a,status:o,children:s}=e,c;t[0]!==a||t[1]!==i||t[2]!==n||t[3]!==o?(c={messages:n,elements:i,citation:a,status:o},t[0]=a,t[1]=i,t[2]=n,t[3]=o,t[4]=c):c=t[4];let l=c,u;t[5]===r?u=t[6]:(u=I(`flex h-full flex-col`,r),t[5]=r,t[6]=u);let d;t[7]===s?d=t[8]:(d=(0,z.jsx)(`div`,{className:`flex h-full min-h-0 flex-1 flex-col`,children:s}),t[7]=s,t[8]=d);let f;t[9]!==u||t[10]!==d?(f=(0,z.jsx)(`div`,{className:u,children:d}),t[9]=u,t[10]=d,t[11]=f):f=t[11];let p;return t[12]!==f||t[13]!==l?(p=(0,z.jsx)(I6,{value:l,children:f}),t[12]=f,t[13]=l,t[14]=p):p=t[14],p}function $5(e){let t=(0,G.c)(5),{className:n,children:r}=e,i;t[0]===n?i=t[1]:(i=I(`flex flex-col gap-4`,n),t[0]=n,t[1]=i);let a;return t[2]!==r||t[3]!==i?(a=(0,z.jsx)(`div`,{className:i,children:r}),t[2]=r,t[3]=i,t[4]=a):a=t[4],a}function e7(e){let t=(0,G.c)(9),{message:n,index:r,className:i,children:a}=e,o;t[0]!==r||t[1]!==n?(o={message:n,index:r},t[0]=r,t[1]=n,t[2]=o):o=t[2];let s=o,c;t[3]!==a||t[4]!==i?(c=(0,z.jsx)(`div`,{className:i,children:a}),t[3]=a,t[4]=i,t[5]=c):c=t[5];let l;return t[6]!==c||t[7]!==s?(l=(0,z.jsx)(L6,{value:s,children:c}),t[6]=c,t[7]=s,t[8]=l):l=t[8],l}function t7(){let e=(0,G.c)(5),{registry:t}=S6(),n=T6().messages,r;if(e[0]!==n||e[1]!==t){bb0:{if(!t){r=null;break bb0}let i=n.findLast(n7);if(!i){r=null;break bb0}let a;e[3]===t?a=e[4]:(a=e=>{if(!Cv(e)||e.state!==`input-available`)return[];let n=t[Ev(e)];return!n||n.static!==!1||!n.requiresUserInput?[]:[{part:e,entry:n}]},e[3]=t,e[4]=a),r=i.parts.flatMap(a).at(0)??null}e[0]=n,e[1]=t,e[2]=r}else r=e[2];return r}function n7(e){let{role:t}=e;return t===`assistant`}function r7(e){let t=(0,G.c)(10),{children:n,className:r}=e,i=t7(),a=i?.entry.component,o=i?`hidden`:`visible`,s;t[0]!==n||t[1]!==o?(s=(0,z.jsx)(R.Activity,{mode:o,children:n}),t[0]=n,t[1]=o,t[2]=s):s=t[2];let c;t[3]!==a||t[4]!==i||t[5]!==r?(c=i&&a?(0,z.jsx)(`div`,{className:I(`sticky bottom-0 mt-auto`,r),children:(0,z.jsx)(a,{part:i.part},i.part.toolCallId)}):null,t[3]=a,t[4]=i,t[5]=r,t[6]=c):c=t[6];let l;return t[7]!==s||t[8]!==c?(l=(0,z.jsxs)(z.Fragment,{children:[s,c]}),t[7]=s,t[8]=c,t[9]=l):l=t[9],l}function i7(e,t){if(e===`error`||e===`ready`||!t)return null;if(t.role!==`assistant`)return`Thinking...`;for(let e=t.parts.length-1;e>=0;e--){let n=t.parts[e];if(xv(n)&&T5(n)&&n.text)return n.text}for(let e=t.parts.length-1;e>=0;e--){let n=t.parts[e];if(Sv(n)&&n.text)return n.text;if(Tv(n)){let e=n.input;if(Yh(e))for(let t of[`reasoning`,`thoughts`,`thought`,`hint`]){let n=e[t];if(typeof n==`string`&&n.length>0)return n}return n.toolCallId}if(xv(n)&&n.text)return``}return`Thinking...`}function a7(e){let t=(0,G.c)(5),{isLast:n}=e,r=n!==void 0&&n,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,z.jsx)(`span`,{className:`bg-muted-foreground/50 z-10 mt-1 size-2 shrink-0 rounded-full`}),t[0]=i):i=t[0];let a;t[1]===r?a=t[2]:(a=!r&&(0,z.jsx)(`span`,{className:`bg-border w-px flex-1`}),t[1]=r,t[2]=a);let o;return t[3]===a?o=t[4]:(o=(0,z.jsxs)(`div`,{className:`absolute top-0 left-0 flex size-3.5 h-full flex-col items-center`,children:[i,a]}),t[3]=a,t[4]=o),o}function o7(e){let t=(0,G.c)(6),{marker:n,children:r,className:i}=e,a;t[0]===i?a=t[1]:(a=I(`relative z-0 flex gap-3 pl-5`,i),t[0]=i,t[1]=a);let o;return t[2]!==r||t[3]!==n||t[4]!==a?(o=(0,z.jsxs)(`div`,{className:a,children:[n,r]}),t[2]=r,t[3]=n,t[4]=a,t[5]=o):o=t[5],o}function s7(){let e=(0,G.c)(6),t=z6(),{messages:n}=R6(),r=t7(),i=n[n.length-1],a;e[0]!==t||e[1]!==i?(a=i7(t,i),e[0]=t,e[1]=i,e[2]=a):a=e[2];let o=a;if(!o||r)return null;let s;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,z.jsx)(a7,{isLast:!0}),e[3]=s):s=e[3];let c;return e[4]===o?c=e[5]:(c=(0,z.jsx)(o7,{className:`mt-2`,marker:s,children:(0,z.jsx)(`span`,{role:`status`,children:(0,z.jsx)(N6,{as:`span`,className:`text-muted-foreground line-clamp-2 font-mono text-xs`,children:o})})}),e[4]=o,e[5]=c),c}var c7=[`inputTokens`,`outputTokens`,`reasoningTokens`,`cachedInputTokens`,`totalTokens`],l7={inputTokens:[[`inputTokens`],[`raw`,`prompt_tokens`]],outputTokens:[[`outputTokens`],[`raw`,`completion_tokens`]],reasoningTokens:[[`reasoningTokens`],[`outputTokenDetails`,`reasoningTokens`],[`raw`,`completion_tokens_details`,`reasoning_tokens`]],cachedInputTokens:[[`inputTokenDetails`,`cacheReadTokens`],[`cachedInputTokens`],[`inputTokenDetails`,`cachedTokens`],[`raw`,`prompt_tokens_details`,`cached_tokens`]],totalTokens:[[`totalTokens`],[`raw`,`total_tokens`]]};function u7(e){if(typeof e==`number`&&Number.isFinite(e)&&e>=0)return e;if(typeof e==`string`&&e.trim().length>0){let t=Number(e);if(Number.isFinite(t)&&t>=0)return t}return null}function d7(e){if(!e||typeof e!=`object`)return null;let t={inputTokens:null,outputTokens:null,reasoningTokens:null,cachedInputTokens:null,totalTokens:null};for(let n of c7)for(let r of l7[n]){let i=u7(Y3(e,r));if(i!==null){t[n]=i;break}}return c7.some(e=>t[e]!==null)?t:null}function f7(e){return Yh(e)?d7(e.totalUsage??e.usage):null}function p7(e){let t=[`↑ ${$3(e.inputTokens)}`,`↓ ${$3(e.outputTokens)}`];return e.totalTokens!==null&&t.push(`· ${Q3(e.totalTokens)} tokens`),e.cachedInputTokens!==null&&e.cachedInputTokens>0&&t.push(`(${$3(e.cachedInputTokens)} cached)`),t.join(` `)}var m7=`x-upload-filename`,h7=Me({path:L().startsWith(`/`),name:L().min(1),mediaType:Mn([`image/png`,`image/jpeg`,`image/webp`,`image/gif`,`image/heic`,`image/heif`,`video/mp4`,`video/quicktime`,`audio/mpeg`,`audio/mp4`,`audio/wav`]),size:Nt().nonnegative(),url:Te()}),g7=class extends Dy{sessionsApi;request;constructor({api:e,fetch:t=(e,t)=>globalThis.fetch(e,t),tools:n={},elements:r=[]}){let i=b7(e),a=r.map(Vj);super({api:i,fetch:async(e,n)=>{let r=await t(e,n);if((n?.method??`GET`).toUpperCase()!==`POST`||!r.ok)return r;let i=await r.json();if(!x7(i))throw Error(`Zukhruf returned an invalid accepted-turn response`);let a=b7(String(e)),o=decodeURIComponent(a.slice(a.lastIndexOf(`/`)+1));if(i.sessionId!==o)throw Error(`Zukhruf returned a different session ID`);let s=n?.signal;return s?.addEventListener(`abort`,()=>{t(`${a}/cancel`,{method:`POST`})},{once:!0}),t(`${a}/stream`,{headers:{accept:`text/event-stream`},method:`GET`,signal:s})},prepareSendMessagesRequest:({id:e,messages:t,trigger:r})=>{let o=t[t.length-1];if(!o)throw Error(`A message is required`);return{api:_7(i,e),body:{sessionId:e,message:o,trigger:r,...Object.keys(n).length>0?{tools:n}:{},...a.length>0?{elements:a}:{}}}},prepareReconnectToStreamRequest:({headers:e,id:t})=>({api:`${_7(i,t)}/stream`,headers:e})}),this.sessionsApi=i,this.request=t}async uploadFile(e,t){let n=await this.request(`${_7(this.sessionsApi,e)}/uploads`,{method:`POST`,headers:{"content-type":t.type,[m7]:encodeURIComponent(t.name)},body:t});if(!n.ok)throw Error(await v7(n,t));let r=h7.safeParse(await n.json());if(!r.success)throw Error(`Zukhruf returned an invalid upload response`);return r.data}};function _7(e,t){return`${e}/${encodeURIComponent(t)}`}async function v7(e,t){let n=`Uploading ${t.name} failed with HTTP ${e.status}`,r=y7(await e.json().catch(e=>{if(e instanceof SyntaxError)return null;throw e}));return r?`${n}: ${r}`:n}function y7(e){if(typeof e!=`object`||!e)return null;let t=`cause`in e&&typeof e.cause==`object`&&e.cause!==null?e.cause:null;return[t&&`code`in t&&typeof t.code==`string`?t.code:null,t&&`detail`in t&&typeof t.detail==`string`?t.detail:`error`in e&&typeof e.error==`string`?e.error:null].filter(e=>e!==null).join(` — `)||null}function b7(e){return e.replace(/\/$/,``)}function x7(e){return typeof e==`object`&&!!e&&`ok`in e&&e.ok===!0&&`sessionId`in e&&typeof e.sessionId==`string`&&`turnId`in e&&typeof e.turnId==`string`}function S7(e){let t=(0,G.c)(24),{label:n,open:r,onOpenChange:i,children:a,className:o,triggerClassName:s,contentClassName:c,chevronClassName:l}=e,u;t[0]===s?u=t[1]:(u=I(`flex items-center font-mono`,s),t[0]=s,t[1]=u);let d;t[2]===u?d=t[3]:(d=(0,z.jsx)(`button`,{type:`button`,className:u}),t[2]=u,t[3]=d);let f=r&&`rotate-180`,p;t[4]!==l||t[5]!==f?(p=I(`size-4 transition-transform`,l,f),t[4]=l,t[5]=f,t[6]=p):p=t[6];let m;t[7]===p?m=t[8]:(m=(0,z.jsx)(He,{className:p}),t[7]=p,t[8]=m);let h;t[9]===n?h=t[10]:(h=(0,z.jsx)(`span`,{children:n}),t[9]=n,t[10]=h);let g;t[11]!==d||t[12]!==m||t[13]!==h?(g=(0,z.jsxs)(Ia,{render:d,children:[m,h]}),t[11]=d,t[12]=m,t[13]=h,t[14]=g):g=t[14];let _;t[15]!==a||t[16]!==c?(_=(0,z.jsx)(La,{className:c,children:a}),t[15]=a,t[16]=c,t[17]=_):_=t[17];let v;return t[18]!==o||t[19]!==i||t[20]!==r||t[21]!==g||t[22]!==_?(v=(0,z.jsxs)(Fa,{open:r,onOpenChange:i,className:o,children:[g,_]}),t[18]=o,t[19]=i,t[20]=r,t[21]=g,t[22]=_,t[23]=v):v=t[23],v}function C7(e){let t=(0,G.c)(7),{metadata:n}=e;if(!n)return null;let r,i,a;if(t[0]!==n){a=Symbol.for(`react.early_return_sentinel`);bb0:{let e=f7(n);if(!e){a=null;break bb0}r=`text-muted-foreground mt-2 text-xs tabular-nums opacity-60`,i=p7(e)}t[0]=n,t[1]=r,t[2]=i,t[3]=a}else r=t[1],i=t[2],a=t[3];if(a!==Symbol.for(`react.early_return_sentinel`))return a;let o;return t[4]!==r||t[5]!==i?(o=(0,z.jsx)(`div`,{className:r,children:i}),t[4]=r,t[5]=i,t[6]=o):o=t[6],o}function w7(e,t){return Yh(e.metadata)?e.metadata[t]:void 0}function T7(e){let t=w7(e,`reminders`);return Array.isArray(t)?t.filter(e=>{if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.id==`string`&&t.id.length>0&&typeof t.text==`string`&&t.text.trim().length>0}):[]}function E7(e){let t=w7(e,`uploads`);return Array.isArray(t)?t.flatMap(e=>{let t=h7.safeParse(e);return t.success?[t.data]:[]}):[]}function D7(e){let t=(0,G.c)(7),{text:n}=e,[r,i]=(0,R.useState)(!1),a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=()=>i(O7),t[0]=a):a=t[0];let o=!r&&`line-clamp-3`,s;t[1]===o?s=t[2]:(s=I(`hover:text-foreground w-full cursor-pointer text-left whitespace-pre-wrap`,o),t[1]=o,t[2]=s);let c;return t[3]!==r||t[4]!==s||t[5]!==n?(c=(0,z.jsx)(`li`,{children:(0,z.jsx)(`button`,{type:`button`,onClick:a,"aria-pressed":r,className:s,children:n})}),t[3]=r,t[4]=s,t[5]=n,t[6]=c):c=t[6],c}function O7(e){return!e}function k7(e){let t=(0,G.c)(8),{reminders:n}=e,[r,i]=(0,R.useState)(!1);if(n.length===0)return null;let a=`${n.length} reminder${n.length===1?``:`s`} attached`,o;t[0]===n?o=t[1]:(o=n.map(A7),t[0]=n,t[1]=o);let s;t[2]===o?s=t[3]:(s=(0,z.jsx)(`ul`,{className:`border-ink-12 text-muted-foreground space-y-1 border-l pl-3 text-xs`,children:o}),t[2]=o,t[3]=s);let c;return t[4]!==a||t[5]!==r||t[6]!==s?(c=(0,z.jsx)(S7,{label:a,open:r,onOpenChange:i,className:`mt-1`,triggerClassName:`text-muted-foreground hover:text-foreground gap-1.5 text-xs`,contentClassName:`mt-1.5`,chevronClassName:`size-3.5`,children:s}),t[4]=a,t[5]=r,t[6]=s,t[7]=c):c=t[7],c}function A7(e){return(0,z.jsx)(D7,{text:e.text},e.id)}function j7(e){let t=(0,G.c)(19),{upload:n}=e;if(n.mediaType.startsWith(`video/`)){let e;t[0]!==n.name||t[1]!==n.url?(e=(0,z.jsx)(`video`,{src:n.url,"aria-label":n.name,muted:!0,playsInline:!0,preload:`metadata`,className:`size-full object-cover`}),t[0]=n.name,t[1]=n.url,t[2]=e):e=t[2];let r;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,z.jsx)(`span`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-0 flex items-center justify-center text-2xl text-white drop-shadow`,children:`▶`}),t[3]=r):r=t[3];let i;return t[4]!==e||t[5]!==n.name?(i=(0,z.jsxs)(Yi,{variant:`image`,className:`size-36 rounded-2xl`,title:n.name,children:[e,r]}),t[4]=e,t[5]=n.name,t[6]=i):i=t[6],i}if(n.mediaType.startsWith(`audio/`)){let e;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,z.jsx)(`span`,{"aria-hidden":!0,className:`text-2xl`,children:`♪`}),t[7]=e):e=t[7];let r;t[8]===n.name?r=t[9]:(r=(0,z.jsx)(`span`,{className:`text-foreground w-full truncate text-center`,children:n.name}),t[8]=n.name,t[9]=r);let i;t[10]===n.mediaType?i=t[11]:(i=(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:n.mediaType}),t[10]=n.mediaType,t[11]=i);let a;return t[12]!==r||t[13]!==i||t[14]!==n.name?(a=(0,z.jsxs)(Yi,{variant:`icon`,className:`h-36 w-48 flex-col gap-1 rounded-2xl px-3 text-xs`,title:n.name,"aria-label":n.name,children:[e,r,i]}),t[12]=r,t[13]=i,t[14]=n.name,t[15]=a):a=t[15],a}let r;return t[16]!==n.name||t[17]!==n.url?(r=(0,z.jsx)(Yi,{variant:`image`,className:`size-36 rounded-2xl`,children:(0,z.jsx)(`img`,{src:n.url,alt:n.name})}),t[16]=n.name,t[17]=n.url,t[18]=r):r=t[18],r}function M7(e){let t=(0,G.c)(13),{message:n}=e,r,i,a,o,s,c;if(t[0]!==n){c=Symbol.for(`react.early_return_sentinel`);bb0:{let e=E7(n);if(e.length===0){c=null;break bb0}r=Xi,i=`list`,a=`Attached files`,o=`max-w-full gap-2 py-0`,s=e.map(N7)}t[0]=n,t[1]=r,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c}else r=t[1],i=t[2],a=t[3],o=t[4],s=t[5],c=t[6];if(c!==Symbol.for(`react.early_return_sentinel`))return c;let l;return t[7]!==r||t[8]!==i||t[9]!==a||t[10]!==o||t[11]!==s?(l=(0,z.jsx)(r,{role:i,"aria-label":a,className:o,children:s}),t[7]=r,t[8]=i,t[9]=a,t[10]=o,t[11]=s,t[12]=l):l=t[12],l}function N7(e){return(0,z.jsx)(`div`,{role:`listitem`,"data-slot":`attachment`,children:(0,z.jsx)(j7,{upload:e})},e.path)}function P7(e){let t=(0,G.c)(10),{body:n,reminders:r,metadata:i}=e,a;t[0]===n?a=t[1]:(a=(0,z.jsx)(`div`,{className:`flex-1 space-y-3`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=(0,z.jsx)(k7,{reminders:r}),t[2]=r,t[3]=o);let s;t[4]===i?s=t[5]:(s=i!==void 0&&(0,z.jsx)(C7,{metadata:i}),t[4]=i,t[5]=s);let c;return t[6]!==a||t[7]!==o||t[8]!==s?(c=(0,z.jsxs)(`div`,{className:`bg-secondary flex max-w-[80%] flex-col gap-3 rounded-lg p-3`,children:[a,o,s]}),t[6]=a,t[7]=o,t[8]=s,t[9]=c):c=t[9],c}function F7(e){let t=(0,G.c)(28),{message:n}=e;w7(n,`reminders`);let r;t[0]===n?r=t[1]:(r=Rb(n),t[0]=n,t[1]=r);let i;t[2]===n?i=t[3]:(i=T7(n),t[2]=n,t[3]=i);let a;t[4]!==r||t[5]!==i?(a={message:r,reminders:i},t[4]=r,t[5]=i,t[6]=a):a=t[6];let{message:o,reminders:s}=a,c;if(t[7]!==n){let e=w7(n,`alias`);c=typeof e==`string`&&e.trim().length>0?e:void 0,t[7]=n,t[8]=c}else c=t[8];let l=c;if(l){let e;t[9]===l?e=t[10]:(e=(0,z.jsx)(`div`,{dir:`auto`,className:`text-sm whitespace-pre-wrap`,children:l}),t[9]=l,t[10]=e);let n;return t[11]!==s||t[12]!==e?(n=(0,z.jsx)(P7,{reminders:s,body:e}),t[11]=s,t[12]=e,t[13]=n):n=t[13],n}let u;t[14]===o?u=t[15]:(u=(0,z.jsx)(M7,{message:o}),t[14]=o,t[15]=u);let d=o.metadata,f;if(t[16]!==o.id||t[17]!==o.parts){let e;t[19]===o.id?e=t[20]:(e=(e,t)=>e.type===`text`?(0,z.jsx)(`div`,{dir:`auto`,className:`text-sm whitespace-pre-wrap`,children:(0,z.jsx)(u4,{text:e.text})},`${o.id}-${t}-text`):null,t[19]=o.id,t[20]=e),f=o.parts.map(e),t[16]=o.id,t[17]=o.parts,t[18]=f}else f=t[18];let p;t[21]!==o.metadata||t[22]!==s||t[23]!==f?(p=(0,z.jsx)(P7,{reminders:s,metadata:d,body:f}),t[21]=o.metadata,t[22]=s,t[23]=f,t[24]=p):p=t[24];let m;return t[25]!==u||t[26]!==p?(m=(0,z.jsxs)(`div`,{className:`flex w-full min-w-0 flex-col items-end gap-3`,children:[u,p]}),t[25]=u,t[26]=p,t[27]=m):m=t[27],m}var I7=(0,R.memo)(function(e){let t=(0,G.c)(7),{className:n}=e,{message:r}=B6(),i;t[0]===n?i=t[1]:(i=I(`flex justify-end`,n),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=(0,z.jsx)(F7,{message:r}),t[2]=r,t[3]=a);let o;return t[4]!==i||t[5]!==a?(o=(0,z.jsx)(`div`,{className:i,children:a}),t[4]=i,t[5]=a,t[6]=o):o=t[6],o});function L7(e){return e.kind===`tool`?!X8(e.part):e.kind===`dynamic-tool`||e.kind===`reasoning`}function R7(e,t){return e.kind===`tool`?!0:e.kind===`reasoning`||e.kind===`dynamic-tool`?!!t:!1}function z7(e){return e.kind===`text`&&e.parts.some(({part:e})=>e.type===`text`&&!T5(e))}function B7(e,t){let n=[];for(let r=0;r<e.length;r++){let i=e[r];if(!L7(i)){n.push({kind:`segment`,segment:i,segmentIndex:r});continue}let a=[],o=r;for(;r<e.length&&L7(e[r]);){let n=e[r];R7(n,t)&&a.push({segment:n}),r++}r--,a.length>0&&n.push({kind:`group`,items:a,hasLaterText:e.slice(r+1).some(e=>z7(e)),firstIndex:o})}return n}function V7(e){if(e.kind!==`tool`&&e.kind!==`dynamic-tool`)return;let{part:t}=e;return Tv(t)?t.state:void 0}function H7({groupStatus:e,labelCount:t}){return e===`running`?{title:`text-info`,detail:`text-info/80`,chevron:`text-info`}:e===`aborted`?{title:`text-destructive`,detail:`text-destructive/80`,chevron:`text-destructive`}:e===`error`?t===1?{title:`text-destructive`,detail:`text-destructive/80`,chevron:`text-destructive`}:{title:`text-warning`,detail:`text-warning/80`,chevron:`text-warning`}:{title:`text-muted-foreground`,detail:`text-muted-foreground`,chevron:`text-muted-foreground`}}function U7(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function W7(e,t=80){let n=e.replace(/\s+/g,` `).trim();return n.length<=t?n:`${n.slice(0,t-3).trimEnd()}...`}function G7(e){if(typeof e==`string`)return W7(e,48);if(typeof e==`number`||typeof e==`boolean`)return String(e);if(Array.isArray(e))return`${e.length} items`}function K7(e){if(!U7(e))return;let t=[`command`,`query`,`path`,`file`,`table`,`metric`,`dimension`,`checks`],n=[...t.filter(t=>t in e).map(t=>[t,e[t]]),...Object.entries(e).filter(([e])=>!t.includes(e))],r={};for(let[e,t]of n){let n=G7(t);if(n&&(r[e]=n,Object.keys(r).length>=2))break}return Object.keys(r).length>0?r:void 0}function q7(e){if(U7(e))for(let t of[`reasoning`,`thoughts`,`thought`,`hint`,`detail`]){let n=e[t];if(typeof n==`string`&&n.trim().length>0)return W7(n)}}function J7(e){if(e.kind!==`reasoning`)return;let{part:t}=e;if(t.type===`reasoning`)return W7(t.text,96)}function Y7(e,t){if(e.kind===`reasoning`)return{kind:`reasoning`,name:`reasoning`,detail:J7(e)};if(e.kind===`dynamic-tool`&&e.part.type===`dynamic-tool`){let t=e.part;return{kind:`dynamic-tool`,name:t.toolName||`Tool`,args:K7(t.input),detail:q7(t.input)}}if(e.kind===`tool`&&Cv(e.part)){let n=e.part,{toolEntry:r,toolKey:i}=Z8(n,t),a=r?.label?.(n);return{kind:`tool`,name:a?.name??i,args:a?.args??K7(n.input),detail:a?.detail??q7(n.input),isError:a?.isError}}return{kind:`tool`,name:`Step`}}function X7(e){if(!e)return;let t=Object.entries(e).filter(e=>typeof e[1]==`string`&&e[1].trim().length>0);if(t.length!==0)return t.slice(0,2).map(([e,t])=>`${e}: ${W7(t,36)}`).join(`, `)}function Z7(e){let t=X7(e.args);return t?`${e.name}(${t})`:e.name}function Q7(e){return e===`output-available`||e===`output-error`||e===`output-denied`}function $7(e){return!!e&&!Q7(e)}function e9(e,t){return A6(e,t)}function t9({items:e,labels:t,status:n,hasLaterText:r}){return e.some(({segment:e})=>e9(V7(e),n))?`aborted`:!r&&(n===`streaming`||n===`submitted`)?`running`:t.some(e=>e.isError)||e.some(({segment:e})=>{let t=V7(e);return t===`output-error`||t===`output-denied`})?`error`:e.some(({segment:e})=>$7(V7(e)))||!r&&t.every(e=>e.kind===`reasoning`)&&(n===`streaming`||n===`submitted`)?`running`:`complete`}function n9(e){return e&&`${e[0].toUpperCase()}${e.slice(1)}`}function r9(e){return e.filter(e=>e.kind!==`reasoning`).length}function i9(e,t){let n=r9(e);if(n!==0)return`${t===`running`||t===`aborted`?`running`:`ran`} ${n} ${n===1?`tool`:`tools`}`}function a9(e,t){let n=i9(e,t);if(n)return n9(t===`error`?`${n} with issues`:t===`aborted`?`cancelled after ${n}`:n)}function o9(e,t,n){let r=e.length===1?e[0]:void 0;if(t===`running`)return n||(r?.kind===`reasoning`?`Reasoning${r.detail?` ${r.detail}`:``}`:e.every(e=>e.kind===`reasoning`)?`Reasoning`:`Working...`);if(r){let e=Z7(r);return t===`error`?`Failed ${e}`:t===`aborted`?`Cancelled ${e}`:r.kind===`reasoning`?`Reasoned${r.detail?` ${r.detail}`:``}`:`Called ${e}`}return e.every(e=>e.kind===`reasoning`)?`Reasoned`:a9(e,t)??`Ran tools`}function s9(e,t){if(t!==`running`){if(e.length===1){let t=e[0];return t.kind===`reasoning`?void 0:t.detail}return Array.from(new Set([...e].sort((e,t)=>e.kind===`reasoning`&&t.kind!==`reasoning`?1:e.kind!==`reasoning`&&t.kind===`reasoning`?-1:0).map(e=>e.name))).slice(0,3).join(`, `)||void 0}}function c9(e){let t;for(let n=e.length-1;n>=0;n--){let r=e[n].segment;if(r.kind===`dynamic-tool`&&r.part.type===`dynamic-tool`){let e=q7(r.part.input);if(e)return e}if(r.kind===`tool`&&Cv(r.part)){let e=q7(r.part.input);if(e)return e}r.kind===`reasoning`&&(t??=J7(r))}return t}function l9(e,t){return!e||e.role!==`assistant`?!1:B7(V5(e.parts),t).some(e=>e.kind===`group`&&!e.hasLaterText)}function u9(){let e=(0,G.c)(8),{message:t}=B6(),{debugMode:n}=S6(),r;e[0]===t.parts?r=e[1]:(r=V5(t.parts),e[0]=t.parts,e[1]=r);let i=r,a;if(e[2]!==n||e[3]!==t.id||e[4]!==i){let r;e[6]===t.id?r=e[7]:(r=e=>e.kind===`group`?{...e,key:`${t.id}-${e.firstIndex}-group-${e.hasLaterText?`past`:`current`}`}:{...e,key:`${t.id}-${H5(e.segment,e.segmentIndex)}-${e.segment.kind}`},e[6]=t.id,e[7]=r),a=B7(i,n).map(r),e[2]=n,e[3]=t.id,e[4]=i,e[5]=a}else a=e[5];return a}var d9=(0,R.createContext)(null);function f9(){let e=(0,R.use)(d9);if(!e)throw Error(`CompactTrajectory group parts must be rendered within CompactTrajectory.Group`);return e}function p9(e){let t=(0,G.c)(21),{group:n,children:r}=e,{registry:i}=S6(),{message:a}=B6(),o=z6(),[s,c]=(0,R.useState)(!n.hasLaterText),l,u,d;if(t[0]!==n.hasLaterText||t[1]!==n.items||t[2]!==i||t[3]!==o){let e;t[7]===i?e=t[8]:(e=e=>{let{segment:t}=e;return Y7(t,i)},t[7]=i,t[8]=e),u=n.items.map(e),l=t9({items:n.items,labels:u,status:o,hasLaterText:n.hasLaterText}),d=H7({groupStatus:l,labelCount:u.length}),t[0]=n.hasLaterText,t[1]=n.items,t[2]=i,t[3]=o,t[4]=l,t[5]=u,t[6]=d}else l=t[4],u=t[5],d=t[6];let f=d,p;t[9]!==n.items||t[10]!==l||t[11]!==u||t[12]!==a.id||t[13]!==f?(p={items:n.items,labels:u,groupStatus:l,tone:f,messageId:a.id},t[9]=n.items,t[10]=l,t[11]=u,t[12]=a.id,t[13]=f,t[14]=p):p=t[14];let m;t[15]!==r||t[16]!==s?(m=(0,z.jsx)(Fa,{open:s,onOpenChange:c,className:`my-2 min-w-0`,children:r}),t[15]=r,t[16]=s,t[17]=m):m=t[17];let h;return t[18]!==p||t[19]!==m?(h=(0,z.jsx)(d9,{value:p,children:m}),t[18]=p,t[19]=m,t[20]=h):h=t[20],h}function m9(e){let t=(0,G.c)(3),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,z.jsx)(`button`,{type:`button`,className:F6(`items-start`)}),t[0]=r):r=t[0];let i;return t[1]===n?i=t[2]:(i=(0,z.jsx)(Ia,{render:r,children:(0,z.jsx)(`span`,{className:`min-w-0 flex-1 text-left text-sm`,children:n})}),t[1]=n,t[2]=i),i}function h9(){let e=(0,G.c)(12),{items:t,labels:n,groupStatus:r,tone:i}=f9(),a;e[0]!==r||e[1]!==t||e[2]!==n?(a=o9(n,r,c9(t)),e[0]=r,e[1]=t,e[2]=n,e[3]=a):a=e[3];let o=a,s;e[4]!==r||e[5]!==n?(s=s9(n,r),e[4]=r,e[5]=n,e[6]=s):s=e[6];let c=s,l;return e[7]!==c||e[8]!==r||e[9]!==o||e[10]!==i?(l={title:o,detail:c,tone:i,groupStatus:r},e[7]=c,e[8]=r,e[9]=o,e[10]=i,e[11]=l):l=e[11],l}function g9(e){let t=(0,G.c)(9),{title:n,suffix:r,children:i}=e,{title:a,tone:o,groupStatus:s}=h9(),c=n??a,l=r?`${c} · ${r}`:c,u=s===`running`,d=s===`running`?`text-info`:o.title,f;t[0]===d?f=t[1]:(f=I(`max-w-full min-w-0 truncate`,d),t[0]=d,t[1]=f);let p;t[2]!==u||t[3]!==f||t[4]!==l?(p=(0,z.jsx)(N6,{as:`span`,enabled:u,className:f,children:l}),t[2]=u,t[3]=f,t[4]=l,t[5]=p):p=t[5];let m;return t[6]!==i||t[7]!==p?(m=(0,z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[p,i]}),t[6]=i,t[7]=p,t[8]=m):m=t[8],m}function _9(){let e=(0,G.c)(2),{tone:t}=f9(),n;return e[0]===t.chevron?n=e[1]:(n=(0,z.jsx)(P6,{className:t.chevron}),e[0]=t.chevron,e[1]=n),n}function v9(e){let t=(0,G.c)(5),{detail:n}=e,{title:r,detail:i,tone:a}=h9();if(n===null)return null;let o=n??i;if(!o||o===r)return null;let s;t[0]===a.detail?s=t[1]:(s=I(`block truncate text-xs`,a.detail),t[0]=a.detail,t[1]=s);let c;return t[2]!==o||t[3]!==s?(c=(0,z.jsx)(`span`,{className:s,children:o}),t[2]=o,t[3]=s,t[4]=c):c=t[4],c}function y9(e){let t=(0,G.c)(14),{children:n}=e,{items:r,messageId:i,groupStatus:a}=f9(),o=a===`running`,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s={initial:`instant`,resize:`instant`},t[0]=s):s=t[0];let{scrollRef:c,contentRef:l}=jj(s),u=o?c:void 0,d=o&&`max-h-64 overflow-y-auto`,f;t[1]===d?f=t[2]:(f=I(`mt-2`,d),t[1]=d,t[2]=f);let p=o?l:void 0,m;t[3]!==n||t[4]!==r||t[5]!==i?(m=n??r.map((e,t)=>{let{segment:n}=e,r=`${i}-${H5(n,t)}-${n.kind}`;return n.kind===`tool`?(0,z.jsx)(L5.Tool,{segment:n},r):n.kind===`reasoning`?(0,z.jsx)(L5.Reasoning,{segment:n},r):n.kind===`dynamic-tool`?(0,z.jsx)(L5.DynamicTool,{segment:n},r):null}),t[3]=n,t[4]=r,t[5]=i,t[6]=m):m=t[6];let h;t[7]!==p||t[8]!==m?(h=(0,z.jsx)(`div`,{ref:p,children:m}),t[7]=p,t[8]=m,t[9]=h):h=t[9];let g;return t[10]!==u||t[11]!==f||t[12]!==h?(g=(0,z.jsx)(La,{ref:u,className:f,children:h}),t[10]=u,t[11]=f,t[12]=h,t[13]=g):g=t[13],g}function b9(e){let t=(0,G.c)(19),{item:n,textClassName:r}=e,i=r===void 0?`my-4`:r,{elements:a}=R6(),{segment:o}=n;if(o.kind===`text`){let e;t[0]===o.parts?e=t[1]:(e=o.parts.filter(x9),t[0]=o.parts,t[1]=e);let n=e;if(n.length===0)return null;let r;t[2]!==o||t[3]!==n?(r={...o,parts:n},t[2]=o,t[3]=n,t[4]=r):r=t[4];let s;return t[5]!==a||t[6]!==r||t[7]!==i?(s=(0,z.jsx)(L5.Text,{segment:r,elements:a,className:i}),t[5]=a,t[6]=r,t[7]=i,t[8]=s):s=t[8],s}if(o.kind===`file`){let e;return t[9]===o?e=t[10]:(e=(0,z.jsx)(L5.File,{segment:o}),t[9]=o,t[10]=e),e}if(o.kind===`source`){let e;return t[11]===o?e=t[12]:(e=(0,z.jsx)(L5.Source,{segment:o}),t[11]=o,t[12]=e),e}if(o.kind===`tool`){let e;return t[13]===o?e=t[14]:(e=(0,z.jsx)(L5.Tool,{segment:o}),t[13]=o,t[14]=e),e}if(o.kind===`reasoning`){let e;return t[15]===o?e=t[16]:(e=(0,z.jsx)(L5.Reasoning,{segment:o}),t[15]=o,t[16]=e),e}if(o.kind===`dynamic-tool`){let e;return t[17]===o?e=t[18]:(e=(0,z.jsx)(L5.DynamicTool,{segment:o}),t[17]=o,t[18]=e),e}return null}function x9(e){let{part:t}=e;return!T5(t)}function S9(){let e=(0,G.c)(1),t=z6(),{messages:n}=R6(),{debugMode:r}=S6(),i=n[n.length-1];if(t!==`ready`&&t!==`error`&&l9(i,r))return null;let a;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,z.jsx)(s7,{}),e[0]=a):a=e[0],a}var C9={Root:Q5,List:$5,Item:e7,UserBubble:I7,AssistantContent:(0,R.memo)(function(e){let t=(0,G.c)(5),{className:n}=e,r=u9(),i;t[0]===r?i=t[1]:(i=r.map(Iee),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,z.jsx)(`div`,{className:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a}),Actions:K5,CopyAction:q5,RegenerateAction:J5,CopyDebugJsonAction:Y5,Thinking:S9,Error:Z5};function Iee(e){return e.kind===`group`?(0,z.jsxs)(p9,{group:e,children:[(0,z.jsxs)(m9,{children:[(0,z.jsx)(g9,{children:(0,z.jsx)(_9,{})}),(0,z.jsx)(v9,{})]}),(0,z.jsx)(y9,{})]},e.key):(0,z.jsx)(b9,{item:e},e.key)}function Lee(e){let t=(0,G.c)(8),{message:n,className:r}=e,i;t[0]===r?i=t[1]:(i=I(`text-destructive/90 bg-destructive/10 flex items-start gap-2 rounded-md px-3 py-2 text-sm`,r),t[0]=r,t[1]=i);let a;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,z.jsx)(_t,{className:`text-destructive mt-0.5 size-4 shrink-0`}),t[2]=a):a=t[2];let o;t[3]===n?o=t[4]:(o=(0,z.jsx)(`span`,{children:n}),t[3]=n,t[4]=o);let s;return t[5]!==i||t[6]!==o?(s=(0,z.jsxs)(`div`,{className:i,children:[a,o]}),t[5]=i,t[6]=o,t[7]=s):s=t[7],s}function Ree(e){let t=(0,G.c)(15),{part:n}=e,r=S6(),i,a;if(t[0]!==r.registry||t[1]!==n){a=Symbol.for(`react.early_return_sentinel`);bb0:{let{toolEntry:e}=Z8(n,r.registry);if(e&&Q8(e,n.state)){let t=e.label?.(n);if(!t){a=null;break bb0}let r=t.icon,i=t.args?Object.values(t.args)[0]:void 0;a=(0,z.jsxs)(`div`,{className:`text-muted-foreground flex items-center text-xs`,children:[r&&(0,z.jsx)(r,{className:`size-3.5`}),(0,z.jsx)(`span`,{className:`ms-2 font-mono`,children:t.name}),i&&(0,z.jsxs)(`span`,{className:`truncate`,children:[`(`,i,`)`]})]});break bb0}i=e?.label?.(n)}t[0]=r.registry,t[1]=n,t[2]=i,t[3]=a}else i=t[2],a=t[3];if(a!==Symbol.for(`react.early_return_sentinel`))return a;let o=i,s;t[4]!==o||t[5]!==n?(s=o&&(0,z.jsx)(x5,{label:o,part:n}),t[4]=o,t[5]=n,t[6]=s):s=t[6];let c;t[7]===o?c=t[8]:(c=o?.isError&&o.detail&&(0,z.jsx)(Lee,{message:o.detail}),t[7]=o,t[8]=c);let l;t[9]===n?l=t[10]:(l=(0,z.jsx)(_5,{part:n}),t[9]=n,t[10]=l);let u;return t[11]!==s||t[12]!==c||t[13]!==l?(u=(0,z.jsxs)(z.Fragment,{children:[s,c,l]}),t[11]=s,t[12]=c,t[13]=l,t[14]=u):u=t[14],u}function zee(e){let t=(0,G.c)(5),{part:n}=e,[r,i]=(0,R.useState)(!1),a;t[0]===n.text?a=t[1]:(a=(0,z.jsx)(M8,{mode:`static`,children:n.text}),t[0]=n.text,t[1]=a);let o;return t[2]!==r||t[3]!==a?(o=(0,z.jsx)(`div`,{"data-copy-exclude":`assistant-snapshot`,className:`bg-muted/30 prose max-w-auto prose-sm text-muted-foreground border-border mb-4 w-full min-w-full rounded-lg p-3`,children:(0,z.jsx)(S7,{label:`Reasoning`,open:r,onOpenChange:i,className:`text-xs`,triggerClassName:`w-full gap-x-2 text-sm hover:opacity-80`,contentClassName:`mt-2`,children:a})}),t[2]=r,t[3]=a,t[4]=o):o=t[4],o}function Bee(e){let t=(0,G.c)(16),{part:n}=e,{elements:r}=R6(),i=v5();if(n.type===`text`){if(T5(n))return null;let e;return t[0]!==r||t[1]!==n.citations||t[2]!==n.text?(e=(0,z.jsx)(g5,{text:n.text,citations:n.citations,elements:r}),t[0]=r,t[1]=n.citations,t[2]=n.text,t[3]=e):e=t[3],e}if(n.type===`dynamic-tool`){let e;return t[4]!==i||t[5]!==n?(e=i?(0,z.jsx)(K8,{part:n}):null,t[4]=i,t[5]=n,t[6]=e):e=t[6],e}if(Cv(n)){let e;return t[7]===n?e=t[8]:(e=(0,z.jsx)(Ree,{part:n}),t[7]=n,t[8]=e),e}if(n.type===`reasoning`&&n.text){let e;return t[9]!==i||t[10]!==n?(e=i?(0,z.jsx)(zee,{part:n}):null,t[9]=i,t[10]=n,t[11]=e):e=t[11],e}if(n.type===`file`){let e;return t[12]!==n.filename||t[13]!==n.mediaType||t[14]!==n.url?(e=(0,z.jsx)(u5,{filename:n.filename,mediaType:n.mediaType,url:n.url}),t[12]=n.filename,t[13]=n.mediaType,t[14]=n.url,t[15]=e):e=t[15],e}return null}(0,R.memo)(function(e){let t=(0,G.c)(10),{className:n}=e,{message:r}=B6(),i;t[0]===n?i=t[1]:(i=I(`flex-1 space-y-3`,n),t[0]=n,t[1]=i);let a;if(t[2]!==r.id||t[3]!==r.parts){let e;t[5]===r.id?e=t[6]:(e=(e,t)=>(0,z.jsx)(Bee,{part:e},`${r.id}-${t}`),t[5]=r.id,t[6]=e),a=r.parts.map(e),t[2]=r.id,t[3]=r.parts,t[4]=a}else a=t[4];let o;return t[7]!==i||t[8]!==a?(o=(0,z.jsx)(`div`,{className:i,children:a}),t[7]=i,t[8]=a,t[9]=o):o=t[9],o});var Vee={braille:{frames:[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`],interval:80},pulse:{frames:[`⠁`,`⠉`,`⠋`,`⠛`,`⠟`,`⠿`,`⡿`,`⣿`,`⡿`,`⠿`,`⠟`,`⠛`,`⠋`,`⠉`,`⠁`,`⠀`],interval:80},clock:{frames:[`⠁`,`⠈`,`⠐`,`⠠`,`⢀`,`⡀`,`⠄`,`⠂`],interval:100},limerence:{frames:[`⠁`,`⠃`,`⠇`,`⡇`,`⣇`,`⣇`,`⣆`,`⣄`,`⣀`,`⢀`,`⠀`],interval:100}};function Hee(e){let t=(0,G.c)(15),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,variant:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0?`braille`:i,o=ln(),{frames:s,interval:c}=Vee[a],[l,u]=(0,R.useState)(0),d,f;t[4]!==o||t[5]!==s.length||t[6]!==c?(d=()=>{if(window.matchMedia(`(prefers-reduced-motion: reduce)`).matches)return;let e=o.setInterval(()=>{u(e=>(e+1)%s.length)},c);return()=>o.clearInterval(e)},f=[o,s.length,c],t[4]=o,t[5]=s.length,t[6]=c,t[7]=d,t[8]=f):(d=t[7],f=t[8]),(0,R.useEffect)(d,f);let p;t[9]===n?p=t[10]:(p=I(`inline-block`,n),t[9]=n,t[10]=p);let m=s[l],h;return t[11]!==r||t[12]!==p||t[13]!==m?(h=(0,z.jsx)(`span`,{role:`status`,"aria-label":`Loading`,className:p,...r,children:m}),t[11]=r,t[12]=p,t[13]=m,t[14]=h):h=t[14],h}function Uee(e){let t=(0,G.c)(11),{Icon:n,isLast:r,isLoading:i,aborted:a,state:o,isError:s}=e,c;t[0]!==n||t[1]!==a||t[2]!==s||t[3]!==i||t[4]!==o?(c=i?(0,z.jsx)(Hee,{className:`text-muted-foreground z-10 shrink-0 text-sm`}):a?(0,z.jsx)(Jn,{className:`text-destructive z-10 size-3.5 shrink-0`}):(0,z.jsx)(n,{className:I(`z-10 size-3.5 shrink-0`,o===`output-error`||s?`text-destructive`:`text-muted-foreground`)}),t[0]=n,t[1]=a,t[2]=s,t[3]=i,t[4]=o,t[5]=c):c=t[5];let l;t[6]===r?l=t[7]:(l=!r&&(0,z.jsx)(`span`,{className:`bg-border w-px flex-1`}),t[6]=r,t[7]=l);let u;return t[8]!==c||t[9]!==l?(u=(0,z.jsxs)(`div`,{className:`absolute top-0 left-0 flex h-full flex-col items-center`,children:[c,l]}),t[8]=c,t[9]=l,t[10]=u):u=t[10],u}function Wee(e){let t=(0,G.c)(15),{isLast:n,label:r,state:i,aborted:a,children:o}=e,s=(0,R.use)(M5),c=r??s?.label,l=i??s?.state,u=a??s?.aborted??!1,d=c?.icon,f=!!l&&!u&&l!==`output-available`&&l!==`output-error`,p;t[0]!==d||t[1]!==u||t[2]!==c?.isError||t[3]!==l||t[4]!==n||t[5]!==f?(p=d?(0,z.jsx)(Uee,{Icon:d,isLast:n,isLoading:f,aborted:u,state:l,isError:c?.isError??!1}):(0,z.jsx)(a7,{isLast:n}),t[0]=d,t[1]=u,t[2]=c?.isError,t[3]=l,t[4]=n,t[5]=f,t[6]=p):p=t[6];let m=p,h=n?``:`pb-3.5`,g;t[7]===h?g=t[8]:(g=I(`min-w-0 flex-1`,h),t[7]=h,t[8]=g);let _;t[9]!==o||t[10]!==g?(_=(0,z.jsx)(`div`,{className:g,children:o}),t[9]=o,t[10]=g,t[11]=_):_=t[11];let v;return t[12]!==m||t[13]!==_?(v=(0,z.jsx)(o7,{marker:m,children:_}),t[12]=m,t[13]=_,t[14]=v):v=t[14],v}function Gee(e){let t=(0,G.c)(10),{label:n,state:r,part:i,defaultOpen:a,children:o}=e,s=a!==void 0&&a,c;t[0]!==n||t[1]!==i||t[2]!==r?(c=(0,z.jsx)(Ia,{className:`cursor-pointer`,children:(0,z.jsx)(C5,{label:n,state:r,part:i})}),t[0]=n,t[1]=i,t[2]=r,t[3]=c):c=t[3];let l;t[4]===o?l=t[5]:(l=(0,z.jsx)(La,{children:o}),t[4]=o,t[5]=l);let u;return t[6]!==s||t[7]!==c||t[8]!==l?(u=(0,z.jsxs)(Fa,{defaultOpen:s,className:`flex min-w-0 flex-1 flex-col`,children:[c,l]}),t[6]=s,t[7]=c,t[8]=l,t[9]=u):u=t[9],u}var w9={Item:Wee,Disclosure:Gee};(0,R.memo)(function(e){let t=(0,G.c)(12),{className:n}=e,{message:r}=B6(),{elements:i}=R6(),{debugMode:a}=S6(),o=v5(),s=Y8(),c;t[0]===r.parts?c=t[1]:(c=V5(r.parts),t[0]=r.parts,t[1]=c);let l=c,u;t[2]!==a||t[3]!==i||t[4]!==s||t[5]!==r.id||t[6]!==l||t[7]!==o?(u=l.map((e,t)=>{let n=`${r.id}-${H5(e,t)}-${e.kind}`;if(e.kind===`text`)return(0,z.jsx)(L5.Text,{segment:e,elements:i,className:`my-4`},n);if(e.kind===`file`)return(0,z.jsx)(L5.File,{segment:e},n);if(e.kind===`source`)return(0,z.jsx)(L5.Source,{segment:e},n);if(e.kind===`dynamic-tool`){if(!o)return null;let r=!B5(l,t,!0);return(0,z.jsx)(w9.Item,{isLast:r,children:(0,z.jsx)(L5.DynamicTool,{segment:e})},n)}if(e.kind===`reasoning`){if(s||e.part.type!==`reasoning`)return null;let r=!B5(l,t,a),i={name:`Reasoning`,icon:si,args:{text:[...e.part.text].slice(0,60).join(``)}};return(0,z.jsx)(w9.Item,{isLast:r,label:i,children:(0,z.jsx)(w9.Disclosure,{label:i,children:(0,z.jsx)(L5.Reasoning,{segment:e})})},n)}if(e.kind===`tool`){let r=!B5(l,t,a);return(0,z.jsx)(L5.Tool,{segment:e,children:(0,z.jsx)(w9.Item,{isLast:r,children:(0,z.jsx)(L5.ToolDisclosure,{})})},n)}return null}),t[2]=a,t[3]=i,t[4]=s,t[5]=r.id,t[6]=l,t[7]=o,t[8]=u):u=t[8];let d;return t[9]!==n||t[10]!==u?(d=(0,z.jsx)(`div`,{className:n,children:u}),t[9]=n,t[10]=u,t[11]=d):d=t[11],d});function Kee(e){let t=(0,G.c)(9),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let{hasSubmitted:i}=w6(),a;t[3]===n?a=t[4]:(a=I(`bg-background sticky bottom-0 rounded-t-2xl border-0 **:data-[slot=composer-editor]:!min-h-15`,n),t[3]=n,t[4]=a);let o;return t[5]!==i||t[6]!==r||t[7]!==a?(o=(0,z.jsx)(c4.Root,{hasInteracted:i,className:a,...r}),t[5]=i,t[6]=r,t[7]=a,t[8]=o):o=t[8],o}function qee(e){let t=(0,G.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=I(`border-border bg-card focus-within:border-primary/80 focus-within:ring-primary/15 relative rounded-2xl border`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,z.jsx)(`div`,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Jee(e){let t=(0,G.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=I(`space-y-1 px-3.5 pt-3`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,z.jsx)(c4.Content,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Yee(e){let t=(0,G.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=I(`!min-h-15 !rounded-none !border-0 !bg-transparent !shadow-none **:data-[slot=composer-editor]:!p-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,z.jsx)(c4.Editor,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Xee(e){let t=(0,G.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=I(`pb-1.5`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,z.jsx)(c4.Attachments,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Zee(e){let t=(0,G.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=I(`p-1.5 pt-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,z.jsx)(c4.Toolbar,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Qee(e){let t=(0,G.c)(3),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,z.jsx)(W5,{icon:(0,z.jsx)(yi,{className:`size-4`})}),t[0]=n):n=t[0];let r;return t[1]===e?r=t[2]:(r=(0,z.jsx)(c4.AttachFiles,{"aria-label":`Attach files`,render:n,...e}),t[1]=e,t[2]=r),r}function $ee(){let e=(0,G.c)(6),{actions:t,meta:n}=qQ(`ChatComposer.CommandButton`),r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,z.jsx)(xi,{className:`size-4`}),e[0]=r):r=e[0];let i=n.activePopup?.trigger===`/`,a;e[1]===t?a=e[2]:(a=e=>{e.stopPropagation(),t.toggleSlashMenu()},e[1]=t,e[2]=a);let o;return e[3]!==i||e[4]!==a?(o=(0,z.jsx)(W5,{"data-command-button":!0,icon:r,"aria-label":`Toggle command menu`,"aria-expanded":i,onClick:a}),e[3]=i,e[4]=a,e[5]=o):o=e[5],o}function ete(e){switch(e){case`permission-denied`:return`Allow microphone access to use dictation`;case`no-microphone`:return`Connect a microphone to use dictation`;case`microphone-in-use`:return`Close other apps using the microphone`;case`interrupted`:return`Recording interrupted`;case`transcription-failed`:return`Unable to transcribe audio`}}function tte(e){switch(e.status){case`unavailable`:return e.reason===`blocked`?`Allow microphone access in your browser settings to use dictation`:`Dictation is not available in this browser`;case`idle`:return`Start dictation`;case`starting`:return`Starting dictation`;case`recording`:return`Stop dictation`;case`finishing`:return`Transcribing…`;case`failed`:return ete(e.error.code)}}function nte(e){switch(e.status){case`recording`:return(0,z.jsx)(Ti,{className:`size-4 fill-current`});case`starting`:case`finishing`:return(0,z.jsx)(me,{className:`size-4 animate-spin`});case`unavailable`:case`idle`:case`failed`:return(0,z.jsx)(pi,{className:`size-4`})}}function rte(){let e=(0,G.c)(20),{status:t}=C6(),{state:n}=Y1(`ChatComposer.Dictate`),r;e[0]===n?r=e[1]:(r=tte(n),e[0]=n,e[1]=r);let i=r,a=n.status===`starting`||n.status===`recording`||n.status===`finishing`,o=t===`streaming`||t===`submitted`,s;e[2]===n?s=e[3]:(s=nte(n),e[2]=n,e[3]=s);let c;e[4]!==i||e[5]!==s?(c=(0,z.jsx)(W5,{icon:s,"aria-label":i,title:i}),e[4]=i,e[5]=s,e[6]=c):c=e[6];let l;e[7]!==o||e[8]!==c?(l=(0,z.jsx)(c4.Dictate,{disabled:o,render:c}),e[7]=o,e[8]=c,e[9]=l):l=e[9];let u;e[10]!==a||e[11]!==n.status?(u=a?(0,z.jsx)(c4.CancelDictation,{render:(0,z.jsx)(W5,{icon:(0,z.jsx)(ye,{className:`size-4`}),"aria-label":n.status===`finishing`?`Cancel transcription`:`Cancel dictation`})}):null,e[10]=a,e[11]=n.status,e[12]=u):u=e[12];let d;e[13]!==i||e[14]!==n.status?(d=n.status===`failed`?(0,z.jsx)(`span`,{role:`status`,className:`text-destructive max-w-48 truncate text-xs`,children:i}):null,e[13]=i,e[14]=n.status,e[15]=d):d=e[15];let f;return e[16]!==l||e[17]!==u||e[18]!==d?(f=(0,z.jsxs)(z.Fragment,{children:[l,u,d]}),e[16]=l,e[17]=u,e[18]=d,e[19]=f):f=e[19],f}var T9={Provider:Kee,Root:qee,Popup:c4.Popup,Content:Jee,Attachments:Xee,Editor:Yee,Error:c4.Error,Toolbar:Zee,CommandButton:$ee,AttachFiles:Qee,Dictate:rte};function ite(e){let t=(0,G.c)(5),{children:n,className:r}=e,i;t[0]===r?i=t[1]:(i=I(`border-border flex flex-col border-b px-2 py-1.5`,r),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,z.jsx)(`div`,{className:i,children:n}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a}function ate(e){let t=(0,G.c)(5),{children:n,className:r}=e,i;t[0]===r?i=t[1]:(i=I(`flex items-center gap-2 px-2 py-1.5`,r),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,z.jsx)(`div`,{className:i,children:n}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a}function ote(e){let t=(0,G.c)(4),{className:n}=e,r;t[0]===n?r=t[1]:(r=I(`text-muted-foreground size-3.5 shrink-0`,n),t[0]=n,t[1]=r);let i;return t[2]===r?i=t[3]:(i=(0,z.jsx)(li,{className:r}),t[2]=r,t[3]=i),i}function ste(e){let t=(0,G.c)(7),{children:n,className:r}=e,i;t[0]===r?i=t[1]:(i=I(`min-w-0 flex-1 truncate text-sm`,r),t[0]=r,t[1]=i);let a;t[2]===n?a=t[3]:(a=typeof n==`string`?(0,z.jsx)(u4,{text:n}):n,t[2]=n,t[3]=a);let o;return t[4]!==i||t[5]!==a?(o=(0,z.jsx)(`span`,{className:i,children:a}),t[4]=i,t[5]=a,t[6]=o):o=t[6],o}function cte(e){let t=(0,G.c)(6),{onClick:n,className:r}=e,i;t[0]===r?i=t[1]:(i=I(`text-muted-foreground hover:text-foreground shrink-0 rounded p-1 transition-colors`,r),t[0]=r,t[1]=i);let a;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,z.jsx)(Rn,{className:`size-3.5`}),t[2]=a):a=t[2];let o;return t[3]!==n||t[4]!==i?(o=(0,z.jsx)(`button`,{type:`button`,onClick:n,className:i,"aria-label":`Remove queued message`,children:a}),t[3]=n,t[4]=i,t[5]=o):o=t[5],o}var E9={Root:ite,Item:ate,Icon:ote,Text:ste,Remove:cte},lte={normal:{d:`m5 12 7-7 7 7`,translateY:0},animate:{d:`m5 12 7-7 7 7`,translateY:[0,3,0],transition:{duration:.4}}},ute={normal:{d:`M12 19V5`},animate:{d:[`M12 19V5`,`M12 19V10`,`M12 19V5`],transition:{duration:.4}}},D9=e=>{let t=(0,G.c)(30),n,r,i,a,o,s;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6]):({ref:o,onMouseEnter:r,onMouseLeave:i,className:n,size:s,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s);let c=s===void 0?20:s,l=wj(),u=(0,R.useRef)(!1),d;t[7]===l?d=t[8]:(d=()=>(u.current=!0,{startAnimation:()=>l.start(`animate`),stopAnimation:()=>l.start(`normal`)}),t[7]=l,t[8]=d),(0,R.useImperativeHandle)(o,d);let f;t[9]!==l||t[10]!==r?(f=e=>{u.current?r?.(e):l.start(`animate`)},t[9]=l,t[10]=r,t[11]=f):f=t[11];let p=f,m;t[12]!==l||t[13]!==i?(m=e=>{u.current?i?.(e):l.start(`normal`)},t[12]=l,t[13]=i,t[14]=m):m=t[14];let h=m,g;t[15]===n?g=t[16]:(g=I(n),t[15]=n,t[16]=g);let _,v;t[17]===l?(_=t[18],v=t[19]):(_=(0,z.jsx)(Tj.path,{animate:l,d:`m5 12 7-7 7 7`,variants:lte}),v=(0,z.jsx)(Tj.path,{animate:l,d:`M12 19V5`,variants:ute}),t[17]=l,t[18]=_,t[19]=v);let y;t[20]!==c||t[21]!==_||t[22]!==v?(y=(0,z.jsxs)(`svg`,{fill:`none`,height:c,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`2`,viewBox:`0 0 24 24`,width:c,xmlns:`http://www.w3.org/2000/svg`,children:[_,v]}),t[20]=c,t[21]=_,t[22]=v,t[23]=y):y=t[23];let b;return t[24]!==p||t[25]!==h||t[26]!==a||t[27]!==g||t[28]!==y?(b=(0,z.jsx)(`div`,{className:g,onMouseEnter:p,onMouseLeave:h,...a,children:y}),t[24]=p,t[25]=h,t[26]=a,t[27]=g,t[28]=y,t[29]=b):b=t[29],b};D9.displayName=`ArrowUpIcon`;var dte={duration:.15,ease:[0,0,.2,1]},fte={duration:.12,ease:[0,0,.2,1]};function O9(e){let t=(0,G.c)(40),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({variant:a,className:n,disabled:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=vj(),s=a===`stop`,c;t[5]===o?c=t[6]:(c=!o&&{opacity:0,scale:.9},t[5]=o,t[6]=c);let l;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(l={opacity:1,scale:1},t[7]=l):l=t[7];let u;t[8]===o?u=t[9]:(u=o?void 0:{opacity:0,scale:.9},t[8]=o,t[9]=u);let d;t[10]!==r||t[11]!==o?(d=r||o?void 0:{scale:1.04},t[10]=r,t[11]=o,t[12]=d):d=t[12];let f;t[13]!==r||t[14]!==o?(f=r||o?void 0:{scale:.96},t[13]=r,t[14]=o,t[15]=f):f=t[15];let p=s?`Stop streaming`:`Send prompt`,m;t[16]===n?m=t[17]:(m=I(`relative flex size-8 items-center justify-center rounded-full`,`bg-primary text-primary-foreground`,`transition-opacity hover:opacity-90 active:opacity-80`,`disabled:cursor-not-allowed disabled:opacity-35 disabled:hover:opacity-35`,`focus-visible:outline-[1.5px] focus-visible:outline-offset-[2.5px] focus-visible:outline-current`,n),t[16]=n,t[17]=m);let h=s?`stop`:`send`,g;t[18]===o?g=t[19]:(g=!o&&{opacity:0,scale:.7},t[18]=o,t[19]=g);let _;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(_={opacity:1,scale:1},t[20]=_):_=t[20];let v;t[21]===o?v=t[22]:(v=o?void 0:{opacity:0,scale:.7},t[21]=o,t[22]=v);let y;t[23]===s?y=t[24]:(y=(0,z.jsx)(s?hte:mte,{}),t[23]=s,t[24]=y);let b;t[25]!==v||t[26]!==y||t[27]!==h||t[28]!==g?(b=(0,z.jsx)(jk,{initial:!1,children:(0,z.jsx)(Tj.span,{initial:g,animate:_,exit:v,transition:fte,className:`absolute flex items-center justify-center`,children:y},h)}),t[25]=v,t[26]=y,t[27]=h,t[28]=g,t[29]=b):b=t[29];let x;return t[30]!==r||t[31]!==i||t[32]!==c||t[33]!==b||t[34]!==u||t[35]!==d||t[36]!==f||t[37]!==p||t[38]!==m?(x=(0,z.jsx)(Tj.button,{initial:c,animate:l,exit:u,transition:dte,whileHover:d,whileTap:f,"aria-label":p,...i,disabled:r,className:m,children:b}),t[30]=r,t[31]=i,t[32]=c,t[33]=b,t[34]=u,t[35]=d,t[36]=f,t[37]=p,t[38]=m,t[39]=x):x=t[39],x}function pte(e){let t=(0,G.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,z.jsx)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 20 20`,fill:`currentColor`,"aria-hidden":`true`,children:n}),t[0]=n,t[1]=r),r}function mte(){let e=(0,G.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,z.jsx)(D9,{}),e[0]=t):t=e[0],t}function hte(){let e=(0,G.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,z.jsx)(pte,{children:(0,z.jsx)(`rect`,{x:`5`,y:`5`,width:`10`,height:`10`,rx:`1.5`})}),e[0]=t):t=e[0],t}function gte(e){let t=(0,G.c)(25),{title:n,detail:r,detailLabel:i,part:a,error:o}=e,s=n===void 0?`Failed to render tool`:n,c=i===void 0?`View details`:i,l=T6(),u;t[0]===o.issues?u=t[1]:(u=o.issues.map(_te).join(`
|
|
350
|
+
`),t[0]=o.issues,t[1]=u);let d=u,f;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,z.jsx)(_t,{className:`size-5`}),t[2]=f):f=t[2];let p;t[3]===s?p=t[4]:(p=(0,z.jsx)($i,{children:(0,z.jsxs)(ea,{className:`text-destructive flex items-center gap-2`,children:[f,s]})}),t[3]=s,t[4]=p);let m,h;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,z.jsx)(_t,{className:`size-4`}),h=(0,z.jsx)(gr,{children:`Error`}),t[5]=m,t[6]=h):(m=t[5],h=t[6]);let g;t[7]===d?g=t[8]:(g=(0,z.jsxs)(we,{variant:`destructive`,children:[m,h,(0,z.jsx)(Je,{children:d})]}),t[7]=d,t[8]=g);let _;t[9]!==r||t[10]!==c?(_=r&&(0,z.jsxs)(`details`,{className:`text-sm`,children:[(0,z.jsx)(`summary`,{className:`text-muted-foreground hover:text-foreground cursor-pointer`,children:c}),(0,z.jsx)(`pre`,{className:`bg-muted mt-2 max-h-48 overflow-auto rounded-md p-3 text-xs`,children:(0,z.jsx)(`code`,{children:r})})]}),t[9]=r,t[10]=c,t[11]=_):_=t[11];let v;t[12]!==g||t[13]!==_?(v=(0,z.jsxs)(ra,{className:`space-y-4`,children:[g,_]}),t[12]=g,t[13]=_,t[14]=v):v=t[14];let y;t[15]!==l||t[16]!==a?(y=()=>{let e=[`The model tried to call the tool "${Dv(a)}" with the following inputs:`,JSON.stringify(a.input),`Please fix the inputs.`];l.addToolOutput({toolCallId:a.toolCallId,tool:Dv(a),output:e,state:`output-available`})},t[15]=l,t[16]=a,t[17]=y):y=t[17];let b;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,z.jsx)(Ci,{className:`size-4`}),t[18]=b):b=t[18];let x;t[19]===y?x=t[20]:(x=(0,z.jsx)(ia,{children:(0,z.jsxs)(Ce,{variant:`outline`,onClick:y,className:`gap-2`,children:[b,`Ask AI to fix this`]})}),t[19]=y,t[20]=x);let S;return t[21]!==v||t[22]!==x||t[23]!==p?(S=(0,z.jsxs)(Qi,{className:`border-destructive/50 bg-destructive/5`,children:[p,v,x]}),t[21]=v,t[22]=x,t[23]=p,t[24]=S):S=t[24],S}function _te(e){return`${e.path.join(`.`)}: ${e.message}`}(0,R.createContext)(``);function vte({question:e}){let{submit:t}=S6();return typeof e!=`string`||e===``?null:(0,z.jsxs)(`button`,{type:`button`,className:`text-muted-foreground hover:bg-accent hover:text-accent-foreground my-1 inline-flex items-center gap-1.5 rounded-full border px-3 py-1 text-sm transition-colors`,onClick:()=>void t({prompt:e,persistedPrompt:e}),children:[(0,z.jsx)(ai,{className:`size-3.5`}),e]})}var k9=Hj([{name:`followup`,description:`Suggest a follow-up question the user is likely to ask next. Renders as a clickable chip that sends the question as the next message. Example: <followup question="How do I undo this?" />`,allowedAttributes:[`question`],component:vte}]),yte=F({label:L().describe(`Display text for the option`),value:L().optional().describe(`Machine value; defaults to label`),description:L().optional().describe(`Helper text for the option`)}),A9=D(e=>typeof e==`object`&&e&&`questions`in e&&Array.isArray(e.questions)?{...e,questions:e.questions.map(e=>typeof e==`object`&&e?{...e,type:`choice`}:e)}:e,F({questions:Xt(F({type:Ye(`choice`).describe(`Selection from predefined options`),question:L().describe(`The question text displayed to the user`),header:L().optional().describe(`Short context label`),multiSelect:Dt().default(!1).describe(`Whether multiple options can be selected`),options:Xt(yte).min(1).describe(`Available choices`)})).min(1).describe(`Questions to present as a wizard`)})),j9=F({label:L(),value:L()}),bte=F({answers:Xt(F({type:L(),question:L(),freeText:L().optional(),notes:L().optional(),choice:j9.optional(),choices:Xt(j9).optional(),multiSelect:Dt().optional(),answer:L().optional()}))});function M9(e){if(e.multiSelect){if(e.selectedMulti.length===0&&!e.customText.trim())return`Pick at least one option or add your own answer.`}else{if(!e.selected&&!e.isOther)return`Select an option or add your own answer.`;if(e.isOther&&!e.customText.trim())return`Add your custom answer for the "Other" option.`}return null}function xte(e){return{type:`choice`,multiSelect:e.multiSelect??!1,selected:null,selectedMulti:[],isOther:!1,customText:``,notes:``}}function N9(e){return e.options.filter(e=>(e.value??e.label).toLowerCase()!==`other`&&e.label.toLowerCase()!==`other`).map(e=>({label:e.label,value:e.value??e.label,description:e.description}))}function Ste(e,t,n){let r=e=>{let t=n.find(t=>t.value===e);return t?{label:t.label,value:t.value}:{label:e,value:e}},i=t.notes.trim()||void 0,a=t.customText.trim()||void 0;if(t.multiSelect){let n=t.selectedMulti.map(r);return a&&n.push({label:`Other`,value:a}),{type:`choice`,question:e.question,multiSelect:!0,choices:n,freeText:a,notes:i}}return{type:`choice`,question:e.question,multiSelect:!1,choice:t.isOther?{label:`Other`,value:a??``}:r(t.selected??``),freeText:t.isOther?a:void 0,notes:i}}function P9({checked:e,children:t,disabled:n}){return(0,z.jsx)(`div`,{className:I(`border-border/60 relative flex items-start gap-2 rounded-lg border px-3 py-1.5 transition-all duration-150`,!n&&`hover:bg-muted/40`,e&&`border-primary/50 bg-primary/5`,n&&`opacity-60`),children:t})}function F9({htmlFor:e,label:t,description:n}){return(0,z.jsxs)(Pn,{htmlFor:e,className:`min-w-0 flex-1 cursor-pointer flex-col items-start gap-0`,children:[(0,z.jsx)(`span`,{className:`text-sm font-medium`,children:t}),n?(0,z.jsx)(`p`,{className:`text-muted-foreground text-xs leading-relaxed text-pretty`,children:n}):null]})}function Cte({id:e,value:t,label:n,description:r,checked:i,disabled:a}){return(0,z.jsxs)(P9,{checked:i,disabled:a,children:[(0,z.jsx)(Vo,{id:e,value:t,disabled:a,className:`mt-0.5`}),(0,z.jsx)(F9,{htmlFor:e,label:n,description:r})]})}function wte({id:e,label:t,description:n,checked:r,disabled:i,onCheckedChange:a}){return(0,z.jsxs)(P9,{checked:r,disabled:i,children:[(0,z.jsx)(xa,{id:e,checked:r,disabled:i,onCheckedChange:e=>a(e===!0),className:`mt-0.5`}),(0,z.jsx)(F9,{htmlFor:e,label:t,description:n})]})}function Tte({id:e,checked:t,disabled:n,customText:r,onCustomTextChange:i}){let a=(0,R.useRef)(null);return(0,z.jsxs)(P9,{checked:t,disabled:n,children:[(0,z.jsx)(Vo,{ref:a,id:e,value:`other`,disabled:n,className:`mt-0.5`}),(0,z.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),placeholder:`Type your answer...`,disabled:n,onFocus:()=>{t||a.current?.click()},className:`placeholder:text-muted-foreground min-w-0 flex-1 bg-transparent text-sm outline-none disabled:cursor-not-allowed`})]})}function Ete({hasCustom:e,disabled:t,customText:n,onCustomTextChange:r,onClear:i}){let a=(0,R.useRef)(null);return(0,z.jsxs)(P9,{checked:e,disabled:t,children:[(0,z.jsx)(xa,{ref:a,checked:e,disabled:t,onCheckedChange:e=>{e||i()},className:`mt-0.5`}),(0,z.jsx)(`input`,{value:n,onChange:e=>r(e.target.value),placeholder:`Type your answer...`,disabled:t,onFocus:()=>{e||a.current?.click()},className:`placeholder:text-muted-foreground min-w-0 flex-1 bg-transparent text-sm outline-none disabled:cursor-not-allowed`})]})}function Dte({value:e,onChange:t,disabled:n}){return(0,z.jsx)(`div`,{className:`mt-2.5 border-t border-dashed pt-2.5`,children:(0,z.jsx)(et,{value:e,onChange:e=>t(e.target.value),placeholder:`Add notes (optional)...`,disabled:n,rows:2,className:`resize-none text-sm`})})}function Ote({value:e,onChange:t,options:n,disabled:r,fieldId:i}){if(e.multiSelect){let a=e.customText.trim().length>0,o=(n,r)=>{let i=new Set(e.selectedMulti);r?i.add(n):i.delete(n),t({...e,selectedMulti:[...i]})};return(0,z.jsxs)(`div`,{className:`space-y-1.5`,children:[n.map(t=>(0,z.jsx)(wte,{id:`${i}-multi-${t.value}`,label:t.label,description:t.description,checked:e.selectedMulti.includes(t.value),disabled:r,onCheckedChange:e=>o(t.value,e)},t.value)),(0,z.jsx)(Ete,{hasCustom:a,disabled:r,customText:e.customText,onCustomTextChange:n=>t({...e,customText:n}),onClear:()=>t({...e,customText:``})})]})}return(0,z.jsxs)(Bo,{value:e.isOther?`other`:e.selected??``,onValueChange:n=>t(n===`other`?{...e,selected:null,isOther:!0}:{...e,selected:n,isOther:!1,customText:``}),children:[n.map(t=>(0,z.jsx)(Cte,{id:`${i}-single-${t.value}`,value:t.value,label:t.label,description:t.description,checked:!e.isOther&&e.selected===t.value,disabled:r},t.value)),(0,z.jsx)(Tte,{id:`${i}-single-other`,checked:e.isOther,disabled:r,customText:e.customText,onCustomTextChange:n=>t({...e,customText:n})})]})}function kte({current:e,total:t}){return t<=1?null:(0,z.jsx)(`div`,{className:`flex items-center gap-1`,children:Array.from({length:t},(t,n)=>(0,z.jsx)(`div`,{className:I(`h-1 w-3 rounded-full transition-colors duration-200`,n<=e?`bg-primary`:`bg-muted`)},n))})}function Ate({onBack:e,onNext:t,isFirst:n,isLast:r,canProceed:i,isSubmitting:a,isSubmitted:o,currentStep:s,totalSteps:c}){return o?null:(0,z.jsxs)(`div`,{className:`flex items-center justify-between border-t border-dashed px-3 py-1.5`,children:[(0,z.jsx)(`div`,{className:`w-16`,children:n?null:(0,z.jsx)(`button`,{type:`button`,onClick:e,disabled:a,className:`text-muted-foreground hover:text-foreground text-xs transition-colors disabled:opacity-50`,children:`← Back`})}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(kte,{current:s,total:c}),c>1?(0,z.jsxs)(`span`,{className:`text-muted-foreground text-[11px] tabular-nums`,children:[s+1,`/`,c]}):null]}),(0,z.jsx)(`div`,{className:`flex w-16 justify-end`,children:(0,z.jsxs)(Ce,{type:`button`,size:`sm`,onClick:t,disabled:!i||a,children:[a?(0,z.jsx)(Ho,{}):null,a?`Sending...`:r?`Submit`:`Next`]})})]})}function jte({question:e}){return(0,z.jsxs)(`div`,{className:`px-3 pt-2.5 pb-2`,children:[(0,z.jsxs)(`div`,{className:`text-muted-foreground mb-2 flex items-center gap-2 text-[11px]`,children:[(0,z.jsx)(Ct,{className:`size-3`}),(0,z.jsx)(`span`,{children:e.header??`Clarification`})]}),(0,z.jsx)(Zi,{className:`mb-2`}),(0,z.jsx)(`p`,{className:`text-sm font-medium text-pretty`,children:e.question})]})}function Mte({question:e,answer:t,options:n,onChange:r,disabled:i,fieldId:a}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Ote,{value:t,onChange:r,options:n,disabled:i,fieldId:a}),(0,z.jsx)(Dte,{value:t.notes,onChange:e=>r({...t,notes:e}),disabled:i})]})}function Nte({question:e,answer:t,options:n}){let r=t.multiSelect?[...t.selectedMulti.map(e=>n.find(t=>t.value===e)?.label??e),...t.customText.trim()?[`Other: ${t.customText.trim()}`]:[]].join(`, `):t.isOther?`Other: ${t.customText.trim()}`:n.find(e=>e.value===t.selected)?.label??t.selected??``,i=t.notes.trim()||void 0;return(0,z.jsxs)(`div`,{className:`px-3 py-2.5`,children:[(0,z.jsx)(`p`,{className:`text-muted-foreground text-sm text-pretty`,children:e.question}),(0,z.jsx)(`p`,{className:`mt-1 text-sm font-medium text-pretty`,children:r}),i?(0,z.jsxs)(`p`,{className:`text-muted-foreground mt-1 text-xs text-pretty italic`,children:[`Note: `,i]}):null]})}function Pte(e){return e.type===`free_form`?e.answer??``:e.multiSelect&&e.choices?e.choices.map(({label:e,value:t})=>e===`Other`?`Other: ${t}`:e).join(`, `):e.freeText?`Other: ${e.freeText}`:e.choice?.label??``}function Fte({answers:e}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:`px-3 pt-2.5 pb-2`,children:(0,z.jsxs)(`div`,{className:`text-muted-foreground flex items-center gap-2 text-xs`,children:[(0,z.jsx)(d,{className:`size-3`}),(0,z.jsx)(`span`,{children:`Answered`})]})}),(0,z.jsx)(Zi,{}),e.map((e,t)=>(0,z.jsxs)(`div`,{className:`px-3 py-2.5`,children:[(0,z.jsx)(`p`,{className:`text-muted-foreground text-sm text-pretty`,children:e.question}),(0,z.jsx)(`p`,{className:`mt-1 text-sm font-medium text-pretty`,children:Pte(e)}),e.notes?(0,z.jsxs)(`p`,{className:`text-muted-foreground mt-1 text-xs text-pretty italic`,children:[`Note: `,e.notes]}):null]},t))]})}function Ite({questions:e,answers:t}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:`px-3 pt-2.5 pb-2`,children:(0,z.jsxs)(`div`,{className:`text-muted-foreground flex items-center gap-2 text-xs`,children:[(0,z.jsx)(d,{className:`size-3`}),(0,z.jsx)(`span`,{children:`Answered`})]})}),(0,z.jsx)(Zi,{}),e.map((e,n)=>(0,z.jsx)(Nte,{question:e,answer:t[n],options:N9(e)},n))]})}var I9=(0,R.createContext)(void 0);function L9(){let e=(0,R.use)(I9);if(!e)throw Error(`useWizard must be used within <ClarificationWizard.Root>`);return e}function Lte({questions:e,onSubmit:t,disabled:n,fieldId:r,children:i}){let[a,o]=(0,R.useState)(0),[s,c]=(0,R.useState)(()=>e.map(xte)),[l,u]=(0,R.useState)(null),[d,f]=(0,R.useState)(!1),[p,m]=(0,R.useState)(!1),h=e[a],g=s[a],_=a===0,v=a===e.length-1,y={questions:e,currentStep:a,currentQuestion:h,currentAnswer:g,options:N9(h),answers:s,updateAnswer:e=>{c(t=>{let n=[...t];return n[a]=e,n}),u(null)},handleBack:()=>{_||(o(e=>e-1),u(null))},handleNext:async()=>{let n=M9(g);if(n){u(n);return}if(!v){o(e=>e+1),u(null);return}for(let t=0;t<e.length;t++){let e=M9(s[t]);if(e){o(t),u(e);return}}f(!0);try{await t(e.map((e,t)=>Ste(e,s[t],N9(e)))),m(!0)}catch(e){u(e instanceof Error?e.message:`Failed to send your answers.`)}finally{f(!1)}},error:l,isFirst:_,isLast:v,canProceed:!n&&!p,isSubmitting:d,isSubmitted:p,disabled:n,fieldId:r,totalSteps:e.length};return(0,z.jsx)(I9,{value:y,children:i})}function Rte(){let{currentQuestion:e,isSubmitted:t}=L9();return t?null:(0,z.jsx)(jte,{question:e})}function zte(){let{currentQuestion:e,currentAnswer:t,options:n,updateAnswer:r,disabled:i,isSubmitting:a,isSubmitted:o,fieldId:s,currentStep:c}=L9();return o?null:(0,z.jsx)(Mte,{question:e,answer:t,options:n,onChange:r,disabled:i||a,fieldId:`${s}-step-${c}`})}function Bte(){let{error:e,isSubmitted:t}=L9();return t||!e?null:(0,z.jsx)(`p`,{className:`text-destructive text-xs`,role:`alert`,children:e})}function Vte(){let{handleBack:e,handleNext:t,isFirst:n,isLast:r,canProceed:i,isSubmitting:a,isSubmitted:o,currentStep:s,totalSteps:c}=L9();return(0,z.jsx)(Ate,{onBack:e,onNext:()=>void t(),isFirst:n,isLast:r,canProceed:i,isSubmitting:a,isSubmitted:o,currentStep:s,totalSteps:c})}function Hte({children:e,className:t}){let{isSubmitted:n}=L9();return n?null:(0,z.jsx)(`div`,{className:t,children:e})}function Ute(){let{questions:e,answers:t,isSubmitted:n}=L9();return n?(0,z.jsx)(Ite,{questions:e,answers:t}):null}var R9={Root:Lte,Header:Rte,Content:Hte,Field:zte,Error:Bte,Navigation:Vte,Submitted:Ute};function Wte({part:e}){let t=T6(),[n,r]=(0,R.useState)(!1),i=(0,R.useId)();if(e.state===`output-available`){let t=bte.safeParse(e.output);return t.success?(0,z.jsx)(`div`,{className:I(`border-border/60 bg-muted/20 mb-2 rounded-lg border border-dashed`),children:(0,z.jsx)(Fte,{answers:t.data.answers})}):null}if(e.state!==`input-available`)return null;let a=A9.safeParse(e.input);return a.success?(0,z.jsx)(`div`,{className:I(`border-border/60 bg-muted/20 rounded-lg border border-dashed`,`animate-in fade-in-0 duration-200`),children:(0,z.jsxs)(R9.Root,{questions:a.data.questions,onSubmit:async n=>{await t.addToolOutput({toolCallId:e.toolCallId,tool:Dv(e),output:{answers:n},state:`output-available`}),r(!0)},disabled:n,fieldId:i,children:[(0,z.jsx)(R9.Submitted,{}),(0,z.jsx)(R9.Header,{}),(0,z.jsxs)(R9.Content,{className:`space-y-2 px-3 pb-2`,children:[(0,z.jsx)(R9.Field,{}),(0,z.jsx)(R9.Error,{})]}),(0,z.jsx)(R9.Navigation,{})]})}):(0,z.jsx)(gte,{error:a.error,title:`Failed to render clarification`,detail:JSON.stringify(e.input,null,2),detailLabel:`View input`,part:e})}var Gte={component:Wte,label:e=>{let t=e.state===`input-available`||e.state===`output-available`?A9.safeParse(e.input):void 0,n=t?.success?t.data.questions[0]:void 0;return{name:`AskUserQuestion`,icon:tee,args:n?{question:n.header??n.question}:void 0}},requiresUserInput:!0,static:!1,inputSchema:A9,description:`Tool to collect information from the user via a multi-step wizard. Use when you need to clarify requirements, gather preferences, or resolve ambiguity before proceeding.
|
|
350
351
|
|
|
351
352
|
Each question MUST have a "type" field set to "choice" for selection from predefined options (single or multiple).
|
|
352
353
|
|
|
353
354
|
IMPORTANT: NEVER include an "Other" option in your options array — the UI always renders one automatically with an inline text input.
|
|
354
355
|
|
|
355
356
|
Example:
|
|
356
|
-
{"questions":[{"type":"choice","question":"Which timeframe?","header":"Timeframe","multiSelect":false,"options":[{"label":"Last 30 days"},{"label":"Last quarter"}]}]}`};function z9(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function B9(e,t){if(!z9(e))return;let n=e[t];return typeof n==`string`?n:void 0}function V9(e,t){if(!z9(e))return;let n=e[t];return typeof n==`number`?n:void 0}function H9(e,t){if(!z9(e))return;let n=e[t];return typeof n==`boolean`?n:void 0}function U9(e){return e.state!==`output-available`&&e.state!==`output-error`&&e.state!==`output-denied`}function W9(e){if(e.state===`output-error`)return e.errorText;if(e.state===`output-denied`)return`Execution denied.`}function G9({children:e,pending:t=!1,error:n=!1}){return(0,z.jsx)(`p`,{"aria-live":t?`polite`:void 0,className:I(`text-xs leading-relaxed`,t&&`animate-pulse`,n?`text-destructive`:`text-muted-foreground`),children:e})}function K9({title:e,code:t,language:n,detail:r,error:i=!1}){return(0,z.jsxs)(`section`,{className:`space-y-1.5`,children:[(0,z.jsxs)(`header`,{className:`flex items-baseline justify-between gap-3 px-0.5`,children:[(0,z.jsx)(`h4`,{className:I(`text-[10px] font-semibold tracking-[0.08em] uppercase`,i?`text-destructive`:`text-muted-foreground`),children:e}),r&&(0,z.jsx)(`span`,{className:`text-muted-foreground font-mono text-[10px]`,children:r})]}),(0,z.jsx)(`div`,{className:`max-h-64 overflow-auto rounded-md`,children:(0,z.jsx)(F8,{className:I(`border-border/60 rounded-md shadow-none`,i&&`border-destructive/30`),code:t,language:n,wrap:!0,children:(0,z.jsx)(I8,{"aria-label":`Copy ${e.toLowerCase()}`,className:`text-muted-foreground bg-background/90 hover:bg-muted h-6 rounded-md px-2 font-mono text-[10px]`,size:`xs`,variant:`ghost`,children:`Copy`})})})]})}function q9({children:e}){return(0,z.jsx)(`div`,{className:`border-border/60 mb-2 space-y-3 border-l pl-3`,children:e})}function
|
|
357
|
-
`)||void 0}}function Kte(e){return!z9(e)||e.type!==`content`||!Array.isArray(e.value)?[]:e.value.flatMap(e=>{if(!z9(e)||e.type!==`file`)return[];let t=typeof e.mediaType==`string`?e.mediaType:`file`;return[`${typeof e.filename==`string`?e.filename:`Attachment`} · ${t}`]})}var qte={css:`css`,csv:`csv`,html:`html`,js:`javascript`,json:`json`,jsx:`jsx`,md:`markdown`,py:`python`,sh:`bash`,sql:`sql`,ts:`typescript`,tsx:`tsx`,txt:`text`,xml:`xml`,yaml:`yaml`,yml:`yaml`};function Y9(e){return qte[e.split(`.`).pop()?.toLowerCase()??``]??`text`}function X9(e){let t=V9(e,`offset`),n=V9(e,`limit`);if(t===void 0&&n===void 0)return;let r=t??1;return n===void 0?`${r}+`:`${r}-${r+n-1}`}function Jte({part:e}){let t=B9(e.input,`path`)??``,n=J9(e.output),r=Kte(e.output),i=z9(e.output)&&e.output.type===`error-text`?J9(e.output):void 0,a=W9(e)??i,o=U9(e),s=X9(e.input);return(0,z.jsx)(q9,{children:a?(0,z.jsx)(G9,{error:!0,children:a}):o?(0,z.jsxs)(G9,{pending:!0,children:[`Reading `,t||`file`,`...`]}):n===void 0?r.length>0?(0,z.jsxs)(`div`,{className:`space-y-1`,children:[(0,z.jsx)(`p`,{className:`text-muted-foreground text-[10px] font-semibold tracking-[0.08em] uppercase`,children:`File content`}),r.map(e=>(0,z.jsx)(`p`,{className:`text-foreground/80 text-xs`,children:e},e))]}):(0,z.jsx)(G9,{children:`File content is unavailable.`}):n?(0,z.jsx)(K9,{code:n,detail:s?`lines ${s}`:void 0,language:Y9(t),title:`File contents`}):(0,z.jsx)(G9,{children:`The file is empty.`})})}function Yte({part:e}){let t=B9(e.input,`path`)??``,n=B9(e.input,`content`)??``,r=V9(e.output,`exitCode`),i=B9(e.output,`stderr`)??``,a=B9(e.output,`stdout`)??``,o=H9(e.output,`success`),s=W9(e);return(0,z.jsxs)(q9,{children:[U9(e)?(0,z.jsxs)(G9,{pending:!0,children:[`Writing `,t||`file`,`...`]}):s||o===!1||(r??0)!==0?(0,z.jsx)(G9,{error:!0,children:s||i||a||`Failed to write ${t||`file`}.`}):(0,z.jsx)(G9,{children:`File written.`}),n?(0,z.jsx)(K9,{code:n,language:Y9(t),title:`Written content`}):(0,z.jsx)(G9,{children:`The file content is empty.`})]})}function Xte(e){let t=B9(e.input,`command`),n=B9(e.input,`reasoning`),r=V9(e.output,`exitCode`);return{name:`Bash`,args:t?{cmd:t.slice(0,80)}:void 0,detail:n,isError:e.state===`output-error`||e.state===`output-denied`||r!==void 0&&r!==0}}function Z9(e,t){let n=B9(e.input,`path`),r=t===`ReadFile`?X9(e.input):void 0,i=V9(e.output,`exitCode`);return{name:t,args:n||r?{...n?{path:n}:{},...r?{lines:r}:{}}:void 0,isError:e.state===`output-error`||e.state===`output-denied`||H9(e.output,`success`)===!1||i!==void 0&&i!==0||z9(e.output)&&e.output.type===`error-text`}}var Q9={ask_user_question:Wte,bash:{component:Gte,label:Xte,static:!0},readFile:{component:Jte,label:e=>Z9(e,`ReadFile`),static:!0},writeFile:{component:Yte,label:e=>Z9(e,`WriteFile`),static:!0}},Zte=lr(`status`,[F({id:L(),status:Ye(`restored`),sourceMessages:tr(),replacementMessages:tr()}),F({id:L(),status:Ye(`started`),tokenScope:Ye(`request`).optional(),triggerIndex:tr(),targetTokens:tr(),messageCount:tr()}),F({id:L(),status:Ye(`completed`),tokenScope:Ye(`request`).optional(),tokens:F({before:tr(),after:tr()})}),F({id:L(),status:Ye(`failed`),phase:Mn([`restore`,`evaluate`,`compact`,`persist`]),reason:Mn([`no-safe-boundary`,`protected-history`,`incomplete-summary`,`empty-summary`,`summary-too-large`,`request-overhead`,`error`])})]);function Qte({message:e,running:t}){let n=e.parts.flatMap(e=>{if(e.type!==`data-compaction`)return[];let t=Zte.safeParse(e.data);return t.success?[t.data]:[]}),r=Map.groupBy(n,e=>e.id);return Array.from(r,([e,n])=>(0,z.jsx)($te,{events:n,running:t},e))}function $te({events:e,running:t}){let n=e.find(e=>e.status===`started`),r=e.find(e=>e.status===`completed`),i=e.find(e=>e.status===`failed`),a=e.find(e=>e.status===`restored`),o=n!==void 0&&!r&&!i;return(0,z.jsxs)(Pa,{className:`my-3`,children:[(0,z.jsx)(Fa,{className:`group w-full text-left`,children:(0,z.jsxs)(Do,{children:[(0,z.jsx)(ko,{children:o&&t?(0,z.jsx)(Vo,{"aria-label":`Compacting context`}):i?(0,z.jsx)(_t,{className:`text-destructive size-4`}):r?(0,z.jsx)(d,{className:`size-4`}):(0,z.jsx)(hi,{className:`size-4`})}),(0,z.jsxs)(Ao,{children:[(0,z.jsx)(jo,{children:i?`Compaction failed`:r?`Context compacted`:o?t?`Compacting context…`:`Compaction interrupted`:`Using saved summary`}),r&&(0,z.jsxs)(Mo,{children:[r.tokens.before.toLocaleString(),` →`,` `,r.tokens.after.toLocaleString(),` estimated`,` `,r.tokenScope===`request`?`input`:`message`,` `,`tokens`]})]}),(0,z.jsx)(Ct,{className:`size-3.5 transition-transform group-data-[panel-open]:rotate-90`})]})}),(0,z.jsxs)(Ia,{children:[(0,z.jsx)(Xi,{}),(0,z.jsxs)(`div`,{className:`space-y-3 px-3 py-3 text-sm`,children:[(0,z.jsxs)(`dl`,{className:`grid grid-cols-[1fr_auto] gap-x-4 gap-y-2`,children:[n&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`dt`,{children:`Messages before compaction`}),(0,z.jsx)(`dd`,{children:n.messageCount.toLocaleString()}),(0,z.jsxs)(`dt`,{children:[`Estimated`,` `,n.tokenScope===`request`?`input`:`message`,` `,`target`]}),(0,z.jsxs)(`dd`,{children:[n.targetTokens.toLocaleString(),` tokens`]}),(0,z.jsx)(`dt`,{children:`Matched trigger`}),(0,z.jsxs)(`dd`,{children:[`#`,n.triggerIndex+1]})]}),r&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`dt`,{children:`Checkpoint`}),(0,z.jsx)(`dd`,{children:`Saved`})]}),a&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`dt`,{children:`Using saved summary`}),(0,z.jsxs)(`dd`,{children:[a.sourceMessages,` → `,a.replacementMessages,` `,`messages`]})]})]}),i&&(0,z.jsx)(we,{variant:`destructive`,children:(0,z.jsxs)(Je,{children:[i.phase,`: `,i.reason]})})]})]})]})}var ene=F({messages:Xt(fn())});async function tne(e){let{params:t,request:n}=e,r=t.sessionId??new URL(n.url).searchParams.get(`chatId`);if(!r)return cn(`/chat?chatId=${encodeURIComponent(crypto.randomUUID())}`);let i=await Kn(n.signal),a=i.history.find(e=>e.chatId===r),o=i.discovery?.capabilities.chat.href;if(!o||!t.sessionId&&!a&&!i.historyError)return{...i,chatId:r,conversation:a,initialMessages:void 0,sessionExists:!1,sessionError:!1};try{let e=await fetch(`${o}/${encodeURIComponent(r)}`,{signal:n.signal});if(e.status===404&&!t.sessionId)return{...i,chatId:r,conversation:a,initialMessages:void 0,sessionExists:!1,sessionError:!1};if(!e.ok)throw Error(`Session request failed: ${e.status}`);let s=ene.safeParse(await e.json());if(!s.success)throw Error(`Session response did not include messages`);return{...i,chatId:r,conversation:a,initialMessages:await ny({messages:s.data.messages}),sessionExists:!0,sessionError:!1}}catch{return{...i,chatId:r,conversation:a,initialMessages:void 0,sessionExists:!1,sessionError:!0}}}function nne({currentParams:e,currentUrl:t,nextParams:n,nextUrl:r}){return e.sessionId!==n.sessionId||t.searchParams.get(`chatId`)!==r.searchParams.get(`chatId`)}function rne(){let{chatId:e}=Ie();return(0,z.jsx)(ine,{chatId:e},e)}function ine({chatId:e}){let{discovery:t,initialMessages:n,sessionError:r,sessionExists:i}=Ie(),a=t?.capabilities.chat.href;return a?r?(0,z.jsx)($9,{children:`Unable to load this conversation.`}):(0,z.jsx)(ane,{api:a,chatId:e,initialMessages:n,sessionExists:i,supportsUploads:t.capabilities.uploads!==void 0,accept:t.capabilities.uploads?.mediaTypes?.join(`,`)}):(0,z.jsx)($9,{children:`Development runtime unavailable.`})}function ane({api:e,chatId:t,initialMessages:n,sessionExists:r,supportsUploads:i,accept:a}){let o=hn(),{revalidate:s}=fe(),c=Ie(),[l]=(0,R.useState)(()=>new g7({api:e,tools:M6(Q9),elements:k9}));return(0,z.jsx)(S6,{chatId:t,initialMessages:n,onFinish:()=>void s(),onResetChat:e=>{o(`/chat?chatId=${encodeURIComponent(e)}`)},resume:r,registry:Q9,transport:l,children:(0,z.jsxs)(u6,{className:`**:data-[slot='content']:max-w-3xl`,children:[(0,z.jsx)(g6.Root,{className:`px-6`,children:(0,z.jsx)(g6.Hero,{children:`How can I help?`})}),(0,z.jsx)(one,{}),(0,z.jsx)(on,{treeId:t,snapshot:c.conversation?.children}),(0,z.jsx)(sne,{supportsUploads:i,accept:a})]})})}function one(){let{error:e,messages:t,regenerate:n,status:r}=E6();return t.length===0&&!e?null:(0,z.jsxs)(C9.Root,{className:`mb-8 min-h-0 flex-1 px-6`,messages:t,elements:k9,status:r,children:[(0,z.jsx)(C9.List,{children:t.map((e,n)=>(0,z.jsx)(C9.Item,{message:e,index:n,children:e.role===`user`?(0,z.jsx)(C9.UserBubble,{}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Qte,{message:e,running:n===t.length-1&&(r===`submitted`||r===`streaming`)}),(0,z.jsx)(C9.AssistantContent,{})]})},e.id))}),(0,z.jsx)(C9.Error,{error:e,onRetry:()=>void n()}),(0,z.jsx)(C9.Thinking,{})]})}function sne({supportsUploads:e,accept:t}){let{submit:n}=C6(),{hasSubmitted:r}=T6(),{status:i}=w6(),a=i===`submitted`||i===`streaming`;return(0,z.jsx)(`div`,{className:I(`w-full px-6 pb-6`,r&&`bg-background sticky bottom-0 mt-auto pt-2`),children:(0,z.jsx)(r7,{className:`bg-background`,children:(0,z.jsx)(T9.Provider,{isTaskRunning:a,onSubmit:t=>{let r=t.items.flatMap(e=>e.type===`image`||e.type===`video`||e.type===`audio`?[e.file]:[]);return!e&&r.length>0?Promise.reject(Error(`This runtime does not support file uploads`)):n({prompt:t.prompt,persistedPrompt:t.persistedPrompt,files:r})},children:(0,z.jsxs)(T9.Root,{children:[(0,z.jsx)(cne,{}),(0,z.jsx)(T9.Popup,{}),(0,z.jsxs)(T9.Content,{children:[(0,z.jsx)(T9.Attachments,{}),(0,z.jsx)(T9.Editor,{placeholder:`Message Zukhruf…`}),(0,z.jsx)(T9.Error,{})]}),(0,z.jsxs)(T9.Toolbar,{children:[e&&(0,z.jsx)(T9.AttachFiles,{accept:t}),(0,z.jsx)(lne,{})]})]})})})})}function cne(){let{experimental_queuedMessages:e,experimental_removeQueuedMessage:t}=E6();return e.length===0?null:(0,z.jsx)(E9.Root,{children:e.map(e=>(0,z.jsxs)(E9.Item,{children:[(0,z.jsx)(E9.Icon,{}),(0,z.jsx)(E9.Text,{children:a6(e)}),(0,z.jsx)(E9.Remove,{onClick:()=>t(e.id)})]},e.id))})}function lne(){let{state:e}=JQ(`ChatSubmitButton`),{stop:t}=C6(),{status:n}=w6(),r=e.text.trim().length>0;return(n===`submitted`||n===`streaming`)&&!r?(0,z.jsx)(O9,{className:`ml-auto`,type:`button`,variant:`stop`,onClick:t}):(0,z.jsx)(l4.Submit,{render:(0,z.jsx)(O9,{className:`ml-auto`,type:`button`,variant:`send`,disabled:!r})})}function $9({children:e}){return(0,z.jsx)(`p`,{className:`text-muted-foreground p-8 text-sm`,children:e})}export{rne as Component,tne as loader,nne as shouldRevalidate};
|
|
357
|
+
{"questions":[{"type":"choice","question":"Which timeframe?","header":"Timeframe","multiSelect":false,"options":[{"label":"Last 30 days"},{"label":"Last quarter"}]}]}`};function z9(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function B9(e,t){if(!z9(e))return;let n=e[t];return typeof n==`string`?n:void 0}function V9(e,t){if(!z9(e))return;let n=e[t];return typeof n==`number`?n:void 0}function H9(e,t){if(!z9(e))return;let n=e[t];return typeof n==`boolean`?n:void 0}function U9(e){return e.state!==`output-available`&&e.state!==`output-error`&&e.state!==`output-denied`}function W9(e){if(e.state===`output-error`)return e.errorText;if(e.state===`output-denied`)return`Execution denied.`}function G9({children:e,pending:t=!1,error:n=!1}){return(0,z.jsx)(`p`,{"aria-live":t?`polite`:void 0,className:I(`text-xs leading-relaxed`,t&&`animate-pulse`,n?`text-destructive`:`text-muted-foreground`),children:e})}function K9({title:e,code:t,language:n,detail:r,error:i=!1}){return(0,z.jsxs)(`section`,{className:`space-y-1.5`,children:[(0,z.jsxs)(`header`,{className:`flex items-baseline justify-between gap-3 px-0.5`,children:[(0,z.jsx)(`h4`,{className:I(`text-[10px] font-semibold tracking-[0.08em] uppercase`,i?`text-destructive`:`text-muted-foreground`),children:e}),r&&(0,z.jsx)(`span`,{className:`text-muted-foreground font-mono text-[10px]`,children:r})]}),(0,z.jsx)(`div`,{className:`max-h-64 overflow-auto rounded-md`,children:(0,z.jsx)(F8,{className:I(`border-border/60 rounded-md shadow-none`,i&&`border-destructive/30`),code:t,language:n,wrap:!0,children:(0,z.jsx)(I8,{"aria-label":`Copy ${e.toLowerCase()}`,className:`text-muted-foreground bg-background/90 hover:bg-muted h-6 rounded-md px-2 font-mono text-[10px]`,size:`xs`,variant:`ghost`,children:`Copy`})})})]})}function q9({children:e}){return(0,z.jsx)(`div`,{className:`border-border/60 mb-2 space-y-3 border-l pl-3`,children:e})}function Kte({part:e}){let t=B9(e.input,`command`)??``,n=B9(e.output,`stdout`)??``,r=B9(e.output,`stderr`)??``,i=V9(e.output,`exitCode`),a=W9(e),o=U9(e);return(0,z.jsxs)(q9,{children:[a?(0,z.jsx)(G9,{error:!0,children:a}):o?(0,z.jsx)(G9,{pending:!0,children:`Running command...`}):(0,z.jsx)(G9,{error:i!==void 0&&i!==0,children:i===void 0?`Command finished.`:`Command exited with code ${i}.`}),t&&(0,z.jsx)(K9,{code:t,language:`bash`,title:`Command`}),n&&(0,z.jsx)(K9,{code:n,language:`text`,title:`Standard output`}),r&&(0,z.jsx)(K9,{code:r,error:!0,language:`text`,title:`Standard error`}),!o&&!a&&!n&&!r&&(0,z.jsx)(G9,{children:`The command produced no output.`})]})}function J9(e){if(typeof e==`string`)return e;if(z9(e)){if((e.type===`text`||e.type===`error-text`)&&typeof e.value==`string`)return e.value;if(!(e.type!==`content`||!Array.isArray(e.value)))return e.value.filter(e=>z9(e)&&e.type===`text`&&typeof e.text==`string`).map(e=>e.text).join(`
|
|
358
|
+
`)||void 0}}function qte(e){return!z9(e)||e.type!==`content`||!Array.isArray(e.value)?[]:e.value.flatMap(e=>{if(!z9(e)||e.type!==`file`)return[];let t=typeof e.mediaType==`string`?e.mediaType:`file`;return[`${typeof e.filename==`string`?e.filename:`Attachment`} · ${t}`]})}var Jte={css:`css`,csv:`csv`,html:`html`,js:`javascript`,json:`json`,jsx:`jsx`,md:`markdown`,py:`python`,sh:`bash`,sql:`sql`,ts:`typescript`,tsx:`tsx`,txt:`text`,xml:`xml`,yaml:`yaml`,yml:`yaml`};function Y9(e){return Jte[e.split(`.`).pop()?.toLowerCase()??``]??`text`}function X9(e){let t=V9(e,`offset`),n=V9(e,`limit`);if(t===void 0&&n===void 0)return;let r=t??1;return n===void 0?`${r}+`:`${r}-${r+n-1}`}function Yte({part:e}){let t=B9(e.input,`path`)??``,n=J9(e.output),r=qte(e.output),i=z9(e.output)&&e.output.type===`error-text`?J9(e.output):void 0,a=W9(e)??i,o=U9(e),s=X9(e.input);return(0,z.jsx)(q9,{children:a?(0,z.jsx)(G9,{error:!0,children:a}):o?(0,z.jsxs)(G9,{pending:!0,children:[`Reading `,t||`file`,`...`]}):n===void 0?r.length>0?(0,z.jsxs)(`div`,{className:`space-y-1`,children:[(0,z.jsx)(`p`,{className:`text-muted-foreground text-[10px] font-semibold tracking-[0.08em] uppercase`,children:`File content`}),r.map(e=>(0,z.jsx)(`p`,{className:`text-foreground/80 text-xs`,children:e},e))]}):(0,z.jsx)(G9,{children:`File content is unavailable.`}):n?(0,z.jsx)(K9,{code:n,detail:s?`lines ${s}`:void 0,language:Y9(t),title:`File contents`}):(0,z.jsx)(G9,{children:`The file is empty.`})})}function Xte({part:e}){let t=B9(e.input,`path`)??``,n=B9(e.input,`content`)??``,r=V9(e.output,`exitCode`),i=B9(e.output,`stderr`)??``,a=B9(e.output,`stdout`)??``,o=H9(e.output,`success`),s=W9(e);return(0,z.jsxs)(q9,{children:[U9(e)?(0,z.jsxs)(G9,{pending:!0,children:[`Writing `,t||`file`,`...`]}):s||o===!1||(r??0)!==0?(0,z.jsx)(G9,{error:!0,children:s||i||a||`Failed to write ${t||`file`}.`}):(0,z.jsx)(G9,{children:`File written.`}),n?(0,z.jsx)(K9,{code:n,language:Y9(t),title:`Written content`}):(0,z.jsx)(G9,{children:`The file content is empty.`})]})}function Zte(e){let t=B9(e.input,`command`),n=B9(e.input,`reasoning`),r=V9(e.output,`exitCode`);return{name:`Bash`,args:t?{cmd:t.slice(0,80)}:void 0,detail:n,isError:e.state===`output-error`||e.state===`output-denied`||r!==void 0&&r!==0}}function Z9(e,t){let n=B9(e.input,`path`),r=t===`ReadFile`?X9(e.input):void 0,i=V9(e.output,`exitCode`);return{name:t,args:n||r?{...n?{path:n}:{},...r?{lines:r}:{}}:void 0,isError:e.state===`output-error`||e.state===`output-denied`||H9(e.output,`success`)===!1||i!==void 0&&i!==0||z9(e.output)&&e.output.type===`error-text`}}var Q9={ask_user_question:Gte,bash:{component:Kte,label:Zte,static:!0},readFile:{component:Yte,label:e=>Z9(e,`ReadFile`),static:!0},writeFile:{component:Xte,label:e=>Z9(e,`WriteFile`),static:!0}},Qte=lr(`status`,[F({id:L(),status:Ye(`restored`),sourceMessages:tr(),replacementMessages:tr()}),F({id:L(),status:Ye(`started`),tokenScope:Ye(`request`).optional(),triggerIndex:tr(),targetTokens:tr(),messageCount:tr()}),F({id:L(),status:Ye(`completed`),tokenScope:Ye(`request`).optional(),tokens:F({before:tr(),after:tr()})}),F({id:L(),status:Ye(`failed`),phase:Mn([`restore`,`evaluate`,`compact`,`persist`]),reason:Mn([`no-safe-boundary`,`protected-history`,`incomplete-summary`,`empty-summary`,`summary-too-large`,`request-overhead`,`error`])})]);function $te({message:e,running:t}){let n=e.parts.flatMap(e=>{if(e.type!==`data-compaction`)return[];let t=Qte.safeParse(e.data);return t.success?[t.data]:[]}),r=Map.groupBy(n,e=>e.id);return Array.from(r,([e,n])=>(0,z.jsx)(ene,{events:n,running:t},e))}function ene({events:e,running:t}){let n=e.find(e=>e.status===`started`),r=e.find(e=>e.status===`completed`),i=e.find(e=>e.status===`failed`),a=e.find(e=>e.status===`restored`),o=n!==void 0&&!r&&!i;return(0,z.jsxs)(Fa,{className:`my-3`,children:[(0,z.jsx)(Ia,{className:`group w-full text-left`,children:(0,z.jsxs)(Oo,{children:[(0,z.jsx)(Ao,{children:o&&t?(0,z.jsx)(Ho,{"aria-label":`Compacting context`}):i?(0,z.jsx)(_t,{className:`text-destructive size-4`}):r?(0,z.jsx)(d,{className:`size-4`}):(0,z.jsx)(hi,{className:`size-4`})}),(0,z.jsxs)(jo,{children:[(0,z.jsx)(Mo,{children:i?`Compaction failed`:r?`Context compacted`:o?t?`Compacting context…`:`Compaction interrupted`:`Using saved summary`}),r&&(0,z.jsxs)(No,{children:[r.tokens.before.toLocaleString(),` →`,` `,r.tokens.after.toLocaleString(),` estimated`,` `,r.tokenScope===`request`?`input`:`message`,` `,`tokens`]})]}),(0,z.jsx)(Ct,{className:`size-3.5 transition-transform group-data-[panel-open]:rotate-90`})]})}),(0,z.jsxs)(La,{children:[(0,z.jsx)(Zi,{}),(0,z.jsxs)(`div`,{className:`space-y-3 px-3 py-3 text-sm`,children:[(0,z.jsxs)(`dl`,{className:`grid grid-cols-[1fr_auto] gap-x-4 gap-y-2`,children:[n&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`dt`,{children:`Messages before compaction`}),(0,z.jsx)(`dd`,{children:n.messageCount.toLocaleString()}),(0,z.jsxs)(`dt`,{children:[`Estimated`,` `,n.tokenScope===`request`?`input`:`message`,` `,`target`]}),(0,z.jsxs)(`dd`,{children:[n.targetTokens.toLocaleString(),` tokens`]}),(0,z.jsx)(`dt`,{children:`Matched trigger`}),(0,z.jsxs)(`dd`,{children:[`#`,n.triggerIndex+1]})]}),r&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`dt`,{children:`Checkpoint`}),(0,z.jsx)(`dd`,{children:`Saved`})]}),a&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`dt`,{children:`Using saved summary`}),(0,z.jsxs)(`dd`,{children:[a.sourceMessages,` → `,a.replacementMessages,` `,`messages`]})]})]}),i&&(0,z.jsx)(we,{variant:`destructive`,children:(0,z.jsxs)(Je,{children:[i.phase,`: `,i.reason]})})]})]})]})}var tne=F({messages:Xt(fn())});async function nne(e){let{params:t,request:n}=e,r=t.sessionId??new URL(n.url).searchParams.get(`chatId`);if(!r)return cn(`/chat?chatId=${encodeURIComponent(crypto.randomUUID())}`);let i=await Kn(n.signal),a=i.history.find(e=>e.chatId===r),o=i.discovery?.capabilities.chat.href;if(!o||!t.sessionId&&!a&&!i.historyError)return{...i,chatId:r,conversation:a,initialMessages:void 0,sessionExists:!1,sessionError:!1};try{let e=await fetch(`${o}/${encodeURIComponent(r)}`,{signal:n.signal});if(e.status===404&&!t.sessionId)return{...i,chatId:r,conversation:a,initialMessages:void 0,sessionExists:!1,sessionError:!1};if(!e.ok)throw Error(`Session request failed: ${e.status}`);let s=tne.safeParse(await e.json());if(!s.success)throw Error(`Session response did not include messages`);return{...i,chatId:r,conversation:a,initialMessages:await ny({messages:s.data.messages}),sessionExists:!0,sessionError:!1}}catch{return{...i,chatId:r,conversation:a,initialMessages:void 0,sessionExists:!1,sessionError:!0}}}function rne({currentParams:e,currentUrl:t,nextParams:n,nextUrl:r}){return e.sessionId!==n.sessionId||t.searchParams.get(`chatId`)!==r.searchParams.get(`chatId`)}function ine(){let{chatId:e}=Ie();return(0,z.jsx)(ane,{chatId:e},e)}function ane({chatId:e}){let{discovery:t,initialMessages:n,sessionError:r,sessionExists:i}=Ie(),a=t?.capabilities.chat.href;return a?r?(0,z.jsx)($9,{children:`Unable to load this conversation.`}):(0,z.jsx)(one,{api:a,chatId:e,initialMessages:n,sessionExists:i,supportsUploads:t.capabilities.uploads!==void 0,accept:t.capabilities.uploads?.mediaTypes?.join(`,`)}):(0,z.jsx)($9,{children:`Development runtime unavailable.`})}function one({api:e,chatId:t,initialMessages:n,sessionExists:r,supportsUploads:i,accept:a}){let o=hn(),{revalidate:s}=fe(),c=Ie(),[l]=(0,R.useState)(()=>new g7({api:e,tools:M6(Q9),elements:k9}));return(0,z.jsx)(x6,{chatId:t,initialMessages:n,onFinish:()=>void s(),onResetChat:e=>{o(`/chat?chatId=${encodeURIComponent(e)}`)},resume:r,registry:Q9,transport:l,children:(0,z.jsxs)(l6,{className:`**:data-[slot='content']:max-w-3xl`,children:[(0,z.jsx)(h6.Root,{className:`px-6`,children:(0,z.jsx)(h6.Hero,{children:`How can I help?`})}),(0,z.jsx)(sne,{}),(0,z.jsx)(on,{treeId:t,snapshot:c.conversation?.children}),(0,z.jsx)(cne,{supportsUploads:i,accept:a})]})})}function sne(){let{error:e,messages:t,regenerate:n,status:r}=T6();return t.length===0&&!e?null:(0,z.jsxs)(C9.Root,{className:`mb-8 min-h-0 flex-1 px-6`,messages:t,elements:k9,status:r,children:[(0,z.jsx)(C9.List,{children:t.map((e,n)=>(0,z.jsx)(C9.Item,{message:e,index:n,children:e.role===`user`?(0,z.jsx)(C9.UserBubble,{}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)($te,{message:e,running:n===t.length-1&&(r===`submitted`||r===`streaming`)}),(0,z.jsx)(C9.AssistantContent,{})]})},e.id))}),(0,z.jsx)(C9.Error,{error:e,onRetry:()=>void n()}),(0,z.jsx)(C9.Thinking,{})]})}function cne({supportsUploads:e,accept:t}){let{submit:n}=S6(),{hasSubmitted:r}=w6(),{status:i}=C6(),a=i===`submitted`||i===`streaming`;return(0,z.jsx)(`div`,{className:I(`w-full px-6 pb-6`,r&&`bg-background sticky bottom-0 mt-auto pt-2`),children:(0,z.jsx)(r7,{className:`bg-background`,children:(0,z.jsx)(T9.Provider,{isTaskRunning:a,onSubmit:t=>{let r=t.items.flatMap(e=>e.type===`image`||e.type===`video`||e.type===`audio`?[e.file]:[]);return!e&&r.length>0?Promise.reject(Error(`This runtime does not support file uploads`)):n({prompt:t.prompt,persistedPrompt:t.persistedPrompt,files:r})},children:(0,z.jsxs)(T9.Root,{children:[(0,z.jsx)(lne,{}),(0,z.jsx)(T9.Popup,{}),(0,z.jsxs)(T9.Content,{children:[(0,z.jsx)(T9.Attachments,{}),(0,z.jsx)(T9.Editor,{placeholder:`Message Zukhruf…`}),(0,z.jsx)(T9.Error,{})]}),(0,z.jsxs)(T9.Toolbar,{children:[e&&(0,z.jsx)(T9.AttachFiles,{accept:t}),(0,z.jsx)(une,{})]})]})})})})}function lne(){let{experimental_queuedMessages:e,experimental_removeQueuedMessage:t}=T6();return e.length===0?null:(0,z.jsx)(E9.Root,{children:e.map(e=>(0,z.jsxs)(E9.Item,{children:[(0,z.jsx)(E9.Icon,{}),(0,z.jsx)(E9.Text,{children:i6(e)}),(0,z.jsx)(E9.Remove,{onClick:()=>t(e.id)})]},e.id))})}function une(){let{state:e}=qQ(`ChatSubmitButton`),{stop:t}=S6(),{status:n}=C6(),r=e.text.trim().length>0;return(n===`submitted`||n===`streaming`)&&!r?(0,z.jsx)(O9,{className:`ml-auto`,type:`button`,variant:`stop`,onClick:t}):(0,z.jsx)(c4.Submit,{render:(0,z.jsx)(O9,{className:`ml-auto`,type:`button`,variant:`send`,disabled:!r})})}function $9({children:e}){return(0,z.jsx)(`p`,{className:`text-muted-foreground p-8 text-sm`,children:e})}export{ine as Component,nne as loader,rne as shouldRevalidate};
|