@mcpjam/inspector 3.25.2 → 3.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/client/assets/app-bootstrap-BTQE7bOL.css +1 -0
  2. package/dist/client/assets/{app-bootstrap-1nvCvKTu.js → app-bootstrap-DH9V5ruc.js} +417 -401
  3. package/dist/client/assets/app-navigation-DR1HvySV.js +1903 -0
  4. package/dist/client/assets/caniuse-instrument-sans-BbzFLZTg.woff2 +0 -0
  5. package/dist/client/assets/{chunk-D32TOXHM-oQ9_W5Z_.js → chunk-D32TOXHM-CyuI5mIj.js} +5 -5
  6. package/dist/client/assets/{dead-clicks-autocapture-4b8CtYsH.js → dead-clicks-autocapture-DPDniRFT.js} +2 -2
  7. package/dist/client/assets/{error-reporting-Dtp0I_co.js → error-reporting-B3uD72Mm.js} +1 -1
  8. package/dist/client/assets/{error-reporting-BSiw4y1I.js → error-reporting-B45ic1xn.js} +60 -60
  9. package/dist/client/assets/{exception-autocapture-B7NhdXJS.js → exception-autocapture-DfmiXL7P.js} +2 -2
  10. package/dist/client/assets/first-run-oauth-return-CNNqEZ9t.css +2 -0
  11. package/dist/client/assets/first-run-oauth-return-D9QTp0pi.js +11 -0
  12. package/dist/client/assets/{highlighted-body-KQOG7T2V-Bkm2yeWV.js → highlighted-body-KQOG7T2V-BJHVzwuE.js} +2 -2
  13. package/dist/client/assets/index-COoa-n8G.js +4 -0
  14. package/dist/client/assets/{jszip.min-BMhd-tDN.js → jszip.min-mcFGNyxN.js} +2 -2
  15. package/dist/client/assets/{mermaid-MCJ5UELQ-BH89GBNu.js → mermaid-MCJ5UELQ-C7LKilvg.js} +1 -1
  16. package/dist/client/assets/{posthog-recorder-BYAtjhGv.js → posthog-recorder-CPrlbyxV.js} +2 -2
  17. package/dist/client/assets/{preload-helper-SIk4t7Ze.js → preload-helper-DSOvb5Vt.js} +2 -2
  18. package/dist/client/assets/{project-route-CVSc0mXZ.js → project-route-Nif61zEo.js} +3 -3
  19. package/dist/client/assets/{react-dom-CeQ1Kv3m.js → react-dom-DYqNESIg.js} +2 -2
  20. package/dist/client/assets/{rolldown-runtime-COoCppmG.js → rolldown-runtime-B8IK0bAc.js} +1 -1
  21. package/dist/client/assets/{surveys-CS6JUc-z.js → surveys-P2oB9RB7.js} +2 -2
  22. package/dist/client/assets/telemetry-files-c187231a8c0529f6.js +1 -0
  23. package/dist/client/assets/trace-timeline-BZb0fhoh.js +90 -0
  24. package/dist/client/assets/{trace-timeline-b3f1aE0g.js → trace-timeline-CKpfuLys.js} +1 -1
  25. package/dist/client/assets/{web-vitals-p0pJml2T.js → web-vitals-D0Dvhg3H.js} +2 -2
  26. package/dist/client/caniuse-instrument-sans-OFL.txt +93 -0
  27. package/dist/client/caniuse-jar.webp +0 -0
  28. package/dist/client/caniuse-share-icons.svg +8 -0
  29. package/dist/client/index.html +9 -9
  30. package/dist/server/harness-install-cli.js +311 -62
  31. package/dist/server/index.js +2 -2
  32. package/package.json +2 -2
  33. package/dist/client/assets/app-bootstrap-wXhyegHd.css +0 -1
  34. package/dist/client/assets/first-run-oauth-return-Ctdtlees.js +0 -1872
  35. package/dist/client/assets/first-run-oauth-return-DS6OM0jO.css +0 -2
  36. package/dist/client/assets/index-BJZmdbiq.js +0 -4
  37. package/dist/client/assets/telemetry-files-fac3cc064e66cb1e.js +0 -1
  38. package/dist/client/assets/trace-timeline-CKGcby6S.js +0 -73
  39. package/dist/client/assets/use-reduced-motion-iJQiY9UT.js +0 -42
@@ -0,0 +1,90 @@
1
+ import{o as lx,r as YM}from"./rolldown-runtime-B8IK0bAc.js";import{Dt as le,Ft as XM,Gt as lr,Ht as ls,It as M,Kt as Ln,Lt as D,Nt as L,St as Ql,Tt as K,Ut as S,Vt as Mr,bt as U,ft as Kd,jt as cx,kt as ft,mt as ZM,vt as eN,wt as ux}from"./project-route-Nif61zEo.js";import{E as tN,Gt as ld,Jt as nN,Kt as Wr,Ot as rN,Q as dx,Qi as sN,T as Hv,Ut as MB,Wt as Pr,Yt as iN,_s as hx,as as oN,b as aN,d as lN,gs as fx,hs as cN,is as uN,kt as dN,l as hN,ms as fN,qt as BN,rs as pN,st as jv,t as mN,tt as gN,ys as ts}from"./error-reporting-B45ic1xn.js";import{Br as CN,Cr as kn,Dr as vN,Er as yN,Lr as bN,N as SN,Or as Ro,Pr as Bx,Sr as Ve,Tr as he,Tt as EN,V as xN,br as wN,fn as DN,hn as TN,jr as Ze,jt as px,kr as AN,mn as IN,pn as kN,wt as RN,xr as ON,zr as vg}from"./app-navigation-DR1HvySV.js";import{n as MN,t as NN}from"./react-dom-DYqNESIg.js";import{i as PN}from"./preload-helper-DSOvb5Vt.js";import{a as LN,c as _N,n as FN,o as HN}from"./chunk-D32TOXHM-CyuI5mIj.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};e.SENTRY_RELEASE={id:"3.26.0"};var t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="567f4a5e-7c78-4996-9a32-083f5cf2771e",e._sentryDebugIdIdentifier="sentry-dbid-567f4a5e-7c78-4996-9a32-083f5cf2771e")}catch{}})();var p=lx(MN(),1),Yo=lx(NN(),1),m=PN(),jN=Object.defineProperty,GN=(e,t)=>jN(e,"name",{value:t,configurable:!0}),gt=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,t)=>{const n=Ro(`Primitive.${t}`),r=p.forwardRef((s,i)=>{const{asChild:o,...a}=s,l=o?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),(0,m.jsx)(l,{...a,ref:i})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function yg(e,t){e&&Yo.flushSync(()=>e.dispatchEvent(t))}GN(yg,"dispatchDiscreteCustomEvent");var VN=Object.defineProperty,UN=(e,t)=>VN(e,"name",{value:t,configurable:!0}),zN=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),$N=p.forwardRef(UN(function(t,n){return(0,m.jsx)(gt.span,{...t,ref:n,style:{...zN,...t.style}})},"VisuallyHidden")),WN=$N,qN=Object.defineProperty,Rn=(e,t)=>qN(e,"name",{value:t,configurable:!0});function KN(e,t){const n=p.createContext(t);n.displayName=e+"Context";const r=Rn(i=>{const{children:o,...a}=i,l=p.useMemo(()=>a,Object.values(a));return(0,m.jsx)(n.Provider,{value:l,children:o})},"Provider");r.displayName=e+"Provider";function s(i,o={}){const{optional:a=!1}=o,l=p.useContext(n);if(l)return l;if(t!==void 0)return t;if(!a)throw new Error(`\`${i}\` must be used within \`${e}\``)}return Rn(s,"useContext"),[r,s]}Rn(KN,"createContext");function fs(e,t=[]){let n=[];function r(i,o){const a=p.createContext(o);a.displayName=i+"Context";const l=n.length;n=[...n,o];const c=Rn(d=>{const{scope:h,children:f,...B}=d,g=h?.[e]?.[l]||a,C=p.useMemo(()=>B,Object.values(B));return(0,m.jsx)(g.Provider,{value:C,children:f})},"Provider");c.displayName=i+"Provider";function u(d,h,f={}){const{optional:B=!1}=f,g=h?.[e]?.[l]||a,C=p.useContext(g);if(C)return C;if(o!==void 0)return o;if(!B)throw new Error(`\`${d}\` must be used within \`${i}\``)}return Rn(u,"useContext"),[c,u]}Rn(r,"createContext");const s=Rn(()=>{const i=n.map(o=>p.createContext(o));return Rn(function(a){const l=a?.[e]||i;return p.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])},"useScope")},"createScope");return s.scopeName=e,[r,mx(s,...t)]}Rn(fs,"createContextScope");function mx(...e){const t=e[0];if(e.length===1)return t;const n=Rn(()=>{const r=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return Rn(function(i){const o=r.reduce((a,{useScope:l,scopeName:c})=>{const u=l(i)[`__scope${c}`];return{...a,...u}},{});return p.useMemo(()=>({[`__scope${t.scopeName}`]:o}),[o])},"useComposedScopes")},"createScope");return n.scopeName=t.scopeName,n}Rn(mx,"composeContextScopes");var JN=Object.defineProperty,Ot=(e,t)=>JN(e,"name",{value:t,configurable:!0});function bg(e){const t=e+"CollectionProvider",[n,r]=fs(t),[s,i]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=Ot(g=>{const{scope:C,children:v}=g,y=p.useRef(null),b=p.useRef(new Map).current;return(0,m.jsx)(s,{scope:C,itemMap:b,collectionRef:y,children:v})},"CollectionProvider");o.displayName=t;const a=e+"CollectionSlot",l=Ro(a),c=p.forwardRef((g,C)=>{const{scope:v,children:y}=g,b=i(a,v),E=Ze(C,b.collectionRef);return(0,m.jsx)(l,{ref:E,children:y})});c.displayName=a;const u=e+"CollectionItemSlot",d="data-radix-collection-item",h=Ro(u),f=p.forwardRef((g,C)=>{const{scope:v,children:y,...b}=g,E=p.useRef(null),w=Ze(C,E),A=i(u,v);return p.useEffect(()=>(A.itemMap.set(E,{ref:E,...b}),()=>{A.itemMap.delete(E)})),(0,m.jsx)(h,{[d]:"",ref:w,children:y})});f.displayName=u;function B(g){const C=i(e+"CollectionConsumer",g);return p.useCallback(()=>{const v=C.collectionRef.current;if(!v)return[];const y=Array.from(v.querySelectorAll(`[${d}]`));return Array.from(C.itemMap.values()).sort((b,E)=>y.indexOf(b.ref.current)-y.indexOf(E.ref.current))},[C.collectionRef,C.itemMap])}return Ot(B,"useCollection"),[{Provider:o,Slot:c,ItemSlot:f},B,r]}Ot(bg,"createCollection");var Gv=new WeakMap,sf=class bs extends Map{static{Ot(this,"OrderedDict")}#e;constructor(t){super(t),this.#e=[...super.keys()],Gv.set(this,!0)}set(t,n){return Gv.get(this)&&(this.has(t)?this.#e[this.#e.indexOf(t)]=t:this.#e.push(t)),super.set(t,n),this}insert(t,n,r){const s=this.has(n),i=this.#e.length,o=Sg(t);let a=o>=0?o:i+o;const l=a<0||a>=i?-1:a;if(l===this.size||s&&l===this.size-1||l===-1)return this.set(n,r),this;const c=this.size+(s?0:1);o<0&&a++;const u=[...this.#e];let d,h=!1;for(let f=a;f<c;f++)if(a===f){let B=u[f];u[f]===n&&(B=u[f+1]),s&&this.delete(n),d=this.get(B),this.set(n,r)}else{!h&&u[f-1]===n&&(h=!0);const B=u[h?f:f-1],g=d;d=this.get(B),this.delete(B),this.set(B,g)}return this}with(t,n,r){const s=new bs(this);return s.insert(t,n,r),s}before(t){const n=this.#e.indexOf(t)-1;if(!(n<0))return this.entryAt(n)}setBefore(t,n,r){const s=this.#e.indexOf(t);return s===-1?this:this.insert(s,n,r)}after(t){let n=this.#e.indexOf(t);if(n=n===-1||n===this.size-1?-1:n+1,n!==-1)return this.entryAt(n)}setAfter(t,n,r){const s=this.#e.indexOf(t);return s===-1?this:this.insert(s+1,n,r)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return this.#e=[],super.clear()}delete(t){const n=super.delete(t);return n&&this.#e.splice(this.#e.indexOf(t),1),n}deleteAt(t){const n=this.keyAt(t);return n!==void 0?this.delete(n):!1}at(t){const n=bu(this.#e,t);if(n!==void 0)return this.get(n)}entryAt(t){const n=bu(this.#e,t);if(n!==void 0)return[n,this.get(n)]}indexOf(t){return this.#e.indexOf(t)}keyAt(t){return bu(this.#e,t)}from(t,n){const r=this.indexOf(t);if(r===-1)return;let s=r+n;return s<0&&(s=0),s>=this.size&&(s=this.size-1),this.at(s)}keyFrom(t,n){const r=this.indexOf(t);if(r===-1)return;let s=r+n;return s<0&&(s=0),s>=this.size&&(s=this.size-1),this.keyAt(s)}find(t,n){let r=0;for(const s of this){if(Reflect.apply(t,n,[s,r,this]))return s;r++}}findIndex(t,n){let r=0;for(const s of this){if(Reflect.apply(t,n,[s,r,this]))return r;r++}return-1}filter(t,n){const r=[];let s=0;for(const i of this)Reflect.apply(t,n,[i,s,this])&&r.push(i),s++;return new bs(r)}map(t,n){const r=[];let s=0;for(const i of this)r.push([i[0],Reflect.apply(t,n,[i,s,this])]),s++;return new bs(r)}reduce(...t){const[n,r]=t;let s=0,i=r??this.at(0);for(const o of this)s===0&&t.length===1?i=o:i=Reflect.apply(n,this,[i,o,s,this]),s++;return i}reduceRight(...t){const[n,r]=t;let s=r??this.at(-1);for(let i=this.size-1;i>=0;i--){const o=this.at(i);i===this.size-1&&t.length===1?s=o:s=Reflect.apply(n,this,[s,o,i,this])}return s}toSorted(t){const n=[...this.entries()].sort(t);return new bs(n)}toReversed(){const t=new bs;for(let n=this.size-1;n>=0;n--){const r=this.keyAt(n),s=this.get(r);t.set(r,s)}return t}toSpliced(...t){const n=[...this.entries()];return n.splice(...t),new bs(n)}slice(t,n){const r=new bs;let s=this.size-1;if(t===void 0)return r;t<0&&(t=t+this.size),n!==void 0&&n>0&&(s=n-1);for(let i=t;i<=s;i++){const o=this.keyAt(i),a=this.get(o);r.set(o,a)}return r}every(t,n){let r=0;for(const s of this){if(!Reflect.apply(t,n,[s,r,this]))return!1;r++}return!0}some(t,n){let r=0;for(const s of this){if(Reflect.apply(t,n,[s,r,this]))return!0;r++}return!1}};function bu(e,t){if("at"in Array.prototype)return Array.prototype.at.call(e,t);const n=gx(e,t);return n===-1?void 0:e[n]}Ot(bu,"at");function gx(e,t){const n=e.length,r=Sg(t),s=r>=0?r:n+r;return s<0||s>=n?-1:s}Ot(gx,"toSafeIndex");function Sg(e){return e!==e||e===0?0:Math.trunc(e)}Ot(Sg,"toSafeInteger");function QN(e){const t=e+"CollectionProvider",[n,r]=fs(t),[s,i]=n(t,{collectionElement:null,collectionRef:{current:null},collectionRefObject:{current:null},itemMap:new sf,setItemMap:Ot(()=>{},"setItemMap")}),o=Ot(({state:y,...b})=>y?(0,m.jsx)(l,{...b,state:y}):(0,m.jsx)(a,{...b}),"CollectionProvider");o.displayName=t;const a=Ot(y=>{const b=C();return(0,m.jsx)(l,{...y,state:b})},"CollectionInit");a.displayName=t+"Init";const l=Ot(y=>{const{scope:b,children:E,state:w}=y,A=p.useRef(null),[x,O]=p.useState(null),R=Ze(A,O),[P,_]=w;return p.useEffect(()=>{if(!x)return;const N=yx(()=>{});return N.observe(x,{childList:!0,subtree:!0}),()=>{N.disconnect()}},[x]),(0,m.jsx)(s,{scope:b,itemMap:P,setItemMap:_,collectionRef:R,collectionRefObject:A,collectionElement:x,children:E})},"CollectionProviderImpl");l.displayName=t+"Impl";const c=e+"CollectionSlot",u=Ro(c),d=p.forwardRef((y,b)=>{const{scope:E,children:w}=y,A=i(c,E),x=Ze(b,A.collectionRef);return(0,m.jsx)(u,{ref:x,children:w})});d.displayName=c;const h=e+"CollectionItemSlot",f="data-radix-collection-item",B=Ro(h),g=p.forwardRef((y,b)=>{const{scope:E,children:w,...A}=y,x=p.useRef(null),[O,R]=p.useState(null),P=Ze(b,x,R),{setItemMap:_}=i(h,E),N=p.useRef(A);Cx(N.current,A)||(N.current=A);const q=N.current;return p.useEffect(()=>{const W=q;return _(F=>O?F.has(O)?F.set(O,{...W,element:O}).toSorted(NB):(F.set(O,{...W,element:O}),F.toSorted(NB)):F),()=>{_(F=>!O||!F.has(O)?F:(F.delete(O),new sf(F)))}},[O,q,_]),(0,m.jsx)(B,{[f]:"",ref:P,children:w})});g.displayName=h;function C(){return p.useState(new sf)}Ot(C,"useInitCollection");function v(y){const{itemMap:b}=i(e+"CollectionConsumer",y);return b}return Ot(v,"useCollection"),[{Provider:o,Slot:d,ItemSlot:g},{createCollectionScope:r,useCollection:v,useInitCollection:C}]}Ot(QN,"createCollection");function Cx(e,t){if(e===t)return!0;if(typeof e!="object"||typeof t!="object"||e==null||t==null)return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const s of n)if(!Object.prototype.hasOwnProperty.call(t,s)||e[s]!==t[s])return!1;return!0}Ot(Cx,"shallowEqual");function vx(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}Ot(vx,"isElementPreceding");function NB(e,t){return!e[1].element||!t[1].element?0:vx(e[1].element,t[1].element)?-1:1}Ot(NB,"sortByDocumentPosition");function yx(e){return new MutationObserver(t=>{for(const n of t)if(n.type==="childList"){e();return}})}Ot(yx,"getChildListObserver");var YN=Object.defineProperty,Xo=(e,t)=>YN(e,"name",{value:t,configurable:!0}),bx=!!(typeof window<"u"&&window.document&&window.document.createElement);function Se(e,t,{checkForDefaultPrevented:n=!0}={}){return Xo(function(s){if(e?.(s),n===!1||!s||!s.defaultPrevented)return t?.(s)},"handleEvent")}Xo(Se,"composeEventHandlers");function XN(e){if(!bx)throw new Error("Cannot access window outside of the DOM");return e?.ownerDocument?.defaultView??window}Xo(XN,"getOwnerWindow");function PB(e){if(!bx)throw new Error("Cannot access document outside of the DOM");return e?.ownerDocument??document}Xo(PB,"getOwnerDocument");function Sx(e,t=!1){const{activeElement:n}=PB(e);if(!n?.nodeName)return null;if(Ex(n)&&n.contentDocument)return Sx(n.contentDocument.body,t);if(t){const r=n.getAttribute("aria-activedescendant");if(r){const s=PB(n).getElementById(r);if(s)return s}}return n}Xo(Sx,"getActiveElement");function Ex(e){return e.tagName==="IFRAME"}Xo(Ex,"isFrame");var wn=globalThis?.document?p.useLayoutEffect:()=>{},ZN=Object.defineProperty,eP=(e,t)=>ZN(e,"name",{value:t,configurable:!0}),Vv=p[" useEffectEvent ".trim().toString()],Uv=p[" useInsertionEffect ".trim().toString()];function xx(e){if(typeof Vv=="function")return Vv(e);const t=p.useRef(()=>{throw new Error("Cannot call an event handler while rendering.")});return typeof Uv=="function"?Uv(()=>{t.current=e}):wn(()=>{t.current=e}),p.useMemo(()=>((...n)=>t.current?.(...n)),[])}eP(xx,"useEffectEvent");var tP=Object.defineProperty,Yl=(e,t)=>tP(e,"name",{value:t,configurable:!0}),nP=p[" useInsertionEffect ".trim().toString()]||wn;function Xl({prop:e,defaultProp:t,onChange:n=Yl(()=>{},"onChange"),caller:r}){const[s,i,o]=wx({defaultProp:t,onChange:n}),a=e!==void 0;return[a?e:s,p.useCallback(c=>{if(a){const u=Dx(c)?c(e):c;u!==e&&o.current?.(u)}else i(c)},[a,e,i,o])]}Yl(Xl,"useControllableState");function wx({defaultProp:e,onChange:t}){const[n,r]=p.useState(e),s=p.useRef(n),i=p.useRef(t);return nP(()=>{i.current=t},[t]),p.useEffect(()=>{s.current!==n&&(i.current?.(n),s.current=n)},[n,s]),[n,r,i]}Yl(wx,"useUncontrolledState");function Dx(e){return typeof e=="function"}Yl(Dx,"isFunction");var zv=Symbol("RADIX:SYNC_STATE");function rP(e,t,n,r){const{prop:s,defaultProp:i,onChange:o,caller:a}=t,l=s!==void 0,c=xx(o),u=[{...n,state:i}];r&&u.push(r);const[d,h]=p.useReducer((C,v)=>{if(v.type===zv)return{...C,state:v.state};const y=e(C,v);return l&&!Object.is(y.state,C.state)&&c(y.state),y},...u),f=d.state,B=p.useRef(f);p.useEffect(()=>{B.current!==f&&(B.current=f,l||c(f))},[f,B,l]);const g=p.useMemo(()=>s!==void 0?{...d,state:s}:d,[d,s]);return p.useEffect(()=>{l&&!Object.is(s,d.state)&&h({type:zv,state:s})},[s,d.state,l]),[g,h]}Yl(rP,"useControllableStateReducer");var sP=Object.defineProperty,cs=(e,t)=>sP(e,"name",{value:t,configurable:!0});function Tx(e,t){return p.useReducer((n,r)=>t[n][r]??n,e)}cs(Tx,"useStateMachine");var Hr=cs(e=>{const{present:t,children:n}=e,r=Ax(t),s=typeof n=="function"?n({present:r.isPresent}):p.Children.only(n),i=Ix(r.ref,kx(s));return typeof n=="function"||r.isPresent?p.cloneElement(s,{ref:i}):null},"Presence");function Ax(e){const[t,n]=p.useState(),r=p.useRef(null),s=p.useRef(e),i=p.useRef("none"),o=p.useRef(void 0),[a,l]=Tx(e?"mounted":"unmounted",{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return p.useEffect(()=>{a==="mounted"?(i.current=o.current??eo(r.current),o.current=void 0):i.current="none"},[a]),wn(()=>{const c=r.current,u=s.current;if(u!==e){const d=i.current,h=eo(c);e?(o.current=h,l("MOUNT")):h==="none"||c?.display==="none"?l("UNMOUNT"):l(u&&d!==h?"ANIMATION_OUT":"UNMOUNT"),s.current=e}},[e,l]),wn(()=>{if(t){let c;const u=t.ownerDocument.defaultView??window,d=cs(f=>{const B=eo(r.current).includes(CSS.escape(f.animationName));if(f.target===t&&B&&(l("ANIMATION_END"),!s.current)){const g=t.style.animationFillMode;t.style.animationFillMode="forwards",c=u.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=g)})}},"handleAnimationEnd"),h=cs(f=>{f.target===t&&(i.current=eo(r.current))},"handleAnimationStart");return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",d),t.addEventListener("animationend",d),()=>{u.clearTimeout(c),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",d),t.removeEventListener("animationend",d)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:p.useCallback(c=>{if(c){const u=getComputedStyle(c);r.current=u,o.current=eo(u)}else r.current=null;n(c)},[])}}cs(Ax,"usePresence");function LB(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}cs(LB,"setRef");function Ix(...e){const t=p.useRef(e);return t.current=e,p.useCallback(n=>{const r=t.current;let s=!1;const i=r.map(o=>{const a=LB(o,n);return!s&&typeof a=="function"&&(s=!0),a});if(s)return()=>{for(let o=0;o<i.length;o++){const a=i[o];typeof a=="function"?a():LB(r[o],null)}}},[])}cs(Ix,"useStableComposedRefs");function eo(e){return e?.animationName||"none"}cs(eo,"getAnimationName");function kx(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}cs(kx,"getElementRef");var iP=Object.defineProperty,oP=(e,t)=>iP(e,"name",{value:t,configurable:!0}),aP=p[" useId ".trim().toString()]||(()=>{}),lP=0;function Ii(e){const[t,n]=p.useState(aP());return wn(()=>{e||n(r=>r??String(lP++))},[e]),e||(t?`radix-${t}`:"")}oP(Ii,"useId");var cP=Object.defineProperty,uP=(e,t)=>cP(e,"name",{value:t,configurable:!0}),dP=p.createContext(void 0);function Jd(e){const t=p.useContext(dP);return e||t||"ltr"}uP(Jd,"useDirection");var hP=Object.defineProperty,fP=(e,t)=>hP(e,"name",{value:t,configurable:!0});function Nt(e){const t=p.useRef(e);return p.useEffect(()=>{t.current=e}),p.useMemo(()=>((...n)=>t.current?.(...n)),[])}fP(Nt,"useCallbackRef");var BP=Object.defineProperty,Rt=(e,t)=>BP(e,"name",{value:t,configurable:!0}),_B="dismissableLayer.update",pP="dismissableLayer.pointerDownOutside",mP="dismissableLayer.focusOutside",$v,Rx=p.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),Ox=p.forwardRef(Rt(function(t,n){const{disableOutsidePointerEvents:r=!1,deferPointerDownOutside:s=!1,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:a,onInteractOutside:l,onDismiss:c,...u}=t,d=p.useContext(Rx),[h,f]=p.useState(null),B=h?.ownerDocument??globalThis?.document,[,g]=p.useState({}),C=Ze(n,f),v=Array.from(d.layers),[y]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),b=y?v.indexOf(y):-1,E=h?v.indexOf(h):-1,w=d.layersWithOutsidePointerEventsDisabled.size>0,A=E>=b,x=p.useRef(!1),O=Mx(N=>{o?.(N),l?.(N),N.defaultPrevented||c?.()},{ownerDocument:B,deferPointerDownOutside:s,isDeferredPointerDownOutsideRef:x,dismissableSurfaces:d.dismissableSurfaces,shouldHandlePointerDownOutside:p.useCallback(N=>{if(!(N instanceof Node))return!1;const q=[...d.branches].some(W=>W.contains(N));return A&&!q},[d.branches,A])}),R=Nx(N=>{if(s&&x.current)return;const q=N.target;[...d.branches].some(W=>W.contains(q))||(a?.(N),l?.(N),N.defaultPrevented||c?.())},B),P=h?E===v.length-1:!1,_=Nt(N=>{N.key==="Escape"&&(i?.(N),!N.defaultPrevented&&c&&(N.preventDefault(),c()))});return p.useEffect(()=>{if(P)return B.addEventListener("keydown",_,{capture:!0}),()=>B.removeEventListener("keydown",_,{capture:!0})},[B,P,_]),p.useEffect(()=>{if(h)return r&&(d.layersWithOutsidePointerEventsDisabled.size===0&&($v=B.body.style.pointerEvents,B.body.style.pointerEvents="none"),d.layersWithOutsidePointerEventsDisabled.add(h)),d.layers.add(h),FB(),()=>{r&&(d.layersWithOutsidePointerEventsDisabled.delete(h),d.layersWithOutsidePointerEventsDisabled.size===0&&(B.body.style.pointerEvents=$v))}},[h,B,r,d]),p.useEffect(()=>()=>{h&&(d.layers.delete(h),d.layersWithOutsidePointerEventsDisabled.delete(h),FB())},[h,d]),p.useEffect(()=>{const N=Rt(()=>g({}),"handleUpdate");return document.addEventListener(_B,N),()=>document.removeEventListener(_B,N)},[]),(0,m.jsx)(gt.div,{...u,ref:C,style:{pointerEvents:w?A?"auto":"none":void 0,...t.style},onFocusCapture:Se(t.onFocusCapture,R.onFocusCapture),onBlurCapture:Se(t.onBlurCapture,R.onBlurCapture),onPointerDownCapture:Se(t.onPointerDownCapture,O.onPointerDownCapture)})},"DismissableLayer"));function gP(){const e=p.useContext(Rx),[t,n]=p.useState(null);return p.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}Rt(gP,"useDismissableLayerSurface");var CP=Rt(()=>!0,"IS_TRUE");function Mx(e,t){const{ownerDocument:n=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:s,dismissableSurfaces:i,shouldHandlePointerDownOutside:o=CP}=t,a=Nt(e),l=p.useRef(!1),c=p.useRef(!1),u=p.useRef(new Map),d=p.useRef(()=>{});return p.useEffect(()=>{function h(){c.current=!1,s.current=!1,u.current.clear()}Rt(h,"resetOutsideInteraction");function f(){return Array.from(u.current.values()).some(Boolean)}Rt(f,"isOutsideInteractionIntercepted");function B(b){if(!c.current)return;const E=b.target;E instanceof Node&&[...i].some(w=>w.contains(E))||u.current.set(b.type,!0),b.type==="click"&&window.setTimeout(()=>{c.current&&d.current()},0)}Rt(B,"handleInteractionCapture");function g(b){c.current&&u.current.set(b.type,!1)}Rt(g,"handleInteractionBubble");const C=Rt(b=>{if(b.target&&!l.current){let E=function(){n.removeEventListener("click",d.current);const A=f();h(),A||Eg(pP,a,w,{discrete:!0})};if(Rt(E,"handleAndDispatchPointerDownOutsideEvent"),!o(b.target)){n.removeEventListener("click",d.current),h(),l.current=!1;return}const w={originalEvent:b};c.current=!0,s.current=r&&b.button===0,u.current.clear(),!r||b.button!==0?E():(n.removeEventListener("click",d.current),d.current=E,n.addEventListener("click",d.current,{once:!0}))}else n.removeEventListener("click",d.current),h();l.current=!1},"handlePointerDown"),v=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(const b of v)n.addEventListener(b,B,!0),n.addEventListener(b,g);const y=window.setTimeout(()=>{n.addEventListener("pointerdown",C)},0);return()=>{window.clearTimeout(y),n.removeEventListener("pointerdown",C),n.removeEventListener("click",d.current);for(const b of v)n.removeEventListener(b,B,!0),n.removeEventListener(b,g)}},[n,a,r,s,i,o]),{onPointerDownCapture:Rt(()=>l.current=!0,"onPointerDownCapture")}}Rt(Mx,"usePointerDownOutside");function Nx(e,t=globalThis?.document){const n=Nt(e),r=p.useRef(!1);return p.useEffect(()=>{const s=Rt(i=>{i.target&&!r.current&&Eg(mP,n,{originalEvent:i},{discrete:!1})},"handleFocus");return t.addEventListener("focusin",s),()=>t.removeEventListener("focusin",s)},[t,n]),{onFocusCapture:Rt(()=>r.current=!0,"onFocusCapture"),onBlurCapture:Rt(()=>r.current=!1,"onBlurCapture")}}Rt(Nx,"useFocusOutside");function FB(){const e=new CustomEvent(_B);document.dispatchEvent(e)}Rt(FB,"dispatchUpdate");function Eg(e,t,n,{discrete:r}){const s=n.originalEvent.target,i=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&s.addEventListener(e,t,{once:!0}),r?yg(s,i):s.dispatchEvent(i)}Rt(Eg,"handleAndDispatchCustomEvent");var vP=Object.defineProperty,Zt=(e,t)=>vP(e,"name",{value:t,configurable:!0}),of="focusScope.autoFocusOnMount",af="focusScope.autoFocusOnUnmount",Wv={bubbles:!1,cancelable:!0},yP=p.forwardRef(Zt(function(t,n){const{loop:r=!1,trapped:s=!1,onMountAutoFocus:i,onUnmountAutoFocus:o,...a}=t,[l,c]=p.useState(null),u=Nt(i),d=Nt(o),h=p.useRef(null),f=Ze(n,c),B=p.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;p.useEffect(()=>{if(s){let C=function(E){if(B.paused||!l)return;const w=E.target;l.contains(w)?h.current=w:$r(h.current,{select:!0})},v=function(E){if(B.paused||!l)return;const w=E.relatedTarget;w!==null&&(l.contains(w)||$r(h.current,{select:!0}))},y=function(E){if(document.activeElement===document.body)for(const w of E)w.removedNodes.length>0&&$r(l)};Zt(C,"handleFocusIn"),Zt(v,"handleFocusOut"),Zt(y,"handleMutations"),document.addEventListener("focusin",C),document.addEventListener("focusout",v);const b=new MutationObserver(y);return l&&b.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",C),document.removeEventListener("focusout",v),b.disconnect()}}},[s,l,B.paused]),p.useEffect(()=>{if(l){qv.add(B);const C=document.activeElement;if(!l.contains(C)){const v=new CustomEvent(of,Wv);l.addEventListener(of,u),l.dispatchEvent(v),v.defaultPrevented||(Px(jx(xg(l)),{select:!0}),document.activeElement===C&&$r(l))}return()=>{l.removeEventListener(of,u),setTimeout(()=>{const v=new CustomEvent(af,Wv);l.addEventListener(af,d),l.dispatchEvent(v),v.defaultPrevented||$r(C??document.body,{select:!0}),l.removeEventListener(af,d),qv.remove(B)},0)}}},[l,u,d,B]);const g=p.useCallback(C=>{if(!r&&!s||B.paused)return;const v=C.key==="Tab"&&!C.altKey&&!C.ctrlKey&&!C.metaKey,y=document.activeElement;if(v&&y){const b=C.currentTarget,[E,w]=Lx(b);E&&w?!C.shiftKey&&y===w?(C.preventDefault(),r&&$r(E,{select:!0})):C.shiftKey&&y===E&&(C.preventDefault(),r&&$r(w,{select:!0})):y===b&&C.preventDefault()}},[r,s,B.paused]);return(0,m.jsx)(gt.div,{tabIndex:-1,...a,ref:f,onKeyDown:g})},"FocusScope"));function Px(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if($r(r,{select:t}),document.activeElement!==n)return}Zt(Px,"focusFirst");function Lx(e){const t=xg(e);return[HB(t,e),HB(t.reverse(),e)]}Zt(Lx,"getTabbableEdges");function xg(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:Zt(r=>{const s=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||s?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},"acceptNode")});for(;n.nextNode();)t.push(n.currentNode);return t}Zt(xg,"getTabbableCandidates");function HB(e,t){const n=typeof t.checkVisibility=="function"&&t.checkVisibility({checkVisibilityCSS:!0});for(const r of e)if(!(n?!r.checkVisibility({checkVisibilityCSS:!0}):_x(r,{upTo:t})))return r}Zt(HB,"findVisible");function _x(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}Zt(_x,"isHidden");function Fx(e){return e instanceof HTMLInputElement&&"select"in e}Zt(Fx,"isSelectableInput");function $r(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Fx(e)&&t&&e.select()}}Zt($r,"focus");var qv=Hx();function Hx(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=jB(e,t),e.unshift(t)},remove(t){e=jB(e,t),e[0]?.resume()}}}Zt(Hx,"createFocusScopesStack");function jB(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}Zt(jB,"arrayRemove");function jx(e){return e.filter(t=>t.tagName!=="A")}Zt(jx,"removeLinks");var bP=Object.defineProperty,SP=(e,t)=>bP(e,"name",{value:t,configurable:!0}),Gx=p.forwardRef(SP(function(t,n){const{container:r,...s}=t,[i,o]=p.useState(!1);wn(()=>o(!0),[]);const a=r||i&&globalThis?.document?.body;return a?Yo.createPortal((0,m.jsx)(gt.div,{...s,ref:n}),a):null},"Portal")),EP=Object.defineProperty,wg=(e,t)=>EP(e,"name",{value:t,configurable:!0}),Tc=0,zi=null;function xP(e){return Dg(),e.children}wg(xP,"FocusGuards");function Dg(){p.useEffect(()=>{zi||(zi={start:GB(),end:GB()});const{start:e,end:t}=zi;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement("afterbegin",e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement("beforeend",t),Tc++,()=>{Tc===1&&(zi?.start.remove(),zi?.end.remove(),zi=null),Tc=Math.max(0,Tc-1)}},[])}wg(Dg,"useFocusGuards");function GB(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}wg(GB,"createFocusGuard");var Dr=function(){return Dr=Object.assign||function(t){for(var n,r=1,s=arguments.length;r<s;r++){n=arguments[r];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},Dr.apply(this,arguments)};function Vx(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(e);s<r.length;s++)t.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(e,r[s])&&(n[r[s]]=e[r[s]]);return n}function wP(e,t,n){if(n||arguments.length===2)for(var r=0,s=t.length,i;r<s;r++)(i||!(r in t))&&(i||(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return e.concat(i||Array.prototype.slice.call(t))}var Su="right-scroll-bar-position",Eu="width-before-scroll-bar",DP="with-scroll-bars-hidden",TP="--removed-body-scroll-bar-size";function lf(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function AP(e,t){var n=(0,p.useState)(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var s=n.value;s!==r&&(n.value=r,n.callback(r,s))}}}})[0];return n.callback=t,n.facade}var IP=typeof window<"u"?p.useLayoutEffect:p.useEffect,Kv=new WeakMap;function kP(e,t){var n=AP(t||null,function(r){return e.forEach(function(s){return lf(s,r)})});return IP(function(){var r=Kv.get(n);if(r){var s=new Set(r),i=new Set(e),o=n.current;s.forEach(function(a){i.has(a)||lf(a,null)}),i.forEach(function(a){s.has(a)||lf(a,o)})}Kv.set(n,e)},[e]),n}function RP(e){return e}function OP(e,t){t===void 0&&(t=RP);var n=[],r=!1;return{read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(s){var i=t(s,r);return n.push(i),function(){n=n.filter(function(o){return o!==i})}},assignSyncMedium:function(s){for(r=!0;n.length;){var i=n;n=[],i.forEach(s)}n={push:function(o){return s(o)},filter:function(){return n}}},assignMedium:function(s){r=!0;var i=[];if(n.length){var o=n;n=[],o.forEach(s),i=n}var a=function(){var c=i;i=[],c.forEach(s)},l=function(){return Promise.resolve().then(a)};l(),n={push:function(c){i.push(c),l()},filter:function(c){return i=i.filter(c),n}}}}}function MP(e){e===void 0&&(e={});var t=OP(null);return t.options=Dr({async:!0,ssr:!1},e),t}var Ux=function(e){var t=e.sideCar,n=Vx(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return p.createElement(r,Dr({},n))};Ux.isSideCarExport=!0;function NP(e,t){return e.useMedium(t),Ux}var zx=MP(),cf=function(){},Qd=p.forwardRef(function(e,t){var n=p.useRef(null),r=p.useState({onScrollCapture:cf,onWheelCapture:cf,onTouchMoveCapture:cf}),s=r[0],i=r[1],o=e.forwardProps,a=e.children,l=e.className,c=e.removeScrollBar,u=e.enabled,d=e.shards,h=e.sideCar,f=e.noRelative,B=e.noIsolation,g=e.inert,C=e.allowPinchZoom,v=e.as,y=v===void 0?"div":v,b=e.gapMode,E=Vx(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),w=h,A=kP([n,t]),x=Dr(Dr({},E),s);return p.createElement(p.Fragment,null,u&&p.createElement(w,{sideCar:zx,removeScrollBar:c,shards:d,noRelative:f,noIsolation:B,inert:g,setCallbacks:i,allowPinchZoom:!!C,lockRef:n,gapMode:b}),o?p.cloneElement(p.Children.only(a),Dr(Dr({},x),{ref:A})):p.createElement(y,Dr({},x,{className:l,ref:A}),a))});Qd.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Qd.classNames={fullWidth:Eu,zeroRight:Su};var Jv,PP=function(){if(Jv)return Jv;if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function LP(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=PP();return t&&e.setAttribute("nonce",t),e}function _P(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function FP(e){(document.head||document.getElementsByTagName("head")[0]).appendChild(e)}var HP=function(){var e=0,t=null;return{add:function(n){e==0&&(t=LP())&&(_P(t,n),FP(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},jP=function(){var e=HP();return function(t,n){p.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},$x=function(){var e=jP(),t=function(n){var r=n.styles,s=n.dynamic;return e(r,s),null};return t},GP={left:0,top:0,right:0,gap:0},uf=function(e){return parseInt(e||"",10)||0},VP=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],s=t[e==="padding"?"paddingRight":"marginRight"];return[uf(n),uf(r),uf(s)]},UP=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return GP;var t=VP(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},zP=$x(),za="data-scroll-locked",$P=function(e,t,n,r){var s=e.left,i=e.top,o=e.right,a=e.gap;return n===void 0&&(n="margin"),`
2
+ .`.concat(DP,` {
3
+ overflow: hidden `).concat(r,`;
4
+ padding-right: `).concat(a,"px ").concat(r,`;
5
+ }
6
+ body[`).concat(za,`] {
7
+ overflow: hidden `).concat(r,`;
8
+ overscroll-behavior: contain;
9
+ `).concat([t&&"position: relative ".concat(r,";"),n==="margin"&&`
10
+ padding-left: `.concat(s,`px;
11
+ padding-top: `).concat(i,`px;
12
+ padding-right: `).concat(o,`px;
13
+ margin-left:0;
14
+ margin-top:0;
15
+ margin-right: `).concat(a,"px ").concat(r,`;
16
+ `),n==="padding"&&"padding-right: ".concat(a,"px ").concat(r,";")].filter(Boolean).join(""),`
17
+ }
18
+
19
+ .`).concat(Su,` {
20
+ right: `).concat(a,"px ").concat(r,`;
21
+ }
22
+
23
+ .`).concat(Eu,` {
24
+ margin-right: `).concat(a,"px ").concat(r,`;
25
+ }
26
+
27
+ .`).concat(Su," .").concat(Su,` {
28
+ right: 0 `).concat(r,`;
29
+ }
30
+
31
+ .`).concat(Eu," .").concat(Eu,` {
32
+ margin-right: 0 `).concat(r,`;
33
+ }
34
+
35
+ body[`).concat(za,`] {
36
+ `).concat(TP,": ").concat(a,`px;
37
+ }
38
+ `)},Qv=function(){var e=parseInt(document.body.getAttribute("data-scroll-locked")||"0",10);return isFinite(e)?e:0},WP=function(){p.useEffect(function(){return document.body.setAttribute(za,(Qv()+1).toString()),function(){var e=Qv()-1;e<=0?document.body.removeAttribute(za):document.body.setAttribute(za,e.toString())}},[])},qP=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,s=r===void 0?"margin":r;WP();var i=p.useMemo(function(){return UP(s)},[s]);return p.createElement(zP,{styles:$P(i,!t,s,n?"":"!important")})},VB=!1;if(typeof window<"u")try{var Ac=Object.defineProperty({},"passive",{get:function(){return VB=!0,!0}});window.addEventListener("test",Ac,Ac),window.removeEventListener("test",Ac,Ac)}catch{VB=!1}var $i=VB?{passive:!1}:!1,KP=function(e){return e.tagName==="TEXTAREA"},Wx=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!KP(e)&&n[t]==="visible")},JP=function(e){return Wx(e,"overflowY")},QP=function(e){return Wx(e,"overflowX")},Yv=function(e,t){var n=t.ownerDocument,r=t;do{if(typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host),qx(e,r)){var s=Kx(e,r);if(s[1]>s[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},YP=function(e){return[e.scrollTop,e.scrollHeight,e.clientHeight]},XP=function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]},qx=function(e,t){return e==="v"?JP(t):QP(t)},Kx=function(e,t){return e==="v"?YP(t):XP(t)},ZP=function(e,t){return e==="h"&&t==="rtl"?-1:1},eL=function(e,t,n,r,s){var i=ZP(e,window.getComputedStyle(t).direction),o=i*r,a=n.target,l=t.contains(a),c=!1,u=o>0,d=0,h=0;do{if(!a)break;var f=Kx(e,a),B=f[0],g=f[1]-f[2]-i*B;(B||g)&&qx(e,a)&&(d+=g,h+=B);var C=a.parentNode;a=C&&C.nodeType===Node.DOCUMENT_FRAGMENT_NODE?C.host:C}while(!l&&a!==document.body||l&&(t.contains(a)||t===a));return(u&&(s&&Math.abs(d)<1||!s&&o>d)||!u&&(s&&Math.abs(h)<1||!s&&-o>h))&&(c=!0),c},Ic=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Xv=function(e){return[e.deltaX,e.deltaY]},Zv=function(e){return e&&"current"in e?e.current:e},tL=function(e,t){return e[0]===t[0]&&e[1]===t[1]},nL=function(e){return`
39
+ .block-interactivity-`.concat(e,` {pointer-events: none;}
40
+ .allow-interactivity-`).concat(e,` {pointer-events: all;}
41
+ `)},rL=0,Wi=[];function sL(e){var t=p.useRef([]),n=p.useRef([0,0]),r=p.useRef(),s=p.useState(rL++)[0],i=p.useState($x)[0],o=p.useRef(e);p.useEffect(function(){o.current=e},[e]),p.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(s));var g=wP([e.lockRef.current],(e.shards||[]).map(Zv),!0).filter(Boolean);return g.forEach(function(C){return C.classList.add("allow-interactivity-".concat(s))}),function(){document.body.classList.remove("block-interactivity-".concat(s)),g.forEach(function(C){return C.classList.remove("allow-interactivity-".concat(s))})}}},[e.inert,e.lockRef.current,e.shards]);var a=p.useCallback(function(g,C){if("touches"in g&&g.touches.length===2||g.type==="wheel"&&g.ctrlKey)return!o.current.allowPinchZoom;var v=Ic(g),y=n.current,b="deltaX"in g?g.deltaX:y[0]-v[0],E="deltaY"in g?g.deltaY:y[1]-v[1],w,A=g.target,x=Math.abs(b)>Math.abs(E)?"h":"v";if("touches"in g&&x==="h"&&A.type==="range")return!1;var O=window.getSelection(),R=O&&O.anchorNode;if(R&&(R===A||R.contains(A)))return!1;var P=Yv(x,A);if(!P)return!0;if(P?w=x:(w=x==="v"?"h":"v",P=Yv(x,A)),!P)return!1;if(!r.current&&"changedTouches"in g&&(b||E)&&(r.current=w),!w)return!0;var _=r.current||w;return eL(_,C,g,_==="h"?b:E,!0)},[]),l=p.useCallback(function(g){var C=g;if(!(!Wi.length||Wi[Wi.length-1]!==i)){var v="deltaY"in C?Xv(C):Ic(C),y=t.current.filter(function(E){return E.name===C.type&&(E.target===C.target||C.target===E.shadowParent)&&tL(E.delta,v)})[0];if(y&&y.should){C.cancelable&&C.preventDefault();return}if(!y){var b=(o.current.shards||[]).map(Zv).filter(Boolean).filter(function(E){return E.contains(C.target)});(b.length>0?a(C,b[0]):!o.current.noIsolation)&&C.cancelable&&C.preventDefault()}}},[]),c=p.useCallback(function(g,C,v,y){var b={name:g,delta:C,target:v,should:y,shadowParent:iL(v)};t.current.push(b),setTimeout(function(){t.current=t.current.filter(function(E){return E!==b})},1)},[]),u=p.useCallback(function(g){n.current=Ic(g),r.current=void 0},[]),d=p.useCallback(function(g){c(g.type,Xv(g),g.target,a(g,e.lockRef.current))},[]),h=p.useCallback(function(g){c(g.type,Ic(g),g.target,a(g,e.lockRef.current))},[]);p.useEffect(function(){return Wi.push(i),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:h}),document.addEventListener("wheel",l,$i),document.addEventListener("touchmove",l,$i),document.addEventListener("touchstart",u,$i),function(){Wi=Wi.filter(function(g){return g!==i}),document.removeEventListener("wheel",l,$i),document.removeEventListener("touchmove",l,$i),document.removeEventListener("touchstart",u,$i)}},[]);var f=e.removeScrollBar,B=e.inert;return p.createElement(p.Fragment,null,B?p.createElement(i,{styles:nL(s)}):null,f?p.createElement(qP,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function iL(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var oL=NP(zx,sL),Jx=p.forwardRef(function(e,t){return p.createElement(Qd,Dr({},e,{ref:t,sideCar:oL}))});Jx.classNames=Qd.classNames;var aL=function(e){return typeof document>"u"?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},qi=new WeakMap,kc=new WeakMap,Rc={},df=0,Qx=function(e){return e&&(e.host||Qx(e.parentNode))},lL=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Qx(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},cL=function(e,t,n,r){var s=lL(t,Array.isArray(e)?e:[e]);Rc[n]||(Rc[n]=new WeakMap);var i=Rc[n],o=[],a=new Set,l=new Set(s),c=function(d){!d||a.has(d)||(a.add(d),c(d.parentNode))};s.forEach(c);var u=function(d){!d||l.has(d)||Array.prototype.forEach.call(d.children,function(h){if(a.has(h))u(h);else try{var f=h.getAttribute(r),B=f!==null&&f!=="false",g=(qi.get(h)||0)+1,C=(i.get(h)||0)+1;qi.set(h,g),i.set(h,C),o.push(h),g===1&&B&&kc.set(h,!0),C===1&&h.setAttribute(n,"true"),B||h.setAttribute(r,"true")}catch(v){console.error("aria-hidden: cannot operate on ",h,v)}})};return u(t),a.clear(),df++,function(){o.forEach(function(d){var h=qi.get(d)-1,f=i.get(d)-1;qi.set(d,h),i.set(d,f),h||(kc.has(d)||d.removeAttribute(r),kc.delete(d)),f||d.removeAttribute(n)}),df--,df||(qi=new WeakMap,qi=new WeakMap,kc=new WeakMap,Rc={})}},uL=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),s=t||aL(e);return s?(r.push.apply(r,Array.from(s.querySelectorAll("[aria-live], script"))),cL(r,s,n,"aria-hidden")):function(){return null}},dL=Object.defineProperty,hL=(e,t)=>dL(e,"name",{value:t,configurable:!0});function Yx(e){const[t,n]=p.useState(void 0);return wn(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(s=>{if(!Array.isArray(s)||!s.length)return;const i=s[0];let o,a;if("borderBoxSize"in i){const l=i.borderBoxSize,c=Array.isArray(l)?l[0]:l;o=c.inlineSize,a=c.blockSize}else o=e.offsetWidth,a=e.offsetHeight;n({width:o,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}hL(Yx,"useSize");var fL=["top","right","bottom","left"],js=Math.min,ss=Math.max,cd=Math.round,Oc=Math.floor,is=e=>({x:e,y:e}),BL={left:"right",right:"left",bottom:"top",top:"bottom"};function Xx(e,t,n){return ss(e,js(t,n))}function us(e,t){return typeof e=="function"?e(t):e}function Gs(e){return e.split("-")[0]}function Zo(e){return e.split("-")[1]}function Tg(e){return e==="x"?"y":"x"}function Ag(e){return e==="y"?"height":"width"}function Ar(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function Ig(e){return Tg(Ar(e))}function pL(e,t,n){n===void 0&&(n=!1);const r=Zo(e),s=Ig(e),i=Ag(s);let o=s==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[i]>t.floating[i]&&(o=ud(o)),[o,ud(o)]}function mL(e){const t=ud(e);return[UB(e),t,UB(t)]}function UB(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}var e0=["left","right"],t0=["right","left"],gL=["top","bottom"],CL=["bottom","top"];function vL(e,t,n){switch(e){case"top":case"bottom":return n?t?t0:e0:t?e0:t0;case"left":case"right":return t?gL:CL;default:return[]}}function yL(e,t,n,r){const s=Zo(e);let i=vL(Gs(e),n==="start",r);return s&&(i=i.map(o=>o+"-"+s),t&&(i=i.concat(i.map(UB)))),i}function ud(e){const t=Gs(e);return BL[t]+e.slice(t.length)}function bL(e){var t,n,r,s;return{top:(t=e.top)!=null?t:0,right:(n=e.right)!=null?n:0,bottom:(r=e.bottom)!=null?r:0,left:(s=e.left)!=null?s:0}}function Zx(e){return typeof e!="number"?bL(e):{top:e,right:e,bottom:e,left:e}}function dd(e){const{x:t,y:n,width:r,height:s}=e;return{width:r,height:s,top:n,left:t,right:t+r,bottom:n+s,x:t,y:n}}function n0(e,t,n){let{reference:r,floating:s}=e;const i=Ar(t),o=Ig(t),a=Ag(o),l=Gs(t),c=i==="y",u=r.x+r.width/2-s.width/2,d=r.y+r.height/2-s.height/2,h=r[a]/2-s[a]/2;let f;switch(l){case"top":f={x:u,y:r.y-s.height};break;case"bottom":f={x:u,y:r.y+r.height};break;case"right":f={x:r.x+r.width,y:d};break;case"left":f={x:r.x-s.width,y:d};break;default:f={x:r.x,y:r.y}}const B=Zo(t);return B&&(f[o]+=h*(B==="end"?1:-1)*(n&&c?-1:1)),f}async function SL(e,t){var n;t===void 0&&(t={});const{x:r,y:s,platform:i,rects:o,elements:a,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:h=!1,padding:f=0}=us(t,e),B=Zx(f),g=a[h?d==="floating"?"reference":"floating":d],C=dd(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(g)))==null||n?g:g.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(a.floating)),boundary:c,rootBoundary:u,strategy:l})),v=d==="floating"?{x:r,y:s,width:o.floating.width,height:o.floating.height}:o.reference,y=await(i.getOffsetParent==null?void 0:i.getOffsetParent(a.floating)),b=await(i.isElement==null?void 0:i.isElement(y))&&await(i.getScale==null?void 0:i.getScale(y))||{x:1,y:1},E=dd(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:v,offsetParent:y,strategy:l}):v);return{top:(C.top-E.top+B.top)/b.y,bottom:(E.bottom-C.bottom+B.bottom)/b.y,left:(C.left-E.left+B.left)/b.x,right:(E.right-C.right+B.right)/b.x}}var EL=50,xL=async(e,t,n)=>{const{placement:r="bottom",strategy:s="absolute",middleware:i=[],platform:o}=n,a=o.detectOverflow?o:{...o,detectOverflow:SL},l=await(o.isRTL==null?void 0:o.isRTL(t));let c=await o.getElementRects({reference:e,floating:t,strategy:s}),{x:u,y:d}=n0(c,r,l),h=r,f=0;const B={};for(let g=0;g<i.length;g++){const C=i[g];if(!C)continue;const{name:v,fn:y}=C,{x:b,y:E,data:w,reset:A}=await y({x:u,y:d,initialPlacement:r,placement:h,strategy:s,middlewareData:B,rects:c,platform:a,elements:{reference:e,floating:t}});u=b??u,d=E??d,B[v]={...B[v],...w},A&&f<EL&&(f++,typeof A=="object"&&(A.placement&&(h=A.placement),A.rects&&(c=A.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:s}):A.rects),{x:u,y:d}=n0(c,h,l)),g=-1)}return{x:u,y:d,placement:h,strategy:s,middlewareData:B}},wL=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:s,rects:i,platform:o,elements:a,middlewareData:l}=t,{element:c,padding:u=0}=us(e,t)||{};if(c==null)return{};const d=Zx(u),h={x:n,y:r},f=Ig(s),B=Ag(f),g=await o.getDimensions(c),C=f==="y",v=C?"top":"left",y=C?"bottom":"right",b=C?"clientHeight":"clientWidth",E=i.reference[B]+i.reference[f]-h[f]-i.floating[B],w=h[f]-i.reference[f],A=await(o.getOffsetParent==null?void 0:o.getOffsetParent(c));let x=A?A[b]:0;(!x||!await(o.isElement==null?void 0:o.isElement(A)))&&(x=a.floating[b]||i.floating[B]);const O=E/2-w/2,R=x/2-g[B]/2-1,P=js(d[v],R),_=js(d[y],R),N=x-g[B]-_,q=x/2-g[B]/2+O,W=Xx(P,q,N),F=!l.arrow&&Zo(s)!=null&&q!==W&&i.reference[B]/2-(q<P?P:_)-g[B]/2<0,z=F?q<P?q-P:q-N:0;return{[f]:h[f]+z,data:{[f]:W,centerOffset:q-W-z,...F&&{alignmentOffset:z}},reset:F}}}),DL=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:s,middlewareData:i,rects:o,initialPlacement:a,platform:l,elements:c}=t,{mainAxis:u=!0,crossAxis:d=!0,fallbackPlacements:h,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:B="none",flipAlignment:g=!0,...C}=us(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const v=Gs(s),y=Ar(a),b=Gs(a)===a,E=await(l.isRTL==null?void 0:l.isRTL(c.floating)),w=h||(b||!g?[ud(a)]:mL(a)),A=B!=="none";!h&&A&&w.push(...yL(a,g,B,E));const x=[a,...w],O=await l.detectOverflow(t,C),R=[];let P=((r=i.flip)==null?void 0:r.overflows)||[];if(u&&R.push(O[v]),d){const W=pL(s,o,E);R.push(O[W[0]],O[W[1]])}if(P=[...P,{placement:s,overflows:R}],!R.every(W=>W<=0)){var _,N;const W=(((_=i.flip)==null?void 0:_.index)||0)+1,F=x[W];if(F&&(!(d==="alignment"&&y!==Ar(F))||P.every(J=>Ar(J.placement)===y?J.overflows[0]>0:!0)))return{data:{index:W,overflows:P},reset:{placement:F}};let z=(N=P.filter(J=>J.overflows[0]<=0).sort((J,Z)=>J.overflows[1]-Z.overflows[1])[0])==null?void 0:N.placement;if(!z)switch(f){case"bestFit":{var q;const J=(q=P.filter(Z=>{if(A){const Q=Ar(Z.placement);return Q===y||Q==="y"}return!0}).map(Z=>[Z.placement,Z.overflows.filter(Q=>Q>0).reduce((Q,G)=>Q+G,0)]).sort((Z,Q)=>Z[1]-Q[1])[0])==null?void 0:q[0];J&&(z=J);break}case"initialPlacement":z=a}if(s!==z)return{reset:{placement:z}}}return{}}}};function r0(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function s0(e){return fL.some(t=>e[t]>=0)}var TL=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:s="referenceHidden",...i}=us(e,t);switch(s){case"referenceHidden":{const o=r0(await r.detectOverflow(t,{...i,elementContext:"reference"}),n.reference);return{data:{referenceHiddenOffsets:o,referenceHidden:s0(o)}}}case"escaped":{const o=r0(await r.detectOverflow(t,{...i,altBoundary:!0}),n.floating);return{data:{escapedOffsets:o,escaped:s0(o)}}}default:return{}}}}},ew=new Set(["left","top"]);async function AL(e,t){const{placement:n,platform:r,elements:s}=e,i=await(r.isRTL==null?void 0:r.isRTL(s.floating)),o=Gs(n),a=Zo(n),l=Ar(n)==="y",c=ew.has(o)?-1:1,u=i&&l?-1:1,d=us(t,e);let{mainAxis:h,crossAxis:f,alignmentAxis:B}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return a&&typeof B=="number"&&(f=a==="end"?B*-1:B),l?{x:f*u,y:h*c}:{x:h*c,y:f*u}}var IL=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:s,y:i,placement:o,middlewareData:a}=t,l=await AL(t,e);return o===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:s+l.x,y:i+l.y,data:{...l,placement:o}}}}},kL=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:s,platform:i}=t,{mainAxis:o=!0,crossAxis:a=!1,limiter:l={fn:y=>{let{x:b,y:E}=y;return{x:b,y:E}}},...c}=us(e,t),u={x:n,y:r},d=await i.detectOverflow(t,c),h=Ar(s),f=Tg(h);let B=u[f],g=u[h];const C=(y,b)=>Xx(b+d[y==="y"?"top":"left"],b,b-d[y==="y"?"bottom":"right"]);o&&(B=C(f,B)),a&&(g=C(h,g));const v=l.fn({...t,[f]:B,[h]:g});return{...v,data:{x:v.x-n,y:v.y-r,enabled:{[f]:o,[h]:a}}}}}},RL=function(e){return e===void 0&&(e={}),{options:e,fn(t){var n,r;const{x:s,y:i,placement:o,rects:a,middlewareData:l}=t,{offset:c=0,mainAxis:u=!0,crossAxis:d=!0}=us(e,t),h={x:s,y:i},f=Ar(o),B=Tg(f);let g=h[B],C=h[f];const v=us(c,t),y=typeof v=="number"?{mainAxis:v,crossAxis:0}:{mainAxis:(n=v.mainAxis)!=null?n:0,crossAxis:(r=v.crossAxis)!=null?r:0};if(u){const w=B==="y"?"height":"width",A=a.reference[B]-a.floating[w]+y.mainAxis,x=a.reference[B]+a.reference[w]-y.mainAxis;g<A?g=A:g>x&&(g=x)}if(d){var b,E;const w=B==="y"?"width":"height",A=ew.has(Gs(o)),x=a.reference[f]-a.floating[w]+(A&&((b=l.offset)==null?void 0:b[f])||0)+(A?0:y.crossAxis),O=a.reference[f]+a.reference[w]+(A?0:((E=l.offset)==null?void 0:E[f])||0)-(A?y.crossAxis:0);C<x?C=x:C>O&&(C=O)}return{[B]:g,[f]:C}}}},OL=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){const{placement:n,rects:r,platform:s,elements:i}=t,{apply:o=()=>{},...a}=us(e,t),l=await s.detectOverflow(t,a),c=Gs(n),u=Zo(n),d=Ar(n)==="y",{width:h,height:f}=r.floating;let B,g;c==="top"||c==="bottom"?(B=c,g=u===(await(s.isRTL==null?void 0:s.isRTL(i.floating))?"start":"end")?"left":"right"):(g=c,B=u==="end"?"top":"bottom");const C=f-l.top-l.bottom,v=h-l.left-l.right,y=js(f-l[B],C),b=js(h-l[g],v),E=t.middlewareData.shift,w=!E;let A=y,x=b;E!=null&&E.enabled.x&&(x=v),E!=null&&E.enabled.y&&(A=C),w&&!u&&(d?x=h-2*ss(l.left,l.right):A=f-2*ss(l.top,l.bottom)),await o({...t,availableWidth:x,availableHeight:A});const O=await s.getDimensions(i.floating);return h!==O.width||f!==O.height?{reset:{rects:!0}}:{}}}};function Yd(){return typeof window<"u"}function ea(e){return tw(e)?(e.nodeName||"").toLowerCase():"#document"}function dn(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Bs(e){var t;return(t=(tw(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function tw(e){return Yd()?e instanceof Node||e instanceof dn(e).Node:!1}function Lr(e){return Yd()?e instanceof Element||e instanceof dn(e).Element:!1}function Ys(e){return Yd()?e instanceof HTMLElement||e instanceof dn(e).HTMLElement:!1}function i0(e){return!Yd()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof dn(e).ShadowRoot}function Xd(e){const{overflow:t,overflowX:n,overflowY:r,display:s}=_r(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&s!=="inline"&&s!=="contents"}function ML(e){return/^(table|td|th)$/.test(ea(e))}function Zd(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}var NL=/transform|translate|scale|rotate|perspective|filter/,PL=/paint|layout|strict|content/,ri=e=>!!e&&e!=="none",hf;function kg(e){const t=Lr(e)?_r(e):e;return ri(t.transform)||ri(t.translate)||ri(t.scale)||ri(t.rotate)||ri(t.perspective)||!Rg()&&(ri(t.backdropFilter)||ri(t.filter))||NL.test(t.willChange||"")||PL.test(t.contain||"")}function LL(e){let t=ki(e);for(;Ys(t)&&!dl(t);){if(kg(t))return t;if(Zd(t))return null;t=ki(t)}return null}function Rg(){return hf==null&&(hf=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),hf}function dl(e){return/^(html|body|#document)$/.test(ea(e))}function _r(e){return dn(e).getComputedStyle(e)}function eh(e){return Lr(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function ki(e){if(ea(e)==="html")return e;const t=e.assignedSlot||e.parentNode||i0(e)&&e.host||Bs(e);return i0(t)?t.host:t}function nw(e){const t=ki(e);return dl(t)?(e.ownerDocument||e).body:Ys(t)&&Xd(t)?t:nw(t)}function hl(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const s=nw(e),i=s===((r=e.ownerDocument)==null?void 0:r.body),o=dn(s);if(i){const a=zB(o);return t.concat(o,o.visualViewport||[],Xd(s)?s:[],a&&n?hl(a):[])}else return t.concat(s,hl(s,[],n))}function zB(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function rw(e){const t=_r(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const s=Ys(e),i=s?e.offsetWidth:n,o=s?e.offsetHeight:r,a=cd(n)!==i||cd(r)!==o;return a&&(n=i,r=o),{width:n,height:r,$:a}}function Og(e){return Lr(e)?e:e.contextElement}function Eo(e){const t=Og(e);if(!Ys(t))return is(1);const n=t.getBoundingClientRect(),{width:r,height:s,$:i}=rw(t);let o=(i?cd(n.width):n.width)/r,a=(i?cd(n.height):n.height)/s;return(!o||!Number.isFinite(o))&&(o=1),(!a||!Number.isFinite(a))&&(a=1),{x:o,y:a}}var _L=is(0);function sw(e){const t=dn(e);return!Rg()||!t.visualViewport?_L:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function FL(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===dn(e)}function Ri(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const s=e.getBoundingClientRect(),i=Og(e);let o=is(1);t&&(r?Lr(r)&&(o=Eo(r)):o=Eo(e));const a=FL(i,n,r)?sw(i):is(0);let l=(s.left+a.x)/o.x,c=(s.top+a.y)/o.y,u=s.width/o.x,d=s.height/o.y;if(i&&r){const h=dn(i),f=Lr(r)?dn(r):r;let B=h,g=zB(B);for(;g&&f!==B;){const C=Eo(g),v=g.getBoundingClientRect(),y=_r(g),b=v.left+(g.clientLeft+parseFloat(y.paddingLeft))*C.x,E=v.top+(g.clientTop+parseFloat(y.paddingTop))*C.y;l*=C.x,c*=C.y,u*=C.x,d*=C.y,l+=b,c+=E,B=dn(g),g=zB(B)}}return dd({width:u,height:d,x:l,y:c})}function th(e,t){const n=eh(e).scrollLeft;return t?t.left+n:Ri(Bs(e)).left+n}function iw(e,t){const n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-th(e,n),y:n.top+t.scrollTop}}function HL(e){let{elements:t,rect:n,offsetParent:r,strategy:s}=e;const i=s==="fixed",o=Bs(r),a=t?Zd(t.floating):!1;if(r===o||a&&i)return n;let l={scrollLeft:0,scrollTop:0},c=is(1);const u=is(0),d=Ys(r);if((d||!i)&&((ea(r)!=="body"||Xd(o))&&(l=eh(r)),d)){const f=Ri(r);c=Eo(r),u.x=f.x+r.clientLeft,u.y=f.y+r.clientTop}const h=o&&!d&&!i?iw(o,l):is(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+u.x+h.x,y:n.y*c.y-l.scrollTop*c.y+u.y+h.y}}function jL(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function GL(e){const t=eh(e),n=e.ownerDocument.body,r=ss(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),s=ss(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight);let i=-t.scrollLeft+th(e);const o=-t.scrollTop;return _r(n).direction==="rtl"&&(i+=ss(e.clientWidth,n.clientWidth)-r),{width:r,height:s,x:i,y:o}}var VL=25;function UL(e,t,n){n===void 0&&(n="viewport");const r=n==="layoutViewport",s=dn(e),i=Bs(e),o=s.visualViewport;let a=i.clientWidth,l=i.clientHeight,c=0,u=0;if(o){const d=!Rg()||t==="fixed";r?d||(c=-o.offsetLeft,u=-o.offsetTop):(a=o.width,l=o.height,d&&(c=o.offsetLeft,u=o.offsetTop))}if(th(i)<=0){const d=i.ownerDocument,h=d.body,f=getComputedStyle(h),B=d.compatMode==="CSS1Compat"&&parseFloat(f.marginLeft)+parseFloat(f.marginRight)||0,g=Math.abs(i.clientWidth-h.clientWidth-B),C=getComputedStyle(i).scrollbarGutter==="stable both-edges"?g/2:g;C<=VL&&(a-=C)}return{width:a,height:l,x:c,y:u}}function zL(e,t){const n=Ri(e,!0,t==="fixed"),r=n.top+e.clientTop,s=n.left+e.clientLeft,i=Eo(e);return{width:e.clientWidth*i.x,height:e.clientHeight*i.y,x:s*i.x,y:r*i.y}}function o0(e,t,n){let r;if(t==="viewport"||t==="layoutViewport")r=UL(e,n,t);else if(t==="document")r=GL(Bs(e));else if(Lr(t))r=zL(t,n);else{const s=sw(e);r={x:t.x-s.x,y:t.y-s.y,width:t.width,height:t.height}}return dd(r)}function $L(e,t){const n=t.get(e);if(n)return n;let r=hl(e,[],!1).filter(a=>Lr(a)&&ea(a)!=="body"),s=null;const i=_r(e).position==="fixed";let o=i?ki(e):e;for(;Lr(o)&&!dl(o);){const a=_r(o),l=kg(o),c=s?s.position:i?"fixed":"";!l&&(c==="fixed"||c==="absolute"&&a.position==="static")?r=r.filter(u=>u!==o):s=a,o=ki(o)}return t.set(e,r),r}function WL(e){let{element:t,boundary:n,rootBoundary:r,strategy:s}=e;const i=[...n==="clippingAncestors"?Zd(t)?[]:$L(t,this._c):[].concat(n),r],o=o0(t,i[0],s);let a=o.top,l=o.right,c=o.bottom,u=o.left;for(let d=1;d<i.length;d++){const h=o0(t,i[d],s);a=ss(h.top,a),l=js(h.right,l),c=js(h.bottom,c),u=ss(h.left,u)}return{width:l-u,height:c-a,x:u,y:a}}function qL(e){const{width:t,height:n}=rw(e);return{width:t,height:n}}function KL(e,t,n){const r=Ys(t),s=Bs(t),i=n==="fixed",o=Ri(e,!0,i,t);let a={scrollLeft:0,scrollTop:0};const l=is(0);if((r||!i)&&((ea(t)!=="body"||Xd(s))&&(a=eh(t)),r)){const u=Ri(t,!0,i,t);l.x=u.x+t.clientLeft,l.y=u.y+t.clientTop}!r&&s&&(l.x=th(s));const c=s&&!r&&!i?iw(s,a):is(0);return{x:o.left+a.scrollLeft-l.x-c.x,y:o.top+a.scrollTop-l.y-c.y,width:o.width,height:o.height}}function ff(e){return _r(e).position==="static"}function a0(e,t){if(!Ys(e)||_r(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Bs(e)===n&&(n=n.ownerDocument.body),n}function ow(e,t){const n=dn(e);if(Zd(e))return n;if(!Ys(e)){let s=ki(e);for(;s&&!dl(s);){if(Lr(s)&&!ff(s))return s;s=ki(s)}return n}let r=a0(e,t);for(;r&&ML(r)&&ff(r);)r=a0(r,t);return r&&dl(r)&&ff(r)&&!kg(r)?n:r||LL(e)||n}var JL=async function(e){const t=this.getOffsetParent||ow,n=this.getDimensions,r=await n(e.floating);return{reference:KL(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function QL(e){return _r(e).direction==="rtl"}var YL={convertOffsetParentRelativeRectToViewportRelativeRect:HL,getDocumentElement:Bs,getClippingRect:WL,getOffsetParent:ow,getElementRects:JL,getClientRects:jL,getDimensions:qL,getScale:Eo,isElement:Lr,isRTL:QL};function aw(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function XL(e,t,n){let r=null,s;const i=Bs(e);function o(){var u;clearTimeout(s),(u=r)==null||u.disconnect(),r=null}function a(u,d){u===void 0&&(u=!1),d===void 0&&(d=1),o();const h=e.getBoundingClientRect(),{left:f,top:B,width:g,height:C}=h;if(u||t(),!g||!C)return;const v=Oc(B),y=Oc(i.clientWidth-(f+g)),b=Oc(i.clientHeight-(B+C)),E=Oc(f),w={rootMargin:-v+"px "+-y+"px "+-b+"px "+-E+"px",threshold:ss(0,js(1,d))||1};let A=!0;function x(O){const R=O[0].intersectionRatio;if(!aw(h,e.getBoundingClientRect()))return a();if(R!==d){if(!A)return a();R?a(!1,R):s=setTimeout(()=>{a(!1,1e-7)},1e3)}A=!1}try{r=new IntersectionObserver(x,{...w,root:i.ownerDocument})}catch{r=new IntersectionObserver(x,w)}r.observe(e)}const l=dn(e),c=()=>a(n);return l.addEventListener("resize",c),a(!0),()=>{l.removeEventListener("resize",c),o()}}function ZL(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:s=!0,ancestorResize:i=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=Og(e),u=s||i?[...c?hl(c):[],...t?hl(t):[]]:[];u.forEach(v=>{s&&v.addEventListener("scroll",n),i&&v.addEventListener("resize",n)});const d=c&&a?XL(c,n,i):null;let h=-1,f=null;o&&(f=new ResizeObserver(v=>{let[y]=v;y&&y.target===c&&f&&t&&(f.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var b;(b=f)==null||b.observe(t)})),n()}),c&&!l&&f.observe(c),t&&f.observe(t));let B,g=l?Ri(e):null;l&&C();function C(){const v=Ri(e);g&&!aw(g,v)&&n(),g=v,B=requestAnimationFrame(C)}return n(),()=>{var v;u.forEach(y=>{s&&y.removeEventListener("scroll",n),i&&y.removeEventListener("resize",n)}),d?.(),(v=f)==null||v.disconnect(),f=null,l&&cancelAnimationFrame(B)}}var e_=IL,t_=kL,n_=DL,r_=OL,s_=TL,l0=wL,i_=RL,o_=(e,t,n)=>{const r=new Map,s=n??{},i={...YL,...s.platform,_c:r};return xL(e,t,{...s,platform:i})},xu=typeof document<"u"?p.useLayoutEffect:function(){};function hd(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,s;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!hd(e[r],t[r]))return!1;return!0}if(s=Object.keys(e),n=s.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,s[r]))return!1;for(r=n;r--!==0;){const i=s[r];if(!(i==="_owner"&&e.$$typeof)&&!hd(e[i],t[i]))return!1}return!0}return e!==e&&t!==t}function lw(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function c0(e,t){const n=lw(e);return Math.round(t*n)/n}function Bf(e){const t=p.useRef(e);return xu(()=>{t.current=e}),t}function a_(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:s,elements:{reference:i,floating:o}={},transform:a=!0,whileElementsMounted:l,open:c}=e,[u,d]=p.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,f]=p.useState(r);hd(h,r)||f(r);const[B,g]=p.useState(null),[C,v]=p.useState(null),y=p.useCallback(Z=>{Z!==A.current&&(A.current=Z,g(Z))},[]),b=p.useCallback(Z=>{Z!==x.current&&(x.current=Z,v(Z))},[]),E=i||B,w=o||C,A=p.useRef(null),x=p.useRef(null),O=p.useRef(u),R=l!=null,P=Bf(l),_=Bf(s),N=Bf(c),q=p.useCallback(()=>{if(!A.current||!x.current)return;const Z={placement:t,strategy:n,middleware:h};_.current&&(Z.platform=_.current),o_(A.current,x.current,Z).then(Q=>{const G={...Q,isPositioned:N.current!==!1};W.current&&!hd(O.current,G)&&(O.current=G,Yo.flushSync(()=>{d(G)}))})},[h,t,n,_,N]);xu(()=>{c===!1&&O.current.isPositioned&&(O.current.isPositioned=!1,d(Z=>({...Z,isPositioned:!1})))},[c]);const W=p.useRef(!1);xu(()=>(W.current=!0,()=>{W.current=!1}),[]),xu(()=>{if(E&&(A.current=E),w&&(x.current=w),E&&w){if(P.current)return P.current(E,w,q);q()}},[E,w,q,P,R]);const F=p.useMemo(()=>({reference:A,floating:x,setReference:y,setFloating:b}),[y,b]),z=p.useMemo(()=>({reference:E,floating:w}),[E,w]),J=p.useMemo(()=>{const Z={position:n,left:0,top:0};if(!z.floating)return Z;const Q=c0(z.floating,u.x),G=c0(z.floating,u.y);return a?{...Z,transform:"translate("+Q+"px, "+G+"px)",...lw(z.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:Q,top:G}},[n,a,z.floating,u.x,u.y]);return p.useMemo(()=>({...u,update:q,refs:F,elements:z,floatingStyles:J}),[u,q,F,z,J])}var l_=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:s}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?l0({element:r.current,padding:s}).fn(n):{}:r?l0({element:r,padding:s}).fn(n):{}}}},c_=(e,t)=>{const n=e_(e);return{name:n.name,fn:n.fn,options:[e,t]}},u_=(e,t)=>{const n=t_(e);return{name:n.name,fn:n.fn,options:[e,t]}},d_=(e,t)=>({fn:i_(e).fn,options:[e,t]}),h_=(e,t)=>{const n=n_(e);return{name:n.name,fn:n.fn,options:[e,t]}},f_=(e,t)=>{const n=r_(e);return{name:n.name,fn:n.fn,options:[e,t]}},B_=(e,t)=>{const n=s_(e);return{name:n.name,fn:n.fn,options:[e,t]}},p_=(e,t)=>{const n=l_(e);return{name:n.name,fn:n.fn,options:[e,t]}},m_=Object.defineProperty,g_=(e,t)=>m_(e,"name",{value:t,configurable:!0}),C_=p.forwardRef(g_(function(t,n){const{children:r,width:s=10,height:i=5,...o}=t;return(0,m.jsx)(gt.svg,{...o,ref:n,width:s,height:i,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:t.asChild?r:(0,m.jsx)("polygon",{points:"0,0 30,0 15,10"})})},"Arrow")),v_=C_,y_=Object.defineProperty,os=(e,t)=>y_(e,"name",{value:t,configurable:!0}),cw="Popper",[uw,nh]=fs(cw),[b_,dw]=uw(cw),S_=os(e=>{const{__scopePopper:t,children:n}=e,[r,s]=p.useState(null),[i,o]=p.useState(void 0);return(0,m.jsx)(b_,{scope:t,anchor:r,onAnchorChange:s,placementState:i,setPlacementState:o,children:n})},"Popper"),E_="PopperAnchor",x_=p.forwardRef(os(function(t,n){const{__scopePopper:r,virtualRef:s,...i}=t,o=dw(E_,r),a=p.useRef(null),l=o.onAnchorChange,c=p.useCallback(g=>{a.current=g,g&&l(g)},[l]),u=Ze(n,c),d=p.useRef(null);p.useEffect(()=>{if(!s)return;const g=d.current;d.current=s.current,g!==d.current&&l(d.current)});const h=o.placementState&&rh(o.placementState),f=h?.[0],B=h?.[1];return s?null:(0,m.jsx)(gt.div,{"data-radix-popper-side":f,"data-radix-popper-align":B,...i,ref:u})},"PopperAnchor")),hw="PopperContent",[w_,D_]=uw(hw),T_=p.forwardRef(os(function(t,n){const{__scopePopper:r,side:s="bottom",sideOffset:i=0,align:o="center",alignOffset:a=0,arrowPadding:l=0,avoidCollisions:c=!0,collisionBoundary:u=[],collisionPadding:d=0,sticky:h="partial",hideWhenDetached:f=!1,updatePositionStrategy:B="optimized",onPlaced:g,...C}=t,v=dw(hw,r),[y,b]=p.useState(null),E=Ze(n,b),[w,A]=p.useState(null),x=Yx(w),O=x?.width??0,R=x?.height??0,P=s+(o!=="center"?"-"+o:""),_=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},N=Array.isArray(u)?u:[u],q=N.length>0,W={padding:_,boundary:N.filter(fw),altBoundary:q},{refs:F,floatingStyles:z,placement:J,isPositioned:Z,middlewareData:Q}=a_({strategy:"fixed",placement:P,whileElementsMounted:os((...de)=>ZL(...de,{animationFrame:B==="always"}),"whileElementsMounted"),elements:{reference:v.anchor},middleware:[c_({mainAxis:i+R,alignmentAxis:a}),c&&u_({mainAxis:!0,crossAxis:!1,limiter:h==="partial"?d_():void 0,...W}),c&&h_({...W}),f_({...W,apply:os(({elements:de,rects:Re,availableWidth:Ee,availableHeight:st})=>{const{width:at,height:Bt}=Re.reference,tt=de.floating.style;tt.setProperty("--radix-popper-available-width",`${Ee}px`),tt.setProperty("--radix-popper-available-height",`${st}px`),tt.setProperty("--radix-popper-anchor-width",`${at}px`),tt.setProperty("--radix-popper-anchor-height",`${Bt}px`)},"apply")}),w&&p_({element:w,padding:l}),R_({arrowWidth:O,arrowHeight:R}),f&&B_({strategy:"referenceHidden",...W,boundary:q?W.boundary:void 0})]}),G=v.setPlacementState;wn(()=>(G(J),()=>{G(void 0)}),[J,G]);const[be,ve]=rh(J),X=Nt(g);wn(()=>{Z&&X?.()},[Z,X]);const Y=Q.arrow?.x,ie=Q.arrow?.y,ne=Q.arrow?.centerOffset!==0,[ee,Be]=p.useState();return wn(()=>{y&&Be(window.getComputedStyle(y).zIndex)},[y]),(0,m.jsx)("div",{ref:F.setFloating,"data-radix-popper-content-wrapper":"",style:{...z,transform:Z?z.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ee,"--radix-popper-transform-origin":[Q.transformOrigin?.x,Q.transformOrigin?.y].join(" "),...Q.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:(0,m.jsx)(w_,{scope:r,placedSide:be,placedAlign:ve,onArrowChange:A,arrowX:Y,arrowY:ie,shouldHideArrow:ne,children:(0,m.jsx)(gt.div,{"data-side":be,"data-align":ve,...C,ref:E,style:{...C.style,animation:Z?C.style?.animation:"none"}})})})},"PopperContent")),A_="PopperArrow",I_={top:"bottom",right:"left",bottom:"top",left:"right"},k_=p.forwardRef(os(function(t,n){const{__scopePopper:r,...s}=t,i=D_(A_,r),o=I_[i.placedSide];return(0,m.jsx)("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[o]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:(0,m.jsx)(v_,{...s,ref:n,style:{...s.style,display:"block"}})})},"PopperArrow"));function fw(e){return e!==null}os(fw,"isNotNull");var R_=os(e=>({name:"transformOrigin",options:e,fn(t){const{placement:n,rects:r,middlewareData:s}=t,i=s.arrow?.centerOffset!==0,o=i?0:e.arrowWidth,a=i?0:e.arrowHeight,[l,c]=rh(n),u={start:"0%",center:"50%",end:"100%"}[c],d=(s.arrow?.x??0)+o/2,h=(s.arrow?.y??0)+a/2;let f="",B="";return l==="bottom"?(f=i?u:`${d}px`,B=`${-a}px`):l==="top"?(f=i?u:`${d}px`,B=`${r.floating.height+a}px`):l==="right"?(f=`${-a}px`,B=i?u:`${h}px`):l==="left"&&(f=`${r.floating.width+a}px`,B=i?u:`${h}px`),{data:{x:f,y:B}}}}),"transformOrigin");function rh(e){const[t,n="center"]=e.split("-");return[t,n]}os(rh,"getSideAndAlignFromPlacement");var Mg=S_,Bw=x_,pw=T_,O_=k_,M_=Object.defineProperty,Ng=(e,t)=>M_(e,"name",{value:t,configurable:!0}),pf=!1;function mw(){const[e,t]=p.useState(pf);return p.useEffect(()=>{pf||(pf=!0,t(!0))},[]),e}Ng(mw,"useIsHydrated");var gw=p[" useSyncExternalStore ".trim().toString()];function Cw(){return()=>{}}Ng(Cw,"subscribe");function vw(){return gw(Cw,()=>!0,()=>!1)}Ng(vw,"useIsHydratedModern");var N_=typeof gw=="function"?vw:mw,P_=Object.defineProperty,Hi=(e,t)=>P_(e,"name",{value:t,configurable:!0}),mf="rovingFocusGroup.onEntryFocus",L_={bubbles:!1,cancelable:!0},sh="RovingFocusGroup",[$B,yw,__]=bg(sh),[F_,bw]=fs(sh,[__]),[H_,j_]=F_(sh),G_=p.forwardRef(Hi(function(t,n){return(0,m.jsx)($B.Provider,{scope:t.__scopeRovingFocusGroup,children:(0,m.jsx)($B.Slot,{scope:t.__scopeRovingFocusGroup,children:(0,m.jsx)(V_,{...t,ref:n})})})},"RovingFocusGroup")),V_=p.forwardRef(Hi(function(t,n){const{__scopeRovingFocusGroup:r,orientation:s,loop:i=!1,dir:o,currentTabStopId:a,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:c,onEntryFocus:u,preventScrollOnEntryFocus:d=!1,...h}=t,f=p.useRef(null),B=Ze(n,f),g=Jd(o),[C,v]=Xl({prop:a,defaultProp:l??null,onChange:c,caller:sh}),[y,b]=p.useState(!1),E=Nt(u),w=yw(r),A=p.useRef(!1),[x,O]=p.useState(0);return p.useEffect(()=>{const R=f.current;if(R)return R.addEventListener(mf,E),()=>R.removeEventListener(mf,E)},[E]),(0,m.jsx)(H_,{scope:r,orientation:s,dir:g,loop:i,currentTabStopId:C,onItemFocus:p.useCallback(R=>v(R),[v]),onItemShiftTab:p.useCallback(()=>b(!0),[]),onFocusableItemAdd:p.useCallback(()=>O(R=>R+1),[]),onFocusableItemRemove:p.useCallback(()=>O(R=>R-1),[]),children:(0,m.jsx)(gt.div,{tabIndex:y||x===0?-1:0,"data-orientation":s,...h,ref:B,style:{outline:"none",...t.style},onMouseDown:Se(t.onMouseDown,()=>{A.current=!0}),onFocus:Se(t.onFocus,R=>{const P=!A.current;if(R.target===R.currentTarget&&P&&!y){const _=new CustomEvent(mf,L_);if(R.currentTarget.dispatchEvent(_),!_.defaultPrevented){const N=w().filter(q=>q.focusable);Pg([N.find(q=>q.active),N.find(q=>q.id===C),...N].filter(Boolean).map(q=>q.ref.current),d)}}A.current=!1}),onBlur:Se(t.onBlur,()=>b(!1))})})},"RovingFocusGroupImpl")),U_="RovingFocusGroupItem",z_=p.forwardRef(Hi(function(t,n){const{__scopeRovingFocusGroup:r,focusable:s=!0,active:i=!1,tabStopId:o,children:a,...l}=t,c=Ii(),u=o||c,d=j_(U_,r),h=d.currentTabStopId===u,f=yw(r),{onFocusableItemAdd:B,onFocusableItemRemove:g,currentTabStopId:C}=d,v=N_();return wn(()=>{if(!(!v||!s))return B(),()=>g()},[v,s,B,g]),p.useEffect(()=>{if(!(v||!s))return B(),()=>g()},[v,s,B,g]),(0,m.jsx)($B.ItemSlot,{scope:r,id:u,focusable:s,active:i,children:(0,m.jsx)(gt.span,{tabIndex:h?0:-1,"data-orientation":d.orientation,...l,ref:n,onMouseDown:Se(t.onMouseDown,y=>{s?d.onItemFocus(u):y.preventDefault()}),onFocus:Se(t.onFocus,()=>d.onItemFocus(u)),onKeyDown:Se(t.onKeyDown,y=>{if(y.key==="Tab"&&y.shiftKey){d.onItemShiftTab();return}if(y.target!==y.currentTarget)return;const b=Ew(y,d.orientation,d.dir);if(b!==void 0){if(y.metaKey||y.ctrlKey||y.altKey||y.shiftKey)return;y.preventDefault();let E=f().filter(w=>w.focusable).map(w=>w.ref.current);if(b==="last")E.reverse();else if(b==="prev"||b==="next"){b==="prev"&&E.reverse();const w=E.indexOf(y.currentTarget);E=d.loop?xw(E,w+1):E.slice(w+1)}setTimeout(()=>Pg(E))}}),children:typeof a=="function"?a({isCurrentTabStop:h,hasTabStop:C!=null}):a})})},"RovingFocusGroupItem")),$_={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Sw(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}Hi(Sw,"getDirectionAwareKey");function Ew(e,t,n){const r=Sw(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return $_[r]}Hi(Ew,"getFocusIntent");function Pg(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}Hi(Pg,"focusFirst");function xw(e,t){return e.map((n,r)=>e[(t+r)%e.length])}Hi(xw,"wrapArray");var W_=G_,q_=z_,K_=Object.defineProperty,Ne=(e,t)=>K_(e,"name",{value:t,configurable:!0}),WB=["Enter"," "],J_=["ArrowDown","PageUp","Home"],ww=["ArrowUp","PageDown","End"],Q_=[...J_,...ww],Y_={ltr:[...WB,"ArrowRight"],rtl:[...WB,"ArrowLeft"]},X_={ltr:["ArrowLeft"],rtl:["ArrowRight"]},ih="Menu",[fl,Z_,eF]=bg(ih),[ji,Dw]=fs(ih,[eF,nh,bw]),oh=nh(),Tw=bw(),[Aw,Xs]=ji(ih),[tF,Zl]=ji(ih),nF=Ne(e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:s,onOpenChange:i,modal:o=!0}=e,a=oh(t),[l,c]=p.useState(null),u=p.useRef(!1),d=Nt(i),h=Jd(s);return p.useEffect(()=>{const f=Ne(()=>{u.current=!0,document.addEventListener("pointerdown",B,{capture:!0,once:!0}),document.addEventListener("pointermove",B,{capture:!0,once:!0})},"handleKeyDown"),B=Ne(()=>u.current=!1,"handlePointer");return document.addEventListener("keydown",f,{capture:!0}),()=>{document.removeEventListener("keydown",f,{capture:!0}),document.removeEventListener("pointerdown",B,{capture:!0}),document.removeEventListener("pointermove",B,{capture:!0})}},[]),p.useEffect(()=>{if(!n)return;const f=Ne(()=>d(!1),"handleBlur");return window.addEventListener("blur",f),()=>window.removeEventListener("blur",f)},[n,d]),(0,m.jsx)(Mg,{...a,children:(0,m.jsx)(Aw,{scope:t,open:n,onOpenChange:d,content:l,onContentChange:c,children:(0,m.jsx)(tF,{scope:t,onClose:p.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:h,modal:o,children:r})})})},"Menu"),Iw=p.forwardRef(Ne(function(t,n){const{__scopeMenu:r,...s}=t,i=oh(r);return(0,m.jsx)(Bw,{...i,...s,ref:n})},"MenuAnchor")),kw="MenuPortal",[rF,Rw]=ji(kw,{forceMount:void 0}),sF=Ne(e=>{const{__scopeMenu:t,forceMount:n,children:r,container:s}=e,i=Xs(kw,t);return(0,m.jsx)(rF,{scope:t,forceMount:n,children:(0,m.jsx)(Hr,{present:n||i.open,children:(0,m.jsx)(Gx,{asChild:!0,container:s,children:r})})})},"MenuPortal"),tr="MenuContent",[iF,Lg]=ji(tr),oF=p.forwardRef(Ne(function(t,n){const r=Rw(tr,t.__scopeMenu),{forceMount:s=r.forceMount,...i}=t,o=Xs(tr,t.__scopeMenu),a=Zl(tr,t.__scopeMenu);return(0,m.jsx)(fl.Provider,{scope:t.__scopeMenu,children:(0,m.jsx)(Hr,{present:s||o.open,children:(0,m.jsx)(fl.Slot,{scope:t.__scopeMenu,children:a.modal?(0,m.jsx)(aF,{...i,ref:n}):(0,m.jsx)(lF,{...i,ref:n})})})})},"MenuContent")),aF=p.forwardRef(Ne(function(t,n){const r=Xs(tr,t.__scopeMenu),s=p.useRef(null),i=Ze(n,s);return p.useEffect(()=>{const o=s.current;if(o)return uL(o)},[]),(0,m.jsx)(_g,{...t,ref:i,trapFocus:r.open,disableOutsidePointerEvents:r.open,disableOutsideScroll:!0,onFocusOutside:Se(t.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>r.onOpenChange(!1)})},"MenuRootContentModal")),lF=p.forwardRef(Ne(function(t,n){const r=Xs(tr,t.__scopeMenu);return(0,m.jsx)(_g,{...t,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>r.onOpenChange(!1)})},"MenuRootContentNonModal")),cF=Ro("MenuContent.ScrollLock"),_g=p.forwardRef(Ne(function(t,n){const{__scopeMenu:r,loop:s=!1,trapFocus:i,onOpenAutoFocus:o,onCloseAutoFocus:a,disableOutsidePointerEvents:l,onEntryFocus:c,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:h,onInteractOutside:f,onDismiss:B,disableOutsideScroll:g,...C}=t,v=Xs(tr,r),y=Zl(tr,r),b=oh(r),E=Tw(r),w=Z_(r),[A,x]=p.useState(null),O=p.useRef(null),R=Ze(n,O,v.onContentChange),P=p.useRef(0),_=p.useRef(""),N=p.useRef(0),q=p.useRef(null),W=p.useRef("right"),F=p.useRef(0),z=g?Jx:p.Fragment,J=g?{as:cF,allowPinchZoom:!0}:void 0,Z=Ne(G=>{const be=_.current+G,ve=w().filter(ee=>!ee.disabled),X=document.activeElement,Y=ve.find(ee=>ee.ref.current===X)?.textValue,ie=Hw(ve.map(ee=>ee.textValue),be,Y),ne=ve.find(ee=>ee.textValue===ie)?.ref.current;Ne((function ee(Be){_.current=Be,window.clearTimeout(P.current),Be!==""&&(P.current=window.setTimeout(()=>ee(""),1e3))}),"updateSearch")(be),ne&&setTimeout(()=>ne.focus())},"handleTypeaheadSearch");p.useEffect(()=>()=>window.clearTimeout(P.current),[]),Dg();const Q=p.useCallback(G=>W.current===q.current?.side&&Gw(G,q.current?.area),[]);return(0,m.jsx)(iF,{scope:r,searchRef:_,onItemEnter:p.useCallback(G=>{Q(G)&&G.preventDefault()},[Q]),onItemLeave:p.useCallback(G=>{Q(G)||(O.current?.focus(),x(null))},[Q]),onTriggerLeave:p.useCallback(G=>{Q(G)&&G.preventDefault()},[Q]),pointerGraceTimerRef:N,onPointerGraceIntentChange:p.useCallback(G=>{q.current=G},[]),children:(0,m.jsx)(z,{...J,children:(0,m.jsx)(yP,{asChild:!0,trapped:i,onMountAutoFocus:Se(o,G=>{G.preventDefault(),O.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:a,children:(0,m.jsx)(Ox,{asChild:!0,disableOutsidePointerEvents:l,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:h,onInteractOutside:f,onDismiss:B,children:(0,m.jsx)(W_,{asChild:!0,...E,dir:y.dir,orientation:"vertical",loop:s,currentTabStopId:A,onCurrentTabStopIdChange:x,onEntryFocus:Se(c,G=>{y.isUsingKeyboardRef.current||G.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,m.jsx)(pw,{role:"menu","aria-orientation":"vertical","data-state":Hg(v.open),"data-radix-menu-content":"",dir:y.dir,...b,...C,ref:R,style:{outline:"none",...C.style},onKeyDown:Se(C.onKeyDown,G=>{const be=G.target.closest("[data-radix-menu-content]")===G.currentTarget,ve=G.ctrlKey||G.altKey||G.metaKey,X=G.key.length===1;be&&(G.key==="Tab"&&G.preventDefault(),!ve&&X&&Z(G.key));const Y=O.current;if(G.target!==Y||!Q_.includes(G.key))return;G.preventDefault();const ie=w().filter(ne=>!ne.disabled).map(ne=>ne.ref.current);ww.includes(G.key)&&ie.reverse(),_w(ie)}),onBlur:Se(t.onBlur,G=>{G.currentTarget.contains(G.target)||(window.clearTimeout(P.current),_.current="")}),onPointerMove:Se(t.onPointerMove,Oo(G=>{const be=G.target,ve=F.current!==G.clientX;if(G.currentTarget.contains(be)&&ve){const X=G.clientX>F.current?"right":"left";W.current=X,F.current=G.clientX}}))})})})})})})},"MenuContentImpl")),uF=p.forwardRef(Ne(function(t,n){const{__scopeMenu:r,...s}=t;return(0,m.jsx)(gt.div,{role:"group",...s,ref:n})},"MenuGroup")),dF=p.forwardRef(Ne(function(t,n){const{__scopeMenu:r,...s}=t;return(0,m.jsx)(gt.div,{...s,ref:n})},"MenuLabel")),qB="MenuItem",u0="menu.itemSelect",Fg=p.forwardRef(Ne(function(t,n){const{disabled:r=!1,onSelect:s,...i}=t,o=p.useRef(null),a=Zl(qB,t.__scopeMenu),l=Lg(qB,t.__scopeMenu),c=Ze(n,o),u=p.useRef(!1),d=Ne(()=>{const h=o.current;if(!r&&h){const f=new CustomEvent(u0,{bubbles:!0,cancelable:!0});h.addEventListener(u0,B=>s?.(B),{once:!0}),yg(h,f),f.defaultPrevented?u.current=!1:a.onClose()}},"handleSelect");return(0,m.jsx)(Ow,{...i,ref:c,disabled:r,onClick:Se(t.onClick,d),onPointerDown:h=>{t.onPointerDown?.(h),u.current=!0},onPointerUp:Se(t.onPointerUp,h=>{u.current||h.currentTarget?.click()}),onKeyDown:Se(t.onKeyDown,h=>{r||h.target!==h.currentTarget||l.searchRef.current!==""&&h.key===" "||WB.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})},"MenuItem")),Ow=p.forwardRef(Ne(function(t,n){const{__scopeMenu:r,disabled:s=!1,textValue:i,...o}=t,a=Lg(qB,r),l=Tw(r),c=p.useRef(null),u=Ze(n,c),[d,h]=p.useState(!1),[f,B]=p.useState("");return p.useEffect(()=>{const g=c.current;g&&B((g.textContent??"").trim())},[o.children]),(0,m.jsx)(fl.ItemSlot,{scope:r,disabled:s,textValue:i??f,children:(0,m.jsx)(q_,{asChild:!0,...l,focusable:!s,children:(0,m.jsx)(gt.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":s||void 0,"data-disabled":s?"":void 0,...o,ref:u,onPointerMove:Se(t.onPointerMove,Oo(g=>{s?a.onItemLeave(g):(a.onItemEnter(g),g.defaultPrevented||g.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Se(t.onPointerLeave,Oo(g=>a.onItemLeave(g))),onFocus:Se(t.onFocus,()=>h(!0)),onBlur:Se(t.onBlur,()=>h(!1))})})})},"MenuItemImpl")),hF=p.forwardRef(Ne(function(t,n){const{checked:r=!1,onCheckedChange:s,...i}=t;return(0,m.jsx)(Nw,{scope:t.__scopeMenu,checked:r,children:(0,m.jsx)(Fg,{role:"menuitemcheckbox","aria-checked":Bl(r)?"mixed":r,...i,ref:n,"data-state":ah(r),onSelect:Se(i.onSelect,()=>s?.(Bl(r)?!0:!r),{checkForDefaultPrevented:!1})})})},"MenuCheckboxItem")),[fF,BF]=ji("MenuRadioGroup",{value:void 0,onValueChange:Ne(()=>{},"onValueChange")}),pF=p.forwardRef(Ne(function(t,n){const{value:r,onValueChange:s,...i}=t,o=Nt(s);return(0,m.jsx)(fF,{scope:t.__scopeMenu,value:r,onValueChange:o,children:(0,m.jsx)(uF,{...i,ref:n})})},"MenuRadioGroup")),mF="MenuRadioItem",gF=p.forwardRef(Ne(function(t,n){const{value:r,...s}=t,i=BF(mF,t.__scopeMenu),o=r===i.value;return(0,m.jsx)(Nw,{scope:t.__scopeMenu,checked:o,children:(0,m.jsx)(Fg,{role:"menuitemradio","aria-checked":o,...s,ref:n,"data-state":ah(o),onSelect:Se(s.onSelect,()=>i.onValueChange?.(r),{checkForDefaultPrevented:!1})})})},"MenuRadioItem")),Mw="MenuItemIndicator",[Nw,CF]=ji(Mw,{checked:!1}),vF=p.forwardRef(Ne(function(t,n){const{__scopeMenu:r,forceMount:s,...i}=t,o=CF(Mw,r);return(0,m.jsx)(Hr,{present:s||Bl(o.checked)||o.checked===!0,children:(0,m.jsx)(gt.span,{...i,ref:n,"data-state":ah(o.checked)})})},"MenuItemIndicator")),yF=p.forwardRef(Ne(function(t,n){const{__scopeMenu:r,...s}=t;return(0,m.jsx)(gt.div,{role:"separator","aria-orientation":"horizontal",...s,ref:n})},"MenuSeparator")),Pw="MenuSub",[bF,Lw]=ji(Pw),SF=Ne(e=>{const{__scopeMenu:t,children:n,open:r=!1,onOpenChange:s}=e,i=Xs(Pw,t),o=oh(t),[a,l]=p.useState(null),[c,u]=p.useState(null),d=Nt(s);return p.useEffect(()=>(i.open===!1&&d(!1),()=>d(!1)),[i.open,d]),(0,m.jsx)(Mg,{...o,children:(0,m.jsx)(Aw,{scope:t,open:r,onOpenChange:d,content:c,onContentChange:u,children:(0,m.jsx)(bF,{scope:t,contentId:Ii(),triggerId:Ii(),trigger:a,onTriggerChange:l,children:n})})})},"MenuSub"),Mc="MenuSubTrigger",EF=p.forwardRef(Ne(function(t,n){const r=Xs(Mc,t.__scopeMenu),s=Zl(Mc,t.__scopeMenu),i=Lw(Mc,t.__scopeMenu),o=Lg(Mc,t.__scopeMenu),a=p.useRef(null),{pointerGraceTimerRef:l,onPointerGraceIntentChange:c}=o,u={__scopeMenu:t.__scopeMenu},d=p.useCallback(()=>{a.current&&window.clearTimeout(a.current),a.current=null},[]);p.useEffect(()=>d,[d]),p.useEffect(()=>{const f=l.current;return()=>{window.clearTimeout(f),c(null)}},[l,c]);const h=Ze(n,i.onTriggerChange);return(0,m.jsx)(Iw,{asChild:!0,...u,children:(0,m.jsx)(Ow,{id:i.triggerId,"aria-haspopup":"menu","aria-expanded":r.open,"aria-controls":r.open?i.contentId:void 0,"data-state":Hg(r.open),...t,ref:h,onClick:f=>{t.onClick?.(f),!(t.disabled||f.defaultPrevented)&&(f.currentTarget.focus(),r.open||r.onOpenChange(!0))},onPointerMove:Se(t.onPointerMove,Oo(f=>{o.onItemEnter(f),!f.defaultPrevented&&!t.disabled&&!r.open&&!a.current&&(o.onPointerGraceIntentChange(null),a.current=window.setTimeout(()=>{r.onOpenChange(!0),d()},100))})),onPointerLeave:Se(t.onPointerLeave,Oo(f=>{d();const B=r.content?.getBoundingClientRect();if(B){const g=r.content?.dataset.side,C=g==="right",v=C?-5:5,y=B[C?"left":"right"],b=B[C?"right":"left"];o.onPointerGraceIntentChange({area:[{x:f.clientX+v,y:f.clientY},{x:y,y:B.top},{x:b,y:B.top},{x:b,y:B.bottom},{x:y,y:B.bottom}],side:g}),window.clearTimeout(l.current),l.current=window.setTimeout(()=>o.onPointerGraceIntentChange(null),300)}else{if(o.onTriggerLeave(f),f.defaultPrevented)return;o.onPointerGraceIntentChange(null)}})),onKeyDown:Se(t.onKeyDown,f=>{t.disabled||f.target!==f.currentTarget||o.searchRef.current!==""&&f.key===" "||Y_[s.dir].includes(f.key)&&(r.onOpenChange(!0),r.content?.focus(),f.preventDefault())})})})},"MenuSubTrigger")),xF="MenuSubContent",wF=p.forwardRef(Ne(function(t,n){const r=Rw(tr,t.__scopeMenu),{forceMount:s=r.forceMount,align:i="start",...o}=t,a=Xs(tr,t.__scopeMenu),l=Zl(tr,t.__scopeMenu),c=Lw(xF,t.__scopeMenu),u=p.useRef(null),d=Ze(n,u);return(0,m.jsx)(fl.Provider,{scope:t.__scopeMenu,children:(0,m.jsx)(Hr,{present:s||a.open,children:(0,m.jsx)(fl.Slot,{scope:t.__scopeMenu,children:(0,m.jsx)(_g,{id:c.contentId,"aria-labelledby":c.triggerId,...o,ref:d,align:i,side:l.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:h=>{l.isUsingKeyboardRef.current&&u.current?.focus(),h.preventDefault()},onCloseAutoFocus:h=>h.preventDefault(),onFocusOutside:Se(t.onFocusOutside,h=>{h.target!==c.trigger&&a.onOpenChange(!1)}),onEscapeKeyDown:Se(t.onEscapeKeyDown,h=>{l.onClose(),h.preventDefault()}),onKeyDown:Se(t.onKeyDown,h=>{const f=h.currentTarget.contains(h.target),B=X_[l.dir].includes(h.key);f&&B&&(a.onOpenChange(!1),c.trigger?.focus(),h.preventDefault())})})})})})},"MenuSubContent"));function Hg(e){return e?"open":"closed"}Ne(Hg,"getOpenState");function Bl(e){return e==="indeterminate"}Ne(Bl,"isIndeterminate");function ah(e){return Bl(e)?"indeterminate":e?"checked":"unchecked"}Ne(ah,"getCheckedState");function _w(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}Ne(_w,"focusFirst");function Fw(e,t){return e.map((n,r)=>e[(t+r)%e.length])}Ne(Fw,"wrapArray");function Hw(e,t,n){const r=t.length>1&&Array.from(t).every(a=>a===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=Fw(e,Math.max(s,0));r.length===1&&(i=i.filter(a=>a!==n));const o=i.find(a=>a.toLowerCase().startsWith(r.toLowerCase()));return o!==n?o:void 0}Ne(Hw,"getNextMatch");function jw(e,t){const{x:n,y:r}=e;let s=!1;for(let i=0,o=t.length-1;i<t.length;o=i++){const a=t[i],l=t[o],c=a.x,u=a.y,d=l.x,h=l.y;u>r!=h>r&&n<(d-c)*(r-u)/(h-u)+c&&(s=!s)}return s}Ne(jw,"isPointInPolygon");function Gw(e,t){return t?jw({x:e.clientX,y:e.clientY},t):!1}Ne(Gw,"isPointerInGraceArea");function Oo(e){return t=>t.pointerType==="mouse"?e(t):void 0}Ne(Oo,"whenMouse");var DF=nF,TF=Iw,AF=sF,IF=oF,kF=dF,RF=Fg,OF=hF,MF=pF,NF=gF,PF=vF,LF=yF,_F=SF,FF=EF,HF=wF,jF=Object.defineProperty,hn=(e,t)=>jF(e,"name",{value:t,configurable:!0}),jg="DropdownMenu",[GF,tre]=fs(jg,[Dw]),fn=Dw(),[VF,Vw]=GF(jg),UF=hn(e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:s,defaultOpen:i,onOpenChange:o,modal:a=!0}=e,l=fn(t),c=p.useRef(null),[u,d]=Xl({prop:s,defaultProp:i??!1,onChange:o,caller:jg});return(0,m.jsx)(VF,{scope:t,triggerId:Ii(),triggerRef:c,contentId:Ii(),open:u,onOpenChange:d,onOpenToggle:p.useCallback(()=>d(h=>!h),[d]),modal:a,children:(0,m.jsx)(DF,{...l,open:u,onOpenChange:d,dir:r,modal:a,children:n})})},"DropdownMenu"),zF="DropdownMenuTrigger",$F=p.forwardRef(hn(function(t,n){const{__scopeDropdownMenu:r,disabled:s=!1,...i}=t,o=Vw(zF,r),a=fn(r),l=Ze(n,o.triggerRef);return(0,m.jsx)(TF,{asChild:!0,...a,children:(0,m.jsx)(gt.button,{type:"button",id:o.triggerId,"aria-haspopup":"menu","aria-expanded":o.open,"aria-controls":o.open?o.contentId:void 0,"data-state":o.open?"open":"closed","data-disabled":s?"":void 0,disabled:s,...i,ref:l,onPointerDown:Se(t.onPointerDown,c=>{!s&&c.button===0&&c.ctrlKey===!1&&(o.onOpenToggle(),o.open||c.preventDefault())}),onKeyDown:Se(t.onKeyDown,c=>{s||(["Enter"," "].includes(c.key)&&o.onOpenToggle(),c.key==="ArrowDown"&&o.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(c.key)&&c.preventDefault())})})})},"DropdownMenuTrigger")),WF=hn(e=>{const{__scopeDropdownMenu:t,...n}=e,r=fn(t);return(0,m.jsx)(AF,{...r,...n})},"DropdownMenuPortal"),qF="DropdownMenuContent",KF=p.forwardRef(hn(function(t,n){const{__scopeDropdownMenu:r,...s}=t,i=Vw(qF,r),o=fn(r),a=p.useRef(!1);return(0,m.jsx)(IF,{id:i.contentId,"aria-labelledby":i.triggerId,...o,...s,ref:n,onCloseAutoFocus:Se(t.onCloseAutoFocus,l=>{a.current||i.triggerRef.current?.focus(),a.current=!1,l.preventDefault()}),onInteractOutside:Se(t.onInteractOutside,l=>{const c=l.detail.originalEvent,u=c.button===0&&c.ctrlKey===!0,d=c.button===2||u;(!i.modal||d)&&(a.current=!0)}),style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})},"DropdownMenuContent")),JF=p.forwardRef(hn(function(t,n){const{__scopeDropdownMenu:r,...s}=t,i=fn(r);return(0,m.jsx)(kF,{...i,...s,ref:n})},"DropdownMenuLabel")),QF=p.forwardRef(hn(function(t,n){const{__scopeDropdownMenu:r,...s}=t,i=fn(r);return(0,m.jsx)(RF,{...i,...s,ref:n})},"DropdownMenuItem")),YF=p.forwardRef(hn(function(t,n){const{__scopeDropdownMenu:r,...s}=t,i=fn(r);return(0,m.jsx)(OF,{...i,...s,ref:n})},"DropdownMenuCheckboxItem")),XF=p.forwardRef(hn(function(t,n){const{__scopeDropdownMenu:r,...s}=t,i=fn(r);return(0,m.jsx)(MF,{...i,...s,ref:n})},"DropdownMenuRadioGroup")),ZF=p.forwardRef(hn(function(t,n){const{__scopeDropdownMenu:r,...s}=t,i=fn(r);return(0,m.jsx)(NF,{...i,...s,ref:n})},"DropdownMenuRadioItem")),e2=p.forwardRef(hn(function(t,n){const{__scopeDropdownMenu:r,...s}=t,i=fn(r);return(0,m.jsx)(PF,{...i,...s,ref:n})},"DropdownMenuItemIndicator")),t2=p.forwardRef(hn(function(t,n){const{__scopeDropdownMenu:r,...s}=t,i=fn(r);return(0,m.jsx)(LF,{...i,...s,ref:n})},"DropdownMenuSeparator")),n2=hn(e=>{const{__scopeDropdownMenu:t,children:n,open:r,onOpenChange:s,defaultOpen:i}=e,o=fn(t),[a,l]=Xl({prop:r,defaultProp:i??!1,onChange:s,caller:"DropdownMenuSub"});return(0,m.jsx)(_F,{...o,open:a,onOpenChange:l,children:n})},"DropdownMenuSub"),r2=p.forwardRef(hn(function(t,n){const{__scopeDropdownMenu:r,...s}=t,i=fn(r);return(0,m.jsx)(FF,{...i,...s,ref:n})},"DropdownMenuSubTrigger")),s2=p.forwardRef(hn(function(t,n){const{__scopeDropdownMenu:r,...s}=t,i=fn(r);return(0,m.jsx)(HF,{...i,...s,ref:n,style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})},"DropdownMenuSubContent")),i2=UF,o2=$F,a2=WF,l2=KF,c2=JF,u2=QF,d2=YF,h2=XF,f2=ZF,Uw=e2,B2=t2,p2=n2,m2=r2,g2=s2,C2=Object.defineProperty,v2=(e,t)=>C2(e,"name",{value:t,configurable:!0});function zw(e,[t,n]){return Math.min(n,Math.max(t,e))}v2(zw,"clamp");var y2=Object.defineProperty,Oe=(e,t)=>y2(e,"name",{value:t,configurable:!0});function $w(e,t){return p.useReducer((n,r)=>t[n][r]??n,e)}Oe($w,"useStateMachine");var Ww="ScrollArea",[qw,nre]=fs(Ww),[b2,jn]=qw(Ww),S2=p.forwardRef(Oe(function(t,n){const{__scopeScrollArea:r,type:s="hover",dir:i,scrollHideDelay:o=600,...a}=t,[l,c]=p.useState(null),[u,d]=p.useState(null),[h,f]=p.useState(null),[B,g]=p.useState(null),[C,v]=p.useState(null),[y,b]=p.useState(0),[E,w]=p.useState(0),[A,x]=p.useState(!1),[O,R]=p.useState(!1),P=Ze(n,c),_=Jd(i);return(0,m.jsx)(b2,{scope:r,type:s,dir:_,scrollHideDelay:o,scrollArea:l,viewport:u,onViewportChange:d,content:h,onContentChange:f,scrollbarX:B,onScrollbarXChange:g,scrollbarXEnabled:A,onScrollbarXEnabledChange:x,scrollbarY:C,onScrollbarYChange:v,scrollbarYEnabled:O,onScrollbarYEnabledChange:R,onCornerWidthChange:b,onCornerHeightChange:w,children:(0,m.jsx)(gt.div,{dir:_,...a,ref:P,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":E+"px",...t.style}})})},"ScrollArea")),E2="ScrollAreaViewport",x2=p.forwardRef(Oe(function(t,n){const{__scopeScrollArea:r,children:s,nonce:i,...o}=t,a=jn(E2,r),l=p.useRef(null),c=Ze(n,l,a.onViewportChange);return(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(w2,{nonce:i}),(0,m.jsx)(gt.div,{"data-radix-scroll-area-viewport":"",...o,ref:c,style:{overflowX:a.scrollbarXEnabled?"scroll":"hidden",overflowY:a.scrollbarYEnabled?"scroll":"hidden",...t.style},children:(0,m.jsx)("div",{ref:a.onContentChange,style:{minWidth:"100%",display:"table"},children:s})})]})},"ScrollAreaViewport")),w2=p.memo(Oe(function({nonce:t}){return(0,m.jsx)("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:t})},"ScrollAreaViewportStyle"),(e,t)=>e.nonce===t.nonce),ps="ScrollAreaScrollbar",D2=p.forwardRef(Oe(function(t,n){const{forceMount:r,...s}=t,i=jn(ps,t.__scopeScrollArea),{onScrollbarXEnabledChange:o,onScrollbarYEnabledChange:a}=i,l=t.orientation==="horizontal";return p.useEffect(()=>(l?o(!0):a(!0),()=>{l?o(!1):a(!1)}),[l,o,a]),i.type==="hover"?(0,m.jsx)(T2,{...s,ref:n,forceMount:r}):i.type==="scroll"?(0,m.jsx)(A2,{...s,ref:n,forceMount:r}):i.type==="auto"?(0,m.jsx)(Kw,{...s,ref:n,forceMount:r}):i.type==="always"?(0,m.jsx)(Gg,{...s,ref:n,"data-state":"visible"}):null},"ScrollAreaScrollbar")),T2=p.forwardRef(Oe(function(t,n){const{forceMount:r,...s}=t,i=jn(ps,t.__scopeScrollArea),[o,a]=p.useState(!1);return p.useEffect(()=>{const l=i.scrollArea;let c=0;if(l){const u=Oe(()=>{window.clearTimeout(c),a(!0)},"handlePointerEnter"),d=Oe(()=>{c=window.setTimeout(()=>a(!1),i.scrollHideDelay)},"handlePointerLeave");return l.addEventListener("pointerenter",u),l.addEventListener("pointerleave",d),()=>{window.clearTimeout(c),l.removeEventListener("pointerenter",u),l.removeEventListener("pointerleave",d)}}},[i.scrollArea,i.scrollHideDelay]),(0,m.jsx)(Hr,{present:r||o,children:(0,m.jsx)(Kw,{"data-state":o?"visible":"hidden",...s,ref:n})})},"ScrollAreaScrollbarHover")),A2=p.forwardRef(Oe(function(t,n){const{forceMount:r,...s}=t,i=jn(ps,t.__scopeScrollArea),o=t.orientation==="horizontal",a=tc(()=>c("SCROLL_END"),100),[l,c]=$w("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return p.useEffect(()=>{if(l==="idle"){const u=window.setTimeout(()=>c("HIDE"),i.scrollHideDelay);return()=>window.clearTimeout(u)}},[l,i.scrollHideDelay,c]),p.useEffect(()=>{const u=i.viewport,d=o?"scrollLeft":"scrollTop";if(u){let h=u[d];const f=Oe(()=>{const B=u[d];h!==B&&(c("SCROLL"),a()),h=B},"handleScroll");return u.addEventListener("scroll",f),()=>u.removeEventListener("scroll",f)}},[i.viewport,o,c,a]),(0,m.jsx)(Hr,{present:r||l!=="hidden",children:(0,m.jsx)(Gg,{"data-state":l==="hidden"?"hidden":"visible",...s,ref:n,onPointerEnter:Se(t.onPointerEnter,()=>c("POINTER_ENTER")),onPointerLeave:Se(t.onPointerLeave,()=>c("POINTER_LEAVE"))})})},"ScrollAreaScrollbarScroll")),Kw=p.forwardRef(Oe(function(t,n){const r=jn(ps,t.__scopeScrollArea),{forceMount:s,...i}=t,[o,a]=p.useState(!1),l=t.orientation==="horizontal",c=tc(()=>{if(r.viewport){const u=r.viewport.offsetWidth<r.viewport.scrollWidth,d=r.viewport.offsetHeight<r.viewport.scrollHeight;a(l?u:d)}},10);return Oi(r.viewport,c),Oi(r.content,c),(0,m.jsx)(Hr,{present:s||o,children:(0,m.jsx)(Gg,{"data-state":o?"visible":"hidden",...i,ref:n})})},"ScrollAreaScrollbarAuto")),Gg=p.forwardRef(Oe(function(t,n){const{orientation:r="vertical",...s}=t,i=jn(ps,t.__scopeScrollArea),o=p.useRef(null),a=p.useRef(0),[l,c]=p.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=Vg(l.viewport,l.content),d={...s,sizes:l,onSizesChange:c,hasThumb:u>0&&u<1,onThumbChange:Oe(f=>o.current=f,"onThumbChange"),onThumbPointerUp:Oe(()=>a.current=0,"onThumbPointerUp"),onThumbPointerDown:Oe(f=>a.current=f,"onThumbPointerDown")};function h(f,B){return Xw(f,a.current,l,B)}return Oe(h,"getScrollPosition"),r==="horizontal"?(0,m.jsx)(I2,{...d,ref:n,onThumbPositionChange:()=>{if(i.viewport&&o.current){const f=i.viewport.scrollLeft,B=JB(f,l,i.dir);o.current.style.transform=`translate3d(${B}px, 0, 0)`}},onWheelScroll:f=>{i.viewport&&(i.viewport.scrollLeft=f)},onDragScroll:f=>{i.viewport&&(i.viewport.scrollLeft=h(f,i.dir))}}):r==="vertical"?(0,m.jsx)(k2,{...d,ref:n,onThumbPositionChange:()=>{if(i.viewport&&o.current){const f=i.viewport.scrollTop,B=JB(f,l);o.current.style.transform=`translate3d(0, ${B}px, 0)`}},onWheelScroll:f=>{i.viewport&&(i.viewport.scrollTop=f)},onDragScroll:f=>{i.viewport&&(i.viewport.scrollTop=h(f))}}):null},"ScrollAreaScrollbarVisible")),I2=p.forwardRef(Oe(function(t,n){const{sizes:r,onSizesChange:s,...i}=t,o=jn(ps,t.__scopeScrollArea),[a,l]=p.useState(),c=p.useRef(null),u=Ze(n,c,o.onScrollbarXChange);return p.useEffect(()=>{c.current&&l(getComputedStyle(c.current))},[c]),(0,m.jsx)(Qw,{"data-orientation":"horizontal",...i,ref:u,sizes:r,style:{bottom:0,left:o.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:o.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":ec(r)+"px",...t.style},onThumbPointerDown:d=>t.onThumbPointerDown(d.x),onDragScroll:d=>t.onDragScroll(d.x),onWheelScroll:(d,h)=>{if(o.viewport){const f=o.viewport.scrollLeft+d.deltaX;t.onWheelScroll(f),zg(f,h)&&d.preventDefault()}},onResize:()=>{c.current&&o.viewport&&a&&s({content:o.viewport.scrollWidth,viewport:o.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:pl(a.paddingLeft),paddingEnd:pl(a.paddingRight)}})}})},"ScrollAreaScrollbarX")),k2=p.forwardRef(Oe(function(t,n){const{sizes:r,onSizesChange:s,...i}=t,o=jn(ps,t.__scopeScrollArea),[a,l]=p.useState(),c=p.useRef(null),u=Ze(n,c,o.onScrollbarYChange);return p.useEffect(()=>{c.current&&l(getComputedStyle(c.current))},[c]),(0,m.jsx)(Qw,{"data-orientation":"vertical",...i,ref:u,sizes:r,style:{top:0,right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":ec(r)+"px",...t.style},onThumbPointerDown:d=>t.onThumbPointerDown(d.y),onDragScroll:d=>t.onDragScroll(d.y),onWheelScroll:(d,h)=>{if(o.viewport){const f=o.viewport.scrollTop+d.deltaY;t.onWheelScroll(f),zg(f,h)&&d.preventDefault()}},onResize:()=>{c.current&&o.viewport&&a&&s({content:o.viewport.scrollHeight,viewport:o.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:pl(a.paddingTop),paddingEnd:pl(a.paddingBottom)}})}})},"ScrollAreaScrollbarY")),[R2,Jw]=qw(ps),Qw=p.forwardRef(Oe(function(t,n){const{__scopeScrollArea:r,sizes:s,hasThumb:i,onThumbChange:o,onThumbPointerUp:a,onThumbPointerDown:l,onThumbPositionChange:c,onDragScroll:u,onWheelScroll:d,onResize:h,...f}=t,B=jn(ps,r),[g,C]=p.useState(null),v=Ze(n,C),y=p.useRef(null),b=p.useRef(""),E=B.viewport,w=s.content-s.viewport,A=Nt(d),x=Nt(c),O=tc(h,10);function R(P){if(y.current){const _=P.clientX-y.current.left,N=P.clientY-y.current.top;u({x:_,y:N})}}return Oe(R,"handleDragScroll"),p.useEffect(()=>{const P=Oe(_=>{const N=_.target;g?.contains(N)&&A(_,w)},"handleWheel");return document.addEventListener("wheel",P,{passive:!1}),()=>document.removeEventListener("wheel",P,{passive:!1})},[E,g,w,A]),p.useEffect(x,[s,x]),Oi(g,O),Oi(B.content,O),(0,m.jsx)(R2,{scope:r,scrollbar:g,hasThumb:i,onThumbChange:Nt(o),onThumbPointerUp:Nt(a),onThumbPositionChange:x,onThumbPointerDown:Nt(l),children:(0,m.jsx)(gt.div,{...f,ref:v,style:{position:"absolute",...f.style},onPointerDown:Se(t.onPointerDown,P=>{P.button===0&&(P.target.setPointerCapture(P.pointerId),y.current=g.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",B.viewport&&(B.viewport.style.scrollBehavior="auto"),R(P))}),onPointerMove:Se(t.onPointerMove,R),onPointerUp:Se(t.onPointerUp,P=>{const _=P.target;_.hasPointerCapture(P.pointerId)&&_.releasePointerCapture(P.pointerId),document.body.style.webkitUserSelect=b.current,B.viewport&&(B.viewport.style.scrollBehavior=""),y.current=null})})})},"ScrollAreaScrollbarImpl")),KB="ScrollAreaThumb",O2=p.forwardRef(Oe(function(t,n){const{forceMount:r,...s}=t,i=Jw(KB,t.__scopeScrollArea);return(0,m.jsx)(Hr,{present:r||i.hasThumb,children:(0,m.jsx)(M2,{ref:n,...s})})},"ScrollAreaThumb")),M2=p.forwardRef(Oe(function(t,n){const{__scopeScrollArea:r,style:s,...i}=t,o=jn(KB,r),a=Jw(KB,r),{onThumbPositionChange:l}=a,c=Ze(n,a.onThumbChange),u=p.useRef(void 0),d=tc(()=>{u.current&&(u.current(),u.current=void 0)},100);return p.useEffect(()=>{const h=o.viewport;if(h){const f=Oe(()=>{if(d(),!u.current){const B=L2(h,l);u.current=B,l()}},"handleScroll");return l(),h.addEventListener("scroll",f),()=>h.removeEventListener("scroll",f)}},[o.viewport,d,l]),(0,m.jsx)(gt.div,{"data-state":a.hasThumb?"visible":"hidden",...i,ref:c,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...s},onPointerDownCapture:Se(t.onPointerDownCapture,h=>{const f=h.target.getBoundingClientRect(),B=h.clientX-f.left,g=h.clientY-f.top;a.onThumbPointerDown({x:B,y:g})}),onPointerUp:Se(t.onPointerUp,a.onThumbPointerUp)})},"ScrollAreaThumbImpl")),Yw="ScrollAreaCorner",N2=p.forwardRef(Oe(function(t,n){const r=jn(Yw,t.__scopeScrollArea),s=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&s?(0,m.jsx)(P2,{...t,ref:n}):null},"ScrollAreaCorner")),P2=p.forwardRef(Oe(function(t,n){const{__scopeScrollArea:r,...s}=t,i=jn(Yw,r),[o,a]=p.useState(0),[l,c]=p.useState(0),u=!!(o&&l),{onCornerWidthChange:d,onCornerHeightChange:h}=i;return Oi(i.scrollbarX,()=>{const f=i.scrollbarX?.offsetHeight||0;i.onCornerHeightChange(f),c(f)}),Oi(i.scrollbarY,()=>{const f=i.scrollbarY?.offsetWidth||0;i.onCornerWidthChange(f),a(f)}),p.useEffect(()=>()=>{d(0),h(0)},[d,h]),u?(0,m.jsx)(gt.div,{...s,ref:n,style:{width:o,height:l,position:"absolute",right:i.dir==="ltr"?0:void 0,left:i.dir==="rtl"?0:void 0,bottom:0,...t.style}}):null},"ScrollAreaCornerImpl"));function pl(e){return e?parseInt(e,10):0}Oe(pl,"toInt");function Vg(e,t){const n=e/t;return isNaN(n)?0:n}Oe(Vg,"getThumbRatio");function ec(e){const t=Vg(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}Oe(ec,"getThumbSize");function Xw(e,t,n,r="ltr"){const s=ec(n),i=s/2,o=t||i,a=s-o,l=n.scrollbar.paddingStart+o,c=n.scrollbar.size-n.scrollbar.paddingEnd-a,u=n.content-n.viewport,d=r==="ltr"?[0,u]:[u*-1,0];return Ug([l,c],d)(e)}Oe(Xw,"getScrollPositionFromPointer");function JB(e,t,n="ltr"){const r=ec(t),s=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,i=t.scrollbar.size-s,o=t.content-t.viewport,a=i-r,l=n==="ltr"?[0,o]:[o*-1,0],c=zw(e,l);return Ug([0,o],[0,a])(c)}Oe(JB,"getThumbOffsetFromScroll");function Ug(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}Oe(Ug,"linearScale");function zg(e,t){return e>0&&e<t}Oe(zg,"isScrollingWithinScrollbarBounds");var L2=Oe((e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return Oe((function s(){const i={left:e.scrollLeft,top:e.scrollTop},o=n.left!==i.left,a=n.top!==i.top;(o||a)&&t(),n=i,r=window.requestAnimationFrame(s)}),"loop")(),()=>window.cancelAnimationFrame(r)},"addUnlinkedScrollListener");function tc(e,t){const n=Nt(e),r=p.useRef(0);return p.useEffect(()=>()=>window.clearTimeout(r.current),[]),p.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}Oe(tc,"useDebounceCallback");function Oi(e,t){const n=Nt(t);wn(()=>{let r=0;if(e){const s=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(n)});return s.observe(e),()=>{window.cancelAnimationFrame(r),s.unobserve(e)}}},[e,n])}Oe(Oi,"useResizeObserver");var _2=S2,F2=x2,H2=N2,j2=Object.defineProperty,Dt=(e,t)=>j2(e,"name",{value:t,configurable:!0}),[$g,rre]=fs("Tooltip",[nh]),lh=nh(),G2="TooltipProvider",V2=700,QB="tooltip.open",[U2,Wg]=$g(G2),z2=Dt(e=>{const{__scopeTooltip:t,delayDuration:n=V2,skipDelayDuration:r=300,disableHoverableContent:s=!1,children:i}=e,o=p.useRef(!0),a=p.useRef(!1),l=p.useRef(0);return p.useEffect(()=>{const c=l.current;return()=>window.clearTimeout(c)},[]),(0,m.jsx)(U2,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:p.useCallback(()=>{r<=0||(window.clearTimeout(l.current),o.current=!1)},[r]),onClose:p.useCallback(()=>{r<=0||(window.clearTimeout(l.current),l.current=window.setTimeout(()=>o.current=!0,r))},[r]),isPointerInTransitRef:a,onPointerInTransitChange:p.useCallback(c=>{a.current=c},[]),disableHoverableContent:s,children:i})},"TooltipProvider"),YB="Tooltip",[$2,nc]=$g(YB),W2=Dt(e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:s,onOpenChange:i,disableHoverableContent:o,delayDuration:a}=e,l=Wg(YB,e.__scopeTooltip),c=lh(t),[u,d]=p.useState(null),[h,f]=p.useState(void 0),B=Ii(),g=p.useRef(0),C=o??l.disableHoverableContent,v=a??l.delayDuration,y=p.useRef(!1),[b,E]=Xl({prop:r,defaultProp:s??!1,onChange:Dt(P=>{P?(l.onOpen(),document.dispatchEvent(new CustomEvent(QB))):l.onClose(),i?.(P)},"onChange"),caller:YB}),w=p.useMemo(()=>b?y.current?"delayed-open":"instant-open":"closed",[b]),A=p.useCallback(()=>{window.clearTimeout(g.current),g.current=0,y.current=!1,E(!0)},[E]),x=p.useCallback(()=>{window.clearTimeout(g.current),g.current=0,E(!1)},[E]),O=p.useCallback(()=>{window.clearTimeout(g.current),g.current=window.setTimeout(()=>{y.current=!0,E(!0),g.current=0},v)},[v,E]);p.useEffect(()=>()=>{g.current&&(window.clearTimeout(g.current),g.current=0)},[]);const R=h??B;return(0,m.jsx)(Mg,{...c,children:(0,m.jsx)($2,{scope:t,contentId:R,setContentId:f,open:b,stateAttribute:w,trigger:u,onTriggerChange:d,onTriggerEnter:p.useCallback(()=>{l.isOpenDelayedRef.current?O():A()},[l.isOpenDelayedRef,O,A]),onTriggerLeave:p.useCallback(()=>{C?x():(window.clearTimeout(g.current),g.current=0)},[x,C]),onOpen:A,onClose:x,disableHoverableContent:C,children:n})})},"Tooltip"),d0="TooltipTrigger",q2=p.forwardRef(Dt(function(t,n){const{__scopeTooltip:r,...s}=t,i=nc(d0,r),o=Wg(d0,r),a=lh(r),l=p.useRef(null),c=Ze(n,l,i.onTriggerChange),u=p.useRef(!1),d=p.useRef(!1),h=p.useCallback(()=>u.current=!1,[]);return p.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),(0,m.jsx)(Bw,{asChild:!0,...a,children:(0,m.jsx)(gt.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...s,ref:c,onPointerMove:Se(t.onPointerMove,f=>{f.pointerType!=="touch"&&!d.current&&!o.isPointerInTransitRef.current&&(i.onTriggerEnter(),d.current=!0)}),onPointerLeave:Se(t.onPointerLeave,()=>{i.onTriggerLeave(),d.current=!1}),onPointerDown:Se(t.onPointerDown,()=>{i.open&&i.onClose(),u.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:Se(t.onFocus,()=>{u.current||i.onOpen()}),onBlur:Se(t.onBlur,i.onClose),onClick:Se(t.onClick,i.onClose)})})},"TooltipTrigger")),Zw="TooltipPortal",[K2,J2]=$g(Zw,{forceMount:void 0}),Q2=Dt(e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:s}=e,i=nc(Zw,t);return(0,m.jsx)(K2,{scope:t,forceMount:n,children:(0,m.jsx)(Hr,{present:n||i.open,children:(0,m.jsx)(Gx,{asChild:!0,container:s,children:r})})})},"TooltipPortal"),ml="TooltipContent",Y2=p.forwardRef(Dt(function(t,n){const r=J2(ml,t.__scopeTooltip),{forceMount:s=r.forceMount,side:i="top",...o}=t,a=nc(ml,t.__scopeTooltip);return(0,m.jsx)(Hr,{present:s||a.open,children:a.disableHoverableContent?(0,m.jsx)(eD,{side:i,...o,ref:n}):(0,m.jsx)(X2,{side:i,...o,ref:n})})},"TooltipContent")),X2=p.forwardRef(Dt(function(t,n){const r=nc(ml,t.__scopeTooltip),s=Wg(ml,t.__scopeTooltip),i=p.useRef(null),o=Ze(n,i),[a,l]=p.useState(null),{trigger:c,onClose:u}=r,d=i.current,{onPointerInTransitChange:h}=s,f=p.useCallback(()=>{l(null),h(!1)},[h]),B=p.useCallback((g,C)=>{const v=g.currentTarget,y={x:g.clientX,y:g.clientY},b=nD(y,tD(y,v.getBoundingClientRect())),E=rD(C.getBoundingClientRect()),w=iD([...b,...E]);l(w),h(!0)},[h]);return p.useEffect(()=>()=>f(),[f]),p.useEffect(()=>{if(c&&d){const g=Dt(v=>B(v,d),"handleTriggerLeave"),C=Dt(v=>B(v,c),"handleContentLeave");return c.addEventListener("pointerleave",g),d.addEventListener("pointerleave",C),()=>{c.removeEventListener("pointerleave",g),d.removeEventListener("pointerleave",C)}}},[c,d,B,f]),p.useEffect(()=>{if(a){const g=Dt(C=>{const v=C.target,y={x:C.clientX,y:C.clientY},b=c?.contains(v)||d?.contains(v),E=!sD(y,a);b?f():E&&(f(),u())},"handleTrackPointerGrace");return document.addEventListener("pointermove",g),()=>document.removeEventListener("pointermove",g)}},[c,d,a,u,f]),(0,m.jsx)(eD,{...t,ref:o})},"TooltipContentHoverable")),Z2=AN("TooltipContent"),eD=p.forwardRef(Dt(function(t,n){const{__scopeTooltip:r,children:s,"aria-label":i,id:o,onEscapeKeyDown:a,onPointerDownOutside:l,...c}=t,u=nc(ml,r),d=lh(r),{onClose:h}=u;p.useEffect(()=>(document.addEventListener(QB,h),()=>document.removeEventListener(QB,h)),[h]),p.useEffect(()=>{if(u.trigger){const B=Dt(g=>{g.target instanceof Node&&g.target.contains(u.trigger)&&h()},"handleScroll");return window.addEventListener("scroll",B,{capture:!0}),()=>window.removeEventListener("scroll",B,{capture:!0})}},[u.trigger,h]);const{setContentId:f}=u;return wn(()=>(f(o),()=>{f(void 0)}),[o,f]),(0,m.jsx)(Ox,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:B=>B.preventDefault(),onDismiss:h,children:(0,m.jsxs)(pw,{"data-state":u.stateAttribute,role:i?void 0:"tooltip",id:i?void 0:u.contentId,...d,...c,ref:n,style:{...c.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[(0,m.jsx)(Z2,{children:s}),i?(0,m.jsx)(WN,{id:u.contentId,role:"tooltip",children:i}):null]})})},"TooltipContentImpl")),eH=p.forwardRef(Dt(function(t,n){const{__scopeTooltip:r,...s}=t,i=lh(r);return(0,m.jsx)(O_,{...i,...s,ref:n})},"TooltipArrow"));function tD(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),s=Math.abs(t.right-e.x),i=Math.abs(t.left-e.x);switch(Math.min(n,r,s,i)){case i:return"left";case s:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}Dt(tD,"getExitSideFromRect");function nD(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n})}return r}Dt(nD,"getPaddedExitPoints");function rD(e){const{top:t,right:n,bottom:r,left:s}=e;return[{x:s,y:t},{x:n,y:t},{x:n,y:r},{x:s,y:r}]}Dt(rD,"getPointsFromRect");function sD(e,t){const{x:n,y:r}=e;let s=!1;for(let i=0,o=t.length-1;i<t.length;o=i++){const a=t[i],l=t[o],c=a.x,u=a.y,d=l.x,h=l.y;u>r!=h>r&&n<(d-c)*(r-u)/(h-u)+c&&(s=!s)}return s}Dt(sD,"isPointInPolygon");function iD(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),oD(t)}Dt(iD,"getHull");function oD(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const s=e[r];for(;t.length>=2;){const i=t[t.length-1],o=t[t.length-2];if((i.x-o.x)*(s.y-o.y)>=(i.y-o.y)*(s.x-o.x))t.pop();else break}t.push(s)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const s=e[r];for(;n.length>=2;){const i=n[n.length-1],o=n[n.length-2];if((i.x-o.x)*(s.y-o.y)>=(i.y-o.y)*(s.x-o.x))n.pop();else break}n.push(s)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}Dt(oD,"getHullPresorted");var tH=z2,nH=W2,rH=q2,sH=Q2,iH=Y2,oH=eH,aD={name:"bot",size:24,node:[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]};aD.node;var aH=Ve(aD),lD={name:"check",size:24,node:[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]};lD.node;var Vs=Ve(lD),cD={name:"chevron-down",size:24,node:[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]};cD.node;var uD=Ve(cD),dD={name:"chevron-right",size:24,node:[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]};dD.node;var Mo=Ve(dD),hD={name:"circle-alert",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],aliases:["alert-circle"]};hD.node;var lH=Ve(hD),fD={name:"clock",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]]};fD.node;var h0=Ve(fD),BD={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"}]]};BD.node;var _s=Ve(BD),pD={name:"expand",size:24,node:[["path",{d:"m15 15 6 6",key:"1s409w"}],["path",{d:"m15 9 6-6",key:"ko1vev"}],["path",{d:"M21 16v5h-5",key:"1ck2sf"}],["path",{d:"M21 8V3h-5",key:"1qoq8a"}],["path",{d:"M3 16v5h5",key:"1t08am"}],["path",{d:"m3 21 6-6",key:"wwnumi"}],["path",{d:"M3 8V3h5",key:"1ln10m"}],["path",{d:"M9 9 3 3",key:"v551iv"}]]};pD.node;var cH=Ve(pD),mD={name:"eye",size:24,node:[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]};mD.node;var uH=Ve(mD),gD={name:"grip-vertical",size:24,node:[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]]};gD.node;var dH=Ve(gD),CD={name:"layers",size:24,node:[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],aliases:["layers-3"]};CD.node;var hH=Ve(CD),vD={name:"list-filter",size:24,node:[["path",{d:"M2 5h20",key:"1fs1ex"}],["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M9 19h6",key:"456am0"}]]};vD.node;var fH=Ve(vD),yD={name:"list-tree",size:24,node:[["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"M3 10a2 2 0 0 0 2 2h3",key:"1npucw"}],["path",{d:"M3 5v12a2 2 0 0 0 2 2h3",key:"x1gjn2"}]]};yD.node;var f0=Ve(yD),bD={name:"maximize-2",size:24,node:[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]]};bD.node;var BH=Ve(bD),SD={name:"message-square-quote",size:24,node:[["path",{d:"M14 14a2 2 0 0 0 2-2V8h-2",key:"1r06pg"}],["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M8 14a2 2 0 0 0 2-2V8H8",key:"1jzu5j"}]]};SD.node;var pH=Ve(SD),ED={name:"minimize-2",size:24,node:[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]]};ED.node;var mH=Ve(ED),xD={name:"minus",size:24,node:[["path",{d:"M5 12h14",key:"1ays0h"}]]};xD.node;var gH=Ve(xD),wD={name:"mouse-pointer-click",size:24,node:[["path",{d:"M14 4.1 12 6",key:"ita8i4"}],["path",{d:"m5.1 8-2.9-.8",key:"1go3kf"}],["path",{d:"m6 12-1.9 2",key:"mnht97"}],["path",{d:"M7.2 2.2 8 5.1",key:"1cfko1"}],["path",{d:"M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z",key:"s0h3yz"}]]};wD.node;var CH=Ve(wD),DD={name:"pencil",size:24,node:[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]};DD.node;var vH=Ve(DD),TD={name:"plus",size:24,node:[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]};TD.node;var yH=Ve(TD),AD={name:"radio",size:24,node:[["path",{d:"M16.247 7.761a6 6 0 0 1 0 8.478",key:"1fwjs5"}],["path",{d:"M19.075 4.933a10 10 0 0 1 0 14.134",key:"ehdyv1"}],["path",{d:"M4.925 19.067a10 10 0 0 1 0-14.134",key:"1q22gi"}],["path",{d:"M7.753 16.239a6 6 0 0 1 0-8.478",key:"r2q7qm"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]};AD.node;var bH=Ve(AD),ID={name:"redo-2",size:24,node:[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]]};ID.node;var SH=Ve(ID),kD={name:"shrink",size:24,node:[["path",{d:"m15 15 6 6m-6-6v4.8m0-4.8h4.8",key:"17vawe"}],["path",{d:"M9 19.8V15m0 0H4.2M9 15l-6 6",key:"chjx8e"}],["path",{d:"M15 4.2V9m0 0h4.8M15 9l6-6",key:"lav6yq"}],["path",{d:"M9 4.2V9m0 0H4.2M9 9 3 3",key:"1pxi2q"}]]};kD.node;var EH=Ve(kD),RD={name:"text-align-start",size:24,node:[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]],aliases:["text","align-left"]};RD.node;var xH=Ve(RD),OD={name:"triangle-alert",size:24,node:[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],aliases:["alert-triangle"]};OD.node;var ch=Ve(OD),MD={name:"undo-2",size:24,node:[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]};MD.node;var wH=Ve(MD),ND={name:"user-round",size:24,node:[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]],aliases:["user-2"]};ND.node;var DH=Ve(ND),PD={name:"user",size:24,node:[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]};PD.node;var TH=Ve(PD),LD={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"}]]};LD.node;var AH=Ve(LD),Fs=class extends Error{constructor(e){super(e),this.name="CanonicalJsonError"}};function _D(e){if(!Number.isFinite(e))throw new Fs(`Cannot canonicalize non-finite number: ${String(e)}`);return e===0?"0":String(e)}function uh(e){if(e===void 0)throw new Fs("Cannot canonicalize `undefined` at the root");return XB(e,new Set)}function XB(e,t){if(e===null)return"null";switch(typeof e){case"boolean":return e?"true":"false";case"number":return _D(e);case"string":return JSON.stringify(e);case"object":break;default:throw new Fs(`Cannot canonicalize value of type ${typeof e}`)}if(t.has(e))throw new Fs("Cannot canonicalize a circular structure");t.add(e);try{if(Array.isArray(e)){const i=[],o=e.length;for(let a=0;a<o;a+=1){const l=e[a];i.push(l===void 0?"null":XB(l,t))}return`[${i.join(",")}]`}const n=Object.getPrototypeOf(e);if(n!==Object.prototype&&n!==null)throw new Fs("Cannot canonicalize a non-plain object (only plain objects, arrays and JSON primitives are part of the contract)");const r=e,s=[];for(const i of Object.keys(r).sort()){const o=r[i];o!==void 0&&s.push(`${JSON.stringify(i)}:${XB(o,t)}`)}return`{${s.join(",")}}`}finally{t.delete(e)}}var ZB=Symbol("canonicalJsonBounded.overBudget"),IH=class{constructor(e){this.maxChars=e}parts=[];length=0;remaining(){return this.maxChars-this.length}push(e){if(e.length>this.remaining())throw ZB;this.parts.push(e),this.length+=e.length}pushString(e,t=""){if(e.length+2+t.length>this.remaining())throw ZB;this.push(JSON.stringify(e)+t)}toString(){return this.parts.join("")}};function sre(e,t){if(e===void 0)return{ok:!1,reason:"uncanonical",message:"Cannot canonicalize `undefined` at the root"};const n=new IH(t);try{ep(e,new Set,n)}catch(r){return r===ZB?{ok:!1,reason:"overBudget"}:{ok:!1,reason:"uncanonical",message:r instanceof Error?r.message:String(r)}}return{ok:!0,json:n.toString()}}function ep(e,t,n){if(e===null){n.push("null");return}switch(typeof e){case"boolean":n.push(e?"true":"false");return;case"number":n.push(_D(e));return;case"string":n.pushString(e);return;case"object":break;default:throw new Fs(`Cannot canonicalize value of type ${typeof e}`)}if(t.has(e))throw new Fs("Cannot canonicalize a circular structure");t.add(e);try{if(Array.isArray(e)){n.push("[");const o=e.length;for(let a=0;a<o;a+=1){a>0&&n.push(",");const l=e[a];l===void 0?n.push("null"):ep(l,t,n)}n.push("]");return}const r=Object.getPrototypeOf(e);if(r!==Object.prototype&&r!==null)throw new Fs("Cannot canonicalize a non-plain object (only plain objects, arrays and JSON primitives are part of the contract)");const s=e;n.push("{");let i=!0;for(const o of Object.keys(s).sort()){const a=s[o];a!==void 0&&(i||n.push(","),i=!1,n.pushString(o,":"),ep(a,t,n))}n.push("}")}finally{t.delete(e)}}function dh(e){return uN(pN(oN(e)))}function qg(e){return dh(uh(e))}function kH(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function RH(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0?e:void 0}function OH(e){const t=Object.entries(e).filter(([,n])=>n!==void 0);return t.length>0?Object.fromEntries(t):void 0}var MH=["uncachedInputTokens","cacheReadTokens","cacheWriteTokens","cacheWrite1hTokens","outputTokens","reasoningTokens","webSearchRequests"];function NH(e){const t=kH(e);if(!t)return;const n={};for(const r of MH){const s=RH(t[r]);s!==void 0&&(n[r]=s)}return OH(n)}var gl=e=>e&&typeof e=="object"&&!Array.isArray(e)?e:void 0,Qr=e=>typeof e=="number"&&Number.isFinite(e)&&e>=0?e:void 0,tp=e=>typeof e=="string"&&e.length>0?e:void 0;function ci(e,t){return t.includes(e)?e:void 0}function Os(e,t,n){const r={};for(const s of t){const i=n(e[s]);i!==void 0&&(r[s]=i)}return r}var B0=["input","output","cacheRead","cacheWrite","cacheWrite1h"];function PH(e){const t=gl(e);if(!t||t.currency!=="USD")return;const n=Os(t,[...B0,"webSearchPerThousand"],Qr);if(n.input===void 0||n.output===void 0)return;const r=(Array.isArray(t.tiers)?t.tiers:[]).map(gl).filter(s=>Qr(s?.aboveInputTokens)!==void 0).map(s=>Os(s,["aboveInputTokens",...B0],Qr));return{...n,currency:"USD",...r.length>0?{tiers:r}:{}}}function LH(e){const t=gl(e),n=ci(t?.source,["list_price","customer_rate"]),r=PH(t?.rates),s=tp(t?.modelId);if(!t||!n||!r||!s)return;const i=Array.isArray(t.assumptions)?t.assumptions.filter(o=>typeof o=="string"):[];return{source:n,rates:r,modelId:s,...Os(t,["provider","versionId"],tp),...Os(t,["effectiveAt","retrievedAt"],Qr),...i.length>0?{assumptions:i}:{}}}function FD(e){const t=gl(e);if(!t||t.currency!=="USD")return;const n=ci(t.completeness,["complete","partial","unavailable"]),r=Qr(t.calculationVersion),s=Qr(t.amountUsd),i=ci(t.source,["provider_reported","list_price","customer_rate","runner_reported"]);if(!n||r===void 0||n==="unavailable"!=(s===void 0)||s!==void 0&&!i)return;const o=Os(gl(t.parts)??{},["input","cacheRead","cacheWrite","output","webSearch"],Qr),a=(Array.isArray(t.missing)?t.missing:[]).filter(f=>ci(f,["usage","input_tokens","output_tokens","rate","cache_read_rate","cache_write_rate","cache_write_1h_rate","web_search_rate"])!==void 0),l=ci(t.reason,["no_usage","no_rate","invalid_rate","unsupported_currency"]),c=ci(t.funding,["mcpjam","customer"]),u=ci(t.usageSource,["provider","runner","interrupted_estimate"]),d=NH(t.usage),h=LH(t.rate);return{calculationVersion:r,currency:"USD",completeness:n,...s!==void 0?{amountUsd:s}:{},...i?{source:i}:{},...Object.keys(o).length>0?{parts:o}:{},...a.length>0?{missing:a}:{},...l?{reason:l}:{},...Os(t,["tierAboveInputTokens"],Qr),...h?{rate:h}:{},...Os(t,["reporter"],tp),...c?{funding:c}:{},...d?{usage:d}:{},...u?{usageSource:u}:{},...Os(t,["recordedAt"],Qr)}}var p0=1000000000000000n,HD=1e15;function _H(e){return BigInt(Math.round(e*HD))}function FH(e){const t=e/p0,n=e%p0;return Number(t)+Number(n)/HD}var HH=["provider_reported","customer_rate","list_price","runner_reported"];function jH(e){let t=0n,n=0,r=0,s=0;const i=new Set;for(const l of e){if(!l||l.amountUsd===void 0||l.currency!=="USD"){s+=1;continue}t+=_H(l.amountUsd),l.source&&i.add(l.source),l.completeness==="complete"?n+=1:r+=1}const o=e.length,a=n===o?"complete":n+r===0?"unavailable":"partial";return{currency:"USD",knownSubtotalUsd:FH(t),completeness:a,totalCalls:o,completeCalls:n,partialCalls:r,unavailableCalls:s,sources:HH.filter(l=>i.has(l))}}function ui(e){const t=[e.scope??"",e.serverId,e.wire,e.taskId];if(e.connectionId!==void 0&&t.push(e.connectionId),t.some(n=>n.includes("\0"))||e.connectionId==="")throw new Error("Invalid task identity");return t.join("\0")}var GH=["completed","failed","cancelled","expired"];function Ta(e){return GH.includes(e)}var VH=250,UH=3e5,zH=1e3,$H=6e4;function m0(e){return typeof e=="number"&&Number.isFinite(e)&&e>0?e:0}function Ki(e){return typeof e=="number"&&Number.isFinite(e)&&e>0?e:void 0}function da(e){return{...e,respondedInputKeys:[...e.respondedInputKeys],terminal:Ta(e.status)}}var ire=class{records=new Map;now;absoluteFloorMs;maximumIntervalMs;backoffBaseMs;backoffMaxMs;userMinimumIntervalMs;callbacks;constructor(e={}){this.now=e.now??(()=>Date.now()),this.absoluteFloorMs=e.absoluteFloorMs??VH,this.maximumIntervalMs=e.maximumIntervalMs??UH,this.backoffBaseMs=e.errorBackoffBaseMs??zH,this.backoffMaxMs=e.errorBackoffMaxMs??$H,this.userMinimumIntervalMs=m0(e.userMinimumIntervalMs),this.callbacks=e.callbacks??{}}setCallbacks(e){this.callbacks=e}setUserMinimumIntervalMs(e){this.userMinimumIntervalMs=m0(e);for(const t of this.records.values()){if(Ta(t.status))continue;const n=(t.lastObservedAt??this.now())+this.effectiveIntervalMs(t),r=t.consecutiveErrors>0?t.nextPollAt:0;t.nextPollAt=Math.max(n,t.retryAfterUntil??0,r)}}getUserMinimumIntervalMs(){return this.userMinimumIntervalMs}effectiveIntervalMs(e,t){const n=t??this.now(),r=Ki(e.pollIntervalMs)??0,s=e.consecutiveErrors>0?Math.min(this.backoffBaseMs*2**(e.consecutiveErrors-1),this.backoffMaxMs):0,i=e.retryAfterUntil?Math.max(0,e.retryAfterUntil-n):0,o=Math.min(Math.max(this.absoluteFloorMs,this.userMinimumIntervalMs,s),Math.max(this.maximumIntervalMs,this.absoluteFloorMs));return Math.max(o,r,i)}get(e){return this.records.get(ui(e))}getByKey(e){return this.records.get(e)}snapshot(e){const t=this.get(e);return t?da(t):void 0}all(){return[...this.records.values()].map(da)}register(e,t={}){const n=ui(e),r=this.records.get(n);if(r)return r;const s=this.now(),i={key:n,identity:{...e},status:t.status??"unknown",createdAt:t.createdAt,ttlMs:t.ttlMs??null,pollIntervalMs:Ki(t.pollIntervalMs),nextPollAt:typeof t.nextPollAt=="number"&&Number.isFinite(t.nextPollAt)?Math.max(s,t.nextPollAt):s,lastObservedAt:typeof t.lastObservedAt=="number"&&Number.isFinite(t.lastObservedAt)?t.lastObservedAt:void 0,consecutiveErrors:0,cancellationRequested:!1,restored:t.restored===!0,pollInFlight:!1,respondedInputKeys:new Set(t.respondedInputKeys??[]),toolName:t.toolName,surface:t.surface};return this.records.set(n,i),t.restored||this.callbacks.onTaskCreated?.(da(i)),i}forget(e){this.records.delete(ui(e))}clear(){this.records.clear()}observe(e,t,n="poll"){const r=this.register(e,{restored:!0}),s=r.status,i=this.now();if(Ta(r.status)&&!r.restored)return r.lastObservedAt=i,r;r.restored=!1,r.status=t.status,r.statusMessage=t.statusMessage,t.createdAt!==void 0&&(r.createdAt=t.createdAt),t.lastUpdatedAt!==void 0&&(r.lastUpdatedAt=t.lastUpdatedAt),t.ttlMs!==void 0&&(r.ttlMs=t.ttlMs),t.pollIntervalMs!==void 0&&(r.pollIntervalMs=Ki(t.pollIntervalMs)),r.inputRequests=t.inputRequests,r.result=t.result,r.error=t.error,r.raw=t.raw,r.lastObservedAt=i,n!=="notification"&&(r.consecutiveErrors=0,r.retryAfterUntil=void 0);const o=Ta(r.status);o?r.nextPollAt=Number.POSITIVE_INFINITY:n==="notification"&&r.consecutiveErrors>0?r.nextPollAt=Math.min(r.nextPollAt,i+this.effectiveIntervalMs(r,i)):r.nextPollAt=i+this.effectiveIntervalMs(r,i);const a=da(r);return s!==r.status?(this.callbacks.onState?.(a,s),r.status==="input_required"&&this.callbacks.onInputRequired?.(a),o&&this.callbacks.onTerminal?.(a)):r.status==="input_required"&&n!=="create"&&this.callbacks.onInputRequired?.(a),r}observeError(e,t={}){const n=this.register(e,{restored:!0}),r=this.now();n.consecutiveErrors+=1;const s=Ki(t.retryAfterMs);return s!==void 0&&(n.retryAfterUntil=r+s),n.nextPollAt=r+this.effectiveIntervalMs(n,r),n}applyRetryAfter(e,t){const n=this.register(e,{restored:!0}),r=this.now(),s=Ki(t);s!==void 0&&(n.retryAfterUntil=r+s,n.nextPollAt=Math.max(n.nextPollAt,r+s))}clearErrorBackoff(e){const t=this.records.get(ui(e));if(!t)return;const n=this.now();t.consecutiveErrors=0;const r=Ki(t.pollIntervalMs)??0;t.nextPollAt=Math.max(n,t.lastObservedAt!==void 0?t.lastObservedAt+r:0,t.retryAfterUntil??0)}markExpired(e){const t=this.register(e,{restored:!0}),n=t.status;t.status="expired",t.lastObservedAt=this.now(),t.nextPollAt=Number.POSITIVE_INFINITY,t.consecutiveErrors=0;const r=da(t);return n!=="expired"&&(this.callbacks.onState?.(r,n),this.callbacks.onTerminal?.(r)),t}markCancellationRequested(e){const t=this.register(e,{restored:!0});t.cancellationRequested=!0}markInputKeysResponded(e,t){const n=this.register(e,{restored:!0});for(const r of t)n.respondedInputKeys.add(r)}pendingInputKeys(e){const t=this.get(e);return t?.inputRequests?Object.keys(t.inputRequests).filter(n=>Object.prototype.hasOwnProperty.call(t.inputRequests,n)&&!t.respondedInputKeys.has(n)):[]}owesRead(e){return Ta(e.status)?e.restored&&e.identity.wire==="extension":!0}due(e){const t=e??this.now();return[...this.records.values()].filter(n=>this.owesRead(n)&&!n.pollInFlight&&n.nextPollAt<=t).sort((n,r)=>n.nextPollAt-r.nextPollAt)}active(){return[...this.records.values()].filter(e=>this.owesRead(e))}msUntilNextDue(e){const t=e??this.now();let n=Number.POSITIVE_INFINITY;for(const r of this.records.values())this.owesRead(r)&&(n=Math.min(n,r.nextPollAt));if(Number.isFinite(n))return Math.max(0,n-t)}reserve(e,t){const n=t??this.now();for(const r of e)r.nextPollAt=n+this.effectiveIntervalMs(r,n)}acquirePoll(e,t){const n=this.records.get(ui(e));return!n||n.pollInFlight?!1:(n.pollInFlight=!0,this.reserve([n],t),!0)}releasePoll(e){const t=this.records.get(ui(e));t&&(t.pollInFlight=!1)}batchIntervalMs(e,t){const n=t??this.now();let r=Math.max(this.absoluteFloorMs,this.userMinimumIntervalMs);for(const s of e)r=Math.max(r,this.effectiveIntervalMs(s,n));return r}},jD=(0,p.createContext)({});function WH(e){const t=(0,p.useRef)(null);return t.current===null&&(t.current=e()),t.current}var qH=typeof window<"u",g0=qH?p.useLayoutEffect:p.useEffect,hh=(0,p.createContext)(null);function Kg(e,t){e.indexOf(t)===-1&&e.push(t)}function fd(e,t){const n=e.indexOf(t);n>-1&&e.splice(n,1)}var ms=(e,t,n)=>n>t?t:n<e?e:n,fh=()=>{},Mi=()=>{},ds={},Jg=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e),GD=e=>typeof e=="object"&&e!==null,Qg=e=>/^0[^.\s]+$/u.test(e);function VD(e){let t;return()=>(t===void 0&&(t=e()),t)}var nr=e=>e,rc=(...e)=>e.reduce((t,n)=>r=>n(t(r))),Cl=(e,t,n)=>{const r=t-e;return r?(n-e)/r:1},Bd=class{constructor(){this.subscriptions=[]}add(e){return Kg(this.subscriptions,e),()=>this.remove(e)}remove(e){fd(this.subscriptions,e)}notify(e,t,n){const r=this.subscriptions.length;if(r)if(r===1)this.subscriptions[0](e,t,n);else for(let s=0;s<r;s++){const i=this.subscriptions[s];i&&i(e,t,n)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}},Dn=e=>e*1e3,Mn=e=>e/1e3,UD=(e,t)=>t?e*(1e3/t):0,zD=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,KH=1e-7,JH=12;function QH(e,t,n,r,s){let i,o,a=0;do o=t+(n-t)/2,i=zD(o,r,s)-e,i>0?n=o:t=o;while(Math.abs(i)>KH&&++a<JH);return o}function sc(e,t,n,r){if(e===t&&n===r)return nr;const s=i=>QH(i,0,1,e,n);return i=>i===0||i===1?i:zD(s(i),t,r)}var $D=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,WD=e=>t=>1-e(1-t),qD=sc(.33,1.53,.69,.99),Yg=WD(qD),KD=$D(Yg),JD=e=>e>=1?1:(e*=2)<1?.5*Yg(e):.5*(2-Math.pow(2,-10*(e-1))),Xg=e=>1-Math.sin(Math.acos(e)),QD=WD(Xg),YD=$D(Xg),YH=sc(.42,0,1,1),XH=sc(0,0,.58,1),Zg=sc(.42,0,.58,1),ZH=e=>Array.isArray(e)&&typeof e[0]!="number",XD=e=>Array.isArray(e)&&typeof e[0]=="number",C0={linear:nr,easeIn:YH,easeInOut:Zg,easeOut:XH,circIn:Xg,circInOut:YD,circOut:QD,backIn:Yg,backInOut:KD,backOut:qD,anticipate:JD},ej=e=>typeof e=="string",v0=e=>{if(XD(e)){Mi(e.length===4,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");const[t,n,r,s]=e;return sc(t,n,r,s)}else if(ej(e))return Mi(C0[e]!==void 0,`Invalid easing type '${e}'`,"invalid-easing-type"),C0[e];return e},xt={delta:0,timestamp:0,isProcessing:!1},wu;function tj(){wu=void 0}var Ht={now:()=>(wu===void 0&&Ht.set(xt.isProcessing||ds.useManualTiming?xt.timestamp:performance.now()),wu),set:e=>{wu=e,queueMicrotask(tj)}},xo=e=>Math.round(e*1e5)/1e5,ZD=e=>t=>typeof t=="string"&&t.startsWith(e),e1=ZD("--"),nj=ZD("var(--"),eC=e=>nj(e)?rj.test(e.split("/*")[0].trim()):!1,rj=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function y0(e){return typeof e!="string"?!1:e.split("/*")[0].includes("var(--")}var ta={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},vl={...ta,transform:e=>ms(0,1,e)},Nc={...ta,default:1},tC=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function sj(e){return e==null}var ij=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,nC=(e,t)=>n=>!!(typeof n=="string"&&ij.test(n)&&n.startsWith(e)||t&&!sj(n)&&Object.prototype.hasOwnProperty.call(n,t)),t1=(e,t,n)=>r=>{if(typeof r!="string")return r;const[s,i,o,a]=r.match(tC);return{[e]:parseFloat(s),[t]:parseFloat(i),[n]:parseFloat(o),alpha:a!==void 0?parseFloat(a):1}},oj=e=>ms(0,255,e),gf={...ta,transform:e=>Math.round(oj(e))},gi={test:nC("rgb","red"),parse:t1("red","green","blue"),transform:({red:e,green:t,blue:n,alpha:r=1})=>"rgba("+gf.transform(e)+", "+gf.transform(t)+", "+gf.transform(n)+", "+xo(vl.transform(r))+")"};function aj(e){let t="",n="",r="",s="";return e.length>5?(t=e.substring(1,3),n=e.substring(3,5),r=e.substring(5,7),s=e.substring(7,9)):(t=e.substring(1,2),n=e.substring(2,3),r=e.substring(3,4),s=e.substring(4,5),t+=t,n+=n,r+=r,s+=s),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(r,16),alpha:s?parseInt(s,16)/255:1}}var np={test:nC("#"),parse:aj,transform:gi.transform},ic=e=>({test:t=>typeof t=="string"&&t.endsWith(e)&&t.split(" ").length===1,parse:parseFloat,transform:t=>`${t}${e}`}),Vr=ic("deg"),Nr=ic("%"),fe=ic("px"),lj=ic("vh"),cj=ic("vw"),b0={...Nr,parse:e=>Nr.parse(e)/100,transform:e=>Nr.transform(e*100)},ho={test:nC("hsl","hue"),parse:t1("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:n,alpha:r=1})=>"hsla("+Math.round(e)+", "+Nr.transform(xo(t))+", "+Nr.transform(xo(n))+", "+xo(vl.transform(r))+")"},wt={test:e=>gi.test(e)||np.test(e)||ho.test(e),parse:e=>gi.test(e)?gi.parse(e):ho.test(e)?ho.parse(e):np.parse(e),transform:e=>typeof e=="string"?e:e.hasOwnProperty("red")?gi.transform(e):ho.transform(e),getAnimatableNone:e=>{const t=wt.parse(e);return t.alpha=0,wt.transform(t)}},uj=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu,n1=new RegExp(tC.source),r1=new RegExp(uj.source,"i");function dj(e){return isNaN(e)&&typeof e=="string"&&(n1.test(e)||r1.test(e))}var s1="number",i1="color",hj="var",fj="var(",S0="${}",Bj=/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 pj(e){const t=e.toString();return n1.test(t)||r1.test(t)}function yl(e){const t=e.toString(),n=[],r={color:[],number:[],var:[]},s=[];let i=0;return{values:n,split:t.replace(Bj,o=>(wt.test(o)?(r.color.push(i),s.push(i1),n.push(wt.parse(o))):o.startsWith(fj)?(r.var.push(i),s.push(hj),n.push(o)):(r.number.push(i),s.push(s1),n.push(parseFloat(o))),++i,S0)).split(S0),indexes:r,types:s}}function mj(e){return yl(e).values}function o1({split:e,types:t}){const n=e.length;return r=>{let s="";for(let i=0;i<n;i++)if(s+=e[i],r[i]!==void 0){const o=t[i];o===s1?s+=xo(r[i]):o===i1?s+=wt.transform(r[i]):s+=r[i]}return s}}function gj(e){return o1(yl(e))}var Cj=e=>typeof e=="number"?0:wt.test(e)?wt.getAnimatableNone(e):e,vj=(e,t)=>typeof e=="number"?t?.trim().endsWith("/")?e:0:Cj(e);function yj(e){const t=yl(e);return o1(t)(t.values.map((n,r)=>vj(n,t.split[r])))}var Tn={test:dj,parse:mj,createTransformer:gj,getAnimatableNone:yj};function Cf(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function bj({hue:e,saturation:t,lightness:n,alpha:r}){e/=360,t/=100,n/=100;let s=0,i=0,o=0;if(!t)s=i=o=n;else{const a=n<.5?n*(1+t):n+t-n*t,l=2*n-a;s=Cf(l,a,e+1/3),i=Cf(l,a,e),o=Cf(l,a,e-1/3)}return{red:Math.round(s*255),green:Math.round(i*255),blue:Math.round(o*255),alpha:r}}function pd(e,t){return n=>n>0?t:e}var Ue=(e,t,n)=>e+(t-e)*n,vf=(e,t,n)=>{const r=e*e,s=n*(t*t-r)+r;return s<0?0:Math.sqrt(s)},Sj=[np,gi,ho],Ej=e=>Sj.find(t=>t.test(e));function E0(e){const t=Ej(e);if(!t)return fh(!1,`'${e}' is not an animatable color. Use the equivalent color code instead.`,"color-not-animatable"),!1;let n=t.parse(e);return t===ho&&(n=bj(n)),n}var x0=(e,t)=>{const n=E0(e),r=E0(t);if(!n||!r)return pd(e,t);const s={...n};return i=>(s.red=vf(n.red,r.red,i),s.green=vf(n.green,r.green,i),s.blue=vf(n.blue,r.blue,i),s.alpha=Ue(n.alpha,r.alpha,i),gi.transform(s))},rp=new Set(["none","hidden"]);function xj(e,t){return rp.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function wj(e,t){return n=>Ue(e,t,n)}function rC(e){return typeof e=="number"?wj:typeof e=="string"?eC(e)?pd:wt.test(e)?x0:Aj:Array.isArray(e)?a1:typeof e=="object"?wt.test(e)?x0:Dj:pd}function a1(e,t){const n=[...e],r=n.length,s=e.map((i,o)=>rC(i)(i,t[o]));return i=>{for(let o=0;o<r;o++)n[o]=s[o](i);return n}}function Dj(e,t){const n={...e,...t},r={};for(const s in n)e[s]!==void 0&&t[s]!==void 0&&(r[s]=rC(e[s])(e[s],t[s]));return s=>{for(const i in r)n[i]=r[i](s);return n}}function Tj(e,t){const n=[],r={color:0,var:0,number:0};for(let s=0;s<t.values.length;s++){const i=t.types[s],o=e.indexes[i][r[i]],a=e.values[o]??0;n[s]=a,r[i]++}return n}var Aj=(e,t)=>{const n=Tn.createTransformer(t),r=yl(e),s=yl(t);return r.indexes.var.length===s.indexes.var.length&&r.indexes.color.length===s.indexes.color.length&&r.indexes.number.length>=s.indexes.number.length?rp.has(e)&&!s.values.length||rp.has(t)&&!r.values.length?xj(e,t):rc(a1(Tj(r,s),s.values),n):(fh(!0,`Complex values '${e}' and '${t}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`,"complex-values-different"),pd(e,t))},w0=/^(-?(?:\d+(?:\.\d*)?|\.\d+))([a-z%]*)$/iu;function Ij(e,t){const n=w0.exec(e);if(!n)return;const r=w0.exec(t);if(!r||n[2]!==r[2])return;const s=n[2],i=parseFloat(n[1]),o=parseFloat(r[1]);return a=>xo(Ue(i,o,a))+s}function sC(e,t,n){if(typeof e=="number"&&typeof t=="number"&&typeof n=="number")return Ue(e,t,n);if(typeof e=="string"&&typeof t=="string"){const r=Ij(e,t);if(r)return r}return rC(e)(e,t)}var Pc=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function kj(e){let t=new Set,n=new Set,r=!1,s=!1;const i=new Set;let o={delta:0,timestamp:0,isProcessing:!1};function a(c){i.has(c)&&(n.add(c),e()),c(o)}const l={schedule:(c,u=!1,d=!1)=>{const h=d&&r?t:n;return u&&i.add(c),h.add(c),c},cancel:c=>{n.delete(c),i.delete(c)},process:c=>{if(o=c,r){s=!0;return}r=!0;const u=t;t=n,n=u,t.forEach(a),t.clear(),r=!1,s&&(s=!1,l.process(c))}};return l}var Rj=40;function l1(e,t,n={delta:0,timestamp:0,isProcessing:!1}){let r=!1,s=!0;const i=()=>r=!0,o=Pc.reduce((b,E)=>(b[E]=kj(i),b),{}),{setup:a,read:l,resolveKeyframes:c,preUpdate:u,update:d,preRender:h,render:f,postRender:B}=o,g=()=>{const b=ds.useManualTiming,E=b?n.timestamp:performance.now();r=!1,b||(n.delta=s?1e3/60:Math.max(Math.min(E-n.timestamp,Rj),1)),n.timestamp=E,n.isProcessing=!0,a.process(n),l.process(n),c.process(n),u.process(n),d.process(n),h.process(n),f.process(n),B.process(n),n.isProcessing=!1,r&&t&&(s=!1,e(g))},C=()=>{r=!0,s=!0,n.isProcessing||e(g)};return{schedule:Pc.reduce((b,E)=>{const w=o[E];return b[E]=(A,x=!1,O=!1)=>(r||C(),w.schedule(A,x,O)),b},{}),cancel:b=>{for(let E=0;E<Pc.length;E++)o[Pc[E]].cancel(b)},state:n,steps:o}}var{schedule:qe,cancel:Us,steps:yf}=l1(typeof requestAnimationFrame<"u"?requestAnimationFrame:nr,!0,xt),Oj=e=>{const t=({timestamp:n})=>e(n);return{start:(n=!0)=>qe.update(t,n),stop:()=>Us(t),now:()=>xt.isProcessing?xt.timestamp:Ht.now()}},c1=(e,t,n=10)=>{let r="";const s=Math.max(Math.round(t/n),2);for(let i=0;i<s;i++)r+=Math.round(e(i/(s-1))*1e4)/1e4+", ";return`linear(${r.substring(0,r.length-2)})`},iC=2e4;function oC(e,t=50,n=iC,r){let s=0,i=e.next(s);for(r?.push(i.value);!i.done&&s<n;)s+=t,i=e.next(s),r?.push(i.value);return s>=n?1/0:s}function Mj(e,t=100,n){const r=n({...e,keyframes:[0,t]}),s=Math.min(oC(r),iC);return{type:"keyframes",ease:i=>r.next(s*i).value/t,duration:Mn(s)}}var Mt={stiffness:100,damping:10,mass:1,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05},u1=e=>e<0?1/Math.max(1+e,Mt.minDamping):Math.max(1-e,Mt.minDamping);function d1(e,t){if(!(e>1))return 1;const n=Math.sqrt(e*e-1),r=e-n,s=e+n,i=2*n*Math.exp(-t)*(1+t);return h1(o=>s*Math.exp(-r*o)-r*Math.exp(-s*o)-i,o=>Math.exp(-s*o)-Math.exp(-r*o),t)/t}function sp(e,t){return e*Math.sqrt(1-t*t)}var Nj=12;function h1(e,t,n){let r=n;for(let s=1;s<Nj;s++)r=r-e(r)/t(r);return r}var D0=.001;function Pj({duration:e=Mt.duration,bounce:t=Mt.bounce}){let n,r;fh(e<=Dn(Mt.maxDuration),"Spring duration must be 10 seconds or less","spring-duration-limit");const s=u1(t);e=ms(Mt.minDuration,Mt.maxDuration,Mn(e)),s<1?(n=c=>{const u=c*s,d=u*e,h=sp(c,s),f=Math.exp(-d);return D0-u/h*f},r=c=>{const u=c*s*e,d=s*s*c*c*e,h=Math.exp(-u),f=sp(c*c,s);return(-n(c)+D0>0?-1:1)*-d*h/f}):(n=c=>-.001+Math.exp(-c*e)*(c*e+1),r=c=>Math.exp(-c*e)*(-c*(e*e)));const i=5/e,o=h1(n,r,i),a=o*d1(s,o*e),l=a*a;return{stiffness:l,damping:s*2*Math.sqrt(l),duration:Dn(e)}}var ip=(e,t)=>(t?e>=0:e>0)&&e<1/0;function bf(e,t){if(ip(e,t))return e}function Lj(e){const t=bf(e.stiffness),n=bf(e.damping,!0),r=bf(e.mass),s={...e,stiffness:t??Mt.stiffness,damping:n??Mt.damping,mass:r??Mt.mass,isResolvedFromDuration:!1,isTimeDefined:(t??n??r)===void 0&&(e.duration!==void 0||e.bounce!==void 0)};if(s.isTimeDefined){if(e.visualDuration){const i=u1(e.bounce||0),o=2*Math.PI/(e.visualDuration*1.2)*d1(i,2*Math.PI/1.2);s.stiffness=o*o,s.damping=2*i*Math.sqrt(s.stiffness)}else Object.assign(s,Pj(s)),s.isResolvedFromDuration=!0;(!ip(s.stiffness)||!ip(s.damping,!0))&&(s.stiffness=Mt.stiffness,s.damping=Mt.damping)}return s}function md(e=Mt.visualDuration,t=Mt.bounce){const n=typeof e!="object"?{visualDuration:e,keyframes:[0,1],bounce:t}:e,r=n.keyframes[0],s=n.keyframes[n.keyframes.length-1],i={done:!1,value:r},{stiffness:o,damping:a,mass:l,duration:c,isResolvedFromDuration:u,isTimeDefined:d}=Lj({...n}),h=x=>d?0:-Mn(x),f=a/(2*Math.sqrt(o*l)),B=Mn(Math.sqrt(o/l)),g=f*B,C={target:s,delta:s-r,velocity:h(n.velocity||0)||0,restSpeed:0,restDelta:0},v=()=>{const x=Math.abs(C.delta)<5;C.restSpeed=n.restSpeed||(x?Mt.restSpeed.granular:Mt.restSpeed.default),C.restDelta=n.restDelta||(x?Mt.restDelta.granular:Mt.restDelta.default)};v();let y,b,E;if(f<1){const x=sp(B,f),O={A:0,sinC:0,cosC:0,t:-1,env:0,sin:0,cos:0};E=()=>{O.A=(C.velocity+g*C.delta)/x,O.sinC=g*O.A+C.delta*x,O.cosC=g*C.delta-O.A*x};const R=P=>{P!==O.t&&(O.t=P,O.env=Math.exp(-g*P),O.sin=Math.sin(x*P),O.cos=Math.cos(x*P))};y=P=>(R(P),C.target-O.env*(O.A*O.sin+C.delta*O.cos)),b=P=>(R(P),O.env*(O.sinC*O.sin+O.cosC*O.cos))}else if(f===1){y=O=>C.target-Math.exp(-B*O)*(C.delta+(C.velocity+B*C.delta)*O);const x={C:0};E=()=>{x.C=C.velocity+B*C.delta},b=O=>Math.exp(-B*O)*(B*x.C*O-C.velocity)}else{const x=B*Math.sqrt(f*f-1),O=g-x,R=g+x,P=d?1/0:300/x,_=(q,W)=>Math.exp(W>P?-q*P-g*(W-P):-q*W),N={S:0,F:0};E=()=>{const q=(C.velocity+g*C.delta)/x;N.S=(C.delta+q)/2,N.F=(C.delta-q)/2},y=q=>C.target-N.S*_(O,q)-N.F*_(R,q),b=q=>O*N.S*_(O,q)+R*N.F*_(R,q)}E();const w=u&&c||null,A={calculatedDuration:w,retarget:(x,O)=>{C.target=x[x.length-1],C.delta=C.target-x[0],C.velocity=h(O),n.restSpeed&&n.restDelta||v(),A.calculatedDuration=w,i.done=!1,E()},velocity:x=>Dn(b(x)),next:x=>{const O=y(x);if(u)i.done=x>=c;else{const R=Dn(b(x));i.done=Math.abs(R)<=C.restSpeed&&Math.abs(C.target-O)<=C.restDelta}return i.value=i.done?C.target:O,i},toString:()=>{const x=Math.min(oC(A),iC),O=c1(R=>A.next(x*R).value,x,30);return x+"ms "+O},toTransition:()=>{}};return A}md.applyToOptions=e=>{const t=Mj(e,100,md);return e.ease=t.ease,e.duration=Dn(t.duration),e.type="keyframes",e};function op({keyframes:e,velocity:t=0,power:n=.8,timeConstant:r=325,bounceDamping:s=10,bounceStiffness:i=500,modifyTarget:o,min:a,max:l,restDelta:c=.5,restSpeed:u}){const d=e[0],h={done:!1,value:d},f=x=>x<a||x>l,B=x=>a===void 0?l:l===void 0||Math.abs(a-x)<Math.abs(l-x)?a:l;let g=n*t;const C=d+g,v=o===void 0?C:o(C);v!==C&&(g=v-d);const y=x=>-g*Math.exp(-x/r),b=x=>{const O=y(x);h.done=Math.abs(O)<=c,h.value=h.done?v:v+O};let E,w;const A=x=>{f(h.value)&&(E=x,w=md({keyframes:[h.value,B(h.value)],velocity:-y(x)/r*1e3,damping:s,stiffness:i,restDelta:c,restSpeed:u}))};return A(0),{calculatedDuration:null,next:x=>{let O=!1;return!w&&E===void 0&&(O=!0,b(x),A(x)),E!==void 0&&x>=E?w.next(x-E):(!O&&b(x),h)}}}function _j(e,t,n){const r=[],s=n||ds.mix||sC,i=e.length-1;for(let o=0;o<i;o++){let a=s(e[o],e[o+1]);if(t){const l=Array.isArray(t)?t[o]||nr:t;a=rc(l,a)}r.push(a)}return r}function Fj(e,t,{clamp:n=!0,ease:r,mixer:s}={}){const i=e.length;if(Mi(i===t.length,"Both input and output ranges must be the same length","range-length"),i===1)return()=>t[0];if(i===2&&t[0]===t[1])return()=>t[1];const o=e[0]===e[1];e[0]>e[i-1]&&(e=[...e].reverse(),t=[...t].reverse());const a=_j(t,r,s),l=a.length,c=u=>{if(o&&u<e[0])return t[0];let d=0;if(l>1)for(;d<e.length-2&&!(u<e[d+1]);d++);const h=Cl(e[d],e[d+1],u);return a[d](h)};return n?u=>c(ms(e[0],e[i-1],u)):c}function Hj(e,t){const n=e[e.length-1];for(let r=1;r<=t;r++){const s=Cl(0,t,r);e.push(Ue(n,1,s))}}function jj(e){const t=[0];return Hj(t,e.length-1),t}function Gj(e,t){return e.map(n=>n*t)}function Vj(e,t){return e.map(()=>t||Zg).splice(0,e.length-1)}function $a({duration:e=300,keyframes:t,times:n,ease:r="easeInOut"}){const s=ZH(r)?r.map(v0):v0(r)||Zg,i={done:!1,value:t[0]};if(t.length===2&&!Array.isArray(s)&&(!n||n.length!==2||n[0]===0&&n[1]===1)){const[l,c]=t,u=l===c?void 0:(ds.mix||sC)(l,c);return{calculatedDuration:e,next:d=>(i.value=u?u(s(e>0?ms(0,1,d/e):1)):c,i.done=d>=e,i)}}const o=Gj(n&&n.length===t.length?n:jj(t),e),a=Fj(o,t,{ease:Array.isArray(s)?s:Vj(t,s)});return{calculatedDuration:e,next:l=>(i.value=a(l),i.done=l>=e,i)}}var Uj=5;function zj(e,t,n){const r=Math.max(t-Uj,0);return UD(n-e(r),t-r)}function $j(e,t,n=0){return t<=0?n:e.velocity?e.velocity(t):zj(r=>e.next(r).value,t,e.next(t).value)}var Wj=e=>e!==null;function Bh(e,{repeat:t,repeatType:n="loop"},r,s=1){const i=e.filter(Wj),o=s<0||t&&n!=="loop"&&t%2===1?0:i.length-1;return!o||r===void 0?i[o]:r}var qj={decay:op,inertia:op,tween:$a,keyframes:$a,spring:md};function f1(e){typeof e.type=="string"&&(e.type=qj[e.type])}function B1(e,t){return{kind:e,animation:t,timestamp:Ht.now(),frameTimestamp:xt.timestamp,frameIsProcessing:xt.isProcessing}}function p1(e,t,n){const r=globalThis.__MOTION_INSPECT__;if(r)try{r({...B1("animation-start",e),options:n?{...t,...n}:t})}catch{}}function Kj(e,t){const n=globalThis.__MOTION_INSPECT__;if(n)try{n({...B1("layout-animation-start",e),node:t})}catch{}}var aC=class{constructor(){this.isResolved=!1}get finished(){return this._finished||(this._finished=this.isResolved?Promise.resolve():new Promise(e=>{this._resolve=e})),this._finished}updateFinished(){this._finished=this._resolve=void 0,this.isResolved=!1}notifyFinished(){this.isResolved=!0,this._resolve?.()}then(e,t){return this.finished.then(e,t)}},Jj=e=>e/100,gd=class extends aC{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=()=>{const{motionValue:t}=this.options;t&&t.updatedAt!==Ht.now()&&this.tick(Ht.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),this.options.onStop?.())},this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause(),p1(this,this.options)}initAnimation(){const{options:e}=this;f1(e);const{type:t=$a,repeat:n=0,repeatDelay:r=0,repeatType:s,velocity:i=0}=e;let{keyframes:o}=e;const a=t||$a;a!==$a&&typeof o[0]!="number"&&(this.mixKeyframes=rc(Jj,sC(o[0],o[1])),o=[0,100]);const l=a(o===e.keyframes?e:{...e,keyframes:o});s==="mirror"&&(this.mirroredGenerator=a({...e,keyframes:[...o].reverse(),velocity:-i})),l.calculatedDuration===null&&(l.calculatedDuration=oC(l));const{calculatedDuration:c}=l;this.calculatedDuration=c,this.resolvedDuration=c+r,this.totalDuration=this.resolvedDuration*(n+1)-r,this.generator=l}updateTime(e){const t=Math.round(e-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=t}tick(e,t=!1){const{generator:n,totalDuration:r,mixKeyframes:s,mirroredGenerator:i,resolvedDuration:o,calculatedDuration:a}=this;if(this.startTime===null)return n.next(0);const{delay:l=0,keyframes:c,repeat:u,repeatType:d,repeatDelay:h,type:f,onUpdate:B,finalKeyframe:g}=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);const C=this.currentTime-l*(this.playbackSpeed>=0?1:-1),v=this.playbackSpeed>=0?C<0:C>r;this.currentTime=Math.max(C,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=r);let y=this.currentTime,b=n;if(u){const x=Math.min(this.currentTime,r)/o;let O=Math.floor(x),R=x%1;!R&&x>=1&&(R=1),R===1&&O--,O=Math.min(O,u+1),O%2&&(d==="reverse"?(R=1-R,h&&(R-=h/o)):d==="mirror"&&(b=i)),y=ms(0,1,R)*o}let E;v?(this.delayState.value=c[0],E=this.delayState):E=b.next(y),s&&!v&&(E.value=s(E.value));let{done:w}=E;!v&&a!==null&&(w=this.playbackSpeed>=0?this.currentTime>=r:this.currentTime<=0);const A=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&w);return A&&f!==op&&(E.value=Bh(c,this.options,g,this.speed)),B&&B(E.value),A&&this.finish(),E}then(e,t){return this.finished.then(e,t)}get duration(){return Mn(this.calculatedDuration)}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+Mn(e)}get time(){return Mn(this.currentTime)}set time(e){e=Dn(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(){return $j(this.generator,this.currentTime,this.options.velocity)}get speed(){return this.playbackSpeed}set speed(e){const t=this.playbackSpeed!==e;t&&this.driver&&this.updateTime(Ht.now()),this.playbackSpeed=e,t&&this.driver&&(this.time=Mn(this.currentTime))}play(){if(this.isStopped)return;const{driver:e=Oj,startTime:t}=this.options;this.driver||(this.driver=e(r=>this.tick(r))),this.options.onPlay?.();const n=this.driver.now();this.state==="finished"?(this.updateFinished(),this.startTime=n):this.holdTime!==null?this.startTime=n-this.holdTime:this.startTime||(this.startTime=t??n),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(Ht.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(),this.driver=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)}},Qj=new Set(["brightness","contrast","saturate","opacity"]);function Yj(e){const[t,n]=e.slice(0,-1).split("(");if(t==="drop-shadow")return e;const[r]=n.match(tC)||[];if(!r)return e;const s=n.replace(r,"");let i=Qj.has(t)?1:0;return r!==n&&(i*=100),t+"("+i+s+")"}var Xj=/\b([a-z-]*)\(.*?\)/gu,ap={...Tn,getAnimatableNone:e=>{const t=e.match(Xj);return t?t.map(Yj).join(" "):e}},lp={...Tn,getAnimatableNone:e=>{const t=Tn.parse(e);return Tn.createTransformer(e)(t.map(n=>typeof n=="number"?0:typeof n=="object"?{...n,alpha:1}:n))}},T0={...ta,transform:Math.round},Zj={rotate:Vr,pathRotation:Vr,rotateX:Vr,rotateY:Vr,rotateZ:Vr,scale:Nc,scaleX:Nc,scaleY:Nc,scaleZ:Nc,skew:Vr,skewX:Vr,skewY:Vr,distance:fe,translateX:fe,translateY:fe,translateZ:fe,x:fe,y:fe,z:fe,perspective:fe,transformPerspective:fe,opacity:vl,originX:b0,originY:b0,originZ:fe},Cd={borderWidth:fe,borderTopWidth:fe,borderRightWidth:fe,borderBottomWidth:fe,borderLeftWidth:fe,borderRadius:fe,borderTopLeftRadius:fe,borderTopRightRadius:fe,borderBottomRightRadius:fe,borderBottomLeftRadius:fe,width:fe,maxWidth:fe,height:fe,maxHeight:fe,top:fe,right:fe,bottom:fe,left:fe,inset:fe,insetBlock:fe,insetBlockStart:fe,insetBlockEnd:fe,insetInline:fe,insetInlineStart:fe,insetInlineEnd:fe,padding:fe,paddingTop:fe,paddingRight:fe,paddingBottom:fe,paddingLeft:fe,paddingBlock:fe,paddingBlockStart:fe,paddingBlockEnd:fe,paddingInline:fe,paddingInlineStart:fe,paddingInlineEnd:fe,margin:fe,marginTop:fe,marginRight:fe,marginBottom:fe,marginLeft:fe,marginBlock:fe,marginBlockStart:fe,marginBlockEnd:fe,marginInline:fe,marginInlineStart:fe,marginInlineEnd:fe,fontSize:fe,backgroundPositionX:fe,backgroundPositionY:fe,...Zj,zIndex:T0,fillOpacity:vl,strokeOpacity:vl,numOctaves:T0},eG={...Cd,color:wt,backgroundColor:wt,outlineColor:wt,fill:wt,stroke:wt,borderColor:wt,borderTopColor:wt,borderRightColor:wt,borderBottomColor:wt,borderLeftColor:wt,filter:ap,WebkitFilter:ap,mask:lp,WebkitMask:lp},m1=e=>eG[e],tG=new Set([ap,lp]);function lC(e,t){let n=m1(e);return tG.has(n)||(n=Tn),n.getAnimatableNone?n.getAnimatableNone(t):void 0}function nG(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}var Ci=e=>e*180/Math.PI,cp=e=>{const t=Ci(Math.atan2(e[1],e[0]));return up(t)},rG={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:cp,rotateZ:cp,skewX:e=>Ci(Math.atan(e[1])),skewY:e=>Ci(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},up=e=>(e=e%360,e<0&&(e+=360),e),A0=cp,I0=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),k0=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),sG={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:I0,scaleY:k0,scale:e=>(I0(e)+k0(e))/2,rotateX:e=>up(Ci(Math.atan2(e[6],e[5]))),rotateY:e=>up(Ci(Math.atan2(-e[2],e[0]))),rotateZ:A0,rotate:A0,skewX:e=>Ci(Math.atan(e[4])),skewY:e=>Ci(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function bl(e){return e.includes("scale")?1:0}function dp(e,t){if(!e||e==="none")return bl(t);const n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let r,s;if(n)r=sG,s=n;else{const a=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);r=rG,s=a}if(!s)return bl(t);const i=r[t],o=s[1].split(",").map(oG);return typeof i=="function"?i(o):o[i]}var iG=(e,t)=>{const{transform:n="none"}=getComputedStyle(e);return dp(n,t)};function oG(e){return parseFloat(e.trim())}var na=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],Hs=new Set([...na,"pathRotation"]),R0=e=>e===ta||e===fe,aG=new Set(["x","y","z"]),lG=na.filter(e=>!aG.has(e));function cG(e){const t=[];return lG.forEach(n=>{const r=e.getValue(n);if(r!==void 0){const s=r.get(),i=n.startsWith("scale")?1:0;if(s===i)return;t.push([n,s]),r.set(i)}}),t}var uG=new Set(["bottom","right"]);function O0(e,t,n,r,s,i){const o=parseFloat(e);if(!isNaN(o))return o;const{min:a,max:l}=t()[n],c=l-a;return i==="border-box"?c:c-parseFloat(r)-parseFloat(s)}var bi={width:({width:e,paddingLeft:t="0",paddingRight:n="0",boxSizing:r},s)=>O0(e,s,"x",t,n,r),height:({height:e,paddingTop:t="0",paddingBottom:n="0",boxSizing:r},s)=>O0(e,s,"y",t,n,r),top:({top:e})=>parseFloat(e),left:({left:e})=>parseFloat(e),bottom:({top:e},t)=>{const{y:n}=t();return parseFloat(e)+(n.max-n.min)},right:({left:e},t)=>{const{x:n}=t();return parseFloat(e)+(n.max-n.min)},x:({transform:e})=>dp(e,"x"),y:({transform:e})=>dp(e,"y")};bi.translateX=bi.x;bi.translateY=bi.y;var Si=new Set,hp=!1,fp=!1,Bp=!1;function g1(){if(fp){const e=[],t=new Set,n=new Set;Si.forEach(s=>{s.needsMeasurement&&(e.push(s),t.add(s.element),uG.has(s.name)&&n.add(s.element))});const r=new Map;n.forEach(s=>{const i=cG(s);i.length&&(r.set(s,i),s.render())}),e.forEach(s=>s.measureInitialState()),t.forEach(s=>{s.render();const i=r.get(s);i&&i.forEach(([o,a])=>{s.getValue(o)?.set(a)})}),e.forEach(s=>s.measureEndState()),e.forEach(s=>{s.suspendedScrollY!==void 0&&window.scrollTo(0,s.suspendedScrollY)})}fp=!1,hp=!1,Si.forEach(e=>e.complete(Bp)),Si.clear()}function C1(){Si.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(fp=!0)})}function dG(){Bp=!0,C1(),g1(),Bp=!1}function hG(e,t,n){if(typeof e=="string"){if(Jg(e)||Qg(e))return parseFloat(e);if(!Tn.test(e)&&Tn.test(n))return lC(t,n)}return e??void 0}var cC=class{constructor(e,t,n,r,s,i=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=t,this.name=n,this.motionValue=r,this.element=s,this.isAsync=i}scheduleResolve(){this.state="scheduled",this.isAsync?(Si.add(this),hp||(hp=!0,qe.read(C1),qe.resolveKeyframes(g1))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:e,name:t,element:n,motionValue:r}=this;if(e[0]===null){const s=r?.get(),i=e[e.length-1];if(s!==void 0)e[0]=s;else if(n&&t){const o=hG(n.readValue(t,i),t,i);o!==void 0&&(e[0]=o)}e[0]===void 0&&(e[0]=i),r&&s===void 0&&r.set(e[0])}nG(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),Si.delete(this)}cancel(){this.state==="scheduled"&&(Si.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}},fG=e=>e.startsWith("--");function v1(e,t,n){fG(t)?e.style.setProperty(t,n):e.style[t]=n}var BG={};function y1(e,t){const n=VD(e);return()=>BG[t]??n()}var pG=y1(()=>window.ScrollTimeline!==void 0,"scrollTimeline"),b1=y1(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),Aa=([e,t,n,r])=>`cubic-bezier(${e}, ${t}, ${n}, ${r})`,M0={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:Aa([0,.65,.55,1]),circOut:Aa([.55,0,1,.45]),backIn:Aa([.31,.01,.66,-.59]),backOut:Aa([.33,1.53,.69,.99])};function S1(e,t){if(e)return typeof e=="function"?b1()?c1(e,t):"ease-out":XD(e)?Aa(e):Array.isArray(e)?e.map(n=>S1(n,t)||M0.easeOut):M0[e]}function mG(e,t,n,{delay:r=0,duration:s=300,repeat:i=0,repeatType:o="loop",ease:a="easeOut",times:l}={},c=void 0){const u={[t]:n};l&&(u.offset=l);const d=S1(a,s);Array.isArray(d)&&(u.easing=d);const h={delay:r,duration:s,easing:Array.isArray(d)?"linear":d,fill:"both",iterations:i+1,direction:o==="reverse"?"alternate":"normal"};return c&&(h.pseudoElement=c),e.animate(u,h)}function E1(e){return typeof e=="function"&&"applyToOptions"in e}function gG({type:e,...t}){return E1(e)&&b1()?e.applyToOptions(t):(t.duration??(t.duration=300),t.ease??(t.ease="easeOut"),t)}var x1=class extends aC{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!e)return;const{element:t,name:n,keyframes:r,pseudoElement:s,allowFlatten:i=!1,finalKeyframe:o,onComplete:a}=e;this.isPseudoElement=!!s,this.allowFlatten=i,this.options=e,Mi(typeof e.type!="string",`Mini animate() doesn't support "type" as a string.`,"mini-spring");const l=gG(e);this.animation=mG(t,n,r,l,s),l.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!s){const c=Bh(r,this.options,o,this.speed);this.updateMotionValue&&this.updateMotionValue(c),v1(t,n,c),this.animation.cancel()}a?.(),this.notifyFinished()},p1(this,e,l)}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;const{state:e}=this;e==="idle"||e==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){const e=this.options?.element;!this.isPseudoElement&&e?.isConnected&&this.animation.commitStyles?.()}get duration(){const e=this.animation.effect?.getComputedTiming?.().duration||0;return Mn(Number(e))}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+Mn(e)}get time(){return Mn(Number(this.animation.currentTime)||0)}set time(e){const t=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=Dn(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?"finished":this.animation.playState}get startTime(){return this.manualStartTime??Number(this.animation.startTime)}set startTime(e){this.manualStartTime=this.animation.startTime=e}attachTimeline({timeline:e,onAttach:t,observe:n,...r}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:"linear"}),this.animation.onfinish=null,e&&pG()?(this.animation.timeline=e,Object.assign(this.animation,r),t?.(this.animation),nr):n(this)}},w1={anticipate:JD,backInOut:KD,circInOut:YD};function CG(e){return e in w1}function vG(e){typeof e.ease=="string"&&CG(e.ease)&&(e.ease=w1[e.ease])}var Sf=10,yG=class extends x1{constructor(e){vG(e),f1(e),super(e),e.startTime!==void 0&&e.autoplay!==!1&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){const{motionValue:t,onUpdate:n,onComplete:r,element:s,...i}=this.options;if(!t)return;if(e!==void 0){t.set(e);return}const o=new gd({...i,autoplay:!1}),a=Math.max(Sf,Ht.now()-this.startTime),l=ms(0,Sf,a-Sf),c=o.sample(a).value,{name:u}=this.options;s&&u&&v1(s,u,c),t.setWithVelocity(o.sample(Math.max(0,a-l)).value,c,l),o.stop()}},N0=(e,t)=>t==="zIndex"?!1:!!(typeof e=="number"||Array.isArray(e)||typeof e=="string"&&(Tn.test(e)||e==="0")&&!e.startsWith("url("));function bG(e){const t=e[0];if(e.length===1)return!0;for(let n=0;n<e.length;n++)if(e[n]!==t)return!0}function SG(e,t,n,r){const s=e[0];if(s===null)return!1;if(t==="display"||t==="visibility")return!0;const i=e[e.length-1],o=N0(s,t),a=N0(i,t);return!o||!a?(o!==a&&fh(!1,`You are trying to animate ${t} from "${s}" to "${i}". "${o?i:s}" is not an animatable value.`,"value-not-animatable"),!1):bG(e)||(n==="spring"||E1(n))&&r}function pp(e){e.duration=0,e.type="keyframes"}var mp=new Set(["opacity","clipPath","filter","transform","backgroundColor"]),EG=/^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;function xG(e){for(let t=0;t<e.length;t++)if(typeof e[t]=="string"&&EG.test(e[t]))return!0;return!1}var P0=new Set(["color","backgroundColor","outlineColor","fill","stroke","borderColor","borderTopColor","borderRightColor","borderBottomColor","borderLeftColor"]),wG=VD(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function DG(e){const{motionValue:t,name:n,repeatDelay:r,repeatType:s,damping:i,type:o,keyframes:a}=e;if(!n||!(mp.has(n)||P0.has(n)))return!1;const l=t?.owner?.current;if(!(l instanceof HTMLElement)&&!(l instanceof SVGElement))return!1;const{onUpdate:c,transformTemplate:u}=t.owner.getProps();return wG()&&(mp.has(n)||P0.has(n)&&xG(a))&&(n!=="transform"||!u)&&!c&&!r&&s!=="mirror"&&i!==0&&o!=="inertia"}var TG=40,AG=class extends aC{constructor(e){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=Ht.now();const{keyframes:t,name:n,motionValue:r,element:s}=e,i=e;i.autoplay??(i.autoplay=!0),i.delay??(i.delay=0),i.type??(i.type="keyframes"),i.repeat??(i.repeat=0),i.repeatDelay??(i.repeatDelay=0),i.repeatType??(i.repeatType="loop");const o=s?.KeyframeResolver||cC;this.keyframeResolver=new o(t,(a,l,c)=>this.onKeyframesResolved(a,l,i,!c),n,r,s),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,t,n,r){this.keyframeResolver=void 0;const{name:s,type:i,velocity:o,delay:a,isHandoff:l,onUpdate:c}=n;this.resolvedAt=Ht.now();let u=!0;SG(e,s,i,o)||(u=!1,(ds.instantAnimations||!a)&&c?.(Bh(e,n,t)),e[0]=e[e.length-1],pp(n),n.repeat=0);const d=r?this.resolvedAt?this.resolvedAt-this.createdAt>TG?this.resolvedAt:this.createdAt:this.createdAt:void 0,{onComplete:h}=n;n.startTime??(n.startTime=d),n.finalKeyframe=t,n.keyframes=e,n.onComplete=()=>{h?.(),this.notifyFinished()};const f=u&&!l&&DG(n);let B;if(f){n.element=n.motionValue?.owner?.current;try{B=new yG(n)}catch{B=new gd(n)}}else B=new gd(n);this.pendingTimeline&&(this.stopTimeline=B.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=B}get finished(){return this._animation?this._animation.finished:super.finished}then(e,t){return this.finished.finally(e).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),dG()),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 D1(e,t,n,r=0,s=1){const i=Array.from(e).sort((l,c)=>l.sortNodePosition(c)).indexOf(t),o=e.size,a=(o-1)*r;return typeof n=="function"?n(i,o):s===1?i*r:a-i*r}var L0=30,IG=e=>!isNaN(parseFloat(e)),_0={current:void 0},kG=class{constructor(e,t={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=n=>{const r=Ht.now();if(this.updatedAt!==r&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(n),this.current!==this.prev&&(this.notifyChange(),this.dependents))for(const s of this.dependents)s.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=t.owner}setCurrent(e){this.current=e,this.updatedAt=Ht.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=IG(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return this.on("change",e)}on(e,t){var n;return e==="change"?this.onChangeSubscribe(t):((n=this.events)[e]||(n[e]=new Bd)).add(t)}onChangeSubscribe(e){const{events:t}=this;return!t.change&&!this.changeSubscriber?this.changeSubscriber=e:(t.change||(t.change=new Bd,t.change.add(this.changeSubscriber),this.changeSubscriber=void 0),t.change.add(e)),()=>{this.changeSubscriber===e?this.changeSubscriber=void 0:t.change?.remove(e),this.stopIfUnobserved()}}stopIfUnobserved(){qe.read(()=>{!this.changeSubscriber&&!this.events.change?.getSize()&&this.stop()})}clearListeners(){this.changeSubscriber=void 0;for(const 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.notifyChange()}notifyChange(){const{current:e,changeSubscriber:t}=this;t?t(e):this.events.change?.notify(e)}addDependent(e){this.dependents||(this.dependents=new Set),this.dependents.add(e)}removeDependent(e){this.dependents&&this.dependents.delete(e)}get(){return _0.current&&_0.current.push(this),this.current}getPrevious(){return this.prev}getVelocity(){const e=Ht.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>L0)return 0;const t=Math.min(this.updatedAt-this.prevUpdatedAt,L0);return UD(parseFloat(this.current)-parseFloat(this.prevFrameValue),t)}start(e){return this.stop(),new Promise(t=>{this.hasAnimated=!0;let n=!1,r;r=e(()=>{n=!0,this.events.animationComplete?.notify(),this.animation===r&&this.clearAnimation(),t()}),n||(this.animation=r),this.events.animationStart?.notify()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){this.animation=void 0}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}};function No(e,t){return new kG(e,t)}function T1(e,t){if(e?.inherit&&t){const{inherit:n,...r}=e;return{...t,...r}}return e}function uC(e,t){const n=e?.[t]??e?.default??e;return n!==e?T1(n,e):n}var RG={type:"spring",stiffness:500,damping:25,restSpeed:10},OG=e=>({type:"spring",stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),MG={type:"keyframes",duration:.8},NG={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},PG=(e,{keyframes:t})=>t.length>2?MG:Hs.has(e)?e.startsWith("scale")?OG(t[1]):RG:NG,LG=new Set(["when","delay","delayChildren","staggerChildren","staggerDirection","repeat","repeatType","repeatDelay","from","elapsed"]);function _G(e){for(const t in e)if(!LG.has(t))return!0;return!1}var dC=(e,t,n,r={},s,i)=>o=>{const a=uC(r,e)||{},l=a.delay||r.delay||0;let{elapsed:c=0}=r;c=c-Dn(l);const u={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:t.getVelocity(),...a,delay:-c,onUpdate:h=>{t.set(h),a.onUpdate&&a.onUpdate(h)},onComplete:()=>{o(),a.onComplete&&a.onComplete()},name:e,motionValue:t,element:i?void 0:s};_G(a)||Object.assign(u,PG(e,u)),u.duration&&(u.duration=Dn(u.duration)),u.repeatDelay&&(u.repeatDelay=Dn(u.repeatDelay)),u.from!==void 0&&(u.keyframes[0]=u.from);let d=!1;if((u.type===!1||u.duration===0&&!u.repeatDelay)&&(pp(u),u.delay===0&&(d=!0)),(ds.instantAnimations||ds.skipAnimations||s?.shouldSkipAnimations||a.skipAnimations)&&(d=!0,pp(u),u.delay=0),u.allowFlatten=!a.type&&!a.ease,d&&!i&&t.get()!==void 0){const h=Bh(u.keyframes,a);if(h!==void 0){qe.update(()=>{u.onUpdate(h),u.onComplete()});return}}return a.isSync?new gd(u):new AG(u)},FG=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function HG(e){const t=FG.exec(e);if(!t)return[,];const[,n,r,s]=t;return[`--${n??r}`,s]}var jG=4;function A1(e,t,n=1){Mi(n<=jG,`Max CSS variable fallback depth detected in property "${e}". This may indicate a circular fallback dependency.`,"max-css-var-depth");const[r,s]=HG(e);if(!r)return;const i=window.getComputedStyle(t).getPropertyValue(r);if(i){const o=i.trim();return Jg(o)?parseFloat(o):o}return eC(s)?A1(s,t,n+1):s}function GG(e){const t=[{},{}];return e?.values.forEach((n,r)=>{t[0][r]=n.get(),t[1][r]=n.getVelocity()}),t}function I1(e,t,n,r){const s=i=>typeof i=="function"?i(n!==void 0?n:e.custom,...GG(r)):i;return t=s(t),typeof t=="string"&&(t=e.variants&&e.variants[t]),s(t)}function Ei(e,t,n){return I1(e.getProps(),t,n,e)}var k1=(e,t)=>t==="exit"?e.presenceContext?.custom:void 0,R1=new Set(["width","height","top","left","right","bottom",...na]),VG=e=>Array.isArray(e);function UG(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,No(n))}function zG(e){return VG(e)?e[e.length-1]||0:e}function $G(e,t){let{transitionEnd:n={},transition:r={},...s}=Ei(e,t)||{};s={...s,...n};for(const i in s)UG(e,i,zG(s[i]))}var jt=e=>!!(e&&e.getVelocity);function WG(e){return!!(jt(e)&&e.add)}function gp(e,t){const n=e.getValue("willChange");if(WG(n))return n.add(t);if(!n&&ds.WillChange){const r=new ds.WillChange("auto");e.addValue("willChange",r),r.add(t)}}function hC(e){return e.replace(/([A-Z])/g,t=>`-${t.toLowerCase()}`)}var qG="framerAppearId",O1="data-"+hC(qG);function M1(e){return e.props[O1]}var KG=typeof window<"u";function JG({protectedKeys:e,needsAnimating:t},n){const r=n in e&&!t[n];return t[n]=!1,r}function N1(e,t,{delay:n=0,transitionOverride:r,type:s}={}){let{transition:i,transitionEnd:o,...a}=t;const l=e.getDefaultTransition();i=i?T1(i,l):l;const c=i?.reduceMotion,u=i?.skipAnimations;r&&(i=r);const d=[],h=s&&e.animationState?.getState()[s],f=i?.path;f&&f.animateVisualElement(e,a,i,n,d);for(const B in a){const g=e.getValue(B,e.latestValues[B]??null),C=a[B];if(C===void 0||h&&JG(h,B))continue;const v={delay:n,...uC(i||{},B)};u&&(v.skipAnimations=!0);const y=g.get();if(y!==void 0&&!g.isAnimating()&&!Array.isArray(C)&&C===y&&!v.velocity){qe.update(()=>g.set(C));continue}let b=!1;if(KG&&window.MotionHandoffAnimation){const A=M1(e);if(A){const x=window.MotionHandoffAnimation(A,B,qe);x!==null&&(v.startTime=x,b=!0)}}gp(e,B);const E=c??e.shouldReduceMotion;g.start(dC(B,g,C,E&&R1.has(B)?{type:!1}:v,e,b));const w=g.animation;w&&d.push(w)}if(o){const B=()=>qe.update(()=>{o&&$G(e,o)});d.length?Promise.all(d).then(B):B()}return d}function Cp(e,t,n={}){const r=Ei(e,t,k1(e,n.type)),s=n.transitionOverride||(r?.transition??(e.getDefaultTransition()||{})),i=()=>Promise.all(r?N1(e,r,n):[]),o=(l=0)=>{const{variantChildren:c}=e,{delayChildren:u=0,staggerChildren:d,staggerDirection:h}=s,f=[];return c?.forEach(B=>{B.notify("AnimationStart",t),f.push(Cp(B,t,{...n,delay:l+(typeof u=="function"?0:u)+D1(c,B,u,d,h)}).then(()=>B.notify("AnimationComplete",t)))}),Promise.all(f)},{when:a}=s;return a?a==="beforeChildren"?i().then(()=>o()):o().then(i):Promise.all([i(),o(n.delay)])}function QG(e,t,n={}){return e.notify("AnimationStart",t),(Array.isArray(t)?Promise.all(t.map(r=>Cp(e,r,n))):typeof t=="string"?Cp(e,t,n):Promise.all(N1(e,Ei(e,t,n.custom),n))).then(()=>{e.notify("AnimationComplete",t)})}var YG={test:e=>e==="auto",parse:e=>e},XG=e=>t=>t.test(e),ZG=[ta,fe,Nr,Vr,cj,lj,YG],F0=e=>ZG.find(XG(e));function eV(e){return typeof e=="number"?e===0:e!==null?e==="none"||e==="0"||Qg(e):!0}var tV=new Set(["auto","none","0"]);function nV(e,t,n){let r=0,s;for(;r<e.length&&!s;){const i=e[r];typeof i=="string"&&!tV.has(i)&&pj(i)&&(s=e[r]),r++}if(s&&n)for(const i of t)e[i]!==s&&(e[i]=lC(n,s))}var rV=class extends cC{constructor(e,t,n,r,s){super(e,t,n,r,s,!0)}readKeyframes(){const{unresolvedKeyframes:e,element:t,name:n}=this;if(!t||!t.current)return;super.readKeyframes();for(let a=0;a<e.length;a++){let l=e[a];if(typeof l=="string"&&(l=l.trim(),eC(l))){const c=A1(l,t.current);c!==void 0&&(e[a]=c),a===e.length-1&&(this.finalKeyframe=l)}}if(this.resolveNoneKeyframes(),!R1.has(n)||e.length!==2)return;const[r,s]=e;if(typeof r=="number"&&typeof s=="number")return;const i=F0(r),o=F0(s);if(y0(r)!==y0(s)&&bi[n]){this.needsMeasurement=!0;return}if(i!==o)if(R0(i)&&R0(o))for(let a=0;a<e.length;a++){const l=e[a];typeof l=="string"&&(e[a]=parseFloat(l))}else bi[n]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:e,name:t}=this,n=[];for(let r=0;r<e.length;r++)(e[r]===null||eV(e[r]))&&n.push(r);n.length&&nV(e,n,t)}measure(){const{element:e,name:t}=this;return bi[t](window.getComputedStyle(e.current),()=>e.measureViewportBox())}measureInitialState(){const{element:e,unresolvedKeyframes:t,name:n}=this;if(!e||!e.current)return;n==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=this.measure(),t[0]=this.measuredOrigin;const r=t[t.length-1];r!==void 0&&this.motionValue?.jump(r,!1)}measureEndState(){const{element:e,unresolvedKeyframes:t}=this;if(!e||!e.current)return;this.motionValue?.jump(this.measuredOrigin,!1);const n=t.length-1,r=t[n];t[n]=this.measure(),r!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=r),this.removedTransforms?.length&&this.removedTransforms.forEach(([s,i])=>{e.getValue(s).set(i)}),this.resolveNoneKeyframes()}},fC=["borderTopLeftRadius","borderTopRightRadius","borderBottomRightRadius","borderBottomLeftRadius"];function sV(e){return GD(e)&&"offsetHeight"in e&&!("ownerSVGElement"in e)}function BC(e){return GD(e)&&"ownerSVGElement"in e}var vp=(e,t)=>t&&typeof e=="number"?t.transform(e):e;function P1(e,t,n){if(e==null)return[];if(e instanceof EventTarget)return[e];if(typeof e=="string"){let r=document;t&&(r=t.current);const s=n?.[e]??r.querySelectorAll(e);return s?Array.from(s):[]}return Array.from(e).filter(r=>r!=null)}var iV={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},oV=na.length;function aV(e,t,n){let r="",s=!0;for(let o=0;o<oV;o++){const a=na[o],l=e[a];if(l===void 0)continue;let c=!0;if(typeof l=="number")c=l===(a.startsWith("scale")?1:0);else{const u=parseFloat(l);c=a.startsWith("scale")?u===1:u===0}if(!c||n){const u=vp(l,Cd[a]);if(!c){s=!1;const d=iV[a]||a;r+=`${d}(${u}) `}n&&(t[a]=u)}}const i=e.pathRotation;return i&&(s=!1,r+=`rotate(${vp(i,Cd.pathRotation)}) `),r=r.trim(),n?r=n(t,s?"":r):s&&(r="none"),r}function pC(e,t,n){const{style:r,vars:s,transformOrigin:i}=e;let o=!1,a=!1;for(const l in t){const c=t[l];if(Hs.has(l)){o=!0;continue}else if(e1(l)){s[l]=c;continue}else{const u=vp(c,Cd[l]);l.startsWith("origin")?(a=!0,i[l]=u):r[l]=u}}if(t.transform||(o||n?r.transform=aV(t,e.transform,n):r.transform&&(r.transform="none")),a){const{originX:l="50%",originY:c="50%",originZ:u=0}=i;r.transformOrigin=`${l} ${c} ${u}`}}var lV={offset:"stroke-dashoffset",array:"stroke-dasharray"},cV={offset:"strokeDashoffset",array:"strokeDasharray"};function uV(e,t,n=1,r=0,s=!0){e.pathLength=1;const i=s?lV:cV;e[i.offset]=`${-r}`,e[i.array]=`${t} ${n}`}var L1=["transform","opacity","offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function _1(e,{attrX:t,attrY:n,attrScale:r,pathLength:s,pathSpacing:i=1,pathOffset:o=0,...a},l,c,u){if(pC(e,a,c),l){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};const{attrs:d,style:h}=e;for(const f of L1)d[f]!==void 0&&(h[f]=d[f],delete d[f]);(h.transform||d.transformOrigin)&&(h.transformOrigin=d.transformOrigin??"50% 50%",delete d.transformOrigin),h.transform&&(h.transformBox=u?.transformBox??"fill-box",delete d.transformBox),t!==void 0&&(d.x=t),n!==void 0&&(d.y=n),r!==void 0&&(d.scale=r),s!==void 0&&uV(d,s,i,o,!1)}function F1({top:e,left:t,right:n,bottom:r}){return{x:{min:t,max:n},y:{min:e,max:r}}}function dV({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function hV(e,t){if(!t)return e;const 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 Ef(e){return e===void 0||e===1}function yp({scale:e,scaleX:t,scaleY:n}){return!Ef(e)||!Ef(t)||!Ef(n)}function di(e){return yp(e)||H1(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function H1(e){return H0(e.x)||H0(e.y)}function H0(e){return e&&e!=="0%"}function vd(e,t,n){return n+t*(e-n)}function j0(e,t,n,r,s){return s!==void 0&&(e=vd(e,s,r)),vd(e,n,r)+t}function bp(e,t=0,n=1,r,s){e.min=j0(e.min,t,n,r,s),e.max=j0(e.max,t,n,r,s)}function j1(e,{x:t,y:n}){bp(e.x,t.translate,t.scale,t.originPoint),bp(e.y,n.translate,n.scale,n.originPoint)}var G0=.999999999999,V0=1.0000000000001;function fV(e,t,n,r=!1){const s=n.length;if(!s)return;t.x=t.y=1;let i,o;for(let a=0;a<s;a++){i=n[a],o=i.projectionDelta;const{visualElement:l}=i.options;l&&l.props.style&&l.props.style.display==="contents"||(r&&i.options.layoutScroll&&i.scroll&&i!==i.root&&(wr(e.x,-i.scroll.offset.x),wr(e.y,-i.scroll.offset.y)),o&&(t.x*=o.x.scale,t.y*=o.y.scale,j1(e,o)),r&&di(i.latestValues)&&Du(e,i.latestValues,i.layout?.layoutBox))}t.x<V0&&t.x>G0&&(t.x=1),t.y<V0&&t.y>G0&&(t.y=1)}function wr(e,t){e.min+=t,e.max+=t}function U0(e,t,n,r,s=.5){bp(e,t,n,Ue(e.min,e.max,s),r)}function z0(e,t){return typeof e=="string"?parseFloat(e)/100*(t.max-t.min):e}function Du(e,t,n){const r=n??e;U0(e.x,z0(t.x,r.x),t.scaleX,t.scale,t.originX),U0(e.y,z0(t.y,r.y),t.scaleY,t.scale,t.originY)}function G1(e,t){return F1(hV(e.getBoundingClientRect(),t))}function BV(e,t,n){const r=G1(e,n),{scroll:s}=t;return s&&(wr(r.x,s.offset.x),wr(r.y,s.offset.y)),r}var{schedule:mC,cancel:ore}=l1(queueMicrotask,!1),Kn={x:!1,y:!1};function V1(){return Kn.x||Kn.y}function pV(e){return e==="x"||e==="y"?Kn[e]?null:(Kn[e]=!0,()=>{Kn[e]=!1}):Kn.x||Kn.y?null:(Kn.x=Kn.y=!0,()=>{Kn.x=Kn.y=!1})}function U1(e,t){const n=P1(e),r=new AbortController,s={passive:!0,...t,signal:r.signal};return[n,s,()=>r.abort()]}function mV(e){return!(e.pointerType==="touch"||V1())}function gV(e,t,n={}){const[r,s,i]=U1(e,n);return r.forEach(o=>{let a=!1,l=!1,c;const u=()=>{o.removeEventListener("pointerleave",B)},d=C=>{c&&(c(C),c=void 0),u()},h=C=>{a=!1,window.removeEventListener("pointerup",h),window.removeEventListener("pointercancel",h),l&&(l=!1,d(C))},f=()=>{a=!0,window.addEventListener("pointerup",h,s),window.addEventListener("pointercancel",h,s)},B=C=>{if(C.pointerType!=="touch"){if(a){l=!0;return}d(C)}},g=C=>{if(!mV(C))return;l=!1;const v=t(o,C);typeof v=="function"&&(c=v,o.addEventListener("pointerleave",B,s))};o.addEventListener("pointerenter",g,s),o.addEventListener("pointerdown",f,s)}),i}var z1=(e,t)=>t?e===t?!0:z1(e,t.parentElement):!1,gC=e=>e.pointerType==="mouse"?typeof e.button!="number"||e.button<=0:e.isPrimary!==!1,CV=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function vV(e){return CV.has(e.tagName)||e.isContentEditable===!0}var yV=new Set(["INPUT","SELECT","TEXTAREA"]);function bV(e){return yV.has(e.tagName)||e.isContentEditable===!0}var Tu=new WeakSet;function $0(e){return t=>{t.key==="Enter"&&e(t)}}function xf(e,t){e.dispatchEvent(new PointerEvent("pointer"+t,{isPrimary:!0,bubbles:!0}))}var SV=(e,t)=>{const n=e.currentTarget;if(!n)return;const r=$0(()=>{if(Tu.has(n))return;xf(n,"down");const s=$0(()=>{xf(n,"up")}),i=()=>xf(n,"cancel");n.addEventListener("keyup",s,t),n.addEventListener("blur",i,t)});n.addEventListener("keydown",r,t),n.addEventListener("blur",()=>n.removeEventListener("keydown",r),t)};function W0(e){return gC(e)&&!V1()}var q0=new WeakSet;function EV(e,t,n={}){const[r,s,i]=U1(e,n),o=a=>{const l=a.currentTarget;if(!W0(a)||q0.has(a))return;Tu.add(l),n.stopPropagation&&q0.add(a);const c=t(l,a),u={...s,capture:!0},d=(B,g)=>{window.removeEventListener("pointerup",h,u),window.removeEventListener("pointercancel",f,u),Tu.has(l)&&Tu.delete(l),W0(B)&&typeof c=="function"&&c(B,{success:g})},h=B=>{d(B,l===window||l===document||n.useGlobalTarget||z1(l,B.target))},f=B=>{d(B,!1)};window.addEventListener("pointerup",h,u),window.addEventListener("pointercancel",f,u)};return r.forEach(a=>{(n.useGlobalTarget?window:a).addEventListener("pointerdown",o,s),sV(a)&&(a.addEventListener("focus",l=>SV(l,s)),!vV(a)&&!a.hasAttribute("tabindex")&&(a.tabIndex=0))}),i}var Au=new WeakMap,Iu,$1=(e,t,n)=>(r,s)=>s&&s[0]?s[0][e+"Size"]:BC(r)&&"getBBox"in r?r.getBBox()[t]:r[n],xV=$1("inline","width","offsetWidth"),wV=$1("block","height","offsetHeight");function DV({target:e,borderBoxSize:t}){Au.get(e)?.forEach(n=>{n(e,{get width(){return xV(e,t)},get height(){return wV(e,t)}})})}function TV(e){e.forEach(DV)}function AV(){typeof ResizeObserver>"u"||(Iu=new ResizeObserver(TV))}function IV(e,t){Iu||AV();const n=P1(e);return n.forEach(r=>{let s=Au.get(r);s||(s=new Set,Au.set(r,s)),s.add(t),Iu?.observe(r)}),()=>{n.forEach(r=>{const s=Au.get(r);s?.delete(t),s?.size||Iu?.unobserve(r)})}}var ku=new Set,fo;function kV(){fo=()=>{const e={get width(){return window.innerWidth},get height(){return window.innerHeight}};ku.forEach(t=>t(e))},window.addEventListener("resize",fo)}function RV(e){return ku.add(e),fo||kV(),()=>{ku.delete(e),!ku.size&&typeof fo=="function"&&(window.removeEventListener("resize",fo),fo=void 0)}}function K0(e,t){return typeof e=="function"?RV(e):IV(e,t)}var to={value:null,addProjectionMetrics:null};function OV(e){return BC(e)&&e.tagName==="svg"}var J0=e=>typeof e=="number"?e:parseFloat(e),Q0=()=>({translate:0,scale:1,origin:0,originPoint:0}),Bo=()=>({x:Q0(),y:Q0()}),Y0=()=>({min:0,max:0}),Et=()=>({x:Y0(),y:Y0()}),MV=new WeakMap;function ph(e){return e!==null&&typeof e=="object"&&typeof e.start=="function"}function Sl(e){return typeof e=="string"||Array.isArray(e)}var CC=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],X0=["initial",...CC];function mh(e){if(ph(e.animate))return!0;for(let t=0;t<X0.length;t++)if(Sl(e[X0[t]]))return!0;return!1}function W1(e){return!!(mh(e)||e.variants)}function NV(e,t,n){for(const r in t){const s=t[r],i=n[r];if(jt(s))e.addValue(r,s);else if(jt(i))e.addValue(r,No(s,{owner:e}));else if(i!==s)if(e.hasValue(r)){const o=e.getValue(r);o.liveStyle===!0?o.jump(s):o.hasAnimated||o.set(s)}else{const o=e.getStaticValue(r);e.addValue(r,No(o!==void 0?o:s,{owner:e}))}}for(const r in n)t[r]===void 0&&e.removeValue(r);return t}var Z0=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"],yd={};function q1(e){yd=e}function PV(){return yd}var LV=class{scrapeMotionValuesFromProps(e,t,n){return{}}constructor({parent:e,props:t,presenceContext:n,reducedMotionConfig:r,skipAnimations:s,blockInitialAnimation:i,visualState:o},a={}){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=cC,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=()=>{const h=Ht.now();this.renderScheduledAt<h&&(this.renderScheduledAt=h,qe.render(this.render,!1,!0))};const{latestValues:l,renderState:c}=o;this.latestValues=l,this.baseTarget={...l},this.initialValues=t.initial?{...l}:{},this.renderState=c,this.parent=e,this.props=t,this.presenceContext=n,this.depth=e?e.depth+1:0,this.reducedMotionConfig=r,this.skipAnimationsConfig=s,this.options=a,this.blockInitialAnimation=!!i,this.isControllingVariants=mh(t),this.isVariantNode=W1(t),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);const{willChange:u,...d}=this.scrapeMotionValuesFromProps(t,{},this);for(const h in d){const f=d[h];l[h]!==void 0&&jt(f)&&f.set(l[h])}}mount(e){if(this.hasBeenMounted)for(const t in this.initialValues)this.values.get(t)?.jump(this.initialValues[t]),this.latestValues[t]=this.initialValues[t];if(this.current=e,MV.set(e,this),this.projection&&!this.projection.instance&&this.projection.mount(e),this.isVariantNode&&!this.isControllingVariants){let t=this;do t=t.props.inherit!==!1&&t.parent;while(t&&!t.isVariantNode);if(t){const{variantChildren:n}=t;n.add(this),this.removeFromVariantTree=()=>n.delete(this)}}this.values.forEach((t,n)=>this.bindToMotionValue(n,t)),this.reducedMotionConfig==="never"?this.shouldReduceMotion=!1:this.reducedMotionConfig==="always"?this.shouldReduceMotion=!0:(IN.current||kN(),this.shouldReduceMotion=TN.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(),Us(this.notifyUpdate),Us(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this);for(const e in this.events)this.events[e].clear();for(const e in this.features){const t=this.features[e];t&&(t.unmount(),t.isMounted=!1)}this.current=null}addChild(e){this.children.add(e),this.enteringChildren??(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&&mp.has(e)&&this.current instanceof HTMLElement){const{factory:i,keyframes:o,times:a,ease:l,duration:c}=t.accelerate,u=new x1({element:this.current,name:e,keyframes:o,times:a,ease:l,duration:Dn(c)}),d=i(u);this.valueSubscriptions.set(e,()=>{d(),u.cancel()});return}const n=Hs.has(e);n&&this.onBindTransform&&this.onBindTransform();const r=t.on("change",i=>{this.latestValues[e]=i,this.props.onUpdate&&qe.preRender(this.notifyUpdate),n&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let s;typeof window<"u"&&window.MotionCheckAppearSync&&(s=window.MotionCheckAppearSync(this,e,t)),this.valueSubscriptions.set(e,()=>{r(),s&&s()})}sortNodePosition(e){return!this.current||!e.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e="animation";for(e in yd){const t=yd[e];if(!t)continue;const{isEnabled:n,Feature:r}=t;if(!this.features[e]&&r&&n(this.props)&&(this.features[e]=new r(this)),this.features[e]){const s=this.features[e];s.isMounted?s.update():(s.mount(),s.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):Et()}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 n=0;n<Z0.length;n++){const r=Z0[n];this.propEventSubscriptions[r]&&(this.propEventSubscriptions[r](),delete this.propEventSubscriptions[r]);const s=e["on"+r];s&&(this.propEventSubscriptions[r]=this.on(r,s))}this.prevMotionValues=NV(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}addValue(e,t){const n=this.values.get(e);if(t!==n){n&&this.removeValue(e),this.bindToMotionValue(e,t),this.values.set(e,t);const r=t.get();r!==void 0&&(this.latestValues[e]=r)}}removeValue(e){this.values.delete(e);const 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=No(t??this.getDefaultValue?.(e),{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"&&(Jg(n)||Qg(n))?n=parseFloat(n):typeof n!="number"&&!Tn.test(n)&&Tn.test(t)&&(n=lC(e,t)),this.setBaseTarget(e,jt(n)?n.get():n)),jt(n)?n.get():n}setBaseTarget(e,t){this.baseTarget[e]=t}on(e,t){return this.events[e]||(this.events[e]=new Bd),this.events[e].add(t)}notify(e,...t){this.events[e]&&this.events[e].notify(...t)}scheduleRenderMicrotask(){mC.render(this.render)}},K1=class extends LV{constructor(){super(...arguments),this.KeyframeResolver=rV}sortInstanceNodePosition(e,t){return e.compareDocumentPosition(t)&2?1:-1}getBaseTargetFromProps(e,t){const 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);const{children:e}=this.props;jt(e)&&(this.childSubscription=e.on("change",t=>{this.current&&(this.current.textContent=`${t}`)}))}},Zs=class{constructor(e){this.isMounted=!1,this.node=e}update(){}};function J1(e,{style:t,vars:n},r,s){const i=e.style;let o;for(o in t)i[o]=t[o];s?.applyProjectionStyles(i,r);for(o in n)i.setProperty(o,n[o])}var El={};function Q1(e,{layout:t,layoutId:n}){return Hs.has(e)||e.startsWith("origin")||(t||n!==void 0)&&(!!El[e]||e==="opacity")}function vC(e,t,n){const r=e.style,s=t?.style,i={};if(!r)return i;for(const o in r)(jt(r[o])||s&&jt(s[o])||Q1(o,e)||n?.getValue(o)?.liveStyle!==void 0)&&(i[o]=r[o]);return i}function _V(e){return window.getComputedStyle(e)}var FV=class extends K1{constructor(){super(...arguments),this.type="html",this.renderInstance=J1}mount(e){Mi(!!e.style,"motion.create() components must forward their ref to a HTML or SVG element","custom-component-ref"),super.mount(e)}readValueFromInstance(e,t){if(Hs.has(t))return this.projection?.isProjecting?bl(t):iG(e,t);{const n=_V(e),r=(e1(t)?n.getPropertyValue(t):n[t])||0;return typeof r=="string"?r.trim():r}}measureInstanceViewportBox(e,{transformPagePoint:t}){return G1(e,t)}build(e,t,n){pC(e,t,n.transformTemplate)}scrapeMotionValuesFromProps(e,t,n){return vC(e,t,n)}},Y1=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"]),X1=e=>typeof e=="string"&&e.toLowerCase()==="svg";function HV(e,t,n,r){J1(e,t,void 0,r);for(const s in t.attrs)e.setAttribute(Y1.has(s)?s:hC(s),t.attrs[s])}function Z1(e,t,n){const r=vC(e,t,n);for(const s in e)if(jt(e[s])||jt(t[s])){const i=na.indexOf(s)!==-1?"attr"+s.charAt(0).toUpperCase()+s.substring(1):s;r[i]=e[s]}return r}var jV=class extends K1{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=Et}getBaseTargetFromProps(e,t){return Hs.has(t)?super.getBaseTargetFromProps(e,t)??bl(t):e[t]}getDefaultValue(e){return Hs.has(e)?this.latestValues[e]??bl(e):void 0}readValueFromInstance(e,t){if(Hs.has(t)){const n=m1(t);return n&&n.default||0}if(L1.includes(t)){const n=getComputedStyle(e)[t];if(typeof n=="string"&&n)return n.trim()}return t=Y1.has(t)?t:hC(t),e.getAttribute(t)}scrapeMotionValuesFromProps(e,t,n){return Z1(e,t,n)}build(e,t,n){_1(e,t,this.isSVGTag,n.transformTemplate,n.style)}renderInstance(e,t,n,r){HV(e,t,n,r)}mount(e){this.isSVGTag=X1(e.tagName),super.mount(e)}};function eT(e,t){if(!Array.isArray(t))return!1;const 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 GV=[...CC].reverse();function VV(e){let t=a=>Promise.all(a.map(({animation:l,options:c})=>QG(e,l,c))),n=ey(),r=!0,s=!1;function i(a){const{props:l,parent:c,manuallyAnimateOnMount:u}=e,d=r||s,h=[],f=new Set;let B={},g=1/0,C=e;do C=C.props.inherit!==!1&&C.parent;while(C&&!C.isControllingVariants);if(GV.forEach((y,b)=>{const E=n[y],w=l[y],A=C&&C.props[y],x=w!==void 0?w:Sl(A)||A===!1?A:void 0,O=Sl(x),R=y===a?E.isActive:null;R===!1&&(g=b);const P=O&&w===void 0&&!(d&&u);if(E.protectedKeys={...B},!E.isActive&&R===null||!x&&!E.prevProp||ph(x)||typeof x=="boolean")return;if(y==="exit"&&E.isActive&&R!==!0){B={...B,...E.prevResolvedValues};return}const _=UV(E.prevProp,x);let N=_||O&&(R&&!P||b>g),q=!1;const W=Array.isArray(x)?x:[x];let F={};if(R!==!1)for(const J of W){const{transition:Z,transitionEnd:Q,...G}=Ei(e,J,k1(e,y))||{};F={...F,...G,...Q}}const{prevResolvedValues:z}=E;for(const J in{...z,...F}){if(J in B)continue;const Z=F[J],Q=z[J],G=Array.isArray(Z)&&Array.isArray(Q)?!eT(Z,Q)||_:Z!==Q;if(G&&Z==null)f.add(J);else if(G||Z!==void 0&&f.has(J)){N=!0,f.delete(J)&&(q=!0),E.needsAnimating[J]=!0;const be=e.getValue(J);be&&(be.liveStyle=!1)}else E.protectedKeys[J]=!0}if(E.prevProp=x,E.prevResolvedValues=F,E.isActive&&(B={...B,...F}),N&&(!(P&&_)||q))for(const J of W){const Z={type:y};if(typeof J=="string"&&d&&u&&c?.enteringChildren){const Q=Ei(c,J)?.transition?.delayChildren;Z.delay=D1(c.enteringChildren,e,Q)}h.push({animation:J,options:Z})}}),f.size){const{initial:y}=l,b={},E=typeof y!="boolean"&&Ei(e,Array.isArray(y)?y[0]:y,e.presenceContext?.custom);E&&E.transition&&(b.transition=E.transition),f.forEach(w=>{const A=e.getValue(w);A&&(A.liveStyle=!0);const x=E&&!Array.isArray(y)?E[w]:void 0,O=e.getBaseTargetFromProps(l,w);b[w]=(x!==void 0?x:O!==void 0&&!jt(O)?O:e.initialValues[w]===void 0?e.baseTarget[w]:void 0)??null}),h.push({animation:b})}const v=d&&e.blockInitialAnimation||r&&!u&&(l.initial===!1||l.initial===l.animate);return r=s=!1,!v&&h.length?t(h):Promise.resolve()}function o(a,l){if(n[a].isActive===l)return Promise.resolve();e.variantChildren?.forEach(u=>u.animationState?.setActive(a,l)),n[a].isActive=l;const c=i(a);for(const u in n)n[u].protectedKeys={};return c}return{animateChanges:i,setActive:o,setAnimateFunction:a=>{t=a(e)},getState:()=>n,reset:()=>{n=ey(),s=!0}}}function UV(e,t){return typeof t=="string"?t!==e:Array.isArray(t)?!eT(t,e):!1}function ey(){const e={};for(const t of CC)e[t]={isActive:t==="animate",protectedKeys:{},needsAnimating:{},prevResolvedValues:{}};return e}function Sp(e,t){e.min=t.min,e.max=t.max}function zn(e,t){Sp(e.x,t.x),Sp(e.y,t.y)}function ty(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}var zV=.9999,$V=1.0001,WV=-.01,qV=.01;function en(e){return e.max-e.min}function KV(e,t,n){return Math.abs(e-t)<=n}function ny(e,t,n,r=.5){e.origin=r,e.originPoint=Ue(t.min,t.max,e.origin),e.scale=en(n)/en(t),e.translate=Ue(n.min,n.max,e.origin)-e.originPoint,(e.scale>=zV&&e.scale<=$V||isNaN(e.scale))&&(e.scale=1),(e.translate>=WV&&e.translate<=qV||isNaN(e.translate))&&(e.translate=0)}function Wa(e,t,n,r){ny(e.x,t.x,n.x,r?r.originX:void 0),ny(e.y,t.y,n.y,r?r.originY:void 0)}function ry(e,t,n,r=0){e.min=(r?Ue(n.min,n.max,r):n.min)+t.min,e.max=e.min+en(t)}function JV(e,t,n,r){ry(e.x,t.x,n.x,r?.x),ry(e.y,t.y,n.y,r?.y)}function sy(e,t,n,r=0){const s=r?Ue(n.min,n.max,r):n.min;e.min=t.min-s,e.max=e.min+en(t)}function bd(e,t,n,r){sy(e.x,t.x,n.x,r?.x),sy(e.y,t.y,n.y,r?.y)}function iy(e,t,n,r,s){return e-=t,e=vd(e,1/n,r),s!==void 0&&(e=vd(e,1/s,r)),e}function QV(e,t=0,n=1,r=.5,s,i=e,o=e){if(Nr.test(t)&&(t=parseFloat(t),t=Ue(o.min,o.max,t/100)-o.min),typeof t!="number")return;let a=Ue(i.min,i.max,r);e===i&&(a-=t),e.min=iy(e.min,t,n,a,s),e.max=iy(e.max,t,n,a,s)}function oy(e,t,[n,r,s],i,o){QV(e,t[n],t[r],t[s],t.scale,i,o)}var YV=["x","scaleX","originX"],XV=["y","scaleY","originY"];function ay(e,t,n,r){oy(e.x,t,YV,n?n.x:void 0,r?r.x:void 0),oy(e.y,t,XV,n?n.y:void 0,r?r.y:void 0)}function ly(e){return e.translate===0&&e.scale===1}function tT(e){return ly(e.x)&&ly(e.y)}function cy(e,t){return e.min===t.min&&e.max===t.max}function ZV(e,t){return cy(e.x,t.x)&&cy(e.y,t.y)}function uy(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function nT(e,t){return uy(e.x,t.x)&&uy(e.y,t.y)}function dy(e){return en(e.x)/en(e.y)}function hy(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}function Er(e){return[e("x"),e("y")]}function fy(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}var ha={correct:(e,t)=>{if(!t.target)return e;if(typeof e=="string")if(fe.test(e))e=parseFloat(e);else return e;return`${fy(e,t.target.x)}% ${fy(e,t.target.y)}%`}},eU={correct:(e,{treeScale:t,projectionDelta:n})=>{const r=e,s=Tn.parse(e);if(s.length>5)return r;const i=Tn.createTransformer(e),o=typeof s[0]!="number"?1:0,a=n.x.scale*t.x,l=n.y.scale*t.y;s[0+o]/=a,s[1+o]/=l;const c=Ue(a,l,.5);return typeof s[2+o]=="number"&&(s[2+o]/=c),typeof s[3+o]=="number"&&(s[3+o]/=c),i(s)}};function tU(e,t,n){let r="";const s=e.x.translate/t.x,i=e.y.translate/t.y,o=n?.z||0;if((s||i||o)&&(r=`translate3d(${s}px, ${i}px, ${o}px) `),(t.x!==1||t.y!==1)&&(r+=`scale(${1/t.x}, ${1/t.y}) `),n){const{transformPerspective:c,rotate:u,pathRotation:d,rotateX:h,rotateY:f,skewX:B,skewY:g}=n;c&&(r=`perspective(${c}px) ${r}`),u&&(r+=`rotate(${u}deg) `),d&&(r+=`rotate(${d}deg) `),h&&(r+=`rotateX(${h}deg) `),f&&(r+=`rotateY(${f}deg) `),B&&(r+=`skewX(${B}deg) `),g&&(r+=`skewY(${g}deg) `)}const a=e.x.scale*t.x,l=e.y.scale*t.y;return(a!==1||l!==1)&&(r+=`scale(${a}, ${l})`),r||"none"}var nU=fC.length,By=e=>typeof e=="number"||fe.test(e);function rU(e,t,n,r,s,i){s?(e.opacity=Ue(0,n.opacity??1,sU(r)),e.opacityExit=Ue(t.opacity??1,0,iU(r))):i&&(e.opacity=Ue(t.opacity??1,n.opacity??1,r));for(let o=0;o<nU;o++){const a=fC[o];let l=py(t,a),c=py(n,a);l===void 0&&c===void 0||(l||(l=0),c||(c=0),l===0||c===0||By(l)===By(c)?(e[a]=Math.max(Ue(J0(l),J0(c),r),0),(Nr.test(c)||Nr.test(l))&&(e[a]+="%")):e[a]=c)}(t.rotate||n.rotate)&&(e.rotate=Ue(t.rotate||0,n.rotate||0,r))}function py(e,t){return e[t]!==void 0?e[t]:e.borderRadius}var sU=rT(0,.5,QD),iU=rT(.5,.95,nr);function rT(e,t,n){return r=>r<e?0:r>t?1:n(Cl(e,t,r))}function oU(e,t,n){const r=jt(e)?e:No(e);return r.start(dC("",r,t,n)),r.animation}function xl(e,t,n,r={passive:!0}){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}var aU=(e,t)=>e.depth-t.depth,lU=class{constructor(){this.children=[],this.isDirty=!1}add(e){Kg(this.children,e),this.isDirty=!0}remove(e){fd(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(aU),this.isDirty=!1,this.children.forEach(e)}};function cU(e,t){const n=Ht.now(),r=({timestamp:s})=>{const i=s-n;i>=t&&(Us(r),e(i-t))};return qe.setup(r,!0),()=>Us(r)}function Ru(e){return jt(e)?e.get():e}var uU=class{constructor(){this.members=[]}add(e){Kg(this.members,e);for(let t=this.members.length-1;t>=0;t--){const n=this.members[t];if(n===e||n===this.lead||n===this.prevLead)continue;const r=n.instance;(!r||r.isConnected===!1)&&!n.snapshot&&(fd(this.members,n),n.unmount())}e.scheduleRender()}remove(e){if(fd(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){const t=this.members[this.members.length-1];t&&this.promote(t)}}relegate(e){for(let t=this.members.indexOf(e)-1;t>=0;t--){const n=this.members[t];if(n.isPresent!==!1&&n.instance?.isConnected!==!1)return this.promote(n),!0}return!1}promote(e,t){const n=this.lead;if(e!==n&&(this.prevLead=n,this.lead=e,e.show(),n)){n.updateSnapshot(),e.scheduleRender();const{layoutDependency:r}=n.options,{layoutDependency:s}=e.options;(r===void 0||r!==s)&&(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)}},dU={borderRadius:{...ha,applyTo:[...fC]},borderTopLeftRadius:ha,borderTopRightRadius:ha,borderBottomLeftRadius:ha,borderBottomRightRadius:ha,boxShadow:eU},Ou={hasAnimatedSinceResize:!0,hasEverUpdated:!1};Object.assign(El,{...dU,...El});var hi={nodes:0,calculatedTargetDeltas:0,calculatedProjections:0},wf=["","X","Y","Z"],hU=1e3,fU=0;function Df(e,t,n,r){const{latestValues:s}=t;s[e]&&(n[e]=s[e],t.setStaticValue(e,0),r&&(r[e]=0))}function sT(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;const{visualElement:t}=e.options;if(!t)return;const n=M1(t);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:s,layoutId:i}=e.options;window.MotionCancelOptimisedAnimation(n,"transform",qe,!(s||i))}const{parent:r}=e;r&&!r.hasCheckedOptimisedAppear&&sT(r)}function iT({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:r,resetTransform:s}){return class{constructor(o={},a=t?.()){this.id=fU++,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.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,to.value&&(hi.nodes=hi.calculatedTargetDeltas=hi.calculatedProjections=0),this.nodes.forEach(mU),this.nodes.forEach(EU),this.nodes.forEach(xU),this.nodes.forEach(gU),to.addProjectionMetrics&&to.addProjectionMetrics(hi)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=o,this.root=a?a.root||a:this,this.path=a?[...a.path,a]:[],this.parent=a,this.depth=a?a.depth+1:0;for(let l=0;l<this.path.length;l++)this.path[l].shouldResetTransform=!0;this.root===this&&(this.nodes=new lU)}addEventListener(o,a){return this.eventHandlers.has(o)||this.eventHandlers.set(o,new Bd),this.eventHandlers.get(o).add(a)}notifyListeners(o,...a){const l=this.eventHandlers.get(o);l&&l.notify(...a)}hasListeners(o){return this.eventHandlers.has(o)}mount(o){if(this.instance)return;this.isSVG=BC(o)&&!OV(o),this.instance=o;const{layoutId:a,layout:l,visualElement:c}=this.options;if(c&&!c.current&&c.mount(o),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(l||a)&&(this.isLayoutDirty=!0),e){let u,d=0;const h=()=>this.root.updateBlockedByResize=!1;qe.read(()=>{d=window.innerWidth}),e(o,()=>{const f=window.innerWidth;f!==d&&(d=f,this.root.updateBlockedByResize=!0,u&&u(),u=cU(h,250),Ou.hasAnimatedSinceResize&&(Ou.hasAnimatedSinceResize=!1,this.nodes.forEach(Cy)))})}a&&this.root.registerSharedNode(a,this),this.options.animate!==!1&&c&&(a||l)&&this.addEventListener("didUpdate",({delta:u,hasLayoutChanged:d,hasRelativeLayoutChanged:h,layout:f})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const B=this.options.transition||c.getDefaultTransition()||IU,{onLayoutAnimationStart:g,onLayoutAnimationComplete:C}=c.getProps(),v=!this.targetLayout||!nT(this.targetLayout,f),y=!d&&h;if(this.options.layoutRoot||this.resumeFrom||y||d&&(v||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const b={...uC(B,"layout"),onPlay:g,onComplete:C};(c.shouldReduceMotion||this.options.layoutRoot)&&(b.delay=0,b.type=!1),this.startAnimation(b),this.setAnimationOrigin(u,y,b.path)}else d||Cy(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=f})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const o=this.getStack();o&&o.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),Us(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(wU),this.animationId++)}getTransformTemplate(){const{visualElement:o}=this.options;return o&&o.getProps().transformTemplate}willUpdate(o=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&sT(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let u=0;u<this.path.length;u++){const d=this.path[u];d.shouldResetTransform=!0,(typeof d.latestValues.x=="string"||typeof d.latestValues.y=="string")&&(d.isLayoutDirty=!0),d.updateScroll("snapshot"),d.options.layoutRoot&&d.willUpdate(!1)}const{layoutId:a,layout:l}=this.options;if(a===void 0&&!l)return;const c=this.getTransformTemplate();this.prevTransformTemplateValue=c?c(this.latestValues,""):void 0,this.updateSnapshot(),o&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){const a=this.updateBlockedByResize;this.unblockUpdate(),this.updateBlockedByResize=!1,this.clearAllSnapshots(),a&&this.nodes.forEach(vU),this.nodes.forEach(my);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(gy);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(yU),this.nodes.forEach(bU),this.nodes.forEach(SU),this.nodes.forEach(BU),this.nodes.forEach(pU)):this.nodes.forEach(gy),this.clearAllSnapshots();const o=Ht.now();xt.delta=ms(0,1e3/60,o-xt.timestamp),xt.timestamp=o,xt.isProcessing=!0,yf.update.process(xt),yf.preRender.process(xt),yf.render.process(xt),xt.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,mC.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(CU),this.sharedNodes.forEach(DU)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,qe.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){qe.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!en(this.snapshot.measuredBox.x)&&!en(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 l=0;l<this.path.length;l++)this.path[l].updateScroll();const o=this.layout;this.layout=this.measure(!1),this.layoutCorrected||(this.layoutCorrected=Et()),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:a}=this.options;a&&a.notify("LayoutMeasure",this.layout.layoutBox,o?o.layoutBox:void 0)}updateScroll(o="measure"){let a=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===o&&(a=!1),a&&this.instance){const l=r(this.instance);this.scroll={animationId:this.root.animationId,phase:o,isRoot:l,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:l}}}resetTransform(){if(!s)return;const o=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,a=this.projectionDelta&&!tT(this.projectionDelta),l=this.getTransformTemplate(),c=l?l(this.latestValues,""):void 0,u=c!==this.prevTransformTemplateValue;o&&this.instance&&(a||di(this.latestValues)||u)&&(s(this.instance,c),this.shouldResetTransform=!1,this.scheduleRender())}measure(o=!0){const a=this.measurePageBox();let l=this.removeElementScroll(a);return o&&(l=this.removeTransform(l)),kU(l),{animationId:this.root.animationId,measuredBox:a,layoutBox:l,latestValues:{},source:this.id}}measurePageBox(){const{visualElement:o}=this.options;if(!o)return Et();const a=o.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(RU))){const{scroll:l}=this.root;l&&(wr(a.x,l.offset.x),wr(a.y,l.offset.y))}return a}removeElementScroll(o){const a=Et();if(zn(a,o),this.scroll?.wasRoot)return a;for(let l=0;l<this.path.length;l++){const c=this.path[l],{scroll:u,options:d}=c;c!==this.root&&u&&d.layoutScroll&&(u.wasRoot&&zn(a,o),wr(a.x,u.offset.x),wr(a.y,u.offset.y))}return a}applyTransform(o,a=!1,l){const c=l||Et();zn(c,o);for(let u=0;u<this.path.length;u++){const d=this.path[u];!a&&d.options.layoutScroll&&d.scroll&&d!==d.root&&(wr(c.x,-d.scroll.offset.x),wr(c.y,-d.scroll.offset.y)),di(d.latestValues)&&Du(c,d.latestValues,d.layout?.layoutBox)}return di(this.latestValues)&&Du(c,this.latestValues,this.layout?.layoutBox),c}removeTransform(o){const a=Et();zn(a,o);for(let l=0;l<this.path.length;l++){const c=this.path[l];if(!di(c.latestValues))continue;let u;c.instance&&(yp(c.latestValues)&&c.updateSnapshot(),u=Et(),zn(u,c.measurePageBox())),ay(a,c.latestValues,c.snapshot?.layoutBox,u)}return di(this.latestValues)&&ay(a,this.latestValues),a}setTargetDelta(o){this.targetDelta=o,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(o){this.options={...this.options,...o,crossfade:o.crossfade!==void 0?o.crossfade:!0}}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!==xt.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(o=!1){const a=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=a.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=a.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=a.isSharedProjectionDirty);const l=!!this.resumingFrom||this!==a;if(!(o||l&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:c,layoutId:u}=this.options;if(!this.layout||!(c||u))return;this.resolvedRelativeTargetAt=xt.timestamp;const d=this.getClosestProjectingParent();!this.targetDelta&&!this.relativeTarget&&(this.options.layoutAnchor!==!1&&d&&d.layout?this.createRelativeTarget(d,this.layout.layoutBox,d.layout.layoutBox):this.removeRelativeTarget()),!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=Et(),this.targetWithTransforms=Et()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),JV(this.target,this.relativeTarget,this.relativeParent.target,this.options.layoutAnchor||void 0)):this.targetDelta?(this.resumingFrom?this.applyTransform(this.layout.layoutBox,!1,this.target):zn(this.target,this.layout.layoutBox),j1(this.target,this.targetDelta)):zn(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget&&(this.attemptToResolveRelativeTarget=!1,this.options.layoutAnchor!==!1&&d&&!!d.resumingFrom==!!this.resumingFrom&&!d.options.layoutScroll&&d.target&&this.animationProgress!==1?this.createRelativeTarget(d,this.target,d.target):this.relativeParent=this.relativeTarget=void 0),to.value&&hi.calculatedTargetDeltas++)}getClosestProjectingParent(){if(!(!this.parent||yp(this.parent.latestValues)||H1(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}createRelativeTarget(o,a,l){this.relativeParent=o,this.forceRelativeParentToResolveTarget(),this.relativeTarget=Et(),this.relativeTargetOrigin=Et(),bd(this.relativeTargetOrigin,a,l,this.options.layoutAnchor||void 0),zn(this.relativeTarget,this.relativeTargetOrigin)}removeRelativeTarget(){this.relativeParent=this.relativeTarget=void 0}calcProjection(){const o=this.getLead(),a=!!this.resumingFrom||this!==o;let l=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(l=!1),a&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(l=!1),this.resolvedRelativeTargetAt===xt.timestamp&&(l=!1),l)return;const{layout:c,layoutId:u}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(c||u))return;zn(this.layoutCorrected,this.layout.layoutBox);const d=this.treeScale.x,h=this.treeScale.y;fV(this.layoutCorrected,this.treeScale,this.path,a),o.layout&&!o.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(o.target=o.layout.layoutBox,o.targetWithTransforms=Et());const{target:f}=o;if(!f){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(ty(this.prevProjectionDelta.x,this.projectionDelta.x),ty(this.prevProjectionDelta.y,this.projectionDelta.y)),Wa(this.projectionDelta,this.layoutCorrected,f,this.latestValues),(this.treeScale.x!==d||this.treeScale.y!==h||!hy(this.projectionDelta.x,this.prevProjectionDelta.x)||!hy(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",f)),to.value&&hi.calculatedProjections++}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(o=!0){if(this.options.visualElement?.scheduleRender(),o){const a=this.getStack();a&&a.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=Bo(),this.projectionDelta=Bo(),this.projectionDeltaWithTransform=Bo()}setAnimationOrigin(o,a=!1,l){const c=this.snapshot,u=c?c.latestValues:{},d={...this.latestValues},h=Bo();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!a;const f=Et(),B=(c?c.source:void 0)!==(this.layout?this.layout.source:void 0),g=this.getStack(),C=!g||g.members.length<=1,v=!!(B&&!C&&this.options.crossfade===!0&&!this.path.some(AU));this.animationProgress=0;let y;const b=l?.interpolateProjection(o);this.mixTargetDelta=E=>{const w=E/1e3,A=b?.(w);A?(h.x.translate=A.x,h.x.scale=Ue(o.x.scale,1,w),h.x.origin=o.x.origin,h.x.originPoint=o.x.originPoint,h.y.translate=A.y,h.y.scale=Ue(o.y.scale,1,w),h.y.origin=o.y.origin,h.y.originPoint=o.y.originPoint):(vy(h.x,o.x,w),vy(h.y,o.y,w)),this.setTargetDelta(h),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(bd(f,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),TU(this.relativeTarget,this.relativeTargetOrigin,f,w),y&&ZV(this.relativeTarget,y)&&(this.isProjectionDirty=!1),y||(y=Et()),zn(y,this.relativeTarget)),B&&(this.animationValues=d,rU(d,u,this.latestValues,w,v,C)),A&&A.rotate!==void 0&&(this.animationValues||(this.animationValues=d),this.animationValues.pathRotation=A.rotate),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=w},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(o){this.notifyListeners("animationStart"),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&(Us(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=qe.update(()=>{Ou.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=No(0)),this.motionValue.jump(0,!1),this.currentAnimation=oU(this.motionValue,[0,1e3],{...o,velocity:0,isSync:!0,onUpdate:a=>{this.mixTargetDelta(a),o.onUpdate&&o.onUpdate(a)},onComplete:()=>{o.onComplete&&o.onComplete(),this.completeAnimation()}}),Kj(this.currentAnimation,this),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const o=this.getStack();o&&o.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(hU),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const o=this.getLead(),{targetWithTransforms:a,layout:l,latestValues:c}=o;let{target:u}=o;if(!(!a||!u||!l)){if(this!==o&&this.layout&&l&&oT(this.options.animationType,this.layout.layoutBox,l.layoutBox)){u=this.target||Et();const d=en(this.layout.layoutBox.x);u.x.min=o.target.x.min,u.x.max=u.x.min+d;const h=en(this.layout.layoutBox.y);u.y.min=o.target.y.min,u.y.max=u.y.min+h}zn(a,u),Du(a,c),Wa(this.projectionDeltaWithTransform,this.layoutCorrected,a,c)}}registerSharedNode(o,a){this.sharedNodes.has(o)||this.sharedNodes.set(o,new uU),this.sharedNodes.get(o).add(a);const l=a.options.initialPromotionConfig;a.promote({transition:l?l.transition:void 0,preserveFollowOpacity:l&&l.shouldPreserveFollowOpacity?l.shouldPreserveFollowOpacity(a):void 0})}isLead(){const o=this.getStack();return o?o.lead===this:!0}getLead(){const{layoutId:o}=this.options;return o?this.getStack()?.lead||this:this}getPrevLead(){const{layoutId:o}=this.options;return o?this.getStack()?.prevLead:void 0}getStack(){const{layoutId:o}=this.options;if(o)return this.root.sharedNodes.get(o)}promote({needsReset:o,transition:a,preserveFollowOpacity:l}={}){const c=this.getStack();c&&c.promote(this,l),o&&(this.projectionDelta=void 0,this.needsReset=!0),a&&this.setOptions({transition:a})}relegate(){const o=this.getStack();return o?o.relegate(this):!1}resetSkewAndRotation(){const{visualElement:o}=this.options;if(!o)return;let a=!1;const{latestValues:l}=o;if((l.z||l.rotate||l.rotateX||l.rotateY||l.rotateZ||l.skewX||l.skewY)&&(a=!0),!a)return;const c={};l.z&&Df("z",o,c,this.animationValues);for(let u=0;u<wf.length;u++)Df(`rotate${wf[u]}`,o,c,this.animationValues),Df(`skew${wf[u]}`,o,c,this.animationValues);o.render();for(const u in c)o.setStaticValue(u,c[u]),this.animationValues&&(this.animationValues[u]=c[u]);o.scheduleRender()}applyProjectionStyles(o,a){if(!this.instance||this.isSVG)return;if(!this.isVisible){o.visibility="hidden";return}const l=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,o.visibility="",o.opacity="",o.pointerEvents=Ru(a?.pointerEvents)||"",o.transform=l?l(this.latestValues,""):"none";return}const c=this.getLead();if(!this.projectionDelta||!this.layout||!c.target){this.options.layoutId&&(o.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,o.pointerEvents=Ru(a?.pointerEvents)||""),this.hasProjected&&!di(this.latestValues)&&(o.transform=l?l({},""):"none",this.hasProjected=!1);return}o.visibility="";const u=c.animationValues||c.latestValues;this.applyTransformsToTarget();let d=tU(this.projectionDeltaWithTransform,this.treeScale,u);l&&(d=l(u,d)),o.transform=d;const{x:h,y:f}=this.projectionDelta;o.transformOrigin=`${h.origin*100}% ${f.origin*100}% 0`,c.animationValues?o.opacity=c===this?u.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:u.opacityExit:o.opacity=c===this?u.opacity!==void 0?u.opacity:"":u.opacityExit!==void 0?u.opacityExit:0;for(const B in El){if(u[B]===void 0)continue;const{correct:g,applyTo:C,isCSSVariable:v}=El[B],y=d==="none"?u[B]:g(u[B],c);if(C){const b=C.length;for(let E=0;E<b;E++)o[C[E]]=y}else v?this.options.visualElement.renderState.vars[B]=y:o[B]=y}this.options.layoutId&&(o.pointerEvents=c===this?Ru(a?.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(o=>o.currentAnimation?.stop()),this.root.nodes.forEach(my),this.root.sharedNodes.clear()}}}function BU(e){e.updateLayout()}function pU(e){const t=e.resumeFrom?.snapshot||e.snapshot;if(e.isLead()&&e.layout&&t&&e.hasListeners("didUpdate")){const{layoutBox:n,measuredBox:r}=e.layout,{animationType:s}=e.options,i=t.source!==e.layout.source;if(s==="size")Er(u=>{const d=i?t.measuredBox[u]:t.layoutBox[u],h=en(d);d.min=n[u].min,d.max=d.min+h});else if(s==="x"||s==="y"){const u=s==="x"?"y":"x";Sp(i?t.measuredBox[u]:t.layoutBox[u],n[u])}else oT(s,t.layoutBox,n)&&Er(u=>{const d=i?t.measuredBox[u]:t.layoutBox[u],h=en(n[u]);d.max=d.min+h,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[u].max=e.relativeTarget[u].min+h)});const o=Bo();Wa(o,n,t.layoutBox);const a=Bo();i?Wa(a,e.applyTransform(r,!0),t.measuredBox):Wa(a,n,t.layoutBox);const l=!tT(o);let c=!1;if(!e.resumeFrom){const u=e.getClosestProjectingParent();if(u&&!u.resumeFrom){const{snapshot:d,layout:h}=u;if(d&&h){const f=e.options.layoutAnchor||void 0,B=Et();bd(B,t.layoutBox,d.layoutBox,f);const g=Et();bd(g,n,h.layoutBox,f),nT(B,g)||(c=!0),u.options.layoutRoot&&(e.relativeTarget=g,e.relativeTargetOrigin=B,e.relativeParent=u)}}}e.notifyListeners("didUpdate",{layout:n,snapshot:t,delta:a,layoutDelta:o,hasLayoutChanged:l,hasRelativeLayoutChanged:c})}else if(e.isLead()){const{onExitComplete:n}=e.options;n&&n()}e.options.transition=void 0}function mU(e){to.value&&hi.nodes++,e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||(e.isSharedProjectionDirty=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty)),e.isTransformDirty||(e.isTransformDirty=e.parent.isTransformDirty))}function gU(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function CU(e){e.clearSnapshot()}function my(e){e.clearMeasurements()}function vU(e){e.isLayoutDirty=!0,e.updateLayout()}function gy(e){e.isLayoutDirty=!1}function yU(e){e.isAnimationBlocked&&e.layout&&!e.isLayoutDirty&&(e.snapshot=e.layout,e.isLayoutDirty=!0)}function bU(e){e.relativeTarget&&e.relativeParent?.isLayoutDirty&&(e.currentAnimation?e.isLayoutDirty=!0:(e.targetDelta=void 0,e.removeRelativeTarget()))}function SU(e){const{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify("BeforeLayoutMeasure"),e.resetTransform()}function Cy(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function EU(e){e.resolveTargetDelta()}function xU(e){e.calcProjection()}function wU(e){e.resetSkewAndRotation()}function DU(e){e.removeLeadSnapshot()}function vy(e,t,n){e.translate=Ue(t.translate,0,n),e.scale=Ue(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function yy(e,t,n,r){e.min=Ue(t.min,n.min,r),e.max=Ue(t.max,n.max,r)}function TU(e,t,n,r){yy(e.x,t.x,n.x,r),yy(e.y,t.y,n.y,r)}function AU(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}var IU={duration:.45,ease:[.4,0,.1,1]},by=e=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),Sy=by("applewebkit/")&&!by("chrome/")?Math.round:nr;function Ey(e){e.min=Sy(e.min),e.max=Sy(e.max)}function kU(e){Ey(e.x),Ey(e.y)}function oT(e,t,n){return e==="position"||e==="preserve-aspect"&&!KV(dy(t),dy(n),.2)}function RU(e){return e!==e.root&&e.scroll?.wasRoot}var OU=iT({attachResizeListener:(e,t)=>xl(e,"resize",t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body?.scrollLeft||0,y:document.documentElement.scrollTop||document.body?.scrollTop||0}),checkIsScrollRoot:()=>!0}),Tf={current:void 0},aT=iT({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!Tf.current){const e=new OU({});e.mount(window),e.setOptions({layoutScroll:!0}),Tf.current=e}return Tf.current},resetTransform:(e,t)=>{e.style.transform=t!==void 0?t:"none"},checkIsScrollRoot:e=>window.getComputedStyle(e).position==="fixed"}),lT=(0,p.createContext)({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});function MU(e=!0){const t=(0,p.useContext)(hh);if(t===null)return[!0,null];const{isPresent:n,onExitComplete:r,register:s}=t,i=(0,p.useId)();(0,p.useEffect)(()=>{if(e)return s(i)},[e]);const o=(0,p.useCallback)(()=>e&&r&&r(i),[i,r,e]);return!n&&r?[!1,o]:[!0]}function lre(){return NU((0,p.useContext)(hh))}function NU(e){return e===null?!0:e.isPresent}var cT=(0,p.createContext)({strict:!1}),xy={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"]},wy=!1;function PU(){if(wy)return;const e={};for(const t in xy)e[t]={isEnabled:n=>xy[t].some(r=>!!n[r])};q1(e),wy=!0}function uT(){return PU(),PV()}function LU(e){const t=uT();for(const n in e)t[n]={...t[n],...e[n]};q1(t)}var gh=(0,p.createContext)({});function _U(e,t){if(mh(e)){const{initial:n,animate:r}=e;return{initial:n===!1||Sl(n)?n:void 0,animate:Sl(r)?r:void 0}}return e.inherit!==!1?t:{}}function FU(e){const{initial:t,animate:n}=_U(e,(0,p.useContext)(gh));return(0,p.useMemo)(()=>({initial:t,animate:n}),[Dy(t),Dy(n)])}function Dy(e){return Array.isArray(e)?e.join(" "):e}var yC=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function dT(e,t,n){for(const r in t)!jt(t[r])&&!Q1(r,n)&&(e[r]=t[r])}function HU({transformTemplate:e},t){return(0,p.useMemo)(()=>{const n=yC();return pC(n,t,e),Object.assign({},n.vars,n.style)},[t])}function jU(e,t){const n=e.style||{},r={};return dT(r,n,e),Object.assign(r,HU(e,t)),r}function GU(e,t){const n={},r=jU(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 hT=()=>({...yC(),attrs:{}});function VU(e,t,n,r){const s=(0,p.useMemo)(()=>{const i=hT();return _1(i,t,X1(r),e.transformTemplate,e.style),{...i.attrs,style:{...i.style}}},[t]);if(e.style){const i={};dT(i,e.style,e),s.style={...i,...s.style}}return s}var UU=new Set(["animate","exit","variants","initial","style","values","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","propagate","ignoreStrict","viewport"]);function Sd(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||UU.has(e)}function zU(e,t){return e.startsWith("on")?!Sd(e):t?.(e)??!Sd(e)}function $U(e,t,n,r){const s={};for(const i in e)i==="values"&&typeof e.values=="object"||jt(e[i])||(zU(i,r)||n===!0&&Sd(i)||!t&&!Sd(i)||e.draggable&&i.startsWith("onDrag"))&&(s[i]=e[i]);return s}var WU=["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 bC(e){return typeof e!="string"||e.includes("-")?!1:!!(WU.indexOf(e)>-1||/[A-Z]/u.test(e))}function qU(e,t,n,{latestValues:r},s,i=!1,o,a){const l=(o??bC(e)?VU:GU)(t,r,s,e),c=$U(t,typeof e=="string",i,a),u=e!==p.Fragment?{...c,...l,ref:n}:{},{children:d}=t,h=(0,p.useMemo)(()=>jt(d)?d.get():d,[d]);return(0,p.createElement)(e,{...u,children:h})}function KU({scrapeMotionValuesFromProps:e,createRenderState:t},n,r,s){return{latestValues:JU(n,r,s,e),renderState:t()}}function JU(e,t,n,r){const s={},i=r(e,{});for(const h in i)s[h]=Ru(i[h]);let{initial:o,animate:a}=e;const l=mh(e),c=W1(e);t&&c&&!l&&e.inherit!==!1&&(o===void 0&&(o=t.initial),a===void 0&&(a=t.animate));let u=n?n.initial===!1:!1;u=u||o===!1;const d=u?a:o;if(d&&typeof d!="boolean"&&!ph(d)){const h=Array.isArray(d)?d:[d];for(let f=0;f<h.length;f++){const B=I1(e,h[f]);if(B){const{transitionEnd:g,transition:C,...v}=B;for(const y in v){let b=v[y];if(Array.isArray(b)){const E=u?b.length-1:0;b=b[E]}b!==null&&(s[y]=b)}for(const y in g)s[y]=g[y]}}}return s}var fT=e=>(t,n)=>{const r=(0,p.useContext)(gh),s=(0,p.useContext)(hh),i=()=>KU(e,t,r,s);return n?i():WH(i)},QU=fT({scrapeMotionValuesFromProps:vC,createRenderState:yC}),YU=fT({scrapeMotionValuesFromProps:Z1,createRenderState:hT}),XU=Symbol.for("motionComponentSymbol");function ZU(e,t,n){const r=(0,p.useRef)(n);(0,p.useInsertionEffect)(()=>{r.current=n});const s=(0,p.useRef)(null);return(0,p.useCallback)(i=>{i&&e.onMount?.(i),t&&(i?t.mount(i):t.unmount());const o=r.current;if(typeof o=="function")if(i){const a=o(i);typeof a=="function"&&(s.current=a)}else s.current?(s.current(),s.current=null):o(i);else o&&(o.current=i)},[t])}var BT=(0,p.createContext)({});function no(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function ez(e,t,n,r,s,i){const{visualElement:o}=(0,p.useContext)(gh),a=(0,p.useContext)(cT),l=(0,p.useContext)(hh),c=(0,p.useContext)(lT),u=c.reducedMotion,d=c.skipAnimations,h=(0,p.useRef)(null),f=(0,p.useRef)(!1);r=r||a.renderer,!h.current&&r&&(h.current=r(e,{visualState:t,parent:o,props:n,presenceContext:l,blockInitialAnimation:l?l.initial===!1:!1,reducedMotionConfig:u,skipAnimations:d,isSVG:i}),f.current&&h.current&&(h.current.manuallyAnimateOnMount=!0));const B=h.current,g=(0,p.useContext)(BT);B&&!B.projection&&s&&(B.type==="html"||B.type==="svg")&&tz(h.current,n,s,g);const C=(0,p.useRef)(!1);(0,p.useInsertionEffect)(()=>{B&&C.current&&B.update(n,l)});const v=n[O1],y=(0,p.useRef)(!!v&&typeof window<"u"&&!window.MotionHandoffIsComplete?.(v)&&window.MotionHasOptimisedAnimation?.(v));return g0(()=>{!f.current||!B||(B.animationState?.animateChanges(),B.enteringChildren=void 0)},[]),g0(()=>{f.current=!0,B&&(C.current=!0,window.MotionIsMounted=!0,B.updateFeatures(),B.scheduleRenderMicrotask(),y.current&&B.animationState&&B.animationState.animateChanges())}),(0,p.useEffect)(()=>{B&&(!y.current&&B.animationState&&B.animationState.animateChanges(),y.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(v)}),y.current=!1),B.enteringChildren=void 0)}),B}function tz(e,t,n,r){const{layoutId:s,layout:i,drag:o,dragConstraints:a,layoutScroll:l,layoutRoot:c,layoutAnchor:u,layoutCrossfade:d}=t;e.projection=new n(e.latestValues,t["data-framer-portal-id"]?void 0:pT(e.parent)),e.projection.setOptions({layoutId:s,layout:i,alwaysMeasureLayout:!!o||a&&no(a),visualElement:e,animationType:typeof i=="string"?i:"both",initialPromotionConfig:r,crossfade:d,layoutScroll:l,layoutRoot:c,layoutAnchor:u})}function pT(e){if(e)return e.options.allowProjection!==!1?e.projection:pT(e.parent)}function Af(e,{forwardMotionProps:t=!1,type:n}={},r,s){r&&LU(r);const i=n?n==="svg":bC(e),o=i?YU:QU;function a(c,u){let d;const h={...(0,p.useContext)(lT),...c,layoutId:nz(c)},{isStatic:f,isValidProp:B}=h,g=FU(c),C=o(c,f);if(!f&&typeof window<"u"){rz(h,r);const v=sz(h);d=v.MeasureLayout,g.visualElement=ez(e,C,h,s,v.ProjectionNode,i)}return(0,m.jsxs)(gh.Provider,{value:g,children:[d&&g.visualElement?(0,m.jsx)(d,{visualElement:g.visualElement,...h}):null,qU(e,c,ZU(C,g.visualElement,u),C,f,t,i,B)]})}a.displayName=`motion.${typeof e=="string"?e:`create(${e.displayName??e.name??""})`}`;const l=(0,p.forwardRef)(a);return l[XU]=e,l}function nz({layoutId:e}){const t=(0,p.useContext)(jD).id;return t&&e!==void 0?t+"-"+e:e}function rz(e,t){(0,p.useContext)(cT).strict}function sz(e){const{drag:t,layout:n}=uT();if(!t&&!n)return{};const r={...t,...n};return{MeasureLayout:t?.isEnabled(e)||n?.isEnabled(e)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}function iz(e,t){if(typeof Proxy>"u")return Af;const n=new Map,r=(i,o)=>Af(i,o,e,t),s=(i,o)=>r(i,o);return new Proxy(s,{get:(i,o)=>o==="create"?r:(n.has(o)||n.set(o,Af(o,void 0,e,t)),n.get(o))})}var oz=(e,t)=>t.isSVG??bC(e)?new jV(t):new FV(t,{allowProjection:e!==p.Fragment}),az=class extends Zs{constructor(e){super(e),e.animationState||(e.animationState=VV(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();ph(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:e}=this.node.getProps(),{animate:t}=this.node.prevProps||{};e!==t&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}},lz=0,cz=class extends Zs{constructor(){super(...arguments),this.id=lz++}update(){const{presenceContext:e,prevPresenceContext:t,animationState:n}=this.node;if(!e||!n)return;const{isPresent:r,onExitComplete:s}=e,i=t?.isPresent;if(r===i)return;if(r&&i===!1){if(this.exit===!0){const{initial:a}=this.node.getProps();if(a&&!Array.isArray(a)){const{transition:l,transitionEnd:c,...u}=Ei(this.node,a)||{};for(const d in u)this.node.getValue(d)?.jump(u[d])}this.node.blockInitialAnimation=!1,n.reset(),n.animateChanges()}else n.setActive("exit",!1);this.exit=void 0;return}const o=this.exit=n.setActive("exit",!r);s&&!r&&o.then(()=>{this.exit===o&&(this.exit=!0,s(this.id))})}mount(){const{register:e,onExitComplete:t}=this.node.presenceContext||{};t&&t(this.id),e&&(this.unmount=e(this.id))}unmount(){}},uz={animation:{Feature:az},exit:{Feature:cz}};function Ch(e){return{point:{x:e.pageX,y:e.pageY}}}var dz=e=>t=>gC(t)&&e(t,Ch(t));function qa(e,t,n,r){return xl(e,t,dz(n),r)}var mT=({current:e})=>e?e.ownerDocument.defaultView:null,Ty=(e,t)=>Math.abs(e-t);function hz(e,t){const n=Ty(e.x,t.x),r=Ty(e.y,t.y);return Math.sqrt(n**2+r**2)}var Ay=new Set(["auto","scroll"]),gT=class{constructor(e,t,{transformPagePoint:n,contextWindow:r=window,dragSnapToOrigin:s=!1,distanceThreshold:i=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=h=>{this.handleScroll(h.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.hasPendingMove=!1,this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=Lc(this.lastRawMoveEventInfo,this.transformPagePoint));const h=If(this.lastMoveEventInfo,this.history),f=this.startEvent!==null,B=hz(h.offset,{x:0,y:0})>=this.distanceThreshold;if(!f&&!B)return;const{point:g}=h;this.history.push({...g,timestamp:Ht.now()});const{onStart:C,onMove:v}=this.handlers;f||(C&&C(this.lastMoveEvent,h),this.startEvent=this.lastMoveEvent),v&&v(this.lastMoveEvent,h)},this.handlePointerMove=(h,f)=>{this.lastMoveEvent=h,this.lastRawMoveEventInfo=f,this.lastMoveEventInfo=Lc(f,this.transformPagePoint),this.hasPendingMove=!0,qe.update(this.updatePoint,!0)},this.handlePointerUp=(h,f)=>{this.hasPendingMove&&this.updatePoint(),this.end();const{onEnd:B,onSessionEnd:g,resumeAnimation:C}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&C&&C(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const v=If(h.type==="pointercancel"?this.lastMoveEventInfo:Lc(f,this.transformPagePoint),this.history);this.startEvent&&B&&B(h,v),g&&g(h,v)},!gC(e))return;this.dragSnapToOrigin=s,this.handlers=t,this.transformPagePoint=n,this.distanceThreshold=i,this.contextWindow=r||window;const a=Lc(Ch(e),this.transformPagePoint),{point:l}=a,{timestamp:c}=xt;this.history=[{...l,timestamp:c}];const{onSessionStart:u}=t;u&&u(e,If(a,this.history));const d={passive:!0,capture:!0};this.removeListeners=rc(qa(this.contextWindow,"pointermove",this.handlePointerMove,d),qa(this.contextWindow,"pointerup",this.handlePointerUp,d),qa(this.contextWindow,"pointercancel",this.handlePointerUp,d)),o&&this.startScrollTracking(o)}startScrollTracking(e){let t=e.parentElement;for(;t;){const n=getComputedStyle(t);(Ay.has(n.overflowX)||Ay.has(n.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){const t=this.scrollPositions.get(e);if(!t)return;const n=e===window,r=n?{x:window.scrollX,y:window.scrollY}:{x:e.scrollLeft,y:e.scrollTop},s={x:r.x-t.x,y:r.y-t.y};s.x===0&&s.y===0||(n?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=s.x,this.lastMoveEventInfo.point.y+=s.y):this.history.length>0&&(this.history[0].x-=s.x,this.history[0].y-=s.y),this.scrollPositions.set(e,r),qe.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),Us(this.updatePoint)}};function Lc(e,t){return t?{point:t(e.point)}:e}function Iy(e,t){return{x:e.x-t.x,y:e.y-t.y}}function If({point:e},t){return{point:e,delta:Iy(e,CT(t)),offset:Iy(e,fz(t)),velocity:Bz(t,.1)}}function fz(e){return e[0]}function CT(e){return e[e.length-1]}function Bz(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,r=null;const s=CT(e);for(;n>=0&&(r=e[n],!(s.timestamp-r.timestamp>Dn(t)));)n--;if(!r)return{x:0,y:0};r===e[0]&&e.length>2&&s.timestamp-r.timestamp>Dn(t)*2&&(r=e[1]);const i=Mn(s.timestamp-r.timestamp);if(i===0)return{x:0,y:0};const o={x:(s.x-r.x)/i,y:(s.y-r.y)/i};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}function pz(e,{min:t,max:n},r){return t!==void 0&&e<t?e=r?Ue(t,e,r.min):Math.max(e,t):n!==void 0&&e>n&&(e=r?Ue(n,e,r.max):Math.min(e,n)),e}function ky(e,t,n){return{min:t!==void 0?e.min+t:void 0,max:n!==void 0?e.max+n-(e.max-e.min):void 0}}function mz(e,{top:t,left:n,bottom:r,right:s}){return{x:ky(e.x,n,s),y:ky(e.y,t,r)}}function Ry(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 gz(e,t){return{x:Ry(e.x,t.x),y:Ry(e.y,t.y)}}function Cz(e,t){let n=.5;const r=en(e),s=en(t);return s>r?n=Cl(t.min,t.max-r,e.min):r>s&&(n=Cl(e.min,e.max-s,t.min)),ms(0,1,n)}function vz(e,t){const n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}var Ep=.35;function yz(e=Ep){return e===!1?e=0:e===!0&&(e=Ep),{x:Oy(e,"left","right"),y:Oy(e,"top","bottom")}}function Oy(e,t,n){return{min:My(e,t),max:My(e,n)}}function My(e,t){return typeof e=="number"?e:e[t]||0}var bz=new WeakMap,Sz=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=Et(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:t=!1,distanceThreshold:n}={}){const{presenceContext:r}=this.visualElement;if(r&&r.isPresent===!1)return;const s=u=>{t&&this.snapToCursor(u),this.stopAnimation()},i=(u,d)=>{const{drag:h,dragPropagation:f,onDragStart:B}=this.getProps();if(h&&!f&&(this.openDragLock&&this.openDragLock(),this.openDragLock=pV(h),!this.openDragLock))return;this.latestPointerEvent=u,this.latestPanInfo=d,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),Er(C=>{let v=this.getAxisMotionValue(C).get()||0;if(Nr.test(v)){const{projection:y}=this.visualElement;if(y&&y.layout){const b=y.layout.layoutBox[C];b&&(v=en(b)*(parseFloat(v)/100))}}this.originPoint[C]=v}),B&&qe.update(()=>B(u,d),!1,!0),gp(this.visualElement,"transform");const{animationState:g}=this.visualElement;g&&g.setActive("whileDrag",!0)},o=(u,d)=>{this.latestPointerEvent=u,this.latestPanInfo=d;const{dragPropagation:h,dragDirectionLock:f,onDirectionLock:B,onDrag:g}=this.getProps();if(!h&&!this.openDragLock)return;const{offset:C}=d;if(f&&this.currentDirection===null){this.currentDirection=xz(C),this.currentDirection!==null&&B&&B(this.currentDirection);return}this.updateAxis("x",d.point,C),this.updateAxis("y",d.point,C),this.visualElement.render(),g&&qe.update(()=>g(u,d),!1,!0)},a=(u,d)=>{this.latestPointerEvent=u,this.latestPanInfo=d,this.stop(u,d),this.latestPointerEvent=null,this.latestPanInfo=null},l=()=>{const{dragSnapToOrigin:u}=this.getProps();(u||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:c}=this.getProps();this.panSession=new gT(e,{onSessionStart:s,onStart:i,onMove:o,onSessionEnd:a,resumeAnimation:l},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:c,distanceThreshold:n,contextWindow:mT(this.visualElement),element:this.visualElement.current})}stop(e,t){const n=e||this.latestPointerEvent,r=t||this.latestPanInfo,s=this.isDragging;if(this.cancel(),!s||!r||!n)return;const{velocity:i}=r;this.startAnimation(i);const{onDragEnd:o}=this.getProps();o&&qe.postRender(()=>o(n,r))}cancel(){this.isDragging=!1;const{projection:e,animationState:t}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.endPanSession();const{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){const{drag:r}=this.getProps();if(!n||!_c(e,r,this.currentDirection))return;const s=this.getAxisMotionValue(e);let i=this.originPoint[e]+n[e];this.constraints&&this.constraints[e]&&(i=pz(i,this.constraints[e],this.elastic[e])),s.set(i)}resolveConstraints(){const{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&&no(e)?this.constraints||(this.constraints=this.resolveRefConstraints()):e&&n?this.constraints=mz(n.layoutBox,e):this.constraints=!1,this.elastic=yz(t),r!==this.constraints&&!no(e)&&n&&this.constraints&&!this.hasMutatedConstraints&&Er(s=>{this.constraints!==!1&&this.getAxisMotionValue(s)&&(this.constraints[s]=vz(n.layoutBox[s],this.constraints[s]))})}resolveRefConstraints(){const{dragConstraints:e,onMeasureDragConstraints:t}=this.getProps();if(!e||!no(e))return!1;const n=e.current;Mi(n!==null,"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.","drag-constraints-ref");const{projection:r}=this.visualElement;if(!r||!r.layout)return!1;r.root&&(r.root.scroll=void 0,r.root.updateScroll());const s=BV(n,r.root,this.visualElement.getTransformPagePoint());let i=gz(r.layout.layoutBox,s);if(t){const o=t(dV(i));this.hasMutatedConstraints=!!o,o&&(i=F1(o))}return i}startAnimation(e){const{drag:t,dragMomentum:n,dragElastic:r,dragTransition:s,dragSnapToOrigin:i,onDragTransitionEnd:o}=this.getProps(),a=this.constraints||{},l=Er(c=>{if(!_c(c,t,this.currentDirection))return;let u=a&&a[c]||{};(i===!0||i===c)&&(u={min:0,max:0});const d=r?200:1e6,h=r?40:1e7,f={type:"inertia",velocity:n?e[c]:0,bounceStiffness:d,bounceDamping:h,timeConstant:750,restDelta:1,restSpeed:10,...s,...u};return this.startAxisValueAnimation(c,f)});return Promise.all(l).then(o)}startAxisValueAnimation(e,t){const n=this.getAxisMotionValue(e);return gp(this.visualElement,e),n.start(dC(e,n,0,t,this.visualElement,!1))}stopAnimation(){Er(e=>this.getAxisMotionValue(e).stop())}getAxisMotionValue(e){const t=`_drag${e.toUpperCase()}`,n=this.visualElement.getProps()[t];return n||this.visualElement.getValue(e,this.visualElement.latestValues[e]??0)}snapToCursor({clientX:e,clientY:t}){const{drag:n}=this.getProps(),r={x:e,y:t},s=this.visualElement.getTransformPagePoint()?.(r)||r,i=this.visualElement.measureViewportBox();Er(o=>{if(!_c(o,n,this.currentDirection))return;const a=this.getAxisMotionValue(o),{min:l,max:c}=i[o];a.set((a.get()||0)+s[o]-Ue(l,c,.5))})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:e,dragConstraints:t}=this.getProps(),{projection:n}=this.visualElement;if(!no(t)||!n||!this.constraints)return;this.stopAnimation();const r=this.constraints,s={x:0,y:0};Er(o=>{const a=this.getAxisMotionValue(o).get();s[o]=Cz({min:a,max:a},r[o])});const{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(),Er(o=>{const a=this.getAxisMotionValue(o);if(!_c(o,e,null)||!a.get())return;const{min:l,max:c}=this.constraints[o];a.set(Ue(l,c,s[o]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;bz.set(this.visualElement,this);const e=this.visualElement.current,t=qa(e,"pointerdown",l=>{const{drag:c,dragListener:u=!0}=this.getProps(),d=l.target,h=d!==e&&bV(d);c&&u&&!h&&this.start(l)});let n;const r=()=>{const{dragConstraints:l}=this.getProps();no(l)&&l.current&&(this.constraints=this.resolveRefConstraints(),n||(n=Ez(e,l.current,()=>this.scalePositionWithinConstraints())))},{projection:s}=this.visualElement,i=s.addEventListener("measure",r);s&&!s.layout&&(s.root&&s.root.updateScroll(),s.updateLayout()),qe.read(r);const o=xl(window,"resize",()=>this.scalePositionWithinConstraints()),a=s.addEventListener("didUpdate",(({delta:l,hasLayoutChanged:c})=>{this.isDragging&&c&&(Er(u=>{const d=this.getAxisMotionValue(u);d&&(this.originPoint[u]+=l[u].translate,d.set(d.get()+l[u].translate))}),this.visualElement.render())}));return()=>{o(),t(),i(),a&&a(),n&&n()}}getProps(){const e=this.visualElement.getProps(),{drag:t=!1,dragDirectionLock:n=!1,dragPropagation:r=!1,dragConstraints:s=!1,dragElastic:i=Ep,dragMomentum:o=!0}=e;return{...e,drag:t,dragDirectionLock:n,dragPropagation:r,dragConstraints:s,dragElastic:i,dragMomentum:o}}};function Ny(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function Ez(e,t,n){const r=K0(e,Ny(n)),s=K0(t,Ny(n));return()=>{r(),s()}}function _c(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function xz(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}var wz=class extends Zs{constructor(e){super(e),this.removeGroupControls=nr,this.removeListeners=nr,this.controls=new Sz(e)}mount(){const{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||nr}update(){const{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()}},kf=e=>(t,n)=>{e&&qe.update(()=>e(t,n),!1,!0)},Dz=class extends Zs{constructor(){super(...arguments),this.removePointerDownListener=nr}onPointerDown(e){this.session=new gT(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:mT(this.node)})}createPanHandlers(){const{onPanSessionStart:e,onPanStart:t,onPan:n,onPanEnd:r}=this.node.getProps();return{onSessionStart:kf(e),onStart:kf(t),onMove:kf(n),onEnd:(s,i)=>{delete this.session,r&&qe.postRender(()=>r(s,i))}}}mount(){this.removePointerDownListener=qa(this.node.current,"pointerdown",e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}},Rf=!1,Tz=class extends p.Component{componentDidMount(){const{visualElement:e,layoutGroup:t,switchLayoutGroup:n,layoutId:r}=this.props,{projection:s}=e;s&&(t.group&&t.group.add(s),n&&n.register&&r&&n.register(s),Rf&&s.root.didUpdate(),s.addEventListener("animationComplete",()=>{this.safeToRemove()}),s.setOptions({...s.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),Ou.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){const{layoutDependency:t,visualElement:n,drag:r,isPresent:s}=this.props,{projection:i}=n;return i&&(i.isPresent=s,e.layoutDependency!==t&&i.setOptions({...i.options,layoutDependency:t}),Rf=!0,r||e.layoutDependency!==t||t===void 0||e.isPresent!==s?i.willUpdate():this.safeToRemove(),e.isPresent!==s&&(s?i.promote():i.relegate()||qe.postRender(()=>{const o=i.getStack();(!o||!o.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{visualElement:e,layoutAnchor:t}=this.props,{projection:n}=e;n&&(n.options.layoutAnchor=t,n.root.didUpdate(),mC.postRender(()=>{!n.currentAnimation&&n.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:e,layoutGroup:t,switchLayoutGroup:n}=this.props,{projection:r}=e;Rf=!0,r&&(r.scheduleCheckAfterUnmount(),t&&t.group&&t.group.remove(r),n&&n.deregister&&n.deregister(r))}safeToRemove(){const{safeToRemove:e}=this.props;e&&e()}render(){return null}};function vT(e){const[t,n]=MU(),r=(0,p.useContext)(jD);return(0,m.jsx)(Tz,{...e,layoutGroup:r,switchLayoutGroup:(0,p.useContext)(BT),isPresent:t,safeToRemove:n})}var Az={pan:{Feature:Dz},drag:{Feature:wz,ProjectionNode:aT,MeasureLayout:vT}};function Py(e,t,n){const{props:r}=e;e.animationState&&r.whileHover&&e.animationState.setActive("whileHover",n==="Start");const s=r["onHover"+n];s&&qe.postRender(()=>s(t,Ch(t)))}var Iz=class extends Zs{mount(){const{current:e}=this.node;e&&(this.unmount=gV(e,(t,n)=>(Py(this.node,n,"Start"),r=>Py(this.node,r,"End"))))}unmount(){}},kz=class extends Zs{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=rc(xl(this.node.current,"focus",()=>this.onFocus()),xl(this.node.current,"blur",()=>this.onBlur()))}unmount(){}};function Ly(e,t,n){const{props:r}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&r.whileTap&&e.animationState.setActive("whileTap",n==="Start");const s=r["onTap"+(n==="End"?"":n)];s&&qe.postRender(()=>s(t,Ch(t)))}var Rz=class extends Zs{mount(){const{current:e}=this.node;if(!e)return;const{globalTapTarget:t,propagate:n}=this.node.props;this.unmount=EV(e,(r,s)=>(Ly(this.node,s,"Start"),(i,{success:o})=>Ly(this.node,i,o?"End":"Cancel")),{useGlobalTarget:t,stopPropagation:n?.tap===!1})}unmount(){}},xp=new WeakMap,Of=new WeakMap,Oz=e=>{const t=xp.get(e.target);t&&t(e)},Mz=e=>{e.forEach(Oz)};function Nz({root:e,...t}){const n=e||document;Of.has(n)||Of.set(n,{});const r=Of.get(n),s=JSON.stringify(t);return r[s]||(r[s]=new IntersectionObserver(Mz,{root:e,...t})),r[s]}function Pz(e,t,n){const r=Nz(t);return xp.set(e,n),r.observe(e),()=>{xp.delete(e),r.unobserve(e)}}var Lz={some:0,all:1},_z=class extends Zs{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.stopObserver?.();const{viewport:e={}}=this.node.getProps(),{root:t,margin:n,amount:r="some",once:s}=e,i={root:t?t.current:void 0,rootMargin:n,threshold:typeof r=="number"?r:Lz[r]},o=a=>{const{isIntersecting:l}=a;if(this.isInView===l||(this.isInView=l,s&&!l&&this.hasEnteredView))return;l&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",l);const{onViewportEnter:c,onViewportLeave:u}=this.node.getProps(),d=l?c:u;d&&d(a)};this.stopObserver=Pz(this.node.current,i,o)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:e,prevProps:t}=this.node;["amount","margin","root"].some(Fz(e,t))&&this.startObserver()}unmount(){this.stopObserver?.(),this.hasEnteredView=!1,this.isInView=!1}};function Fz({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}var Hz={inView:{Feature:_z},tap:{Feature:Rz},focus:{Feature:kz},hover:{Feature:Iz}},jz={layout:{ProjectionNode:aT,MeasureLayout:vT}},Gz={...uz,...Hz,...Az,...jz},yT=iz(Gz,oz);function Vz(){return document.activeElement?.closest('[role="dialog"],[role="alertdialog"]')??document.body}async function ra(e){try{return await navigator.clipboard.writeText(e),!0}catch{const t=document.createElement("textarea");try{return t.value=e,t.style.position="fixed",t.style.opacity="0",Vz().appendChild(t),t.select(),t.selectionStart!==0||t.selectionEnd!==t.value.length?(console.warn("Clipboard copy failed: fallback selection did not take, nothing was copied"),!1):document.execCommand("copy")?(console.warn("Clipboard API unavailable, used deprecated execCommand fallback"),!0):(console.warn("Clipboard copy failed: execCommand fallback reported failure"),!1)}catch{return console.warn("Clipboard copy failed: both modern and fallback methods failed"),!1}finally{t.remove()}}}var Uz="Project connection defaults are still syncing. Try again in a moment.",cre="Finishing setup.",zz=1e4,$z={hover:!0,touch:!1},Wz={top:0,right:0,bottom:0,left:0},bT=["inline","pip","fullscreen"];function ST(){return{headers:{},requestTimeout:zz}}function ure(){return{version:1,connectionDefaults:ST(),clientCapabilities:Kd()}}function dre(e){return{theme:e.theme,displayMode:e.displayMode,availableDisplayModes:bT,locale:e.locale,timeZone:e.timeZone,deviceCapabilities:e.deviceCapabilities,safeAreaInsets:e.safeAreaInsets}}function hre(e){if(!e||typeof e!="object")return!1;const t=e;return t.version===1&&(t.connectionDefaults===void 0||wT(t.connectionDefaults))&&Po(t.clientCapabilities)&&Po(t.hostContext)}function qz(e,t=Kd()){return Po(e)?e:t}function Kz(e,t={}){return Po(e)?e:t}function fre(e){return{version:1,connectionDefaults:ET(e?.connectionDefaults),clientCapabilities:qz(e?.clientCapabilities)}}function Bre(e,t={}){return Kz(e?.hostContext,t)}function ET(e,t=ST()){return wT(e)?{headers:DT(e.headers),requestTimeout:e5(e.requestTimeout,t.requestTimeout)}:t}function pre(e){return ET(e?.connectionDefaults)}function mre(e,t){return{...DT(e),...Zz(t)}}function gre(e){return Jz(e?.clientCapabilities??Kd())}function Jz(e){return ZM(e)}function Qz(e){const t=e?.availableDisplayModes;if(!Array.isArray(t))return bT;const n=t.filter(xT);return n.length>0?n:["inline"]}function Yz(e){const t=e?.displayMode;return xT(t)?t:void 0}function Cre(e){return Xz(Yz(e),Qz(e))}function vre(e){const t=e?.theme;return t==="light"||t==="dark"?t:void 0}function yre(e,t="en-US"){return typeof e?.locale=="string"?e.locale:t}function bre(e,t="UTC"){return typeof e?.timeZone=="string"?e.timeZone:t}function Sre(e,t=$z){const n=e?.deviceCapabilities;if(!n||typeof n!="object"||Array.isArray(n))return t;const r=n;return{hover:r.hover??t.hover,touch:r.touch??t.touch}}function Ere(e,t=Wz){const n=e?.safeAreaInsets;if(!n||typeof n!="object"||Array.isArray(n))return t;const r=n;return{top:r.top??t.top,right:r.right??t.right,bottom:r.bottom??t.bottom,left:r.left??t.left}}function Xz(e,t){return e&&t.includes(e)?e:t[0]??"inline"}function xT(e){return e==="inline"||e==="pip"||e==="fullscreen"}function wT(e){return!Po(e)||e.headers!==void 0&&!Po(e.headers)?!1:e.requestTimeout===void 0||typeof e.requestTimeout=="number"&&Number.isFinite(e.requestTimeout)}function DT(e){return e?Object.fromEntries(Object.entries(e).filter(([t,n])=>t.trim()!==""&&t.toLowerCase()!=="authorization"&&typeof n=="string")):{}}function Zz(e){return e?Object.fromEntries(Object.entries(e).filter(([t,n])=>t.trim()!==""&&typeof n=="string")):{}}function e5(e,t){return typeof e!="number"||!Number.isFinite(e)||e<=0?t:e}function Po(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var t5=class extends Error{reason;constructor(e,t){super(t?`App is still bootstrapping (${e}): ${t}`:`App is still bootstrapping (${e}). Wait for useAppReady() to resolve before initiating requests.`),this.name="BootstrapNotReadyError",this.reason=e}},wp="mcpjam:task-bookmarks-changed";function n5(){typeof window<"u"&&window.dispatchEvent(new Event(wp))}function xre(e){return window.addEventListener(wp,e),window.addEventListener("storage",e),()=>{window.removeEventListener(wp,e),window.removeEventListener("storage",e)}}var r5=2e3,s5=6048e5;function wre(e){return e!=="working"&&e!=="input_required"}function Dre(e,t){return Math.max(e,r5,t??0)}function i5(e,t){return e&&t?JSON.stringify(["owned-task-v1",e,t]):void 0}var vh,wl;function o5(e){vh=e??void 0}function a5(){return vh}function l5(e,t){wl=i5(e,t)}function SC(){return wl}function Lo(e){return e.connectionId!==void 0||e.sourceExecutionId!==void 0}function oc(e){return{...e,scope:e.scope??(Lo(e)?wl:vh)}}function TT(e){return Lo(e)?wl!==void 0&&e.scope===wl:e.scope===vh}function Dp(e,t){const n=`${t?.scope??(t?.connectionId!==void 0?SC():a5())??""}\0${e}`;return t?.wire!==void 0||t?.connectionId!==void 0?`${n}\0${t.wire??""}\0${t.connectionId??""}`:n}function sa(e,t){return e.connectionId===t?.connectionId&&(t?.scope===void 0||e.scope===t.scope)&&(t?.wire===void 0||e.wire===t.wire)}var AT="mcp-tracked-tasks",IT="mcp-tracked-tasks-v4",Mu=4,c5=50,_o=1024,kT=100,u5=524288;function _n(e){return ui(e)}function d5(e,t){const n=Date.parse(e.createdAt);return Number.isNaN(n)?!0:t-n<s5}function $n(e){if(typeof e=="string")return e.length>_o?e.slice(0,_o):e}function Yn(e){if(typeof e=="string")return e.length>_o||e.includes("\0")?void 0:e}function si(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function _y(e){if(typeof e!="object"||e===null||Array.isArray(e))return;const t=e,n=Yn(t.taskId),r=Yn(t.serverId),s=$n(t.createdAt);if(!n||!r)return;const i=Yn(t.connectionId),o=Yn(t.sourceExecutionId);if(t.connectionId!==void 0&&!i||t.sourceExecutionId!==void 0&&!o)return;const a=Yn(t.scope);if(t.scope!==void 0&&a===void 0||!s||Number.isNaN(Date.parse(s)))return;const l=t.wire==="extension"||t.wire==="legacy"?t.wire:"legacy",c=t.ttlMs===null?null:si(t.ttlMs),u=Array.isArray(t.respondedInputKeys)?t.respondedInputKeys.filter(d=>typeof d=="string").slice(0,kT).map(d=>d.slice(0,_o)):void 0;return{taskId:n,serverId:r,wire:l,createdAt:s,...$n(t.toolName)?{toolName:$n(t.toolName)}:{},...t.primitiveType==="tool"||t.primitiveType==="prompt"||t.primitiveType==="resource"?{primitiveType:t.primitiveType}:{},...$n(t.primitiveName)?{primitiveName:$n(t.primitiveName)}:{},...t.dismissed===!0?{dismissed:!0}:{},...t.expired===!0?{expired:!0}:{},...a!==void 0?{scope:a}:{},...i!==void 0?{connectionId:i}:{},...o!==void 0?{sourceExecutionId:o}:{},...$n(t.serverName)?{serverName:$n(t.serverName)}:{},...$n(t.lastUpdatedAt)?{lastUpdatedAt:$n(t.lastUpdatedAt)}:{},...$n(t.status)?{status:$n(t.status)}:{},...c!==void 0?{ttlMs:c}:{},...si(t.pollIntervalMs)!==void 0?{pollIntervalMs:si(t.pollIntervalMs)}:{},...si(t.nextPollAt)!==void 0?{nextPollAt:si(t.nextPollAt)}:{},...si(t.lastObservedAt)!==void 0?{lastObservedAt:si(t.lastObservedAt)}:{},...u?.length?{respondedInputKeys:u}:{}}}function h5(e){if(Array.isArray(e))return e.map(_y).filter(n=>n!==void 0);if(typeof e!="object"||e===null)return[];const t=e;return typeof t.version=="number"&&t.version>Mu?[]:Array.isArray(t.tasks)?t.tasks.map(_y).filter(n=>n!==void 0):[]}function Fy(e){try{const t=localStorage.getItem(e);return t?h5(JSON.parse(t)).filter(n=>d5(n,Date.now())):[]}catch{return[]}}function yh(){const e=Fy(AT).filter(n=>!Lo(n)),t=Fy(IT);return[...new Map([...e,...t].map(n=>[_n(n),n])).values()]}function dr(){return yh().filter(TT)}function ac(e){EC([...e,...yh().filter(t=>!TT(t))])}function EC(e){try{let t=e,n=JSON.stringify({version:Mu,tasks:t});for(;n.length>u5&&t.length>1;)t=t.slice(0,Math.floor(t.length/2)),n=JSON.stringify({version:Mu,tasks:t});localStorage.setItem(AT,JSON.stringify({version:3,tasks:t.filter(r=>!Lo(r))})),localStorage.setItem(IT,JSON.stringify({version:Mu,tasks:t.filter(Lo)})),n5()}catch{}}function Tre(){return dr()}function Are(e,t,n,r){return dr().filter(s=>s.serverId===e&&!s.dismissed&&sa(s,{wire:t,connectionId:n,scope:r}))}function Ire(e,t,n){return dr().find(r=>r.taskId===e&&(t===void 0||r.serverId===t)&&sa(r,n))}function kre(e){const t=oc(e);if(Lo(t)&&t.scope===void 0||Yn(t.taskId)===void 0||Yn(t.serverId)===void 0||t.scope!==void 0&&Yn(t.scope)===void 0||t.connectionId!==void 0&&!Yn(t.connectionId)||t.sourceExecutionId!==void 0&&!Yn(t.sourceExecutionId))return;const n=yh(),r=_n(t);if(n.some(o=>_n(o)===r))return;const s=o=>(o.scope??void 0)===(t.scope??void 0),i=n.filter(s);i.unshift({...t,dismissed:!1}),EC([...i.slice(0,c5),...n.filter(o=>!s(o))])}function f5(e,t){t.status!==void 0&&(e.status=t.status),t.lastUpdatedAt!==void 0&&(e.lastUpdatedAt=t.lastUpdatedAt),t.ttlMs!==void 0&&(e.ttlMs=t.ttlMs),t.pollIntervalMs!==void 0&&(e.pollIntervalMs=t.pollIntervalMs),t.nextPollAt!==void 0&&(e.nextPollAt=t.nextPollAt),t.lastObservedAt!==void 0&&(e.lastObservedAt=t.lastObservedAt)}function Rre(e){if(e.length===0)return;const t=dr(),n=new Map(t.map(s=>[_n(s),s]));let r=!1;for(const{identity:s,observation:i}of e){const o=n.get(_n(oc(s)));o&&(f5(o,i),r=!0)}r&&ac(t)}function Ore(e){const t=new Map;if(e.length===0)return t;const n=new Map;for(const r of e)n.set(_n(oc(r)),_n(r));for(const r of dr()){const s=n.get(_n(r));s!==void 0&&t.set(s,{nextPollAt:r.nextPollAt,lastObservedAt:r.lastObservedAt,pollIntervalMs:r.pollIntervalMs,ttlMs:r.ttlMs,status:r.status,respondedInputKeys:r.respondedInputKeys??[]})}return t}function Mre(e,t){if(t.length===0)return;const n=_n(oc(e)),r=dr(),s=r.find(i=>_n(i)===n);s&&(s.respondedInputKeys=[...new Set([...s.respondedInputKeys??[],...t])].slice(0,kT).map(i=>i.slice(0,_o)),ac(r))}function Nre(e){const t=_n(oc(e));return dr().find(n=>_n(n)===t)?.respondedInputKeys??[]}function Pre(e,t,n){const r=dr();for(const s of r)s.taskId===e&&(t===void 0||s.serverId===t)&&sa(s,n)&&(s.expired=!0);ac(r)}function Lre(e,t,n){const r=new Set(t),s=dr();for(const i of s)i.serverId===e&&r.has(i.taskId)&&sa(i,n)&&(i.dismissed=!0);ac(s)}var RT="mcp-dismissed-registry-tasks",B5=200;function xC(){try{const e=localStorage.getItem(RT);if(!e)return{};const t=JSON.parse(e);if(typeof t!="object"||t===null||Array.isArray(t))return{};const n={};for(const[r,s]of Object.entries(t))Array.isArray(s)&&(n[r]=s.filter(i=>typeof i=="string"&&i.length>0&&i.length<=_o).slice(0,B5));return n}catch{return{}}}function OT(e){try{localStorage.setItem(RT,JSON.stringify(e))}catch{}}function _re(e,t,n){if(n?.connectionId!==void 0&&n.scope===void 0&&SC()===void 0)return;const r=t.filter(o=>Yn(o)!==void 0);if(r.length===0)return;const s=xC(),i=Dp(e,n);s[i]=[...new Set([...s[i]??[],...r])].slice(-200),OT(s)}function Fre(e,t){if(t?.connectionId!==void 0&&t.scope===void 0&&SC()===void 0)return new Set;const n=new Set(dr().filter(i=>i.serverId===e&&i.dismissed&&sa(i,t)).map(i=>i.taskId)),r=xC(),s=[Dp(e,t)];t?.connectionId===void 0&&t?.scope===void 0&&s.push(Dp(e));for(const i of s)for(const o of r[i]??[])n.add(o);return n}function Hre(e,t){ac(dr().filter(n=>n.serverId!==e||!sa(n,t)))}function p5(e){const t=e??void 0;EC(yh().filter(i=>(i.scope??void 0)!==t));const n=xC(),r=`${t??""}\0`;let s=!1;for(const i of Object.keys(n))i.startsWith(r)&&(delete n[i],s=!0);s&&OT(n)}var MT={projectId:null,serverIdsByName:{}},ge=MT,Jn=null,zs=0,Tp=new Set,Ia=3e4,m5=3e3,g5=100,Mf=null;function wC(){Jn=null}var C5=1e4;async function v5(){if(po())return null;const e=ge.getAccessToken;if(!e)return null;const t=zs;wC();let n;try{const r=await Promise.race([e({forceRefresh:!0}),new Promise(s=>{n=setTimeout(()=>s(null),C5)})]);return!r||t!==zs?null:(Jn={token:r,expiresAt:Date.now()+Ia,kind:"session"},r)}catch{return null}finally{clearTimeout(n)}}function NT(){zs+=1;for(const e of Tp)e()}function jre(e){return Tp.add(e),()=>{Tp.delete(e)}}function Gre(){return zs}var Hy=null;function Vre(e){const t=Hy;if(t&&t.revision===zs&&t.serverNameOrId===e)return t.key;const n=ge.clientConfigSyncPending||!S5(e)?null:JSON.stringify([po(),D5(e)]);return Hy={revision:zs,serverNameOrId:e,key:n},n}function y5(){throw new Error("Hosted API context is only available in hosted mode")}function DC(){if(ge.clientConfigSyncPending)throw new Error(Uz)}function b5(){return!ge.isAuthenticated&&!ge.hasSession}function TC(){return!(ge.isAuthenticated||ge.hasSession)}function po(){return TC()}function Ure(e){const t=ge.projectId??void 0,n=e?.projectId??void 0;t&&n&&t!==n&&p5(t),o5(n),l5(n,e?.taskOwnerId),ge=e?{...e,clientCapabilities:e.clientCapabilities??Kd()}:MT,wC(),NT()}function zre(e,t,n){ge.projectId===n&&ge.serverIdsByName[e]!==t&&(ge={...ge,serverIdsByName:{...ge.serverIdsByName,[e]:t}},NT())}function PT(){const e=ge.projectId;if(!e)throw new t5("provisioning-project","hosted projectId is not in the API context yet");return e}function S5(e){const t=ge.projectId;if(!t)return null;const n=ge.serverIdsByName[e];return n?{projectId:t,serverId:n}:Object.values(ge.serverIdsByName).includes(e)?{projectId:t,serverId:e}:null}function E5(e){const t=e.trim();return!(t.length<1||t.length>=20&&/^[a-z0-9]+$/i.test(t))}var x5="Hosted server not found. The server is not in your hosted project, or the server list is still loading.";function LT(e){const t=ge.serverIdsByName[e];if(t)return t;if(Object.values(ge.serverIdsByName).includes(e))return e;throw E5(e)?new Error(`Hosted server not found for "${e}"`):new Error(x5)}function lc(e){return Object.entries(ge.serverIdsByName).find(([,t])=>t===e)?.[0]}function $re(e){return lc(e)}function Wre(e){}function qre(e){y5();const t=new Set,n=[];for(const r of e){if(typeof r!="string")continue;const s=r.trim();if(!s)continue;const i=ge.serverIdsByName[s]!==void 0?s:lc(s)??s,o=i.toLowerCase();t.has(o)||(t.add(o),n.push(i))}return n}function w5(e){const t=new Set,n=[];for(const r of e){const s=LT(r);t.has(s)||(t.add(s),n.push({serverId:s,serverName:ge.serverIdsByName[r]!==void 0?r:lc(s)??r}))}return n}function AC(){return ge.scenarioId}function _T(){return ge.accessVersion}function FT(){return AC()?"chat_v2":void 0}function IC(e){return{...e.mirrorToolParamHeaders===!1?{mirrorToolParamHeaders:!1}:{},...e.firstPageOnly===!0?{firstPageOnly:!0}:{},...e.suppressListenChannel===!0?{suppressListenChannel:!0}:{},...e.dropToolListChanged===!0?{dropToolListChanged:!0}:{},...e.toolCallCancellation?{toolCallCancellation:e.toolCallCancellation}:{},...e.supportsMrtr===!1?{supportsMrtr:!1}:{}}}function D5(e){DC();const t=PT(),n=LT(e),r=AC(),s=_T(),i=FT();return{projectId:t,serverId:n,serverName:ge.serverIdsByName[e]!==void 0?e:lc(n)??e,...ge.clientCapabilities?{clientCapabilities:ge.clientCapabilities}:{},...ge.clientInfo?{clientInfo:ge.clientInfo}:{},...ge.supportedProtocolVersions?.length?{supportedProtocolVersions:ge.supportedProtocolVersions}:{},...ge.mcpProtocolVersionsByServerId?.[n]?{mcpProtocolVersion:ge.mcpProtocolVersionsByServerId[n]}:{},...IC(ge),...ge.xaaPolicy?{xaaPolicy:ge.xaaPolicy}:{},...i?{accessScope:i}:{},...r?{scenarioId:r}:{},...r&&Number.isFinite(s)?{accessVersion:s}:{}}}function Kre(e){DC();const t=PT(),n=w5(e),r=n.map(c=>c.serverId),s=n.map(c=>c.serverName),i=HT(r),o=AC(),a=_T(),l=FT();return{projectId:t,serverIds:r,serverNames:s,...ge.clientCapabilities?{clientCapabilities:ge.clientCapabilities}:{},...ge.clientInfo?{clientInfo:ge.clientInfo}:{},...ge.supportedProtocolVersions?.length?{supportedProtocolVersions:ge.supportedProtocolVersions}:{},...i?{mcpProtocolVersionsByServerId:i}:{},...IC(ge),...ge.xaaPolicy?{xaaPolicy:ge.xaaPolicy}:{},...l?{accessScope:l}:{},...o?{scenarioId:o}:{},...o&&Number.isFinite(a)?{accessVersion:a}:{}}}function HT(e){const t=ge.mcpProtocolVersionsByServerId;if(!t)return;const n={};for(const r of e){const s=t[r];s&&(n[r]=s)}return Object.keys(n).length>0?n:void 0}function Jre(e){DC();const t=HT(e.serverIds);return{projectId:e.projectId,serverIds:e.serverIds,serverNames:e.serverNames,...ge.clientCapabilities?{clientCapabilities:ge.clientCapabilities}:{},...ge.clientInfo?{clientInfo:ge.clientInfo}:{},...ge.supportedProtocolVersions?.length?{supportedProtocolVersions:ge.supportedProtocolVersions}:{},...t?{mcpProtocolVersionsByServerId:t}:{},...IC(ge),...ge.xaaPolicy?{xaaPolicy:ge.xaaPolicy}:{},...e.accessScope?{accessScope:e.accessScope}:{},...e.scenarioId?{scenarioId:e.scenarioId}:{},...e.scenarioId&&Number.isFinite(e.accessVersion)?{accessVersion:e.accessVersion}:{}}}function T5(){return Mf??=A5().finally(()=>{Mf=null}),Mf}async function A5(){const e=Date.now()+m5;for(;Date.now()<e;){if(await new Promise(n=>setTimeout(n,g5)),TC())return null;const t=ge.getAccessToken;if(t)try{const n=await t();if(n)return n}catch{}}return null}async function jT(e=1){const t=zs,n=po(),r=()=>zs!==t||po()!==n,s=()=>e>0?jT(e-1):null,i=Date.now();if(Jn&&Jn.expiresAt>i)if(Jn.kind==="guest"&&!po())Jn=null;else return`Bearer ${Jn.token}`;if(po()){const l=await jv();if(r())return s();if(l)return Jn={token:l,expiresAt:i+Ia,kind:"guest"},`Bearer ${l}`}const o=ge.getAccessToken;if(o)try{const l=await o();if(r())return s();if(l)return Jn={token:l,expiresAt:i+Ia,kind:"session"},`Bearer ${l}`}catch{}if(!TC()){const l=await T5();return r()?s():l?(Jn={token:l,expiresAt:Date.now()+Ia,kind:"session"},`Bearer ${l}`):null}const a=await jv();return r()?s():a?(Jn={token:a,expiresAt:i+Ia,kind:"guest"},`Bearer ${a}`):null}function I5(){const e=rN();if(e)return e;const t=dN()??"https://rt.mcpjam.com";return t&&typeof t=="string"?t.replace(".convex.cloud",".convex.site"):null}var k5=["billing_","credit_topup_","plan_limit_","plans_upgrade_confirm_","pricing_"];function R5(e){return k5.some(t=>e.startsWith(t))}function O5(e){const t=e.toLowerCase();return t==="organization_id"||t==="package_id"||t==="price_cents"||t==="price_paid_cents"||t==="granted_credits"||t==="amount_credits"||t==="error"||t==="error_name"||t==="error_message"||t.startsWith("stripe_")||t.startsWith("invoice_")||t==="checkout_session_id"||t==="payment_intent_id"}function Ed(e,t={}){const{location:n="unknown",platform:r,environment:s,...i}=t;try{const o=R5(e),a=o?i.organization_id:void 0,l=typeof a=="string"&&a.length>0?a:void 0,c=o?Object.fromEntries(Object.entries(i).filter(([u])=>!O5(u))):i;dx.capture(e,{...c,...aN(n),...o?{organization_id:null,...l?{$groups:{organization:l}}:{}}:{}})}catch(o){console.warn(`[analytics] Failed to capture ${e}`,o)}}function Qre(e,t,n=Hv()){const r=tN();!n||Hv()!==n||r.policy.content!=="full"||e.capture("$set",{},{$set:r.policy.identity==="full"?t:{deployment:t.deployment}})}function M5(e){if(typeof e!="object"||e===null)return!1;const{code:t,details:n}=e;return t==="SESSION_REVOKED"?!0:t==="UNAUTHORIZED"&&typeof n=="object"&&n!==null&&n.reason==="SESSION_REVOKED"}async function N5(e){if(e.status!==401)return!1;try{return typeof e.clone!="function"?!1:M5(await e.clone().json())}catch{return!1}}var Ka=null,jy=!1,Ap=!1;function GT(e){try{e()}catch{}}function P5(){jy||(jy=!0,Ka?GT(Ka):Ap=!0)}function Yre(e){return Ka=e,Ap&&(Ap=!1,GT(e)),()=>{Ka===e&&(Ka=null)}}async function L5(e){const t=e.headers.get("content-type")?.split(";")[0].trim().toLowerCase()||void 0,n=await e.text().catch(()=>""),r=n.trimStart().startsWith("{")?_5(n):null;return r?{ok:"ok"in r&&r.ok===!0,code:"code"in r&&typeof r.code=="string"?r.code:void 0,contentType:t}:{ok:!1,contentType:t}}function _5(e){try{const t=JSON.parse(e);return typeof t=="object"?t:null}catch{return null}}var Fo=null,ka=null,kC=class extends Error{status;code;restarted;contentType;constructor(e,{code:t,restarted:n=!1,contentType:r}={}){super(`Failed to get session token: ${e}`),this.name="SessionTokenError",this.status=e,this.code=t,this.restarted=n,this.contentType=r}};function Xre(e){return e instanceof kC&&e.status===403&&e.code==="HOST_NOT_ALLOWED"}function F5(e){return e instanceof kC&&e.status===401&&e.code==="ACCESS_LINK_REQUIRED"}var Gy={"/api/web/scenarios/bootstrap":"scenario"};function H5(e){const t=e instanceof URL?e.toString():typeof Request<"u"&&e instanceof Request?e.url:String(e),n=typeof window<"u"?window.location.origin:"http://localhost";try{const r=new URL(t,n);return Gy[r.pathname]??null}catch{return Gy[t]??null}}function j5(...e){const t={};for(const n of e)if(n){if(n instanceof Headers){n.forEach((r,s)=>{t[s]=r});continue}if(Array.isArray(n)){for(const[r,s]of n)t[r]=s;continue}Object.assign(t,n)}return t}function G5(e){return e?e instanceof Headers?e.has("Authorization"):Array.isArray(e)?e.some(([t])=>t.toLowerCase()==="authorization"):Object.keys(e).some(t=>t.toLowerCase()==="authorization"):!1}function Fc(e,t,n){const r=$T(e)?U5():void 0,s=n&&WT(e)?{Authorization:n}:void 0;return{...t,headers:j5(r,s,t?.headers)}}async function VT(e){const t=await fetch("/api/session-token",{headers:e?{"X-MCP-Session-Auth":`Bearer ${e}`}:{},cache:"no-store"}),n=await L5(t);if(!t.ok||!n.ok||!bN(e))throw new kC(t.status,{code:n.code,restarted:!!e,contentType:n.contentType});return Fo=e,CN(e),e}async function Zre(){return Fo||(ka||(ka=VT(vg()).catch(e=>{throw ka=null,e})),ka)}async function V5(){Fo=null,ka=null;try{return await VT(vg(!0))}catch(e){return F5(e)&&window.dispatchEvent(new CustomEvent(Bx,{detail:{restarted:e.restarted}})),null}}function bh(){return Fo||(vg()??"")}function ese(){return!!bh()}function U5(){const e=bh();return e?{"X-MCP-Session-Auth":`Bearer ${e}`}:(console.warn("[Auth] Session token not available"),{})}function UT(e){return e==="localhost"||e==="127.0.0.1"||e==="::1"||e==="[::1]"}function RC(e){const t=typeof window<"u"?window.location.origin:"http://localhost";try{return e instanceof URL?e:typeof Request<"u"&&e instanceof Request?new URL(e.url,t):new URL(String(e),t)}catch{return null}}function zT(e){return UT(e.hostname)?!0:typeof window<"u"&&e.origin===window.location.origin}function $T(e){const t=RC(e);return t?zT(t)&&t.pathname.startsWith("/api/"):typeof e=="string"&&e.startsWith("/api/")}var z5=["/api/mcp/webmcp","/api/web/","/api/v1/harness/","/api/v1/built-in-tools/","/api/web-clients/accounts/","/api/web-clients/reconnect/","/api/v1/agent-ops","/api/mcp/local-harness","/api/mcp/connect","/api/mcp/servers/reconnect","/api/mcp/servers/approve-command","/api/mcp/server-features/observations","/api/mcp/servers/canvas/refresh","/api/mcp/chat-v2","/api/mcp/xaa/proxy/token","/api/mcp/xaa/negative-tests","/api/mcp/xaa/authenticate","/api/mcp/xaa/token-exchange","/api/mcp/xaa/token","/api/mcp/computers/local-consent","/api/mcp/computers/local-terminal-token","/api/mcp/computers/local-browser","/api/mcp/computers/browser-location","/web/oauth/","/web/registry/"];function $5(e){if(typeof window<"u"&&e.origin===window.location.origin||UT(e.hostname))return!0;const t=I5();if(t)try{const n=new URL(t).hostname;if(e.hostname===n)return!0}catch{}return!1}var W5=[/^\/api\/mcp\/(chat-persistence|turn-authorization)\/?$/,/^\/api\/mcp\/servers\/command-approval\/?$/,/^\/api\/v1\/projects\/[^/]+\/readiness-runs(\/[^/]+(\/(cancel|report|resume))?)?$/,/^\/api\/v1\/projects\/[^/]+\/servers\/[^/]+\/revisions(\/\d+\/diff)?$/,/^\/api\/v1\/projects\/[^/]+\/servers\/[^/]+\/readiness-runs\/(claude|openai)$/,/^\/api\/v1\/projects\/[^/]+\/directory-submissions\/[^/]+\/reviewer-attempts(\/[^/]+(\/(resume|cancel|handoff))?)?$/,/^\/api\/v1\/directory-flows(\/[^/]+)?$/,/^\/api\/v1\/projects\/[^/]+\/directory-submissions(\/[^/]+(\/(runs|results|handoff|export|events|snapshots|findings(\/[^/]+)?))?)?$/,/^\/api\/v1\/projects\/[^/]+\/directory-submissions\/[^/]+\/(test-plan(\/draft)?|tool-tests)$/,/^\/api\/v1\/projects\/[^/]+\/eval-suites\/[^/]+\/run-disclosure$/,/^\/api\/v1\/projects\/[^/]+\/eval-runs\/[^/]+\/(decision-summary|stage-analytics|route-facts|server-facts)$/,/^\/api\/v1\/projects\/[^/]+\/eval-suites\/[^/]+\/stage-analytics$/,/^\/api\/v1\/projects\/[^/]+\/eval-runs\/[^/]+\/description-experiments$/,/^\/api\/v1\/projects\/[^/]+\/eval-description-experiments\/[^/]+(\/start)?$/,/^\/api\/v1\/projects\/[^/]+\/eval-runs\/[^/]+\/backtest$/,/^\/api\/v1\/projects\/[^/]+\/eval-runs\/[^/]+\/iterations$/,/^\/api\/v1\/projects\/[^/]+\/eval-runs\/[^/]+\/compare$/,/^\/api\/v1\/projects\/[^/]+\/eval-runs\/[^/]+\/cancel$/];function Vy(e){return W5.some(t=>t.test(e))?!0:z5.some(t=>t.endsWith("/")?e.startsWith(t):e===t||e.startsWith(`${t}/`))}var q5=["/api/web/apps/plugin-instances/","/api/web/plugin-forms/"];function K5(e){const t=RC(e),n=t?t.pathname:typeof e=="string"?e.split("?")[0]:"";return/^\/api\/(web|mcp)\/(chat-persistence|turn-authorization)\/?$/.test(n)||q5.some(r=>n.startsWith(r))}function J5(e){return e==null||typeof e=="string"||e instanceof FormData||e instanceof URLSearchParams||e instanceof Blob||e instanceof ArrayBuffer||ArrayBuffer.isView(e)}function WT(e){const t=RC(e);if(t)return $5(t)?Vy(t.pathname):!1;if(typeof e!="string"||!e.startsWith("/"))return!1;const n=e.split("?")[0];return Vy(n)}function Q5(e){const t=bh();if(!t)return console.warn("[Auth] Session token not available for URL"),e;try{const n=new URL(e,window.location.origin);return zT(n)?(n.searchParams.set("_token",t),n.origin===window.location.origin?n.pathname+n.search:n.href):(console.warn("[Auth] Refusing to attach session token to foreign origin"),e)}catch{return`${e}${e.includes("?")?"&":"?"}_token=${encodeURIComponent(t)}`}}async function tse(e,t){const n=H5(e),r=G5(t?.headers),s=WT(e),i=s&&!r?await jT():null,o=Fc(e,t,i),a=await fetch(e,o);if(a.status===401&&s&&await N5(a))return P5(),a;if(a.status===401&&s&&!r&&K5(e)&&J5(t?.body)&&a.headers?.get("X-MCP-Auth-Required")!=="oauth"){const u=await v5();if(u)return t?.signal?.throwIfAborted(),fetch(e,Fc(e,t,`Bearer ${u}`))}if(a.status===401&&$T(e)&&a.headers?.get("X-MCPJam-Session")!=null){const u=bh(),d=await V5();if(d&&d!==u){const h=Fc(e,t,i),f=await fetch(e,h);return f.status===401&&f.headers.get("X-MCPJam-Session")&&window.dispatchEvent(new CustomEvent(Bx,{detail:{restarted:!0}})),f}}if(a.status!==401||!s||!b5()||r||a.headers?.get("X-MCP-Auth-Required")==="oauth")return a;wC();const l=await gN();if(!l)return n&&Ed("guest_refresh_failure",{location:"auth_fetch",surface:n,auth_mode:"guest",status:"failure",error_kind:"guest_refresh_unavailable"}),a;n&&Ed("guest_refresh_success",{location:"auth_fetch",surface:n,auth_mode:"guest",status:"success"});const c=Fc(e,t,`Bearer ${l}`);return fetch(e,c)}var Uy="1.46.0",Dl=Symbol.for("functionName"),Y5=Symbol.for("toReferencePath");function X5(e){return e[Y5]??null}function Z5(e){return e.startsWith("function://")}function e3(e){let t;if(typeof e=="string")Z5(e)?t={functionHandle:e}:t={name:e};else if(e[Dl])t={name:e[Dl]};else{const n=X5(e);if(!n)throw new Error(`${e} is not a functionReference`);t={reference:n}}return t}function tn(e){const t=e3(e);if(t.name===void 0)throw t.functionHandle!==void 0?new Error(`Expected function reference like "api.file.func" or "internal.file.func", but received function handle ${t.functionHandle}`):t.reference!==void 0?new Error(`Expected function reference in the current component like "api.file.func" or "internal.file.func", but received reference ${t.reference}`):new Error(`Expected function reference like "api.file.func" or "internal.file.func", but received ${JSON.stringify(t)}`);if(typeof e=="string")return e;const n=e[Dl];if(!n)throw new Error(`${e} is not a functionReference`);return n}function Sh(e){return{[Dl]:e}}function qT(e=[]){return new Proxy({},{get(t,n){if(typeof n=="string")return qT([...e,n]);if(n===Dl){if(e.length<2){const i=["api",...e].join(".");throw new Error(`API path is expected to be of the form \`api.moduleName.functionName\`. Found: \`${i}\``)}const r=e.slice(0,-1).join("/"),s=e[e.length-1];return s==="default"?r:r+":"+s}else return n===Symbol.toStringTag?"FunctionReference":void 0}})}var nse=qT(),t3=Object.defineProperty,n3=(e,t,n)=>t in e?t3(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,zy=(e,t,n)=>n3(e,typeof t!="symbol"?t+"":t,n),r3="color:rgb(0, 145, 255)";function KT(e){switch(e){case"query":return"Q";case"mutation":return"M";case"action":return"A";case"any":return"?"}}var JT=class{constructor(e){zy(this,"_onLogLineFuncs"),zy(this,"_verbose"),this._onLogLineFuncs={},this._verbose=e.verbose}addLogLineListener(e){let t=Math.random().toString(36).substring(2,15);for(let n=0;n<10&&this._onLogLineFuncs[t]!==void 0;n++)t=Math.random().toString(36).substring(2,15);return this._onLogLineFuncs[t]=e,()=>{delete this._onLogLineFuncs[t]}}logVerbose(...e){if(this._verbose)for(const t of Object.values(this._onLogLineFuncs))t("debug",`${new Date().toISOString()}`,...e)}log(...e){for(const t of Object.values(this._onLogLineFuncs))t("info",...e)}warn(...e){for(const t of Object.values(this._onLogLineFuncs))t("warn",...e)}error(...e){for(const t of Object.values(this._onLogLineFuncs))t("error",...e)}};function QT(e){const t=new JT(e);return t.addLogLineListener((n,...r)=>{switch(n){case"debug":console.debug(...r);break;case"info":console.log(...r);break;case"warn":console.warn(...r);break;case"error":console.error(...r);break;default:console.log(...r)}}),t}function YT(e){return new JT(e)}function xd(e,t,n,r,s){const i=KT(n);if(typeof s=="object"&&(s=`ConvexError ${JSON.stringify(s.errorData,null,2)}`),t==="info"){const o=s.match(/^\[.*?\] /);if(o===null){e.error(`[CONVEX ${i}(${r})] Could not parse console.log`);return}const a=s.slice(1,o[0].length-2),l=s.slice(o[0].length);e.log(`%c[CONVEX ${i}(${r})] [${a}]`,r3,l)}else e.error(`[CONVEX ${i}(${r})] ${s}`)}function s3(e,t){const n=`[CONVEX FATAL ERROR] ${t}`;return e.error(n),new Error(n)}function mo(e,t,n){return`[CONVEX ${KT(e)}(${t})] ${n.errorMessage}
42
+ Called by client`}function Ip(e,t){return t.data=e.errorData,t}function Ni(e){const t=e.split(":");let n,r;return t.length===1?(n=t[0],r="default"):(n=t.slice(0,t.length-1).join(":"),r=t[t.length-1]),n.endsWith(".js")&&(n=n.slice(0,-3)),`${n}:${r}`}function xi(e,t){return JSON.stringify({udfPath:Ni(e),args:Pr(t)})}function $y(e,t,n){const{initialNumItems:r,id:s}=n;return JSON.stringify({type:"paginated",udfPath:Ni(e),args:Pr(t),options:Pr({initialNumItems:r,id:s})})}var i3=Object.defineProperty,o3=(e,t,n)=>t in e?i3(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,mr=(e,t,n)=>o3(e,typeof t!="symbol"?t+"":t,n),a3=class{constructor(){mr(this,"nextQueryId"),mr(this,"querySetVersion"),mr(this,"querySet"),mr(this,"queryIdToToken"),mr(this,"identityVersion"),mr(this,"auth"),mr(this,"outstandingQueriesOlderThanRestart"),mr(this,"outstandingAuthOlderThanRestart"),mr(this,"paused"),mr(this,"pendingQuerySetModifications"),this.nextQueryId=0,this.querySetVersion=0,this.identityVersion=0,this.querySet=new Map,this.queryIdToToken=new Map,this.outstandingQueriesOlderThanRestart=new Set,this.outstandingAuthOlderThanRestart=!1,this.paused=!1,this.pendingQuerySetModifications=new Map}hasSyncedPastLastReconnect(){return this.outstandingQueriesOlderThanRestart.size===0&&!this.outstandingAuthOlderThanRestart}markAuthCompletion(){this.outstandingAuthOlderThanRestart=!1}subscribe(e,t,n,r){const s=Ni(e),i=xi(s,t),o=this.querySet.get(i);if(o!==void 0)return o.numSubscribers+=1,{queryToken:i,modification:null,unsubscribe:()=>this.removeSubscriber(i)};{const a=this.nextQueryId++,l={id:a,canonicalizedUdfPath:s,args:t,numSubscribers:1,journal:n,componentPath:r};this.querySet.set(i,l),this.queryIdToToken.set(a,i);const c=this.querySetVersion,u=this.querySetVersion+1,d={type:"Add",queryId:a,udfPath:s,args:[Pr(t)],journal:n,componentPath:r};return this.paused?this.pendingQuerySetModifications.set(a,d):this.querySetVersion=u,{queryToken:i,modification:{type:"ModifyQuerySet",baseVersion:c,newVersion:u,modifications:[d]},unsubscribe:()=>this.removeSubscriber(i)}}}transition(e){for(const t of e.modifications)switch(t.type){case"QueryUpdated":case"QueryFailed":{this.outstandingQueriesOlderThanRestart.delete(t.queryId);const n=t.journal;if(n!==void 0){const r=this.queryIdToToken.get(t.queryId);r!==void 0&&(this.querySet.get(r).journal=n)}break}case"QueryRemoved":this.outstandingQueriesOlderThanRestart.delete(t.queryId);break;default:throw new Error(`Invalid modification ${t.type}`)}}queryId(e,t){const n=Ni(e),r=xi(n,t),s=this.querySet.get(r);return s!==void 0?s.id:null}isCurrentOrNewerAuthVersion(e){return e>=this.identityVersion}getAuth(){return this.auth}setAuth(e){this.auth={tokenType:"User",value:e};const t=this.identityVersion;return this.paused||(this.identityVersion=t+1),{type:"Authenticate",baseVersion:t,...this.auth}}setAdminAuth(e,t){const n={tokenType:"Admin",value:e,impersonating:t};this.auth=n;const r=this.identityVersion;return this.paused||(this.identityVersion=r+1),{type:"Authenticate",baseVersion:r,...n}}clearAuth(){this.auth=void 0,this.markAuthCompletion();const e=this.identityVersion;return this.paused||(this.identityVersion=e+1),{type:"Authenticate",tokenType:"None",baseVersion:e}}hasAuth(){return!!this.auth}isNewAuth(e){return this.auth?.value!==e}queryPath(e){const t=this.queryIdToToken.get(e);return t?this.querySet.get(t).canonicalizedUdfPath:null}queryArgs(e){const t=this.queryIdToToken.get(e);return t?this.querySet.get(t).args:null}queryToken(e){return this.queryIdToToken.get(e)??null}queryJournal(e){return this.querySet.get(e)?.journal}restart(){this.unpause(),this.outstandingQueriesOlderThanRestart.clear();const e=[];for(const r of this.querySet.values()){const s={type:"Add",queryId:r.id,udfPath:r.canonicalizedUdfPath,args:[Pr(r.args)],journal:r.journal,componentPath:r.componentPath};e.push(s),this.outstandingQueriesOlderThanRestart.add(r.id)}this.querySetVersion=1;const t={type:"ModifyQuerySet",baseVersion:0,newVersion:1,modifications:e};if(!this.auth)return this.identityVersion=0,[t,void 0];this.outstandingAuthOlderThanRestart=!0;const n={type:"Authenticate",baseVersion:0,...this.auth};return this.identityVersion=1,[t,n]}pause(){this.paused=!0}resume(){const e=this.pendingQuerySetModifications.size>0?{type:"ModifyQuerySet",baseVersion:this.querySetVersion,newVersion:++this.querySetVersion,modifications:Array.from(this.pendingQuerySetModifications.values())}:void 0,t=this.auth!==void 0?{type:"Authenticate",baseVersion:this.identityVersion++,...this.auth}:void 0;return this.unpause(),[e,t]}unpause(){this.paused=!1,this.pendingQuerySetModifications.clear()}removeSubscriber(e){const t=this.querySet.get(e);if(t.numSubscribers>1)return t.numSubscribers-=1,null;{this.querySet.delete(e),this.queryIdToToken.delete(t.id),this.outstandingQueriesOlderThanRestart.delete(t.id);const n=this.querySetVersion,r=this.querySetVersion+1,s={type:"Remove",queryId:t.id};return this.paused?this.pendingQuerySetModifications.has(t.id)?this.pendingQuerySetModifications.delete(t.id):this.pendingQuerySetModifications.set(t.id,s):this.querySetVersion=r,{type:"ModifyQuerySet",baseVersion:n,newVersion:r,modifications:[s]}}}},l3=Object.defineProperty,c3=(e,t,n)=>t in e?l3(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Hc=(e,t,n)=>c3(e,typeof t!="symbol"?t+"":t,n),u3=class{constructor(e,t){this.logger=e,this.markConnectionStateDirty=t,Hc(this,"inflightRequests"),Hc(this,"requestsOlderThanRestart"),Hc(this,"inflightMutationsCount",0),Hc(this,"inflightActionsCount",0),this.inflightRequests=new Map,this.requestsOlderThanRestart=new Set}request(e,t){const n=new Promise(r=>{const s=t?"Requested":"NotSent";this.inflightRequests.set(e.requestId,{message:e,status:{status:s,requestedAt:new Date,onResult:r}}),e.type==="Mutation"?this.inflightMutationsCount++:e.type==="Action"&&this.inflightActionsCount++});return this.markConnectionStateDirty(),n}onResponse(e){const t=this.inflightRequests.get(e.requestId);if(t===void 0||t.status.status==="Completed")return null;const n=t.message.type==="Mutation"?"mutation":"action",r=t.message.udfPath;for(const a of e.logLines)xd(this.logger,"info",n,r,a);const s=t.status;let i,o;if(e.success)i={success:!0,logLines:e.logLines,value:ld(e.result)},o=()=>s.onResult(i);else{const a=e.result,{errorData:l}=e;xd(this.logger,"error",n,r,a),i={success:!1,errorMessage:a,errorData:l!==void 0?ld(l):void 0,logLines:e.logLines},o=()=>s.onResult(i)}return e.type==="ActionResponse"||!e.success?(o(),this.inflightRequests.delete(e.requestId),this.requestsOlderThanRestart.delete(e.requestId),t.message.type==="Action"?this.inflightActionsCount--:t.message.type==="Mutation"&&this.inflightMutationsCount--,this.markConnectionStateDirty(),{requestId:e.requestId,result:i}):(t.status={status:"Completed",result:i,ts:e.ts,onResolve:o},null)}removeCompleted(e){const t=new Map;for(const[n,r]of this.inflightRequests.entries()){const s=r.status;s.status==="Completed"&&s.ts.lessThanOrEqual(e)&&(s.onResolve(),t.set(n,s.result),r.message.type==="Mutation"?this.inflightMutationsCount--:r.message.type==="Action"&&this.inflightActionsCount--,this.inflightRequests.delete(n),this.requestsOlderThanRestart.delete(n))}return t.size>0&&this.markConnectionStateDirty(),t}restart(){this.requestsOlderThanRestart=new Set(this.inflightRequests.keys());const e=[];for(const[t,n]of this.inflightRequests){if(n.status.status==="NotSent"){n.status.status="Requested",e.push(n.message);continue}if(n.message.type==="Mutation")e.push(n.message);else if(n.message.type==="Action"){if(this.inflightRequests.delete(t),this.requestsOlderThanRestart.delete(t),this.inflightActionsCount--,n.status.status==="Completed")throw new Error("Action should never be in 'Completed' state");n.status.onResult({success:!1,errorMessage:"Connection lost while action was in flight",logLines:[]})}}return this.markConnectionStateDirty(),e}resume(){const e=[];for(const[,t]of this.inflightRequests)if(t.status.status==="NotSent"){t.status.status="Requested",e.push(t.message);continue}return e}hasIncompleteRequests(){for(const e of this.inflightRequests.values())if(e.status.status==="Requested")return!0;return!1}hasInflightRequests(){return this.inflightRequests.size>0}hasSyncedPastLastReconnect(){return this.requestsOlderThanRestart.size===0}timeOfOldestInflightRequest(){if(this.inflightRequests.size===0)return null;let e=Date.now();for(const t of this.inflightRequests.values())t.status.status!=="Completed"&&t.status.requestedAt.getTime()<e&&(e=t.status.requestedAt.getTime());return new Date(e)}inflightMutations(){return this.inflightMutationsCount}inflightActions(){return this.inflightActionsCount}},d3=Object.defineProperty,h3=(e,t,n)=>t in e?d3(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,wd=(e,t,n)=>h3(e,typeof t!="symbol"?t+"":t,n),Wy=class kp{constructor(t){wd(this,"queryResults"),wd(this,"modifiedQueries"),this.queryResults=t,this.modifiedQueries=[]}getQuery(t,...n){const r=Wr(n[0]),s=tn(t),i=this.queryResults.get(xi(s,r));if(i!==void 0)return kp.queryValue(i.result)}getAllQueries(t){const n=[],r=tn(t);for(const s of this.queryResults.values())s.udfPath===Ni(r)&&n.push({args:s.args,value:kp.queryValue(s.result)});return n}setQuery(t,n,r){const s=Wr(n),i=tn(t),o=xi(i,s);let a;r===void 0?a=void 0:a={success:!0,value:r,logLines:[]};const l={udfPath:i,args:s,result:a};this.queryResults.set(o,l),this.modifiedQueries.push(o)}static queryValue(t){if(t!==void 0)return t.success?t.value:void 0}},f3=class{constructor(){wd(this,"queryResults"),wd(this,"optimisticUpdates"),this.queryResults=new Map,this.optimisticUpdates=[]}ingestQueryResultsFromServer(e,t){this.optimisticUpdates=this.optimisticUpdates.filter(i=>!t.has(i.mutationId));const n=this.queryResults;this.queryResults=new Map(e);const r=new Wy(this.queryResults);for(const i of this.optimisticUpdates)i.update(r);const s=[];for(const[i,o]of this.queryResults){const a=n.get(i);(a===void 0||a.result!==o.result)&&s.push(i)}return s}applyOptimisticUpdate(e,t){this.optimisticUpdates.push({update:e,mutationId:t});const n=new Wy(this.queryResults);return e(n),n.modifiedQueries}rawQueryResult(e){const t=this.queryResults.get(e);if(t!==void 0)return t.result}queryResult(e){const t=this.queryResults.get(e);if(t===void 0)return;const n=t.result;if(n!==void 0){if(n.success)return n.value;throw n.errorData!==void 0?Ip(n,new MB(mo("query",t.udfPath,n))):new Error(mo("query",t.udfPath,n))}}hasQueryResult(e){return this.queryResults.get(e)!==void 0}queryLogs(e){return this.queryResults.get(e)?.result?.logLines}},B3=Object.defineProperty,p3=(e,t,n)=>t in e?B3(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Nf=(e,t,n)=>p3(e,typeof t!="symbol"?t+"":t,n),cc=class Ur{constructor(t,n){Nf(this,"low"),Nf(this,"high"),Nf(this,"__isUnsignedLong__"),this.low=t|0,this.high=n|0,this.__isUnsignedLong__=!0}static isLong(t){return(t&&t.__isUnsignedLong__)===!0}static fromBytesLE(t){return new Ur(t[0]|t[1]<<8|t[2]<<16|t[3]<<24,t[4]|t[5]<<8|t[6]<<16|t[7]<<24)}toBytesLE(){const t=this.high,n=this.low;return[n&255,n>>>8&255,n>>>16&255,n>>>24,t&255,t>>>8&255,t>>>16&255,t>>>24]}static fromNumber(t){return isNaN(t)||t<0?qy:t>=m3?g3:new Ur(t%Ja|0,t/Ja|0)}toString(){return(BigInt(this.high)*BigInt(Ja)+BigInt(this.low)).toString()}equals(t){return Ur.isLong(t)||(t=Ur.fromValue(t)),this.high>>>31===1&&t.high>>>31===1?!1:this.high===t.high&&this.low===t.low}notEquals(t){return!this.equals(t)}comp(t){return Ur.isLong(t)||(t=Ur.fromValue(t)),this.equals(t)?0:t.high>>>0>this.high>>>0||t.high===this.high&&t.low>>>0>this.low>>>0?-1:1}lessThanOrEqual(t){return this.comp(t)<=0}static fromValue(t){return typeof t=="number"?Ur.fromNumber(t):new Ur(t.low,t.high)}},qy=new cc(0,0),Ky=65536,Ja=Ky*Ky,m3=Ja*Ja,g3=new cc(-1,-1),C3=Object.defineProperty,v3=(e,t,n)=>t in e?C3(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,jc=(e,t,n)=>v3(e,typeof t!="symbol"?t+"":t,n),Jy=class{constructor(e,t){jc(this,"version"),jc(this,"remoteQuerySet"),jc(this,"queryPath"),jc(this,"logger"),this.version={querySet:0,ts:cc.fromNumber(0),identity:0},this.remoteQuerySet=new Map,this.queryPath=e,this.logger=t}transition(e){const t=e.startVersion;if(this.version.querySet!==t.querySet||this.version.ts.notEquals(t.ts)||this.version.identity!==t.identity)throw new Error(`Invalid start version: ${t.ts.toString()}:${t.querySet}:${t.identity}, transitioning from ${this.version.ts.toString()}:${this.version.querySet}:${this.version.identity}`);for(const n of e.modifications)switch(n.type){case"QueryUpdated":{const r=this.queryPath(n.queryId);if(r)for(const i of n.logLines)xd(this.logger,"info","query",r,i);const s=ld(n.value??null);this.remoteQuerySet.set(n.queryId,{success:!0,value:s,logLines:n.logLines});break}case"QueryFailed":{const r=this.queryPath(n.queryId);if(r)for(const i of n.logLines)xd(this.logger,"info","query",r,i);const{errorData:s}=n;this.remoteQuerySet.set(n.queryId,{success:!1,errorMessage:n.errorMessage,errorData:s!==void 0?ld(s):void 0,logLines:n.logLines});break}case"QueryRemoved":this.remoteQuerySet.delete(n.queryId);break;default:throw new Error(`Invalid modification ${n.type}`)}this.version=e.endVersion}remoteQueryResults(){return this.remoteQuerySet}timestamp(){return this.version.ts}};function Pf(e){const t=iN(e);return cc.fromBytesLE(Array.from(t))}function y3(e){const t=new Uint8Array(e.toBytesLE());return nN(t)}function Qy(e){switch(e.type){case"FatalError":case"AuthError":case"ActionResponse":case"TransitionChunk":case"Ping":return{...e};case"MutationResponse":return e.success?{...e,ts:Pf(e.ts)}:{...e};case"Transition":return{...e,startVersion:{...e.startVersion,ts:Pf(e.startVersion.ts)},endVersion:{...e.endVersion,ts:Pf(e.endVersion.ts)}}}}function b3(e){switch(e.type){case"Authenticate":case"ModifyQuerySet":case"Mutation":case"Action":case"Event":return{...e};case"Connect":return e.maxObservedTimestamp!==void 0?{...e,maxObservedTimestamp:y3(e.maxObservedTimestamp)}:{...e,maxObservedTimestamp:void 0}}}var S3=Object.defineProperty,E3=(e,t,n)=>t in e?S3(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,vt=(e,t,n)=>E3(e,typeof t!="symbol"?t+"":t,n),x3=1e3,w3=1001,D3=1005,T3=4040,Nu;function ro(){return Nu===void 0&&(Nu=Date.now()),typeof performance>"u"||!performance.now?Date.now():Math.round(Nu+performance.now())}function Yy(){return`t=${Math.round((ro()-Nu)/100)/10}s`}var XT={InternalServerError:{timeout:1e3},SubscriptionsWorkerFullError:{timeout:3e3},TooManyConcurrentRequests:{timeout:3e3},CommitterFullError:{timeout:3e3},AwsTooManyRequestsException:{timeout:3e3},ExecuteFullError:{timeout:3e3},SystemTimeoutError:{timeout:3e3},ExpiredInQueue:{timeout:3e3},VectorIndexesUnavailable:{timeout:1e3},SearchIndexesUnavailable:{timeout:1e3},TableSummariesUnavailable:{timeout:1e3},VectorIndexTooLarge:{timeout:3e3},SearchIndexTooLarge:{timeout:3e3},TooManyWritesInTimePeriod:{timeout:3e3}};function A3(e){if(e===void 0)return"Unknown";for(const t of Object.keys(XT))if(e.startsWith(t))return t;return"Unknown"}var I3=class{constructor(e,t,n,r,s,i){this.markConnectionStateDirty=s,this.debug=i,vt(this,"socket"),vt(this,"connectionCount"),vt(this,"_hasEverConnected",!1),vt(this,"lastCloseReason"),vt(this,"transitionChunkBuffer",null),vt(this,"defaultInitialBackoff"),vt(this,"maxBackoff"),vt(this,"retries"),vt(this,"serverInactivityThreshold"),vt(this,"reconnectDueToServerInactivityTimeout"),vt(this,"scheduledReconnect",null),vt(this,"networkOnlineHandler",null),vt(this,"pendingNetworkRecoveryInfo",null),vt(this,"uri"),vt(this,"onOpen"),vt(this,"onResume"),vt(this,"onMessage"),vt(this,"webSocketConstructor"),vt(this,"logger"),vt(this,"onServerDisconnectError"),this.webSocketConstructor=n,this.socket={state:"disconnected"},this.connectionCount=0,this.lastCloseReason="InitialConnect",this.defaultInitialBackoff=1e3,this.maxBackoff=16e3,this.retries=0,this.serverInactivityThreshold=6e4,this.reconnectDueToServerInactivityTimeout=null,this.uri=e,this.onOpen=t.onOpen,this.onResume=t.onResume,this.onMessage=t.onMessage,this.onServerDisconnectError=t.onServerDisconnectError,this.logger=r,this.setupNetworkListener(),this.connect()}setSocketState(e){this.socket=e,this._logVerbose(`socket state changed: ${this.socket.state}, paused: ${"paused"in this.socket?this.socket.paused:void 0}`),this.markConnectionStateDirty()}setupNetworkListener(){typeof window>"u"||typeof window.addEventListener!="function"||this.networkOnlineHandler===null&&(this.networkOnlineHandler=()=>{this._logVerbose("network online event detected"),this.tryReconnectImmediately()},window.addEventListener("online",this.networkOnlineHandler),this._logVerbose("network online event listener registered"))}cleanupNetworkListener(){this.networkOnlineHandler&&typeof window<"u"&&typeof window.removeEventListener=="function"&&(window.removeEventListener("online",this.networkOnlineHandler),this.networkOnlineHandler=null,this._logVerbose("network online event listener removed"))}assembleTransition(e){if(e.partNumber<0||e.partNumber>=e.totalParts||e.totalParts===0||this.transitionChunkBuffer&&(this.transitionChunkBuffer.totalParts!==e.totalParts||this.transitionChunkBuffer.transitionId!==e.transitionId))throw this.transitionChunkBuffer=null,new Error("Invalid TransitionChunk");if(this.transitionChunkBuffer===null&&(this.transitionChunkBuffer={chunks:[],totalParts:e.totalParts,transitionId:e.transitionId}),e.partNumber!==this.transitionChunkBuffer.chunks.length){const t=this.transitionChunkBuffer.chunks.length;throw this.transitionChunkBuffer=null,new Error(`TransitionChunk received out of order: expected part ${t}, got ${e.partNumber}`)}if(this.transitionChunkBuffer.chunks.push(e.chunk),this.transitionChunkBuffer.chunks.length===e.totalParts){const t=this.transitionChunkBuffer.chunks.join("");this.transitionChunkBuffer=null;const n=Qy(JSON.parse(t));if(n.type!=="Transition")throw new Error(`Expected Transition, got ${n.type} after assembling chunks`);return n}return null}connect(){if(this.socket.state==="terminated")return;if(this.socket.state!=="disconnected"&&this.socket.state!=="stopped")throw new Error("Didn't start connection from disconnected state: "+this.socket.state);const e=new this.webSocketConstructor(this.uri);this._logVerbose("constructed WebSocket"),this.setSocketState({state:"connecting",ws:e,paused:"no"}),this.resetServerInactivityTimeout(),e.onopen=()=>{if(this.logger.logVerbose("begin ws.onopen"),this.socket.state!=="connecting")throw new Error("onopen called with socket not in connecting state");if(this.setSocketState({state:"ready",ws:e,paused:this.socket.paused==="yes"?"uninitialized":"no"}),this.resetServerInactivityTimeout(),this.socket.paused==="no"&&(this._hasEverConnected=!0,this.onOpen({connectionCount:this.connectionCount,lastCloseReason:this.lastCloseReason,clientTs:ro()})),this.lastCloseReason!=="InitialConnect"&&(this.lastCloseReason?this.logger.log("WebSocket reconnected at",Yy(),"after disconnect due to",this.lastCloseReason):this.logger.log("WebSocket reconnected at",Yy())),this.connectionCount+=1,this.lastCloseReason=null,this.pendingNetworkRecoveryInfo!==null){const{timeSavedMs:t}=this.pendingNetworkRecoveryInfo;this.pendingNetworkRecoveryInfo=null,this.sendMessage({type:"Event",eventType:"NetworkRecoveryReconnect",event:{timeSavedMs:t}}),this.logger.log(`Network recovery reconnect saved ~${Math.round(t/1e3)}s of waiting`)}},e.onerror=t=>{this.transitionChunkBuffer=null;const n=t.message;n&&this.logger.log(`WebSocket error message: ${n}`)},e.onmessage=t=>{this.resetServerInactivityTimeout();const n=t.data.length;let r=Qy(JSON.parse(t.data));if(this._logVerbose(`received ws message with type ${r.type}`),r.type!=="Ping"){if(r.type==="TransitionChunk"){const s=this.assembleTransition(r);if(!s)return;r=s,this._logVerbose(`assembled full ws message of type ${r.type}`)}this.transitionChunkBuffer!==null&&(this.transitionChunkBuffer=null,this.logger.log(`Received unexpected ${r.type} while buffering TransitionChunks`)),r.type==="Transition"&&this.reportLargeTransition({messageLength:n,transition:r}),this.onMessage(r).hasSyncedPastLastReconnect&&(this.retries=0,this.markConnectionStateDirty())}},e.onclose=t=>{if(this._logVerbose("begin ws.onclose"),this.transitionChunkBuffer=null,this.lastCloseReason===null&&(this.lastCloseReason=t.reason||`closed with code ${t.code}`),t.code!==x3&&t.code!==w3&&t.code!==D3&&t.code!==T3){let r=`WebSocket closed with code ${t.code}`;t.reason&&(r+=`: ${t.reason}`),this.logger.log(r),this.onServerDisconnectError&&t.reason&&this.onServerDisconnectError(r)}const n=A3(t.reason);this.scheduleReconnect(n)}}socketState(){return this.socket.state}sendMessage(e){const t={type:e.type,...e.type==="Authenticate"&&e.tokenType==="User"?{value:`...${e.value.slice(-7)}`}:{}};if(this.socket.state==="ready"&&this.socket.paused==="no"){const n=b3(e),r=JSON.stringify(n);let s=!1;try{this.socket.ws.send(r),s=!0}catch(i){this.logger.log(`Failed to send message on WebSocket, reconnecting: ${i}`),this.closeAndReconnect("FailedToSendMessage")}return this._logVerbose(`${s?"sent":"failed to send"} message with type ${e.type}: ${JSON.stringify(t)}`),!0}return this._logVerbose(`message not sent (socket state: ${this.socket.state}, paused: ${"paused"in this.socket?this.socket.paused:void 0}): ${JSON.stringify(t)}`),!1}resetServerInactivityTimeout(){this.socket.state!=="terminated"&&(this.reconnectDueToServerInactivityTimeout!==null&&(clearTimeout(this.reconnectDueToServerInactivityTimeout),this.reconnectDueToServerInactivityTimeout=null),this.reconnectDueToServerInactivityTimeout=setTimeout(()=>{this.closeAndReconnect("InactiveServer")},this.serverInactivityThreshold))}scheduleReconnect(e){this.scheduledReconnect&&(clearTimeout(this.scheduledReconnect.timeout),this.scheduledReconnect=null),this.socket={state:"disconnected"};const t=this.nextBackoff(e);this.markConnectionStateDirty(),this.logger.log(`Attempting reconnect in ${Math.round(t)}ms`);const n=ro(),r=setTimeout(()=>{this.scheduledReconnect?.timeout===r&&(this.scheduledReconnect=null,this.connect())},t);this.scheduledReconnect={timeout:r,scheduledAt:n,backoffMs:t}}closeAndReconnect(e){switch(this._logVerbose(`begin closeAndReconnect with reason ${e}`),this.socket.state){case"disconnected":case"terminated":case"stopped":return;case"connecting":case"ready":this.lastCloseReason=e,this.close(),this.scheduleReconnect("client");return;default:this.socket}}close(){switch(this.transitionChunkBuffer=null,this.socket.state){case"disconnected":case"terminated":case"stopped":return Promise.resolve();case"connecting":{const e=this.socket.ws;return e.onmessage=t=>{this._logVerbose("Ignoring message received after close")},new Promise(t=>{e.onclose=()=>{this._logVerbose("Closed after connecting"),t()},e.onopen=()=>{this._logVerbose("Opened after connecting"),e.close()}})}case"ready":{this._logVerbose("ws.close called");const e=this.socket.ws;e.onmessage=n=>{this._logVerbose("Ignoring message received after close")};const t=new Promise(n=>{e.onclose=()=>{n()}});return e.close(),t}default:return this.socket,Promise.resolve()}}terminate(){switch(this.reconnectDueToServerInactivityTimeout&&clearTimeout(this.reconnectDueToServerInactivityTimeout),this.scheduledReconnect&&(clearTimeout(this.scheduledReconnect.timeout),this.scheduledReconnect=null),this.cleanupNetworkListener(),this.socket.state){case"terminated":case"stopped":case"disconnected":case"connecting":case"ready":{const e=this.close();return this.setSocketState({state:"terminated"}),e}default:throw this.socket,new Error(`Invalid websocket state: ${this.socket.state}`)}}stop(){switch(this.socket.state){case"terminated":return Promise.resolve();case"connecting":case"stopped":case"disconnected":case"ready":{this.cleanupNetworkListener();const e=this.close();return this.socket={state:"stopped"},e}default:return this.socket,Promise.resolve()}}tryRestart(){switch(this.socket.state){case"stopped":break;case"terminated":case"connecting":case"ready":case"disconnected":this.logger.logVerbose("Restart called without stopping first");return;default:this.socket}this.setupNetworkListener(),this.connect()}pause(){switch(this.socket.state){case"disconnected":case"stopped":case"terminated":return;case"connecting":case"ready":this.socket={...this.socket,paused:"yes"};return;default:this.socket;return}}tryReconnectImmediately(){if(this._logVerbose("tryReconnectImmediately called"),this.socket.state!=="disconnected"){this._logVerbose(`tryReconnectImmediately called but socket state is ${this.socket.state}, no action taken`);return}let e=null;if(this.scheduledReconnect){const t=ro()-this.scheduledReconnect.scheduledAt;e=Math.max(0,this.scheduledReconnect.backoffMs-t),this._logVerbose(`would have waited ${Math.round(e)}ms more (backoff was ${Math.round(this.scheduledReconnect.backoffMs)}ms, elapsed ${Math.round(t)}ms)`),clearTimeout(this.scheduledReconnect.timeout),this.scheduledReconnect=null,this._logVerbose("canceled scheduled reconnect")}this.logger.log("Network recovery detected, reconnecting immediately"),this.pendingNetworkRecoveryInfo=e!==null?{timeSavedMs:e}:null,this.connect()}resume(){switch(this.socket.state){case"connecting":this.socket={...this.socket,paused:"no"};return;case"ready":this.socket.paused==="uninitialized"?(this.socket={...this.socket,paused:"no"},this._hasEverConnected=!0,this.onOpen({connectionCount:this.connectionCount,lastCloseReason:this.lastCloseReason,clientTs:ro()})):this.socket.paused==="yes"&&(this.socket={...this.socket,paused:"no"},this.onResume());return;case"terminated":case"stopped":case"disconnected":return;default:this.socket}this.connect()}connectionState(){return{isConnected:this.socket.state==="ready",hasEverConnected:this._hasEverConnected,connectionCount:this.connectionCount,connectionRetries:this.retries}}_logVerbose(e){this.logger.logVerbose(e)}nextBackoff(e){const t=(e==="client"?100:e==="Unknown"?this.defaultInitialBackoff:XT[e].timeout)*Math.pow(2,this.retries);this.retries+=1;const n=Math.min(t,this.maxBackoff);return n+n*(Math.random()-.5)}reportLargeTransition({transition:e,messageLength:t}){if(e.clientClockSkew===void 0||e.serverTs===void 0)return;const n=ro()-e.clientClockSkew-e.serverTs/1e6,r=`${Math.round(n)}ms`,s=`${Math.round(t/1e4)/100}MB`,i=t/(n/1e3),o=`${Math.round(i/1e4)/100}MB per second`;this._logVerbose(`received ${s} transition in ${r} at ${o}`),t>2e7?this.logger.log(`received query results totaling more that 20MB (${s}) which will take a long time to download on slower connections`):n>2e4&&this.logger.log(`received query results totaling ${s} which took more than 20s to arrive (${r})`),this.debug&&this.sendMessage({type:"Event",eventType:"ClientReceivedTransition",event:{transitionTransitTime:n,messageLength:t}})}};function k3(){return R3()}function R3(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}var Ra=class extends Error{};Ra.prototype.name="InvalidTokenError";function O3(e){return decodeURIComponent(atob(e).replace(/(.)/g,(t,n)=>{let r=n.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r}))}function M3(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw new Error("base64 string is not of the correct length")}try{return O3(t)}catch{return atob(t)}}function ZT(e,t){if(typeof e!="string")throw new Ra("Invalid token specified: must be a string");t||(t={});const n=t.header===!0?0:1,r=e.split(".")[n];if(typeof r!="string")throw new Ra(`Invalid token specified: missing part #${n+1}`);let s;try{s=M3(r)}catch(i){throw new Ra(`Invalid token specified: invalid base64 for part #${n+1} (${i.message})`)}try{return JSON.parse(s)}catch(i){throw new Ra(`Invalid token specified: invalid json for part #${n+1} (${i.message})`)}}var N3=Object.defineProperty,P3=(e,t,n)=>t in e?N3(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,sn=(e,t,n)=>P3(e,typeof t!="symbol"?t+"":t,n),L3=1728e6,Xy=2,_3=class{constructor(e,t,n){sn(this,"authState",{state:"noAuth"}),sn(this,"configVersion",0),sn(this,"syncState"),sn(this,"authenticate"),sn(this,"stopSocket"),sn(this,"tryRestartSocket"),sn(this,"pauseSocket"),sn(this,"resumeSocket"),sn(this,"clearAuth"),sn(this,"logger"),sn(this,"refreshTokenLeewaySeconds"),sn(this,"initialAuthTokenReuse"),sn(this,"lastRefreshChange"),sn(this,"tokenConfirmationAttempts",0),this.syncState=e,this.authenticate=t.authenticate,this.stopSocket=t.stopSocket,this.tryRestartSocket=t.tryRestartSocket,this.pauseSocket=t.pauseSocket,this.resumeSocket=t.resumeSocket,this.clearAuth=t.clearAuth,this.logger=n.logger,this.refreshTokenLeewaySeconds=n.refreshTokenLeewaySeconds,this.initialAuthTokenReuse=n.initialAuthTokenReuse,this.lastRefreshChange=!1}notifyRefreshChange(e){this.authState.state!=="noAuth"&&this.authState.state!=="initialRefetch"&&this.authState.config.onRefreshChange&&this.lastRefreshChange!==e&&(this.lastRefreshChange=e,this.authState.config.onRefreshChange(e))}async setConfig(e,t,n){this.resetAuthState(),this._logVerbose("pausing WS for auth token fetch"),this.pauseSocket();const r=await this.fetchTokenAndGuardAgainstRace(e,{forceRefreshToken:!1});if(r.isFromOutdatedConfig)return;const s={fetchToken:e,onAuthChange:t,onRefreshChange:n};r.value?(this.setAuthState({state:"waitingForServerConfirmationOfCachedToken",config:s,hasRetried:!1}),this.authenticate(r.value)):(this.setAuthState({state:"initialRefetch",config:s}),await this.refetchToken()),this._logVerbose("resuming WS after auth token fetch"),this.resumeSocket()}onTransition(e){if(this.syncState.isCurrentOrNewerAuthVersion(e.endVersion.identity)&&!(e.endVersion.identity<=e.startVersion.identity)){if(this._logVerbose(`auth state is ${this.authState.state} when handling transition`),this.syncState.markAuthCompletion(),this.authState.state==="waitingForServerConfirmationOfCachedToken"){this._logVerbose("server confirmed auth token is valid");const t=this.syncState.getAuth()?.value;this.initialAuthTokenReuse&&t?this.scheduleTokenRefetch(t,e.clientClockSkew):this.refetchToken(),this.authState.config.onAuthChange(!0);return}this.authState.state==="waitingForServerConfirmationOfFreshToken"&&(this._logVerbose("server confirmed new auth token is valid"),this.notifyRefreshChange(!1),this.scheduleTokenRefetch(this.authState.token),this.tokenConfirmationAttempts=0,this.authState.hadAuth||this.authState.config.onAuthChange(!0))}}onAuthError(e){if(e.authUpdateAttempted===!1&&(this.authState.state==="waitingForServerConfirmationOfFreshToken"||this.authState.state==="waitingForServerConfirmationOfCachedToken")){this._logVerbose("ignoring non-auth token expired error");return}const{baseVersion:t}=e;if(!this.syncState.isCurrentOrNewerAuthVersion(t+1)){this._logVerbose("ignoring auth error for previous auth attempt");return}this.tryToReauthenticate(e)}async tryToReauthenticate(e){if(this._logVerbose(`attempting to reauthenticate: ${e.error}`),this.authState.state==="noAuth"||this.authState.state==="waitingForServerConfirmationOfFreshToken"&&this.tokenConfirmationAttempts>=Xy){this.logger.error(`Failed to authenticate: "${e.error}", check your server auth config`),this.syncState.hasAuth()&&this.syncState.clearAuth(),this.authState.state!=="noAuth"&&this.setAndReportAuthFailed(this.authState.config.onAuthChange);return}if(this.authState.state==="waitingForServerConfirmationOfFreshToken"&&(this.tokenConfirmationAttempts++,this._logVerbose(`retrying reauthentication, ${Xy-this.tokenConfirmationAttempts} attempts remaining`)),this.notifyRefreshChange(!0),await this.stopSocket(),this.authState.state==="noAuth")return;const t=await this.fetchTokenAndGuardAgainstRace(this.authState.config.fetchToken,{forceRefreshToken:!0});t.isFromOutdatedConfig||(t.value&&this.syncState.isNewAuth(t.value)?(this.authenticate(t.value),this.setAuthState({state:"waitingForServerConfirmationOfFreshToken",config:this.authState.config,token:t.value,hadAuth:this.authState.state==="notRefetching"||this.authState.state==="waitingForScheduledRefetch"})):(this._logVerbose("reauthentication failed, could not fetch a new token"),this.syncState.hasAuth()&&this.syncState.clearAuth(),this.setAndReportAuthFailed(this.authState.config.onAuthChange)),this.tryRestartSocket())}async refetchToken(){if(this.authState.state==="noAuth")return;this._logVerbose("refetching auth token");const e=await this.fetchTokenAndGuardAgainstRace(this.authState.config.fetchToken,{forceRefreshToken:!0});e.isFromOutdatedConfig||(e.value?this.syncState.isNewAuth(e.value)?(this.setAuthState({state:"waitingForServerConfirmationOfFreshToken",hadAuth:this.syncState.hasAuth(),token:e.value,config:this.authState.config}),this.authenticate(e.value)):this.setAuthState({state:"notRefetching",config:this.authState.config}):(this._logVerbose("refetching token failed"),this.syncState.hasAuth()&&this.clearAuth(),this.setAndReportAuthFailed(this.authState.config.onAuthChange)),this._logVerbose("restarting WS after auth token fetch (if currently stopped)"),this.tryRestartSocket())}scheduleTokenRefetch(e,t){if(this.authState.state==="noAuth")return;const n=this.decodeToken(e);if(!n){this.logger.error("Auth token is not a valid JWT, cannot refetch the token");return}const{iat:r,exp:s}=n;if(!r||!s){this.logger.error("Auth token does not have required fields, cannot refetch the token");return}const i=s-r;if(i<=2){this.logger.error("Auth token does not live long enough, cannot refetch the token");return}let o;t!==void 0?(o=s-(Date.now()-t)/1e3,o<=0&&(o=0)):o=i;let a=Math.min(L3,(o-this.refreshTokenLeewaySeconds)*1e3);a<=0&&(this.logger.warn(`Refetching auth token immediately, configured leeway ${this.refreshTokenLeewaySeconds}s is larger than the token's lifetime ${o}s`),a=0);const l=setTimeout(()=>{this._logVerbose("running scheduled token refetch"),this.refetchToken()},a);this.setAuthState({state:"waitingForScheduledRefetch",refetchTokenTimeoutId:l,config:this.authState.config}),this._logVerbose(`scheduled preemptive auth token refetching in ${a}ms`)}async fetchTokenAndGuardAgainstRace(e,t){const n=++this.configVersion;this._logVerbose(`fetching token with config version ${n}`);const r=await e(t);return this.configVersion!==n?(this._logVerbose(`stale config version, expected ${n}, got ${this.configVersion}`),{isFromOutdatedConfig:!0}):{isFromOutdatedConfig:!1,value:r}}stop(){this.resetAuthState(),this.configVersion++,this._logVerbose(`config version bumped to ${this.configVersion}`)}setAndReportAuthFailed(e){e(!1),this.resetAuthState()}resetAuthState(){this.notifyRefreshChange(!1),this.setAuthState({state:"noAuth"})}setAuthState(e){const t=e.state==="waitingForServerConfirmationOfFreshToken"?{hadAuth:e.hadAuth,state:e.state,token:`...${e.token.slice(-7)}`}:{state:e.state};switch(this._logVerbose(`setting auth state to ${JSON.stringify(t)}`),e.state){case"waitingForScheduledRefetch":case"notRefetching":case"noAuth":this.tokenConfirmationAttempts=0}this.authState.state==="waitingForScheduledRefetch"&&clearTimeout(this.authState.refetchTokenTimeoutId),this.authState=e}decodeToken(e){try{return ZT(e)}catch(t){return this._logVerbose(`Error decoding token: ${t instanceof Error?t.message:"Unknown error"}`),null}}_logVerbose(e){this.logger.logVerbose(`${e} [v${this.configVersion}]`)}},F3=["convexClientConstructed","convexWebSocketOpen","convexFirstMessageReceived"];function H3(e,t){const n={sessionId:t};typeof performance>"u"||!performance.mark||performance.mark(e,{detail:n})}function j3(e){let t=e.name.slice(6);return t=t.charAt(0).toLowerCase()+t.slice(1),{name:t,startTime:e.startTime}}function G3(e){if(typeof performance>"u"||!performance.getEntriesByName)return[];const t=[];for(const n of F3){const r=performance.getEntriesByName(n).filter(s=>s.entryType==="mark").filter(s=>s.detail.sessionId===e);t.push(...r)}return t.map(j3)}var V3=Object.defineProperty,U3=(e,t,n)=>t in e?V3(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,yt=(e,t,n)=>U3(e,typeof t!="symbol"?t+"":t,n),z3=class{constructor(e,t,n){if(yt(this,"address"),yt(this,"state"),yt(this,"requestManager"),yt(this,"webSocketManager"),yt(this,"authenticationManager"),yt(this,"remoteQuerySet"),yt(this,"optimisticQueryResults"),yt(this,"_transitionHandlerCounter",0),yt(this,"_nextRequestId"),yt(this,"_onTransitionFns",new Map),yt(this,"_sessionId"),yt(this,"firstMessageReceived",!1),yt(this,"debug"),yt(this,"logger"),yt(this,"maxObservedTimestamp"),yt(this,"connectionStateSubscribers",new Map),yt(this,"nextConnectionStateSubscriberId",0),yt(this,"_lastPublishedConnectionState"),yt(this,"markConnectionStateDirty",()=>{Promise.resolve().then(()=>{const h=this.connectionState();if(JSON.stringify(h)!==JSON.stringify(this._lastPublishedConnectionState)){this._lastPublishedConnectionState=h;for(const f of this.connectionStateSubscribers.values())f(h)}})}),yt(this,"mark",h=>{this.debug&&H3(h,this.sessionId)}),typeof e=="object")throw new Error("Passing a ClientConfig object is no longer supported. Pass the URL of the Convex deployment as a string directly.");n?.skipConvexDeploymentUrlCheck!==!0&&BN(e),n={...n};const r=n.authRefreshTokenLeewaySeconds??10;let s=n.webSocketConstructor;if(!s&&typeof WebSocket>"u")throw new Error("No WebSocket global variable defined! To use Convex in an environment without WebSocket try the HTTP client: https://docs.convex.dev/api/classes/browser.ConvexHttpClient");s=s||WebSocket,this.debug=n.reportDebugInfoToConvex??!1,this.address=e,this.logger=n.logger===!1?YT({verbose:n.verbose??!1}):n.logger!==!0&&n.logger?n.logger:QT({verbose:n.verbose??!1});const i=e.search("://");if(i===-1)throw new Error("Provided address was not an absolute URL.");const o=e.substring(i+3),a=e.substring(0,i);let l;if(a==="http")l="ws";else if(a==="https")l="wss";else throw new Error(`Unknown parent protocol ${a}`);const c=`${l}://${o}/api/${Uy}/sync`;this.state=new a3,this.remoteQuerySet=new Jy(h=>this.state.queryPath(h),this.logger),this.requestManager=new u3(this.logger,this.markConnectionStateDirty);const u=()=>{this.webSocketManager.pause(),this.state.pause()};this.authenticationManager=new _3(this.state,{authenticate:h=>{const f=this.state.setAuth(h);return this.webSocketManager.sendMessage(f),f.baseVersion},stopSocket:()=>this.webSocketManager.stop(),tryRestartSocket:()=>this.webSocketManager.tryRestart(),pauseSocket:u,resumeSocket:()=>this.webSocketManager.resume(),clearAuth:()=>{this.clearAuth()}},{logger:this.logger,refreshTokenLeewaySeconds:r,initialAuthTokenReuse:n.initialAuthTokenReuse??!1}),this.optimisticQueryResults=new f3,this.addOnTransitionHandler(h=>{t(h.queries.map(f=>f.token))}),this._nextRequestId=0,this._sessionId=k3();const{unsavedChangesWarning:d}=n;if(typeof window>"u"||typeof window.addEventListener>"u"){if(d===!0)throw new Error("unsavedChangesWarning requested, but window.addEventListener not found! Remove {unsavedChangesWarning: true} from Convex client options.")}else d!==!1&&window.addEventListener("beforeunload",h=>{if(this.requestManager.hasIncompleteRequests()){h.preventDefault();const f="Are you sure you want to leave? Your changes may not be saved.";return(h||window.event).returnValue=f,f}});this.webSocketManager=new I3(c,{onOpen:h=>{this.mark("convexWebSocketOpen"),this.webSocketManager.sendMessage({...h,type:"Connect",sessionId:this._sessionId,maxObservedTimestamp:this.maxObservedTimestamp}),this.remoteQuerySet=new Jy(g=>this.state.queryPath(g),this.logger);const[f,B]=this.state.restart();B&&this.webSocketManager.sendMessage(B),this.webSocketManager.sendMessage(f);for(const g of this.requestManager.restart())this.webSocketManager.sendMessage(g)},onResume:()=>{const[h,f]=this.state.resume();f&&this.webSocketManager.sendMessage(f),h&&this.webSocketManager.sendMessage(h);for(const B of this.requestManager.resume())this.webSocketManager.sendMessage(B)},onMessage:h=>{switch(this.firstMessageReceived||(this.firstMessageReceived=!0,this.mark("convexFirstMessageReceived"),this.reportMarks()),h.type){case"Transition":{this.observedTimestamp(h.endVersion.ts),this.authenticationManager.onTransition(h),this.remoteQuerySet.transition(h),this.state.transition(h);const f=this.requestManager.removeCompleted(this.remoteQuerySet.timestamp());this.notifyOnQueryResultChanges(f);break}case"MutationResponse":{h.success&&this.observedTimestamp(h.ts);const f=this.requestManager.onResponse(h);f!==null&&this.notifyOnQueryResultChanges(new Map([[f.requestId,f.result]]));break}case"ActionResponse":this.requestManager.onResponse(h);break;case"AuthError":this.authenticationManager.onAuthError(h);break;case"FatalError":{const f=s3(this.logger,h.error);throw this.webSocketManager.terminate(),f}}return{hasSyncedPastLastReconnect:this.hasSyncedPastLastReconnect()}},onServerDisconnectError:n.onServerDisconnectError},s,this.logger,this.markConnectionStateDirty,this.debug),this.mark("convexClientConstructed"),n.expectAuth&&u()}hasSyncedPastLastReconnect(){return this.requestManager.hasSyncedPastLastReconnect()&&this.state.hasSyncedPastLastReconnect()}observedTimestamp(e){(this.maxObservedTimestamp===void 0||this.maxObservedTimestamp.lessThanOrEqual(e))&&(this.maxObservedTimestamp=e)}getMaxObservedTimestamp(){return this.maxObservedTimestamp}notifyOnQueryResultChanges(e){const t=this.remoteQuerySet.remoteQueryResults(),n=new Map;for(const[s,i]of t){const o=this.state.queryToken(s);if(o!==null){const a={result:i,udfPath:this.state.queryPath(s),args:this.state.queryArgs(s)};n.set(o,a)}}const r=this.optimisticQueryResults.ingestQueryResultsFromServer(n,new Set(e.keys()));this.handleTransition({queries:r.map(s=>({token:s,modification:{kind:"Updated",result:this.optimisticQueryResults.rawQueryResult(s)}})),reflectedMutations:Array.from(e).map(([s,i])=>({requestId:s,result:i})),timestamp:this.remoteQuerySet.timestamp()})}handleTransition(e){for(const t of this._onTransitionFns.values())t(e)}addOnTransitionHandler(e){const t=this._transitionHandlerCounter++;return this._onTransitionFns.set(t,e),()=>this._onTransitionFns.delete(t)}getCurrentAuthClaims(){const e=this.state.getAuth();let t={};if(e&&e.tokenType==="User")try{t=e?ZT(e.value):{}}catch{t={}}else return;return{token:e.value,decoded:t}}setAuth(e,t,n){this.authenticationManager.setConfig(e,t,n)}hasAuth(){return this.state.hasAuth()}setAdminAuth(e,t){const n=this.state.setAdminAuth(e,t);this.webSocketManager.sendMessage(n)}clearAuth(){const e=this.state.clearAuth();this.webSocketManager.sendMessage(e)}subscribe(e,t,n){const r=Wr(t),{modification:s,queryToken:i,unsubscribe:o}=this.state.subscribe(e,r,n?.journal,n?.componentPath);return s!==null&&this.webSocketManager.sendMessage(s),{queryToken:i,unsubscribe:()=>{const a=o();a&&this.webSocketManager.sendMessage(a)}}}localQueryResult(e,t){const n=Wr(t),r=xi(e,n);return this.optimisticQueryResults.queryResult(r)}localQueryResultByToken(e){return this.optimisticQueryResults.queryResult(e)}hasLocalQueryResultByToken(e){return this.optimisticQueryResults.hasQueryResult(e)}localQueryLogs(e,t){const n=Wr(t),r=xi(e,n);return this.optimisticQueryResults.queryLogs(r)}queryJournal(e,t){const n=Wr(t),r=xi(e,n);return this.state.queryJournal(r)}connectionState(){const e=this.webSocketManager.connectionState();return{hasInflightRequests:this.requestManager.hasInflightRequests(),isWebSocketConnected:e.isConnected,hasEverConnected:e.hasEverConnected,connectionCount:e.connectionCount,connectionRetries:e.connectionRetries,timeOfOldestInflightRequest:this.requestManager.timeOfOldestInflightRequest(),inflightMutations:this.requestManager.inflightMutations(),inflightActions:this.requestManager.inflightActions()}}subscribeToConnectionState(e){const t=this.nextConnectionStateSubscriberId++;return this.connectionStateSubscribers.set(t,e),()=>{this.connectionStateSubscribers.delete(t)}}async mutation(e,t,n){const r=await this.mutationInternal(e,t,n);if(!r.success)throw r.errorData!==void 0?Ip(r,new MB(mo("mutation",e,r))):new Error(mo("mutation",e,r));return r.value}async mutationInternal(e,t,n,r){const{mutationPromise:s}=this.enqueueMutation(e,t,n,r);return s}enqueueMutation(e,t,n,r){const s=Wr(t);this.tryReportLongDisconnect();const i=this.nextRequestId;if(this._nextRequestId++,n!==void 0){const l=n.optimisticUpdate;if(l!==void 0){const c=d=>{l(d,s)instanceof Promise&&this.logger.warn("Optimistic update handler returned a Promise. Optimistic updates should be synchronous.")},u=this.optimisticQueryResults.applyOptimisticUpdate(c,i).map(d=>{const h=this.localQueryResultByToken(d);return{token:d,modification:{kind:"Updated",result:h===void 0?void 0:{success:!0,value:h,logLines:[]}}}});this.handleTransition({queries:u,reflectedMutations:[],timestamp:this.remoteQuerySet.timestamp()})}}const o={type:"Mutation",requestId:i,udfPath:e,componentPath:r,args:[Pr(s)]},a=this.webSocketManager.sendMessage(o);return{requestId:i,mutationPromise:this.requestManager.request(o,a)}}async action(e,t){const n=await this.actionInternal(e,t);if(!n.success)throw n.errorData!==void 0?Ip(n,new MB(mo("action",e,n))):new Error(mo("action",e,n));return n.value}async actionInternal(e,t,n){const r=Wr(t),s=this.nextRequestId;this._nextRequestId++,this.tryReportLongDisconnect();const i={type:"Action",requestId:s,udfPath:e,componentPath:n,args:[Pr(r)]},o=this.webSocketManager.sendMessage(i);return this.requestManager.request(i,o)}async close(){return this.authenticationManager.stop(),this.webSocketManager.terminate()}get url(){return this.address}get nextRequestId(){return this._nextRequestId}get sessionId(){return this._sessionId}reportMarks(){if(this.debug){const e=G3(this.sessionId);this.webSocketManager.sendMessage({type:"Event",eventType:"ClientConnect",event:e})}}tryReportLongDisconnect(){if(!this.debug)return;const e=this.connectionState().timeOfOldestInflightRequest;if(e===null||Date.now()-e.getTime()<=6e4)return;const t=`${this.address}/api/debug_event`;fetch(t,{method:"POST",headers:{"Content-Type":"application/json","Convex-Client":`npm-${Uy}`},body:JSON.stringify({event:"LongWebsocketDisconnect"})}).then(n=>{n.ok||this.logger.warn("Analytics request failed with response:",n.body)}).catch(n=>{this.logger.warn("Analytics response failed with error:",n)})}};function Lf(e){if(typeof e!="object"||e===null||!Array.isArray(e.page)||typeof e.isDone!="boolean"||typeof e.continueCursor!="string")throw new Error(`Not a valid paginated query result: ${e?.toString()}`);return e}var $3=Object.defineProperty,W3=(e,t,n)=>t in e?$3(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Zy=(e,t,n)=>W3(e,typeof t!="symbol"?t+"":t,n),q3=class{constructor(e,t){this.client=e,this.onTransition=t,Zy(this,"paginatedQuerySet",new Map),Zy(this,"lastTransitionTs"),this.lastTransitionTs=cc.fromNumber(0),this.client.addOnTransitionHandler(n=>this.onBaseTransition(n))}subscribe(e,t,n){const r=Ni(e),s=$y(r,t,n),i=()=>this.removePaginatedQuerySubscriber(s),o=this.paginatedQuerySet.get(s);return o?(o.numSubscribers+=1,{paginatedQueryToken:s,unsubscribe:i}):(this.paginatedQuerySet.set(s,{token:s,canonicalizedUdfPath:r,args:t,numSubscribers:1,options:{initialNumItems:n.initialNumItems},nextPageKey:0,pageKeys:[],pageKeyToQuery:new Map,ongoingSplits:new Map,skip:!1,id:n.id}),this.addPageToPaginatedQuery(s,null,n.initialNumItems),{paginatedQueryToken:s,unsubscribe:i})}localQueryResult(e,t,n){const r=Ni(e),s=$y(r,t,n);return this.localQueryResultByToken(s)}localQueryResultByToken(e){const t=this.paginatedQuerySet.get(e);if(!t)return;const n=this.activePageQueryTokens(t);if(n.length===0)return{results:[],status:"LoadingFirstPage",loadMore:a=>this.loadMoreOfPaginatedQuery(e,a)};let r=[],s=!1,i=!1;for(const a of n){const l=this.client.localQueryResultByToken(a);if(l===void 0){s=!0,i=!1;continue}const c=Lf(l);r=r.concat(c.page),i=!!c.isDone}let o;return s?o=r.length===0?"LoadingFirstPage":"LoadingMore":i?o="Exhausted":o="CanLoadMore",{results:r,status:o,loadMore:a=>this.loadMoreOfPaginatedQuery(e,a)}}onBaseTransition(e){const t=e.queries.map(i=>i.token),n=this.queriesContainingTokens(t);let r=[];n.length>0&&(this.processPaginatedQuerySplits(n,i=>this.client.localQueryResultByToken(i)),r=n.map(i=>({token:i,modification:{kind:"Updated",result:this.localQueryResultByToken(i)}})));const s={...e,paginatedQueries:r};this.onTransition(s)}loadMoreOfPaginatedQuery(e,t){this.mustGetPaginatedQuery(e);const n=this.queryTokenForLastPageOfPaginatedQuery(e),r=this.client.localQueryResultByToken(n);if(!r)return!1;const s=Lf(r);if(s.isDone)return!1;this.addPageToPaginatedQuery(e,s.continueCursor,t);const i={timestamp:this.lastTransitionTs,reflectedMutations:[],queries:[],paginatedQueries:[{token:e,modification:{kind:"Updated",result:this.localQueryResultByToken(e)}}]};return this.onTransition(i),!0}queriesContainingTokens(e){if(e.length===0)return[];const t=[],n=new Set(e);for(const[r,s]of this.paginatedQuerySet)for(const i of this.allQueryTokens(s))if(n.has(i)){t.push(r);break}return t}processPaginatedQuerySplits(e,t){for(const n of e){const r=this.mustGetPaginatedQuery(n),{ongoingSplits:s,pageKeyToQuery:i,pageKeys:o}=r;for(const[a,[l,c]]of s)t(i.get(l).queryToken)!==void 0&&t(i.get(c).queryToken)!==void 0&&this.completePaginatedQuerySplit(r,a,l,c);for(const a of o){if(s.has(a))continue;const l=i.get(a);if(!l)throw new Error(`No page query for active pageKey ${a}`);const c=t(l.queryToken);if(!c)continue;const u=Lf(c);u.splitCursor&&(u.pageStatus==="SplitRecommended"||u.pageStatus==="SplitRequired"||u.page.length>r.options.initialNumItems*2)&&this.splitPaginatedQueryPage(r,a,l.cursor,u.splitCursor,u.continueCursor)}}}splitPaginatedQueryPage(e,t,n,r,s){const i=e.nextPageKey++,o=e.nextPageKey++,a={numItems:e.options.initialNumItems,id:e.id},l=this.client.subscribe(e.canonicalizedUdfPath,{...e.args,paginationOpts:{...a,cursor:n,endCursor:r}});e.pageKeyToQuery.set(i,{...l,cursor:n});const c=this.client.subscribe(e.canonicalizedUdfPath,{...e.args,paginationOpts:{...a,cursor:r,endCursor:s}});e.pageKeyToQuery.set(o,{...c,cursor:r}),e.ongoingSplits.set(t,[i,o])}addPageToPaginatedQuery(e,t,n){const r=this.mustGetPaginatedQuery(e),s=r.nextPageKey++,i={cursor:t,numItems:n,id:r.id},o={...r.args,paginationOpts:i},a=this.client.subscribe(r.canonicalizedUdfPath,o);return r.pageKeys.push(s),r.pageKeyToQuery.set(s,{...a,cursor:t}),a}removePaginatedQuerySubscriber(e){const t=this.paginatedQuerySet.get(e);if(t&&(t.numSubscribers-=1,!(t.numSubscribers>0))){for(const n of t.pageKeyToQuery.values())n.unsubscribe();this.paginatedQuerySet.delete(e)}}completePaginatedQuerySplit(e,t,n,r){const s=e.pageKeyToQuery.get(t);e.pageKeyToQuery.delete(t);const i=e.pageKeys.indexOf(t);e.pageKeys.splice(i,1,n,r),e.ongoingSplits.delete(t),s.unsubscribe()}activePageQueryTokens(e){return e.pageKeys.map(t=>e.pageKeyToQuery.get(t).queryToken)}allQueryTokens(e){return Array.from(e.pageKeyToQuery.values()).map(t=>t.queryToken)}queryTokenForLastPageOfPaginatedQuery(e){const t=this.mustGetPaginatedQuery(e),n=t.pageKeys[t.pageKeys.length-1];if(n===void 0)throw new Error(`No pages for paginated query ${e}`);return t.pageKeyToQuery.get(n).queryToken}mustGetPaginatedQuery(e){const t=this.paginatedQuerySet.get(e);if(!t)throw new Error("paginated query no longer exists for token "+e);return t}};function K3({getCurrentValue:e,subscribe:t}){const[n,r]=(0,p.useState)(()=>({getCurrentValue:e,subscribe:t,value:e()}));let s=n.value;return(n.getCurrentValue!==e||n.subscribe!==t)&&(s=e(),r({getCurrentValue:e,subscribe:t,value:s})),(0,p.useEffect)(()=>{let i=!1;const o=()=>{i||r(l=>{if(l.getCurrentValue!==e||l.subscribe!==t)return l;const c=e();return l.value===c?l:{...l,value:c}})},a=t(o);return o(),()=>{i=!0,a()}},[e,t]),s}var J3=Object.defineProperty,Q3=(e,t,n)=>t in e?J3(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,jr=(e,t,n)=>Q3(e,typeof t!="symbol"?t+"":t,n),Y3=5e3;if(typeof p.default>"u")throw new Error("Required dependency 'react' not found");function eA(e,t,n){function r(s){return e$(s),t.mutation(e,s,{optimisticUpdate:n})}return r.withOptimisticUpdate=function(i){if(n!==void 0)throw new Error(`Already specified optimistic update for mutation ${tn(e)}`);return eA(e,t,i)},r}function X3(e,t){return function(n){return t.action(e,n)}}var rse=class{constructor(e,t){if(jr(this,"address"),jr(this,"cachedSync"),jr(this,"cachedPaginatedQueryClient"),jr(this,"listeners"),jr(this,"options"),jr(this,"closed",!1),jr(this,"_logger"),jr(this,"adminAuth"),jr(this,"fakeUserIdentity"),e===void 0)throw new Error("No address provided to ConvexReactClient.\nIf trying to deploy to production, make sure to follow all the instructions found at https://docs.convex.dev/production/hosting/\nIf running locally, make sure to run `convex dev` and ensure the .env.local file is populated.");if(typeof e!="string")throw new Error(`ConvexReactClient requires a URL like 'https://happy-otter-123.convex.cloud', received something of type ${typeof e} instead.`);if(!e.includes("://"))throw new Error("Provided address was not an absolute URL.");this.address=e,this.listeners=new Map,this._logger=t?.logger===!1?YT({verbose:t?.verbose??!1}):t?.logger!==!0&&t?.logger?t.logger:QT({verbose:t?.verbose??!1}),this.options={...t,logger:this._logger}}get url(){return this.address}get sync(){if(this.closed)throw new Error("ConvexReactClient has already been closed.");return this.cachedSync?this.cachedSync:(this.cachedSync=this.options.baseClient??new z3(this.address,()=>{},this.options),this.adminAuth&&this.cachedSync.setAdminAuth(this.adminAuth,this.fakeUserIdentity),this.cachedPaginatedQueryClient=new q3(this.cachedSync,e=>this.handleTransition(e)),this.cachedSync)}get paginatedQueryClient(){if(this.sync,this.cachedPaginatedQueryClient)return this.cachedPaginatedQueryClient;throw new Error("Should already be instantiated")}setAuth(e,t,n){if(typeof e=="string")throw new Error("Passing a string to ConvexReactClient.setAuth is no longer supported, please upgrade to passing in an async function to handle reauthentication.");this.sync.setAuth(e,t??(()=>{}),n)}clearAuth(){this.sync.clearAuth()}setAdminAuth(e,t){if(this.adminAuth=e,this.fakeUserIdentity=t,this.closed)throw new Error("ConvexReactClient has already been closed.");this.cachedSync&&this.sync.setAdminAuth(e,t)}watchQuery(e,...t){const[n,r]=t,s=tn(e);return{onUpdate:i=>{const{queryToken:o,unsubscribe:a}=this.sync.subscribe(s,n,r),l=this.listeners.get(o);return l!==void 0?l.add(i):this.listeners.set(o,new Set([i])),()=>{if(this.closed)return;const c=this.listeners.get(o);c.delete(i),c.size===0&&this.listeners.delete(o),a()}},localQueryResult:()=>{if(this.cachedSync)return this.cachedSync.localQueryResult(s,n)},localQueryLogs:()=>{if(this.cachedSync)return this.cachedSync.localQueryLogs(s,n)},journal:()=>{if(this.cachedSync)return this.cachedSync.queryJournal(s,n)}}}prewarmQuery(e){const t=e.extendSubscriptionFor??Y3,n=this.watchQuery(e.query,e.args||{}).onUpdate(()=>{});setTimeout(n,t)}watchPaginatedQuery(e,t,n){const r=tn(e);return{onUpdate:s=>{const{paginatedQueryToken:i,unsubscribe:o}=this.paginatedQueryClient.subscribe(r,t||{},n),a=this.listeners.get(i);return a!==void 0?a.add(s):this.listeners.set(i,new Set([s])),()=>{if(this.closed)return;const l=this.listeners.get(i);l.delete(s),l.size===0&&this.listeners.delete(i),o()}},localQueryResult:()=>this.paginatedQueryClient.localQueryResult(r,t,n)}}mutation(e,...t){const[n,r]=t,s=tn(e);return this.sync.mutation(s,n,r)}action(e,...t){const n=tn(e);return this.sync.action(n,...t)}query(e,...t){const n=this.watchQuery(e,...t),r=n.localQueryResult();return r!==void 0?Promise.resolve(r):new Promise((s,i)=>{const o=n.onUpdate(()=>{o();try{s(n.localQueryResult())}catch(a){i(a)}})})}connectionState(){return this.sync.connectionState()}subscribeToConnectionState(e){return this.sync.subscribeToConnectionState(e)}get logger(){return this._logger}async close(){if(this.closed=!0,this.listeners=new Map,this.cachedPaginatedQueryClient&&(this.cachedPaginatedQueryClient=void 0),this.cachedSync){const e=this.cachedSync;this.cachedSync=void 0,await e.close()}}handleTransition(e){const t=e.queries.map(r=>r.token),n=e.paginatedQueries.map(r=>r.token);this.transition([...t,...n])}transition(e){for(const t of e){const n=this.listeners.get(t);if(n)for(const r of n)r()}}},Eh=p.createContext(void 0);function Z3(){return(0,p.useContext)(Eh)}var sse=({client:e,children:t})=>p.createElement(Eh.Provider,{value:e},t);function tA(e,...t){const n=t[0]==="skip",r=t[0]==="skip"?{}:Wr(t[0]),s=typeof e=="string"?Sh(e):e,i=tn(s),o=(0,p.useMemo)(()=>n?{}:{query:{query:s,args:r}},[JSON.stringify(Pr(r)),i,n]),a=s$(o).query;if(a instanceof Error)throw a;return a}function ise(e){const t=typeof e=="string"?Sh(e):e,n=(0,p.useContext)(Eh);if(n===void 0)throw new Error("Could not find Convex client! `useMutation` must be used in the React component tree under `ConvexProvider`. Did you forget it? See https://docs.convex.dev/quick-start#set-up-convex-in-your-react-app");return(0,p.useMemo)(()=>eA(t,n),[n,tn(t)])}function ose(e){const t=(0,p.useContext)(Eh),n=typeof e=="string"?Sh(e):e;if(t===void 0)throw new Error("Could not find Convex client! `useAction` must be used in the React component tree under `ConvexProvider`. Did you forget it? See https://docs.convex.dev/quick-start#set-up-convex-in-your-react-app");return(0,p.useMemo)(()=>X3(n,t),[t,tn(n)])}function e$(e){if(typeof e=="object"&&e!==null&&"bubbles"in e&&"persist"in e&&"isDefaultPrevented"in e)throw new Error("Convex function called with SyntheticEvent object. Did you use a Convex function as an event handler directly? Event handlers like onClick receive an event object as their first argument. These SyntheticEvent objects are not valid Convex values. Try wrapping the function like `const handler = () => myMutation();` and using `handler` in the event handler.")}var t$=Object.defineProperty,n$=(e,t,n)=>t in e?t$(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,_f=(e,t,n)=>n$(e,typeof t!="symbol"?t+"":t,n),r$=class{constructor(e){_f(this,"createWatch"),_f(this,"queries"),_f(this,"listeners"),this.createWatch=e,this.queries={},this.listeners=new Set}setQueries(e){for(const t of Object.keys(e)){const{query:n,args:r,paginationOptions:s}=e[t];if(tn(n),this.queries[t]===void 0)this.addQuery(t,n,r,s?{paginationOptions:s}:{});else{const i=this.queries[t];(tn(n)!==tn(i.query)||JSON.stringify(Pr(r))!==JSON.stringify(Pr(i.args))||JSON.stringify(s)!==JSON.stringify(i.paginationOptions))&&(this.removeQuery(t),this.addQuery(t,n,r,s?{paginationOptions:s}:{}))}}for(const t of Object.keys(this.queries))e[t]===void 0&&this.removeQuery(t)}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}getLocalResults(e){const t={};for(const n of Object.keys(e)){const{query:r,args:s}=e[n],i=e[n].paginationOptions;tn(r);const o=this.createWatch(r,s,i?{paginationOptions:i}:{});let a;try{a=o.localQueryResult()}catch(l){if(l instanceof Error)a=l;else throw l}t[n]=a}return t}setCreateWatch(e){this.createWatch=e;for(const t of Object.keys(this.queries)){const{query:n,args:r,watch:s,paginationOptions:i}=this.queries[t],o="journal"in s?s.journal():void 0;this.removeQuery(t),this.addQuery(t,n,r,{...o?{journal:o}:[],...i?{paginationOptions:i}:{}})}}destroy(){for(const e of Object.keys(this.queries))this.removeQuery(e);this.listeners=new Set}addQuery(e,t,n,{paginationOptions:r,journal:s}){if(this.queries[e]!==void 0)throw new Error(`Tried to add a new query with identifier ${e} when it already exists.`);const i=this.createWatch(t,n,{...s?{journal:s}:[],...r?{paginationOptions:r}:{}}),o=i.onUpdate(()=>this.notifyListeners());this.queries[e]={query:t,args:n,watch:i,unsubscribe:o,...r?{paginationOptions:r}:{}}}removeQuery(e){const t=this.queries[e];if(t===void 0)throw new Error(`No query found with identifier ${e}.`);t.unsubscribe(),delete this.queries[e]}notifyListeners(){for(const e of this.listeners)e()}};function s$(e){const t=Z3();if(t===void 0)throw new Error("Could not find Convex client! `useQuery` must be used in the React component tree under `ConvexProvider`. Did you forget it? See https://docs.convex.dev/quick-start#set-up-convex-in-your-react-app");return i$(e,(0,p.useMemo)(()=>(n,r,{journal:s,paginationOptions:i})=>i?t.watchPaginatedQuery(n,r,i):t.watchQuery(n,r,s?{journal:s}:{}),[t]))}function i$(e,t){const[n]=(0,p.useState)(()=>new r$(t));n.createWatch!==t&&n.setCreateWatch(t),(0,p.useEffect)(()=>()=>n.destroy(),[n]);const r=(0,p.useMemo)(()=>({getCurrentValue:()=>n.getLocalResults(e),subscribe:s=>(n.setQueries(e),n.subscribe(s))}),[n,e]);return K3(r)}function o$(e){if(!e||typeof document>"u")return;let t=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",t.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}var a$=e=>{switch(e){case"success":return u$;case"info":return h$;case"warning":return d$;case"error":return f$;default:return null}},l$=Array(12).fill(0),c$=({visible:e,className:t})=>p.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},p.createElement("div",{className:"sonner-spinner"},l$.map((n,r)=>p.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),u$=p.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20","aria-hidden":"true"},p.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),d$=p.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20","aria-hidden":"true"},p.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),h$=p.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20","aria-hidden":"true"},p.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),f$=p.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20","aria-hidden":"true"},p.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),B$=p.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true"},p.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),p.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),p$=()=>{const[e,t]=p.useState(document.hidden);return p.useEffect(()=>{const n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>document.removeEventListener("visibilitychange",n)},[]),e},m$=1,g$=100,eb=e=>{var t;return typeof e?.id=="number"||(e==null||(t=e.id)==null?void 0:t.length)>0?e.id:m$++},C$=class{constructor(){this.subscribe=e=>(this.subscribers.push(e),this.getActiveToasts().forEach(t=>e(t)),()=>{const t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e],this.trimHistory()},this.trimHistory=()=>{let e=this.toasts.length-g$;e<=0||(this.toasts=this.toasts.filter(t=>e>0&&this.dismissedToasts.has(t.id)?(this.dismissedToasts.delete(t.id),e--,!1):!0))},this.create=e=>{const{message:t,...n}=e,r=eb(e),s=this.pendingDismissals.get(r);s!==void 0&&(cancelAnimationFrame(s),this.pendingDismissals.delete(r),this.dismissedToasts.delete(r));const i=this.dismissedToasts.has(r),o=e.dismissible===void 0?!0:e.dismissible;return i&&(this.dismissedToasts.delete(r),this.toasts=this.toasts.filter(a=>a.id!==r)),!i&&this.toasts.find(a=>a.id===r)?this.toasts=this.toasts.map(a=>a.id===r?(this.publish({...a,...e,id:r,title:t}),{...a,...e,id:r,dismissible:o,title:t}):a):this.addToast({title:t,...n,dismissible:o,id:r}),r},this.dismiss=e=>{if(e==null)return this.getActiveToasts().forEach(n=>{this.dismissedToasts.add(n.id),this.subscribers.forEach(r=>r({id:n.id,dismiss:!0}))}),e;this.dismissedToasts.add(e);const t=this.pendingDismissals.get(e);return t!==void 0&&cancelAnimationFrame(t),this.pendingDismissals.set(e,requestAnimationFrame(()=>{this.pendingDismissals.delete(e),this.subscribers.forEach(n=>n({id:e,dismiss:!0}))})),e},this.message=(e,t)=>this.create({...t,message:e,type:void 0}),this.error=(e,t)=>this.create({...t,message:e,type:"error"}),this.success=(e,t)=>this.create({...t,type:"success",message:e}),this.info=(e,t)=>this.create({...t,type:"info",message:e}),this.warning=(e,t)=>this.create({...t,type:"warning",message:e}),this.loading=(e,t)=>this.create({...t,type:"loading",message:e}),this.promise=(e,t)=>{if(!t)return;let n;t.loading!==void 0&&(n=this.create({...t,promise:e,type:"loading",message:t.loading,description:typeof t.description!="function"?t.description:void 0}));const r=Promise.resolve(e instanceof Function?e():e);let s=n!==void 0,i;const o=r.then(async l=>{if(i=["resolve",l],p.isValidElement(l))s=!1,this.create({id:n,type:"default",message:l});else if(y$(l)&&!l.ok){s=!1;const c=typeof t.error=="function"?await t.error(`HTTP error! status: ${l.status}`):t.error,u=typeof t.description=="function"?await t.description(`HTTP error! status: ${l.status}`):t.description,d=typeof c=="object"&&!p.isValidElement(c)?c:{message:c};this.create({id:n,type:"error",description:u,...d})}else if(l instanceof Error){s=!1;const c=typeof t.error=="function"?await t.error(l):t.error,u=typeof t.description=="function"?await t.description(l):t.description,d=typeof c=="object"&&!p.isValidElement(c)?c:{message:c};this.create({id:n,type:"error",description:u,...d})}else if(t.success!==void 0){s=!1;const c=typeof t.success=="function"?await t.success(l):t.success,u=typeof t.description=="function"?await t.description(l):t.description,d=typeof c=="object"&&!p.isValidElement(c)?c:{message:c};this.create({id:n,type:"success",description:u,...d})}}).catch(async l=>{if(i=["reject",l],t.error!==void 0){s=!1;const c=typeof t.error=="function"?await t.error(l):t.error,u=typeof t.description=="function"?await t.description(l):t.description,d=typeof c=="object"&&!p.isValidElement(c)?c:{message:c};this.create({id:n,type:"error",description:u,...d})}}).finally(()=>{s&&(this.dismiss(n),n=void 0),t.finally==null||t.finally.call(t)}),a=()=>new Promise((l,c)=>o.then(()=>i[0]==="reject"?c(i[1]):l(i[1])).catch(c));return typeof n!="string"&&typeof n!="number"?{unwrap:a}:Object.assign(n,{unwrap:a})},this.custom=(e,t)=>{const n=eb(t);return this.create({...t,jsx:e(n),id:n,type:void 0}),n},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set,this.pendingDismissals=new Map}},ln=new C$,v$=(e,t)=>ln.message(e,t),y$=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",b$=v$,S$=()=>ln.toasts,E$=()=>ln.getActiveToasts(),Rp=Object.assign(b$,{success:ln.success,info:ln.info,warning:ln.warning,error:ln.error,custom:ln.custom,message:ln.message,promise:ln.promise,dismiss:ln.dismiss,loading:ln.loading},{getHistory:S$,getToasts:E$});o$("[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px;flex:1;min-width:0}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--normal-text);background:var(--normal-bg);border:1px solid var(--normal-border);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{-webkit-user-select:none;user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}");function Gc(e){return e.label!==void 0}var x$=3,w$="24px",D$="16px",tb=4e3,T$=356,A$=14,I$=45,k$=200;function gr(...e){return e.filter(Boolean).join(" ")}function R$(e){const[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}var O$=e=>{var t,n,r,s,i,o,a,l,c;const{invert:u,toast:d,unstyled:h,interacting:f,setHeights:B,visibleToasts:g,heights:C,index:v,toasts:y,expanded:b,removeToast:E,defaultRichColors:w,closeButton:A,style:x,cancelButtonStyle:O,actionButtonStyle:R,className:P="",descriptionClassName:_="",duration:N,position:q,gap:W,expandByDefault:F,classNames:z,icons:J,closeButtonAriaLabel:Z="Close toast"}=e,[Q,G]=p.useState(null),[be,ve]=p.useState(null),[X,Y]=p.useState(!1),[ie,ne]=p.useState(!1),[ee,Be]=p.useState(!1),[de,Re]=p.useState(!1),[Ee,st]=p.useState(!1),[at,Bt]=p.useState(0),[tt,pt]=p.useState(0),Lt=p.useRef(d.duration||N||tb),mt=p.useRef(null),lt=p.useRef(null),Vn=v===0,it=v+1<=g,oe=d.type,je=oe??"default",Le=d.dismissible!==!1,Un=d.className||"",_t=d.descriptionClassName||"",Vt=p.useMemo(()=>C.findIndex(te=>te.toastId===d.id)||0,[C,d.id]),Bn=p.useMemo(()=>{var te;return(te=d.closeButton)!=null?te:A},[d.closeButton,A]),An=p.useMemo(()=>d.duration||N||tb,[d.duration,N]),gs=p.useRef(0),Ge=p.useRef(0),Cs=p.useRef(0),Kt=p.useRef(null),[vs,Qe]=q.split("-"),xc=p.useMemo(()=>C.reduce((te,He,ze)=>ze>=Vt?te:te+He.height,0),[C,Vt]),ti=p$(),pn=p.useMemo(()=>{var te;return(te=e.swipeDirections)!=null?te:R$(q)},[e.swipeDirections,q]),tf=d.invert||u,ni=oe==="loading";Ge.current=p.useMemo(()=>Vt*W+xc,[Vt,xc]),p.useEffect(()=>{Lt.current=An},[An]),p.useEffect(()=>{Y(!0)},[]),p.useEffect(()=>{const te=lt.current;if(te){const He=te.getBoundingClientRect().height;return pt(He),B(ze=>[{toastId:d.id,height:He,position:d.position},...ze]),()=>B(ze=>ze.filter(ct=>ct.toastId!==d.id))}},[B,d.id]),p.useLayoutEffect(()=>{if(!X)return;const te=lt.current,He=te.style.height;te.style.height="auto";const ze=te.getBoundingClientRect().height;te.style.height=He,pt(ze),B(ct=>ct.find(_e=>_e.toastId===d.id)?ct.map(_e=>_e.toastId===d.id?{..._e,height:ze}:_e):[{toastId:d.id,height:ze,position:d.position},...ct])},[X,d.title,d.description,B,d.id,d.jsx,d.action,d.cancel]);const Br=p.useCallback(()=>{ne(!0),Bt(Ge.current),B(te=>te.filter(He=>He.toastId!==d.id)),setTimeout(()=>{E(d)},k$)},[d,E,B,Ge]);p.useEffect(()=>{if(d.promise&&oe==="loading"||d.duration===1/0||d.type==="loading")return;let te;return b||f||ti?(()=>{if(Cs.current<gs.current){const ct=new Date().getTime()-gs.current;Lt.current=Lt.current-ct}Cs.current=new Date().getTime()})():Lt.current!==1/0&&(gs.current=new Date().getTime(),te=setTimeout(()=>{d.onAutoClose==null||d.onAutoClose.call(d,d),Br()},Lt.current)),()=>clearTimeout(te)},[b,f,d,oe,ti,Br]),p.useEffect(()=>{d.delete&&(Br(),d.onDismiss==null||d.onDismiss.call(d,d))},[Br,d.delete]);function j(){var te;if(J?.loading){var He;return p.createElement("div",{className:gr(z?.loader,d==null||(He=d.classNames)==null?void 0:He.loader,"sonner-loader"),"data-visible":oe==="loading"},J.loading)}return p.createElement(c$,{className:gr(z?.loader,d==null||(te=d.classNames)==null?void 0:te.loader),visible:oe==="loading"})}const we=d.icon||J?.[oe]||a$(oe);var Ae,Ye;return p.createElement("li",{tabIndex:0,ref:lt,className:gr(P,Un,z?.toast,d==null||(t=d.classNames)==null?void 0:t.toast,z?.[je],d==null||(n=d.classNames)==null?void 0:n[je]),"data-sonner-toast":"","data-rich-colors":(Ae=d.richColors)!=null?Ae:w,"data-styled":!(d.jsx||d.unstyled||h),"data-mounted":X,"data-promise":!!d.promise,"data-swiped":Ee,"data-removed":ie,"data-visible":it,"data-y-position":vs,"data-x-position":Qe,"data-index":v,"data-front":Vn,"data-swiping":ee,"data-dismissible":Le,"data-type":oe,"data-invert":tf,"data-swipe-out":de,"data-swipe-direction":be,"data-expanded":!!(b||F&&X),"data-testid":d.testId,style:{"--index":v,"--toasts-before":v,"--z-index":y.length-v,"--offset":`${ie?at:Ge.current}px`,"--initial-height":F?"auto":`${tt}px`,...x,...d.style},onDragEnd:()=>{Be(!1),G(null),Kt.current=null},onPointerDown:te=>{te.button!==2&&(ni||!Le||(mt.current=new Date,Bt(Ge.current),te.target.setPointerCapture(te.pointerId),te.target.tagName!=="BUTTON"&&(Be(!0),Kt.current={x:te.clientX,y:te.clientY})))},onPointerUp:()=>{var te,He,ze;if(de||!Le)return;Kt.current=null;const ct=Number(((te=lt.current)==null?void 0:te.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),_e=Number(((He=lt.current)==null?void 0:He.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),St=new Date().getTime()-((ze=mt.current)==null?void 0:ze.getTime()),ot=Q==="x"?ct:_e,pr=Math.abs(ot)/St;if((Q==="x"?pn.includes(ct>0?"right":"left"):pn.includes(_e>0?"bottom":"top"))&&(Math.abs(ot)>=I$||pr>.11)){Bt(Ge.current),d.onDismiss==null||d.onDismiss.call(d,d),ve(Q==="x"?ct>0?"right":"left":_e>0?"down":"up"),Br(),Re(!0);return}else{var Ct,ys;(Ct=lt.current)==null||Ct.style.setProperty("--swipe-amount-x","0px"),(ys=lt.current)==null||ys.style.setProperty("--swipe-amount-y","0px")}st(!1),Be(!1),G(null)},onPointerMove:te=>{var He,ze,ct;if(!Kt.current||!Le||((He=window.getSelection())==null?void 0:He.toString().length)>0)return;const _e=te.clientY-Kt.current.y,St=te.clientX-Kt.current.x;!Q&&(Math.abs(St)>1||Math.abs(_e)>1)&&G(Math.abs(St)>Math.abs(_e)?"x":"y");let ot={x:0,y:0};const pr=Ct=>1/(1.5+Math.abs(Ct)/20);if(Q==="y"){if(pn.includes("top")||pn.includes("bottom"))if(pn.includes("top")&&_e<0||pn.includes("bottom")&&_e>0)ot.y=_e;else{const Ct=_e*pr(_e);ot.y=Math.abs(Ct)<Math.abs(_e)?Ct:_e}}else if(Q==="x"&&(pn.includes("left")||pn.includes("right")))if(pn.includes("left")&&St<0||pn.includes("right")&&St>0)ot.x=St;else{const Ct=St*pr(St);ot.x=Math.abs(Ct)<Math.abs(St)?Ct:St}(Math.abs(ot.x)>0||Math.abs(ot.y)>0)&&st(!0),(ze=lt.current)==null||ze.style.setProperty("--swipe-amount-x",`${ot.x}px`),(ct=lt.current)==null||ct.style.setProperty("--swipe-amount-y",`${ot.y}px`)}},Bn&&!d.jsx&&oe!=="loading"?p.createElement("button",{"aria-label":Z,"data-disabled":ni,"data-close-button":!0,onClick:ni||!Le?()=>{}:()=>{Br(),d.onDismiss==null||d.onDismiss.call(d,d)},className:gr(z?.closeButton,d==null||(r=d.classNames)==null?void 0:r.closeButton)},(Ye=J?.close)!=null?Ye:B$):null,(oe||d.icon||d.promise)&&d.icon!==null&&(J?.[oe]!==null||d.icon)?p.createElement("div",{"data-icon":"",className:gr(z?.icon,d==null||(s=d.classNames)==null?void 0:s.icon)},oe==="loading"?d.icon||j():d.promise?j():null,oe!=="loading"?we:null):null,p.createElement("div",{"data-content":"",className:gr(z?.content,d==null||(i=d.classNames)==null?void 0:i.content)},p.createElement("div",{"data-title":"",className:gr(z?.title,d==null||(o=d.classNames)==null?void 0:o.title)},d.jsx?d.jsx:typeof d.title=="function"?d.title():d.title),d.description?p.createElement("div",{"data-description":"",className:gr(_,_t,z?.description,d==null||(a=d.classNames)==null?void 0:a.description)},typeof d.description=="function"?d.description():d.description):null),p.isValidElement(d.cancel)?d.cancel:d.cancel&&Gc(d.cancel)?p.createElement("button",{"data-button":!0,"data-cancel":!0,style:d.cancelButtonStyle||O,onClick:te=>{Gc(d.cancel)&&Le&&(d.cancel.onClick==null||d.cancel.onClick.call(d.cancel,te),Br())},className:gr(z?.cancelButton,d==null||(l=d.classNames)==null?void 0:l.cancelButton)},d.cancel.label):null,p.isValidElement(d.action)?d.action:d.action&&Gc(d.action)?p.createElement("button",{"data-button":!0,"data-action":!0,style:d.actionButtonStyle||R,onClick:te=>{Gc(d.action)&&(d.action.onClick==null||d.action.onClick.call(d.action,te),!te.defaultPrevented&&Br())},className:gr(z?.actionButton,d==null||(c=d.classNames)==null?void 0:c.actionButton)},d.action.label):null)};function nb(){if(typeof window>"u"||typeof document>"u")return"ltr";const e=document.documentElement.getAttribute("dir");return e==="auto"||!e?window.getComputedStyle(document.documentElement).direction:e}function M$(e,t){const n={};return[e,t].forEach((r,s)=>{const i=s===1,o=i?"--mobile-offset":"--offset",a=i?D$:w$;function l(c){["top","right","bottom","left"].forEach(u=>{n[`${o}-${u}`]=typeof c=="number"?`${c}px`:c})}typeof r=="number"||typeof r=="string"?l(r):typeof r=="object"?["top","right","bottom","left"].forEach(c=>{r[c]===void 0?n[`${o}-${c}`]=a:n[`${o}-${c}`]=typeof r[c]=="number"?`${r[c]}px`:r[c]}):l(a)}),n}var ase=p.forwardRef(function(t,n){const{id:r,invert:s,position:i="bottom-right",hotkey:o=["altKey","KeyT"],expand:a,closeButton:l,className:c,offset:u,mobileOffset:d,theme:h="light",richColors:f,duration:B,style:g,visibleToasts:C=x$,toastOptions:v,dir:y=nb(),gap:b=A$,icons:E,customAriaLabel:w,containerAriaLabel:A="Notifications"}=t,[x,O]=p.useState([]),R=p.useMemo(()=>r?x.filter(Y=>Y.toasterId===r):x.filter(Y=>!Y.toasterId),[x,r]),P=p.useMemo(()=>Array.from(new Set([i].concat(R.filter(Y=>Y.position).map(Y=>Y.position)))),[R,i]),[_,N]=p.useState([]),[q,W]=p.useState(!1),[F,z]=p.useState(!1),[J,Z]=p.useState(h!=="system"?h:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),Q=p.useRef(null),G=o.join("+").replace(/Key/g,"").replace(/Digit/g,""),be=p.useRef(null),ve=p.useRef(!1),X=p.useCallback(Y=>{O(ie=>{var ne;return(ne=ie.find(ee=>ee.id===Y.id))!=null&&ne.delete||ln.dismiss(Y.id),ie.filter(({id:ee})=>ee!==Y.id)})},[]);return p.useEffect(()=>ln.subscribe(Y=>{if(Y.dismiss){requestAnimationFrame(()=>{O(ie=>ie.map(ne=>ne.id===Y.id?{...ne,delete:!0}:ne))});return}setTimeout(()=>{Yo.flushSync(()=>{O(ie=>{const ne=ie.findIndex(ee=>ee.id===Y.id);return ne!==-1?[...ie.slice(0,ne),{...ie[ne],...Y},...ie.slice(ne+1)]:[Y,...ie]})})})}),[]),p.useEffect(()=>{if(h!=="system"){Z(h);return}if(h==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?Z("dark"):Z("light")),typeof window>"u")return;const Y=window.matchMedia("(prefers-color-scheme: dark)");try{Y.addEventListener("change",({matches:ie})=>{Z(ie?"dark":"light")})}catch{Y.addListener(({matches:ne})=>{try{Z(ne?"dark":"light")}catch(ee){console.error(ee)}})}},[h]),p.useEffect(()=>{x.length<=1&&W(!1)},[x]),p.useEffect(()=>{const Y=ie=>{var ne;if(o.length>0&&o.every(Be=>ie[Be]||ie.code===Be)){var ee;W(!0),(ee=Q.current)==null||ee.focus()}ie.code==="Escape"&&(document.activeElement===Q.current||(ne=Q.current)!=null&&ne.contains(document.activeElement))&&W(!1)};return document.addEventListener("keydown",Y),()=>document.removeEventListener("keydown",Y)},[o]),p.useEffect(()=>{if(Q.current)return()=>{be.current&&(be.current.focus({preventScroll:!0}),be.current=null,ve.current=!1)}},[Q.current]),p.createElement("section",{ref:n,"aria-label":w??`${A} ${G}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0,"data-react-aria-top-layer":!0},P.map((Y,ie)=>{var ne;const[ee,Be]=Y.split("-");return R.length?p.createElement("ol",{key:Y,dir:y==="auto"?nb():y,tabIndex:-1,ref:Q,className:c,"data-sonner-toaster":!0,"data-sonner-theme":J,"data-y-position":ee,"data-x-position":Be,style:{"--front-toast-height":`${((ne=_[0])==null?void 0:ne.height)||0}px`,"--width":`${T$}px`,"--gap":`${b}px`,...g,...M$(u,d)},onBlur:de=>{ve.current&&!de.currentTarget.contains(de.relatedTarget)&&(ve.current=!1,be.current&&(be.current.focus({preventScroll:!0}),be.current=null))},onFocus:de=>{de.target instanceof HTMLElement&&de.target.dataset.dismissible==="false"||ve.current||(ve.current=!0,be.current=de.relatedTarget)},onMouseEnter:()=>W(!0),onMouseMove:()=>W(!0),onMouseLeave:()=>{F||W(!1)},onDragEnd:()=>W(!1),onPointerDown:de=>{de.target instanceof HTMLElement&&de.target.dataset.dismissible==="false"||z(!0)},onPointerUp:()=>z(!1)},R.filter(de=>!de.position&&ie===0||de.position===Y).map((de,Re)=>{var Ee,st;return p.createElement(O$,{key:de.id,icons:E,index:Re,toast:de,defaultRichColors:f,duration:(Ee=v?.duration)!=null?Ee:B,className:v?.className,descriptionClassName:v?.descriptionClassName,invert:s,visibleToasts:C,closeButton:(st=v?.closeButton)!=null?st:l,interacting:F,position:Y,style:v?.style,unstyled:v?.unstyled,classNames:v?.classNames,cancelButtonStyle:v?.cancelButtonStyle,actionButtonStyle:v?.actionButtonStyle,closeButtonAriaLabel:v?.closeButtonAriaLabel,removeToast:X,toasts:R.filter(at=>at.position==de.position),heights:_.filter(at=>at.position==de.position),setHeights:N,expandByDefault:a,gap:b,expanded:q,swipeDirections:t.swipeDirections})})):null}))});function N$(e,t){return e?.slug==="sdk/protocol_version_pin_unsupported"?!0:typeof t=="string"&&P$.test(t)}var P$=/which this client is pinned to/i;function L$({text:e,copyText:t}){const[n,r]=(0,p.useState)(!1);return(0,p.useEffect)(()=>{if(!n)return;const s=setTimeout(()=>r(!1),1500);return()=>clearTimeout(s)},[n]),(0,m.jsxs)("div",{className:"relative min-h-5 pr-7",children:[(0,m.jsx)("span",{className:"whitespace-pre-wrap break-words",children:e}),(0,m.jsx)("button",{type:"button","aria-label":"Copy error message",title:"Copy error message",onClick:s=>{s.stopPropagation(),ra(t??e).then(i=>{i&&r(!0)})},className:"absolute right-2 top-0 z-10 flex h-5 w-5 items-center justify-center rounded-full border border-border bg-popover text-muted-foreground opacity-0 transition-opacity hover:text-foreground focus-visible:opacity-100 group-hover/toast:opacity-100",children:n?(0,m.jsx)(Vs,{className:"h-3 w-3 text-green-500"}):(0,m.jsx)(_s,{className:"h-3 w-3"})})]})}var _$=8e3;function F$(e,t){if(!t?.action&&typeof e=="string"&&N$(void 0,e))return{action:{label:"Change protocol version",onClick:()=>{Ed("change_protocol_version_clicked",{location:"toast_fallback",has_host_id:!1}),SN(xN.hosts)}}}}function H$(e,t){const{text:n,requestId:r}=lN(e),s=t?.description,i=typeof s=="string"&&s.trim()!==""?s:void 0;if(!r)return{title:e,description:i};if(s!=null&&typeof s!="string")return{title:e,description:void 0};const o=`Reference ${r}`;return{title:n||e,description:i?`${i}
43
+ ${o}`:o}}var j$=(e,t)=>{const n=typeof e=="string"?H$(e,t):null;return Rp.error(n?(0,m.jsx)(L$,{text:n.title,copyText:n.description?`${n.title}: ${n.description}`:void 0}):e,{duration:_$,...t,...n?.description?{description:n.description}:{},...F$(e,t)})},G$=Object.assign((...e)=>Rp(...e),Rp,{error:j$}),Dd=class extends p.Component{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){this.isExpected(e)?console.debug("ErrorBoundary caught an expected error:",e):(console.error("ErrorBoundary caught an error:",e,t),mN(e,t,this.props.name)),this.props.onError?.(e,t)}isExpected(e){if(!this.props.isExpectedError)return!1;try{return this.props.isExpectedError(e)===!0}catch{return!1}}handleReset=()=>{this.setState({hasError:!1,error:null})};render(){return this.state.hasError?this.props.fallback!==void 0?typeof this.props.fallback=="function"?this.props.fallback({error:this.state.error,reset:this.handleReset}):this.props.fallback:(0,m.jsx)("div",{className:"flex items-center justify-center min-h-[400px] p-6",children:(0,m.jsxs)("div",{className:"text-center max-w-md",children:[(0,m.jsx)(ch,{className:"h-12 w-12 text-destructive mx-auto mb-4"}),(0,m.jsx)("h2",{className:"text-xl font-semibold mb-2",children:"Something went wrong"}),(0,m.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:this.state.error?.message||"An unexpected error occurred"}),(0,m.jsx)(kn,{onClick:this.handleReset,variant:"outline",children:"Try again"})]})}):this.props.children}};function Ff(e){return e.trim().toLowerCase()}function V$(e,t){return e.createdAt-t.createdAt||e.hostId.localeCompare(t.hostId)}function lse(e){const t=new Map,n=new Map;for(const i of e){const o=i.name.trim()||"Client",a=Ff(o);n.set(a,n.get(a)??o);const l=t.get(a)??[];l.push(i),t.set(a,l)}const r=new Set(n.keys()),s=new Map;for(const i of t.values()){const o=[...i].sort(V$),a=o[0]?.name.trim()||"Client";let l=2;o.forEach((c,u)=>{if(u===0){s.set(c.hostId,a);return}let d=`${a} #${l}`;for(;r.has(Ff(d));)l+=1,d=`${a} #${l}`;r.add(Ff(d)),s.set(c.hostId,d),l+=1})}return s}function rb(e){return e.displayName??e.name}function OC({...e}){return(0,m.jsx)(i2,{"data-slot":"dropdown-menu",...e})}function MC({...e}){return(0,m.jsx)(o2,{"data-slot":"dropdown-menu-trigger",...e})}function NC({className:e,sideOffset:t=4,...n}){return(0,m.jsx)(a2,{children:(0,m.jsx)(l2,{"data-slot":"dropdown-menu-content",sideOffset:t,className:he("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md",e),...n})})}function Pu({className:e,inset:t,variant:n="default",...r}){return(0,m.jsx)(u2,{"data-slot":"dropdown-menu-item","data-inset":t,"data-variant":n,className:he("focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...r})}function cse({className:e,children:t,checked:n,...r}){return(0,m.jsxs)(d2,{"data-slot":"dropdown-menu-checkbox-item",className:he("focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),checked:n,...r,children:[(0,m.jsx)("span",{className:"pointer-events-none absolute left-2 flex size-3.5 items-center justify-center",children:(0,m.jsx)(Uw,{children:(0,m.jsx)(Vs,{className:"size-4"})})}),t]})}function U$({...e}){return(0,m.jsx)(h2,{"data-slot":"dropdown-menu-radio-group",...e})}function z$({className:e,children:t,hideIndicator:n=!1,...r}){return(0,m.jsxs)(f2,{"data-slot":"dropdown-menu-radio-item",className:he("focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",n?"pl-2":"pl-8",e),...r,children:[n?null:(0,m.jsx)("span",{className:"pointer-events-none absolute left-2 flex size-3.5 items-center justify-center",children:(0,m.jsx)(Uw,{children:(0,m.jsx)(ON,{className:"size-2 fill-current"})})}),t]})}function $$({className:e,inset:t,...n}){return(0,m.jsx)(c2,{"data-slot":"dropdown-menu-label","data-inset":t,className:he("px-2 py-1.5 text-sm font-medium data-[inset]:pl-8",e),...n})}function use({className:e,...t}){return(0,m.jsx)(B2,{"data-slot":"dropdown-menu-separator",className:he("bg-border -mx-1 my-1 h-px",e),...t})}function dse({...e}){return(0,m.jsx)(p2,{"data-slot":"dropdown-menu-sub",...e})}function hse({className:e,inset:t,children:n,...r}){return(0,m.jsxs)(m2,{"data-slot":"dropdown-menu-sub-trigger","data-inset":t,className:he("focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground flex cursor-default items-center rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[inset]:pl-8",e),...r,children:[n,(0,m.jsx)(Mo,{className:"ml-auto size-4"})]})}function fse({className:e,...t}){return(0,m.jsx)(g2,{"data-slot":"dropdown-menu-sub-content",className:he("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden rounded-md border p-1 shadow-lg",e),...t})}function W$({delayDuration:e=0,...t}){return(0,m.jsx)(tH,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function xs({...e}){return(0,m.jsx)(W$,{children:(0,m.jsx)(nH,{"data-slot":"tooltip",...e})})}function ws({...e}){return(0,m.jsx)(rH,{"data-slot":"tooltip-trigger",...e})}var nA="rounded-md px-3 py-1.5 text-xs",rA="bg-primary text-primary-foreground",sA="z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]",Bse=`${nA} ${rA}`,q$=`${sA} bg-primary fill-primary`;function Ds({className:e,sideOffset:t=0,children:n,variant:r="default",...s}){const i=r==="muted";return(0,m.jsx)(sH,{children:(0,m.jsxs)(iH,{"data-slot":"tooltip-content",sideOffset:t,className:he("animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit max-w-xs origin-(--radix-tooltip-content-transform-origin)",nA,i?"border border-border bg-popover text-popover-foreground shadow-md":rA,e),...s,children:[n,(0,m.jsx)(oH,{className:i?he(sA,"fill-popover"):q$})]})})}function pse({reason:e,fallback:t,children:n,...r}){const s=e||t;return s?(0,m.jsxs)(xs,{children:[(0,m.jsx)(ws,{asChild:!0,children:e?(0,m.jsx)("span",{className:"inline-flex rounded-md outline-none focus-visible:ring-ring/50 focus-visible:ring-[3px]",tabIndex:0,children:n}):n}),(0,m.jsx)(Ds,{...r,children:s})]}):n}var K$=(function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,s){r.__proto__=s}||function(r,s){for(var i in s)Object.prototype.hasOwnProperty.call(s,i)&&(r[i]=s[i])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}})();var J$=function(e,t,n){return typeof t=="symbol"&&(t=t.description?"[".concat(t.description,"]"):""),Object.defineProperty(e,"name",{configurable:!0,value:n?"".concat(n," ",t):t})};var Vc,sb="__POSTHOG_REACT_SHARED_STATE__",ib=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{},Tl;try{Tl=ib[sb]=ib[sb]||new WeakMap}catch{Tl=new WeakMap}Tl.has(p.createContext)||Tl.set(p.createContext,{});var wi=Tl.get(p.createContext),Op;function Q$(e){(!wi.defaultPostHogInstance||wi.defaultPostHogInstance===Op)&&(wi.defaultPostHogInstance=e),Op=e}function Mp(){return Op}wi.context||(wi.context=(0,p.createContext)({get client(){return Mp()||wi.defaultPostHogInstance},bootstrap:void 0}));var ia=wi.context;function iA(e,t,n){if(n===void 0&&(n=new WeakMap),e===t)return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(n.has(e)&&n.get(e)===t)return!0;n.set(e,t);var r=Object.keys(e),s=Object.keys(t);if(r.length!==s.length)return!1;for(var i=0,o=r;i<o.length;i++){var a=o[i];if(!s.includes(a)||!iA(e[a],t[a],n))return!1}return!0}function mse(e){var t,n,r=e.children,s=e.client,i=e.apiKey,o=e.options,a=(0,p.useRef)(null),l=(0,p.useMemo)(function(){if(s)return i&&console.warn("[PostHog.js] You have provided both `client` and `apiKey` to `PostHogProvider`. `apiKey` will be ignored in favour of `client`."),o&&console.warn("[PostHog.js] You have provided both `client` and `options` to `PostHogProvider`. `options` will be ignored in favour of `client`."),s;var c=Mp();return i||console.warn("[PostHog.js] No `apiKey` or `client` were provided to `PostHogProvider`. Using default global `window.posthog` instance. You must initialize it manually. This is not recommended behavior."),c},[s,i,JSON.stringify(o)]);return(0,p.useEffect)(function(){if(!(s||!i)){var c=Mp(),u=a.current;u?(i!==u.apiKey&&console.warn("[PostHog.js] You have provided a different `apiKey` to `PostHogProvider` than the one that was already initialized. This is not supported by our provider and we'll keep using the previous key. If you need to toggle between API Keys you need to control the `client` yourself and pass it in as a prop rather than an `apiKey` prop."),o&&!iA(o,u.options)&&c.set_config(o),a.current={apiKey:i,options:o??{}}):(c.__loaded&&console.warn("[PostHog.js] `posthog` was already loaded elsewhere. This may cause issues."),c.init(i,o),a.current={apiKey:i,options:o??{}})}},[s,i,JSON.stringify(o)]),p.createElement(ia.Provider,{value:{client:l,bootstrap:(t=o?.bootstrap)!==null&&t!==void 0?t:(n=s?.config)===null||n===void 0?void 0:n.bootstrap}},r)}var Hf=function(e){return typeof e=="function"},Np=function(e){return e===void 0};function oA(e,t){var n,r,s=(0,p.useContext)(ia),i=s.client,o=s.bootstrap,a=(0,p.useState)(function(){return i.isFeatureEnabled(e)}),l=a[0],c=a[1];(0,p.useEffect)(function(){return i.onFeatureFlags(function(){c(i.isFeatureEnabled(e))})},[i,e]);var u=(n=o?.featureFlags)===null||n===void 0?void 0:n[e];return!(!((r=i?.featureFlags)===null||r===void 0)&&r.hasLoadedFlags)&&o?.featureFlags?Np(u)?t:!!u:Np(l)?t:l}function gse(){var e,t=(0,p.useContext)(ia),n=t.client,r=t.bootstrap,s=(0,p.useState)(function(){return n.featureFlags.getFlags()}),i=s[0],o=s[1];return(0,p.useEffect)(function(){return n.onFeatureFlags(function(a){o(a)})},[n]),!(!((e=n?.featureFlags)===null||e===void 0)&&e.hasLoadedFlags)&&r?.featureFlags?Object.entries(r.featureFlags).filter(function(a){return a[1]}).map(function(a){return a[0]}):i}function Cse(e){var t,n=(0,p.useContext)(ia),r=n.client,s=n.bootstrap,i=(0,p.useState)(function(){return r.getFeatureFlag(e)}),o=i[0],a=i[1];return(0,p.useEffect)(function(){return r.onFeatureFlags(function(){a(r.getFeatureFlag(e))})},[r,e]),!(!((t=r?.featureFlags)===null||t===void 0)&&t.hasLoadedFlags)&&s?.featureFlags?s.featureFlags[e]:o}var vse=function(){return(0,p.useContext)(ia).client},Lu=function(e){var t=Object.prototype.toString.call(e);return e instanceof Error||t==="[object Error]"||t==="[object Exception]"||t==="[object DOMException]"||t==="[object DOMError]"},Y$=function(e,t){try{Object.defineProperty(e,"name",{value:t,writable:!0,enumerable:!0,configurable:!0})}catch{}},X$=function(e,t){for(var n=new WeakSet,r=e;!n.has(r);){if(n.add(r),!Lu(r.cause)){Np(r.cause)||(t.cause=r.cause),r.cause=t;return}r=r.cause}},Z$=function(e,t){if(!t)return e;var n=new Error(Lu(e)?e.message:"Primitive value captured as exception: ".concat(String(e)));return Y$(n,"React ErrorBoundary ".concat(Lu(e)?e.name:"Error")),n.stack=t,Lu(e)?(X$(e,n),e):n},ob={componentStack:null,exceptionEvent:null,error:null},e4={INVALID_FALLBACK:"[PostHog.js][PostHogErrorBoundary] Invalid fallback prop, provide a valid React element or a function that returns a valid React element."},yse=(Vc=(function(e){K$(t,e);function t(n){var r=e.call(this,n)||this;return r._resetError=function(){r.setState(ob)},r.state=ob,r}return t.prototype.componentDidCatch=function(n,r){var s=this.props.additionalProperties,i;Hf(s)?i=s(n,r):typeof s=="object"&&(i=s);var o=this.context.client,a=r.componentStack,l=o.captureException(Z$(n,a),i);this.setState({error:n,componentStack:a??null,exceptionEvent:l})},t.prototype.render=function(){var n=this.props,r=n.children,s=n.fallback,i=this.state;if(i.componentStack==null)return Hf(r)?r():r;var o=Hf(s)?p.createElement(s,{error:i.error,componentStack:i.componentStack,exceptionEvent:i.exceptionEvent,resetError:this._resetError}):s;return p.isValidElement(o)?o:(console.warn(e4.INVALID_FALLBACK),p.createElement(p.Fragment,null))},t})(p.Component),J$(Vc,"PostHogErrorBoundary"),(function(){Vc.contextType=ia})(),Vc);Q$(dx);var t4=8192,n4=8192,jf=64,r4=new Set(["_truncated","bytes","limitBytes","reason","head"]);function Ms(e,t){let n=0,r=0;for(let s=0;s<e.length&&!(n>t);s++){const i=e.charCodeAt(s);if(i<128){n+=1,i===34||i===92?r+=1:i<32&&(r+=i===8||i===9||i===10||i===12||i===13?1:5);continue}if(i<2048){n+=2;continue}if(i>=55296&&i<=56319){const o=e.charCodeAt(s+1);if(o>=56320&&o<=57343){n+=4,s++;continue}}if(i>=55296&&i<=57343){n+=3,r+=3;continue}n+=3}return{utf8:n,json:n+r+2}}function s4(e){const t=e.charCodeAt(8191);return e.slice(0,t>=55296&&t<=56319?8191:n4)}var i4=8,aA=5e4;function lA(e,t){let n=0,r=0;const s=[e];for(;s.length>0;){if(n>t)return{bytes:n,exceeded:!0};if(++r>aA)return{bytes:n,exceeded:!0};const i=s.pop();if(typeof i=="string"){n+=Ms(i,t-n).json;continue}if(i===null||typeof i!="object"){n+=5;continue}if(Array.isArray(i)){n+=2+i.length;for(const o of i){if(n>t)return{bytes:n,exceeded:!0};s.push(o)}continue}n+=2;for(const o in i)if(Object.hasOwn(i,o)){if(n+=Ms(o,t-n).json+2,n>t)return{bytes:n,exceeded:!0};s.push(i[o])}}return{bytes:n,exceeded:n>t}}function o4(e,t){const n={_truncated:!0,limitBytes:t};if(typeof e!="object"||e===null||Array.isArray(e))return n;let r=0,s=0;const i=new Set,o=d=>d===void 0?{_truncated:!0}:{_truncated:!0,bytes:d},a=(d,h)=>{if(++s>aA)return o();if(typeof d=="string"){const B=Ms(d,t-r);if(d.length<=t4&&r+B.json<=t)return r+=B.json,d;const g=Ms(d,Number.POSITIVE_INFINITY).utf8,C=s4(d);if(C.length<d.length){const v=Ms(C,Number.POSITIVE_INFINITY).json;if(r+v+jf<=t)return r+=v+jf,{_truncated:!0,bytes:g,head:C}}return r+=jf,o(g)}if(d===null||typeof d!="object")return r+=5,d;if(h>=i4||i.has(d))return o();if(i.add(d),Array.isArray(d)){r+=2;const B=[];for(const g of d){if(r+=1,r>t)return i.delete(d),o();B.push(a(g,h+1))}return i.delete(d),B}r+=2;const f={};for(const B in d)if(Object.hasOwn(d,B)){if(r+=Ms(B,t-r).json+2,r>t)return i.delete(d),o();f[B]=a(d[B],h+1)}return i.delete(d),f},l=a(e,0),c={};if(!a4(l)&&typeof l=="object"&&l!==null)for(const[d,h]of Object.entries(l))r4.has(d)||(c[d]=h);const u={...c,...n};return lA(u,t).exceeded?n:u}function a4(e){return typeof e=="object"&&e!==null&&e._truncated===!0}function Gf(e){return e<1024?`${e} B`:e<1048576?`${Math.round(e/1024)} KB`:`${(e/1048576).toFixed(1)} MB`}function bse(e){if(e.reason)return`Payload not recorded: ${e.reason}.`;const t=typeof e.limitBytes=="number"?`over the ${Gf(e.limitBytes)} log limit`:"over the log size limit",n=typeof e.bytes=="number"?` It was ${Gf(e.bytes)}.`:"";return typeof e.head=="string"?`Payload truncated — ${t}.${n} Showing the first ${Gf(Ms(e.head,Number.POSITIVE_INFINITY).utf8)}.`:`Payload not recorded — ${t}.${n}`}function cA(e){try{return new URL(e).pathname}catch{return e}}function l4(e){return typeof e=="string"&&e.startsWith("Automatic resolved to ")}var Pp=1e3,Vf=1048576,uA=8388608,dA=new WeakMap;function c4(e){const t=e.length>Pp?e.slice(0,Pp):e;let n=0;for(let r=0;r<t.length;r++)if(n+=dA.get(t[r])??0,n>uA&&r>0)return t.slice(0,r);return t}var Ho=fN(e=>({items:[],mcpServerItems:[],addLog:t=>{const n={...t,id:`${Date.now()}-${Math.random().toString(36).slice(2)}`,timestamp:new Date().toISOString()};e(r=>({items:[n,...r.items].slice(0,Pp)}))},addMcpServerLog:t=>{const n={...t,id:t.id??`${t.timestamp}-${Math.random().toString(36).slice(2)}`};dA.set(n,lA(n.payload,uA).bytes),e(r=>({mcpServerItems:c4(r.mcpServerItems.some(s=>s.id===n.id)?r.mcpServerItems.map(s=>s.id===n.id?n:s):[n,...r.mcpServerItems])}))},clear:()=>e({items:[],mcpServerItems:[]})}));function hA(e){return typeof e.eventId=="string"&&e.eventId.length>0?e.eventId:void 0}function Sse(e){if(!Array.isArray(e)||e.length===0)return;const t=Ho.getState();e.forEach(n=>{const r=hA(n);t.addMcpServerLog({...r?{id:r}:{},serverId:n.serverId,serverName:n.serverName,direction:n.direction.toUpperCase(),method:hx(n.message),timestamp:n.timestamp,payload:n.message})})}function Ese(e){if(!Array.isArray(e)||e.length===0)return;const t=Ho.getState();e.forEach(n=>{const r=hA(n);t.addMcpServerLog({...r?{id:r}:{},serverId:n.serverId,serverName:n.serverName,direction:"HTTP",method:`${n.exchange.request.method} ${cA(n.exchange.request.url)}`,timestamp:n.timestamp,payload:n.exchange,kind:"http"})})}function xse(e){const{serverId:t,serverName:n,trace:r}=e;if(!r||!Array.isArray(r.steps)||r.steps.length===0)return;const s=Ho.getState();r.steps.forEach(i=>{const o=new Date(i.completedAt??i.startedAt).toISOString();l4(i.message)&&s.addMcpServerLog({id:`oauth:${t}:${r.source}:automatic_resolution:${i.startedAt}`,serverId:t,serverName:n,direction:"OAUTH",method:"Automatic Resolution",timestamp:o,payload:{source:r.source,step:"automatic_resolution",title:"Automatic Resolution",status:i.status,message:i.message,details:i.details,relatedStep:i.step},kind:"oauth",oauthStatus:i.status,oauthSource:r.source,oauthRecovered:i.recovered===!0}),s.addMcpServerLog({id:`oauth:${t}:${r.source}:${i.step}:${i.startedAt}`,serverId:t,serverName:n,direction:"OAUTH",method:i.title,timestamp:o,payload:{source:r.source,step:i.step,title:i.title,status:i.status,message:i.message,error:i.error,details:i.details,recovered:i.recovered,recoveredAt:i.recoveredAt,recoveryMessage:i.recoveryMessage,httpHistory:r.httpHistory.filter(a=>a.step===i.step)},kind:"oauth",oauthStatus:i.status,oauthSource:r.source,oauthRecovered:i.recovered===!0})})}var Gr=null,fa=0;function wse(){if(fa++,!Gr){const e=new URLSearchParams;e.set("replay","3"),e.set("_t",Date.now().toString()),Gr=new EventSource(Q5(`/api/mcp/servers/rpc/stream?${e.toString()}`)),Gr.onmessage=t=>{try{const n=JSON.parse(t.data);if(!n)return;const r=typeof n.eventId=="string"&&n.eventId.length>0?n.eventId:void 0;if(n.type==="http"){if(!n.exchange)return;const l=n.exchange;Ho.getState().addMcpServerLog({...r?{id:r}:{},serverId:typeof n.serverId=="string"?n.serverId:"unknown",direction:"HTTP",method:`${l.request.method} ${cA(l.request.url)}`,timestamp:n.timestamp??new Date().toISOString(),payload:l,kind:"http"});return}if(n.type!=="rpc")return;const{serverId:s,direction:i,message:o,timestamp:a}=n;Ho.getState().addMcpServerLog({...r?{id:r}:{},serverId:typeof s=="string"?s:"unknown",direction:typeof i=="string"?i.toUpperCase():"",method:hx(o),timestamp:a??new Date().toISOString(),payload:Ms(t.data,Vf).utf8>Vf?o4(o,Vf):o})}catch{}},Gr.onerror=()=>{Gr?.close(),Gr=null,fa=0}}return()=>{fa--,fa<=0&&Gr&&(Gr.close(),Gr=null,fa=0)}}var u4=yN("inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"border-transparent bg-destructive text-destructive-foreground [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",inverse:"border-transparent bg-popover text-popover-foreground"}},defaultVariants:{variant:"default"}});function Al({className:e,variant:t,asChild:n=!1,...r}){const s=n?vN:"span";return(0,m.jsx)(s,{"data-slot":"badge",className:he(u4({variant:t}),e),...r})}var Dse=["role","severity"];function Tse(e){const{role:t,severity:n,evaluator:r,...s}=e;return s}function Ase(e){return e?.role==="advisory"?"advisory":"gating"}function fA(e){return e==="gating"||e==="required"}function d4(e){if(!e||typeof e!="object"||e.role!=="required")return e;const{role:t,...n}=e;return n}function Ise(e){return Array.isArray(e)?e.map(d4):void 0}function kse(e){return e?.severity==="warn"?"warn":void 0}var _u={toolCallOrder:"ignore",maxExtraToolCalls:null,argumentMatching:"partial"};function Rse(e,t,n){const r={..._u};for(const s of[e,t,n])s&&(s.toolCallOrder!==void 0&&(r.toolCallOrder=s.toolCallOrder),s.argumentMatching!==void 0&&(r.argumentMatching=s.argumentMatching),s.maxExtraToolCalls!==void 0?r.maxExtraToolCalls=s.maxExtraToolCalls:s.allowExtraToolCalls!==void 0&&(r.maxExtraToolCalls=s.allowExtraToolCalls?null:0));return h4(r),r}function h4(e){if(e.toolCallOrder!==void 0&&!["ignore","strict","superset"].includes(e.toolCallOrder))throw new Error(`Invalid toolCallOrder: ${String(e.toolCallOrder)}`);if(e.argumentMatching!==void 0&&!["partial","exact","ignore"].includes(e.argumentMatching))throw new Error(`Invalid argumentMatching: ${String(e.argumentMatching)}`);pA(e.maxExtraToolCalls)}function f4(e,t){if(typeof e!="string")return null;switch(e.trim().toLowerCase()){case"any":return t!==void 0;case"string":return typeof t=="string";case"number":return typeof t=="number";case"boolean":return typeof t=="boolean";case"object":return t!==null&&typeof t=="object"&&!Array.isArray(t);case"array":return Array.isArray(t);case"null":return t===null;default:return null}}function Il(e){return e===null||typeof e!="object"?JSON.stringify(e):Array.isArray(e)?`[${e.map(Il).join(",")}]`:`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${Il(e[t])}`).join(",")}}`}function BA(e,t){return Il(e)===Il(t)}function B4(e){const t=e.map(r=>`${JSON.stringify(r?.toolName)}:${Il(r?.arguments??{})}`),n=[];return e.forEach((r,s)=>{if(r?.failed!==!0)return;const i=t.indexOf(t[s],s+1);i!==-1&&n.push({toolName:r.toolName,arguments:r.arguments??{},actualIndex:s,retriedByIndex:i})}),n}function Ose(e,t){const n=new Set;for(const r of t)typeof r?.toolCallId=="string"&&r.toolCallId.length>0&&n.add(r.toolCallId);return n.size===0?[...e]:e.map(r=>typeof r.toolCallId=="string"&&n.has(r.toolCallId)?{...r,failed:!0}:r)}function p4(e,t){for(const[n,r]of Object.entries(e)){const s=f4(r,t[n]);if(s!==null){if(!s)return!1;continue}if(!BA(t[n],r))return!1}return!0}function m4(e,t){return BA(e,t)}function g4(e,t,n){return n==="ignore"?!0:n==="partial"?Object.keys(e).length===0?!0:p4(e,t):m4(e,t)}function Uf(e,t,n){return e.toolName!==t.toolName?!1:g4(e.arguments||{},t.arguments||{},n)}function Fu(e,t){return typeof e=="function"?e(t):e}function C4(e,t,n,r){const s=new Map;if(n==="strict"){const o=Math.min(e.length,t.length);for(let a=0;a<o;a++){const l=Fu(r,a);Uf(e[a],t[a],l)&&s.set(a,a)}return{expectedToActual:s}}if(n==="superset"){let o=0;const a=new Array(e.length);for(let l=0;l<e.length;l++){a[l]=o;const c=Fu(r,l);for(;o<t.length;){if(Uf(e[l],t[o],c)){s.set(l,o),o++;break}o++}if(o>=t.length){for(let u=l+1;u<e.length;u++)a[u]=o;break}}return{expectedToActual:s,supersetCursorByExpected:a}}const i=new Set;for(let o=0;o<e.length;o++){const a=Fu(r,o);for(let l=0;l<t.length;l++)if(!i.has(l)&&Uf(e[o],t[l],a)){s.set(o,l),i.add(l);break}}return{expectedToActual:s}}function v4(e,t,n,r){const{expectedToActual:s,supersetCursorByExpected:i}=C4(e,t,n,r),o=new Set(s.keys()),a=new Set(s.values()),l=[];for(let c=0;c<e.length;c++){if(o.has(c))continue;const u=e[c];let d=0,h=t.length;n==="strict"?(d=c,h=Math.min(c+1,t.length)):n==="superset"&&i&&(d=Math.min(i[c]??0,t.length));for(let f=d;f<h;f++)if(!a.has(f)&&t[f].toolName===u.toolName){o.add(c),a.add(f),s.set(c,f),Fu(r,c)!=="ignore"&&l.push(c);break}}return{expectedToActual:s,argumentMismatchExpected:l}}function pA(e){if(e!=null&&(!Number.isInteger(e)||e<0))throw new Error(`Invalid maxExtraToolCalls: ${e}. Must be null (unlimited) or a non-negative integer.`)}function mA(e,t,n){const r=Array.isArray(e)?e:[],s=Array.isArray(t)?t:[];let i;n?.maxExtraToolCalls!==void 0?i=n.maxExtraToolCalls:n?.allowExtraToolCalls!==void 0?i=n.allowExtraToolCalls?null:0:i=_u.maxExtraToolCalls,pA(i);const o=n?.toolCallOrder??_u.toolCallOrder,a=n?.argumentMatching??_u.argumentMatching;if(n?.isNegativeTest)return{missing:[],extra:s,outOfOrder:[],argumentMismatches:[],retries:[],passed:s.length===0};if(s.length===0)return{missing:r,extra:[],outOfOrder:[],argumentMismatches:[],retries:[],passed:!1};const l=B4(s),c=new Set(l.map(E=>E.actualIndex)),u=c.size===0?s:s.filter((E,w)=>!c.has(w)),{expectedToActual:d,argumentMismatchExpected:h}=v4(r,u,o,a),f=new Set(d.keys()),B=new Set(d.values()),g=h.map(E=>({toolName:r[E].toolName,expectedArgs:r[E].arguments||{},actualArgs:u[d.get(E)].arguments||{}})),C=[],v=r.filter((E,w)=>!f.has(w)),y=u.filter((E,w)=>!B.has(w)),b=i!==null&&y.length>i;return{missing:v,extra:y,outOfOrder:C,argumentMismatches:g,retries:l,passed:v.length===0&&g.length===0&&C.length===0&&!b}}var $=class fi{static FOLD_CASE=1;static LITERAL=2;static CLASS_NL=4;static DOT_NL=8;static ONE_LINE=16;static NON_GREEDY=32;static PERL_X=64;static UNICODE_GROUPS=128;static WAS_DOLLAR=256;static LOOKBEHIND=512;static MATCH_NL=fi.CLASS_NL|fi.DOT_NL;static PERL=fi.CLASS_NL|fi.ONE_LINE|fi.PERL_X|fi.UNICODE_GROUPS;static POSIX=0;static UNANCHORED=0;static ANCHOR_START=1;static ANCHOR_BOTH=2},Qn={CASE_INSENSITIVE:1,DOTALL:2,MULTILINE:4,DISABLE_UNICODE_GROUPS:8,LONGEST_MATCH:16,LOOKBEHINDS:512},kl=128,Lp=new Int32Array(kl),_p=new Int32Array(kl),Uc=65535;for(let e=0;e<kl;e++)e>=97&&e<=122?Lp[e]=e-32:Lp[e]=e,e>=65&&e<=90?_p[e]=e+32:_p[e]=e;var V=class{static CODES=new Map([["\x07",7],["\b",8],[" ",9],[`
44
+ `,10],["\v",11],["\f",12],["\r",13],[" ",32],['"',34],["$",36],["&",38],["'",39],["(",40],[")",41],["*",42],["+",43],["-",45],[".",46],["0",48],["1",49],["2",50],["3",51],["4",52],["5",53],["6",54],["7",55],["8",56],["9",57],[":",58],["<",60],[">",62],["?",63],["A",65],["B",66],["C",67],["F",70],["P",80],["Q",81],["U",85],["Z",90],["[",91],["\\",92],["]",93],["^",94],["_",95],["`",96],["a",97],["b",98],["f",102],["i",105],["m",109],["n",110],["r",114],["s",115],["t",116],["v",118],["x",120],["z",122],["{",123],["|",124],["}",125]]);static toUpperCase(e){if(e<kl)return Lp[e];const t=String.fromCodePoint(e).toUpperCase(),n=t.codePointAt(0)>Uc?2:1;if(t.length>n)return e;const r=String.fromCodePoint(t.codePointAt(0)).toLowerCase(),s=r.codePointAt(0)>Uc?2:1;return r.length>s||r.codePointAt(0)!==e?e:t.codePointAt(0)}static toLowerCase(e){if(e<kl)return _p[e];const t=String.fromCodePoint(e).toLowerCase(),n=t.codePointAt(0)>Uc?2:1;if(t.length>n)return e;const r=String.fromCodePoint(t.codePointAt(0)).toUpperCase(),s=r.codePointAt(0)>Uc?2:1;return r.length>s||r.codePointAt(0)!==e?e:t.codePointAt(0)}},T=class{constructor(e,t=!1){this.data=e,this.isStride1=t,this.SIZE=t?2:3}getLo(e){return this.data[e*this.SIZE]}getHi(e){return this.data[e*this.SIZE+1]}getStride(e){return this.isStride1?1:this.data[e*this.SIZE+2]}get length(){return this.data.length/this.SIZE}},gA=new Uint8Array(256);for(let e=0,t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-";e<64;e++)gA[t.charCodeAt(e)]=e;var CA=e=>{const t=[];let n=0,r=0;for(let s=0;s<e.length;s++){let i=gA[e.charCodeAt(s)];n|=(i&31)<<r,(i&32)===0?(t.push(n),n=0,r=0):r+=5}return t},I=(e,t)=>{const n=CA(e),r=t?n.length/2:n.length/3,s=new Uint32Array(r*3);let i=0,o=0;for(let a=0;a<r;a++)i+=n[o++],s[a*3]=i,i+=n[o++],s[a*3+1]=i,s[a*3+2]=t?1:n[o++];return s},y4=e=>{const t=CA(e),n=new Map;let r=0;for(let s=0;s<t.length;s+=2){r+=t[s];const i=t[s+1],o=i>>>1^-(i&1);n.set(r,r+o)}return n},zc=class{constructor(e){this.initializer=e,this.cache=new Map}has(e){return e in this.initializer}get(e){if(this.cache.has(e))return this.cache.get(e);const t=this.initializer[e],n=t?t():null;return this.cache.set(e,n),n}},an=class{static _CASE_ORBIT=null;static get CASE_ORBIT(){return this._CASE_ORBIT||(this._CASE_ORBIT=y4("rCgCIgCY+rQI4QiCuuBLgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCCgCBgCBgCBgCBgCBgCBgCB+7OB-BB-BB-BB-BB-BBskQB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BC-BB-BB-BB-BB-BB-BB-BByHBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBDCBBBCBBBCBBCCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBCCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBxHBCBBBCBBBCBBB3SBmMBkNBCBBBCBBB8MBCBBB6MB6MBCBBC+EB0MB2MBCBBB6MB+MBiGBmNBiNBCBBBmKBikzCBmNBqNBkIBsNBCBBBCBBBCBBB0NBCBBB0NDCBBB0NBCBBByNByNBCBBBCBBB2NBCBBDCBBCwDFCBCBDBCBCBDBCBCBDBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBB9EBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBCCBCBDBCBBBhGBvDBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBjICCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBH2iVBCBBBlKBwiVB+jVB+jVBCBBBlMBqEBuEBCBBBCBBBCBBBCBBBCBBB+hVB4hVB8hVBjNB7MC5MB5MCzMC1MB+0yCE5MB20yCC9MBu2yCBwyyCBo0yCChNBlNBo0yCBu-UBi0yCDlNC6-UBpNDrNIu+UDzNCm0yCBzNE0yyCBzNBpEBxNBxNBtEG1NLqxyCBkxyCnFoFrBCBBBCBBDCBBEkIBkIBkICoHHsCCqCBqCBqCCgEC+DB+DBmkOBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCC+BBgCBgCBgCBgCBgCBgCBgCBgCBrCBpCBpCBpCBmjOB-BB8BB-BB-BBgEB-BB-BByBBqgOBsDB-BBtwBB-BB-BB-BBsBBgDBCB-BB-BB-BBeB-BB-BB61OB-BB-BB-DB9DB9DBQB7DBmCE9CBrDBPBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBrFB-EBOBnHB3FB-FCCBBBNBCBBCjIBjIBjIBgFBgFBgFBgFBgFBgFBgFBgFBgFBgFBgFBgFBgFBgFBgFBgFBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCB-BB-BB8kMB-BB6kMB-BB-BB-BB-BB-BB-BB-BB-BB-BBokMB-BB-BBkkMBkkMB-BB-BB-BB-BB-BB-BB-BB4jMB-BB-BB-BB-BB-BB-EB-EB-EB-EB-EB-EB-EB-EB-EB-EB-EB-EB-EB-EB-EB-EBCBBBCBoiMBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBJCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBeBCBBBCBBBCBBBCBBBCBBBCBBBCBBBdBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBCgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDL-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-C64CgmOBgmOBgmOBgmOBgmOBgmOBgmOBgmOBgmOBgmOBgmOBgmOBgmOBgmOBgmOBgmOBgmOBgmOBgmOBgmOBgmOBgmOBgmOBgmOBgmOBgmOBgmOBgmOBgmOBgmOBgmOBgmOBgmOBgmOBgmOBgmOBgmOBgmOCgmOGgmODg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FDg8FBg8FBg8FhVg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBQBQBQBQBQBQDPBPBPBPBPBPjkC7mMB5mMBnmMBjmMBCBlmMB3lMBpiMBk8kCBCBBG-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FD-7FB-7FB-7F6FoglCEsuHRwjlCyDCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCB0DBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBG1DD97OCCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBQBQBQBQBQBQBQBQBPBPBPBPBPBPBPBPBQBQBQBQBQBQDPBPBPBPBPBPDQBQBQBQBQBQBQBQBPBPBPBPBPBPBPBPBQBQBQBQBQBQBQBQBPBPBPBPBPBPBPBPBQBQBQBQBQBQDPBPBPBPBPBPEQCQCQCQCPCPCPCPBQBQBQBQBQBQBQBQBPBPBPBPBPBPBPBPB0EB0EBsFBsFBsFBsFBoGBoGBgIBgIBgHBgHB8HB8HDQBQBQBQBQBQBQBQBPBPBPBPBPBPBPBPBQBQBQBQBQBQBQBQBPBPBPBPBPBPBPBPBQBQBQBQBQBQBQBQBPBPBPBPBPBPBPBPBQBQCSFPBPBzEBzEBRCxnOFSFrFBrFBrFBrFBREQBQClkOFPBPBnGBnGFQBQCljOCODPBPB-GB-GBNHSF-HB-HB7HB7HBRqJ53OE9tQBrmQH4Bc3BSgBBgBBgBBgBBgBBgBBgBBgBBgBBgBBgBBgBBgBBgBBgBBgBBfBfBfBfBfBfBfBfBfBfBfBfBfBfBfBfECBByZ0BB0BB0BB0BB0BB0BB0BB0BB0BB0BB0BB0BB0BB0BB0BB0BB0BB0BB0BB0BB0BB0BB0BB0BB0BB0BBzBBzBBzBBzBBzBBzBBzBBzBBzBBzBBzBBzBBzBBzBBzBBzBBzBBzBBzBBzBBzBBzBBzBBzBBzBBzB34BgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CBCBBBt-UBruHBt+UB1iVBviVBCBBBCBBBCBBB3hVB5-UB9hVB7hVCCBBCCBBI9jVB9jVBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBICBBBCBBECBBN-lOB-lOB-lOB-lOB-lOB-lOB-lOB-lOB-lOB-lOB-lOB-lOB-lOB-lOB-lOB-lOB-lOB-lOB-lOB-lOB-lOB-lOB-lOB-lOB-lOB-lOB-lOB-lOB-lOB-lOB-lOB-lOB-lOB-lOB-lOB-lOB-lOB-lOC-lOG-lOzoeCBBBCBBBCBBBCBBBCBBBCBl8kCBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBTCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBnECBBBCBBBCBBBCBBBCBBBCBBBCBBDCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBKCBBBCBBBnglCBCBBBCBBBCBBBCBBBCBBECBBBvyyCDCBBBCBBBgDCCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBn0yCB90yCB10yCBh0yCBn0yCCjxyCBzyyCBpxyCBg6BBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBB-CBl0yCBvjlCBCBBBCBBBt2yCBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBhkzCZCBB9a-5Bd-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCm6TCBB7gBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCH-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BmlBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvChDwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCFvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvC1DuCBuCBuCBuCBuCBuCBuCBuCBuCBuCBuCCuCBuCBuCBuCBuCBuCBuCBuCBuCBuCBuCBuCBuCBuCBuCCuCBuCBuCBuCBuCBuCBuCCuCBuCCtCBtCBtCBtCBtCBtCBtCBtCBtCBtCBtCCtCBtCBtCBtCBtCBtCBtCBtCBtCBtCBtCBtCBtCBtCBtCCtCBtCBtCBtCBtCBtCBtCCtCBtCk2BgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEO-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-D+CgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCL-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-B74CgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BhrVgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BhB2BB2BB2BB2BB2BB2BB2BB2BB2BB2BB2BB2BB2BB2BB2BB2BB2BB2BB2BB2BB2BB2BB2BB2BB2BD1BB1BB1BB1BB1BB1BB1BB1BB1BB1BB1BB1BB1BB1BB1BB1BB1BB1BB1BB1BB1BB1BB1BB1BB1BtxekCBkCBkCBkCBkCBkCBkCBkCBkCBkCBkCBkCBkCBkCBkCBkCBkCBkCBkCBkCBkCBkCBkCBkCBkCBkCBkCBkCBkCBkCBkCBkCBkCBkCBjCBjCBjCBjCBjCBjCBjCBjCBjCBjCBjCBjCBjCBjCBjCBjCBjCBjCBjCBjCBjCBjCBjCBjCBjCBjCBjCBjCBjCBjCBjCBjCBjCBjC")),this._CASE_ORBIT}static _Print=null;static get Print(){return this._Print||(this._Print=new T(I("hB9CBjBLBCpWBDFBFGBCCCBSBCsMBClBBDxBBDCBC2BBJaBFFBSVBC-FBCvBBD6BBDkDBP6BBDwBBDOBCbBDCCBJBGfBIqCBCgFBCHBDBBDVBCGBCEEBCBDIBDBBDDBJFFBCCBDBDYBDCBCFBFBBDVBCGBCBBCBBCBBDCCBDBFBBDCBEIIBCBCIIBPBLCBCIBCCBCVBCGBCBBCEBDJBCCBCCBDQQBCBDLBIGBCCBCHBDBBDVBCGBCBBCEBDIBDBBDCBICBFBBCEBDRBLBBCFBECBCDBEBBCCCBEEBEEBBBELBFEBECBCDBDHHPUBGMBCCBCWBCPBDIBCCBCDBIBBCCBCBBDDBDJBIVBCCBCWBCJBCEBDIBCCBCDBIBBGCBCDBDJBCCBNMBCCBCyBBCCBCFBFPBDZBCCBCRBEXBCIBCDDBFBEFFBEBCCCBGBHJBDCBN5BBFcBmBBBCCCBDBCXBCCCBVBDEBCCCBFBCJBDDBhBnCBCjBBFmBBCjBBCOBCMBmBlGBCGGD4LBCDBDGBCCCBCBDoBBCDBDgBBCDBDGBCCCBCBDOBC4BBCDBDiCBDfBEZBH1CBDFBD-TBCbBE4CBIVBKXBKTBNMBCCBCBBN9CBDJBHJBHNBCKBH4CBIqBBGlCBLeBCLBFLBFEEBoBBDEBMrBBFZBHKBE9BBDgCBCcBDKBHJBHNBDtBBDLBVsCBClFBJ7BBEOBE9BBGqBBDKBJqBBG1QBDFBDlBBDFBDHBCGCBdBD0BBCOBCNBDFBCSBDCBCIBSXBJuBBSBBDaBCMBEhBBPgBBQrEBF5UBXKBWz4BBD9LBGsBBCGGD3BBIBBPXBKGBCGBCGBCGBCGBCGBCGBCGBC9DBjBZBC4CBN1GBbPBC+BBC1CBDmDBGqBBC9CBC1CBKvBBCszcBE2BBK7KBV3FBJ8GBV7BBEJBH3BBJlCBJLBHzDBMdBEtCBCKBFgBBC2BBKNBDJBDmDBZbBLFBDFBDFBKGBCGBC7BBF9DBDJBHj9KBNWBFwBBloItLBDpDBnBGBNEBGZBCEBCCCBCCBCCBoUBhBpBBHyBBCSBCDBFEBCmEBF9FBEFBDFBDFBDCBEGBCGBOBBDLBCZBCSBCBBCOBDNBjB6DBGCBFsBBE3CBCMBEwBwBBsBBjEcBEwBBQbBFjBBKdBGqBBGdBCkBBFNBrB9EBDJBHjBBFjBBFnBBJzBBMLBCOBCGBCBBCKBCOBCGBCBBEzBBN2JBKVBLHBZFBCpBBCIBmCFBDCCBqBBCBBEDDBVBCnCBJIBxBSBCBBGgBBEaBGaBnB3BBFTBDxBBCBBGHBCCBCcBDCBFJBIIBI-BBhBmBBFLBK1BBEcBDaBGZBIDBNGBxCoCB4ByBBOyBBItBBJJBHlBBEcBJBBxGeBCpBBCCBDBBRFBJIBiBtBBJpBBXZBnBbBVWBKtCBFjBBK9BBCEBOYBIJBH0BBCRBJmBBK-CBCTBMRBCuBB-BGBCCCBCBCOBCKBH6BBGJBHDBCHBDBBDVBCGBCBBCEBCJBDBBDCBDHHGGBDGBEEBMJBCDDClBBCJBCDDCDBCJBCBBJBBe7CBCEBfnCBJJBnF1BBDlBBjBkCBMJBHMBU5BBHJBHTBdaBDOBFWB6F7BBlDyCBNHBDDDBGBCBBCdBCBBDLBKJBnCHBDtBBDKBcnCBJyCBOoCBIJB3CHB5ChBBPJBHIBCsBBCNBLcBEfBDVBCNBqCGBCBBCrBBECCBCCBHBJJBHFBCBBCkBBCBBCFBIJBHrBBFJB3HYBIQBCoBBEcB2CQQBwBBO6cBnDuDBCEBMjGBtyCiDBOvhBBRVBL68DBGmSB61G5BBn2B4RBIeBCJBFwCBCJBHdBDFBLlCBLJBCGBCUBGSBxN5BBnG6CBGYBDYBtBqCBF4BBIQBhCEBMGBK1mHBqBfBiDyDB+vIDBCGBCBBCiJBQeeBBBDPPBCBJrMBloCqDBGMBEIBIJBDDBh7D8HBEzNBHWBQQBQtBBDWBKzDB9B1HBLmBBDpCBJvDBWlCB7DTBNTBN2CBKYBoE0CBCmCBCBBDDDBDDBCBCLBCCCBFBCgCBCDBDHBCGBCbBCDBCEBCEEBFBCzKBDjJBD9VBQEBCOBxiBeBHFB2GGBCQBDGBCBBCEBG9BBiBxDxDBrBBENBDJBFBBhKeBS5BBGxOxOBoBB3GqBBFhGhGBdBCVBJBBhHGBCDBCBBCOBCkGBDPBqBrCBFJBFBByYjCBtC8BBjGDBCaBCBBCDDCJBCDBCCCHFFCECBBBCBBCDDCICBCCDDBCGBCDBCDBCCCBIBCQBGCBCEBCQB1BBBvIrBBFjDBNOBDOBCOBCkBBLtFB5BcBOrBBFIBIBBPFB7E4eBEQBEMBE5GBHLBFQQBKBF3BBJJBHnBBJdBDLBFBBPIBoB3KBJNBDMBEKBE4BBCFFBOBDLBFJBIyEBCmDBmgB-2pBBhB9oEBDt0FBDwpHBQtTBjtC9QBjvBq6EBGppIBnkzVvHB",!1))),this._Print}static CATEGORIES=new zc({C:()=>new T(I("AfBgDgBBOrWrWBHHBCBICCVuMuMnBBBzBBBE4B4BBGBcDBHQBXhGhGxBBB8BBBmDNB8BBByBBBQddBCCMEBhBGBsCiFiFJBBDBBXIICCBFBBKBBDBBFHBCDBDGGBaaBEEHDBDBBXIIDGDBCCGDBDBBECBCGBFCCBFBSJBEKKEXXIDDGBBLIEBCCBNBFBBNGBIEEJBBDBBXIIDGGBKKBDDBEEBFBEDBDGGBTTBIBDHHBBBEFFBBBDCCDCBDCBECBNDBGCBEFFBCCBEBCNBWEBOEEYRRBKKEFFBFBDEEDBBFBBLGBXEEYLLGBBKEEFGBDEBEFFBLLELBOEE0BEEHDBRBBbEETCBZKKCBBICBCDBHCCJFBLBBELB7BDBekBBDCCGZZCYYBGGCIILBBFfBpClBlBBCBoBlBlBQOOBjBBnGCCBDBCBB6LFFBIICFFBqBqBFBBiBFFBIICFFBQQ6BFFBkCkCBhBhBBBBbFB3CBBHBB+UCB6CGBXIBZIBVLBOEEDLB-CBBLFBLFBPMMBEB6CGBsBEBnCJBgBNNBCBNDBCCBrBBBGKBtBDBbFBMCB-BBBiCeeBMMBEBLFBPBBvBBBNTBuCnFnFBGB9BCBQCB-BEBsBBBMHBsBEB3QBBHBBnBBBHBBJGCgBBB2BQQPBBHUUBEEKMMBDBbEByBPBDBBcOOBBBjBNBiBOBtEDB7UVBMUB14BBB-LEBuBCCBDBCBB5BGBDNBZIBI4BI-DhBBb6C6CBKB3GZBxC3C3CBoDoDBDBsB-C-C3CIBxBuzcuzcBBB4BIB9KTB5FHB+GTB9BCBLFB5BHBnCHBNFB1DKBfCBvCMMBCBiB4B4BBHBPBBLBBoDXBdJBHBBHBBHIBIII9BDB-DBBLFBl9KLBYDByBjoIBvLBBrDlBBILBGEBbGGCGDrUfBrBFB0BUUFDBGoEoEBCB-FCBHBBHBBHBBECBIIIBLBDBBNbbUDDQBBPhBB8DEBEDBuBCB5COOBBBCuBBvBhEBeCByBOBdDBlBIBfEBsBEBfmBmBBCBPpBB-EBBLFBlBDBlBDBpBHB1BKBNQQIDDMQQIDDBBB1BLB4JIBXJBJXBHrBrBKkCBHBBCtBtBDCBCBBYpCpCBGBKvBBUDDBDBiBCBcEBclBB5BDBVBBzBDDBDBJEEeBBEDBLGBKGBhCfBoBDBNIB3BCBeBBcEBbGBFLBIvCBqC2BB0BMB0BGBvBHBLFBnBCBeHBDvGBgBrBrBEBBDPBHHBKgBBvBHBrBVBblBBdTBYIBvCDBlBIB-BGGBLBaGBLFB2BTTBGBoBIBhDVVBJBTwBwBB8BBICCFQQMFB8BEBLFBFJJBDDBXXIDDGLLBDDBEEBCCBEBCEBIBBICBGKBLCCBCCnBLLCBBCFFLDDBGBDcB9CGGBcBpCHBLlFB3BBBnBhBBmCKBLFBOSB7BFBLFBVbBcBBQDBY4FB9BjDB0CLBJBBCBBJDDfDDBNNBHBLlCBJBBvBBBMaBpCHB0CMBqCGBL1CBJ3CBjBNBLFBKuBuBPJBeCBhBBBXPPBnCBIDDtBCBCDDKHBLFBHDDmBDDHGBLFBtBDBL1HBaGBSqBqBBBBe0CBCOBzBMB8clDBwDGGBJBlGryCBkDMBxhBPBXJB88DEBoS41GB7Bl2BB6RGBgBLLBCByCLLBEBfBBHJBnCJBLIIWEBUvNB7BlGB8CEBaBBarBBsCDB6BGBS-BBGKBIIB3mHoBBhBgDB0D8vIBFIIDkJkJBNBCcBEBBCNBFHBtMjoCBsDEBOCBKGBLBBF-6DB+HCB1NFBYOBSOBvBBBYIB1D7BB3HJBoBBBrCHBxDUBnC5DBVLBVLB4CIBamEB2CoCoCDBBCBBDBBFNNCIIiCFFBJJIddFGGCCBI1K1KBlJlJB-V-VBNBGQQBuiBBgBFBH0GBISSBIIDGGBDB-BgBBCvDBuBCBPBBLDBD-JBgBQB7BEBCvOBrB1GBsBDBC-FBgBXXBGBD-GBIFFDQQmGBBRoBBtCDBLDBDwYBlCrCB+BhGBFccDCCBCCLFFCCCBEBCDBCECEDDCBBCICDCCBFFIKFCLLSEBEGGSzBBDtIBtBDBlDLBQBBQQQmBJBvF3BBeMBtBDBKGBDNBH5EB6eCBSCBOCB7GFBNDBCOBNDB5BHBLFBpBHBfBBNDBDNBKmBB5KHBPBBOCBMCB6BCCBCBRBBNDBLGB0EoDoDBjgBBh3pBfB-oEBBv0FBBypHOBvThtCB-QhvBBs6EEBrpIlkzVBxHvw-FB",!1)),Cc:()=>new T(I("AfgDgB",!0)),Cf:()=>new T(I("tFzqBzqBBEBXhGhGyBhMhMBxCxCs5D9-B9-BBDBbEByBEBCJBw03B6H6HBBBimEQQj7IPBhjiBDBwmFHBn0rYffB+CB",!1)),Cn:()=>new T(I("4bBBHDBICCVuMuMnBBBzBBBE4B4BBGBcDBHKBvI9B9BBmDmDBMB8BBByBBBQddBCCMEBjBEBuHJJBDDBXXICCBBBFBBKBBDBBFHBCDBDGGBaaBEEHDBDBBXIIDGDBCCGDBDBBECBCGBFCCBFBSJBEKKEXXIDDGBBLIEBCCBNBFBBNGBIEEJBBDBBXIIDGGBKKBDDBEEBFBEDBDGGBTTBIBDHHBBBEFFBBBDCCDCBDCBECBNDBGCBEFFBCCBEBCNBWEBOEEYRRBKKEFFBFBDEEDBBFBBLGBXEEYLLGBBKEEFGBDEBEFFBLLELBOEE0BEEHDBRBBbEETCBZKKCBBICBCDBHCCJFBLBBELB7BDBekBBDCCGZZCYYBGGCIILBBFfBpClBlBBCBoBlBlBQOOBjBBnGCCBDBCBB6LFFBIICFFBqBqBFBBiBFFBIICFFBQQ6BFFBkCkCBhBhBBBBbFB3CBBHBB+UCB6CGBXIBZIBVLBOEEDLB-CBBLFBLFBbFB6CGBsBEBnCJBgBNNBCBNDBCCBrBBBGKBtBDBbFBMCB-BBBiCeeBMMBEBLFBPBBvBBBNTBuCnFnFBGB9BCBQCB-BEBsBBBMHBsBEB3QBBHBBnBBBHBBJGCgBBB2BQQPBBHUUBEEKmDmDNBBcOOBBBjBNBiBOBtEDB7UVBMUB14BBB-LEBuBCCBDBCBB5BGBDNBZIBI4BI-DhBBb6C6CBKB3GZBxC3C3CBoDoDBDBsB-C-C3CIBxBuzcuzcBBB4BIB9KTB5FHB+GTB9BCBLFB5BHBnCHBNFB1DKBfCBvCMMBCBiB4B4BBHBPBBLBBoDXBdJBHBBHBBHIBIII9BDB-DBBLFBl9KLBYDByBDBvzIBBrDlBBILBGEBbGGCGDrUfBrBFB0BUUFDBGoEoEBCC-FCBHBBHBBHBBECBIIIBIBGBBNbbUDDQBBPhBB8DEBEDBuBCB5COOBBBCuBBvBhEBeCByBOBdDBlBIBfEBsBEBfmBmBBCBPpBB-EBBLFBlBDBlBDBpBHB1BKBNQQIDDMQQIDDBBB1BLB4JIBXJBJXBHrBrBKkCBHBBCtBtBDCBCBBYpCpCBGBKvBBUDDBDBiBCBcEBclBB5BDBVBBzBDDBDBJEEeBBEDBLGBKGBhCfBoBDBNIB3BCBeBBcEBbGBFLBIvCBqC2BB0BMB0BGBvBHBLFBnBCBeHBDvGBgBrBrBEBBDPBHHBKgBBvBHBrBVBblBBdTBYIBvCDBlBIBlCJBCBBaGBLFB2BTTBGBoBIBhDVVBJBTwBwBB8BBICCFQQMFB8BEBLFBFJJBDDBXXIDDGLLBDDBEEBCCBEBCEBIBBICBGKBLCCBCCnBLLCBBCFFLDDBGBDcB9CGGBcBpCHBLlFB3BBBnBhBBmCKBLFBOSB7BFBLFBVbBcBBQDBY4FB9BjDB0CLBJBBCBBJDDfDDBNNBHBLlCBJBBvBBBMaBpCHB0CMBqCGBL1CBJ3CBjBNBLFBKuBuBPJBeCBhBBBXPPBnCBIDDtBCBCDDKHBLFBHDDmBDDHGBLFBtBDBL1HBaGBSqBqBBBBe0CBCOBzBMB8clDBwDGGBJBlGryCBkDMB3iBJB88DEBoS41GB7Bl2BB6RGBgBLLBCByCLLBEBfBBHJBnCJBLIIWEBUvNB7BlGB8CEBaBBarBBsCDB6BGBS-BBGKBIIB3mHoBBhBgDB0D8vIBFIIDkJkJBNBCcBEBBCNBFHBtMjoCBsDEBOCBKGBLBBJ76DB+HCB1NFBYOBSOBvBBBYIB1D7BB3HJBoBBBjGUBnC5DBVLBVLB4CIBamEB2CoCoCDBBCBBDBBFNNCIIiCFFBJJIddFGGCCBI1K1KBlJlJB-V-VBNBGQQBuiBBgBFBH0GBISSBIIDGGBDB-BgBBCvDBuBCBPBBLDBD-JBgBQB7BEBCvOBrB1GBsBDBC-FBgBXXBGBD-GBIFFDQQmGBBRoBBtCDBLDBDwYBlCrCB+BhGBFccDCCBCCLFFCCCBEBCDBCECEDDCBBCICDCCBFFIKFCLLSEBEGGSzBBDtIBtBDBlDLBQBBQQQmBJBvF3BBeMBtBDBKGBDNBH5EB6eCBSCBOCB7GFBNDBCOBNDB5BHBLFBpBHBfBBNDBDNBKmBB5KHBPBBOCBMCB6BCCBCBRBBNDBLGB0EoDoDBjgBBh3pBfB-oEBBv0FBBypHOBvThtCB-QhvBBs6EEBrpIm8yVBCdBhD-DBxHvw-BB---BBB---BBB",!1)),Co:()=>new T(I("gg4B-nGh4hc9--BD9--B",!0)),Cs:()=>new T(I("gg2B--B",!0)),L:()=>new T(I("hCZBHZBwBLLFGGBVBCeBCpOBFLBPEBICCiEEBCBBDDBCHHCCBCCCBSBCyCBCqEBJlFBClBBDHHBnBBoCaBFDBuBqBBkBBBCiDBCQQBIIBLLBBBDRRCdBe4CBMZZBfBKBBFGGBUBFKKEYYBXBIKBGXBCGBRpBB7B1BBETTIJBQPBFHBDBBDVBCGBCEEBCBERROBBCCBPBBLJJBEBFBBDVBCGBCBBCBBCBBgBDBCUUBBBRIBCCBCVBCGBCBBCEBETTQBBYMMBGBDBBDVBCGBCBBCEBEffBCCBBBQSSCFBECBCDBEBBCCCBEEBEEBBBELBX1B1BBGBCCBCWBCPBEbbBBBCBBDBBfFFBGBCCBCWBCJBCEBEffBBBCBBQBBSIBCCBCoBBDRRGCBJCBZFBGRBEXBCIBCDDBFB7BvBBCBBNGB7BBBCCCBDBCXBCCCBIBCBBKDDBDBCWWBCBhBgCgCBGBCjBBcEB0DqBBVRRBEBFDBEEEBIIBBBFMBNSSBkBBCGGDqBBCsKBCDBDGBCCCBCBDoBBCDBDgBBCDBDGBCCCBCBDOBC4BBCDBDiCBmBPBR1CBDFBErTBDQBCZBGqCBHHBIRBOSBPRBPMBCCBQzBBkBFFkC4CBIEBDhBBCGGBkCBLeByBdBDEBMrBBFZB3BWBK0BBzC+C+CBtBBSHB3BdBOBBLrBBbjBBqBCBLjBBDKBGqBBDCBqBDBCFBCBBEGGB+FBhC1IBDFBDlBBDFBDHBCGCBdBD0BBCGBCEEBBBCGBEDBDFBFMBGCBCGB1DOORMBmDFFDJBCEEBDBHGCBCBCKBDDBGEBF1B1BB8zC8zCBjHBHDBEBBNlBBCGGD3BBIRRBVBKGBCGBCGBCGBCGBCGBCGBCGBxC2O2OBrBrBBDBGBBF1CBHCBC5CBCDBGqBBC9CBSfBxBPBhQ-tGBhCs0VBkCtBBDsIBEPBLBBVuBBReBDlCByBIBDmDBDxCBVQBCCBCDBCWBezBBPxBB-BFBECCBMMBaBLWBacBIuBBdRRBDBCJBLEBCoBBYCBCHBVWBEEEBwBBCEEBDDBDBDCCZCBDKBICBNFBDFBDFBKGBCGBCqBBCNBHyDBej9KBNWBFwBBloItLBDpDBnBGBNEBGCCBIBCMBCEBCCCBCCBCCBqDBiBqLBT-BBD1BBpBLB1DEBCmEBlBZBHZBM4CBEFBDFBDFBDCBkBLBCZBCSBCBBCOBDNBjB6DBmMcBEwBBwBfBOTBCHBHlBBLdBDjBBFHBxB9EBTjBBFjBBFnBBJzBBNKBCOBCGBCBBCKBCOBCGBCBBEzBBN2JBKVBLHBZFBCpBBCIBmCFBDCCBqBBCBBEDDBVBLWBKeBiCSBCBBLVBLZBHZBnB3BBHBBhCQQBCBCCBCcBrBcBEcBkBHBCbBc1BBLVBLSBORBvDoCB4ByBBOyBBOjBBnBbBKWB7HpBBHBBRFB5BcBLJJBUBrBRBvBUBcWBN0BB6BBBDOOBrBBhBYBbjBBeDDJiBBENNBuBBPDBWCCkBRBCYBUBBgCGBCCCBCBCOBCJBIuBBnBHBDBBDVBCGBCBBCEBETTNEBfJBCDDClBBCaaCtBtBBzBBTDBVCBfvBBVBBC5F5FBtBBqBDBlBvBBV8B8BBpBBOoCoCBZBmBGB6FrBB1D-BBgBHBDDDBGBCBBCXBQCC-CHBDmBBRCCdLLBmBBIWWMtBBUTTBnCBoGgBBgBIBCkBBSyByBBcBxDGBCBBClBBWaaBEBCBBCfBPYYBqBBlISBQCCBLBChBB9DwCwCB4cBnHjGBtyCgDBQvhBBSFBa68DBGmSB61GdBj3B4RBIeBSuCBSdBTvBBRDBgBUBGSBxNsBB0G-BBhBYBDYBtBqCBGjCjCBLBhCBBCPPBNNB0mHBqBfBiDyDB+vIDBCGBCBBCiJBQeeBBBDPPBCBJrMBloCqDBGMBEIBIJBn7F0CBCmCBCBBDDDBDDBCBCLBCCCBFBCgCBCDBDHBCGBCbBCDBCEBCEEBFBCzKBDYBCYBCeBCYBCeBCYBCeBCYBCeBCYBCHB15BeBHFBmI9BBzEsBBLGBRiKiKBcBTrBBlPbBlHdBDwGwGBdBCCBCBBCGBDEBKBBhHGBCDBCBBCOBCkGB8BjCBI1lB1lBBCBCaBCBBCDDCJBCDBCCCHFFCECBBBCBBCDDCICBCCDDBCGBCDBCDBCCCBIBCQBGCBCEBCQBlqE-2pBBhB9oEBDt0FBDwpHBQtTBjtC9QBjvBq6EBGppIB",!1)),LC:()=>new T(I("hCZBHZB7BLLBVBCeBCiGBCDBFvGBDZBhGDBDBBECBCHHCCBCCCBSBCyCBCqEBJlFBClBBKoBB44ClBBCGGDqBBDCBhV1CBDFBjkCKBGqBBDCBhCrBBgCMBChBBmD1IBDFBDlBBDFBDHBCGCBdBD0BBCGBCEEBBBCGBEDBDFBFMBGCBCGBmIFFDJBCEEBDBHGCBCBCFBFDDBCBGEBF1B1BB8zC8zCB6DBDmDBHDBEBBNlBBCGGzoetBBTbBnEtCBCWBEDBCsCBZBBE2Z2ZBpBBGIBIvCBh6TGBNEBqgBZBHZBmlBvCBhDjBBFjBB1DKBCOBCGBCBBCKBCOBCGBCBBk2ByBBOyBB+CVBLVB74C-BBhrV-BBhBYBDYBtpZ0CBCmCBCBBDDDBDDBCBCLBCCCBFBCgCBCDBDHBCGBCbBCDBCEBCEEBFBCzKBDYBCYBCeBCYBCeBCYBCeBCYBCeBCYBCHB15BJBCTBHFB2uCjCB",!1)),Ll:()=>new T(I("hDZB7BqBqBBWBCHBC2BCBQCBuBCDECBBBDCCDEEBFFDEEBBBDDDCCCDCCBCCDEECDDBDDBBBHGDCOCBSCBDDCEEC4BCBFBDDDBCCFICBjCBDZBiGCCEEEBBBTccBhBBCBBECBCWCBDBCGDB0B0BBuBBCgBCK0BCDMCBgDCxBoBBo6CqBBDCB5XFBjkCIBC2D2DBqBBgCMBChBBnD0ECBHBCgDCBHBJFBLHBJHBJFBLHBJHBJNBDHBJHBJHBJEBCBBHEEBBBCBBJDBDBBJHBLCBCBBzIEEBEEcKFDBBJDBF2B2Bs1CvBBCEEBGCFCCBCCBEBGiDCBIICFFNlBBCGG0oesBCUaCoEMCBBBC+BCBGBCCCDICFCCDCCBBBCSCGGGCMCFCCDOCbEE2ZqBBGIBIvCBh6TGBNEBqhBZBumBnBBpEjBB8EKBCOBCGBCBBk4ByBB+DVB75CfBhsVfB8BYBnqZZBbGBCRBbZBbDBCCCBFBCKBbZBbZBbZBbZBbZBbZBbZBbZBbbBdYBCFBbYBCFBbYBCFBbYBCFBbYBCFBC15B15BBIBCTBHFB4vChBB",!1)),Lm:()=>new T(I("wVRBFLBPEBICCmEGG-OnHnHlFBBuIBBFgBgBKEEhFoFoF1mBgEgE2R72B72BsDkTkTxOFBvF+BBOjBjBBjBByVOORMBg-CBByHgGgG2OsBsBBDBGiDiDB+C+CBBB34bjnBjnBBEBvIzDzDdBB6DIBxCYYpDDBEBB2OXXqEtDtDWBBoDDBKngVngVuBBBh-BFBCpBBCIB0sBhBhB2K04D04DnrTDB9PCBpBBBnRMBhCBBCPPB9-P9-PBCBCGBCBByhM9BBqGGBud0Q0QsSAB",!1)),Lo:()=>new T(I("qFQQhIFFBCBxGBB7ZaBFDBuBfBCJBkBBBCiDBCZZBLLBBBDRRCdBe4CBMZZBfBWVBrBYBIKBGXBCGBRoBB8B1BBETTIJBROBFHBDBBDVBCGBCEEBCBERROBBCCBPBBLJJBEBFBBDVBCGBCBBCBBCBBgBDBCUUBBBRIBCCBCVBCGBCBBCEBETTQBBYMMBGBDBBDVBCGBCBBCEBEffBCCBBBQSSCFBECBCDBEBBCCCBEEBEEBBBELBX1B1BBGBCCBCWBCPBEbbBBBCBBDBBfFFBGBCCBCWBCJBCEBEffBBBCBBQBBSIBCCBCoBBDRRGCBJCBZFBGRBEXBCIBCDDBFB7BvBBCBBNFB8BBBCCCBDBCXBCCCBIBCBBKDDBDBYDBhBgCgCBGBCjBBcEB0DqBBVRRBEBFDBEEEBIIBBBFMBNyDyDBnKBCDBDGBCCCBCBDoBBCDBDgBBCDBDGBCCCBCBDOBC4BBCDBDiCBmBPByDrTBDQBCZBGqCBHHBIRBOSBPRBPMBCCBQzBBpBkCkCBhBBC0BBIEBDhBBCGGBkCBLeByBdBDEBMrBBFZB3BWBK0BBxFuBBSHB3BdBOBBLrBBbjBBqBCBLdByDDBCFBCBBE7hB7hBBCB4-C3BBZWBKGBCGBCGBCGBCGBCGBCGBCGBoR2B2BF1CBJCCB4CBFGGBpBBC9CBSfBxBPBhQ-tGBhC0wUBC2jBBkCnBBJrIBFPBLBBjCyByBBkCBqFoDoDEGBCCBCDBCWBezBBPxBB-BFBECCBMMBaBLWBacBIuBBuBEBDIBLEBCoBBYCBCHBVPBCFBEEEBwBBCEEBDDBDBDCCZBBEKBIPPBEBDFBDFBKGBCGByEiBBej9KBNWBFwBBloItLBDpDBkCCCBIBCMBCEBCCCBCCBCCBqDBiBqLBT-BBD1BBpBLB1DEBCmEBqDJBCsBBDeBEFBDFBDFBDCBkBLBCZBCSBCBBCOBDNBjB6DBmMcBEwBBwBfBOTBCHBHlBBLdBDjBBFHBhEtCBjDnBBJzBB9CzBBN2JBKVBLHB5EFBDCCBqBBCBBEDDBVBLWBKeBiCSBCBBLVBLZBHZBnB3BBHBBhCQQBCBCCBCcBrBcBEcBkBHBCbBc1BBLVBLSBORBvDoCB4FjBBnBDBCxJxJBoBBHBBRCBCBB5BcBLJJBUBrBRBvBUBcWBN0BB6BBBDOOBrBBhBYBbjBBeDDJiBBENNBuBBPDBWCCkBRBCYBUBBgCGBCCCBCBCOBCJBIuBBnBHBDBBDVBCGBCBBCEBETTNEBfJBCDDClBBCaaCtBtBBzBBTDBVCBfvBBVBBC5F5FBtBBqBDBlBvBBV8B8BBpBBOoCoCBZBmBGB6FrBB0GHBDDDBGBCBBCXBQCC-CHBDmBBRCCdLLBmBBIWWMtBBUTTBnCBoGgBBgBIBCkBBSyByBBcBxDGBCBBClBBWaaBEBCBBCfBPYYBnBBCBBlISBQCCBLBChBB9DwCwCB4cBnHjGBtyCgDBQvhBBSFBa68DBGmSB61GdBj3B4RBIeBSuCBSdBTvBB0BUBGSB0NnBB2MqCBGwFwFB0mHBqBfBiDyDBuwIiJBQeeBBBDPPBCBJrMBloCqDBGMBEIBIJBxzI2P2PBrBBiBiKiKBcBTrBBlPaBmHdBDwGwGBdBCCBCBBCGBDEBKiHiHBFBCDBCBBCOBCkGB8pBDBCaBCBBCDDCJBCDBCCCHFFCECBBBCBBCDDCICBCCDDBCGBCDBCDBCCCBIBCQBGCBCEBCQBlqE-2pBBhB9oEBDt0FBDwpHBQtTBjtC9QBjvBq6EBGppIB",!1)),Lt:()=>new T(I("lOGDnB2sH2sHBGBJHBJHBNQQwBAB",!1)),Lu:()=>new T(I("hCZBmDWBCGBiB2BCDOCDuBCBECEBBCCCBCCBBBDDBCBBCCBEBBCBBCECBCCDCCBCCBBBCCCBEEIJDCMCDQCDDDCCBC4BCIBBCBBDCCBCBCGCiJCCEJJHCCBBBCCCBCCBPBCIBkBDDBBBEWCGDDCBBDyBBxBgBCK2BCBMCD+CCDlBBq6ClBBCGGzW1CB0kCHHBpBBDCBhK0ECKgDCKHBJFBLHBJHBJFBMGCJHBpCDBNDBNDBNEBMDBnIFFECBDCBDEEBDBHGCBCBDDBLBBG+B+B9zCvBBxBCCBBBDGCBCBCDDJCBCgDCJCCFuqeuqeCqBCUaCoEMCE8BCLECBICFCCDCCEUCBDBCEBCOCBCBCCCBQCZs5Vs5VBYBmmBnBBpEjBB9EKBCOBCGBCBBr3ByBB+EVB75CfBhsVfBhCYBoqZZBbZBbZBbCCBGDBDDBCBCHBbZBbBBCDBDHBCGBcBBCDBCEBCEEBFBcZBbZBbZBbZBbZBbZBfYBiBYBiBYBiBYBiBYBiB2pE2pEBgBB",!1)),M:()=>new T(I("gYvDB0IGBoIsBBCCCBCCBCCpCKBxBUBRmDmDBFBDFBDBBCDBkBffBZB8CKB7BIBKZZBCBCIBCCBCEBsBCB8BIBrBXBCgBB3BCBCRBCGBLBBeCB5BCCBFBDBBDCBKLLBbbDCB5BCCBDBFBBDCBEffBEEMCB5BCCBGBCCBCCBVBBXFBCCB5BCCBFBDBBDCBICBLBBf8B8BBDBECBCDBKpBpBBDB4BCCBFBCCBCDBIBBMBBeCB5BCCBFBCCBCDBIBBMBBQNNBCB4BBBCGBCCBCDBKLLBeeBBBnCFFBEBCCCBGBTBB+BDDBFBNHBjDDDBHBMGBqCBBcECFBByBTBCBBGKBCjBBKlDlDBSBYDBFCBCCBDGBEDBOLBCLLBCBgWCBzdDBdCBeBBfBBhCfBKuBuBBBBC2D2DBjBjB3DLBFLB8GEB6BJBCcBDxBxBBsBBDLBVEBwBQBnBIBNCBfMB5BNBxBTB5ECBCUBFHHDCBnG-BBxWgBB--CCBuEhDhDBeBrRFBqDBB1udDBCJBhBBBxCBBxIEEFYYBDBF0C0CBzBzBBQBbRBOnBnBBGBaMBtBDBwBNBlBkCkCBMBNJJBuBuBBBBzBCCBBBDBBGBBCqBqBBDBGBBtHHBCBBx5TiXiXBOBRPBuejHjH2EEBn0BCBCBBGDBpBCBFmFmFB+R+RBCBiCEB+JBBuCFBnCKByBDB7DCB2BOBqBDDBLLBCBuBKBI+B+BBBBlBNBRBBtBNNBBBxBNBJDBCBB9CLBHDD+ELBWDB4BBBCGBDBBDCBKLLBDDBFBEEBkCIBCDDCDBCEBCPPBzCzCBQBYyCyCBSBsHGBDIBcBBzCQBrDMBmDOBhIOB2HFBCBBDDBCCCBuEuEBFBDGBEddBIBpBGBCDBJKKBJBvBPBnGHBoGHBCHBzCVBCNB7DFBECCBCCBFBCjCjCBDBCBBCEB8KDBKBBCxBxBBFBEEBYmnFmnFHOBpmLRBhuCEB8BGB5gBCCB1BBIDByCMMBslTslTBizEizEBsBBDWB-QEBEFBJHBDGBfDB1ECB89B2BBFxBBJPPXEBCOBxqBGBCQBDGBCBBCEBlDhFhFBFB4L+B+BBCB9PDB-HBB0HDDIBBG7O7OBFBuDGB29lYvHB",!1)),Mc:()=>new T(I("joC4B4BDCBJDBCBBzBBB7BCBHBBDBBLsBsB7BCBjC7B7BBBBJCCB2B2BB7B7BCHHBDDBLLnDBBCBBECBCCBLqBqBBBB+BDB+BBB7BCCBDBDBBCBBKBBdPPB7B7BBBBGCBCCBLrBrBBsCsCBBBHHBTBBrKBBgCsFsFBFFHDDBaaBLLBBBDGBWBBDFBDLLBBB5zBffiEIIBGBCBB7KDBDCBFBBCFBhHBB7BCCKCCBJJBEByExBxBGCCBDBCBB+BffFBBD9B9BDCBCEEBxBxBBGBJBBsFWW35EBB0-dBBD5C5CBzBzBBOBvEBBwBxBxBBFFBDDBBBvDBBDBBZuBuBCuDuDDBBGuHuHBCCBCCBCC0gZCCgEuBuBBBBFBB0DZZB8B8BxBCBKBBO+C+CBBBEBBCrFrFBBBgBBB7BBBCDBDBBDCBKLLB1C1CBBBIDDCDBCBBCmDmDBBBJBBErDrDBBBHCCBCBDuHuHBBBHDBDyDyDBBBJBBCuDuDCBBHoDoDCBBFmImIBBBK4H4HBEBCBBFDDCvEvEBBBJDBF1C1CeBB-BqGqGECCoGPPrDIID2G2GBDBFBBC-K-KBNNxBBBJBBCpvQpvQBBBlxD2BBpDBB0rYBBHFB",!1)),Me:()=>new T(I("okBBB1xF-wB-wBBCBCCBsshBCB",!1)),Mn:()=>new T(I("gYvDB0IEBqIsBBCCCBCCBCCpCKBxBUBRmDmDBFBDFBDBBCDBkBffBZB8CKB7BIBKZZBCBCIBCCBCEBsBCB8BIBrBXBCfB4BCCFHBFEEBFBLBBe7B7BFDBJVVBbbDBB6BFFBFFBDDBBBEffBEEMBB6BFFBDBCBBFVVBXXBEBC7B7BDCCBCBJIIBMMBff+BNNzBEE4BCCBBBGCBCDBIBBMBBe7B7BDHHGBBVBBdBB6BBBFDBJVVBeepCIIBBBC7C7CDGBNHBjDDDBHBMGBqCBBcEC4BNBCEBCBBGKBCjBBKnDnDBCBCFBCBBDBBaBBFCBRDBODDBHHQgWgWBBBzdCBeBBfBBfBBhCBBCGBJDDBJBKuBuBBBBC2D2DBjBjB3DCBFBBKHHBBB8GBBD7B7BCGBCCCDHBHJBDxBxBBMBCeBDLBVDBxBCCBDBCGGpBIBNBBhBDBDBBCCB5BCCBEECCB7BHBDBB5ECBCMBCGBFHHEBBnG-BBxWMBFEEBKB--CCBuEhDhDBeBrRDBsDBB1udFFBIBhBBBxCBBxIEEFaaBGG4EBBbRBOnBnBBGBaKBvBCBxBDDBCBDBBoBkCkCBEBDBBDBBNJJwB0B0BCCBDBBGBBCrBrBBJJvHDDFx5Tx5TiXPBRPBuejHjH2EEBn0BCBCBBGDBpBCBFmFmFB+R+RBCBiCEB+JBBuCFBnCKByBDB8D3B3BBNBqBDDBLLBBByBDBDBBI+B+BBBBlBEBCHB-BNNB1B1BBHBLDBDgDgDBBBDCCBHHD+E+EEHBWBB6BBBEmBmBBFBEEBnCFBOECPBB2CHBDCBCYY1CFBCFFBCCBvHvHBCBHBBCBBcBB2CHBDCCBrDrDCDDBEBCmDmDCDDBCBCEBkIIBCBBhIBBCFFxEDBDBBFhBhBBIBpBFBDDBJKKBEBDCBvBMBCBBnGCCBBBCqGqGBFBCFBCzCzCBUBDGBCBBCBB7DFBECCBCCBFBCpCpCBEEC8K8KBMMB1B1BBDBGCCYmnFmnFHOBpmLLBECBhuCEB8BGB5gBgCgCBCByC5lT5lTBizEizEBsBBDWBhRCBSHBDGBfDB1ECB89B2BBFxBBJPPXEBCOBxqBGBCQBDGBCBBCEBlDhFhFBFB4L+B+BBCB9PDB-HBB0HDDIBBG7O7OBFBuDGB29lYvHB",!1)),N:()=>new T(I("wBJB5DBBGDDBBBitBJBnEJBnGJB9MJB3DJBFFBtDJB3DJB3DJBDFBvDMB0DJBJGBoDJBpDGBISBuDJBhDJB3DJBnCTBtIJBnCJBwWTBybCBwHJBHJBXJBtJJBhEKBmFJBHJB3FJB3CJBnEJBHJB3gBEEBEBHJBnGyBBDEB3W7BBvCVB3TdBqrBqYqYaIBPCB4KDBrEJBfHBCOBhBJBoBOBh7cJB9FJBhKFB7EJBnBJBnGJBXJB3CJB3MJB34UJBuPsBBN4BBSBB2KaBlBDBeJJnEEBrGJBvdHBaGBoBIBsCEBXFBhFBBDPBDtBBhCIB1BBBfCBsCEBpDHBZHBqBGBrKFBxBJBHJB3IeB-EJBrBDBxDGBnEdBhEJB9BJBxEJBITB8HJB3KJB3DJB3LJBnDJBHTBtCLBlNSB+CJB3UJB3CcBkHJBnCJB3BJBnLJBnDUBshBuDBimPJBnpCJB3CJBnEJBCGBvQJBnIWB+KCB6nXJBnuBTBNTBtDYB2iBxBBhqCJBnNJB3PJB4HJBtWIBhEJB4Y6BBCCBCDBtCsBBCOBjeMBk3CJB",!1)),Nd:()=>new T(I("wBJnxBJnEJnGJ9MJ3DJ3DJ3DJ3DJ3DJ3DJ3DJ3DJ3DJhDJ3DJnCJ3IJnCJn6BJnBJtJJhEJnFJHJ3FJ3CJnEJHJnuiBJnVJnBJnGJXJ3CJ3MJ34UJnsBJnkCJHJ9YJhEJ9BJxEJ3IJ3KJ3DJ3LJnDJHTtCJnNJnDJ3UJ3CJ3HJnCJ3BJnLJ3uQJnpCJ3CJnEJ3QJ37XJ12CxBhqCJnNJ3PJ4HJ2aJ30EJ",!0)),Nl:()=>new T(I("u3FCBwzCiBBDDB-zDaaBHBPCBs1dJBxyW0BBtOJJnEEBrhIuDBm8SCB",!1)),No:()=>new T(I("yFBBGDDBBB2pCFB5LFB5DCBmEGB6GGBSIByNJB2hBTB0jBJBhP20B20BEFBHJBnGPBqB3W3WB6BBvCVB3TdBqrB1kB1kBBCBrEJBfHBCOBhBJBoBOBxrdFBymWsBBiCDBSBB2KaBlBDB1pBHBaGBoBIBsCEBXFBhFBBDPBDtBBhCIB1BBBfCBsCEBpDHBZHBqBGBrKFBhLeB-EJBrBDBxDGBnETB8LTBmqBBBvNIBobSB0aUBn8SGB-YWBqhZTBNTBtDYBvqFIBid6BBCCBCDBtCsBBCOBjeMB",!1)),P:()=>new T(I("hBCBCFBCDBLBBEBBbCBCccCkBkBGEELBBEEE-VJJzOFBqBBB0BCCDDDtBBBVBBCBBOCCBBBrCDBnDsBsBBMBqHCB3BOBgBmImIBLLtE5D5D6DnMnMNwLwL7CLLBpFpFBNBCmBmBBCBoCrCrCBDBFBBwDFBsFlTlTBHB4EuTuTtBBBvCCBoCBB+ECBCCBmBKB6JBB5GBBhEGBCFBhFBBLGBdCB9DDB8BEB-BBBhCHBM9Z9ZBWBJTBCMBCLBfBBPBB6TDBeBB+hBNBwCBBgBJB0MVBgCDBhBBB8XDBCBBxDwEwEBtBBCfBDLBkNCBFJBDLBRNNjD7C7CjgdBBuICBkDLL0DFB9LDB3CBBpBCBCyByBBwBwBiDMBRBB9DDB-DBBRBB6HzqUzqUBxGxGBIBXiBBCNBCFFCBB2ECBCFBCDBLBBEBBbCBCccCCCBFB7MCB9UxBxB-MoXoXoGgBgBxIIBnBxDxDBFBjCGB6CDByO-J-JjBlElEBDBtBDB+FGBuDBBCDB-DDBxBBBwCDBFOOCCB5CFBsDrJrJBCCBzDzDBDBLBBCpDpD7HWBqDCBdMBtCjEjEBBB9HpIpIBBB8E9C9CBGB0CCBCEB+CJB4GgDgDBDBrBBBmUBBrCMBwFxjBxjBBDB97CBB8zOBBmEiCiCBDBJpRpRBBBoJDBoK9lT9lTovHEB07C-a-aBAB",!1)),Pc:()=>new T(I("-Cg-Hg-HBUU-u3BBBZCBwHAB",!1)),Pd:()=>new T(I("tB9qB9qB0BiyDiyDmgBqgCqgCBEBiwDDDgBBBFdd-NUUwDxszBxszBBmBmBLqFqFhzD-J-J",!1)),Pe:()=>new T(I("pB0B0BgB+1D+1DC-6B-6BqtC4B4BQ7T7TCff-hBMCxChBhBCGC1MUChCCCiBmhBmhBCECtBGCtNICEGCDBB-ozB6G6GeOCESSCCCrF0B0BgBGD",!1)),Pf:()=>new T(I("7F+6H+6HEddpuDCCFDDQEE",!1)),Pi:()=>new T(I("rFt7Ht7HDBBDaapuDCCFDDQEE",!1)),Po:()=>new T(I("hBCBCCBDECBLLBEEBcclCGGPBBI-V-VJzOzOBEBqB3B3BDDDtBBBVBBCBBOCCBBBrCDBnDsBsBBMBqHCB3BOBgBmImIBLLtE5D5D6DnMnMNwLwL7CLLBpFpFBNBCxDxDrCEBFBBwDFBsFlTlTBHBmY9D9DBBBoCBB+ECBCCBmBFBCDB6JBB5GBBhEGBCFBhFBBLGBdCB9DDB8BEB-BBBhCHBMjajaBJJBGBJIBDDBDCBEKBCCCBIB7kDDBCBBxDwEwEBFFBBBDDDBHBCBBCDDBLLBDBCJBDDBCCCBLBDCBtNCB6B+F+FjgdBBuICBkDLL0DFB9LDB3CBBpBCBCyByBBwBwBiDMBRBB9DDB-DBBRBB6HlxUlxUBFBDXXVBBDDBECBCDBICBHCCB2E2EBBBCCBDECBLLBEEBcclBDDB7M7MBBB9UxBxB-MoXoXoGgBgBxIIBnBxDxDBFBjCGB6CDB0ZlElEBDBtBDB+FGBuDBBCDB-DDBxBBBwCDBFOOCCB5CFBsDrJrJBCCBzDzDBDBLBBCpDpD7HWBqDCBdMBtCjEjEBBB9HpIpIBBB8E9C9CBGB0CCBCEB+CJB4GgDgDBDBrBBBmUBBrCMBwFxjBxjBBDB97CBB8zOBBmEiCiCBDBJpRpRBBBoJDBoK9lT9lTovHEB07C-a-aBAB",!1)),Ps:()=>new T(I("oBzBzBgB-1D-1DC-6B-6B-rCEEnB4B4BQ7T7TCff-hBMCxChBhBCGC1MUChCCCiBmhBmhBCECaTTCECtNICEGCDipzBipzB4GeeCMCESSCCCrFzBzBgBEEDAB",!1)),S:()=>new T(I("kBHHRCBgBCCcCCkBEBCBBDCCBCBDEEfgBgBrODBNNBGGBCCCBPB2DPPBxDxDsErIrIBBB3DCBDDDBvGvGLUUB4H4HIBBpEqLqLBHHB2H2H-DjEjEBGBlEwGwGqBmGmGiGCBQCCBBBDFBVECmEHBCFBCBBGDBmGBBxXJB0WuLuLlL+E+EBgBBiLJBKIBhiBCCBBBMCBOCBOCBOBBmCOOoBCBOCBUhBB-BBBCDBCBBLCCBBBGFBCECFMMBFFBDBGDBC7B7BBFFB2LBFcBD+HBXKByCtCBXnTBtBwBBDeBLyMBX+BBFfBD1LBDpEBmHFBmLBBvBZBC4CBN1GBbPBFOOBNNWBBHBB8CBB0HBBFJBhBlBBKRRBdBMdBJQQBeBLmBBQ-JBhuG-BBx0V2BB6RWBKBBoDBB+EDBLDB+RCBiHPPB+9T+9TpEgBBuLPBhCBB3BHBtBDBjDCCBBBD7E7EHRRBBBgBCCcCCiEGBCGBOBB6JIB6BQBDCBCMBEwBwBBrBB7zBBBwSmWmWBiKiKBGBnjC2kC2kCBbBr6SDBG3qU3qUk7DvHBLCBEzNBHWBQQBgDzDB9B1HBLmBBD7BBGCBXBBIdBF8BBWhCBE7F7FB1CBrbaagBaagBaagBaagBaa9B-PB4BDBzBHBCNBCBBp2BwNwNttCEE+DiOiOBvIvIBqBBFjDBNOBDOBCOBCkBBYgFB5BcBOrBBFIBIBBPFB7E4eBEQBEMBE5GBHLBFQQBKBF3BBJJBHnBBJdBDLBFBBPIBoB3KBJNBDMBEKBE4BBCFFBOBDLBFJBIyEBC7CBLAB",!1)),Sc:()=>new T(I("kB+D+DBCBqnB8D8DzPBBzPBBI2H2HoImSmS8sClmClmCBgBB37hBkuVkuVtD7E7E8GBBEBB3-HDB-4wBxtCxtC",!1)),Sk:()=>new T(I("+CCCoCHHFEEqQDBNNBGGBCCCBPB2DPPBjoBjoB15FCCBBBMCBOCBOCBOBB9kEBBkzdWBKBBoDBBxePPBniUniUBPB8bCCjF4g9B4g9BBDB",!1)),Sm:()=>new T(I("rBRRBBB+BCCuBFFmBgBgB-XwQwQBBB8xGOOoBCBOCBsEoBoBBDBHlClCBDBGBBFGDIgBgBBDDCgBgBBqIBhBBB7CffBXBpBFB2OKK3BHBwDxKxKBDBDeBLPBhIiEBX+BBFfBDhIBxBUBDFB9+zB5Z5ZCCBlFRRBBB+BCCkEHHBCBitDBBhrwBx+Bx+BagBgBagBgBagBgBagBgBat5Ft5FB-uC-uCBHB",!1)),So:()=>new T(I("mFDDFCCyerIrIBgEgEBvGvGLUUB4H4HkQ2L2LjEFBClElEwGqBqBoMCBQCCBBBDFBVECmEHBCFBCBBGDBmGBBxXJB0WzWzW+EhBBiLJBKIBksBBBCDBCBBLCCBHHBEBCECFMMBPPCBBC7B7BBKKBDBDDBCBBCBBCGBCeBDBBCCCBdBtIHBFTBDGBDwCBCdBanBBHnCBXKByCtCBX2FBCIBC1BBJuDBC3HBtBrBBhC-HBhQvBBWBBHmBBDpEBmHFBmLBBvBZBC4CBN1GBbPBFOOBNNWBBHBBxKBBFJBhBlBBKRRBdBMdBJQQBeBLmBBQ-JBhuG-BBx0V2BBibDBLBBC+R+RBBBqqUPBuLPBhCBB3BHBuBCBlPEEFBBOBB6JIB6BQBDCBCMBEwBwBBrBB7zBBBwSpgBpgBBGBnjC2kC2kCBGBFQBr6SDBG3qU3qUk7DvHBLCBEzNBHWBQPBhDzDB9B1HBLmBBD7BBGCBXBBIdBF8BBWhCBE7F7FB1CBqlB-PB4BDBzBHBCNBCBBp2B96C96CiEyWyWBqBBFjDBNOBDOBCOBCkBBYgFB5BcBOrBBFIBIBBPFB7E6HBG4WBEQBEMBE5GBHLBFQQBKBF3BBJJBHnBBJdBDLBFBB-B3KBJNBDMBEKBE4BBCFFBOBDLBFJBIyEBC7CBLAB",!1)),Z:()=>new T(I("gBgEgEgvFgsCgsCBJBeBBGwBwBh9DAB",!1)),Zl:()=>new T(I("ohIA",!0)),Zp:()=>new T(I("phIA",!0)),Zs:()=>new T(I("gBgEgEgvFgsCgsCBJBlBwBwBh9DAB",!1)),ASCII_Hex_Digit:()=>new T(I("wBJIFbF",!0)),Alphabetic:()=>new T(I("hCZBHZBwBLLFGGBVBCeBCpOBFLBPEBICC3CeeBQBCBBDDBCHHCCBCCCBSBCyCBCqEBJlFBClBBDHHBnBBoBNBCCCBCCBCCJaBFDBeKBG3BBCGBPlDBCHBFHBFCBLCBDRRBuBBOkDBZgBBKBBFGGBWBDSBUYBIKBGXBCGBIJJBoBBLLBEGBHrCBCPBCCBFOBOSBCHBDBBDVBCGBCEEBCBEHBDBBDBBCJJFBBCEBNBBLFFBBBCFBFBBDVBCGBCBBCBBCBBFEBFBBDBBFIIBCBCSSBEBMCBCIBCCBCVBCGBCBBCEBEIBCCBCBBEQQBCBWDBFCBCHBDBBDVBCGBCBBCEBEHBDBBDBBKBBFBBCEBORRBCCBEBECBCDBEBBCCCBEEBEEBBBELBFEBECBCCBEHHpBMBCCBCWBCPBEHBCCBCCBJBBCCBCBBDDBdDBCHBCCBCWBCJBCEBEHBCCBCCBJBBGCBCDBOCBNMBCCBCoBBDHBCCBCCBCGGBCBIEBXFBCCBCRBEXBCIBCDDBFBJFBCCCBGBTBBO5BBGGBH0B0BBECBDBCXBCCCBRBCCBDEBCHHPDBhBgCgCBGBCjBBFSBFPBCjBBkC2BBCDDBDBR-BBLDBDlBBCGGDqBBCsKBCDBDGBCCCBCBDoBBCDBDgBBCDBDGBCCCBCBDOBC4BBCDBDiCBmBPBR1CBDFBErTBDQBCZBGqCBEKBITBMUBNTBNMBCCBCBBNzBBDSBPFFkC4CBIqBBGlCBLeBCLBFIBYdBDEBMrBBFZB3BbBF+BBDTBzBYYBMMBBByBzBBCOBCHB0BpBBDDBLrBBCKBP2BBXCBLjBBDKBGqBBDCBqBDBCFBCBBEGGB+FBUhBBM1IBDFBDlBBDFBDHBCGCBdBD0BBCGBCEEBBBCGBEDBDFBFMBGCBCGB1DOORMBmDFFDJBCEEBDBHGCBCBCKBDDBGEBFSSBnBBuZzBB34BkHBHDBEBBNlBBCGGD3BBIRRBVBKGBCGBCGBCGBCGBCGBCGBCGBCfBwB2O2OBBBaIBIEBDEBF1CBHCBC5CBCDBGqBBC9CBSfBxBPBhQ-tGBhCs0VBkCtBBDsIBEPBLBBVuBBGHBEwDBoBIBDmDBDxCBVUBCgBBZzBBNjCBCtBtBBEBECCBBBLgBBGiBBOcBEyBBCLBQRRBOBLEBC2BBKNBTWBEkCBCCCZCBDPBDDBMFBDFBDFBKGBCGBCqBBCNBH6DBWj9KBNWBFwBBloItLBDpDBnBGBNEBGLBCMBCEBCCCBCCBCCBqDBiBqLBT-BBD1BBpBLB1DEBCmEBlBZBHZBM4CBEFBDFBDFBDCBkBLBCZBCSBCBBCOBDNBjB6DBmC0BBsIcBEwBBwBfBOdBGqBBGdBDjBBFHBCEBrB9EBTjBBFjBBFnBBJzBBNKBCOBCGBCBBCKBCOBCGBCBBEzBBN2JBKVBLHBZFBCpBBCIBmCFBDCCBqBBCBBEDDBVBLWBKeBiCSBCBBLVBLZBHZBnB3BBHBBhCDBCBBGHBCCBCcBrBcBEcBkBHBCbBc1BBLVBLSBORBvDoCB4ByBBOyBBOnBBjBbBEGGBVB7HpBBCBBEBBRFBzBCBEcBLJJBUBrBRBvBUBcWBKlCBsBEBL4BBKOOBXBYyBBSDBJiBBEKKB+BBCDBKBBLCCkBRBChBBDHHBCB-BGBCCCBCBCOBCJBI4BBYDBCHBDBBDVBCGBCBBCEBEHBDBBDBBEHHGGBdJBCDDClBBCJBCDDCDBCBBECCtBhCBCCBCDBVCBfhCBDBBC5F5FB0BBDGBaFBjB+BBCEE8B1BBDoCoCBZBDNBWGB6F4BBoD-BBgBHBDDDBGBCBBCdBCBBDBBDDB+CHBDtBBDFBCCCBccBxBBDJBSnCBGTTBnCBoDHB5CgBBgBIBCsBBCGBCyByBBcBDVBCNBqCGBCBBCrBBECCBCCBBBCDDBZZBEBCBBCkBBCBBCDBCYYBqBBlIWBKQBCoBBECBwDwCwCB4cBnDuDBSjGBtyCgDBQvhBBSFBa68DBGmSB61GuBBy2B4RBIeBSuCBSdBTvBBRDBgBUBGSBxNsBB0G-BBhBYBDYBtBqCBF4BBIQBhCBBCNNBFBK1mHBqBfBiDyDB+vIDBCGBCBBCiJBQeeBBBDPPBCBJrMBloCqDBGMBEIBIJBFi7Fi7FBzCBCmCBCBBDDDBDDBCBCLBCCCBFBCgCBCDBDHBCGBCbBCDBCEBCEEBFBCzKBDYBCYBCeBCYBCeBCYBCeBCYBCeBCYBCHB15BeBHFB2GGBCQBDGBCBBCEBG9BBiBxDxDBrBBLGBRiKiKBcBTrBBlPbBlHdBDwGwGBdBCVBJBBhHGBCDBCBBCOBCkGB8BjCBEEE1lBDBCaBCBBCDDCJBCDBCCCHFFCECBBBCBBCDDCICBCCDDBCGBCDBCDBCCCBIBCQBGCBCEBCQB1TZBHZBHZB3zD-2pBBhB9oEBDt0FBDwpHBQtTBjtC9QBjvBq6EBGppIB",!1)),Dash:()=>new T(I("tB9qB9qB0BiyDiyDmgBqgCqgCBEB+BoBoBQnMnMlgDDDgBBBFdd-NUUwDxszBxszBBmBmBLqFqFhzD-J-J",!1)),Emoji:()=>new T(I("jBHHGJBwDFFu8HNN5GXX7CFBQBBwLBBNnFnFaKBFCBoGoHoHBLLK7B7BBCBCEBKGDBDDFDDCBBDIEBJJBBBGCCGLBMBBDCCBCCTDDBTTBEBCCCBEEBGGDBBFBBMBBGBBDGGBECBVVBGGBEBCDBDFFDDDBEBCDDCCCHEEHLLBQQDFFCFFBBBCMMBxBxBBBBKeP1LBBwOCBUBB0BFF7mBNN6SCCrrvDrGrGhFBBNBBPDDBIBsCZBCBBYVVDIBWBBvFhBBDvDBDBBCCBDyCBDCBCmIBC+BBMFBCXBIBBDHBNDDBCBDFFBOOBDDJBBKGGBBBNCBJCBDCCFHHEHHB0CBxBlCBGHBDDBEJBECCBEEDJBkHLBF8I8IBtBBCJBC4FBxDMBEKBE4BBCFFBOBDLBFJB",!1)),Emoji_Component:()=>new T(I("jBHHGJB0+H2G2Gsp3B3+8B3+8BBYB8PEBxtBDBtzhY-CB",!1)),Emoji_Modifier:()=>new T(I("7-8DE",!0)),Emoji_Modifier_Base:()=>new T(I("9wJ8G8GRDB4jzD9B9BBBBDDDBBB2DBBDKBWSBEFFBBBCCBICCZqGqGBFFWFFBvFvFBBBEEB0CRRBBBKMMgSDDJHBHKKBIBDCB5B+B+BBCCBCCSCBCMBmHCBrBIB",!1)),Emoji_Presentation:()=>new T(I("64IBBuGDBEDDqQBBWBBzBLBsBUUOJJBSSBGGBJJGWWIBBCFFDIIFBBdkBkBCFFBBBC+B+BBBBZPP8aBB0BFFvlxDrGrG-FDDBIBsCZBCZZVDDBDBCCBWBBvFgBBNIBClCBCVBNqBBFEBNQBEEEBlCBCCCB5FBD+BBODBCXBTbbBOO3C0CBxBlCBHEEBBBDDBEDBMBBIIBkHLBF8I8IBtBBCJBC4FBxDMBEKBE4BBCFFBOBDLBFJB",!1)),Extended_Pictographic:()=>new T(I("pFFFu8HNN5GXX7CFBQBBwLBBNnFnFaKBFCBoGoHoHBLLK7B7BBCBCEBKGDBDDFDDCBBDIEBJJBBBGCCGLBMBBDCCBCCTDDBTTBEBCCCBEEBGGDBBFBBMBBGBBDGGBECBVVBGGBEBCDBDFFDDDBEBCDDCCCHEEHLLBQQDFFCFFBBBCMMBxBxBBBBKeP1LBBwOCBUBB0BFF7mBNN6SCCrrvDoBoBBCBlDLBQBBQPPBmBmBBIBxDBBNBBPDDBIBU3BBcOBLVVDIBCDBKWBH7FBDvDBDBBCCBDyCBDCBCDBG9HBC+BBMFBCXBIBBDHBNDDBCBDFFBOOBDDJBBKGGBBBNCBJCBDCCFHHEHHB0CBxBlCBGHBDQBECCBEBDMB7GlBBNDB5BHBLFBpBHBfBBNDBDNBKmBBNuBBCJBC4FB5CHBPxEBhI9fB",!1)),Hex_Digit:()=>new T(I("wBJIFbFq1-BJIFbF",!0)),Lowercase:()=>new T(I("hDZBwBLLFlBlBBWBCHBC2BCBQCBuBCDECBBBDCCDEEBFFDEEBBBDDDCCCDCCBCCDEECDDBDDBBBHGDCOCBSCBDDCEEC4BCBFBDDDBCCFICBjCBDiBBIBBfEBhDsBsBCEEDDBTccBhBBCBBECBCWCBDBCGDB0B0BBuBBCgBCK0BCDMCBgDCxBoBBo6CqBBCDB5XFBjkCIBC2D2DB+FBiC0ECBHBCgDCBHBJFBLHBJHBJFBLHBJHBJNBDHBJHBJHBJEBCBBHEEBBBCBBJDBDBBJHBLCBCBB6DOORMBuDEEBEEcKFDBBJDBFiBiBBOBFsasaBYBn6BvBBCEEBGCFCCBCCBGBEiDCBIICFFNlBBCGG0oesBCUaCBBBmEMCBBBC8BCBIBCCCDICFCCDCCBBBCSCGGGCMCFCCDOCWDBCCCBBB2ZqBBCNBHvCBh6TGBNEBqhBZBumBnBBpEjBB8EKBCOBCGBCBBkODDBBBCpBBCIBmoByBB+DVB75CfBhsVfB8BYBnqZZBbGBCRBbZBbDBCCCBFBCKBbZBbZBbZBbZBbZBbZBbZBbZBbbBdYBCFBbYBCFBbYBCFBbYBCFBbYBCFBC15B15BBIBCTBHFBmI9BB1lChBB",!1)),Math:()=>new T(I("rBRRBBBgBeeCuBuBFmBmBgB5W5WBBBDbbBDDBBBwQCBuwGccBBBMEEOPPBCBWEBMEBiCMBFEEBFFBDBTFFDJBCDDBEBHEEBDDBCCBBBCFBENBClClCBWBCFBCBBFBBFfBCHHBPPBqIBJDBVBB7CffBZBCZZMGB+NBBNJBFFBFBBDBBEEBPCCDFBMHBGBB6BCCeDBKCBxK-BBhI-PBxBUBDFB9+zB4Z4ZBEBCjFjFRCBeCCeCCkEHHBCBitDBBhrwBwoBwoBBzCBCmCBCBBDDDBDDBCBCLBCCCBFBCgCBCDBDHBCGBCbBCDBCEBCEEBFBCzKBDjJBDxBBhwFDBCaBCBBCDDCJBCDBCCCHFFCECBBBCBBCDDCICBCCDDBCGBCDBCDBCCCBIBCQBGCBCEBCQB1BBB-uCIB",!1)),Quotation_Mark:()=>new T(I("iBFFkEQQ96HHBaBBowDqOqOBCBOCBixzBDB+FFF7CBB",!1)),Terminal_Punctuation:()=>new T(I("hBLLCMMBEE-ZJJiQ6B6BpCPPCCB1FsBsBBJBCsHsHB3B3BBEBCHBgBmImIB1nB1nBBtFtFFFB4JBB2YHBmY9D9DBBBoCBB+ECBEoBoBBCBDBB7JBBjLDBjFBBLBBCCBeCB8FEB-BBBldYYBKKBBBwlDCBzJOOFLLCBBEBBtNBB8ndBBuICBkHEB-LBB3CBBgD4E4EBBB0ECBgERRB6H6HnxUDDB6B6BBBBCDBqFLLCMMBEEiCDD7hBxBxBnkBoGoG3JBB5EFBlCFB6CDB5dEBtBDB+FGBxDDBgECBiEBBHRRB5C5CBDBtDrJrJB2D2DBBBNBBnLDBEOBqDBB6HCBmQCC8HBB4CBBFBB-MCBuBmUmUBrCrCBspBspBBDB6vRBBmEiCiCBBBLqRqRBoJoJBnwTnwTovHDB",!1)),Uppercase:()=>new T(I("hCZBmDWBCGBiB2BCDOCDuBCBECEBBCCCBCCBBBDDBCBBCCBEBBCBBCECBCCDCCBCCBBBCCCBEEIJDCMCDQCDDDCCBC4BCIBBCBBDCCBCBCGCiJCCEJJHCCBBBCCCBCCBPBCIBkBDDBBBEWCGDDCBBDyBBxBgBCK2BCBMCD+CCDlBBq6ClBBCGGzW1CB0kCHHBpBBDCBhK0ECKgDCKHBJFBLHBJHBJFBMGCJHBpCDBNDBNDBNEBMDBnIFFECBDCBDEEBDBHGCBCBDDBLBBGbbBOBUzZzZBYBx5BvBBxBCCBBBDGCBCBCDDJCBCgDCJCCFuqeuqeCqBCUaCoEMCE8BCLECBICFCCDCCEUCBDBCEBCOCBCBCCCBQCZs5Vs5VBYBmmBnBBpEjBB9EKBCOBCGBCBBr3ByBB+EVB75CfBhsVfBhCYBoqZZBbZBbZBbCCBGDBDDBCBCHBbZBbBBCDBDHBCGBcBBCDBCEBCEEBFBcZBbZBbZBbZBbZBbZBfYBiBYBiBYBiBYBiBYBiB2pE2pEBgBBvgCZBHZBHZB",!1)),White_Space:()=>new T(I("JEBTlDlDbgvFgvFgsCKBeBBGwBwBh9DAB",!1))});static get Upper(){return this.CATEGORIES.get("Lu")}static SCRIPTS=new zc({Adlam:()=>new T(I("go6DrCFJFB",!0)),Ahom:()=>new T(I("g4lCaDOFW",!0)),Anatolian_Hieroglyphs:()=>new T(I("ggxCmS",!0)),Arabic:()=>new T(I("gwBEBCFBCNBCCBCfBCJBMZBCrDBChBBxCvBBxHhBBGqCBCcBxy8BtPBDvEBhBPBxDEBCmEBk7DeBkCFBJIBiBFBh43BDBCaBCBBCDDCJBCDBCCCHFFCECBBBCBBCDDCICBCCDDBCGBCDBCDBCCCBIBCQBGCBCEBCQB1BBB",!1)),Armenian:()=>new T(I("xpBlBDxBDCks9BE",!0)),Avestan:()=>new T(I("g4iC1BEG",!0)),Balinese:()=>new T(I("g4GsCCxB",!0)),Bamum:()=>new T(I("g1pB3CpowB4R",!0)),Bassa_Vah:()=>new T(I("w26CdDF",!0)),Batak:()=>new T(I("g+GzBJD",!0)),Bengali:()=>new T(I("gsCDBCHBDBBDVBCGBCEEBCBDIBDBBDDBJFFBCCBDBDYB",!1)),Beria_Erfe:()=>new T(I("g17CYDY",!0)),Bhaiksuki:()=>new T(I("ggnCICsBCNLc",!0)),Bopomofo:()=>new T(I("qXB6wLqBxDf",!0)),Brahmi:()=>new T(I("ggkCtCFjBKA",!0)),Braille:()=>new T(I("ggK-H",!0)),Buginese:()=>new T(I("gwGbDB",!0)),Buhid:()=>new T(I("g6FT",!0)),Canadian_Aboriginal:()=>new T(I("ggF-TxRlC7tgCP",!0)),Carian:()=>new T(I("g1gCwB",!0)),Caucasian_Albanian:()=>new T(I("wphCzBMA",!0)),Chakma:()=>new T(I("gokC0BCR",!0)),Cham:()=>new T(I("gwqB2BKNDJDD",!0)),Cherokee:()=>new T(I("g9E1CDFz7lBvC",!0)),Chorasmian:()=>new T(I("w9jCb",!0)),Common:()=>new T(I("AgCBbFBbuBBCOBCEBYgBgBiOmBBGEBDTB1DKKHCC+THHPEEhB9E9ElQiEiEB6mB6mB2MDBjJwvBwvBBBBoCBBsGBBCumBumBOIIBCBCFBCCBDmYmYBKBD2CBCKBEKBCOBShBB-BlBBCCBDFBCaBCQBqBCBF5UBXKBW-cBhIzTBDpEBhQ9CBzMUBCCCBXBQHBFDB8CBBE7C7CB0E0EBOBhBlBBKxBxBB+BBgBwCBwB5C5CBmFBhuG-BBhoWhBBnDCBmFJB1HhFhFsMPPBzuUzuUBxGxGBIBXiBBCSBCDB0ECCBeBbFBbKBLuBuBBhChCBFBCGBLEBjICBFsBBEIBxCMB0BsBBlHaBltuBDB96D8HBEzNBHWBQQBgDzDB9B1HBLmBBD9BBEQBJBBIdBF8BB2GTBNTBN2CBKYBoE0CBCmCBCBBDDDBDDBCBCLBCCCBFBCgCBCDBDHBCGBCbBCDBCEBCEEBFBCzKBDjJBDxBByjFjCBtC8BBjWrBBFjDBNOBDOBCOBCkBBLtFB5BZBCBBOrBBFIBIBBPFB7E4eBEQBEMBE5GBHLBFQQBKBF3BBJJBHnBBJdBDLBFBBPIBoB3KBJNBDMBEKBE4BBCFFBOBDLBFJBIyEBCmDBnghYffB+CB",!1)),Coptic:()=>new T(I("ifNxkKzDGG",!0)),Cuneiform:()=>new T(I("ggoC5cnDuDCEMjG",!0)),Cypriot:()=>new T(I("ggiCFBDCCBqBBCBBEDD",!1)),Cypro_Minoan:()=>new T(I("w8rCiD",!0)),Cyrillic:()=>new T(I("ggBkEBDoFBx6FKBhFtCtCojEfBhie-CBv8VBBhw4B9BBiBAB",!1)),Deseret:()=>new T(I("gghCvC",!0)),Devanagari:()=>new T(I("goCwCFODZh7nBfhwcJ",!0)),Dives_Akuru:()=>new T(I("gomCGBDDDBGBCBBCdBCBBDLBKJB",!1)),Dogra:()=>new T(I("ggmC7B",!0)),Duployan:()=>new T(I("ggvDqDGMEIIJDD",!0)),Egyptian_Hieroglyphs:()=>new T(I("ggsC1iBL68D",!0)),Elbasan:()=>new T(I("gohCnB",!0)),Elymaic:()=>new T(I("g-jCW",!0)),Ethiopic:()=>new T(I("gwEoCBCDBDGBCCCBCBDoBBCDBDgBBCDBDGBCCCBCBDOBC4BBCDBDiCBDfBEZBnvGWBKGBCGBCGBCGBCGBCGBCGBCGBjpfFBDFBDFBKGBCGBylvCGBCDBCBBCOB",!1)),Garay:()=>new T(I("gqjClBEcJB",!0)),Georgian:()=>new T(I("glElBBCGGDqBBCDBx8CqBBDCBhiElBBCGG",!1)),Glagolitic:()=>new T(I("ggL-Ch9sDGCQDGCBCE",!0)),Gothic:()=>new T(I("w5gCa",!0)),Grantha:()=>new T(I("g4kCDBCHBDBBDVBCGBCBBCEBDIBDBBDCBDHHGGBDGBEEB",!1)),Greek:()=>new T(I("wbDBCCBDDBCFFCCCBBBCCCBSBC+BBPPBnpGEBzBEBFEB1ChKhKBUBDFBDlBBDFBDHBCGCBdBD0BBCOBCNBDFBCSBDCBCIBoJ-xiB-xiB7uVuCBSgj0Bgj0BBkCB",!1)),Gujarati:()=>new T(I("h0CCBCIBCCBCVBCGBCBBCEBDJBCCBCCBDQQBCBDLBIGB",!1)),Gunjala_Gondi:()=>new T(I("grnCFCBCkBCBCFIJ",!0)),Gurmukhi:()=>new T(I("hwCCBCFBFBBDVBCGBCBBCBBCBBDCCBDBFBBDCBEIIBCBCIIBPB",!1)),Gurung_Khema:()=>new T(I("go4C5B",!0)),Han:()=>new T(I("g0LZBC4CBN1GBwBCCaIBPDBle-tGBhC-vUBhoWtLBDpDBpodBBNGBqgkB-2pBBhB9oEBDt0FBDwpHBQtTBjtC9QBjvBq6EBGppIB",!1)),Hangul:()=>new T(I("goE-HvxHBiI9CyDeiCei3dckUj9KNWFwBl9JeEFDFDFDC",!0)),Hanifi_Rohingya:()=>new T(I("gojCnBJJ",!0)),Hanunoo:()=>new T(I("g5FU",!0)),Hatran:()=>new T(I("gniCSCBGE",!0)),Hebrew:()=>new T(I("xsB2BBJaBFFBpp9BZBCEBCCCBCCBCCBIB",!1)),Hiragana:()=>new T(I("hiM1CBHCBi7-C+IBTeeBBBulQAB",!1)),Imperial_Aramaic:()=>new T(I("giiCVCI",!0)),Inherited:()=>new T(I("gYvDB2IBBlOKBbhXhXBCB8qEtBBDLBlPCBCMBCGBFHHEBBnG-BBtQBBjGgBB65DDBsDBBmrzBPBRNBwejHjH7iEl+uBl+uBBsBBDWBhRCBSHBDGBfDBz6rYvHB",!1)),Inscriptional_Pahlavi:()=>new T(I("g7iCSGH",!0)),Inscriptional_Parthian:()=>new T(I("g6iCVDH",!0)),Javanese:()=>new T(I("gsqBtCDJFB",!0)),Kaithi:()=>new T(I("gkkCiCLA",!0)),Kannada:()=>new T(I("gkDMCCCWCJCEDICCCDIBGCCDDJCC",!0)),Katakana:()=>new T(I("hlM5CBDCBxHPBxGuBBC3CBvgzBJBCsBBzisBDBCGBCBBCgJgJBBBzBPPBCB",!1)),Kawi:()=>new T(I("g4nCQCoBEc",!0)),Kayah_Li:()=>new T(I("goqBtBCA",!0)),Kharoshthi:()=>new T(I("gwiCDCBGHCCCcDCFJII",!0)),Khitan_Small_Script:()=>new T(I("k-7C84G84GB0OBqBAB",!1)),Khmer:()=>new T(I("g8F9CDJHJnPf",!0)),Khojki:()=>new T(I("gwkCRCuB",!0)),Khudawadi:()=>new T(I("w1kC6BGJ",!0)),Kirat_Rai:()=>new T(I("gq7C5B",!0)),Lao:()=>new T(I("h0DBBCCCBDBCXBCCCBVBDEBCCCBFBCJBDDB",!1)),Latin:()=>new T(I("hCZBHZBwBQQGWBCeBCgOBoBEB8wGlBBHwBBGDBGMBClCBiC-HByLOORMBuEBBHccSoBB42CfBj1elDBExCBVOBxZqBBCIBCDB38TGB7gBZBHZBmhCFBCpBBCIBm61BeBHFB",!1)),Lepcha:()=>new T(I("ggH3BEOEC",!0)),Limbu:()=>new T(I("goGeBCLBFLBFEEBKB",!1)),Linear_A:()=>new T(I("gwhC2JKVLH",!0)),Linear_B:()=>new T(I("gggCLCZCSCBCODNjB6D",!0)),Lisu:()=>new T(I("wmpBvBx1eA",!0)),Lycian:()=>new T(I("g0gCc",!0)),Lydian:()=>new T(I("gpiCZGA",!0)),Mahajani:()=>new T(I("wqkCmB",!0)),Makasar:()=>new T(I("g3nCY",!0)),Malayalam:()=>new T(I("goDMCCCyBCCCFFPDZ",!0)),Mandaic:()=>new T(I("giCbDA",!0)),Manichaean:()=>new T(I("g2iCmBFL",!0)),Marchen:()=>new T(I("wjnCfDVCN",!0)),Masaram_Gondi:()=>new T(I("gonCGBCBBCrBBECCBCCBHBJJB",!1)),Medefaidrin:()=>new T(I("gy7C6C",!0)),Meetei_Mayek:()=>new T(I("g3qBWqGtBDJ",!0)),Mende_Kikakui:()=>new T(I("gg6DkGDP",!0)),Meroitic_Cursive:()=>new T(I("gtiCXFTDtB",!0)),Meroitic_Hieroglyphs:()=>new T(I("gsiCf",!0)),Miao:()=>new T(I("g47CqCF4BIQ",!0)),Modi:()=>new T(I("gwlCkCMJ",!0)),Mongolian:()=>new T(I("ggGBBDCCBSBH4CBIqBB2t-BMB",!1)),Mro:()=>new T(I("gy6CeCJFB",!0)),Multani:()=>new T(I("g0kCGBCCCBCBCOBCKB",!1)),Myanmar:()=>new T(I("ggE-EhqmBeiDfxibT",!0)),Nabataean:()=>new T(I("gkiCeJI",!0)),Nag_Mundari:()=>new T(I("wm5DpB",!0)),Nandinagari:()=>new T(I("gtmCHDtBDK",!0)),New_Tai_Lue:()=>new T(I("gsGrBFZHKEB",!0)),Newa:()=>new T(I("gglC7CCE",!0)),Nko:()=>new T(I("g+B6BDC",!0)),Nushu:()=>new T(I("h-7CvsQvsQBqMB",!1)),Nyiakeng_Puachue_Hmong:()=>new T(I("go4DsBENDJFB",!0)),Ogham:()=>new T(I("g0Fc",!0)),Ol_Chiki:()=>new T(I("wiHvB",!0)),Ol_Onal:()=>new T(I("wu5DqBFA",!0)),Old_Hungarian:()=>new T(I("gkjCyBOyBIF",!0)),Old_Italic:()=>new T(I("g4gCjBKC",!0)),Old_North_Arabian:()=>new T(I("g0iCf",!0)),Old_Permic:()=>new T(I("w6gCqB",!0)),Old_Persian:()=>new T(I("g9gCjBFN",!0)),Old_Sogdian:()=>new T(I("g4jCnB",!0)),Old_South_Arabian:()=>new T(I("gziCf",!0)),Old_Turkic:()=>new T(I("ggjCoC",!0)),Old_Uyghur:()=>new T(I("w7jCZ",!0)),Oriya:()=>new T(I("h4CCCHDBDVCGCBCEDIDBDCICFBCEDR",!0)),Osage:()=>new T(I("wlhCjBFjB",!0)),Osmanya:()=>new T(I("gkhCdDJ",!0)),Pahawh_Hmong:()=>new T(I("g46ClCLJCGCUGS",!0)),Palmyrene:()=>new T(I("gjiCf",!0)),Pau_Cin_Hau:()=>new T(I("g2mC4B",!0)),Phags_Pa:()=>new T(I("giqB3B",!0)),Phoenician:()=>new T(I("goiCbEA",!0)),Psalter_Pahlavi:()=>new T(I("g8iCRIDNG",!0)),Rejang:()=>new T(I("wpqBjBMA",!0)),Runic:()=>new T(I("g1FqCEK",!0)),Samaritan:()=>new T(I("ggCtBDO",!0)),Saurashtra:()=>new T(I("gkqBlCJL",!0)),Sharada:()=>new T(I("gskC-ChsCH",!0)),Shavian:()=>new T(I("wihCvB",!0)),Siddham:()=>new T(I("gslC1BDlB",!0)),Sidetic:()=>new T(I("gqiCZ",!0)),SignWriting:()=>new T(I("gg2DrUQECO",!0)),Sinhala:()=>new T(I("hsDCBCRBEXBCIBCDDBFBEFFBEBCCCBGBHJBDCBt-gCTB",!1)),Sogdian:()=>new T(I("w5jCpB",!0)),Sora_Sompeng:()=>new T(I("wmkCYIJ",!0)),Soyombo:()=>new T(I("wymCyC",!0)),Sundanese:()=>new T(I("g8G-BhIH",!0)),Sunuwar:()=>new T(I("g+mChBPJ",!0)),Syloti_Nagri:()=>new T(I("ggqBsB",!0)),Syriac:()=>new T(I("g4BNC7BDCxIK",!0)),Tagalog:()=>new T(I("g4FVKA",!0)),Tagbanwa:()=>new T(I("g7FMCCCB",!0)),Tai_Le:()=>new T(I("wqGdDE",!0)),Tai_Tham:()=>new T(I("gxG+BCcDKHJHN",!0)),Tai_Viet:()=>new T(I("g0qBiCZE",!0)),Tai_Yo:()=>new T(I("g25DeCVJB",!0)),Takri:()=>new T(I("g0lC5BHJ",!0)),Tamil:()=>new T(I("i8CBBCFBECBCDBEBBCCCBEEBEEBBBELBFEBECBCDBDHHPUBm+kCxBBOAB",!1)),Tangsa:()=>new T(I("wz6CuCCJ",!0)),Tangut:()=>new T(I("g-7CgBgBB+3GBhQeBiDyDB",!1)),Telugu:()=>new T(I("ggDMCCCWCPDICCCDIBCCCBDDDJII",!0)),Thaana:()=>new T(I("g8BxB",!0)),Thai:()=>new T(I("hwD5BGb",!0)),Tibetan:()=>new T(I("g4DnCCjBFmBCjBCOCGFB",!0)),Tifinagh:()=>new T(I("wpL3BIBPA",!0)),Tirhuta:()=>new T(I("gklCnCJJ",!0)),Todhri:()=>new T(I("guhCzB",!0)),Tolong_Siki:()=>new T(I("wtnCrBFJ",!0)),Toto:()=>new T(I("w04De",!0)),Tulu_Tigalari:()=>new T(I("g8kCJBCDDClBBCJBCDDCDBCJBCBBJBB",!1)),Ugaritic:()=>new T(I("g8gCdCA",!0)),Unknown:()=>new T(I("4bBBHDBICCVuMuMnBBBzBBBE4B4BBGBcDBHKBvI9B9BBmDmDBMB8BBByBBBQddBCCMEBjBEBuHJJBDDBXXICCBBBFBBKBBDBBFHBCDBDGGBaaBEEHDBDBBXIIDGDBCCGDBDBBECBCGBFCCBFBSJBEKKEXXIDDGBBLIEBCCBNBFBBNGBIEEJBBDBBXIIDGGBKKBDDBEEBFBEDBDGGBTTBIBDHHBBBEFFBBBDCCDCBDCBECBNDBGCBEFFBCCBEBCNBWEBOEEYRRBKKEFFBFBDEEDBBFBBLGBXEEYLLGBBKEEFGBDEBEFFBLLELBOEE0BEEHDBRBBbEETCBZKKCBBICBCDBHCCJFBLBBELB7BDBekBBDCCGZZCYYBGGCIILBBFfBpClBlBBCBoBlBlBQOOBjBBnGCCBDBCBB6LFFBIICFFBqBqBFBBiBFFBIICFFBQQ6BFFBkCkCBhBhBBBBbFB3CBBHBB+UCB6CGBXIBZIBVLBOEEDLB-CBBLFBLFBbFB6CGBsBEBnCJBgBNNBCBNDBCCBrBBBGKBtBDBbFBMCB-BBBiCeeBMMBEBLFBPBBvBBBNTBuCnFnFBGB9BCBQCB-BEBsBBBMHBsBEB3QBBHBBnBBBHBBJGCgBBB2BQQPBBHUUBEEKmDmDNBBcOOBBBjBNBiBOBtEDB7UVBMUB14BBB-LEBuBCCBDBCBB5BGBDNBZIBI4BI-DhBBb6C6CBKB3GZBxC3C3CBoDoDBDBsB-C-C3CIBxBuzcuzcBBB4BIB9KTB5FHB+GTB9BCBLFB5BHBnCHBNFB1DKBfCBvCMMBCBiB4B4BBHBPBBLBBoDXBdJBHBBHBBHIBIII9BDB-DBBLFBl9KLBYDByBjoIBvLBBrDlBBILBGEBbGGCGDrUfBrBFB0BUUFDBGoEoEBCC-FCBHBBHBBHBBECBIIIBIBGBBNbbUDDQBBPhBB8DEBEDBuBCB5COOBBBCuBBvBhEBeCByBOBdDBlBIBfEBsBEBfmBmBBCBPpBB-EBBLFBlBDBlBDBpBHB1BKBNQQIDDMQQIDDBBB1BLB4JIBXJBJXBHrBrBKkCBHBBCtBtBDCBCBBYpCpCBGBKvBBUDDBDBiBCBcEBclBB5BDBVBBzBDDBDBJEEeBBEDBLGBKGBhCfBoBDBNIB3BCBeBBcEBbGBFLBIvCBqC2BB0BMB0BGBvBHBLFBnBCBeHBDvGBgBrBrBEBBDPBHHBKgBBvBHBrBVBblBBdTBYIBvCDBlBIBlCJBCBBaGBLFB2BTTBGBoBIBhDVVBJBTwBwBB8BBICCFQQMFB8BEBLFBFJJBDDBXXIDDGLLBDDBEEBCCBEBCEBIBBICBGKBLCCBCCnBLLCBBCFFLDDBGBDcB9CGGBcBpCHBLlFB3BBBnBhBBmCKBLFBOSB7BFBLFBVbBcBBQDBY4FB9BjDB0CLBJBBCBBJDDfDDBNNBHBLlCBJBBvBBBMaBpCHB0CMBqCGBL1CBJ3CBjBNBLFBKuBuBPJBeCBhBBBXPPBnCBIDDtBCBCDDKHBLFBHDDmBDDHGBLFBtBDBL1HBaGBSqBqBBBBe0CBCOBzBMB8clDBwDGGBJBlGryCBkDMB3iBJB88DEBoS41GB7Bl2BB6RGBgBLLBCByCLLBEBfBBHJBnCJBLIIWEBUvNB7BlGB8CEBaBBarBBsCDB6BGBS-BBGKBIIB3mHoBBhBgDB0D8vIBFIIDkJkJBNBCcBEBBCNBFHBtMjoCBsDEBOCBKGBLBBJ76DB+HCB1NFBYOBSOBvBBBYIB1D7BB3HJBoBBBjGUBnC5DBVLBVLB4CIBamEB2CoCoCDBBCBBDBBFNNCIIiCFFBJJIddFGGCCBI1K1KBlJlJB-V-VBNBGQQBuiBBgBFBH0GBISSBIIDGGBDB-BgBBCvDBuBCBPBBLDBD-JBgBQB7BEBCvOBrB1GBsBDBC-FBgBXXBGBD-GBIFFDQQmGBBRoBBtCDBLDBDwYBlCrCB+BhGBFccDCCBCCLFFCCCBEBCDBCECEDDCBBCICDCCBFFIKFCLLSEBEGGSzBBDtIBtBDBlDLBQBBQQQmBJBvF3BBeMBtBDBKGBDNBH5EB6eCBSCBOCB7GFBNDBCOBNDB5BHBLFBpBHBfBBNDBDNBKmBB5KHBPBBOCBMCB6BCCBCBRBBNDBLGB0EoDoDBjgBBh3pBfB-oEBBv0FBBypHOBvThtCB-QhvBBs6EEBrpIm8yVBCdBhD-DBxHvw-FB",!1)),Vai:()=>new T(I("gopBrJ",!0)),Vithkuqi:()=>new T(I("wrhCKCOCGCBCKCOCGCB",!0)),Wancho:()=>new T(I("g24D5BGA",!0)),Warang_Citi:()=>new T(I("glmCyCNA",!0)),Yezidi:()=>new T(I("g0jCpBCCDB",!0)),Yi:()=>new T(I("ggoBskBE2B",!0)),Zanabazar_Square:()=>new T(I("gwmCnC",!0))});static FOLD_CATEGORIES=new zc({L:()=>new T(I("laA",!0)),LC:()=>new T(I("laA",!0)),Ll:()=>new T(I("hCZBmDWBCGBiBuBCEECDOCDuBCBECEBBCCCBCCBBBDDBCBBCCBEBBCBBCECBCCDCCBCCBBBCCCBEEIBBCBBCBBCOCDQCDBBCCCBBBC4BCIBBCBBDCCBCBCGC3HrBrBCEEJHHCCBCCCBCCBPBCIBkBJJCUCGDDCBBDyBBxBgBCK2BCBMCD+CCDlBBq6ClBBCGGzW1CB0kCHHBpBBDCBhK0ECKgDCKHBJFBLHBJHBJFBMGCJHBZHBJHBJHBJEBMEBMDBNEBMEBqJEEBHHxC9zC9zCBuBBxBCCBBBDGCBCBCDDJCBCgDCJCCFuqeuqeCqBCUaCoEMCE8BCLECBICFCCDCCEUCBDBCEBCOCBCBCCCBQCZs5Vs5VBYBmmBnBBpEjBB9EKBCOBCGBCBBr3ByBB+EVB75CfBhsVfBhCYBoyehBB",!1)),Lt:()=>new T(I("kOCCBCCBCClBCCtsHHBJHBJHBMQQwBAB",!1)),Lu:()=>new T(I("hDZB7BqBqBBWBCHBCuBCEECDOCDsBCDECBBBDCCDEEGDDECBDDDCCCDFFDEECDDECCGBBCBBCBBCOCBSCDBBCEECkBCEQCJDDBCCFICBEBCBBCCCBEEBCCBCBCEBDCCBDDIDDCBBEFBGLLBnFnFsBCCEEEBBBvBDBCdBCBBECBCWCBDBCGD1BvBBCgBCK0BCDMCBgDCyBlBBq6CqBBDCB5XFBjkCIBCvHvHERRzD0ECGGGC8CCBHBJFBLHBJHBJFBMGCJHBJNBzBBBNSSBPPBEEpL2B2Bs1CvBBCEEBGCHDDLiDCJCCFNNBkBBCGG0oesBCUaCoEMCE8BCLCCDICFFFCBBDSCMOCFCCDOCb9a9advCBi8UZBumBnBBpEjBB8EKBCOBCGBCBBk4ByBB+DVB75CfBhsVfB8BYBvyehBB",!1)),M:()=>new T(I("5cgBgBlgHAB",!1)),Mn:()=>new T(I("5cgBgBlgHAB",!1)),Emoji:()=>new T(I("8mJA",!0)),Extended_Pictographic:()=>new T(I("8mJA",!0)),Lowercase:()=>new T(I("hCZBmDWBCGBiBuBCEECDOCDuBCBECEBBCCCBCCBBBDDBCBBCCBEBBCBBCECBCCDCCBCCBBBCCCBEEIBBCBBCBBCOCDQCDBBCCCBBBC4BCIBBCBBDCCBCBCGCiJCCEJJHCCBBBCCCBCCBPBCIBkBJJCUCGDDCBBDyBBxBgBCK2BCBMCD+CCDlBBq6ClBBCGGzW1CB0kCHHBpBBDCBhK0ECKgDCKHBJFBLHBJHBJFBMGCJHBZHBJHBJHBJEBMEBMDBNEBMEBqJEEBHHuBPBUzZzZBYBx5BvBBxBCCBBBDGCBCBCDDJCBCgDCJCCFuqeuqeCqBCUaCoEMCE8BCLECBICFCCDCCEUCBDBCEBCOCBCBCCCBQCZs5Vs5VBYBmmBnBBpEjBB9EKBCOBCGBCBBr3ByBB+EVB75CfBhsVfBhCYBoyehBB",!1)),Math:()=>new T(I("ycGDCHHFMMDDDCHHFAB",!1)),Uppercase:()=>new T(I("hDZB7BqBqBBWBCHBCuBCEECDOCDsBCDECBBBDCCDEEGDDECBDDDCCCDFFDEECDDECCGBBCBBCBBCOCBSCDBBCEECkBCEQCJDDBCCFICBEBCBBCCCBEEBCCBCBCEBDCCBDDIDDCBBEFBGLLBnFnFsBCCEEEBBBvBDBCdBCBBECBCWCBDBCGD1BvBBCgBCK0BCDMCBgDCyBlBBq6CqBBDCB5XFBjkCIBCvHvHERRzD0ECGGGC8CCBHBJFBLHBJHBJFBMGCJHBJNBzBBBNSSBPPBEEpLiBiBBOBFsasaBYBn6BvBBCEEBGCHDDLiDCJCCFNNBkBBCGG0oesBCUaCoEMCE8BCLCCDICFFFCBBDSCMOCFCCDOCb9a9advCBi8UZBumBnBBpEjBB8EKBCOBCGBCBBk4ByBB+DVB75CfBhsVfB8BYBvyehBB",!1))});static FOLD_SCRIPT=new zc({Common:()=>new T(I("8cgBgB",!1)),Greek:()=>new T(I("1FwUwU",!1)),Inherited:()=>new T(I("5cgBgBlgHAB",!1))})},ce=class Jt{static MAX_RUNE=1114111;static RUNE_ERROR=65533;static isUnsearchable(t){return t===Jt.RUNE_ERROR||t>=Jt.MIN_HIGH_SURROGATE&&t<=Jt.MAX_LOW_SURROGATE}static MAX_ASCII=127;static MAX_LATIN1=255;static MAX_BMP=65535;static MIN_FOLD=65;static MAX_FOLD=125251;static MIN_HIGH_SURROGATE=55296;static MAX_HIGH_SURROGATE=56319;static MIN_LOW_SURROGATE=56320;static MAX_LOW_SURROGATE=57343;static MIN_SUPPLEMENTARY_CODE_POINT=65536;static is32(t,n){let r=0,s=t.length;for(;r<s;){const i=r+Math.floor((s-r)/2),o=t.getLo(i),a=t.getHi(i);if(o<=n&&n<=a){const l=t.getStride(i);return(n-o)%l===0}n<o?s=i:r=i+1}return!1}static is(t,n){if(n<=Jt.MAX_LATIN1){for(let r=0;r<t.length;r++){if(n>t.getHi(r))continue;const s=t.getLo(r);if(n<s)return!1;const i=t.getStride(r);return(n-s)%i===0}return!1}return t.length>0&&n>=t.getLo(0)&&Jt.is32(t,n)}static isUpper(t){if(t<=Jt.MAX_LATIN1){const n=String.fromCodePoint(t);return n.toUpperCase()===n&&n.toLowerCase()!==n}return Jt.is(an.Upper,t)}static isPrint(t){return t<=Jt.MAX_LATIN1?t>=32&&t<Jt.MAX_ASCII||t>=161&&t!==173:Jt.is(an.Print,t)}static simpleFold(t){if(an.CASE_ORBIT.has(t))return an.CASE_ORBIT.get(t);const n=V.toLowerCase(t);return n!==t?n:V.toUpperCase(t)}static equalsIgnoreCase(t,n){if(t===n)return!0;if(t<0||n<0)return!1;if(t<=Jt.MAX_ASCII&&n<=Jt.MAX_ASCII)return 65<=t&&t<=90&&(t|=32),65<=n&&n<=90&&(n|=32),t===n;for(let r=Jt.simpleFold(t);r!==t;r=Jt.simpleFold(r))if(r===n)return!0;return!1}},PC=256,vA=new Uint8Array(PC);for(let e=0;e<PC;e++)vA[e]=97<=e&&e<=122||65<=e&&e<=90||48<=e&&e<=57||e===95?1:0;var zf=null,$f=null,me=class yn{static METACHARACTERS="\\.+*?()|[]{}^$";static EMPTY_BEGIN_LINE=1;static EMPTY_END_LINE=2;static EMPTY_BEGIN_TEXT=4;static EMPTY_END_TEXT=8;static EMPTY_WORD_BOUNDARY=16;static EMPTY_NO_WORD_BOUNDARY=32;static EMPTY_ALL=-1;static emptyInts(){return[]}static isByteArray(t){return Array.isArray(t)||Object.prototype.toString.call(t)==="[object Uint8Array]"}static isalnum(t){return V.CODES.get("0")<=t&&t<=V.CODES.get("9")||V.CODES.get("a")<=t&&t<=V.CODES.get("z")||V.CODES.get("A")<=t&&t<=V.CODES.get("Z")}static unhex(t){return V.CODES.get("0")<=t&&t<=V.CODES.get("9")?t-V.CODES.get("0"):V.CODES.get("a")<=t&&t<=V.CODES.get("f")?t-V.CODES.get("a")+10:V.CODES.get("A")<=t&&t<=V.CODES.get("F")?t-V.CODES.get("A")+10:-1}static escapeRune(t){let n="";if(ce.isPrint(t))yn.METACHARACTERS.indexOf(String.fromCodePoint(t))>=0&&(n+="\\"),n+=String.fromCodePoint(t);else switch(t){case V.CODES.get('"'):n+='\\"';break;case V.CODES.get("\\"):n+="\\\\";break;case V.CODES.get(" "):n+="\\t";break;case V.CODES.get(`
45
+ `):n+="\\n";break;case V.CODES.get("\r"):n+="\\r";break;case V.CODES.get("\b"):n+="\\b";break;case V.CODES.get("\f"):n+="\\f";break;default:{let r=t.toString(16);t<256?(n+="\\x",r.length===1&&(n+="0"),n+=r):n+=`\\x{${r}}`;break}}return n}static stringToRunes(t){const n=String(t),r=[];let s=0;for(;s<n.length;){const i=n.codePointAt(s);r.push(i),s+=i>ce.MAX_BMP?2:1}return new Int32Array(r)}static runeToString(t){return String.fromCodePoint(t)}static isWordRune(t){return t<PC?vA[t]===1:!1}static emptyOpContext(t,n){let r=0;return t<0&&(r|=yn.EMPTY_BEGIN_TEXT|yn.EMPTY_BEGIN_LINE),t===10&&(r|=yn.EMPTY_BEGIN_LINE),n<0&&(r|=yn.EMPTY_END_TEXT|yn.EMPTY_END_LINE),n===10&&(r|=yn.EMPTY_END_LINE),yn.isWordRune(t)!==yn.isWordRune(n)?r|=yn.EMPTY_WORD_BOUNDARY:r|=yn.EMPTY_NO_WORD_BOUNDARY,r}static quoteMeta(t){return t.split("").map(n=>yn.METACHARACTERS.indexOf(n)>=0?`\\${n}`:n).join("")}static charCount(t){return t>ce.MAX_BMP?2:1}static toArray(t){const n=t.length,r=new Array(n);for(let s=0;s<n;s++)r[s]=t[s];return r}static stringToUtf8ByteArray(t){if(globalThis.TextEncoder)return zf||(zf=new TextEncoder),zf.encode(t);{let n=[],r=0;for(let s=0;s<t.length;s++){let i=t.charCodeAt(s);i<128?n[r++]=i:i<2048?(n[r++]=i>>6|192,n[r++]=i&63|128):(i&64512)===ce.MIN_HIGH_SURROGATE&&s+1<t.length&&(t.charCodeAt(s+1)&64512)===ce.MIN_LOW_SURROGATE?(i=ce.MIN_SUPPLEMENTARY_CODE_POINT+((i&1023)<<10)+(t.charCodeAt(++s)&1023),n[r++]=i>>18|240,n[r++]=i>>12&63|128,n[r++]=i>>6&63|128,n[r++]=i&63|128):(n[r++]=i>>12|224,n[r++]=i>>6&63|128,n[r++]=i&63|128)}return n}}static utf8ByteArrayToString(t){if(globalThis.TextDecoder){$f||($f=new TextDecoder("utf-8"));const n=t instanceof Uint8Array?t:new Uint8Array(t);return $f.decode(n)}else{let n=[],r=0,s=0;for(;r<t.length;){let i=t[r++];if(i<128)n[s++]=String.fromCharCode(i);else if(i>191&&i<224){let o=t[r++];n[s++]=String.fromCharCode((i&31)<<6|o&63)}else if(i>239&&i<365){let o=t[r++],a=t[r++],l=t[r++],c=((i&7)<<18|(o&63)<<12|(a&63)<<6|l&63)-ce.MIN_SUPPLEMENTARY_CODE_POINT;n[s++]=String.fromCharCode(ce.MIN_HIGH_SURROGATE+(c>>10)),n[s++]=String.fromCharCode(ce.MIN_LOW_SURROGATE+(c&1023))}else{let o=t[r++],a=t[r++];n[s++]=String.fromCharCode((i&15)<<12|(o&63)<<6|a&63)}}return n.join("")}}},yA=(e=[],t=0)=>{const n=Object.create(null);for(let r=0;r<e.length;r++){const s=e[r],i=t+r;n[s]=i,n[i]=s}return Object.freeze(n)},Pi=class Fp{static Encoding=yA(["UTF_16","UTF_8"]);getEncoding(){throw Error("not implemented")}asCharSequence(){throw Error("not implemented")}asBytes(){throw Error("not implemented")}length(){throw Error("not implemented")}isUTF8Encoding(){return this.getEncoding()===Fp.Encoding.UTF_8}isUTF16Encoding(){return this.getEncoding()===Fp.Encoding.UTF_16}},ab=class extends Pi{constructor(e=null){super(),this.bytes=e}getEncoding(){return Pi.Encoding.UTF_8}asCharSequence(){return me.utf8ByteArrayToString(this.bytes)}asBytes(){return this.bytes}length(){return this.bytes.length}},b4=class extends Pi{constructor(e=null){super(),this.charSequence=e}getEncoding(){return Pi.Encoding.UTF_16}asCharSequence(){return this.charSequence}asBytes(){return me.stringToUtf8ByteArray(this.charSequence.toString())}length(){return this.charSequence.length}},vi=class{static utf16(e){return new b4(e)}static utf8(e){return me.isByteArray(e)?new ab(e):new ab(me.stringToUtf8ByteArray(e))}},nn=class{static EOF(){return-8}constructor(){this.end=0}canCheckPrefix(){return!0}endPos(){return this.end}hasString(){return!1}hasAnyString(){return!1}prefixLength(){return 0}},S4=class so extends nn{static RUNE_ERROR_STEP=ce.RUNE_ERROR<<3|1;constructor(t,n=0,r=t.length){super(),this.bytes=t,this.start=n,this.end=r}hasString(t,n){const r=t.bytes;if(r.length===0)return!0;const s=this.indexOf(this.bytes,r,this.start+n);return s!==-1&&s<=this.end-r.length}hasAnyString(t,n){return t.automaton8().searchUTF8(this.bytes,this.start+n,this.end)}step(t){if(t+=this.start,t>=this.end)return nn.EOF();const n=this.bytes[t]&255;if(n<128)return n<<3|1;let r,s,i=128,o=191;if(n>=194&&n<=223)r=2,s=n&31;else if(n>=224&&n<=239)r=3,s=n&15,n===224?i=160:n===237&&(o=159);else if(n>=240&&n<=244)r=4,s=n&7,n===240?i=144:n===244&&(o=143);else return so.RUNE_ERROR_STEP;if(t+r>this.end)return so.RUNE_ERROR_STEP;const a=this.bytes[t+1]&255;if(a<i||a>o)return so.RUNE_ERROR_STEP;if(s=s<<6|a&63,r>2){const l=this.bytes[t+2]&255;if((l&192)!==128)return so.RUNE_ERROR_STEP;if(s=s<<6|l&63,r>3){const c=this.bytes[t+3]&255;if((c&192)!==128)return so.RUNE_ERROR_STEP;s=s<<6|c&63}}return s<<3|r}index(t,n){n+=this.start;const r=this.indexOf(this.bytes,t.prefixUTF8,n);return r<0?r:r-n}context(t){t+=this.start;let n=-1;if(t>this.start&&t<=this.end){let s=t-1;if(n=this.bytes[s--],n>=128){let i=t-4;for(i<this.start&&(i=this.start);s>=i&&(this.bytes[s]&192)===128;)s--;s<this.start&&(s=this.start),n=this.step(s-this.start)>>3}}const r=t<this.end?this.step(t-this.start)>>3:-1;return me.emptyOpContext(n,r)}indexOf(t,n,r=0){let s=n.length;if(s===0)return r<=this.end?r:-1;const i=n[0];let o=this.end-s;const a=typeof t.indexOf=="function";let l=r;for(;l<=o;){if(a){if(l=t.indexOf(i,l),l===-1||l>o)return-1}else{for(;l<=o&&t[l]!==i;)l++;if(l>o)return-1}let c=!0;for(let u=1;u<s;u++)if(t[l+u]!==n[u]){c=!1;break}if(c)return l;l++}return-1}prefixLength(t){return t.prefixUTF8.length}},E4=class extends nn{constructor(e,t=0,n=e.length){super(),this.charSequence=e,this.start=t,this.end=n}hasString(e,t){const n=this.charSequence.indexOf(e.str,this.start+t);return n!==-1&&n<=this.end-e.str.length}hasAnyString(e,t){return e.automaton16().searchUTF16(this.charSequence,this.start+t,this.end)}step(e){if(e+=this.start,e>=this.end)return nn.EOF();const t=this.charSequence.charCodeAt(e);if(t<ce.MIN_HIGH_SURROGATE||t>ce.MAX_HIGH_SURROGATE||e+1>=this.end)return t<<3|1;const n=this.charSequence.charCodeAt(e+1);return n>=ce.MIN_LOW_SURROGATE&&n<=ce.MAX_LOW_SURROGATE?(t-ce.MIN_HIGH_SURROGATE)*1024+(n-ce.MIN_LOW_SURROGATE)+ce.MIN_SUPPLEMENTARY_CODE_POINT<<3|2:t<<3|1}index(e,t){t+=this.start;const n=this.charSequence.indexOf(e.prefix,t);return n<0||n>this.end-e.prefix.length?-1:n-t}context(e){e+=this.start;const t=e>this.start&&e<=this.end?this.charSequence.charCodeAt(e-1):-1,n=e<this.end?this.charSequence.charCodeAt(e):-1;return me.emptyOpContext(t,n)}prefixLength(e){return e.prefix.length}},$e=class{static fromUTF8(e,t=0,n=e.length){return new S4(e,t,n)}static fromUTF16(e,t=0,n=e.length){return new E4(e,t,n)}},uc=class extends Error{constructor(e){super(e),this.name="RE2JSException"}},Ke=class extends uc{constructor(e,t=null){let n=`error parsing regexp: ${e}`;t&&(n+=`: \`${t}\``),super(n),this.name="RE2JSSyntaxException",this.message=n,this.error=e,this.input=t}getDescription(){return this.error}getPattern(){return this.input}},Qa=class extends uc{constructor(e){super(e),this.name="RE2JSCompileException"}},on=class extends uc{constructor(e){super(e),this.name="RE2JSGroupException"}},x4=class extends uc{constructor(e){super(e),this.name="RE2JSFlagsException"}},Ya=class extends uc{constructor(e){super(e),this.name="RE2JSInternalException"}},lb=class bA{static MAX_REPLACER_ARGS=65535;static quoteReplacement(t,n=!1){return n?t.indexOf("\\")<0&&t.indexOf("$")<0?t:t.split("").map(r=>{const s=r.codePointAt(0);return s===V.CODES.get("\\")||s===V.CODES.get("$")?`\\${r}`:r}).join(""):t.indexOf("$")<0?t:t.split("").map(r=>r.codePointAt(0)===V.CODES.get("$")?"$$":r).join("")}constructor(t,n){if(t===null)throw new Error("pattern is null");this.patternInput=t;const r=this.patternInput.re2();this.patternGroupCount=r.numberOfCapturingGroups(),this.groups=[],this.namedGroups=r.namedGroups,this.numberOfInstructions=r.numberOfInstructions(),this.lookbehindState=null,n instanceof Pi?this.resetMatcherInput(n):me.isByteArray(n)?this.resetMatcherInput(vi.utf8(n)):this.resetMatcherInput(vi.utf16(n))}pattern(){return this.patternInput}reset(){return this.matcherInputLength=this.matcherInput.length(),this.appendPos=0,this.hasMatch=!1,this.hasGroups=!1,this.anchorFlag=0,this}resetMatcherInput(t){if(t===null)throw new Error("input is null");return t instanceof Pi||(me.isByteArray(t)?t=vi.utf8(t):t=vi.utf16(t)),this.matcherInput=t,this.lookbehindState!==null?this.lookbehindState.reset():this.lookbehindState=this.patternInput.re2().createLookbehindState(),this.reset(),this}start(t=0){if(typeof t=="string"){const n=this.namedGroups[t];if(!Number.isFinite(n))throw new on(`group '${t}' not found`);t=n}return this.loadGroup(t),this.groups[2*t]}end(t=0){if(typeof t=="string"){const n=this.namedGroups[t];if(!Number.isFinite(n))throw new on(`group '${t}' not found`);t=n}return this.loadGroup(t),this.groups[2*t+1]}programSize(){return this.numberOfInstructions}group(t=0){if(typeof t=="string"){const s=this.namedGroups[t];if(!Number.isFinite(s))throw new on(`group '${t}' not found`);t=s}const n=this.start(t),r=this.end(t);return n<0&&r<0?null:this.substring(n,r)}getNamedGroups(){if(!this.hasMatch)throw new on("perhaps no match attempted");const t=Object.create(null);for(const n of Object.keys(this.namedGroups))t[n]=this.group(n);return t}groupCount(){return this.patternGroupCount}loadGroup(t){if(!Number.isInteger(t)||t<0||t>this.patternGroupCount)throw new on(`Group index out of bounds: ${t}`);if(!this.hasMatch)throw new on("perhaps no match attempted");if(t===0||this.hasGroups)return;const n=this.matcherInputLength,r=this.patternInput.re2().matchMachineInput(this.matcherInput,this.groups[0],n,this.anchorFlag,1+this.patternGroupCount,this.lookbehindState);if(!r[0])throw new on("inconsistency in matching group data");this.groups=r[1],this.hasGroups=!0}matches(){return this.genMatch(0,$.ANCHOR_BOTH)}lookingAt(){return this.genMatch(0,$.ANCHOR_START)}find(t=null){if(t!==null){if(!Number.isInteger(t)||t<0||t>this.matcherInputLength)throw new on(`start index out of bounds: ${t}`);return this.reset(),this.genMatch(t,0)}if(t=0,this.hasMatch&&(t=this.groups[1],this.groups[0]===this.groups[1])){const n=(this.matcherInput.isUTF16Encoding()?$e.fromUTF16(this.matcherInput.asCharSequence(),0,this.matcherInputLength):$e.fromUTF8(this.matcherInput.asBytes(),0,this.matcherInputLength)).step(t);n<0?t++:t+=n&7}return this.genMatch(t,$.UNANCHORED)}genMatch(t,n){const r=this.patternInput.re2().matchMachineInput(this.matcherInput,t,this.matcherInputLength,n,1,this.lookbehindState);return r[0]?(this.groups=r[1],this.hasMatch=!0,this.hasGroups=this.patternGroupCount===0,this.anchorFlag=n,!0):(this.hasMatch=!1,!1)}substring(t,n){return this.matcherInput.isUTF8Encoding()?me.utf8ByteArrayToString(this.matcherInput.asBytes().slice(t,n)):this.matcherInput.asCharSequence().substring(t,n).toString()}inputLength(){return this.matcherInputLength}appendReplacement(t,n=!1){let r="";const s=this.start(),i=this.end();return this.appendPos<s&&(r+=this.substring(this.appendPos,s)),this.appendPos=i,r+=n?this.appendReplacementInternalJava(t):this.appendReplacementInternalJs(t),r}appendReplacementInternalJava(t){let n="",r=0;const s=t.length;let i=0;for(;i<s;){const o=t.codePointAt(i);if(o===V.CODES.get("\\")){if(r<i&&(n+=t.substring(r,i)),i++,i>=s)throw new on("character to be escaped is missing");r=i,i++;continue}if(o===V.CODES.get("$")){if(r<i&&(n+=t.substring(r,i)),i+1>=s)throw new on("Illegal group reference: group index is missing");const a=t.codePointAt(i+1);if(V.CODES.get("0")<=a&&a<=V.CODES.get("9")){let l=a-V.CODES.get("0"),c=i+2;for(;c<s;c++){const d=t.codePointAt(c);if(d<V.CODES.get("0")||d>V.CODES.get("9")||l*10+d-V.CODES.get("0")>this.patternGroupCount)break;l=l*10+d-V.CODES.get("0")}if(l>this.patternGroupCount)throw new on(`n > number of groups: ${l}`);const u=this.group(l);u!==null&&(n+=u),i=c,r=i}else if(a===V.CODES.get("{")){let l=i+2;for(;l<s&&t.codePointAt(l)!==V.CODES.get("}");)l++;if(l>=s)throw new on("named capture group is missing trailing '}'");const c=t.substring(i+2,l),u=this.group(c);u!==null&&(n+=u),i=l+1,r=i}else throw new on("Illegal group reference");continue}i++}return r<s&&(n+=t.substring(r,s)),n}appendReplacementInternalJs(t){let n="",r=0;const s=t.length;for(let i=0;i<s-1;i++)if(t.codePointAt(i)===V.CODES.get("$")){let o=t.codePointAt(i+1);if(V.CODES.get("$")===o){r<i&&(n+=t.substring(r,i)),n+="$",i++,r=i+1;continue}else if(V.CODES.get("&")===o){r<i&&(n+=t.substring(r,i));const a=this.group(0);a!==null?n+=a:n+="$&",i++,r=i+1;continue}else if(V.CODES.get("`")===o){r<i&&(n+=t.substring(r,i)),n+=this.substring(0,this.start(0)),i++,r=i+1;continue}else if(V.CODES.get("'")===o){r<i&&(n+=t.substring(r,i)),n+=this.substring(this.end(0),this.matcherInputLength),i++,r=i+1;continue}else if(V.CODES.get("1")<=o&&o<=V.CODES.get("9")){let a=o-V.CODES.get("0");for(r<i&&(n+=t.substring(r,i)),i+=2;i<s&&(o=t.codePointAt(i),!(o<V.CODES.get("0")||o>V.CODES.get("9")||a*10+o-V.CODES.get("0")>this.patternGroupCount));i++)a=a*10+o-V.CODES.get("0");if(a>this.patternGroupCount){n+=`$${a}`,r=i,i--;continue}const l=this.group(a);l!==null&&(n+=l),r=i,i--;continue}else if(o===V.CODES.get("<")){r<i&&(n+=t.substring(r,i)),i++;let a=i+1;for(;a<t.length&&t.codePointAt(a)!==V.CODES.get(">")&&t.codePointAt(a)!==V.CODES.get(" ");)a++;if(a===t.length||t.codePointAt(a)!==V.CODES.get(">")){n+=t.substring(i-1,a+1),r=a+1,i=a;continue}const l=t.substring(i+1,a);if(Object.prototype.hasOwnProperty.call(this.namedGroups,l)){const c=this.group(l);c!==null&&(n+=c)}else n+=`$<${l}>`;r=a+1,i=a;continue}}return r<s&&(n+=t.substring(r,s)),n}appendTail(){return this.substring(this.appendPos,this.matcherInputLength)}replaceAll(t,n=!1){return this.replace(t,!0,n)}replaceFirst(t,n=!1){return this.replace(t,!1,n)}replace(t,n=!0,r=!1){let s="";this.reset();const i=typeof t=="function",o=Object.keys(this.namedGroups).length>0;let a=null;if(i){if(this.groupCount()>=bA.MAX_REPLACER_ARGS)throw new on("Too many capture groups to safely invoke replacer function");a=this.matcherInput.isUTF8Encoding()?this.matcherInput.asBytes():this.matcherInput.asCharSequence()}for(;this.find()&&(s+=i?this.appendReplacementFunc(t,o,a):this.appendReplacement(t,r),!!n););return s+=this.appendTail(),s}appendReplacementFunc(t,n,r){let s="";const i=this.start(),o=this.end();this.appendPos<i&&(s+=this.substring(this.appendPos,i)),this.appendPos=o;const a=this.buildReplacerArgs(i,n,r);return s+=String(t(...a)),s}buildReplacerArgs(t,n,r){const s=[this.group(0)],i=this.groupCount();for(let o=1;o<=i;o++){const a=this.start(o);a<0?s.push(void 0):s.push(this.substring(a,this.end(o)))}if(s.push(t),s.push(r),n){const o=this.getNamedGroups();for(const a in o)o[a]===null&&(o[a]=void 0);s.push(o)}return s}},H=class It{static ALT=1;static ALT_MATCH=2;static CAPTURE=3;static EMPTY_WIDTH=4;static FAIL=5;static MATCH=6;static NOP=7;static RUNE=8;static RUNE1=9;static RUNE_ANY=10;static RUNE_ANY_NOT_NL=11;static LB_WRITE=12;static LB_CHECK=13;static isRuneOp(t){return It.RUNE<=t&&t<=It.RUNE_ANY_NOT_NL}static escapeRunes(t){let n='"';for(let r of t)n+=me.escapeRune(r);return n+='"',n}constructor(t){this.op=t,this.out=0,this.arg=0,this.runes=new Int32Array(0),this.next=null}matchRune(t){if(this.runes.length===1){const o=this.runes[0];return(this.arg&$.FOLD_CASE)!==0?ce.equalsIgnoreCase(o,t):t===o}const n=this.runes.length;if(n===0)return!1;if(n===2||n===4||n===6||n===8){for(let o=0;o<n;o+=2){if(t<this.runes[o])return!1;if(t<=this.runes[o+1])return!0}return!1}let r=0,s=n>>1;for(;s>1;){const o=s>>1;r+=this.runes[r+o<<1]<=t?o:0,s-=o}r+=this.runes[r<<1]<=t?1:0;const i=r-1;return i>=0&&t<=this.runes[i<<1|1]}matchRunePos(t){if(this.runes.length===1){const o=this.runes[0];return(this.arg&$.FOLD_CASE)!==0?ce.equalsIgnoreCase(o,t)?0:-1:t===o?0:-1}const n=this.runes.length;if(n===0)return-1;if(n===2||n===4||n===6||n===8){for(let o=0;o<n;o+=2){if(t<this.runes[o])return-1;if(t<=this.runes[o+1])return Math.floor(o/2)}return-1}let r=0,s=n>>1;for(;s>1;){const o=s>>1;r+=this.runes[r+o<<1]<=t?o:0,s-=o}r+=this.runes[r<<1]<=t?1:0;const i=r-1;return i>=0&&t<=this.runes[i<<1|1]?i:-1}toString(){switch(this.op){case It.ALT:return`alt -> ${this.out}, ${this.arg}`;case It.ALT_MATCH:return`altmatch -> ${this.out}, ${this.arg}`;case It.CAPTURE:return`cap ${this.arg} -> ${this.out}`;case It.EMPTY_WIDTH:return`empty ${this.arg} -> ${this.out}`;case It.MATCH:return`match${this.arg!==0?` ${this.arg}`:""}`;case It.FAIL:return"fail";case It.NOP:return`nop -> ${this.out}`;case It.LB_WRITE:return`lbwrite ${this.arg} -> ${this.out}`;case It.LB_CHECK:return`lbcheck ${this.arg} -> ${this.out}`;case It.RUNE:return this.runes===null?"rune <null>":["rune ",It.escapeRunes(this.runes),(this.arg&$.FOLD_CASE)!==0?"/i":""," -> ",this.out].join("");case It.RUNE1:return`rune1 ${It.escapeRunes(this.runes)} -> ${this.out}`;case It.RUNE_ANY:return`any -> ${this.out}`;case It.RUNE_ANY_NOT_NL:return`anynotnl -> ${this.out}`;default:throw new Error("unhandled case in Inst.toString")}}},cb=class SA{constructor(t){this.sparse=new Int32Array(t),this.densePcs=new Int32Array(t),this.denseCaps=null,this.size=0,this.ncap=0,this.mainThreads=0}static INITIAL_THREADS=32;init(t){this.ncap=t;const n=Math.min(this.densePcs.length,SA.INITIAL_THREADS)*t;(!this.denseCaps||this.denseCaps.length<n)&&(this.denseCaps=new Int32Array(n))}growCaps(t){const n=this.densePcs.length*this.ncap,r=new Int32Array(Math.min(n,Math.max(t,2*this.denseCaps.length)));r.set(this.denseCaps),this.denseCaps=r}contains(t){const n=this.sparse[t];return n<this.size&&this.densePcs[n]===t}isEmpty(){return this.size===0}add(t){const n=this.size++;return this.sparse[t]=n,this.densePcs[n]=t,n}clear(){this.size=0,this.mainThreads=0}toString(){let t="{";for(let n=0;n<this.size;n++)n!==0&&(t+=", "),t+=this.densePcs[n];return t+="}",t}},w4=class{constructor(e){this.pos=-1,this.pcs=new Int32Array(e.numInst()),this.size=0,this.lbTable=new Int32Array(e.numLb+1)}reset(){this.pos=-1,this.size=0}},EA=class xA{static fromRE2(t){const n=new xA;return n.prog=t.prog,n.re2=t,n.q0=new cb(n.prog.numInst()),n.q1=new cb(n.prog.numInst()),n.addStack=new Int32Array(2*(n.prog.numInst()+1)),n.matched=!1,n.matchcap=new Int32Array(n.prog.numCap<2?2:n.prog.numCap),n.ncap=0,n}constructor(){this.prog=null,this.re2=null,this.q0=null,this.q1=null,this.addStack=null,this.matched=!1,this.matchcap=null,this.ncap=0,this.lbTable=null}init(t){this.ncap=t,t>this.matchcap.length?this.matchcap=new Int32Array(t).fill(-1):this.matchcap.fill(-1),this.q0.init(t),this.q1.init(t),this.prog.numLb>0&&((!this.lbTable||this.lbTable.length<this.prog.numLb+1)&&(this.lbTable=new Int32Array(this.prog.numLb+1)),this.lbTable.fill(-1))}submatches(){return this.ncap===0?me.emptyInts():me.toArray(this.matchcap.subarray(0,this.ncap))}match(t,n,r,s=null){const i=this.re2.cond;if(i===me.EMPTY_ALL||(r===$.ANCHOR_START||r===$.ANCHOR_BOTH)&&n!==0)return!1;this.matched=!1,this.matchcap.fill(-1);const o=this.prog.numLb>0,a=n;let l=n,c=!1;o&&(s!==null&&s.pos>=0&&s.pos<=n?(l=s.pos,c=!0):l=0);let u=o&&s!==null,d=this.q0,h=this.q1,f=t.step(l),B=f>>3,g=f&7,C=-1,v=0;f!==nn.EOF()&&(f=t.step(l+g),C=f>>3,v=f&7);let y;for(l===0?y=me.emptyOpContext(-1,B):y=t.context(l),o&&(c?this.restoreLookbehinds(s,d,y):this.spawnLookbehinds(d,l,y));;){if(d.mainThreads===0){if((i&me.EMPTY_BEGIN_TEXT)!==0&&l!==0||(r===$.ANCHOR_START||r===$.ANCHOR_BOTH)&&l!==0||this.matched)break;if(this.prog.numLb===0&&d.isEmpty()&&this.re2.prefix.length!==0&&C!==this.re2.prefixRune&&t.canCheckPrefix()){const w=t.index(this.re2,l);if(w<0)break;l+=w,f=t.step(l),B=f>>3,g=f&7,f=t.step(l+g),C=f>>3,v=f&7,y=t.context(l)}}l>=a&&(u&&(this.saveLookbehinds(s,d,l),u=!1),!this.matched&&(l===0||r===$.UNANCHORED)&&(this.ncap>0&&(this.matchcap[0]=l),this.add(d,this.prog.start,l,this.matchcap,0,y)));const b=l+g;if(y=t.context(b),this.step(d,h,l,b,B,y,r,l===t.endPos()),g===0||this.ncap===0&&this.matched)break;l+=g,B=C,g=v,B!==-1&&(f=t.step(l+g),C=f>>3,v=f&7);const E=d;d=h,h=E}return d.clear(),h.clear(),this.matched}matchSet(t,n,r){const s=this.re2.cond;if(s===me.EMPTY_ALL)return[];if((r===$.ANCHOR_START||r===$.ANCHOR_BOTH)&&n!==0)return[];let i=this.prog.numLb>0?0:n,o=n,a=this.q0,l=this.q1,c=t.step(i),u=c>>3,d=c&7,h=-1,f=0;c!==nn.EOF()&&(c=t.step(i+d),h=c>>3,f=c&7);let B=i===0?me.emptyOpContext(-1,u):t.context(i);const g=new Set;for(this.prog.numLb>0&&this.spawnLookbehinds(a,i,B);!(a.mainThreads===0&&((s&me.EMPTY_BEGIN_TEXT)!==0&&i!==0||(r===$.ANCHOR_START||r===$.ANCHOR_BOTH)&&i!==0));){(i===0||r===$.UNANCHORED)&&i>=o&&this.add(a,this.prog.start,i,this.matchcap,0,B);const C=i+d;B=t.context(C);for(let y=0;y<a.size;y++){const b=a.densePcs[y],E=this.prog.inst[b],w=y*this.ncap;let A=!1;switch(E.op){case H.MATCH:if(r===$.ANCHOR_BOTH&&i!==t.endPos())break;g.add(E.arg);break;case H.RUNE:A=E.matchRune(u);break;case H.RUNE1:A=u===E.runes[0];break;case H.RUNE_ANY:A=!0;break;case H.RUNE_ANY_NOT_NL:A=u!==10;break;default:continue}A&&this.add(l,E.out,C,a.denseCaps,w,B)}if(a.clear(),d===0)break;i+=d,u=h,d=f,u!==-1&&(c=t.step(i+d),h=c>>3,f=c&7);const v=a;a=l,l=v}return l.clear(),Array.from(g).sort((C,v)=>C-v)}step(t,n,r,s,i,o,a,l){const c=this.re2.longest;for(let u=0;u<t.size;u++){const d=t.densePcs[u],h=u*this.ncap;if(c&&this.matched&&this.ncap>0&&this.matchcap[0]<t.denseCaps[h])continue;const f=this.prog.inst[d];let B=!1;switch(f.op){case H.MATCH:if(a===$.ANCHOR_BOTH&&!l)break;if(this.ncap>0&&(!c||!this.matched||this.matchcap[1]<r)){t.denseCaps[h+1]=r;for(let g=0;g<this.ncap;g++)this.matchcap[g]=t.denseCaps[h+g]}c||(t.size=0),this.matched=!0;break;case H.RUNE:B=f.matchRune(i);break;case H.RUNE1:B=i===f.runes[0];break;case H.RUNE_ANY:B=!0;break;case H.RUNE_ANY_NOT_NL:B=i!==10;break;default:continue}B&&this.add(n,f.out,s,t.denseCaps,h,o)}t.clear()}spawnLookbehinds(t,n,r){for(let s=0;s<this.prog.lbStarts.length;s++)this.add(t,this.prog.lbStarts[s],n,this.matchcap,0,r)}restoreLookbehinds(t,n,r){this.lbTable.set(t.lbTable);for(let s=0;s<t.size;s++)this.add(n,t.pcs[s],t.pos,this.matchcap,0,r)}saveLookbehinds(t,n,r){let s=0;for(let i=0;i<n.size;i++){const o=n.densePcs[i];this.prog.lbInst[o]===1&&H.isRuneOp(this.prog.inst[o].op)&&(t.pcs[s++]=o)}t.size=s,t.pos=r,t.lbTable.set(this.lbTable)}add(t,n,r,s,i,o){const a=this.addStack;let l=0;for(;;){for(;n!==0&&!t.contains(n);){const u=t.add(n),d=this.prog.inst[n];switch(d.op){case H.FAIL:n=0;break;case H.ALT:case H.ALT_MATCH:a[l++]=d.arg,a[l++]=0,n=d.out;break;case H.EMPTY_WIDTH:n=(d.arg&~o)===0?d.out:0;break;case H.NOP:n=d.out;break;case H.CAPTURE:d.arg<this.ncap&&(a[l++]=-d.arg-1,a[l++]=s[i+d.arg],s[i+d.arg]=r),n=d.out;break;case H.LB_WRITE:this.lbTable[Math.abs(d.arg)]=r,n=d.out;break;case H.LB_CHECK:d.arg>0?n=this.lbTable[d.arg]===r?d.out:0:n=this.lbTable[-d.arg]!==r?d.out:0;break;case H.MATCH:case H.RUNE:case H.RUNE1:case H.RUNE_ANY:case H.RUNE_ANY_NOT_NL:if(this.prog.lbInst[n]===0&&t.mainThreads++,this.ncap>0){const h=u*this.ncap;h+this.ncap>t.denseCaps.length&&t.growCaps(h+this.ncap);for(let f=0;f<this.ncap;f++)t.denseCaps[h+f]=s[i+f]}n=0;break;default:throw new Ya("unhandled")}}if(l===0)return;l-=2;const c=a[l];c<0?(s[i-c-1]=a[l+1],n=0):n=c}}},D4=e=>{let t=-2128831035;for(let n=0;n<e.length;n++)t^=e[n],t=Math.imul(t,16777619);return t},T4=(e,t)=>{if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0},A4=class{constructor(e,t,n){this.nfaStates=e,this.isMatch=t,this.matchIDs=n,this.next=null,this.nextAnchored=null}},wA=class Hu{static STATE_OVERHEAD=160;static TABLE_OVERHEAD=16;static PROGRESS_PER_STATE=10;constructor(t,n=8388608){this.prog=t,this.maxMem=n,this.stateCache=new Map,this.stateCount=0,this.startState=null,this.failed=!1;for(let r=0;r<t.numInst();r++){const s=t.getInst(r).op;if(s===H.EMPTY_WIDTH||s===H.LB_WRITE||s===H.LB_CHECK){this.failed=!0;break}}this.computeRuneClasses(),this.stateBudget=n,this.memBudget=n}computeRuneClasses(){const t=new Set,n=s=>{t.add(s),t.add(s+1)};for(let s=0;s<this.prog.numInst();s++){const i=this.prog.getInst(s);switch(i.op){case H.RUNE:case H.RUNE1:if(i.runes.length===1){if(n(i.runes[0]),(i.arg&$.FOLD_CASE)!==0)for(let o=ce.simpleFold(i.runes[0]);o!==i.runes[0];o=ce.simpleFold(o))n(o)}else for(let o=0;o<i.runes.length;o+=2)t.add(i.runes[o]),t.add(i.runes[o+1]+1);break;case H.RUNE_ANY_NOT_NL:n(10)}}t.delete(0),this.classBounds=Int32Array.from(t).sort(),this.numClasses=this.classBounds.length+1;const r=new Int32Array(ce.MAX_LATIN1+1);for(let s=0;s<=ce.MAX_LATIN1;s++)r[s]=this.searchClass(s);this.latin1Class=r}runeClass(t){return t<=ce.MAX_LATIN1?this.latin1Class[t]:this.searchClass(t)}searchClass(t){const n=this.classBounds;let r=0,s=n.length;for(;r<s;){const i=r+s>>1;n[i]<=t?r=i+1:s=i}return r}computeClosure(t){const n=new Set,r=[...t];let s=!1;const i=new Set;for(;r.length>0;){const l=r.pop();if(n.has(l))continue;n.add(l);const c=this.prog.getInst(l);switch(c.op){case H.MATCH:s=!0,i.add(c.arg);break;case H.ALT:case H.ALT_MATCH:r.push(c.out),r.push(c.arg);break;case H.NOP:case H.CAPTURE:r.push(c.out);break;case H.EMPTY_WIDTH:case H.LB_WRITE:case H.LB_CHECK:return null}}const o=Int32Array.from(n).sort(),a=Array.from(i).sort((l,c)=>l-c);return{pcs:o,isMatch:s,matchIDs:a}}getState(t){const n=this.computeClosure(t);if(!n)return null;const r=n.pcs,s=D4(r);let i=this.stateCache.get(s);if(i)for(let l=0;l<i.length;l++){const c=i[l];if(T4(c.nfaStates,r))return c}const o=Hu.STATE_OVERHEAD+4*r.length+8*n.matchIDs.length;if(this.memBudget<o)return null;this.memBudget-=o,i||(i=[],this.stateCache.set(s,i));const a=new A4(r,n.isMatch,n.matchIDs);return i.push(a),this.stateCount++,a}allocTable(t,n){const r=Hu.TABLE_OVERHEAD+8*this.numClasses;if(this.memBudget<r)return null;this.memBudget-=r;const s=new Array(this.numClasses).fill(null);return n===$.UNANCHORED?t.next=s:t.nextAnchored=s,s}clearCache(){this.stateCache.clear(),this.stateCount=0,this.startState=null,this.memBudget=this.stateBudget}resetCache(t){return this.clearCache(),this.getState(t.nfaStates)}step(t,n,r,s){let i=s===$.UNANCHORED?t.next:t.nextAnchored;if(i!==null){const l=i[n];if(l!==null)return l}else if(i=this.allocTable(t,s),i===null)return null;const o=[];for(let l=0;l<t.nfaStates.length;l++){const c=t.nfaStates[l],u=this.prog.getInst(c);H.isRuneOp(u.op)&&u.matchRune(r)&&o.push(u.out)}s===$.UNANCHORED&&o.push(this.prog.start);const a=this.getState(o);return a===null?null:(i[n]=a,a)}start(){return this.startState===null&&(this.startState=this.getState([this.prog.start]),this.startState===null&&!this.failed&&(this.clearCache(),this.startState=this.getState([this.prog.start]))),this.startState}run(t,n,r,s,i,o){const a=t.endPos(),l=this.latin1Class;let c=-1,u=n;for(;u<a;){const d=t.step(u),h=d>>3,f=d&7;if(f===0)break;const B=h<=ce.MAX_LATIN1?l[h]:this.runeClass(h);let g=r===$.UNANCHORED&&s.next!==null?s.next[B]:null;if(g===null&&(g=this.step(s,B,h,r),g===null&&(c>=0&&u-c<Hu.PROGRESS_PER_STATE*this.stateCount||(c=u,s=this.resetCache(s),s===null)||(g=this.step(s,B,h,r),g===null))))return null;s=g,u+=f;const C=i(s,u);if(C!==null)return C;if(s.nfaStates.length===0&&r!==$.UNANCHORED)return o}return o}match(t,n,r){if(this.failed)return null;if((r===$.ANCHOR_START||r===$.ANCHOR_BOTH)&&n!==0)return!1;const s=this.start();if(s===null)return null;const i=t.endPos();return s.isMatch&&(r!==$.ANCHOR_BOTH||n===i)?!0:this.run(t,n,r,s,(o,a)=>o.isMatch&&(r!==$.ANCHOR_BOTH||a===i)?!0:null,!1)}matchSet(t,n,r){if(this.failed)return null;if((r===$.ANCHOR_START||r===$.ANCHOR_BOTH)&&n!==0)return[];const s=this.start();if(s===null)return null;const i=t.endPos(),o=new Set,a=(l,c)=>{if(l.isMatch&&(r!==$.ANCHOR_BOTH||c===i))for(let u=0;u<l.matchIDs.length;u++)o.add(l.matchIDs[u]);return null};return a(s,n),this.run(t,n,r,s,a,!1)===null?null:Array.from(o).sort((l,c)=>l-c)}},I4=32,k4=500,Wf=256,R4=262144,O4=class{constructor(){this.end=0,this.cap=new Int32Array(0),this.matchcap=new Int32Array(0),this.ncap=0,this.jobPc=new Int32Array(Wf),this.jobArg=new Uint8Array(Wf),this.jobPos=new Int32Array(Wf),this.jobLen=0,this.visited=new Uint32Array(0)}reset(e,t,n){this.end=t,this.jobLen=0,this.ncap=n;const r=e.numInst()*(t+1)+I4-1>>>5;this.visited.length<r?this.visited=new Uint32Array(r):this.visited.fill(0,0,r),this.cap.length<n?this.cap=new Int32Array(n).fill(-1):this.cap.fill(-1,0,n),this.matchcap.length<n?this.matchcap=new Int32Array(n).fill(-1):this.matchcap.fill(-1,0,n)}shouldVisit(e,t){const n=e*(this.end+1)+t,r=n>>>5,s=1<<(n&31);return(this.visited[r]&s)!==0?!1:(this.visited[r]|=s,!0)}push(e,t,n,r){if(e.prog.getInst(t).op!==H.FAIL&&(r||this.shouldVisit(t,n))){if(this.jobLen>=this.jobPc.length){const s=this.jobPc.length*2,i=new Int32Array(s);i.set(this.jobPc),this.jobPc=i;const o=new Uint8Array(s);o.set(this.jobArg),this.jobArg=o;const a=new Int32Array(s);a.set(this.jobPos),this.jobPos=a}this.jobPc[this.jobLen]=t,this.jobArg[this.jobLen]=r?1:0,this.jobPos[this.jobLen]=n,this.jobLen++}}tryBacktrack(e,t,n,r,s){const i=e.longest;for(this.push(e,n,r,!1);this.jobLen>0;){this.jobLen--;let o=this.jobPc[this.jobLen],a=this.jobArg[this.jobLen]===1,l=this.jobPos[this.jobLen],c=!0;for(;!(!c&&!this.shouldVisit(o,l));){c=!1;const u=e.prog.getInst(o);switch(u.op){case H.FAIL:throw new Ya("unexpected InstFail");case H.ALT:if(a){a=!1,o=u.arg;continue}else{this.push(e,o,l,!0),o=u.out;continue}case H.ALT_MATCH:{const d=e.prog.getInst(u.out);if(H.isRuneOp(d.op)){this.push(e,u.arg,l,!1),o=u.arg,l=this.end;continue}this.push(e,u.out,this.end,!1),o=u.out;continue}case H.RUNE:{const d=t.step(l);if(d===nn.EOF()||!u.matchRune(d>>3))break;l+=d&7,o=u.out;continue}case H.RUNE1:{const d=t.step(l);if(d===nn.EOF()||d>>3!==u.runes[0])break;l+=d&7,o=u.out;continue}case H.RUNE_ANY_NOT_NL:{const d=t.step(l);if(d===nn.EOF()||d>>3===10)break;l+=d&7,o=u.out;continue}case H.RUNE_ANY:{const d=t.step(l);if(d===nn.EOF())break;l+=d&7,o=u.out;continue}case H.CAPTURE:if(a){this.cap[u.arg]=l;break}else{u.arg<this.ncap&&(this.push(e,o,this.cap[u.arg],!0),this.cap[u.arg]=l),o=u.out;continue}case H.EMPTY_WIDTH:{const d=t.context(l);if((u.arg&~d)!==0)break;o=u.out;continue}case H.NOP:o=u.out;continue;case H.MATCH:{if(s===$.ANCHOR_BOTH&&l!==this.end)break;if(this.ncap===0)return!0;this.ncap>1&&(this.cap[1]=l);const d=this.matchcap[1];if((d===-1||i&&l>0&&l>d)&&this.matchcap.set(this.cap),!i||l===this.end)return!0;break}case H.LB_WRITE:case H.LB_CHECK:throw new Ya("Backtracker cannot evaluate Lookbehind instructions");default:throw new Ya("bad inst")}break}}return i&&this.matchcap.length>1&&this.matchcap[1]>=0}},$c=[],Wc=class DA{static shouldBacktrack(t){return t.numInst()<=k4}static maxBitStateLen(t){return DA.shouldBacktrack(t)?Math.floor(R4/t.numInst()):0}static execute(t,n,r,s,i){const o=t.cond;if(o===me.EMPTY_ALL||(s===$.ANCHOR_START||s===$.ANCHOR_BOTH)&&r!==0||(o&me.EMPTY_BEGIN_TEXT)!==0&&r!==0)return null;const a=$c.length>0?$c.pop():new O4,l=n.endPos();a.reset(t.prog,l,i);let c=!1;if((o&me.EMPTY_BEGIN_TEXT)!==0||s===$.ANCHOR_START||s===$.ANCHOR_BOTH)a.ncap>0&&(a.cap[0]=r),a.tryBacktrack(t,n,t.prog.start,r,s)&&(c=!0);else{let d=-1;for(;r<=l&&d!==0;r+=d){if(t.prefix.length>0){const f=n.index(t,r);if(f<0)break;r+=f}if(a.ncap>0&&(a.cap[0]=r),a.tryBacktrack(t,n,t.prog.start,r,s)){c=!0;break}const h=n.step(r);d=h===nn.EOF()?0:h&7}}if(!c)return $c.push(a),null;const u=i===0?[]:me.toArray(a.matchcap.subarray(0,i));return $c.push(a),u}},ub=class{constructor(e){this.sparse=new Uint32Array(e),this.dense=new Uint32Array(e),this.size=0,this.nextIndex=0}empty(){return this.nextIndex>=this.size}next(){return this.dense[this.nextIndex++]}clear(){this.size=0,this.nextIndex=0}contains(e){return e<this.sparse.length&&this.sparse[e]<this.size&&this.dense[this.sparse[e]]===e}insert(e){this.contains(e)||this.insertNew(e)}insertNew(e){e>=this.sparse.length||(this.sparse[e]=this.size,this.dense[this.size]=e,this.size++)}},M4=(e,t,n,r)=>{const s=e.length,i=t.length;let o=0,a=0;const l=[],c=[];let u=!0,d=-1;const h=f=>{const B=f?e:t,g=f?o:a,C=f?n:r;return d>0&&B[g]<=l[d]?!1:(l.push(B[g],B[g+1]),f?o+=2:a+=2,d+=2,c.push(C),!0)};for(;o<s||a<i;)if(a>=i?u=h(!0):o>=s||t[a]<e[o]?u=h(!1):u=h(!0),!u)return null;return{merged:l,next:c}},N4=class{constructor(e){this.start=e.start,this.numCap=e.numCap,this.inst=new Array(e.inst.length);for(let t=0;t<e.inst.length;t++){const n=e.inst[t],r=new H(n.op);r.out=n.out,r.arg=n.arg,r.runes=n.runes?new Int32Array(n.runes):new Int32Array(0),r.next=null,this.inst[t]=r}}},P4=e=>{const t=new N4(e);for(let n=0;n<t.inst.length;n++){const r=t.inst[n];if(r.op!==H.ALT&&r.op!==H.ALT_MATCH)continue;let s="out",i="arg",o=t.inst[r[i]];if(o.op!==H.ALT&&o.op!==H.ALT_MATCH&&(s="arg",i="out",o=t.inst[r[i]],o.op!==H.ALT&&o.op!==H.ALT_MATCH))continue;const a=t.inst[r[s]];if(a.op===H.ALT||a.op===H.ALT_MATCH)continue;let l="out",c="arg",u=!1;o.out===n?u=!0:o.arg===n&&(u=!0,l="arg",c="out"),u&&(o[l]=r[s]),r[s]===o[l]&&(r[i]=o[c])}return t},L4=e=>{if(e.inst.length>=1e3)return null;const t=new ub(e.inst.length),n=new ub(e.inst.length),r=new Array(e.inst.length),s=new Array(e.inst.length).fill(!1),i=o=>{let a=!0;const l=e.inst[o];if(n.contains(o))return!0;switch(n.insert(o),l.op){case H.ALT:case H.ALT_MATCH:{a=i(l.out)&&i(l.arg);let c=s[l.out],u=s[l.arg];if(c&&u)return!1;if(u){const B=l.out;l.out=l.arg,l.arg=B;const g=c;c=u,u=g}c&&(s[o]=!0,l.op=H.ALT_MATCH);const d=r[l.out]||[],h=r[l.arg]||[],f=M4(d,h,l.out,l.arg);if(!f)return!1;r[o]=new Int32Array(f.merged),l.next=new Uint32Array(f.next);break}case H.CAPTURE:case H.EMPTY_WIDTH:case H.NOP:a=i(l.out),s[o]=s[l.out],r[o]=r[l.out]?new Int32Array(r[l.out]):new Int32Array(0),l.next=new Uint32Array(Math.floor(r[o].length/2)+1).fill(l.out);break;case H.MATCH:case H.FAIL:s[o]=l.op===H.MATCH;break;case H.RUNE:{if(s[o]=!1,l.next&&l.next.length>0)break;if(t.insert(l.out),!l.runes||l.runes.length===0){r[o]=new Int32Array(0),l.next=new Uint32Array([l.out]);break}let c=[];if(l.runes.length===1&&(l.arg&$.FOLD_CASE)!==0){const u=l.runes[0];c.push(u,u);for(let d=ce.simpleFold(u);d!==u;d=ce.simpleFold(d))c.push(d,d);c.sort((d,h)=>d-h)}else for(let u=0;u<l.runes.length;u++)c.push(l.runes[u]);r[o]=new Int32Array(c),l.next=new Uint32Array(Math.floor(c.length/2)+1).fill(l.out),l.op=H.RUNE;break}case H.RUNE1:{if(s[o]=!1,l.next&&l.next.length>0)break;t.insert(l.out);let c=[];if((l.arg&$.FOLD_CASE)!==0){const u=l.runes[0];c.push(u,u);for(let d=ce.simpleFold(u);d!==u;d=ce.simpleFold(d))c.push(d,d);c.sort((d,h)=>d-h)}else c.push(l.runes[0],l.runes[0]);r[o]=new Int32Array(c),l.next=new Uint32Array(Math.floor(c.length/2)+1).fill(l.out),l.op=H.RUNE;break}case H.RUNE_ANY:if(s[o]=!1,l.next&&l.next.length>0)break;t.insert(l.out),r[o]=new Int32Array([0,ce.MAX_RUNE]),l.next=new Uint32Array([l.out]);break;case H.RUNE_ANY_NOT_NL:if(s[o]=!1,l.next&&l.next.length>0)break;t.insert(l.out),r[o]=new Int32Array([0,9,11,ce.MAX_RUNE]),l.next=new Uint32Array(Math.floor(r[o].length/2)+1).fill(l.out)}return a};for(t.clear(),t.insert(e.start);!t.empty();)if(n.clear(),!i(t.next()))return null;for(let o=0;o<e.inst.length;o++)r[o]&&(e.inst[o].runes=r[o]);return e},_4=(e,t)=>{for(let n=0;n<t.inst.length;n++){const r=t.inst[n];switch(r.op){case H.ALT:case H.ALT_MATCH:case H.RUNE:break;case H.CAPTURE:case H.EMPTY_WIDTH:case H.NOP:case H.MATCH:case H.FAIL:e.inst[n].next=null;break;case H.RUNE1:case H.RUNE_ANY:case H.RUNE_ANY_NOT_NL:e.inst[n].next=null,e.inst[n].op=r.op,e.inst[n].runes=r.runes?new Int32Array(r.runes):new Int32Array(0)}}},db=class TA{static compile(t){if(t.start===0||t.numLb>0)return null;const n=t.inst[t.start];if(n.op!==H.EMPTY_WIDTH||(n.arg&me.EMPTY_BEGIN_TEXT)===0)return null;let r=!1;for(let i=0;i<t.inst.length;i++)if(t.inst[i].op===H.ALT||t.inst[i].op===H.ALT_MATCH){r=!0;break}for(let i=0;i<t.inst.length;i++){const o=t.inst[i],a=t.inst[o.out].op;switch(o.op){case H.ALT:case H.ALT_MATCH:if(a===H.MATCH||t.inst[o.arg].op===H.MATCH)return null;break;case H.EMPTY_WIDTH:if(a===H.MATCH){if((o.arg&me.EMPTY_END_TEXT)===me.EMPTY_END_TEXT)continue;return null}break;default:if(a===H.MATCH&&r)return null}}let s=P4(t);return s=L4(s),s!==null&&_4(s,t),s}static next(t,n){const r=t.matchRunePos(n);return r>=0?t.next[r]:t.op===H.ALT_MATCH?t.out:0}static execute(t,n,r,s,i){const o=t.onepass;if(!o)return null;const a=new Int32Array(i).fill(-1);let l=!1,c=n.step(r),u=c>>3,d=c&7,h=nn.EOF(),f=-1,B=0;c!==nn.EOF()&&(h=n.step(r+d),h!==nn.EOF()&&(f=h>>3,B=h&7));let g=r===0?me.emptyOpContext(-1,u):n.context(r),C=o.start,v;for(;;){switch(v=o.inst[C],C=v.out,v.op){case H.MATCH:return s===$.ANCHOR_BOTH&&r!==n.endPos()?null:(l=!0,a.length>0&&(a[0]=0,a[1]=r),i===0?[]:me.toArray(a));case H.RUNE:if(!v.matchRune(u))return null;break;case H.RUNE1:if(u!==v.runes[0])return null;break;case H.RUNE_ANY:break;case H.RUNE_ANY_NOT_NL:if(u===10)return null;break;case H.ALT:case H.ALT_MATCH:C=TA.next(v,u);continue;case H.FAIL:return null;case H.NOP:continue;case H.EMPTY_WIDTH:if((v.arg&~g)!==0)return null;continue;case H.CAPTURE:v.arg<a.length&&(a[v.arg]=r);continue;default:throw new Ya("bad inst")}if(d===0)break;g=me.emptyOpContext(u,f),r+=d,u=f,d=B,u!==-1&&(h=n.step(r+d),h!==nn.EOF()?(f=h>>3,B=h&7):(f=-1,B=0))}return l?i===0?[]:me.toArray(a):null}},k=class ye{static Op=yA(["NO_MATCH","EMPTY_MATCH","LITERAL","CHAR_CLASS","ANY_CHAR_NOT_NL","ANY_CHAR","BEGIN_LINE","END_LINE","BEGIN_TEXT","END_TEXT","WORD_BOUNDARY","NO_WORD_BOUNDARY","CAPTURE","STAR","PLUS","QUEST","REPEAT","CONCAT","ALTERNATE","PLB","NLB","LEFT_PAREN","VERTICAL_BAR"]);static isPseudoOp(t){return t>=ye.Op.LEFT_PAREN}static emptySubs(){return[]}static quoteIfHyphen(t){return t===V.CODES.get("-")?"\\":""}static fromRegexp(t){const n=new ye(t.op);return n.flags=t.flags,n.subs=t.subs,n.runes=t.runes,n.cap=t.cap,n.min=t.min,n.max=t.max,n.name=t.name,n.namedGroups=t.namedGroups,n.lb=t.lb,n}constructor(t){this.op=t,this.flags=0,this.subs=ye.emptySubs(),this.runes=new Int32Array(0),this.min=0,this.max=0,this.cap=0,this.name=null,this.namedGroups=Object.create(null),this.lb=0}reinit(){this.flags=0,this.subs=ye.emptySubs(),this.runes=new Int32Array(0),this.cap=0,this.min=0,this.max=0,this.name=null,this.namedGroups=Object.create(null),this.lb=0}toString(){return this.appendTo()}appendTo(){let t="";switch(this.op){case ye.Op.NO_MATCH:t+="[^\\x00-\\x{10FFFF}]";break;case ye.Op.EMPTY_MATCH:t+="(?:)";break;case ye.Op.STAR:case ye.Op.PLUS:case ye.Op.QUEST:case ye.Op.REPEAT:{const n=this.subs[0];switch(n.op>ye.Op.CAPTURE||n.op===ye.Op.LITERAL&&n.runes.length>1?t+=`(?:${n.appendTo()})`:t+=n.appendTo(),this.op){case ye.Op.STAR:t+="*";break;case ye.Op.PLUS:t+="+";break;case ye.Op.QUEST:t+="?";break;case ye.Op.REPEAT:t+=`{${this.min}`,this.min!==this.max&&(t+=",",this.max>=0&&(t+=this.max)),t+="}"}(this.flags&$.NON_GREEDY)!==0&&(t+="?");break}case ye.Op.CONCAT:for(let n of this.subs)n.op===ye.Op.ALTERNATE?t+=`(?:${n.appendTo()})`:t+=n.appendTo();break;case ye.Op.ALTERNATE:{let n="";for(let r of this.subs)t+=n,n="|",t+=r.appendTo();break}case ye.Op.LITERAL:(this.flags&$.FOLD_CASE)!==0&&(t+="(?i:");for(let n of this.runes)t+=me.escapeRune(n);(this.flags&$.FOLD_CASE)!==0&&(t+=")");break;case ye.Op.ANY_CHAR_NOT_NL:t+="(?-s:.)";break;case ye.Op.ANY_CHAR:t+="(?s:.)";break;case ye.Op.PLB:t+=`(?<=${this.subs[0].appendTo()})`;break;case ye.Op.NLB:t+=`(?<!${this.subs[0].appendTo()})`;break;case ye.Op.CAPTURE:this.name===null||this.name.length===0?t+="(":t+=`(?P<${this.name}>`,this.subs[0].op!==ye.Op.EMPTY_MATCH&&(t+=this.subs[0].appendTo()),t+=")";break;case ye.Op.BEGIN_TEXT:t+="\\A";break;case ye.Op.END_TEXT:(this.flags&$.WAS_DOLLAR)!==0?t+="(?-m:$)":t+="\\z";break;case ye.Op.BEGIN_LINE:t+="^";break;case ye.Op.END_LINE:t+="$";break;case ye.Op.WORD_BOUNDARY:t+="\\b";break;case ye.Op.NO_WORD_BOUNDARY:t+="\\B";break;case ye.Op.CHAR_CLASS:if(this.runes.length%2!==0){t+="[invalid char class]";break}if(t+="[",this.runes.length===0)t+="^\\x00-\\x{10FFFF}";else if(this.runes[0]===0&&this.runes[this.runes.length-1]===ce.MAX_RUNE){t+="^";for(let n=1;n<this.runes.length-1;n+=2){const r=this.runes[n]+1,s=this.runes[n+1]-1;t+=ye.quoteIfHyphen(r),t+=me.escapeRune(r),r!==s&&(t+="-",t+=ye.quoteIfHyphen(s),t+=me.escapeRune(s))}}else for(let n=0;n<this.runes.length;n+=2){const r=this.runes[n],s=this.runes[n+1];t+=ye.quoteIfHyphen(r),t+=me.escapeRune(r),r!==s&&(t+="-",t+=ye.quoteIfHyphen(s),t+=me.escapeRune(s))}t+="]";break;default:t+=this.op}return t}maxCap(){let t=0;if(this.op===ye.Op.CAPTURE&&(t=this.cap),this.subs!==null)for(let n of this.subs){const r=n.maxCap();t<r&&(t=r)}return t}equals(t){if(!(t!==null&&t instanceof ye)||this.op!==t.op)return!1;switch(this.op){case ye.Op.END_TEXT:if((this.flags&$.WAS_DOLLAR)!==(t.flags&$.WAS_DOLLAR))return!1;break;case ye.Op.LITERAL:case ye.Op.CHAR_CLASS:if(this.runes===null&&t.runes===null)break;if(this.runes===null||t.runes===null||this.runes.length!==t.runes.length)return!1;for(let n=0;n<this.runes.length;n++)if(this.runes[n]!==t.runes[n])return!1;break;case ye.Op.ALTERNATE:case ye.Op.CONCAT:if(this.subs.length!==t.subs.length)return!1;for(let n=0;n<this.subs.length;++n)if(!this.subs[n].equals(t.subs[n]))return!1;break;case ye.Op.STAR:case ye.Op.PLUS:case ye.Op.QUEST:if((this.flags&$.NON_GREEDY)!==(t.flags&$.NON_GREEDY)||!this.subs[0].equals(t.subs[0]))return!1;break;case ye.Op.REPEAT:if((this.flags&$.NON_GREEDY)!==(t.flags&$.NON_GREEDY)||this.min!==t.min||this.max!==t.max||!this.subs[0].equals(t.subs[0]))return!1;break;case ye.Op.CAPTURE:if(this.cap!==t.cap||(this.name===null?t.name!==null:this.name!==t.name)||!this.subs[0].equals(t.subs[0]))return!1;break;case ye.Op.PLB:case ye.Op.NLB:if(this.lb!==t.lb||!this.subs[0].equals(t.subs[0]))return!1}return!0}},LC=class{static walk(e,t){const n=[];let r=e,s;for(;;){if(r.subs.length===0)s=t.leaf(r);else{const i=t.enter(r);if(i.result===void 0){n.push({re:r,state:i,i:0}),r=r.subs[0];continue}s=i.result}for(;;){if(n.length===0)return s;const i=n[n.length-1];if(t.child(i.re,i.state,s,i.i),i.i++,i.state.result===void 0&&i.i<i.re.subs.length){r=i.re.subs[i.i];break}n.pop(),s=i.state.result!==void 0?i.state.result:t.leave(i.re,i.state)}}}},hb=class{constructor(e,t){const n=new Map,r=[0],s=[0],i=[0],o=[0];for(const B of e){let g=0;for(let C=0;C<B.length;C++){const v=g*t+B[C];let y=n.get(v);y===void 0&&(y=r.length,n.set(v,y),r.push(g),s.push(B[C]),i.push(i[g]+1),o.push(0)),g=y}o[g]=1}const a=r.length,l=new Int32Array(a-1);for(let B=1;B<a;B++)l[B-1]=B;l.sort((B,g)=>r[B]-r[g]||s[B]-s[g]);const c=new Int32Array(a+1);for(let B=1;B<a;B++)c[r[B]+1]++;for(let B=0;B<a;B++)c[B+1]+=c[B];const u=new Int32Array(a-1);for(let B=0;B<l.length;B++)u[B]=s[l[B]];this.childStart=c,this.childUnit=u,this.childNode=l;const d=new Int32Array(a);for(let B=0;B<a;B++)d[B]=B;d.sort((B,g)=>i[B]-i[g]);const h=new Int32Array(a),f=Uint8Array.from(o);for(let B=1;B<a;B++){const g=d[B],C=r[g];if(C!==0){let v=h[C],y=this.next(v,s[g]);for(;y<0&&v!==0;)v=h[v],y=this.next(v,s[g]);h[g]=y>=0?y:0}f[g]|=f[h[g]]}this.fail=h,this.match=f}next(e,t){let n=this.childStart[e],r=this.childStart[e+1];const s=this.childUnit;for(;n<r;){const i=n+r>>1,o=s[i];if(o===t)return this.childNode[i];o<t?n=i+1:r=i}return-1}advance(e,t){for(;;){const n=this.next(e,t);if(n>=0)return n;if(e===0)return 0;e=this.fail[e]}}searchUTF16(e,t,n){let r=0;for(let s=t;s<n;s++)if(r=this.advance(r,e.charCodeAt(s)),this.match[r]===1)return!0;return!1}searchUTF8(e,t,n){let r=0;for(let s=t;s<n;s++)if(r=this.advance(r,e[s]),this.match[r]===1)return!0;return!1}},De=class io{static Type={NONE:0,EXACT:1,AND:2,OR:3};static MAX_SCANS=32;static MAX_AC_UNITS=1<<18;constructor(t){this.type=t,this.subs=[],this.str="",this.bytes=null,this.cost=t===io.Type.EXACT?1:0,this.allExact=!1,this.ac16=null,this.ac8=null}automaton16(){if(this.ac16===null){const t=this.subs.map(n=>{const r=new Array(n.str.length);for(let s=0;s<n.str.length;s++)r[s]=n.str.charCodeAt(s);return r});this.ac16=new hb(t,65536)}return this.ac16}automaton8(){return this.ac8===null&&(this.ac8=new hb(this.subs.map(t=>t.bytes),256)),this.ac8}eval(t,n){switch(this.type){case io.Type.NONE:return!0;case io.Type.EXACT:return t.hasString(this,n);case io.Type.AND:for(let r=0;r<this.subs.length;r++)if(!this.subs[r].eval(t,n))return!1;return!0;case io.Type.OR:if(this.allExact)return t.hasAnyString(this,n);for(let r=0;r<this.subs.length;r++)if(this.subs[r].eval(t,n))return!0;return!1;default:return!0}}},F4=class oo{static build(t){return t?LC.walk(t,oo.WALKER):new De(De.Type.NONE)}static WALKER={leaf:t=>oo.leaf(t),enter:t=>oo.enter(t),child:(t,n,r)=>oo.child(t,n,r),leave:(t,n)=>oo.leave(t,n)};static leaf(t){if(t.op!==k.Op.LITERAL)return new De(De.Type.NONE);if(t.runes.length===0||(t.flags&$.FOLD_CASE)!==0)return new De(De.Type.NONE);let n="";for(let s=0;s<t.runes.length;s++){if(ce.isUnsearchable(t.runes[s]))return new De(De.Type.NONE);n+=String.fromCodePoint(t.runes[s])}const r=new De(De.Type.EXACT);return r.str=n,r.bytes=me.stringToUtf8ByteArray(r.str),r}static enter(t){switch(t.op){case k.Op.CAPTURE:case k.Op.PLUS:return{sub:null};case k.Op.REPEAT:return t.min>=1?{sub:null}:{result:new De(De.Type.NONE)};case k.Op.CONCAT:return{pf:new De(De.Type.AND),subs:[]};case k.Op.ALTERNATE:return{pf:new De(De.Type.OR),subs:[]};default:return{result:new De(De.Type.NONE)}}}static child(t,n,r){if(n.subs===void 0){n.sub=r;return}if(n.pf.type===De.Type.AND){if(r.type===De.Type.NONE)return;if(r.type===De.Type.AND){for(let s=0;s<r.subs.length;s++)n.subs.push(r.subs[s]);return}n.subs.push(r);return}if(r.type===De.Type.NONE){n.result=new De(De.Type.NONE);return}if(r.type===De.Type.OR){for(let s=0;s<r.subs.length;s++)n.subs.push(r.subs[s]);return}n.subs.push(r)}static leave(t,n){if(n.subs===void 0)return n.sub;const r=n.pf,s=new Set,i=[];for(const c of n.subs){if(c.type===De.Type.EXACT){if(s.has(c.str))continue;s.add(c.str)}i.push(c)}if(r.type===De.Type.AND){const c=[];let u=0;for(const d of i)u+d.cost>De.MAX_SCANS||(c.push(d),u+=d.cost);return c.length===0?new De(De.Type.NONE):c.length===1?c[0]:(r.subs=c,r.cost=u,r)}if(i.length===0)return new De(De.Type.NONE);if(i.length===1)return i[0];r.subs=i;let o=!0,a=0,l=0;for(const c of i)c.type!==De.Type.EXACT?o=!1:l+=c.bytes.length,a+=c.cost;return o?l>De.MAX_AC_UNITS?new De(De.Type.NONE):(r.allExact=!0,r.cost=1,r):a>De.MAX_SCANS?new De(De.Type.NONE):(r.cost=a,r)}},In=class{constructor(e=0,t=0){this.head=e,this.tail=t}},H4=class{constructor(){this.inst=[],this.start=0,this.numCap=2,this.lbStarts=[],this.numLb=0,this.lbInst=null}getInst(e){return this.inst[e]}numInst(){return this.inst.length}addInst(e){this.inst.push(new H(e))}markLookbehindInsts(){const e=new Uint8Array(this.inst.length),t=this.lbStarts.slice();for(;t.length>0;){const n=t.pop();if(n===0||e[n]===1)continue;e[n]=1;const r=this.inst[n];switch(r.op){case H.ALT:case H.ALT_MATCH:t.push(r.out,r.arg);break;case H.MATCH:case H.FAIL:break;default:t.push(r.out)}}this.lbInst=e}skipNop(e){let t=this.inst[e];for(;t.op===H.NOP||t.op===H.CAPTURE;)t=this.inst[e],e=t.out;return t}prefix(){let e="",t=this.skipNop(this.start);if(!H.isRuneOp(t.op)||t.runes.length!==1)return[t.op===H.MATCH,e];for(;H.isRuneOp(t.op)&&t.runes.length===1&&(t.arg&$.FOLD_CASE)===0&&!ce.isUnsearchable(t.runes[0]);)e+=String.fromCodePoint(t.runes[0]),t=this.skipNop(t.out);return[t.op===H.MATCH,e]}startCond(){let e=0,t=this.start;e:for(;;){const n=this.inst[t];switch(n.op){case H.EMPTY_WIDTH:e|=n.arg;break;case H.FAIL:return-1;case H.CAPTURE:case H.NOP:break;default:break e}t=n.out}return e}patch(e,t){let n=e.head;for(;n!==0;){const r=this.inst[n>>1];(n&1)===0?(n=r.out,r.out=t):(n=r.arg,r.arg=t)}}append(e,t){if(e.head===0)return t;if(t.head===0)return e;const n=this.inst[e.tail>>1];return(e.tail&1)===0?n.out=t.head:n.arg=t.head,new In(e.head,t.tail)}toString(){let e="";for(let t=0;t<this.inst.length;t++){const n=e.length;e+=t,t===this.start&&(e+="*"),e+=" ".substring(e.length-n),e+=this.inst[t],e+=`
46
+ `}return e}},j4=new Int32Array([0,V.CODES.get(`
47
+ `)-1,V.CODES.get(`
48
+ `)+1,ce.MAX_RUNE]),fb=new Int32Array([0,ce.MAX_RUNE]),qc=class{constructor(e=0,t=new In,n=!1){this.i=e,this.out=t,this.nullable=n}},AA=class Hp{static compileRegexp(t){const n=new Hp,r=n.compile(t);return n.prog.patch(r.out,n.newInst(H.MATCH).i),n.prog.start=r.i,n.prog.markLookbehindInsts(),n.prog}static compileSet(t){const n=new Hp;if(t.length===0)return n.prog.start=n.newInst(H.FAIL).i,n.prog.markLookbehindInsts(),n.prog;let r=[];for(let i=0;i<t.length;i++){const o=n.compile(t[i]),a=n.newInst(H.MATCH);n.prog.getInst(a.i).arg=i,n.prog.patch(o.out,a.i),r.push(o.i)}let s=r[0];for(let i=1;i<r.length;i++){const o=n.newInst(H.ALT),a=n.prog.getInst(o.i);a.out=s,a.arg=r[i],s=o.i}return n.prog.start=s,n.prog.markLookbehindInsts(),n.prog}constructor(){this.prog=new H4,this.newInst(H.FAIL),this.runeCache=new Map,this.walker={leaf:t=>this.leaf(t),enter:t=>this.enter(t),child:(t,n,r)=>this.child(t,n,r),leave:(t,n)=>this.leave(t,n)}}newInst(t){return this.prog.addInst(t),new qc(this.prog.numInst()-1,new In,!0)}nop(){const t=this.newInst(H.NOP);return t.out=new In(t.i<<1,t.i<<1),t}fail(){return new qc}cap(t){const n=this.newInst(H.CAPTURE);return n.out=new In(n.i<<1,n.i<<1),this.prog.getInst(n.i).arg=t,this.prog.numCap<t+1&&(this.prog.numCap=t+1),n}cat(t,n){return t.i===0||n.i===0?this.fail():(this.prog.patch(t.out,n.i),new qc(t.i,n.out,t.nullable&&n.nullable))}alt(t,n){if(t.i===0)return n;if(n.i===0)return t;const r=this.newInst(H.ALT),s=this.prog.getInst(r.i);return s.out=t.i,s.arg=n.i,r.out=this.prog.append(t.out,n.out),r.nullable=t.nullable||n.nullable,r}loop(t,n){const r=this.newInst(H.ALT),s=this.prog.getInst(r.i);return n?(s.arg=t.i,r.out=new In(r.i<<1,r.i<<1)):(s.out=t.i,r.out=new In(r.i<<1|1,r.i<<1|1)),this.prog.patch(t.out,r.i),r}quest(t,n){const r=this.newInst(H.ALT),s=this.prog.getInst(r.i);return n?(s.arg=t.i,r.out=new In(r.i<<1,r.i<<1)):(s.out=t.i,r.out=new In(r.i<<1|1,r.i<<1|1)),r.out=this.prog.append(r.out,t.out),r}star(t,n){return t.nullable?this.quest(this.plus(t,n),n):this.loop(t,n)}plus(t,n){return new qc(t.i,this.loop(t,n).out,t.nullable)}empty(t){const n=this.newInst(H.EMPTY_WIDTH);return this.prog.getInst(n.i).arg=t,n.out=new In(n.i<<1,n.i<<1),n}rune(t,n){const r=this.newInst(H.RUNE);r.nullable=!1;const s=this.prog.getInst(r.i);return s.runes=t,n&=$.FOLD_CASE,(t.length!==1||ce.simpleFold(t[0])===t[0])&&(n&=~$.FOLD_CASE),s.arg=n,r.out=new In(r.i<<1,r.i<<1),(n&$.FOLD_CASE)===0&&t.length===1||t.length===2&&t[0]===t[1]?s.op=H.RUNE1:t.length===2&&t[0]===0&&t[1]===ce.MAX_RUNE?s.op=H.RUNE_ANY:t.length===4&&t[0]===0&&t[1]===V.CODES.get(`
49
+ `)-1&&t[2]===V.CODES.get(`
50
+ `)+1&&t[3]===ce.MAX_RUNE&&(s.op=H.RUNE_ANY_NOT_NL),r}lookBehind(t,n){const r=this.newInst(H.LB_WRITE);this.prog.getInst(r.i).arg=n;const s=this.rune(fb,0),i=this.star(s,!0),o=this.cat(i,t);this.prog.patch(o.out,r.i);const a=this.newInst(H.LB_CHECK);return this.prog.getInst(a.i).arg=n,this.prog.lbStarts.push(o.i),Math.abs(n)>this.prog.numLb&&(this.prog.numLb=Math.abs(n)),a.out=new In(a.i<<1,a.i<<1),a}compile(t){return LC.walk(t,this.walker)}leaf(t){switch(t.op){case k.Op.NO_MATCH:return this.fail();case k.Op.EMPTY_MATCH:return this.nop();case k.Op.LITERAL:{if(t.runes.length===0)return this.nop();let n=null;for(let r of t.runes){let s=this.runeCache.get(r);s===void 0&&(s=new Int32Array([r]),this.runeCache.set(r,s));const i=this.rune(s,t.flags);n=n===null?i:this.cat(n,i)}return n}case k.Op.CHAR_CLASS:return this.rune(t.runes,t.flags);case k.Op.ANY_CHAR_NOT_NL:return this.rune(j4,0);case k.Op.ANY_CHAR:return this.rune(fb,0);case k.Op.BEGIN_LINE:return this.empty(me.EMPTY_BEGIN_LINE);case k.Op.END_LINE:return this.empty(me.EMPTY_END_LINE);case k.Op.BEGIN_TEXT:return this.empty(me.EMPTY_BEGIN_TEXT);case k.Op.END_TEXT:return this.empty(me.EMPTY_END_TEXT);case k.Op.WORD_BOUNDARY:return this.empty(me.EMPTY_WORD_BOUNDARY);case k.Op.NO_WORD_BOUNDARY:return this.empty(me.EMPTY_NO_WORD_BOUNDARY);case k.Op.CONCAT:case k.Op.ALTERNATE:return this.nop();default:throw new Qa("regexp: unhandled case in compile")}}enter(t){switch(t.op){case k.Op.PLB:case k.Op.NLB:case k.Op.STAR:case k.Op.PLUS:case k.Op.QUEST:return{sub:null};case k.Op.CAPTURE:return{bra:this.cap(t.cap<<1),sub:null};case k.Op.CONCAT:case k.Op.ALTERNATE:return{f:null};default:throw new Qa("regexp: unhandled case in compile")}}child(t,n,r){t.op===k.Op.CONCAT?n.f=n.f===null?r:this.cat(n.f,r):t.op===k.Op.ALTERNATE?n.f=n.f===null?r:this.alt(n.f,r):n.sub=r}leave(t,n){switch(t.op){case k.Op.PLB:case k.Op.NLB:return this.lookBehind(n.sub,t.lb);case k.Op.CAPTURE:{const r=this.cap(t.cap<<1|1);return this.cat(this.cat(n.bra,n.sub),r)}case k.Op.STAR:return this.star(n.sub,(t.flags&$.NON_GREEDY)!==0);case k.Op.PLUS:return this.plus(n.sub,(t.flags&$.NON_GREEDY)!==0);case k.Op.QUEST:return this.quest(n.sub,(t.flags&$.NON_GREEDY)!==0);case k.Op.CONCAT:case k.Op.ALTERNATE:return n.f;default:throw new Qa("regexp: unhandled case in compile")}}},IA=class Ut{static simplify(t){return t===null?null:LC.walk(t,Ut.WALKER)}static WALKER={leaf:t=>Ut.leaf(t),enter:t=>Ut.enter(t),child:(t,n,r,s)=>Ut.child(t,n,r,s),leave:(t,n)=>Ut.leave(t,n)};static leaf(t){if(t.op===k.Op.CHAR_CLASS){if(t.runes===null)return t;if(t.runes.length===0)return new k(k.Op.NO_MATCH);if(t.runes.length===2&&t.runes[0]===0&&t.runes[1]===ce.MAX_RUNE)return new k(k.Op.ANY_CHAR);if(t.runes.length===4&&t.runes[0]===0&&t.runes[1]===V.CODES.get(`
51
+ `)-1&&t.runes[2]===V.CODES.get(`
52
+ `)+1&&t.runes[3]===ce.MAX_RUNE)return new k(k.Op.ANY_CHAR_NOT_NL)}return t}static enter(t){switch(t.op){case k.Op.PLB:case k.Op.NLB:case k.Op.CAPTURE:case k.Op.STAR:case k.Op.PLUS:case k.Op.QUEST:return{sub:null};case k.Op.CONCAT:case k.Op.ALTERNATE:return{subs:[],changed:!1};case k.Op.REPEAT:return t.min===0&&t.max===0?{result:new k(k.Op.EMPTY_MATCH)}:{sub:null};default:return{result:t}}}static child(t,n,r,s){if(n.subs===void 0){n.sub=r;return}if(r!==t.subs[s]&&(n.changed=!0),t.op===k.Op.CONCAT){if(r.op===k.Op.NO_MATCH){n.result=new k(k.Op.NO_MATCH);return}if(r.op===k.Op.EMPTY_MATCH){n.changed=!0;return}if(r.op===k.Op.CONCAT){n.changed=!0;for(let i=0;i<r.subs.length;i++)n.subs.push(r.subs[i]);return}}else{if(r.op===k.Op.NO_MATCH){n.changed=!0;return}if(r.op===k.Op.ALTERNATE){n.changed=!0;for(let i=0;i<r.subs.length;i++)n.subs.push(r.subs[i]);return}}n.subs.push(r)}static leave(t,n){switch(t.op){case k.Op.PLB:case k.Op.NLB:case k.Op.CAPTURE:{const r=n.sub;if(r!==t.subs[0]){const s=k.fromRegexp(t);return s.runes=new Int32Array(0),s.subs=[r],s}return t}case k.Op.CONCAT:case k.Op.ALTERNATE:if(n.changed){const r=n.subs;if(r.length===0)return new k(t.op===k.Op.CONCAT?k.Op.EMPTY_MATCH:k.Op.NO_MATCH);if(r.length===1)return r[0];const s=k.fromRegexp(t);return s.runes=new Int32Array(0),s.subs=r,s}return t;case k.Op.STAR:case k.Op.PLUS:case k.Op.QUEST:return Ut.simplify1(t.op,t.flags,n.sub,t);case k.Op.REPEAT:return Ut.simplifyRepeat(t,n.sub);default:return t}}static simplifyRepeat(t,n){if(t.max===-1){if(t.min===0)return Ut.simplify1(k.Op.STAR,t.flags,n,null);if(t.min===1)return Ut.simplify1(k.Op.PLUS,t.flags,n,null);const s=[];for(let i=0;i<t.min-1;i++)s.push(n);return s.push(Ut.simplify1(k.Op.PLUS,t.flags,n,null)),Ut.concat(s)}if(t.min===1&&t.max===1)return n;let r=null;if(t.min>0){r=[];for(let s=0;s<t.min;s++)r.push(n)}if(t.max>t.min){let s=Ut.simplify1(k.Op.QUEST,t.flags,n,null);for(let i=t.min+1;i<t.max;i++)s=Ut.simplify1(k.Op.QUEST,t.flags,Ut.concat([n,s]),null);if(r===null)return s;r.push(s)}return r!==null?Ut.concat(r):new k(k.Op.NO_MATCH)}static concat(t){const n=[];for(let s=0;s<t.length;s++){const i=t[s];if(i.op===k.Op.NO_MATCH)return new k(k.Op.NO_MATCH);if(i.op!==k.Op.EMPTY_MATCH){if(i.op===k.Op.CONCAT){for(let o=0;o<i.subs.length;o++)n.push(i.subs[o]);continue}n.push(i)}}if(n.length===0)return new k(k.Op.EMPTY_MATCH);if(n.length===1)return n[0];const r=new k(k.Op.CONCAT);return r.subs=n,r}static simplify1(t,n,r,s){if(r.op===k.Op.EMPTY_MATCH)return r;if(r.op===k.Op.NO_MATCH)return t===k.Op.PLUS?r:new k(k.Op.EMPTY_MATCH);if(t===r.op&&(n&$.NON_GREEDY)===(r.flags&$.NON_GREEDY))return r;if(s!==null&&s.op===t&&(s.flags&$.NON_GREEDY)===(n&$.NON_GREEDY)&&r===s.subs[0])return s;const i=new k(t);return i.flags=n,i.subs=[r],i}},Pe=class{constructor(e,t){this.sign=e,this.cls=t}},Bb=[48,57],pb=[9,10,12,13,32,32],mb=[48,57,65,90,95,95,97,122],gb=new Map([["\\d",new Pe(1,Bb)],["\\D",new Pe(-1,Bb)],["\\s",new Pe(1,pb)],["\\S",new Pe(-1,pb)],["\\w",new Pe(1,mb)],["\\W",new Pe(-1,mb)]]),Cb=[48,57,65,90,97,122],vb=[65,90,97,122],yb=[0,127],bb=[9,9,32,32],Sb=[0,31,127,127],Eb=[48,57],xb=[33,126],wb=[97,122],Db=[32,126],Tb=[33,47,58,64,91,96,123,126],Ab=[9,13,32,32],Ib=[65,90],kb=[48,57,65,90,95,95,97,122],Rb=[48,57,65,70,97,102],Ob=new Map([["[:alnum:]",new Pe(1,Cb)],["[:^alnum:]",new Pe(-1,Cb)],["[:alpha:]",new Pe(1,vb)],["[:^alpha:]",new Pe(-1,vb)],["[:ascii:]",new Pe(1,yb)],["[:^ascii:]",new Pe(-1,yb)],["[:blank:]",new Pe(1,bb)],["[:^blank:]",new Pe(-1,bb)],["[:cntrl:]",new Pe(1,Sb)],["[:^cntrl:]",new Pe(-1,Sb)],["[:digit:]",new Pe(1,Eb)],["[:^digit:]",new Pe(-1,Eb)],["[:graph:]",new Pe(1,xb)],["[:^graph:]",new Pe(-1,xb)],["[:lower:]",new Pe(1,wb)],["[:^lower:]",new Pe(-1,wb)],["[:print:]",new Pe(1,Db)],["[:^print:]",new Pe(-1,Db)],["[:punct:]",new Pe(1,Tb)],["[:^punct:]",new Pe(-1,Tb)],["[:space:]",new Pe(1,Ab)],["[:^space:]",new Pe(-1,Ab)],["[:upper:]",new Pe(1,Ib)],["[:^upper:]",new Pe(-1,Ib)],["[:word:]",new Pe(1,kb)],["[:^word:]",new Pe(-1,kb)],["[:xdigit:]",new Pe(1,Rb)],["[:^xdigit:]",new Pe(-1,Rb)]]),ii=class ju{static charClassToString(t,n){let r="[";for(let s=0;s<n;s+=2){s>0&&(r+=" ");const i=t[s],o=t[s+1];i===o?r+=`0x${i.toString(16)}`:r+=`0x${i.toString(16)}-0x${o.toString(16)}`}return r+="]",r}static sortRanges(t,n){const r=n>>1,s=new Array(r);for(let o=0;o<r;o++)s[o]=o;s.sort((o,a)=>t[2*o]-t[2*a]||t[2*a+1]-t[2*o+1]);const i=t.slice(0,n);for(let o=0;o<r;o++)t[2*o]=i[2*s[o]],t[2*o+1]=i[2*s[o]+1]}constructor(t=me.emptyInts()){this.r=t,this.len=t.length}toArray(){return this.r instanceof Int32Array?this.len===this.r.length?this.r:this.r.subarray(0,this.len):new Int32Array(this.len===this.r.length?this.r:this.r.slice(0,this.len))}toGrowableArray(){return Array.isArray(this.r)?(this.r.length=this.len,this.r):Array.from(this.r.subarray(0,this.len))}cleanClass(){if(this.len<4)return this;ju.sortRanges(this.r,this.len);let t=2;for(let n=2;n<this.len;n+=2){const r=this.r[n],s=this.r[n+1];if(r<=this.r[t-1]+1){s>this.r[t-1]&&(this.r[t-1]=s);continue}this.r[t]=r,this.r[t+1]=s,t+=2}return this.len=t,this}appendLiteral(t,n){return(n&$.FOLD_CASE)!==0?this.appendFoldedRange(t,t):this.appendRange(t,t)}appendRange(t,n){if(this.len>0){for(let r=2;r<=4;r+=2)if(this.len>=r){const s=this.r[this.len-r],i=this.r[this.len-r+1];if(t<=i+1&&s<=n+1)return t<s&&(this.r[this.len-r]=t),n>i&&(this.r[this.len-r+1]=n),this}}return this.r[this.len++]=t,this.r[this.len++]=n,this}appendFoldedRange(t,n){if(t<=ce.MIN_FOLD&&n>=ce.MAX_FOLD)return this.appendRange(t,n);if(n<ce.MIN_FOLD||t>ce.MAX_FOLD)return this.appendRange(t,n);t<ce.MIN_FOLD&&(this.appendRange(t,ce.MIN_FOLD-1),t=ce.MIN_FOLD),n>ce.MAX_FOLD&&(this.appendRange(ce.MAX_FOLD+1,n),n=ce.MAX_FOLD);for(let r=t;r<=n;r++){this.appendRange(r,r);for(let s=ce.simpleFold(r);s!==r;s=ce.simpleFold(s))this.appendRange(s,s)}return this}appendClass(t){for(let n=0;n<t.length;n+=2)this.appendRange(t[n],t[n+1]);return this}appendFoldedClass(t){for(let n=0;n<t.length;n+=2)this.appendFoldedRange(t[n],t[n+1]);return this}appendNegatedClass(t){let n=0;for(let r=0;r<t.length;r+=2){const s=t[r],i=t[r+1];n<=s-1&&this.appendRange(n,s-1),n=i+1}return n<=ce.MAX_RUNE&&this.appendRange(n,ce.MAX_RUNE),this}appendTable(t){for(let n=0;n<t.length;++n){const r=t.getLo(n),s=t.getHi(n),i=t.getStride(n);if(i===1){this.appendRange(r,s);continue}for(let o=r;o<=s;o+=i)this.appendRange(o,o)}return this}appendNegatedTable(t){let n=0;for(let r=0;r<t.length;++r){const s=t.getLo(r),i=t.getHi(r),o=t.getStride(r);if(o===1){n<=s-1&&this.appendRange(n,s-1),n=i+1;continue}for(let a=s;a<=i;a+=o)n<=a-1&&this.appendRange(n,a-1),n=a+1}return n<=ce.MAX_RUNE&&this.appendRange(n,ce.MAX_RUNE),this}appendTableWithSign(t,n){return n<0?this.appendNegatedTable(t):this.appendTable(t)}negateClass(){let t=0,n=0;for(let r=0;r<this.len;r+=2){const s=this.r[r],i=this.r[r+1];t<=s-1&&(this.r[n]=t,this.r[n+1]=s-1,n+=2),t=i+1}return this.len=n,t<=ce.MAX_RUNE&&(this.r[this.len++]=t,this.r[this.len++]=ce.MAX_RUNE),this}appendClassWithSign(t,n){return n<0?this.appendNegatedClass(t):this.appendClass(t)}appendGroup(t,n){let r=t.cls;return n&&(r=new ju().appendFoldedClass(r).cleanClass().toArray()),this.appendClassWithSign(r,t.sign)}toString(){return ju.charClassToString(this.r,this.len)}},G4=class{constructor(e){this.str=e,this.position=0}pos(){return this.position}rewindTo(e){this.position=e}more(){return this.position<this.str.length}peek(){return this.str.codePointAt(this.position)}skip(e){this.position+=e}skipString(e){this.position+=e.length}pop(){const e=this.str.codePointAt(this.position);return this.position+=me.charCount(e),e}lookingAt(e){return this.str.startsWith(e,this.position)}rest(){return this.str.substring(this.position)}from(e){return this.str.substring(e,this.position)}toString(){return this.rest()}},Oa=class pe{static ERR_INTERNAL_ERROR="regexp/syntax: internal error";static ERR_INVALID_CHAR_RANGE="invalid character class range";static ERR_INVALID_ESCAPE="invalid escape sequence";static ERR_INVALID_NAMED_CAPTURE="invalid named capture";static ERR_INVALID_PERL_OP="invalid or unsupported Perl syntax";static ERR_INVALID_REPEAT_OP="invalid nested repetition operator";static ERR_INVALID_REPEAT_SIZE="invalid repeat count";static ERR_MISSING_BRACKET="missing closing ]";static ERR_MISSING_PAREN="missing closing )";static ERR_MISSING_REPEAT_ARGUMENT="missing argument to repetition operator";static ERR_TRAILING_BACKSLASH="trailing backslash at end of expression";static ERR_DUPLICATE_NAMED_CAPTURE="duplicate capture group name";static ERR_UNEXPECTED_PAREN="unexpected )";static ERR_NESTING_DEPTH="expression nests too deeply";static ERR_LARGE="expression too large";static ERR_INVALID_CAPTURE_IN_LOOKBEHIND="invalid capture in lookbehind";static MAX_HEIGHT=1e3;static MAX_SIZE=1398101;static MAX_RUNES=33554432;static ANY_TABLE=new T(new Uint32Array([0,ce.MAX_RUNE,1]));static ASCII_TABLE=new T(new Uint32Array([0,127,1]));static ASCII_FOLD_TABLE=new T(new Uint32Array([0,127,1,383,383,1,8490,8490,1]));static unicodeTable(t){return t==="Any"?{tab:pe.ANY_TABLE,fold:pe.ANY_TABLE,sign:1}:t==="Ascii"?{tab:pe.ASCII_TABLE,fold:pe.ASCII_FOLD_TABLE,sign:1}:t==="Assigned"?{tab:an.CATEGORIES.get("Cn"),fold:an.CATEGORIES.get("Cn"),sign:-1}:t==="Lc"?{tab:an.CATEGORIES.get("LC"),fold:an.FOLD_CATEGORIES.get("LC"),sign:1}:an.CATEGORIES.has(t)?{tab:an.CATEGORIES.get(t),fold:an.FOLD_CATEGORIES.get(t),sign:1}:an.SCRIPTS.has(t)?{tab:an.SCRIPTS.get(t),fold:an.FOLD_SCRIPT.get(t),sign:1}:null}static minFoldRune(t){if(t<ce.MIN_FOLD||t>ce.MAX_FOLD)return t;let n=t;const r=t;for(t=ce.simpleFold(t);t!==r;t=ce.simpleFold(t))n>t&&(n=t);return n}static leadingRegexp(t){if(t.op===k.Op.EMPTY_MATCH)return null;if(t.op===k.Op.CONCAT&&t.subs.length>0){const n=t.subs[0];return n.op===k.Op.EMPTY_MATCH?null:n}return t}static literalRegexp(t,n){const r=new k(k.Op.LITERAL);return r.flags=n,r.runes=me.stringToRunes(t),r}static parse(t,n){return new pe(t,n).parseInternal()}static parseRepeat(t){const n=t.pos();if(!t.more()||!t.lookingAt("{"))return-1;t.skip(1);const r=pe.parseInt(t);if(r===-1||!t.more())return-1;let s;if(!t.lookingAt(","))s=r;else{if(t.skip(1),!t.more())return-1;if(t.lookingAt("}"))s=-1;else if((s=pe.parseInt(t))===-1)return-1}if(!t.more()||!t.lookingAt("}"))return-1;if(t.skip(1),r<0||r>1e3||s===-2||s>1e3||s>=0&&r>s)throw new Ke(pe.ERR_INVALID_REPEAT_SIZE,t.from(n));return r<<16|s&ce.MAX_BMP}static isValidCaptureName(t){if(t.length===0)return!1;for(let n=0;n<t.length;n++){const r=t.codePointAt(n);if(r!==V.CODES.get("_")&&!me.isalnum(r))return!1}return!0}static parseInt(t){const n=t.pos();for(;t.more()&&t.peek()>=V.CODES.get("0")&&t.peek()<=V.CODES.get("9");)t.skip(1);const r=t.from(n);return r.length===0||r.length>1&&r.codePointAt(0)===V.CODES.get("0")?-1:r.length>8?-2:parseInt(r,10)}static isCharClass(t){return t.op===k.Op.LITERAL&&t.runes.length===1||t.op===k.Op.CHAR_CLASS||t.op===k.Op.ANY_CHAR_NOT_NL||t.op===k.Op.ANY_CHAR}static matchRune(t,n){switch(t.op){case k.Op.LITERAL:return t.runes.length===1&&t.runes[0]===n;case k.Op.CHAR_CLASS:for(let r=0;r<t.runes.length;r+=2)if(t.runes[r]<=n&&n<=t.runes[r+1])return!0;return!1;case k.Op.ANY_CHAR_NOT_NL:return n!==V.CODES.get(`
53
+ `);case k.Op.ANY_CHAR:return!0}return!1}static mergeCharClass(t,n){switch(t.op){case k.Op.ANY_CHAR:break;case k.Op.ANY_CHAR_NOT_NL:pe.matchRune(n,V.CODES.get(`
54
+ `))&&(t.op=k.Op.ANY_CHAR);break;case k.Op.CHAR_CLASS:{const r=new ii(Array.isArray(t.runes)?t.runes:Array.from(t.runes));n.op===k.Op.LITERAL?r.appendLiteral(n.runes[0],n.flags):r.appendClass(n.runes),t.runes=r.toGrowableArray();break}case k.Op.LITERAL:if(n.runes[0]===t.runes[0]&&n.flags===t.flags)break;t.op=k.Op.CHAR_CLASS,t.runes=new ii().appendLiteral(t.runes[0],t.flags).appendLiteral(n.runes[0],n.flags).toGrowableArray()}}static parseEscape(t){const n=t.pos();if(t.skip(1),!t.more())throw new Ke(pe.ERR_TRAILING_BACKSLASH);let r=t.pop();e:switch(r){case V.CODES.get("1"):case V.CODES.get("2"):case V.CODES.get("3"):case V.CODES.get("4"):case V.CODES.get("5"):case V.CODES.get("6"):case V.CODES.get("7"):if(!t.more()||t.peek()<V.CODES.get("0")||t.peek()>V.CODES.get("7"))break;case V.CODES.get("0"):{let s=r-V.CODES.get("0");for(let i=1;i<3&&!(!t.more()||t.peek()<V.CODES.get("0")||t.peek()>V.CODES.get("7"));i++)s=s*8+t.peek()-V.CODES.get("0"),t.skip(1);return s}case V.CODES.get("x"):{if(!t.more())break;if(r=t.pop(),r===V.CODES.get("{")){let o=0,a=0;for(;;){if(!t.more())break e;if(r=t.pop(),r===V.CODES.get("}"))break;const l=me.unhex(r);if(l<0||(a=a*16+l,a>ce.MAX_RUNE))break e;o++}if(o===0)break e;return a}const s=me.unhex(r);if(!t.more())break;r=t.pop();const i=me.unhex(r);if(s<0||i<0)break;return s*16+i}case V.CODES.get("a"):return V.CODES.get("\x07");case V.CODES.get("f"):return V.CODES.get("\f");case V.CODES.get("n"):return V.CODES.get(`
55
+ `);case V.CODES.get("r"):return V.CODES.get("\r");case V.CODES.get("t"):return V.CODES.get(" ");case V.CODES.get("v"):return V.CODES.get("\v");default:if(r<=ce.MAX_ASCII&&!me.isalnum(r))return r}throw new Ke(pe.ERR_INVALID_ESCAPE,t.from(n))}static parseClassChar(t,n){if(!t.more())throw new Ke(pe.ERR_MISSING_BRACKET,t.from(n));return t.lookingAt("\\")?pe.parseEscape(t):t.pop()}static hasCapture(t){if(t===null)return!1;if(t.op===k.Op.CAPTURE)return!0;if(t.subs){for(let n of t.subs)if(pe.hasCapture(n))return!0}return!1}constructor(t,n=0){this.wholeRegexp=t,this.flags=n,this.numCap=0,this.namedGroups=Object.create(null),this.stack=[],this.free=null,this.numRegexp=0,this.numRunes=0,this.repeats=0,this.height=null,this.size=null,this.nlb=0}newRegexp(t){let n=this.free;return n!==null&&n.subs!==null&&n.subs.length>0?(this.free=n.subs[0],n.reinit(),n.op=t):(n=new k(t),this.numRegexp+=1),n}reuse(t){this.height!==null&&this.height.has(t)&&this.height.delete(t),t.subs!==null&&t.subs.length>0&&(t.subs[0]=this.free),this.free=t}checkLimits(t){if(this.numRunes>pe.MAX_RUNES)throw new Ke(pe.ERR_LARGE);this.checkSize(t),this.checkHeight(t)}checkSize(t){if(this.size===null){if(this.repeats===0&&(this.repeats=1),t.op===k.Op.REPEAT){let n=t.max;n===-1&&(n=t.min),n<=0&&(n=1),n>Math.floor(pe.MAX_SIZE/this.repeats)?this.repeats=pe.MAX_SIZE:this.repeats*=n}if(this.numRegexp<Math.floor(pe.MAX_SIZE/this.repeats))return;this.size=new Map;for(let n of this.stack)this.checkSize(n)}if(this.calcSize(t,!0)>pe.MAX_SIZE)throw new Ke(pe.ERR_LARGE)}calcSize(t,n=!1){if(!n&&this.size!==null&&this.size.has(t))return this.size.get(t);let r=0;switch(t.op){case k.Op.LITERAL:r=t.runes.length;break;case k.Op.PLB:case k.Op.NLB:case k.Op.CAPTURE:case k.Op.STAR:r=2+this.calcSize(t.subs[0]);break;case k.Op.PLUS:case k.Op.QUEST:r=1+this.calcSize(t.subs[0]);break;case k.Op.CONCAT:for(let s of t.subs)r=r+this.calcSize(s);break;case k.Op.ALTERNATE:for(let s of t.subs)r=r+this.calcSize(s);t.subs.length>1&&(r=r+t.subs.length-1);break;case k.Op.REPEAT:{let s=this.calcSize(t.subs[0]);if(t.max===-1){t.min===0?r=2+s:r=1+t.min*s;break}r=t.max*s+(t.max-t.min);break}}return r=Math.max(1,r),this.size===null&&(this.size=new Map),this.size.set(t,r),r}checkHeight(t){if(!(this.numRegexp<pe.MAX_HEIGHT)){if(this.height===null){this.height=new Map;for(let n of this.stack)this.checkHeight(n)}if(this.calcHeight(t,!0)>pe.MAX_HEIGHT)throw new Ke(pe.ERR_NESTING_DEPTH)}}calcHeight(t,n=!1){if(!n&&this.height!==null&&this.height.has(t))return this.height.get(t);let r=1;for(let s of t.subs){const i=this.calcHeight(s);r<1+i&&(r=1+i)}return this.height===null&&(this.height=new Map),this.height.set(t,r),r}pop(){return this.stack.pop()}popToPseudo(){const t=this.stack.length;let n=t;for(;n>0&&!k.isPseudoOp(this.stack[n-1].op);)n--;return this.stack.splice(n,t-n)}push(t){if(this.numRunes+=t.runes.length,t.op===k.Op.CHAR_CLASS&&t.runes.length===2&&t.runes[0]===t.runes[1]){if(this.maybeConcat(t.runes[0],this.flags&~$.FOLD_CASE))return null;t.op=k.Op.LITERAL,t.runes=[t.runes[0]],t.flags=this.flags&~$.FOLD_CASE}else if(t.op===k.Op.CHAR_CLASS&&t.runes.length===4&&t.runes[0]===t.runes[1]&&t.runes[2]===t.runes[3]&&ce.simpleFold(t.runes[0])===t.runes[2]&&ce.simpleFold(t.runes[2])===t.runes[0]||t.op===k.Op.CHAR_CLASS&&t.runes.length===2&&t.runes[0]+1===t.runes[1]&&ce.simpleFold(t.runes[0])===t.runes[1]&&ce.simpleFold(t.runes[1])===t.runes[0]){if(this.maybeConcat(t.runes[0],this.flags|$.FOLD_CASE))return null;t.op=k.Op.LITERAL,t.runes=[t.runes[0]],t.flags=this.flags|$.FOLD_CASE}else this.maybeConcat(-1,0);return this.stack.push(t),this.checkLimits(t),t}maybeConcat(t,n){const r=this.stack.length;if(r<2)return!1;const s=this.stack[r-1],i=this.stack[r-2];if(s.op!==k.Op.LITERAL||i.op!==k.Op.LITERAL||(s.flags&$.FOLD_CASE)!==(i.flags&$.FOLD_CASE))return!1;Array.isArray(i.runes)||(i.runes=Array.from(i.runes));for(let o=0;o<s.runes.length;o++)i.runes.push(s.runes[o]);return t>=0?(s.runes=[t],s.flags=n,!0):(this.pop(),this.reuse(s),!1)}newLiteral(t,n){const r=this.newRegexp(k.Op.LITERAL);return r.flags=n,(n&$.FOLD_CASE)!==0&&(t=pe.minFoldRune(t)),r.runes=[t],r}literal(t){this.push(this.newLiteral(t,this.flags))}op(t){const n=this.newRegexp(t);return n.flags=this.flags,this.push(n)}repeat(t,n,r,s,i,o){let a=this.flags;if((a&$.PERL_X)!==0&&(i.more()&&i.lookingAt("?")&&(i.skip(1),a^=$.NON_GREEDY),o!==-1))throw new Ke(pe.ERR_INVALID_REPEAT_OP,i.from(o));const l=this.stack.length;if(l===0)throw new Ke(pe.ERR_MISSING_REPEAT_ARGUMENT,i.from(s));const c=this.stack[l-1];if(k.isPseudoOp(c.op))throw new Ke(pe.ERR_MISSING_REPEAT_ARGUMENT,i.from(s));const u=this.newRegexp(t);if(u.min=n,u.max=r,u.flags=a,u.subs=[c],this.stack[l-1]=u,this.checkLimits(u),t===k.Op.REPEAT&&(n>=2||r>=2)&&!this.repeatIsValid(u,1e3))throw new Ke(pe.ERR_INVALID_REPEAT_SIZE,i.from(s))}repeatIsValid(t,n){if(t.op===k.Op.REPEAT){let r=t.max;if(r===0)return!0;if(r<0&&(r=t.min),r>n)return!1;r>0&&(n=Math.trunc(n/r))}for(let r of t.subs)if(!this.repeatIsValid(r,n))return!1;return!0}concat(){this.maybeConcat(-1,0);const t=this.popToPseudo();return t.length===0?this.push(this.newRegexp(k.Op.EMPTY_MATCH)):this.push(this.collapse(t,k.Op.CONCAT))}alternate(){const t=this.popToPseudo();return t.length>0&&this.cleanAlt(t[t.length-1]),t.length===0?this.push(this.newRegexp(k.Op.NO_MATCH)):this.push(this.collapse(t,k.Op.ALTERNATE))}cleanAlt(t){t.op===k.Op.CHAR_CLASS&&(t.runes=new ii(Array.from(t.runes)).cleanClass().toArray(),t.runes.length===2&&t.runes[0]===0&&t.runes[1]===ce.MAX_RUNE?(t.runes=new Int32Array(0),t.op=k.Op.ANY_CHAR):t.runes.length===4&&t.runes[0]===0&&t.runes[1]===V.CODES.get(`
56
+ `)-1&&t.runes[2]===V.CODES.get(`
57
+ `)+1&&t.runes[3]===ce.MAX_RUNE&&(t.runes=new Int32Array(0),t.op=k.Op.ANY_CHAR_NOT_NL))}collapse(t,n){if(t.length===1)return t[0];let r=0;for(let a of t)r+=a.op===n?a.subs.length:1;let s=new Array(r).fill(null),i=0;for(let a of t)if(a.op===n){for(let l=0;l<a.subs.length;l++)s[i++]=a.subs[l];this.reuse(a)}else s[i++]=a;let o=this.newRegexp(n);if(o.subs=s,n===k.Op.ALTERNATE&&(o.subs=this.factor(o.subs),o.subs.length===1)){const a=o;o=o.subs[0],this.reuse(a)}return o}factor(t){if(t.length<2)return t;let n=0,r=t.length,s=0,i=null,o=0,a=0,l=0;for(let u=0;u<=r;u++){let d=null,h=0,f=0;if(u<r){let B=t[n+u];if(B.op===k.Op.CONCAT&&B.subs.length>0&&(B=B.subs[0]),B.op===k.Op.LITERAL&&(d=B.runes,h=B.runes.length,f=B.flags&$.FOLD_CASE),f===a){let g=0;for(;g<o&&g<h&&i[g]===d[g];)g++;if(g>0){o=g;continue}}}if(u!==l)if(u===l+1)t[s++]=t[n+l];else{const B=this.newRegexp(k.Op.LITERAL);B.flags=a,B.runes=i.slice(0,o);for(let v=l;v<u;v++)t[n+v]=this.removeLeadingString(t[n+v],o),this.checkLimits(t[n+v]);const g=this.collapse(t.slice(n+l,n+u),k.Op.ALTERNATE),C=this.newRegexp(k.Op.CONCAT);C.subs=[B,g],t[s++]=C}l=u,i=d,o=h,a=f}r=s,n=0,l=0,s=0;let c=null;for(let u=0;u<=r;u++){let d=null;if(!(u<r&&(d=pe.leadingRegexp(t[n+u]),c!==null&&c.equals(d)&&(pe.isCharClass(c)||c.op===k.Op.REPEAT&&c.min===c.max&&pe.isCharClass(c.subs[0]))))){if(u!==l)if(u===l+1)t[s++]=t[n+l];else{const h=c;for(let g=l;g<u;g++){const C=g!==l;t[n+g]=this.removeLeadingRegexp(t[n+g],C),this.checkLimits(t[n+g])}const f=this.collapse(t.slice(n+l,n+u),k.Op.ALTERNATE),B=this.newRegexp(k.Op.CONCAT);B.subs=[h,f],t[s++]=B}l=u,c=d}}r=s,n=0,l=0,s=0;for(let u=0;u<=r;u++)if(!(u<r&&pe.isCharClass(t[n+u]))){if(u!==l)if(u===l+1)t[s++]=t[n+l];else{let d=l;for(let f=l+1;f<u;f++){const B=t[n+d],g=t[n+f];(B.op<g.op||B.op===g.op&&(B.runes!==null?B.runes.length:0)<(g.runes!==null?g.runes.length:0))&&(d=f)}const h=t[n+l];t[n+l]=t[n+d],t[n+d]=h;for(let f=l+1;f<u;f++)pe.mergeCharClass(t[n+l],t[n+f]),this.reuse(t[n+f]);this.cleanAlt(t[n+l]),t[s++]=t[n+l]}u<r&&(t[s++]=t[n+u]),l=u+1}r=s,n=0,l=0,s=0;for(let u=0;u<r;++u)u+1<r&&t[n+u].op===k.Op.EMPTY_MATCH&&t[n+u+1].op===k.Op.EMPTY_MATCH||(t[s++]=t[n+u]);return r=s,n=0,t.slice(n,r)}removeLeadingString(t,n){if(t.op===k.Op.CONCAT&&t.subs.length>0){const r=this.removeLeadingString(t.subs[0],n);if(t.subs[0]=r,r.op===k.Op.EMPTY_MATCH)switch(this.reuse(r),t.subs.length){case 0:case 1:t.op=k.Op.EMPTY_MATCH,t.subs=k.emptySubs();break;case 2:{const s=t;t=t.subs[1],this.reuse(s);break}default:t.subs=t.subs.slice(1,t.subs.length)}return t}return t.op===k.Op.LITERAL&&(t.runes=t.runes.slice(n,t.runes.length),t.runes.length===0&&(t.op=k.Op.EMPTY_MATCH)),t}removeLeadingRegexp(t,n){if(t.op===k.Op.CONCAT&&t.subs.length>0){switch(n&&this.reuse(t.subs[0]),t.subs=t.subs.slice(1,t.subs.length),t.subs.length){case 0:t.op=k.Op.EMPTY_MATCH,t.subs=k.emptySubs();break;case 1:{const r=t;t=t.subs[0],this.reuse(r);break}}return t}return n&&this.reuse(t),this.newRegexp(k.Op.EMPTY_MATCH)}parseInternal(){if((this.flags&$.LITERAL)!==0)return pe.literalRegexp(this.wholeRegexp,this.flags);let t=-1,n=-1,r=-1;const s=new G4(this.wholeRegexp);for(;s.more();){let i=-1;e:switch(s.peek()){case V.CODES.get("("):if((this.flags&$.LOOKBEHIND)!==0){if(s.lookingAt("(?<=")){this.parsePosLookBehind(),s.skip(4);break}if(s.lookingAt("(?<!")){this.parseNegLookBehind(),s.skip(4);break}}if((this.flags&$.PERL_X)!==0&&s.lookingAt("(?")){this.parsePerlFlags(s);break}this.op(k.Op.LEFT_PAREN).cap=++this.numCap,s.skip(1);break;case V.CODES.get("|"):this.parseVerticalBar(),s.skip(1);break;case V.CODES.get(")"):this.parseRightParen(),s.skip(1);break;case V.CODES.get("^"):(this.flags&$.ONE_LINE)!==0?this.op(k.Op.BEGIN_TEXT):this.op(k.Op.BEGIN_LINE),s.skip(1);break;case V.CODES.get("$"):(this.flags&$.ONE_LINE)!==0?this.op(k.Op.END_TEXT).flags|=$.WAS_DOLLAR:this.op(k.Op.END_LINE),s.skip(1);break;case V.CODES.get("."):(this.flags&$.DOT_NL)!==0?this.op(k.Op.ANY_CHAR):this.op(k.Op.ANY_CHAR_NOT_NL),s.skip(1);break;case V.CODES.get("["):this.parseClass(s);break;case V.CODES.get("*"):case V.CODES.get("+"):case V.CODES.get("?"):{i=s.pos();let o=null;switch(s.pop()){case V.CODES.get("*"):o=k.Op.STAR;break;case V.CODES.get("+"):o=k.Op.PLUS;break;case V.CODES.get("?"):o=k.Op.QUEST}this.repeat(o,n,r,i,s,t);break}case V.CODES.get("{"):{i=s.pos();const o=pe.parseRepeat(s);if(o<0){s.rewindTo(i),this.literal(s.pop());break}n=o>>16,r=(o&ce.MAX_BMP)<<16>>16,this.repeat(k.Op.REPEAT,n,r,i,s,t);break}case V.CODES.get("\\"):{const o=s.pos();if(s.skip(1),(this.flags&$.PERL_X)!==0&&s.more())switch(s.pop()){case V.CODES.get("A"):this.op(k.Op.BEGIN_TEXT);break e;case V.CODES.get("b"):this.op(k.Op.WORD_BOUNDARY);break e;case V.CODES.get("B"):this.op(k.Op.NO_WORD_BOUNDARY);break e;case V.CODES.get("C"):throw new Ke(pe.ERR_INVALID_ESCAPE,"\\C");case V.CODES.get("Q"):{let c=s.rest();const u=c.indexOf("\\E");u>=0?(c=c.substring(0,u),s.skipString(c),s.skipString("\\E")):s.skipString(c);let d=0;for(;d<c.length;){const h=c.codePointAt(d);this.literal(h),d+=me.charCount(h)}break e}case V.CODES.get("z"):this.op(k.Op.END_TEXT);break e;default:s.rewindTo(o)}else s.rewindTo(o);const a=this.newRegexp(k.Op.CHAR_CLASS);if(a.flags=this.flags,s.lookingAt("\\p")||s.lookingAt("\\P")){const c=new ii;if(this.parseUnicodeClass(s,c)){a.runes=c.toArray(),this.push(a);break e}}const l=new ii;if(this.parsePerlClassEscape(s,l)){a.runes=l.toArray(),this.push(a);break e}s.rewindTo(o),this.reuse(a),this.literal(pe.parseEscape(s));break}default:this.literal(s.pop())}t=i}if(this.concat(),this.swapVerticalBar()&&this.pop(),this.alternate(),this.stack.length!==1)throw new Ke(pe.ERR_MISSING_PAREN,this.wholeRegexp);return this.stack[0].namedGroups=this.namedGroups,this.stack[0]}parsePerlFlags(t){const n=t.pos(),r=t.rest();if(r.startsWith("(?P<")||r.startsWith("(?<")){const a=r.charAt(2)==="P"?4:3,l=r.indexOf(">");if(l<0)throw new Ke(pe.ERR_INVALID_NAMED_CAPTURE,r);const c=r.substring(a,l);if(t.skipString(c),t.skip(a+1),!pe.isValidCaptureName(c))throw new Ke(pe.ERR_INVALID_NAMED_CAPTURE,r.substring(0,l+1));const u=this.op(k.Op.LEFT_PAREN);if(u.cap=++this.numCap,this.namedGroups[c])throw new Ke(pe.ERR_DUPLICATE_NAMED_CAPTURE,c);this.namedGroups[c]=this.numCap,u.name=c;return}t.skip(2);let s=this.flags,i=1,o=!1;e:for(;t.more();){const a=t.pop();switch(a){case V.CODES.get("i"):s|=$.FOLD_CASE,o=!0;break;case V.CODES.get("m"):s&=~$.ONE_LINE,o=!0;break;case V.CODES.get("s"):s|=$.DOT_NL,o=!0;break;case V.CODES.get("U"):s|=$.NON_GREEDY,o=!0;break;case V.CODES.get("-"):if(i<0)break e;i=-1,s=~s,o=!1;break;case V.CODES.get(":"):case V.CODES.get(")"):if(i<0){if(!o)break e;s=~s}a===V.CODES.get(":")&&this.op(k.Op.LEFT_PAREN),this.flags=s;return;default:break e}}throw new Ke(pe.ERR_INVALID_PERL_OP,t.from(n))}parsePosLookBehind(){const t=this.newRegexp(k.Op.LEFT_PAREN);return t.flags=this.flags,t.lb=++this.nlb,this.push(t)}parseNegLookBehind(){const t=this.newRegexp(k.Op.LEFT_PAREN);return t.flags=this.flags,t.lb=-++this.nlb,this.push(t)}parseVerticalBar(){this.concat(),this.swapVerticalBar()||this.op(k.Op.VERTICAL_BAR)}swapVerticalBar(){const t=this.stack.length;if(t>=3&&this.stack[t-2].op===k.Op.VERTICAL_BAR&&pe.isCharClass(this.stack[t-1])&&pe.isCharClass(this.stack[t-3])){let n=this.stack[t-1],r=this.stack[t-3];if(n.op>r.op){const s=r;r=n,n=s,this.stack[t-3]=r}return pe.mergeCharClass(r,n),this.reuse(n),this.pop(),!0}if(t>=2){const n=this.stack[t-1],r=this.stack[t-2];if(r.op===k.Op.VERTICAL_BAR)return t>=3&&this.cleanAlt(this.stack[t-3]),this.stack[t-2]=n,this.stack[t-1]=r,!0}return!1}parseRightParen(){if(this.concat(),this.swapVerticalBar()&&this.pop(),this.alternate(),this.stack.length<2)throw new Ke(pe.ERR_UNEXPECTED_PAREN,this.wholeRegexp);const t=this.pop(),n=this.pop();if(n.op!==k.Op.LEFT_PAREN)throw new Ke(pe.ERR_UNEXPECTED_PAREN,this.wholeRegexp);if(this.flags=n.flags,n.lb!==0){if(pe.hasCapture(t))throw new Ke(pe.ERR_INVALID_CAPTURE_IN_LOOKBEHIND,this.wholeRegexp);n.lb>0?n.op=k.Op.PLB:n.op=k.Op.NLB,n.subs=[t],this.push(n);return}n.cap===0?this.push(t):(n.op=k.Op.CAPTURE,n.subs=[t],this.push(n))}parsePerlClassEscape(t,n){const r=t.pos();if((this.flags&$.PERL_X)===0||!t.more()||t.pop()!==V.CODES.get("\\")||!t.more())return!1;t.pop();const s=t.from(r),i=gb.has(s)?gb.get(s):null;return i===null?!1:(n.appendGroup(i,(this.flags&$.FOLD_CASE)!==0),!0)}parseNamedClass(t,n){const r=t.rest(),s=r.indexOf(":]");if(s<0)return!1;const i=r.substring(0,s+2);t.skipString(i);const o=Ob.has(i)?Ob.get(i):null;if(o===null)throw new Ke(pe.ERR_INVALID_CHAR_RANGE,i);return n.appendGroup(o,(this.flags&$.FOLD_CASE)!==0),!0}parseUnicodeClass(t,n){const r=t.pos();if((this.flags&$.UNICODE_GROUPS)===0||!t.lookingAt("\\p")&&!t.lookingAt("\\P"))return!1;t.skip(1);let s=1,i=t.pop();if(i===V.CODES.get("P")&&(s=-1),!t.more())throw t.rewindTo(r),new Ke(pe.ERR_INVALID_CHAR_RANGE,t.rest());i=t.pop();let o;if(i!==V.CODES.get("{"))o=me.runeToString(i);else{const u=t.rest(),d=u.indexOf("}");if(d<0)throw t.rewindTo(r),new Ke(pe.ERR_INVALID_CHAR_RANGE,t.rest());o=u.substring(0,d),t.skipString(o),t.skip(1)}o.length!==0&&o.codePointAt(0)===V.CODES.get("^")&&(s=0-s,o=o.substring(1));const a=pe.unicodeTable(o);if(a===null)throw new Ke(pe.ERR_INVALID_CHAR_RANGE,t.from(r));a.sign<0&&(s=0-s);const l=a.tab,c=a.fold;if((this.flags&$.FOLD_CASE)===0||c===null)n.appendTableWithSign(l,s);else{const u=new ii().appendTable(l).appendTable(c).cleanClass().toArray();n.appendClassWithSign(Array.from(u),s)}return!0}parseClass(t){const n=t.pos();t.skip(1);const r=this.newRegexp(k.Op.CHAR_CLASS);r.flags=this.flags;const s=new ii;let i=1;t.more()&&t.lookingAt("^")&&(i=-1,t.skip(1),(this.flags&$.CLASS_NL)===0&&s.appendRange(V.CODES.get(`
58
+ `),V.CODES.get(`
59
+ `)));let o=!0;for(;!t.more()||t.peek()!==V.CODES.get("]")||o;){if(t.more()&&t.lookingAt("-")&&(this.flags&$.PERL_X)===0&&!o){const u=t.rest();if(u==="-"||!u.startsWith("-]"))throw t.rewindTo(n),new Ke(pe.ERR_INVALID_CHAR_RANGE,t.rest())}o=!1;const a=t.pos();if(t.lookingAt("[:")){if(this.parseNamedClass(t,s))continue;t.rewindTo(a)}if(this.parseUnicodeClass(t,s)||this.parsePerlClassEscape(t,s))continue;t.rewindTo(a);const l=pe.parseClassChar(t,n);let c=l;if(t.more()&&t.lookingAt("-")){if(t.skip(1),t.more()&&t.lookingAt("]"))t.skip(-1);else if(c=pe.parseClassChar(t,n),c<l)throw new Ke(pe.ERR_INVALID_CHAR_RANGE,t.from(a))}(this.flags&$.FOLD_CASE)===0?s.appendRange(l,c):s.appendFoldedRange(l,c)}t.skip(1),s.cleanClass(),i<0&&s.negateClass(),r.runes=s.toArray(),this.push(r)}},V4=class Bi{static initTest(t){const n=Bi.compile(t),r=new Bi(n.expr,n.prog,n.numSubexp,n.longest);return r.cond=n.cond,r.prefix=n.prefix,r.prefixUTF8=n.prefixUTF8,r.prefixComplete=n.prefixComplete,r.prefixRune=n.prefixRune,r.prefilter=n.prefilter,r}static compile(t){return Bi.compileImpl(t,$.PERL,!1)}static compilePOSIX(t){return Bi.compileImpl(t,$.POSIX,!0)}static compileImpl(t,n,r){let s=Oa.parse(t,n);const i=s.maxCap();s=IA.simplify(s);const o=F4.build(s),a=AA.compileRegexp(s),l=new Bi(t,a,i,r);l.prefilter=o.type===De.Type.NONE?null:o;const[c,u]=a.prefix();return l.prefixComplete=c,l.prefix=u,l.prefixUTF8=me.stringToUtf8ByteArray(l.prefix),l.prefix.length>0&&(l.prefixRune=l.prefix.codePointAt(0)),l.namedGroups=s.namedGroups,l}static match(t,n){return Bi.compile(t).match(n)}constructor(t,n,r=0,s=0){this.expr=t,this.prog=n,this.numSubexp=r,this.longest=s,this.cond=n.startCond(),this.prefix=null,this.prefixUTF8=null,this.prefixComplete=!1,this.prefixRune=0,this.machinePool=[],this.dfa=new wA(this.prog),this.onepass=db.compile(this.prog),this.prefilter=null}matchPrefixComplete(t,n,r,s){if((r===$.ANCHOR_START||r===$.ANCHOR_BOTH)&&n!==0)return null;let i=-1,o=-1;const a=t.prefixLength(this);if(r===$.UNANCHORED){const l=t.index(this,n);if(l<0)return null;i=n+l,o=i+a}else if(r===$.ANCHOR_BOTH){if(t.endPos()!==a||t.index(this,0)!==0)return null;i=0,o=a}else if(r===$.ANCHOR_START){if(t.index(this,0)!==0)return null;i=0,o=a}if(i<0)return null;if(s>0){const l=new Int32Array(s).fill(-1);return l[0]=i,l[1]=o,Array.from(l)}return[]}createLookbehindState(){return this.prog.numLb>0?new w4(this.prog):null}executeEngine(t,n,r,s,i=null){if(this.prefixComplete&&(s===0||this.numSubexp===0))return this.matchPrefixComplete(t,n,r,s);if(this.prefilter!==null&&r===$.UNANCHORED&&!this.prefilter.eval(t,n))return null;if(this.onepass!==null)return db.execute(this,t,n,r,s);if(s>0)return this.prog.numLb===0&&t.endPos()<=Wc.maxBitStateLen(this.prog)?Wc.execute(this,t,n,r,s):this.doExecuteNFA(t,n,r,s,i);if(this.prog.numLb===0){const o=this.dfa.match(t,n,r);if(o!==null)return o?[]:null;if(t.endPos()<=Wc.maxBitStateLen(this.prog))return Wc.execute(this,t,n,r,s)}return this.doExecuteNFA(t,n,r,s,i)}numberOfCapturingGroups(){return this.numSubexp}numberOfInstructions(){return this.prog.numInst()}get(){return this.machinePool.length>0?this.machinePool.pop():null}reset(){this.machinePool.length=0}put(t){this.machinePool.push(t)}toString(){return this.expr}doExecuteNFA(t,n,r,s,i=null){let o=this.get();o||(o=EA.fromRE2(this)),o.init(s);const a=o.match(t,n,r,i)?o.submatches():null;return this.put(o),a}match(t){return this.executeEngine($e.fromUTF16(t),0,$.UNANCHORED,0)!==null}matchWithGroup(t,n,r,s,i,o=null){return t instanceof Pi||(me.isByteArray(t)?t=vi.utf8(t):t=vi.utf16(t)),this.matchMachineInput(t,n,r,s,i,o)}matchMachineInput(t,n,r,s,i,o=null){if(n>r)return[!1,null];const a=t.isUTF16Encoding()?$e.fromUTF16(t.asCharSequence(),0,r):$e.fromUTF8(t.asBytes(),0,r),l=this.executeEngine(a,n,s,2*i,o);return l===null?[!1,null]:[!0,l]}matchUTF8(t){return this.executeEngine($e.fromUTF8(t),0,$.UNANCHORED,0)!==null}replaceAll(t,n){return this.replaceAllFunc(t,()=>n,2*t.length+1)}replaceFirst(t,n){return this.replaceAllFunc(t,()=>n,1)}replaceAllFunc(t,n,r){let s=0,i=0,o="";const a=$e.fromUTF16(t),l=this.createLookbehindState();let c=0;for(;i<=t.length;){const u=this.executeEngine(a,i,$.UNANCHORED,2,l);if(u===null||u.length===0)break;o+=t.substring(s,u[0]),(u[1]>s||u[0]===0)&&(o+=n(t.substring(u[0],u[1])),c++),s=u[1];const d=a.step(i)&7;if(i+d>u[1]?i+=d:i+1>u[1]?i++:i=u[1],c>=r)break}return o+=t.substring(s),o}pad(t){if(t===null)return null;let n=(1+this.numSubexp)*2;if(t.length<n){let r=new Array(n).fill(-1);for(let s=0;s<t.length;s++)r[s]=t[s];t=r}return t}allMatches(t,n,r=s=>s){let s=[];const i=t.endPos();n<0&&(n=i+1);let o=0,a=0,l=-1;const c=this.createLookbehindState();for(;a<n&&o<=i;){const u=this.executeEngine(t,o,$.UNANCHORED,this.prog.numCap,c);if(u===null||u.length===0)break;let d=!0;if(u[1]===o){u[0]===l&&(d=!1);const h=t.step(o);h<0?o=i+1:o+=h&7}else o=u[1];l=u[1],d&&(s.push(r(this.pad(u))),a++)}return s}findUTF8(t){const n=this.executeEngine($e.fromUTF8(t),0,$.UNANCHORED,2);return n===null?null:t.slice(n[0],n[1])}findUTF8Index(t){const n=this.executeEngine($e.fromUTF8(t),0,$.UNANCHORED,2);return n===null?null:n.slice(0,2)}find(t){const n=this.executeEngine($e.fromUTF16(t),0,$.UNANCHORED,2);return n===null?"":t.substring(n[0],n[1])}findIndex(t){return this.executeEngine($e.fromUTF16(t),0,$.UNANCHORED,2)}findUTF8Submatch(t){const n=this.executeEngine($e.fromUTF8(t),0,$.UNANCHORED,this.prog.numCap);if(n===null)return null;const r=new Array(1+this.numSubexp).fill(null);for(let s=0;s<r.length;s++)2*s<n.length&&n[2*s]>=0&&(r[s]=t.slice(n[2*s],n[2*s+1]));return r}findUTF8SubmatchIndex(t){return this.pad(this.executeEngine($e.fromUTF8(t),0,$.UNANCHORED,this.prog.numCap))}findSubmatch(t){const n=this.executeEngine($e.fromUTF16(t),0,$.UNANCHORED,this.prog.numCap);if(n===null)return null;const r=new Array(1+this.numSubexp).fill(null);for(let s=0;s<r.length;s++)2*s<n.length&&n[2*s]>=0&&(r[s]=t.substring(n[2*s],n[2*s+1]));return r}findSubmatchIndex(t){return this.pad(this.executeEngine($e.fromUTF16(t),0,$.UNANCHORED,this.prog.numCap))}findAllUTF8(t,n){const r=this.allMatches($e.fromUTF8(t),n,s=>t.slice(s[0],s[1]));return r.length===0?null:r}findAllUTF8Index(t,n){const r=this.allMatches($e.fromUTF8(t),n,s=>s.slice(0,2));return r.length===0?null:r}findAll(t,n){const r=this.allMatches($e.fromUTF16(t),n,s=>t.substring(s[0],s[1]));return r.length===0?null:r}findAllIndex(t,n){const r=this.allMatches($e.fromUTF16(t),n,s=>s.slice(0,2));return r.length===0?null:r}findAllUTF8Submatch(t,n){const r=this.allMatches($e.fromUTF8(t),n,s=>{let i=new Array(s.length/2|0).fill(null);for(let o=0;o<i.length;o++)s[2*o]>=0&&(i[o]=t.slice(s[2*o],s[2*o+1]));return i});return r.length===0?null:r}findAllUTF8SubmatchIndex(t,n){const r=this.allMatches($e.fromUTF8(t),n);return r.length===0?null:r}findAllSubmatch(t,n){const r=this.allMatches($e.fromUTF16(t),n,s=>{let i=new Array(s.length/2|0).fill(null);for(let o=0;o<i.length;o++)s[2*o]>=0&&(i[o]=t.substring(s[2*o],s[2*o+1]));return i});return r.length===0?null:r}findAllSubmatchIndex(t,n){const r=this.allMatches($e.fromUTF16(t),n);return r.length===0?null:r}},Mse=class Gu{static UNANCHORED=$.UNANCHORED;static ANCHOR_START=$.ANCHOR_START;static ANCHOR_BOTH=$.ANCHOR_BOTH;constructor(t=Gu.UNANCHORED,n=0,r=8388608){this.anchor=t,this.jsFlags=n,this.maxMem=r;let s=$.PERL;(n&Qn.DISABLE_UNICODE_GROUPS)!==0&&(s&=~$.UNICODE_GROUPS),(n&Qn.LOOKBEHINDS)!==0&&(s|=$.LOOKBEHIND),this.re2Flags=s,this.regexps=[],this.prog=null,this.dfa=null,this.dummyRe2=null}add(t){if(this.prog)throw new Qa("Cannot add patterns after compile");let n=t;(this.jsFlags&Qn.CASE_INSENSITIVE)!==0&&(n=`(?i)${n}`),(this.jsFlags&Qn.DOTALL)!==0&&(n=`(?s)${n}`),(this.jsFlags&Qn.MULTILINE)!==0&&(n=`(?m)${n}`);const r=Oa.parse(n,this.re2Flags);return this.regexps.push(IA.simplify(r)),this.regexps.length-1}compile(){if(this.prog)return;const t=AA.compileSet(this.regexps);if(t.numInst()>Oa.MAX_SIZE)throw new Qa(`${Oa.ERR_LARGE}: the set compiles to ${t.numInst()} instructions, more than ${Oa.MAX_SIZE}`);this.prog=t,this.dfa=new wA(this.prog,this.maxMem),this.dummyRe2={prog:this.prog,cond:this.prog.startCond(),prefix:"",prefixRune:0,longest:!1}}match(t){this.prog||this.compile();const n=me.isByteArray(t)?$e.fromUTF8(t):$e.fromUTF16(t);let r=$.UNANCHORED;this.anchor===Gu.ANCHOR_START?r=$.ANCHOR_START:this.anchor===Gu.ANCHOR_BOTH&&(r=$.ANCHOR_BOTH);const s=this.dfa.matchSet(n,0,r);if(s!==null)return s;const i=EA.fromRE2(this.dummyRe2);return i.init(0),i.matchSet(n,0,r)}},U4=class ao{static isHexadecimal(t){return"0"<=t&&t<="9"||"A"<=t&&t<="F"||"a"<=t&&t<="f"}static translate(t){let n="";if(t instanceof RegExp&&(t.ignoreCase&&(n+="i"),t.multiline&&(n+="m"),t.dotAll&&(n+="s"),t=t.source),typeof t!="string")return t;let r="",s=!1,i=t.length;i===0&&(r="(?:)",s=!0);let o=!1,a=0;for(;a<i;){let c=t[a];if(c==="\\"){if(a+1<i)switch(c=t[a+1],c){case"\\":r+="\\\\",a+=2;continue;case"c":if(a+2<i){let h=t[a+2].charCodeAt(0);if(h>=65&&h<=90||h>=97&&h<=122){let f=h%32;r+="\\x",r+=(f>>4).toString(16).toUpperCase(),r+=(f&15).toString(16).toUpperCase(),a+=3,s=!0;continue}}r+="c",a+=2,s=!0;continue;case"u":if(a+2<i){if(t[a+2]==="{"){let h=a+3,f=!1,B=!1;for(;h<i;){const g=t[h];if(g==="}"){B=!0;break}if(!ao.isHexadecimal(g))break;f=!0,h++}if(B&&f){r+="\\x",a+=2,s=!0;continue}}else if(a+5<i){let h=!0;for(let f=0;f<4;f++)if(!ao.isHexadecimal(t[a+2+f])){h=!1;break}if(h){r+="\\x{"+t.substring(a+2,a+6)+"}",a+=6,s=!0;continue}}}r+="u",a+=2,s=!0;continue;case"x":{let h=!1;if(a+2<i&&t[a+2]==="{"){let f=a+3,B=!1,g=!1;for(;f<i;){const C=t[f];if(C==="}"){g=!0;break}if(!ao.isHexadecimal(C))break;B=!0,f++}g&&B&&(h=!0)}else a+3<i&&ao.isHexadecimal(t[a+2])&&ao.isHexadecimal(t[a+3])&&(h=!0);h?(r+="\\x",a+=2):(r+="x",a+=2,s=!0);continue}case"n":case"r":case"t":case"a":case"f":case"v":case"d":case"D":case"s":case"S":case"w":case"W":case"b":case"B":case"p":case"P":case"A":case"z":case"Q":case"E":case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":r+="\\"+c,a+=2;continue;default:{let h=t.codePointAt(a+1);if(h>=48&&h<=57||h>=65&&h<=90||h>=97&&h<=122){let f=me.charCount(h);r+=t.substring(a+1,a+1+f),a+=f+1,s=!0}else{r+="\\";let f=me.charCount(h);r+=t.substring(a+1,a+1+f),a+=f+1}continue}}}else if(c==="/"){r+="\\/",a+=1,s=!0;continue}else if(c==="[")o=!0;else if(c==="]")o=!1;else if(!o&&c==="("&&a+2<i&&t[a+1]==="?"&&t[a+2]==="<"&&a+3<i&&!"=!>)".includes(t[a+3])){r+="(?P<",a+=3,s=!0;continue}let u=t.codePointAt(a),d=me.charCount(u);r+=t.substring(a,a+d),a+=d}const l=s?r:t;return n.length>0?`(?${n})${l}`:l}},Xa=class zt{static CASE_INSENSITIVE=Qn.CASE_INSENSITIVE;static DOTALL=Qn.DOTALL;static MULTILINE=Qn.MULTILINE;static DISABLE_UNICODE_GROUPS=Qn.DISABLE_UNICODE_GROUPS;static LONGEST_MATCH=Qn.LONGEST_MATCH;static LOOKBEHINDS=Qn.LOOKBEHINDS;static quote(t){return me.quoteMeta(t)}static quoteReplacement(t,n=!1){return lb.quoteReplacement(t,n)}static translateRegExp(t){return U4.translate(t)}static compile(t,n=0){let r=t;if((n&zt.CASE_INSENSITIVE)!==0&&(r=`(?i)${r}`),(n&zt.DOTALL)!==0&&(r=`(?s)${r}`),(n&zt.MULTILINE)!==0&&(r=`(?m)${r}`),(n&~(zt.MULTILINE|zt.DOTALL|zt.CASE_INSENSITIVE|zt.DISABLE_UNICODE_GROUPS|zt.LONGEST_MATCH|zt.LOOKBEHINDS))!==0)throw new x4("Flags should only be a combination of MULTILINE, DOTALL, CASE_INSENSITIVE, DISABLE_UNICODE_GROUPS, LONGEST_MATCH, LOOKBEHINDS");let s=$.PERL;(n&zt.DISABLE_UNICODE_GROUPS)!==0&&(s&=~$.UNICODE_GROUPS),(n&zt.LOOKBEHINDS)!==0&&(s|=$.LOOKBEHIND);const i=new zt(t,n);return i.re2Input=V4.compileImpl(r,s,(n&zt.LONGEST_MATCH)!==0),i}static matches(t,n){return zt.compile(t).testExact(n)}static initTest(t,n,r){if(t==null)throw new Error("pattern is null");if(r==null)throw new Error("re2 is null");const s=new zt(t,n);return s.re2Input=r,s}constructor(t,n){this.patternInput=t,this.flagsInput=n,this.re2Input=null}reset(){this.re2Input.reset()}flags(){return this.flagsInput}pattern(){return this.patternInput}re2(){return this.re2Input}matches(t){return this.testExact(t)}matcher(t){return me.isByteArray(t)&&(t=vi.utf8(t)),new lb(this,t)}test(t){return me.isByteArray(t)?this.re2Input.matchUTF8(t):this.re2Input.match(t)}testExact(t){const n=me.isByteArray(t)?$e.fromUTF8(t):$e.fromUTF16(t);return this.re2Input.executeEngine(n,0,$.ANCHOR_BOTH,0)!==null}exec(t){const n=this.matcher(t);if(!n.find())return null;const r=[n.group(0)];for(let i=1;i<=n.groupCount();i++){const o=n.group(i);r.push(o===null?void 0:o)}r.index=n.start(0),r.input=t;const s=this.namedGroups();if(Object.keys(s).length>0){const i=n.getNamedGroups();for(const o in i)i[o]===null&&(i[o]=void 0);r.groups=i}else r.groups=void 0;return r}split(t,n=0){const r=this.matcher(t),s=[];let i=0,o=0;for(;r.find();){if(o===0&&r.end()===0){o=r.end();continue}if(n>0&&s.length===n-1)break;if(o===r.start()){if(n===0){i+=1,o=r.end();continue}}else for(;i>0;)s.push(""),i-=1;s.push(r.substring(o,r.start())),o=r.end()}if(n===0&&o!==r.inputLength()){for(;i>0;)s.push(""),i-=1;s.push(r.substring(o,r.inputLength()))}return(n!==0||s.length===0&&!(o===r.inputLength()&&o>0))&&s.push(r.substring(o,r.inputLength())),s}*matchAll(t){const n=this.matcher(t);for(;n.find();){const r=[n.group(0)];for(let i=1;i<=n.groupCount();i++){const o=n.group(i);r.push(o===null?void 0:o)}r.index=n.start(0),r.input=t;const s=this.namedGroups();if(Object.keys(s).length>0){const i=n.getNamedGroups();for(const o in i)i[o]===null&&(i[o]=void 0);r.groups=i}else r.groups=void 0;yield r}}toString(){return this.patternInput}programSize(){return this.re2Input.numberOfInstructions()}groupCount(){return this.re2Input.numberOfCapturingGroups()}namedGroups(){return this.re2Input.namedGroups}equals(t){return this===t?!0:t===null||this.constructor!==t.constructor?!1:this.flagsInput===t.flagsInput&&this.patternInput===t.patternInput}},kA=1e5,z4=4e6,Nse={implementationVersion:1,algorithm:"levenshtein-code-points",maxCells:z4,maxInputChars:kA};function $4(e,t){let n=t.caseSensitive?e:e.toLowerCase();return t.normalizeWhitespace&&(n=n.replace(/\s+/gu," ").trim()),n}var RA=/^\/(?:[^/~]|~[01])+$/,OA=1e5,W4=["i","m","s","im","is","ms","ims"],Pse={implementationVersion:1,engine:"re2js",encoding:"canonical-json-bounded",maxSubjectChars:OA},Lse={implementationVersion:1,engine:"re2js",encoding:"canonical-json-bounded",maxSubjectChars:OA,subject:"text,structuredContent,json",pathSource:"structuredContent,json"};function q4(e){let t=0;return e?.includes("i")&&(t|=Xa.CASE_INSENSITIVE),e?.includes("m")&&(t|=Xa.MULTILINE),e?.includes("s")&&(t|=Xa.DOTALL),t}function K4(e,t){try{return{ok:!0,compiled:Xa.compile(Xa.translateRegExp(e),q4(t))}}catch(n){return{ok:!1,message:n instanceof Error?n.message:String(n)}}}function J4(e,t){const n=K4(e,t);return n.ok?void 0:n.message}function Q4(e,t,n){if(e===0&&t===void 0)return{path:"min",message:`min: 0 needs a max; on its own it passes every transcript (use max: 0 for "no ${n} matches")`};if(t!==void 0&&t<(e??1))return{path:"max",message:`max must be at least min (${e??1}${e===void 0?", the default":""})`}}function Y4(e){if(typeof e!="string")return"path must be a string";if(e.length===0)return'path "" is the whole value; omit path instead';if(e.length<2||e.length>257)return'path must be 2 to 257 characters: "/" and the key, e.g. "/elements"';if(!e.startsWith("/"))return'path must be a JSON Pointer that starts with "/", e.g. "/elements"';if(e.indexOf("/",1)!==-1)return'path must name exactly one top-level key; nested paths are not supported yet (write a "/" inside a key as ~1)';if(!RA.test(e))return'path has an invalid escape: "~" must be followed by 0 or 1'}function _se(e){const t=Y4(e);return t!==void 0?{ok:!1,message:t}:{ok:!0,key:e.slice(1).replace(/~1/g,"/").replace(/~0/g,"~")}}function Fse(e){return`/${e.replace(/~/g,"~0").replace(/\//g,"~1")}`}function Hse(e,t){const{min:n,max:r}=e;return r===void 0?`at least ${n} matching ${t}(s)`:r===0?`no matching ${t}`:n===r?`exactly ${n} matching ${t}(s)`:n===0?`at most ${r} matching ${t}(s)`:`${n} to ${r} matching ${t}s`}var MA=["toolCalledWith","toolCalledAtLeastOnce","toolNeverCalled","onlyToolsCalled","firstToolWas","responseCloseTo","responseContains","responseMatches","noToolErrors","finalAssistantMessageNonEmpty","widgetRendered","widgetRenderLatencyUnder","widgetNoConsoleErrors","noEndingQuestion","toolCallCountUnder","toolCalledBefore","noRepeatedIdenticalCall","toolInputMatches"];function X4(e){return MA.includes(e)}var NA=["widgetRendered","widgetRenderLatencyUnder","widgetNoConsoleErrors"];function Z4(e){return NA.includes(e)}var PA=["noDeprecatedToolExposed","noEndingQuestion","noRepeatedIdenticalCall","noDeprecatedToolCalled","toolErrorNamesInput","fullPageHasContinuation"];function LA(e){return PA.includes(e)}var _A=1e3,jp=16384;function eW(e){try{const t=JSON.stringify(e);return t===void 0?1/0:new TextEncoder().encode(t).length}catch{return 1/0}}var tW=["any","string","number","boolean","object","array","null"],FA=D({args:Mr(S(),Ln()),argumentMatching:U(["exact","partial","ignore"]).optional()});var Me={role:U(["gating","advisory","required"]).optional(),severity:L("warn").optional(),evaluator:ls({id:S().min(1).max(64),version:M().int().positive()}).optional()},Za=lr([L("declared"),Mr(S(),Ln()),le()]),Mb={patterns:K(S().min(1).max(512)).min(1).max(8),flags:U(W4).optional(),path:S().min(2).max(257).regex(RA,{message:'path must be a one-key JSON Pointer such as "/elements" ("~1" writes "/" and "~0" writes "~" inside the key)'}).optional(),min:M().int().nonnegative().optional(),max:M().int().nonnegative().optional()};function Nb(e){return(t,n)=>{t.patterns.forEach((s,i)=>{const o=J4(s,t.flags);o!==void 0&&n.addIssue({code:ts.custom,path:["patterns",i],message:`pattern does not compile in re2js: ${o}`})});const r=Q4(t.min,t.max,e);r&&n.addIssue({code:ts.custom,path:[r.path],message:r.message})}}var _C=ft("type",[D({type:L("toolDescriptionsPresent"),minLength:M().int().positive().optional(),...Me}),D({type:L("toolAnnotationsPresent"),require:K(U(["readOnlyHint","destructiveHint"])).max(2).refine(e=>new Set(e).size===e.length,"Annotation keys must be unique").optional(),...Me}),D({type:L("toolNamesUnique"),...Me}),D({type:L("noDeprecatedToolExposed"),...Me}),D({type:L("toolInputSchemasWellFormed"),...Me}),D({type:L("toolOutputSchemasPresent"),...Me}),D({type:L("toolCalledWith"),toolName:S().min(1),args:FA,minCount:M().int().positive().optional(),...Me}),D({type:L("toolCalledAtLeastOnce"),toolName:S().min(1),...Me}),D({type:L("toolNeverCalled"),toolName:S().min(1),...Me}),D({type:L("onlyToolsCalled"),toolNames:K(S().min(1)),...Me}),D({type:L("firstToolWas"),toolName:S().min(1),...Me}),D({type:L("responseCloseTo"),reference:S().min(1).max(kA),maxDistance:M().finite().min(0).max(1),caseSensitive:le().optional(),normalizeWhitespace:le().optional(),...Me}),D({type:L("responseContains"),needle:S().min(1),caseSensitive:le().optional(),...Me}),D({type:L("responseMatches"),pattern:S().min(1).refine(e=>{try{return new RegExp(e),!0}catch{return!1}},{message:"Invalid regular expression"}),...Me}),D({type:L("noToolErrors"),...Me}),D({type:L("finalAssistantMessageNonEmpty"),...Me}),D({type:L("tokenBudgetUnder"),tokens:M().int().positive(),...Me}),D({type:L("widgetRendered"),toolName:S().min(1).optional(),...Me}),D({type:L("widgetRenderLatencyUnder"),ms:M().int().positive(),toolName:S().min(1).optional(),...Me}),D({type:L("widgetNoConsoleErrors"),toolName:S().min(1).optional(),...Me}),D({type:L("turnCountUnder"),turns:M().int().positive(),...Me}),D({type:L("noEndingQuestion"),...Me}),D({type:L("toolLatencyUnder"),ms:M().int().positive(),toolName:S().min(1).optional(),...Me}),D({type:L("toolResultContains"),needle:S().min(1).max(_A),caseSensitive:le().optional(),toolName:S().min(1).optional(),...Me}),D({type:L("toolResultMatchesSchema"),schema:lr([Za.options[0],Za.options[1],K(Ln()),M(),Za.options[2],Ql()]).refine(e=>eW(e)<=jp,`schema must canonicalize to at most ${jp} bytes`),toolName:S().min(1).optional(),...Me}),D({type:L("toolResultSizeUnder"),maxBytes:M().int().positive(),toolName:S().min(1).optional(),...Me}),D({type:L("argumentsMatchToolSchema"),toolName:S().min(1).optional(),...Me}),D({type:L("toolInputMatches"),toolName:S().min(1),...Mb,...Me}).superRefine(Nb("call")),D({type:L("toolResultMatches"),toolName:S().min(1).optional(),...Mb,...Me}).superRefine(Nb("result")),D({type:L("noRepeatedIdenticalCall"),toolName:S().min(1).optional(),...Me}),D({type:L("toolCallCountUnder"),count:M().int().positive(),toolName:S().min(1).optional(),...Me}),D({type:L("toolCalledBefore"),toolName:S().min(1),beforeToolName:S().min(1),...Me}),D({type:L("noDeprecatedToolCalled"),...Me}),D({type:L("noDestructiveToolCalled"),...Me}),D({type:L("toolErrorNamesInput"),toolName:S().min(1).optional(),...Me}),D({type:L("fullPageHasContinuation"),toolName:S().min(1).optional(),...Me})]),jo=_C.superRefine((e,t)=>{e.type==="responseCloseTo"&&$4(e.reference,e).length===0&&t.addIssue({code:ts.custom,path:["reference"],message:"reference must remain non-empty after normalization"}),e.severity!==void 0&&e.role!=="advisory"&&t.addIssue({code:ts.custom,path:["severity"],message:'severity requires role: "advisory"'}),LA(e.type)&&e.role!=="advisory"&&t.addIssue({code:ts.custom,path:["role"],message:`"${e.type}" is an observation (a heuristic) and cannot gate; set role: "advisory"`})}),dc=jo.refine(e=>e.type!=="toolResultMatchesSchema"||Za.safeParse(e.schema).success,{path:["schema"],message:'Replace this schema with a JSON Schema object, true, false, or "declared".'}),nW=K(dc),rW=D({mode:U(["inherit","replace","extend"]),list:K(dc)}),hc=D({kind:L("turn"),promptIndex:M().int().nonnegative()}),jse="declared",Gse=new RegExp(String.raw`\b(authorization|password|passwd|secret|token|api[_-]?key|access[_-]?key|client[_-]?secret|cookie|credential|private[_-]?key)\b`+String.raw`(\s*[:=]\s*)`+String.raw`(?:bearer\s+)?["']?[\w.\-+/=]{6,}["']?`,"gi"),fc=2e3,Vse=YM({MAX_EVALUATOR_ID_CHARS:()=>64,MAX_NEEDLE_CHARS:()=>_A,MAX_SCHEMA_BYTES:()=>jp,OBSERVATION_PREDICATE_KINDS:()=>PA,PREDICATE_PLACEHOLDER_STRINGS:()=>tW,RENDER_OBSERVATION_PREDICATE_KINDS:()=>NA,TURN_SCOPABLE_PREDICATE_KINDS:()=>MA,argMatcherSchema:()=>FA,authoredResultSchemaRoot:()=>Za,casePredicatesSchema:()=>rW,isObservationPredicateKind:()=>LA,isTurnScopablePredicateKind:()=>X4,predicateArraySchema:()=>nW,predicateSchema:()=>dc,predicateScopeSchema:()=>hc,predicateUnion:()=>_C,requiresRenderObservations:()=>Z4,storedPredicateSchema:()=>jo});function HA(e){const t=fA(e.role)?"fail":"ignore",{onError:n,onSkipped:r,...s}=e;return{...s,onError:n??t,onSkipped:r??t}}function sW(e){return e==="advisory"?"advisory":"gating"}function jA(e){return{scorerId:e.scorerId,idSource:e.idSource,scorerVersion:e.scorerVersion,implementationHash:e.implementationHash,deterministic:e.deterministic,passThreshold:e.passThreshold,role:sW(e.role),onError:e.onError,onSkipped:e.onSkipped,model:e.model,scope:e.scope}}function xh(e){return dh(uh(jA(e)))}function GA(e){const t=e.map(n=>uh(jA(n))).sort();return dh(`[${t.join(",")}]`)}function Use(e){return dh(uh([...e].sort()))}function zse(e){const t=e.map(s=>HA(s)),n=new Map,r=[];for(const s of t){const i=xh(s),o=n.get(s.scorerId);if(o===void 0){n.set(s.scorerId,i),r.push(s);continue}if(o!==i)throw new Error(`Duplicate scorerId "${s.scorerId}" in the evaluation config with different settings. Scorer ids must be unique within a run.`)}return{hash:GA(r),definitions:r}}function iW(e,t){return e>=t}function Bc(e,t){return e.length<=t?e:`${e.slice(0,t-1)}…`}function oW(e){if(!(!e||e.length===0))return e.slice(0,20).map(t=>Bc(String(t),300))}function wh(e){return{scorerId:e.scorerId,scorerVersion:e.scorerVersion,definitionHash:xh(e),passThreshold:e.passThreshold,deterministic:e.deterministic}}function aW(e){if(e instanceof Error)return e.message||e.name||"unknown error";const t=typeof e=="string"?e:String(e);return t.trim()===""?"unknown error":t}function lW(e,t){return t??e.scope}function FC(e,t){const n=lW(e,t);return{...e.model?{model:e.model}:{},...n?{scope:n}:{}}}function Gp(e,t,n){return{...wh(e),status:"error",error:Bc(aW(t),500),...FC(e,n?.scope)}}function VA(e,t,n){return{...wh(e),status:"skipped",...t?{rationale:Bc(t,fc)}:{},...FC(e,n?.scope)}}function UA(e,t,n){return{...wh(e),status:"not_applicable",...t?{rationale:Bc(t,fc)}:{},...FC(e,n?.scope)}}function cW(e,t){if(t.kind==="skipped")return VA(e,t.rationale,{scope:t.scope});if(t.kind==="not_applicable")return UA(e,t.rationale,{scope:t.scope});const{value:n}=t;if(typeof n!="number"||!Number.isFinite(n))return Gp(e,`scorer returned a non-numeric value (${String(n)})`,{scope:t.scope});if(n<0||n>1)return Gp(e,`scorer returned ${n}, outside the required [0,1] range`,{scope:t.scope});const r=t.model??e.model,s=t.scope??e.scope,i=oW(t.evidence);return{...wh(e),status:"scored",value:n,passed:iW(n,e.passThreshold),...t.rationale?{rationale:Bc(t.rationale,fc)}:{},...i?{evidence:i}:{},...r?{model:r}:{},...t.promptHash?{promptHash:t.promptHash}:{},...t.judgeTemplateVersion!==void 0?{judgeTemplateVersion:t.judgeTemplateVersion}:{},...t.judgeTemplateHash!==void 0?{judgeTemplateHash:t.judgeTemplateHash}:{},...t.evidenceHash!==void 0?{evidenceHash:t.evidenceHash}:{},...t.evidenceManifest!==void 0?{evidenceManifest:t.evidenceManifest}:{},...s?{scope:s}:{}}}function uW(e,t){const n=[],r=[];for(const s of t.definitions){if(!fA(s.role))continue;const i=xh(s),o=e.filter(u=>u.definitionHash===i),a=o.filter(u=>u.status!=="not_applicable");if(a.length===0){o.length===0&&r.push(s.scorerId);continue}let l=!1,c=!1;for(const u of a){if(u.status==="scored"){u.passed!==!1&&typeof u.value=="number"&&u.value>=s.passThreshold||(l=!0);continue}(u.status==="error"?s.onError:s.onSkipped)==="fail"&&(c=!0)}l?n.push(s.scorerId):c&&r.push(s.scorerId)}return{passed:n.length===0&&r.length===0,disagreeingScorerIds:n,unresolvedScorerIds:r}}var zA=U(["scored","error","skipped","not_applicable"]),HC=U(["gating","advisory","required"]),Td=U(["fail","ignore"]),jC=U(["explicit","generated","platform"]),Vp=M().min(0).max(1),$A={scorerId:S().min(1).max(128),idSource:jC,scorerVersion:S().min(1),implementationHash:S().min(1),label:S().min(1).optional(),deterministic:le(),passThreshold:Vp,role:HC,model:S().min(1).optional(),scope:hc.optional()},$se=D({...$A,onError:Td.optional(),onSkipped:Td.optional()}).strict(),WA=D({...$A,onError:Td,onSkipped:Td}).strict(),qA=D({scorerId:S().min(1).max(128),scorerVersion:S().min(1),definitionHash:S().min(1),status:zA,value:Vp.optional(),passThreshold:Vp,passed:le().optional(),rationale:S().max(fc).optional(),evidence:K(S().max(300)).max(20).optional(),deterministic:le(),model:S().min(1).optional(),promptHash:S().min(1).optional(),error:S().min(1).max(500).optional(),scope:hc.optional()}).strict().superRefine((e,t)=>{if(e.status==="scored"){if(e.value===void 0&&t.addIssue({code:"custom",path:["value"],message:'`value` is required when status is "scored"'}),e.passed===void 0&&t.addIssue({code:"custom",path:["passed"],message:'`passed` is required when status is "scored"'}),e.value!==void 0&&e.passed!==void 0){const n=e.value>=e.passThreshold;e.passed!==n&&t.addIssue({code:"custom",path:["passed"],message:`\`passed\` must equal \`value >= passThreshold\` (${e.value} >= ${e.passThreshold} is ${n}, got ${e.passed})`})}}else e.value!==void 0&&t.addIssue({code:"custom",path:["value"],message:'`value` is only allowed when status is "scored"'}),e.passed!==void 0&&t.addIssue({code:"custom",path:["passed"],message:'`passed` is only allowed when status is "scored"'});e.status==="error"?e.error===void 0&&t.addIssue({code:"custom",path:["error"],message:'`error` is required when status is "error"'}):e.error!==void 0&&t.addIssue({code:"custom",path:["error"],message:'`error` is only allowed when status is "error"'})}),Wse=K(qA),qse=D({hash:S().min(1),definitions:K(WA)}).strict().superRefine((e,t)=>{const n=new Set;e.definitions.forEach((s,i)=>{n.has(s.scorerId)&&t.addIssue({code:"custom",path:["definitions",i,"scorerId"],message:`duplicate scorerId "${s.scorerId}"`}),n.add(s.scorerId)});const r=GA(e.definitions);r!==e.hash&&t.addIssue({code:"custom",path:["hash"],message:`evaluationConfigHash mismatch (declared ${e.hash}, recomputed ${r})`})});var Gi=S().min(1).max(128).regex(/^[A-Za-z0-9_-]+$/,"id must contain only letters, digits, '-' and '_' (no whitespace or punctuation)");var dW="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";function hW(e){const t=globalThis.crypto;if(!t?.getRandomValues)throw new Error("Cannot mint an id: this runtime has no `crypto.getRandomValues`. Pass an explicit id instead.");return t.getRandomValues(new Uint8Array(e))}function fW(e){const t=hW(21);let n=e;for(const r of t)n+=dW[r&63];return n}function Kse(){return fW("c_")}function Jse(e){return Gi.safeParse(e).success}var rr=["connection","discovery","selection","call","response","userValue"],Vi=U(rr),GC=["passed","failed","notReached","notMeasured","notApplicable"],KA=U(GC),VC=["setup","metadata","selection","arguments","serverData","userValue","evaluator"],UC=U(VC),BW=["pending","running","completed","failed","cancelled","timed_out","setup_failed","skipped"],Qse=U(BW),pW=["exact","approximated","unsupported","unresolved"],mW=U(pW),gW=_C.options.map(e=>e.shape.type.value),Rl={toolDescriptionsPresent:"discovery",toolAnnotationsPresent:"discovery",toolNamesUnique:"discovery",noDeprecatedToolExposed:"discovery",toolInputSchemasWellFormed:"discovery",toolOutputSchemasPresent:"discovery",toolCalledWith:"selection",toolCalledAtLeastOnce:"selection",toolNeverCalled:"selection",onlyToolsCalled:"selection",firstToolWas:"selection",toolCallCountUnder:"selection",toolCalledBefore:"selection",noDeprecatedToolCalled:"selection",noDestructiveToolCalled:"selection",argumentsMatchToolSchema:"call",noRepeatedIdenticalCall:"call",toolInputMatches:"call",noToolErrors:"response",toolLatencyUnder:"response",toolResultContains:"response",toolResultMatches:"response",toolResultMatchesSchema:"response",toolResultSizeUnder:"response",toolErrorNamesInput:"response",fullPageHasContinuation:"response",responseCloseTo:"userValue",responseContains:"userValue",responseMatches:"userValue",finalAssistantMessageNonEmpty:"userValue",tokenBudgetUnder:"userValue",turnCountUnder:"userValue",widgetRendered:"userValue",widgetRenderLatencyUnder:"userValue",widgetNoConsoleErrors:"userValue",noEndingQuestion:"userValue"},CW={"toolCalls:match":"selection","toolCalls:arguments":"call","judge:goalCompletion":"userValue","judge:groundedness":"userValue","judge:rubricChecks":"userValue"},vW={tokenBudgetUnder:"budget",turnCountUnder:"budget"},Yse=gW,Dh=Rl,Xse=CW,Zse=vW,zC=["noSpanChannel","noEvidenceCaptured","matchVerdictUnavailable","traceAbsent","executorEmitsNoSpans","blockedByPolicy","evaluatorError","providerError","setupAborted","connectFailed","toolsListFailed","egressUnverified","lifecycleStopped","notAuthored","earlierStageFailed","missingToolCall","unexpectedToolCall","argumentMismatch","toolError","protocolError","renderFailed","predicateFailed","observed","impliedByLaterEvidence","judgeObserved","judgePartial","judgeFailed","judgePending","judgeNotRequested"],eie=Object.fromEntries(Object.entries({toolCalledAtLeastOnce:"missingToolCall",firstToolWas:"unexpectedToolCall",toolNeverCalled:"unexpectedToolCall",onlyToolsCalled:"unexpectedToolCall",toolCallCountUnder:"unexpectedToolCall",toolCalledBefore:"unexpectedToolCall",noDeprecatedToolCalled:"unexpectedToolCall",noDestructiveToolCalled:"unexpectedToolCall"}).filter(([e,t])=>t!==void 0&&Dh[e]==="selection")),tie=new Set(Object.entries(Dh).filter(([,e])=>e==="discovery").map(([e])=>e)),nie=new Set(Object.entries(Dh).filter(([,e])=>e==="response").map(([e])=>e)),rie=new Set(Object.entries(Dh).filter(([,e])=>e==="call").map(([e])=>e)),yW=new Set(["toolCalledAtLeastOnce","firstToolWas"]);function sie(e){return e!==void 0&&yW.has(e)}var JA=U(zC),QA=D({stage:Vi,state:KA,reason:JA.optional(),evidence:D({spanIds:K(S()).optional(),promptIndexes:K(M()).optional(),predicateReasons:K(S()).optional()}).optional()}),YA=D({stageResults:K(QA),firstFailedStage:Vi.optional(),failureCategory:UC.optional(),stageAnalyzerVersion:M().int().nonnegative()}).superRefine((e,t)=>{if(e.stageResults.length!==rr.length){t.addIssue({code:ts.custom,path:["stageResults"],message:`expected ${rr.length} stage rows, received ${e.stageResults.length}`});return}rr.forEach((r,s)=>{e.stageResults[s]?.stage!==r&&t.addIssue({code:ts.custom,path:["stageResults",s,"stage"],message:`stage rows must be in USER_VALUE_STAGES order; expected "${r}" at index ${s}`})});const n=e.stageResults.find(r=>r.state==="failed");n&&e.firstFailedStage!==n.stage&&t.addIssue({code:ts.custom,path:["firstFailedStage"],message:`firstFailedStage must name the first failed row ("${n.stage}")`}),!n&&e.firstFailedStage!==void 0&&t.addIssue({code:ts.custom,path:["firstFailedStage"],message:"firstFailedStage is set but no stage row failed"})});function iie(e){if(!e||typeof e!="object")return{};const t=e;if(!("stageResults"in t))return{};const n=YA.safeParse({stageResults:t.stageResults,...t.firstFailedStage!==void 0?{firstFailedStage:t.firstFailedStage}:{},...t.failureCategory!==void 0?{failureCategory:t.failureCategory}:{},stageAnalyzerVersion:t.stageAnalyzerVersion});if(n.success)return{stageResults:n.data.stageResults,...n.data.firstFailedStage?{firstFailedStage:n.data.firstFailedStage}:{},...n.data.failureCategory?{failureCategory:n.data.failureCategory}:{},stageAnalyzerVersion:n.data.stageAnalyzerVersion};const r=t.stageAnalyzerVersion;return{stageResultsUnverified:!0,...typeof r=="number"&&Number.isInteger(r)&&r>=0?{stageAnalyzerVersion:r}:{}}}var bW=["assertion","judge"];function SW(e){return e.deterministic?"assertion":"judge"}function Th(e){return{schemaVersion:1,evaluatorId:e.scorerId,evaluatorVersion:e.scorerVersion,definitionHash:e.definitionHash,kind:SW(e),status:e.status,...e.value!==void 0?{score:e.value}:{},passThreshold:e.passThreshold,...e.passed!==void 0?{passed:e.passed}:{},...e.rationale!==void 0?{explanation:e.rationale}:{},...e.evidence!==void 0?{evidence:e.evidence}:{},deterministic:e.deterministic,...e.model!==void 0?{model:e.model}:{},...e.promptHash!==void 0?{promptHash:e.promptHash}:{},...e.error!==void 0?{error:e.error}:{},...e.judgeTemplateVersion!==void 0?{judgeTemplateVersion:e.judgeTemplateVersion}:{},...e.judgeTemplateHash!==void 0?{judgeTemplateHash:e.judgeTemplateHash}:{},...e.evidenceHash!==void 0?{evidenceHash:e.evidenceHash}:{},...e.evidenceManifest!==void 0?{evidenceManifest:e.evidenceManifest}:{},...e.scope!==void 0?{scope:e.scope}:{}}}function XA(e){return{scorerId:e.evaluatorId,scorerVersion:e.evaluatorVersion,definitionHash:e.definitionHash,status:e.status,...e.score!==void 0?{value:e.score}:{},passThreshold:e.passThreshold,...e.passed!==void 0?{passed:e.passed}:{},...e.explanation!==void 0?{rationale:e.explanation}:{},...e.evidence!==void 0?{evidence:e.evidence}:{},deterministic:e.deterministic,...e.model!==void 0?{model:e.model}:{},...e.promptHash!==void 0?{promptHash:e.promptHash}:{},...e.error!==void 0?{error:e.error}:{},...e.judgeTemplateVersion!==void 0?{judgeTemplateVersion:e.judgeTemplateVersion}:{},...e.judgeTemplateHash!==void 0?{judgeTemplateHash:e.judgeTemplateHash}:{},...e.evidenceHash!==void 0?{evidenceHash:e.evidenceHash}:{},...e.evidenceManifest!==void 0?{evidenceManifest:e.evidenceManifest}:{},...e.scope!==void 0?{scope:e.scope}:{}}}function EW(e){return e.kind==="scored"?{kind:"scored",value:e.score,...e.explanation!==void 0?{rationale:e.explanation}:{},...e.evidence!==void 0?{evidence:e.evidence}:{},...e.model!==void 0?{model:e.model}:{},...e.promptHash!==void 0?{promptHash:e.promptHash}:{},...e.judgeTemplateVersion!==void 0?{judgeTemplateVersion:e.judgeTemplateVersion}:{},...e.judgeTemplateHash!==void 0?{judgeTemplateHash:e.judgeTemplateHash}:{},...e.evidenceHash!==void 0?{evidenceHash:e.evidenceHash}:{},...e.evidenceManifest!==void 0?{evidenceManifest:e.evidenceManifest}:{},...e.scope!==void 0?{scope:e.scope}:{}}:{kind:e.kind,...e.explanation!==void 0?{rationale:e.explanation}:{},...e.scope!==void 0?{scope:e.scope}:{}}}function oie(e){return HA(e)}function aie(e){return xh(e)}function lie(e,t){return Th(cW(e,EW(t)))}function cie(e,t,n){return Th(Gp(e,t,n))}function uie(e,t,n){return Th(VA(e,t,n))}function die(e,t,n){return Th(UA(e,t,n))}function hie(e,t){const n=e.map(r=>"evaluatorId"in r?XA(r):r);return uW(n,t)}var xW=U(bW),wW=U(["scored","error","skipped","not_applicable"]),Pb=M().min(0).max(1),Lb={scorerId:"evaluatorId",scorerVersion:"evaluatorVersion",value:"score",rationale:"explanation"},DW=D({schemaVersion:L(1),evaluatorId:S().min(1).max(128),evaluatorVersion:S().min(1),definitionHash:S().min(1),kind:xW,status:wW,score:Pb.optional(),passThreshold:Pb,passed:le().optional(),explanation:S().max(fc).optional(),evidence:K(S().max(300)).max(20).optional(),deterministic:le(),model:S().min(1).optional(),promptHash:S().min(1).optional(),error:S().min(1).max(500).optional(),scope:hc.optional()}).strict(),TW=DW.superRefine((e,t)=>{const n=e.deterministic?"assertion":"judge";e.kind!==n&&t.addIssue({code:"custom",path:["kind"],message:`\`kind\` is derived from \`deterministic\` (${e.deterministic} means "${n}", got "${e.kind}")`});const r=qA.safeParse(XA(e));if(!r.success)for(const s of r.error.issues)t.addIssue({code:"custom",path:s.path.map(i=>typeof i=="string"?Lb[i]??i:i),message:Object.entries(Lb).reduce((i,[o,a])=>i.replace(new RegExp(`\\b${o}\\b`,"g"),a),s.message)})}),fie=K(TW);var AW="json_chars_div_4",IW=2e5,kW=["snapshotMissing","snapshotPartial","setupNotObserved"],RW=["aggregated_catalog_json","normalized_snapshot"],OW=["spec_required","spec_recommended","quality_signal"],_b=D({outcome:U(["ok","failed"]),attribution:U(["ours","theirs","unknown"]).optional(),egressVerified:le().optional(),durationMs:M().int().nonnegative().optional(),basis:L("setup_phase_wall")}).strict(),MW="estimate of a reference window, not measured context consumption",NW=D({toolName:S().min(1),code:S().min(1),class:U(OW),detail:Mr(S().regex(/^[A-Za-z0-9_.-]{1,64}$/),M()).optional(),protocolDependent:le().optional()}).strict(),PW=D({kind:U(["conformance","readiness"]),runId:S().min(1).optional(),createdAt:M().int().nonnegative(),protocolVersion:S().min(1).optional(),serverVersion:S().min(1).optional(),comparability:L("sameServerId")}).strict(),LW=D({bytes:M().int().nonnegative(),basis:U(RW),complete:le()}).strict(),_W=D({serverId:S().min(1),capture:U(["complete","failed"]),toolCount:M().int().nonnegative(),payload:LW,estimatedTokens:M().int().nonnegative(),referenceWindowShare:M().min(0),annotations:D({total:M().int().nonnegative(),withReadOnlyHint:M().int().nonnegative(),withDestructiveHint:M().int().nonnegative()}).strict().refine(e=>e.withReadOnlyHint<=e.total&&e.withDestructiveHint<=e.total,{message:"annotation counts cannot exceed the tool total"}),outputSchema:D({total:M().int().nonnegative(),present:M().int().nonnegative()}).strict().refine(e=>e.present<=e.total,{message:"outputSchema.present cannot exceed the tool total"}),prechecks:K(NW).max(500),relatedAssessments:K(PW).max(8)}).strict(),Bie=D({schemaVersion:L(1),sourceVersion:L(1),runId:S().min(1),suiteId:S().min(1),computedAt:M().int().nonnegative(),state:U(["ready","unavailable"]),reason:U(kW).optional(),protocolVersion:S().min(1).optional(),tokenEstimate:D({method:L(AW),referenceWindowTokens:L(IW),note:L(MW)}).strict(),setup:D({connection:_b.optional(),discovery:_b.optional()}).strict(),servers:K(_W).max(50)}).strict().refine(e=>e.state==="unavailable"==(e.reason!==void 0),{message:'`reason` is required exactly when `state` is "unavailable"',path:["reason"]});var pie="Unlabeled",FW=S().min(1).max(64).refine(e=>e.trim()===e,{message:"intent must be trimmed (no leading or trailing whitespace); normalize with normalizeIntent before validating"}),HW=FW.nullable();var ZA="evidence_span_union",jW="setup_phase_wall",GW=["reached","notReached","unknown","notApplicable"],VW=U(GW),eI=["selection","call","response"];function UW(e){return eI.includes(e)}var zW=D({unit:L("ms"),basis:L(ZA),value:M().finite().min(0)}).strict(),$W=D({stage:Vi,reach:VW,latency:zW.optional()}).strict(),WW=D({schemaVersion:L(1),stageAnalyzerVersion:M().int().min(1),rows:K($W).length(rr.length)}).strict(),mie=WW.superRefine((e,t)=>{rr.forEach((n,r)=>{const s=e.rows[r];s!==void 0&&(s.stage!==n&&t.addIssue({code:"custom",path:["rows",r,"stage"],message:`rows[${r}] is '${s.stage}' but must be '${n}': the six rows are a funnel in USER_VALUE_STAGES order and position is meaning`}),s.latency!==void 0&&!UW(s.stage)&&t.addIssue({code:"custom",path:["rows",r,"latency"],message:`stage '${s.stage}' may not carry a per-trial latency at schema version 1 (eligible stages: ${eI.join(", ")})`}),s.latency!==void 0&&s.reach!=="reached"&&t.addIssue({code:"custom",path:["rows",r,"latency"],message:`stage '${s.stage}' reports latency but reach is '${s.reach}': a stage that was not reached cannot have taken time`}))})}),qW=2e3,KW=ls({id:S().regex(/^[A-Za-z0-9_-]{1,64}$/),label:S().trim().min(1).max(200),description:S().max(1e3).optional(),required:le().optional()}),JW=ls({criteria:K(KW).min(1).max(25).optional(),instructions:S().trim().min(1).max(qW).optional().describe("Grading instructions: extra rules applied alongside each case's task and expected outcome. They do not replace the expected outcome.")}).superRefine((e,t)=>{e.criteria===void 0&&e.instructions===void 0&&t.addIssue({code:"custom",message:"Provide grading instructions or criteria; use null to clear.",path:[]});const n=new Set;e.criteria?.forEach((r,s)=>{n.has(r.id)&&t.addIssue({code:"custom",message:"Criterion IDs must be unique.",path:["criteria",s,"id"]}),n.add(r.id)})}),QW=ls({enabled:le().optional(),model:S().trim().min(1).optional(),autoRun:le().optional(),threshold:M().min(0).max(1).optional(),role:U(["advisory","gating","required"]).optional(),severity:L("warn").optional(),rubric:JW.nullable().optional()}).refine(e=>e.severity===void 0||e.role===void 0||e.role==="advisory",{message:"Severity is only available for advisory judges.",path:["severity"]}),YW=ls({enabled:le().optional()});var Fb=65536,XW=262144;var Hb="/home/user/";var ZW=/^[A-Za-z0-9_-]{1,64}$/,eq=/^[A-Za-z0-9][A-Za-z0-9._-]{0,99}\.(sh|py|ts|js)$/;function tI(e){return new TextEncoder().encode(e).length}var Ma=S().refine(e=>tI(e)<=Fb,{message:`Scripts can be at most ${Fb.toLocaleString("en-US")} bytes.`});function tq(e){if(e.length>512)return"is longer than 512 characters";if([...e].some(n=>n.charCodeAt(0)<32||n===""))return"has a control character";if(!e.startsWith("/home/user/"))return`must start with ${Hb}`;const t=e.slice(11).replace(/\/$/,"");if(!t)return`must name a file or folder inside ${Hb}`;for(const n of t.split("/")){if(!n)return'has an empty folder name ("//")';if(n==="..")return'contains ".."';if(n.startsWith("."))return"is inside a hidden folder or names a hidden file"}}var nq=ls({id:S().regex(ZW,{message:'Use 1 to 64 letters, digits, "-" or "_".'}).describe("Stable id; the score row is code:<id>."),name:S().trim().min(1).max(100).optional(),fileName:S().regex(eq,{message:"Use a file name ending in .sh, .py, .ts or .js."}).describe("The extension picks the interpreter."),script:Ma.refine(e=>e.trim().length>0,{message:"The script is empty."}).describe('Reads the iteration from $MCPJAM_ITERATION and writes {"score": 0 to 1, "reason": "..."} to $MCPJAM_RESULT.'),role:U(["required","advisory"]).optional().describe("Required gates the iteration; advisory only reports. Default advisory."),threshold:M().gt(0).max(1).optional().describe("The score an iteration needs to pass. Default 1."),evaluator:ls({id:S().min(1).max(64),version:M().int().min(1)}).optional()}),rq=K(nq).max(10).superRefine((e,t)=>{const n=e.reduce((s,i)=>s+tI(i.script),0);n>262144&&t.addIssue({code:"custom",message:`Code evaluators and scripts can total at most ${XW.toLocaleString("en-US")} bytes. These evaluators total ${n.toLocaleString("en-US")}.`});const r=new Set;e.forEach((s,i)=>{r.has(s.id)&&t.addIssue({code:"custom",message:"Code evaluator ids must be unique.",path:[i,"id"]}),r.add(s.id)})}),sq=ls({runSetup:Ma.optional(),iterationSetup:Ma.optional(),iterationCleanup:Ma.optional(),runCleanup:Ma.optional()}),iq=ls({files:K(S().superRefine((e,t)=>{const n=tq(e);n&&t.addIssue({code:"custom",message:`The path ${n}.`})})).max(20).optional().describe("Files or folders from the agent's box to copy into the grading box."),network:U(["none","web"]).optional().describe("none (default): evaluators can't reach the network.")}),pc={"discovery.description":"toolDescriptionsPresent","discovery.annotations":"toolAnnotationsPresent","discovery.collisions":"toolNamesUnique","discovery.deprecated":"noDeprecatedToolExposed","call.schema":"toolInputSchemasWellFormed","response.schema":"toolOutputSchemasPresent","selection.hops":"toolCallCountUnder","call.parameters":"argumentsMatchToolSchema","call.repeated":"noRepeatedIdenticalCall","response.performance":"toolLatencyUnder","response.size":"toolResultSizeUnder","response.errors":"noToolErrors","response.recovery":"toolErrorNamesInput","response.pagination":"fullPageHasContinuation","userValue.turns":"turnCountUnder"};function oq(e){return Object.prototype.hasOwnProperty.call(pc,e)}function aq(e){if(e?.length){if(e.length>64||e.some(t=>!oq(t)))throw new Error("Suppression must contain at most 64 known standard assertion check ids");return[...new Set(e)].sort()}}function lq(e,t){const n=new Set((aq(t)??[]).map(r=>pc[r]));return e.filter(r=>!n.has(r.type))}var nI={"discovery.description":{name:"Description quality",label:"Tool descriptions meet the minimum length",rule:{type:"toolDescriptionsPresent",minLength:20}},"discovery.annotations":{name:"Tool annotations",label:"Every tool declares annotations",rule:{type:"toolAnnotationsPresent"}},"discovery.collisions":{name:"Name collisions",label:"Tool names are unique within each server",rule:{type:"toolNamesUnique"}},"discovery.deprecated":{name:"Deprecated tools exposed",label:"No tool description marks itself deprecated",rule:{type:"noDeprecatedToolExposed",role:"advisory"}},"call.schema":{name:"Input schema quality",label:"Input schemas have an object root and documented parameters",rule:{type:"toolInputSchemasWellFormed"}},"response.schema":{name:"Output schema quality",label:"Every tool declares an output schema",rule:{type:"toolOutputSchemasPresent"}},"selection.hops":{name:"Tool hops before the right tool",label:"Tool call count stays below the configured limit",rule:{type:"toolCallCountUnder",count:4}},"call.parameters":{name:"Parameter validity",label:"Arguments match the tool's input schema",rule:{type:"argumentsMatchToolSchema"}},"call.repeated":{name:"Repeated identical calls",label:"No identical call repeated back-to-back",rule:{type:"noRepeatedIdenticalCall",role:"advisory"}},"response.performance":{name:"Tool latency",label:"Tool latency stays below the configured limit",rule:{type:"toolLatencyUnder",ms:5e3}},"response.size":{name:"Payload size",label:"Tool result size stays below the configured limit",rule:{type:"toolResultSizeUnder",maxBytes:64e3}},"response.errors":{name:"Tool errors (isError)",label:"No tool returns an error",rule:{type:"noToolErrors"}},"response.recovery":{name:"Error messages that help recovery",label:"Tool errors name an input",rule:{type:"toolErrorNamesInput",role:"advisory"}},"response.pagination":{name:"Pagination and truncation clarity",label:"Full pages include a continuation marker",rule:{type:"fullPageHasContinuation",role:"advisory"}},"userValue.turns":{name:"User turns to completion",label:"User turn count stays below the configured limit",rule:{type:"turnCountUnder",turns:6}}},gie=[{id:"connection.success",name:"Successful connection",stage:"connection",label:"Connection",kind:"runner",measuredBy:"connection"},{id:"discovery.toolsList",name:"Tools listed",stage:"discovery",label:"Tool discovery",kind:"runner",measuredBy:"discovery"},{id:"call.completed",name:"Tool call completed",stage:"call",label:"Tool call",kind:"runner",measuredBy:"call"},{id:"response.returned",name:"Result returned to the model",stage:"response",label:"Response",kind:"runner",measuredBy:"response"},...Object.entries(nI).map(([e,{name:t,label:n,rule:r}])=>{const s=e;return{id:s,name:t,label:n,kind:"assertion",stage:Rl[pc[s]],preset:{...r,role:"advisory",severity:"warn"}}}),{id:"userValue.outcome",name:"Outcome achieved",stage:"userValue",label:"Outcome achieved",kind:"judge"}],Cie=Object.fromEntries(Object.entries(pc).map(([e,t])=>[t,nI[e].name])),rI=K(U(Object.keys(pc))).max(64),Up=5e3,cq=3e4,uq=12e4,jb=1e5,el=D({role:D({role:S().min(1),name:S().optional(),exact:le().optional()}).strict().optional(),text:S().min(1).optional(),css:S().min(1).optional(),testId:S().min(1).optional(),nth:M().int().nonnegative().optional()}).strict().refine(e=>!!(e.role||e.text||e.css||e.testId),{message:"locator must specify at least one of role/text/css/testId"}),dq=D({id:S(),kind:L("prompt"),prompt:S()}).strict(),hq=Mr(S(),Ln()).refine(e=>{try{return JSON.stringify(e).length<=jb}catch{return!1}},{message:`arguments must be ≤ ${jb} characters when serialized`}),fq=D({id:S(),kind:L("toolCall"),serverId:S().min(1).optional(),serverName:S().min(1),toolName:S().min(1),arguments:hq,renderTimeoutMs:M().int().positive().max(uq).optional()}).strict(),Bq=ft("kind",[D({kind:L("click"),target:el,clickType:U(["left","double","right"]).optional()}).strict(),D({kind:L("type"),target:el,text:S().max(Up)}).strict(),D({kind:L("key"),key:S().min(1)}).strict(),D({kind:L("scroll"),direction:U(["up","down"]),amount:M().int().positive().optional()}).strict(),D({kind:L("wait"),ms:M().int().positive().max(cq)}).strict()]),pq=D({id:S(),kind:L("interact"),toolName:S().min(1),action:Bq}).strict(),sI=ft("kind",[D({kind:L("textVisible"),toolName:S().min(1),text:S().min(1).max(Up)}).strict(),D({kind:L("elementVisible"),toolName:S().min(1),target:el}).strict(),D({kind:L("elementHidden"),toolName:S().min(1),target:el}).strict(),D({kind:L("inputValue"),toolName:S().min(1),target:el,equals:S().max(Up)}).strict(),D({kind:L("widgetToolCalled"),toolName:S().min(1),calledToolName:S().min(1)}).strict()]),iI=D({kind:XM().optional()}).catchall(Ln()),mq=lr([sI,cx(dc,iI)]),oI=D({id:S(),kind:L("assert"),assertion:mq}).strict(),aI=[dq,fq,pq],gq=ft("kind",[...aI,oI]);var Cq=K(gq).max(200),vq=K(ft("kind",[...aI,oI.extend({assertion:lr([sI,cx(jo,iI)])})])).max(200),vie=e=>e.kind==="prompt",yie=e=>e.kind==="toolCall",bie=e=>e.kind==="interact",Sie=e=>e.kind==="assert";function Eie(e){return typeof e.kind=="string"}var yq=["1","2"];var bq=2e3,Ad=M().min(0).max(1),Ah=M().int().min(1).max(100);function zp(e,t,n,r){return s=>{const i=s.input;return typeof i=="string"&&n.includes(i)?`${e} "${i}" is reserved and not accepted in schemaVersion ${r}; the only supported ${e} is "${t}"`:`${e} must be "${t}" in schemaVersion ${r} (received ${JSON.stringify(i)}); "${n.join('", "')}" are reserved for a future version`}}var Sq=["serverContract"],Eq=["restricted","summary"],xq=["metadataOnly","none"],$p=D({name:S().min(1).max(200),id:Gi.optional()}).strict(),wq=D({name:S().min(1).max(200),id:Gi.optional(),servers:K($p).optional()}).strict(),Gb={hosts:K(wq).min(1).optional()},Dq=lr([D({servers:K($p).min(1),environment:S().min(1).optional(),...Gb}).strict(),D({servers:K($p).min(1).optional(),environment:S().min(1),...Gb}).strict()]),$C=D({minEligibleTrials:M().int().min(1).optional(),minCompletionRate:Ad.optional(),maxEvaluatorErrorRate:Ad.optional()}).strict(),Tq=D({mode:U(["default","readOnly"]),allow:K(S().min(1)).optional(),deny:K(S().min(1)).optional()}).strict();function lI(e){return{head:{model:S().min(1),provider:S().min(1).optional(),systemPrompt:S().optional(),temperature:M().optional()},tail:{judge:QW.optional(),codeEvaluators:rq.optional(),scripts:sq.optional(),grading:iq.optional(),passThreshold:Ad,validity:$C,toolPolicy:Tq.optional(),captureLevel:L("full",{error:zp("captureLevel","full",xq,e)}).optional()}}}var Vb=lI("1"),Aq=D({...Vb.head,repetitions:Ah,...Vb.tail}).strict(),Ub=lI("2"),Iq=D({...Ub.head,iterations:Ah,...Ub.tail}).strict(),kq=D({sourceHash:S().min(1),sourceFormat:S().min(1),sourceFormatVersion:S().min(1).optional(),converter:S().min(1).optional(),converterVersion:S().min(1).optional(),model:S().min(1).optional(),discoverySnapshotHash:S().min(1).optional(),reportHash:S().min(1),importedAt:eN().optional()}).strict();function zb(e,t){return e.refine(n=>n.trim().length>0,{message:`import.${t} must not be blank`})}var Rq=D({status:mW,sourceCaseKey:zb(S().min(1).max(512),"sourceCaseKey").optional(),note:zb(S().min(1).max(bq),"note").optional()}).strict().refine(e=>e.status!=="exact"||e.note!==void 0,{message:'import.note is required when status is "exact": an exact claim is converter-asserted, not verified, so it must cite the mapping rule that earns it. Record "approximated" with a note describing the difference when no rule can be cited.',path:["note"]}),cI={id:Gi,title:S().min(1).max(200),intent:HW.optional(),scenario:S().min(1).optional(),kind:U(["capability","regression"]).nullable().optional(),steps:vq.min(1)},uI={judge:YW.optional(),expectedOutput:S().optional(),isNegativeTest:le().optional(),model:S().min(1).optional()},dI={passThreshold:Ad.optional(),disabled:le().optional(),import:Rq.optional()},Oq=D({...cI,checks:K(jo).max(50).optional(),suppressedSuiteStandardCheckIds:rI.optional(),assertions:K(jo).max(50).optional(),...uI,repetitions:Ah.optional(),...dI}).strict(),Mq=D({...cI,assertions:K(jo).max(50).optional(),suppressedSuiteStandardCheckIds:rI.optional(),...uI,iterations:Ah.optional(),...dI}).strict();function hI(e,t,n){return D({schemaVersion:L(e,{error:r=>`schemaVersion ${JSON.stringify(r.input)} is not supported by this validator, which reads schemaVersion "${e}". This file needs a newer CLI/SDK — upgrade @mcpjam/cli or @mcpjam/sdk rather than editing the file.`}),mode:L("agentWorkflow",{error:zp("mode","agentWorkflow",Sq,e)}),reportingMode:L("standard",{error:zp("reportingMode","standard",Eq,e)}),suite:D({id:Gi,name:S().min(1).max(200),description:S().optional()}).strict(),target:Dq,defaults:t,provenance:kq.optional(),cases:K(n).min(1).max(500)}).strict()}var Nq=hI("1",Aq,Oq),Pq=hI("2",Iq,Mq),Lq=ft("schemaVersion",[Nq,Pq],{error:e=>{const t=e.input?.schemaVersion;return`schemaVersion ${JSON.stringify(t)} is not supported by this validator, which reads schemaVersion ${yq.map(n=>`"${n}"`).join(" or ")}. This file needs a newer CLI/SDK — upgrade @mcpjam/cli or @mcpjam/sdk rather than editing the file.`}}),xie=Lq.superRefine((e,t)=>{const n=new Set;e.cases.forEach((r,s)=>{n.has(r.id)&&t.addIssue({code:"custom",path:["cases",s,"id"],message:`duplicate case id "${r.id}"`}),n.add(r.id);const i=new Set;r.steps.forEach((o,a)=>{i.has(o.id)&&t.addIssue({code:"custom",path:["cases",s,"steps",a,"id"],message:`duplicate step id "${o.id}" in case "${r.id}"`}),i.add(o.id)}),r.import&&!e.provenance&&t.addIssue({code:"custom",path:["cases",s,"import"],message:`case "${r.id}" records an import status but the file has no top-level \`provenance\`, so the mapping cannot be audited`})}),e.schemaVersion==="1"&&e.cases.forEach((r,s)=>{r.checks&&r.assertions&&t.addIssue({code:"custom",path:["cases",s,"checks"],message:`case "${r.id}" sets both \`checks\` and its deprecated \`assertions\` alias — set one`})})});var _q=L(2,{error:e=>e.input===void 0?"verdictPolicyVersion is required and must be 2. An absent version is a LEGACY (percent-threshold) row and must not be read as v2.":`verdictPolicyVersion ${JSON.stringify(e.input)} is not supported by this contract, which pins 2.`}),Fq=["passed","failed","inconclusive"],fI=U(Fq),Fn=M().min(0).max(1),Qt=M().int().min(0),Hq=M().int().min(1).max(100),BI=["notTerminal","skipped","setupFailed","cancelled","timedOut","executionFailed","evaluatorError"],wie=U(BI),Id=D({notTerminal:Qt.optional(),skipped:Qt.optional(),setupFailed:Qt.optional(),cancelled:Qt.optional(),timedOut:Qt.optional(),executionFailed:Qt.optional(),evaluatorError:Qt.optional()}).strict(),Wp=["measured","notMeasured"],Die=U(Wp),Xt=ft("state",[D({state:L("measured"),value:Fn,numerator:Qt,denominator:M().int().min(1),exclusions:Id}).strict(),D({state:L("notMeasured"),value:Ql(),numerator:L(0),denominator:L(0),exclusions:Id}).strict()]),pI=Xt.superRefine((e,t)=>{if(e.state!=="measured")return;e.numerator>e.denominator&&t.addIssue({code:"custom",path:["numerator"],message:`numerator ${e.numerator} exceeds denominator ${e.denominator}`});const n=e.numerator/e.denominator;e.value!==n&&t.addIssue({code:"custom",path:["value"],message:`value ${e.value} is not ${e.numerator}/${e.denominator} (${n}); a rate must be the quotient of the counts it ships with`})});function tl(e,t,n){const r=pI.safeParse(n);if(!r.success)for(const s of r.error.issues)e.addIssue({code:"custom",path:[...t,...s.path],message:s.message})}var jq=ft("kind",[D({kind:L("allConfiguredTrialsAttempted"),minGradeableTrials:L(1)}).strict(),D({kind:L("minEligibleTrials"),minEligibleTrials:M().int().min(1)}).strict()]),mI=D({coverage:jq,minCompletionRate:Fn,maxEvaluatorErrorRate:Fn}).strict(),gI=["configuredTrialsNotAttempted","noGradeableTrials","eligibleTrialsBelowMinimum","completionRateBelowMinimum","completionRateNotMeasured","evaluatorErrorRateAboveMaximum","evaluatorErrorRateNotMeasured","caseHasNoEligibleTrials"],Gq=["casePassRateMetThreshold","casePassRateBelowThreshold","allMeasuredCasesMetThreshold"],Ol=[...gI,...Gq],CI=U(Ol).describe("Why the verdict is what it is. The validity reasons are evaluated FIRST and make a run `inconclusive`; the task reasons decide `passed` / `failed` once validity holds. `configuredTrialsNotAttempted` — some configured trial never ran. `noGradeableTrials` — nothing in the suite was gradeable. `eligibleTrialsBelowMinimum` — the explicit `minEligibleTrials` was not reached. `completionRateBelowMinimum` — measured, and under the floor. `completionRateNotMeasured` — nothing was attempted, so the floor is unsatisfiable; a not-measured rate never passes one. `evaluatorErrorRateAboveMaximum` — the grader failed too often for the run to describe the server. `evaluatorErrorRateNotMeasured` — the same unsatisfiable case for the ceiling. `caseHasNoEligibleTrials` — a case graded nothing, which is inconclusive even at `passThreshold: 0`. `casePassRateMetThreshold` — a case's own passing reason. `casePassRateBelowThreshold` — a case failed its threshold, and so therefore did the suite. `allMeasuredCasesMetThreshold` — the suite's only passing reason.");function Vq(e){return typeof e=="string"&&gI.includes(e)}var Uq=2e3,oa=D({model:S().min(1).max(200),provider:S().min(1).max(200).optional(),selectionKey:S().min(1).max(Uq).optional()}).strict();function zq(e){if(!e.executionVariant)return`${e.caseId}\0`;const{model:n,provider:r,selectionKey:s}=e.executionVariant,i=`${e.caseId}\0${r??""}\0${n}`;return s===void 0?i:`${i}\0${s}`}var vI=500*100,yI=D({caseId:Gi,executionVariant:oa.optional(),configuredTrials:Hq,attemptedTrials:Qt,eligibleTrials:Qt,passedTrials:Qt,failedTrials:Qt,effectivePassThreshold:Fn,passRate:Xt,completionRate:Xt,observedStability:Xt,mixedVerdict:le(),verdict:fI,reason:CI}).strict(),$q=yI.superRefine((e,t)=>{const n=(a,l)=>t.addIssue({code:"custom",path:[a],message:l});tl(t,["passRate"],e.passRate),tl(t,["completionRate"],e.completionRate),tl(t,["observedStability"],e.observedStability),e.attemptedTrials>e.configuredTrials&&n("attemptedTrials",`attempted ${e.attemptedTrials} exceeds configured ${e.configuredTrials}`),e.eligibleTrials>e.attemptedTrials&&n("eligibleTrials",`eligible ${e.eligibleTrials} exceeds attempted ${e.attemptedTrials}`),e.passedTrials+e.failedTrials!==e.eligibleTrials&&n("eligibleTrials",`passed ${e.passedTrials} + failed ${e.failedTrials} must equal eligible ${e.eligibleTrials}: an eligible trial is one with a task verdict, so there is no third bucket`),e.mixedVerdict!==(e.passedTrials>0&&e.failedTrials>0)&&n("mixedVerdict","mixedVerdict must be true exactly when both a pass and a fail were graded"),e.passRate.denominator!==e.eligibleTrials&&n("passRate",`passRate denominator ${e.passRate.denominator} must be eligibleTrials ${e.eligibleTrials}`),e.passRate.numerator!==e.passedTrials&&n("passRate",`passRate numerator ${e.passRate.numerator} must be passedTrials ${e.passedTrials}`),e.completionRate.denominator!==e.attemptedTrials&&n("completionRate",`completionRate denominator ${e.completionRate.denominator} must be attemptedTrials ${e.attemptedTrials}`),e.observedStability.denominator!==e.eligibleTrials&&n("observedStability",`observedStability denominator ${e.observedStability.denominator} must be eligibleTrials ${e.eligibleTrials}`);const r=Math.max(e.passedTrials,e.failedTrials);if(e.observedStability.numerator!==r&&n("observedStability",`observedStability numerator ${e.observedStability.numerator} must be max(passed, failed) = ${r}`),e.eligibleTrials===0){e.verdict!=="inconclusive"&&n("verdict","a case with no eligible trials is inconclusive, whatever its threshold"),e.reason!=="caseHasNoEligibleTrials"&&n("reason",'expected reason "caseHasNoEligibleTrials"');return}if(e.passRate.state!=="measured"){n("passRate","a case with eligible trials has a measured passRate");return}const s=e.passRate.value>=e.effectivePassThreshold,i=s?"passed":"failed";e.verdict!==i&&n("verdict",`passRate ${e.passRate.value} against threshold ${e.effectivePassThreshold} is "${i}"`);const o=s?"casePassRateMetThreshold":"casePassRateBelowThreshold";e.reason!==o&&n("reason",`expected reason "${o}"`)});function Tie(e,t){if(!Number.isFinite(e)||e<=0||!Number.isFinite(t)||t<=0)return 0;const n=Math.floor(e),r=Math.min(1,t);let s=0;for(;s<n&&s/n<r;)s+=1;return s}var Wq=D({policy:mI,holds:le(),configuredTrials:Qt,attemptedTrials:Qt,eligibleTrials:Qt,completionRate:Xt,evaluatorErrorRate:Xt}).strict(),qq=D({verdictPolicyVersion:_q,verdict:fI,reasons:K(CI).min(1).max(Ol.length),validity:Wq,cases:K(yI).min(1).max(vI)}).strict();function $b(e,t,n){const r=[...n].sort((s,i)=>Ol.indexOf(s)-Ol.indexOf(i));t.length===r.length&&t.every((s,i)=>s===r[i])||e(["reasons"],`reasons must be exactly [${r.join(", ")}] in that order — the checks this decision's own measurements failed (or, once validity holds, the one its cases produced) — not [${t.join(", ")}]`)}var WC=qq.superRefine((e,t)=>{const n=(y,b)=>t.addIssue({code:"custom",path:y,message:b});for(const[y,b]of e.cases.entries()){const E=$q.safeParse(b);if(!E.success)for(const w of E.error.issues)n(["cases",y,...w.path],w.message)}const r=new Set;e.reasons.forEach((y,b)=>{r.has(y)&&n(["reasons",b],`duplicate reason "${y}"`),r.add(y)});const s=new Set,i=new Set,o=new Set;e.cases.forEach((y,b)=>{const E=zq(y);s.has(E)&&n(["cases",b],`case "${y.caseId}" already has an aggregate for this execution variant; a fan-out run reports ONE row per provider/model pair`),s.add(E),(y.executionVariant?i:o).add(y.caseId)});for(const y of i)o.has(y)&&n(["cases"],`case "${y}" mixes variant-keyed and unkeyed aggregates: an omitted executionVariant means "this run did not fan out", not "any variant", so the two cannot describe the same case`);const a=new Set(e.cases.map(y=>y.caseId)).size;a>500&&n(["cases"],`${a} distinct cases exceeds the portable suite-file maximum of 500`);const l=e.cases.reduce((y,b)=>({configured:y.configured+b.configuredTrials,attempted:y.attempted+b.attemptedTrials,eligible:y.eligible+b.eligibleTrials}),{configured:0,attempted:0,eligible:0}),c=e.validity;c.configuredTrials!==l.configured&&n(["validity","configuredTrials"],`configuredTrials ${c.configuredTrials} must be the sum over cases (${l.configured})`),c.attemptedTrials!==l.attempted&&n(["validity","attemptedTrials"],`attemptedTrials ${c.attemptedTrials} must be the sum over cases (${l.attempted})`),c.eligibleTrials!==l.eligible&&n(["validity","eligibleTrials"],`eligibleTrials ${c.eligibleTrials} must be the sum over cases (${l.eligible})`),c.completionRate.denominator!==c.attemptedTrials&&n(["validity","completionRate"],`completionRate denominator ${c.completionRate.denominator} must be attemptedTrials ${c.attemptedTrials}`),tl(t,["validity","completionRate"],c.completionRate),tl(t,["validity","evaluatorErrorRate"],c.evaluatorErrorRate),c.evaluatorErrorRate.denominator!==c.attemptedTrials&&n(["validity","evaluatorErrorRate"],`evaluatorErrorRate denominator ${c.evaluatorErrorRate.denominator} must be attemptedTrials ${c.attemptedTrials}`);const u=c.policy.coverage.kind==="minEligibleTrials"?c.eligibleTrials>=c.policy.coverage.minEligibleTrials:c.attemptedTrials===c.configuredTrials&&c.eligibleTrials>=c.policy.coverage.minGradeableTrials,d=c.completionRate.state==="measured"&&c.completionRate.value>=c.policy.minCompletionRate,h=c.evaluatorErrorRate.state==="measured"&&c.evaluatorErrorRate.value<=c.policy.maxEvaluatorErrorRate,f=e.cases.every(y=>y.eligibleTrials>0),B=u&&d&&h&&f;if(c.holds!==B&&n(["validity","holds"],`holds must be ${B} for these measurements against this policy`),!B){e.verdict!=="inconclusive"&&n(["verdict"],"validity does not hold, so the verdict is inconclusive — a run that was not measured says nothing about the server");const y=e.reasons.find(E=>!Vq(E));y&&n(["reasons"],`"${y}" is a task reason, but validity is evaluated first and did not hold`);const b=[];c.policy.coverage.kind==="allConfiguredTrialsAttempted"?(c.attemptedTrials!==c.configuredTrials&&b.push("configuredTrialsNotAttempted"),c.eligibleTrials<c.policy.coverage.minGradeableTrials&&b.push("noGradeableTrials")):c.eligibleTrials<c.policy.coverage.minEligibleTrials&&b.push("eligibleTrialsBelowMinimum"),c.completionRate.state!=="measured"?b.push("completionRateNotMeasured"):d||b.push("completionRateBelowMinimum"),c.evaluatorErrorRate.state!=="measured"?b.push("evaluatorErrorRateNotMeasured"):h||b.push("evaluatorErrorRateAboveMaximum"),f||b.push("caseHasNoEligibleTrials"),$b(n,e.reasons,b);return}const g=e.cases.find(y=>y.verdict==="inconclusive"),C=e.cases.find(y=>y.verdict==="failed"),v=g?"inconclusive":C?"failed":"passed";e.verdict!==v&&n(["verdict"],`with validity holding, the cases make this run "${v}"`),$b(n,e.reasons,[v==="passed"?"allMeasuredCasesMetThreshold":"casePassRateBelowThreshold"])});var Ie=M().int().min(0);var Kq=rr.length,Jq=["provisional","final"],qC=U(Jq),Ml=D({lifecycle:Ie.optional(),integrity:Ie.optional(),version:Ie.optional(),notApplicable:Ie.optional(),reachUnknown:Ie.optional(),notMeasured:Ie.optional()}).strict(),Qq=D({notTerminal:Ie.optional(),skipped:Ie.optional(),cancelled:Ie.optional(),setupFailed:Ie.optional(),timedOut:Ie.optional(),executionFailed:Ie.optional(),evaluatorError:Ie.optional(),chainMissing:Ie.optional(),chainUnverified:Ie.optional(),chainVersionAhead:Ie.optional(),measurementsMissing:Ie.optional(),measurementsInvalid:Ie.optional(),measurementsVersionAhead:Ie.optional(),analyzerMismatch:Ie.optional()}).strict(),Aie=ft("state",[D({state:L(Wp[0]),value:Fn,numerator:Ie,denominator:M().int().min(1),exclusions:Ml}).strict(),D({state:L(Wp[1]),value:Ql(),numerator:L(0),denominator:L(0),exclusions:Ml}).strict()]);function KC(e,t,n={}){return!Number.isInteger(e)||!Number.isInteger(t)||t<=0||e<0||e>t?{state:"notMeasured",value:null,numerator:0,denominator:0,exclusions:n}:{state:"measured",value:e/t,numerator:e,denominator:t,exclusions:n}}function bI(e){return D({unit:L("ms"),basis:L(e),sampleCount:M().int().min(1),totalMs:M().finite().min(0),minMs:M().finite().min(0),maxMs:M().finite().min(0)}).strict().superRefine((t,n)=>{t.minMs>t.maxMs&&n.addIssue({code:"custom",path:["minMs"],message:`minMs ${t.minMs} exceeds maxMs ${t.maxMs}`}),t.totalMs<t.minMs*t.sampleCount&&n.addIssue({code:"custom",path:["totalMs"],message:`totalMs ${t.totalMs} is below minMs × sampleCount (${t.minMs} × ${t.sampleCount}); the counts and bounds describe different sample sets`}),t.totalMs>t.maxMs*t.sampleCount&&n.addIssue({code:"custom",path:["totalMs"],message:`totalMs ${t.totalMs} exceeds maxMs × sampleCount (${t.maxMs} × ${t.sampleCount}); the counts and bounds describe different sample sets`})})}var Yq=bI(ZA),Xq=bI(jW);function Iie(e){return e===void 0||e.sampleCount<=0?null:e.totalMs/e.sampleCount}var Zq=D({reason:JA,count:M().int().min(1)}).strict(),e8=D({stage:Vi,applicable:Ie,reached:Ie,notReached:Ie,reachUnknown:Ie,measured:Ie,passed:Ie,failed:Ie,notMeasured:Ie,notApplicable:Ie,excluded:Ml,reasons:K(Zq).max(zC.length),latency:Yq.optional()}).strict().superRefine((e,t)=>{e.passed+e.failed!==e.measured&&t.addIssue({code:"custom",path:["measured"],message:`measured ${e.measured} is not passed + failed (${e.passed} + ${e.failed})`}),e.measured+e.notMeasured!==e.reached&&t.addIssue({code:"custom",path:["reached"],message:`reached ${e.reached} is not measured + notMeasured (${e.measured} + ${e.notMeasured})`}),e.reached+e.notReached+e.reachUnknown!==e.applicable&&t.addIssue({code:"custom",path:["applicable"],message:`applicable ${e.applicable} is not reached + notReached + reachUnknown (${e.reached} + ${e.notReached} + ${e.reachUnknown})`}),e.latency!==void 0&&e.latency.sampleCount>e.reached&&t.addIssue({code:"custom",path:["latency","sampleCount"],message:`latency sampleCount ${e.latency.sampleCount} exceeds reached ${e.reached}; a stage cannot be timed more often than it ran`})}),t8=D({category:UC,count:M().int().min(1)}).strict(),n8=ft("dimension",[D({dimension:L("overall")}).strict(),D({dimension:L("intent"),intent:S().min(1).nullable()}).strict(),D({dimension:L("model"),provider:S().min(1),model:S().min(1)}).strict(),D({dimension:L("host"),hostKey:S().min(1),hostName:S().min(1).optional(),executionEngine:S().min(1).optional()}).strict()]),r8=D({slice:n8,includedTrials:Ie,excludedTrials:Ml,failureCategories:K(t8).max(VC.length),stages:K(e8).length(Kq)}).strict().superRefine((e,t)=>{rr.forEach((n,r)=>{const s=e.stages[r];s!==void 0&&s.stage!==n&&t.addIssue({code:"custom",path:["stages",r,"stage"],message:`stages[${r}] is '${s.stage}' but must be '${n}': the six tallies are a funnel and position is meaning`})})}),SI=["connection","discovery"],s8=D({phase:U(SI),uniqueAttempts:Ie,failedAttempts:Ie,serverAttributedFailures:Ie,impactedTrials:Ie,latency:Xq.optional()}).strict().superRefine((e,t)=>{e.failedAttempts>e.uniqueAttempts&&t.addIssue({code:"custom",path:["failedAttempts"],message:`failedAttempts ${e.failedAttempts} exceeds uniqueAttempts ${e.uniqueAttempts}`}),e.serverAttributedFailures>e.failedAttempts&&t.addIssue({code:"custom",path:["serverAttributedFailures"],message:`serverAttributedFailures ${e.serverAttributedFailures} exceeds failedAttempts ${e.failedAttempts}`}),e.latency!==void 0&&e.latency.sampleCount>e.uniqueAttempts&&t.addIssue({code:"custom",path:["latency","sampleCount"],message:`latency sampleCount ${e.latency.sampleCount} exceeds uniqueAttempts ${e.uniqueAttempts}; setup latency is sampled once per attempt, never once per copied iteration`})}),i8=D({dimension:U(["intent","model","host"]),distinctValues:M().int().min(1),retained:M().int().min(0)}).strict(),o8=D({schemaVersion:L(1),measurementUnit:L("trial"),runId:S().min(1),suiteId:S().min(1),runGroupId:S().min(1).optional(),configRevision:S().min(1).optional(),caseSetFingerprint:S().min(1).optional(),organizationId:S().min(1).optional(),workspaceId:S().min(1).optional(),projectId:S().min(1).optional(),runCompletedAt:M().int().min(0).optional(),sourceIterationCount:Ie,sourceMaxUpdatedAt:M().int().min(0).optional(),stageAnalyzerVersion:M().int().min(1),sourceStageAnalyzerVersions:K(M().int().min(1)).min(2).optional(),measurementsSchemaVersion:M().int().min(1),sourceMeasurementsSchemaVersions:K(M().int().min(1)).min(2).optional(),materializationState:qC,createdAt:M().int().min(0),updatedAt:M().int().min(0),includedTrials:Ie,excludedTrials:Ml,totalTrials:Ie,excludedTrialDetail:Qq,slices:K(r8).max(101),setup:K(s8).max(SI.length),sliceTruncation:K(i8).max(3).optional()}).strict(),kie=o8.superRefine((e,t)=>{const n=e.slices.filter(i=>i.slice.dimension==="overall"),[r]=n;n.length!==1||r===void 0?t.addIssue({code:"custom",path:["slices"],message:`expected exactly one 'overall' slice, found ${n.length}: the overall funnel is the one slice every reader can rely on`}):r.includedTrials!==e.includedTrials&&t.addIssue({code:"custom",path:["slices"],message:`the overall slice counts ${r.includedTrials} included trials but the row counts ${e.includedTrials}`}),e.includedTrials>e.totalTrials&&t.addIssue({code:"custom",path:["includedTrials"],message:`includedTrials ${e.includedTrials} exceeds totalTrials ${e.totalTrials}`});const s=e.setup.map(i=>i.phase);new Set(s).size!==s.length&&t.addIssue({code:"custom",path:["setup"],message:`duplicate setup phases ${JSON.stringify(s)}: a phase is measured once per run and two rows for one phase means the copies were counted`})});function Rie(e){return KC(e.measured,e.reached,{...e.excluded,...e.notMeasured>0?{notMeasured:e.notMeasured}:{}})}function Oie(e){return KC(e.passed,e.measured,{...e.excluded,...e.notMeasured>0?{notMeasured:e.notMeasured}:{}})}function Mie(e){return KC(e.reached,e.reached+e.notReached,{...e.excluded,...e.reachUnknown>0?{reachUnknown:e.reachUnknown}:{}})}var EI=["iterations","casesIgnoringExecutionVariant"],a8=lr([L(0),L(1)]),l8=ft("scope",[D({scope:L("perCase"),threshold:Fn}).strict(),D({scope:L("suiteWide"),thresholdPercent:M().min(0).max(100),population:U(EI),emptyPopulationRate:a8}).strict()]),xI=M().int().min(1).max(100);var c8=ft("kind",[D({kind:L("defaultCount"),iterations:xI}).strict(),D({kind:L("caseCountWithFloor"),minimumIterations:M().int().min(1).max(10).nullable()}).strict()]),u8=ft("enforced",[D({enforced:L(!1)}).strict(),D({enforced:L(!0),declared:$C,resolved:mI}).strict()]),d8=D({caseRef:S().min(1).max(200),iterations:xI.optional(),passThreshold:Fn.optional()}).strict(),wI=["suiteFile","hostedPerCase","hostedSuiteWide","runReporting"],h8=D({passCriterion:l8,iterationRule:c8,validity:u8,caseOverrides:K(d8),origin:U(wI)}).strict(),Nie=h8.superRefine((e,t)=>{e.passCriterion.scope==="suiteWide"&&e.caseOverrides.forEach((n,r)=>{n.passThreshold!==void 0&&t.addIssue({code:"custom",path:["caseOverrides",r,"passThreshold"],message:`case "${n.caseRef}" carries a per-case passThreshold under a suite-wide criterion, where nothing reads it: the suite-wide rate is measured once over the whole run. Change the criterion scope to perCase, or drop the override.`})})}),f8=["hosted","localFallback"],B8=["iterationsNotRepresentable","minimumIterationsNotRepresentable","validityNotEnforced","readOnlyPolicy"],Pie=D({passThreshold:Fn.optional(),iterations:M().int().min(1).max(100).optional(),minimumIterations:lr([M().int().min(1).max(10),Ql()]).optional(),validity:$C.optional()}).strict();var Ih=["identifierSurfacedUnused","searchRepeatedAfterIdentifier","identicalRetry","changedRetry","paginationContinuation"],Lie=U(Ih),p8=["identifierSurfacedUnused","searchRepeatedAfterIdentifier"],DI=["noToolCalls","resultsUnavailable","orderingUnknown","evidenceIncomplete","truncated"],TI=U(DI);var AI=["cursor","nextCursor","page","pageToken","offset","after","before","start","limit"],_ie=new Set(AI),sr=M().int().min(0),qf=M().int().min(0),mc=S().min(1),II=S().min(1),m8=D({kind:L("identifierSurfacedUnused"),informationCallIndex:sr,observedAtCallIndex:sr,toolName:mc,toolCallId:S().min(1).optional(),identifierKeyPaths:K(II).max(8),identifierCount:M().int().min(1),laterCallCount:M().int().min(2)}).strict(),g8=D({kind:L("searchRepeatedAfterIdentifier"),informationCallIndex:sr,observedAtCallIndex:sr,toolName:mc,toolCallId:S().min(1).optional(),repeatCallIndexes:K(sr).min(1).max(8),identifierKeyPaths:K(II).max(8),identifierCount:M().int().min(1)}).strict(),C8=D({kind:L("identicalRetry"),callIndex:sr,priorCallIndex:sr,toolName:mc,afterError:le()}).strict(),v8=D({kind:L("changedRetry"),callIndex:sr,priorCallIndex:sr,toolName:mc,afterError:le()}).strict(),y8=D({kind:L("paginationContinuation"),callIndex:sr,priorCallIndex:sr,toolName:mc,paginationKeys:K(U(AI)).min(1).max(4)}).strict(),b8=ft("kind",[m8,g8,C8,v8,y8]),S8=ft("state",[D({state:L("measured")}).strict(),D({state:L("notMeasured"),reason:TI}).strict()]),E8=D({version:L(1),state:U(["measured","notMeasured"]),notMeasuredReason:TI.optional(),callCount:qf,resultAvailableCount:qf,timedCallCount:qf,identifierSignals:S8,signals:K(b8).max(24)}).strict();function x8(e){return e.kind==="identifierSurfacedUnused"||e.kind==="searchRepeatedAfterIdentifier"?e.observedAtCallIndex:e.callIndex}var Fie=E8.superRefine((e,t)=>{e.state==="notMeasured"?(e.notMeasuredReason===void 0&&t.addIssue({code:"custom",path:["notMeasuredReason"],message:"a notMeasured document must say why"}),e.signals.length>0&&t.addIssue({code:"custom",path:["signals"],message:"a notMeasured document cannot carry signals"})):e.notMeasuredReason!==void 0&&t.addIssue({code:"custom",path:["notMeasuredReason"],message:"a measured document must not carry a notMeasured reason"}),e.resultAvailableCount>e.callCount&&t.addIssue({code:"custom",path:["resultAvailableCount"],message:`resultAvailableCount ${e.resultAvailableCount} cannot exceed callCount ${e.callCount}`}),e.timedCallCount>e.callCount&&t.addIssue({code:"custom",path:["timedCallCount"],message:`timedCallCount ${e.timedCallCount} cannot exceed callCount ${e.callCount}`});let n=-1;for(const[r,s]of e.signals.entries()){const i=["signals",r];e.identifierSignals.state==="notMeasured"&&p8.includes(s.kind)&&t.addIssue({code:"custom",path:[...i,"kind"],message:"identifier signals are notMeasured, so no identifier-kind signal may be present"});const o=s.kind==="identifierSurfacedUnused"||s.kind==="searchRepeatedAfterIdentifier"?[["informationCallIndex",s.informationCallIndex],["observedAtCallIndex",s.observedAtCallIndex]]:[["priorCallIndex",s.priorCallIndex],["callIndex",s.callIndex]];for(const[l,c]of o)c>=e.callCount&&t.addIssue({code:"custom",path:[...i,l],message:`${l} ${c} must be below callCount ${e.callCount}`});if(s.kind==="identifierSurfacedUnused"||s.kind==="searchRepeatedAfterIdentifier"){if(s.informationCallIndex>=s.observedAtCallIndex&&t.addIssue({code:"custom",path:[...i,"observedAtCallIndex"],message:"observedAtCallIndex must be after informationCallIndex — the pattern cannot become observable before it happened"}),s.kind==="searchRepeatedAfterIdentifier")for(const[l,c]of s.repeatCallIndexes.entries())c>s.observedAtCallIndex&&t.addIssue({code:"custom",path:[...i,"repeatCallIndexes",l],message:"a repeat cannot fall after the observation index"})}else s.priorCallIndex>=s.callIndex&&t.addIssue({code:"custom",path:[...i,"priorCallIndex"],message:"priorCallIndex must be before callIndex"});const a=x8(s);a<n&&t.addIssue({code:"custom",path:i,message:"signals must be ordered by the call that made them observable"}),n=a}}),Hie=new Map(Ih.map((e,t)=>[e,t])),kI=["unclear","idBuriedInPayload","idNameCollision","missingQueryEcho","silentTruncation","ambiguousErrorSemantics","missingUnits","responseWasClear","descriptionMisleading"],w8=U(kI),D8=["low","medium","high"],T8=U(D8),A8=["spendBlocked","traceIncomplete","noEvidence","cap"];var I8=D({callIndex:M().int().min(0),toolName:S().min(1),fieldPath:S().min(1).max(120).optional()}).strict(),Kf={gradingKey:S().min(1),signalKind:S().min(1),informationCallIndex:M().int().min(0),observedAtCallIndex:M().int().min(0),judgeTemplateVersion:M().int().min(1),judgeTemplateHash:S().min(1),model:S().min(1),generatedAt:M().int().min(0)},jie=ft("status",[D({status:L("scored"),condition:w8,confidence:T8,remediation:S().min(1).max(300).optional(),evidence:I8.optional(),...Kf}).strict(),D({status:L("skipped"),reason:U(A8),...Kf}).strict(),D({status:L("error"),...Kf}).strict()]);var k8=["pending","running","succeeded","failed","rate_limited"],R8=["pending","running","ran","broke","limited","withdrawn"],O8=["passed","failed","inconclusive","notEstablished"],M8=["notRequested","queued","running","settled","unavailable"],N8=["canceled","stale_runner","runner_shutdown","run_timeout"],RI={attemptPending:"notEstablished",attemptRunning:"notEstablished",withdrawn:"notEstablished",spendCapReached:"notEstablished",notRun:"notEstablished",executionFailed:"notEstablished",ungraded:"notEstablished",gradingNotClaimed:"notEstablished",criteriaPending:"notEstablished",judgePending:"notEstablished",gatingCriterionFailed:"failed",judgeFailed:"failed",criteriaGradingErrored:"inconclusive",gatingCriterionUnmeasured:"inconclusive",judgeErrored:"inconclusive",gradingUnavailable:"inconclusive",allGatingCriteriaPassed:"passed",judgePassed:"passed",allGradersPassed:"passed"},P8=Object.keys(RI),L8=U(R8),JC=U(O8),Wb=U(["advisory","required"]),_8=D({status:U(k8),errorCode:S().nullable().optional()}).strict(),OI=D({state:U(M8),reasonCode:S().min(1).optional()}).strict(),F8=D({criterionId:S().min(1),passed:le(),status:U(["scored","error"]).optional()}).strict(),Gie=D({attempt:_8.nullable(),hasTranscript:le(),rubric:K(D({id:S().min(1),role:Wb,predicateType:S().min(1).optional()}).strict()),criteria:D({status:U(["pending","completed","failed"]),criterionIds:K(S().min(1)).optional(),results:K(F8).optional()}).strict().nullable(),goalScore:ft("status",[D({status:L("completed"),passed:le()}).strict(),D({status:L("running")}).strict(),D({status:L("failed")}).strict()]).nullable(),judge:D({automatic:le(),role:Wb,requested:le().optional()}).strict(),grading:OI}).strict().superRefine((e,t)=>{const n=new Set(e.rubric.map(s=>s.id));n.size!==e.rubric.length&&t.addIssue({code:"custom",path:["rubric"],message:"Duplicate criterion definition"});for(const[s,i]of[["criterionIds",e.criteria?.criterionIds??[]],["results",e.criteria?.results?.map(o=>o.criterionId)??[]]])(new Set(i).size!==i.length||i.some(o=>!n.has(o)))&&t.addIssue({code:"custom",path:["criteria",s],message:"Criterion IDs must be unique and defined in the snapshot"});const r=e.criteria?.criterionIds;r&&e.criteria?.results?.some(s=>!r.includes(s.criterionId))&&t.addIssue({code:"custom",path:["criteria","results"],message:"Result outside claimed scope"})}),H8=["pending","running","completed","failed","setup_failed","cancelled"],j8=D({status:U(H8),taskVerdict:U(["passed","failed"]).optional(),evaluatorError:L(!0).optional()}).strict().superRefine((e,t)=>{const n=e.taskVerdict!==void 0,r=e.evaluatorError===!0;(e.status==="completed"?n===r:n||r)&&t.addIssue({code:"custom",message:"Only completed trials carry exactly one verdict or evaluator error"})}),G8=D({gating:M().int().nonnegative(),gatingPassed:M().int().nonnegative(),gatingFailed:M().int().nonnegative(),gatingUnmeasured:M().int().nonnegative(),advisoryFailed:M().int().nonnegative()}).strict(),V8=D({contractVersion:L(1),lifecycle:L8,verdict:JC,reason:U(P8),verdictSource:U(["goalJudge","requiredAssertions","combined","none"]),grading:OI,graders:D({criteria:U(["notConfigured","notClaimed","pending","scored","errored"]),judge:U(["notConfigured","silent","pending","scored","errored"])}).strict(),counts:G8,trial:j8.nullable()}).strict().superRefine((e,t)=>{const n=i=>t.addIssue({code:"custom",message:i});RI[e.reason]!==e.verdict&&n("Reason contradicts verdict");const r=e.counts;r.gating!==r.gatingPassed+r.gatingFailed+r.gatingUnmeasured&&n("Required measurement counts do not add up");const s=e.trial;s?.status==="completed"&&(e.lifecycle!=="ran"&&n("Only a completed execution can be a completed trial"),s.taskVerdict!==void 0&&s.taskVerdict!==e.verdict&&n("Trial contradicts goal result"),s.evaluatorError&&e.verdict!=="inconclusive"&&n("Evaluator error requires inconclusive grading")),e.lifecycle!=="ran"&&s?.status!=={pending:"pending",running:"running",broke:"failed",limited:"setup_failed",withdrawn:"cancelled"}[e.lifecycle]&&n("Trial must preserve execution lifecycle"),e.lifecycle==="ran"&&s!==null&&s.status!=="completed"&&n("Completed execution must not become skipped or running"),(e.verdict==="passed"||e.verdict==="failed")&&e.verdictSource==="none"&&n("A measured goal verdict needs a source"),e.lifecycle==="ran"&&e.verdict!=="notEstablished"&&s===null&&n("Settled grading on completed execution needs an observation"),e.verdict==="notEstablished"&&e.verdictSource!=="none"&&n("An undecided goal has no verdict source")});function Vie(e,t=!1){return!e||e.status==="pending"?"pending":e.status==="running"?"running":N8.includes(e.errorCode)?"withdrawn":e.status==="rate_limited"&&!t?"limited":e.status==="succeeded"?"ran":"broke"}function Uie(e,t){return(e==="broke"||e==="limited"||e==="withdrawn")&&t===0}function zie(e){return e?e.verdict==="notEstablished"?["queued","running"].includes(e.grading.state)?"Grading":e.reason==="ungraded"?"Not graded":"Not established":U8(e.verdict):"Unknown"}function U8(e){return{passed:"Passed",failed:"Failed",inconclusive:"Inconclusive",notEstablished:"Not established"}[e]}var qp=["notRun","blockedConnecting","lostFindingTool","blockedCallingTool","blockedByResponse","goalMissed","goalMetWithFriction","goalMet","notMeasured"],MI=["fail","warn","ok","muted"],Kp=["notLaunched","broken","friction","landed","ungraded","unread"],Jp=["sessionScanCapped","budgetExhausted","transcriptMissing","contextTooLarge","extractionRejected","chainUnmeasured","judgeNotRun","sessionsWithdrawn","sessionsRateLimited","partialRead","toolCatalogMissing","mechanismsRejected","analysisUnavailable"],Qp=["outputTruncated","hallucinatedTool","toolErrored","noToolCalled","turnCapReached"],Yp=["session","goal","persona","target","wave"],Xp=["verifiedMechanism","sessionReport","populationFact"],z8=["derived","reported","unmeasured"],$8=Object.freeze({notRun:"muted",blockedConnecting:"fail",lostFindingTool:"fail",blockedCallingTool:"fail",blockedByResponse:"fail",goalMissed:"fail",goalMetWithFriction:"warn",goalMet:"ok",notMeasured:"muted"}),Is=e=>e.map(t=>"`"+t+"`").join(", "),kt=M().int().nonnegative(),NI=D({personaRefId:S().nullable(),name:S()}).strict(),PI=U(qp).describe(Is(qp)),LI=K(U(Jp).describe(Is(Jp))),qb=K(S().regex(/^[^/]+\/.+$/)).max(30),_I=e=>e.tone===$8[e.disposition],FI={message:"tone must equal SWARM_FINDING_TONE_OF_DISPOSITION[disposition]",path:["tone"]},W8=D({id:S().min(1),basis:U(Xp).describe(Is(Xp)),scopeLevel:U(Yp).describe(Is(Yp)),persona:NI,goal:D({runId:S(),journeyRefId:S(),title:S()}).strict(),target:D({kind:U(["environment","host"]),id:S(),label:S(),modelId:S().nullable()}).strict(),population:D({count:kt,total:kt,unit:L("sessions")}).strict(),sessionIds:K(S()).max(1e3),citations:qb,verdictSeen:JC,chainStage:Vi.nullable().describe(Is(rr)),chainStageState:KA.nullable().describe(Is(GC)),chainStageBasis:U(z8),disposition:PI,tone:U(MI),coverageNotes:LI,outcomePhrase:S().max(100).regex(/^[^0-9]*$/).refine(e=>e.trim().split(/\s+/).length<=8,"At most eight words").nullable(),mechanismPhrase:S().nullable(),fixPhrase:S().nullable(),reportExcerpt:D({actual:S().max(1800),account:S().max(600).nullable().optional(),citations:qb}).strict().nullable(),mechanismId:S().nullable(),signal:U(Qp).describe(Is(Qp)).nullable().optional()}).strict().refine(_I,FI),$ie=D({contractVersion:L(1),generatedAt:kt,sourceRevision:S(),pipelineVersion:kt,extractionVersion:kt,extractionModel:S(),reasoningModel:S(),summaryKind:U(Kp).describe(Is(Kp)),population:D({configured:kt,started:kt,read:kt,unread:kt,withdrawn:kt,limited:kt,graded:kt}).strict(),coverageNotes:LI,disclosure:D({rail:U(["gateway","openrouter"]),evidenceSent:K(S())}).strict(),personas:K(D({persona:NI,disposition:PI,tone:U(MI),goalRunIds:K(S())}).strict().refine(_I,FI)),findings:K(W8).max(200),verification:D({proposed:kt,confirmed:kt,rejected:kt,unverified:kt,omitted:kt}).strict().optional()}).strict(),Wie=D({status:U(["pending","completed","failed","skipped"]),errorCode:S().optional(),updatedAt:kt}).strict(),qie=Object.freeze({connection:"Connection",discovery:"Discovery",selection:"Selection",call:"Tool call",response:"Response",userValue:"User value"}),Kie=Object.freeze({connection:"Could the client reach the server and initialize a session?",discovery:"Did the client receive usable primitives and metadata?",selection:"Did the model choose the right tool for the request?",call:"Was the call made with usable arguments?",response:"Did the server return data the model could use?",userValue:"Was the user's actual request satisfied?"}),Jie=Object.freeze({connection:"Session connected",discovery:"Tools and resources discovered",selection:"Right tool selected",call:"Valid call made",response:"Usable response returned",userValue:"Request satisfied"}),Qie=Object.freeze({passed:"passed",failed:"failed",notReached:"never ran (an earlier stage failed)",notMeasured:"not measured",notApplicable:"not applicable to this case"}),Yie=Object.freeze({setup:"setup",metadata:"tool metadata",selection:"tool selection",arguments:"call arguments",serverData:"server data",userValue:"user value",evaluator:"evaluator"}),Xie=Object.freeze({noSpanChannel:"this run captures no evidence channel for that stage",noEvidenceCaptured:"nothing eligible for that stage was captured",matchVerdictUnavailable:"extra tool calls were captured but the run did not report whether its match options tolerate them",traceAbsent:"the iteration recorded no trace",executorEmitsNoSpans:"the executor emitted no spans",blockedByPolicy:"a policy blocked the run before it could be measured",evaluatorError:"the evaluator itself failed, so the run says nothing about the server",providerError:"the model provider failed the call, so this stage was never measured",setupAborted:"the environment was never prepared, so the test never began",connectFailed:"the configured server was reached and initialize failed there",toolsListFailed:"initialize succeeded and listing tools failed",egressUnverified:"the connection failed with no evidence that our own network egress works",lifecycleStopped:"the run was stopped mid-flight",notAuthored:"the case asserts nothing this stage could decide",earlierStageFailed:"an earlier stage failed",missingToolCall:"an expected tool call was never made",unexpectedToolCall:"a tool call was made that the case did not expect",argumentMismatch:"the call arguments did not match what the case expects",toolError:"the server reported a tool error",protocolError:"the call never produced a result",renderFailed:"the widget did not render",predicateFailed:"an assertion on the result did not hold",observed:"the evidence was inspected and the stage held",impliedByLaterEvidence:"a later stage's success implies it",judgeObserved:"the LLM judge scored at or above the threshold",judgePartial:"the LLM judge scored inside the partial band — at or above the floor, below the threshold",judgeFailed:"the LLM judge scored below the partial floor",judgePending:"an LLM judge verdict is owed and has not arrived",judgeNotRequested:"no LLM judge verdict was ever owed"}),Zie=Object.freeze({missingToolCall:"if this pull request intentionally renamed or removed the expected tool, update this case's expected tool call in MCPJam so the check matches the server; if the tool should still be chosen for this prompt, review its name and description in the tool catalog, then push again",unexpectedToolCall:"decide which side is right: if the extra call is correct behaviour, widen this case's expected tool calls or its match options in MCPJam; if it is not, review the names and descriptions that made the extra tool look applicable",argumentMismatch:"compare the recorded call against the tool's input schema: if this pull request changed the schema, update the case's expected arguments in MCPJam; otherwise review the parameter descriptions that led the model to fill them this way",toolError:"read the error the server returned on the tool result: fix the handler if the arguments were valid, or tighten the input schema so the model cannot send what the handler rejects",protocolError:"the call failed instead of returning a result: read the recorded failure for that call, and its error code where one was captured, to tell a rejection by the server from a connection that broke between the two sides",renderFailed:"read the recorded render status: it names the step that failed — for example no UI resource on the tool result, a widget that never mounted, or a bridge handshake that never completed",predicateFailed:"read the recorded reasons: either this pull request changed the response, or the case asserts something the server no longer promises",connectFailed:"the server was reached and initialize failed there: check the start command in the run recipe and the port the recipe declares",toolsListFailed:"initialize succeeded and listing tools failed: check the server's tools/list handler",setupAborted:"the environment was never prepared, so nothing here is a statement about the server: check the build and start steps in the run recipe",evaluatorError:"the evaluator itself failed, so this case says nothing about the server: check the suite's evaluator configuration",blockedByPolicy:"a policy stopped this run before it could be measured: check the suite's tool policy and the environment it runs against",lifecycleStopped:"the run was stopped mid-flight, so this case reached no verdict: re-run the check",notAuthored:"this case asserts nothing this stage could decide: add a check in MCPJam if this stage should be measured",judgeFailed:"read the judge's rationale on the run: either the response stopped satisfying the case's goal, or the goal needs rewording to match what the server now returns",judgePartial:"read the judge's rationale on the run: the response was close to the case's goal but under its threshold, so either the server's answer or the threshold needs to move"}),eoe=Object.freeze(["noSpanChannel","noEvidenceCaptured","matchVerdictUnavailable","traceAbsent","executorEmitsNoSpans","providerError","egressUnverified","earlierStageFailed","observed","impliedByLaterEvidence","judgeObserved","judgePending","judgeNotRequested"]),toe=Object.freeze({configuredTrialsNotAttempted:"some configured iteration never ran, so the run does not cover what it was asked to",noGradeableTrials:"nothing in the run produced a gradeable verdict",eligibleTrialsBelowMinimum:"fewer gradeable iterations than the suite's validity floor requires",completionRateBelowMinimum:"too few attempted iterations completed to meet the suite's completion floor",completionRateNotMeasured:"nothing was attempted, so the completion floor cannot be satisfied",evaluatorErrorRateAboveMaximum:"the evaluator failed too often for this run to describe the server",evaluatorErrorRateNotMeasured:"nothing was attempted, so the evaluator-error ceiling cannot be satisfied",caseHasNoEligibleTrials:"a case graded nothing at all",casePassRateMetThreshold:"the case met its pass threshold",casePassRateBelowThreshold:"a case did not meet its pass threshold",allMeasuredCasesMetThreshold:"every measured case met its threshold"}),noe=Object.freeze({setup:"check the server connection and environment configuration",metadata:"review the tool metadata and descriptions in the server catalog",selection:"review tool selection and the tool catalog",arguments:"review the authored arguments against the tool input schema",serverData:"inspect the tool response returned by the server",userValue:"review whether the response answered the user's goal",evaluator:"check the evaluator configuration; the case was not graded"}),roe="inspect the case trace; no failure category was recorded",Kb=Object.freeze({notTerminal:"still running, so nothing final to compare",skipped:"deliberately not run",cancelled:"cancelled before it finished",setupFailed:"its environment was never prepared, so the test never began",timedOut:"timed out",executionFailed:"failed to execute",evaluatorError:"the evaluator itself failed, so it says nothing about the server",chainMissing:"no stage chain was ever recorded",chainUnverified:"its stage chain did not validate",chainVersionAhead:"its stage chain was produced by a newer analyzer than this reader knows",measurementsMissing:"no stage measurements were recorded",measurementsInvalid:"its stage measurements did not validate",measurementsVersionAhead:"its stage measurements were produced by a newer schema than this reader knows",analyzerMismatch:"its chain and its measurements were produced by different analyzers"});function soe(e){const t=[];for(const n of Object.keys(Kb)){const r=e[n];r!==void 0&&r>0&&t.push({key:n,label:Kb[n],count:r})}return t}var ioe=Object.freeze({identifierSurfacedUnused:"Identifiers surfaced, none used later",searchRepeatedAfterIdentifier:"Same tool searched again after identifiers",identicalRetry:"Repeated with identical arguments",changedRetry:"Same tool called again with changed arguments",paginationContinuation:"Pagination continued"}),ooe=Object.freeze({noToolCalls:"no tool calls to look at",resultsUnavailable:"tool results were not retained",orderingUnknown:"the calls cannot be placed in a causal order",evidenceIncomplete:"the evidence for this iteration has a known hole",truncated:"too many tool calls to measure"}),aoe=Object.freeze({unclear:"could not attribute",idBuriedInPayload:"identifier buried in payload",idNameCollision:"identifier name collision",missingQueryEcho:"response does not echo the query",silentTruncation:"response truncated without saying so",ambiguousErrorSemantics:"error text does not say whether to retry",missingUnits:"value has no stated unit",responseWasClear:"the response was clear",descriptionMisleading:"tool description points the wrong way"}),loe=Object.freeze({low:"low confidence",medium:"medium confidence",high:"high confidence"}),coe=Object.freeze({notRun:"Not run",blockedConnecting:"Stuck",lostFindingTool:"Lost",blockedCallingTool:"Annoyed",blockedByResponse:"Frustrated",goalMissed:"Stalled",goalMetWithFriction:"Uneasy",goalMet:"Relieved",notMeasured:"Unscored"}),uoe=Object.freeze({sessionScanCapped:"Session scan limit reached",budgetExhausted:"Analysis budget exhausted",transcriptMissing:"Transcript unavailable",contextTooLarge:"Transcript exceeds analysis limits",extractionRejected:"Analysis could not be verified",chainUnmeasured:"Journey stages not measured",judgeNotRun:"Judge did not run",sessionsWithdrawn:"Some sessions were withdrawn",sessionsRateLimited:"Some sessions were rate limited",partialRead:"Only part of this wave was read",toolCatalogMissing:"Tool catalog unavailable",mechanismsRejected:"A possible cause was rejected",analysisUnavailable:"Causes could not be analysed"}),doe=Object.freeze({notLaunched:"Not launched",broken:"Goals blocked",friction:"Goals met with friction",landed:"Goals met",ungraded:"Not graded",unread:"Not fully read"}),hoe=Object.freeze({verifiedMechanism:"Verified explanation",sessionReport:"Session report",populationFact:"Population fact"}),foe=Object.freeze({outputTruncated:"Reply cut off",hallucinatedTool:"Called a tool that does not exist",toolErrored:"A tool errored",noToolCalled:"No tool used",turnCapReached:"Hit the turn limit"}),Boe=Object.freeze({swarmFindingDispositions:qp,swarmFindingCoverageNotes:Jp,swarmFindingSummaryKinds:Kp,swarmFindingBases:Xp,swarmFindingScopeLevels:Yp,swarmFindingSignals:Qp,stages:rr,stageStates:GC,failureCategories:VC,stageReasons:zC,verdictDecisionReasons:Ol,frictionSignalKinds:Ih,frictionNotMeasuredReasons:DI,suspectedConditions:kI}),poe=Object.freeze({perCase:"Per-case pass rate",suiteWide:"Suite accuracy"}),moe=Object.freeze({perCase:"Each case must pass at least this share of its own iterations. A case that falls short fails, whatever the rest of the suite did.",suiteWide:"One rate across the whole run must reach this percentage. Individual cases have no threshold of their own."}),goe=Object.freeze({perCase:{suffix:"",range:"0–1",noun:"fraction"},suiteWide:{suffix:"%",range:"0–100",noun:"percentage"}}),q8=Object.freeze({iterations:"iterations",casesIgnoringExecutionVariant:"cases, counting all models as one"}),Coe=Object.freeze({iterations:"Every iteration is one unit, so a 3-case suite run 5 times each is measured over 15.",casesIgnoringExecutionVariant:"Every case is one unit however many times or on however many models it ran, so a 3-case suite run 5 times each is measured over 3. A case fails if any of its iterations failed or timed out, and a case with no finished iteration is dropped from the rate entirely."}),voe=Object.freeze({0:"a run that measured nothing does not pass",1:"a run that measured nothing passes"}),yoe=Object.freeze({defaultCount:"Iterations per case",caseCountWithFloor:"Minimum iterations per case"}),boe=Object.freeze({defaultCount:"The suite default. A case that sets its own count uses that instead.",caseCountWithFloor:"A floor, 1–10: a case always runs at least this many times, and a case configured for more keeps its own count. Clearing it removes the floor."}),Soe=Object.freeze({enforced:"Evidence requirements",notEnforced:"No evidence requirements"}),Eoe=Object.freeze({enforced:"A run that measured too little is inconclusive rather than passed or failed.",notEnforced:"Runs on this suite are always passed or failed; they are never inconclusive on evidence grounds."}),xoe=Object.freeze({minCompletionRate:"Minimum completion rate",maxEvaluatorErrorRate:"Maximum evaluator error rate",minEligibleTrials:"Minimum gradeable iterations"}),woe=Object.freeze({minCompletionRate:"Share of attempted iterations that must finish for the run to be decided.",maxEvaluatorErrorRate:"Share of iterations the evaluator may fail on before the run says nothing about the server.",minEligibleTrials:"Leave empty to require every configured iteration attempted and at least one gradeable — the stricter rule. A number relaxes that to a count."}),Doe=Object.freeze({suiteFile:"from the suite file",hostedPerCase:"from this suite's settings",hostedSuiteWide:"from this suite's settings",runReporting:"recorded on the run"}),Toe=Object.freeze({hosted:"measured over cases",localFallback:"measured over iterations"}),Aoe=Object.freeze({iterationsNotRepresentable:"This suite sets a minimum iteration count per case, not a suite default. Change the minimum, or set the count on each case.",minimumIterationsNotRepresentable:"This suite sets a default iteration count that each case can override, not a minimum. Change the default, or set the count on the cases that need more.",validityNotEnforced:"Runs on this suite are always passed or failed, so there is nothing for evidence requirements to withhold. They apply only where a run can be inconclusive.",readOnlyPolicy:"This describes how one finished run was decided. It is not a setting, and changing it would not re-decide the run."}),Ioe=Object.freeze({deploymentDoesNotReportPolicy:"This deployment does not report which criterion decides the suite's runs, so its threshold cannot be read or edited from here."});function koe(e){return e.scope==="perCase"?`each case must pass ${e.threshold} of its own iterations`:`${e.thresholdPercent}% of ${q8[e.population]} must pass`}var Roe=Object.freeze({passCriterionScopes:["perCase","suiteWide"],suiteWidePopulations:EI,iterationRuleKinds:["defaultCount","caseCountWithFloor"],policyOrigins:wI,runReportingProducers:f8,editRefusals:B8}),K8=["pending","running","grading","completed","failed","cancelled","timed_out"],Ooe=U(K8),J8=["completed","failed","cancelled","timed_out"];function Moe(e){return J8.includes(e)}var Q8=["passed","failed","inconclusive","notEstablished"],Y8=U(Q8),X8=["policyV2","legacy","none"],Z8=U(X8),kh=["caseVariant","trial"],Noe=U(kh),eK=["runNotTerminal","runStatusNotAVerdict","runResultNotAVerdict","verdictSummaryUnavailable"],tK=U(eK),nK=D({reason:tK,detail:S().min(1).optional()}).strict(),Ss=M().int().min(0),rK=ft("measurementUnit",[D({measurementUnit:L("caseVariant"),total:Ss,passed:Ss,failed:Ss,inconclusive:Ss}).strict(),D({measurementUnit:L("trial"),total:Ss.optional(),passed:Ss.optional(),failed:Ss.optional()}).strict()]),sK=ft("status",[D({status:L("verified"),stages:K(QA),firstFailedStage:Vi.optional(),failureCategory:UC.optional(),analyzerVersion:M().int().min(0),analyzerVersionAhead:D({reported:M().int().min(0),known:M().int().min(0)}).strict().optional()}).strict(),D({status:L("unverified"),analyzerVersion:M().int().min(0).optional(),analyzerVersionAhead:D({reported:M().int().min(0),known:M().int().min(0)}).strict().optional()}).strict(),D({status:L("absent")}).strict()]),iK=D({runId:S().min(1),iterationId:S().min(1),stage:Vi.optional(),spanIds:K(S().min(1)).min(1).optional(),promptIndexes:K(M().int().min(0)).min(1).optional(),reasons:K(S().min(1)).min(1).optional(),tracePath:S().min(1)}).strict(),oK=D({iterationId:S().min(1),iterationNumber:M().int().min(0),caseId:Gi.optional(),testCaseId:S().min(1).optional(),title:S().min(1).optional(),status:S().min(1),result:U(["passed","failed"]).optional(),chain:sK,expected:D({toolNames:K(S().min(1)).min(1)}).strict().optional(),observed:D({toolNames:K(S().min(1)).min(1).optional(),failure:S().min(1).optional()}).strict().optional(),evidence:iK,nextAction:S().min(1)}).strict(),aK=D({items:K(oK),complete:le(),nextCursor:S().min(1).optional(),scannedIterations:Ss}).strict().superRefine((e,t)=>{e.complete&&e.nextCursor!==void 0&&t.addIssue({code:"custom",path:["nextCursor"],message:"a complete diagnostics page has no next cursor: more pages means the set is not complete"}),e.items.length>e.scannedIterations&&t.addIssue({code:"custom",path:["scannedIterations"],message:`scannedIterations ${e.scannedIterations} is fewer than the ${e.items.length} diagnostics drawn from them`})}),lK=D({schemaVersion:L(1),runId:S().min(1),runStatus:S().min(1),verdict:Y8,verdictSource:Z8,counts:rK.optional(),decision:WC.optional(),undecided:nK.optional(),diagnostics:aK}).strict(),Poe=lK.superRefine((e,t)=>{const n=(r,s)=>t.addIssue({code:"custom",path:r,message:s});if(e.verdictSource==="policyV2"){if(e.decision===void 0){n(["decision"],'verdictSource "policyV2" requires the decision it names as the authority');return}e.verdict!==e.decision.verdict&&n(["verdict"],`verdict "${e.verdict}" must be the decision's own verdict "${e.decision.verdict}" — this contract explains a decision, it never re-decides one`),e.undecided!==void 0&&n(["undecided"],"a decided run has no undecided reason");const r=e.counts;if(r===void 0||r.measurementUnit!=="caseVariant"){n(["counts"],`a policy-v2 summary counts case-execution variants, not ${r?.measurementUnit??"nothing"}`);return}const s=cK(e.decision);(r.total!==s.total||r.passed!==s.passed||r.failed!==s.failed||r.inconclusive!==s.inconclusive)&&n(["counts"],`counts must be the tally of decision.cases[].verdict (${s.passed} passed / ${s.failed} failed / ${s.inconclusive} inconclusive of ${s.total})`);return}if(e.decision!==void 0&&n(["decision"],`only a "policyV2" summary carries a decision; this one is "${e.verdictSource}"`),e.verdictSource==="legacy"){e.verdict!=="passed"&&e.verdict!=="failed"&&n(["verdict"],`a legacy run's verdict is its own "passed" or "failed"; "${e.verdict}" is not one a percent-threshold run can reach`),e.undecided!==void 0&&n(["undecided"],"a decided run has no undecided reason"),e.counts!==void 0&&e.counts.measurementUnit!=="trial"&&n(["counts"],`a legacy run's stored summary counts trials, not ${e.counts.measurementUnit}`);return}e.verdict!=="notEstablished"&&n(["verdict"],`with no verdict source the verdict is "notEstablished", not "${e.verdict}"`),e.undecided===void 0&&n(["undecided"],"an undecided run must say which check left it undecided"),e.counts!==void 0&&n(["counts"],"a run with no verdict reports no counts: the numbers it happens to have recorded describe a decision nobody took")});function cK(e){let t=0,n=0,r=0;for(const s of e.cases)s.verdict==="passed"?t+=1:s.verdict==="failed"?n+=1:r+=1;return{total:e.cases.length,passed:t,failed:n,inconclusive:r}}function Loe(e){return uK(e)}function uK(e){const t=dK(e.stageAnalyzerVersion),n=t!==void 0&&t>12?{analyzerVersionAhead:{reported:t,known:12}}:{},r=YA.safeParse({stageResults:e.stageResults,...e.firstFailedStage!==void 0?{firstFailedStage:e.firstFailedStage}:{},...e.failureCategory!==void 0?{failureCategory:e.failureCategory}:{},stageAnalyzerVersion:e.stageAnalyzerVersion});return r.success?{status:"verified",stages:r.data.stageResults,...r.data.firstFailedStage?{firstFailedStage:r.data.firstFailedStage}:{},...r.data.failureCategory?{failureCategory:r.data.failureCategory}:{},analyzerVersion:r.data.stageAnalyzerVersion,...n}:e.stageResultsUnverified===!0||e.stageResults!==void 0?{status:"unverified",...t!==void 0?{analyzerVersion:t}:{},...n}:{status:"absent"}}function dK(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0?e:void 0}function _oe(e){return e.chain.status==="verified"?e.chain.failureCategory:void 0}function Foe(e){return e.chain.status==="verified"?e.chain.firstFailedStage:void 0}var Hoe=Object.freeze({passed:"passed",failed:"failed",inconclusive:"inconclusive",notEstablished:"no verdict established"}),joe=Object.freeze({policyV2:"per-case grading",legacy:"suite accuracy threshold",none:"no verdict source"}),hK=Object.freeze({caseVariant:{one:"case variant",many:"case variants"},trial:{one:"iteration",many:"iterations"}}),Goe=Object.freeze({runNotTerminal:"the run has not finished yet",runStatusNotAVerdict:"the run stopped before it finished, so its recorded counts describe a sample rather than the run",runResultNotAVerdict:"the run finished without recording a verdict",verdictSummaryUnavailable:"the run was decided by per-case grading and its decision could not be read"});function Voe(e,t){const n=hK[e];return t===1?n.one:n.many}var At=M().int().min(0);var fK=["noToolCalled","retried","looping"],Uoe=U(fK),BK=["loaded","notLoaded"],pK=U(BK),mK=["inCatalog","outsideCatalog","catalogNotLoaded"],gK=U(mK),CK=["measured","excludedNegativeTest","notMeasured"],zoe=U(CK),vK=D({pathKey:S().min(1),trials:At,passed:At,failed:At}).strict(),yK=D({distinctPaths:M().int().min(1).optional(),trials:At,passed:At,failed:At}).strict(),bK=D({tool:S().min(1),trials:At}).strict(),SK=D({noToolCalled:Xt,retried:Xt,looping:Xt}).strict(),EK=D({identifierSurfacedUnused:Xt,searchRepeatedAfterIdentifier:Xt,identicalRetry:Xt,changedRetry:Xt,paginationContinuation:Xt}).strict(),xK=D({population:L(kh[1]),totalTrials:At,includedTrials:At,exclusions:Id,routes:K(vK).max(24),otherRoutes:yK.optional(),tags:SK,loopedOn:K(bK),endedWithQuestion:Xt,frictionSignals:EK.optional(),truncatedTrials:At.optional()}).strict(),wK=D({tool:S().min(1),expectedIn:At,notCalledIn:At,notCalledInFailed:At}).strict(),DK=D({tool:S().min(1),calledIn:At,calledInFailed:At,catalog:gK}).strict(),TK=D({expected:S().min(1),observed:S().min(1),trials:At}).strict(),AK=ft("state",[D({state:L("measured"),gradeableTrials:M().int().min(1),expected:K(wK).max(64),unexpected:K(DK).max(64),substitutions:K(TK).max(64),truncated:L(!0).optional()}).strict(),D({state:L("excludedNegativeTest")}).strict(),D({state:L("notMeasured")}).strict()]),IK=D({distinctCases:M().int().min(1),retained:M().int().min(0)}).strict(),kK=D({caseVariantKey:S().min(1),caseKey:S().min(1).optional(),executionVariant:oa.optional(),routes:xK,mismatch:AK}).strict(),RK=D({schemaVersion:L(1),routeFactsVersion:L(1),measurementUnit:L(kh[1]),runId:S().min(1),suiteId:S().min(1),runGroupId:S().min(1).optional(),configRevision:S().min(1).optional(),runCompletedAt:M().int().min(0).optional(),catalogState:pK,catalogHash:S().min(1).optional(),sourceIterationCount:At,sourceMaxUpdatedAt:M().int().min(0).optional(),materializationState:qC,createdAt:M().int().min(0),updatedAt:M().int().min(0),totalTrials:At,includedTrials:At,exclusions:Id,cases:K(kK).max(vI),caseTruncation:IK.optional()}).strict();function Ba(e,t,n){const r=pI.safeParse(n);if(!r.success)for(const s of r.error.issues)e.addIssue({code:"custom",path:[...t,...s.path],message:s.message})}var $oe=RK.superRefine((e,t)=>{e.includedTrials+Jf(e.exclusions)!==e.totalTrials&&t.addIssue({code:"custom",path:["includedTrials"],message:`includedTrials ${e.includedTrials} plus exclusions ${Jf(e.exclusions)} must equal totalTrials ${e.totalTrials}`}),e.sourceIterationCount!==e.totalTrials&&t.addIssue({code:"custom",path:["sourceIterationCount"],message:`sourceIterationCount ${e.sourceIterationCount} must equal totalTrials ${e.totalTrials}`});for(const[n,r]of e.cases.entries()){const s=Jf(r.routes.exclusions);r.routes.includedTrials+s!==r.routes.totalTrials&&t.addIssue({code:"custom",path:["cases",n,"routes","includedTrials"],message:`includedTrials ${r.routes.includedTrials} plus exclusions ${s} must equal totalTrials ${r.routes.totalTrials}`}),r.mismatch.state==="measured"&&r.mismatch.gradeableTrials>r.routes.includedTrials&&t.addIssue({code:"custom",path:["cases",n,"mismatch","gradeableTrials"],message:"gradeableTrials cannot exceed the case's includedTrials"}),Ba(t,["cases",n,"routes","tags","noToolCalled"],r.routes.tags.noToolCalled),Ba(t,["cases",n,"routes","tags","retried"],r.routes.tags.retried),Ba(t,["cases",n,"routes","tags","looping"],r.routes.tags.looping),Ba(t,["cases",n,"routes","endedWithQuestion"],r.routes.endedWithQuestion);const i=r.routes.frictionSignals;if(i)for(const o of Ih)Ba(t,["cases",n,"routes","frictionSignals",o],i[o])}});function Jf(e){let t=0;for(const n of BI)t+=e[n]??0;return t}var un=M().int().min(0),OK=["original","rewrite"],Woe=U(OK),MK=["notTerminal","errored","timedOut","negativeTest","overrideNotApplied","unsupportedEngine"],qoe=U(MK),NK=["controlled","reproducible"],PK=U(NK),LK=["deterministic","judge_gated"],_K=U(LK),FK=["improved","regressed","no_difference","insufficient_data"],HK=U(FK),jK=["passed","failed","non_gateable"],GK=U(jK),VK=["per_trial_sandbox","none"],UK=U(VK),zK=["concurrent_two_run"],$K=U(zK),WK=D({notTerminal:un.optional(),errored:un.optional(),timedOut:un.optional(),negativeTest:un.optional(),overrideNotApplied:un.optional(),unsupportedEngine:un.optional()}).strict(),Jb=D({eligible:un,passed:un,failed:un,exclusions:WK}).strict(),qK=D({deltaPoints:M(),lowerPoints:M(),upperPoints:M()}).strict(),HI=D({original:Jb,rewrite:Jb,interval:qK.nullable(),verdict:HK,minSampleSize:M().int().min(1),minEffectSize:M().min(0).max(1)}).strict(),KK=HI.extend({aggregationKey:S().min(1)}).strict(),JK=HI,QK=D({expectedToolNotCalled:D({original:un,rewrite:un}).strict(),substitutions:K(D({expected:S().min(1),observed:S().min(1),original:un,rewrite:un}).strict()).optional()}).strict(),YK=D({checked:le(),otherCases:un,regressed:K(S().min(1)),status:GK,reason:S().min(1).optional()}).strict(),XK=["model","engine","hostConfigId","toolSnapshotHash","judgeConfigHash"],ZK=U(XK),e6=D({model:K(S().min(1)),engine:S().min(1).optional(),hostConfigId:S().min(1).optional(),toolSnapshotHash:S().min(1).optional(),judgeConfigHash:S().min(1).optional(),environmentReset:UK,equal:le(),differences:K(ZK).min(1).optional()}).strict().superRefine((e,t)=>{e.equal&&e.differences!==void 0&&t.addIssue({code:"custom",path:["differences"],message:"equal arms carry no differences"}),!e.equal&&e.differences===void 0&&t.addIssue({code:"custom",path:["differences"],message:"unequal arms must name what differed"})}),t6=D({method:$K,overlapVerified:le()}).strict(),n6=D({schemaVersion:L(1),toolName:S().min(1),population:L(kh[1]),primary:D({outcomeSource:_K,pooled:JK,perCase:K(KK)}).strict(),secondary:QK,regression:YK,frozen:e6,assignment:t6,evidenceLabel:PK,reportOnly:L(!0)}).strict();function Kc(e,t,n){n.passed+n.failed!==n.eligible&&e.addIssue({code:"custom",path:[...t,"eligible"],message:`eligible ${n.eligible} is not passed ${n.passed} + failed ${n.failed}`})}var Koe=n6.superRefine((e,t)=>{Kc(t,["primary","pooled","original"],e.primary.pooled.original),Kc(t,["primary","pooled","rewrite"],e.primary.pooled.rewrite);for(const[r,s]of e.primary.perCase.entries())Kc(t,["primary","perCase",r,"original"],s.original),Kc(t,["primary","perCase",r,"rewrite"],s.rewrite);const n=[[["primary","pooled"],e.primary.pooled],...e.primary.perCase.map((r,s)=>[["primary","perCase",s],r])];for(const[r,s]of n){const i=s.original.eligible<s.minSampleSize||s.rewrite.eligible<s.minSampleSize;i&&s.interval!==null&&t.addIssue({code:"custom",path:[...r,"interval"],message:"interval must be null when either arm is below minSampleSize"}),i&&s.verdict!=="insufficient_data"&&t.addIssue({code:"custom",path:[...r,"verdict"],message:"verdict must be insufficient_data when either arm is below minSampleSize"})}e.evidenceLabel==="controlled"&&!(e.frozen.environmentReset==="per_trial_sandbox"&&e.assignment.overlapVerified&&e.frozen.equal)&&t.addIssue({code:"custom",path:["evidenceLabel"],message:"controlled requires per-trial sandbox reset, verified overlap, and equal frozen variables"})});function Qb(e){const t=e.trim();return t.length===0?[]:t.split(/\s+/)}var r6=25e4;function Joe(e,t){const n=Qb(e),r=Qb(t),s=n.length,i=r.length;if(s*i>r6)return{added:r,removed:n,tokens:[...n.map(u=>({type:"del",text:u})),...r.map(u=>({type:"add",text:u}))]};const o=Array.from({length:s+1},()=>Array.from({length:i+1},()=>0));for(let u=1;u<=s;u+=1)for(let d=1;d<=i;d+=1)o[u][d]=n[u-1]===r[d-1]?(o[u-1][d-1]??0)+1:Math.max(o[u-1][d]??0,o[u][d-1]??0);const a=[];let l=s,c=i;for(;l>0||c>0;)l>0&&c>0&&n[l-1]===r[c-1]?(a.push({type:"eq",text:n[l-1]}),l-=1,c-=1):c>0&&(l===0||(o[l][c-1]??0)>=(o[l-1][c]??0))?(a.push({type:"add",text:r[c-1]}),c-=1):(a.push({type:"del",text:n[l-1]}),l-=1);return a.reverse(),{added:a.filter(u=>u.type==="add").map(u=>u.text),removed:a.filter(u=>u.type==="del").map(u=>u.text),tokens:a}}var s6=L(1);var i6=L(1),jI=ft("kind",[D({kind:L("run"),runId:S().min(1)}).strict(),D({kind:L("commit_sha"),commitSha:S().min(1)}).strict(),D({kind:L("previous_completed")}).strict()]),o6=D({baseline:jI.optional(),maximumPassRateDrop:M().min(0).max(1).optional(),noDeterministicRegressions:le().optional(),maximumP95LatencyIncreaseMs:M().min(0).optional(),noGatingScoreErrors:le().optional()}).strict(),a6=["noGatingScoreErrors","maximumPassRateDrop","noDeterministicRegressions","maximumP95LatencyIncreaseMs"],l6=["maximumPassRateDrop","noDeterministicRegressions","maximumP95LatencyIncreaseMs"];Object.freeze(l6);var c6=["POLICY_MALFORMED","PREVIOUS_COMPLETED_UNSUPPORTED","COMPARATIVE_WITHOUT_BASELINE","BASELINE_UNRESOLVED","EVIDENCE_MALFORMED","EVIDENCE_NOT_FINAL","EVIDENCE_LIMIT_REACHED","INCOMPLETE_CAPTURE","INTEGRITY_UNVERIFIED","NO_EVALUATION_CONFIG","EMPTY_COUNTABLE_EVIDENCE","GENERATED_SCORER_ID","SCORER_MISSING","SCORER_ADDED","SCORER_REMOVED","SCORER_CHANGED","POPULATION_INCOMPATIBLE","CONFIGURED_WEIGHTS_MISMATCH","OBSERVED_WEIGHTS_MISMATCH","QUARANTINED","LATENCY_UNMEASURED","SCORE_DELTAS_UNAVAILABLE"],GI=U(c6),u6=D({scorerId:S().min(1),definitionHash:S().min(1),status:zA,passed:le().optional()}).strict(),d6=D({scorerId:S().min(1),definitionHash:S().min(1),idSource:jC,role:HC,deterministic:le(),countable:M().int().min(0),passed:M().int().min(0),passRate:M().min(0).max(1).nullable()}).strict(),Jc=D({caseId:S().min(1),executionVariant:oa.optional(),trials:M().int().min(0),quarantined:le().optional()}).strict(),h6=D({caseKey:S().min(1),scorerId:S().min(1)}).strict(),f6=D({hash:S().min(1).optional(),definitions:K(WA)}).strict(),VI=D({runId:S().min(1),final:le(),scoreIntegrity:U(["valid","invalid"]).optional(),evaluationConfig:f6.optional(),scores:K(u6).optional(),scorerSummaries:K(d6).optional(),e2eP95Ms:M().min(0).optional(),captureComplete:le().optional(),evidenceLimitReached:le().optional()}).strict(),B6=D({selector:jI,resolved:le(),run:VI.optional(),caseSetChanged:le().optional(),scenarioConfigChanged:le().optional(),evaluationConfigChanged:le().optional(),iterationWeightingEqual:le().optional(),configuredWeightsMatch:le().optional(),observedWeightsMatch:le().optional(),scoreDeltasAvailable:le().optional(),deterministicScoreRegressions:K(h6).optional(),configuredWeights:D({subject:K(Jc),baseline:K(Jc)}).strict().optional(),observedWeights:D({subject:K(Jc),baseline:K(Jc)}).strict().optional(),quarantined:le().optional()}).strict(),Qoe=D({subject:VI,baseline:B6.optional()}).strict(),p6=["passed","failed","non_gateable"],m6=["passed","failed","non_gateable","not_configured"],g6=D({condition:U(a6),status:U(p6),message:S().min(1),reason:GI.optional(),observed:M().optional(),threshold:M().optional(),scorerId:S().min(1).optional()}).strict(),Yoe=D({schemaVersion:s6,evaluatorVersion:i6,policy:o6,policyHash:S().min(1),outcome:U(m6),conditions:K(g6),policyError:D({reason:GI,message:S().min(1)}).strict().optional()}).strict();function Xoe(e){const t={};return e.baseline!==void 0&&(t.baseline=e.baseline),e.maximumPassRateDrop!==void 0&&(t.maximumPassRateDrop=e.maximumPassRateDrop),e.noDeterministicRegressions===!0&&(t.noDeterministicRegressions=!0),e.maximumP95LatencyIncreaseMs!==void 0&&(t.maximumP95LatencyIncreaseMs=e.maximumP95LatencyIncreaseMs),e.noGatingScoreErrors===!0&&(t.noGatingScoreErrors=!0),t}var C6=L(1);var v6=L(1);var cn=M().int().min(0),y6=M().int().min(1).max(100),b6=D({caseId:S().min(1),executionVariant:oa.optional(),configuredTrials:y6,effectivePassThreshold:Fn}).strict(),S6=D({caseId:S().min(1),executionVariant:oa.optional(),countable:cn,scored:cn,errors:cn,skipped:cn,notApplicable:cn,missing:cn.optional(),quarantined:cn.optional()}).strict(),E6=D({kind:S().min(1),version:S().min(1),configurationDigest:S().min(1)}).strict(),x6=D({executionVariant:oa.optional(),model:S().min(1),provider:S().min(1).optional(),configurationDigest:S().min(1).optional()}).strict(),w6=D({environmentId:S().min(1).optional(),configurationDigest:S().min(1)}).strict(),D6=D({environmentId:S().min(1).optional(),namedHostId:S().min(1).optional(),hostHarness:E6.optional(),effectiveModels:K(x6).optional(),serverEnvironment:w6.optional(),executionOverridesDigest:S().min(1).optional()}).strict(),T6=D({retained:M().int().min(0).max(200),omitted:M().int().min(1),total:M().int().min(1)}).strict(),A6=D({scorerId:S().min(1),definitionHash:S().min(1),idSource:jC,role:HC,deterministic:le(),passThreshold:Fn,scope:hc.optional(),criterion:S().min(1).optional(),countable:cn,passed:cn,failed:cn,errors:cn,skipped:cn,notApplicable:cn,passRate:Fn.nullable(),meanValue:Fn.nullable(),observedPopulation:K(S6),observedPopulationFingerprint:S().min(1)}).strict(),I6=D({schemaVersion:C6,sourceVersion:v6,suiteId:S().min(1),runId:S().min(1),runGroupId:S().min(1).optional(),configRevision:S().min(1).optional(),caseSetFingerprint:S().min(1).optional(),organizationId:S().min(1).optional(),workspaceId:S().min(1).optional(),projectId:S().min(1).optional(),runCompletedAt:M().int().min(0).optional(),sourceIterationCount:cn,sourceMaxUpdatedAt:M().int().min(0).optional(),generation:M().int().min(0).optional(),materializationState:qC,scoreIntegrity:U(["valid","invalid"]).optional(),configuredTrials:K(b6),configuredTrialFingerprint:S().min(1),execution:D6,executionFingerprint:S().min(1),entries:K(A6).max(200),truncation:T6.optional(),createdAt:M().int().min(0),updatedAt:M().int().min(0)}).strict(),Zoe=I6.superRefine((e,t)=>{const n=M6(e.configuredTrials);e.configuredTrialFingerprint!==n&&t.addIssue({code:"custom",path:["configuredTrialFingerprint"],message:"configuredTrialFingerprint is not the digest of the normalized configuredTrials snapshot"});const r=F6(e.execution);e.executionFingerprint!==r&&t.addIssue({code:"custom",path:["executionFingerprint"],message:"executionFingerprint is not the digest of the normalized execution snapshot"});const s=new Set;for(const[i,o]of e.entries.entries()){const a=R6(o);s.has(a)&&t.addIssue({code:"custom",path:["entries",i],message:`duplicate scorer entry ${a}: entries are keyed by (scorerId, definitionHash)`}),s.add(a),o.passed+o.failed+o.errors+o.skipped!==o.countable&&t.addIssue({code:"custom",path:["entries",i,"countable"],message:`countable ${o.countable} is not passed ${o.passed} + failed ${o.failed} + errors ${o.errors} + skipped ${o.skipped}`});const l=k6(o);o.passRate!==l&&t.addIssue({code:"custom",path:["entries",i,"passRate"],message:o.countable===0?"passRate must be null when countable is 0 (unmeasured is not 0)":`passRate ${o.passRate} is not ${o.passed}/${o.countable} (${l})`}),o.passed+o.failed===0&&o.meanValue!==null&&t.addIssue({code:"custom",path:["entries",i,"meanValue"],message:"meanValue must be null when no observation was scored (unmeasured is not 0)"});const c=P6(o.observedPopulation);o.observedPopulationFingerprint!==c&&t.addIssue({code:"custom",path:["entries",i,"observedPopulationFingerprint"],message:"observedPopulationFingerprint is not the digest of the normalized observedPopulation snapshot"})}e.truncation&&(e.truncation.retained!==e.entries.length&&t.addIssue({code:"custom",path:["truncation","retained"],message:`truncation.retained ${e.truncation.retained} does not match ${e.entries.length} stored entries`}),e.truncation.retained+e.truncation.omitted!==e.truncation.total&&t.addIssue({code:"custom",path:["truncation","total"],message:`truncation.total ${e.truncation.total} is not retained ${e.truncation.retained} + omitted ${e.truncation.omitted}`}))});function k6(e){return e.countable===0?null:e.passed/e.countable}function R6(e){return`${e.scorerId}\0${e.definitionHash}`}function go(e,t){return e<t?-1:e>t?1:0}function kd(e){return e?`${e.provider??""}\0${e.model}`:""}function QC(e){if(!e)return;const t={model:e.model};return e.provider!==void 0&&(t.provider=e.provider),t}function UI(e,t){const n=go(e.caseId,t.caseId);return n!==0?n:go(kd(e.executionVariant),kd(t.executionVariant))}function O6(e){return e.map(t=>{const n={caseId:t.caseId,configuredTrials:t.configuredTrials,effectivePassThreshold:t.effectivePassThreshold},r=QC(t.executionVariant);return r&&(n.executionVariant=r),n}).sort((t,n)=>{const r=UI(t,n);return r!==0?r:t.configuredTrials!==n.configuredTrials?t.configuredTrials-n.configuredTrials:t.effectivePassThreshold-n.effectivePassThreshold})}function M6(e){return qg(O6(e))}function N6(e){return e.map(t=>{const n={caseId:t.caseId,countable:t.countable,scored:t.scored,errors:t.errors,skipped:t.skipped,notApplicable:t.notApplicable},r=QC(t.executionVariant);return r&&(n.executionVariant=r),t.missing!==void 0&&(n.missing=t.missing),t.quarantined!==void 0&&(n.quarantined=t.quarantined),n}).sort((t,n)=>{const r=UI(t,n);if(r!==0)return r;if(t.countable!==n.countable)return t.countable-n.countable;if(t.scored!==n.scored)return t.scored-n.scored;if(t.errors!==n.errors)return t.errors-n.errors;if(t.skipped!==n.skipped)return t.skipped-n.skipped;if(t.notApplicable!==n.notApplicable)return t.notApplicable-n.notApplicable;const s=t.missing??-1,i=n.missing??-1;return s!==i?s-i:(t.quarantined??-1)-(n.quarantined??-1)})}function P6(e){return qg(N6(e))}function L6(e){const t={model:e.model},n=QC(e.executionVariant);return n&&(t.executionVariant=n),e.provider!==void 0&&(t.provider=e.provider),e.configurationDigest!==void 0&&(t.configurationDigest=e.configurationDigest),t}function _6(e){const t={};if(e.environmentId!==void 0&&(t.environmentId=e.environmentId),e.namedHostId!==void 0&&(t.namedHostId=e.namedHostId),e.hostHarness&&(t.hostHarness={kind:e.hostHarness.kind,version:e.hostHarness.version,configurationDigest:e.hostHarness.configurationDigest}),e.effectiveModels&&(t.effectiveModels=e.effectiveModels.map(L6).sort((n,r)=>{const s=go(kd(n.executionVariant),kd(r.executionVariant));if(s!==0)return s;const i=go(n.provider??"",r.provider??"");if(i!==0)return i;const o=go(n.model,r.model);return o!==0?o:go(n.configurationDigest??"",r.configurationDigest??"")})),e.serverEnvironment){const n={configurationDigest:e.serverEnvironment.configurationDigest};e.serverEnvironment.environmentId!==void 0&&(n.environmentId=e.serverEnvironment.environmentId),t.serverEnvironment=n}return e.executionOverridesDigest!==void 0&&(t.executionOverridesDigest=e.executionOverridesDigest),t}function F6(e){return qg(_6(e))}var H6=D({format:U(["markdown","json","csv"]),method:L("ai"),fileName:S().min(1).max(255),fileHash:S().regex(/^[a-f0-9]{64}$/),excerpt:S().min(1).max(102400),startLine:M().int().positive(),endLine:M().int().positive(),extractorVersion:S().min(1).max(100)}).strict().refine(e=>e.endLine>=e.startLine,"Invalid source line range"),En=6e4,Ns=36e5,zI={turnTimeoutMs:M().int().min(1e4).max(30*En).optional(),toolCallTimeoutMs:M().int().min(1e3).max(10*En).optional(),runTimeoutMs:M().int().min(En).max(12*Ns).optional(),turnRetries:M().int().min(0).max(5).optional()},eae=D({...zI,iterationTimeoutMs:M().int().min(3e4).max(2*Ns).optional()}).strict(),tae=D({...zI,sessionTimeoutMs:M().int().min(En).max(2*Ns).optional()}).strict(),nae=D({turnTimeoutMs:M().int().positive(),toolCallTimeoutMs:M().int().positive().optional(),unitTimeoutMs:M().int().positive(),runTimeoutMs:M().int().positive(),turnRetries:M().int().min(0),sources:D({turnTimeoutMs:U(["authored","default"]),toolCallTimeoutMs:U(["authored","default"]).optional(),unitTimeoutMs:U(["authored","default"]),runTimeoutMs:U(["authored","default"]),turnRetries:U(["authored","default"])}).strict()}).strict(),rae=Object.freeze({evals:Object.freeze({turnTimeoutMs:6*En,toolCallTimeoutMs:3e4,unitTimeoutMs:10*En,runTimeoutMs:30*En,turnRetries:2}),swarms:Object.freeze({turnTimeoutMs:6*En,toolCallTimeoutMs:12e4,unitTimeoutMs:20*En,runTimeoutMs:2*Ns,turnRetries:2})}),sae=Object.freeze({evals:Object.freeze({turnTimeoutMs:30*En,toolCallTimeoutMs:10*En,unitTimeoutMs:2*Ns,runTimeoutMs:12*Ns,turnRetries:5}),swarms:Object.freeze({turnTimeoutMs:30*En,toolCallTimeoutMs:10*En,unitTimeoutMs:2*Ns,runTimeoutMs:12*Ns,turnRetries:5})}),j6=D({toolCallOrder:U(["ignore","strict","superset"]).optional(),argumentMatching:U(["exact","partial","ignore"]).optional(),maxExtraToolCalls:M().int().nonnegative().nullable().optional(),allowExtraToolCalls:le().optional()}).strict(),G6=D({matchOptions:j6.nullable().optional(),assertions:D({mode:U(["replace","extend","inherit"]),list:K(dc).max(25)}).strict()}).strict(),V6=D({cursor:S().min(1).max(8192),sourceHash:S().min(1).max(256),reservationId:S().min(1).max(256),draftHash:S().min(1).max(256)}).strict(),iae=G6.extend({continuation:V6.optional()});var Xe=M().int().nonnegative(),U6=ft("status",[D({status:L("pending"),pendingSessions:Xe,updatedAt:Xe}).strict(),D({status:L("decided"),decision:WC,updatedAt:Xe}).strict(),D({status:L("notEstablished"),reason:L("gradingNotConfigured"),updatedAt:Xe}).strict(),D({status:L("integrityFailed"),reason:S().min(1),updatedAt:Xe}).strict()]),$I=D({evaluatorId:S().min(1),predicateType:U(Object.keys(Rl)),role:U(["advisory","required"]),status:U(["passed","failed","pending","unavailable"])}).strict(),z6=D({id:S().min(1),startEvidence:U(["started","notStarted","unknown"]),verdict:V8,observations:K($I)}).strict().superRefine((e,t)=>{new Set(e.observations.map(n=>n.evaluatorId)).size!==e.observations.length&&t.addIssue({code:"custom",path:["observations"],message:"Duplicate evaluator in one session"}),e.startEvidence==="notStarted"&&["running","ran"].includes(e.verdict.lifecycle)&&t.addIssue({code:"custom",path:["startEvidence"],message:"Execution contradicts explicit non-start"})}),oae=D({runId:S().min(1),executionComplete:le(),configuredSessions:Xe,verdictSummary:U6.nullable(),evaluatorDefinitions:K($I.omit({status:!0})),sessions:K(z6)}).strict().superRefine((e,t)=>{e.sessions.length>e.configuredSessions&&t.addIssue({code:"custom",path:["sessions"],message:"Reported sessions exceed configured population"}),new Set(e.sessions.map(r=>r.id)).size!==e.sessions.length&&t.addIssue({code:"custom",path:["sessions"],message:"Duplicate session/attempt identity"});const n=new Map(e.evaluatorDefinitions.map(r=>[r.evaluatorId,r]));n.size!==e.evaluatorDefinitions.length&&t.addIssue({code:"custom",path:["evaluatorDefinitions"],message:"Duplicate evaluator definition"});for(const r of e.sessions)for(const s of r.observations){const i=n.get(s.evaluatorId);(!i||i.role!==s.role||i.predicateType!==s.predicateType)&&t.addIssue({code:"custom",path:["sessions"],message:"Observation contradicts the frozen evaluator definition"})}}),$6=D({evaluatorId:S().min(1),predicateType:U(Object.keys(Rl)),role:U(["advisory","required"]),stage:U(rr).describe("The stage this observation was read from, and the only stage it is evidence ABOUT. `connection` — the server was reachable and the session initialized. `discovery` — its tools and resources were listed and readable. `selection` — the model chose the right tool for the request. `call` — the call was made with usable arguments. `response` — the server returned data the model could use. `userValue` — the user's actual request was satisfied."),unit:L("sessions"),total:Xe,passed:Xe,failed:Xe,pending:Xe,unavailable:Xe}).strict().superRefine((e,t)=>{e.total!==e.passed+e.failed+e.pending+e.unavailable&&t.addIssue({code:"custom",message:"Observation coverage must partition its population"}),e.stage!==Rl[e.predicateType]&&t.addIssue({code:"custom",message:"Observation stage contradicts the shared evaluator map"})}),aae=D({contractVersion:L(1),runId:S().min(1),verdict:JC,verdictSource:U(["policyV2","none"]),decision:WC.optional(),undecidedReason:U(["executionPending","gradingPending","gradingNotConfigured","verdictSummaryUnavailable","integrityFailed"]).optional(),execution:D({unit:L("sessions"),configured:Xe,reported:Xe,started:Xe,notStarted:Xe,unknown:Xe,completed:Xe,interrupted:Xe,neverLaunched:le()}).strict(),goalGrading:D({unit:L("sessions"),reported:Xe,passed:Xe,failed:Xe,pending:Xe,unavailable:Xe,notRequested:Xe,waitingForDecisiveGrading:Xe}).strict(),observations:K($6)}).strict().superRefine((e,t)=>{const n=i=>t.addIssue({code:"custom",message:i});e.verdictSource==="policyV2"?(!e.decision||e.verdict!==e.decision.verdict||e.undecidedReason!==void 0)&&n("Report must copy its authoritative decision"):(e.verdict!=="notEstablished"||e.decision!==void 0||!e.undecidedReason)&&n("Missing authority must have an undecided reason");const r=e.execution;(r.started+r.notStarted+r.unknown!==r.configured||r.reported>r.configured)&&n("Execution evidence does not cover its configured population"),(r.started+r.notStarted>r.reported||r.completed+r.interrupted>r.reported)&&n("Execution counts exceed reported evidence"),r.neverLaunched!==(r.configured>0&&r.reported===r.configured&&r.notStarted===r.configured)&&n("Not run requires explicit evidence for the entire population");const s=e.goalGrading;(s.reported!==r.reported||s.passed+s.failed+s.pending+s.unavailable+s.notRequested!==s.reported||s.waitingForDecisiveGrading>s.reported)&&n("Goal coverage must partition reported sessions"),(new Set(e.observations.map(i=>i.evaluatorId)).size!==e.observations.length||e.observations.some(i=>i.total>r.reported))&&n("Invalid observation population")});function lae(e){const t=new TextEncoder().encode(e),n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";let r="target_";for(let s=0;s<t.length;s+=3){const i=t[s]<<16|(t[s+1]??0)<<8|(t[s+2]??0);r+=n[i>>>18&63]+n[i>>>12&63],s+1<t.length&&(r+=n[i>>>6&63]),s+2<t.length&&(r+=n[i&63])}return r}var W6=D({code:U(["missing_expectation","missing_prerequisite","unclear_expectation","unsupported_workflow","unknown_tool","invalid_arguments","missing_evidence"]),message:S().min(1).max(2e3),stepId:S().optional(),blocking:le().default(!0),origin:U(["model","validation"]).optional(),resolution:S().trim().min(10).max(2e3).optional()}).strict(),q6=D({id:S().min(1).max(200),path:S().min(1).max(500),explanation:S().min(1).max(2e3)}).strict(),K6=D({title:S().trim().min(1).max(500),steps:Cq,expectedOutput:S().max(1e4).optional(),isNegativeTest:le().default(!1),runs:M().int().min(1).max(10).default(5),models:K(D({model:S().min(1),provider:S().min(1)}).strict()).max(20).default([]),scenario:S().max(1e4).optional(),checks:D({mode:U(["inherit","replace","extend"]),list:K(Mr(S(),Ln())).max(200)}).strict().optional(),matchOptions:Mr(S(),Ln()).optional()}).strict(),cae=D({version:L(1),draftId:S().min(1),revision:M().int().nonnegative(),case:K6,source:H6.optional(),issues:K(W6).max(100),evidenceNotes:K(S().trim().min(10).max(2e3)).max(100).optional(),additions:K(q6).max(200),review:U(["required","accepted"])}).strict();function uae(e){if(!e.title.trim())return"Add a case title.";if(!e.steps.length)return"Add at least one step.";if(new Set(e.steps.map(t=>t.id)).size!==e.steps.length)return"Step ids must be unique.";if(e.steps.some(t=>t.kind==="prompt"&&!t.prompt.trim()))return"Complete each prompt step.";if(e.isNegativeTest)return e.steps.some(t=>t.kind==="assert"&&"type"in t.assertion&&t.assertion.type==="toolCalledWith")?"Negative cases cannot require tool calls.":void 0;if(!e.steps.some(t=>t.kind==="assert")&&!e.expectedOutput?.trim()&&!e.checks?.list.length)return"Add an assertion, expected outcome, or case check."}var J6="quickstart";function dae(e){return e.tags?.includes(J6)===!0}var hae={MIN_PASS_RATE:100,RUNS_PER_TEST:5,CHART_HEIGHT:"h-32",MAX_QUERY_DISPLAY_LENGTH:100,BATCH_DELETE_CONFIRMATION_DELAY:0},Nn={PASSED:"passed",FAILED:"failed",CANCELLED:"cancelled",TIMED_OUT:"timed_out",PENDING:"pending"},fae={passed:"text-success",failed:"text-destructive"},Bae="text-destructive",pae="border-transparent bg-destructive/50 text-foreground shadow-xs hover:bg-destructive/50 hover:brightness-95 focus-visible:ring-destructive/35",mae="bg-destructive/50",gae="bg-destructive/50 text-foreground",Cae="bg-success/15 text-success",vae="bg-destructive/15 text-destructive",yae="bg-warning/15 text-warning",bae={[Nn.PASSED]:"bg-success/50",[Nn.FAILED]:"bg-destructive/50",[Nn.CANCELLED]:"bg-muted",[Nn.PENDING]:"bg-warning/50"},Sae={[Nn.PASSED]:"bg-success/50",[Nn.FAILED]:"bg-destructive/50",[Nn.CANCELLED]:"bg-muted-foreground/50",[Nn.PENDING]:"bg-warning/50",RUNNING:"bg-warning/50",DEFAULT:"bg-muted-foreground/50"},Eae={EVALS_RUN:"/api/mcp/evals/run",EVALS_GENERATE_TESTS:"/api/mcp/evals/generate-tests",EVALS_GENERATE_NEGATIVE_TESTS:"/api/mcp/evals/generate-negative-tests",EVALS_RUN_TEST_CASE:"/api/mcp/evals/run-test-case",LIST_TOOLS:"/api/mcp/list-tools"};function Q6(e){try{Ho.getState().addMcpServerLog({...e.dedupeKey?{id:`plugin-extensions:${e.dedupeKey}`}:{},serverId:e.serverId??"plugin-extensions",serverName:e.serverName??"Plugin extensions",direction:"RECEIVE",method:`plugin-extensions/${e.code}`,timestamp:new Date().toISOString(),payload:{level:e.level??"error",code:e.code,message:e.message,...e.detail??{}}})}catch{}}function Yb(e){Q6({code:`workspace/${e.label}`,message:e.message,level:e.level,serverId:e.serverId,...e.serverName?{serverName:e.serverName}:{},...e.detail?{detail:e.detail}:{}})}var Xb={APPROVAL_DENIED:"Tool approval was denied.",INSTANCE_UNAVAILABLE:"The App's instance is no longer available. Close it and open it again.",INSTANCE_DENIED:"This App belongs to a different chat or client.",INSTANCE_BINDING_CHANGED:"The server changed this App's tool while it was open. Close it and open it again.",ACTIVATION_BINDING_CHANGED:"The server changed this App's tool while it was open. Close it and open it again.",INSTANCE_DEEP_LINK_UNAVAILABLE:"No global App with that tool accepts this link.",INSTANCE_RESPONSE_INVALID:"The host returned a response the App can't use.",INSTANCE_RESPONSE_TOO_LARGE:"The App's response was too large.",INSTANCE_UI_UNAVAILABLE:"The App's UI resource couldn't be read, isn't text/html;profile=mcp-app, or is over 5 MB.",INSTANCE_UNSUPPORTED_CONTINUATION:"The tool asked for input in a way this client can't answer.",INSTANCE_LIMIT:"Too many Apps are open. Close one and try again.",ACTIVATION_SCHEMA_INVALID:"The entrypoint's input schema doesn't accept the arguments this entrypoint sends."};function xae(e){const t=e&&typeof e=="object"&&"description"in e?e.description:void 0,n=e&&typeof e=="object"&&"candidates"in e?e.candidates:void 0,r=Array.isArray(n)&&n.length?n.filter(i=>typeof i=="string"):[];if(typeof t=="string"&&t.trim())return r.length&&!r.every(i=>t.includes(i))?`${t} (${r.join(", ")})`:t;const s=e&&typeof e=="object"&&"code"in e?String(e.code):void 0;return s&&Xb[s]?Xb[s]:e instanceof Error&&e.message&&!/^[A-Z_]+$/.test(e.message)?e.message:s?`The App couldn't open (${s}).`:"The App couldn't open."}var Rh=(0,p.createContext)(null),wae=()=>(0,p.useContext)(Rh),YC=(0,p.createContext)(null),Y6=512;function Dae({value:e,children:t}){const n=(0,p.useMemo)(()=>fx(()=>({links:{}})),[e?.api]);return(0,m.jsx)(Rh.Provider,{value:e,children:(0,m.jsx)(YC.Provider,{value:n,children:t})})}function X6(e,t){const n=(0,p.useContext)(YC),r=JSON.stringify([e,t.map(s=>[s.uri,s.name])]);(0,p.useEffect)(()=>{!n||!e||!t.length||n.setState(s=>{const i={...s.links};for(const a of t)i[a.uri]={serverId:e,name:a.name};const o=Object.keys(i);for(const a of o.slice(0,Math.max(0,o.length-Y6)))delete i[a];return{links:i}})},[n,r])}var Z6={},eJ=fx(()=>({links:Z6}));function tJ(){const e=(0,p.useContext)(YC);return cN(e??eJ,t=>t.links)}function Vu(e,t){return!!e&&e.enabled!==!1&&!!t&&e.serverIds.includes(t.serverId)&&!!t.resourceUri}function nJ(e,t){const[n,r]=(0,p.useState)({state:"closed"}),[s,i]=(0,p.useState)(!1),o=(0,p.useRef)(null),a=JSON.stringify([t?.serverId,t?.resourceUri]),l=(0,p.useRef)({actions:e,reference:t});l.current={actions:e,reference:t};const c=()=>l.current.actions?.api===e?.api&&l.current.actions?.workspaceId===e?.workspaceId&&l.current.reference?.serverId===t?.serverId&&l.current.reference?.resourceUri===t?.resourceUri&&Vu(l.current.actions,l.current.reference);(0,p.useEffect)(()=>(r({state:"closed"}),i(!1),()=>o.current?.abort()),[a,e?.api]);const u=async h=>{if(!(!Vu(e,t)||!c())){r({state:"closed"}),i(!1);try{await e.open(t.serverId,h)}catch{i(!0)}}};return{menu:n,setMenu:r,failed:s,activate:async()=>{if(!Vu(e,t)||!c())return;o.current?.abort();const h=new AbortController;o.current=h,i(!1),r({state:"loading"});try{const f=await e.api.discoverFile(t.serverId,t.resourceUri,h.signal);if(h.signal.aborted||!c())return;if(f.length===1){await u(f[0]);return}f.length===0&&Yb({serverId:t.serverId,label:"file-viewer",level:"info",message:"No file viewer of this server accepts this file's extension."}),r({state:"ready",entries:f})}catch{if(h.signal.aborted||!c())return;r({state:"error"}),Yb({serverId:t.serverId,label:"file-viewer",level:"error",message:"Couldn't list the file viewers for this file."})}},open:u}}var rJ={onPointerDown:e=>e.preventDefault(),onKeyDown:e=>{(e.key==="Enter"||e.key===" ")&&e.preventDefault()}};function sJ({menu:e,onOpen:t}){return(0,m.jsxs)(NC,{align:"start",children:[(0,m.jsx)($$,{className:"text-xs text-muted-foreground",children:"Open with…"}),e.state==="error"&&(0,m.jsx)(Pu,{disabled:!0,children:"Couldn't load viewers"}),e.state==="ready"&&e.entries.length===0&&(0,m.jsx)(Pu,{disabled:!0,children:"No viewer can open this file"}),e.state==="ready"&&e.entries.map(n=>(0,m.jsx)(Pu,{onSelect:()=>t(n),children:n.title},n.toolName))]})}function WI({reference:e,label:t,className:n}){const r=(0,p.useContext)(Rh),s=nJ(r,e);return Vu(r,e)?(0,m.jsxs)(OC,{open:s.menu.state==="ready"||s.menu.state==="error",onOpenChange:i=>{i||s.setMenu({state:"closed"})},children:[(0,m.jsx)(MC,{asChild:!0,...rJ,children:(0,m.jsxs)("button",{type:"button",onClick:i=>{i.stopPropagation(),s.activate()},className:he("inline-flex max-w-full items-center gap-1 text-left text-primary underline-offset-2 hover:underline",n),children:[(0,m.jsx)("span",{className:"truncate",children:t}),s.menu.state==="loading"?(0,m.jsx)(wN,{className:"size-3 shrink-0 animate-spin","aria-hidden":!0}):null]})}),(0,m.jsx)(sJ,{menu:s.menu,onOpen:i=>{s.open(i)}}),s.failed&&(0,m.jsx)("span",{role:"alert",className:"ms-1 text-xs text-destructive",children:"Could not open viewer"})]}):(0,m.jsx)("span",{className:n,children:t})}function Tae({result:e,serverId:t}){const n=(0,p.useContext)(Rh);if(!n||!t||!n.serverIds.includes(t)||!e||typeof e!="object")return null;const r=e,s=r.content??r.value?.content;if(!Array.isArray(s))return null;const i=s.slice(0,64).filter(o=>!!o&&typeof o=="object"&&o.type==="resource_link"&&typeof o.uri=="string"&&o.uri.length<=4096&&typeof o.name=="string"&&o.name.length<=4096);return i.length?(0,m.jsx)(iJ,{serverId:t,links:i}):null}function iJ({serverId:e,links:t}){return X6(e,t),(0,m.jsx)("div",{className:"flex flex-wrap gap-2 px-3 pb-2",children:t.map((n,r)=>(0,m.jsx)("div",{className:"inline-flex max-w-64 items-center gap-2 rounded-md border border-border px-2 py-1 text-xs",title:n.name,children:(0,m.jsx)(WI,{reference:{serverId:e,resourceUri:n.uri},label:n.name})},`${n.uri}:${r}`))})}var qI=(0,p.createContext)(new Map);function Aae(e){const t=(0,p.useContext)(qI);return e?t.get(e):void 0}function oJ({name:e}){return e?(0,m.jsxs)("span",{className:"inline-flex max-w-40 shrink-0 items-center gap-1 rounded-full bg-foreground/5 px-1.5 py-0.5 text-[10px] text-muted-foreground/80",title:`Ran with the ${e} account`,"data-testid":"tool-call-account",children:[(0,m.jsx)(DH,{className:"size-2.5 shrink-0","aria-hidden":!0}),(0,m.jsx)("span",{className:"min-w-0 truncate",children:e})]}):null}var aJ=50,Qf="null";function Ji(){return{line:1,column:1}}function lJ(e){if(e===void 0)return Qf;try{return JSON.stringify(e,null,2)??Qf}catch{return Qf}}function Qi(e){try{return{value:JSON.parse(e),error:null}}catch(t){return{value:void 0,error:t instanceof Error?t.message:"Invalid JSON"}}}function Yi(e){try{return JSON.stringify(e)}catch{return null}}function Di(e){if(typeof e=="string"){try{const t=JSON.parse(e);if(typeof t=="object"&&t!==null)return Di(t)}catch{}return e}if(Array.isArray(e))return e.map(Di);if(typeof e=="object"&&e!==null){const t={};for(const[n,r]of Object.entries(e))t[n]=Di(r);return t}return e}function nl(e,t){if(typeof t=="string"&&typeof e!="string")try{const n=JSON.parse(t);if(typeof n=="object"&&n!==null)return JSON.stringify(e)}catch{}if(typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof t=="object"&&t!==null&&!Array.isArray(t)){const n={},r=t;for(const[s,i]of Object.entries(e))n[s]=s in r?nl(i,r[s]):i;return n}return Array.isArray(e)&&Array.isArray(t)?e.map((n,r)=>r<t.length?nl(n,t[r]):n):e}function Qc(e,t,n){return e!==void 0?e:lJ(n?Di(t):t)}function cJ({initialValue:e,initialContent:t,onChange:n,onRawChange:r,onValidationError:s,expandJsonStrings:i=!1}){const o=(0,p.useRef)(null);if(o.current===null){const F=Qc(t,e,i),z=Qi(F);let J;z.error!==null?J=null:i?J=Yi(nl(z.value,e)):J=Yi(z.value),o.current={content:F,lastEmitted:J,error:z.error}}const[a,l]=(0,p.useState)(o.current.content),c=(0,p.useRef)(e),u=(0,p.useRef)(o.current.content),d=(0,p.useRef)(o.current.content),h=(0,p.useRef)(o.current.lastEmitted),[f,B]=(0,p.useState)(o.current.error),[g,C]=(0,p.useState)(Ji),v=(0,p.useRef)([{content:o.current.content,cursorPosition:Ji()}]),y=(0,p.useRef)(0),b=(0,p.useCallback)(F=>{const z=Qi(F);return B(z.error),s?.(z.error),z},[s]);(0,p.useEffect)(()=>{u.current=a},[a]);const E=(0,p.useRef)({value:e,content:t});if(e!==E.current.value||t!==E.current.content)if(E.current={value:e,content:t},t===void 0&&i){const F=Yi(e);F!==null&&F===h.current?(c.current=e,d.current=u.current):(c.current=e,d.current=Qc(void 0,e,!0))}else c.current=e,d.current=Qc(t,e,i);(0,p.useEffect)(()=>{const F=d.current;if(F===u.current)return;u.current=F,l(F),C(Ji()),v.current=[{content:F,cursorPosition:Ji()}],y.current=0,b(F);const z=Qi(F);if(z.error===null&&i){const J=nl(z.value,e);h.current=Yi(J)}else h.current=z.error===null?Yi(z.value):null},[e,t,b,i]);const w=(0,p.useCallback)((F,z,J)=>{r?.(F);const Z=Q=>{const G=i?nl(Q,c.current):Q,be=Yi(G);if(be===null){n?.(G);return}be!==h.current&&(h.current=be,n?.(G))};if(J===void 0){const Q=Qi(F);Q.error===null&&Z(Q.value);return}J===null&&Z(z)},[n,r,i]),A=(0,p.useCallback)(F=>{if(F===u.current)return;u.current=F,l(F);const{value:z,error:J}=b(F),Z=y.current;let Q=v.current;Z<Q.length-1&&(Q=Q.slice(0,Z+1));const G=Q[Q.length-1];(!G||G.content!==F)&&(Q=[...Q,{content:F,cursorPosition:g}]),Q.length>aJ&&(Q=Q.slice(-50)),v.current=Q,y.current=Q.length-1,w(F,z,J)},[g,w,b]),x=(0,p.useCallback)(F=>{u.current=F.content,l(F.content),C(F.cursorPosition);const{value:z,error:J}=b(F.content);w(F.content,z,J)},[w,b]),O=(0,p.useCallback)(()=>{const F=v.current,z=y.current;if(z>0){y.current=z-1;const J=F[z-1];x(J)}},[x]),R=(0,p.useCallback)(()=>{const F=v.current,z=y.current;if(z<F.length-1){y.current=z+1;const J=F[z+1];x(J)}},[x]),P=(0,p.useCallback)(()=>{const{value:F,error:z}=Qi(a);if(z===null){const J=i?Di(F):F,Z=JSON.stringify(J,null,2);A(Z)}},[a,A,i]),_=(0,p.useCallback)(()=>{c.current=e;const F=Qc(t,e,i);d.current=F,u.current=F,l(F),C(Ji()),v.current=[{content:F,cursorPosition:Ji()}],y.current=0;const{value:z,error:J}=b(F);w(F,z,J)},[e,t,b,w,i]),N=(0,p.useCallback)(()=>{const{value:F,error:z}=Qi(a);return z===null?F:void 0},[a]),q=y.current>0,W=y.current<v.current.length-1;return{content:a,setContent:A,isValid:f===null,validationError:f,cursorPosition:g,setCursorPosition:C,undo:O,redo:R,canUndo:q,canRedo:W,format:P,reset:_,getParsedValue:N,sourceContent:d.current}}function uJ(e){return typeof e=="object"?e.key:e}function dJ(e,t){const n=e.length;return new Proxy(e,{get(r,s,i){if(typeof s=="string"){const o=s.charCodeAt(0);if(o>=48&&o<=57){const a=+s;if(Number.isInteger(a)&&a>=0&&a<n){let l=r[a];if(typeof l!="object"){const c=t[a*2];l=r[a]={index:a,key:l,start:c,size:t[a*2+1],end:c+t[a*2+1],lane:0}}return l}}if(s==="length")return n}return Reflect.get(r,s,i)}})}function Xi(e,t,n){let r=n.initialDeps??[],s,i=!0;function o(){const a=e();return(a.length!==r.length||a.some((l,c)=>r[c]!==l))&&(r=a,s=t(...a),n?.onChange&&!(i&&n.skipInitialOnChange)&&n.onChange(s),i=!1),s}return o.updateDeps=a=>{r=a},o}function Zb(e,t){if(e===void 0)throw new Error(`Unexpected undefined${t?`: ${t}`:""}`);return e}var eS=(e,t)=>Math.abs(e-t)<1.01,hJ=(e,t,n)=>{let r;return Object.assign(function(...s){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,s),n)},{cancel:()=>{e.clearTimeout(r)}})},pa,Yf=()=>{if(pa!==void 0)return pa;if(typeof navigator>"u")return pa=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return pa=!0;const e=navigator.maxTouchPoints;return pa=navigator.platform==="MacIntel"&&e!==void 0&&e>0},tS=e=>{const{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},fJ=e=>e,BJ=e=>{const t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,r=new Array(n);for(let s=0;s<n;s++)r[s]=t+s;return r},pJ=(e,t)=>{const n=e.scrollElement;if(!n)return;const r=e.targetWindow;if(!r)return;const s=o=>{const{width:a,height:l}=o;t({width:Math.round(a),height:Math.round(l)})};if(s(tS(n)),!r.ResizeObserver)return()=>{};const i=new r.ResizeObserver(o=>{const a=()=>{const l=o[0];if(l?.borderBoxSize){const c=l.borderBoxSize[0];if(c){s({width:c.inlineSize,height:c.blockSize});return}}s(tS(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()});return i.observe(n,{box:"border-box"}),()=>{i.unobserve(n)}},Rd={passive:!0},mJ=typeof window>"u"?!0:"onscrollend"in window,gJ=(e,t,n)=>{const r=e.scrollElement;if(!r)return;const s=e.targetWindow;if(!s)return;const i=e.options.useScrollendEvent&&mJ;let o=0;const a=i?null:hJ(s,()=>t(n(r),!1),e.options.isScrollingResetDelay),l=d=>()=>{o=n(r),a?.(),t(o,d)},c=l(!0),u=l(!1);return r.addEventListener("scroll",c,Rd),i&&r.addEventListener("scrollend",u,Rd),()=>{r.removeEventListener("scroll",c),i&&r.removeEventListener("scrollend",u),a?.cancel()}},CJ=(e,t)=>gJ(e,t,n=>{const{horizontal:r,isRtl:s}=e.options;return r?n.scrollLeft*(s&&-1||1):n.scrollTop}),vJ=(e,t,n)=>{if(n.options.useCachedMeasurements){const r=n.indexFromElement(e),s=n.options.getItemKey(r);return n.itemSizeCache.get(s)??n.options.estimateSize(r)}if(t?.borderBoxSize){const r=t.borderBoxSize[0];if(r)return Math.round(r[n.options.horizontal?"inlineSize":"blockSize"])}if(!t){const r=n.indexFromElement(e),s=n.options.getItemKey(r),i=n.itemSizeCache.get(s);if(i!==void 0)return i}return e[n.options.horizontal?"offsetWidth":"offsetHeight"]},yJ=(e,{adjustments:t=0,behavior:n},r)=>{var s,i;(i=(s=r.scrollElement)==null?void 0:s.scrollTo)==null||i.call(s,{[r.options.horizontal?"left":"top"]:e+t,behavior:n})},bJ=yJ;function SJ(e,t,n,r){if(t===0)return!1;const s=r(0),i=new Set;let o=0;for(;o<e;){const l=n(o);if(l===s)break;i.add(l),o++}const a=e-o;if(a===0||a>=t)return!1;for(let l=0;l<a;l++)if(r(l)!==n(o+l))return!1;for(let l=a;l<t;l++)if(i.has(r(l)))return!1;return!0}var EJ=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this._clampedAdjustment=null,this.elementsCache=new Map,this.now=()=>{var t,n,r;return((r=(n=(t=this.targetWindow)==null?void 0:t.performance)==null?void 0:n.now)==null?void 0:r.call(n))??Date.now()},this.observer=(()=>{let t=null;const n=()=>t||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:t=new this.targetWindow.ResizeObserver(r=>{r.forEach(s=>{const i=()=>{const o=s.target,a=this.indexFromElement(o);if(!o.isConnected){this.observer.unobserve(o);for(const[l,c]of this.elementsCache)if(c===o){this.elementsCache.delete(l);break}return}this.isIndexInRange(a)&&this.shouldMeasureDuringScroll(a)&&this.resizeItem(a,this.options.measureElement(o,s,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(i):i()})}));return{disconnect:()=>{var r;(r=n())==null||r.disconnect(),t=null},observe:r=>{var s;return(s=n())==null?void 0:s.observe(r,{box:"border-box"})},unobserve:r=>{var s;return(s=n())==null?void 0:s.unobserve(r)}}})(),this.range=null,this.setOptions=t=>{var n;const r={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:fJ,rangeExtractor:BJ,onChange:()=>{},measureElement:vJ,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,anchorTo:"start",followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:"estimate",useCachedMeasurements:!1};for(const u in t){const d=t[u];d!==void 0&&(r[u]=d)}const s=this.options;let i=null,o=null,a=!1;if(s!==void 0&&s.enabled&&r.enabled&&r.anchorTo==="end"&&this.scrollElement!==null){const u=s.count,d=r.count,h=this.getMeasurements(),f=((n=this._singleLaneMeasurements)==null?void 0:n.items)??h,B=v=>uJ(f[v]),g=u>0?B(0):null,C=u>0?B(u-1):null;if(d!==u||u>0&&d>0&&(r.getItemKey(0)!==g||r.getItemKey(d-1)!==C)){a=!0;const v=u>0?this.getVirtualItemForOffset(this.getScrollOffset())??h[0]:null;v&&(i=[v.key,this.getScrollOffset()-v.start]);const y=r.followOnAppend===!0?"auto":r.followOnAppend||null;y&&d>0&&this.isAtEnd(s.scrollEndThreshold)&&(u===0||r.getItemKey(d-1)!==C)&&(d>u||SJ(u,d,B,r.getItemKey))&&(o=y)}}this.options=r,a&&(this.pendingMin=0,this.itemSizeCacheVersion++);let l=!1,c=0;if(i&&this.scrollOffset!==null){const[u,d]=i,h=this.getMeasurements(),{count:f,getItemKey:B}=this.options;let g=0;for(;g<f&&B(g)!==u;)g++;if(g<f){const C=h[g];if(C){const v=Math.max(0,C.start+d);!o&&v!==this.scrollOffset&&(c=v-this.scrollOffset,this.scrollOffset=v,l=!0)}}}(l||o)&&(this.pendingScrollAnchor=[l?i[0]:null,l?i[1]:0,o,c])},this.notify=t=>{var n,r;(r=(n=this.options).onChange)==null||r.call(n,this,t)},this.maybeNotify=Xi(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),t=>{this.notify(t)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(t=>t()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.isScrolling=!1,this.scrollDirection=null,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._clampedAdjustment=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var t,n;const r=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==r){if(this.cleanup(),!r){this.maybeNotify();return}if(this.scrollElement=r,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((t=this.scrollElement)==null?void 0:t.window)??null,this.elementsCache.forEach(i=>{this.observer.observe(i)}),this.unsubs.push(this.options.observeElementRect(this,i=>{this.scrollRect=i,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(i,o)=>{if(o&&this._intendedScrollOffset===null&&i===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(i-this._intendedScrollOffset)<1.5&&(i=this._intendedScrollOffset),this._intendedScrollOffset=null,this._clampedAdjustment!==null&&Math.abs(i-this._clampedAdjustment.maxAtWrite)>=1.5&&(this._clampedAdjustment=null),this.scrollAdjustments=0;const a=this.getScrollOffset();this.scrollDirection=o?a===i?this.scrollDirection:a<i?"forward":"backward":null,this.scrollOffset=i,this.isScrolling=o,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),"addEventListener"in this.scrollElement){const i=this.scrollElement,o=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},a=()=>{this._iosTouching=!1,!(!Yf()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};i.addEventListener("touchstart",o,Rd),i.addEventListener("touchend",a,Rd),this.unsubs.push(()=>{i.removeEventListener("touchstart",o),i.removeEventListener("touchend",a),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}const s=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,s&&this.scrollElement&&this.options.enabled){const[i,o,a,l]=s;i!==null&&!a&&(Yf()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?l!==0&&(this._iosDeferredAdjustment+=l):((n=this.scrollState)==null?void 0:n.behavior)==="smooth"&&!eS(this.getScrollOffset()-l,this.scrollState.lastTargetOffset)||this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),a&&this.scrollToEnd({behavior:a})}this._retryClampedAdjustment()},this._retryClampedAdjustment=()=>{if(this._clampedAdjustment===null||!this.scrollElement||!this.options.enabled)return;const{target:t,maxAtWrite:n}=this._clampedAdjustment,r=this.getMaxScrollOffset();r>n+.5&&(this._clampedAdjustment=t>r+.5?{target:t,maxAtWrite:r}:null,this._scrollToOffset(t,{adjustments:void 0,behavior:void 0}))},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;const t=this.getScrollOffset(),n=this.getMaxScrollOffset();if(t<0||t>n)return;if(this._iosDeferredAdjustment<0&&t>=n-1){this._iosDeferredAdjustment=0;return}const r=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(t,{adjustments:this.scrollAdjustments+=r,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=Xi(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap],(t,n,r,s,i,o,a,l)=>(this.prevLanes!==void 0&&this.prevLanes!==o&&(this.lanesChangedFlag=!0),this.prevLanes=o,this.pendingMin=null,{count:t,paddingStart:n,scrollMargin:r,getItemKey:s,enabled:i,lanes:o,laneAssignmentMode:a,gap:l}),{key:!1}),this.isIndexInRange=t=>t>=0&&t<this.options.count,this.getMeasurements=Xi(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:t,paddingStart:n,scrollMargin:r,getItemKey:s,enabled:i,lanes:o,laneAssignmentMode:a,gap:l},c)=>{var u;const d=this.itemSizeCache;if(!i)return this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>t)for(const v of this.laneAssignments.keys())v>=t&&this.laneAssignments.delete(v);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(v=>{this.itemSizeCache.set(v.key,v.size)}));const h=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===t&&(this.lanesSettling=!1),o===1){const v=t*2;let y=(u=this._singleLaneMeasurements)==null?void 0:u.flat;if(!y||y.length<v){const A=new Float64Array(v);y&&h>0&&A.set(y.subarray(0,h*2)),y=A}const b=h===0?new Array(t):this._singleLaneMeasurements.items.slice();let E;if(h===0)E=n+r;else{const A=h-1;E=y[A*2]+y[A*2+1]+l}for(let A=h;A<t;A++){const x=s(A);b[A]=x;const O=d.get(x),R=typeof O=="number"?O:this.options.estimateSize(A);y[A*2]=E,y[A*2+1]=R,E+=R+l}this._singleLaneMeasurements={flat:y,items:b};const w=dJ(b,y);return this.measurementsCache=w,w}const f=this.measurementsCache.slice(0,h),B=new Array(o).fill(void 0),g=new Float64Array(o);let C=0;for(let v=0;v<h;v++){const y=f[v];y&&(B[y.lane]===void 0&&C++,B[y.lane]=v,g[y.lane]=y.end)}for(let v=h;v<t;v++){const y=s(v),b=this.laneAssignments.get(v);let E,w;const A=a==="estimate"||d.has(y);if(b!==void 0&&this.options.lanes>1){E=b;const P=B[E],_=P!==void 0?f[P]:void 0;w=_?_.end+l:n+r}else if(C===o){let P=0,_=g[0],N=B[0];for(let q=1;q<o;q++){const W=g[q];(W<_||W===_&&B[q]<N)&&(P=q,_=W,N=B[q])}E=P,w=_+l,A&&this.laneAssignments.set(v,E)}else E=v%this.options.lanes,w=n+r,A&&this.laneAssignments.set(v,E);const x=d.get(y),O=typeof x=="number"?x:this.options.estimateSize(v),R=w+O;f[v]={index:v,start:w,size:O,end:R,key:y,lane:E},B[E]===void 0&&C++,B[E]=v,g[E]=R}return this.measurementsCache=f,f},{key:!1,debug:()=>this.options.debug}),this.calculateRange=Xi(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(t,n,r,s)=>t.length===0||n===0?(this.range=null,null):(this.range=wJ(t,n,r,s,s===1&&this._singleLaneMeasurements!==null?this._singleLaneMeasurements.flat:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=Xi(()=>{let t=null,n=null;const r=this.calculateRange();return r&&(t=r.startIndex,n=r.endIndex),this.maybeNotify.updateDeps([this.isScrolling,t,n]),[this.options.rangeExtractor,this.options.overscan,this.options.count,t,n]},(t,n,r,s,i)=>s===null||i===null?[]:t({startIndex:s,endIndex:i,overscan:n,count:r}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=t=>{const n=this.options.indexAttribute,r=t.getAttribute(n);return r?parseInt(r,10):(console.warn(`Missing attribute name '${n}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=t=>{var n;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const r=this.scrollState.index??((n=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:n.index);if(r!==void 0&&this.range){const s=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),i=Math.max(0,r-s),o=Math.min(this.options.count-1,r+s);return t>=i&&t<=o}return!0},this.measureElement=t=>{if(!t){this.elementsCache.forEach((i,o)=>{i.isConnected||(this.observer.unobserve(i),this.elementsCache.delete(o))});return}const n=this.indexFromElement(t);if(!this.isIndexInRange(n))return;const r=this.options.getItemKey(n),s=this.elementsCache.get(r);s!==t&&(s&&this.observer.unobserve(s),this.observer.observe(t),this.elementsCache.set(r,t)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,void 0,this))},this.resizeItem=(t,n)=>{var r,s,i;if(!this.isIndexInRange(t))return;let o,a,l;const c=(r=this._singleLaneMeasurements)==null?void 0:r.flat;if(this.options.lanes===1&&c!=null)l=this.options.getItemKey(t),a=c[t*2],o=c[t*2+1];else{const h=this.measurementsCache[t];if(!h)return;l=h.key,a=h.start,o=h.size}const u=this.itemSizeCache.get(l)??o,d=n-u;if(d!==0){const h=this.options.anchorTo==="end"&&((s=this.scrollState)==null?void 0:s.behavior)!=="smooth"&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,f=h?this.getTotalSize():0,B=this.getScrollOffset()+this.scrollAdjustments,g=this.itemSizeCache.has(l)?a+u<=B&&this.scrollDirection!=="backward":a<B,C=((i=this.scrollState)==null?void 0:i.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[t]??{index:t,key:l,start:a,size:o,end:a+o,lane:0},d,this):g);(this.pendingMin===null||t<this.pendingMin)&&(this.pendingMin=t),this.itemSizeCache.set(l,n),this.itemSizeCacheVersion++;let v=!1;h?v=this.applyScrollAdjustment(this.getTotalSize()-f):C&&(v=this.applyScrollAdjustment(d)),this.notify(v),this._retryClampedAdjustment()}},this.getVirtualItems=Xi(()=>[this.getVirtualIndexes(),this.getMeasurements()],(t,n)=>{const r=[];for(let s=0,i=t.length;s<i;s++){const o=n[t[s]];r.push(o)}return r},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=t=>{var n;const r=this.getMeasurements();if(r.length===0)return;const s=(n=this._singleLaneMeasurements)==null?void 0:n.flat,i=this.options.lanes===1&&s!=null,o=KI(0,r.length-1,i?a=>s[a*2]:a=>Zb(r[a]).start,t);return Zb(r[o])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const t=this.scrollElement.document.documentElement;return this.options.horizontal?t.scrollWidth-this.scrollElement.innerWidth:t.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(t=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=t,this.getOffsetForAlignment=(t,n,r=0)=>{if(!this.scrollElement)return 0;const s=this.getSize(),i=this.getScrollOffset();n==="auto"&&(n=t>=i+s?"end":"start"),n==="center"?t+=(r-s)/2:n==="end"&&(t-=s);const o=this.getMaxScrollOffset();return Math.max(Math.min(o,t),0)},this.getOffsetForIndex=(t,n="auto")=>{t=Math.max(0,Math.min(t,this.options.count-1));const r=this.getSize(),s=this.getScrollOffset(),i=this.measurementsCache[t];if(!i)return;if(n==="auto")if(i.end>=s+r-this.options.scrollPaddingEnd)n="end";else if(i.start<=s+this.options.scrollPaddingStart)n="start";else return[s,n];if(n==="end"&&t===this.options.count-1)return[this.getMaxScrollOffset(),n];const o=n==="end"?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(o,n,i.size),n]},this.scrollToOffset=(t,{align:n="start",behavior:r="auto"}={})=>{this._iosDeferredAdjustment=0;const s=this.getOffsetForAlignment(t,n),i=this.now();this.scrollState={index:null,align:n,behavior:r,startedAt:i,lastTargetOffset:s,stableFrames:0},this._scrollToOffset(s,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.scrollToIndex=(t,{align:n="auto",behavior:r="auto"}={})=>{this._iosDeferredAdjustment=0,t=Math.max(0,Math.min(t,this.options.count-1));const s=this.getOffsetForIndex(t,n);if(!s)return;const[i,o]=s,a=this.now();this.scrollState={index:t,align:o,behavior:r,startedAt:a,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.scrollBy=(t,{behavior:n="auto"}={})=>{const r=this.getScrollOffset()+t,s=this.now();this.scrollState={index:null,align:"start",behavior:n,startedAt:s,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:t="auto"}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:"end",behavior:t});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:t})},this.getTotalSize=()=>{var t,n;const r=this.getMeasurements();let s;if(r.length===0)s=this.options.paddingStart;else if(this.options.lanes===1){const i=r.length-1,o=(t=this._singleLaneMeasurements)==null?void 0:t.flat;o!=null?s=o[i*2]+o[i*2+1]:s=((n=r[i])==null?void 0:n.end)??0}else{const i=Array(this.options.lanes).fill(null);let o=r.length-1;for(;o>=0&&i.some(a=>a===null);){const a=r[o];i[a.lane]===null&&(i[a.lane]=a.end),o--}s=Math.max(...i.filter(a=>a!==null))}return Math.max(s-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{const t=[];if(this.itemSizeCache.size===0)return t;const n=this.getMeasurements();for(const r of n)r&&this.itemSizeCache.has(r.key)&&t.push({index:r.index,key:r.key,start:r.start,size:r.size,end:r.end,lane:r.lane});return t},this._scrollToOffset=(t,{adjustments:n,behavior:r})=>{this._intendedScrollOffset=t+(n??0),this.options.scrollToFn(t,{behavior:r,adjustments:n},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(e)}applyScrollAdjustment(e,t){if(e===0)return!1;if(Yf()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded))return this._iosDeferredAdjustment+=e,!1;{const n=this.getScrollOffset()+this.scrollAdjustments+e,r=this.scrollElement,s=r!==null&&("scrollHeight"in r||"document"in r)?this.getMaxScrollOffset():null;return this._clampedAdjustment=s!==null&&n>s+.5?{target:n,maxAtWrite:s}:null,this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=e,behavior:t}),this.scrollOffset!==null&&(this.scrollOffset+=this.scrollAdjustments,this.scrollOffset<0&&(this.scrollOffset=0),this.scrollAdjustments=0),!0}}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}const e=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,t=e?e[0]:this.scrollState.lastTargetOffset,n=1,r=t!==this.scrollState.lastTargetOffset;if(!r&&eS(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=n){this.getScrollOffset()!==t&&this._scrollToOffset(t,{adjustments:void 0,behavior:"auto"}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,r){const s=this.getSize()||600,i=Math.abs(t-this.getScrollOffset()),o=this.scrollState.behavior==="smooth"&&i>s;this.scrollState.lastTargetOffset=t,o||(this.scrollState.behavior="auto"),this._scrollToOffset(t,{adjustments:void 0,behavior:o?"smooth":"auto"})}this.scheduleScrollReconcile()}},KI=(e,t,n,r)=>{for(;e<=t;){const s=(e+t)/2|0,i=n(s);if(i<r)e=s+1;else if(i>r)t=s-1;else return s}return e>0?e-1:0};function xJ(e,t,n){let r=0;for(;r<=t;){const s=(r+t)/2|0,i=e[s*2];if(i<n)r=s+1;else if(i>n)t=s-1;else return s}return r>0?r-1:0}function wJ(e,t,n,r,s){const i=e.length-1;if(e.length<=r)return{startIndex:0,endIndex:i};if(r===1&&s!==null){const c=xJ(s,i,n);let u=c;const d=n+t;for(;u<i&&s[u*2]+s[u*2+1]<d;)u++;return{startIndex:c,endIndex:u}}let a=KI(0,i,c=>e[c].start,n),l=a;if(r===1)for(;l<i&&e[l].end<n+t;)l++;else if(r>1){const c=Array(r).fill(0);for(;l<i&&c.some(d=>d<n+t);){const d=e[l];c[d.lane]=d.end,l++}const u=Array(r).fill(n+t);for(;a>=0&&u.some(d=>d>=n);){const d=e[a];u[d.lane]=d.start,a--}a=Math.max(0,a-a%r),l=Math.min(i,l+(r-1-l%r))}return{startIndex:a,endIndex:l}}var Xf=typeof document<"u"?p.useLayoutEffect:p.useEffect;function DJ({useFlushSync:e=!0,directDomUpdates:t=!1,directDomUpdatesMode:n="transform",...r}){const s=p.useReducer(d=>d+1,0)[1],i=p.useRef({enabled:t,mode:n,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});i.current.enabled=t,i.current.mode=n;const o=p.useRef(!1),a=d=>{const h=i.current;if(!h.enabled||!h.container)return;const f=d.getTotalSize();if(f!==h.lastSize){h.lastSize=f;const B=d.options.horizontal?"width":"height";h.container.style[B]=`${f}px`}},l=d=>{const h=i.current;if(!h.enabled||!h.container)return;a(d);const f=!!d.options.horizontal,B=h.mode==="transform",g=f?"left":"top",C=d.options.scrollMargin,v=d.getVirtualItems();for(const y of v){const b=y.start-C,E=d.elementsCache.get(y.key);E&&h.lastPositions.get(E)!==b&&(h.lastPositions.set(E,b),B?E.style.transform=f?`translate3d(${b}px, 0, 0)`:`translate3d(0, ${b}px, 0)`:E.style[g]=`${b}px`)}},c={...r,onChange:(d,h)=>{var f;const B=i.current;let g=!0;if(B.enabled){l(d);const C=d.range,v=B.prevRange;g=!v||v.isScrolling!==d.isScrolling||v.startIndex!==C?.startIndex||v.endIndex!==C?.endIndex,g&&(B.prevRange=C?{startIndex:C.startIndex,endIndex:C.endIndex,isScrolling:d.isScrolling}:null)}g&&(e&&h&&!o.current?(0,Yo.flushSync)(s):s()),(f=r.onChange)==null||f.call(r,d,h)}},[u]=p.useState(()=>{const d=new EJ(c),h=d.measureElement;return d.measureElement=f=>{o.current=!0;try{h(f)}finally{o.current=!1}},Object.assign(d,{containerRef:f=>{const B=i.current;if(B.container=f,B.lastSize=null,f&&B.enabled){const g=d.getTotalSize();B.lastSize=g;const C=d.options.horizontal?"width":"height";f.style[C]=`${g}px`}}})});return u.setOptions(c),Xf(()=>u._didMount(),[]),Xf(()=>(a(u),u._willUpdate())),Xf(()=>{l(u)}),u}function TJ(e){return DJ({observeElementRect:pJ,observeElementOffset:CJ,scrollToFn:bJ,...e})}function AJ(e){return e.map((t,n)=>typeof t=="number"?`[${t}]`:n===0?t:`.${t}`).join("")}function JI(e){const t=[];let n=0;const r=()=>{for(;n<e.length&&/\s/.test(e[n]);)n++},s=()=>{const d=n;for(n++;n<e.length;)if(e[n]==="\\")n+=2;else if(e[n]==='"'){n++;break}else n++;return e.slice(d,n)},i=()=>{const d=n;for(e[n]==="-"&&n++;n<e.length&&/[0-9]/.test(e[n]);)n++;if(e[n]===".")for(n++;n<e.length&&/[0-9]/.test(e[n]);)n++;if(e[n]==="e"||e[n]==="E")for(n++,(e[n]==="+"||e[n]==="-")&&n++;n<e.length&&/[0-9]/.test(e[n]);)n++;return e.slice(d,n)},o=()=>{const d=n;for(;n<e.length&&/[a-z]/.test(e[n]);)n++;return e.slice(d,n)},a=[];let l=!1;const c=[];let u=null;for(;n<e.length&&(r(),!(n>=e.length));){const d=e[n],h=n;switch(d){case"{":t.push({type:"punctuation",value:"{",start:h,end:n+1}),a.push("object"),l=!0,u!==null&&(c.push(u),u=null),n++;break;case"}":t.push({type:"punctuation",value:"}",start:h,end:n+1}),a.pop(),c.length>0&&typeof c[c.length-1]=="string"&&c.pop(),l=!1,n++;break;case"[":t.push({type:"punctuation",value:"[",start:h,end:n+1}),a.push("array"),u!==null&&(c.push(u),u=null),c.push(0),l=!1,n++;break;case"]":t.push({type:"punctuation",value:"]",start:h,end:n+1}),a.pop(),c.length>0&&typeof c[c.length-1]=="number"&&c.pop(),c.length>0&&typeof c[c.length-1]=="string"&&c.pop(),l=!1,n++;break;case":":t.push({type:"punctuation",value:":",start:h,end:n+1}),l=!1,n++;break;case",":t.push({type:"punctuation",value:",",start:h,end:n+1}),l=a.length>0&&a[a.length-1]==="object",a.length>0&&a[a.length-1]==="array"&&c.length>0&&typeof c[c.length-1]=="number"&&(c[c.length-1]=c[c.length-1]+1),n++;break;case'"':{const f=s();if(l&&a.length>0&&a[a.length-1]==="object"){let B;try{B=JSON.parse(f)}catch{B=f.slice(1,-1)}u=B,t.push({type:"key",value:f,start:h,end:n,path:[...c,B],keyName:B})}else{const B=u!==null?[...c,u]:[...c];t.push({type:"string",value:f,start:h,end:n,path:B,keyName:u??void 0}),u=null}break}case"-":case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{const f=i(),B=u!==null?[...c,u]:[...c];t.push({type:"number",value:f,start:h,end:n,path:B,keyName:u??void 0}),u=null,l=!1;break}case"t":case"f":{const f=o(),B=u!==null?[...c,u]:[...c];f==="true"?t.push({type:"boolean",value:f,start:h,end:n,path:B,keyName:u??void 0}):f==="false"&&t.push({type:"boolean-false",value:f,start:h,end:n,path:B,keyName:u??void 0}),u=null,l=!1;break}case"n":{const f=o();if(f==="null"){const B=u!==null?[...c,u]:[...c];t.push({type:"null",value:f,start:h,end:n,path:B,keyName:u??void 0}),u=null}l=!1;break}default:n++}}return t}function QI(e){const t=JI(e);let n="",r=0;const s=i=>{i&&(n+=`<span class="json-punctuation">${nS(i)}</span>`)};for(const i of t){i.start>r&&s(e.slice(r,i.start));const o=`json-${i.type}`;n+=`<span class="${o}">${nS(i.value)}</span>`,r=i.end}return r<e.length&&s(e.slice(r)),n}function nS(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function YI({value:e,displayValue:t,maxLength:n,onCopy:r,keyName:s,path:i}){const[o,a]=(0,p.useState)(null),[l,c]=(0,p.useState)(!1),[u,d]=(0,p.useState)(!1),h=e.length>n,f=h&&!u?`"${e.slice(0,n)}..."`:t,B=(0,p.useCallback)(async(y,b)=>{await ra(y)&&(a(b),r?.(y),setTimeout(()=>a(null),1500))},[r]),g=(0,p.useCallback)(y=>{h&&(y.stopPropagation(),d(b=>!b))},[h]),C=i&&i.length>0?AJ(i):null,v=[];return v.push({label:"Copy value",value:e,key:"value"}),s&&v.push({label:"Copy key",value:s,key:"key"}),C&&v.push({label:"Copy path",value:C,key:"path"}),v.length===1?(0,m.jsxs)("span",{className:"relative group/copy",onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),children:[(0,m.jsx)("span",{onClick:g,className:he("json-string",h&&!u&&"json-string-truncated"),children:f}),(0,m.jsx)("button",{onClick:y=>{y.stopPropagation(),B(v[0].value,v[0].key)},className:he("inline-flex items-center justify-center ml-1 p-0.5 rounded","transition-all duration-150","hover:bg-muted",l||o?"opacity-100":"opacity-0"),style:{verticalAlign:"middle"},children:o?(0,m.jsx)(Vs,{className:"h-3 w-3 text-green-500"}):(0,m.jsx)(_s,{className:"h-3 w-3 text-muted-foreground/60 hover:text-muted-foreground"})})]}):(0,m.jsxs)("span",{className:"relative group/copy",onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),children:[(0,m.jsx)("span",{onClick:g,className:he("json-string",h&&!u&&"json-string-truncated"),children:f}),(0,m.jsxs)(OC,{children:[(0,m.jsx)(MC,{asChild:!0,children:(0,m.jsx)("button",{className:he("inline-flex items-center justify-center ml-1 p-0.5 rounded","transition-all duration-150","hover:bg-muted",l||o?"opacity-100":"opacity-0"),style:{verticalAlign:"middle"},onClick:y=>y.stopPropagation(),children:o?(0,m.jsx)(Vs,{className:"h-3 w-3 text-green-500"}):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(_s,{className:"h-3 w-3 text-muted-foreground/60"}),(0,m.jsx)(uD,{className:"h-2 w-2 text-muted-foreground/60 -ml-0.5"})]})})}),(0,m.jsx)(NC,{align:"start",className:"min-w-[140px]",children:v.map(y=>(0,m.jsxs)(Pu,{onClick:()=>B(y.value,y.key),className:"text-xs",children:[(0,m.jsx)(_s,{className:"h-3 w-3 mr-2"}),y.label]},y.key))})]})]})}function rS(e,t){return t?(0,m.jsx)("span",{className:"json-punctuation",children:t},e):null}function Zf({children:e,value:t,onCopy:n}){const[r,s]=(0,p.useState)(!1),[i,o]=(0,p.useState)(!1),a=(0,p.useCallback)(async l=>{await ra(l)&&(s(!0),n?.(l),setTimeout(()=>s(!1),1500))},[n]);return(0,m.jsxs)("span",{className:"relative group/copy",onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),children:[e,(0,m.jsx)("button",{onClick:l=>{l.stopPropagation(),a(t)},className:he("inline-flex items-center justify-center ml-1 p-0.5 rounded","transition-all duration-150","hover:bg-muted",i||r?"opacity-100":"opacity-0"),style:{verticalAlign:"middle"},children:r?(0,m.jsx)(Vs,{className:"h-3 w-3 text-green-500"}):(0,m.jsx)(_s,{className:"h-3 w-3 text-muted-foreground/60 hover:text-muted-foreground"})})]})}function sS(e,t){const n=e[t],r=n==="{"?"}":"]";let s=1,i=t+1,o=!1,a=!1;for(;i<e.length&&s>0;){const l=e[i];a?a=!1:l==="\\"?a=!0:l==='"'?o=!o:o||(l===n?s++:l===r&&s--),i++}return e.slice(t,i)}function IJ({content:e,onCopy:t,collapseStringsAfterLength:n}){const r=(0,p.useMemo)(()=>{const s=JI(e),i=[];let o=0,a=null,l=!0;const c=u=>{for(let d=u+1;d<s.length;d++){const h=s[d];if(!(h.type==="punctuation"&&h.value===":"))return h}return null};for(let u=0;u<s.length;u++){const d=s[u];d.start>o&&i.push(rS(`ws-${o}`,e.slice(o,d.start)));const h=`json-${d.type}`;if(d.type==="key"){const g=c(u);g&&g.type==="punctuation"&&(g.value==="{"||g.value==="[")&&(a={start:g.start}),i.push((0,m.jsx)("span",{className:h,children:d.value},`token-${u}`)),o=d.end;continue}if(l&&d.type==="punctuation"&&(d.value==="{"||d.value==="[")){l=!1;const g=sS(e,d.start);i.push((0,m.jsx)(Zf,{value:g,onCopy:t,children:(0,m.jsx)("span",{className:h,children:d.value})},`token-${u}`)),o=d.end;continue}if(a&&d.type==="punctuation"&&(d.value==="{"||d.value==="[")&&d.start===a.start){const g=sS(e,d.start);a=null,i.push((0,m.jsx)(Zf,{value:g,onCopy:t,children:(0,m.jsx)("span",{className:h,children:d.value})},`token-${u}`)),o=d.end;continue}const f=d.type==="string"||d.type==="number"||d.type==="boolean"||d.type==="boolean-false"||d.type==="null",B=()=>{if(d.type==="string")try{return JSON.parse(d.value)}catch{return d.value.slice(1,-1)}return d.value};if(d.type==="string"&&n!==void 0){const g=B();i.push((0,m.jsx)(YI,{value:g,displayValue:d.value,maxLength:n,onCopy:t,keyName:d.keyName,path:d.path},`token-${u}`))}else f?i.push((0,m.jsx)(Zf,{value:B(),onCopy:t,children:(0,m.jsx)("span",{className:h,children:d.value})},`token-${u}`)):i.push((0,m.jsx)("span",{className:h,children:d.value},`token-${u}`));o=d.end}return o<e.length&&i.push(rS("ws-end",e.slice(o))),i},[e,t,n]);return(0,m.jsx)(m.Fragment,{children:r})}var yi=20,iS=30,oS=12,Zp=80,kJ=2;function RJ(e){const t=e.value,n=e.selectionStart,r=t.substring(0,n).split(`
60
+ `);return{line:r.length,column:r[r.length-1].length+1}}function OJ(e){const t=window.getComputedStyle(e),n=document.createElement("span");n.textContent="0",n.style.font=t.font,n.style.position="absolute",n.style.visibility="hidden",n.style.whiteSpace="pre",document.body.appendChild(n);const r=n.getBoundingClientRect().width;if(n.remove(),!Number.isFinite(r)||r<=0)return Zp;const s=Number.parseFloat(t.paddingLeft)||0,i=Number.parseFloat(t.paddingRight)||0,o=e.clientWidth-s-i;return o<=0?Zp:Math.max(1,Math.floor(o/r))}function MJ(e,t){const n=e.replace(/\t/g," ".repeat(kJ)).length;return n===0?1:Math.max(1,Math.ceil(n/t))}function NJ(e,t,n){let r=0;return e.map((s,i)=>{const o=t?MJ(s,n)*yi:yi,a=t?r:i*yi;return r+=o,{top:a,height:o}})}function PJ(e,t,n,r,s){return(0,p.useMemo)(()=>{if(!r)return{highlightedHtml:"",paddingTop:0,paddingBottom:0};const i=e.split(`
61
+ `),o=i.length;if(o===0)return{highlightedHtml:"",paddingTop:0,paddingBottom:0};let a=0,l=o-1;for(;a<=l;){const w=a+l>>>1,A=s[w];!A||A.top+A.height<=t?a=w+1:l=w-1}const c=Math.min(a,o-1),u=t+n;let d=c;for(let w=c;w<o;w++){const A=s[w];if(!A||A.top>=u)break;d=w}const h=Math.max(0,c-iS),f=Math.min(o-1,d+iS),B=i.slice(h,f+1).join(`
62
+ `),g=s[h],C=s[f],v=s[o-1],y=v?v.top+v.height:0,b=g?.top??0,E=Math.max(0,y-(C?C.top+C.height:0));return{highlightedHtml:QI(B),paddingTop:b,paddingBottom:E}},[e,t,n,r,s])}function XI({content:e,onChange:t,onCursorChange:n,onUndo:r,onRedo:s,onEscape:i,isValid:o=!0,readOnly:a=!1,className:l,height:c,maxHeight:u,showLineNumbers:d=!0,collapseStringsAfterLength:h,wrapLongLinesInEdit:f=!1,wrapLongLinesInView:B=!1}){const g=(0,p.useRef)(null),C=(0,p.useRef)(null),v=(0,p.useRef)(null),y=(0,p.useRef)(null),b=(0,p.useRef)(null),[E,w]=(0,p.useState)(!1),[A,x]=(0,p.useState)(1),[O,R]=(0,p.useState)(0),[P,_]=(0,p.useState)(0),[N,q]=(0,p.useState)(400),W=(0,p.useRef)(null),F=(0,p.useRef)(null),z=(0,p.useRef)(0),[J,Z]=(0,p.useState)(Zp),Q=a?B:f,G=a&&c==="auto",be=(0,p.useMemo)(()=>e.split(`
63
+ `),[e]),ve=(0,p.useMemo)(()=>NJ(be,Q,J),[J,Q,be]),X=be.length,Y=ve[Math.min(Math.max(A-1,0),X-1)],ie=Y?.top??0,ne=Y?.height??yi,ee=!a,Be=ie-O+oS,de=(0,p.useCallback)(()=>{const oe=a?y.current:g.current;if(!Q||!oe)return;const je=OJ(oe);Z(Le=>Le===je?Le:je)},[Q,a]),Re=TJ({count:X,getScrollElement:()=>a?v.current:C.current,estimateSize:oe=>ve[oe]?.height??yi,overscan:20}),{highlightedHtml:Ee,paddingTop:st}=PJ(e,O,N,ee,ve),at=(0,p.useMemo)(()=>a?"":ee?Ee:QI(e),[e,a,ee,Ee]),Bt=ee?st:0,tt=(0,p.useRef)(0);tt.current=Bt;const pt=(0,p.useRef)(0);pt.current=ie;const Lt=(0,p.useCallback)(()=>{if(g.current){const oe=g.current.scrollTop,je=g.current.scrollLeft;C.current&&(C.current.scrollTop=oe),W.current&&(W.current.style.transform=`translate(${-je}px, ${tt.current-oe}px)`),F.current&&(F.current.style.transform=`translateY(${pt.current-oe+oS}px)`),cancelAnimationFrame(z.current),z.current=requestAnimationFrame(()=>{R(oe),_(je)})}},[]),mt=(0,p.useCallback)(()=>{if(g.current&&n){const oe=RJ(g.current);n(oe),x(oe.line)}},[n]),lt=(0,p.useCallback)(oe=>{const je=oe.currentTarget,{selectionStart:Le,selectionEnd:Un,value:_t}=je;if((oe.ctrlKey||oe.metaKey)&&oe.key==="z"&&!oe.shiftKey){oe.preventDefault(),r?.();return}if((oe.ctrlKey||oe.metaKey)&&oe.shiftKey&&oe.key==="z"||oe.ctrlKey&&oe.key==="y"){oe.preventDefault(),s?.();return}if(oe.key==="Escape"&&i){oe.preventDefault(),i();return}if(oe.key==="Tab"){oe.preventDefault();const Vt=" ";if(oe.shiftKey){const Bn=_t.lastIndexOf(`
64
+ `,Le-1)+1;if(_t.substring(Bn,Le).startsWith(Vt)){const An=_t.substring(0,Bn)+_t.substring(Bn+2);t?.(An),requestAnimationFrame(()=>{je.selectionStart=je.selectionEnd=Le-2})}}else{const Bn=_t.substring(0,Le)+Vt+_t.substring(Un);t?.(Bn),requestAnimationFrame(()=>{je.selectionStart=je.selectionEnd=Le+2})}return}if(oe.key==="Enter"){oe.preventDefault();const Vt=_t.lastIndexOf(`
65
+ `,Le-1)+1,Bn=_t.substring(Vt,Le).match(/^(\s*)/)?.[1]||"",An=_t[Le-1],gs=_t[Le],Ge=An==="{"||An==="[",Cs=gs==="}"||gs==="]";let Kt=`
66
+ `+Bn,vs=Kt.length;Ge&&(Kt=`
67
+ `+Bn+" ",vs=Kt.length,Cs&&(Kt+=`
68
+ `+Bn));const Qe=_t.substring(0,Le)+Kt+_t.substring(Un);t?.(Qe),requestAnimationFrame(()=>{je.selectionStart=je.selectionEnd=Le+vs})}},[t,r,s,i]);(0,p.useEffect)(()=>{a||g.current?.focus()},[a]),(0,p.useEffect)(()=>{const oe=()=>{b.current&&q(b.current.clientHeight)};return oe(),window.addEventListener("resize",oe),()=>window.removeEventListener("resize",oe)},[]),(0,p.useEffect)(()=>()=>cancelAnimationFrame(z.current),[]),(0,p.useEffect)(()=>{A>X&&x(X)},[A,X]),(0,p.useEffect)(()=>{Re.measure()},[ve,Re]),(0,p.useEffect)(()=>{if(!Q)return;de(),window.addEventListener("resize",de);let oe;const je=a?y.current:g.current;return window.ResizeObserver&&je&&(oe=new ResizeObserver(()=>de()),oe.observe(je)),()=>{window.removeEventListener("resize",de),oe?.disconnect()}},[Q,a,de]);const Vn={height:c??"auto",maxHeight:u??"none"},it={fontFamily:"var(--font-code)"};return(0,m.jsxs)("div",{ref:b,className:he("group relative flex w-full overflow-hidden bg-muted/30",!o&&"border-destructive",l),style:Vn,children:[d&&!a&&(0,m.jsx)("div",{ref:C,className:"flex-shrink-0 h-full overflow-hidden bg-muted/50 text-right select-none border-r border-border/50",style:{width:"3rem"},children:(0,m.jsx)("div",{className:"py-3 pr-2 text-xs text-muted-foreground leading-5 relative",style:{...it,height:`${Re.getTotalSize()}px`},children:Re.getVirtualItems().map(oe=>{const je=oe.index+1,Le=ve[oe.index]?.height??yi;return(0,m.jsx)("div",{className:he("leading-5 transition-colors duration-150 absolute left-0 right-0 pr-2",je===A&&E&&"text-foreground font-medium"),style:{transform:`translateY(${oe.start}px)`,height:`${Le}px`},children:je},oe.index)})})}),(0,m.jsx)("div",{className:he("relative flex-1 min-w-0",G?"overflow-visible":"h-full overflow-hidden"),children:a?(0,m.jsxs)("div",{ref:v,className:he("relative z-10 flex min-w-0 items-start",G?"h-auto overflow-visible":"h-full min-h-0 overflow-auto overscroll-none"),children:[d&&(0,m.jsx)("div",{ref:C,className:he("flex-shrink-0 border-r border-border/50 bg-muted/50 text-right select-none self-stretch",!G&&"sticky left-0 z-20"),style:{width:"3rem"},children:(0,m.jsx)("div",{className:"py-3 pr-2 text-xs text-muted-foreground leading-5 relative",style:{...it,height:`${Re.getTotalSize()}px`},children:Re.getVirtualItems().map(oe=>{const je=oe.index+1,Le=ve[oe.index]?.height??yi;return(0,m.jsx)("div",{className:"leading-5 transition-colors duration-150 absolute left-0 right-0 pr-2",style:{transform:`translateY(${oe.start}px)`,height:`${Le}px`},children:je},oe.index)})})}),(0,m.jsx)("div",{className:he("relative self-start overflow-visible",Q?"flex-1 min-w-0":"w-max min-w-full"),children:(0,m.jsx)("pre",{ref:y,className:he("p-3 text-xs leading-5 m-0 select-text cursor-text",Q?"w-full whitespace-pre-wrap break-words":"w-max min-w-full whitespace-pre"),style:it,children:(0,m.jsx)(IJ,{content:e,collapseStringsAfterLength:h})})})]}):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)("pre",{ref:y,className:he("absolute inset-0 p-3 text-xs leading-5 overflow-hidden",Q?"whitespace-pre-wrap break-words":"whitespace-pre","pointer-events-none m-0","text-muted-foreground"),style:{...it,scrollbarGutter:"stable"},"aria-hidden":"true",children:(0,m.jsx)("div",{ref:W,style:{transform:`translate(${-P}px, ${Bt-O}px)`,willChange:"transform"},children:(0,m.jsx)("div",{dangerouslySetInnerHTML:{__html:at+`
69
+ `}})})}),E&&(0,m.jsx)("div",{ref:F,className:"absolute left-0 right-0 bg-foreground/[0.03] pointer-events-none",style:{height:`${ne}px`,transform:`translateY(${Be}px)`}}),(0,m.jsx)("textarea",{ref:g,value:e,wrap:Q?"soft":"off",onChange:oe=>t?.(oe.target.value),onScroll:Lt,onSelect:mt,onClick:mt,onKeyDown:lt,onKeyUp:mt,onFocus:()=>w(!0),onBlur:()=>w(!1),spellCheck:!1,className:he("absolute inset-0 z-10 w-full h-full resize-none bg-transparent p-3 text-xs leading-5","focus:outline-none","text-transparent caret-foreground","selection:bg-primary/20",Q?"overflow-auto whitespace-pre-wrap break-words":"overflow-auto whitespace-pre"),style:{...it,tabSize:2,scrollbarGutter:"stable"}})]})})]})}var aS=100;function LJ(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}function ZI(e,t){const n=Math.min(t,aS),r=[],s=[{value:e,path:"root",depth:0}];for(;s.length>0;){const i=s.pop();if(typeof i.value!="object"||i.value===null)continue;if(i.depth>=aS){i.depth>=n&&LJ(i.value)&&r.push(i.path);continue}const o=Object.entries(i.value);if(o.length!==0){i.depth>=n&&r.push(i.path);for(const[a,l]of o)s.push({value:l,path:`${i.path}.${a}`,depth:i.depth+1})}}return r}function _J(e){return ZI(e,0)}function FJ({value:e,defaultExpandDepth:t,initialCollapsedPaths:n,onCollapseChange:r}={}){const[s]=(0,p.useState)(()=>n!==void 0||t===void 0?null:new Set(ZI(e,t))),[i,o]=(0,p.useState)(()=>s??n??new Set),a=(0,p.useCallback)(h=>i.has(h),[i]),l=(0,p.useCallback)(h=>{o(f=>{const B=new Set(f);return B.has(h)?B.delete(h):B.add(h),r?.(B),B})},[r]),c=(0,p.useCallback)(()=>{o(new Set),r?.(new Set)},[r]),u=(0,p.useCallback)(h=>{const f=_J(h),B=new Set(f);o(B),r?.(B)},[r]),d=(0,p.useRef)(!1);return(0,p.useEffect)(()=>{d.current||s===null||(d.current=!0,r?.(s))},[s,r]),(0,p.useEffect)(()=>{n!==void 0&&o(n)},[n]),(0,p.useMemo)(()=>({collapsedPaths:i,isCollapsed:a,toggleCollapse:l,expandAll:c,collapseAll:u}),[i,a,l,c,u])}var Yc=50,HJ=100,jJ=typeof requestIdleCallback<"u"?requestIdleCallback:(e,t)=>{const n=Date.now();return setTimeout(()=>{e({didTimeout:t?.timeout?Date.now()-n>=t.timeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-n))})},1)},GJ=typeof cancelIdleCallback<"u"?cancelIdleCallback:clearTimeout;function ek(e,t){const[n,r]=(0,p.useState)(e.length<=Yc?e.length:Yc);return(0,p.useEffect)(()=>{if(!t){r(Math.min(e.length,Yc));return}r(s=>s>e.length?Math.min(e.length,Yc):s)},[e.length,t]),(0,p.useEffect)(()=>{if(!t||n>=e.length)return;const s=jJ(()=>{r(i=>Math.min(i+HJ,e.length))},{timeout:100});return()=>GJ(s)},[e.length,n,t]),e.slice(0,n)}var Ir=(0,p.memo)(function({children:t,value:n,onCopy:r,alwaysVisible:s=!1}){const[i,o]=(0,p.useState)(!1),[a,l]=(0,p.useState)(!1),c=(0,p.useCallback)(async u=>{u.stopPropagation();let d;try{d=typeof n=="function"?n():n}catch(h){console.error("Failed to serialize value for copy",h);return}await ra(d)&&(o(!0),r?.(d),setTimeout(()=>o(!1),1500))},[n,r]);return(0,m.jsxs)("span",{className:"relative group/copy",onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),children:[t,(0,m.jsx)("button",{onClick:c,className:he("inline-flex items-center justify-center ml-1 p-0.5 rounded","transition-all duration-150","hover:bg-muted",s||a||i?"opacity-100":"opacity-0"),style:{verticalAlign:"middle"},children:i?(0,m.jsx)(Vs,{className:"h-3 w-3 text-green-500"}):(0,m.jsx)(_s,{className:"h-3 w-3 text-muted-foreground/60 hover:text-muted-foreground"})})]})});function VJ({value:e,path:t,keyName:n,isLast:r=!0,depth:s=0,isCollapsed:i,toggleCollapse:o,collapseStringsAfterLength:a,onCopy:l}){const c=s*16,u=i(t),d=ek(e,!u),h=(0,p.useCallback)(()=>JSON.stringify(e,null,2),[e]),f=()=>n===void 0?null:(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)("span",{className:"json-key",children:['"',n,'"']}),(0,m.jsx)("span",{className:"json-punctuation",children:": "})]}),B=()=>r?null:(0,m.jsx)("span",{className:"json-punctuation",children:","});if(e.length===0)return(0,m.jsxs)("div",{className:"leading-5",style:{paddingLeft:c},children:[f(),(0,m.jsx)(Ir,{value:"[]",onCopy:l,alwaysVisible:!0,children:(0,m.jsx)("span",{className:"json-punctuation",children:"[]"})}),B()]});const g=C=>{C.stopPropagation(),o(t)};return u?(0,m.jsxs)("div",{className:"leading-5",style:{paddingLeft:c},children:[(0,m.jsx)("button",{onClick:g,className:"json-collapse-toggle inline-flex items-center justify-center w-4 h-4 -ml-4 hover:bg-muted rounded","data-state":"closed",children:(0,m.jsx)(Mo,{className:"h-3 w-3"})}),f(),(0,m.jsxs)(Ir,{value:h,onCopy:l,alwaysVisible:!0,children:[(0,m.jsx)("span",{className:"json-punctuation",children:"["}),(0,m.jsxs)("span",{className:"text-muted-foreground text-xs px-1",children:[e.length," ",e.length===1?"item":"items"]}),(0,m.jsx)("span",{className:"json-punctuation",children:"]"})]}),B()]}):(0,m.jsxs)(p.Fragment,{children:[(0,m.jsxs)("div",{className:"leading-5",style:{paddingLeft:c},children:[(0,m.jsx)("button",{onClick:g,className:"json-collapse-toggle inline-flex items-center justify-center w-4 h-4 -ml-4 hover:bg-muted rounded","data-state":"open",children:(0,m.jsx)(Mo,{className:"h-3 w-3"})}),f(),(0,m.jsx)(Ir,{value:h,onCopy:l,alwaysVisible:!0,children:(0,m.jsx)("span",{className:"json-punctuation",children:"["})})]}),d.map((C,v)=>(0,m.jsx)(XC,{value:C,path:`${t}.${v}`,isLast:v===e.length-1&&d.length===e.length,depth:s+1,isCollapsed:i,toggleCollapse:o,collapseStringsAfterLength:a,onCopy:l},`${t}.${v}`)),d.length<e.length&&(0,m.jsxs)("div",{className:"leading-5 text-muted-foreground text-xs",style:{paddingLeft:(s+1)*16},children:["Loading ",e.length-d.length," more items..."]}),(0,m.jsxs)("div",{className:"leading-5",style:{paddingLeft:c},children:[(0,m.jsx)("span",{className:"json-punctuation",children:"]"}),B()]})]})}function UJ({value:e,path:t,keyName:n,isLast:r=!0,depth:s=0,isCollapsed:i,toggleCollapse:o,collapseStringsAfterLength:a,onCopy:l}){const c=s*16,u=i(t),d=Object.entries(e),h=ek(d,!u),f=(0,p.useCallback)(()=>JSON.stringify(e,null,2),[e]),B=()=>n===void 0?null:(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)("span",{className:"json-key",children:['"',n,'"']}),(0,m.jsx)("span",{className:"json-punctuation",children:": "})]}),g=()=>r?null:(0,m.jsx)("span",{className:"json-punctuation",children:","});if(d.length===0)return(0,m.jsxs)("div",{className:"leading-5",style:{paddingLeft:c},children:[B(),(0,m.jsx)(Ir,{value:"{}",onCopy:l,alwaysVisible:!0,children:(0,m.jsx)("span",{className:"json-punctuation",children:"{}"})}),g()]});const C=v=>{v.stopPropagation(),o(t)};return u?(0,m.jsxs)("div",{className:"leading-5",style:{paddingLeft:c},children:[(0,m.jsx)("button",{onClick:C,className:"json-collapse-toggle inline-flex items-center justify-center w-4 h-4 -ml-4 hover:bg-muted rounded","data-state":"closed",children:(0,m.jsx)(Mo,{className:"h-3 w-3"})}),B(),(0,m.jsxs)(Ir,{value:f,onCopy:l,alwaysVisible:!0,children:[(0,m.jsx)("span",{className:"json-punctuation",children:"{"}),(0,m.jsxs)("span",{className:"text-muted-foreground text-xs px-1",children:[d.length," ",d.length===1?"key":"keys"]}),(0,m.jsx)("span",{className:"json-punctuation",children:"}"})]}),g()]}):(0,m.jsxs)(p.Fragment,{children:[(0,m.jsxs)("div",{className:"leading-5",style:{paddingLeft:c},children:[(0,m.jsx)("button",{onClick:C,className:"json-collapse-toggle inline-flex items-center justify-center w-4 h-4 -ml-4 hover:bg-muted rounded","data-state":"open",children:(0,m.jsx)(Mo,{className:"h-3 w-3"})}),B(),(0,m.jsx)(Ir,{value:f,onCopy:l,alwaysVisible:!0,children:(0,m.jsx)("span",{className:"json-punctuation",children:"{"})})]}),h.map(([v,y],b)=>(0,m.jsx)(XC,{value:y,path:`${t}.${v}`,keyName:v,isLast:b===d.length-1&&h.length===d.length,depth:s+1,isCollapsed:i,toggleCollapse:o,collapseStringsAfterLength:a,onCopy:l},`${t}.${v}`)),h.length<d.length&&(0,m.jsxs)("div",{className:"leading-5 text-muted-foreground text-xs",style:{paddingLeft:(s+1)*16},children:["Loading ",d.length-h.length," more keys..."]}),(0,m.jsxs)("div",{className:"leading-5",style:{paddingLeft:c},children:[(0,m.jsx)("span",{className:"json-punctuation",children:"}"}),g()]})]})}function zJ({value:e,path:t,keyName:n,isLast:r=!0,depth:s=0,isCollapsed:i,toggleCollapse:o,collapseStringsAfterLength:a,onCopy:l}){const c=s*16,u=()=>{if(e===null)return(0,m.jsx)(Ir,{value:"null",onCopy:l,children:(0,m.jsx)("span",{className:"json-null",children:"null"})});if(typeof e=="boolean")return(0,m.jsx)(Ir,{value:String(e),onCopy:l,children:(0,m.jsx)("span",{className:e?"json-boolean":"json-boolean-false",children:String(e)})});if(typeof e=="number")return(0,m.jsx)(Ir,{value:String(e),onCopy:l,children:(0,m.jsx)("span",{className:"json-number",children:String(e)})});if(typeof e=="string"){const f=JSON.stringify(e);return a!==void 0?(0,m.jsx)(YI,{value:e,displayValue:f,maxLength:a,onCopy:l}):(0,m.jsx)(Ir,{value:e,onCopy:l,children:(0,m.jsx)("span",{className:"json-string",children:f})})}return null},d=()=>n===void 0?null:(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)("span",{className:"json-key",children:['"',n,'"']}),(0,m.jsx)("span",{className:"json-punctuation",children:": "})]}),h=()=>r?null:(0,m.jsx)("span",{className:"json-punctuation",children:","});return e===null||typeof e=="boolean"||typeof e=="number"||typeof e=="string"?(0,m.jsxs)("div",{className:"leading-5",style:{paddingLeft:c},children:[d(),u(),h()]}):Array.isArray(e)?(0,m.jsx)(VJ,{value:e,path:t,keyName:n,isLast:r,depth:s,isCollapsed:i,toggleCollapse:o,collapseStringsAfterLength:a,onCopy:l}):typeof e=="object"?(0,m.jsx)(UJ,{value:e,path:t,keyName:n,isLast:r,depth:s,isCollapsed:i,toggleCollapse:o,collapseStringsAfterLength:a,onCopy:l}):(0,m.jsxs)("div",{className:"leading-5",style:{paddingLeft:c},children:[d(),(0,m.jsx)("span",{className:"text-muted-foreground",children:"undefined"}),h()]})}function $J(e,t){return!(e.value!==t.value||e.path!==t.path||e.keyName!==t.keyName||e.isLast!==t.isLast||e.depth!==t.depth||e.collapseStringsAfterLength!==t.collapseStringsAfterLength||e.isCollapsed!==t.isCollapsed)}var XC=(0,p.memo)(zJ,$J);function WJ({value:e,className:t,height:n,maxHeight:r,defaultExpandDepth:s,collapsedPaths:i,onCollapseChange:o,collapseStringsAfterLength:a,onCopy:l}){const{isCollapsed:c,toggleCollapse:u}=FJ({value:e,defaultExpandDepth:s,initialCollapsedPaths:i,onCollapseChange:o});return(0,m.jsx)("div",{className:he("p-3 text-xs overflow-auto select-text cursor-text",t,"pl-7"),style:{fontFamily:"var(--font-code)",...n!=null?{height:n}:{},...r!=null?{maxHeight:r}:{}},children:(0,m.jsx)(XC,{value:e,path:"root",isCollapsed:c,toggleCollapse:u,collapseStringsAfterLength:a,onCopy:l})})}function em({value:e,className:t,height:n,maxHeight:r,showLineNumbers:s=!0,collapseStringsAfterLength:i,wrapLongLinesInView:o=!0,collapsible:a=!1,defaultExpandDepth:l,collapsedPaths:c,onCollapseChange:u}){const d=(0,p.useMemo)(()=>{if(e==null)return"null";try{return JSON.stringify(e,null,2)}catch{return String(e)}},[e]);return a?(0,m.jsx)(WJ,{value:e,className:t,height:n??"100%",maxHeight:r,defaultExpandDepth:l,collapsedPaths:c,onCollapseChange:u,collapseStringsAfterLength:i}):(0,m.jsx)(XI,{content:d,readOnly:!0,className:t,height:n??"100%",maxHeight:r,showLineNumbers:s,collapseStringsAfterLength:i,wrapLongLinesInView:o})}var tk=1024,qJ=0,eB=class{constructor(e,t){this.from=e,this.to=t}},ke=class{constructor(e={}){this.id=qJ++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=Hn.match(e)),t=>{let n=e(t);return n===void 0?null:[this,n]}}};ke.closedBy=new ke({deserialize:e=>e.split(" ")});ke.openedBy=new ke({deserialize:e=>e.split(" ")});ke.group=new ke({deserialize:e=>e.split(" ")});ke.isolate=new ke({deserialize:e=>{if(e&&e!="rtl"&&e!="ltr"&&e!="auto")throw new RangeError("Invalid value for isolate: "+e);return e||"auto"}});ke.contextHash=new ke({perNode:!0});ke.lookAhead=new ke({perNode:!0});ke.mounted=new ke({perNode:!0});var rl=class{constructor(e,t,n,r=!1){this.tree=e,this.overlay=t,this.parser=n,this.bracketed=r}static get(e){return e&&e.props&&e.props[ke.mounted.id]}},KJ=Object.create(null),Hn=class nk{constructor(t,n,r,s=0){this.name=t,this.props=n,this.id=r,this.flags=s}static define(t){let n=t.props&&t.props.length?Object.create(null):KJ,r=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(t.name==null?8:0),s=new nk(t.name||"",n,t.id,r);if(t.props){for(let i of t.props)if(Array.isArray(i)||(i=i(s)),i){if(i[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[i[0].id]=i[1]}}return s}prop(t){return this.props[t.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(t){if(typeof t=="string"){if(this.name==t)return!0;let n=this.prop(ke.group);return n?n.indexOf(t)>-1:!1}return this.id==t}static match(t){let n=Object.create(null);for(let r in t)for(let s of r.split(" "))n[s]=t[r];return r=>{for(let s=r.prop(ke.group),i=-1;i<(s?s.length:0);i++){let o=n[i<0?r.name:s[i]];if(o)return o}}}};Hn.none=new Hn("",Object.create(null),0,8);var JJ=class rk{constructor(t){this.types=t;for(let n=0;n<t.length;n++)if(t[n].id!=n)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...t){let n=[];for(let r of this.types){let s=null;for(let i of t){let o=i(r);if(o){s||(s=Object.assign({},r.props));let a=o[1],l=o[0];l.combine&&l.id in s&&(a=l.combine(s[l.id],a)),s[l.id]=a}}n.push(s?new Hn(r.name,s,r.id,r.flags):r)}return new rk(n)}},Xc=new WeakMap,lS=new WeakMap,ut;(function(e){e[e.ExcludeBuffers=1]="ExcludeBuffers",e[e.IncludeAnonymous=2]="IncludeAnonymous",e[e.IgnoreMounts=4]="IgnoreMounts",e[e.IgnoreOverlays=8]="IgnoreOverlays",e[e.EnterBracketed=16]="EnterBracketed"})(ut||(ut={}));var Pt=class tm{constructor(t,n,r,s,i){if(this.type=t,this.children=n,this.positions=r,this.length=s,this.props=null,i&&i.length){this.props=Object.create(null);for(let[o,a]of i)this.props[typeof o=="number"?o:o.id]=a}}toString(){let t=rl.get(this);if(t&&!t.overlay)return t.tree.toString();let n="";for(let r of this.children){let s=r.toString();s&&(n&&(n+=","),n+=s)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(n.length?"("+n+")":""):n}cursor(t=0){return new sm(this.topNode,t)}cursorAt(t,n=0,r=0){let s=Xc.get(this)||this.topNode,i=new sm(s);return i.moveTo(t,n),Xc.set(this,i._tree),i}get topNode(){return new $s(this,0,0,null)}resolve(t,n=0){let r=Nl(Xc.get(this)||this.topNode,t,n,!1);return Xc.set(this,r),r}resolveInner(t,n=0){let r=Nl(lS.get(this)||this.topNode,t,n,!0);return lS.set(this,r),r}resolveStack(t,n=0){return ZJ(this,t,n)}iterate(t){let{enter:n,leave:r,from:s=0,to:i=this.length}=t,o=t.mode||0,a=(o&ut.IncludeAnonymous)>0;for(let l=this.cursor(o|ut.IncludeAnonymous);;){let c=!1;if(l.from<=i&&l.to>=s&&(!a&&l.type.isAnonymous||n(l)!==!1)){if(l.firstChild())continue;c=!0}for(;c&&r&&(a||!l.type.isAnonymous)&&r(l),!l.nextSibling();){if(!l.parent())return;c=!0}}}prop(t){return t.perNode?this.props?this.props[t.id]:void 0:this.type.prop(t)}get propValues(){let t=[];if(this.props)for(let n in this.props)t.push([+n,this.props[n]]);return t}balance(t={}){return this.children.length<=8?this:ev(Hn.none,this.children,this.positions,0,this.children.length,0,this.length,(n,r,s)=>new tm(this.type,n,r,s,this.propValues),t.makeTree||((n,r,s)=>new tm(Hn.none,n,r,s)))}static build(t){return e9(t)}};Pt.empty=new Pt(Hn.none,[],[],0);var QJ=class sk{constructor(t,n){this.buffer=t,this.index=n}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new sk(this.buffer,this.index)}},Go=class ik{constructor(t,n,r){this.buffer=t,this.length=n,this.set=r}get type(){return Hn.none}toString(){let t=[];for(let n=0;n<this.buffer.length;)t.push(this.childString(n)),n=this.buffer[n+3];return t.join(",")}childString(t){let n=this.buffer[t],r=this.buffer[t+3],s=this.set.types[n],i=s.name;if(/\W/.test(i)&&!s.isError&&(i=JSON.stringify(i)),t+=4,r==t)return i;let o=[];for(;t<r;)o.push(this.childString(t)),t=this.buffer[t+3];return i+"("+o.join(",")+")"}findChild(t,n,r,s,i){let{buffer:o}=this,a=-1;for(let l=t;l!=n&&!(ok(i,s,o[l+1],o[l+2])&&(a=l,r>0));l=o[l+3]);return a}slice(t,n,r){let s=this.buffer,i=new Uint16Array(n-t),o=0;for(let a=t,l=0;a<n;){i[l++]=s[a++],i[l++]=s[a++]-r;let c=i[l++]=s[a++]-r;i[l++]=s[a++]-t,o=Math.max(o,c)}return new ik(i,o,this.set)}};function ok(e,t,n,r){switch(e){case-2:return n<t;case-1:return r>=t&&n<t;case 0:return n<t&&r>t;case 1:return n<=t&&r>t;case 2:return r>t;case 4:return!0}}function Nl(e,t,n,r){for(var s;e.from==e.to||(n<1?e.from>=t:e.from>t)||(n>-1?e.to<=t:e.to<t);){let o=!r&&e instanceof $s&&e.index<0?null:e.parent;if(!o)return e;e=o}let i=r?0:ut.IgnoreOverlays;if(r)for(let o=e,a=o.parent;a;o=a,a=o.parent)o instanceof $s&&o.index<0&&((s=a.enter(t,n,i))===null||s===void 0?void 0:s.from)!=o.from&&(e=a);for(;;){let o=e.enter(t,n,i);if(!o)return e;e=o}}var ak=class{cursor(e=0){return new sm(this,e)}getChild(e,t=null,n=null){let r=cS(this,e,t,n);return r.length?r[0]:null}getChildren(e,t=null,n=null){return cS(this,e,t,n)}resolve(e,t=0){return Nl(this,e,t,!1)}resolveInner(e,t=0){return Nl(this,e,t,!0)}matchContext(e){return nm(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),n=this;for(;t;){let r=t.lastChild;if(!r||r.to!=t.to)break;r.type.isError&&r.from==r.to?(n=t,t=r.prevSibling):t=r}return n}get node(){return this}get next(){return this.parent}},$s=class Uu extends ak{constructor(t,n,r,s){super(),this._tree=t,this.from=n,this.index=r,this._parent=s}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,n,r,s,i=0){for(let o=this;;){for(let{children:a,positions:l}=o._tree,c=n>0?a.length:-1;t!=c;t+=n){let u=a[t],d=l[t]+o.from,h;if(!(!(i&ut.EnterBracketed&&u instanceof Pt&&(h=rl.get(u))&&!h.overlay&&h.bracketed&&r>=d&&r<=d+u.length)&&!ok(s,r,d,d+u.length))){if(u instanceof Go){if(i&ut.ExcludeBuffers)continue;let f=u.findChild(0,u.buffer.length,n,r-d,s);if(f>-1)return new rm(new YJ(o,u,t,d),null,f)}else if(i&ut.IncludeAnonymous||!u.type.isAnonymous||ZC(u)){let f;if(!(i&ut.IgnoreMounts)&&(f=rl.get(u))&&!f.overlay)return new Uu(f.tree,d,t,o);let B=new Uu(u,d,t,o);return i&ut.IncludeAnonymous||!B.type.isAnonymous?B:B.nextChild(n<0?u.children.length-1:0,n,r,s,i)}}}if(i&ut.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?t=o.index+n:t=n<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(t){return this.nextChild(0,1,t,2)}childBefore(t){return this.nextChild(this._tree.children.length-1,-1,t,-2)}prop(t){return this._tree.prop(t)}enter(t,n,r=0){let s;if(!(r&ut.IgnoreOverlays)&&(s=rl.get(this._tree))&&s.overlay){let i=t-this.from,o=r&ut.EnterBracketed&&s.bracketed;for(let{from:a,to:l}of s.overlay)if((n>0||o?a<=i:a<i)&&(n<0||o?l>=i:l>i))return new Uu(s.tree,s.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,n,r)}nextSignificantParent(){let t=this;for(;t.type.isAnonymous&&t._parent;)t=t._parent;return t}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}};function cS(e,t,n,r){let s=e.cursor(),i=[];if(!s.firstChild())return i;if(n!=null){for(let o=!1;!o;)if(o=s.type.is(n),!s.nextSibling())return i}for(;;){if(r!=null&&s.type.is(r))return i;if(s.type.is(t)&&i.push(s.node),!s.nextSibling())return r==null?i:[]}}function nm(e,t,n=t.length-1){for(let r=e;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(t[n]&&t[n]!=r.name)return!1;n--}}return!0}var YJ=class{constructor(e,t,n,r){this.parent=e,this.buffer=t,this.index=n,this.start=r}},rm=class Na extends ak{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(t,n,r){super(),this.context=t,this._parent=n,this.index=r,this.type=t.buffer.set.types[t.buffer.buffer[r]]}child(t,n,r){let{buffer:s}=this.context,i=s.findChild(this.index+4,s.buffer[this.index+3],t,n-this.context.start,r);return i<0?null:new Na(this.context,this,i)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(t){return this.child(1,t,2)}childBefore(t){return this.child(-1,t,-2)}prop(t){return this.type.prop(t)}enter(t,n,r=0){if(r&ut.ExcludeBuffers)return null;let{buffer:s}=this.context,i=s.findChild(this.index+4,s.buffer[this.index+3],n>0?1:-1,t-this.context.start,n);return i<0?null:new Na(this.context,this,i)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(t){return this._parent?null:this.context.parent.nextChild(this.context.index+t,t,0,4)}get nextSibling(){let{buffer:t}=this.context,n=t.buffer[this.index+3];return n<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new Na(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new Na(this.context,this._parent,t.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let t=[],n=[],{buffer:r}=this.context,s=this.index+4,i=r.buffer[this.index+3];if(i>s){let o=r.buffer[this.index+1];t.push(r.slice(s,i,o)),n.push(0)}return new Pt(this.type,t,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function lk(e){if(!e.length)return null;let t=0,n=e[0];for(let i=1;i<e.length;i++){let o=e[i];(o.from>n.from||o.to<n.to)&&(n=o,t=i)}let r=n instanceof $s&&n.index<0?null:n.parent,s=e.slice();return r?s[t]=r:s.splice(t,1),new XJ(s,n)}var XJ=class{constructor(e,t){this.heads=e,this.node=t}get next(){return lk(this.heads)}};function ZJ(e,t,n){let r=e.resolveInner(t,n),s=null;for(let i=r instanceof $s?r:r.context.parent;i;i=i.parent)if(i.index<0){let o=i.parent;(s||(s=[r])).push(o.resolve(t,n)),i=o}else{let o=rl.get(i.tree);if(o&&o.overlay&&o.overlay[0].from<=t&&o.overlay[o.overlay.length-1].to>=t){let a=new $s(o.tree,o.overlay[0].from+i.from,-1,i);(s||(s=[r])).push(Nl(a,t,n,!1))}}return s?lk(s):r}var sm=class{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~ut.EnterBracketed,e instanceof $s)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let n=e._parent;n;n=n._parent)this.stack.unshift(n.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:n,buffer:r}=this.buffer;return this.type=t||r.set.types[r.buffer[e]],this.from=n+r.buffer[e+1],this.to=n+r.buffer[e+2],!0}yield(e){return e?e instanceof $s?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,n,this.mode));let{buffer:r}=this.buffer,s=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,n);return s<0?!1:(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,n=this.mode){return this.buffer?n&ut.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&ut.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&ut.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,n=this.stack.length-1;if(e<0){let r=n<0?0:this.stack[n]+4;if(this.index!=r)return this.yieldBuf(t.findChild(r,this.index,-1,0,4))}else{let r=t.buffer[this.index+3];if(r<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(r)}return n<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,n,{buffer:r}=this;if(r){if(e>0){if(this.index<r.buffer.buffer.length)return!1}else for(let s=0;s<this.index;s++)if(r.buffer.buffer[s+3]<this.index)return!1;({index:t,parent:n}=r)}else({index:t,_parent:n}=this._tree);for(;n;{index:t,_parent:n}=n)if(t>-1)for(let s=t+e,i=e<0?-1:n._tree.children.length;s!=i;s+=e){let o=n._tree.children[s];if(this.mode&ut.IncludeAnonymous||o instanceof Go||!o.type.isAnonymous||ZC(o))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,n=0;if(e&&e.context==this.buffer)e:for(let r=this.index,s=this.stack.length;s>=0;){for(let i=e;i;i=i._parent)if(i.index==r){if(r==this.index)return i;t=i,n=s+1;break e}r=this.stack[--s]}for(let r=n;r<this.stack.length;r++)t=new rm(this.buffer,t,this.stack[r]);return this.bufferNode=new rm(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let n=0;;){let r=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){n++;continue}this.type.isAnonymous||(r=!0)}for(;;){if(r&&t&&t(this),r=this.type.isAnonymous,!n)return;if(this.nextSibling())break;this.parent(),n--,r=!0}}}matchContext(e){if(!this.buffer)return nm(this.node.parent,e);let{buffer:t}=this.buffer,{types:n}=t.set;for(let r=e.length-1,s=this.stack.length-1;r>=0;s--){if(s<0)return nm(this._tree,e,r);let i=n[t.buffer[this.stack[s]]];if(!i.isAnonymous){if(e[r]&&e[r]!=i.name)return!1;r--}}return!0}};function ZC(e){return e.children.some(t=>t instanceof Go||!t.type.isAnonymous||ZC(t))}function e9(e){var t;let{buffer:n,nodeSet:r,maxBufferLength:s=tk,reused:i=[],minRepeatType:o=r.types.length}=e,a=Array.isArray(n)?new QJ(n,n.length):n,l=r.types,c=0,u=0;function d(w,A,x,O,R,P){let{id:_,start:N,end:q,size:W}=a,F=u,z=c;if(W<0)if(a.next(),W==-1){let be=i[_];x.push(be),O.push(N-w);return}else if(W==-3){c=_;return}else if(W==-4){u=_;return}else throw new RangeError(`Unrecognized record size: ${W}`);let J=l[_],Z,Q,G=N-w;if(q-N<=s&&(Q=C(a.pos-A,R))){let be=new Uint16Array(Q.size-Q.skip),ve=a.pos-Q.size,X=be.length;for(;a.pos>ve;)X=v(Q.start,be,X);Z=new Go(be,q-Q.start,r),G=Q.start-w}else{let be=a.pos-W;a.next();let ve=[],X=[],Y=_>=o?_:-1,ie=0,ne=q;for(;a.pos>be;)Y>=0&&a.id==Y&&a.size>=0?(a.end<=ne-s&&(B(ve,X,N,ie,a.end,ne,Y,F,z),ie=ve.length,ne=a.end),a.next()):P>2500?h(N,be,ve,X):d(N,be,ve,X,Y,P+1);if(Y>=0&&ie>0&&ie<ve.length&&B(ve,X,N,ie,N,ne,Y,F,z),ve.reverse(),X.reverse(),Y>-1&&ie>0){let ee=f(J,z);Z=ev(J,ve,X,0,ve.length,0,q-N,ee,ee)}else Z=g(J,ve,X,q-N,F-q,z)}x.push(Z),O.push(G)}function h(w,A,x,O){let R=[],P=0,_=-1;for(;a.pos>A;){let{id:N,start:q,end:W,size:F}=a;if(F>4)a.next();else{if(_>-1&&q<_)break;_<0&&(_=W-s),R.push(N,q,W),P++,a.next()}}if(P){let N=new Uint16Array(P*4),q=R[R.length-2];for(let W=R.length-3,F=0;W>=0;W-=3)N[F++]=R[W],N[F++]=R[W+1]-q,N[F++]=R[W+2]-q,N[F++]=F;x.push(new Go(N,R[2]-q,r)),O.push(q-w)}}function f(w,A){return(x,O,R)=>{let P=0,_=x.length-1,N,q;if(_>=0&&(N=x[_])instanceof Pt){if(!_&&N.type==w&&N.length==R)return N;(q=N.prop(ke.lookAhead))&&(P=O[_]+N.length+q)}return g(w,x,O,R,P,A)}}function B(w,A,x,O,R,P,_,N,q){let W=[],F=[];for(;w.length>O;)W.push(w.pop()),F.push(A.pop()+x-R);w.push(g(r.types[_],W,F,P-R,N-P,q)),A.push(R-x)}function g(w,A,x,O,R,P,_){if(P){let N=[ke.contextHash,P];_=_?[N].concat(_):[N]}if(R>25){let N=[ke.lookAhead,R];_=_?[N].concat(_):[N]}return new Pt(w,A,x,O,_)}function C(w,A){let x=a.fork(),O=0,R=0,P=0,_=x.end-s,N={size:0,start:0,skip:0};e:for(let q=x.pos-w;x.pos>q;){let W=x.size;if(x.id==A&&W>=0){N.size=O,N.start=R,N.skip=P,P+=4,O+=4,x.next();continue}let F=x.pos-W;if(W<0||F<q||x.start<_)break;let z=x.id>=o?4:0,J=x.start;for(x.next();x.pos>F;){if(x.size<0)if(x.size==-3||x.size==-4)z+=4;else break e;else x.id>=o&&(z+=4);x.next()}R=J,O+=W,P+=z}return(A<0||O==w)&&(N.size=O,N.start=R,N.skip=P),N.size>4?N:void 0}function v(w,A,x){let{id:O,start:R,end:P,size:_}=a;if(a.next(),_>=0&&O<o){let N=x;if(_>4){let q=a.pos-(_-4);for(;a.pos>q;)x=v(w,A,x)}A[--x]=N,A[--x]=P-w,A[--x]=R-w,A[--x]=O}else _==-3?c=O:_==-4&&(u=O);return x}let y=[],b=[];for(;a.pos>0;)d(e.start||0,e.bufferStart||0,y,b,-1,0);let E=(t=e.length)!==null&&t!==void 0?t:y.length?b[0]+y[0].length:0;return new Pt(l[e.topID],y.reverse(),b.reverse(),E)}var uS=new WeakMap;function zu(e,t){if(!e.isAnonymous||t instanceof Go||t.type!=e)return 1;let n=uS.get(t);if(n==null){n=1;for(let r of t.children){if(r.type!=e||!(r instanceof Pt)){n=1;break}n+=zu(e,r)}uS.set(t,n)}return n}function ev(e,t,n,r,s,i,o,a,l){let c=0;for(let B=r;B<s;B++)c+=zu(e,t[B]);let u=Math.ceil(c*1.5/8),d=[],h=[];function f(B,g,C,v,y){for(let b=C;b<v;){let E=b,w=g[b],A=zu(e,B[b]);for(b++;b<v;b++){let x=zu(e,B[b]);if(A+x>=u)break;A+=x}if(b==E+1){if(A>u){let x=B[E];f(x.children,x.positions,0,x.children.length,g[E]+y);continue}d.push(B[E])}else{let x=g[b-1]+B[b-1].length-w;d.push(ev(e,B,g,E,b,w,x,null,l))}h.push(w+y-i)}}return f(t,n,r,s,0),(a||l)(d,h,o)}var $u=class im{constructor(t,n,r,s,i=!1,o=!1){this.from=t,this.to=n,this.tree=r,this.offset=s,this.open=(i?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(t,n=[],r=!1){let s=[new im(0,t.length,t,0,!1,r)];for(let i of n)i.to>t.length&&s.push(i);return s}static applyChanges(t,n,r=128){if(!n.length)return t;let s=[],i=1,o=t.length?t[0]:null;for(let a=0,l=0,c=0;;a++){let u=a<n.length?n[a]:null,d=u?u.fromA:1e9;if(d-l>=r)for(;o&&o.from<d;){let h=o;if(l>=h.from||d<=h.to||c){let f=Math.max(h.from,l)-c,B=Math.min(h.to,d)-c;h=f>=B?null:new im(f,B,h.tree,h.offset+c,a>0,!!u)}if(h&&s.push(h),o.to>d)break;o=i<t.length?t[i++]:null}if(!u)break;l=u.toA,c=u.toA-u.toB}return s}},ck=class{startParse(e,t,n){return typeof e=="string"&&(e=new t9(e)),n=n?n.length?n.map(r=>new eB(r.from,r.to)):[new eB(0,0)]:[new eB(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let r=this.startParse(e,t,n);for(;;){let s=r.advance();if(s)return s}}},t9=class{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}},Iae=new ke({perNode:!0}),n9=class om{constructor(t,n,r,s,i,o,a,l,c,u=0,d){this.p=t,this.stack=n,this.state=r,this.reducePos=s,this.pos=i,this.score=o,this.buffer=a,this.bufferBase=l,this.curContext=c,this.lookAhead=u,this.parent=d}toString(){return`[${this.stack.filter((t,n)=>n%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(t,n,r=0){let s=t.parser.context;return new om(t,[],n,r,r,0,[],0,s?new dS(s,s.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(t,n){this.stack.push(this.state,n,this.bufferBase+this.buffer.length),this.state=t}reduce(t){var n;let r=t>>19,s=t&65535,{parser:i}=this.p,o=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),a=i.dynamicPrecedence(s);if(a&&(this.score+=a),r==0){s<i.minRepeatTerm&&this.reducePos<this.pos&&(this.reducePos=this.pos),this.pushState(i.getGoto(this.state,s,!0),this.reducePos),s<i.minRepeatTerm&&this.storeNode(s,this.reducePos,this.reducePos,o?8:4,!0),this.reduceContext(s,this.reducePos);return}let l=this.stack.length-(r-1)*3-(t&262144?6:0),c=l?this.stack[l-2]:this.p.ranges[0].from;s<i.minRepeatTerm&&c==this.reducePos&&this.reducePos<this.pos&&(this.reducePos=this.pos);let u=this.reducePos-c;u>=2e3&&!(!((n=this.p.parser.nodeSet.types[s])===null||n===void 0)&&n.isAnonymous)&&(c==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=u):this.p.lastBigReductionSize<u&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=c,this.p.lastBigReductionSize=u));let d=l?this.stack[l-1]:0,h=this.bufferBase+this.buffer.length-d;if(s<i.minRepeatTerm||t&131072){let f=i.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(s,c,f,h+4,!0)}if(t&262144)this.state=this.stack[l];else{let f=this.stack[l-3];this.state=i.getGoto(f,s,!0)}for(;this.stack.length>l;)this.stack.pop();this.reduceContext(s,c)}storeNode(t,n,r,s=4,i=!1){if(t==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let o=this.buffer.length;if(o>0&&this.buffer[o-4]==0&&this.buffer[o-1]>-1){if(n==r)return;if(this.buffer[o-2]>=n){this.buffer[o-2]=r;return}}}if(!i||this.pos==r)this.buffer.push(t,n,r,s);else{let o=this.buffer.length;if(o>0&&(this.buffer[o-4]!=0||this.buffer[o-1]<0)){let a=!1;for(let l=o;l>0&&this.buffer[l-2]>r;l-=4)if(this.buffer[l-1]>=0){a=!0;break}if(a)for(;o>0&&this.buffer[o-2]>r;)this.buffer[o]=this.buffer[o-4],this.buffer[o+1]=this.buffer[o-3],this.buffer[o+2]=this.buffer[o-2],this.buffer[o+3]=this.buffer[o-1],o-=4,s>4&&(s-=4)}this.buffer[o]=t,this.buffer[o+1]=n,this.buffer[o+2]=r,this.buffer[o+3]=s}}shift(t,n,r,s){if(t&131072)this.pushState(t&65535,this.pos);else if((t&262144)==0){let i=t,{parser:o}=this.p;this.pos=s;let a=o.stateFlag(i,1);!a&&(s>r||n<=o.maxNode)&&(this.reducePos=s),this.pushState(i,a?r:Math.min(r,this.reducePos)),this.shiftContext(n,r),n<=o.maxNode&&this.buffer.push(n,r,s,4)}else this.pos=s,this.shiftContext(n,r),n<=this.p.parser.maxNode&&this.buffer.push(n,r,s,4)}apply(t,n,r,s){t&65536?this.reduce(t):this.shift(t,n,r,s)}useNode(t,n){let r=this.p.reused.length-1;(r<0||this.p.reused[r]!=t)&&(this.p.reused.push(t),r++);let s=this.pos;this.reducePos=this.pos=s+t.length,this.pushState(n,s),this.buffer.push(r,s,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,t,this,this.p.stream.reset(this.pos-t.length)))}split(){let t=this,n=t.buffer.length;for(n&&t.buffer[n-4]==0&&(n-=4);n>0&&t.buffer[n-2]>t.reducePos;)n-=4;let r=t.buffer.slice(n),s=t.bufferBase+n;for(;t&&s==t.bufferBase;)t=t.parent;return new om(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,r,s,this.curContext,this.lookAhead,t)}recoverByDelete(t,n){let r=t<=this.p.parser.maxNode;r&&this.storeNode(t,this.pos,n,4),this.storeNode(0,this.pos,n,r?8:4),this.pos=this.reducePos=n,this.score-=190}canShift(t){for(let n=new r9(this);;){let r=this.p.parser.stateSlot(n.state,4)||this.p.parser.hasAction(n.state,t);if(r==0)return!1;if((r&65536)==0)return!0;n.reduce(r)}}recoverByInsert(t){if(this.stack.length>=300)return[];let n=this.p.parser.nextStates(this.state);if(n.length>8||this.stack.length>=120){let s=[];for(let i=0,o;i<n.length;i+=2)(o=n[i+1])!=this.state&&this.p.parser.hasAction(o,t)&&s.push(n[i],o);if(this.stack.length<120)for(let i=0;s.length<8&&i<n.length;i+=2){let o=n[i+1];s.some((a,l)=>l&1&&a==o)||s.push(n[i],o)}n=s}let r=[];for(let s=0;s<n.length&&r.length<4;s+=2){let i=n[s+1];if(i==this.state)continue;let o=this.split();o.pushState(i,this.pos),o.storeNode(0,o.pos,o.pos,4,!0),o.shiftContext(n[s],this.pos),o.reducePos=this.pos,o.score-=200,r.push(o)}return r}forceReduce(){let{parser:t}=this.p,n=t.stateSlot(this.state,5);if((n&65536)==0)return!1;if(!t.validAction(this.state,n)){let r=n>>19,s=n&65535,i=this.stack.length-r*3;if(i<0||t.getGoto(this.stack[i],s,!1)<0){let o=this.findForcedReduction();if(o==null)return!1;n=o}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(n),!0}findForcedReduction(){let{parser:t}=this.p,n=[],r=(s,i)=>{if(!n.includes(s))return n.push(s),t.allActions(s,o=>{if(!(o&393216))if(o&65536){let a=(o>>19)-i;if(a>1){let l=o&65535,c=this.stack.length-a*3;if(c>=0&&t.getGoto(this.stack[c],l,!1)>=0)return a<<19|65536|l}}else{let a=r(o,i+1);if(a!=null)return a}})};return r(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:t}=this.p;return t.data[t.stateSlot(this.state,1)]==65535&&!t.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(t){if(this.state!=t.state||this.stack.length!=t.stack.length)return!1;for(let n=0;n<this.stack.length;n+=3)if(this.stack[n]!=t.stack[n])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(t){return this.p.parser.dialect.flags[t]}shiftContext(t,n){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,t,this,this.p.stream.reset(n)))}reduceContext(t,n){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,t,this,this.p.stream.reset(n)))}emitContext(){let t=this.buffer.length-1;(t<0||this.buffer[t]!=-3)&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let t=this.buffer.length-1;(t<0||this.buffer[t]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(t){if(t!=this.curContext.context){let n=new dS(this.curContext.tracker,t);n.hash!=this.curContext.hash&&this.emitContext(),this.curContext=n}}setLookAhead(t){return t<=this.lookAhead?!1:(this.emitLookAhead(),this.lookAhead=t,!0)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}},dS=class{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}},r9=class{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=e&65535,n=e>>19;n==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(n-1)*3;let r=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=r}},s9=class am{constructor(t,n,r){this.stack=t,this.pos=n,this.index=r,this.buffer=t.buffer,this.index==0&&this.maybeNext()}static create(t,n=t.bufferBase+t.buffer.length){return new am(t,n,n-t.bufferBase)}maybeNext(){let t=this.stack.parent;t!=null&&(this.index=this.stack.bufferBase-t.bufferBase,this.stack=t,this.buffer=t.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new am(this.stack,this.pos,this.index)}};function Pa(e,t=Uint16Array){if(typeof e!="string")return e;let n=null;for(let r=0,s=0;r<e.length;){let i=0;for(;;){let o=e.charCodeAt(r++),a=!1;if(o==126){i=65535;break}o>=92&&o--,o>=34&&o--;let l=o-32;if(l>=46&&(l-=46,a=!0),i+=l,a)break;i*=46}n?n[s++]=i:n=new t(i)}return n}var Wu=class{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}},hS=new Wu,i9=class{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=hS,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let n=this.range,r=this.rangeIndex,s=this.pos+e;for(;s<n.from;){if(!r)return null;let i=this.ranges[--r];s-=n.from-i.to,n=i}for(;t<0?s>n.to:s>=n.to;){if(r==this.ranges.length-1)return null;let i=this.ranges[++r];s+=i.from-n.to,n=i}return s}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let t of this.ranges)if(t.to>e)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,n,r;if(t>=0&&t<this.chunk.length)n=this.pos+e,r=this.chunk.charCodeAt(t);else{let s=this.resolveOffset(e,1);if(s==null)return-1;if(n=s,n>=this.chunk2Pos&&n<this.chunk2Pos+this.chunk2.length)r=this.chunk2.charCodeAt(n-this.chunk2Pos);else{let i=this.rangeIndex,o=this.range;for(;o.to<=n;)o=this.ranges[++i];this.chunk2=this.input.chunk(this.chunk2Pos=n),n+this.chunk2.length>o.to&&(this.chunk2=this.chunk2.slice(0,o.to-n)),r=this.chunk2.charCodeAt(0)}}return n>=this.token.lookAhead&&(this.token.lookAhead=n+1),r}acceptToken(e,t=0){let n=t?this.resolveOffset(t,-1):this.pos;if(n==null||n<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=e,this.token.end=n}acceptTokenTo(e,t){this.token.value=e,this.token.end=t}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:t}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=t,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),t=this.pos+e.length;this.chunk=t>this.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=hS,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;e>=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e<this.chunkPos+this.chunk.length?this.chunkOff=e-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(e,t){if(e>=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let n="";for(let r of this.ranges){if(r.from>=t)break;r.to>e&&(n+=this.input.read(Math.max(r.from,e),Math.min(r.to,t)))}return n}},wo=class{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:n}=t.p;uk(this.data,e,t,this.id,n.data,n.tokenPrecTable)}};wo.prototype.contextual=wo.prototype.fallback=wo.prototype.extend=!1;var o9=class{constructor(e,t,n){this.precTable=t,this.elseToken=n,this.data=typeof e=="string"?Pa(e):e}token(e,t){let n=e.pos,r=0;for(;;){let s=e.next<0,i=e.resolveOffset(1,1);if(uk(this.data,e,t,0,this.data,this.precTable),e.token.value>-1)break;if(this.elseToken==null)return;if(s||r++,i==null)break;e.reset(i,e.token)}r&&(e.reset(n,e.token),e.acceptToken(this.elseToken,r))}};o9.prototype.contextual=wo.prototype.fallback=wo.prototype.extend=!1;function uk(e,t,n,r,s,i){let o=0,a=1<<r,{dialect:l}=n.p.parser;e:for(;(a&e[o])!=0;){let c=e[o+1];for(let f=o+3;f<c;f+=2)if((e[f+1]&a)>0){let B=e[f];if(l.allows(B)&&(t.token.value==-1||t.token.value==B||a9(B,t.token.value,s,i))){t.acceptToken(B);break}}let u=t.next,d=0,h=e[o+2];if(t.next<0&&h>d&&e[c+h*3-3]==65535){o=e[c+h*3-1];continue e}for(;d<h;){let f=d+h>>1,B=c+f+(f<<1),g=e[B],C=e[B+1]||65536;if(u<g)h=f;else if(u>=C)d=f+1;else{o=e[B+2],t.advance();continue e}}break}}function fS(e,t,n){for(let r=t,s;(s=e[r])!=65535;r++)if(s==n)return r-t;return-1}function a9(e,t,n,r){let s=fS(n,r,t);return s<0||fS(n,r,e)<s}var vn=typeof process<"u"&&/\bparse\b/.test({}.LOG),tB=null;function BS(e,t,n){let r=e.cursor(ut.IncludeAnonymous);for(r.moveTo(t);;)if(!(n<0?r.childBefore(t):r.childAfter(t)))for(;;){if((n<0?r.to<t:r.from>t)&&!r.type.isError)return n<0?Math.max(0,Math.min(r.to-1,t-25)):Math.min(e.length,Math.max(r.from+1,t+25));if(n<0?r.prevSibling():r.nextSibling())break;if(!r.parent())return n<0?0:e.length}}var l9=class{constructor(e,t){this.fragments=e,this.nodeSet=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?BS(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?BS(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(e<this.nextStart)return null;for(;this.fragment&&this.safeTo<=e;)this.nextFragment();if(!this.fragment)return null;for(;;){let t=this.trees.length-1;if(t<0)return this.nextFragment(),null;let n=this.trees[t],r=this.index[t];if(r==n.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let s=n.children[r],i=this.start[t]+n.positions[r];if(i>e)return this.nextStart=i,null;if(s instanceof Pt){if(i==e){if(i<this.safeFrom)return null;let o=i+s.length;if(o<=this.safeTo){let a=s.prop(ke.lookAhead);if(!a||o+a<this.fragment.to)return s}}this.index[t]++,i+s.length>=Math.max(this.safeFrom,e)&&(this.trees.push(s),this.start.push(i),this.index.push(0))}else this.index[t]++,this.nextStart=i+s.length}}},c9=class{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(n=>new Wu)}getActions(e){let t=0,n=null,{parser:r}=e.p,{tokenizers:s}=r,i=r.stateSlot(e.state,3),o=e.curContext?e.curContext.hash:0,a=0;for(let l=0;l<s.length;l++){if((1<<l&i)==0)continue;let c=s[l],u=this.tokens[l];if(!(n&&!c.fallback)&&((c.contextual||u.start!=e.pos||u.mask!=i||u.context!=o)&&(this.updateCachedToken(u,c,e),u.mask=i,u.context=o),u.lookAhead>u.end+25&&(a=Math.max(u.lookAhead,a)),u.value!=0)){let d=t;if(u.extended>-1&&(t=this.addActions(e,u.extended,u.end,t)),t=this.addActions(e,u.value,u.end,t),!c.extend&&(n=u,t>d))break}}for(;this.actions.length>t;)this.actions.pop();return a&&e.setLookAhead(a),!n&&e.pos==this.stream.end&&(n=new Wu,n.value=e.p.parser.eofTerm,n.start=n.end=e.pos,t=this.addActions(e,n.value,n.end,t)),this.mainToken=n,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new Wu,{pos:n,p:r}=e;return t.start=n,t.end=Math.min(n+1,r.stream.end),t.value=n==r.stream.end?r.parser.eofTerm:0,t}updateCachedToken(e,t,n){let r=this.stream.clipPos(n.pos);if(t.token(this.stream.reset(r,e),n),e.value>-1){let{parser:s}=n.p;for(let i=0;i<s.specialized.length;i++)if(s.specialized[i]==e.value){let o=s.specializers[i](this.stream.read(e.start,e.end),n);if(o>=0&&n.p.parser.dialect.allows(o>>1)){(o&1)==0?e.value=o>>1:e.extended=o>>1;break}}}else e.value=0,e.end=this.stream.clipPos(r+1)}putAction(e,t,n,r){for(let s=0;s<r;s+=3)if(this.actions[s]==e)return r;return this.actions[r++]=e,this.actions[r++]=t,this.actions[r++]=n,r}addActions(e,t,n,r){let{state:s}=e,{parser:i}=e.p,{data:o}=i;for(let a=0;a<2;a++)for(let l=i.stateSlot(s,a?2:1);;l+=3){if(o[l]==65535)if(o[l+1]==1)l=qr(o,l+2);else{r==0&&o[l+1]==2&&(r=this.putAction(qr(o,l+2),t,n,r));break}o[l]==t&&(r=this.putAction(qr(o,l+1),t,n,r))}return r}},u9=class{constructor(e,t,n,r){this.parser=e,this.input=t,this.ranges=r,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new i9(t,r),this.tokens=new c9(e,this.stream),this.topTerm=e.top[1];let{from:s}=r[0];this.stacks=[n9.start(this,e.top[0],s)],this.fragments=n.length&&this.stream.end-s>e.bufferLength*4?new l9(n,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,n=this.stacks=[],r,s;if(this.bigReductionCount>300&&e.length==1){let[i]=e;for(;i.forceReduce()&&i.stack.length&&i.stack[i.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let i=0;i<e.length;i++){let o=e[i];for(;;){if(this.tokens.mainToken=null,o.pos>t)n.push(o);else{if(this.advanceStack(o,n,e))continue;{r||(r=[],s=[]),r.push(o);let a=this.tokens.getMainToken(o);s.push(a.value,a.end)}}break}}if(!n.length){let i=r&&f9(r);if(i)return vn&&console.log("Finish with "+this.stackID(i)),this.stackToTree(i);if(this.parser.strict)throw vn&&r&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+t);this.recovering||(this.recovering=5)}if(this.recovering&&r){let i=this.stoppedAt!=null&&r[0].pos>this.stoppedAt?r[0]:this.runRecovery(r,s,n);if(i)return vn&&console.log("Force-finish "+this.stackID(i)),this.stackToTree(i.forceAll())}if(this.recovering){let i=this.recovering==1?1:this.recovering*3;if(n.length>i)for(n.sort((o,a)=>a.score-o.score);n.length>i;)n.pop();n.some(o=>o.reducePos>t)&&this.recovering--}else if(n.length>1){e:for(let i=0;i<n.length-1;i++){let o=n[i];for(let a=i+1;a<n.length;a++){let l=n[a];if(o.sameState(l)||o.buffer.length>500&&l.buffer.length>500)if((o.score-l.score||o.buffer.length-l.buffer.length)>0)n.splice(a--,1);else{n.splice(i--,1);continue e}}}n.length>12&&(n.sort((i,o)=>o.score-i.score),n.splice(12,n.length-12))}this.minStackPos=n[0].pos;for(let i=1;i<n.length;i++)n[i].pos<this.minStackPos&&(this.minStackPos=n[i].pos);return null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}advanceStack(e,t,n){let r=e.pos,{parser:s}=this,i=vn?this.stackID(e)+" -> ":"";if(this.stoppedAt!=null&&r>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let l=e.curContext&&e.curContext.tracker.strict,c=l?e.curContext.hash:0;for(let u=this.fragments.nodeAt(r);u;){let d=this.parser.nodeSet.types[u.type.id]==u.type?s.getGoto(e.state,u.type.id):-1;if(d>-1&&u.length&&(!l||(u.prop(ke.contextHash)||0)==c))return e.useNode(u,d),vn&&console.log(i+this.stackID(e)+` (via reuse of ${s.getName(u.type.id)})`),!0;if(!(u instanceof Pt)||u.children.length==0||u.positions[0]>0)break;let h=u.children[0];if(h instanceof Pt&&u.positions[0]==0)u=h;else break}}let o=s.stateSlot(e.state,4);if(o>0)return e.reduce(o),vn&&console.log(i+this.stackID(e)+` (via always-reduce ${s.getName(o&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let a=this.tokens.getActions(e);for(let l=0;l<a.length;){let c=a[l++],u=a[l++],d=a[l++],h=l==a.length||!n,f=h?e:e.split(),B=this.tokens.mainToken;if(f.apply(c,u,B?B.start:f.pos,d),vn&&console.log(i+this.stackID(f)+` (via ${(c&65536)==0?"shift":`reduce of ${s.getName(c&65535)}`} for ${s.getName(u)} @ ${r}${f==e?"":", split"})`),h)return!0;f.pos>r?t.push(f):n.push(f)}return!1}advanceFully(e,t){let n=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>n)return pS(e,t),!0}}runRecovery(e,t,n){let r=null,s=!1;for(let i=0;i<e.length;i++){let o=e[i],a=t[i<<1],l=t[(i<<1)+1],c=vn?this.stackID(o)+" -> ":"";if(o.deadEnd&&(s||(s=!0,o.restart(),vn&&console.log(c+this.stackID(o)+" (restarted)"),this.advanceFully(o,n))))continue;let u=o.split(),d=c;for(let h=0;h<10&&u.forceReduce()&&(vn&&console.log(d+this.stackID(u)+" (via force-reduce)"),!this.advanceFully(u,n));h++)vn&&(d=this.stackID(u)+" -> ");for(let h of o.recoverByInsert(a))vn&&console.log(c+this.stackID(h)+" (via recover-insert)"),this.advanceFully(h,n);this.stream.end>o.pos?(l==o.pos&&(l++,a=0),o.recoverByDelete(a,l),vn&&console.log(c+this.stackID(o)+` (via recover-delete ${this.parser.getName(a)})`),pS(o,n)):(!r||r.score<u.score)&&(r=u)}return r}stackToTree(e){return e.close(),Pt.build({buffer:s9.create(e),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:e.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(e){let t=(tB||(tB=new WeakMap)).get(e);return t||tB.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}};function pS(e,t){for(let n=0;n<t.length;n++){let r=t[n];if(r.pos==e.pos&&r.sameState(e)){t[n].score<e.score&&(t[n]=e);return}}t.push(e)}var d9=class{constructor(e,t,n){this.source=e,this.flags=t,this.disabled=n}allows(e){return!this.disabled||this.disabled[e]==0}},h9=class lm extends ck{constructor(t){if(super(),this.wrappers=[],t.version!=14)throw new RangeError(`Parser version (${t.version}) doesn't match runtime version (14)`);let n=t.nodeNames.split(" ");this.minRepeatTerm=n.length;for(let a=0;a<t.repeatNodeCount;a++)n.push("");let r=Object.keys(t.topRules).map(a=>t.topRules[a][1]),s=[];for(let a=0;a<n.length;a++)s.push([]);function i(a,l,c){s[a].push([l,l.deserialize(String(c))])}if(t.nodeProps)for(let a of t.nodeProps){let l=a[0];typeof l=="string"&&(l=ke[l]);for(let c=1;c<a.length;){let u=a[c++];if(u>=0)i(u,l,a[c++]);else{let d=a[c+-u];for(let h=-u;h>0;h--)i(a[c++],l,d);c++}}}this.nodeSet=new JJ(n.map((a,l)=>Hn.define({name:l>=this.minRepeatTerm?void 0:a,id:l,props:s[l],top:r.indexOf(l)>-1,error:l==0,skipped:t.skippedNodes&&t.skippedNodes.indexOf(l)>-1}))),t.propSources&&(this.nodeSet=this.nodeSet.extend(...t.propSources)),this.strict=!1,this.bufferLength=tk;let o=Pa(t.tokenData);this.context=t.context,this.specializerSpecs=t.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let a=0;a<this.specializerSpecs.length;a++)this.specialized[a]=this.specializerSpecs[a].term;this.specializers=this.specializerSpecs.map(mS),this.states=Pa(t.states,Uint32Array),this.data=Pa(t.stateData),this.goto=Pa(t.goto),this.maxTerm=t.maxTerm,this.tokenizers=t.tokenizers.map(a=>typeof a=="number"?new wo(o,a):a),this.topRules=t.topRules,this.dialects=t.dialects||{},this.dynamicPrecedences=t.dynamicPrecedences||null,this.tokenPrecTable=t.tokenPrec,this.termNames=t.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(t,n,r){let s=new u9(this,t,n,r);for(let i of this.wrappers)s=i(s,t,n,r);return s}getGoto(t,n,r=!1){let s=this.goto;if(n>=s[0])return-1;for(let i=s[n+1];;){let o=s[i++],a=o&1,l=s[i++];if(a&&r)return l;for(let c=i+(o>>1);i<c;i++)if(s[i]==t)return l;if(a)return-1}}hasAction(t,n){let r=this.data;for(let s=0;s<2;s++)for(let i=this.stateSlot(t,s?2:1),o;;i+=3){if((o=r[i])==65535)if(r[i+1]==1)o=r[i=qr(r,i+2)];else{if(r[i+1]==2)return qr(r,i+2);break}if(o==n||o==0)return qr(r,i+1)}return 0}stateSlot(t,n){return this.states[t*6+n]}stateFlag(t,n){return(this.stateSlot(t,0)&n)>0}validAction(t,n){return!!this.allActions(t,r=>r==n?!0:null)}allActions(t,n){let r=this.stateSlot(t,4),s=r?n(r):void 0;for(let i=this.stateSlot(t,1);s==null;i+=3){if(this.data[i]==65535)if(this.data[i+1]==1)i=qr(this.data,i+2);else break;s=n(qr(this.data,i+1))}return s}nextStates(t){let n=[];for(let r=this.stateSlot(t,1);;r+=3){if(this.data[r]==65535)if(this.data[r+1]==1)r=qr(this.data,r+2);else break;if((this.data[r+2]&1)==0){let s=this.data[r+1];n.some((i,o)=>o&1&&i==s)||n.push(this.data[r],s)}}return n}configure(t){let n=Object.assign(Object.create(lm.prototype),this);if(t.props&&(n.nodeSet=this.nodeSet.extend(...t.props)),t.top){let r=this.topRules[t.top];if(!r)throw new RangeError(`Invalid top rule name ${t.top}`);n.top=r}return t.tokenizers&&(n.tokenizers=this.tokenizers.map(r=>{let s=t.tokenizers.find(i=>i.from==r);return s?s.to:r})),t.specializers&&(n.specializers=this.specializers.slice(),n.specializerSpecs=this.specializerSpecs.map((r,s)=>{let i=t.specializers.find(a=>a.from==r.external);if(!i)return r;let o=Object.assign(Object.assign({},r),{external:i.to});return n.specializers[s]=mS(o),o})),t.contextTracker&&(n.context=t.contextTracker),t.dialect&&(n.dialect=this.parseDialect(t.dialect)),t.strict!=null&&(n.strict=t.strict),t.wrap&&(n.wrappers=n.wrappers.concat(t.wrap)),t.bufferLength!=null&&(n.bufferLength=t.bufferLength),n}hasWrappers(){return this.wrappers.length>0}getName(t){return this.termNames?this.termNames[t]:String(t<=this.maxNode&&this.nodeSet.types[t].name||t)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(t){let n=this.dynamicPrecedences;return n==null?0:n[t]||0}parseDialect(t){let n=Object.keys(this.dialects),r=n.map(()=>!1);if(t)for(let i of t.split(" ")){let o=n.indexOf(i);o>=0&&(r[o]=!0)}let s=null;for(let i=0;i<n.length;i++)if(!r[i])for(let o=this.dialects[n[i]],a;(a=this.data[o++])!=65535;)(s||(s=new Uint8Array(this.maxTerm+1)))[a]=1;return new d9(t,r,s)}static deserialize(t){return new lm(t)}};function qr(e,t){return e[t]|e[t+1]<<16}function f9(e){let t=null;for(let n of e){let r=n.p.stoppedAt;(n.pos==n.p.stream.end||r!=null&&n.pos>r)&&n.p.parser.stateFlag(n.state,2)&&(!t||t.score<n.score)&&(t=n)}return t}function mS(e){if(e.external){let t=e.extend?1:0;return(n,r)=>e.external(n,r)<<1|t}return e.get}var B9=0,Kr=class cm{constructor(t,n,r,s){this.name=t,this.set=n,this.base=r,this.modified=s,this.id=B9++}toString(){let{name:t}=this;for(let n of this.modified)n.name&&(t=`${n.name}(${t})`);return t}static define(t,n){let r=typeof t=="string"?t:"?";if(t instanceof cm&&(n=t),n?.base)throw new Error("Can not derive from a modified tag");let s=new cm(r,[],null,[]);if(s.set.push(s),n)for(let i of n.set)s.set.push(i);return s}static defineModifier(t){let n=new gS(t);return r=>r.modified.indexOf(n)>-1?r:gS.get(r.base||r,r.modified.concat(n).sort((s,i)=>s.id-i.id))}},p9=0,gS=class dk{constructor(t){this.name=t,this.instances=[],this.id=p9++}static get(t,n){if(!n.length)return t;let r=n[0].instances.find(a=>a.base==t&&m9(n,a.modified));if(r)return r;let s=[],i=new Kr(t.name,s,t,n);for(let a of n)a.instances.push(i);let o=g9(n);for(let a of t.set)if(!a.modified.length)for(let l of o)s.push(dk.get(a,l));return i}};function m9(e,t){return e.length==t.length&&e.every((n,r)=>n==t[r])}function g9(e){let t=[[]];for(let n=0;n<e.length;n++)for(let r=0,s=t.length;r<s;r++)t.push(t[r].concat(e[n]));return t.sort((n,r)=>r.length-n.length)}function hk(e){let t=Object.create(null);for(let n in e){let r=e[n];Array.isArray(r)||(r=[r]);for(let s of n.split(" "))if(s){let i=[],o=2,a=s;for(let u=0;;){if(a=="..."&&u>0&&u+3==s.length){o=1;break}let d=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!d)throw new RangeError("Invalid path: "+s);if(i.push(d[0]=="*"?"":d[0][0]=='"'?JSON.parse(d[0]):d[0]),u+=d[0].length,u==s.length)break;let h=s[u++];if(u==s.length&&h=="!"){o=0;break}if(h!="/")throw new RangeError("Invalid path: "+s);a=s.slice(u)}let l=i.length-1,c=i[l];if(!c)throw new RangeError("Invalid path: "+s);t[c]=new Pl(r,o,l>0?i.slice(0,l):null).sort(t[c])}}return fk.add(t)}var fk=new ke({combine(e,t){let n,r,s;for(;e||t;){if(!e||t&&e.depth<=t.depth?(s=t,t=t.next):(s=e,e=e.next),n&&n.mode==s.mode&&!s.context&&!n.context)continue;let i=new Pl(s.tags,s.mode,s.context);n?n.next=i:r=i,n=i}return r}}),Pl=class{constructor(e,t,n,r){this.tags=e,this.mode=t,this.context=n,this.next=r}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}};Pl.empty=new Pl([],2,null);function Bk(e,t){let n=Object.create(null);for(let i of e)if(!Array.isArray(i.tag))n[i.tag.id]=i.class;else for(let o of i.tag)n[o.id]=i.class;let{scope:r,all:s=null}=t||{};return{style:i=>{let o=s;for(let a of i)for(let l of a.set){let c=n[l.id];if(c){o=o?o+" "+c:c;break}}return o},scope:r}}function C9(e,t){let n=null;for(let r of e){let s=r.style(t);s&&(n=n?n+" "+s:s)}return n}function v9(e,t,n,r=0,s=e.length){let i=new y9(r,Array.isArray(t)?t:[t],n);i.highlightRange(e.cursor(),r,s,"",i.highlighters),i.flush(s)}var y9=class{constructor(e,t,n){this.at=e,this.highlighters=t,this.span=n,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,n,r,s){let{type:i,from:o,to:a}=e;if(o>=n||a<=t)return;i.isTop&&(s=this.highlighters.filter(h=>!h.scope||h.scope(i)));let l=r,c=b9(e)||Pl.empty,u=C9(s,c.tags);if(u&&(l&&(l+=" "),l+=u,c.mode==1&&(r+=(r?" ":"")+u)),this.startSpan(Math.max(t,o),l),c.opaque)return;let d=e.tree&&e.tree.prop(ke.mounted);if(d&&d.overlay){let h=e.node.enter(d.overlay[0].from+o,1),f=this.highlighters.filter(g=>!g.scope||g.scope(d.tree.type)),B=e.firstChild();for(let g=0,C=o;;g++){let v=g<d.overlay.length?d.overlay[g]:null,y=v?v.from+o:a,b=Math.max(t,C),E=Math.min(n,y);if(b<E&&B)for(;e.from<E&&(this.highlightRange(e,b,E,r,s),this.startSpan(Math.min(E,e.to),l),!(e.to>=y||!e.nextSibling())););if(!v||y>n)break;C=v.to+o,C>t&&(this.highlightRange(h.cursor(),Math.max(t,v.from+o),Math.min(n,C),"",f),this.startSpan(Math.min(n,C),l))}B&&e.parent()}else if(e.firstChild()){d&&(r="");do if(!(e.to<=t)){if(e.from>=n)break;this.highlightRange(e,t,n,r,s),this.startSpan(Math.min(n,e.to),l)}while(e.nextSibling());e.parent()}}};function b9(e){let t=e.type.prop(fk);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}var ae=Kr.define,Zc=ae(),Ts=ae(),CS=ae(Ts),vS=ae(Ts),As=ae(),eu=ae(As),nB=ae(As),br=ae(),oi=ae(br),Cr=ae(),vr=ae(),um=ae(),ma=ae(um),tu=ae(),re={comment:Zc,lineComment:ae(Zc),blockComment:ae(Zc),docComment:ae(Zc),name:Ts,variableName:ae(Ts),typeName:CS,tagName:ae(CS),propertyName:vS,attributeName:ae(vS),className:ae(Ts),labelName:ae(Ts),namespace:ae(Ts),macroName:ae(Ts),literal:As,string:eu,docString:ae(eu),character:ae(eu),attributeValue:ae(eu),number:nB,integer:ae(nB),float:ae(nB),bool:ae(As),regexp:ae(As),escape:ae(As),color:ae(As),url:ae(As),keyword:Cr,self:ae(Cr),null:ae(Cr),atom:ae(Cr),unit:ae(Cr),modifier:ae(Cr),operatorKeyword:ae(Cr),controlKeyword:ae(Cr),definitionKeyword:ae(Cr),moduleKeyword:ae(Cr),operator:vr,derefOperator:ae(vr),arithmeticOperator:ae(vr),logicOperator:ae(vr),bitwiseOperator:ae(vr),compareOperator:ae(vr),updateOperator:ae(vr),definitionOperator:ae(vr),typeOperator:ae(vr),controlOperator:ae(vr),punctuation:um,separator:ae(um),bracket:ma,angleBracket:ae(ma),squareBracket:ae(ma),paren:ae(ma),brace:ae(ma),content:br,heading:oi,heading1:ae(oi),heading2:ae(oi),heading3:ae(oi),heading4:ae(oi),heading5:ae(oi),heading6:ae(oi),contentSeparator:ae(br),list:ae(br),quote:ae(br),emphasis:ae(br),strong:ae(br),link:ae(br),monospace:ae(br),strikethrough:ae(br),inserted:ae(),deleted:ae(),changed:ae(),invalid:ae(),meta:tu,documentMeta:ae(tu),annotation:ae(tu),processingInstruction:ae(tu),definition:Kr.defineModifier("definition"),constant:Kr.defineModifier("constant"),function:Kr.defineModifier("function"),standard:Kr.defineModifier("standard"),local:Kr.defineModifier("local"),special:Kr.defineModifier("special")};for(let e in re){let t=re[e];t instanceof Kr&&(t.name=e)}var kae=Bk([{tag:re.link,class:"tok-link"},{tag:re.heading,class:"tok-heading"},{tag:re.emphasis,class:"tok-emphasis"},{tag:re.strong,class:"tok-strong"},{tag:re.keyword,class:"tok-keyword"},{tag:re.atom,class:"tok-atom"},{tag:re.bool,class:"tok-bool"},{tag:re.url,class:"tok-url"},{tag:re.labelName,class:"tok-labelName"},{tag:re.inserted,class:"tok-inserted"},{tag:re.deleted,class:"tok-deleted"},{tag:re.literal,class:"tok-literal"},{tag:re.string,class:"tok-string"},{tag:re.number,class:"tok-number"},{tag:[re.regexp,re.escape,re.special(re.string)],class:"tok-string2"},{tag:re.variableName,class:"tok-variableName"},{tag:re.local(re.variableName),class:"tok-variableName tok-local"},{tag:re.definition(re.variableName),class:"tok-variableName tok-definition"},{tag:re.special(re.variableName),class:"tok-variableName2"},{tag:re.definition(re.propertyName),class:"tok-propertyName tok-definition"},{tag:re.typeName,class:"tok-typeName"},{tag:re.namespace,class:"tok-namespace"},{tag:re.className,class:"tok-className"},{tag:re.macroName,class:"tok-macroName"},{tag:re.propertyName,class:"tok-propertyName"},{tag:re.operator,class:"tok-operator"},{tag:re.comment,class:"tok-comment"},{tag:re.meta,class:"tok-meta"},{tag:re.invalid,class:"tok-invalid"},{tag:re.punctuation,class:"tok-punctuation"}]),S9=hk({String:re.string,Number:re.number,"True False":re.bool,PropertyName:re.propertyName,Null:re.null,", :":re.separator,"[ ]":re.squareBracket,"{ }":re.brace}),E9=h9.deserialize({version:14,states:"$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#ClOOQO'#Cr'#CrQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CtOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59W,59WO!iQPO,59WOVQPO,59QOqQPO'#CmO!nQPO,59`OOQO1G.k1G.kOVQPO'#CnO!vQPO,59aOOQO1G.r1G.rOOQO1G.l1G.lOOQO,59X,59XOOQO-E6k-E6kOOQO,59Y,59YOOQO-E6l-E6l",stateData:"#O~OeOS~OQSORSOSSOTSOWQO_ROgPO~OVXOgUO~O^[O~PVO[^O~O]_OVhX~OVaO~O]bO^iX~O^dO~O]_OVha~O]bO^ia~O",goto:"!kjPPPPPPkPPkqwPPPPk{!RPPP!XP!e!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",nodeNames:"⚠ JsonText True False Null Number String } { Object Property PropertyName : , ] [ Array",maxTerm:25,nodeProps:[["isolate",-2,6,11,""],["openedBy",7,"{",14,"["],["closedBy",8,"}",15,"]"]],propSources:[S9],skippedNodes:[0],repeatNodeCount:2,tokenData:"(|~RaXY!WYZ!W]^!Wpq!Wrs!]|}$u}!O$z!Q!R%T!R![&c![!]&t!}#O&y#P#Q'O#Y#Z'T#b#c'r#h#i(Z#o#p(r#q#r(w~!]Oe~~!`Wpq!]qr!]rs!xs#O!]#O#P!}#P;'S!];'S;=`$o<%lO!]~!}Og~~#QXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#m~#pR!Q![#y!c!i#y#T#Z#y~#|R!Q![$V!c!i$V#T#Z$V~$YR!Q![$c!c!i$c#T#Z$c~$fR!Q![!]!c!i!]#T#Z!]~$rP;=`<%l!]~$zO]~~$}Q!Q!R%T!R![&c~%YRT~!O!P%c!g!h%w#X#Y%w~%fP!Q![%i~%nRT~!Q![%i!g!h%w#X#Y%w~%zR{|&T}!O&T!Q![&Z~&WP!Q![&Z~&`PT~!Q![&Z~&hST~!O!P%c!Q![&c!g!h%w#X#Y%w~&yO[~~'OO_~~'TO^~~'WP#T#U'Z~'^P#`#a'a~'dP#g#h'g~'jP#X#Y'm~'rOR~~'uP#i#j'x~'{P#`#a(O~(RP#`#a(U~(ZOS~~(^P#f#g(a~(dP#i#j(g~(jP#X#Y(m~(rOQ~~(wOW~~(|OV~",tokenizers:[0],topRules:{JsonText:[0,1]},tokenPrec:0}),dm=[],pk=[];(()=>{let e="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(t=>t?parseInt(t,36):1);for(let t=0,n=0;t<e.length;t++)(t%2?pk:dm).push(n=n+e[t])})();function x9(e){if(e<768)return!1;for(let t=0,n=dm.length;;){let r=t+n>>1;if(e<dm[r])n=r;else if(e>=pk[r])t=r+1;else return!0;if(t==n)return!1}}function yS(e){return e>=127462&&e<=127487}var bS=8205;function w9(e,t,n=!0,r=!0){return(n?mk:D9)(e,t,r)}function mk(e,t,n){if(t==e.length)return t;t&&gk(e.charCodeAt(t))&&Ck(e.charCodeAt(t-1))&&t--;let r=rB(e,t);for(t+=SS(r);t<e.length;){let s=rB(e,t);if(r==bS||s==bS||n&&x9(s))t+=SS(s),r=s;else if(yS(s)){let i=0,o=t-2;for(;o>=0&&yS(rB(e,o));)i++,o-=2;if(i%2==0)break;t+=2}else break}return t}function D9(e,t,n){for(;t>0;){let r=mk(e,t-2,n);if(r<t)return r;t--}return 0}function rB(e,t){let n=e.charCodeAt(t);if(!Ck(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return gk(r)?(n-55296<<10)+(r-56320)+65536:n}function gk(e){return e>=56320&&e<57344}function Ck(e){return e>=55296&&e<56320}function SS(e){return e<65536?1:2}var Fe=class vk{lineAt(t){if(t<0||t>this.length)throw new RangeError(`Invalid position ${t} in document of length ${this.length}`);return this.lineInner(t,!1,1,0)}line(t){if(t<1||t>this.lines)throw new RangeError(`Invalid line number ${t} in ${this.lines}-line document`);return this.lineInner(t,!0,1,0)}replace(t,n,r){[t,n]=Vo(this,t,n);let s=[];return this.decompose(0,t,s,2),r.length&&r.decompose(0,r.length,s,3),this.decompose(n,this.length,s,1),qu.from(s,this.length-(n-t)+r.length)}append(t){return this.replace(this.length,this.length,t)}slice(t,n=this.length){[t,n]=Vo(this,t,n);let r=[];return this.decompose(t,n,r,0),qu.from(r,n-t)}eq(t){if(t==this)return!0;if(t.length!=this.length||t.lines!=this.lines)return!1;let n=this.scanIdentical(t,1),r=this.length-this.scanIdentical(t,-1),s=new sl(this),i=new sl(t);for(let o=n,a=n;;){if(s.next(o),i.next(o),o=0,s.lineBreak!=i.lineBreak||s.done!=i.done||s.value!=i.value)return!1;if(a+=s.value.length,s.done||a>=r)return!0}}iter(t=1){return new sl(this,t)}iterRange(t,n=this.length){return new yk(this,t,n)}iterLines(t,n){let r;if(t==null)r=this.iter();else{n==null&&(n=this.lines+1);let s=this.line(t).from;r=this.iterRange(s,Math.max(s,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new bk(r)}toString(){return this.sliceString(0)}toJSON(){let t=[];return this.flatten(t),t}constructor(){}static of(t){if(t.length==0)throw new RangeError("A document must have at least one line");return t.length==1&&!t[0]?vk.empty:t.length<=32?new Xn(t):qu.from(Xn.split(t,[]))}},Xn=class Sr extends Fe{constructor(t,n=T9(t)){super(),this.text=t,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(t,n,r,s){for(let i=0;;i++){let o=this.text[i],a=s+o.length;if((n?r:a)>=t)return new A9(s,a,r,o);s=a+1,r++}}decompose(t,n,r,s){let i=t<=0&&n>=this.length?this:new Sr(ES(this.text,t,n),Math.min(n,this.length)-Math.max(0,t));if(s&1){let o=r.pop(),a=Ku(i.text,o.text.slice(),0,i.length);if(a.length<=32)r.push(new Sr(a,o.length+i.length));else{let l=a.length>>1;r.push(new Sr(a.slice(0,l)),new Sr(a.slice(l)))}}else r.push(i)}replace(t,n,r){if(!(r instanceof Sr))return super.replace(t,n,r);[t,n]=Vo(this,t,n);let s=Ku(this.text,Ku(r.text,ES(this.text,0,t)),n),i=this.length+r.length-(n-t);return s.length<=32?new Sr(s,i):qu.from(Sr.split(s,[]),i)}sliceString(t,n=this.length,r=`
70
+ `){[t,n]=Vo(this,t,n);let s="";for(let i=0,o=0;i<=n&&o<this.text.length;o++){let a=this.text[o],l=i+a.length;i>t&&o&&(s+=r),t<l&&n>i&&(s+=a.slice(Math.max(0,t-i),n-i)),i=l+1}return s}flatten(t){for(let n of this.text)t.push(n)}scanIdentical(){return 0}static split(t,n){let r=[],s=-1;for(let i of t)r.push(i),s+=i.length+1,r.length==32&&(n.push(new Sr(r,s)),r=[],s=-1);return s>-1&&n.push(new Sr(r,s)),n}},qu=class lo extends Fe{constructor(t,n){super(),this.children=t,this.length=n,this.lines=0;for(let r of t)this.lines+=r.lines}lineInner(t,n,r,s){for(let i=0;;i++){let o=this.children[i],a=s+o.length,l=r+o.lines-1;if((n?l:a)>=t)return o.lineInner(t,n,r,s);s=a+1,r=l+1}}decompose(t,n,r,s){for(let i=0,o=0;o<=n&&i<this.children.length;i++){let a=this.children[i],l=o+a.length;if(t<=l&&n>=o){let c=s&((o<=t?1:0)|(l>=n?2:0));o>=t&&l<=n&&!c?r.push(a):a.decompose(t-o,n-o,r,c)}o=l+1}}replace(t,n,r){if([t,n]=Vo(this,t,n),r.lines<this.lines)for(let s=0,i=0;s<this.children.length;s++){let o=this.children[s],a=i+o.length;if(t>=i&&n<=a){let l=o.replace(t-i,n-i,r),c=this.lines-o.lines+l.lines;if(l.lines<c>>4&&l.lines>c>>6){let u=this.children.slice();return u[s]=l,new lo(u,this.length-(n-t)+r.length)}return super.replace(i,a,l)}i=a+1}return super.replace(t,n,r)}sliceString(t,n=this.length,r=`
71
+ `){[t,n]=Vo(this,t,n);let s="";for(let i=0,o=0;i<this.children.length&&o<=n;i++){let a=this.children[i],l=o+a.length;o>t&&i&&(s+=r),t<l&&n>o&&(s+=a.sliceString(t-o,n-o,r)),o=l+1}return s}flatten(t){for(let n of this.children)n.flatten(t)}scanIdentical(t,n){if(!(t instanceof lo))return 0;let r=0,[s,i,o,a]=n>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;s+=n,i+=n){if(s==o||i==a)return r;let l=this.children[s],c=t.children[i];if(l!=c)return r+l.scanIdentical(c,n);r+=l.length+1}}static from(t,n=t.reduce((r,s)=>r+s.length+1,-1)){let r=0;for(let f of t)r+=f.lines;if(r<32){let f=[];for(let B of t)B.flatten(f);return new Xn(f,n)}let s=Math.max(32,r>>5),i=s<<1,o=s>>1,a=[],l=0,c=-1,u=[];function d(f){let B;if(f.lines>i&&f instanceof lo)for(let g of f.children)d(g);else f.lines>o&&(l>o||!l)?(h(),a.push(f)):f instanceof Xn&&l&&(B=u[u.length-1])instanceof Xn&&f.lines+B.lines<=32?(l+=f.lines,c+=f.length+1,u[u.length-1]=new Xn(B.text.concat(f.text),B.length+1+f.length)):(l+f.lines>s&&h(),l+=f.lines,c+=f.length+1,u.push(f))}function h(){l!=0&&(a.push(u.length==1?u[0]:lo.from(u,c)),c=-1,l=u.length=0)}for(let f of t)d(f);return h(),a.length==1?a[0]:new lo(a,n)}};Fe.empty=new Xn([""],0);function T9(e){let t=-1;for(let n of e)t+=n.length+1;return t}function Ku(e,t,n=0,r=1e9){for(let s=0,i=0,o=!0;i<e.length&&s<=r;i++){let a=e[i],l=s+a.length;l>=n&&(l>r&&(a=a.slice(0,r-s)),s<n&&(a=a.slice(n-s)),o?(t[t.length-1]+=a,o=!1):t.push(a)),s=l+1}return t}function ES(e,t,n){return Ku(e,[""],t,n)}var sl=class{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[t>0?1:(e instanceof Xn?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,r=this.nodes[n],s=this.offsets[n],i=s>>1,o=r instanceof Xn?r.text.length:r.children.length;if(i==(t>0?o:0)){if(n==0)return this.done=!0,this.value="",this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((s&1)==(t>0?0:1)){if(this.offsets[n]+=t,e==0)return this.lineBreak=!0,this.value=`
72
+ `,this;e--}else if(r instanceof Xn){let a=r.text[i+(t<0?-1:0)];if(this.offsets[n]+=t,a.length>Math.max(0,e))return this.value=e==0?a:t>0?a.slice(e):a.slice(0,a.length-e),this;e-=a.length}else{let a=r.children[i+(t<0?-1:0)];e>a.length?(e-=a.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(a),this.offsets.push(t>0?1:(a instanceof Xn?a.text.length:a.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}},yk=class{constructor(e,t,n){this.value="",this.done=!1,this.cursor=new sl(e,t>n?-1:1),this.pos=t>n?e.length:0,this.from=Math.min(t,n),this.to=Math.max(t,n)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let n=t<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*t,this.value=r.length<=n?r:t<0?r.slice(r.length-n):r.slice(0,n),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}},bk=class{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:n,value:r}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):n?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}};typeof Symbol<"u"&&(Fe.prototype[Symbol.iterator]=function(){return this.iter()},sl.prototype[Symbol.iterator]=yk.prototype[Symbol.iterator]=bk.prototype[Symbol.iterator]=function(){return this});var A9=class{constructor(e,t,n,r){this.from=e,this.to=t,this.number=n,this.text=r}get length(){return this.to-this.from}};function Vo(e,t,n){return t=Math.max(0,Math.min(e.length,t)),[t,Math.max(t,Math.min(e.length,n))]}function Wt(e,t,n=!0,r=!0){return w9(e,t,n,r)}function I9(e){return e>=56320&&e<57344}function k9(e){return e>=55296&&e<56320}function R9(e,t){let n=e.charCodeAt(t);if(!k9(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return I9(r)?(n-55296<<10)+(r-56320)+65536:n}function O9(e){return e<65536?1:2}var hm=/\r\n?|\n/,xn=(function(e){return e[e.Simple=0]="Simple",e[e.TrackDel=1]="TrackDel",e[e.TrackBefore=2]="TrackBefore",e[e.TrackAfter=3]="TrackAfter",e})(xn||(xn={})),Do=class Ju{constructor(t){this.sections=t}get length(){let t=0;for(let n=0;n<this.sections.length;n+=2)t+=this.sections[n];return t}get newLength(){let t=0;for(let n=0;n<this.sections.length;n+=2){let r=this.sections[n+1];t+=r<0?this.sections[n]:r}return t}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(t){for(let n=0,r=0,s=0;n<this.sections.length;){let i=this.sections[n++],o=this.sections[n++];o<0?(t(r,s,i),s+=i):s+=o,r+=i}}iterChangedRanges(t,n=!1){fm(this,t,n)}get invertedDesc(){let t=[];for(let n=0;n<this.sections.length;){let r=this.sections[n++],s=this.sections[n++];s<0?t.push(r,s):t.push(s,r)}return new Ju(t)}composeDesc(t){return this.empty?t:t.empty?this:Sk(this,t)}mapDesc(t,n=!1){return t.empty?this:Bm(this,t,n)}mapPos(t,n=-1,r=xn.Simple){let s=0,i=0;for(let o=0;o<this.sections.length;){let a=this.sections[o++],l=this.sections[o++],c=s+a;if(l<0){if(c>t)return i+(t-s);i+=a}else{if(r!=xn.Simple&&c>=t&&(r==xn.TrackDel&&s<t&&c>t||r==xn.TrackBefore&&s<t||r==xn.TrackAfter&&c>t))return null;if(c>t||c==t&&n<0&&!a)return t==s||n<0?i:i+l;i+=l}s=c}if(t>s)throw new RangeError(`Position ${t} is out of range for changeset of length ${s}`);return i}touchesRange(t,n=t){for(let r=0,s=0;r<this.sections.length&&s<=n;){let i=this.sections[r++],o=this.sections[r++],a=s+i;if(o>=0&&s<=n&&a>=t)return s<t&&a>n?"cover":!0;s=a}return!1}toString(){let t="";for(let n=0;n<this.sections.length;){let r=this.sections[n++],s=this.sections[n++];t+=(t?" ":"")+r+(s>=0?":"+s:"")}return t}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some(n=>typeof n!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new Ju(t)}static create(t){return new Ju(t)}},cr=class Es extends Do{constructor(t,n){super(t),this.inserted=n}apply(t){if(this.length!=t.length)throw new RangeError("Applying change set to a document with the wrong length");return fm(this,(n,r,s,i,o)=>t=t.replace(s,s+(r-n),o),!1),t}mapDesc(t,n=!1){return Bm(this,t,n,!0)}invert(t){let n=this.sections.slice(),r=[];for(let s=0,i=0;s<n.length;s+=2){let o=n[s],a=n[s+1];if(a>=0){n[s]=a,n[s+1]=o;let l=s>>1;for(;r.length<l;)r.push(Fe.empty);r.push(o?t.slice(i,i+o):Fe.empty)}i+=o}return new Es(n,r)}compose(t){return this.empty?t:t.empty?this:Sk(this,t,!0)}map(t,n=!1){return t.empty?this:Bm(this,t,n,!0)}iterChanges(t,n=!1){fm(this,t,n)}get desc(){return Do.create(this.sections)}filter(t){let n=[],r=[],s=[],i=new Ll(this);e:for(let o=0,a=0;;){let l=o==t.length?1e9:t[o++];for(;a<l||a==l&&i.len==0;){if(i.done)break e;let u=Math.min(i.len,l-a);$t(s,u,-1);let d=i.ins==-1?-1:i.off==0?i.ins:0;$t(n,u,d),d>0&&Ps(r,n,i.text),i.forward(u),a+=u}let c=t[o++];for(;a<c;){if(i.done)break e;let u=Math.min(i.len,c-a);$t(n,u,-1),$t(s,u,i.ins==-1?-1:i.off==0?i.ins:0),i.forward(u),a+=u}}return{changes:new Es(n,r),filtered:Do.create(s)}}toJSON(){let t=[];for(let n=0;n<this.sections.length;n+=2){let r=this.sections[n],s=this.sections[n+1];s<0?t.push(r):s==0?t.push([r]):t.push([r].concat(this.inserted[n>>1].toJSON()))}return t}static of(t,n,r){let s=[],i=[],o=0,a=null;function l(u=!1){if(!u&&!s.length)return;o<n&&$t(s,n-o,-1);let d=new Es(s,i);a=a?a.compose(d.map(a)):d,s=[],i=[],o=0}function c(u){if(Array.isArray(u))for(let d of u)c(d);else if(u instanceof Es){if(u.length!=n)throw new RangeError(`Mismatched change set length (got ${u.length}, expected ${n})`);l(),a=a?a.compose(u.map(a)):u}else{let{from:d,to:h=d,insert:f}=u;if(d>h||d<0||h>n)throw new RangeError(`Invalid change range ${d} to ${h} (in doc of length ${n})`);let B=f?typeof f=="string"?Fe.of(f.split(r||hm)):f:Fe.empty,g=B.length;if(d==h&&g==0)return;d<o&&l(),d>o&&$t(s,d-o,-1),$t(s,h-d,g),Ps(i,s,B),o=h}}return c(t),l(!a),a}static empty(t){return new Es(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],r=[];for(let s=0;s<t.length;s++){let i=t[s];if(typeof i=="number")n.push(i,-1);else{if(!Array.isArray(i)||typeof i[0]!="number"||i.some((o,a)=>a&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(i.length==1)n.push(i[0],0);else{for(;r.length<s;)r.push(Fe.empty);r[s]=Fe.of(i.slice(1)),n.push(i[0],r[s].length)}}}return new Es(n,r)}static createSet(t,n){return new Es(t,n)}};function $t(e,t,n,r=!1){if(t==0&&n<=0)return;let s=e.length-2;s>=0&&n<=0&&n==e[s+1]?e[s]+=t:s>=0&&t==0&&e[s]==0?e[s+1]+=n:r?(e[s]+=t,e[s+1]+=n):e.push(t,n)}function Ps(e,t,n){if(n.length==0)return;let r=t.length-2>>1;if(r<e.length)e[e.length-1]=e[e.length-1].append(n);else{for(;e.length<r;)e.push(Fe.empty);e.push(n)}}function fm(e,t,n){let r=e.inserted;for(let s=0,i=0,o=0;o<e.sections.length;){let a=e.sections[o++],l=e.sections[o++];if(l<0)s+=a,i+=a;else{let c=s,u=i,d=Fe.empty;for(;c+=a,u+=l,l&&r&&(d=d.append(r[o-2>>1])),!(n||o==e.sections.length||e.sections[o+1]<0);)a=e.sections[o++],l=e.sections[o++];t(s,c,i,u,d),s=c,i=u}}}function Bm(e,t,n,r=!1){let s=[],i=r?[]:null,o=new Ll(e),a=new Ll(t);for(let l=-1;;){if(o.done&&a.len||a.done&&o.len)throw new Error("Mismatched change set lengths");if(o.ins==-1&&a.ins==-1){let c=Math.min(o.len,a.len);$t(s,c,-1),o.forward(c),a.forward(c)}else if(a.ins>=0&&(o.ins<0||l==o.i||o.off==0&&(a.len<o.len||a.len==o.len&&!n))){let c=a.len;for($t(s,a.ins,-1);c;){let u=Math.min(o.len,c);o.ins>=0&&l<o.i&&o.len<=u&&($t(s,0,o.ins),i&&Ps(i,s,o.text),l=o.i),o.forward(u),c-=u}a.next()}else if(o.ins>=0){let c=0,u=o.len;for(;u;)if(a.ins==-1){let d=Math.min(u,a.len);c+=d,u-=d,a.forward(d)}else if(a.ins==0&&a.len<u)u-=a.len,a.next();else break;$t(s,c,l<o.i?o.ins:0),i&&l<o.i&&Ps(i,s,o.text),l=o.i,o.forward(o.len-u)}else{if(o.done&&a.done)return i?cr.createSet(s,i):Do.create(s);throw new Error("Mismatched change set lengths")}}}function Sk(e,t,n=!1){let r=[],s=n?[]:null,i=new Ll(e),o=new Ll(t);for(let a=!1;;){if(i.done&&o.done)return s?cr.createSet(r,s):Do.create(r);if(i.ins==0)$t(r,i.len,0,a),i.next();else if(o.len==0&&!o.done)$t(r,0,o.ins,a),s&&Ps(s,r,o.text),o.next();else{if(i.done||o.done)throw new Error("Mismatched change set lengths");{let l=Math.min(i.len2,o.len),c=r.length;if(i.ins==-1){let u=o.ins==-1?-1:o.off?0:o.ins;$t(r,l,u,a),s&&u&&Ps(s,r,o.text)}else o.ins==-1?($t(r,i.off?0:i.len,l,a),s&&Ps(s,r,i.textBit(l))):($t(r,i.off?0:i.len,o.off?0:o.ins,a),s&&!o.off&&Ps(s,r,o.text));a=(i.ins>l||o.ins>=0&&o.len>l)&&(a||r.length>c),i.forward2(l),o.forward(l)}}}}var Ll=class{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?Fe.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?Fe.empty:t[n].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}},ga=class pm{constructor(t,n,r,s){this.from=t,this.to=n,this.flags=r,this.goalColumn=s}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get undirectional(){return(this.flags&64)>0}get bidiLevel(){let t=this.flags&7;return t==7?null:t}map(t,n=-1){let r,s;return this.empty?r=s=t.mapPos(this.from,n):(r=t.mapPos(this.from,1),s=t.mapPos(this.to,-1)),r==this.from&&s==this.to?this:new pm(r,s,this.flags,this.goalColumn)}extend(t,n=t,r=0){if(t<=this.anchor&&n>=this.anchor)return se.range(t,n,void 0,void 0,r);let s=Math.abs(t-this.anchor)>Math.abs(n-this.anchor)?t:n;return se.range(this.anchor,s,void 0,void 0,r)}eq(t,n=!1){return this.anchor==t.anchor&&this.head==t.head&&this.goalColumn==t.goalColumn&&(!n||!this.empty||this.assoc==t.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(t){if(!t||typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return se.range(t.anchor,t.head)}static create(t,n,r,s){return new pm(t,n,r,s)}},se=class bn{constructor(t,n){this.ranges=t,this.mainIndex=n}map(t,n=-1){return t.empty?this:bn.create(this.ranges.map(r=>r.map(t,n)),this.mainIndex)}eq(t,n=!1){if(this.ranges.length!=t.ranges.length||this.mainIndex!=t.mainIndex)return!1;for(let r=0;r<this.ranges.length;r++)if(!this.ranges[r].eq(t.ranges[r],n))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new bn([this.main],0)}addRange(t,n=!0){return bn.create([t].concat(this.ranges),n?0:this.mainIndex+1)}replaceRange(t,n=this.mainIndex){let r=this.ranges.slice();return r[n]=t,bn.create(r,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(t=>t.toJSON()),main:this.mainIndex}}static fromJSON(t){if(!t||!Array.isArray(t.ranges)||typeof t.main!="number"||t.main>=t.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new bn(t.ranges.map(n=>ga.fromJSON(n)),t.main)}static single(t,n=t){return new bn([bn.range(t,n)],0)}static create(t,n=0){if(t.length==0)throw new RangeError("A selection needs at least one range");for(let r=0,s=0;s<t.length;s++){let i=t[s];if(i.empty?i.from<=r:i.from<r)return bn.normalized(t.slice(),n);r=i.to}return new bn(t,n)}static cursor(t,n=0,r,s){return ga.create(t,t,(n==0?0:n<0?8:16)|(r==null?7:Math.min(6,r)),s)}static range(t,n,r,s,i){let o=s==null?7:Math.min(6,s);return!i&&t!=n&&(i=n<t?1:-1),i&&(o|=i<0?8:16),n<t?ga.create(n,t,o|32,r):ga.create(t,n,o,r)}static undirectionalRange(t,n){return ga.create(t,n,64,void 0)}static normalized(t,n=0){let r=t[n];t.sort((s,i)=>s.from-i.from),n=t.indexOf(r);for(let s=1;s<t.length;s++){let i=t[s],o=t[s-1];if(i.empty?i.from<=o.to:i.from<o.to){let a=o.from,l=Math.max(i.to,o.to);s<=n&&n--,t.splice(--s,2,i.anchor>i.head?bn.range(l,a):bn.range(a,l))}}return new bn(t,n)}};function Ek(e,t){for(let n of e.ranges)if(n.to>t)throw new RangeError("Selection points outside of document")}var tv=0,Ce=class xk{constructor(t,n,r,s,i){this.combine=t,this.compareInput=n,this.compare=r,this.isStatic=s,this.id=tv++,this.default=t([]),this.extensions=typeof i=="function"?i(this):i}get reader(){return this}static define(t={}){return new xk(t.combine||(n=>n),t.compareInput||((n,r)=>n===r),t.compare||(t.combine?(n,r)=>n===r:nv),!!t.static,t.enables)}of(t){return new Qu([],this,0,t)}compute(t,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Qu(t,this,1,n)}computeN(t,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Qu(t,this,2,n)}from(t,n){return n||(n=r=>r),this.compute([t],r=>n(r.field(t)))}};function nv(e,t){return e==t||e.length==t.length&&e.every((n,r)=>n===t[r])}var Qu=class{constructor(e,t,n,r){this.dependencies=e,this.facet=t,this.type=n,this.value=r,this.id=tv++}dynamicSlot(e){var t;let n=this.value,r=this.facet.compareInput,s=this.id,i=e[s]>>1,o=this.type==2,a=!1,l=!1,c=[];for(let u of this.dependencies)u=="doc"?a=!0:u=="selection"?l=!0:(((t=e[u.id])!==null&&t!==void 0?t:1)&1)==0&&c.push(e[u.id]);return{create(u){return u.values[i]=n(u),1},update(u,d){if(a&&d.docChanged||l&&(d.docChanged||d.selection)||mm(u,c)){let h=n(u);if(o?!xS(h,u.values[i],r):!r(h,u.values[i]))return u.values[i]=h,1}return 0},reconfigure:(u,d)=>{let h,f=d.config.address[s];if(f!=null){let B=Od(d,f);if(this.dependencies.every(g=>g instanceof Ce?d.facet(g)===u.facet(g):g instanceof gc?d.field(g,!1)==u.field(g,!1):!0)||(o?xS(h=n(u),B,r):r(h=n(u),B)))return u.values[i]=B,0}else h=n(u);return u.values[i]=h,1}}}get extension(){return this}};function xS(e,t,n){if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!n(e[r],t[r]))return!1;return!0}function mm(e,t){let n=!1;for(let r of t)il(e,r)&1&&(n=!0);return n}function M9(e,t,n){let r=n.map(l=>e[l.id]),s=n.map(l=>l.type),i=r.filter(l=>!(l&1)),o=e[t.id]>>1;function a(l){let c=[];for(let u=0;u<r.length;u++){let d=Od(l,r[u]);if(s[u]==2)for(let h of d)c.push(h);else c.push(d)}return t.combine(c)}return{create(l){for(let c of r)il(l,c);return l.values[o]=a(l),1},update(l,c){if(!mm(l,i))return 0;let u=a(l);return t.compare(u,l.values[o])?0:(l.values[o]=u,1)},reconfigure(l,c){let u=mm(l,r),d=c.config.facets[t.id],h=c.facet(t);if(d&&!u&&nv(n,d))return l.values[o]=h,0;let f=a(l);return t.compare(f,h)?(l.values[o]=h,0):(l.values[o]=f,1)}}}var nu=Ce.define({static:!0}),gc=class wk{constructor(t,n,r,s,i){this.id=t,this.createF=n,this.updateF=r,this.compareF=s,this.spec=i,this.provides=void 0}static define(t){let n=new wk(tv++,t.create,t.update,t.compare||((r,s)=>r===s),t);return t.provide&&(n.provides=t.provide(n)),n}create(t){let n=t.facet(nu).find(r=>r.field==this);return(n?.create||this.createF)(t)}slot(t){let n=t[this.id]>>1;return{create:r=>(r.values[n]=this.create(r),1),update:(r,s)=>{let i=r.values[n],o=this.updateF(i,s);return this.compareF(i,o)?0:(r.values[n]=o,1)},reconfigure:(r,s)=>{let i=r.facet(nu),o=s.facet(nu),a;return(a=i.find(l=>l.field==this))&&a!=o.find(l=>l.field==this)?(r.values[n]=a.create(r),1):s.config.address[this.id]!=null?(r.values[n]=s.field(this),0):(r.values[n]=this.create(r),1)}}}init(t){return[this,nu.of({field:this,create:t})]}get extension(){return this}},mi={lowest:4,low:3,default:2,high:1,highest:0};function Ca(e){return t=>new Dk(t,e)}var Oh={highest:Ca(mi.highest),high:Ca(mi.high),default:Ca(mi.default),low:Ca(mi.low),lowest:Ca(mi.lowest)},Dk=class{constructor(e,t){this.inner=e,this.prec=t}get extension(){return this}},Tk=class Ak{of(t){return new gm(this,t)}reconfigure(t){return Ak.reconfigure.of({compartment:this,extension:t})}get(t){return t.config.compartments.get(this)}},gm=class{constructor(e,t){this.compartment=e,this.inner=t}get extension(){return this}},wS=class Ik{constructor(t,n,r,s,i,o){for(this.base=t,this.compartments=n,this.dynamicSlots=r,this.address=s,this.staticValues=i,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<r.length;)this.statusTemplate.push(0)}staticFacet(t){let n=this.address[t.id];return n==null?t.default:this.staticValues[n>>1]}static resolve(t,n,r){let s=[],i=Object.create(null),o=new Map;for(let h of N9(t,n,o))h instanceof gc?s.push(h):(i[h.facet.id]||(i[h.facet.id]=[])).push(h);let a=Object.create(null),l=[],c=[];for(let h of s)a[h.id]=c.length<<1,c.push(f=>h.slot(f));let u=r?.config.facets;for(let h in i){let f=i[h],B=f[0].facet,g=u&&u[h]||[];if(f.every(C=>C.type==0))if(a[B.id]=l.length<<1|1,nv(g,f))l.push(r.facet(B));else{let C=B.combine(f.map(v=>v.value));l.push(r&&B.compare(C,r.facet(B))?r.facet(B):C)}else{for(let C of f)C.type==0?(a[C.id]=l.length<<1|1,l.push(C.value)):(a[C.id]=c.length<<1,c.push(v=>C.dynamicSlot(v)));a[B.id]=c.length<<1,c.push(C=>M9(C,B,f))}}let d=c.map(h=>h(a));return new Ik(t,o,d,a,l,i)}};function N9(e,t,n){let r=[[],[],[],[],[]],s=new Map;function i(o,a){let l=s.get(o);if(l!=null){if(l<=a)return;let c=r[l].indexOf(o);c>-1&&r[l].splice(c,1),o instanceof gm&&n.delete(o.compartment)}if(s.set(o,a),Array.isArray(o))for(let c of o)i(c,a);else if(o instanceof gm){if(n.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let c=t.get(o.compartment)||o.inner;n.set(o.compartment,c),i(c,a)}else if(o instanceof Dk)i(o.inner,o.prec);else if(o instanceof gc)r[a].push(o),o.provides&&i(o.provides,a);else if(o instanceof Qu)r[a].push(o),o.facet.extensions&&i(o.facet.extensions,mi.default);else{let c=o.extension;if(!c)throw new Error(`Unrecognized extension value in extension set (${o}).`);if(c==o)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);i(c,a)}}return i(e,mi.default),r.reduce((o,a)=>o.concat(a))}function il(e,t){if(t&1)return 2;let n=t>>1,r=e.status[n];if(r==4)throw new Error("Cyclic dependency between fields and/or facets");if(r&2)return r;e.status[n]=4;let s=e.computeSlot(e,e.config.dynamicSlots[n]);return e.status[n]=2|s}function Od(e,t){return t&1?e.config.staticValues[t>>1]:e.values[t>>1]}var kk=Ce.define(),Cm=Ce.define({combine:e=>e.some(t=>t),static:!0}),Rk=Ce.define({combine:e=>e.length?e[0]:void 0,static:!0}),Ok=Ce.define(),Mk=Ce.define(),Nk=Ce.define(),Pk=Ce.define({combine:e=>e.length?e[0]:!1}),Ui=class{constructor(e,t){this.type=e,this.value=t}static define(){return new P9}},P9=class{of(e){return new Ui(this,e)}},L9=class{constructor(e){this.map=e}of(e){return new Tt(this,e)}},Tt=class Lk{constructor(t,n){this.type=t,this.value=n}map(t){let n=this.type.map(this.value,t);return n===void 0?void 0:n==this.value?this:new Lk(this.type,n)}is(t){return this.type==t}static define(t={}){return new L9(t.map||(n=>n))}static mapEffects(t,n){if(!t.length)return t;let r=[];for(let s of t){let i=s.map(n);i&&r.push(i)}return r}};Tt.reconfigure=Tt.define();Tt.appendConfig=Tt.define();var ir=class La{constructor(t,n,r,s,i,o){this.startState=t,this.changes=n,this.selection=r,this.effects=s,this.annotations=i,this.scrollIntoView=o,this._doc=null,this._state=null,r&&Ek(r,n.newLength),i.some(a=>a.type==La.time)||(this.annotations=i.concat(La.time.of(Date.now())))}static create(t,n,r,s,i,o){return new La(t,n,r,s,i,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(t){for(let n of this.annotations)if(n.type==t)return n.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(t){let n=this.annotation(La.userEvent);return!!(n&&(n==t||n.length>t.length&&n.slice(0,t.length)==t&&n[t.length]=="."))}};ir.time=Ui.define();ir.userEvent=Ui.define();ir.addToHistory=Ui.define();ir.remote=Ui.define();function _9(e,t){let n=[];for(let r=0,s=0;;){let i,o;if(r<e.length&&(s==t.length||t[s]>=e[r]))i=e[r++],o=e[r++];else if(s<t.length)i=t[s++],o=t[s++];else return n;!n.length||n[n.length-1]<i?n.push(i,o):n[n.length-1]<o&&(n[n.length-1]=o)}}function _k(e,t,n){var r;let s,i,o;return n?(s=t.changes,i=cr.empty(t.changes.length),o=e.changes.compose(t.changes)):(s=t.changes.map(e.changes),i=e.changes.mapDesc(t.changes,!0),o=e.changes.compose(s)),{changes:o,selection:t.selection?t.selection.map(i):(r=e.selection)===null||r===void 0?void 0:r.map(s),effects:Tt.mapEffects(e.effects,s).concat(Tt.mapEffects(t.effects,i)),annotations:e.annotations.length?e.annotations.concat(t.annotations):t.annotations,scrollIntoView:e.scrollIntoView||t.scrollIntoView}}function vm(e,t,n){let r=t.selection,s=To(t.annotations);return t.userEvent&&(s=s.concat(ir.userEvent.of(t.userEvent))),{changes:t.changes instanceof cr?t.changes:cr.of(t.changes||[],n,e.facet(Rk)),selection:r&&(r instanceof se?r:se.single(r.anchor,r.head)),effects:To(t.effects),annotations:s,scrollIntoView:!!t.scrollIntoView}}function Fk(e,t,n){let r=vm(e,t.length?t[0]:{},e.doc.length);t.length&&t[0].filter===!1&&(n=!1);for(let i=1;i<t.length;i++){t[i].filter===!1&&(n=!1);let o=!!t[i].sequential;r=_k(r,vm(e,t[i],o?r.changes.newLength:e.doc.length),o)}let s=ir.create(e,r.changes,r.selection,r.effects,r.annotations,r.scrollIntoView);return H9(n?F9(s):s)}function F9(e){let t=e.startState,n=!0;for(let s of t.facet(Ok)){let i=s(e);if(i===!1){n=!1;break}Array.isArray(i)&&(n=n===!0?i:_9(n,i))}if(n!==!0){let s,i;if(n===!1)i=e.changes.invertedDesc,s=cr.empty(t.doc.length);else{let o=e.changes.filter(n);s=o.changes,i=o.filtered.mapDesc(o.changes).invertedDesc}e=ir.create(t,s,e.selection&&e.selection.map(i),Tt.mapEffects(e.effects,i),e.annotations,e.scrollIntoView)}let r=t.facet(Mk);for(let s=r.length-1;s>=0;s--){let i=r[s](e);i instanceof ir?e=i:Array.isArray(i)&&i.length==1&&i[0]instanceof ir?e=i[0]:e=Fk(t,To(i),!1)}return e}function H9(e){let t=e.startState,n=t.facet(Nk),r=e;for(let s=n.length-1;s>=0;s--){let i=n[s](e);i&&Object.keys(i).length&&(r=_k(r,vm(t,i,e.changes.newLength),!0))}return r==e?e:ir.create(t,e.changes,e.selection,r.effects,r.annotations,r.scrollIntoView)}var j9=[];function To(e){return e==null?j9:Array.isArray(e)?e:[e]}var ns=(function(e){return e[e.Word=0]="Word",e[e.Space=1]="Space",e[e.Other=2]="Other",e})(ns||(ns={})),G9=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,ym;try{ym=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function V9(e){if(ym)return ym.test(e);for(let t=0;t<e.length;t++){let n=e[t];if(/\w/.test(n)||n>"€"&&(n.toUpperCase()!=n.toLowerCase()||G9.test(n)))return!0}return!1}function U9(e){return t=>{if(!/\S/.test(t))return ns.Space;if(V9(t))return ns.Word;for(let n=0;n<e.length;n++)if(t.indexOf(e[n])>-1)return ns.Word;return ns.Other}}var bt=class Wn{constructor(t,n,r,s,i,o){this.config=t,this.doc=n,this.selection=r,this.values=s,this.status=t.statusTemplate.slice(),this.computeSlot=i,o&&(o._state=this);for(let a=0;a<this.config.dynamicSlots.length;a++)il(this,a<<1);this.computeSlot=null}field(t,n=!0){let r=this.config.address[t.id];if(r==null){if(n)throw new RangeError("Field is not present in this state");return}return il(this,r),Od(this,r)}update(...t){return Fk(this,t,!0)}applyTransaction(t){let n=this.config,{base:r,compartments:s}=n;for(let a of t.effects)a.is(Tk.reconfigure)?(n&&(s=new Map,n.compartments.forEach((l,c)=>s.set(c,l)),n=null),s.set(a.value.compartment,a.value.extension)):a.is(Tt.reconfigure)?(n=null,r=a.value):a.is(Tt.appendConfig)&&(n=null,r=To(r).concat(a.value));let i;n?i=t.startState.values.slice():(n=wS.resolve(r,s,this),i=new Wn(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(a,l)=>l.reconfigure(a,this),null).values);let o=t.startState.facet(Cm)?t.newSelection:t.newSelection.asSingle();new Wn(n,t.newDoc,o,i,(a,l)=>l.update(a,t),t)}replaceSelection(t){return typeof t=="string"&&(t=this.toText(t)),this.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:t},range:se.cursor(n.from+t.length,-1)}))}changeByRange(t){let n=this.selection,r=t(n.ranges[0]),s=this.changes(r.changes),i=[r.range],o=To(r.effects);for(let a=1;a<n.ranges.length;a++){let l=t(n.ranges[a]),c=this.changes(l.changes),u=c.map(s);for(let h=0;h<a;h++)i[h]=i[h].map(u);let d=s.mapDesc(c,!0);i.push(l.range.map(d)),s=s.compose(u),o=Tt.mapEffects(o,u).concat(Tt.mapEffects(To(l.effects),d))}return{changes:s,selection:se.create(i,n.mainIndex),effects:o}}changes(t=[]){return t instanceof cr?t:cr.of(t,this.doc.length,this.facet(Wn.lineSeparator))}toText(t){return Fe.of(t.split(this.facet(Wn.lineSeparator)||hm))}sliceDoc(t=0,n=this.doc.length){return this.doc.sliceString(t,n,this.lineBreak)}facet(t){let n=this.config.address[t.id];return n==null?t.default:(il(this,n),Od(this,n))}toJSON(t){let n={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(t)for(let r in t){let s=t[r];s instanceof gc&&this.config.address[s.id]!=null&&(n[r]=s.spec.toJSON(this.field(t[r]),this))}return n}static fromJSON(t,n={},r){if(!t||typeof t.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let s=[];if(r){for(let i in r)if(Object.prototype.hasOwnProperty.call(t,i)){let o=r[i],a=t[i];s.push(o.init(l=>o.spec.fromJSON(a,l)))}}return Wn.create({doc:t.doc,selection:se.fromJSON(t.selection),extensions:n.extensions?s.concat([n.extensions]):s})}static create(t={}){let n=wS.resolve(t.extensions||[],new Map),r=t.doc instanceof Fe?t.doc:Fe.of((t.doc||"").split(n.staticFacet(Wn.lineSeparator)||hm)),s=t.selection?t.selection instanceof se?t.selection:se.single(t.selection.anchor,t.selection.head):se.single(0);return Ek(s,r.length),n.staticFacet(Cm)||(s=s.asSingle()),new Wn(n,r,s,n.dynamicSlots.map(()=>null),(i,o)=>o.create(i),null)}get tabSize(){return this.facet(Wn.tabSize)}get lineBreak(){return this.facet(Wn.lineSeparator)||`
73
+ `}get readOnly(){return this.facet(Pk)}phrase(t,...n){for(let r of this.facet(Wn.phrases))if(Object.prototype.hasOwnProperty.call(r,t)){t=r[t];break}return n.length&&(t=t.replace(/\$(\$|\d*)/g,(r,s)=>{if(s=="$")return"$";let i=+(s||1);return!i||i>n.length?r:n[i-1]})),t}languageDataAt(t,n,r=-1){let s=[];for(let i of this.facet(kk))for(let o of i(this,n,r))Object.prototype.hasOwnProperty.call(o,t)&&s.push(o[t]);return s}charCategorizer(t){let n=this.languageDataAt("wordChars",t);return U9(n.length?n[0]:"")}wordAt(t){let{text:n,from:r,length:s}=this.doc.lineAt(t),i=this.charCategorizer(t),o=t-r,a=t-r;for(;o>0;){let l=Wt(n,o,!1);if(i(n.slice(l,o))!=ns.Word)break;o=l}for(;a<s;){let l=Wt(n,a);if(i(n.slice(a,l))!=ns.Word)break;a=l}return o==a?null:se.range(o+r,a+r)}};bt.allowMultipleSelections=Cm;bt.tabSize=Ce.define({combine:e=>e.length?e[0]:4});bt.lineSeparator=Rk;bt.readOnly=Pk;bt.phrases=Ce.define({compare(e,t){let n=Object.keys(e),r=Object.keys(t);return n.length==r.length&&n.every(s=>e[s]==t[s])}});bt.languageData=kk;bt.changeFilter=Ok;bt.transactionFilter=Mk;bt.transactionExtender=Nk;Tk.reconfigure=Tt.define();function rv(e,t,n={}){let r={};for(let s of e)for(let i of Object.keys(s)){let o=s[i],a=r[i];if(a===void 0)r[i]=o;else if(!(a===o||o===void 0))if(Object.hasOwnProperty.call(n,i))r[i]=n[i](a,o);else throw new Error("Config merge conflict for field "+i)}for(let s in t)r[s]===void 0&&(r[s]=t[s]);return r}var Li=class{eq(e){return this==e}range(e,t=e){return bm.create(e,t,this)}};Li.prototype.startSide=Li.prototype.endSide=0;Li.prototype.point=!1;Li.prototype.mapMode=xn.TrackDel;function sv(e,t){return e==t||e.constructor==t.constructor&&e.eq(t)}var bm=class Hk{constructor(t,n,r){this.from=t,this.to=n,this.value=r}static create(t,n,r){return new Hk(t,n,r)}};function Sm(e,t){return e.from-t.from||e.value.startSide-t.value.startSide}var z9=class jk{constructor(t,n,r,s){this.from=t,this.to=n,this.value=r,this.maxPoint=s}get length(){return co(this.to)}findIndex(t,n,r,s=0){let i=r?this.to:this.from;for(let o=s,a=i.length;;){if(o==a)return o;let l=o+a>>1,c=i[l]-t||(r?this.value[l].endSide:this.value[l].startSide)-n;if(l==o)return c>=0?o:a;c>=0?a=l:o=l+1}}between(t,n,r,s){for(let i=this.findIndex(n,-1e9,!0),o=this.findIndex(r,1e9,!1,i);i<o;i++)if(s(this.from[i]+t,this.to[i]+t,this.value[i])===!1)return!1}map(t,n,r,s,i){let o=[],a=[],l=[],c=-1,u=-1;e:for(let d=0;d<this.value.length;d++){let h=this.value[d],f=this.from[d]+t,B=this.to[d]+t,g,C;if(f==B){let v=n.mapPos(f,h.startSide,h.mapMode);if(v==null||(g=C=v,h.startSide!=h.endSide&&(C=n.mapPos(f,h.endSide),C<g)))continue}else if(g=n.mapPos(f,h.startSide),C=n.mapPos(B,h.endSide),g>C||g==C&&h.startSide>0&&h.endSide<=0)continue;if(!((C-g||h.endSide-h.startSide)<0))if(c<0&&(c=g),h.point&&(u=Math.max(u,C-g)),(g-r||h.startSide-s)>=0)o.push(h),a.push(g-c),l.push(C-c),r=C,s=h.endSide;else{if(g==C)for(let v=o.length;v>0;v--){if((g-(l[v-1]+c)||h.startSide-o[v-1].endSide)>=0){o.splice(v,0,h),a.splice(v,0,g-c),l.splice(v,0,C-c);continue e}if((g-(a[v-1]+c)||h.endSide-o[v-1].startSide)>0)break}i(g,C,h)}}return{mapped:o.length?new jk(a,l,o,u):null,pos:c}}},et=class zr{constructor(t,n,r,s){this.chunkPos=t,this.chunk=n,this.nextLayer=r,this.maxPoint=s}static create(t,n,r,s){return new zr(t,n,r,s)}get length(){let t=this.chunk.length-1;return t<0?0:Math.max(this.chunkEnd(t),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let t=this.nextLayer.size;for(let n of this.chunk)t+=n.value.length;return t}chunkEnd(t){return this.chunkPos[t]+this.chunk[t].length}update(t){let{add:n=[],sort:r=!1,filterFrom:s=0,filterTo:i=this.length}=t,o=t.filter;if(n.length==0&&!o)return this;if(r&&(n=n.slice().sort(Sm)),this.isEmpty)return n.length?zr.of(n):this;let a=new Vk(this,null,-1).goto(0),l=0,c=[],u=new Yu;for(;a.value||l<n.length;)if(l<n.length&&(a.from-n[l].from||a.startSide-n[l].value.startSide)>=0){let d=n[l++];u.addInner(d.from,d.to,d.value,!1)||c.push(d)}else a.rangeIndex==1&&a.chunkIndex<this.chunk.length&&(l==n.length||this.chunkEnd(a.chunkIndex)<n[l].from)&&(!o||s>this.chunkEnd(a.chunkIndex)||i<this.chunkPos[a.chunkIndex])&&u.addChunk(this.chunkPos[a.chunkIndex],this.chunk[a.chunkIndex])?a.nextChunk():((!o||s>a.to||i<a.from||o(a.from,a.to,a.value))&&(u.addInner(a.from,a.to,a.value,!1)||c.push(bm.create(a.from,a.to,a.value))),a.next());return u.finishInner(this.nextLayer.isEmpty&&!c.length?zr.empty:this.nextLayer.update({add:c,filter:o,filterFrom:s,filterTo:i}))}map(t){if(t.empty||this.isEmpty)return this;let n=[],r=[],s=-1,i,o=(l,c,u)=>{i||(i=new Yu),i.addRange(l,c,u,!1)};for(let l=0;l<this.chunk.length;l++){let c=this.chunkPos[l],u=this.chunk[l],d=t.touchesRange(c,c+u.length);if(d===!1)s=Math.max(s,u.maxPoint),n.push(u),r.push(t.mapPos(c));else if(d===!0){let[h,f]=n.length?[co(r)+co(n).length,co(co(n).value).endSide]:[-1,-1],{mapped:B,pos:g}=u.map(c,t,h,f,o);B&&(s=Math.max(s,B.maxPoint),n.push(B),r.push(g))}}let a=this.nextLayer.map(t);return i&&(a=i.finishInner(a)),n.length==0?a:new zr(r,n,a||zr.empty,s)}between(t,n,r){if(!this.isEmpty){for(let s=0;s<this.chunk.length;s++){let i=this.chunkPos[s],o=this.chunk[s];if(n>=i&&t<=i+o.length&&o.between(i,t-i,n-i,r)===!1)return}this.nextLayer.between(t,n,r)}}iter(t=0){return Em.from([this]).goto(t)}get isEmpty(){return this.nextLayer==this}static iter(t,n=0){return Em.from(t).goto(n)}static compare(t,n,r,s,i=-1){let o=t.filter(d=>d.maxPoint>0||!d.isEmpty&&d.maxPoint>=i),a=n.filter(d=>d.maxPoint>0||!d.isEmpty&&d.maxPoint>=i),l=DS(o,a,r),c=new va(o,l,i),u=new va(a,l,i);r.iterGaps((d,h,f)=>TS(c,d,u,h,f,s)),r.empty&&r.length==0&&TS(c,0,u,0,0,s)}static eq(t,n,r=0,s){s==null&&(s=999999999);let i=t.filter(u=>!u.isEmpty&&n.indexOf(u)<0),o=n.filter(u=>!u.isEmpty&&t.indexOf(u)<0);if(i.length!=o.length)return!1;if(!i.length)return!0;let a=DS(i,o),l=new va(i,a,0).goto(r),c=new va(o,a,0).goto(r);for(;;){if(l.to!=c.to||!xm(l.active,c.active)||l.point&&(!c.point||!sv(l.point,c.point)))return!1;if(l.to>s)return!0;l.next(),c.next()}}static spans(t,n,r,s,i=-1){let o=new va(t,null,i).goto(n),a=n,l=o.openStart;for(;;){let c=Math.min(o.to,r);if(o.point){let u=o.activeForPoint(o.to),d=o.pointFrom<n?u.length+1:o.point.startSide<0?u.length:Math.min(u.length,l);s.point(a,c,o.point,u,d,o.pointRank),l=Math.min(o.openEnd(c),u.length)}else c>a&&(s.span(a,c,o.active,l),l=o.openEnd(c));if(o.to>r)return l+(o.point&&o.to>r?1:0);a=o.to,o.next()}}static of(t,n=!1){let r=new Yu;for(let s of t instanceof bm?[t]:n?$9(t):t)r.add(s.from,s.to,s.value);return r.finish()}static join(t){if(!t.length)return zr.empty;let n=co(t);for(let r=t.length-2;r>=0;r--)for(let s=t[r];s!=zr.empty;s=s.nextLayer)n=new zr(s.chunkPos,s.chunk,n,Math.max(s.maxPoint,n.maxPoint));return n}};et.empty=new et([],[],null,-1);function co(e){return e[e.length-1]}function $9(e){if(e.length>1)for(let t=e[0],n=1;n<e.length;n++){let r=e[n];if(Sm(t,r)>0)return e.slice().sort(Sm);t=r}return e}et.empty.nextLayer=et.empty;var Yu=class Gk{finishChunk(t){this.chunks.push(new z9(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,t&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(t,n,r){this.addRange(t,n,r,!0)}addRange(t,n,r,s){this.addInner(t,n,r,s)||(this.nextLayer||(this.nextLayer=new Gk)).addRange(t,n,r,s)}addInner(t,n,r,s){let i=t-this.lastTo||r.startSide-this.last.endSide;if(s&&i<=0&&(t-this.lastFrom||r.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return i<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=t),this.from.push(t-this.chunkStart),this.to.push(n-this.chunkStart),this.last=r,this.lastFrom=t,this.lastTo=n,this.value.push(r),r.point&&(this.maxPoint=Math.max(this.maxPoint,n-t)),!0)}addChunk(t,n){if((t-this.lastTo||n.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,n.maxPoint),this.chunks.push(n),this.chunkPos.push(t);let r=n.value.length-1;return this.last=n.value[r],this.lastFrom=n.from[r]+t,this.lastTo=n.to[r]+t,!0}finish(){return this.finishInner(et.empty)}finishInner(t){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return t;let n=et.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(t):t,this.setMaxPoint);return this.from=null,n}};function DS(e,t,n){let r=new Map;for(let i of e)for(let o=0;o<i.chunk.length;o++)i.chunk[o].maxPoint<=0&&r.set(i.chunk[o],i.chunkPos[o]);let s=new Set;for(let i of t)for(let o=0;o<i.chunk.length;o++){let a=r.get(i.chunk[o]);a!=null&&(n?n.mapPos(a):a)==i.chunkPos[o]&&!n?.touchesRange(a,a+i.chunk[o].length)&&s.add(i.chunk[o])}return s}var Vk=class{constructor(e,t,n,r=0){this.layer=e,this.skip=t,this.minPoint=n,this.rank=r}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,t=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,t,!1),this}gotoInner(e,t,n){for(;this.chunkIndex<this.layer.chunk.length;){let r=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(r)||this.layer.chunkEnd(this.chunkIndex)<e||r.maxPoint<this.minPoint))break;this.chunkIndex++,n=!1}if(this.chunkIndex<this.layer.chunk.length){let r=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!n||this.rangeIndex<r)&&this.setRangeIndex(r)}this.next()}forward(e,t){(this.to-e||this.endSide-t)<0&&this.gotoInner(e,t,!0)}next(){for(;;)if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}else{let e=this.layer.chunkPos[this.chunkIndex],t=this.layer.chunk[this.chunkIndex],n=e+t.from[this.rangeIndex];if(this.from=n,this.to=e+t.to[this.rangeIndex],this.value=t.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}},Em=class Uk{constructor(t){this.heap=t}static from(t,n=null,r=-1){let s=[];for(let i=0;i<t.length;i++)for(let o=t[i];!o.isEmpty;o=o.nextLayer)o.maxPoint>=r&&s.push(new Vk(o,n,r,i));return s.length==1?s[0]:new Uk(s)}get startSide(){return this.value?this.value.startSide:0}goto(t,n=-1e9){for(let r of this.heap)r.goto(t,n);for(let r=this.heap.length>>1;r>=0;r--)sB(this.heap,r);return this.next(),this}forward(t,n){for(let r of this.heap)r.forward(t,n);for(let r=this.heap.length>>1;r>=0;r--)sB(this.heap,r);(this.to-t||this.value.endSide-n)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let t=this.heap[0];this.from=t.from,this.to=t.to,this.value=t.value,this.rank=t.rank,t.value&&t.next(),sB(this.heap,0)}}};function sB(e,t){for(let n=e[t];;){let r=(t<<1)+1;if(r>=e.length)break;let s=e[r];if(r+1<e.length&&s.compare(e[r+1])>=0&&(s=e[r+1],r++),n.compare(s)<0)break;e[r]=n,e[t]=s,t=r}}var va=class{constructor(e,t,n){this.minPoint=n,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=Em.from(e,t,n)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){ru(this.active,e),ru(this.activeTo,e),ru(this.activeRank,e),this.minActive=AS(this.active,this.activeTo)}addActive(e){let t=0,{value:n,to:r,rank:s}=this.cursor;for(;t<this.activeRank.length&&(s-this.activeRank[t]||r-this.activeTo[t])>0;)t++;su(this.active,t,n),su(this.activeTo,t,r),su(this.activeRank,t,s),e&&su(e,t,this.cursor.from),this.minActive=AS(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let n=this.openStart<0?[]:null;for(;;){let r=this.minActive;if(r>-1&&(this.activeTo[r]-this.cursor.from||this.active[r].endSide-this.cursor.startSide)<0){if(this.activeTo[r]>e){this.to=this.activeTo[r],this.endSide=this.active[r].endSide;break}this.removeActive(r),n&&ru(n,r)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let s=this.cursor.value;if(!s.point)this.addActive(n),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=s,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=s.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}}else{this.to=this.endSide=1e9;break}}if(n){this.openStart=0;for(let r=n.length-1;r>=0&&n[r]<e;r--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let t=[];for(let n=this.active.length-1;n>=0&&!(this.activeRank[n]<this.pointRank);n--)(this.activeTo[n]>e||this.activeTo[n]==e&&this.active[n].endSide>=this.point.endSide)&&t.push(this.active[n]);return t.reverse()}openEnd(e){let t=0;for(let n=this.activeTo.length-1;n>=0&&this.activeTo[n]>e;n--)t++;return t}};function TS(e,t,n,r,s,i){e.goto(t),n.goto(r);let o=r+s,a=r,l=r-t,c=!!i.boundChange;for(let u=!1;;){let d=e.to+l-n.to,h=d||e.endSide-n.endSide,f=h<0?e.to+l:n.to,B=Math.min(f,o);if(e.point||n.point?(e.point&&n.point&&sv(e.point,n.point)&&xm(e.activeForPoint(e.to),n.activeForPoint(n.to))||i.comparePoint(a,B,e.point,n.point),u=!1):(u&&(i.boundChange(a),u=!1),B>a&&!xm(e.active,n.active)&&i.compareRange(a,B,e.active,n.active),c&&B<o&&(d||e.openEnd(f)!=n.openEnd(f))&&(u=!0)),f>o)break;a=f,h<=0&&e.next(),h>=0&&n.next()}}function xm(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n]&&!sv(e[n],t[n]))return!1;return!0}function ru(e,t){for(let n=t,r=e.length-1;n<r;n++)e[n]=e[n+1];e.pop()}function su(e,t,n){for(let r=e.length-1;r>=t;r--)e[r+1]=e[r];e[t]=n}function AS(e,t){let n=-1,r=1e9;for(let s=0;s<t.length;s++)(t[s]-r||e[s].endSide-e[n].endSide)<0&&(n=s,r=t[s]);return n}function Mh(e,t,n=e.length){let r=0;for(let s=0;s<n&&s<e.length;)e.charCodeAt(s)==9?(r+=t-r%t,s++):(r++,s=Wt(e,s));return r}function W9(e,t,n,r){for(let s=0,i=0;;){if(i>=t)return s;if(s==e.length)break;i+=e.charCodeAt(s)==9?n-i%n:1,s=Wt(e,s)}return r===!0?-1:e.length}var zk="ͼ",IS=typeof Symbol>"u"?"__ͼ":Symbol.for(zk),wm=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),kS=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{},Ws=class{constructor(e,t){this.rules=[];let{finish:n}=t||{};function r(i){return/^@/.test(i)?[i]:i.split(/,\s*/)}function s(i,o,a,l){let c=[],u=/^@(\w+)\b/.exec(i[0]),d=u&&u[1]=="keyframes";if(u&&o==null)return a.push(i[0]+";");for(let h in o){let f=o[h];if(/&/.test(h))s(h.split(/,\s*/).map(B=>i.map(g=>B.replace(/&/,g))).reduce((B,g)=>B.concat(g)),f,a);else if(f&&typeof f=="object"){if(!u)throw new RangeError("The value of a property ("+h+") should be a primitive value.");s(r(h),f,c,d)}else f!=null&&c.push(h.replace(/_.*/,"").replace(/[A-Z]/g,B=>"-"+B.toLowerCase())+": "+f+";")}(c.length||d)&&a.push((n&&!u&&!l?i.map(n):i).join(", ")+" {"+c.join(" ")+"}")}for(let i in e)s(r(i),e[i],this.rules)}getRules(){return this.rules.join(`
74
+ `)}static newName(){let e=kS[IS]||1;return kS[IS]=e+1,zk+e.toString(36)}static mount(e,t,n){let r=e[wm],s=n&&n.nonce;r?s&&r.setNonce(s):r=new q9(e,s),r.mount(Array.isArray(t)?t:[t],e)}},RS=new Map,q9=class{constructor(e,t){let n=e.ownerDocument||e,r=n.defaultView;if(!e.head&&e.adoptedStyleSheets&&r.CSSStyleSheet){let s=RS.get(n);if(s)return e[wm]=s;this.sheet=new r.CSSStyleSheet,RS.set(n,this)}else this.styleTag=n.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[wm]=this}mount(e,t){let n=this.sheet,r=0,s=0;for(let i=0;i<e.length;i++){let o=e[i],a=this.modules.indexOf(o);if(a<s&&a>-1&&(this.modules.splice(a,1),s--,a=-1),a==-1){if(this.modules.splice(s++,0,o),n)for(let l=0;l<o.rules.length;l++)n.insertRule(o.rules[l],r++)}else{for(;s<a;)r+=this.modules[s++].rules.length;r+=o.rules.length,s++}}if(n)t.adoptedStyleSheets.indexOf(this.sheet)<0&&(t.adoptedStyleSheets=[this.sheet,...t.adoptedStyleSheets]);else{let i="";for(let a=0;a<this.modules.length;a++)i+=this.modules[a].getRules()+`
75
+ `;this.styleTag.textContent=i;let o=t.head||t;this.styleTag.parentNode!=o&&o.insertBefore(this.styleTag,o.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}},qs={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},_l={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},K9=typeof navigator<"u"&&/Mac/.test(navigator.platform),J9=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Ft=0;Ft<10;Ft++)qs[48+Ft]=qs[96+Ft]=String(Ft);for(var Ft=1;Ft<=24;Ft++)qs[Ft+111]="F"+Ft;for(var Ft=65;Ft<=90;Ft++)qs[Ft]=String.fromCharCode(Ft+32),_l[Ft]=String.fromCharCode(Ft);for(var iB in qs)_l.hasOwnProperty(iB)||(_l[iB]=qs[iB]);function Q9(e){var t=!(K9&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||J9&&e.shiftKey&&e.key&&e.key.length==1||e.key=="Unidentified")&&e.key||(e.shiftKey?_l:qs)[e.keyCode]||e.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}var Yt=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},Dm=typeof document<"u"?document:{documentElement:{style:{}}},Tm=/Edge\/(\d+)/.exec(Yt.userAgent),$k=/MSIE \d/.test(Yt.userAgent),Am=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Yt.userAgent),Nh=!!($k||Am||Tm),OS=!Nh&&/gecko\/(\d+)/i.test(Yt.userAgent),oB=!Nh&&/Chrome\/(\d+)/.exec(Yt.userAgent),MS="webkitFontSmoothing"in Dm.documentElement.style,Im=!Nh&&/Apple Computer/.test(Yt.vendor),NS=Im&&(/Mobile\/\w+/.test(Yt.userAgent)||Yt.maxTouchPoints>2),ue={mac:NS||/Mac/.test(Yt.platform),windows:/Win/.test(Yt.platform),linux:/Linux|X11/.test(Yt.platform),ie:Nh,ie_version:$k?Dm.documentMode||6:Am?+Am[1]:Tm?+Tm[1]:0,gecko:OS,gecko_version:OS?+(/Firefox\/(\d+)/.exec(Yt.userAgent)||[0,0])[1]:0,chrome:!!oB,chrome_version:oB?+oB[1]:0,ios:NS,android:/Android\b/.test(Yt.userAgent),webkit:MS,webkit_version:MS?+(/\bAppleWebKit\/(\d+)/.exec(Yt.userAgent)||[0,0])[1]:0,safari:Im,safari_version:Im?+(/\bVersion\/(\d+(\.\d+)?)/.exec(Yt.userAgent)||[0,0])[1]:0,tabSize:Dm.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function iv(e,t){for(let n in e)n=="class"&&t.class?t.class+=" "+e.class:n=="style"&&t.style?t.style+=";"+e.style:t[n]=e[n];return t}var Md=Object.create(null);function ov(e,t,n){if(e==t)return!0;e||(e=Md),t||(t=Md);let r=Object.keys(e),s=Object.keys(t);if(r.length-(n&&r.indexOf(n)>-1?1:0)!=s.length-(n&&s.indexOf(n)>-1?1:0))return!1;for(let i of r)if(i!=n&&(s.indexOf(i)==-1||e[i]!==t[i]))return!1;return!0}function Y9(e,t){for(let n=e.attributes.length-1;n>=0;n--){let r=e.attributes[n].name;t[r]==null&&e.removeAttribute(r)}for(let n in t){let r=t[n];n=="style"?e.style.cssText=r:e.getAttribute(n)!=r&&e.setAttribute(n,r)}}function PS(e,t,n){let r=!1;if(t)for(let s in t)n&&s in n||(r=!0,s=="style"?e.style.cssText="":e.removeAttribute(s));if(n)for(let s in n)t&&t[s]==n[s]||(r=!0,s=="style"?e.style.cssText=n[s]:e.setAttribute(s,n[s]));return r}function X9(e){let t=Object.create(null);for(let n=0;n<e.attributes.length;n++){let r=e.attributes[n];t[r.name]=r.value}return t}var Ph=class{eq(e){return!1}updateDOM(e,t,n){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,t,n){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}},Gt=(function(e){return e[e.Text=0]="Text",e[e.WidgetBefore=1]="WidgetBefore",e[e.WidgetAfter=2]="WidgetAfter",e[e.WidgetRange=3]="WidgetRange",e})(Gt||(Gt={})),rt=class extends Li{constructor(e,t,n,r){super(),this.startSide=e,this.endSide=t,this.widget=n,this.spec=r}get heightRelevant(){return!1}static mark(e){return new av(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),n=!!e.block;return t+=n&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new Fl(e,t,t,n,e.widget||null,!1)}static replace(e){let t=!!e.block,n,r;if(e.isBlockGap)n=-5e8,r=4e8;else{let{start:s,end:i}=Jk(e,t);n=(s?t?-3e8:-1:5e8)-1,r=(i?t?2e8:1:-6e8)+1}return new Fl(e,n,r,t,e.widget||null,!0)}static line(e){return new lv(e)}static set(e,t=!1){return et.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}};rt.none=et.empty;var av=class Wk extends rt{constructor(t){let{start:n,end:r}=Jk(t);super(n?-1:5e8,r?1:-6e8,null,t),this.tagName=t.tagName||"span",this.attrs=t.class&&t.attributes?iv(t.attributes,{class:t.class}):t.class?{class:t.class}:t.attributes||Md}eq(t){return this==t||t instanceof Wk&&this.tagName==t.tagName&&ov(this.attrs,t.attrs)}range(t,n=t){if(t>=n)throw new RangeError("Mark decorations may not be empty");return super.range(t,n)}};av.prototype.point=!1;var lv=class qk extends rt{constructor(t){super(-2e8,-2e8,null,t)}eq(t){return t instanceof qk&&this.spec.class==t.spec.class&&ov(this.spec.attributes,t.spec.attributes)}range(t,n=t){if(n!=t)throw new RangeError("Line decoration ranges must be zero-length");return super.range(t,n)}};lv.prototype.mapMode=xn.TrackBefore;lv.prototype.point=!0;var Fl=class Kk extends rt{constructor(t,n,r,s,i,o){super(n,r,i,t),this.block=s,this.isReplace=o,this.mapMode=s?n<=0?xn.TrackBefore:xn.TrackAfter:xn.TrackDel}get type(){return this.startSide!=this.endSide?Gt.WidgetRange:this.startSide<=0?Gt.WidgetBefore:Gt.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(t){return t instanceof Kk&&Z9(this.widget,t.widget)&&this.block==t.block&&this.startSide==t.startSide&&this.endSide==t.endSide}range(t,n=t){if(this.isReplace&&(t>n||t==n&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&n!=t)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(t,n)}};Fl.prototype.point=!0;function Jk(e,t=!1){let{inclusiveStart:n,inclusiveEnd:r}=e;return n==null&&(n=e.inclusive),r==null&&(r=e.inclusive),{start:n??t,end:r??t}}function Z9(e,t){return e==t||!!(e&&t&&e.compare(t))}function Ao(e,t,n,r=0){let s=n.length-1;s>=0&&n[s]+r>=e?n[s]=Math.max(n[s],t):n.push(e,t)}var LS=class km extends Li{constructor(t,n,r){super(),this.tagName=t,this.attributes=n,this.rank=r}eq(t){return t==this||t instanceof km&&this.tagName==t.tagName&&ov(this.attributes,t.attributes)}static create(t){return new km(t.tagName,t.attributes||Md,t.rank==null?50:Math.max(0,Math.min(t.rank,100)))}static set(t,n=!1){return et.of(t,n)}};LS.prototype.startSide=LS.prototype.endSide=-1;function Hl(e){let t;return e.nodeType==11?t=e.getSelection?e:e.ownerDocument:t=e,t.getSelection()}function Rm(e,t){return t?e==t||e.contains(t.nodeType!=1?t.parentNode:t):!1}function ol(e,t){if(!t.anchorNode)return!1;try{return Rm(e,t.anchorNode)}catch{return!1}}function Xu(e){return e.nodeType==3?jl(e,0,e.nodeValue.length).getClientRects():e.nodeType==1?e.getClientRects():[]}function al(e,t,n,r){return n?_S(e,t,n,r,-1)||_S(e,t,n,r,1):!1}function Ks(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t}function Nd(e){return e.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(e.nodeName)}function _S(e,t,n,r,s){for(;;){if(e==n&&t==r)return!0;if(t==(s<0?0:hs(e))){if(e.nodeName=="DIV")return!1;let i=e.parentNode;if(!i||i.nodeType!=1)return!1;t=Ks(e)+(s<0?0:1),e=i}else if(e.nodeType==1){if(e=e.childNodes[t+(s<0?-1:0)],e.nodeType==1&&e.contentEditable=="false")return!1;t=s<0?hs(e):0}else return!1}}function hs(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function Pd(e,t){let{left:n,right:r}=e;if(n==r)return e;let s=t?n:r;return{left:s,right:s,top:e.top,bottom:e.bottom}}function eQ(e){let t=e.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.innerWidth,top:0,bottom:e.innerHeight}}function Qk(e,t){let n=t.width/e.offsetWidth,r=t.height/e.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(t.width-e.offsetWidth)<1)&&(n=1),(r>.995&&r<1.005||!isFinite(r)||Math.abs(t.height-e.offsetHeight)<1)&&(r=1),{scaleX:n,scaleY:r}}function tQ(e,t,n,r,s,i,o,a){let l=e.ownerDocument,c=l.defaultView||window;for(let u=e,d=!1;u&&!d;)if(u.nodeType==1){let h,f=u==l.body,B=1,g=1;if(f)h=eQ(c);else{if(/^(fixed|sticky)$/.test(getComputedStyle(u).position)&&(d=!0),u.scrollHeight<=u.clientHeight&&u.scrollWidth<=u.clientWidth){u=u.assignedSlot||u.parentNode;continue}let y=u.getBoundingClientRect();({scaleX:B,scaleY:g}=Qk(u,y)),h={left:y.left,right:y.left+u.clientWidth*B,top:y.top,bottom:y.top+u.clientHeight*g}}let C=0,v=0;if(s=="nearest")t.top<h.top+o?(v=t.top-(h.top+o),n>0&&t.bottom>h.bottom+v&&(v=t.bottom-h.bottom+o)):t.bottom>h.bottom-o&&(v=t.bottom-h.bottom+o,n<0&&t.top-v<h.top&&(v=t.top-(h.top+o)));else{let y=t.bottom-t.top,b=h.bottom-h.top;v=(s=="center"&&y<=b?t.top+y/2-b/2:s=="start"||s=="center"&&n<0?t.top-o:t.bottom-b+o)-h.top}if(r=="nearest"?t.left<h.left+i?(C=t.left-(h.left+i),n>0&&t.right>h.right+C&&(C=t.right-h.right+i)):t.right>h.right-i&&(C=t.right-h.right+i,n<0&&t.left<h.left+C&&(C=t.left-(h.left+i))):C=(r=="center"?t.left+(t.right-t.left)/2-(h.right-h.left)/2:r=="start"==a?t.left-i:t.right-(h.right-h.left)+i)-h.left,C||v)if(f)c.scrollBy(C,v);else{let y=0,b=0;if(v){let E=u.scrollTop;u.scrollTop+=v/g,b=(u.scrollTop-E)*g}if(C){let E=u.scrollLeft;u.scrollLeft+=C/B,y=(u.scrollLeft-E)*B}t={left:t.left-y,top:t.top-b,right:t.right-y,bottom:t.bottom-b},y&&Math.abs(y-C)<1&&(r="nearest"),b&&Math.abs(b-v)<1&&(s="nearest")}if(f)break;(t.top<h.top||t.bottom>h.bottom||t.left<h.left||t.right>h.right)&&(t={left:Math.max(t.left,h.left),right:Math.min(t.right,h.right),top:Math.max(t.top,h.top),bottom:Math.min(t.bottom,h.bottom)}),u=u.assignedSlot||u.parentNode}else if(u.nodeType==11)u=u.host;else break}function Yk(e,t=!0){let n=e.ownerDocument,r=null,s=null;for(let i=e.parentNode;i&&!(i==n.body||(!t||r)&&s);)if(i.nodeType==1)!s&&i.scrollHeight>i.clientHeight&&(s=i),t&&!r&&i.scrollWidth>i.clientWidth&&(r=i),i=i.assignedSlot||i.parentNode;else if(i.nodeType==11)i=i.host;else break;return{x:r,y:s}}var nQ=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:n}=e;this.set(t,Math.min(e.anchorOffset,t?hs(t):0),n,Math.min(e.focusOffset,n?hs(n):0))}set(e,t,n,r){this.anchorNode=e,this.anchorOffset=t,this.focusNode=n,this.focusOffset=r}};function Xk(e){let t=[];for(let n=e;n;n=n.nodeType==11?n.host:n.parentNode)n.nodeType==1&&t.push({node:n,left:n.scrollLeft,top:n.scrollTop});return t}function Zk(e,t=!0){for(let{node:n,left:r,top:s}of e)t&&n.scrollTop!=s&&(n.scrollTop=s),n.scrollLeft!=r&&(n.scrollLeft=r)}var pi=null;ue.safari&&ue.safari_version>=26&&(pi=!1);function eR(e){if(e.setActive)return e.setActive();if(pi)return e.focus(pi);let t=Xk(e);e.focus(pi==null?{get preventScroll(){return pi={preventScroll:!0},!0}}:void 0),pi||(pi=!1,Zk(t))}var FS;function jl(e,t,n=t){let r=FS||(FS=document.createRange());return r.setEnd(e,n),r.setStart(e,t),r}function Io(e,t,n,r){let s={key:t,code:t,keyCode:n,which:n,cancelable:!0};r&&({altKey:s.altKey,ctrlKey:s.ctrlKey,shiftKey:s.shiftKey,metaKey:s.metaKey}=r);let i=new KeyboardEvent("keydown",s);i.synthetic=!0,e.dispatchEvent(i);let o=new KeyboardEvent("keyup",s);return o.synthetic=!0,e.dispatchEvent(o),i.defaultPrevented||o.defaultPrevented}function rQ(e){for(;e;){if(e&&(e.nodeType==9||e.nodeType==11&&e.host))return e;e=e.assignedSlot||e.parentNode}return null}function sQ(e,t){let n=t.focusNode,r=t.focusOffset;if(!n||t.anchorNode!=n||t.anchorOffset!=r)return!1;for(r=Math.min(r,hs(n));;)if(r){if(n.nodeType!=1)return!1;let s=n.childNodes[r-1];s.contentEditable=="false"?r--:(n=s,r=hs(n))}else{if(n==e)return!0;r=Ks(n),n=n.parentNode}}function tR(e){return e instanceof Window?e.pageYOffset>Math.max(0,e.document.documentElement.scrollHeight-e.innerHeight-4):e.scrollTop>Math.max(1,e.scrollHeight-e.clientHeight-4)}function nR(e,t){for(let n=e,r=t;;){if(n.nodeType==3&&r>0)return{node:n,offset:r};if(n.nodeType==1&&r>0){if(n.contentEditable=="false")return null;n=n.childNodes[r-1],r=hs(n)}else if(n.parentNode&&!Nd(n))r=Ks(n),n=n.parentNode;else return null}}function rR(e,t){for(let n=e,r=t;;){if(n.nodeType==3&&r<n.nodeValue.length)return{node:n,offset:r};if(n.nodeType==1&&r<n.childNodes.length){if(n.contentEditable=="false")return null;n=n.childNodes[r],r=0}else if(n.parentNode&&!Nd(n))r=Ks(n)+1,n=n.parentNode;else return null}}var Ls=class Om{constructor(t,n,r=!0){this.node=t,this.offset=n,this.precise=r}static before(t,n){return new Om(t.parentNode,Ks(t),n)}static after(t,n){return new Om(t.parentNode,Ks(t)+1,n)}},nt=(function(e){return e[e.LTR=0]="LTR",e[e.RTL=1]="RTL",e})(nt||(nt={})),_i=nt.LTR,cv=nt.RTL;function sR(e){let t=[];for(let n=0;n<e.length;n++)t.push(1<<+e[n]);return t}var iQ=sR("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),oQ=sR("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),Mm=Object.create(null),yr=[];for(let e of["()","[]","{}"]){let t=e.charCodeAt(0),n=e.charCodeAt(1);Mm[t]=n,Mm[n]=-t}function iR(e){return e<=247?iQ[e]:1424<=e&&e<=1524?2:1536<=e&&e<=1785?oQ[e-1536]:1774<=e&&e<=2220?4:8192<=e&&e<=8204?256:64336<=e&&e<=65023?4:1}var aQ=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/,kr=class{get dir(){return this.level%2?cv:_i}constructor(e,t,n){this.from=e,this.to=t,this.level=n}side(e,t){return this.dir==t==e?this.to:this.from}forward(e,t){return e==(this.dir==t)}static find(e,t,n,r){let s=-1;for(let i=0;i<e.length;i++){let o=e[i];if(o.from<=t&&o.to>=t){if(o.level==n)return i;(s<0||(r!=0?r<0?o.from<t:o.to>t:e[s].level>o.level))&&(s=i)}}if(s<0)throw new RangeError("Index out of range");return s}};function oR(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],s=t[n];if(r.from!=s.from||r.to!=s.to||r.direction!=s.direction||!oR(r.inner,s.inner))return!1}return!0}var We=[];function lQ(e,t,n,r,s){for(let i=0;i<=r.length;i++){let o=i?r[i-1].to:t,a=i<r.length?r[i].from:n,l=i?256:s;for(let c=o,u=l,d=l;c<a;c++){let h=iR(e.charCodeAt(c));h==512?h=u:h==8&&d==4&&(h=16),We[c]=h==4?2:h,h&7&&(d=h),u=h}for(let c=o,u=l,d=l;c<a;c++){let h=We[c];if(h==128)c<a-1&&u==We[c+1]&&u&24?h=We[c]=u:We[c]=256;else if(h==64){let f=c+1;for(;f<a&&We[f]==64;)f++;let B=c&&u==8||f<n&&We[f]==8?d==1?1:8:256;for(let g=c;g<f;g++)We[g]=B;c=f-1}else h==8&&d==1&&(We[c]=1);u=h,h&7&&(d=h)}}}function cQ(e,t,n,r,s){let i=s==1?2:1;for(let o=0,a=0,l=0;o<=r.length;o++){let c=o?r[o-1].to:t,u=o<r.length?r[o].from:n;for(let d=c,h,f,B;d<u;d++)if(f=Mm[h=e.charCodeAt(d)])if(f<0){for(let g=a-3;g>=0;g-=3)if(yr[g+1]==-f){let C=yr[g+2],v=C&2?s:C&4?C&1?i:s:0;v&&(We[d]=We[yr[g]]=v),a=g;break}}else{if(yr.length==189)break;yr[a++]=d,yr[a++]=h,yr[a++]=l}else if((B=We[d])==2||B==1){let g=B==s;l=g?0:1;for(let C=a-3;C>=0;C-=3){let v=yr[C+2];if(v&2)break;if(g)yr[C+2]|=2;else{if(v&4)break;yr[C+2]|=4}}}}}function uQ(e,t,n,r){for(let s=0,i=r;s<=n.length;s++){let o=s?n[s-1].to:e,a=s<n.length?n[s].from:t;for(let l=o;l<a;){let c=We[l];if(c==256){let u=l+1;for(;;)if(u==a){if(s==n.length)break;u=n[s++].to,a=s<n.length?n[s].from:t}else if(We[u]==256)u++;else break;let d=i==1,h=d==((u<t?We[u]:r)==1)?d?1:2:r;for(let f=u,B=s,g=B?n[B-1].to:e;f>l;)f==g&&(f=n[--B].from,g=B?n[B-1].to:e),We[--f]=h;l=u}else i=c,l++}}}function Nm(e,t,n,r,s,i,o){let a=r%2?2:1;if(r%2==s%2)for(let l=t,c=0;l<n;){let u=!0,d=!1;if(c==i.length||l<i[c].from){let g=We[l];g!=a&&(u=!1,d=g==16)}let h=!u&&a==1?[]:null,f=u?r:r+1,B=l;e:for(;;)if(c<i.length&&B==i[c].from){if(d)break e;let g=i[c];if(!u)for(let C=g.to,v=c+1;;){if(C==n)break e;if(v<i.length&&i[v].from==C)C=i[v++].to;else{if(We[C]==a)break e;break}}c++,h?h.push(g):(g.from>l&&o.push(new kr(l,g.from,f)),Pm(e,g.direction==_i!=!(f%2)?r+1:r,s,g.inner,g.from,g.to,o),l=g.to),B=g.to}else{if(B==n||(u?We[B]!=a:We[B]==a))break;B++}h?Nm(e,l,B,r+1,s,h,o):l<B&&o.push(new kr(l,B,f)),l=B}else for(let l=n,c=i.length;l>t;){let u=!0,d=!1;if(!c||l>i[c-1].to){let g=We[l-1];g!=a&&(u=!1,d=g==16)}let h=!u&&a==1?[]:null,f=u?r:r+1,B=l;e:for(;;)if(c&&B==i[c-1].to){if(d)break e;let g=i[--c];if(!u)for(let C=g.from,v=c;;){if(C==t)break e;if(v&&i[v-1].to==C)C=i[--v].from;else{if(We[C-1]==a)break e;break}}h?h.push(g):(g.to<l&&o.push(new kr(g.to,l,f)),Pm(e,g.direction==_i!=!(f%2)?r+1:r,s,g.inner,g.from,g.to,o),l=g.from),B=g.from}else{if(B==t||(u?We[B-1]!=a:We[B-1]==a))break;B--}h?Nm(e,B,l,r+1,s,h,o):B<l&&o.push(new kr(B,l,f)),l=B}}function Pm(e,t,n,r,s,i,o){let a=t%2?2:1;lQ(e,s,i,r,a),cQ(e,s,i,r,a),uQ(s,i,r,a),Nm(e,s,i,t,n,r,o)}function dQ(e,t,n){if(!e)return[new kr(0,0,t==cv?1:0)];if(t==_i&&!n.length&&!aQ.test(e))return aR(e.length);if(n.length)for(;e.length>We.length;)We[We.length]=256;let r=[],s=t==_i?0:1;return Pm(e,s,s,n,0,e.length,r),r}function aR(e){return[new kr(0,e,0)]}var lR="";function hQ(e,t,n,r,s){var i;if(!e.length)return null;let o=r.head-e.from,a;if(r.head==e.from&&r.assoc<0){if(!s)return null;o=t[a=0].side(!1,n)}else if(r.head==e.to&&r.assoc>0){if(s)return null;o=t[a=t.length-1].side(!0,n)}else a=kr.find(t,o,(i=r.bidiLevel)!==null&&i!==void 0?i:-1,r.assoc);let l=t[a],c=l.side(s,n);if(o==c){let h=a+=s?1:-1;if(h<0||h>=t.length)return null;l=t[a=h],o=l.side(!s,n),c=l.side(s,n)}let u=Wt(e.text,o,l.forward(s,n));(u<l.from||u>l.to)&&(u=c),lR=e.text.slice(Math.min(o,u),Math.max(o,u));let d=a==(s?t.length-1:0)?null:t[a+(s?1:-1)];if(u==c){if(!d)return s?se.cursor(e.to,1):se.cursor(e.from,-1);if(d.level+(s?0:1)<l.level)return se.cursor(d.side(!s,n)+e.from,d.forward(s,n)?1:-1,d.level)}return se.cursor(u+e.from,l.forward(s,n)?-1:1,l.level)}function fQ(e,t,n){for(let r=t;r<n;r++){let s=iR(e.charCodeAt(r));if(s==1)return _i;if(s==2||s==4)return cv}return _i}var cR=Ce.define(),uR=Ce.define(),dR=Ce.define(),hR=Ce.define(),Lm=Ce.define(),fR=Ce.define(),BR=Ce.define(),uv=Ce.define(),dv=Ce.define(),pR=Ce.define({combine:e=>e.some(t=>t)}),mR=Ce.define({combine:e=>e.some(t=>t)}),gR=Ce.define(),aB=class _m{constructor(t,n,r,s,i,o=!1){this.range=t,this.y=n,this.x=r,this.yMargin=s,this.xMargin=i,this.isSnapshot=o}map(t){return t.empty?this:new _m(this.range.map(t),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(t){return this.range.to<=t.doc.length?this:new _m(se.cursor(t.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}},iu=Tt.define({map:(e,t)=>e.map(t)}),CR=Tt.define();function Rr(e,t,n){let r=e.facet(hR);r.length?r[0](t):window.onerror&&window.onerror(String(t),n,void 0,void 0,t)||(n?console.error(n+":",t):console.error(t))}var Yr=Ce.define({combine:e=>e.length?e[0]:!0}),BQ=0,Co=Ce.define({combine(e){return e.filter((t,n)=>{for(let r=0;r<n;r++)if(e[r].plugin==t.plugin)return!1;return!0})}}),Js=class Fm{constructor(t,n,r,s,i){this.id=t,this.create=n,this.domEventHandlers=r,this.domEventObservers=s,this.baseExtensions=i(this),this.extension=this.baseExtensions.concat(Co.of({plugin:this,arg:void 0}))}of(t){return this.baseExtensions.concat(Co.of({plugin:this,arg:t}))}static define(t,n){const{eventHandlers:r,eventObservers:s,provide:i,decorations:o}=n||{};return new Fm(BQ++,t,r,s,a=>{let l=[];return o&&l.push(Lh.of(c=>{let u=c.plugin(a);return u?o(u):rt.none})),i&&l.push(i(a)),l})}static fromClass(t,n){return Fm.define((r,s)=>new t(r,s),n)}},lB=class{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(n){if(Rr(t.state,n,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(t){Rr(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(!((t=this.value)===null||t===void 0)&&t.destroy)try{this.value.destroy()}catch(n){Rr(e.state,n,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}},vR=Ce.define(),hv=Ce.define(),Lh=Ce.define(),yR=Ce.define(),fv=Ce.define(),Cc=Ce.define(),bR=Ce.define();function HS(e,t){let n=e.state.facet(bR);if(!n.length)return n;let r=n.map(i=>i instanceof Function?i(e):i),s=[];return et.spans(r,t.from,t.to,{point(){},span(i,o,a,l){let c=i-t.from,u=o-t.from,d=s;for(let h=a.length-1;h>=0;h--,l--){let f=a[h].spec.bidiIsolate,B;if(f==null&&(f=fQ(t.text,c,u)),l>0&&d.length&&(B=d[d.length-1]).to==c&&B.direction==f)B.to=u,d=B.inner;else{let g={from:c,to:u,direction:f,inner:[]};d.push(g),d=g.inner}}}}),s}var SR=Ce.define();function ER(e){let t=0,n=0,r=0,s=0;for(let i of e.state.facet(SR)){let o=i(e);o&&(o.left!=null&&(t=Math.max(t,o.left)),o.right!=null&&(n=Math.max(n,o.right)),o.top!=null&&(r=Math.max(r,o.top)),o.bottom!=null&&(s=Math.max(s,o.bottom)))}return{left:t,right:n,top:r,bottom:s}}var _a=Ce.define(),rs=class Hm{constructor(t,n,r,s){this.fromA=t,this.toA=n,this.fromB=r,this.toB=s}join(t){return new Hm(Math.min(this.fromA,t.fromA),Math.max(this.toA,t.toA),Math.min(this.fromB,t.fromB),Math.max(this.toB,t.toB))}addToSet(t){let n=t.length,r=this;for(;n>0;n--){let s=t[n-1];if(!(s.fromA>r.toA)){if(s.toA<r.fromA)break;r=r.join(s),t.splice(n-1,1)}}return t.splice(n,0,r),t}static extendWithRanges(t,n){if(n.length==0)return t;let r=[];for(let s=0,i=0,o=0;;){let a=s<t.length?t[s].fromB:1e9,l=i<n.length?n[i]:1e9,c=Math.min(a,l);if(c==1e9)break;let u=c+o,d=c,h=u;for(;;)if(i<n.length&&n[i]<=d){let f=n[i+1];i+=2,d=Math.max(d,f);for(let B=s;B<t.length&&t[B].fromB<=d;B++)o=t[B].toA-t[B].toB;h=Math.max(h,f+o)}else if(s<t.length&&t[s].fromB<=d){let f=t[s++];d=Math.max(d,f.toB),h=Math.max(h,f.toA),o=f.toA-f.toB}else break;r.push(new Hm(u,h,c,d))}return r}},jS=class xR{constructor(t,n,r){this.view=t,this.state=n,this.transactions=r,this.flags=0,this.startState=t.state,this.changes=cr.empty(this.startState.doc.length);for(let i of r)this.changes=this.changes.compose(i.changes);let s=[];this.changes.iterChangedRanges((i,o,a,l)=>s.push(new rs(i,o,a,l))),this.changedRanges=s}static create(t,n,r){return new xR(t,n,r)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(t=>t.selection)}get empty(){return this.flags==0&&this.transactions.length==0}},pQ=[],ht=class{constructor(e,t,n=0){this.dom=e,this.length=t,this.flags=n,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return pQ}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let t=this.domAttrs;t&&Y9(this.dom,t)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,t=this.posAtStart){let n=t;for(let r of this.children){if(r==e)return n;n+=r.length+r.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,t,n){return null}domPosFor(e,t){let n=Ks(this.dom),r=this.length?e>0:t>0;return new Ls(this.parent.dom,n+(r?1:0),e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof Fh)return e;return null}static get(e){return e.cmTile}},_h=class extends ht{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let t=this.dom,n=null,r,s=e?.node==t?e:null,i=0;for(let o of this.children){if(o.sync(e),i+=o.length+o.breakAfter,r=n?n.nextSibling:t.firstChild,s&&r!=o.dom&&(s.written=!0),o.dom.parentNode==t)for(;r&&r!=o.dom;)r=GS(r);else t.insertBefore(o.dom,r);n=o.dom}for(r=n?n.nextSibling:t.firstChild,s&&r&&(s.written=!0);r;)r=GS(r);this.length=i}};function GS(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}var Fh=class extends _h{constructor(e,t){super(t),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let t=ht.get(e);if(t&&this.owns(t))return t;e=e.parentNode}}blockTiles(e){for(let t=[],n=this,r=0,s=0;;)if(r==n.children.length){if(!t.length)return;n=n.parent,n.breakAfter&&s++,r=t.pop()}else{let i=n.children[r++];if(i instanceof Ti)t.push(r),n=i,r=0;else{let o=s+i.length,a=e(i,s);if(a!==void 0)return a;s=o+i.breakAfter}}}resolveBlock(e,t){let n,r=-1,s,i=-1;if(this.blockTiles((o,a)=>{let l=a+o.length;if(e>=a&&e<=l){if(o.isWidget()&&t>=-1&&t<=1){if(o.flags&32)return!0;o.flags&16&&(n=void 0)}(a<e||e==l&&(t<-1?o.length:o.covers(1)))&&(!n||!o.isWidget()&&n.isWidget())&&(n=o,r=e-a),(l>e||e==a&&(t>1?o.length:o.covers(-1)))&&(!s||!o.isWidget()&&s.isWidget())&&(s=o,i=e-a)}}),!n&&!s)throw new Error("No tile at position "+e);return n&&t<0||!s?{tile:n,offset:r}:{tile:s,offset:i}}},Ti=class wR extends _h{constructor(t,n){super(t),this.wrapper=n}isBlock(){return!0}covers(t){return this.children.length?t<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(t,n){let r=new wR(n||document.createElement(t.tagName),t);return n||(r.flags|=4),r}},Ld=class DR extends _h{constructor(t,n){super(t),this.attrs=n}isLine(){return!0}static start(t,n,r){let s=new DR(n||document.createElement("div"),t);return(!n||!r)&&(s.flags|=4),s}get domAttrs(){return this.attrs}resolveInline(t,n,r){let s=null,i=-1,o=null,a=-1;function l(u,d){for(let h=0,f=0;h<u.children.length&&f<=d;h++){let B=u.children[h],g=f+B.length;g>=d&&(B.isComposite()?l(B,d-f):(!o||o.isHidden&&(n>0&&!(o.flags&32)||r&&gQ(o,B)))&&(g>d||B.flags&32&&n<=1)?(o=B,a=d-f):(f<d||B.flags&16&&!B.isHidden&&n>=-1)&&(s=B,i=d-f)),f=g}}l(this,t);let c=(n<0?s:o)||s||o;return c?{tile:c,offset:c==s?i:a}:null}coordsIn(t,n,r){let s=this.resolveInline(t,n,!0);return s?s.tile.coordsIn(Math.max(0,s.offset),n,r):mQ(this)}domIn(t,n){let r=this.resolveInline(t,n);if(r){let{tile:s,offset:i}=r;if(this.dom.contains(s.dom))return s.isText()?new Ls(s.dom,Math.min(s.dom.nodeValue.length,i)):s.domPosFor(i,s.flags&16?1:s.flags&32?-1:n);let o=r.tile.parent,a=!1;for(let l of o.children){if(a)return new Ls(l.dom,0);l==r.tile&&(a=!0)}}return new Ls(this.dom,0)}};function mQ(e){let t=e.dom.lastChild;if(!t)return e.dom.getBoundingClientRect();let n=Xu(t);return n[n.length-1]||null}function gQ(e,t){let n=e.coordsIn(0,1),r=t.coordsIn(0,1);return n&&r&&r.top<n.bottom}var On=class TR extends _h{constructor(t,n){super(t),this.mark=n}get domAttrs(){return this.mark.attrs}static of(t,n){let r=new TR(n||document.createElement(t.tagName),t);return n||(r.flags|=4),r}},Fa=class AR extends ht{constructor(t,n){super(t,n.length),this.text=n}sync(t){this.flags&2||(super.sync(t),this.dom.nodeValue!=this.text&&(t&&t.node==this.dom&&(t.written=!0),this.dom.nodeValue=this.text))}isText(){return!0}toString(){return JSON.stringify(this.text)}coordsIn(t,n,r){let s=this.dom.nodeValue.length;t>s&&(t=s);let i=t,o=t,a=0;t==0&&n<0||t==s&&n>=0?ue.chrome||ue.gecko||(t?(i--,a=1):o<s&&(o++,a=-1)):n<0?i--:o<s&&o++;let l=jl(this.dom,i,o).getClientRects();if(!l.length)return null;let c=l[(a?a<0:n>=0)?0:l.length-1];return ue.safari&&!a&&c.width==0&&(c=Array.prototype.find.call(l,u=>u.width)||c),r==null?c:Pd(c,(a?a>0:n<0)==r)}static of(t,n){let r=new AR(n||document.createTextNode(t),t);return n||(r.flags|=2),r}},Gl=class IR extends ht{constructor(t,n,r,s){super(t,n,s),this.widget=r}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(t){return this.flags&48?!1:(this.flags&(t<0?64:128))>0}coordsIn(t,n){return this.coordsInWidget(t,n,!1)}coordsInWidget(t,n,r){let s=this.widget.coordsAt(this.dom,t,n);if(s)return s;if(r)return Pd(this.dom.getBoundingClientRect(),this.length?t==0:n<=0);{let i=this.dom.getClientRects(),o=null;if(!i.length)return null;let a=this.flags&16?!0:this.flags&32?!1:t>0;for(let l=a?i.length-1:0;o=i[l],!(t>0?l==0:l==i.length-1||o.top<o.bottom);l+=a?-1:1);return Pd(o,!a)}}get overrideDOMText(){if(!this.length)return Fe.empty;let{root:t}=this;if(!t)return Fe.empty;let n=this.posAtStart;return t.view.state.doc.slice(n,n+this.length)}destroy(){super.destroy(),this.widget.destroy(this.dom)}static of(t,n,r,s,i){return i||(i=t.toDOM(n),t.editable||(i.contentEditable="false")),new IR(i,r,t,s)}},_d=class extends ht{constructor(e){let t=document.createElement("img");t.className="cm-widgetBuffer",t.setAttribute("aria-hidden","true"),super(t,0,e)}get isHidden(){return!0}get overrideDOMText(){return Fe.empty}coordsIn(e,t,n){let r=this.dom.getBoundingClientRect();return n==null?r:Pd(r,t>0==n)}},CQ=class{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,t,n){let{tile:r,index:s,beforeBreak:i,parents:o}=this;for(;e||t>0;)if(r.isComposite())if(i){if(!e)break;n&&n.break(),e--,i=!1}else if(s==r.children.length){if(!e&&!o.length)break;n&&n.leave(r),i=!!r.breakAfter,{tile:r,index:s}=o.pop(),s++}else{let a=r.children[s],l=a.breakAfter;(t>0?a.length<=e:a.length<e)&&(!n||n.skip(a,0,a.length)!==!1||!a.isComposite)?(i=!!l,s++,e-=a.length):(o.push({tile:r,index:s}),r=a,s=0,n&&a.isComposite()&&n.enter(a))}else{let a=r.length;if(s<a&&e){let l=Math.min(e,a-s);n&&n.skip(r,s,s+l),e-=l,s+=l}if(s==a)i=!!r.breakAfter,{tile:r,index:s}=o.pop(),s++;else if(!e)break}return this.tile=r,this.index=s,this.beforeBreak=i,this}get root(){return this.parents.length?this.parents[0].tile:this.tile}},vQ=class{constructor(e,t,n,r){this.from=e,this.to=t,this.wrapper=n,this.rank=r}},yQ=class{constructor(e,t,n){this.cache=e,this.root=t,this.blockWrappers=n,this.curLine=null,this.lastBlock=null,this.afterWidget=null,this.pos=0,this.wrappers=[],this.wrapperPos=0}addText(e,t,n,r){var s;this.flushBuffer();let i=this.ensureMarks(t,n),o=i.lastChild;if(o&&o.isText()&&!(o.flags&8)&&o.length+e.length<512){this.cache.reused.set(o,2);let a=i.children[i.children.length-1]=new Fa(o.dom,o.text+e);a.parent=i}else i.append(r||Fa.of(e,(s=this.cache.find(Fa))===null||s===void 0?void 0:s.dom));this.pos+=e.length,this.afterWidget=null}addComposition(e,t){let n=this.curLine;n.dom!=t.line.dom&&(n.setDOM(this.cache.reused.has(t.line)?cB(t.line.dom):t.line.dom),this.cache.reused.set(t.line,2));let r=n;for(let o=t.marks.length-1;o>=0;o--){let a=t.marks[o],l=r.lastChild;if(l instanceof On&&l.mark.eq(a.mark))l.dom!=a.dom&&l.setDOM(cB(a.dom)),r=l;else{let{dom:c}=a;this.cache.reused.get(a)&&ht.get(a.dom)&&(c=cB(a.dom));let u=On.of(a.mark,c);r.append(u),r=u}this.cache.reused.set(a,2)}let s=ht.get(e.text);s&&this.cache.reused.set(s,2);let i=new Fa(e.text,e.text.nodeValue);i.flags|=8,this.pos=e.range.toB,r.append(i)}addInlineWidget(e,t,n){let r=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);r||this.flushBuffer();let s=this.ensureMarks(t,n);!r&&!(e.flags&16)&&s.append(this.getBuffer(1)),s.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,t,n){this.flushBuffer(),this.ensureMarks(t,n).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let t=this.afterWidget||this.lastBlock;t.length+=e,this.pos+=e}addLineStart(e,t){var n;e||(e=kR);let r=Ld.start(e,t||((n=this.cache.find(Ld))===null||n===void 0?void 0:n.dom),!!t);this.getBlockPos().append(this.lastBlock=this.curLine=r)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,t){var n;let r=this.curLine;for(let s=e.length-1;s>=0;s--){let i=e[s],o;if(t>0&&(o=r.lastChild)&&o instanceof On&&o.mark.eq(i))r=o,t--;else{let a=On.of(i,(n=this.cache.find(On,l=>l.mark.eq(i)))===null||n===void 0?void 0:n.dom);r.append(a),r=a,t=0}}return r}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!VS(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(ue.ios&&VS(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(uB,0,32)||new Gl(uB.toDOM(),0,uB,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to<this.pos&&this.wrappers.splice(e,1);for(let e=this.blockWrappers;e.value&&e.from<=this.pos;e.next())if(e.to>=this.pos){let t=e.rank*102+e.value.rank,n=new vQ(e.from,e.to,e.value,t),r=this.wrappers.length;for(;r>0&&(this.wrappers[r-1].rank-n.rank||this.wrappers[r-1].to-n.to)<0;)r--;this.wrappers.splice(r,0,n)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let t=this.root;for(let n of this.wrappers){let r=t.lastChild;if(n.from<this.pos&&r instanceof Ti&&r.wrapper.eq(n.wrapper))t=r;else{let s=Ti.of(n.wrapper,(e=this.cache.find(Ti,i=>i.wrapper.eq(n.wrapper)))===null||e===void 0?void 0:e.dom);t.append(s),t=s}}return t}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let t=2|(e<0?16:32),n=this.cache.find(_d,void 0,1);return n&&(n.flags=t),n||new _d(t)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}},bQ=class{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:r,lineBreak:s,done:i}=this.cursor.next(this.skipCount);if(this.skipCount=0,i)throw new Error("Ran out of text content when drawing inline views");this.text=r;let o=this.textOff=Math.min(e,r.length);return s?null:r.slice(0,o)}let t=Math.min(this.text.length,this.textOff+e),n=this.text.slice(this.textOff,t);return this.textOff=t,n}},Fd=[Gl,Ld,Fa,On,_d,Ti,Fh];for(let e=0;e<Fd.length;e++)Fd[e].bucket=e;var SQ=class{constructor(e){this.view=e,this.buckets=Fd.map(()=>[]),this.index=Fd.map(()=>0),this.reused=new Map}add(e){let t=e.constructor.bucket,n=this.buckets[t];n.length<6?n.push(e):n[this.index[t]=(this.index[t]+1)%6]=e}find(e,t,n=2){let r=e.bucket,s=this.buckets[r],i=this.index[r];for(let o=0;o<s.length;o++){let a=(o+i)%s.length,l=s[a];if((!t||t(l))&&!this.reused.has(l))return s.splice(a,1),a<i&&this.index[r]--,this.reused.set(l,n),l}return null}findWidget(e,t,n){let r=this.buckets[0];if(r.length)for(let s=0,i=0;;s++){if(s==r.length){if(i)return null;i=1,s=0}let o=r[s];if(!this.reused.has(o)&&(i==0?o.widget.compare(e):o.widget.constructor==e.constructor&&e.updateDOM(o.dom,this.view,o.widget)))return r.splice(s,1),s<this.index[0]&&this.index[0]--,o.widget==e&&o.length==t&&(o.flags&497)==n?(this.reused.set(o,1),o):(this.reused.set(o,2),new Gl(o.dom,t,e,o.flags&-498|n))}}reuse(e){return this.reused.set(e,1),e}maybeReuse(e,t=2){if(!this.reused.has(e))return this.reused.set(e,t),e.dom}clear(){for(let e=0;e<this.buckets.length;e++)this.buckets[e].length=this.index[e]=0}},EQ=class{constructor(e,t,n,r,s){this.view=e,this.decorations=r,this.disallowBlockEffectsFor=s,this.openWidget=!1,this.openMarks=0,this.cache=new SQ(e),this.text=new bQ(e.state.doc),this.builder=new yQ(this.cache,new Fh(e,e.contentDOM),et.iter(n)),this.cache.reused.set(t,2),this.old=new CQ(t),this.reuseWalker={skip:(i,o,a)=>{if(this.cache.add(i),i.isComposite())return!1},enter:i=>this.cache.add(i),leave:()=>{},break:()=>{}}}run(e,t){let n=t&&this.getCompositionContext(t.text);for(let r=0,s=0,i=0;;){let o=i<e.length?e[i++]:null,a=o?o.fromA:this.old.root.length;if(a>r){let l=a-r;this.preserve(l,!i,!o),r=a,s+=l}if(!o)break;t&&o.fromA<=t.range.fromA&&o.toA>=t.range.toA?(this.forward(o.fromA,t.range.fromA,t.range.fromA<t.range.toA?1:-1),this.emit(s,t.range.fromB),this.builder.flushBuffer(),this.cache.clear(),this.builder.addComposition(t,n),this.text.skip(t.range.toB-t.range.fromB),this.forward(t.range.fromA,o.toA),this.emit(t.range.toB,o.toB)):(this.forward(o.fromA,o.toA),this.emit(s,o.toB)),s=o.toB,r=o.toA}return this.builder.curLine&&this.builder.endLine(),this.builder.root}preserve(e,t,n){let r=DQ(this.old),s=this.openMarks;this.old.advance(e,n?1:-1,{skip:(i,o,a)=>{if(i.isWidget())if(this.openWidget)this.builder.continueWidget(a-o);else{let l=a>0||o<i.length?Gl.of(i.widget,this.view,a-o,i.flags&496,this.cache.maybeReuse(i)):this.cache.reuse(i);l.flags&256?(l.flags&=-2,this.builder.addBlockWidget(l)):(this.builder.ensureLine(null),this.builder.addInlineWidget(l,r,s),s=r.length)}else if(i.isText())this.builder.ensureLine(null),!o&&a==i.length&&!this.cache.reused.has(i)?this.builder.addText(i.text,r,s,this.cache.reuse(i)):(this.cache.add(i),this.builder.addText(i.text.slice(o,a),r,s)),s=r.length;else if(i.isLine())i.flags&=-2,this.cache.reused.set(i,1),this.builder.addLine(i);else if(i instanceof _d)this.cache.add(i);else if(i instanceof On)this.builder.ensureLine(null),this.builder.addMark(i,r,s),this.cache.reused.set(i,1),s=r.length;else return!1;this.openWidget=!1},enter:i=>{i.isLine()?this.builder.addLineStart(i.attrs,this.cache.maybeReuse(i)):(this.cache.add(i),i instanceof On&&r.unshift(i.mark)),this.openWidget=!1},leave:i=>{i.isLine()?r.length&&(r.length=s=0):i instanceof On&&(r.shift(),s=Math.min(s,r.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,t){let n=null,r=this.builder,s=-1,i=et.spans(this.decorations,e,t,{point:(o,a,l,c,u,d)=>{if(l instanceof Fl){if(this.disallowBlockEffectsFor[d]){if(l.block)throw new RangeError("Block decorations may not be specified via plugins");if(a>this.view.state.doc.lineAt(o).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(s=c.length,u>c.length)r.continueWidget(a-o);else{let h=l.widget||(l.block?Uo.block:Uo.inline),f=xQ(l),B=this.cache.findWidget(h,a-o,f)||Gl.of(h,this.view,a-o,f);l.block?(l.startSide>0&&r.addLineStartIfNotCovered(n),r.addBlockWidget(B)):(r.ensureLine(n),r.addInlineWidget(B,c,u))}n=null}else n=wQ(n,l);a>o&&this.text.skip(a-o)},span:(o,a,l,c)=>{for(let u=o;u<a;){let d=this.text.next(Math.min(512,a-u));d==null?(r.addLineStartIfNotCovered(n),r.addBreak(),u++):(r.ensureLine(n),r.addText(d,l,u==o?c:l.length),u+=d.length),n=null}s=l.length}});s>-1&&(this.openWidget=i>s),this.openWidget||r.addLineStartIfNotCovered(n),this.openMarks=i}forward(e,t,n=1){t-e<=10?this.old.advance(t-e,n,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(t-e-10,-1),this.old.advance(5,n,this.reuseWalker))}getCompositionContext(e){let t=[],n=null;for(let r=e.parentNode;;r=r.parentNode){let s=ht.get(r);if(r==this.view.contentDOM)break;s instanceof On?t.push(s):s?.isLine()?n=s:s instanceof Ti||(r.nodeName=="DIV"&&!n?n=new Ld(r,kR):n||t.push(On.of(new av({tagName:r.nodeName.toLowerCase(),attributes:X9(r)}),r)))}return n?{line:n,marks:t}:null}};function VS(e,t){let n=r=>{for(let s of r.children)if((t?s.isText():s.length)||n(s))return!0;return!1};return n(e)}function xQ(e){let t=e.isReplace?(e.startSide<0?64:0)|(e.endSide>0?128:0):e.startSide>0?32:16;return e.block&&(t|=256),t}var kR={class:"cm-line"};function wQ(e,t){let n=t.spec.attributes,r=t.spec.class;return!n&&!r||(e||(e={class:"cm-line"}),n&&iv(n,e),r&&(e.class+=" "+r)),e}function DQ(e){let t=[];for(let n=e.parents.length;n>1;n--){let r=n==e.parents.length?e.tile:e.parents[n].tile;r instanceof On&&t.push(r.mark)}return t}function cB(e){let t=ht.get(e);return t&&t.setDOM(e.cloneNode()),e}var Uo=class extends Ph{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}};Uo.inline=new Uo("span");Uo.block=new Uo("div");var uB=new class extends Ph{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}},US=class{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=rt.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new Fh(e,e.contentDOM),this.updateInner([new rs(0,0,0,e.state.doc.length)],null)}update(e){var t;let n=e.changedRanges;this.minWidth>0&&n.length&&(n.every(({fromA:c,toA:u})=>u<this.minWidthFrom||c>this.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let r=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((t=this.domChanged)===null||t===void 0)&&t.newSel?r=this.domChanged.newSel.head:!PQ(e.changes,this.hasComposition)&&!e.selectionSet&&(r=e.state.selection.main.head));let s=r>-1?AQ(this.view,e.changes,r):null;if(this.domChanged=null,this.hasComposition){let{from:c,to:u}=this.hasComposition;n=new rs(c,u,e.changes.mapPos(c,-1),e.changes.mapPos(u,1)).addToSet(n.slice())}this.hasComposition=s?{from:s.range.fromB,to:s.range.toB}:null,(ue.ie||ue.chrome)&&!s&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let i=this.decorations,o=this.blockWrappers;this.updateDeco();let a=RQ(i,this.decorations,e.changes);a.length&&(n=rs.extendWithRanges(n,a));let l=MQ(o,this.blockWrappers,e.changes);return l.length&&(n=rs.extendWithRanges(n,l)),s&&!n.some(c=>c.fromA<=s.range.fromA&&c.toA>=s.range.toA)&&(n=s.range.addToSet(n.slice())),this.tile.flags&2&&n.length==0?!1:(this.updateInner(n,s),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t){this.view.viewState.mustMeasureContent=!0;let{observer:n}=this.view;n.ignore(()=>{if(t||e.length){let i=this.tile,o=new EQ(this.view,i,this.blockWrappers,this.decorations,this.dynamicDecorationMap);t&&ht.get(t.text)&&o.cache.reused.set(ht.get(t.text),2),this.tile=o.run(e,t),jm(i,o.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let s=ue.chrome||ue.ios?{node:n.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(s),s&&(s.written||n.selectionRange.focusNode!=s.node||!this.tile.dom.contains(s.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let r=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let s of this.tile.children)s.isWidget()&&s.widget instanceof dB&&r.push(s.dom);n.updateGaps(r)}updateEditContextFormatting(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);for(let t of e.transactions)for(let n of t.effects)n.is(CR)&&(this.editContextFormatting=n.value)}updateSelection(e=!1,t=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let{dom:n}=this.tile,r=this.view.root.activeElement,s=r==n,i=!s&&!(this.view.state.facet(Yr)||n.tabIndex>-1)&&ol(n,this.view.observer.selectionRange)&&!(r&&n.contains(r));if(!(s||t||i))return;let o=this.forceSelection;this.forceSelection=!1;let a=this.view.state.selection.main,l,c;if(a.empty?c=l=this.inlineDOMNearPos(a.anchor,a.assoc||1):(c=this.inlineDOMNearPos(a.head,a.head==a.from?1:-1),l=this.inlineDOMNearPos(a.anchor,a.anchor==a.from?1:-1)),ue.gecko&&a.empty&&!this.hasComposition&&TQ(l)){let d=document.createTextNode("");this.view.observer.ignore(()=>l.node.insertBefore(d,l.node.childNodes[l.offset]||null)),l=c=new Ls(d,0),o=!0}let u=this.view.observer.selectionRange;(o||!u.focusNode||(!al(l.node,l.offset,u.anchorNode,u.anchorOffset)||!al(c.node,c.offset,u.focusNode,u.focusOffset))&&!this.suppressWidgetCursorChange(u,a))&&(this.view.observer.ignore(()=>{ue.android&&ue.chrome&&n.contains(u.focusNode)&&NQ(u.focusNode,n)&&(n.blur(),n.focus({preventScroll:!0}));let d=Hl(this.view.root);if(d)if(a.empty){if(ue.gecko){let h=IQ(l.node,l.offset);if(h&&h!=3){let f=(h==1?nR:rR)(l.node,l.offset);f&&(l=new Ls(f.node,f.offset))}}d.collapse(l.node,l.offset),a.bidiLevel!=null&&d.caretBidiLevel!==void 0&&(d.caretBidiLevel=a.bidiLevel)}else if(d.extend){d.collapse(l.node,l.offset);try{d.extend(c.node,c.offset)}catch{}}else{let h=document.createRange();a.anchor>a.head&&([l,c]=[c,l]),h.setEnd(c.node,c.offset),h.setStart(l.node,l.offset),d.removeAllRanges(),d.addRange(h)}i&&this.view.root.activeElement==n&&(n.blur(),r&&r.focus())}),this.view.observer.setSelectionRange(l,c)),this.impreciseAnchor=l.precise?null:new Ls(u.anchorNode,u.anchorOffset),this.impreciseHead=c.precise?null:new Ls(u.focusNode,u.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&al(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,n=Hl(e.root),{anchorNode:r,anchorOffset:s}=e.observer.selectionRange;if(!n||!t.empty||!t.assoc||!n.modify)return;let i=this.lineAt(t.head,t.assoc);if(!i)return;let o=i.posAtStart;if(t.head==o||t.head==o+i.length)return;let a=this.coordsAt(t.head,-1),l=this.coordsAt(t.head,1);if(!a||!l||a.bottom>l.top)return;let c=this.domAtPos(t.head+t.assoc,t.assoc);n.collapse(c.node,c.offset),n.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let u=e.observer.selectionRange;e.docView.posFromDOM(u.anchorNode,u.anchorOffset)!=t.from&&n.collapse(r,s)}posFromDOM(e,t){let n=this.tile.nearest(e);if(!n)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let r=n.posAtStart;if(n.isComposite()){let s;if(e==n.dom)s=n.dom.childNodes[t];else{let i=hs(e)==0?0:t==0?-1:1;for(;;){let o=e.parentNode;if(o==n.dom)break;i==0&&o.firstChild!=o.lastChild&&(e==o.firstChild?i=-1:i=1),e=o}i<0?s=e:s=e.nextSibling}if(s==n.dom.firstChild)return r;for(;s&&!ht.get(s);)s=s.nextSibling;if(!s)return r+n.length;for(let i=0,o=r;;i++){let a=n.children[i];if(a.dom==s)return o;o+=a.length+a.breakAfter}}else return n.isText()?e==n.dom?r+t:r+(t?n.length:0):r}domAtPos(e,t){let{tile:n,offset:r}=this.tile.resolveBlock(e,t);return n.isWidget()?n.domPosFor(r,t):n.domIn(r,t)}inlineDOMNearPos(e,t){let n,r=-1,s=!1,i,o=-1,a=!1;return this.tile.blockTiles((l,c)=>{if(l.isWidget()){if(l.flags&32&&c>=e)return!0;l.flags&16&&(s=!0)}else{let u=c+l.length;if(c<=e&&(n=l,r=e-c,s=u<e),u>=e&&!i&&(i=l,o=e-c,a=c>e),c>e&&i)return!0}}),!n&&!i?this.domAtPos(e,t):(s&&i?n=null:a&&n&&(i=null),n&&t<0||!i?n.domIn(r,t):i.domIn(o,t))}coordsAt(e,t,n){let{tile:r,offset:s}=this.tile.resolveBlock(e,t);return r.isWidget()?r.widget instanceof dB?null:r.coordsInWidget(s,t,!0):r.coordsIn(s,t,n)}lineAt(e,t){let{tile:n}=this.tile.resolveBlock(e,t);return n.isLine()?n:null}coordsForChar(e){let{tile:t,offset:n}=this.tile.resolveBlock(e,1);if(!t.isLine())return null;function r(s,i){if(s.isComposite())for(let o of s.children){if(o.length>=i){let a=r(o,i);if(a)return a}if(i-=o.length,i<0)break}else if(s.isText()&&i<s.length){let o=Wt(s.text,i);if(o==i)return null;let a=jl(s.dom,i,o).getClientRects();for(let l=0;l<a.length;l++){let c=a[l];if(l==a.length-1||c.top<c.bottom&&c.left<c.right)return c}}return null}return r(t,n)}measureVisibleLineHeights(e){let t=[],{from:n,to:r}=e,s=this.view.contentDOM.clientWidth,i=s>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,o=-1,a=this.view.textDirection==nt.LTR,l=0,c=(u,d,h)=>{for(let f=0;f<u.children.length&&!(d>r);f++){let B=u.children[f],g=d+B.length,C=B.dom.getBoundingClientRect(),{height:v}=C;if(h&&!f&&(l+=C.top-h.top),B instanceof Ti)g>n&&c(B,d,C);else if(d>=n&&(l>0&&t.push(-l),t.push(v+l),l=0,i)){let y=B.dom.lastChild,b=y?Xu(y):[];if(b.length){let E=b[b.length-1],w=a?E.right-C.left:C.right-E.left;w>o&&(o=w,this.minWidth=s,this.minWidthFrom=d,this.minWidthTo=g)}}h&&f==u.children.length-1&&(l+=h.bottom-C.bottom),d=g+B.breakAfter}};return c(this.tile,0,null),t}textDirectionAt(e){let{tile:t}=this.tile.resolveBlock(e,1);return getComputedStyle(t.dom).direction=="rtl"?nt.RTL:nt.LTR}measureTextSize(){let e=this.tile.blockTiles(i=>{if(i.isLine()&&i.children.length&&i.length<=20){let o=0,a;for(let l of i.children){if(!l.isText()||/[^ -~]/.test(l.text))return;let c=Xu(l.dom);if(c.length!=1)return;o+=c[0].width,a=c[0].height}if(o)return{lineHeight:i.dom.getBoundingClientRect().height,charWidth:o/i.length,textHeight:a}}});if(e)return e;let t=document.createElement("div"),n,r,s;return t.className="cm-line",t.style.width="99999px",t.style.position="absolute",t.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(t);let i=Xu(t.firstChild)[0];n=t.getBoundingClientRect().height,r=i&&i.width?i.width/27:7,s=i&&i.height?i.height:n,t.remove()}),{lineHeight:n,charWidth:r,textHeight:s}}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let n=0,r=0;;r++){let s=r==t.viewports.length?null:t.viewports[r],i=s?s.from-1:this.view.state.doc.length;if(i>n){let o=(t.lineBlockAt(i).bottom-t.lineBlockAt(n).top)/this.view.scaleY;e.push(rt.replace({widget:new dB(o),block:!0,inclusive:!0,isBlockGap:!0}).range(n,i))}if(!s)break;n=s.to+1}return rt.set(e)}updateDeco(){let e=1,t=this.view.state.facet(Lh).map(s=>(this.dynamicDecorationMap[e++]=typeof s=="function")?s(this.view):s),n=!1,r=this.view.state.facet(fv).map((s,i)=>{let o=typeof s=="function";return o&&(n=!0),o?s(this.view):s});for(r.length&&(this.dynamicDecorationMap[e++]=n,t.push(et.join(r))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e<this.decorations.length;)this.dynamicDecorationMap[e++]=!1;this.blockWrappers=this.view.state.facet(yR).map(s=>typeof s=="function"?s(this.view):s)}scrollIntoView(e){if(e.isSnapshot){let l=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=l.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let l of this.view.state.facet(gR))try{if(l(this.view,e.range,e))return!0}catch(c){Rr(this.view.state,c,"scroll handler")}let{range:t}=e,n=this.coordsAt(t.head,t.assoc||(t.head>t.anchor?-1:1)),r;if(!n)return;!t.empty&&(r=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(n={left:Math.min(n.left,r.left),top:Math.min(n.top,r.top),right:Math.max(n.right,r.right),bottom:Math.max(n.bottom,r.bottom)});let s=ER(this.view),i={left:n.left-s.left,top:n.top-s.top,right:n.right+s.right,bottom:n.bottom+s.bottom},{offsetWidth:o,offsetHeight:a}=this.view.scrollDOM;if(tQ(this.view.scrollDOM,i,t.head<t.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,o),-o),Math.max(Math.min(e.yMargin,a),-a),this.view.textDirection==nt.LTR),window.visualViewport&&window.innerHeight-window.visualViewport.height>1&&(n.top>window.visualViewport.offsetTop+window.visualViewport.height||n.bottom<window.visualViewport.offsetTop)){let l=this.view.docView.lineAt(t.head,1);if(l){let c=Xk(l.dom);l.dom.scrollIntoView({block:"nearest"}),Zk(c,!1)}}}lineHasWidget(e){let t=n=>n.isWidget()||n.children.some(t);return t(this.tile.resolveBlock(e,1).tile)}destroy(){jm(this.tile)}};function jm(e,t){let n=t?.get(e);if(n!=1){n==null&&e.destroy();for(let r of e.children)jm(r,t)}}function TQ(e){return e.node.nodeType==1&&e.node.firstChild&&(e.offset==0||e.node.childNodes[e.offset-1].contentEditable=="false")&&(e.offset==e.node.childNodes.length||e.node.childNodes[e.offset].contentEditable=="false")}function RR(e,t){let n=e.observer.selectionRange;if(!n.focusNode)return null;let r=nR(n.focusNode,n.focusOffset),s=rR(n.focusNode,n.focusOffset),i=r||s;if(s&&r&&s.node!=r.node){let a=ht.get(s.node);if(!a||a.isText()&&a.text!=s.node.nodeValue)i=s;else if(e.docView.lastCompositionAfterCursor){let l=ht.get(r.node);!l||l.isText()&&l.text!=r.node.nodeValue||(i=s)}}if(e.docView.lastCompositionAfterCursor=i!=r,!i)return null;let o=t-i.offset;return{from:o,to:o+i.node.nodeValue.length,node:i.node}}function AQ(e,t,n){let r=RR(e,n);if(!r)return null;let{node:s,from:i,to:o}=r,a=s.nodeValue;if(/[\n\r]/.test(a)||e.state.doc.sliceString(r.from,r.to)!=a)return null;let l=t.invertedDesc;return{range:new rs(l.mapPos(i),l.mapPos(o),i,o),text:s}}function IQ(e,t){return e.nodeType!=1?0:(t&&e.childNodes[t-1].contentEditable=="false"?1:0)|(t<e.childNodes.length&&e.childNodes[t].contentEditable=="false"?2:0)}var kQ=class{constructor(){this.changes=[]}compareRange(t,n){Ao(t,n,this.changes)}comparePoint(t,n){Ao(t,n,this.changes)}boundChange(t){Ao(t,t,this.changes)}};function RQ(e,t,n){let r=new kQ;return et.compare(e,t,n,r),r.changes}var OQ=class{constructor(){this.changes=[]}compareRange(e,t){Ao(e,t,this.changes)}comparePoint(){}boundChange(e){Ao(e,e,this.changes)}};function MQ(e,t,n){let r=new OQ;return et.compare(e,t,n,r),r.changes}function NQ(e,t){for(let n=e;n&&n!=t;n=n.assignedSlot||n.parentNode)if(n.nodeType==1&&n.contentEditable=="false")return!0;return!1}function PQ(e,t){let n=!1;return t&&e.iterChangedRanges((r,s)=>{r<t.to&&s>t.from&&(n=!0)}),n}var dB=class extends Ph{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}};function LQ(e,t,n=1){let r=e.charCategorizer(t),s=e.doc.lineAt(t),i=t-s.from;if(s.length==0)return se.cursor(t);i==0?n=1:i==s.length&&(n=-1);let o=i,a=i;n<0?o=Wt(s.text,i,!1):a=Wt(s.text,i);let l=r(s.text.slice(o,a));for(;o>0;){let c=Wt(s.text,o,!1);if(r(s.text.slice(c,o))!=l)break;o=c}for(;a<s.length;){let c=Wt(s.text,a);if(r(s.text.slice(a,c))!=l)break;a=c}return se.undirectionalRange(o+s.from,a+s.from)}function _Q(e,t,n,r,s){let i=Math.round((r-t.left)*e.defaultCharacterWidth);if(e.lineWrapping&&n.height>e.defaultLineHeight*1.5){let a=e.viewState.heightOracle.textHeight,l=Math.floor((s-n.top-(e.defaultLineHeight-a)*.5)/a);i+=l*e.viewState.heightOracle.lineLength}let o=e.state.sliceDoc(n.from,n.to);return n.from+W9(o,i,e.state.tabSize)}function Gm(e,t,n){let r=e.lineBlockAt(t);if(Array.isArray(r.type)){let s;for(let i of r.type){if(i.from>t)break;if(!(i.to<t)){if(i.from<t&&i.to>t)return i;(!s||i.type==Gt.Text&&(s.type!=i.type||(n<0?i.from<t:i.to>t)))&&(s=i)}}return s||r}return r}function FQ(e,t,n,r){let s=Gm(e,t.head,t.assoc||-1),i=!r||s.type!=Gt.Text||!(e.lineWrapping||s.widgetLineBreaks)?null:e.coordsAtPos(t.assoc<0&&t.head>s.from?t.head-1:t.head);if(i){let o=e.dom.getBoundingClientRect(),a=e.textDirectionAt(s.from),l=e.posAtCoords({x:n==(a==nt.LTR)?o.right-1:o.left+1,y:(i.top+i.bottom)/2});if(l!=null)return se.cursor(l,n?-1:1)}return se.cursor(n?s.to:s.from,n?-1:1)}function zS(e,t,n,r){let s=e.state.doc.lineAt(t.head),i=e.bidiSpans(s),o=e.textDirectionAt(s.from);for(let a=t,l=null;;){let c=hQ(s,i,o,a,n),u=lR;if(!c){if(s.number==(n?e.state.doc.lines:1))return a;u=`
76
+ `,s=e.state.doc.line(s.number+(n?1:-1)),i=e.bidiSpans(s),c=n?se.cursor(s.from,-1):se.cursor(s.to,1)}if(l){if(!l(u))return a}else{if(!r)return c;l=r(u)}a=c}}function HQ(e,t,n){let r=e.state.charCategorizer(t),s=r(n);return i=>{let o=r(i);return s==ns.Space&&(s=o),s==o}}function jQ(e,t,n,r){let s=t.head,i=n?1:-1;if(s==(n?e.state.doc.length:0))return se.cursor(s,t.assoc);let o=t.goalColumn,a,l=e.contentDOM.getBoundingClientRect(),c=e.coordsAtPos(s,t.assoc||((t.empty?n:t.head==t.from)?1:-1)),u=e.documentTop;if(c)o==null&&(o=c.left-l.left),a=i<0?c.top:c.bottom;else{let B=e.viewState.lineBlockAt(s);o==null&&(o=Math.min(l.right-l.left,e.defaultCharacterWidth*(s-B.from))),a=(i<0?B.top:B.bottom)+u}let d=l.left+o,h=e.viewState.heightOracle.textHeight>>1,f=r??h;for(let B=0;;B+=h){let g=a+(f+B)*i,C=Vm(e,{x:d,y:g},!1,i);if(n?g>l.bottom:g<l.top)return se.cursor(C.pos,C.assoc);let v=e.coordsAtPos(C.pos,C.assoc),y=v?(v.top+v.bottom)/2:0;if(!v||(n?y>a:y<a))return se.cursor(C.pos,C.assoc,void 0,o)}}function ll(e,t,n){for(;;){let r=0;for(let s of e)s.between(t-1,t+1,(i,o,a)=>{if(t>i&&t<o){let l=r||n||(t-i<o-t?-1:1);t=l<0?i:o,r=l}});if(!r)return t}}function OR(e,t){let n=null;for(let r=0;r<t.ranges.length;r++){let s=t.ranges[r],i=null;if(s.empty){let o=ll(e,s.from,0);o!=s.from&&(i=se.cursor(o,-1))}else{let o=ll(e,s.from,-1),a=ll(e,s.to,1);(o!=s.from||a!=s.to)&&(s.undirectional?i=se.undirectionalRange(s.from,s.to):i=se.range(s.from==s.anchor?o:a,s.from==s.head?o:a))}i&&(n||(n=t.ranges.slice()),n[r]=i)}return n?se.create(n,t.mainIndex):t}function hB(e,t,n){let r=ll(e.state.facet(Cc).map(s=>s(e)),n.from,t.head>n.from?-1:1);return r==n.from?n:se.cursor(r,r<n.from?1:-1)}var Tr=class{constructor(e,t){this.pos=e,this.assoc=t}};function Vm(e,t,n,r){let s=e.contentDOM.getBoundingClientRect(),i=s.top+e.viewState.paddingTop,{x:o,y:a}=t,l=a-i,c;for(;;){if(l<0)return new Tr(0,1);if(l>e.viewState.docHeight)return new Tr(e.state.doc.length,-1);if(c=e.elementAtHeight(l),r==null)break;if(c.type==Gt.Text){if(r<0?c.to<e.viewport.from:c.from>e.viewport.to)break;let h=e.docView.coordsAt(r<0?c.from:c.to,r>0?-1:1);if(h&&(r<0?h.top<=l+i:h.bottom>=l+i))break}let d=e.viewState.heightOracle.textHeight/2;l=r>0?c.bottom+d:c.top-d}if(e.viewport.from>=c.to||e.viewport.to<=c.from){if(n)return null;if(c.type==Gt.Text){let d=_Q(e,s,c,o,a);return new Tr(d,d==c.from?1:-1)}}if(c.type!=Gt.Text)return l<(c.top+c.bottom)/2?new Tr(c.from,1):new Tr(c.to,-1);let u=e.docView.lineAt(c.from,2);return(!u||u.length!=c.length)&&(u=e.docView.lineAt(c.from,-2)),new GQ(e,o,a,e.textDirectionAt(c.from)).scanTile(u,c.from)}var GQ=class{constructor(e,t,n,r){this.view=e,this.x=t,this.y=n,this.baseDir=r,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to<e)&&(this.line=this.view.state.doc.lineAt(e),this.spans=this.view.bidiSpans(this.line)),this}baseDirAt(e,t){let{line:n,spans:r}=this.bidiSpansAt(e);return r[kr.find(r,e-n.from,-1,t)].level==this.baseDir}dirAt(e,t){let{line:n,spans:r}=this.bidiSpansAt(e);return r[kr.find(r,e-n.from,-1,t)].dir}bidiIn(e,t){let{spans:n,line:r}=this.bidiSpansAt(e);return n.length>1||n.length&&(n[0].level!=this.baseDir||n[0].to+r.from<t)}scan(e,t,n=!1){let r=0,s=e.length-1,i=new Set,o=this.bidiIn(e[0],e[s]),a,l,c=-1,u=1e9,d;e:for(;r<s;){let f=s-r,B=r+s>>1;t:if(i.has(B)){for(let v=1;v<f;v++){let y=B+v;if(y>=s&&(y-=f),!i.has(y)){B=y;break t}}break e}i.add(B);let g=t(B),C=0;if(g)for(let v=0;v<g.length;v++){let y=g[v];if(!(y.width==0&&g.length>1))if(y.bottom<this.y)(!a||a.bottom<y.bottom)&&(a=y),C=1;else if(y.top>this.y)(!l||l.top>y.top)&&(l=y),C=-1;else{let b=y.left>this.x?this.x-y.left:y.right<this.x?this.x-y.right:0,E=Math.abs(b);E<u&&(c=B,u=E,d=y),b&&(C=b<0==(this.baseDir==nt.LTR)?-1:1)}}C==-1&&(!o||this.baseDirAt(e[B],1))?s=B:C==1&&(!o||this.baseDirAt(e[B+1],-1))&&(r=B+1)}if(!d){if(!l&&!a)return{i:0,after:!1};let f=a&&(!l||this.y-a.bottom<l.top-this.y)?a:l;return this.y=(f.top+f.bottom)/2,this.scan(e,t,!0)}if(u&&!n){let{top:f,bottom:B}=d;if(a&&a.bottom>(f+f+B)/3)return this.y=a.bottom-1,this.scan(e,t,!0);if(l&&l.top<(f+B+B)/3)return this.y=l.top+1,this.scan(e,t,!0)}let h=(o?this.dirAt(e[c],1):this.baseDir)==nt.LTR;return{i:c,after:this.x>(d.left+d.right)/2==h}}scanText(e,t){let n=[];for(let s=0;s<e.length;s=Wt(e.text,s))n.push(t+s);n.push(t+e.length);let r=this.scan(n,s=>{let i=n[s]-t,o=n[s+1]-t;return jl(e.dom,i,o).getClientRects()});return r.after?new Tr(n[r.i+1],-1):new Tr(n[r.i],1)}scanTile(e,t){if(!e.length)return new Tr(t,1);if(e.children.length==1){let o=e.children[0];if(o.isText())return this.scanText(o,t);if(o.isComposite())return this.scanTile(o,t)}let n=[t];for(let o=0,a=t;o<e.children.length;o++)n.push(a+=e.children[o].length);let r=this.scan(n,o=>{let a=e.children[o];return a.flags&48?null:(a.dom.nodeType==1?a.dom:jl(a.dom,0,a.length)).getClientRects()}),s=e.children[r.i],i=n[r.i];return s.isText()?this.scanText(s,i):s.isComposite()?this.scanTile(s,i):r.after?new Tr(n[r.i+1],-1):new Tr(i,1)}},Zu="￿",VQ=class{constructor(e,t){this.points=e,this.view=t,this.text="",this.lineSeparator=t.state.facet(bt.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=Zu}readRange(e,t){if(!e)return this;let n=e.parentNode;for(let r=e;;){this.findPointBefore(n,r);let s=this.text.length;this.readNode(r);let i=ht.get(r),o=r.nextSibling;if(o==t){i?.breakAfter&&!o&&n!=this.view.contentDOM&&this.lineBreak();break}let a=ht.get(o);(i&&a?i.breakAfter:(i?i.breakAfter:Nd(r))||Nd(o)&&(r.nodeName!="BR"||i?.isWidget())&&this.text.length>s)&&!zQ(o,t)&&this.lineBreak(),r=o}return this.findPointBefore(n,t),this}readTextNode(e){let t=e.nodeValue;for(let n of this.points)n.node==e&&(n.pos=this.text.length+Math.min(n.offset,t.length));for(let n=0,r=this.lineSeparator?null:/\r\n?|\n/g;;){let s=-1,i=1,o;if(this.lineSeparator?(s=t.indexOf(this.lineSeparator,n),i=this.lineSeparator.length):(o=r.exec(t))&&(s=o.index,i=o[0].length),this.append(t.slice(n,s<0?t.length:s)),s<0)break;if(this.lineBreak(),i>1)for(let a of this.points)a.node==e&&a.pos>this.text.length&&(a.pos-=i-1);n=s+i}}readNode(e){let t=ht.get(e),n=t&&t.overrideDOMText;if(n!=null){this.findPointInside(e,n.length);for(let r=n.iter();!r.next().done;)r.lineBreak?this.lineBreak():this.append(r.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let n of this.points)n.node==e&&e.childNodes[n.offset]==t&&(n.pos=this.text.length)}findPointInside(e,t){for(let n of this.points)(e.nodeType==3?n.node==e:e.contains(n.node))&&(n.pos=this.text.length+(UQ(e,n.node,n.offset)?t:0))}};function UQ(e,t,n){for(;;){if(!t||n<hs(t))return!1;if(t==e)return!0;n=Ks(t)+1,t=t.parentNode}}function zQ(e,t){let n;for(;!(e==t||!e);e=e.nextSibling){let r=ht.get(e);if(!r?.isWidget())return!1;r&&(n||(n=[])).push(r)}if(n)for(let r of n){let s=r.overrideDOMText;if(s?.length)return!1}return!0}var $S=class{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}},$Q=class{constructor(e,t,n,r){this.typeOver=r,this.bounds=null,this.text="",this.domChanged=t>-1;let{impreciseHead:s,impreciseAnchor:i}=e.docView,o=e.state.selection;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=MR(e.docView.tile,t,n,0))){let a=s||i?[]:qQ(e),l=new VQ(a,e);l.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=l.text,this.newSel=KQ(a,this.bounds.from)}else{let a=e.observer.selectionRange,l=s&&s.node==a.focusNode&&s.offset==a.focusOffset||!Rm(e.contentDOM,a.focusNode)?o.main.head:e.docView.posFromDOM(a.focusNode,a.focusOffset),c=i&&i.node==a.anchorNode&&i.offset==a.anchorOffset||!Rm(e.contentDOM,a.anchorNode)?o.main.anchor:e.docView.posFromDOM(a.anchorNode,a.anchorOffset),u=e.viewport;if((ue.ios||ue.chrome)&&l!=c&&Math.min(l,c)<=o.main.from&&Math.max(l,c)>=o.main.to&&(u.from>0||u.to<e.state.doc.length)){let d=Math.min(l,c),h=Math.max(l,c),f=u.from-d,B=u.to-h;(f==0||f==1||d==0)&&(B==0||B==-1||h==e.state.doc.length)&&(l=0,c=e.state.doc.length)}if(e.inputState.composing>-1&&o.ranges.length>1)this.newSel=o.replaceRange(se.range(c,l));else if(e.lineWrapping&&c==l&&!(o.main.empty&&o.main.head==l)&&e.inputState.lastTouchTime>Date.now()-100){let d=e.coordsAtPos(l,-1),h=0;d&&(h=e.inputState.lastTouchY<=d.bottom?-1:1),this.newSel=se.create([se.cursor(l,h)])}else this.newSel=se.single(c,l)}}};function MR(e,t,n,r){if(e.isComposite()){let s=-1,i=-1,o=-1,a=-1;for(let l=0,c=r,u=r;l<e.children.length;l++){let d=e.children[l],h=c+d.length;if(c<t&&h>n)return MR(d,t,n,c);if(h>=t&&s==-1&&(s=l,i=c),c>n&&d.dom.parentNode==e.dom){o=l,a=u;break}u=h,c=h+d.breakAfter}return{from:i,to:a<0?r+e.length:a,startDOM:(s?e.children[s-1].dom.nextSibling:null)||e.dom.firstChild,endDOM:o<e.children.length&&o>=0?e.children[o].dom:null}}else return e.isText()?{from:r,to:r+e.length,startDOM:e.dom,endDOM:e.dom.nextSibling}:null}function NR(e,t){let n,{newSel:r}=t,{state:s}=e,i=s.selection.main,o=e.inputState.lastKeyTime>Date.now()-100?e.inputState.lastKeyCode:-1;if(t.bounds){let{from:a,to:l}=t.bounds,c=i.from,u=null;(o===8||ue.android&&t.text.length<l-a)&&(c=i.to,u="end");let d=s.doc.sliceString(a,l,Zu),h,f;!i.empty&&i.from>=a&&i.to<=l&&(t.typeOver||d!=t.text)&&d.slice(0,i.from-a)==t.text.slice(0,i.from-a)&&d.slice(i.to-a)==t.text.slice(h=t.text.length-(d.length-(i.to-a)))?n={from:i.from,to:i.to,insert:Fe.of(t.text.slice(i.from-a,h).split(Zu))}:(f=PR(d,t.text,c-a,u))&&(ue.chrome&&o==13&&f.toB==f.from+2&&t.text.slice(f.from,f.toB)=="￿￿"&&f.toB--,n={from:a+f.from,to:a+f.toA,insert:Fe.of(t.text.slice(f.from,f.toB).split(Zu))})}else r&&(!e.hasFocus&&s.facet(Yr)||Hd(r,i))&&(r=null);if(!n&&!r)return!1;if((ue.mac||ue.android)&&n&&n.from==n.to&&n.from==i.head-1&&/^\. ?$/.test(n.insert.toString())&&e.contentDOM.getAttribute("autocorrect")=="off"?(r&&n.insert.length==2&&(r=se.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:Fe.of([n.insert.toString().replace("."," ")])}):s.doc.lineAt(i.from).to<i.to&&e.docView.lineHasWidget(i.to)&&e.inputState.insertingTextAt>Date.now()-50?n={from:i.from,to:i.to,insert:s.toText(e.inputState.insertingText)}:ue.chrome&&n&&n.from==n.to&&n.from==i.head&&n.insert.toString()==`
77
+ `&&e.lineWrapping&&(r&&(r=se.single(r.main.anchor-1,r.main.head-1)),n={from:i.from,to:i.to,insert:Fe.of([" "])}),n)return Bv(e,n,r,o);if(r&&!Hd(r,i)){let a=!1,l="select";return e.inputState.lastSelectionTime>Date.now()-50&&(e.inputState.lastSelectionOrigin=="select"&&(a=!0),l=e.inputState.lastSelectionOrigin,l=="select.pointer"&&(r=OR(s.facet(Cc).map(c=>c(e)),r))),e.dispatch({selection:r,scrollIntoView:a,userEvent:l}),!0}else return!1}function Bv(e,t,n,r=-1){if(ue.ios&&e.inputState.flushIOSKey(t))return!0;let s=e.state.selection.main;if(ue.android&&(t.to==s.to&&(t.from==s.from||t.from==s.from-1&&e.state.sliceDoc(t.from,s.from)==" ")&&t.insert.length==1&&t.insert.lines==2&&Io(e.contentDOM,"Enter",13)||(t.from==s.from-1&&t.to==s.to&&t.insert.length==0||r==8&&t.insert.length<t.to-t.from&&t.to>s.head)&&Io(e.contentDOM,"Backspace",8)||t.from==s.from&&t.to==s.to+1&&t.insert.length==0&&Io(e.contentDOM,"Delete",46)))return!0;let i=t.insert.toString();e.inputState.composing>=0&&e.inputState.composing++;let o,a=()=>o||(o=WQ(e,t,n));return e.state.facet(fR).some(l=>l(e,t.from,t.to,i,a))||e.dispatch(a()),!0}function WQ(e,t,n){let r,s=e.state,i=s.selection.main,o=-1;if(t.from==t.to&&t.from<i.from||t.from>i.to){let l=t.from<i.from?-1:1,c=l<0?i.from:i.to,u=ll(s.facet(Cc).map(d=>d(e)),c,l);t.from==u&&(o=u)}if(o>-1)r={changes:t,selection:se.cursor(t.from+t.insert.length,-1)};else if(t.from>=i.from&&t.to<=i.to&&t.to-t.from>=(i.to-i.from)/3&&(!n||n.main.empty&&n.main.from==t.from+t.insert.length)&&e.inputState.composing<0){let l=i.from<t.from?s.sliceDoc(i.from,t.from):"",c=i.to>t.to?s.sliceDoc(t.to,i.to):"";r=s.replaceSelection(e.state.toText(l+t.insert.sliceString(0,void 0,e.state.lineBreak)+c))}else{let l=s.changes(t),c=n&&n.main.to<=l.newLength?n.main:void 0;if(s.selection.ranges.length>1&&(e.inputState.composing>=0||e.inputState.compositionPendingChange)&&t.to<=i.to+10&&t.to>=i.to-10){let u=e.state.sliceDoc(t.from,t.to),d,h=n&&RR(e,n.main.head);if(h){let B=t.insert.length-(t.to-t.from);d={from:h.from,to:h.to-B}}else d=e.state.doc.lineAt(i.head);let f=i.to-t.to;r=s.changeByRange(B=>{if(B.from==i.from&&B.to==i.to)return{changes:l,range:c||B.map(l)};let g=B.to-f,C=g-u.length;if(e.state.sliceDoc(C,g)!=u||g>=d.from&&C<=d.to)return{range:B};let v=s.changes({from:C,to:g,insert:t.insert}),y=B.to-i.to;return{changes:v,range:c?se.range(Math.max(0,c.anchor+y),Math.max(0,c.head+y)):B.map(v)}})}else r={changes:l,selection:c&&s.selection.replaceRange(c)}}let a="input.type";return(e.composing||e.inputState.compositionPendingChange&&e.inputState.compositionEndedAt>Date.now()-50)&&(e.inputState.compositionPendingChange=!1,a+=".compose",e.inputState.compositionFirstChange&&(a+=".start",e.inputState.compositionFirstChange=!1)),s.update(r,{userEvent:a,scrollIntoView:!0})}function PR(e,t,n,r){let s=Math.min(e.length,t.length),i=0;for(;i<s&&e.charCodeAt(i)==t.charCodeAt(i);)i++;if(i==s&&e.length==t.length)return null;let o=e.length,a=t.length;for(;o>0&&a>0&&e.charCodeAt(o-1)==t.charCodeAt(a-1);)o--,a--;if(r=="end"){let l=Math.max(0,i-Math.min(o,a));n-=o+l-i}if(o<i&&e.length<t.length){let l=n<=i&&n>=o?i-n:0;i-=l,a=i+(a-o),o=i}else if(a<i){let l=n<=i&&n>=a?i-n:0;i-=l,o=i+(o-a),a=i}return{from:i,toA:o,toB:a}}function qQ(e){let t=[];if(e.root.activeElement!=e.contentDOM)return t;let{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:i}=e.observer.selectionRange;return n&&(t.push(new $S(n,r)),(s!=n||i!=r)&&t.push(new $S(s,i))),t}function KQ(e,t){if(e.length==0)return null;let n=e[0].pos,r=e.length==2?e[1].pos:n;return n<0||r<0?null:n==r?se.create([se.cursor(r+t,-1)]):se.single(n+t,r+t)}function Hd(e,t){return t.head==e.main.head&&t.anchor==e.main.anchor}var JQ=class{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,ue.safari&&e.contentDOM.addEventListener("input",()=>null),ue.gecko&&dY(e.contentDOM.ownerDocument)}handleEvent(e){!sY(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,t){let n=this.handlers[e];if(n){for(let r of n.observers)r(this.view,t);for(let r of n.handlers){if(t.defaultPrevented)break;if(r(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=YQ(e),n=this.handlers,r=this.view.contentDOM;for(let s in t)if(s!="scroll"){let i=!t[s].handlers.length,o=n[s];o&&i!=!o.handlers.length&&(r.removeEventListener(s,this.handleEvent),o=null),o||r.addEventListener(s,this.handleEvent,{passive:i})}for(let s in n)s!="scroll"&&!t[s]&&r.removeEventListener(s,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&_R.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),ue.android&&ue.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(ue.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(LR.some(t=>t.keyCode==e.keyCode)&&!e.ctrlKey||XQ.indexOf(e.key)>-1&&e.ctrlKey)){let t={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};t.shiftKey&&ue.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&QQ(this.view.win)&&(t.shiftKey=!1);let n=this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:t};return setTimeout(()=>{this.pendingIOSKey==n&&this.flushIOSKey()},50),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let t=this.pendingIOSKey;return!t||this.view.observer.pendingRecords().length||t.key=="Enter"&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString())?!1:(this.pendingIOSKey=void 0,Io(this.view.contentDOM,t.key,t.keyCode,t.mods))}ignoreDuringComposition(e){return!/^key/.test(e.type)||e.synthetic?!1:this.composing>0?!0:ue.safari&&!ue.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}};function QQ(e){return e.visualViewport?e.visualViewport.height*e.visualViewport.scale/e.document.documentElement.clientHeight<.85:!1}function WS(e,t){return(n,r)=>{try{return t.call(e,r,n)}catch(s){Rr(n.state,s)}}}function YQ(e){let t=Object.create(null);function n(r){return t[r]||(t[r]={observers:[],handlers:[]})}for(let r of e){let s=r.spec,i=s&&s.plugin.domEventHandlers,o=s&&s.plugin.domEventObservers;if(i)for(let a in i){let l=i[a];l&&n(a).handlers.push(WS(r.value,l))}if(o)for(let a in o){let l=o[a];l&&n(a).observers.push(WS(r.value,l))}}for(let r in ur)n(r).handlers.push(ur[r]);for(let r in rn)n(r).observers.push(rn[r]);return t}var LR=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],XQ="dthko",_R=[16,17,18,20,91,92,224,225],ou=6;function au(e){return Math.max(0,e)*.7+8}function ZQ(e,t){return Math.max(Math.abs(e.clientX-t.clientX),Math.abs(e.clientY-t.clientY))}var eY=class{constructor(e,t,n,r){this.view=e,this.startEvent=t,this.style=n,this.mustSelect=r,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=Yk(e.contentDOM),this.atoms=e.state.facet(Cc).map(i=>i(e));let s=e.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(bt.allowMultipleSelections)&&tY(e,t),this.dragging=rY(e,t)&&jR(t)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&ZQ(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,n=0,r=0,s=0,i=this.view.win.innerWidth,o=this.view.win.innerHeight;this.scrollParents.x&&({left:r,right:i}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:s,bottom:o}=this.scrollParents.y.getBoundingClientRect());let a=ER(this.view);e.clientX-a.left<=r+ou?t=-au(r-e.clientX):e.clientX+a.right>=i-ou&&(t=au(e.clientX-i)),e.clientY-a.top<=s+ou?n=-au(s-e.clientY):e.clientY+a.bottom>=o-ou&&(n=au(e.clientY-o)),this.setScrollSpeed(t,n)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:t}=this,n=OR(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!n.eq(t.state.selection,this.dragging===!1))&&this.view.dispatch({selection:n,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(t=>t.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}};function tY(e,t){let n=e.state.facet(cR);return n.length?n[0](t):ue.mac?t.metaKey:t.ctrlKey}function nY(e,t){let n=e.state.facet(uR);return n.length?n[0](t):ue.mac?!t.altKey:!t.ctrlKey}function rY(e,t){let{main:n}=e.state.selection;if(n.empty)return!1;let r=Hl(e.root);if(!r||r.rangeCount==0)return!0;let s=r.getRangeAt(0).getClientRects();for(let i=0;i<s.length;i++){let o=s[i];if(o.left<=t.clientX&&o.right>=t.clientX&&o.top<=t.clientY&&o.bottom>=t.clientY)return!0}return!1}function sY(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target,r;n!=e.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(r=ht.get(n))&&r.isWidget()&&!r.isHidden&&r.widget.ignoreEvent(t))return!1;return!0}var ur=Object.create(null),rn=Object.create(null),FR=ue.ie&&ue.ie_version<15||ue.ios&&ue.webkit_version<604;function iY(e){let t=e.dom.parentNode;if(!t)return;let n=t.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{e.focus(),n.remove(),HR(e,n.value)},50)}function Hh(e,t,n){for(let r of e.facet(t))n=r(n,e);return n}function HR(e,t){t=Hh(e.state,uv,t);let{state:n}=e,r,s=1,i=n.toText(t),o=i.lines==n.selection.ranges.length;if(Um!=null&&n.selection.ranges.every(a=>a.empty)&&Um==i.toString()){let a=-1;r=n.changeByRange(l=>{let c=n.doc.lineAt(l.from);if(c.from==a)return{range:l};a=c.from;let u=n.toText((o?i.line(s++).text:t)+n.lineBreak);return{changes:{from:c.from,insert:u},range:se.cursor(l.from+u.length,-1)}})}else o?r=n.changeByRange(a=>{let l=i.line(s++);return{changes:{from:a.from,to:a.to,insert:l.text},range:se.cursor(a.from+l.length,-1)}}):r=n.replaceSelection(i);e.dispatch(r,{userEvent:"input.paste",scrollIntoView:!0})}rn.scroll=e=>{let t=e.inputState;t.lastScrollTop=e.scrollDOM.scrollTop,t.lastScrollLeft=e.scrollDOM.scrollLeft,ue.ios&&!t.touchActive&&(t.lastIOSMomentumScroll=Date.now())};rn.wheel=rn.mousewheel=e=>{e.inputState.lastWheelEvent=Date.now()};ur.keydown=(e,t)=>(e.inputState.setSelectionOrigin("select"),t.keyCode==27&&e.inputState.tabFocusMode!=0&&(e.inputState.tabFocusMode=Date.now()+2e3),!1);rn.touchstart=(e,t)=>{let n=e.inputState,r=t.targetTouches[0];n.touchActive=!0,n.lastTouchTime=Date.now(),r&&(n.lastTouchX=r.clientX,n.lastTouchY=r.clientY),n.setSelectionOrigin("select.pointer")};rn.touchmove=e=>{e.inputState.setSelectionOrigin("select.pointer")};rn.touchend=(e,t)=>{e.inputState.touchActive=!1};ur.mousedown=(e,t)=>{if(e.observer.flush(),e.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let r of e.state.facet(dR))if(n=r(e,t),n)break;if(!n&&t.button==0&&(n=aY(e,t)),n){let r=!e.hasFocus;e.inputState.startMouseSelection(new eY(e,t,n,r)),r&&e.observer.ignore(()=>{eR(e.contentDOM);let i=e.root.activeElement;i&&!i.contains(e.contentDOM)&&i.blur()});let s=e.inputState.mouseSelection;if(s)return s.start(t),s.dragging===!1}else e.inputState.setSelectionOrigin("select.pointer");return!1};function qS(e,t,n,r){if(r==1)return se.cursor(t,n);if(r==2)return LQ(e.state,t,n);{let s=e.docView.lineAt(t,n),i=e.state.doc.lineAt(s?s.posAtEnd:t),o=s?s.posAtStart:i.from,a=s?s.posAtEnd:i.to;return a<e.state.doc.length&&a==i.to&&a++,se.undirectionalRange(o,a)}}var oY=ue.ie&&ue.ie_version<=11,KS=null,JS=0,QS=0;function jR(e){if(!oY)return e.detail;let t=KS,n=QS;return KS=e,QS=Date.now(),JS=!t||n>Date.now()-400&&Math.abs(t.clientX-e.clientX)<2&&Math.abs(t.clientY-e.clientY)<2?(JS+1)%3:1}function aY(e,t){let n=e.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),r=jR(t),s=e.state.selection;return{update(i){i.docChanged&&(n.pos=i.changes.mapPos(n.pos),s=s.map(i.changes))},get(i,o,a){let l=e.posAndSideAtCoords({x:i.clientX,y:i.clientY},!1),c,u=qS(e,l.pos,l.assoc,r);if(n.pos!=l.pos&&!o){let d=qS(e,n.pos,n.assoc,r),h=Math.min(d.from,u.from),f=Math.max(d.to,u.to);u=h<u.from?se.range(h,f,u.assoc):se.range(f,h,u.assoc)}return o?s.replaceRange(s.main.extend(u.from,u.to,u.assoc)):a&&r==1&&s.ranges.length>1&&(c=lY(s,l.pos))?c:a?s.addRange(u):se.create([u])}}}function lY(e,t){for(let n=0;n<e.ranges.length;n++){let{from:r,to:s}=e.ranges[n];if(r<=t&&s>=t)return se.create(e.ranges.slice(0,n).concat(e.ranges.slice(n+1)),e.mainIndex==n?0:e.mainIndex-(e.mainIndex>n?1:0))}return null}ur.dragstart=(e,t)=>{let{selection:{main:n}}=e.state;if(t.target.draggable){let s=e.docView.tile.nearest(t.target);if(s&&s.isWidget()){let i=s.posAtStart,o=i+s.length;(i>=n.to||o<=n.from)&&(n=se.undirectionalRange(i,o))}}let{inputState:r}=e;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,t.dataTransfer&&(t.dataTransfer.setData("Text",Hh(e.state,dv,e.state.sliceDoc(n.from,n.to))),t.dataTransfer.effectAllowed="copyMove"),!1};ur.dragend=e=>(e.inputState.draggedContent=null,!1);function YS(e,t,n,r){if(n=Hh(e.state,uv,n),!n)return;let s=e.posAtCoords({x:t.clientX,y:t.clientY},!1),{draggedContent:i}=e.inputState,o=r&&i&&nY(e,t)?{from:i.from,to:i.to}:null,a={from:s,insert:n},l=e.state.changes(o?[o,a]:a);e.focus(),e.dispatch({changes:l,selection:{anchor:l.mapPos(s,-1),head:l.mapPos(s,1)},userEvent:o?"move.drop":"input.drop"}),e.inputState.draggedContent=null}ur.drop=(e,t)=>{if(!t.dataTransfer)return!1;if(e.state.readOnly)return!0;let n=t.dataTransfer.files;if(n&&n.length){let r=Array(n.length),s=0,i=()=>{++s==n.length&&YS(e,t,r.filter(o=>o!=null).join(e.state.lineBreak),!1)};for(let o=0;o<n.length;o++){let a=new FileReader;a.onerror=i,a.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(a.result)||(r[o]=a.result),i()},a.readAsText(n[o])}return!0}else{let r=t.dataTransfer.getData("Text");if(r)return YS(e,t,r,!0),!0}return!1};ur.paste=(e,t)=>{if(e.state.readOnly)return!0;e.observer.flush();let n=FR?null:t.clipboardData;return n?(HR(e,n.getData("text/plain")||n.getData("text/uri-list")),!0):(iY(e),!1)};function cY(e,t){let n=e.dom.parentNode;if(!n)return;let r=n.appendChild(document.createElement("textarea"));r.style.cssText="position: fixed; left: -10000px; top: 10px",r.value=t,r.focus(),r.selectionEnd=t.length,r.selectionStart=0,setTimeout(()=>{r.remove(),e.focus()},50)}function uY(e){let t=[],n=[],r=!1;for(let s of e.selection.ranges)s.empty||(t.push(e.sliceDoc(s.from,s.to)),n.push(s));if(!t.length){let s=-1;for(let{from:i}of e.selection.ranges){let o=e.doc.lineAt(i);o.number>s&&(t.push(o.text),n.push({from:o.from,to:Math.min(e.doc.length,o.to+1)})),s=o.number}r=!0}return{text:Hh(e,dv,t.join(e.lineBreak)),ranges:n,linewise:r}}var Um=null;ur.copy=ur.cut=(e,t)=>{if(!ol(e.contentDOM,e.observer.selectionRange))return!1;let{text:n,ranges:r,linewise:s}=uY(e.state);if(!n&&!s)return!1;Um=s?n:null,t.type=="cut"&&!e.state.readOnly&&e.dispatch({changes:r,scrollIntoView:!0,userEvent:"delete.cut"});let i=FR?null:t.clipboardData;return i?(i.clearData(),i.setData("text/plain",n),!0):(cY(e,n),!1)};var GR=Ui.define();function VR(e,t){let n=[];for(let r of e.facet(BR)){let s=r(e,t);s&&n.push(s)}return n.length?e.update({effects:n,annotations:GR.of(!0)}):null}function UR(e){setTimeout(()=>{let t=e.hasFocus;if(t!=e.inputState.notifiedFocused){let n=VR(e.state,t);n?e.dispatch(n):e.update([])}},10)}rn.focus=e=>{e.inputState.lastFocusTime=Date.now(),!e.scrollDOM.scrollTop&&(e.inputState.lastScrollTop||e.inputState.lastScrollLeft)&&(e.scrollDOM.scrollTop=e.inputState.lastScrollTop,e.scrollDOM.scrollLeft=e.inputState.lastScrollLeft),UR(e)};rn.blur=e=>{e.observer.clearSelectionRange(),UR(e)};rn.compositionstart=rn.compositionupdate=e=>{if(!e.observer.editContext&&(e.inputState.compositionFirstChange==null&&(e.inputState.compositionFirstChange=!0),e.inputState.composing<0)){let{main:t}=e.state.selection;!t.empty&&e.lineBlockAt(t.from).from!=e.lineBlockAt(t.to).from&&e.dispatch({changes:e.state.selection.ranges.filter(n=>!n.empty).map(n=>({from:n.from,to:n.to})),userEvent:"input"}),e.inputState.composing=0}};rn.compositionend=e=>{e.observer.editContext||(e.inputState.composing=-1,e.inputState.compositionEndedAt=Date.now(),e.inputState.compositionPendingKey=!0,e.inputState.compositionPendingChange=e.observer.pendingRecords().length>0,e.inputState.compositionFirstChange=null,ue.chrome&&ue.android?e.observer.flushSoon():e.inputState.compositionPendingChange?Promise.resolve().then(()=>e.observer.flush()):setTimeout(()=>{e.inputState.composing<0&&e.docView.hasComposition&&e.update([])},50))};rn.contextmenu=e=>{e.inputState.lastContextMenu=Date.now()};ur.beforeinput=(e,t)=>{var n,r;if((t.inputType=="insertText"||t.inputType=="insertCompositionText")&&(e.inputState.insertingText=t.data,e.inputState.insertingTextAt=Date.now()),t.inputType=="insertReplacementText"&&e.observer.editContext){let i=(n=t.dataTransfer)===null||n===void 0?void 0:n.getData("text/plain"),o=t.getTargetRanges();if(i&&o.length){let a=o[0];return Bv(e,{from:e.posAtDOM(a.startContainer,a.startOffset),to:e.posAtDOM(a.endContainer,a.endOffset),insert:e.state.toText(i)},null),!0}}let s;if(ue.chrome&&ue.android&&(s=LR.find(i=>i.inputType==t.inputType))&&(e.observer.delayAndroidKey(s.key,s.keyCode),s.key=="Backspace"||s.key=="Delete")){let i=((r=window.visualViewport)===null||r===void 0?void 0:r.height)||0;setTimeout(()=>{var o;(((o=window.visualViewport)===null||o===void 0?void 0:o.height)||0)>i+10&&e.hasFocus&&(e.contentDOM.blur(),e.focus())},100)}return ue.ios&&t.inputType=="deleteContentForward"&&e.observer.flushSoon(),ue.safari&&t.inputType=="insertText"&&e.inputState.composing>=0&&setTimeout(()=>rn.compositionend(e,t),20),!1};var XS=new Set;function dY(e){XS.has(e)||(XS.add(e),e.addEventListener("copy",()=>{}),e.addEventListener("cut",()=>{}))}var ZS=["pre-wrap","normal","pre-line","break-spaces"],zo=!1;function eE(){zo=!1}var hY=class{constructor(e){this.lineWrapping=e,this.doc=Fe.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let n=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(n+=Math.max(0,Math.ceil((t-e-n*this.lineLength*.5)/this.lineLength))),this.lineHeight*n}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return ZS.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let n=0;n<e.length;n++){let r=e[n];r<0?n++:this.heightSamples[Math.floor(r*10)]||(t=!0,this.heightSamples[Math.floor(r*10)]=!0)}return t}refresh(e,t,n,r,s,i){let o=ZS.indexOf(e)>-1,a=Math.abs(t-this.lineHeight)>.3||this.lineWrapping!=o;if(this.lineWrapping=o,this.lineHeight=t,this.charWidth=n,this.textHeight=r,this.lineLength=s,a){this.heightSamples={};for(let l=0;l<i.length;l++){let c=i[l];c<0?l++:this.heightSamples[Math.floor(c*10)]=!0}}return a}},fY=class{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}},Xr=class zR{constructor(t,n,r,s,i){this.from=t,this.length=n,this.top=r,this.height=s,this._content=i}get type(){return typeof this._content=="number"?Gt.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof Fl?this._content.widget:null}get widgetLineBreaks(){return typeof this._content=="number"?this._content:0}join(t){let n=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(t._content)?t._content:[t]);return new zR(this.from,this.length+t.length,this.top,this.height+t.height,n)}},Je=(function(e){return e[e.ByPos=0]="ByPos",e[e.ByHeight=1]="ByHeight",e[e.ByPosNoHeight=2]="ByPosNoHeight",e})(Je||(Je={})),ed=.001,or=class td{constructor(t,n,r=2){this.length=t,this.height=n,this.flags=r}get outdated(){return(this.flags&2)>0}set outdated(t){this.flags=(t?2:0)|this.flags&-3}setHeight(t){this.height!=t&&(Math.abs(this.height-t)>ed&&(zo=!0),this.height=t)}replace(t,n,r){return td.of(r)}decomposeLeft(t,n){n.push(this)}decomposeRight(t,n){n.push(this)}applyChanges(t,n,r,s){let i=this,o=r.doc;for(let a=s.length-1;a>=0;a--){let{fromA:l,toA:c,fromB:u,toB:d}=s[a],h=i.lineAt(l,Je.ByPosNoHeight,r.setDoc(n),0,0),f=h.to>=c?h:i.lineAt(c,Je.ByPosNoHeight,r,0,0);for(d+=f.to-c,c=f.to;a>0&&h.from<=s[a-1].toA;)l=s[a-1].fromA,u=s[a-1].fromB,a--,l<h.from&&(h=i.lineAt(l,Je.ByPosNoHeight,r,0,0));u+=h.from-l,l=h.from;let B=gY.build(r.setDoc(o),t,u,d);i=jd(i,i.replace(l,c,B))}return i.updateHeight(r,0)}static empty(){return new xr(0,0,0)}static of(t){if(t.length==1)return t[0];let n=0,r=t.length,s=0,i=0;for(;;)if(n==r)if(s>i*2){let a=t[n-1];a.break?t.splice(--n,1,a.left,null,a.right):t.splice(--n,1,a.left,a.right),r+=1+a.break,s-=a.size}else if(i>s*2){let a=t[r];a.break?t.splice(r,1,a.left,null,a.right):t.splice(r,1,a.left,a.right),r+=2+a.break,i-=a.size}else break;else if(s<i){let a=t[n++];a&&(s+=a.size)}else{let a=t[--r];a&&(i+=a.size)}let o=!1;return t[n-1]==null?(o=!0,n--):t[n]==null&&(o=!0,r++),new pY(td.of(t.slice(0,n)),o,td.of(t.slice(r)))}};function jd(e,t){return e==t?e:(e.constructor!=t.constructor&&(zo=!0),t)}or.prototype.size=1;var BY=rt.replace({}),$R=class extends or{constructor(e,t,n){super(e,t),this.deco=n,this.spaceAbove=0}mainBlock(e,t){return new Xr(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.deco||0)}blockAt(e,t,n,r){return this.spaceAbove&&e<n+this.spaceAbove?new Xr(r,0,n,this.spaceAbove,BY):this.mainBlock(n,r)}lineAt(e,t,n,r,s){let i=this.mainBlock(r,s);return this.spaceAbove?this.blockAt(0,n,r,s).join(i):i}forEachLine(e,t,n,r,s,i){e<=s+this.length&&t>=s&&i(this.lineAt(0,Je.ByPos,n,r,s))}setMeasuredHeight(e){let t=e.heights[e.index++];t<0?(this.spaceAbove=-t,t=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(t)}updateHeight(e,t=0,n=!1,r){return r&&r.from<=t&&r.more&&this.setMeasuredHeight(r),this.outdated=!1,this}toString(){return`block(${this.length})`}},xr=class zm extends $R{constructor(t,n,r){super(t,n,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=r}mainBlock(t,n){return new Xr(n,this.length,t+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(t,n,r){let s=r[0];return r.length==1&&(s instanceof zm||s instanceof ko&&s.flags&4)&&Math.abs(this.length-s.length)<10?(s instanceof ko?s=new zm(s.length,this.height,this.spaceAbove):s.height=this.height,this.outdated||(s.outdated=!1),s):or.of(r)}updateHeight(t,n=0,r=!1,s){return s&&s.from<=n&&s.more?this.setMeasuredHeight(s):(r||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,t.heightForLine(this.length-this.collapsed))+this.breaks*t.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}},ko=class qn extends or{constructor(t){super(t,0)}heightMetrics(t,n){let r=t.doc.lineAt(n).number,s=t.doc.lineAt(n+this.length).number,i=s-r+1,o,a=0;if(t.lineWrapping){let l=Math.min(this.height,t.lineHeight*i);o=l/i,this.length>i+1&&(a=(this.height-l)/(this.length-i-1))}else o=this.height/i;return{firstLine:r,lastLine:s,perLine:o,perChar:a}}blockAt(t,n,r,s){let{firstLine:i,lastLine:o,perLine:a,perChar:l}=this.heightMetrics(n,s);if(n.lineWrapping){let c=s+(t<n.lineHeight?0:Math.round(Math.max(0,Math.min(1,(t-r)/this.height))*this.length)),u=n.doc.lineAt(c),d=a+u.length*l,h=Math.max(r,t-d/2);return new Xr(u.from,u.length,h,d,0)}else{let c=Math.max(0,Math.min(o-i,Math.floor((t-r)/a))),{from:u,length:d}=n.doc.line(i+c);return new Xr(u,d,r+a*c,a,0)}}lineAt(t,n,r,s,i){if(n==Je.ByHeight)return this.blockAt(t,r,s,i);if(n==Je.ByPosNoHeight){let{from:f,to:B}=r.doc.lineAt(t);return new Xr(f,B-f,0,0,0)}let{firstLine:o,perLine:a,perChar:l}=this.heightMetrics(r,i),c=r.doc.lineAt(t),u=a+c.length*l,d=c.number-o,h=s+a*d+l*(c.from-i-d);return new Xr(c.from,c.length,Math.max(s,Math.min(h,s+this.height-u)),u,0)}forEachLine(t,n,r,s,i,o){t=Math.max(t,i),n=Math.min(n,i+this.length);let{firstLine:a,perLine:l,perChar:c}=this.heightMetrics(r,i);for(let u=t,d=s;u<=n;){let h=r.doc.lineAt(u);if(u==t){let B=h.number-a;d+=l*B+c*(t-i-B)}let f=l+c*h.length;o(new Xr(h.from,h.length,d,f,0)),d+=f,u=h.to+1}}replace(t,n,r){let s=this.length-n;if(s>0){let i=r[r.length-1];i instanceof qn?r[r.length-1]=new qn(i.length+s):r.push(null,new qn(s-1))}if(t>0){let i=r[0];i instanceof qn?r[0]=new qn(t+i.length):r.unshift(new qn(t-1),null)}return or.of(r)}decomposeLeft(t,n){n.push(new qn(t-1),null)}decomposeRight(t,n){n.push(null,new qn(this.length-t-1))}updateHeight(t,n=0,r=!1,s){let i=n+this.length;if(s&&s.from<=n+this.length&&s.more){let o=[],a=Math.max(n,s.from),l=-1;for(s.from>n&&o.push(new qn(s.from-n-1).updateHeight(t,n));a<=i&&s.more;){let u=t.doc.lineAt(a).length;o.length&&o.push(null);let d=s.heights[s.index++],h=0;d<0&&(h=-d,d=s.heights[s.index++]),l==-1?l=d:Math.abs(d-l)>=ed&&(l=-2);let f=new xr(u,d,h);f.outdated=!1,o.push(f),a+=u+1}a<=i&&o.push(null,new qn(i-a).updateHeight(t,a));let c=or.of(o);return(l<0||Math.abs(c.height-this.height)>=ed||Math.abs(l-this.heightMetrics(t,n).perLine)>=ed)&&(zo=!0),jd(this,c)}else(r||this.outdated)&&(this.setHeight(t.heightForGap(n,n+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}},pY=class extends or{constructor(e,t,n){super(e.length+(t?1:0)+n.length,e.height+n.height,(t?1:0)|(e.outdated||n.outdated?2:0)),this.left=e,this.right=n,this.size=e.size+n.size}get break(){return this.flags&1}blockAt(e,t,n,r){let s=n+this.left.height;return e<s?this.left.blockAt(e,t,n,r):this.right.blockAt(e,t,s,r+this.left.length+this.break)}lineAt(e,t,n,r,s){let i=r+this.left.height,o=s+this.left.length+this.break,a=t==Je.ByHeight?e<i:e<o,l=a?this.left.lineAt(e,t,n,r,s):this.right.lineAt(e,t,n,i,o);if(this.break||(a?l.to<o:l.from>o))return l;let c=t==Je.ByPosNoHeight?Je.ByPosNoHeight:Je.ByPos;return a?l.join(this.right.lineAt(o,c,n,i,o)):this.left.lineAt(o,c,n,r,s).join(l)}forEachLine(e,t,n,r,s,i){let o=r+this.left.height,a=s+this.left.length+this.break;if(this.break)e<a&&this.left.forEachLine(e,t,n,r,s,i),t>=a&&this.right.forEachLine(e,t,n,o,a,i);else{let l=this.lineAt(a,Je.ByPos,n,r,s);e<l.from&&this.left.forEachLine(e,Math.min(t,l.from-1),n,r,s,i),l.to>=e&&l.from<=t&&i(l),t>l.to&&this.right.forEachLine(Math.max(e,l.to+1),t,n,o,a,i)}}replace(e,t,n){let r=this.left.length+this.break;if(t<r)return this.balanced(this.left.replace(e,t,n),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-r,t-r,n));let s=[];e>0&&this.decomposeLeft(e,s);let i=s.length;for(let o of n)s.push(o);if(e>0&&tE(s,i-1),t<this.length){let o=s.length;this.decomposeRight(t,s),tE(s,o)}return or.of(s)}decomposeLeft(e,t){let n=this.left.length;if(e<=n)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&(n++,e>=n&&t.push(null)),e>n&&this.right.decomposeLeft(e-n,t)}decomposeRight(e,t){let n=this.left.length,r=n+this.break;if(e>=r)return this.right.decomposeRight(e-r,t);e<n&&this.left.decomposeRight(e,t),this.break&&e<r&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?or.of(this.break?[e,null,t]:[e,t]):(this.left=jd(this.left,e),this.right=jd(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,n=!1,r){let{left:s,right:i}=this,o=t+s.length+this.break,a=null;return r&&r.from<=t+s.length&&r.more?a=s=s.updateHeight(e,t,n,r):s.updateHeight(e,t,n),r&&r.from<=o+i.length&&r.more?a=i=i.updateHeight(e,o,n,r):i.updateHeight(e,o,n),a?this.balanced(s,i):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}};function tE(e,t){let n,r;e[t]==null&&(n=e[t-1])instanceof ko&&(r=e[t+1])instanceof ko&&e.splice(t-1,3,new ko(n.length+1+r.length))}var mY=5,gY=class WR{constructor(t,n){this.pos=t,this.oracle=n,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=t}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(t,n){if(this.lineStart>-1){let r=Math.min(n,this.lineEnd),s=this.nodes[this.nodes.length-1];s instanceof xr?s.length+=r-this.pos:(r>this.pos||!this.isCovered)&&this.nodes.push(new xr(r-this.pos,-1,0)),this.writtenTo=r,n>r&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=n}point(t,n,r){if(t<n||r.heightRelevant){let s=r.widget?r.widget.estimatedHeight:0,i=r.widget?r.widget.lineBreaks:0;s<0&&(s=this.oracle.lineHeight);let o=n-t;r.block?this.addBlock(new $R(o,s,r)):(o||i||s>=mY)&&this.addLineDeco(s,i,o)}else n>t&&this.span(t,n);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:t,to:n}=this.oracle.doc.lineAt(this.pos);this.lineStart=t,this.lineEnd=n,this.writtenTo<t&&((this.writtenTo<t-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,t-1)),this.nodes.push(null)),this.pos>t&&this.nodes.push(new xr(this.pos-t,-1,0)),this.writtenTo=this.pos}blankContent(t,n){let r=new ko(n-t);return this.oracle.doc.lineAt(t).to==n&&(r.flags|=4),r}ensureLine(){this.enterLine();let t=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(t instanceof xr)return t;let n=new xr(0,-1,0);return this.nodes.push(n),n}addBlock(t){this.enterLine();let n=t.deco;n&&n.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(t),this.writtenTo=this.pos=this.pos+t.length,n&&n.endSide>0&&(this.covering=t)}addLineDeco(t,n,r){let s=this.ensureLine();s.length+=r,s.collapsed+=r,s.widgetHeight=Math.max(s.widgetHeight,t),s.breaks+=n,this.writtenTo=this.pos=this.pos+r}finish(t){let n=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(n instanceof xr)&&!this.isCovered?this.nodes.push(new xr(0,-1,0)):(this.writtenTo<this.pos||n==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let r=t;for(let s of this.nodes)s instanceof xr&&s.updateHeight(this.oracle,r),r+=s?s.length:1;return this.nodes}static build(t,n,r,s){let i=new WR(r,t);return et.spans(n,r,s,i,0),i.finish(r)}};function CY(e,t,n){let r=new vY;return et.compare(e,t,n,r,0),r.changes}var vY=class{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,n,r){(e<t||n&&n.heightRelevant||r&&r.heightRelevant)&&Ao(e,t,this.changes,5)}};function yY(e,t){let n=e.getBoundingClientRect(),r=e.ownerDocument,s=r.defaultView||window,i=Math.max(0,n.left),o=Math.min(s.innerWidth,n.right),a=Math.max(0,n.top),l=Math.min(s.innerHeight,n.bottom);for(let c=e.parentNode;c&&c!=r.body;)if(c.nodeType==1){let u=c,d=window.getComputedStyle(u);if((u.scrollHeight>u.clientHeight||u.scrollWidth>u.clientWidth)&&d.overflow!="visible"){let h=u.getBoundingClientRect();i=Math.max(i,h.left),o=Math.min(o,h.right),a=Math.max(a,h.top),l=Math.min(c==e.parentNode?s.innerHeight:l,h.bottom)}c=d.position=="absolute"||d.position=="fixed"?u.offsetParent:u.parentNode}else if(c.nodeType==11)c=c.host;else break;return{left:i-n.left,right:Math.max(i,o)-n.left,top:a-(n.top+t),bottom:Math.max(a,l)-(n.top+t)}}function bY(e){let t=e.getBoundingClientRect(),n=e.ownerDocument.defaultView||window;return t.left<n.innerWidth&&t.right>0&&t.top<n.innerHeight&&t.bottom>0}function SY(e,t){let n=e.getBoundingClientRect();return{left:0,right:n.right-n.left,top:t,bottom:n.bottom-(n.top+t)}}var fB=class{constructor(e,t,n,r){this.from=e,this.to=t,this.size=n,this.displaySize=r}static same(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],s=t[n];if(r.from!=s.from||r.to!=s.to||r.size!=s.size)return!1}return!0}draw(e,t){return rt.replace({widget:new EY(this.displaySize*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}},EY=class extends Ph{constructor(e,t){super(),this.size=e,this.vertical=t}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement("div");return this.vertical?e.style.height=this.size+"px":(e.style.width=this.size+"px",e.style.height="2px",e.style.display="inline-block"),e}get estimatedHeight(){return this.vertical?this.size:-1}},nE=class{constructor(e,t){this.view=e,this.state=t,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scaleX=1,this.scaleY=1,this.scrollOffset=0,this.scrolledToBottom=!1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=rE,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=nt.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let n=t.facet(hv).some(r=>typeof r!="function"&&r.class=="cm-lineWrapping");this.heightOracle=new hY(n),this.stateDeco=sE(t),this.heightMap=or.empty().applyChanges(this.stateDeco,Fe.empty,this.heightOracle.setDoc(t.doc),[new rs(0,0,0,t.doc.length)]);for(let r=0;r<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());r++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=rt.set(this.lineGaps.map(r=>r.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let n=0;n<=1;n++){let r=n?t.head:t.anchor;if(!e.some(({from:s,to:i})=>r>=s&&r<=i)){let{from:s,to:i}=this.lineBlockAt(r);e.push(new lu(s,i))}}return this.viewports=e.sort((n,r)=>n.from-r.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?rE:new DY(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(Ha(e,this.scaler))})}update(e,t=null){this.state=e.state;let n=this.stateDeco;this.stateDeco=sE(this.state);let r=e.changedRanges,s=rs.extendWithRanges(r,CY(n,this.stateDeco,e?e.changes:cr.empty(this.state.doc.length))),i=this.heightMap.height,o=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);eE(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),s),(this.heightMap.height!=i||zo)&&(e.flags|=2),o?(this.scrollAnchorPos=e.changes.mapPos(o.from,-1),this.scrollAnchorHeight=o.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=i);let a=s.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.head<a.from||t.range.head>a.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,t));let l=a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,e.flags|=this.updateForViewport(),(l||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(mR)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,t=e.contentDOM,n=window.getComputedStyle(t),r=this.heightOracle,s=n.whiteSpace;this.defaultTextDirection=n.direction=="rtl"?nt.RTL:nt.LTR;let i=this.heightOracle.mustRefreshForWrapping(s)||this.mustMeasureContent==="refresh",o=t.getBoundingClientRect(),a=i||this.mustMeasureContent||this.contentDOMHeight!=o.height;this.contentDOMHeight=o.height,this.mustMeasureContent=!1;let l=0,c=0;if(o.width&&o.height){let{scaleX:E,scaleY:w}=Qk(t,o);(E>.005&&Math.abs(this.scaleX-E)>.005||w>.005&&Math.abs(this.scaleY-w)>.005)&&(this.scaleX=E,this.scaleY=w,l|=16,i=a=!0)}let u=(parseInt(n.paddingTop)||0)*this.scaleY,d=(parseInt(n.paddingBottom)||0)*this.scaleY;(this.paddingTop!=u||this.paddingBottom!=d)&&(this.paddingTop=u,this.paddingBottom=d,l|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(r.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,l|=16);let h=Yk(this.view.contentDOM,!1).y;h!=this.scrollParent&&(this.scrollParent=h,this.scrollAnchorHeight=-1,this.scrollOffset=0);let f=this.getScrollOffset();this.scrollOffset!=f&&(this.scrollAnchorHeight=-1,this.scrollOffset=f),this.scrolledToBottom=tR(this.scrollParent||e.win);let B=(this.printing?SY:yY)(t,this.paddingTop),g=B.top-this.pixelViewport.top,C=B.bottom-this.pixelViewport.bottom;this.pixelViewport=B;let v=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(v!=this.inView&&(this.inView=v,v&&(a=!0)),!this.inView&&!this.scrollTarget&&!bY(e.dom))return 0;let y=o.width;if((this.contentDOMWidth!=y||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=o.width,this.editorHeight=e.scrollDOM.clientHeight,l|=16),a){let E=e.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(E)&&(i=!0),i||r.lineWrapping&&Math.abs(y-this.contentDOMWidth)>r.charWidth){let{lineHeight:w,charWidth:A,textHeight:x}=e.docView.measureTextSize();i=w>0&&r.refresh(s,w,A,x,Math.max(5,y/A),E),i&&(e.docView.minWidth=0,l|=16)}g>0&&C>0?c=Math.max(g,C):g<0&&C<0&&(c=Math.min(g,C)),eE();for(let w of this.viewports){let A=w.from==this.viewport.from?E:e.docView.measureVisibleLineHeights(w);this.heightMap=(i?or.empty().applyChanges(this.stateDeco,Fe.empty,this.heightOracle,[new rs(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,i,new fY(w.from,A))}zo&&(l|=2)}let b=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return b&&(l&2&&(l|=this.updateScaler()),this.viewport=this.getViewport(c,this.scrollTarget),l|=this.updateForViewport()),(l&2||b)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(i?[]:this.lineGaps,e)),l|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),l}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let n=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),r=this.heightMap,s=this.heightOracle,{visibleTop:i,visibleBottom:o}=this,a=new lu(r.lineAt(i-n*1e3,Je.ByHeight,s,0,0).from,r.lineAt(o+(1-n)*1e3,Je.ByHeight,s,0,0).to);if(t){let{head:l}=t.range;if(l<a.from||l>a.to){let c=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),u=r.lineAt(l,Je.ByPos,s,0,0),d;t.y=="center"?d=(u.top+u.bottom)/2-c/2:t.y=="start"||t.y=="nearest"&&l<a.from?d=u.top:d=u.bottom-c,a=new lu(r.lineAt(d-500,Je.ByHeight,s,0,0).from,r.lineAt(d+c+500,Je.ByHeight,s,0,0).to)}}return a}mapViewport(e,t){let n=t.mapPos(e.from,-1),r=t.mapPos(e.to,1);return new lu(this.heightMap.lineAt(n,Je.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(r,Je.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},n=0){if(!this.inView)return!0;let{top:r}=this.heightMap.lineAt(e,Je.ByPos,this.heightOracle,0,0),{bottom:s}=this.heightMap.lineAt(t,Je.ByPos,this.heightOracle,0,0),{visibleTop:i,visibleBottom:o}=this;return(e==0||r<=i-Math.max(10,Math.min(-n,250)))&&(t==this.state.doc.length||s>=o+Math.max(10,Math.min(n,250)))&&r>i-2e3&&s<o+2e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let n=[];for(let r of e)t.touchesRange(r.from,r.to)||n.push(new fB(t.mapPos(r.from),t.mapPos(r.to),r.size,r.displaySize));return n}ensureLineGaps(e,t){let n=this.heightOracle.lineWrapping,r=n?1e4:2e3,s=r>>1,i=r<<1;if(this.defaultTextDirection!=nt.LTR&&!n)return[];let o=[],a=(c,u,d,h)=>{if(u-c<s)return;let f=this.state.selection.main,B=[f.from];f.empty||B.push(f.to);for(let C of B)if(C>c&&C<u){a(c,C-10,d,h),a(C+10,u,d,h);return}let g=wY(e,C=>C.from>=d.from&&C.to<=d.to&&Math.abs(C.from-c)<s&&Math.abs(C.to-u)<s&&!B.some(v=>C.from<v&&C.to>v));if(!g){if(u<d.to&&t&&n&&t.visibleRanges.some(v=>v.from<=u&&v.to>=u)){let v=t.moveToLineBoundary(se.cursor(u),!1,!0).head;v>c&&(u=v)}let C=this.gapSize(d,c,u,h);g=new fB(c,u,C,n||C<2e6?C:2e6)}o.push(g)},l=c=>{if(c.length<i||c.type!=Gt.Text)return;let u=xY(c.from,c.to,this.stateDeco);if(u.total<i)return;let d=this.scrollTarget?this.scrollTarget.range.head:null,h,f;if(n){let B=r/this.heightOracle.lineLength*this.heightOracle.lineHeight,g,C;if(d!=null){let v=uu(u,d),y=((this.visibleBottom-this.visibleTop)/2+B)/c.height;g=v-y,C=v+y}else g=(this.visibleTop-c.top-B)/c.height,C=(this.visibleBottom-c.top+B)/c.height;h=cu(u,g),f=cu(u,C)}else{let B=u.total*this.heightOracle.charWidth,g=r*this.heightOracle.charWidth,C=0;if(B>2e6)for(let w of e)w.from>=c.from&&w.from<c.to&&w.size!=w.displaySize&&w.from*this.heightOracle.charWidth+C<this.pixelViewport.left&&(C=w.size-w.displaySize);let v=this.pixelViewport.left+C,y=this.pixelViewport.right+C,b,E;if(d!=null){let w=uu(u,d),A=((y-v)/2+g)/B;b=w-A,E=w+A}else b=(v-g)/B,E=(y+g)/B;h=cu(u,b),f=cu(u,E)}h>c.from&&a(c.from,h,c,u),f<c.to&&a(f,c.to,c,u)};for(let c of this.viewportLines)Array.isArray(c.type)?c.type.forEach(l):l(c);return o}gapSize(e,t,n,r){let s=uu(r,n)-uu(r,t);return this.heightOracle.lineWrapping?e.height*s:r.total*this.heightOracle.charWidth*s}updateLineGaps(e){fB.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=rt.set(e.map(t=>t.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let n=[];et.spans(t,this.viewport.from,this.viewport.to,{span(s,i){n.push({from:s,to:i})},point(){}},20);let r=0;if(n.length!=this.visibleRanges.length)r=12;else for(let s=0;s<n.length&&!(r&8);s++){let i=this.visibleRanges[s],o=n[s];(i.from!=o.from||i.to!=o.to)&&(r|=4,e&&e.mapPos(i.from,-1)==o.from&&e.mapPos(i.to,1)==o.to||(r|=8))}return this.visibleRanges=n,r}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||Ha(this.heightMap.lineAt(e,Je.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(t=>t.top<=e&&t.bottom>=e)||Ha(this.heightMap.lineAt(this.scaler.fromDOM(e),Je.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop*this.scaleY:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return Ha(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}},lu=class{constructor(e,t){this.from=e,this.to=t}};function xY(e,t,n){let r=[],s=e,i=0;return et.spans(n,e,t,{span(){},point(o,a){o>s&&(r.push({from:s,to:o}),i+=o-s),s=a}},20),s<t&&(r.push({from:s,to:t}),i+=t-s),{total:i,ranges:r}}function cu({total:e,ranges:t},n){if(n<=0)return t[0].from;if(n>=1)return t[t.length-1].to;let r=Math.floor(e*n);for(let s=0;;s++){let{from:i,to:o}=t[s],a=o-i;if(r<=a)return i+r;r-=a}}function uu(e,t){let n=0;for(let{from:r,to:s}of e.ranges){if(t<=s){n+=t-r;break}n+=s-r}return n/e.total}function wY(e,t){for(let n of e)if(t(n))return n}var rE={toDOM(e){return e},fromDOM(e){return e},scale:1,eq(e){return e==this}};function sE(e){let t=e.facet(Lh).filter(r=>typeof r!="function"),n=e.facet(fv).filter(r=>typeof r!="function");return n.length&&t.push(et.join(n)),t}var DY=class qR{constructor(t,n,r){let s=0,i=0,o=0;this.viewports=r.map(({from:a,to:l})=>{let c=n.lineAt(a,Je.ByPos,t,0,0).top,u=n.lineAt(l,Je.ByPos,t,0,0).bottom;return s+=u-c,{from:a,to:l,top:c,bottom:u,domTop:0,domBottom:0}}),this.scale=(7e6-s)/(n.height-s);for(let a of this.viewports)a.domTop=o+(a.top-i)*this.scale,o=a.domBottom=a.domTop+(a.bottom-a.top),i=a.bottom}toDOM(t){for(let n=0,r=0,s=0;;n++){let i=n<this.viewports.length?this.viewports[n]:null;if(!i||t<i.top)return s+(t-r)*this.scale;if(t<=i.bottom)return i.domTop+(t-i.top);r=i.bottom,s=i.domBottom}}fromDOM(t){for(let n=0,r=0,s=0;;n++){let i=n<this.viewports.length?this.viewports[n]:null;if(!i||t<i.domTop)return r+(t-s)/this.scale;if(t<=i.domBottom)return i.top+(t-i.domTop);r=i.bottom,s=i.domBottom}}eq(t){return t instanceof qR?this.scale==t.scale&&this.viewports.length==t.viewports.length&&this.viewports.every((n,r)=>n.from==t.viewports[r].from&&n.to==t.viewports[r].to):!1}};function Ha(e,t){if(t.scale==1)return e;let n=t.toDOM(e.top),r=t.toDOM(e.bottom);return new Xr(e.from,e.length,n,r-n,Array.isArray(e._content)?e._content.map(s=>Ha(s,t)):e._content)}var du=Ce.define({combine:e=>e.join(" ")}),$m=Ce.define({combine:e=>e.indexOf(!0)>-1}),Wm=Ws.newName(),KR=Ws.newName(),JR=Ws.newName(),QR={"&light":"."+KR,"&dark":"."+JR};function qm(e,t,n){return new Ws(t,{finish(r){return/&/.test(r)?r.replace(/&\w*/,s=>{if(s=="&")return e;if(!n||!n[s])throw new RangeError(`Unsupported selector: ${s}`);return n[s]}):e+" "+r}})}var TY=qm("."+Wm,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},".cm-panels-top":{top:"0"},".cm-panels-bottom":{bottom:"0"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{background:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 0) no-repeat",backgroundSize:".4em",backgroundPosition:"calc(min(50%, 0px)) center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},QR),AY={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},BB=ue.ie&&ue.ie_version<=11,IY=class{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new nQ,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let n of t)this.queue.push(n);(ue.ie&&ue.ie_version<=11||ue.ios&&e.composing)&&t.some(n=>n.type=="childList"&&n.removedNodes.length||n.type=="characterData"&&n.oldValue.length>n.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&ue.android&&e.constructor.EDIT_CONTEXT!==!1&&!(ue.chrome&&ue.chrome_version<126)&&(this.editContext=new RY(e),e.state.facet(Yr)&&(e.contentDOM.editContext=this.editContext.editContext)),BB&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var t;((t=this.view.docView)===null||t===void 0?void 0:t.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),typeof IntersectionObserver=="function"&&(this.intersection=new IntersectionObserver(t=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,n)=>t!=e[n]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:n}=this,r=this.selectionRange;if(n.state.facet(Yr)?n.root.activeElement!=this.dom:!ol(this.dom,r))return;let s=r.anchorNode&&n.docView.tile.nearest(r.anchorNode);if(s&&s.isWidget()&&s.widget.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(ue.ie&&ue.ie_version<=11||ue.android&&ue.chrome)&&!n.state.selection.main.empty&&r.focusNode&&al(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=Hl(e.root);if(!t)return!1;let n=ue.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&kY(this.view,t)||t;if(!n||this.selectionRange.eq(n))return!1;let r=ol(this.dom,n);return r&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&sQ(this.dom,n)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(n),r&&(this.selectionChanged=!0),!0)}setSelectionRange(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,t=null;for(let n=this.dom;n;)if(n.nodeType==1)!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==n?e++:t||(t=this.scrollTargets.slice(0,e)),t&&t.push(n),n=n.assignedSlot||n.parentNode;else if(n.nodeType==11)n=n.host;else break;if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let n of this.scrollTargets)n.removeEventListener("scroll",this.onScroll);for(let n of this.scrollTargets=t)n.addEventListener("scroll",this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,AY),BB&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),BB&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){var n;if(!this.delayedAndroidKey){let r=()=>{let s=this.delayedAndroidKey;s&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=s.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&s.force&&Io(this.dom,s.key,s.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(r)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!(!((n=this.delayedAndroidKey)===null||n===void 0)&&n.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,n=-1,r=!1;for(let s of e){let i=this.readMutation(s);i&&(i.typeOver&&(r=!0),t==-1?{from:t,to:n}=i:(t=Math.min(i.from,t),n=Math.max(i.to,n)))}return{from:t,to:n,typeOver:r}}readChange(){let{from:e,to:t,typeOver:n}=this.processRecords(),r=this.selectionChanged&&ol(this.dom,this.selectionRange);if(e<0&&!r)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let s=new $Q(this.view,e,t,n);return this.view.docView.domChanged={newSel:s.newSel?s.newSel.main:null},s}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let n=this.view.state,r=NR(this.view,t);return this.view.state==n&&(t.domChanged||t.newSel&&!Hd(this.view.state.selection,t.newSel.main))&&this.view.update([]),r}readMutation(e){let t=this.view.docView.tile.nearest(e.target);if(!t||t.isWidget())return null;if(t.markDirty(e.type=="attributes"),e.type=="childList"){let n=iE(t,e.previousSibling||e.target.previousSibling,-1),r=iE(t,e.nextSibling||e.target.nextSibling,1);return{from:n?t.posAfter(n):t.posAtStart,to:r?t.posBefore(r):t.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(Yr)!=e.state.facet(Yr)&&(e.view.contentDOM.editContext=e.state.facet(Yr)?this.editContext.editContext:null))}destroy(){var e,t,n;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(t=this.gapIntersection)===null||t===void 0||t.disconnect(),(n=this.resizeScroll)===null||n===void 0||n.disconnect();for(let r of this.scrollTargets)r.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}};function iE(e,t,n){for(;t;){let r=ht.get(t);if(r&&r.parent==e)return r;let s=t.parentNode;t=s!=e.dom?s:n>0?t.nextSibling:t.previousSibling}return null}function oE(e,t){let n=t.startContainer,r=t.startOffset,s=t.endContainer,i=t.endOffset,o=e.docView.domAtPos(e.state.selection.main.anchor,1);return al(o.node,o.offset,s,i)&&([n,r,s,i]=[s,i,n,r]),{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:i}}function kY(e,t){if(t.getComposedRanges){let s=t.getComposedRanges(e.root)[0];if(s)return oE(e,s)}let n=null;function r(s){s.preventDefault(),s.stopImmediatePropagation(),n=s.getTargetRanges()[0]}return e.contentDOM.addEventListener("beforeinput",r,!0),e.dom.ownerDocument.execCommand("indent"),e.contentDOM.removeEventListener("beforeinput",r,!0),n?oE(e,n):null}var RY=class{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=n=>{let r=e.state.selection.main,{anchor:s,head:i}=r,o=this.toEditorPos(n.updateRangeStart),a=this.toEditorPos(n.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:n.updateRangeStart,editorBase:o,drifted:!1});let l=a-o>n.text.length;o==this.from&&s<this.from?o=s:a==this.to&&s>this.to&&(a=s);let c=PR(e.state.sliceDoc(o,a),n.text,(l?r.from:r.to)-o,l?"end":null);if(!c){let d=se.single(this.toEditorPos(n.selectionStart),this.toEditorPos(n.selectionEnd));Hd(d,r)||e.dispatch({selection:d,userEvent:"select"});return}let u={from:c.from+o,to:c.toA+o,insert:Fe.of(n.text.slice(c.from,c.toB).split(`
78
+ `))};if((ue.mac||ue.android)&&u.from==i-1&&/^\. ?$/.test(n.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(u={from:o,to:a,insert:Fe.of([n.text.replace("."," ")])}),this.pendingContextChange=u,!e.state.readOnly){let d=this.to-this.from+(u.to-u.from+u.insert.length);Bv(e,u,se.single(this.toEditorPos(n.selectionStart,d),this.toEditorPos(n.selectionEnd,d)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),u.from<u.to&&!u.insert.length&&e.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,n.updateRangeStart-1),Math.min(t.text.length,n.updateRangeStart+1)))&&this.handlers.compositionend(n)},this.handlers.characterboundsupdate=n=>{let r=[],s=null;for(let i=this.toEditorPos(n.rangeStart),o=this.toEditorPos(n.rangeEnd);i<o;i++){let a=e.coordsForChar(i);s=a&&new DOMRect(a.left,a.top,a.right-a.left,a.bottom-a.top)||s||new DOMRect,r.push(s)}t.updateCharacterBounds(n.rangeStart,r)},this.handlers.textformatupdate=n=>{let r=[];for(let s of n.getTextFormats()){let i=s.underlineStyle,o=s.underlineThickness;if(!/none/i.test(i)&&!/none/i.test(o)){let a=this.toEditorPos(s.rangeStart),l=this.toEditorPos(s.rangeEnd);if(a<l){let c=`text-decoration: underline ${/^[a-z]/.test(i)?i+" ":i=="Dashed"?"dashed ":i=="Squiggle"?"wavy ":""}${/thin/i.test(o)?1:2}px`;r.push(rt.mark({attributes:{style:c}}).range(a,l))}}}e.dispatch({effects:CR.of(rt.set(r))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:n}=this.composing;this.composing=null,n&&this.reset(e.state)}};for(let n in this.handlers)t.addEventListener(n,this.handlers[n]);this.measureReq={read:n=>{let r=Hl(n.root);r&&r.rangeCount&&this.editContext.updateSelectionBounds(r.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,n=!1,r=this.pendingContextChange;return e.changes.iterChanges((s,i,o,a,l)=>{if(n)return;let c=l.length-(i-s);if(r&&i>=r.to)if(r.from==s&&r.to==i&&r.insert.eq(l)){r=this.pendingContextChange=null,t+=c,this.to+=c;return}else r=null,this.revertPending(e.state);if(s+=t,i+=t,i<=this.from)this.from+=c,this.to+=c;else if(s<this.to){if(s<this.from||i>this.to||this.to-this.from+l.length>3e4){n=!0;return}this.editContext.updateText(this.toContextPos(s),this.toContextPos(i),l.toString()),this.to+=c}t+=c}),r&&!n&&this.revertPending(e.state),!n}update(e){let t=this.pendingContextChange,n=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(n.from,n.to)&&e.transactions.some(r=>!r.isUserEvent("input.type")&&r.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,n=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),r=this.toContextPos(t.head);(this.editContext.selectionStart!=n||this.editContext.selectionEnd!=r)&&this.editContext.updateSelection(n,r)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to<e.doc.length&&this.to-t<500||this.to-this.from>3e4)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let n=this.composing;return n&&n.drifted?n.editorBase+(e-n.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}},xe=class nd{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(t={}){var n;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.clearAnnouncement=-1,this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),t.parent&&t.parent.appendChild(this.dom);let{dispatch:r}=t;this.dispatchTransactions=t.dispatchTransactions||r&&(s=>s.forEach(i=>r(i,this)))||(s=>this.update(s)),this.dispatch=this.dispatch.bind(this),this._root=t.root||rQ(t.parent)||document,this.viewState=new nE(this,t.state||bt.create(t)),t.scrollTo&&t.scrollTo.is(iu)&&(this.viewState.scrollTarget=t.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Co).map(s=>new lB(s));for(let s of this.plugins)s.update(this);this.observer=new IY(this),this.inputState=new JQ(this),this.inputState.ensureHandlers(this.plugins),this.docView=new US(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((n=document.fonts)===null||n===void 0)&&n.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...t){let n=t.length==1&&t[0]instanceof ir?t:t.length==1&&Array.isArray(t[0])?t[0]:[this.state.update(...t)];this.dispatchTransactions(n,this)}update(t){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let n=!1,r=!1,s,i=this.state;for(let h of t){if(h.startState!=i)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");i=h.state}if(this.destroyed){this.viewState.state=i;return}let o=this.hasFocus,a=0,l=null;t.some(h=>h.annotation(GR))?(this.inputState.notifiedFocused=o,a=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,l=VR(i,o),l||(a=1));let c=this.observer.delayedAndroidKey,u=null;if(c?(this.observer.clearDelayedAndroidKey(),u=this.observer.readChange(),(u&&!this.state.doc.eq(i.doc)||!this.state.selection.eq(i.selection))&&(u=null)):this.observer.clear(),i.facet(bt.phrases)!=this.state.facet(bt.phrases))return this.setState(i);s=jS.create(this,i,t),s.flags|=a;let d=this.viewState.scrollTarget;try{this.updateState=2;for(let h of t){if(d&&(d=d.map(h.changes)),h.scrollIntoView){let{main:f}=h.state.selection,{x:B,y:g}=this.state.facet(nd.cursorScrollMargin);d=new aB(f.empty?f:se.cursor(f.head,f.head>f.anchor?-1:1),"nearest","nearest",g,B)}for(let f of h.effects)f.is(iu)&&(d=f.value.clip(this.state))}this.viewState.update(s,d),this.bidiCache=lE.update(this.bidiCache,s.changes),s.empty||(this.updatePlugins(s),this.inputState.update(s)),n=this.docView.update(s),this.state.facet(_a)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(n,t.some(h=>h.isUserEvent("select.pointer")))}finally{this.updateState=0}if(s.startState.facet(du)!=s.state.facet(du)&&(this.viewState.mustMeasureContent=!0),(n||r||d||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!s.empty)for(let h of this.state.facet(Lm))try{h(s)}catch(f){Rr(this.state,f,"update listener")}(l||u)&&Promise.resolve().then(()=>{l&&this.state==l.startState&&this.dispatch(l),u&&!NR(this,u)&&c.force&&Io(this.contentDOM,c.key,c.keyCode)})}setState(t){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=t;return}this.updateState=2;let n=this.hasFocus;try{for(let r of this.plugins)r.destroy(this);this.viewState=new nE(this,t),this.plugins=t.facet(Co).map(r=>new lB(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new US(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}n&&this.focus(),this.requestMeasure()}updatePlugins(t){let n=t.startState.facet(Co),r=t.state.facet(Co);if(n!=r){let s=[];for(let i of r){let o=n.indexOf(i);if(o<0)s.push(new lB(i));else{let a=this.plugins[o];a.mustUpdate=t,s.push(a)}}for(let i of this.plugins)i.mustUpdate!=t&&i.destroy(this);this.plugins=s,this.pluginMap.clear()}else for(let s of this.plugins)s.mustUpdate=t;for(let s=0;s<this.plugins.length;s++)this.plugins[s].update(this);n!=r&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let t of this.plugins){let n=t.value;if(n&&n.docViewUpdate)try{n.docViewUpdate(this)}catch(r){Rr(this.state,r,"doc view update listener")}}}measure(t=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,t&&this.observer.forceFlush();let n=null,r=this.viewState.scrollParent,s=this.viewState.getScrollOffset(),{scrollAnchorPos:i,scrollAnchorHeight:o,scaleY:a}=this.viewState;Math.abs(s-this.viewState.scrollOffset)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let l=0;;l++){if(o<0){if(tR(r||this.win))i=-1,o=this.viewState.heightMap.height/this.viewState.scaleY;else{let B=this.viewState.scrollAnchorAt(s);i=B.from,o=B.top}a=this.viewState.scaleY}this.updateState=1;let c=this.viewState.measure();if(!c&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(l>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let u=[];c&4||([this.measureRequests,u]=[u,this.measureRequests]);let d=u.map(B=>{try{return B.read(this)}catch(g){return Rr(this.state,g),aE}}),h=jS.create(this,this.state,[]),f=!1;h.flags|=c,n?n.flags|=c:n=h,this.updateState=2,h.empty||(this.updatePlugins(h),this.inputState.update(h),this.updateAttrs(),f=this.docView.update(h),f&&this.docViewUpdate());for(let B=0;B<u.length;B++)if(d[B]!=aE)try{let g=u[B];g.write&&g.write(d[B],this)}catch(g){Rr(this.state,g)}if(f&&this.docView.updateSelection(!0),!h.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,o=-1;continue}else{let B=(i<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(i).top)/this.viewState.scaleY-o/a;if((B>1||B<-1)&&!(ue.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(r==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){s=s+B,r?i<0?r.scrollTop=r.scrollHeight:r.scrollTop+=B:this.win.scrollBy(0,B),o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(n&&!n.empty)for(let l of this.state.facet(Lm))l(n)}get themeClasses(){return Wm+" "+(this.state.facet($m)?JR:KR)+" "+this.state.facet(du)}updateAttrs(){let t=cE(this,vR,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(Yr)?"true":"false",class:"cm-content",style:`${ue.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),cE(this,hv,n);let r=this.observer.ignore(()=>{let s=PS(this.contentDOM,this.contentAttrs,n),i=PS(this.dom,this.editorAttrs,t);return s||i});return this.editorAttrs=t,this.contentAttrs=n,r}showAnnouncements(t){let n=!0;for(let r of t)for(let s of r.effects)if(s.is(nd.announce)){n&&(this.announceDOM.textContent="",this.win.clearTimeout(this.clearAnnouncement),this.clearAnnouncement=this.win.setTimeout(()=>{this.announceDOM.textContent=" "},200),n=!1);let i=this.announceDOM.appendChild(document.createElement("div"));i.textContent=s.value}}mountStyles(){this.styleModules=this.state.facet(_a);let t=this.state.facet(nd.cspNonce);Ws.mount(this.root,this.styleModules.concat(TY).reverse(),t?{nonce:t}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(t){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),t){if(this.measureRequests.indexOf(t)>-1)return;if(t.key!=null){for(let n=0;n<this.measureRequests.length;n++)if(this.measureRequests[n].key===t.key){this.measureRequests[n]=t;return}}this.measureRequests.push(t)}}plugin(t){let n=this.pluginMap.get(t);return(n===void 0||n&&n.plugin!=t)&&this.pluginMap.set(t,n=this.plugins.find(r=>r.plugin==t)||null),n&&n.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(t){return this.readMeasured(),this.viewState.elementAtHeight(t)}lineBlockAtHeight(t){return this.readMeasured(),this.viewState.lineBlockAtHeight(t)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(t){return this.viewState.lineBlockAt(t)}get contentHeight(){return this.viewState.contentHeight}moveByChar(t,n,r){return hB(this,t,zS(this,t,n,r))}moveByGroup(t,n){return hB(this,t,zS(this,t,n,r=>HQ(this,t.head,r)))}visualLineSide(t,n){return n?se.cursor(t.to,1):se.cursor(t.from,-1)}moveToLineBoundary(t,n,r=!0){return FQ(this,t,n,r)}moveVertically(t,n,r){return hB(this,t,jQ(this,t,n,r))}domAtPos(t,n=1){return this.docView.domAtPos(t,n)}posAtDOM(t,n=0){return this.docView.posFromDOM(t,n)}posAtCoords(t,n=!0){this.readMeasured();let r=Vm(this,t,n);return r&&r.pos}posAndSideAtCoords(t,n=!0){return this.readMeasured(),Vm(this,t,n)}coordsAtPos(t,n=1){this.readMeasured();let r=this.state.doc.lineAt(t),s=this.bidiSpans(r),i=s[kr.find(s,t-r.from,-1,n)];return r.length&&(t==r.from&&n<0||t==r.to&&n>0)&&i.dir!=this.textDirectionAt(r.from)&&(t==r.to?(t=r.from+i.from,n=1):(t=r.from+i.to,n=-1)),this.docView.coordsAt(t,n,i.dir==nt.RTL)}coordsForChar(t){return this.readMeasured(),this.docView.coordsForChar(t)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(t){return!this.state.facet(pR)||t<this.viewport.from||t>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(t))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(t){if(t.length>OY)return aR(t.length);let n=this.textDirectionAt(t.from),r;for(let i of this.bidiCache)if(i.from==t.from&&i.dir==n&&(i.fresh||oR(i.isolates,r=HS(this,t))))return i.order;r||(r=HS(this,t));let s=dQ(t.text,n,r);return this.bidiCache.push(new lE(t.from,t.to,n,r,!0,s)),s}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||ue.safari&&((t=this.inputState)===null||t===void 0?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{eR(this.contentDOM),this.docView.updateSelection()})}setRoot(t){this._root!=t&&(this._root=t,this.observer.setWindow((t.nodeType==9?t:t.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let t of this.plugins)t.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.win.clearTimeout(this.clearAnnouncement),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(t,n={}){var r,s,i,o;return iu.of(new aB(typeof t=="number"?se.cursor(t):t,(r=n.y)!==null&&r!==void 0?r:"nearest",(s=n.x)!==null&&s!==void 0?s:"nearest",(i=n.yMargin)!==null&&i!==void 0?i:5,(o=n.xMargin)!==null&&o!==void 0?o:5))}scrollSnapshot(){let{scrollTop:t,scrollLeft:n}=this.scrollDOM,r=this.viewState.scrollAnchorAt(t);return iu.of(new aB(se.cursor(r.from),"start","start",r.top-t,n,!0))}setTabFocusMode(t){t==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof t=="boolean"?this.inputState.tabFocusMode=t?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+t)}static domEventHandlers(t){return Js.define(()=>({}),{eventHandlers:t})}static domEventObservers(t){return Js.define(()=>({}),{eventObservers:t})}static theme(t,n){let r=Ws.newName(),s=[du.of(r),_a.of(qm(`.${r}`,t))];return n&&n.dark&&s.push($m.of(!0)),s}static baseTheme(t){return Oh.lowest(_a.of(qm("."+Wm,t,QR)))}static findFromDOM(t){var n;let r=t.querySelector(".cm-content"),s=r&&ht.get(r)||ht.get(t);return((n=s?.root)===null||n===void 0?void 0:n.view)||null}};xe.styleModule=_a;xe.inputHandler=fR;xe.clipboardInputFilter=uv;xe.clipboardOutputFilter=dv;xe.scrollHandler=gR;xe.focusChangeEffect=BR;xe.perLineTextDirection=pR;xe.exceptionSink=hR;xe.updateListener=Lm;xe.editable=Yr;xe.mouseSelectionStyle=dR;xe.dragMovesSelection=uR;xe.clickAddsSelectionRange=cR;xe.decorations=Lh;xe.blockWrappers=yR;xe.outerDecorations=fv;xe.atomicRanges=Cc;xe.bidiIsolatedRanges=bR;xe.cursorScrollMargin=Ce.define({combine:e=>{let t=5,n=5;for(let r of e)typeof r=="number"?t=n=r:{x:t,y:n}=r;return{x:t,y:n}}});xe.scrollMargins=SR;xe.darkTheme=$m;xe.cspNonce=Ce.define({combine:e=>e.length?e[0]:""});xe.contentAttributes=hv;xe.editorAttributes=vR;xe.lineWrapping=xe.contentAttributes.of({class:"cm-lineWrapping"});xe.announce=Tt.define();var OY=4096,aE={},lE=class YR{constructor(t,n,r,s,i,o){this.from=t,this.to=n,this.dir=r,this.isolates=s,this.fresh=i,this.order=o}static update(t,n){if(n.empty&&!t.some(i=>i.fresh))return t;let r=[],s=t.length?t[t.length-1].dir:nt.LTR;for(let i=Math.max(0,t.length-10);i<t.length;i++){let o=t[i];o.dir==s&&!n.touchesRange(o.from,o.to)&&r.push(new YR(n.mapPos(o.from,1),n.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return r}};function cE(e,t,n){for(let r=e.state.facet(t),s=r.length-1;s>=0;s--){let i=r[s],o=typeof i=="function"?i(e):i;o&&iv(o,n)}return n}var MY=ue.mac?"mac":ue.windows?"win":ue.linux?"linux":"key";function NY(e,t){const n=e.split(/-(?!$)/);let r=n[n.length-1];r=="Space"&&(r=" ");let s,i,o,a;for(let l=0;l<n.length-1;++l){const c=n[l];if(/^(cmd|meta|m)$/i.test(c))a=!0;else if(/^a(lt)?$/i.test(c))s=!0;else if(/^(c|ctrl|control)$/i.test(c))i=!0;else if(/^s(hift)?$/i.test(c))o=!0;else if(/^mod$/i.test(c))t=="mac"?a=!0:i=!0;else throw new Error("Unrecognized modifier name: "+c)}return s&&(r="Alt-"+r),i&&(r="Ctrl-"+r),a&&(r="Meta-"+r),o&&(r="Shift-"+r),r}function hu(e,t,n){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),n!==!1&&t.shiftKey&&(e="Shift-"+e),e}var PY=Oh.default(xe.domEventHandlers({keydown(e,t){return HY(LY(t.state),e,t,"editor")}})),XR=Ce.define({enables:PY}),uE=new WeakMap;function LY(e){let t=e.facet(XR),n=uE.get(t);return n||uE.set(t,n=FY(t.reduce((r,s)=>r.concat(s),[]))),n}var ks=null,_Y=4e3;function FY(e,t=MY){let n=Object.create(null),r=Object.create(null),s=(o,a)=>{let l=r[o];if(l==null)r[o]=a;else if(l!=a)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},i=(o,a,l,c,u)=>{var d,h;let f=n[o]||(n[o]=Object.create(null)),B=a.split(/ (?!$)/).map(v=>NY(v,t));for(let v=1;v<B.length;v++){let y=B.slice(0,v).join(" ");s(y,!0),f[y]||(f[y]={preventDefault:!0,stopPropagation:!1,run:[b=>{let E=ks={view:b,prefix:y,scope:o};return setTimeout(()=>{ks==E&&(ks=null)},_Y),!0}]})}let g=B.join(" ");s(g,!1);let C=f[g]||(f[g]={preventDefault:!1,stopPropagation:!1,run:((h=(d=f._any)===null||d===void 0?void 0:d.run)===null||h===void 0?void 0:h.slice())||[]});l&&C.run.push(l),c&&(C.preventDefault=!0),u&&(C.stopPropagation=!0)};for(let o of e){let a=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let c of a){let u=n[c]||(n[c]=Object.create(null));u._any||(u._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:d}=o;for(let h in u)u[h].run.push(f=>d(f,Km))}let l=o[t]||o.key;if(l)for(let c of a)i(c,l,o.run,o.preventDefault,o.stopPropagation),o.shift&&i(c,"Shift-"+l,o.shift,o.preventDefault,o.stopPropagation)}return n}var Km=null;function HY(e,t,n,r){Km=t;let s=Q9(t),i=R9(s,0),o=O9(i)==s.length&&s!=" ",a="",l=!1,c=!1,u=!1;ks&&ks.view==n&&ks.scope==r&&(a=ks.prefix+" ",_R.indexOf(t.keyCode)<0&&(c=!0,ks=null));let d=new Set,h=C=>{if(C){for(let v of C.run)if(!d.has(v)&&(d.add(v),v(n)))return C.stopPropagation&&(u=!0),!0;C.preventDefault&&(C.stopPropagation&&(u=!0),c=!0)}return!1},f=e[r],B,g;return f&&(h(f[a+hu(s,t,!o)])?l=!0:o&&(t.altKey||t.metaKey||t.ctrlKey)&&!(ue.windows&&t.ctrlKey&&t.altKey)&&!(ue.mac&&t.altKey&&!(t.ctrlKey||t.metaKey))&&(B=qs[t.keyCode])&&B!=s?(h(f[a+hu(B,t,!0)])||t.shiftKey&&(g=_l[t.keyCode])!=s&&g!=B&&h(f[a+hu(g,t,!1)]))&&(l=!0):o&&t.shiftKey&&h(f[a+hu(s,t,!0)])&&(l=!0),!l&&h(f._any)&&(l=!0)),c&&(l=!0),l&&u&&t.stopPropagation(),Km=null,l}var cl=class ZR{constructor(t,n,r,s,i){this.className=t,this.left=n,this.top=r,this.width=s,this.height=i}draw(){let t=document.createElement("div");return t.className=this.className,this.adjust(t),t}update(t,n){return n.className!=this.className?!1:(this.adjust(t),!0)}adjust(t){t.style.left=this.left+"px",t.style.top=this.top+"px",this.width!=null&&(t.style.width=this.width+"px"),t.style.height=this.height+"px"}eq(t){return this.left==t.left&&this.top==t.top&&this.width==t.width&&this.height==t.height&&this.className==t.className}static forRange(t,n,r){if(r.empty){let s=t.coordsAtPos(r.head,r.assoc||1);if(!s)return[];let i=eO(t);return[new ZR(n,s.left-i.left,s.top-i.top,null,s.bottom-s.top)]}else return jY(t,n,r)}};function eO(e){let t=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==nt.LTR?t.left:t.right-e.scrollDOM.clientWidth*e.scaleX)-e.scrollDOM.scrollLeft*e.scaleX,top:t.top-e.scrollDOM.scrollTop*e.scaleY}}function dE(e,t,n,r){let s=e.coordsAtPos(t,n*2);if(!s)return r;let i=e.dom.getBoundingClientRect(),o=(s.top+s.bottom)/2,a=e.posAtCoords({x:i.left+1,y:o}),l=e.posAtCoords({x:i.right-1,y:o});return a==null||l==null?r:{from:Math.max(r.from,Math.min(a,l)),to:Math.min(r.to,Math.max(a,l))}}function jY(e,t,n){if(n.to<=e.viewport.from||n.from>=e.viewport.to)return[];let r=Math.max(n.from,e.viewport.from),s=Math.min(n.to,e.viewport.to),i=e.textDirection==nt.LTR,o=e.contentDOM,a=o.getBoundingClientRect(),l=eO(e),c=o.querySelector(".cm-line"),u=c&&window.getComputedStyle(c),d=a.left+(u?parseInt(u.paddingLeft)+Math.min(0,parseInt(u.textIndent)):0),h=a.right-(u?parseInt(u.paddingRight):0),f=Gm(e,r,1),B=Gm(e,s,-1),g=f.type==Gt.Text?f:null,C=B.type==Gt.Text?B:null;if(g&&(e.lineWrapping||f.widgetLineBreaks)&&(g=dE(e,r,1,g)),C&&(e.lineWrapping||B.widgetLineBreaks)&&(C=dE(e,s,-1,C)),g&&C&&g.from==C.from&&g.to==C.to)return y(b(n.from,n.to,g));{let w=g?b(n.from,null,g):E(f,!1),A=C?b(null,n.to,C):E(B,!0),x=[];return(g||f).to<(C||B).from-(g&&C?1:0)||f.widgetLineBreaks>1&&w.bottom+e.defaultLineHeight/2<A.top?x.push(v(d,w.bottom,h,A.top)):w.bottom<A.top&&e.elementAtHeight((w.bottom+A.top)/2).type==Gt.Text&&(w.bottom=A.top=(w.bottom+A.top)/2),y(w).concat(x).concat(y(A))}function v(w,A,x,O){return new cl(t,w-l.left,A-l.top,Math.max(0,x-w),O-A)}function y({top:w,bottom:A,horizontal:x}){let O=[];for(let R=0;R<x.length;R+=2)O.push(v(x[R],w,x[R+1],A));return O}function b(w,A,x){let O=1e9,R=-1e9,P=[];function _(W,F,z,J,Z){let Q=e.coordsAtPos(W,W==x.to?-2:2),G=e.coordsAtPos(z,z==x.from?2:-2);!Q||!G||(O=Math.min(Q.top,G.top,O),R=Math.max(Q.bottom,G.bottom,R),Z==nt.LTR?P.push(i&&F?d:Q.left,i&&J?h:G.right):P.push(!i&&J?d:G.left,!i&&F?h:Q.right))}let N=w??x.from,q=A??x.to;for(let W of e.visibleRanges)if(W.to>N&&W.from<q)for(let F=Math.max(W.from,N),z=Math.min(W.to,q);;){let J=e.state.doc.lineAt(F);for(let Z of e.bidiSpans(J)){let Q=Z.from+J.from,G=Z.to+J.from;if(Q>=z)break;G>F&&_(Math.max(Q,F),w==null&&Q<=N,Math.min(G,z),A==null&&G>=q,Z.dir)}if(F=J.to+1,F>=z)break}return P.length==0&&_(N,w==null,q,A==null,e.textDirection),{top:O,bottom:R,horizontal:P}}function E(w,A){let x=a.top+(A?w.top:w.bottom);return{top:x,bottom:x,horizontal:[]}}}function GY(e,t){return e.constructor==t.constructor&&e.eq(t)}var VY=class{constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),t.above&&this.dom.classList.add("cm-layer-above"),t.class&&this.dom.classList.add(t.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(rd)!=e.state.facet(rd)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let t=0,n=e.facet(rd);for(;t<n.length&&n[t]!=this.layer;)t++;this.dom.style.zIndex=String((this.layer.above?150:-1)-t)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:e,scaleY:t}=this.view;(e!=this.scaleX||t!=this.scaleY)&&(this.scaleX=e,this.scaleY=t,this.dom.style.transform=`scale(${1/e}, ${1/t})`)}draw(e){if(e.length!=this.drawn.length||e.some((t,n)=>!GY(t,this.drawn[n]))){let t=this.dom.firstChild,n=0;for(let r of e)r.update&&t&&r.constructor&&this.drawn[n].constructor&&r.update(t,this.drawn[n])?(t=t.nextSibling,n++):this.dom.insertBefore(r.draw(),t);for(;t;){let r=t.nextSibling;t.remove(),t=r}this.drawn=e,ue.webkit&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}},rd=Ce.define();function tO(e){return[Js.define(t=>new VY(t,e)),rd.of(e)]}var $o=Ce.define({combine(e){return rv(e,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(t,n)=>Math.min(t,n),drawRangeCursor:(t,n)=>t||n})}});function UY(e={}){return[$o.of(e),zY,$Y,qY,mR.of(!0)]}function nO(e){return e.startState.facet($o)!=e.state.facet($o)}var zY=tO({above:!0,markers(e){let{state:t}=e,n=t.facet($o),r=[];for(let s of t.selection.ranges){let i=s==t.selection.main;if(s.empty||n.drawRangeCursor&&!(i&&ue.ios&&n.iosSelectionHandles)){let o=i?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",a=s.empty?s:se.cursor(s.head,s.assoc);for(let l of cl.forRange(e,o,a))r.push(l)}}return r},update(e,t){e.transactions.some(r=>r.selection)&&(t.style.animationName=t.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let n=nO(e);return n&&hE(e.state,t),e.docChanged||e.selectionSet||n},mount(e,t){hE(t.state,e)},class:"cm-cursorLayer"});function hE(e,t){t.style.animationDuration=e.facet($o).cursorBlinkRate+"ms"}var $Y=tO({above:!1,markers(e){let t=[],{main:n,ranges:r}=e.state.selection;for(let s of r)if(!s.empty)for(let i of cl.forRange(e,"cm-selectionBackground",s))t.push(i);if(ue.ios&&!n.empty&&e.state.facet($o).iosSelectionHandles){for(let s of cl.forRange(e,"cm-selectionHandle cm-selectionHandle-start",se.cursor(n.from,1)))t.push(s);for(let s of cl.forRange(e,"cm-selectionHandle cm-selectionHandle-end",se.cursor(n.to,1)))t.push(s)}return t},update(e,t){return e.docChanged||e.selectionSet||e.viewportChanged||nO(e)},class:"cm-selectionLayer"}),WY=ue.gecko&&ue.gecko_version==153?"#ffffff01":"transparent",qY=Oh.highest(xe.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:`${WY} !important`},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}})),Oae=/x/.unicode!=null?"gu":"g";function KY(){return QY}var JY=rt.line({class:"cm-activeLine"}),QY=Js.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.docChanged||e.selectionSet)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=-1,n=[];for(let r of e.state.selection.ranges){let s=e.lineBlockAt(r.head);s.from>t&&(n.push(JY.range(s.from)),t=s.from)}return rt.set(n)}},{decorations:e=>e.decorations}),Qs=class extends Li{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};Qs.prototype.elementClass="";Qs.prototype.toDOM=void 0;Qs.prototype.mapMode=xn.TrackBefore;Qs.prototype.startSide=Qs.prototype.endSide=-1;Qs.prototype.point=!0;var sd=Ce.define(),YY=Ce.define(),id=Ce.define(),Jm=Ce.define({combine:e=>e.some(t=>t)});function XY(e){let t=[ZY];return e&&e.fixed===!1&&t.push(Jm.of(!0)),t}var ZY=Js.fromClass(class{constructor(e){this.view=e,this.domAfter=null,this.prevViewport=e.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=e.state.facet(id).map(t=>new BE(e,t)),this.fixed=!e.state.facet(Jm);for(let t of this.gutters)t.config.side=="after"?this.getDOMAfter().appendChild(t.dom):this.dom.appendChild(t.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),e.scrollDOM.insertBefore(this.dom,e.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(e){if(this.updateGutters(e)){let t=this.prevViewport,n=e.view.viewport,r=Math.min(t.to,n.to)-Math.max(t.from,n.from);this.syncGutters(r<(n.to-n.from)*.8)}if(e.geometryChanged){let t=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=t,this.domAfter&&(this.domAfter.style.minHeight=t)}this.view.state.facet(Jm)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=e.view.viewport}syncGutters(e){let t=this.dom.nextSibling;e&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let n=et.iter(this.view.state.facet(sd),this.view.viewport.from),r=[],s=this.gutters.map(i=>new e7(i,this.view.viewport,-this.view.documentPadding.top));for(let i of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(i.type)){let o=!0;for(let a of i.type)if(a.type==Gt.Text&&o){Qm(n,r,a.from);for(let l of s)l.line(this.view,a,r);o=!1}else if(a.widget)for(let l of s)l.widget(this.view,a)}else if(i.type==Gt.Text){Qm(n,r,i.from);for(let o of s)o.line(this.view,i,r)}else if(i.widget)for(let o of s)o.widget(this.view,i);for(let i of s)i.finish();e&&(this.view.scrollDOM.insertBefore(this.dom,t),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(e){let t=e.startState.facet(id),n=e.state.facet(id),r=e.docChanged||e.heightChanged||e.viewportChanged||!et.eq(e.startState.facet(sd),e.state.facet(sd),e.view.viewport.from,e.view.viewport.to);if(t==n)for(let s of this.gutters)s.update(e)&&(r=!0);else{r=!0;let s=[];for(let i of n){let o=t.indexOf(i);o<0?s.push(new BE(this.view,i)):(this.gutters[o].update(e),s.push(this.gutters[o]))}for(let i of this.gutters)i.dom.remove(),s.indexOf(i)<0&&i.destroy();for(let i of s)i.config.side=="after"?this.getDOMAfter().appendChild(i.dom):this.dom.appendChild(i.dom);this.gutters=s}return r}destroy(){for(let e of this.gutters)e.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:e=>xe.scrollMargins.of(t=>{let n=t.plugin(e);if(!n||n.gutters.length==0||!n.fixed)return null;let r=n.dom.offsetWidth*t.scaleX,s=n.domAfter?n.domAfter.offsetWidth*t.scaleX:0;return t.textDirection==nt.LTR?{left:r,right:s}:{right:r,left:s}})});function fE(e){return Array.isArray(e)?e:[e]}function Qm(e,t,n){for(;e.value&&e.from<=n;)e.from==n&&t.push(e.value),e.next()}var e7=class{constructor(e,t,n){this.gutter=e,this.height=n,this.i=0,this.cursor=et.iter(e.markers,t.from)}addElement(e,t,n){let{gutter:r}=this,s=(t.top-this.height)/e.scaleY,i=t.height/e.scaleY;if(this.i==r.elements.length){let o=new rO(e,i,s,n);r.elements.push(o),r.dom.appendChild(o.dom)}else r.elements[this.i].update(e,i,s,n);this.height=t.bottom,this.i++}line(e,t,n){let r=[];Qm(this.cursor,r,t.from),n.length&&(r=r.concat(n));let s=this.gutter.config.lineMarker(e,t,r);s&&r.unshift(s);let i=this.gutter;r.length==0&&!i.config.renderEmptyElements||this.addElement(e,t,r)}widget(e,t){let n=this.gutter.config.widgetMarker(e,t.widget,t),r=n?[n]:null;for(let s of e.state.facet(YY)){let i=s(e,t.widget,t);i&&(r||(r=[])).push(i)}r&&this.addElement(e,t,r)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}},BE=class{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let n in t.domEventHandlers)this.dom.addEventListener(n,r=>{let s=r.target,i;if(s!=this.dom&&this.dom.contains(s)){for(;s.parentNode!=this.dom;)s=s.parentNode;let a=s.getBoundingClientRect();i=(a.top+a.bottom)/2}else i=r.clientY;let o=e.lineBlockAtHeight(i-e.documentTop);t.domEventHandlers[n](e,o,r)&&r.preventDefault()});this.markers=fE(t.markers(e)),t.initialSpacer&&(this.spacer=new rO(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let t=this.markers;if(this.markers=fE(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let r=this.config.updateSpacer(this.spacer.markers[0],e);r!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[r])}let n=e.view.viewport;return!et.eq(this.markers,t,n.from,n.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}},rO=class{constructor(e,t,n,r){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,n,r)}update(e,t,n,r){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=n&&(this.dom.style.marginTop=(this.above=n)?n+"px":""),t7(this.markers,r)||this.setMarkers(e,r)}setMarkers(e,t){let n="cm-gutterElement",r=this.dom.firstChild;for(let s=0,i=0;;){let o=i,a=s<t.length?t[s++]:null,l=!1;if(a){let c=a.elementClass;c&&(n+=" "+c);for(let u=i;u<this.markers.length;u++)if(this.markers[u].compare(a)){o=u,l=!0;break}}else o=this.markers.length;for(;i<o;){let c=this.markers[i++];if(c.toDOM){c.destroy(r);let u=r.nextSibling;r.remove(),r=u}}if(!a)break;a.toDOM&&(l?r=r.nextSibling:this.dom.insertBefore(a.toDOM(e),r)),l&&i++}this.dom.className=n,this.markers=t}destroy(){this.setMarkers(null,[])}};function t7(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].compare(t[n]))return!1;return!0}var n7=Ce.define(),r7=Ce.define(),vo=Ce.define({combine(e){return rv(e,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(t,n){let r=Object.assign({},t);for(let s in n){let i=r[s],o=n[s];r[s]=i?(a,l,c)=>i(a,l,c)||o(a,l,c):o}return r}})}}),pB=class extends Qs{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}};function mB(e,t){return e.state.facet(vo).formatNumber(t,e.state)}var s7=id.compute([vo],e=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(t){return t.state.facet(n7)},lineMarker(t,n,r){return r.some(s=>s.toDOM)?null:new pB(mB(t,t.state.doc.lineAt(n.from).number))},widgetMarker:(t,n,r)=>{for(let s of t.state.facet(r7)){let i=s(t,n,r);if(i)return i}return null},lineMarkerChange:t=>t.startState.facet(vo)!=t.state.facet(vo),initialSpacer(t){return new pB(mB(t,pE(t.state.doc.lines)))},updateSpacer(t,n){let r=mB(n.view,pE(n.view.state.doc.lines));return r==t.number?t:new pB(r)},domEventHandlers:e.facet(vo).domEventHandlers,side:"before"}));function i7(e={}){return[vo.of(e),XY(),s7]}function pE(e){let t=9;for(;t<e;)t=t*10+9;return t}var o7=new class extends Qs{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},a7=sd.compute(["selection"],e=>{let t=[],n=-1;for(let r of e.selection.ranges){let s=e.doc.lineAt(r.head).from;s>n&&(n=s,t.push(o7.range(s)))}return et.of(t)});function l7(){return a7}var gB,yo=new ke;function c7(e){return Ce.define({combine:e?t=>t.concat(e):void 0})}var u7=new ke,Zn=class{constructor(e,t,n=[],r=""){this.data=e,this.name=r,bt.prototype.hasOwnProperty("tree")||Object.defineProperty(bt.prototype,"tree",{get(){return Fr(this)}}),this.parser=t,this.extension=[Wo.of(this),bt.languageData.of((s,i,o)=>{let a=mE(s,i,o),l=a.type.prop(yo);if(!l)return[];let c=s.facet(l),u=a.type.prop(u7);if(u){let d=a.resolve(i-a.from,o);for(let h of u)if(h.test(d,s)){let f=s.facet(h.facet);return h.type=="replace"?f:f.concat(c)}}return c})].concat(n)}isActiveAt(e,t,n=-1){return mE(e,t,n).type.prop(yo)==this.data}findRegions(e){let t=e.facet(Wo);if(t?.data==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],r=(s,i)=>{if(s.prop(yo)==this.data){n.push({from:i,to:i+s.length});return}let o=s.prop(ke.mounted);if(o){if(o.tree.prop(yo)==this.data){if(o.overlay)for(let a of o.overlay)n.push({from:a.from+i,to:a.to+i});else n.push({from:i,to:i+s.length});return}else if(o.overlay){let a=n.length;if(r(o.tree,o.overlay[0].from+i),n.length>a)return}}for(let a=0;a<s.children.length;a++){let l=s.children[a];l instanceof Pt&&r(l,s.positions[a]+i)}};return r(Fr(e),0),n}get allowsNesting(){return!0}};Zn.setState=Tt.define();function mE(e,t,n){let r=e.facet(Wo),s=Fr(e).topNode;if(!r||r.allowsNesting)for(let i=s;i;i=i.enter(t,n,ut.ExcludeBuffers|ut.EnterBracketed))i.type.isTop&&(s=i);return s}var d7=class Ym extends Zn{constructor(t,n,r){super(t,n,[],r),this.parser=n}static define(t){let n=c7(t.languageData);return new Ym(n,t.parser.configure({props:[yo.add(r=>r.isTop?n:void 0)]}),t.name)}configure(t,n){return new Ym(this.data,this.parser.configure(t),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}};function Fr(e){let t=e.field(Zn.state,!1);return t?t.tree:Pt.empty}var h7=class{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let n=this.cursorPos-this.string.length;return e<n||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}},ya=null,f7=class Xm{constructor(t,n,r=[],s,i,o,a,l){this.parser=t,this.state=n,this.fragments=r,this.tree=s,this.treeLen=i,this.viewport=o,this.skipped=a,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(t,n,r){return new Xm(t,n,[],Pt.empty,0,r,[],null)}startParse(){return this.parser.startParse(new h7(this.state.doc),this.fragments)}work(t,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=Pt.empty&&this.isDone(n??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var r;if(typeof t=="number"){let s=Date.now()+t;t=()=>Date.now()>s}for(this.parse||(this.parse=this.startParse()),n!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>n)&&n<this.state.doc.length&&this.parse.stopAt(n);;){let s=this.parse.advance();if(s)if(this.fragments=this.withoutTempSkipped($u.addTree(s,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(r=this.parse.stoppedAt)!==null&&r!==void 0?r:this.state.doc.length,this.tree=s,this.parse=null,this.treeLen<(n??this.state.doc.length))this.parse=this.startParse();else return!0;if(t())return!1}})}takeTree(){let t,n;this.parse&&(t=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&this.parse.stopAt(t),this.withContext(()=>{for(;!(n=this.parse.advance()););}),this.treeLen=t,this.tree=n,this.fragments=this.withoutTempSkipped($u.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let n=ya;ya=this;try{return t()}finally{ya=n}}withoutTempSkipped(t){for(let n;n=this.tempSkipped.pop();)t=gE(t,n.from,n.to);return t}changes(t,n){let{fragments:r,tree:s,treeLen:i,viewport:o,skipped:a}=this;if(this.takeTree(),!t.empty){let l=[];if(t.iterChangedRanges((c,u,d,h)=>l.push({fromA:c,toA:u,fromB:d,toB:h})),r=$u.applyChanges(r,l),s=Pt.empty,i=0,o={from:t.mapPos(o.from,-1),to:t.mapPos(o.to,1)},this.skipped.length){a=[];for(let c of this.skipped){let u=t.mapPos(c.from,1),d=t.mapPos(c.to,-1);u<d&&a.push({from:u,to:d})}}}return new Xm(this.parser,n,r,s,i,o,a,this.scheduleOn)}updateViewport(t){if(this.viewport.from==t.from&&this.viewport.to==t.to)return!1;this.viewport=t;let n=this.skipped.length;for(let r=0;r<this.skipped.length;r++){let{from:s,to:i}=this.skipped[r];s<t.to&&i>t.from&&(this.fragments=gE(this.fragments,s,i),this.skipped.splice(r--,1))}return this.skipped.length>=n?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(t,n){this.skipped.push({from:t,to:n})}static getSkippingParser(t){return new class extends ck{createParse(n,r,s){let i=s[0].from,o=s[s.length-1].to;return{parsedPos:i,advance(){let a=ya;if(a){for(let l of s)a.tempSkipped.push(l);t&&(a.scheduleOn=a.scheduleOn?Promise.all([a.scheduleOn,t]):t)}return this.parsedPos=o,new Pt(Hn.none,[],[],o-i)},stoppedAt:null,stopAt(){}}}}}isDone(t){t=Math.min(t,this.state.doc.length);let n=this.fragments;return this.treeLen>=t&&n.length&&n[0].from==0&&n[0].to>=t}static get(){return ya}};function gE(e,t,n){return $u.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}var Zm=class eg{constructor(t){this.context=t,this.tree=t.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(t.changes,t.state),r=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new eg(n)}static init(t){let n=Math.min(3e3,t.doc.length),r=f7.create(t.facet(Wo).parser,t,{from:0,to:n});return r.work(20,n)||r.takeTree(),new eg(r)}};Zn.state=gc.define({create:Zm.init,update(e,t){for(let n of t.effects)if(n.is(Zn.setState))return n.value;return t.startState.facet(Wo)!=t.state.facet(Wo)?Zm.init(t.state):e.apply(t)}});var sO=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<"u"&&(sO=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});var CB=typeof navigator<"u"&&(!((gB=navigator.scheduling)===null||gB===void 0)&&gB.isInputPending)?()=>navigator.scheduling.isInputPending():null,B7=Js.fromClass(class{constructor(t){this.view=t,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(t){let n=this.view.state.field(Zn.state).context;(n.updateViewport(t.view.viewport)||this.view.viewport.to>n.treeLen)&&this.scheduleWork(),(t.docChanged||t.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(n)}scheduleWork(){if(this.working)return;let{state:t}=this.view,n=t.field(Zn.state);(n.tree!=n.context.tree||!n.context.isDone(t.doc.length))&&(this.working=sO(this.work))}work(t){this.working=null;let n=Date.now();if(this.chunkEnd<n&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=n+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:r,viewport:{to:s}}=this.view,i=r.field(Zn.state);if(i.tree==i.context.tree&&i.context.isDone(s+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,t&&!CB?Math.max(25,t.timeRemaining()-5):1e9),a=i.context.treeLen<s&&r.doc.length>s+1e3,l=i.context.work(()=>CB&&CB()||Date.now()>o,s+(a?0:1e5));this.chunkBudget-=Date.now()-n,(l||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:Zn.setState.of(new Zm(i.context))})),this.chunkBudget>0&&!(l&&!a)&&this.scheduleWork(),this.checkAsyncSchedule(i.context)}checkAsyncSchedule(t){t.scheduleOn&&(this.workScheduled++,t.scheduleOn.then(()=>this.scheduleWork()).catch(n=>Rr(this.view.state,n)).then(()=>this.workScheduled--),t.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Wo=Ce.define({combine(e){return e.length?e[0]:null},enables:e=>[Zn.state,B7,xe.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]}),p7=class{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}},m7=Ce.define(),pv=Ce.define({combine:e=>{if(!e.length)return" ";let t=e[0];if(!t||/\S/.test(t)||Array.from(t).some(n=>n!=t[0]))throw new Error("Invalid indent unit: "+JSON.stringify(e[0]));return t}});function Gd(e){let t=e.facet(pv);return t.charCodeAt(0)==9?e.tabSize*t.length:t.length}function Vl(e,t){let n="",r=e.tabSize,s=e.facet(pv)[0];if(s==" "){for(;t>=r;)n+=" ",t-=r;s=" "}for(let i=0;i<t;i++)n+=s;return n}function mv(e,t){e instanceof bt&&(e=new jh(e));for(let r of e.state.facet(m7)){let s=r(e,t);if(s!==void 0)return s}let n=Fr(e.state);return n.length>=t?g7(e,n,t):null}var jh=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=Gd(e)}lineAt(e,t=1){let n=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:s}=this.options;return r!=null&&r>=n.from&&r<=n.to?s&&r==e?{text:"",from:e}:(t<0?r<e:r<=e)?{text:n.text.slice(r-n.from),from:r}:{text:n.text.slice(0,r-n.from),from:n.from}:n}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:n,from:r}=this.lineAt(e,t);return n.slice(e-r,Math.min(n.length,e+100-r))}column(e,t=1){let{text:n,from:r}=this.lineAt(e,t),s=this.countColumn(n,e-r),i=this.options.overrideIndentation?this.options.overrideIndentation(r):-1;return i>-1&&(s+=i-this.countColumn(n,n.search(/\S|$/))),s}countColumn(e,t=e.length){return Mh(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:n,from:r}=this.lineAt(e,t),s=this.options.overrideIndentation;if(s){let i=s(r);if(i>-1)return i}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}},iO=new ke;function g7(e,t,n){let r=t.resolveStack(n),s=t.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(s!=r.node){let i=[];for(let o=s;o&&!(o.from<r.node.from||o.to>r.node.to||o.from==r.node.from&&o.type==r.node.type);o=o.parent)i.push(o);for(let o=i.length-1;o>=0;o--)r={node:i[o],next:r}}return oO(r,e,n)}function oO(e,t,n){for(let r=e;r;r=r.next){let s=v7(r.node);if(s)return s(b7.create(t,n,r))}return 0}function C7(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}function v7(e){let t=e.type.prop(iO);if(t)return t;let n=e.firstChild,r;if(n&&(r=n.type.prop(ke.closedBy))){let s=e.lastChild,i=s&&r.indexOf(s.name)>-1;return o=>x7(o,!0,1,void 0,i&&!C7(o)?s.from:void 0)}return e.parent==null?y7:null}function y7(){return 0}var b7=class aO extends jh{constructor(t,n,r){super(t.state,t.options),this.base=t,this.pos=n,this.context=r}get node(){return this.context.node}static create(t,n,r){return new aO(t,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(t){let n=this.state.doc.lineAt(t.from);for(;;){let r=t.resolve(n.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(S7(r,t))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return oO(this.context.next,this.base,this.pos)}};function S7(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function E7(e){let t=e.node,n=t.childAfter(t.from),r=t.lastChild;if(!n)return null;let s=e.options.simulateBreak,i=e.state.doc.lineAt(n.from),o=s==null||s<=i.from?i.to:Math.min(i.to,s);for(let a=n.to;;){let l=t.childAfter(a);if(!l||l==r)return null;if(!l.type.isSkipped){if(l.from>=o)return null;let c=/^ */.exec(i.text.slice(n.to-i.from))[0].length;return{from:n.from,to:n.to+c}}a=l.to}}function x7(e,t,n,r,s){let i=e.textAfter,o=i.match(/^\s*/)[0].length,a=r&&i.slice(o,o+r.length)==r||s==e.pos+o,l=t?E7(e):null;return l?a?e.column(l.from):e.column(l.to):e.baseIndent+(a?0:e.unit*n)}function CE({except:e,units:t=1}={}){return n=>{let r=e&&e.test(n.textAfter);return n.baseIndent+(r?0:t*n.unit)}}var w7=200;function D7(){return bt.transactionFilter.of(e=>{if(!e.docChanged||!e.isUserEvent("input.type")&&!e.isUserEvent("input.complete"))return e;let t=e.startState.languageDataAt("indentOnInput",e.startState.selection.main.head);if(!t.length)return e;let n=e.newDoc,{head:r}=e.newSelection.main,s=n.lineAt(r);if(r>s.from+w7)return e;let i=n.sliceString(s.from,r);if(!t.some(c=>c.test(i)))return e;let{state:o}=e,a=-1,l=[];for(let{head:c}of o.selection.ranges){let u=o.doc.lineAt(c);if(u.from==a)continue;a=u.from;let d=mv(o,u.from);if(d==null)continue;let h=/^\s*/.exec(u.text)[0],f=Vl(o,d);h!=f&&l.push({from:u.from,to:u.from+h.length,insert:f})}return l.length?[e,{changes:l,sequential:!0}]:e})}var T7=new ke;function A7(e){let t=e.firstChild,n=e.lastChild;return t&&t.to<n.from?{from:t.to,to:n.type.isError?e.to:n.from}:null}var gv=class lO{constructor(t,n){this.specs=t;let r;function s(a){let l=Ws.newName();return(r||(r=Object.create(null)))["."+l]=a,l}const i=typeof n.all=="string"?n.all:n.all?s(n.all):void 0,o=n.scope;this.scope=o instanceof Zn?a=>a.prop(yo)==o.data:o?a=>a==o:void 0,this.style=Bk(t.map(a=>({tag:a.tag,class:a.class||s(Object.assign({},a,{tag:null}))})),{all:i}).style,this.module=r?new Ws(r):null,this.themeType=n.themeType}static define(t,n){return new lO(t,n||{})}},tg=Ce.define(),cO=Ce.define({combine(e){return e.length?[e[0]]:null}});function vB(e){let t=e.facet(tg);return t.length?t:e.facet(cO)}function I7(e,t){let n=[R7],r;return e instanceof gv&&(e.module&&n.push(xe.styleModule.of(e.module)),r=e.themeType),t?.fallback?n.push(cO.of(e)):r?n.push(tg.computeN([xe.darkTheme],s=>s.facet(xe.darkTheme)==(r=="dark")?[e]:[])):n.push(tg.of(e)),n}var k7=class{constructor(e){this.markCache=Object.create(null),this.tree=Fr(e.state),this.decorations=this.buildDeco(e,vB(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=Fr(e.state),n=vB(e.state),r=n!=vB(e.startState),{viewport:s}=e.view,i=e.changes.mapPos(this.decoratedTo,1);t.length<s.to&&!r&&t.type==this.tree.type&&i>=s.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=i):(t!=this.tree||e.viewportChanged||r)&&(this.tree=t,this.decorations=this.buildDeco(e.view,n),this.decoratedTo=s.to)}buildDeco(e,t){if(!t||!this.tree.length)return rt.none;let n=new Yu;for(let{from:r,to:s}of e.visibleRanges)v9(this.tree,t,(i,o,a)=>{n.add(i,o,this.markCache[a]||(this.markCache[a]=rt.mark({class:a})))},r,s);return n.finish()}},R7=Oh.high(Js.fromClass(k7,{decorations:e=>e.decorations})),Nae=gv.define([{tag:re.meta,color:"#404740"},{tag:re.link,textDecoration:"underline"},{tag:re.heading,textDecoration:"underline",fontWeight:"bold"},{tag:re.emphasis,fontStyle:"italic"},{tag:re.strong,fontWeight:"bold"},{tag:re.strikethrough,textDecoration:"line-through"},{tag:re.keyword,color:"#708"},{tag:[re.atom,re.bool,re.url,re.contentSeparator,re.labelName],color:"#219"},{tag:[re.literal,re.inserted],color:"#164"},{tag:[re.string,re.deleted],color:"#a11"},{tag:[re.regexp,re.escape,re.special(re.string)],color:"#e40"},{tag:re.definition(re.variableName),color:"#00f"},{tag:re.local(re.variableName),color:"#30a"},{tag:[re.typeName,re.namespace],color:"#085"},{tag:re.className,color:"#167"},{tag:[re.special(re.variableName),re.macroName],color:"#256"},{tag:re.definition(re.propertyName),color:"#00c"},{tag:re.comment,color:"#940"},{tag:re.invalid,color:"#f00"}]),O7=xe.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),uO=1e4,dO="()[]{}",hO=Ce.define({combine(e){return rv(e,{afterCursor:!0,brackets:dO,maxScanDistance:uO,renderMatch:P7})}}),M7=rt.mark({class:"cm-matchingBracket"}),N7=rt.mark({class:"cm-nonmatchingBracket"});function P7(e){let t=[],n=e.matched?M7:N7;return t.push(n.range(e.start.from,e.start.to)),e.end&&t.push(n.range(e.end.from,e.end.to)),t}function vE(e){let t=[],n=e.facet(hO);for(let r of e.selection.ranges){if(!r.empty)continue;let s=Or(e,r.head,-1,n)||r.head>0&&Or(e,r.head-1,1,n)||n.afterCursor&&(Or(e,r.head,1,n)||r.head<e.doc.length&&Or(e,r.head+1,-1,n));s&&(t=t.concat(n.renderMatch(s,e)))}return rt.set(t,!0)}var L7=[Js.fromClass(class{constructor(e){this.paused=!1,this.decorations=vE(e.state)}update(e){(e.docChanged||e.selectionSet||this.paused)&&(e.view.composing?(this.decorations=this.decorations.map(e.changes),this.paused=!0):(this.decorations=vE(e.state),this.paused=!1))}},{decorations:e=>e.decorations}),O7];function _7(e={}){return[hO.of(e),L7]}var F7=new ke;function ng(e,t,n){let r=e.prop(t<0?ke.openedBy:ke.closedBy);if(r)return r;if(e.name.length==1){let s=n.indexOf(e.name);if(s>-1&&s%2==(t<0?1:0))return[n[s+t]]}return null}function rg(e){let t=e.type.prop(F7);return t?t(e.node):e}function Or(e,t,n,r={}){let s=r.maxScanDistance||uO,i=r.brackets||dO,o=Fr(e),a=o.resolveInner(t,n);for(let l=a;l;l=l.parent){let c=ng(l.type,n,i);if(c&&l.from<l.to){let u=rg(l);if(u&&(n>0?t>=u.from&&t<u.to:t>u.from&&t<=u.to))return H7(e,t,n,l,u,c,i)}}return j7(e,t,n,o,a.type,s,i)}function H7(e,t,n,r,s,i,o){let a=r.parent,l={from:s.from,to:s.to},c=0,u=a?.cursor();if(u&&(n<0?u.childBefore(r.from):u.childAfter(r.to)))do if(n<0?u.to<=r.from:u.from>=r.to){if(c==0&&i.indexOf(u.type.name)>-1&&u.from<u.to){let d=rg(u);return{start:l,end:d?{from:d.from,to:d.to}:void 0,matched:!0}}else if(ng(u.type,n,o))c++;else if(ng(u.type,-n,o)){if(c==0){let d=rg(u);return{start:l,end:d&&d.from<d.to?{from:d.from,to:d.to}:void 0,matched:!1}}c--}}while(n<0?u.prevSibling():u.nextSibling());return{start:l,matched:!1}}function j7(e,t,n,r,s,i,o){if(n<0?!t:t==e.doc.length)return null;let a=n<0?e.sliceDoc(t-1,t):e.sliceDoc(t,t+1),l=o.indexOf(a);if(l<0||l%2==0!=n>0)return null;let c={from:n<0?t-1:t,to:n>0?t+1:t},u=e.doc.iterRange(t,n>0?e.doc.length:0),d=0;for(let h=0;!u.next().done&&h<=i;){let f=u.value;n<0&&(h+=f.length);let B=t+h*n;for(let g=n>0?0:f.length-1,C=n>0?f.length:-1;g!=C;g+=n){let v=o.indexOf(f[g]);if(!(v<0||r.resolveInner(B+g,1).type!=s))if(v%2==0==n>0)d++;else{if(d==1)return{start:c,end:{from:B+g,to:B+g+1},matched:v>>1==l>>1};d--}}n>0&&(h+=f.length)}return u.done?{start:c,matched:!1}:null}var G7=Object.create(null),yE=[Hn.none],bE=[],SE=Object.create(null),V7=Object.create(null);for(let[e,t]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])V7[e]=U7(G7,t);function yB(e,t){bE.indexOf(e)>-1||(bE.push(e),console.warn(t))}function U7(e,t){let n=[];for(let a of t.split(" ")){let l=[];for(let c of a.split(".")){let u=e[c]||re[c];u?typeof u=="function"?l.length?l=l.map(u):yB(c,`Modifier ${c} used at start of tag`):l.length?yB(c,`Tag ${c} used as modifier`):l=Array.isArray(u)?u:[u]:yB(c,`Unknown highlighting tag ${c}`)}for(let c of l)n.push(c)}if(!n.length)return 0;let r=t.replace(/ /g,"_"),s=r+" "+n.map(a=>a.id),i=SE[s];if(i)return i.id;let o=SE[s]=Hn.define({id:yE.length,name:r,props:[hk({[r]:n})]});return yE.push(o),o.id}var Pae={rtl:rt.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"rtl"},bidiIsolate:nt.RTL}),ltr:rt.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"ltr"},bidiIsolate:nt.LTR}),auto:rt.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"auto"},bidiIsolate:null})},z7=d7.define({name:"json",parser:E9.configure({props:[iO.add({Object:CE({except:/^\s*\}/}),Array:CE({except:/^\s*\]/})}),T7.add({"Object Array":A7})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function $7(){return new p7(z7)}var W7=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=vv(e.state,n.from);return r.line?q7(e):r.block?J7(e):!1};function Cv(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let s=e(t,n);return s?(r(n.update(s)),!0):!1}}var q7=Cv(X7,0),K7=Cv(fO,0),J7=Cv((e,t)=>fO(e,t,Y7(t)),0);function vv(e,t){let n=e.languageDataAt("commentTokens",t,1);return n.length?n[0]:{}}var fu=50;function Q7(e,{open:t,close:n},r,s){let i=e.sliceDoc(r-fu,r),o=e.sliceDoc(s,s+fu),a=/\s*$/.exec(i)[0].length,l=/^\s*/.exec(o)[0].length,c=i.length-a;if(i.slice(c-t.length,c)==t&&o.slice(l,l+n.length)==n)return{open:{pos:r-a,margin:a&&1},close:{pos:s+l,margin:l&&1}};let u,d;s-r<=100?u=d=e.sliceDoc(r,s):(u=e.sliceDoc(r,r+fu),d=e.sliceDoc(s-fu,s));let h=/^\s*/.exec(u)[0].length,f=/\s*$/.exec(d)[0].length,B=d.length-f-n.length;return u.slice(h,h+t.length)==t&&d.slice(B,B+n.length)==n?{open:{pos:r+h+t.length,margin:/\s/.test(u.charAt(h+t.length))?1:0},close:{pos:s-f-n.length,margin:/\s/.test(d.charAt(B-1))?1:0}}:null}function Y7(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),s=n.to<=r.to?r:e.doc.lineAt(n.to);s.from>r.from&&s.from==n.to&&(s=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let i=t.length-1;i>=0&&t[i].to>r.from?t[i].to=s.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:s.to})}return t}function fO(e,t,n=t.selection.ranges){let r=n.map(i=>vv(t,i.from).block);if(!r.every(i=>i))return null;let s=n.map((i,o)=>Q7(t,r[o],i.from,i.to));if(e!=2&&!s.every(i=>i))return{changes:t.changes(n.map((i,o)=>s[o]?[]:[{from:i.from,insert:r[o].open+" "},{from:i.to,insert:" "+r[o].close}]))};if(e!=1&&s.some(i=>i)){let i=[];for(let o=0,a;o<s.length;o++)if(a=s[o]){let l=r[o],{open:c,close:u}=a;i.push({from:c.pos-l.open.length,to:c.pos+c.margin},{from:u.pos-u.margin,to:u.pos+l.close.length})}return{changes:i}}return null}function X7(e,t,n=t.selection.ranges){let r=[],s=-1;e:for(let{from:i,to:o}of n){let a=r.length,l=1e9,c;for(let u=i;u<=o;){let d=t.doc.lineAt(u);if(c==null&&(c=vv(t,d.from).line,!c))continue e;if(d.from>s&&(i==o||o>d.from)){s=d.from;let h=/^\s*/.exec(d.text)[0].length,f=h==d.length,B=d.text.slice(h,h+c.length)==c?h:-1;h<d.text.length&&h<l&&(l=h),r.push({line:d,comment:B,token:c,indent:h,empty:f,single:!1})}u=d.to+1}if(l<1e9)for(let u=a;u<r.length;u++)r[u].indent<r[u].line.text.length&&(r[u].indent=l);r.length==a+1&&(r[a].single=!0)}if(e!=2&&r.some(i=>i.comment<0&&(!i.empty||i.single))){let i=[];for(let{line:a,token:l,indent:c,empty:u,single:d}of r)(d||!u)&&i.push({from:a.from+c,insert:l+" "});let o=t.changes(i);return{changes:o,selection:t.selection.map(o,1)}}else if(e!=1&&r.some(i=>i.comment>=0)){let i=[];for(let{line:o,comment:a,token:l}of r)if(a>=0){let c=o.from+a,u=c+l.length;o.text[u-o.from]==" "&&u++,i.push({from:c,to:u})}return{changes:i}}return null}var EE=Ui.define(),Z7=Ce.define(),Ul=class ja{constructor(t,n,r,s,i){this.changes=t,this.effects=n,this.mapped=r,this.startSelection=s,this.selectionsAfter=i}setSelAfter(t){return new ja(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){var t,n,r;return{changes:(t=this.changes)===null||t===void 0?void 0:t.toJSON(),mapped:(n=this.mapped)===null||n===void 0?void 0:n.toJSON(),startSelection:(r=this.startSelection)===null||r===void 0?void 0:r.toJSON(),selectionsAfter:this.selectionsAfter.map(s=>s.toJSON())}}static fromJSON(t){return new ja(t.changes&&cr.fromJSON(t.changes),[],t.mapped&&Do.fromJSON(t.mapped),t.startSelection&&se.fromJSON(t.startSelection),t.selectionsAfter.map(se.fromJSON))}static fromTransaction(t,n){let r=Pn;for(let s of t.startState.facet(Z7)){let i=s(t);i.length&&(r=r.concat(i))}return!r.length&&t.changes.empty?null:new ja(t.changes.invert(t.startState.doc),r,void 0,n||t.startState.selection,Pn)}static selection(t){return new ja(void 0,Pn,void 0,void 0,t)}};function sg(e,t,n,r){let s=t+1>n+20?t-n-1:0,i=e.slice(s,t);return i.push(r),i}function eX(e,t){let n=[],r=!1;return e.iterChangedRanges((s,i)=>n.push(s,i)),t.iterChangedRanges((s,i,o,a)=>{for(let l=0;l<n.length;){let c=n[l++],u=n[l++];a>=c&&o<=u&&(r=!0)}}),r}function tX(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((n,r)=>n.empty!=t.ranges[r].empty).length===0}function BO(e,t){return e.length?t.length?e.concat(t):e:t}var Pn=[],nX=200;function rX(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-nX));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),sg(e,e.length-1,1e9,n.setSelAfter(r)))}else return[Ul.selection([t])]}function sX(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function bB(e,t){if(!e.length)return e;let n=e.length,r=Pn;for(;n;){let s=iX(e[n-1],t,r);if(s.changes&&!s.changes.empty||s.effects.length){let i=e.slice(0,n);return i[n-1]=s,i}else t=s.mapped,n--,r=s.selectionsAfter}return r.length?[Ul.selection(r)]:Pn}function iX(e,t,n){let r=BO(e.selectionsAfter.length?e.selectionsAfter.map(a=>a.map(t)):Pn,n);if(!e.changes)return Ul.selection(r);let s=e.changes.map(t),i=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(i):i;return new Ul(s,Tt.mapEffects(e.effects,t),o,e.startSelection.map(i),r)}var oX=/^(input\.type|delete)($|\.)/,xE=class Ga{constructor(t,n,r=0,s=void 0){this.done=t,this.undone=n,this.prevTime=r,this.prevUserEvent=s}isolate(){return this.prevTime?new Ga(this.done,this.undone):this}addChanges(t,n,r,s,i){let o=this.done,a=o[o.length-1];return a&&a.changes&&!a.changes.empty&&t.changes&&(!r||oX.test(r))&&(!a.selectionsAfter.length&&n-this.prevTime<s.newGroupDelay&&s.joinToEvent(i,eX(a.changes,t.changes))||r=="input.type.compose")?o=sg(o,o.length-1,s.minDepth,new Ul(t.changes.compose(a.changes),BO(Tt.mapEffects(t.effects,a.changes),a.effects),a.mapped,a.startSelection,Pn)):o=sg(o,o.length,s.minDepth,t),new Ga(o,Pn,n,r)}addSelection(t,n,r,s){let i=this.done.length?this.done[this.done.length-1].selectionsAfter:Pn;return i.length>0&&n-this.prevTime<s&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&tX(i[i.length-1],t)?this:new Ga(rX(this.done,t),this.undone,n,r)}addMapping(t){return new Ga(bB(this.done,t),bB(this.undone,t),this.prevTime,this.prevUserEvent)}pop(t,n,r){let s=t==0?this.done:this.undone;if(s.length==0)return null;let i=s[s.length-1],o=i.selectionsAfter[0]||(i.startSelection?i.startSelection.map(i.changes.invertedDesc,1):n.selection);if(r&&i.selectionsAfter.length)return n.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:EE.of({side:t,rest:sX(s),selection:o}),userEvent:t==0?"select.undo":"select.redo",scrollIntoView:!0});if(i.changes){let a=s.length==1?Pn:s.slice(0,s.length-1);return i.mapped&&(a=bB(a,i.mapped)),n.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:EE.of({side:t,rest:a,selection:o}),filter:!1,userEvent:t==0?"undo":"redo",scrollIntoView:!0})}else return null}};xE.empty=new xE(Pn,Pn);function aa(e,t){return se.create(e.ranges.map(t),e.mainIndex)}function hr(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function fr({state:e,dispatch:t},n){let r=aa(e.selection,n);return r.eq(e.selection,!0)?!1:(t(hr(e,r)),!0)}function Gh(e,t){return se.cursor(t?e.to:e.from)}function pO(e,t){return fr(e,n=>n.empty?e.moveByChar(n,t):Gh(n,t))}function qt(e){return e.textDirectionAt(e.state.selection.main.head)==nt.LTR}var mO=e=>pO(e,!qt(e)),gO=e=>pO(e,qt(e));function CO(e,t){return fr(e,n=>n.empty?e.moveByGroup(n,t):Gh(n,t))}var aX=e=>CO(e,!qt(e)),lX=e=>CO(e,qt(e)),Lae=typeof Intl<"u"&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"word"}):null;function cX(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function Vh(e,t,n){let r=Fr(e).resolveInner(t.head),s=n?ke.closedBy:ke.openedBy;for(let l=t.head;;){let c=n?r.childAfter(l):r.childBefore(l);if(!c)break;cX(e,c,s)?r=c:l=n?c.to:c.from}let i=r.type.prop(s),o,a;return i&&(o=n?Or(e,r.from,1):Or(e,r.to,-1))&&o.matched?a=n?o.end.to:o.end.from:a=n?r.to:r.from,se.cursor(a,n?-1:1)}var uX=e=>fr(e,t=>Vh(e.state,t,!qt(e))),dX=e=>fr(e,t=>Vh(e.state,t,qt(e)));function vO(e,t){return fr(e,n=>{if(!n.empty)return Gh(n,t);let r=e.moveVertically(n,t);return r.head!=n.head?r:e.moveToLineBoundary(n,t)})}var yO=e=>vO(e,!1),bO=e=>vO(e,!0);function SO(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0,s;if(t){for(let i of e.state.facet(xe.scrollMargins)){let o=i(e);o?.top&&(n=Math.max(o?.top,n)),o?.bottom&&(r=Math.max(o?.bottom,r))}s=e.scrollDOM.clientHeight-n-r}else s=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:t,height:Math.max(e.defaultLineHeight,s-5)}}function EO(e,t){let n=SO(e),{state:r}=e,s=aa(r.selection,o=>o.empty?e.moveVertically(o,t,n.height):Gh(o,t));if(s.eq(r.selection))return!1;let i;if(n.selfScroll){let o=e.coordsAtPos(r.selection.main.head),a=e.scrollDOM.getBoundingClientRect(),l=a.top+n.marginTop,c=a.bottom-n.marginBottom;o&&o.top>l&&o.bottom<c&&(i=xe.scrollIntoView(s.main.head,{y:"start",yMargin:o.top-l}))}return e.dispatch(hr(r,s),{effects:i}),!0}var wE=e=>EO(e,!1),ig=e=>EO(e,!0);function ei(e,t,n){let r=e.lineBlockAt(t.head),s=e.moveToLineBoundary(t,n);if(s.head==t.head&&s.head!=(n?r.to:r.from)&&(s=e.moveToLineBoundary(t,n,!1)),!n&&s.head==r.from&&r.length){let i=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;i&&t.head!=r.from+i&&(s=se.cursor(r.from+i))}return s}var hX=e=>fr(e,t=>ei(e,t,!0)),fX=e=>fr(e,t=>ei(e,t,!1)),BX=e=>fr(e,t=>ei(e,t,!qt(e))),pX=e=>fr(e,t=>ei(e,t,qt(e))),mX=e=>fr(e,t=>e.moveToLineBoundary(t,!1,!1)),gX=e=>fr(e,t=>e.moveToLineBoundary(t,!0,!1));function CX(e,t,n){let r=!1,s=aa(e.selection,i=>{let o=Or(e,i.head,-1)||Or(e,i.head,1)||i.head>0&&Or(e,i.head-1,1)||i.head<e.doc.length&&Or(e,i.head+1,-1);if(!o||!o.end)return i;r=!0;let a=o.start.from==i.head?o.end.to:o.end.from;return n?se.range(i.anchor,a):se.cursor(a)});return r?(t(hr(e,s)),!0):!1}var vX=({state:e,dispatch:t})=>CX(e,t,!1);function Gn(e,t,n){let r=aa(e.state.selection,s=>{s.undirectional&&s.head>=s.anchor!=t&&(s=se.range(s.head,s.anchor));let i=n(s);return se.range(s.anchor,i.head,i.goalColumn,i.bidiLevel||void 0,i.assoc)});return r.eq(e.state.selection)?!1:(e.dispatch(hr(e.state,r)),!0)}function xO(e,t){return Gn(e,t,n=>e.moveByChar(n,t))}var wO=e=>xO(e,!qt(e)),DO=e=>xO(e,qt(e));function TO(e,t){return Gn(e,t,n=>e.moveByGroup(n,t))}var yX=e=>TO(e,!qt(e)),bX=e=>TO(e,qt(e)),SX=e=>{let t=!qt(e);return Gn(e,t,n=>Vh(e.state,n,t))},EX=e=>{let t=qt(e);return Gn(e,t,n=>Vh(e.state,n,t))};function AO(e,t){return Gn(e,t,n=>e.moveVertically(n,t))}var IO=e=>AO(e,!1),kO=e=>AO(e,!0);function RO(e,t){return Gn(e,t,n=>e.moveVertically(n,t,SO(e).height))}var DE=e=>RO(e,!1),TE=e=>RO(e,!0),xX=e=>Gn(e,!0,t=>ei(e,t,!0)),wX=e=>Gn(e,!1,t=>ei(e,t,!1)),DX=e=>{let t=!qt(e);return Gn(e,t,n=>ei(e,n,t))},TX=e=>{let t=qt(e);return Gn(e,t,n=>ei(e,n,t))},AX=e=>Gn(e,!1,t=>se.cursor(e.lineBlockAt(t.head).from)),IX=e=>Gn(e,!0,t=>se.cursor(e.lineBlockAt(t.head).to)),AE=({state:e,dispatch:t})=>(t(hr(e,{anchor:0})),!0),IE=({state:e,dispatch:t})=>(t(hr(e,{anchor:e.doc.length})),!0),kE=({state:e,dispatch:t})=>(t(hr(e,{anchor:e.selection.main.anchor,head:0})),!0),RE=({state:e,dispatch:t})=>(t(hr(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),kX=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:"select"})),!0),RX=({state:e,dispatch:t})=>{let n=Uh(e).map(({from:r,to:s})=>se.undirectionalRange(r,Math.min(s+1,e.doc.length)));return t(e.update({selection:se.create(n),userEvent:"select"})),!0},OX=({state:e,dispatch:t})=>{let n=aa(e.selection,r=>{let s=Fr(e),i=s.resolveStack(r.from,1);if(r.empty){let o=s.resolveStack(r.from,-1);o.node.from>=i.node.from&&o.node.to<=i.node.to&&(i=o)}for(let o=i;o;o=o.next){let{node:a}=o;if((a.from<r.from&&a.to>=r.to||a.to>r.to&&a.from<=r.from)&&o.next)return se.undirectionalRange(a.from,a.to)}return r});return n.eq(e.selection)?!1:(t(hr(e,n)),!0)};function OO(e,t){let{state:n}=e,r=n.selection,s=n.selection.ranges.slice();for(let i of n.selection.ranges){let o=n.doc.lineAt(i.head);if(t?o.to<e.state.doc.length:o.from>0)for(let a=i;;){let l=e.moveVertically(a,t);if(l.head<o.from||l.head>o.to){s.some(c=>c.head==l.head)||s.push(l);break}else{if(l.head==a.head)break;a=l}}}return s.length==r.ranges.length?!1:(e.dispatch(hr(n,se.create(s,s.length-1))),!0)}var MX=e=>OO(e,!1),NX=e=>OO(e,!0),PX=({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=se.create([n.main]):n.main.empty||(r=se.create([se.cursor(n.main.head)])),r?(t(hr(e,r)),!0):!1};function vc(e,t){if(e.state.readOnly)return!1;let n="delete.selection",{state:r}=e,s=r.changeByRange(i=>{let{from:o,to:a}=i;if(o==a){let l=t(i);l<o?(n="delete.backward",l=Bu(e,l,!1)):l>o&&(n="delete.forward",l=Bu(e,l,!0)),o=Math.min(o,l),a=Math.max(a,l)}else o=Bu(e,o,!1),a=Bu(e,a,!0);return o==a?{range:i}:{changes:{from:o,to:a},range:se.cursor(o,o<i.head?-1:1)}});return s.changes.empty?!1:(e.dispatch(r.update(s,{scrollIntoView:!0,userEvent:n,effects:n=="delete.selection"?xe.announce.of(r.phrase("Selection deleted")):void 0})),!0)}function Bu(e,t,n){if(e instanceof xe)for(let r of e.state.facet(xe.atomicRanges).map(s=>s(e)))r.between(t,t,(s,i)=>{s<t&&i>t&&(t=n?i:s)});return t}var MO=(e,t,n)=>vc(e,r=>{let s=r.from,{state:i}=e,o=i.doc.lineAt(s),a,l;if(n&&!t&&s>o.from&&s<o.from+200&&!/[^ \t]/.test(a=o.text.slice(0,s-o.from))){if(a[a.length-1]==" ")return s-1;let c=Mh(a,i.tabSize)%Gd(i)||Gd(i);for(let u=0;u<c&&a[a.length-1-u]==" ";u++)s--;l=s}else l=Wt(o.text,s-o.from,t,t)+o.from,l==s&&o.number!=(t?i.doc.lines:1)?l+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(o.text.slice(l-o.from,s-o.from))&&(l=Wt(o.text,l-o.from,!1,!1)+o.from);return l}),og=e=>MO(e,!1,!0),NO=e=>MO(e,!0,!1),PO=(e,t)=>vc(e,n=>{let r=n.head,{state:s}=e,i=s.doc.lineAt(r),o=s.charCategorizer(r);for(let a=null;;){if(r==(t?i.to:i.from)){r==n.head&&i.number!=(t?s.doc.lines:1)&&(r+=t?1:-1);break}let l=Wt(i.text,r-i.from,t)+i.from,c=i.text.slice(Math.min(r,l)-i.from,Math.max(r,l)-i.from),u=o(c);if(a!=null&&u!=a)break;(c!=" "||r!=n.head)&&(a=u),r=l}return r}),LO=e=>PO(e,!1),LX=e=>PO(e,!0),_X=e=>vc(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),FX=e=>vc(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),HX=e=>vc(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),jX=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:Fe.of(["",""])},range:se.cursor(r.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},GX=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(r=>{if(!r.empty||r.from==0||r.from==e.doc.length)return{range:r};let s=r.from,i=e.doc.lineAt(s),o=s==i.from?s-1:Wt(i.text,s-i.from,!1)+i.from,a=s==i.to?s+1:Wt(i.text,s-i.from,!0)+i.from;return{changes:{from:o,to:a,insert:e.doc.slice(s,a).append(e.doc.slice(o,s))},range:se.cursor(a)}});return n.changes.empty?!1:(t(e.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Uh(e){let t=[],n=-1;for(let r of e.selection.ranges){let s=e.doc.lineAt(r.from),i=e.doc.lineAt(r.to);if(!r.empty&&r.to==i.from&&(i=e.doc.lineAt(r.to-1)),n>=s.number){let o=t[t.length-1];o.to=i.to,o.ranges.push(r)}else t.push({from:s.from,to:i.to,ranges:[r]});n=i.number+1}return t}function _O(e,t,n){if(e.readOnly)return!1;let r=[],s=[];for(let i of Uh(e)){if(n?i.to==e.doc.length:i.from==0)continue;let o=e.doc.lineAt(n?i.to+1:i.from-1),a=o.length+1;if(n){r.push({from:i.to,to:o.to},{from:i.from,insert:o.text+e.lineBreak});for(let l of i.ranges)s.push(se.range(Math.min(e.doc.length,l.anchor+a),Math.min(e.doc.length,l.head+a)))}else{r.push({from:o.from,to:i.from},{from:i.to,insert:e.lineBreak+o.text});for(let l of i.ranges)s.push(se.range(l.anchor-a,l.head-a))}}return r.length?(t(e.update({changes:r,scrollIntoView:!0,selection:se.create(s,e.selection.mainIndex),userEvent:"move.line"})),!0):!1}var VX=({state:e,dispatch:t})=>_O(e,t,!1),UX=({state:e,dispatch:t})=>_O(e,t,!0);function FO(e,t,n){if(e.readOnly)return!1;let r=[];for(let i of Uh(e))n?r.push({from:i.from,insert:e.doc.slice(i.from,i.to)+e.lineBreak}):r.push({from:i.to,insert:e.lineBreak+e.doc.slice(i.from,i.to)});let s=e.changes(r);return t(e.update({changes:s,selection:e.selection.map(s,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}var zX=({state:e,dispatch:t})=>FO(e,t,!1),$X=({state:e,dispatch:t})=>FO(e,t,!0),WX=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(Uh(t).map(({from:s,to:i})=>(s>0?s--:i<t.doc.length&&i++,{from:s,to:i}))),r=aa(t.selection,s=>{let i;if(e.lineWrapping){let o=e.lineBlockAt(s.head),a=e.coordsAtPos(s.head,s.assoc||1);a&&(i=o.bottom+e.documentTop-a.bottom+e.defaultLineHeight/2)}return e.moveVertically(s,!0,i)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0};function qX(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=Fr(e).resolveInner(t),r=n.childBefore(t),s=n.childAfter(t),i;return r&&s&&r.to<=t&&s.from>=t&&(i=r.type.prop(ke.closedBy))&&i.indexOf(s.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(s.from).from&&!/\S/.test(e.sliceDoc(r.to,s.from))?{from:r.to,to:s.from}:null}var OE=HO(!1),KX=HO(!0);function HO(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(s=>{let{from:i,to:o}=s,a=t.doc.lineAt(i),l=!e&&i==o&&qX(t,i);e&&(i=o=(o<=a.to?a:t.doc.lineAt(o)).to);let c=new jh(t,{simulateBreak:i,simulateDoubleBreak:!!l}),u=mv(c,i);for(u==null&&(u=Mh(/^\s*/.exec(t.doc.lineAt(i).text)[0],t.tabSize));o<a.to&&/\s/.test(a.text[o-a.from]);)o++;l?{from:i,to:o}=l:i>a.from&&i<a.from+100&&!/\S/.test(a.text.slice(0,i))&&(i=a.from);let d=["",Vl(t,u)];return l&&d.push(Vl(t,c.lineIndent(a.from,-1))),{changes:{from:i,to:o,insert:Fe.of(d)},range:se.cursor(i+1+d[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:"input"})),!0}}function yv(e,t){let n=-1;return e.changeByRange(r=>{let s=[];for(let o=r.from;o<=r.to;){let a=e.doc.lineAt(o);a.number>n&&(r.empty||r.to>a.from)&&(t(a,s,r),n=a.number),o=a.to+1}let i=e.changes(s);return{changes:s,range:se.range(i.mapPos(r.anchor,1),i.mapPos(r.head,1))}})}var JX=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new jh(e,{overrideIndentation:i=>{let o=n[i];return o??-1}}),s=yv(e,(i,o,a)=>{let l=mv(r,i.from);if(l==null)return;/\S/.test(i.text)||(l=0);let c=/^\s*/.exec(i.text)[0],u=Vl(e,l);(c!=u||a.from<i.from+c.length)&&(n[i.from]=l,o.push({from:i.from,to:i.from+c.length,insert:u}))});return s.changes.empty||t(e.update(s,{userEvent:"indent"})),!0},jO=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(yv(e,(n,r)=>{r.push({from:n.from,insert:e.facet(pv)})}),{userEvent:"input.indent"})),!0),GO=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(yv(e,(n,r)=>{let s=/^\s*/.exec(n.text)[0];if(!s)return;let i=Mh(s,e.tabSize),o=0,a=Vl(e,Math.max(0,i-Gd(e)));for(;o<s.length&&o<a.length&&s.charCodeAt(o)==a.charCodeAt(o);)o++;r.push({from:n.from+o,to:n.from+s.length,insert:a.slice(o)})}),{userEvent:"delete.dedent"})),!0),QX=e=>(e.setTabFocusMode(),!0),YX=[{key:"Ctrl-b",run:mO,shift:wO,preventDefault:!0},{key:"Ctrl-f",run:gO,shift:DO},{key:"Ctrl-p",run:yO,shift:IO},{key:"Ctrl-n",run:bO,shift:kO},{key:"Ctrl-a",run:mX,shift:AX},{key:"Ctrl-e",run:gX,shift:IX},{key:"Ctrl-d",run:NO},{key:"Ctrl-h",run:og},{key:"Ctrl-k",run:_X},{key:"Ctrl-Alt-h",run:LO},{key:"Ctrl-o",run:jX},{key:"Ctrl-t",run:GX},{key:"Ctrl-v",run:ig}],XX=[{key:"ArrowLeft",run:mO,shift:wO,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:aX,shift:yX,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:BX,shift:DX,preventDefault:!0},{key:"ArrowRight",run:gO,shift:DO,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:lX,shift:bX,preventDefault:!0},{mac:"Cmd-ArrowRight",run:pX,shift:TX,preventDefault:!0},{key:"ArrowUp",run:yO,shift:IO,preventDefault:!0},{mac:"Cmd-ArrowUp",run:AE,shift:kE},{mac:"Ctrl-ArrowUp",run:wE,shift:DE},{key:"ArrowDown",run:bO,shift:kO,preventDefault:!0},{mac:"Cmd-ArrowDown",run:IE,shift:RE},{mac:"Ctrl-ArrowDown",run:ig,shift:TE},{key:"PageUp",run:wE,shift:DE},{key:"PageDown",run:ig,shift:TE},{key:"Home",run:fX,shift:wX,preventDefault:!0},{key:"Mod-Home",run:AE,shift:kE},{key:"End",run:hX,shift:xX,preventDefault:!0},{key:"Mod-End",run:IE,shift:RE},{key:"Enter",run:OE,shift:OE},{key:"Mod-a",run:kX},{key:"Backspace",run:og,shift:og,preventDefault:!0},{key:"Delete",run:NO,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:LO,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:LX,preventDefault:!0},{mac:"Mod-Backspace",run:FX,preventDefault:!0},{mac:"Mod-Delete",run:HX,preventDefault:!0}].concat(YX.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),ZX=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:uX,shift:SX},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:dX,shift:EX},{key:"Alt-ArrowUp",run:VX},{key:"Shift-Alt-ArrowUp",run:zX},{key:"Alt-ArrowDown",run:UX},{key:"Shift-Alt-ArrowDown",run:$X},{key:"Mod-Alt-ArrowUp",run:MX},{key:"Mod-Alt-ArrowDown",run:NX},{key:"Escape",run:PX},{key:"Mod-Enter",run:KX},{key:"Alt-l",mac:"Ctrl-l",run:RX},{key:"Mod-i",run:OX,preventDefault:!0},{key:"Mod-[",run:GO},{key:"Mod-]",run:jO},{key:"Mod-Alt-\\",run:JX},{key:"Shift-Mod-k",run:WX},{key:"Shift-Mod-\\",run:vX},{key:"Mod-/",run:W7},{key:"Alt-A",mac:"Ctrl-A",run:K7},{key:"Ctrl-m",mac:"Shift-Alt-m",run:QX}].concat(XX),eZ={key:"Tab",run:jO,shift:GO},tZ=xe.theme({"&":{height:"100%",width:"100%",backgroundColor:"transparent",color:"var(--foreground)",fontSize:"12px"},"&.cm-focused":{outline:"none"},".cm-scroller":{height:"100%",overflow:"auto",fontFamily:"var(--font-code)",lineHeight:"20px"},".cm-content":{minHeight:"100%",padding:"12px 0",caretColor:"var(--foreground)"},".cm-line":{padding:"0 12px"},".cm-gutters":{backgroundColor:"color-mix(in oklch, var(--muted) 50%, transparent)",color:"var(--muted-foreground)",borderRight:"1px solid color-mix(in oklch, var(--border) 50%, transparent)",fontFamily:"var(--font-code)",fontSize:"12px",lineHeight:"20px",paddingTop:"12px"},".cm-lineNumbers .cm-gutterElement":{minWidth:"2.5rem",padding:"0 8px 0 0"},".cm-activeLine":{backgroundColor:"color-mix(in oklch, var(--foreground) 3%, transparent)"},".cm-activeLineGutter":{backgroundColor:"color-mix(in oklch, var(--foreground) 3%, transparent)",color:"var(--foreground)",fontWeight:"500"},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:"color-mix(in oklch, var(--primary) 20%, transparent)"},"&.cm-focused .cm-cursor":{borderLeftColor:"var(--foreground)"},".cm-matchingBracket":{backgroundColor:"color-mix(in oklch, var(--primary) 14%, transparent)",outline:"1px solid color-mix(in oklch, var(--primary) 35%, transparent)"}}),nZ=gv.define([{tag:re.propertyName,color:"var(--json-key)"},{tag:re.string,color:"var(--json-string)"},{tag:re.number,color:"var(--json-number)"},{tag:re.bool,color:"var(--json-boolean)"},{tag:re.null,color:"var(--json-null)"},{tag:re.punctuation,color:"var(--json-punctuation)"},{tag:re.invalid,color:"var(--destructive)"}]);function ME(e){const t=e.state.selection.main.head,n=e.state.doc.lineAt(t);return{line:n.number,column:t-n.from+1}}function NE(e,t){return typeof e=="number"?`${e}px`:e??t}function rZ({content:e,onChange:t,onCursorChange:n,onUndo:r,onRedo:s,onEscape:i,isValid:o=!0,height:a,maxHeight:l,showLineNumbers:c=!0,wrapLongLines:u=!0,className:d}){const h=(0,p.useRef)(null),f=(0,p.useRef)(null),B=(0,p.useRef)(e),g=(0,p.useRef)({onChange:t,onCursorChange:n,onUndo:r,onRedo:s,onEscape:i});B.current=e,g.current={onChange:t,onCursorChange:n,onUndo:r,onRedo:s,onEscape:i};const C=(0,p.useMemo)(()=>{const v=[tZ,I7(nZ),$7(),UY(),D7(),_7(),KY(),xe.updateListener.of(y=>{y.docChanged&&g.current.onChange?.(y.state.doc.toString()),(y.docChanged||y.selectionSet||y.focusChanged)&&g.current.onCursorChange?.(ME(y.view))}),XR.of([{key:"Mod-z",run:()=>(g.current.onUndo?.(),!0)},{key:"Mod-y",run:()=>(g.current.onRedo?.(),!0)},{key:"Shift-Mod-z",run:()=>(g.current.onRedo?.(),!0)},{key:"Escape",run:()=>(g.current.onEscape?.(),!0)},eZ,...ZX])];return c&&v.push(i7(),l7()),u&&v.push(xe.lineWrapping),v},[c,u]);return(0,p.useEffect)(()=>{if(!h.current)return;const v=new xe({state:bt.create({doc:B.current,extensions:C}),parent:h.current});return f.current=v,g.current.onCursorChange?.(ME(v)),()=>{v.destroy(),f.current=null}},[C]),(0,p.useEffect)(()=>{const v=f.current;if(!v||v.state.doc.toString()===e)return;const y=Math.min(v.state.selection.main.head,e.length);v.dispatch({changes:{from:0,to:v.state.doc.length,insert:e},selection:{anchor:y}})},[e]),(0,m.jsx)("div",{className:he("h-full w-full overflow-hidden bg-muted/30",!o&&"border-destructive",d),style:{height:NE(a,"100%"),maxHeight:NE(l,"none")},children:(0,m.jsx)("div",{ref:h,className:"h-full w-full"})})}function sZ({options:e,value:t,onChange:n,className:r,size:s="sm",disabled:i=!1}){const o=(0,p.useRef)(null),[a,l]=(0,p.useState)({});return(0,p.useEffect)(()=>{const c=o.current;if(!c)return;const u=e.findIndex(h=>h.value===t),d=c.querySelectorAll("button")[u];d&&l({width:d.offsetWidth,transform:`translateX(${d.offsetLeft}px)`})},[t,e,s]),(0,m.jsxs)("div",{ref:o,className:he("relative inline-flex items-center rounded-md bg-muted/50",s==="default"?"p-1":"p-0.5",i&&"opacity-50",r),children:[(0,m.jsx)("div",{className:he("absolute left-0 rounded-md bg-background shadow-sm","transition-all duration-200 ease-out",s==="default"?"top-1 h-[calc(100%-8px)]":"top-0.5 h-[calc(100%-4px)]"),style:a}),e.map(c=>(0,m.jsxs)("button",{type:"button",disabled:i||c.disabled,title:c.title,"aria-pressed":t===c.value,onClick:()=>n(c.value),className:he("relative z-10 flex items-center rounded-md font-medium transition-colors duration-200",s==="default"?"gap-2 px-3.5 py-1.5 text-sm":"gap-1.5 px-2.5 py-1 text-xs",t===c.value?"text-foreground":"text-muted-foreground hover:text-foreground/80",(i||c.disabled)&&"cursor-not-allowed",c.disabled&&!i&&"opacity-50"),children:[c.icon,c.label]},c.value))]})}var iZ=[{value:"view",label:"View",icon:(0,m.jsx)(uH,{className:"h-3 w-3"})},{value:"edit",label:"Edit",icon:(0,m.jsx)(vH,{className:"h-3 w-3"})}];function oZ({mode:e,onModeChange:t,showModeToggle:n=!0,readOnly:r=!1,onFormat:s,onCopy:i,onUndo:o,onRedo:a,canUndo:l=!1,canRedo:c=!1,isMaximized:u=!1,onToggleMaximize:d,allowMaximize:h=!1,isValid:f=!0,className:B,leftContent:g,rightContent:C,error:v}){const[y,b]=(0,p.useState)(!1),E=(0,p.useRef)(null);(0,p.useEffect)(()=>()=>{E.current&&clearTimeout(E.current)},[]);const w=async()=>{let A;try{A=await i?.()}catch{return}A!==!1&&(E.current&&clearTimeout(E.current),b(!0),E.current=setTimeout(()=>b(!1),2e3))};return(0,m.jsxs)("div",{className:he("flex items-center justify-between border-b border-border/50 px-3 py-1.5 bg-muted/50",B),children:[(0,m.jsxs)("div",{className:"flex shrink-0 items-center gap-2",children:[g,n&&!r&&t&&(0,m.jsx)(sZ,{options:iZ,value:e,onChange:t})]}),v?(0,m.jsxs)(xs,{children:[(0,m.jsx)(ws,{asChild:!0,children:(0,m.jsxs)("div",{className:"mx-3 flex min-w-0 flex-1 cursor-default items-center gap-1.5 text-xs text-destructive",children:[(0,m.jsx)(ch,{className:"h-3 w-3 shrink-0"}),(0,m.jsx)("span",{className:"truncate",children:v})]})}),(0,m.jsx)(Ds,{side:"bottom",className:"max-w-[min(40rem,calc(100vw-2rem))] break-words",children:(0,m.jsx)("p",{children:v})})]}):null,(0,m.jsxs)("div",{className:"flex shrink-0 items-center gap-1",children:[e==="edit"&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(xs,{children:[(0,m.jsx)(ws,{asChild:!0,children:(0,m.jsx)(kn,{size:"sm",variant:"ghost",onClick:o,disabled:!l,className:"h-7 w-7 p-0 transition-all duration-200 hover:scale-105",children:(0,m.jsx)(wH,{className:"h-3.5 w-3.5"})})}),(0,m.jsx)(Ds,{side:"bottom",children:(0,m.jsx)("p",{children:"Undo (Ctrl+Z)"})})]}),(0,m.jsxs)(xs,{children:[(0,m.jsx)(ws,{asChild:!0,children:(0,m.jsx)(kn,{size:"sm",variant:"ghost",onClick:a,disabled:!c,className:"h-7 w-7 p-0 transition-all duration-200 hover:scale-105",children:(0,m.jsx)(SH,{className:"h-3.5 w-3.5"})})}),(0,m.jsx)(Ds,{side:"bottom",children:(0,m.jsx)("p",{children:"Redo (Ctrl+Shift+Z)"})})]}),(0,m.jsx)("div",{className:"w-px h-4 bg-border mx-1"}),(0,m.jsxs)(xs,{children:[(0,m.jsx)(ws,{asChild:!0,children:(0,m.jsx)(kn,{size:"sm",variant:"ghost",onClick:s,disabled:!f,className:"h-7 w-7 p-0 transition-all duration-200 hover:scale-105",children:(0,m.jsx)(xH,{className:"h-3.5 w-3.5"})})}),(0,m.jsx)(Ds,{side:"bottom",children:(0,m.jsx)("p",{children:"Format JSON"})})]})]}),(0,m.jsxs)(xs,{children:[(0,m.jsx)(ws,{asChild:!0,children:(0,m.jsx)(kn,{size:"sm",variant:"ghost",onClick:w,className:he("h-7 w-7 p-0 transition-all duration-200 hover:scale-105",y&&"bg-success/10"),children:y?(0,m.jsx)(Vs,{className:"h-3.5 w-3.5 text-success"}):(0,m.jsx)(_s,{className:"h-3.5 w-3.5"})})}),(0,m.jsx)(Ds,{side:"bottom",children:(0,m.jsx)("p",{children:y?"Copied!":"Copy to clipboard"})})]}),h&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)("div",{className:"w-px h-4 bg-border mx-1"}),(0,m.jsxs)(xs,{children:[(0,m.jsx)(ws,{asChild:!0,children:(0,m.jsx)(kn,{size:"sm",variant:"ghost",onClick:d,className:"h-7 w-7 p-0 transition-all duration-200 hover:scale-105",children:u?(0,m.jsx)(mH,{className:"h-3.5 w-3.5"}):(0,m.jsx)(BH,{className:"h-3.5 w-3.5"})})}),(0,m.jsx)(Ds,{side:"bottom",children:(0,m.jsx)("p",{children:u?"Exit fullscreen":"Fullscreen"})})]})]}),C&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)("div",{className:"w-px h-4 bg-border mx-1"}),C]})]})]})}function aZ({cursorPosition:e,characterCount:t,validationError:n,className:r}){return(0,m.jsxs)("div",{className:he("flex items-center justify-between gap-3 px-3 py-1.5 border-t border-border/50","bg-gradient-to-r from-muted/40 via-muted/30 to-muted/40","text-xs text-muted-foreground tabular-nums transition-colors duration-300",r),style:{fontFamily:"var(--font-code)"},children:[(0,m.jsxs)("div",{className:"flex items-center gap-3",children:[(0,m.jsxs)("span",{className:"transition-colors duration-200",children:["Ln ",e.line,", Col ",e.column]}),(0,m.jsxs)("span",{className:"transition-colors duration-200",children:[t.toLocaleString()," chars"]})]}),n?(0,m.jsxs)(xs,{children:[(0,m.jsx)(ws,{asChild:!0,children:(0,m.jsxs)("div",{className:"flex min-w-0 cursor-default items-center gap-1.5 text-destructive",children:[(0,m.jsx)(ch,{className:"h-3 w-3 shrink-0"}),(0,m.jsx)("span",{className:"truncate",children:n})]})}),(0,m.jsx)(Ds,{side:"top",className:"max-w-[min(40rem,calc(100vw-2rem))] break-words",children:(0,m.jsx)("p",{children:n})})]}):null]})}function lZ(e){if(e===void 0)return"null";try{return JSON.stringify(e,null,2)??"null"}catch{return"null"}}function ag(){return(0,m.jsxs)("div",{className:"flex items-center justify-center p-4 text-sm text-muted-foreground",children:[(0,m.jsx)(ch,{className:"h-4 w-4 mr-2 text-destructive"}),"Failed to render JSON content"]})}function cZ(e){return e.viewOnly&&e.rawContent===void 0?(0,m.jsx)(uZ,{...e}):(0,m.jsx)(dZ,{...e})}function uZ({value:e,expandJsonStrings:t=!1,className:n,height:r,maxHeight:s,collapsible:i=!1,defaultExpandDepth:o,collapsedPaths:a,onCollapseChange:l,showLineNumbers:c=!0,collapseStringsAfterLength:u,wrapLongLinesInView:d=!0}){const h=(0,p.useMemo)(()=>t?Di(e):e,[t,e]);return(0,m.jsx)(Dd,{fallback:(0,m.jsx)(ag,{}),children:(0,m.jsx)(em,{value:h,className:n,height:r??"100%",maxHeight:s,collapsible:i,defaultExpandDepth:o,collapsedPaths:a,onCollapseChange:l,showLineNumbers:c,collapseStringsAfterLength:u,wrapLongLinesInView:d})})}function dZ({value:e,onChange:t,rawContent:n,onRawChange:r,mode:s,onModeChange:i,readOnly:o=!1,showModeToggle:a=!0,showToolbar:l=!0,allowMaximize:c=!1,height:u,maxHeight:d,className:h,onValidationError:f,collapsible:B=!1,defaultExpandDepth:g,collapsedPaths:C,onCollapseChange:v,collapseStringsAfterLength:y,viewOnly:b=!1,expandJsonStrings:E=!1,autoFormatOnEdit:w=!0,wrapLongLinesInEdit:A=!1,editSurface:x="codemirror",wrapLongLinesInView:O=!0,showLineNumbers:R=!0,toolbarLeftContent:P,toolbarRightContent:_,error:N,showValidationErrorInStatusBar:q=!0}){const W=n!==void 0,[F,z]=(0,p.useState)("view"),J=o?"view":s??F,[Z,Q]=(0,p.useState)(!1),G=cJ({initialValue:W?void 0:e,initialContent:W?n:void 0,onChange:t,onRawChange:W?r:void 0,onValidationError:f,expandJsonStrings:E}),be=W?n??"":G.sourceContent,ve=G.content!==be,X=(0,p.useRef)(J),Y=(0,p.useRef)(!1),ie=(0,p.useMemo)(()=>W?G.getParsedValue():E?Di(e):e,[G.content,E,W,e]);(0,p.useEffect)(()=>{const Ee=X.current,st=!Y.current;Y.current=!0,X.current=J,!(b||o||!w)&&(!(J==="edit"&&(st||Ee!=="edit"))||!G.isValid||G.format())},[J,G.format,G.isValid,w,o,b]);const ne=(0,p.useCallback)(Ee=>{if(!o){if(J==="edit"&&Ee==="view"&&ve&&!G.isValid){if(!window.confirm("The JSON is invalid. Switching to view mode will lose your changes. Continue?"))return;G.reset()}z(Ee),i?.(Ee)}},[J,ve,G,i,o]),ee=(0,p.useCallback)(async()=>{let Ee;return J==="edit"?Ee=G.content:W?Ee=n??"":Ee=lZ(e),ra(Ee)},[J,G.content,e,W,n]),Be=(0,p.useCallback)(()=>{ve&&!window.confirm("You have unsaved changes. Discard them?")||(G.reset(),z("view"),i?.("view"))},[ve,G,i]),de=(0,p.useCallback)(()=>{Q(Ee=>!Ee)},[]);if(b)return(0,m.jsx)(Dd,{fallback:(0,m.jsx)(ag,{}),children:(0,m.jsx)(em,{value:ie,className:h,height:u??"100%",maxHeight:d,collapsible:B,defaultExpandDepth:g,collapsedPaths:C,onCollapseChange:v,showLineNumbers:R,collapseStringsAfterLength:y,wrapLongLinesInView:O})});const Re=Z?{position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:50}:{height:u??"100%",maxHeight:d??"none"};return(0,m.jsx)(Dd,{fallback:(0,m.jsx)(ag,{}),children:(0,m.jsxs)("div",{className:he("flex flex-col rounded-lg bg-background overflow-hidden",Z&&"rounded-none",h),style:Re,children:[l&&(0,m.jsx)(oZ,{mode:J,onModeChange:ne,showModeToggle:a&&!o,readOnly:o,onFormat:G.format,onCopy:ee,onUndo:G.undo,onRedo:G.redo,canUndo:G.canUndo,canRedo:G.canRedo,isMaximized:Z,onToggleMaximize:de,allowMaximize:c,isValid:G.isValid,leftContent:P,rightContent:_,error:N}),(0,m.jsx)("div",{className:"flex-1 min-h-0 h-full",children:J==="view"?(0,m.jsx)(em,{value:ie,height:u??"100%",collapsible:B,defaultExpandDepth:g,collapsedPaths:C,onCollapseChange:v,showLineNumbers:R,collapseStringsAfterLength:y,wrapLongLinesInView:O}):x==="codemirror"?(0,m.jsx)(rZ,{content:G.content,onChange:G.setContent,onCursorChange:G.setCursorPosition,onUndo:G.undo,onRedo:G.redo,onEscape:Be,isValid:G.isValid,height:u??"100%",maxHeight:Z?void 0:d,showLineNumbers:R,wrapLongLines:A}):(0,m.jsx)(XI,{content:G.content,onChange:G.setContent,onCursorChange:G.setCursorPosition,onUndo:G.undo,onRedo:G.redo,onEscape:Be,isValid:G.isValid,height:u??"100%",maxHeight:Z?void 0:d,showLineNumbers:R,wrapLongLinesInEdit:A,wrapLongLinesInView:O})}),J==="edit"&&(0,m.jsx)(aZ,{cursorPosition:G.cursorPosition,characterCount:G.content.length,validationError:q?G.validationError:null})]})})}function hZ({value:e,className:t,collapsible:n=!1,defaultExpandDepth:r,collapsedPaths:s,onCollapseChange:i,collapseStringsAfterLength:o,expandJsonStrings:a=!1,wrapLongLinesInView:l=!0,showLineNumbers:c=!0,containerClassName:u}){return(0,m.jsx)("div",{className:he("overflow-auto",u),children:(0,m.jsx)(cZ,{value:e,className:t,collapsible:n,defaultExpandDepth:r,collapsedPaths:s,onCollapseChange:i,collapseStringsAfterLength:o,expandJsonStrings:a,wrapLongLinesInView:l,showLineNumbers:c,height:"auto",viewOnly:!0,showToolbar:!1})})}var fZ=class extends Error{};function _ae(e){return typeof e=="string"&&e===e.trim()&&/^[A-Za-z0-9][A-Za-z0-9._~:-]{0,255}$/.test(e)&&!e.startsWith("server-")}function BZ(e){const t=()=>new fZ("PLUGIN_DEEP_LINK_INVALID");if(typeof e!="string"||e.length>8192||/[\s\\#\u0000-\u001f\u007f]/.test(e))throw t();const n=/^(codex|chatgpt):\/\/plugins\/([^/?]+)\/app\/([^/?]+)(?:\?([^#]*))?$/.exec(e),r=/^https:\/\/chatgpt\.com\/plugins\/([^/?]+)\/app\/([^/?]+)(?:\?([^#]*))?$/.exec(e);if(!n&&!r)throw t();const s=n?n[1]:"https",i=n?n[2]:r[1],o=n?n[3]:r[2],a=n?n[4]:r[3],l=i.split("@");if(l.length>2||s==="https"&&l.length!==1)throw t();const c=C=>{let v;try{v=decodeURIComponent(C)}catch{throw t()}if(!v||v.length>256||/[\u0000-\u001f\u007f\\]/.test(v))throw t();return v},u=c(l[0]),d=l[1]===void 0?void 0:c(l[1]),h=c(o);if([u,d,h].some(C=>C==="."||C==="..")||a&&/%(?![\da-f]{2})/i.test(a))throw t();const f=new URLSearchParams(a),B=[...f.entries()];if(B.some(([C])=>C!=="path")||B.length>1)throw t();const g=f.get("path")??"/";if(!g.startsWith("/")||g.startsWith("//")||g.length>4096||/[\u0000-\u001f\u007f\\#]/.test(g)||new TextEncoder().encode(g).byteLength>8192)throw t();return{scheme:s,pluginId:u,...d===void 0?{}:{marketplace:d},toolName:h,url:g}}var VO=(0,p.createContext)(null);function Fae({value:e,children:t}){return(0,m.jsx)(VO.Provider,{value:e,children:t})}function PE(e){try{return BZ(e),!0}catch{return!1}}function lg(e){return typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(lg).join(""):(0,p.isValidElement)(e)?lg(e.props.children):""}var pZ=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),SB=e=>e.replace(/([\\[\]])/g,"\\$1"),UO="#mcpjam-link-",mZ=/(?:codex|chatgpt):\/\/plugins\/[^\s)\]>]+|https:\/\/chatgpt\.com\/plugins\/[^\s)\]>]+/g,gZ=/(`[^`\n]*`)|\[((?:\\.|[^\[\]\\])*)\]\(\s*<?([^\s)>]+)>?(?:\s+"[^"]*")?\s*\)|<([a-z][a-z0-9+.-]*:[^>\s]+)>/gi;function CZ(e,t,n){const r=[],s=d=>!!t[d]||n&&PE(d),i=(d,h)=>(r.push(h),`[${d}](${UO}${r.length-1})`);if(/^\s*(```|~~~)/.test(e))return{content:e,targets:r};const o=Object.keys(t).filter(d=>e.includes(d)).sort((d,h)=>h.length-d.length),a=o.length?new RegExp(o.map(pZ).join("|"),"g"):null,l=d=>{let h=a?d.replace(a,f=>i(SB(t[f]?.name??f),f)):d;return n&&(h=h.replace(mZ,f=>PE(f)?i(SB(f),f):f)),h};let c="",u=0;for(const d of e.matchAll(gZ)){c+=l(e.slice(u,d.index)),u=d.index+d[0].length;const[h,f,B,g,C]=d;f!==void 0?c+=h:g!==void 0?c+=s(g)?i(B,g):h:C!==void 0?c+=s(C)?i(SB(t[C]?.name??C),C):h:c+=h}return{content:c+l(e.slice(u)),targets:r}}function vZ(){const e=tJ(),t=(0,p.useContext)(VO),n=(0,p.useCallback)(r=>{const s=CZ(r,e,!!t);if(!s.targets.length)return null;const i=HN.a,o=a=>{const l=typeof a.href=="string"?a.href:"",c=l.startsWith(UO)?Number(l.slice(13)):NaN,u=Number.isInteger(c)?s.targets[c]:void 0;if(!u)return(0,m.jsx)(i,{...a});const d=e[u];if(d){const h=lg(a.children).trim();return(0,m.jsx)(WI,{reference:{serverId:d.serverId,resourceUri:u},label:!h||h===u?d.name:a.children})}return(0,m.jsx)("button",{type:"button",className:"text-primary underline underline-offset-2",title:u,onClick:()=>t?.open(u),children:a.children})};return{content:s.content,components:{a:o}}},[e,t]);return Object.keys(e).length||t?n:null}var zO=(0,p.createContext)({linkBase:null,trustLinks:!1});function Hae({base:e,trustLinks:t=!1,children:n}){const r=(0,p.useMemo)(()=>({linkBase:e,trustLinks:t}),[e,t]);return(0,m.jsx)(zO.Provider,{value:r,children:n})}function yZ(e){if(!e)return;const t=e.replace(/\/$/,"");return(n,r,s)=>n.startsWith("/")&&!n.startsWith("//")?t+n:FN(n,r,s)}function bZ(e){const t=_N.lexer(e);return t.length===0?[e]:t.map(n=>n.raw)}var $O=(0,p.memo)(({content:e})=>{const{linkBase:t,trustLinks:n}=(0,p.useContext)(zO),r=vZ(),s=(0,p.useMemo)(()=>yZ(t),[t]),i=(0,p.useMemo)(()=>n?{enabled:!1}:void 0,[n]),o=(0,p.useMemo)(()=>r?.(e)??null,[r,e]);return(0,m.jsx)(LN,{linkSafety:i,urlTransform:s,...o?{components:o.components}:{},children:o?o.content:e})},(e,t)=>e.content===t.content);$O.displayName="MemoizedMarkdownBlock";var WO=(0,p.memo)(({content:e,className:t})=>(0,p.useMemo)(()=>bZ(e),[e]).map((n,r)=>(0,m.jsx)("div",{className:t,children:(0,m.jsx)($O,{content:n})},`markdown-block_${r}`)),(e,t)=>!(e.content!==t.content||e.className!==t.className));WO.displayName="MemoizedMarkdown";var qO="/web/artifact",KO=3e4,SZ=15e3,EZ=2e3,xZ=2e4,wZ=new Set([401,403,404,410]),DZ=new Set([404,410]),TZ=1,AZ=6e5;function yc(e){if(!e)return!1;try{const t=new URL(e);return(t.protocol==="https:"||t.protocol==="http:")&&t.pathname.endsWith(qO)&&t.searchParams.has("t")}catch{return!1}}function zh(e){if(!yc(e))return null;const t=new URL(e).searchParams.get("t")??"",n=t.lastIndexOf(".");if(n<=0)return null;const r=t.slice(0,n).replace(/-/g,"+").replace(/_/g,"/");try{const s=JSON.parse(atob(r+"=".repeat((4-r.length%4)%4)));if(!s||typeof s!="object")return null;const{s:i,k:o,e:a}=s;return typeof i=="string"&&typeof o=="string"&&typeof a=="number"?{s:i,k:o,e:a}:null}catch{return null}}function bv(e,t){return`artifact:${new URL(e).origin}:${t.k}:${t.s}`}function Sv(e){const t=zh(e);return t?bv(e,t):e}var qo=new Map,JO=0,zl=new Set;function IZ(e){for(const[t,n]of qo)n.expiresAt<=e&&qo.delete(t)}function kZ(e){const t=zh(e);if(!t)return!1;const n=bv(e,t),r=t.e*1e3,s=qo.get(n);return s&&s.expiresAt>=r?!1:(qo.set(n,{url:e,expiresAt:r}),!0)}function RZ(e){let t=!1,n=xZ;const r=[e];for(;r.length>0&&n>0;){n-=1;const s=r.pop();if(typeof s=="string")s.includes(qO)&&kZ(s)&&(t=!0);else if(Array.isArray(s))for(const i of s)r.push(i);else if(s&&typeof s=="object")for(const i of Object.values(s))r.push(i)}if(t){qo.size>EZ&&IZ(Date.now()),JO+=1;for(const s of zl)s()}}function Vd(e){const t=zh(e);if(!t)return e;const n=qo.get(bv(e,t));return n&&n.expiresAt>t.e*1e3?n.url:e}function OZ(e){return zl.add(e),()=>{zl.delete(e)}}function LE(){return JO}function MZ(e,t){const n=Vd(e);return n!==e?Promise.resolve(n):new Promise(r=>{const s=()=>{const a=Vd(e);a!==e&&(o(),r(a))},i=setTimeout(()=>{o(),r(null)},t),o=()=>{clearTimeout(i),zl.delete(s)};zl.add(s)})}function Ev(e){return(0,p.useSyncExternalStore)(OZ,LE,LE),typeof e=="string"?Vd(e):e}var cg,ug=Number.NEGATIVE_INFINITY,dg=new Set,Ud=new Map;function QO(e){return(Ud.get(Sv(e))??0)<TZ}function YO(e){const t=Sv(e);Ud.set(t,(Ud.get(t)??0)+1)}function hg(e){Ud.delete(Sv(e))}function XO(e=Date.now()){if(e-ug<KO)return!1;ug=e,cg=Math.max((cg??0)+1,Math.floor(e/6e4));for(const t of dg)t();return!0}function NZ(e){return dg.add(e),()=>{dg.delete(e)}}function _E(){return cg}function PZ(){return(0,p.useSyncExternalStore)(NZ,_E,_E)}async function LZ(e,t){const n=Vd(e),r=t===void 0?await fetch(n):await fetch(n,t);if(!yc(n))return r;if(r.ok)return hg(n),r;if(!wZ.has(r.status))return r;const s=DZ.has(r.status);if(s&&!QO(n))return r;XO()&&s&&YO(n);const i=await MZ(n,SZ);if(!i||t?.signal?.aborted)return r;const o=t===void 0?await fetch(i):await fetch(i,t);return o.ok&&hg(i),o}function ZO(e,t=Date.now()){if(!yc(e))return null;const n=zh(e),r=n!==null&&n.e*1e3-t<=AZ;return!r&&!QO(e)?null:XO(t)?(r||YO(e),0):ug+KO-t}function eM(e){yc(e)&&hg(e)}function jae(e,t){const n=PZ(),r=t==="skip"||n===void 0?t:{...t,urlEpoch:n},s=tA(e,r);(0,p.useEffect)(()=>{s!==void 0&&RZ(s)},[s]);const i=t==="skip"?null:JSON.stringify(t),o=(0,p.useRef)(null);if(i!==null)return s!==void 0?(o.current={argsKey:i,value:s},s):o.current?.argsKey===i?o.current.value:void 0}function tM({src:e,alt:t,onError:n,onLoad:r,...s}){const i=Ev(e);return(0,m.jsx)("img",{...s,src:i,alt:t,onError:o=>{ZO(i),n?.(o)},onLoad:o=>{eM(i),r?.(o)}})}var _Z="eval-account-selection-enabled";function FZ(){return oA(_Z)===!0}var HZ={slot:{button:"flex h-8 w-8 shrink-0 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",icon:"h-3.5 w-3.5"},inline:{button:"mt-0.5 flex-shrink-0 cursor-pointer p-1 text-muted-foreground/50 transition-colors hover:text-foreground",icon:"h-3 w-3"}};function jZ({value:e,subject:t,size:n="slot"}){const[r,s]=(0,p.useState)(!1);(0,p.useEffect)(()=>{if(!r)return;const o=setTimeout(()=>s(!1),1500);return()=>clearTimeout(o)},[r]);const i=HZ[n];return(0,m.jsx)("button",{type:"button",onClick:async o=>{o.stopPropagation(),await ra(e)?s(!0):G$.error(`Could not copy the ${t}. Show it and copy it by hand.`)},"aria-label":`Copy ${t}`,title:`Copy ${t}`,className:i.button,children:r?(0,m.jsx)(Vs,{className:`${i.icon} text-success`}):(0,m.jsx)(_s,{className:i.icon})})}var $h=(0,p.createContext)(null);$h.displayName="PanelGroupContext";var dt={group:"data-panel-group",groupDirection:"data-panel-group-direction",groupId:"data-panel-group-id",panel:"data-panel",panelCollapsible:"data-panel-collapsible",panelId:"data-panel-id",panelSize:"data-panel-size",resizeHandle:"data-resize-handle",resizeHandleActive:"data-resize-handle-active",resizeHandleEnabled:"data-panel-resize-handle-enabled",resizeHandleId:"data-panel-resize-handle-id",resizeHandleState:"data-resize-handle-state"},xv=10,Ai=p.useLayoutEffect,FE=p.useId,GZ=typeof FE=="function"?FE:()=>null,VZ=0;function wv(e=null){const t=GZ(),n=(0,p.useRef)(e||t||null);return n.current===null&&(n.current=""+VZ++),e??n.current}function nM({children:e,className:t="",collapsedSize:n,collapsible:r,defaultSize:s,forwardedRef:i,id:o,maxSize:a,minSize:l,onCollapse:c,onExpand:u,onResize:d,order:h,style:f,tagName:B="div",...g}){const C=(0,p.useContext)($h);if(C===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:v,expandPanel:y,getPanelSize:b,getPanelStyle:E,groupId:w,isPanelCollapsed:A,reevaluatePanelConstraints:x,registerPanel:O,resizePanel:R,unregisterPanel:P}=C,_=wv(o),N=(0,p.useRef)({callbacks:{onCollapse:c,onExpand:u,onResize:d},constraints:{collapsedSize:n,collapsible:r,defaultSize:s,maxSize:a,minSize:l},id:_,idIsFromProps:o!==void 0,order:h});(0,p.useRef)({didLogMissingDefaultSizeWarning:!1}),Ai(()=>{const{callbacks:W,constraints:F}=N.current,z={...F};N.current.id=_,N.current.idIsFromProps=o!==void 0,N.current.order=h,W.onCollapse=c,W.onExpand=u,W.onResize=d,F.collapsedSize=n,F.collapsible=r,F.defaultSize=s,F.maxSize=a,F.minSize=l,(z.collapsedSize!==F.collapsedSize||z.collapsible!==F.collapsible||z.maxSize!==F.maxSize||z.minSize!==F.minSize)&&x(N.current,z)}),Ai(()=>{const W=N.current;return O(W),()=>{P(W)}},[h,_,O,P]),(0,p.useImperativeHandle)(i,()=>({collapse:()=>{v(N.current)},expand:W=>{y(N.current,W)},getId(){return _},getSize(){return b(N.current)},isCollapsed(){return A(N.current)},isExpanded(){return!A(N.current)},resize:W=>{R(N.current,W)}}),[v,y,b,A,_,R]);const q=E(N.current,s);return(0,p.createElement)(B,{...g,children:e,className:t,id:_,style:{...q,...f},[dt.groupId]:w,[dt.panel]:"",[dt.panelCollapsible]:r||void 0,[dt.panelId]:_,[dt.panelSize]:parseFloat(""+q.flexGrow).toFixed(1)})}var Dv=(0,p.forwardRef)((e,t)=>(0,p.createElement)(nM,{...e,forwardedRef:t}));nM.displayName="Panel";Dv.displayName="forwardRef(Panel)";var UZ;function zZ(){return UZ}var fg=null,$Z=!0,HE=null,od=-1,Jr=null;function WZ(e,t,n){const r=(t&aM)!==0,s=(t&lM)!==0,i=(t&cM)!==0,o=(t&uM)!==0;if(HE)return HE({exceedsHorizontalMaximum:s,exceedsHorizontalMinimum:r,exceedsVerticalMaximum:o,exceedsVerticalMinimum:i,intersectsHorizontalDragHandle:e==="horizontal"||e==="intersection",intersectsVerticalDragHandle:e==="vertical"||e==="intersection",isPointerDown:n});if(t){if(r)return i?"se-resize":o?"ne-resize":"e-resize";if(s)return i?"sw-resize":o?"nw-resize":"w-resize";if(i)return"s-resize";if(o)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}function qZ(){Jr!==null&&(document.head.removeChild(Jr),fg=null,Jr=null,od=-1)}function EB(e,t,n){var r,s;if(!$Z)return;const i=WZ(e,t,n);if(fg!==i){if(fg=i,Jr===null){Jr=document.createElement("style");const a=zZ();a&&Jr.setAttribute("nonce",a),document.head.appendChild(Jr)}if(od>=0){var o;(o=Jr.sheet)===null||o===void 0||o.removeRule(od)}od=(r=(s=Jr.sheet)===null||s===void 0?void 0:s.insertRule(`*{cursor: ${i} !important;}`))!==null&&r!==void 0?r:-1}}function rM(e){return e.type==="keydown"}function sM(e){return e.type.startsWith("pointer")}function iM(e){return e.type.startsWith("mouse")}function Wh(e){if(sM(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(iM(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function KZ(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function JZ(e,t,n){return n?e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y:e.x<=t.x+t.width&&e.x+e.width>=t.x&&e.y<=t.y+t.height&&e.y+e.height>=t.y}function QZ(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:VE(e),b:VE(t)};let r;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),r=e;Te(r,"Stacking order can only be calculated for elements with a common ancestor");const s={a:GE(jE(n.a)),b:GE(jE(n.b))};if(s.a===s.b){const i=r.childNodes,o={a:n.a.at(-1),b:n.b.at(-1)};let a=i.length;for(;a--;){const l=i[a];if(l===o.a)return 1;if(l===o.b)return-1}}return Math.sign(s.a-s.b)}var YZ=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function XZ(e){var t;const n=getComputedStyle((t=oM(e))!==null&&t!==void 0?t:e).display;return n==="flex"||n==="inline-flex"}function ZZ(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||XZ(e))||+t.opacity<1||"transform"in t&&t.transform!=="none"||"webkitTransform"in t&&t.webkitTransform!=="none"||"mixBlendMode"in t&&t.mixBlendMode!=="normal"||"filter"in t&&t.filter!=="none"||"webkitFilter"in t&&t.webkitFilter!=="none"||"isolation"in t&&t.isolation==="isolate"||YZ.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function jE(e){let t=e.length;for(;t--;){const n=e[t];if(Te(n,"Missing node"),ZZ(n))return n}return null}function GE(e){return e&&Number(getComputedStyle(e).zIndex)||0}function VE(e){const t=[];for(;e;)t.push(e),e=oM(e);return t}function oM(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}var aM=1,lM=2,cM=4,uM=8,eee=KZ()==="coarse",ar=[],as=!1,Rs=new Map,qh=new Map,$l=new Set;function tee(e,t,n,r,s){var i;const{ownerDocument:o}=t,a={direction:n,element:t,hitAreaMargins:r,setResizeHandlerState:s},l=(i=Rs.get(o))!==null&&i!==void 0?i:0;return Rs.set(o,l+1),$l.add(a),zd(),function(){var u;qh.delete(e),$l.delete(a);const d=(u=Rs.get(o))!==null&&u!==void 0?u:1;if(Rs.set(o,d-1),zd(),d===1&&Rs.delete(o),ar.includes(a)){const h=ar.indexOf(a);h>=0&&ar.splice(h,1),Kh(),s("up",!0,null)}}}function nee(e){const{target:t}=e,{x:n,y:r}=Wh(e);as=!0,Tv({target:t,x:n,y:r}),zd(),ar.length>0&&($d("down",e),Kh(),e.preventDefault(),dM(t)||e.stopImmediatePropagation())}function xB(e){const{x:t,y:n}=Wh(e);if(as&&e.type!=="pointerleave"&&e.buttons===0&&(as=!1,$d("up",e)),!as){const{target:r}=e;Tv({target:r,x:t,y:n})}$d("move",e),Kh(),ar.length>0&&e.preventDefault()}function wB(e){const{target:t}=e,{x:n,y:r}=Wh(e);qh.clear(),as=!1,ar.length>0&&(e.preventDefault(),dM(t)||e.stopImmediatePropagation()),$d("up",e),Tv({target:t,x:n,y:r}),Kh(),zd()}function dM(e){let t=e;for(;t;){if(t.hasAttribute(dt.resizeHandle))return!0;t=t.parentElement}return!1}function Tv({target:e,x:t,y:n}){ar.splice(0);let r=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(r=e),$l.forEach(s=>{const{element:i,hitAreaMargins:o}=s,a=i.getBoundingClientRect(),{bottom:l,left:c,right:u,top:d}=a,h=eee?o.coarse:o.fine;if(t>=c-h&&t<=u+h&&n>=d-h&&n<=l+h){if(r!==null&&document.contains(r)&&i!==r&&!i.contains(r)&&!r.contains(i)&&QZ(r,i)>0){let f=r,B=!1;for(;f&&!f.contains(i);){if(JZ(f.getBoundingClientRect(),a,!0)){B=!0;break}f=f.parentElement}if(B)return}ar.push(s)}})}function DB(e,t){qh.set(e,t)}function Kh(){let e=!1,t=!1;ar.forEach(r=>{const{direction:s}=r;s==="horizontal"?e=!0:t=!0});let n=0;qh.forEach(r=>{n|=r}),e&&t?EB("intersection",n,as):e?EB("horizontal",n,as):t?EB("vertical",n,as):qZ()}var TB;function zd(){var e;(e=TB)===null||e===void 0||e.abort(),TB=new AbortController;const t={capture:!0,signal:TB.signal};$l.size&&(as?(ar.length>0&&Rs.forEach((n,r)=>{const{body:s}=r;n>0&&(s.addEventListener("contextmenu",wB,t),s.addEventListener("pointerleave",xB,t),s.addEventListener("pointermove",xB,t))}),Rs.forEach((n,r)=>{const{body:s}=r;s.addEventListener("pointerup",wB,t),s.addEventListener("pointercancel",wB,t)})):Rs.forEach((n,r)=>{const{body:s}=r;n>0&&(s.addEventListener("pointerdown",nee,t),s.addEventListener("pointermove",xB,t))}))}function $d(e,t){$l.forEach(n=>{const{setResizeHandlerState:r}=n;r(e,ar.includes(n),t)})}function ree(){const[e,t]=(0,p.useState)(0);return(0,p.useCallback)(()=>t(n=>n+1),[])}function Te(e,t){if(!e)throw console.error(t),Error(t)}function Fi(e,t,n=xv){return e.toFixed(n)===t.toFixed(n)?0:e>t?1:-1}function Zr(e,t,n=xv){return Fi(e,t,n)===0}function Sn(e,t,n){return Fi(e,t,n)===0}function see(e,t,n){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++){const s=e[r],i=t[r];if(!Sn(s,i,n))return!1}return!0}function bo({panelConstraints:e,panelIndex:t,size:n}){const r=e[t];Te(r!=null,`Panel constraints not found for index ${t}`);let{collapsedSize:s=0,collapsible:i,maxSize:o=100,minSize:a=0}=r;if(Fi(n,a)<0)if(i){const l=(s+a)/2;Fi(n,l)<0?n=s:n=a}else n=a;return n=Math.min(o,n),n=parseFloat(n.toFixed(xv)),n}function Va({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:s,trigger:i}){if(Sn(e,0))return t;const o=[...t],[a,l]=r;Te(a!=null,"Invalid first pivot index"),Te(l!=null,"Invalid second pivot index");let c=0;if(i==="keyboard"){{const u=e<0?l:a,d=n[u];Te(d,`Panel constraints not found for index ${u}`);const{collapsedSize:h=0,collapsible:f,minSize:B=0}=d;if(f){const g=t[u];if(Te(g!=null,`Previous layout not found for panel index ${u}`),Sn(g,h)){const C=B-g;Fi(C,Math.abs(e))>0&&(e=e<0?0-C:C)}}}{const u=e<0?a:l,d=n[u];Te(d,`No panel constraints found for index ${u}`);const{collapsedSize:h=0,collapsible:f,minSize:B=0}=d;if(f){const g=t[u];if(Te(g!=null,`Previous layout not found for panel index ${u}`),Sn(g,B)){const C=g-h;Fi(C,Math.abs(e))>0&&(e=e<0?0-C:C)}}}}{const u=e<0?1:-1;let d=e<0?l:a,h=0;for(;;){const B=t[d];Te(B!=null,`Previous layout not found for panel index ${d}`);const g=bo({panelConstraints:n,panelIndex:d,size:100})-B;if(h+=g,d+=u,d<0||d>=n.length)break}const f=Math.min(Math.abs(e),Math.abs(h));e=e<0?0-f:f}{let u=e<0?a:l;for(;u>=0&&u<n.length;){const d=Math.abs(e)-Math.abs(c),h=t[u];Te(h!=null,`Previous layout not found for panel index ${u}`);const f=h-d,B=bo({panelConstraints:n,panelIndex:u,size:f});if(!Sn(h,B)&&(c+=h-B,o[u]=B,c.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?u--:u++}}if(see(s,o))return s;{const u=e<0?l:a,d=t[u];Te(d!=null,`Previous layout not found for panel index ${u}`);const h=d+c,f=bo({panelConstraints:n,panelIndex:u,size:h});if(o[u]=f,!Sn(f,h)){let B=h-f,g=e<0?l:a;for(;g>=0&&g<n.length;){const C=o[g];Te(C!=null,`Previous layout not found for panel index ${g}`);const v=C+B,y=bo({panelConstraints:n,panelIndex:g,size:v});if(Sn(C,y)||(B-=y-C,o[g]=y),Sn(B,0))break;e>0?g--:g++}}}return Sn(o.reduce((u,d)=>d+u,0),100)?o:s}function iee({layout:e,panelsArray:t,pivotIndices:n}){let r=0,s=100,i=0,o=0;const a=n[0];return Te(a!=null,"No pivot index found"),t.forEach((l,c)=>{const{constraints:u}=l,{maxSize:d=100,minSize:h=0}=u;c===a?(r=h,s=d):(i+=h,o+=d)}),{valueMax:Math.min(s,100-i),valueMin:Math.max(r,100-o),valueNow:e[a]}}function Wl(e,t=document){return Array.from(t.querySelectorAll(`[${dt.resizeHandleId}][data-panel-group-id="${e}"]`))}function hM(e,t,n=document){const r=Wl(e,n).findIndex(s=>s.getAttribute(dt.resizeHandleId)===t);return r??null}function fM(e,t,n){const r=hM(e,t,n);return r!=null?[r,r+1]:[-1,-1]}function oee(e){return e instanceof HTMLElement?!0:typeof e=="object"&&e!==null&&"tagName"in e&&"getAttribute"in e}function BM(e,t=document){if(oee(t)&&t.dataset.panelGroupId==e)return t;const n=t.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return n||null}function Jh(e,t=document){const n=t.querySelector(`[${dt.resizeHandleId}="${e}"]`);return n||null}function aee(e,t,n,r=document){var s,i,o,a;const l=Jh(t,r),c=Wl(e,r),u=l?c.indexOf(l):-1;return[(s=(i=n[u])===null||i===void 0?void 0:i.id)!==null&&s!==void 0?s:null,(o=(a=n[u+1])===null||a===void 0?void 0:a.id)!==null&&o!==void 0?o:null]}function lee({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:r,panelDataArray:s,panelGroupElement:i,setLayout:o}){(0,p.useRef)({didWarnAboutMissingResizeHandle:!1}),Ai(()=>{if(!i)return;const a=Wl(n,i);for(let l=0;l<s.length-1;l++){const{valueMax:c,valueMin:u,valueNow:d}=iee({layout:r,panelsArray:s,pivotIndices:[l,l+1]}),h=a[l];if(h!=null){const f=s[l];Te(f,`No panel data found for index "${l}"`),h.setAttribute("aria-controls",f.id),h.setAttribute("aria-valuemax",""+Math.round(c)),h.setAttribute("aria-valuemin",""+Math.round(u)),h.setAttribute("aria-valuenow",d!=null?""+Math.round(d):"")}}return()=>{a.forEach((l,c)=>{l.removeAttribute("aria-controls"),l.removeAttribute("aria-valuemax"),l.removeAttribute("aria-valuemin"),l.removeAttribute("aria-valuenow")})}},[n,r,s,i]),(0,p.useEffect)(()=>{if(!i)return;const a=t.current;Te(a,"Eager values not found");const{panelDataArray:l}=a;Te(BM(n,i)!=null,`No group found for id "${n}"`);const c=Wl(n,i);Te(c,`No resize handles found for group id "${n}"`);const u=c.map(d=>{const h=d.getAttribute(dt.resizeHandleId);Te(h,"Resize handle element has no handle id attribute");const[f,B]=aee(n,h,l,i);if(f==null||B==null)return()=>{};const g=C=>{if(!C.defaultPrevented)switch(C.key){case"Enter":{C.preventDefault();const v=l.findIndex(y=>y.id===f);if(v>=0){const y=l[v];Te(y,`No panel data found for index ${v}`);const b=r[v],{collapsedSize:E=0,collapsible:w,minSize:A=0}=y.constraints;if(b!=null&&w){const x=Va({delta:Sn(b,E)?A-E:E-b,initialLayout:r,panelConstraints:l.map(O=>O.constraints),pivotIndices:fM(n,h,i),prevLayout:r,trigger:"keyboard"});r!==x&&o(x)}}break}}};return d.addEventListener("keydown",g),()=>{d.removeEventListener("keydown",g)}});return()=>{u.forEach(d=>d())}},[i,e,t,n,r,s,o])}function UE(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function pM(e,t){const n=e==="horizontal",{x:r,y:s}=Wh(t);return n?r:s}function cee(e,t,n,r,s){const i=n==="horizontal",o=Jh(t,s);Te(o,`No resize handle element found for id "${t}"`);const a=o.getAttribute(dt.groupId);Te(a,"Resize handle element has no group id attribute");let{initialCursorPosition:l}=r;const c=pM(n,e),u=BM(a,s);Te(u,`No group element found for id "${a}"`);const d=u.getBoundingClientRect(),h=i?d.width:d.height;return(c-l)/h*100}function uee(e,t,n,r,s,i){if(rM(e)){const o=n==="horizontal";let a=0;e.shiftKey?a=100:s!=null?a=s:a=10;let l=0;switch(e.key){case"ArrowDown":l=o?0:a;break;case"ArrowLeft":l=o?-a:0;break;case"ArrowRight":l=o?a:0;break;case"ArrowUp":l=o?0:-a;break;case"End":l=100;break;case"Home":l=-100}return l}else return r==null?0:cee(e,t,n,r,i)}function dee({panelDataArray:e}){const t=Array(e.length),n=e.map(i=>i.constraints);let r=0,s=100;for(let i=0;i<e.length;i++){const o=n[i];Te(o,`Panel constraints not found for index ${i}`);const{defaultSize:a}=o;a!=null&&(r++,t[i]=a,s-=a)}for(let i=0;i<e.length;i++){const o=n[i];Te(o,`Panel constraints not found for index ${i}`);const{defaultSize:a}=o;if(a!=null)continue;const l=e.length-r,c=s/l;r++,t[i]=c,s-=c}return t}function Zi(e,t,n){t.forEach((r,s)=>{const i=e[s];Te(i,`Panel data not found for index ${s}`);const{callbacks:o,constraints:a,id:l}=i,{collapsedSize:c=0,collapsible:u}=a,d=n[l];if(d==null||r!==d){n[l]=r;const{onCollapse:h,onExpand:f,onResize:B}=o;B&&B(r,d),u&&(h||f)&&(f&&(d==null||Zr(d,c))&&!Zr(r,c)&&f(),h&&(d==null||!Zr(d,c))&&Zr(r,c)&&h())}})}function pu(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function hee({defaultSize:e,dragState:t,layout:n,panelData:r,panelIndex:s,precision:i=3}){const o=n[s];let a;return o==null?a=e!=null?e.toFixed(i):"1":r.length===1?a="1":a=o.toFixed(i),{flexBasis:0,flexGrow:a,flexShrink:1,overflow:"hidden",pointerEvents:t!==null?"none":void 0}}function fee(e,t=10){let n=null;return(...s)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...s)},t)}}function zE(e){try{if(typeof localStorage<"u")e.getItem=t=>localStorage.getItem(t),e.setItem=(t,n)=>{localStorage.setItem(t,n)};else throw new Error("localStorage not supported in this environment")}catch(t){console.error(t),e.getItem=()=>null,e.setItem=()=>{}}}function mM(e){return`react-resizable-panels:${e}`}function gM(e){return e.map(t=>{const{constraints:n,id:r,idIsFromProps:s,order:i}=t;return s?r:i?`${i}:${JSON.stringify(n)}`:JSON.stringify(n)}).sort((t,n)=>t.localeCompare(n)).join(",")}function CM(e,t){try{const n=mM(e),r=t.getItem(n);if(r){const s=JSON.parse(r);if(typeof s=="object"&&s!=null)return s}}catch{}return null}function Bee(e,t,n){var r,s;return(s=((r=CM(e,n))!==null&&r!==void 0?r:{})[gM(t)])!==null&&s!==void 0?s:null}function pee(e,t,n,r,s){var i;const o=mM(e),a=gM(t),l=(i=CM(e,s))!==null&&i!==void 0?i:{};l[a]={expandToSizes:Object.fromEntries(n.entries()),layout:r};try{s.setItem(o,JSON.stringify(l))}catch(c){console.error(c)}}function $E({layout:e,panelConstraints:t}){const n=[...e],r=n.reduce((i,o)=>i+o,0);if(n.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${n.map(i=>`${i}%`).join(", ")}`);if(!Sn(r,100)&&n.length>0)for(let i=0;i<t.length;i++){const o=n[i];Te(o!=null,`No layout data found for index ${i}`);const a=100/r*o;n[i]=a}let s=0;for(let i=0;i<t.length;i++){const o=n[i];Te(o!=null,`No layout data found for index ${i}`);const a=bo({panelConstraints:t,panelIndex:i,size:o});o!=a&&(s+=o-a,n[i]=a)}if(!Sn(s,0))for(let i=0;i<t.length;i++){const o=n[i];Te(o!=null,`No layout data found for index ${i}`);const a=o+s,l=bo({panelConstraints:t,panelIndex:i,size:a});if(o!==l&&(s-=l-o,n[i]=l,Sn(s,0)))break}return n}var mee=100,Ua={getItem:e=>(zE(Ua),Ua.getItem(e)),setItem:(e,t)=>{zE(Ua),Ua.setItem(e,t)}},WE={};function vM({autoSaveId:e=null,children:t,className:n="",direction:r,forwardedRef:s,id:i=null,onLayout:o=null,keyboardResizeBy:a=null,storage:l=Ua,style:c,tagName:u="div",...d}){const h=wv(i),f=(0,p.useRef)(null),[B,g]=(0,p.useState)(null),[C,v]=(0,p.useState)([]),y=ree(),b=(0,p.useRef)({}),E=(0,p.useRef)(new Map),w=(0,p.useRef)(0),A=(0,p.useRef)({autoSaveId:e,direction:r,dragState:B,id:h,keyboardResizeBy:a,onLayout:o,storage:l}),x=(0,p.useRef)({layout:C,panelDataArray:[],panelDataArrayChanged:!1});(0,p.useRef)({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),(0,p.useImperativeHandle)(s,()=>({getId:()=>A.current.id,getLayout:()=>{const{layout:X}=x.current;return X},setLayout:X=>{const{onLayout:Y}=A.current,{layout:ie,panelDataArray:ne}=x.current,ee=$E({layout:X,panelConstraints:ne.map(Be=>Be.constraints)});UE(ie,ee)||(v(ee),x.current.layout=ee,Y&&Y(ee),Zi(ne,ee,b.current))}}),[]),Ai(()=>{A.current.autoSaveId=e,A.current.direction=r,A.current.dragState=B,A.current.id=h,A.current.onLayout=o,A.current.storage=l}),lee({committedValuesRef:A,eagerValuesRef:x,groupId:h,layout:C,panelDataArray:x.current.panelDataArray,setLayout:v,panelGroupElement:f.current}),(0,p.useEffect)(()=>{const{panelDataArray:X}=x.current;if(e){if(C.length===0||C.length!==X.length)return;let Y=WE[e];Y==null&&(Y=fee(pee,mee),WE[e]=Y);const ie=[...X],ne=new Map(E.current);Y(e,ie,ne,C,l)}},[e,C,l]),(0,p.useEffect)(()=>{});const O=(0,p.useCallback)(X=>{const{onLayout:Y}=A.current,{layout:ie,panelDataArray:ne}=x.current;if(X.constraints.collapsible){const ee=ne.map(Ee=>Ee.constraints),{collapsedSize:Be=0,panelSize:de,pivotIndices:Re}=ai(ne,X,ie);if(Te(de!=null,`Panel size not found for panel "${X.id}"`),!Zr(de,Be)){E.current.set(X.id,de);const Ee=Va({delta:uo(ne,X)===ne.length-1?de-Be:Be-de,initialLayout:ie,panelConstraints:ee,pivotIndices:Re,prevLayout:ie,trigger:"imperative-api"});pu(ie,Ee)||(v(Ee),x.current.layout=Ee,Y&&Y(Ee),Zi(ne,Ee,b.current))}}},[]),R=(0,p.useCallback)((X,Y)=>{const{onLayout:ie}=A.current,{layout:ne,panelDataArray:ee}=x.current;if(X.constraints.collapsible){const Be=ee.map(Bt=>Bt.constraints),{collapsedSize:de=0,panelSize:Re=0,minSize:Ee=0,pivotIndices:st}=ai(ee,X,ne),at=Y??Ee;if(Zr(Re,de)){const Bt=E.current.get(X.id),tt=Bt!=null&&Bt>=at?Bt:at,pt=Va({delta:uo(ee,X)===ee.length-1?Re-tt:tt-Re,initialLayout:ne,panelConstraints:Be,pivotIndices:st,prevLayout:ne,trigger:"imperative-api"});pu(ne,pt)||(v(pt),x.current.layout=pt,ie&&ie(pt),Zi(ee,pt,b.current))}}},[]),P=(0,p.useCallback)(X=>{const{layout:Y,panelDataArray:ie}=x.current,{panelSize:ne}=ai(ie,X,Y);return Te(ne!=null,`Panel size not found for panel "${X.id}"`),ne},[]),_=(0,p.useCallback)((X,Y)=>{const{panelDataArray:ie}=x.current,ne=uo(ie,X);return hee({defaultSize:Y,dragState:B,layout:C,panelData:ie,panelIndex:ne})},[B,C]),N=(0,p.useCallback)(X=>{const{layout:Y,panelDataArray:ie}=x.current,{collapsedSize:ne=0,collapsible:ee,panelSize:Be}=ai(ie,X,Y);return Te(Be!=null,`Panel size not found for panel "${X.id}"`),ee===!0&&Zr(Be,ne)},[]),q=(0,p.useCallback)(X=>{const{layout:Y,panelDataArray:ie}=x.current,{collapsedSize:ne=0,collapsible:ee,panelSize:Be}=ai(ie,X,Y);return Te(Be!=null,`Panel size not found for panel "${X.id}"`),!ee||Fi(Be,ne)>0},[]),W=(0,p.useCallback)(X=>{const{panelDataArray:Y}=x.current;Y.push(X),Y.sort((ie,ne)=>{const ee=ie.order,Be=ne.order;return ee==null&&Be==null?0:ee==null?-1:Be==null?1:ee-Be}),x.current.panelDataArrayChanged=!0,y()},[y]);Ai(()=>{if(x.current.panelDataArrayChanged){x.current.panelDataArrayChanged=!1;const{autoSaveId:X,onLayout:Y,storage:ie}=A.current,{layout:ne,panelDataArray:ee}=x.current;let Be=null;if(X){const Re=Bee(X,ee,ie);Re&&(E.current=new Map(Object.entries(Re.expandToSizes)),Be=Re.layout)}Be==null&&(Be=dee({panelDataArray:ee}));const de=$E({layout:Be,panelConstraints:ee.map(Re=>Re.constraints)});UE(ne,de)||(v(de),x.current.layout=de,Y&&Y(de),Zi(ee,de,b.current))}}),Ai(()=>{const X=x.current;return()=>{X.layout=[]}},[]);const F=(0,p.useCallback)(X=>{let Y=!1;const ie=f.current;return ie&&window.getComputedStyle(ie,null).getPropertyValue("direction")==="rtl"&&(Y=!0),function(ee){ee.preventDefault();const Be=f.current;if(!Be)return()=>null;const{direction:de,dragState:Re,id:Ee,keyboardResizeBy:st,onLayout:at}=A.current,{layout:Bt,panelDataArray:tt}=x.current,{initialLayout:pt}=Re??{},Lt=fM(Ee,X,Be);let mt=uee(ee,X,de,Re,st,Be);const lt=de==="horizontal";lt&&Y&&(mt=-mt);const Vn=tt.map(je=>je.constraints),it=Va({delta:mt,initialLayout:pt??Bt,panelConstraints:Vn,pivotIndices:Lt,prevLayout:Bt,trigger:rM(ee)?"keyboard":"mouse-or-touch"}),oe=!pu(Bt,it);(sM(ee)||iM(ee))&&w.current!=mt&&(w.current=mt,!oe&&mt!==0?lt?DB(X,mt<0?aM:lM):DB(X,mt<0?cM:uM):DB(X,0)),oe&&(v(it),x.current.layout=it,at&&at(it),Zi(tt,it,b.current))}},[]),z=(0,p.useCallback)((X,Y)=>{const{onLayout:ie}=A.current,{layout:ne,panelDataArray:ee}=x.current,Be=ee.map(st=>st.constraints),{panelSize:de,pivotIndices:Re}=ai(ee,X,ne);Te(de!=null,`Panel size not found for panel "${X.id}"`);const Ee=Va({delta:uo(ee,X)===ee.length-1?de-Y:Y-de,initialLayout:ne,panelConstraints:Be,pivotIndices:Re,prevLayout:ne,trigger:"imperative-api"});pu(ne,Ee)||(v(Ee),x.current.layout=Ee,ie&&ie(Ee),Zi(ee,Ee,b.current))},[]),J=(0,p.useCallback)((X,Y)=>{const{layout:ie,panelDataArray:ne}=x.current,{collapsedSize:ee=0,collapsible:Be}=Y,{collapsedSize:de=0,collapsible:Re,maxSize:Ee=100,minSize:st=0}=X.constraints,{panelSize:at}=ai(ne,X,ie);at!=null&&(Be&&Re&&Zr(at,ee)?Zr(ee,de)||z(X,de):at<st?z(X,st):at>Ee&&z(X,Ee))},[z]),Z=(0,p.useCallback)((X,Y)=>{const{direction:ie}=A.current,{layout:ne}=x.current;if(!f.current)return;const ee=Jh(X,f.current);Te(ee,`Drag handle element not found for id "${X}"`);const Be=pM(ie,Y);g({dragHandleId:X,dragHandleRect:ee.getBoundingClientRect(),initialCursorPosition:Be,initialLayout:ne})},[]),Q=(0,p.useCallback)(()=>{g(null)},[]),G=(0,p.useCallback)(X=>{const{panelDataArray:Y}=x.current,ie=uo(Y,X);ie>=0&&(Y.splice(ie,1),delete b.current[X.id],x.current.panelDataArrayChanged=!0,y())},[y]),be=(0,p.useMemo)(()=>({collapsePanel:O,direction:r,dragState:B,expandPanel:R,getPanelSize:P,getPanelStyle:_,groupId:h,isPanelCollapsed:N,isPanelExpanded:q,reevaluatePanelConstraints:J,registerPanel:W,registerResizeHandle:F,resizePanel:z,startDragging:Z,stopDragging:Q,unregisterPanel:G,panelGroupElement:f.current}),[O,B,r,R,P,_,h,N,q,J,W,F,z,Z,Q,G]),ve={display:"flex",flexDirection:r==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return(0,p.createElement)($h.Provider,{value:be},(0,p.createElement)(u,{...d,children:t,className:n,id:i,ref:f,style:{...ve,...c},[dt.group]:"",[dt.groupDirection]:r,[dt.groupId]:h}))}var yM=(0,p.forwardRef)((e,t)=>(0,p.createElement)(vM,{...e,forwardedRef:t}));vM.displayName="PanelGroup";yM.displayName="forwardRef(PanelGroup)";function uo(e,t){return e.findIndex(n=>n===t||n.id===t.id)}function ai(e,t,n){const r=uo(e,t),s=r===e.length-1?[r-1,r]:[r,r+1],i=n[r];return{...t.constraints,panelSize:i,pivotIndices:s}}function gee({disabled:e,handleId:t,resizeHandler:n,panelGroupElement:r}){(0,p.useEffect)(()=>{if(e||n==null||r==null)return;const s=Jh(t,r);if(s==null)return;const i=o=>{if(!o.defaultPrevented)switch(o.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":o.preventDefault(),n(o);break;case"F6":{o.preventDefault();const a=s.getAttribute(dt.groupId);Te(a,`No group element found for id "${a}"`);const l=Wl(a,r),c=hM(a,t,r);Te(c!==null,`No resize element found for id "${t}"`),l[o.shiftKey?c>0?c-1:l.length-1:c+1<l.length?c+1:0].focus();break}}};return s.addEventListener("keydown",i),()=>{s.removeEventListener("keydown",i)}},[r,e,t,n])}function bM({children:e=null,className:t="",disabled:n=!1,hitAreaMargins:r,id:s,onBlur:i,onClick:o,onDragging:a,onFocus:l,onPointerDown:c,onPointerUp:u,style:d={},tabIndex:h=0,tagName:f="div",...B}){var g,C;const v=(0,p.useRef)(null),y=(0,p.useRef)({onClick:o,onDragging:a,onPointerDown:c,onPointerUp:u});(0,p.useEffect)(()=>{y.current.onClick=o,y.current.onDragging=a,y.current.onPointerDown=c,y.current.onPointerUp=u});const b=(0,p.useContext)($h);if(b===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:E,groupId:w,registerResizeHandle:A,startDragging:x,stopDragging:O,panelGroupElement:R}=b,P=wv(s),[_,N]=(0,p.useState)("inactive"),[q,W]=(0,p.useState)(!1),[F,z]=(0,p.useState)(null),J=(0,p.useRef)({state:_});Ai(()=>{J.current.state=_}),(0,p.useEffect)(()=>{if(n)z(null);else{const be=A(P);z(()=>be)}},[n,P,A]);const Z=(g=r?.coarse)!==null&&g!==void 0?g:15,Q=(C=r?.fine)!==null&&C!==void 0?C:5;(0,p.useEffect)(()=>{if(n||F==null)return;const be=v.current;Te(be,"Element ref not attached");let ve=!1;return tee(P,be,E,{coarse:Z,fine:Q},(Y,ie,ne)=>{if(!ie){N("inactive");return}switch(Y){case"down":{N("drag"),ve=!1,Te(ne,'Expected event to be defined for "down" action'),x(P,ne);const{onDragging:ee,onPointerDown:Be}=y.current;ee?.(!0),Be?.();break}case"move":{const{state:ee}=J.current;ve=!0,ee!=="drag"&&N("hover"),Te(ne,'Expected event to be defined for "move" action'),F(ne);break}case"up":{N("hover"),O();const{onClick:ee,onDragging:Be,onPointerUp:de}=y.current;Be?.(!1),de?.(),ve||ee?.();break}}})},[Z,E,n,Q,A,P,F,x,O]),gee({disabled:n,handleId:P,resizeHandler:F,panelGroupElement:R});const G={touchAction:"none",userSelect:"none"};return(0,p.createElement)(f,{...B,children:e,className:t,id:s,onBlur:()=>{W(!1),i?.()},onFocus:()=>{W(!0),l?.()},ref:v,role:"separator",style:{...G,...d},tabIndex:h,[dt.groupDirection]:E,[dt.groupId]:w,[dt.resizeHandle]:"",[dt.resizeHandleActive]:_==="drag"?"pointer":q?"keyboard":void 0,[dt.resizeHandleEnabled]:!n,[dt.resizeHandleId]:P,[dt.resizeHandleState]:_})}bM.displayName="PanelResizeHandle";function Cee({className:e,...t}){return(0,m.jsx)(yM,{"data-slot":"resizable-panel-group",className:he("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...t})}var Bg=p.forwardRef((e,t)=>(0,m.jsx)(Dv,{ref:t,"data-slot":"resizable-panel",...e}));Bg.displayName=Dv.displayName;function vee({withHandle:e,className:t,...n}){return(0,m.jsx)(bM,{"data-slot":"resizable-handle",className:he("bg-border focus-visible:ring-ring relative flex w-px items-center justify-center after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-offset-1 focus-visible:outline-hidden data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:translate-x-0 data-[panel-group-direction=vertical]:after:-translate-y-1/2 [&[data-panel-group-direction=vertical]>div]:rotate-90",t),...n,children:e&&(0,m.jsx)("div",{className:"bg-border z-10 flex h-4 w-3 items-center justify-center rounded-xs border",children:(0,m.jsx)(dH,{className:"size-2.5"})})})}function Wd(e){return Array.isArray(e)?e.map(t=>{if(!t||typeof t!="object")return null;const n=t;return n.type!=="text"||typeof n.text!="string"?null:n.text.trim()?n.text:null}).filter(t=>!!t):[]}function yee(e){try{const t=JSON.parse(e);if(Array.isArray(t)||t&&typeof t=="object"&&!Array.isArray(t))return t}catch{}return null}function bee(e){if(typeof e!="string")return null;const t=e.trim();return t||null}function See(e){return!Array.isArray(e.content)||e.content.length>0||e.structuredContent!==void 0?!1:Object.keys(e).every(t=>["content","_meta","meta","isError"].includes(t))}function ba(e){if(e==null)return null;if(Array.isArray(e))return{kind:"json",value:e};if(typeof e=="string"){const t=bee(e)?yee(e.trim()):null;return t?{kind:"json",value:t}:{kind:"text",text:e}}return typeof e=="number"||typeof e=="boolean"?{kind:"text",text:String(e)}:typeof e!="object"?null:{kind:"json",value:e}}function Gae(e){if(e==null)return null;if(typeof e!="object"||Array.isArray(e))return ba(e);const t=e;if(See(t))return null;if(typeof t.text=="string")return ba(t.text);const n=Wd(t.content);if(n.length>0)return ba(n.join(`
79
+
80
+ `));const r=Wd((t.value&&typeof t.value=="object"?t.value:null)?.content);return r.length>0?ba(r.join(`
81
+
82
+ `)):ba(t)}function AB(e){if(!e)return null;if(typeof e=="string")return e.trim()||null;if(typeof e!="object")return null;const t=e;if(typeof t.text=="string"&&t.text.trim())return t.text.trim();const n=Wd(t.content);if(n.length>0)return n.join(`
83
+
84
+ `);const r=Wd((t.value&&typeof t.value=="object"?t.value:null)?.content);return r.length>0?r.join(`
85
+
86
+ `):null}function Eee({className:e,children:t,...n}){return(0,m.jsxs)(_2,{"data-slot":"scroll-area",className:he("relative",e),...n,children:[(0,m.jsx)(F2,{"data-slot":"scroll-area-viewport",className:"focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1",children:t}),(0,m.jsx)(xee,{}),(0,m.jsx)(H2,{})]})}function xee({className:e,orientation:t="vertical",...n}){return(0,m.jsx)(D2,{"data-slot":"scroll-area-scrollbar",orientation:t,className:he("flex touch-none p-px transition-colors select-none",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent",e),...n,children:(0,m.jsx)(O2,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}var wee=["listSkills","loadSkill","listSkillFiles","readSkillFile"],Dee=new Set(wee);function Vae(e){return Dee.has(e)}var Uae=D({toolCallOrder:U(["ignore","strict","superset"]).optional(),maxExtraToolCalls:lr([M().refine(e=>Number.isInteger(e)&&e>=0,"maxExtraToolCalls must be a non-negative integer or null"),Ql()]).optional(),allowExtraToolCalls:le().optional(),argumentMatching:U(["exact","partial","ignore"]).optional()}).strict();function zae(e,t,n){const r=mA(e,t,{isNegativeTest:n});return{missing:r.missing,unexpected:r.extra,argumentMismatches:r.argumentMismatches,passed:r.passed}}function qE(e){return e?e.maxExtraToolCalls!==void 0?e.maxExtraToolCalls:e.allowExtraToolCalls===!1?0:null:null}function $ae(e,t,n){const r=lq(e??[],n),s=t?.list??[];let i;if(!t)i=r;else switch(t.mode){case"inherit":i=r;break;case"replace":i=s;break;case"extend":i=[...r,...s];break;default:i=r}return i.length>0?i:void 0}function Tee(e){const t=e.infraError;return!!t&&typeof t=="object"&&typeof t.class=="string"}function Aee(e,t){return e.resultSource==="reported"&&(e.result==="pending"||e.result==="passed"||e.result==="failed"||e.result==="cancelled"||e.result==="timed_out")?e.result:e.status==="pending"||e.status==="running"?"pending":e.status==="cancelled"?"cancelled":e.status==="timed_out"?"timed_out":e.status==="setup_failed"?"setup_failed":e.status==="skipped"?"skipped":Iee(e,t)?"passed":"failed"}function SM(e,t){return Tee(e)?"infra_error":Aee(e,t)}function Iee(e,t){if(e.result==="passed"||e.result==="failed")return e.result==="passed";if(e.resultSource==="reported")return!1;const n=e.actualToolCalls||[],r=e.testCaseSnapshot?.expectedToolCalls||[],s=e.testCaseSnapshot?.isNegativeTest,i=e.testCaseSnapshot?.matchOptions,o=mA(r,n,{...i,isNegativeTest:s});if(s)return o.passed;if(r.length===0&&n.length>0){const u=qE(i);return u===null||o.extra.length<=u}const a=t?.allowUnexpectedTools?[]:o.missing,l=t?.ignoreArgumentMismatches?[]:o.argumentMismatches;if(a.length>0||l.length>0||o.outOfOrder.length>0)return!1;const c=qE(i);return!(c!==null&&o.extra.length>c)}function Av(e){if(e.environmentTargets?.length)return Array.from(new Set(e.environmentTargets.flatMap(r=>r.serverNames)));if(e.serverAttachment)return Array.from(new Set(e.serverAttachment.resolvedServerNames??[]));const t=e.environment?.servers??[],n=e.hostAttachments?.flatMap(r=>r.resolvedServerNames??[])??[];return n.length===0?t:Array.from(new Set([...t,...n]))}function EM(e){return{namedHostId:void 0,hostName:null,serverIds:e}}function xM(e,t,n=!0){return{namedHostId:e.namedHostId,hostName:e.hostName??"host",serverIds:n&&e.resolvedServerNames.length>0?e.resolvedServerNames:t}}function kee(e,t=Av(e)){const n=t,r=e.hostAttachments??[],s=!e.serverAttachment;return r.length===0?[EM(n)]:r.map(i=>xM(i,n,s))}function Ree(e,t,n){const r=e.environmentIds??[];return r.length>0?r.map(s=>({namedHostId:void 0,hostName:null,serverIds:[],environmentId:s,environmentName:t?.find(i=>i.environmentId===s)?.name??s})):kee(e,n)}function Wae(e,t,n){return Ree(e,t,n).length}function qae(e,t){const n=Av(e),r=t?e.hostAttachments?.find(s=>s.namedHostId===t):null;return r?xM(r,n,!e.serverAttachment):EM(n)}function Kae(e){return e?new Date(e).toLocaleString():"—"}function Jae(e){return e.updatedAt??e.startedAt??e.createdAt??0}function Oee(e){if(e<1e3)return`${e}ms`;const t=Math.round(e/1e3);if(t<60)return`${t}s`;const n=Math.floor(t/60),r=t%60;if(n<60)return r?`${n}m ${r}s`:`${n}m`;const s=Math.floor(n/60),i=n%60;return i?`${s}h ${i}m`:`${s}h`}function Mee(e){return e.substring(0,8)}function bc(e){return e.configSnapshot?.environmentRef??null}function Qh(e,t){const n=e.client,r=n?.namedHostId??e.namedHostId;if(n){const s=n.hostStyle?.trim();return{name:(n.versionId?n.name.trim():r&&t?.get(r)?.trim())||(n.source==="suite_default"&&px(s)?RN(s):n.name.trim())||"Client",hostStyle:s,namedHostId:r,source:n.source,key:r?`host:${r}`:n.source==="sdk"?"sdk":`style:${s||"unknown"}`}}return r?{name:t?.get(r)?.trim()||Mee(r),namedHostId:r,key:`host:${r}`,source:"unknown"}:{name:"Suite default",key:"style:unknown",source:"unknown"}}function Qae(e,t){const n=Qh(e).hostStyle;return n&&px(n)?EN(n,void 0,t):void 0}function Yae(e){return Array.isArray(e.models)?e.models.filter(t=>!!t.model):e.model?[{model:e.model,provider:e.provider??""}]:[]}function Nee(e){const t=bc(e);return t?`environment:${t.environmentId}`:Qh(e).key}function Pee(e,t){return!e.client&&!e.namedHostId?null:Qh(e,t).name}function Xae(e,t){const n=bc(e);return n?n.name:Pee(e,t)??Qh(e,t).name}function Zae(e){const t=bc(e);return t?`rev ${t.revision}`:null}function ele(e,t){const n=new Map,r=new Map((t??[]).map(s=>[s.hostId,s]));for(const s of t??[])n.set(s.hostId,rb(s));for(const s of e??[]){const i=r.get(s.namedHostId),o=i!==void 0&&s.hostName?.trim().toLowerCase()===i.name.trim().toLowerCase();n.set(s.namedHostId,i&&(s.hostName===null||o)?rb(i):s.hostName??n.get(s.namedHostId)??null)}return n}function tle(e){const t=new Set,n=[];for(const r of e){const s=Nee(r);t.has(s)||(t.add(s),n.push(s))}return n}function nle(e){return e.some(t=>bc(t)!==null)}function rle(e){const t=e.map(s=>bc(s)?.revision).filter(s=>typeof s=="number");if(t.length===0)return null;const n=Math.min(...t),r=Math.max(...t);return n===r?`rev ${n}`:`rev ${n}–${r}`}function sle(e){if(e?.code!=="ENVIRONMENT_REVISION_CONFLICT")return null;const t=e instanceof Error?e.message:null;return t&&t.length>0?t:"Environment changed since the suite was configured — retry the run."}function Lee(e){const t={runs:e.length,passed:0,failed:0,cancelled:0,pending:0,tokens:0,avgDuration:null};let n=0,r=0;return e.forEach(s=>{s.result==="passed"?t.passed+=1:s.result==="failed"?t.failed+=1:s.result==="cancelled"?t.cancelled+=1:s.status==="timed_out"?t.failed+=1:t.pending+=1,t.tokens+=s.tokensUsed||0;const i=s.startedAt??s.createdAt,o=s.updatedAt??s.createdAt;if(i&&o){const a=Math.max(o-i,0);n+=a,r+=1}}),r>0&&(t.avgDuration=n/r),t}function ile(e){return e.testTemplateKey?e.testTemplateKey:e._id?`fallback:${e._id}`:`fallback:${e.title}-${e.query}`}function _ee(e){return e?.rerunScope==="failed_cases"}function ole(e){switch(e){case Nn.PASSED:return"border-l-success/50";case Nn.FAILED:return"border-l-destructive/50";case Nn.PENDING:case"running":case"grading":return"border-l-warning/50";case Nn.CANCELLED:return"border-l-muted";case"mixed":case"inconclusive":return"border-l-warning/50";default:return"border-l-muted-foreground/50"}}function Fee(e,t){return(e?.source??t)==="sdk"?"sdk":"ui"}function ale(e,t){let n=null,r=-1;for(const s of e){const i=s.completedAt??s.createdAt??0;i>r&&(n=s,r=i)}return Fee(n,t)}function lle(e){if(!e)return"No runs yet";const t=Date.now()-e,n=Math.floor(t/6e4);if(n<1)return"Just now";if(n<60)return`${n}m ago`;const r=Math.floor(n/60);if(r<24)return`${r}h ago`;const s=Math.floor(r/24);return s<7?`${s}d ago`:new Date(e).toLocaleDateString()}function Ko(e,t){if(!Array.isArray(e)||e.length===0)return null;const n=[...e].sort((a,l)=>a-l);if(t<=0)return n[0];if(t>=1)return n[n.length-1];const r=(n.length-1)*t,s=Math.floor(r),i=Math.ceil(r);if(s===i)return n[s];const o=r-s;return n[s]*(1-o)+n[i]*o}function wM(e){const t=e.startedAt,n=e.updatedAt;return typeof t!="number"||typeof n!="number"||n<t?null:n-t}function DM(e){return Ko(e.filter(t=>t.status==="completed").map(wM).filter(t=>t!==null),.5)}function TM(e){return Ko(e.filter(t=>t.status==="completed").map(wM).filter(t=>t!==null),.95)}function cle(e,t){return e.runNumber-t.runNumber||e.createdAt-t.createdAt}function ule(e){const t=e.filter(n=>n.status==="completed"&&!_ee(n));return t.length===0?null:t.reduce((n,r)=>r.runNumber>n.runNumber?r:n)}function dle(e,t){return e.environment?.computerEnvironmentId?!0:(e.environmentIds??[]).some(n=>!!(t??[]).find(r=>r.environmentId===n)?.computerEnvironmentId)}var KE=1e-4;function Hee(e){const t=e<0?"-":"",n=Math.abs(e);if(n>0&&n<KE){const r=`$${KE.toFixed(4)}`;return t==="-"?`>-${r}`:`<${r}`}return n>0&&n<.01?`${t}$${n.toFixed(4)}`:`${t}$${n.toFixed(2)}`}function hle(e){return typeof e=="number"?Hee(e):"—"}function fle(e){return e.length?e.reduce((t,n)=>t+n,0)/e.length:null}function Ble(e){const t=(n,r)=>`${(e/n).toFixed(1).replace(/\.0$/,"")}${r}`;return e>=1e9?t(1e9,"b"):e>=1e6?t(1e6,"m"):e>=1e3?t(1e3,"k"):Number.isInteger(e)?e.toLocaleString():e.toFixed(1)}function ple(e,t){if(e?.source==="sdk_runner")return"Reported by your runner — MCPJam did not price this run.";if(typeof t=="number"||e?.status==="estimated")return null;switch(e?.reason){case"no_pricing":return"Not an MCPJam-billed model, so there is no cost to report.";case"harness_mixed_models":return"Harness runs mix models within a turn; their cost arrives with billed attribution.";case"no_tokens":return"This iteration reported no token usage.";default:return"No cost was recorded for this iteration."}}function jee(e){return e?.source==="sdk_runner"}function Gee(e){let t=null,n=0,r=!1;for(const s of e){const i=s.usage?.estimatedCostUsd;typeof i=="number"&&(t=(t??0)+i,n+=1,jee(s.usage?.costBasis)&&(r=!0))}return{totalUsd:t,costedIterations:n,totalIterations:e.length,hasRunnerReported:r}}function mle(e){return e.map(t=>t.usage?.estimatedCostUsd).filter(t=>typeof t=="number")}function Vee(e){return e.status==="pending"||e.status==="running"||e.status==="grading"}function gle(e){return e.filter(Vee).map(t=>t._id)}function Iv(e){return!e.environmentIds?.length||!e.environmentTargets?null:e.environmentTargets.filter(t=>!t.unavailable)}function Cle(e){if(e.source==="sdk"&&!e.environmentIds?.length)return!0;if(e.environmentIds?.length){const t=Iv(e);return t===null||t.some(n=>n.serverNames.length>0||n.pluginVersionCount>0)}return Av(e).length>0}function kv(e,t){if(!e.environmentIds?.length)return{kind:"legacy"};const n=Iv(e);if(!n)return{kind:"none",reason:"This suite's environments are still loading, or this deployment can't describe them yet."};const r=n.filter(o=>o.serverNames.length>0||o.pluginVersionCount>0);if(r.length===0)return{kind:"none",reason:"None of this suite's environments has servers. Pick a server group in suite settings."};const s=t?r.find(o=>o.environmentId===t):void 0;if(s)return{kind:"environment",environmentId:s.environmentId};const i=r.every(o=>o.pluginVersionCount===0)&&new Set(r.map(o=>o.serverAttachmentId??"")).size===1;return r.length===1||i?{kind:"environment",environmentId:r[0].environmentId}:{kind:"choose",targets:r}}function vle(e){const t=kv(e);return t.kind==="choose"?t.targets:null}function yle(e,t){const n=kv(e,t);return n.kind==="environment"?n.environmentId:void 0}function mu(e){return e.name?.trim()?e.name.trim():[e.hostName??"Client",e.modelId].filter(Boolean).join(" · ")}function ble(e){const t=e.pluginVersionCount>0?`${e.pluginVersionCount} plugin${e.pluginVersionCount===1?"":"s"}`:"";return[e.serverNames.join(", "),t].filter(Boolean).join(" + ")||"No servers"}function Sle(e,t,n){const r=t?.trim();if(!e.environmentIds?.length)return r?{error:"it does not run environments. Omit 'environment'."}:{};const s=Iv(e)??[],i=s.map(mu).join(", ");let o=n;if(r){const l=r.toLowerCase(),c=s.filter(h=>mu(h).toLowerCase()===l),u=s.find(h=>h.environmentId===r);if(!u&&c.length>1)return{error:`more than one of its environments is named "${r}". Name one by ID: ${c.map(h=>h.environmentId).join(", ")}.`};const d=u??c[0];if(!d)return{error:`it has no environment "${r}". Its environments: ${i||"none"}.`};if(d.serverNames.length===0&&d.pluginVersionCount===0)return{error:`its environment "${mu(d)}" has no servers. Pick a server group for it in suite settings.`};o=d.environmentId}const a=kv(e,o);return a.kind==="environment"?{environmentId:a.environmentId}:a.kind==="choose"?{error:`its environments connect different servers. Name the one to generate for with 'environment': ${a.targets.map(mu).join(", ")}.`}:a.kind==="none"?{error:a.reason}:{}}var Uee=new Set(["pending","running","grading"]);function zee(e){return Uee.has(e.status)}function $ee(e){return zee(e)||!e.metrics?!0:e.metrics.results.unscored>0}function Wee(e){const t=e.startedAt,n=e.updatedAt;return typeof t!="number"||typeof n!="number"||n<t?null:n-t}function qee(e){const t=e.execution?.effectiveSettings?.reasoningEffort;if(typeof t!="string")return;const n=t.trim();return n.length>0?n:void 0}function Kee(e,t){return`${e}::${t??"default"}`}function Jee(e){const t={passed:0,failed:0,timedOut:0,cancelled:0,pending:0,setupFailed:0,skipped:0,unscored:0,infraError:0},n=[];let r=0,s=0,i=0,o=0,a=0,l=0,c=!1;const u=new Map;for(const f of e){const B=SM(f),g=B==="timed_out"?"timedOut":B==="setup_failed"?"setupFailed":B==="infra_error"?"infraError":B;if(t[g]+=1,f.status==="completed"){const y=Wee(f);y!==null&&n.push(y)}typeof f.tokensUsed=="number"&&Number.isFinite(f.tokensUsed)&&(r+=f.tokensUsed,s+=1),f.actualToolCalls&&(i+=f.actualToolCalls.length,o+=1);const C=f.usage?.estimatedCostUsd;typeof C=="number"&&(a+=C,l+=1,f.usage?.costBasis?.source==="sdk_runner"&&(c=!0));const v=f.testCaseSnapshot?.model?.trim();if(v){const y=qee(f),b=Kee(v,y),E=u.get(b)??{model:v,total:0,passed:0,failed:0,timedOut:0,...y?{reasoningEffort:y}:{}};E.total+=1,B==="passed"?E.passed+=1:B==="failed"?E.failed+=1:B==="timed_out"&&(E.timedOut+=1),typeof C=="number"&&(E.costUsd=(E.costUsd??0)+C,E.costedIterations=(E.costedIterations??0)+1);const w=f.usage?.reasoningTokens;typeof w=="number"&&Number.isFinite(w)&&(E.reasoningTokens=(E.reasoningTokens??0)+w),u.set(b,E)}}const d=DM([...e]),h=TM([...e]);return{version:1,iterationCount:e.length,results:t,completedCount:n.length,...d!==null?{latencyP50Ms:d}:{},...h!==null?{latencyP95Ms:h}:{},...s>0?{tokensTotal:r}:{},tokensMeasuredIterations:s,...o>0?{toolCallsTotal:i}:{},toolCallsMeasuredIterations:o,...l>0?{costUsd:a}:{},costedIterations:l,hasRunnerReportedCost:c,models:[...u.values()],durationsMs:n}}function Ele(e,t){return!$ee(e)&&e.metrics?e.metrics:t?Jee(t):e.metrics??null}function xle(e,t){const n=t?.results.passed??0,r=n+(t?.results.failed??0),s=r>0?n:e.summary?.passed??0,i=r>0?r:e.summary?.total??0;return{effectivePassed:s,effectiveTotal:i,passRate:i>0?Math.round(s/i*100):null}}function Qee(e){const t=e.filter(n=>n!=null&&n.completedCount>0);if(t.length===0)return{latencyP50:null,latencyP95:null};if(t.every(n=>n.durationsMs)){const n=t.flatMap(r=>r.durationsMs??[]);return{latencyP50:Ko(n,.5),latencyP95:Ko(n,.95)}}return{latencyP50:JE(t,"latencyP50Ms",.5),latencyP95:JE(t,"latencyP95Ms",.95)}}function JE(e,t,n){const r=e.map(o=>({value:o[t],weight:o.completedCount})).filter(o=>typeof o.value=="number"&&o.weight>0).sort((o,a)=>o.value-a.value);if(r.length===0)return null;const s=r.reduce((o,a)=>o+a.weight,0)*n;let i=0;for(const o of r)if(i+=o.weight,i>=s)return o.value;return r[r.length-1].value}function Yee(e){return e==="passed"?100:e==="partial"?50:0}function Xee(e){const t=e.total!=null&&e.total>0,n=t?e.passed??0:e.result==="passed"?1:0,r=t?e.failed??0:e.result==="failed"?1:0,s=t?e.total??1:1;return{passRate:t?Math.round(n/s*100):Yee(e.result),passed:n,total:s,failed:r,latencyP50:e.latencyMs,latencyP95:e.latencyP95Ms??e.latencyMs,tokens:e.tokens??0,toolCalls:e.toolCalls??0,costUsd:null,costedIterations:0,hasRunnerReportedCost:!1}}function Zee(e){const t=e.map(r=>r.latencyMs).filter(r=>r!=null),n=e.map(r=>r.latencyP95Ms??r.latencyMs).filter(r=>r!=null);return{latencyP50:Ko(t,.5),latencyP95:Ko(n,.95)}}function wle(e){if(e.length===0)return null;const t=e.map(Xee),n=la(t);if(!n)return null;const{latencyP50:r,latencyP95:s}=Zee(e);let i=0,o=0,a=0;for(const l of t)i+=l.passed,o+=l.failed,a+=l.total;return{...n,latest:{...n.latest,passed:i,failed:o,total:a,passRate:a>0?Math.round(i/a*100):n.latest.passRate,latencyP50:r,latencyP95:s},runLabels:e.map(l=>`Run ${l.runLabel}`)}}function Dle(e){return e>=1e6?`${(e/1e6).toFixed(1).replace(/\.0$/,"")}M`:e>=1e3?`${(e/1e3).toFixed(1).replace(/\.0$/,"")}k`:Number.isInteger(e)?String(e):e.toFixed(1).replace(/\.0$/,"")}function ete(e){return e>=1e3?`${(e/1e3).toFixed(e>=1e4?1:2)}s`:`${Math.round(e)}ms`}function tte(e){return e.actualToolCalls?.length??0}function nte(e){return e.reduce((t,n)=>t+tte(n),0)}function rte(e){return e.length===0?0:e.reduce((t,n)=>t+(n.tokensUsed||0),0)/e.length}function ste(e){let t=0,n=0,r=0;for(const s of e){const i=SM(s);i!=="infra_error"&&(t+=1,i==="passed"?n+=1:i==="failed"&&(r+=1))}return{passed:n,failed:r,total:t}}function Rv(e,t){const{passed:n,failed:r,total:s}=t??ste(e);return{passRate:s>0?Math.round(n/s*100):0,passed:n,total:s,failed:r,latencyP50:DM(e),latencyP95:TM(e),tokens:rte(e),toolCalls:nte(e),...(()=>{const{totalUsd:i,costedIterations:o,hasRunnerReported:a}=Gee(e);return{costUsd:i,costedIterations:o,hasRunnerReportedCost:a}})()}}function la(e){if(e.length===0)return null;const t=e[e.length-1],n=e.length>=2?e[e.length-2]:null;return{latest:t,series:e,delta:n?t.passRate-n.passRate:null,showTrend:e.length>=2}}function Yh(e){return e.filter(t=>t.result!=="inconclusive")}function Tle(e,t,n){const r=Yh(e);if(r.length===0)return null;const s=new Map;for(const c of t){if(!c.suiteRunId)continue;const u=s.get(c.suiteRunId);u?u.push(c):s.set(c.suiteRunId,[c])}const i=[...r].sort((c,u)=>c.createdAt-u.createdAt),o=[],a=[];for(const c of i){const u=s.get(c._id);if(!u||u.length===0)continue;const d=n?n(c):c.runNumber?`#${c.runNumber}`:`Run ${c._id.slice(0,8)}`;a.push(`${d} · ${new Date(c.createdAt).toLocaleString()}`);const h=Lee(u),f=c.summary?.total??h.runs,B=c.summary?.passed??h.passed,g=c.summary?.failed??h.failed;o.push(Rv(u,{total:f,passed:B,failed:g}))}const l=la(o);return l?{...l,runLabels:a}:null}function Ale(e,t){const n=Yh(e);if(n.length===0)return null;const r=new Set(n.map(c=>c._id)),s=t.filter(c=>c.suiteRunId&&r.has(c.suiteRunId));if(s.length===0)return null;let i=0,o=0,a=0,l=!0;for(const c of n)c.summary?(i+=c.summary.total,o+=c.summary.passed,a+=c.summary.failed):l=!1;return la([Rv(s,l?{total:i,passed:o,failed:a}:void 0)])}function AM(e,t){let n=0,r=0,s=0,i=0,o=0,a=null,l=0,c=!1;for(const g of e)n+=g.iterationCount,r+=g.results.passed,s+=g.results.failed,i+=g.tokensTotal??0,o+=g.toolCallsTotal??0,g.costUsd!==void 0&&(a=(a??0)+g.costUsd),l+=g.costedIterations,g.hasRunnerReportedCost&&(c=!0);const{passed:u,failed:d,total:h}=t??{passed:r,failed:s,total:n},{latencyP50:f,latencyP95:B}=Qee(e);return{passRate:h>0?Math.round(u/h*100):0,passed:u,total:h,failed:d,latencyP50:f,latencyP95:B,tokens:n>0?i/n:0,toolCalls:o,costUsd:a,costedIterations:l,hasRunnerReportedCost:c}}function Ile(e,t,n){const r=Yh(e);if(r.length===0)return null;const s=[...r].sort((l,c)=>l.createdAt-c.createdAt),i=[],o=[];for(const l of s){const c=t.get(l._id);if(!c||c.iterationCount===0)continue;const u=n?n(l):l.runNumber?`#${l.runNumber}`:`Run ${l._id.slice(0,8)}`;o.push(`${u} · ${new Date(l.createdAt).toLocaleString()}`),i.push(AM([c],{total:l.summary?.total??c.iterationCount,passed:l.summary?.passed??c.results.passed,failed:l.summary?.failed??c.results.failed+c.results.timedOut}))}const a=la(i);return a?{...a,runLabels:o}:null}function kle(e,t){const n=Yh(e);if(n.length===0)return null;const r=n.map(l=>t.get(l._id)).filter(l=>l!=null&&l.iterationCount>0);if(r.length===0)return null;let s=0,i=0,o=0,a=!0;for(const l of n)l.summary?(s+=l.summary.total,i+=l.summary.passed,o+=l.summary.failed):a=!1;return la([AM(r,a?{total:s,passed:i,failed:o}:void 0)])}function Rle(e){return e.length===0?null:la([...e].reverse().map(t=>Rv(t.iterations)))}function Ole(e){return e==="schedule"?"Schedule owner":e==="api"||e==="sdk"?"Key owner":null}function pg(e){return e.kind==="xaa"&&e.xaaSubject?.trim()||e.name}function Mle(e){const t=[];for(const n of e){const r=pg(n),s=t.find(i=>i.serverId===n.serverId);s?s.names.includes(r)||s.names.push(r):t.push({serverId:n.serverId,names:[r]})}return t}function IM(e,t){if(e.category!=="tool"||!t?.length)return;if(e.connectionId){const r=t.find(s=>s.connectionId===e.connectionId);return r?pg(r):void 0}const n=e.serverId?t.filter(r=>r.serverId===e.serverId):[];return n.length===1?pg(n[0]):void 0}function ite(e,t){const n=new Map;for(const r of e??[]){const s=r.toolCallId?IM(r,t):void 0;r.toolCallId&&s&&n.set(r.toolCallId,s)}return n}var ote=["opened","selected","shown","hidden","closed","call-started","call-completed","call-denied","call-unknown","call-suspended","call-continued","cancel-requested"],ate=["model-tool","app-tool","preview-tool","entrypoint","global-entrypoint","thread-entrypoint","settings-entrypoint","quick-action","file-entrypoint","settings-read","settings-update","settings-action","mention-search","model-context","context-removal","file-open","file-read","file-write","file-subscribe","file-unsubscribe","form-mrtr","form-legacy","resource-preview","app-preview","deep-link","message","message-prepare","app-display"],lte=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,Sa=(e,t=0)=>Number.isSafeInteger(e)&&e>=t;function gu(e,t){return!!e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).every(n=>t.includes(n))}var Cu=e=>typeof e=="string"&&lte.test(e);function Ov(e){if(!gu(e,["version","runtime","sequence","droppedEvents","activeInstanceId","instances","events"])||e.version!==1&&e.version!==2||!["chatgpt","codex"].includes(e.runtime)||!Sa(e.sequence)||!Sa(e.droppedEvents)||e.droppedEvents>e.sequence||!Array.isArray(e.instances)||e.instances.length>64||!Array.isArray(e.events)||e.events.length>128)throw new Error("PLUGIN_RECORDING_INVALID");const t=new Set;for(const r of e.instances){if(!gu(r,["instanceId","generation","visible"])||!Cu(r.instanceId)||t.has(r.instanceId)||!Sa(r.generation,1)||typeof r.visible!="boolean")throw new Error("PLUGIN_RECORDING_INVALID");t.add(r.instanceId)}if(e.activeInstanceId!==void 0&&(!Cu(e.activeInstanceId)||!e.instances.some(r=>r.instanceId===e.activeInstanceId&&r.visible)))throw new Error("PLUGIN_RECORDING_INVALID");let n=e.droppedEvents;for(const r of e.events){if(!gu(r,["sequence","kind","instanceId","generation","operationId",...e.version===2?["feature","fidelity","outcome","display"]:[]])||!Sa(r.sequence,1)||r.sequence!==n+1||r.sequence>e.sequence||!ote.includes(r.kind)||!Cu(r.instanceId)||!Sa(r.generation,1))throw new Error("PLUGIN_RECORDING_INVALID");const s=r.kind.startsWith("call-")||r.kind==="cancel-requested";if(s?!Cu(r.operationId):r.operationId!==void 0)throw new Error("PLUGIN_RECORDING_INVALID");if(r.feature===void 0!=(r.fidelity===void 0)||r.feature!==void 0&&(!s||!ate.includes(r.feature)||!["observed","assumed","degraded"].includes(r.fidelity)))throw new Error("PLUGIN_RECORDING_INVALID");if(r.outcome!==void 0&&(r.feature!=="file-write"||r.kind!=="call-completed"||!["saved","conflict","too-large"].includes(r.outcome)))throw new Error("PLUGIN_RECORDING_INVALID");if(r.display!==void 0){const i=r.display;if(r.feature!=="app-display"||r.kind!=="call-completed"||!gu(i,["availableDisplayModes","displayMode","interactionCursor"])||!Array.isArray(i.availableDisplayModes)||i.availableDisplayModes.length>2||new Set(i.availableDisplayModes).size!==i.availableDisplayModes.length||!i.availableDisplayModes.every(o=>o==="inline"||o==="fullscreen")||(i.availableDisplayModes.length===0?i.displayMode!==void 0:!i.availableDisplayModes.includes(i.displayMode))||!["pointer","default"].includes(i.interactionCursor))throw new Error("PLUGIN_RECORDING_INVALID")}n=r.sequence}if(n!==e.sequence)throw new Error("PLUGIN_RECORDING_INVALID");return JSON.parse(JSON.stringify(e))}function kM(e){if(e.length>Math.ceil(1048576/3)*4||!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(e))throw new Error("PLUGIN_REPLAY_IMAGE_INVALID");const t=atob(e);if(t.length>1048576)throw new Error("PLUGIN_REPLAY_IMAGE_INVALID");const n=t.startsWith(`‰PNG\r
87
+ 
88
+ `),r=t.startsWith("ÿØÿ");if(!n&&!r)throw new Error("PLUGIN_REPLAY_IMAGE_INVALID");return`data:image/${n?"png":"jpeg"};base64,${e}`}function cte(e,t){e!==void 0&&Ov(e);const n=t?kM(t):void 0;return`<!doctype html><html><head><meta charset="utf-8"><meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src data:; style-src 'unsafe-inline'; base-uri 'none'; form-action 'none'; frame-src 'none'; connect-src 'none'"><meta name="referrer" content="no-referrer"><style>html,body{margin:0}img{display:block;max-width:100%;height:auto}</style></head><body>${n?`<img alt="Captured workspace" src="${n}">`:"<p>No captured image available.</p>"}</body></html>`}function QE({recording:e,screenshotBase64:t}){let n;try{n=cte(e,t)}catch{return(0,m.jsx)("p",{role:"status",className:"text-xs text-muted-foreground",children:"Unsupported workspace capture."})}return(0,m.jsx)("iframe",{title:"Recorded plugin workspace",sandbox:"",referrerPolicy:"no-referrer",srcDoc:n,className:"h-96 w-full rounded-md border border-border bg-background"})}function ute({recording:e,screenshotUrl:t}){const n=Ev(t??void 0),[r,s]=(0,p.useState)();let i=!1;try{e!==void 0&&Ov(e),i=!0}catch{}return(0,p.useEffect)(()=>{if(!i||!n)return;const o=new AbortController;return(async()=>{try{if(!yc(n))throw new Error("Owned screenshot link unavailable");const a=await LZ(n,{signal:o.signal,credentials:"omit",redirect:"error"});if(!a.ok||!a.body)throw new Error("Screenshot unavailable");const l=a.body.getReader(),c=[];let u=0;try{for(;;){const{done:g,value:C}=await l.read();if(g)break;if(u+=C.byteLength,u>1048576)throw new Error("Screenshot too large");c.push(C)}}finally{await l.cancel().catch(()=>{}),l.releaseLock()}const d=new Uint8Array(u);let h=0;for(const g of c)d.set(g,h),h+=g.length;let f="";for(let g=0;g<d.length;g+=8192)f+=String.fromCharCode(...d.subarray(g,g+8192));const B=btoa(f);kM(B),o.signal.aborted||s({url:n,base64:B})}catch{o.signal.aborted||s({url:n,failed:!0})}})(),()=>o.abort()},[n,i]),i?n&&r?.url!==n?(0,m.jsx)("p",{role:"status",className:"text-xs text-muted-foreground",children:"Loading captured workspace…"}):(0,m.jsxs)("div",{className:"space-y-2",children:[r?.failed?(0,m.jsx)("p",{role:"status",className:"text-xs text-muted-foreground",children:"Captured image unavailable."}):null,(0,m.jsx)(QE,{recording:e,screenshotBase64:n?r?.base64:void 0})]}):(0,m.jsx)(QE,{recording:e})}var dte=500,hte={ok:"border-success/30 bg-success/10 text-success",error:"border-destructive/30 bg-destructive/10 text-destructive",unknown:"border-border/50 bg-muted/40 text-muted-foreground"};function RM(e){switch(e){case"left_click":return"Click";case"double_click":return"Double-click";case"right_click":return"Right-click";case"mouse_move":return"Move";case"type":return"Type";case"key":return"Key";case"scroll":return"Scroll";case"wait":return"Wait";case"screenshot":return"Assert";default:return e}}function Jo(e){const t=RM(e.action),n=e.locatorLabel?.trim();return n?`Interact · ${t} ${n}`:`Interact · ${t}`}function qd(e){return e.assertion?e.assertion.passed?"ok":"error":e.ok===!0?"ok":e.ok===!1?"error":"unknown"}function Ea(e){return`${e.toolCallId}:${e.stepIndex}`}function fte(e){if(!e)return[];const t=[];return typeof e.durationMs=="number"&&e.durationMs>0&&t.push({key:"duration",label:Bte(e.durationMs),...typeof e.distinctFrames=="number"?{title:`${e.distinctFrames.toLocaleString()} distinct frames — identical frames are dropped, so an idle page costs none`}:{}}),typeof e.fps=="number"&&e.fps>0&&t.push({key:"fps",label:`${e.fps} fps`}),t}function Bte(e){const t=Math.round(e/1e3),n=t%60,r=Math.floor(t/60)%60,s=Math.floor(t/3600),i=String(r).padStart(s>0?2:1,"0");return s>0?`${s}:${i}:${String(n).padStart(2,"0")}`:`${i}:${String(n).padStart(2,"0")}`}function OM(e){return typeof e=="string"&&e.length>0?e:null}function Nle(e){return(e.widgetRenderObservations?.length??0)>0||(e.browserInteractionSteps?.length??0)>0||OM(e.videoUrl)!==null}function pte(e){return e==="ok"?"OK":e==="error"?"Failed":"Unknown"}function MM({step:e,leading:t,className:n}){const r=qd(e),s=e.widgetToolCalls??[],i=e.coordinateX!=null&&e.coordinateY!=null?`(${e.coordinateX}, ${e.coordinateY})`:null;return(0,m.jsxs)("div",{"data-testid":"browser-step-detail",className:he("flex flex-col gap-4",n),children:[(0,m.jsxs)("div",{className:"flex items-center gap-2",children:[t,(0,m.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,m.jsx)("p",{className:"truncate text-sm font-medium text-foreground",children:Jo(e)}),(0,m.jsxs)("p",{className:"text-xs text-muted-foreground",children:["App interaction · ",e.elapsedMs,"ms",i?` · ${i}`:""]})]}),(0,m.jsx)("span",{className:he("inline-flex shrink-0 items-center rounded-full border px-2 py-0.5 text-[11px] font-medium",hte[r]),children:pte(r)})]}),e.assertion&&!e.assertion.passed&&e.assertion.reason?(0,m.jsx)("p",{className:"text-xs text-destructive",children:e.assertion.reason}):null,e.pluginWorkspace?(0,m.jsx)(ute,{recording:e.pluginWorkspace,screenshotUrl:e.screenshotUrl}):e.screenshotUrl?(0,m.jsx)(tM,{src:e.screenshotUrl,alt:Jo(e),className:"max-h-72 w-full rounded-md border border-border/50 object-contain"}):null,s.length>0?(0,m.jsxs)("div",{className:"space-y-1.5",children:[(0,m.jsx)("p",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Widget tool calls"}),s.map((o,a)=>(0,m.jsxs)("div",{className:"flex items-center gap-2 rounded-md border border-border/50 px-2.5 py-1.5 text-xs",children:[(0,m.jsx)("span",{className:he("inline-block h-1.5 w-1.5 shrink-0 rounded-full",o.ok?"bg-success":"bg-destructive"),"aria-hidden":!0}),(0,m.jsx)("span",{className:"font-mono text-foreground",children:o.name}),o.error?(0,m.jsx)("span",{className:"truncate text-destructive",children:o.error}):null]},`${o.name}-${a}`))]}):null,e.followUps&&e.followUps.length>0?(0,m.jsxs)("div",{className:"space-y-1.5",children:[(0,m.jsx)("p",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Sent message to chat"}),e.followUps.map((o,a)=>(0,m.jsxs)("div",{className:"flex items-center gap-2 rounded-md border border-border/50 px-2.5 py-1.5 text-xs",children:[(0,m.jsx)("span",{"aria-hidden":!0,children:"↳"}),(0,m.jsx)("span",{className:"truncate text-foreground",children:o})]},a))]}):null]})}function mte(e){const t=Math.floor(e/1e3),n=Math.floor(t/60),r=t%60;return`${n}:${String(r).padStart(2,"0")}`}function gte(e,t){let n=null;for(const r of e)if(r.videoOffsetMs!=null)if(r.videoOffsetMs<=t)n=r;else break;return n}function Ple({steps:e,videoUrl:t,videoMeta:n,isRunning:r=!1,className:s}){const i=(0,p.useRef)(null),[o,a]=(0,p.useState)(null),[l,c]=(0,p.useState)(null),u=(0,p.useRef)(null),[d,h]=(0,p.useState)(!1),[f,B]=(0,p.useState)(null),g=Ev(OM(t)),C=(0,p.useMemo)(()=>fte(n),[n]),v=(0,p.useMemo)(()=>[...e].sort((R,P)=>(R.videoOffsetMs??Number.POSITIVE_INFINITY)-(P.videoOffsetMs??Number.POSITIVE_INFINITY)||R.promptIndex-P.promptIndex||R.ts-P.ts),[e]),y=o??l??null,b=(0,p.useMemo)(()=>v.find(R=>Ea(R)===y)??null,[v,y]),E=g!=null&&!d,w=v.some(R=>R.screenshotUrl),A=(0,p.useCallback)(R=>{a(Ea(R));const P=i.current;if(!P||!E||R.videoOffsetMs==null)return;const _=R.videoOffsetMs/1e3;u.current=_,P.currentTime=_},[E]),x=(0,p.useCallback)(()=>{u.current=null},[]),O=(0,p.useCallback)(()=>{const R=i.current;if(!R)return;const P=gte(v,R.currentTime*1e3);if(c(P?Ea(P):null),u.current==null){if(o!=null){const _=v.find(N=>Ea(N)===o);if(_?.videoOffsetMs!=null){const N=_.videoOffsetMs-R.currentTime*1e3;if(N>0&&N<dte)return}}a(null)}},[v,o]);return(0,p.useEffect)(()=>{h(!1)},[g]),(0,p.useEffect)(()=>{if(!f||f.url!==g)return;const R=setTimeout(()=>{B(null),h(!1)},f.delayMs);return()=>clearTimeout(R)},[f,g]),v.length===0&&!g?(0,m.jsx)("div",{className:"flex items-center justify-center rounded-md border border-dashed border-border/40 py-8 text-xs text-muted-foreground","data-testid":"browser-filmstrip-empty",children:r?"Finalizing replay…":"No app interactions were recorded."}):(0,m.jsxs)("section",{className:he("flex min-w-0 flex-col gap-3",s),"data-testid":"browser-step-filmstrip",children:[(0,m.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,m.jsxs)("h3",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:["Replay",(0,m.jsx)("span",{className:"ml-1.5 font-normal normal-case text-muted-foreground/70",children:"screen recording of the app interactions in this run"})]}),g&&!d&&(C.length>0||n?.truncated)?(0,m.jsxs)("p",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-[11px] text-muted-foreground","data-testid":"browser-replay-video-meta",children:[C.map(R=>(0,m.jsx)("span",{title:R.title,children:R.label},R.key)),n?.truncated?(0,m.jsx)("span",{className:"rounded-sm border border-warning/30 bg-warning/10 px-1.5 py-px font-medium text-warning-foreground","data-testid":"browser-replay-truncated-badge",title:"The recorder stopped at its size limit, so this video covers the beginning of the run and not the end of it.",children:"Stopped at the size limit"}):null]}):null,g&&!d?(0,m.jsx)("video",{ref:i,src:g,controls:!0,preload:"metadata",onTimeUpdate:O,onSeeked:x,onError:()=>{const R=ZO(g);h(!0),B(R!==null&&R>0?{url:g,delayMs:R}:null)},onLoadedMetadata:()=>eM(g),className:"w-full rounded-md border border-border/60 bg-black","data-testid":"browser-replay-video"}):(0,m.jsx)("p",{className:"rounded-md border border-dashed border-border/50 bg-muted/20 px-3 py-2 text-[11px] text-muted-foreground","data-testid":"browser-replay-video-unavailable",children:r?"Finalizing replay — the recording is written when the run ends.":d?w?"Recording failed to load — screenshots preserved.":"Recording failed to load, and no screenshots were captured.":w?"Video unavailable — screenshots preserved.":"Partial capture — no recording, and no screenshots survived."})]}),v.length>0?(0,m.jsxs)("div",{className:"flex min-w-0 flex-col gap-2",children:[(0,m.jsx)("div",{className:"flex min-w-0 gap-2 overflow-x-auto pb-1","data-testid":"browser-filmstrip-track",children:v.map(R=>{const P=Ea(R),_=qd(R),N=P===y;return(0,m.jsxs)("button",{type:"button",onClick:()=>A(R),"aria-pressed":N,title:Jo(R),"data-testid":"browser-filmstrip-frame","data-step-key":P,"data-active":N?"true":"false",className:he("flex w-28 shrink-0 flex-col gap-1 rounded-md border p-1 text-left transition-colors",N?"border-primary bg-primary/5":"border-border/50 hover:border-border"),children:[R.pluginWorkspace?(0,m.jsx)("span",{className:"text-xs text-muted-foreground",children:"Workspace capture"}):R.screenshotUrl?(0,m.jsx)(tM,{src:R.screenshotUrl,alt:Jo(R),loading:"lazy",className:"h-16 w-full rounded-sm border border-border/40 bg-background object-cover object-top"}):(0,m.jsx)("div",{className:"flex h-16 w-full items-center justify-center rounded-sm border border-dashed border-border/50 bg-muted/20 text-[10px] text-muted-foreground",children:"No frame"}),(0,m.jsx)("span",{className:"truncate text-[10px] font-medium text-foreground",children:RM(R.action)}),(0,m.jsx)("span",{className:he("truncate text-[10px]",_==="error"?"text-destructive":"text-muted-foreground"),children:R.videoOffsetMs!=null?mte(R.videoOffsetMs):`turn ${R.promptIndex+1}`})]},P)})}),b?(0,m.jsx)(MM,{step:b,className:"rounded-lg bg-muted/5 px-4 py-4"}):(0,m.jsx)("p",{className:"px-1 text-[11px] text-muted-foreground",children:"Select a frame to see the interaction that produced it."})]}):null]})}function Cte(e){const t=[];for(const n of e)n?.event&&t.push({promptIndex:n.promptIndex,...typeof n.startedAtMs=="number"&&Number.isFinite(n.startedAtMs)?{turnStartedAtMs:n.startedAtMs}:{},event:n.event});return t.sort((n,r)=>n.promptIndex-r.promptIndex)}function Lle(e,t){if(!e&&!t)return;const n={},r=(e?.inputTokens??0)+(t?.inputTokens??0),s=(e?.outputTokens??0)+(t?.outputTokens??0),i=(e?.totalTokens??0)+(t?.totalTokens??0),o=(e?.reasoningTokens??0)+(t?.reasoningTokens??0),a=(e?.cachedInputTokens??0)+(t?.cachedInputTokens??0);return r>0&&(n.inputTokens=r),s>0&&(n.outputTokens=s),i>0&&(n.totalTokens=i),o>0&&(n.reasoningTokens=o),a>0&&(n.cachedInputTokens=a),Object.keys(n).length>0?n:void 0}function _le(e){return!Array.isArray(e)||e.length===0?0:e.reduce((t,n)=>Math.max(t,n.endMs),0)}function Fle(e,t){return!Array.isArray(e)||e.length===0?[]:e.map(n=>({...n,startMs:n.startMs+t,endMs:n.endMs+t}))}function vte(e){const t=new Map;return e.map(n=>{const r=t.get(n.turnId),s={system:n.inherits?.system?r?.system??"":n.payload.system??"",tools:n.inherits?.tools?r?.tools??{}:n.payload.tools??{},messages:n.payload.messages??[]};t.set(n.turnId,s);const{inherits:i,...o}=n;return{...o,payload:s}})}function Hle(e){if(!e||typeof e!="object"||Array.isArray(e))return[];const t=e;try{const n=t.requestPayloads??(t.requestPayloadsJson?JSON.parse(t.requestPayloadsJson):void 0);return Array.isArray(n)?vte(n):[]}catch{return[]}}function yte(e){return typeof e=="string"&&e.length>0&&e.length<=200?e:void 0}var bte={[-32700]:"Parse error",[-32600]:"Invalid request",[-32601]:"Method not found",[-32602]:"Invalid params",[-32603]:"Internal error",[-32e3]:"Connection closed",[-32001]:"Request timeout",[-32042]:"URL elicitation required"};function Ste(e){const t=bte[e];return t?`${e} · ${t}`:String(e)}var Ete=D({id:S(),parentId:S().optional(),name:S(),category:U(["step","llm","tool","error","connection","discovery"]),startMs:M(),endMs:M(),promptIndex:M().optional(),stepIndex:M().optional(),authoredStepId:S().optional(),status:U(["ok","error"]).optional(),toolCallId:S().optional(),toolName:S().optional(),toolOrigin:U(["mcp","native","builtin","unknown"]).optional(),serverId:S().optional(),connectionId:S().optional(),modelId:S().optional(),inputTokens:M().optional(),outputTokens:M().optional(),totalTokens:M().optional(),cost:Ln().transform(FD).optional(),callId:Ln().transform(yte).optional(),messageStartIndex:M().optional(),messageEndIndex:M().optional(),finishReason:S().optional(),provider:S().optional(),responseId:S().optional(),responseTimestamp:S().optional(),ttfcMs:M().optional(),mcpErrorCode:M().optional(),outputSource:lr([L("narration"),L("evidence"),L("reconstructed")]).optional(),wireCorroborated:le().optional(),evidenceRequestId:S().optional(),evidenceStatus:lr([L("complete"),L("incomplete")]).optional()}),li=D({toolName:S(),arguments:Mr(S(),ux())}),xte=D({promptIndex:M(),prompt:S(),expectedToolCalls:K(li),actualToolCalls:K(li),expectedOutput:S().optional(),passed:le(),missing:K(li),unexpected:K(li),argumentMismatches:K(D({expected:li,actual:li,mismatchedArguments:K(S())})),retries:K(li.extend({actualIndex:M().int().nonnegative(),retriedByIndex:M().int().nonnegative()})).optional()}),wte=D({toolCallId:S(),toolName:S(),protocol:lr([L("mcp-apps"),L("openai-apps")]),serverId:S(),resourceUri:S().optional(),toolMetadata:Mr(S(),Ln()),widgetCsp:Mr(S(),Ln()).nullable().optional(),widgetPermissions:Mr(S(),Ln()).nullable().optional(),widgetPermissive:le().optional(),prefersBorder:le().optional(),widgetHtmlBlobId:S().optional(),widgetHtmlUrl:S().nullable().optional(),injectedOpenAiCompat:le().optional(),injectedOpenAiCompatCapabilities:D({callTool:le().optional(),sendFollowUpMessage:le().optional(),setWidgetState:le().optional(),requestDisplayMode:U(["all","fullscreen-only","none"]).optional(),notifyIntrinsicHeight:le().optional(),openExternal:le().optional(),setOpenInAppUrl:le().optional(),requestModal:le().optional(),uploadFile:le().optional(),selectFiles:le().optional(),getFileDownloadUrl:le().optional(),requestCheckout:le().optional(),requestClose:le().optional()}).optional()}),Dte=D({source:U(["hosted","widget"]),fps:M().optional(),durationMs:M().optional(),distinctFrames:M().optional(),truncated:le().optional()}),jle=D({traceVersion:L(1),messages:K(ux()),widgetSnapshots:K(wte).optional(),spans:K(Ete).optional(),prompts:K(xte).optional(),videoBlobId:S().optional(),videoMeta:Dte.optional()});function Tte(e,t){const n=[],r=new Map;return t.forEach((s,i)=>{if(s.role==="user"&&n.push(i),!!Array.isArray(s.content))for(const o of s.content){if(typeof o!="object"||o===null||o.type!=="tool-call"&&o.type!=="tool-result"||typeof o.toolCallId!="string")continue;const a=r.get(o.toolCallId)??[];a.push(i),r.set(o.toolCallId,a)}}),{userIndices:n,spans:e.map(s=>{const i=n[s.promptIndex??0],o=n[(s.promptIndex??0)+1]??t.length,a=i!==void 0&&s.category==="tool"&&s.toolCallId?r.get(s.toolCallId)?.filter(l=>l>=i&&l<o):void 0;return{...s,messageStartIndex:a?.[0],messageEndIndex:a?.at(-1)}})}}function Ate({recording:e}){let t;try{t=Ov(e)}catch{return null}return(0,m.jsxs)("section",{"aria-label":"Workspace events",className:"mt-4 space-y-2 text-xs",children:[(0,m.jsx)("p",{className:"font-medium",children:"Workspace events"}),t.droppedEvents>0&&(0,m.jsxs)("p",{className:"text-muted-foreground",children:[t.droppedEvents," earlier events omitted."]}),t.events.map(n=>(0,m.jsxs)("div",{className:"flex gap-2 border-b border-border py-2",children:[(0,m.jsx)("span",{className:"tabular-nums text-muted-foreground",children:n.sequence}),(0,m.jsxs)("span",{children:[n.kind,"feature"in n&&n.feature?` · ${n.feature} (${n.fidelity})`:"","outcome"in n&&n.outcome?` · ${n.outcome}`:"","display"in n&&n.display?` · ${n.display.displayMode??"unavailable"} · cursor ${n.display.interactionCursor}`:""]})]},n.sequence))]})}var Mv=(0,p.createContext)(void 0);function Gle({accounts:e,testCaseId:t,children:n}){const r=FZ(),s=(0,p.useMemo)(()=>r?e?.filter(i=>!i.cases||i.cases.some(o=>o.testCaseId===t)):void 0,[e,r,t]);return(0,m.jsx)(Mv.Provider,{value:s,children:n})}function NM(){const e=(0,p.useContext)(Mv);return(0,p.useCallback)(t=>IM(t,e),[e])}function Vle({spans:e,children:t}){const n=(0,p.useContext)(Mv),r=(0,p.useMemo)(()=>ite(e,n),[e,n]);return(0,m.jsx)(qI.Provider,{value:r,children:t})}var Ite=1024;function kte(e){const[t,n]=(0,p.useState)(null),[r,s]=(0,p.useState)(!1);return(0,p.useLayoutEffect)(()=>{if(e!=="auto"||!t)return;const i=()=>s(t.getBoundingClientRect().width>=Ite);if(i(),typeof ResizeObserver>"u")return;const o=new ResizeObserver(i);return o.observe(t),()=>o.disconnect()},[e,t]),{containerRef:n,direction:e==="auto"&&r?"horizontal":"vertical"}}var Rte=["all","connection","discovery","llm","tool","error"];function IB(e){switch(e){case"all":return"All";case"connection":return"Connect";case"discovery":return"Discovery";case"llm":return"LLM";case"tool":return"Tool";case"error":return"Error"}}function Ote({filter:e,onFilterChange:t,isFullyExpanded:n,expandDisabled:r,onToggleExpandAll:s,zoomControls:i,showBottomBorder:o=!0}){return(0,m.jsxs)("div",{className:he("flex min-h-7 min-w-0 flex-1 flex-row flex-nowrap items-center gap-2 overflow-x-auto [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",o&&"border-b border-border/30 pb-2"),children:[(0,m.jsxs)(OC,{children:[(0,m.jsx)(MC,{asChild:!0,children:(0,m.jsxs)(kn,{type:"button",variant:"outline",size:"sm",className:"h-7 shrink-0 gap-1.5 border-border/50 px-2 text-[10px] font-medium text-foreground","aria-label":`Filter timeline rows: ${IB(e)}`,children:[(0,m.jsx)(fH,{className:"size-3.5 shrink-0 opacity-80","aria-hidden":!0}),IB(e)]})}),(0,m.jsx)(NC,{align:"start",className:"min-w-[8rem]",children:(0,m.jsx)(U$,{value:e,onValueChange:a=>t(a),children:Rte.map(a=>(0,m.jsx)(z$,{value:a,className:"text-xs",children:IB(a)},a))})})]}),(0,m.jsx)(kn,{type:"button",variant:"outline",size:"icon",disabled:r,className:"h-7 w-7 shrink-0 border-border/50 text-muted-foreground hover:text-foreground disabled:opacity-40",title:n?"Collapse all":"Expand all","aria-label":n?"Collapse all":"Expand all","aria-pressed":n,onClick:s,children:n?(0,m.jsx)(EH,{className:"size-3.5",strokeWidth:2,"aria-hidden":!0}):(0,m.jsx)(cH,{className:"size-3.5",strokeWidth:2,"aria-hidden":!0})}),i?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)("span",{className:"bg-border hidden h-3 w-px shrink-0 md:block","aria-hidden":!0}),(0,m.jsx)("div",{className:"flex shrink-0 items-center gap-0.5",children:i})]}):null]})}function PM(e,t=[]){const n=e.filter(r=>r.category==="llm");if(!(!n.some(r=>r.cost)&&t.length===0))return jH([...n.map(r=>r.cost),...t])}function LM(e,t){if(!e||e.kind==="interaction")return;if(e.kind==="span"){const{span:r}=e;if(r.category!=="llm")return;const s=r.cost??t?.find(({id:i})=>i===r.id)?.cost;return s?{kind:"call",cost:s}:void 0}const n=PM((t??[]).filter(r=>(r.promptIndex??0)===e.promptIndex));return n?{kind:"rollup",rollup:n}:void 0}function Mte(e){if(e===0)return"$0.00";if(e<1e-4)return"<$0.0001";const t=e.toFixed(4);return Number(t)<1?`$${t}`:`$${e.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}`}var Nv={provider_reported:"Provider-reported",list_price:"Estimated at list price",customer_rate:"Estimated at your rates",runner_reported:"Runner-reported"},_M={partial:"Partial",unavailable:"Cost unavailable"},Pv=e=>e==="list_price"||e==="customer_rate",Nte={no_usage:"No token usage was reported for this call.",no_rate:"No price is on record for this model.",invalid_rate:"The price on record for this model was invalid. An organization admin can set a price under Model prices to price future calls.",unsupported_currency:"The price on record is not in US dollars."},Pte={usage:"unreported usage",input_tokens:"input tokens",output_tokens:"output tokens",rate:"tokens without a rate",cache_read_rate:"cache reads",cache_write_rate:"cache writes",cache_write_1h_rate:"one-hour cache writes",web_search_rate:"web searches"},Lte={input:"Input",cacheRead:"Cache read",cacheWrite:"Cache write",output:"Output",webSearch:"Web search"};function _te(e){if(e.length<=1)return e[0]&&Nv[e[0]];const t=e.filter(Pv).length;return t===e.length?"Estimated":t>0?"Reported and estimated":"Reported"}function Fte(e){const t=(e.missing??[]).map(s=>Pte[s]),n=e.completeness==="unavailable"?e.reason?Nte[e.reason]:"No price is on record for this call.":e.completeness==="partial"?t.length>0?`Excludes ${t.join(", ")}.`:"Some charges on this call are not priced.":void 0,r=Object.entries(Lte).flatMap(([s,i])=>{const o=e.parts?.[s];return typeof o=="number"?[{label:i,amountUsd:o}]:[]});return{amountUsd:e.amountUsd,estimated:e.source?Pv(e.source):!1,sourceLabel:e.source?Nv[e.source]:void 0,completeness:e.completeness,note:n,parts:r}}function Hte(e){const t=e.totalCalls-e.unavailableCalls,n=e.totalCalls===1?"call":"calls",r=e.partialCalls>0?`, ${e.partialCalls} partly`:"";return{amountUsd:e.completeness==="unavailable"?void 0:e.knownSubtotalUsd,estimated:e.sources.some(Pv),sourceLabel:_te(e.sources),completeness:e.completeness,coverage:`${t} of ${e.totalCalls} ${n} priced${r}`,parts:[]}}function FM(e){return e.kind==="call"?Fte(e.cost):Hte(e.rollup)}var xa={name:512,eventId:1024,timestamp:64,subscriptionId:256,triggerId:256},mg=["poll","push","webhook"],jte=["server","simulation","replay"];function YE(e){return e>=55296&&e<=56319}function XE(e){return e>=56320&&e<=57343}function Gte(e,t){let n="",r=0;for(;r<e.length;){const s=e.charCodeAt(r);let i;if(YE(s)&&r+1<e.length&&XE(e.charCodeAt(r+1))?i=e.slice(r,r+2):YE(s)||XE(s)?i="�":i=e[r],n.length+i.length>t)break;n+=i,r+=i==="�"?1:i.length}return n}function Vte(e,t){return typeof e=="string"&&mg.includes(e)?{origin:"server",delivery:e}:e==="simulation"||e==="replay"?typeof t=="string"&&mg.includes(t)?{origin:e,delivery:t}:{origin:e}:{origin:"server"}}function wa(e,t){if(typeof e!="string")return;const n=Gte(e,t);return n.length>0?n:void 0}function Ute(e){return e>=0&&!Number.isNaN(new Date(e).getTime())}function HM(e){const t=wa(e.name,xa.name);if(!t||!Ute(e.receivedAt))return;const{origin:n,delivery:r}=Vte(e.origin,e.subscriptionMode),s=wa(e.eventId,xa.eventId),i=wa(e.timestamp,xa.timestamp),o=wa(e.subscriptionId,xa.subscriptionId),a=wa(e.triggerId,xa.triggerId);return{name:t,...s?{eventId:s}:{},...i?{timestamp:i}:{},receivedAt:e.receivedAt,...r?{delivery:r}:{},origin:n,...o?{subscriptionId:o}:{},...a?{triggerId:a}:{}}}function Ule(e,t){return HM({name:e.name??"",eventId:e.eventId,timestamp:e.timestamp,receivedAt:e.receivedAt,origin:e.origin,subscriptionMode:t,subscriptionId:e.logicalSubscriptionId})}function zte(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function vu(e){return e==null||typeof e=="string"}function jM(e){if(!zte(e)||typeof e.name!="string"||typeof e.receivedAt!="number"||typeof e.origin!="string"||!jte.includes(e.origin)||!(e.delivery===void 0||e.delivery===null||typeof e.delivery=="string"&&mg.includes(e.delivery))||!vu(e.eventId)||!vu(e.timestamp)||!vu(e.subscriptionId)||!vu(e.triggerId))return;const t=HM({name:e.name,eventId:e.eventId,timestamp:e.timestamp,receivedAt:e.receivedAt,subscriptionId:e.subscriptionId,triggerId:e.triggerId});if(t)return{...t,...typeof e.delivery=="string"?{delivery:e.delivery}:{},origin:e.origin}}function zle(e){if(!e||typeof e!="object"||Array.isArray(e))return;const t=e.turnEvents;if(!Array.isArray(t))return;const n=new Map;for(const r of t){if(!r||typeof r!="object")continue;const{promptIndex:s,turnStartedAtMs:i,event:o}=r,a=jM(o);typeof s!="number"||!a||n.set(s,{promptIndex:s,...GM(i)?{turnStartedAtMs:i}:{},event:a})}return n.size>0?n:void 0}function $le(e){return Cte((e??[]).map(t=>({promptIndex:t.promptIndex,startedAtMs:t.startedAt,event:jM(t.eventAtTurn)})))}function $te(e){return`Event: ${e.name}`}function Wte(e){return e.origin==="simulation"}function qte(e,t,n=Xte){const r=[];if(e.timestamp!==void 0){const l=Qte(e.timestamp);r.push(l===void 0?{key:"occurred",label:"Occurred",asSent:e.timestamp}:{key:"occurred",label:"Occurred",ms:l})}r.push({key:"received",label:"Received",ms:e.receivedAt}),GM(t)&&r.push({key:"turn-started",label:"Turn started",ms:t});const s=r.map((l,c)=>{const u=r[c-1];if(!u||!("ms"in u)||!("ms"in l))return;const d=l.ms-u.ms;return d>=0?d:void 0}),i=r.map((l,c)=>{const u=s[c];return{key:l.key,label:l.label,..."ms"in l?{value:n(l.ms)}:{value:l.asSent,asSent:!0},...u!==void 0?{waitSincePrevious:ZE(u)}:{}}}),[,o,a]=s;return{stops:i,...r.length===3&&o!==void 0&&a!==void 0?{totalWait:ZE(o+a)}:{}}}var Kte={poll:"Poll",push:"Push",webhook:"Webhook"};function Jte(e){const t=[];return e.eventId&&t.push({label:"Event ID",value:e.eventId,copySubject:"event ID"}),e.subscriptionId&&t.push({label:"Subscription",value:e.subscriptionId,copySubject:"subscription ID"}),e.triggerId&&t.push({label:"Trigger",value:e.triggerId,copySubject:"trigger ID"}),e.delivery&&t.push({label:"Delivery",value:Kte[e.delivery]}),t}function Qte(e){const t=/(\d{4})-(\d{2})-(\d{2})[T ]\d{2}:\d{2}/.exec(e);if(!t||!Yte(Number(t[1]),Number(t[2]),Number(t[3])))return;const n=Date.parse(e);return Number.isFinite(n)?n:void 0}function Yte(e,t,n){const r=new Date(0);return r.setUTCFullYear(e,t-1,n),r.getUTCFullYear()===e&&r.getUTCMonth()===t-1&&r.getUTCDate()===n}function Xte(e){return new Date(e).toLocaleString()}function ZE(e){const t=Math.round(e);return t<6e4?ete(t):Oee(t)}function GM(e){return typeof e=="number"&&Number.isFinite(e)}function VM({event:e}){return!e||!Wte(e)?null:(0,m.jsx)(Al,{variant:"outline","data-testid":"trace-event-test-badge",className:"border-border/60 bg-muted/30 px-1.5 py-0 text-[10px] font-medium text-muted-foreground",title:"A test event, sent from MCPJam",children:"Test"})}function Zte({turnEvent:e}){const{event:t}=e,n=qte(t,e.turnStartedAtMs),r=Jte(t);return(0,m.jsxs)("section",{"data-testid":"trace-event-section","aria-label":"Event",className:"space-y-3 rounded-md border border-border/50 px-3 py-3 text-xs",children:[(0,m.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,m.jsx)(bH,{className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":!0}),(0,m.jsx)("span",{className:"text-[10px] uppercase tracking-wide text-muted-foreground",children:"Event"}),(0,m.jsx)("span",{className:"min-w-0 truncate font-mono text-xs font-medium text-foreground",title:t.name,children:t.name}),(0,m.jsx)(VM,{event:t})]}),(0,m.jsxs)("div",{"data-testid":"trace-event-timing",children:[n.stops.map((s,i)=>(0,m.jsxs)("div",{children:[i>0?(0,m.jsxs)("div",{className:"flex min-h-4 items-stretch gap-3 text-[11px] tabular-nums text-muted-foreground","data-testid":`trace-event-wait-${s.key}`,children:[(0,m.jsx)("span",{className:"flex w-[11px] shrink-0 justify-center","aria-hidden":!0,children:(0,m.jsx)("span",{className:"w-px bg-border"})}),(0,m.jsx)("span",{className:"w-24 shrink-0","aria-hidden":!0}),(0,m.jsx)("span",{className:"self-center",children:s.waitSincePrevious?`+${s.waitSincePrevious}`:null})]}):null,(0,m.jsx)(kB,{marker:(0,m.jsx)("span",{className:"block size-[11px] rounded-full border border-border bg-background"}),label:s.label,children:(0,m.jsx)("span",{"data-testid":`trace-event-time-${s.key}`,className:s.asSent?"break-all font-mono text-foreground":"tabular-nums text-foreground",children:s.value})})]},s.key)),n.totalWait?(0,m.jsx)("div",{className:"pt-2",children:(0,m.jsx)(kB,{label:"Total wait",children:(0,m.jsx)("span",{"data-testid":"trace-event-total-wait",className:"font-medium tabular-nums text-foreground",children:n.totalWait})})}):null]}),r.length>0?(0,m.jsx)("div",{"data-testid":"trace-event-identifiers",className:"space-y-1 border-t border-border/40 pt-3",children:r.map(s=>(0,m.jsx)(kB,{label:s.label,children:(0,m.jsxs)("span",{className:"flex min-w-0 items-center gap-1",children:[(0,m.jsx)("span",{className:s.copySubject?"min-w-0 truncate font-mono text-foreground":"min-w-0 truncate text-foreground",title:s.value,children:s.value}),s.copySubject?(0,m.jsx)(jZ,{value:s.value,subject:s.copySubject,size:"inline"}):null]})},s.label))}):null]})}function kB({marker:e,label:t,children:n}){return(0,m.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,m.jsx)("span",{className:"flex w-[11px] shrink-0 justify-center","aria-hidden":!0,children:e}),(0,m.jsx)("span",{className:"w-24 shrink-0 text-muted-foreground",children:t}),(0,m.jsx)("span",{className:"min-w-0 flex-1",children:n})]})}var ene="trace-cost";function Sc(){return oA(ene)===!0}var UM="evalIterationModelCalls:list",tne=Sh(UM),yu=e=>Number.isInteger(e)&&e>=0;function nne(e){if(!e||typeof e!="object")return;const t=e,{knownSubtotalUsd:n,sources:r}=t;return t.currency==="USD"&&typeof n=="number"&&Number.isFinite(n)&&n>=0&&["complete","partial","unavailable"].includes(t.completeness)&&yu(t.totalCalls)&&yu(t.completeCalls)&&yu(t.partialCalls)&&yu(t.unavailableCalls)&&Array.isArray(r)&&r.every(s=>typeof s=="string"&&Object.hasOwn(Nv,s))?e:void 0}function Wle(e,t){const n=nne(e.usage?.costRollup);return{iterationId:e._id,...n?{rollup:n}:{},harness:t?t.startsWith("harness:"):!!sN(e.execution)?.harness}}function rne(e,t){const n=new Set(e.filter(o=>o.category==="llm").map(o=>o.id)),r=new Map,s=[],i=new Set;for(const o of t??[]){if(i.has(o.generationId))continue;i.add(o.generationId);const a=FD(o.cost),l=o.matchedSpanId;l&&n.has(l)&&!r.has(l)?r.set(l,a):s.push({generationId:o.generationId,modelId:o.modelId,cost:a})}return{spans:e.map(o=>{const a=o.cost??r.get(o.id);return a===o.cost?o:{...o,cost:a}}),unmatched:s}}function sne(e){return hN(e,UM)}var zM=[];function Xh(e){const t=Sc();return(0,p.useMemo)(()=>t&&e?FM(e):void 0,[t,e])}function ql({amountUsd:e,estimated:t,slot:n=!1}){return(0,m.jsxs)("span",{className:"whitespace-nowrap tabular-nums",children:[t?(0,m.jsx)("span",{className:"inline-block w-[1ch] text-center",children:"≈"}):n?(0,m.jsx)("span",{"aria-hidden":!0,className:"inline-block w-[1ch]"}):null,Mte(e)]})}function $M({view:e}){return(0,m.jsxs)(m.Fragment,{children:[e.sourceLabel?(0,m.jsx)(Al,{variant:"outline",className:"px-1.5 py-0 text-[10px] text-muted-foreground",children:e.sourceLabel}):null,e.completeness!=="complete"?(0,m.jsx)(Al,{variant:"outline",className:he("px-1.5 py-0 text-[10px]",e.completeness==="partial"?"border-warning/50 bg-warning/10 text-foreground":"text-muted-foreground"),children:_M[e.completeness]}):null,e.coverage?(0,m.jsx)("span",{children:e.coverage}):null,e.note?(0,m.jsx)("span",{children:e.note}):null]})}function ine({cost:e}){const t=Xh(e);return t?.amountUsd===void 0?null:(0,m.jsxs)("span",{"data-testid":"trace-cost-inline",children:[" · ",(0,m.jsx)("span",{className:"font-medium text-foreground",children:(0,m.jsx)(ql,{amountUsd:t.amountUsd,estimated:t.estimated})})]})}function one({cost:e}){const t=Xh(e);return t?(0,m.jsxs)("div",{"data-testid":"trace-cost-chips",className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-[11px] text-muted-foreground",children:[(0,m.jsx)("span",{className:"text-muted-foreground/70",children:"Cost"}),(0,m.jsx)($M,{view:t})]}):null}function Da({label:e,children:t}){return(0,m.jsxs)("div",{className:"flex min-w-0 items-baseline justify-between gap-3",children:[(0,m.jsx)("span",{className:"shrink-0 text-popover-foreground/70",children:e}),(0,m.jsx)("span",{className:"min-w-0 text-right font-medium text-popover-foreground",children:t})]})}function ane({cost:e}){const t=Xh(e);return t?(0,m.jsxs)("div",{"data-testid":"trace-row-hover-cost",className:"space-y-1.5",children:[(0,m.jsx)("div",{className:"text-[10px] font-semibold uppercase tracking-wide text-popover-foreground/65",children:"Cost"}),(0,m.jsxs)("div",{className:"space-y-1 text-xs",children:[(0,m.jsx)(Da,{label:e?.kind==="rollup"?"Total":"Amount",children:t.amountUsd===void 0?"Unavailable":(0,m.jsx)(ql,{amountUsd:t.amountUsd,estimated:t.estimated,slot:!0})}),t.parts.map(n=>(0,m.jsx)(Da,{label:n.label,children:(0,m.jsx)(ql,{amountUsd:n.amountUsd,estimated:t.estimated,slot:!0})},n.label)),t.sourceLabel?(0,m.jsx)(Da,{label:"Source",children:t.sourceLabel}):null,t.completeness==="partial"?(0,m.jsx)(Da,{label:"Status",children:_M.partial}):null,t.coverage?(0,m.jsx)(Da,{label:"Coverage",children:t.coverage}):null,t.note?(0,m.jsx)("p",{className:"text-popover-foreground/70",children:t.note}):null]})]}):null}function lne(e,t){const n=Sc()&&t?.harness?t.iterationId:void 0,[r,s]=(0,p.useState)(),i=r?.iterationId===n?r?.calls:void 0,o=(0,p.useMemo)(()=>i?rne(e??[],i):void 0,[e,i]),a=(0,p.useCallback)(()=>s(void 0),[]),l=n?(0,m.jsx)(Dd,{name:"trace-cost-model-calls",isExpectedError:sne,onError:a,fallback:null,children:(0,m.jsx)(cne,{iterationId:n,onLoad:s})},n):null;return{spans:o?.spans??e,unmatched:o?.unmatched??zM,loader:l}}function cne({iterationId:e,onLoad:t}){const n=tA(tne,{iterationId:e});return(0,p.useEffect)(()=>{n&&t({iterationId:e,calls:n})},[n,e,t]),null}function une({spans:e,iteration:t,unmatched:n=zM}){const r=Sc(),s=Xh((0,p.useMemo)(()=>{if(!r)return;const i=t?.rollup??PM(e??[],n.map(o=>o.cost));return i&&{kind:"rollup",rollup:i}},[r,e,t?.rollup,n]));return s?(0,m.jsxs)("div",{"data-testid":"trace-cost-summary",className:"shrink-0 space-y-2 rounded-lg border border-border/50 bg-background px-3 py-2 text-xs text-muted-foreground",children:[(0,m.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[(0,m.jsx)("span",{className:"text-[10px] font-semibold uppercase tracking-wide",children:"Trace cost"}),s.amountUsd!==void 0?(0,m.jsx)("span",{className:"text-sm font-semibold text-foreground",children:(0,m.jsx)(ql,{amountUsd:s.amountUsd,estimated:s.estimated})}):null,(0,m.jsx)($M,{view:s})]}),n.length>0?(0,m.jsx)(dne,{calls:n}):null]}):null}function dne({calls:e}){return(0,m.jsxs)("div",{"data-testid":"trace-cost-unmatched-calls",className:"space-y-1",children:[(0,m.jsx)("div",{className:"text-[10px] font-semibold uppercase tracking-wide",children:"Model calls not matched to a step"}),(0,m.jsx)("ul",{"data-testid":"trace-cost-unmatched-list",className:"max-h-40 space-y-0.5 overflow-y-auto",children:e.map(t=>{const n=t.cost&&FM({kind:"call",cost:t.cost});return(0,m.jsxs)("li",{className:"flex flex-wrap items-baseline gap-x-2",children:[(0,m.jsx)("span",{className:"min-w-0 truncate font-mono text-foreground",children:t.modelId}),(0,m.jsx)("span",{className:"font-medium text-foreground",children:n?.amountUsd!==void 0?(0,m.jsx)(ql,{amountUsd:n.amountUsd,estimated:n.estimated}):"Cost unavailable"}),n?.sourceLabel?(0,m.jsx)("span",{children:n.sourceLabel}):null]},t.generationId)})})]})}var ex=[0,25,50,75,100],hne=54,fne=120;function Bne(e){if(!Number.isFinite(e))return[0,100];if(e<=0)return[0,100];const t=Math.max(2,Math.floor(e/hne));return t>=ex.length?[...ex]:t<=2?[0,100]:t===3?[0,50,100]:[0,25,75,100]}function pne(e){return e<=0?"left-0 top-1/2 -translate-x-0 -translate-y-1/2 text-left":e>=100?"left-0 top-1/2 -translate-x-full -translate-y-1/2 text-right":"left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 text-center"}function tx(e){return e<=0?ad(0):`${ad(0)}–${ad(e)}`}function mne(e){const t=e.filter(l=>l.category==="llm");let n=0,r=0,s=0,i=0,o=0,a=0;for(const l of t)typeof l.inputTokens=="number"&&(n+=l.inputTokens,r++),typeof l.outputTokens=="number"&&(s+=l.outputTokens,i++),typeof l.totalTokens=="number"&&(o+=l.totalTokens,a++);return{...r?{inputTokens:n}:{},...i?{outputTokens:s}:{},...a?{totalTokens:o}:{}}}function Zh(e,t){return t}function nx(e){switch(e){case"connection":return-2;case"discovery":return-1;case"step":return 0;case"llm":return 1;case"tool":return 2;case"error":return 3;default:return Zh(e,9)}}function gne(e,t){if(e.startMs!==t.startMs)return e.startMs-t.startMs;const n=nx(e.category)-nx(t.category);return n!==0?n:e.endMs!==t.endMs?e.endMs-t.endMs:e.name.localeCompare(t.name)}function Cne(e,t){return typeof e!="number"||t<50?null:e/(t/1e3)}function ul(e){return e>=1e3?`${(e/1e3).toFixed(e>=1e4?1:2)}s`:`${Math.round(e)}ms`}function ad(e){return e>=1e3?`${(e/1e3).toFixed(2)}s`:`${Math.round(e)}ms`}function es(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Kl(e){const t=e.toolName??e.name;return typeof t=="string"&&t.trim()?t:void 0}function Ec(e){return Array.isArray(e.content)?e.content.filter(t=>es(t)&&typeof t.type=="string"):typeof e.content=="string"?[{type:"text",text:e.content}]:[]}function WM(e){if(e==null)return"None";if(typeof e=="string")return e.length>180?`${e.slice(0,177)}...`:e;if(typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e))return`${e.length} item${e.length===1?"":"s"}`;if(es(e)){const t=Object.keys(e);return t.length>0?`{ ${t.slice(0,4).join(", ")}${t.length>4?", ...":""} }`:"{}"}return String(e)}function vne(e){const t=Ec(e);if(t.length===0)return typeof e.content=="string"?e.content:"No content";const n=t.slice(0,3).map(r=>r.type==="text"&&typeof r.text=="string"?r.text:r.type==="tool-call"?`Tool call: ${Kl(r)??"Tool"}`:r.type==="tool-result"?`Tool result: ${Kl(r)??"Tool"}`:typeof r.type=="string"?r.type:"content").join(" | ");return n.length>220?`${n.slice(0,217)}...`:n}function yne(e){return!es(e)||!("type"in e)||!("value"in e)?e:e.value}function bne(e){return e.result!==void 0?e.result:yne(e.output)}function Sne(e){const t=bne(e);if(typeof e.error=="string"&&e.error.trim())return e.error.trim();if(es(e.error)&&typeof e.error.message=="string")return e.error.message;if(es(e.output)&&e.output.type==="error-text")return typeof e.output.value=="string"?e.output.value:"Tool error";if(es(e.result)&&e.result.isError===!0||es(e.output)&&es(e.output.value)&&e.output.value.isError===!0||e.isError===!0)return AB(t)??"Tool error"}function ef(e,t,n,r){if(!t&&!n)return{};if(r){if(!t||r.messageStartIndex===void 0||r.messageEndIndex===void 0)return{};e=e.slice(r.messageStartIndex,r.messageEndIndex+1)}let s,i,o;for(const a of e)for(const l of Ec(a)){const c=typeof t=="string"&&l.toolCallId===t,u=!t&&typeof n=="string"&&Kl(l)===n;if(!(!c&&!u)&&(l.type==="tool-call"&&(s=l.input??l.parameters??l.args),l.type==="tool-result")){i=l.result??(es(l.output)&&"value"in l.output?l.output.value:l.output);const d=Sne(l);d&&(o=d)}}return{input:s,output:i,errorText:o}}function So(e,t,n=!1){return e.category==="error"||e.status==="error"?!0:e.category==="tool"?!!ef(t,e.toolCallId,e.toolName??e.name,n?e:void 0).errorText:!1}function ca(e,t){if(typeof e!="number"&&typeof t!="number")return;const n=e??t??0,r=t??e??n;return{startIndex:Math.min(n,r),endIndex:Math.max(n,r)}}function Ene(e){return ca(e.messageStartIndex,e.messageEndIndex)}function xne(e){return ca(e.span.messageStartIndex,e.span.messageEndIndex)}function qM(e){if(!e||e.startIndex<0)return[];const t=[];for(let n=e.startIndex;n<=e.endIndex;n+=1)t.push(n);return t}function KM(e,t,n){if(t)for(let r=t.startIndex;r<=t.endIndex;r+=1){const s=e[r];if(s&&n(s))return r}}function Lv(e,t,n){if(!e.length)return;const r=ca(t,n);if(!r){const i=e.findIndex(o=>o.role==="user");return i>=0?i:void 0}const s=KM(e,r,i=>i.role==="user");if(typeof s=="number")return s;if(!(r.startIndex>=e.length)&&r.startIndex>0)for(let i=r.startIndex-1;i>=0;i-=1){const o=e[i];if(o){if(o.role==="user")return i;if(o.role==="assistant")break}}}function wne(e,t){if(e.kind==="prompt")return"trace-waterfall-bar-prompt";if(e.kind==="interaction")return e.status==="error"?"trace-waterfall-bar-error":"trace-waterfall-bar-tool";if(e.kind==="span"&&t)return"trace-waterfall-bar-error";if(e.kind!=="span")return"trace-waterfall-bar-step";const n=e.span.category;switch(n){case"llm":return"trace-waterfall-bar-llm";case"tool":return"trace-waterfall-bar-tool";case"step":case"connection":case"discovery":return"trace-waterfall-bar-step";case"error":return"trace-waterfall-bar-error";default:return Zh(n,"trace-waterfall-bar-step")}}function Dne(e){switch(e){case"prompt":return"trace-waterfall-glyph-prompt";case"step":return"trace-waterfall-glyph-step";case"llm":return"trace-waterfall-glyph-llm";case"tool":case"interaction":return"trace-waterfall-glyph-tool";case"error":return"trace-waterfall-glyph-error";case"connection":case"discovery":return"trace-waterfall-glyph-step";default:return Zh(e,"text-muted-foreground")}}function Tne(e,t){if(e.kind==="prompt")return"trace-waterfall-row-accent-prompt";if(e.kind==="interaction")return e.status==="error"?"trace-waterfall-row-accent-error":"trace-waterfall-row-accent-tool";const n=t?"error":e.span.category;switch(n){case"llm":return"trace-waterfall-row-accent-llm";case"tool":return"trace-waterfall-row-accent-tool";case"error":return"trace-waterfall-row-accent-error";case"step":case"connection":case"discovery":return"trace-waterfall-row-accent-step";default:return Zh(n,"border-l-muted-foreground")}}function Ane(e){const t=new Map;for(const n of e){const r=typeof n.promptIndex=="number"?n.promptIndex:0,s=t.get(r);s?s.push(n):t.set(r,[n])}return[...t.entries()].sort(([n],[r])=>n-r).map(([n,r])=>{const s=new Map;r.forEach(c=>{s.set(c.id,{span:c,children:[]})});const i=[];r.forEach(c=>{const u=s.get(c.id),d=typeof c.parentId=="string"?s.get(c.parentId):void 0;if(d){d.children.push(u);return}i.push(u)});const o=c=>{c.sort((u,d)=>gne(u.span,d.span)),c.forEach(u=>o(u.children))};o(i);const a=r.flatMap(c=>{const u=[];return typeof c.messageStartIndex=="number"&&u.push(c.messageStartIndex),typeof c.messageEndIndex=="number"&&u.push(c.messageEndIndex),u}),l={step:0,llm:0,tool:0,error:0,connection:0,discovery:0};for(const c of r)c.category in l&&l[c.category]++;return{key:`prompt-${n}`,promptIndex:n,label:`Prompt ${n+1}`,spans:r,roots:i,startMs:Math.min(...r.map(c=>c.startMs)),endMs:Math.max(...r.map(c=>c.endMs)),messageStartIndex:a.length>0?Math.min(...a):void 0,messageEndIndex:a.length>0?Math.max(...a):void 0,counts:l}})}function rx(e){const t=new Set;function n(r){for(const s of r)s.span.category==="step"&&s.children.length>0&&t.add(s.span.id),n(s.children)}for(const r of e)n(r.roots);return t}function RB(e){return{role:e.role,content:e.content}}function JM(e,t,n){const r=ca(t,n);if(!r)return[];const s=e.slice(r.startIndex,r.endIndex+1);if(s.length===0)return[];let i=-1;for(let a=0;a<s.length;a++)if(s[a].role==="assistant"){i=a;break}if(i<0)return e.slice(0,r.endIndex+1);const o=r.startIndex+i;return o===0?[]:e.slice(0,o)}function Ine(e,t,n){const r=ca(t,n);if(!r)return{input:null,output:null};const s=e.slice(r.startIndex,r.endIndex+1);if(s.length===0)return{input:[],output:null};let i=-1;for(let l=s.length-1;l>=0;l-=1)if(s[l].role==="assistant"){i=l;break}if(i<0)return{input:s.map(RB),output:null};const o=JM(e,t,n),a=s[i];return{input:o.length>0?o.map(RB):null,output:RB(a)}}var kne=96;function er(e,t=kne){const n=e.replace(/\s+/g," ").trim();return n.length<=t?n:`${n.slice(0,t-1)}…`}function Jl(e){return typeof e.content=="string"?e.content.trim():Ec(e).map(t=>t.type==="text"&&typeof t.text=="string"?t.text.trim():"").filter(Boolean).join(" ")}function Rne(e){const t=Ec(e),n=[];for(const r of t)r.type==="tool-call"&&n.push(Kl(r)??"tool");return n}function One(e,t){if(!e.length)return;const n=JM(e,t.messageStartIndex,t.messageEndIndex);if(n.length!==0){for(let r=n.length-1;r>=0;r--){const s=n[r];if(s.role==="user"){const i=Jl(s);if(i)return er(i)}}for(const r of n)if(r.role==="system"){const s=Jl(r);if(s)return er(s)}for(let r=n.length-1;r>=0;r--){const s=n[r];if(s.role==="tool"){const i=vne(s);if(i&&i!=="No content")return er(i)}}}}function Mne(e,t){if(!e.length)return;const n=ca(t.messageStartIndex,t.messageEndIndex);if(!n)return;const r=e.slice(n.startIndex,n.endIndex+1);for(let s=r.length-1;s>=0;s--){const i=r[s];if(i.role!=="assistant")continue;const o=Jl(i);if(o)return{kind:"text",preview:er(o)};const a=Rne(i);if(a.length>0)return{kind:"tools",preview:er(`Calling ${a.join(", ")}`)}}}function Nne(e,t,n){const r=Lv(e,t,n);if(typeof r!="number")return;const s=Jl(e[r]);return s?er(s):void 0}function Pne(e,t,n){const r=Lv(e,t,n);if(typeof r=="number")return Jl(e[r])||void 0}function sx(e,t){if(typeof t.toolCallId=="string"&&e.toolCallId===t.toolCallId)return!0;const n=t.toolName?.trim()||t.name?.trim();return!!(!t.toolCallId&&n&&Kl(e)===n)}function Lne(e,t,n){if(n)for(let r=n.startIndex;r<=n.endIndex;r+=1){const s=e[r];if(!s)continue;const i=Ec(s);if(i.some(o=>o.type==="tool-call"&&sx(o,t))||i.some(o=>o.type==="tool-result"&&sx(o,t)))return r}}function _ne(e,t){const n=Lv(t,e.messageStartIndex,e.messageEndIndex);if(typeof n=="number")return{focusSourceIndex:n,highlightSourceIndices:[n]};const r=qM(Ene(e));if(r.length!==0)return{focusSourceIndex:r[0],highlightSourceIndices:r}}function Fne(e,t){const n=xne(e),r=qM(n);if(r.length===0)return;const s=KM(t,n,i=>i.role==="assistant");return{focusSourceIndex:(e.span.category==="tool"?Lne(t,e.span,n):void 0)??s??r[0],highlightSourceIndices:r}}function Hne(e,t,n=!1){const r=ef(e,t.toolCallId,t.toolName??t.name,n?t:void 0);if(r.input==null)return;const s=WM(r.input);if(!(!s||s==="None"))return er(s)}function Qo({category:e,size:t="sm"}){const n=he(t==="lg"?"h-5 w-5 shrink-0":"h-3.5 w-3.5 shrink-0",Dne(e));switch(e){case"prompt":return(0,m.jsx)(TH,{className:n,"aria-hidden":!0});case"llm":return(0,m.jsx)(aH,{className:n,"aria-hidden":!0});case"tool":return(0,m.jsx)(AH,{className:n,"aria-hidden":!0});case"interaction":return(0,m.jsx)(CH,{className:n,"aria-hidden":!0});case"error":return(0,m.jsx)(lH,{className:n,"aria-hidden":!0});case"connection":case"discovery":case"step":return(0,m.jsx)(f0,{className:n,"aria-hidden":!0});default:return(0,m.jsx)(f0,{className:n,"aria-hidden":!0})}}function jne(e,t){const n=t.promptIndex,r=t.stepIndex;if(typeof n!="number"||typeof r!="number")return{};const s=e.find(i=>i.category==="llm"&&i.promptIndex===n&&i.stepIndex===r);return s?{...typeof s.inputTokens=="number"?{inputTokens:s.inputTokens}:{},...typeof s.outputTokens=="number"?{outputTokens:s.outputTokens}:{},...typeof s.totalTokens=="number"?{totalTokens:s.totalTokens}:{}}:{}}function Gne(e,t){if(e.kind==="prompt")return{inputTokens:e.aggregatedInputTokens,outputTokens:e.aggregatedOutputTokens,totalTokens:e.aggregatedTotalTokens};if(e.kind==="interaction")return{};const n={inputTokens:e.span.inputTokens,outputTokens:e.span.outputTokens,totalTokens:e.span.totalTokens};if(typeof n.inputTokens=="number"||typeof n.outputTokens=="number"||typeof n.totalTokens=="number"||!t?.length||e.span.category!=="llm"&&e.span.category!=="step")return n;const r=jne(t,e.span);return typeof r.inputTokens=="number"||typeof r.outputTokens=="number"||typeof r.totalTokens=="number"?r:n}function OB(e){return typeof e=="number"?e.toLocaleString():"—"}function ix(e){return typeof e=="number"&&Number.isFinite(e)?new Date(e).toLocaleString():"—"}function Vne({traceStartedAtMs:e,traceEndedAtMs:t,traceDurationMs:n}){return typeof e=="number"&&Number.isFinite(e)?e:typeof t=="number"&&Number.isFinite(t)?t-n:null}function gg(e,t,n=!1,r){const{span:s,promptIndex:i}=e,o=s.modelId?.trim()?er(s.modelId.trim(),56):void 0,a=s.name?.trim()??"";if(s.category==="step"){const l=typeof s.stepIndex=="number"?s.stepIndex+1:void 0,c=typeof l=="number"?`Step ${l}`:a||"Step",u=typeof l=="number"&&(a===`Step ${l}`||a.toLowerCase()===`step ${l}`),d=a&&!u?er(a,64):c,h=One(t,s);return h?{title:d,subtitle:h}:o?{title:d,subtitle:o}:{title:d,subtitle:`Prompt ${i+1}`}}if(s.category==="llm"){const l=Mne(t,s),c=!a||/^assistant$/i.test(a)||/^llm$/i.test(a)||/^model$/i.test(a)||a==="Model response"||/·\s*response$/i.test(a)?"Agent":er(a,64);return l?.kind==="text"?{title:`${c}: "${l.preview}"`,subtitle:o}:l?.kind==="tools"?{title:`${c} · ${l.preview}`,subtitle:o}:{title:c,subtitle:o}}if(s.category==="tool"){const l=`Tool · ${(s.toolName??s.name).trim()||"tool"}${r?` · ${r}`:""}`,c=Hne(t,s,n),u=!c||c==="{}"||c==="None";if(c&&!u)return{title:l,subtitle:c};if(u){const d=ef(t,s.toolCallId,s.toolName??s.name,n?s:void 0);if(d.output!=null){const h=WM(d.output);if(h&&h!=="None"&&h!=="{}")return{title:l,subtitle:er(h)}}}return typeof s.stepIndex=="number"?{title:l,subtitle:o?`${o} · step ${s.stepIndex+1}`:`step ${s.stepIndex+1}`}:{title:l,subtitle:o}}return{title:s.name,subtitle:typeof s.stepIndex=="number"?o?`${o} · step ${s.stepIndex+1}`:`step ${s.stepIndex+1}`:o}}function Cg(e){const t=e.kind==="span"?e.span.startMs:e.startMs,n=e.kind==="span"?e.span.endMs:e.endMs;return{startMs:t,endMs:n,durationMs:n-t}}function Une({format:e,onFormatChange:t}){return(0,m.jsx)("div",{className:"flex flex-wrap gap-1",children:["plain","markdown"].map(n=>(0,m.jsx)(kn,{type:"button",size:"sm",variant:e===n?"secondary":"outline",className:"h-7 text-[10px] capitalize",onClick:()=>t(n),children:n==="plain"?"Plain":"Markdown"},n))})}function ox({value:e}){const[t,n]=(0,p.useState)("plain");return(0,p.useEffect)(()=>{typeof e=="string"&&n("plain")},[e]),e==null?(0,m.jsx)("div",{className:"rounded-md border border-dashed border-border/60 px-3 py-2 text-xs text-muted-foreground",children:"None"}):typeof e=="string"?(0,m.jsxs)("div",{className:"space-y-2",children:[(0,m.jsx)(Une,{format:t,onFormatChange:n}),t==="markdown"?(0,m.jsx)("div",{className:"max-h-44 overflow-auto rounded-md border border-border/60 bg-muted/10 p-3 text-xs leading-relaxed text-foreground",children:(0,m.jsx)(WO,{content:e})}):(0,m.jsx)("pre",{className:"max-h-44 overflow-auto rounded-md border border-border/60 bg-muted/20 p-3 text-xs whitespace-pre-wrap break-words",children:e})]}):(0,m.jsx)(hZ,{value:e,containerClassName:"max-h-56 rounded-md border border-border/60 bg-background"})}function zne({row:e}){return(0,m.jsxs)("div",{"data-testid":"trace-detail-pane",className:"min-h-[280px] rounded-lg bg-muted/5 px-5 py-5",children:[(0,m.jsx)(MM,{step:e.step,leading:(0,m.jsx)(Qo,{category:"interaction",size:"lg"})}),e.step.pluginWorkspace&&(0,m.jsx)(Ate,{recording:e.step.pluginWorkspace})]})}function ax(e){return e.split(/[-_\s]+/).filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function $ne(e){return e.engine==="harness"?e.harness?ax(e.harness):"Harness":e.engine==="emulated"?"Emulated":e.harness?ax(e.harness):"Unknown"}function Wne({row:e,recordedSpans:t,projectedMessages:n,transcriptMessages:r,onRevealInTranscript:s,turnRuntimeByPromptIndex:i,turnEvent:o}){const a=NM(),l=Sc();if(!e)return(0,m.jsxs)("div",{"data-testid":"trace-detail-pane",className:"flex min-h-[280px] flex-col items-center justify-center gap-3 rounded-lg bg-muted/5 px-6 py-12 text-center",children:[(0,m.jsx)("div",{className:"flex h-14 w-14 items-center justify-center rounded-full border border-border/50 bg-background shadow-sm",children:(0,m.jsx)(hH,{className:"h-7 w-7 text-muted-foreground","aria-hidden":!0})}),(0,m.jsxs)("div",{className:"space-y-1",children:[(0,m.jsx)("p",{className:"text-sm font-medium text-foreground",children:"No span selected"}),(0,m.jsx)("p",{className:"text-xs text-muted-foreground",children:"Click a row or use arrow keys"})]})]});if(e.kind==="interaction")return(0,m.jsx)(zne,{row:e});const c=e.kind==="prompt"?_ne(e,r):Fne(e,r),u=e.kind==="span"?ef(r,e.span.toolCallId,e.span.toolName??e.span.name,n?e.span:void 0):{},{durationMs:d}=Cg(e),h=e.kind==="span"?gg(e,r,n,a(e.span)):null,f=e.kind==="prompt"?e.label:h.title,B=e.kind==="prompt"?e.hasAnyFailure?"error":"ok":So(e.span,r,n)?"error":"ok",g=e.kind==="prompt"?"prompt":e.span.category==="tool"&&So(e.span,r,n)?"error":e.span.category,C=i?.get(e.promptIndex),v=e.kind==="span"&&(e.span.category==="llm"||e.span.category==="step")?Ine(r,e.span.messageStartIndex,e.span.messageEndIndex):{input:null,output:null},y=e.kind==="span"&&e.span.category==="tool"&&(!!e.span.toolCallId||!!(e.span.toolName?.trim()||e.span.name?.trim())),b=e.kind==="prompt"?null:y?u.input:e.kind==="span"&&(e.span.category==="llm"||e.span.category==="step")?v.input:(e.kind==="span"&&e.span.category==="error",null),E=e.kind==="prompt"?null:y?u.output:e.kind==="span"&&(e.span.category==="llm"||e.span.category==="step")?v.output:e.kind==="span"&&e.span.category==="error"?e.span.name:null,w=e.kind==="prompt"?Pne(r,e.messageStartIndex,e.messageEndIndex):void 0,A=e.kind==="span"&&(typeof e.span.inputTokens=="number"||typeof e.span.outputTokens=="number"||typeof e.span.totalTokens=="number"),x=e.kind==="prompt"&&(typeof e.aggregatedInputTokens=="number"||typeof e.aggregatedOutputTokens=="number"||typeof e.aggregatedTotalTokens=="number"),O=e.kind==="span"&&u.errorText?u.errorText:null,R=!!(c&&s),P=l?LM(e,t):void 0;return(0,m.jsxs)("div",{"data-testid":"trace-detail-pane",className:"space-y-4 bg-background p-4",children:[(0,m.jsxs)("div",{className:he("border-b border-border/40 pb-3",R?"flex flex-col gap-3 min-[400px]:flex-row min-[400px]:items-start":""),children:[(0,m.jsxs)("div",{className:he("flex gap-3",R?"min-w-0 min-[400px]:flex-1":""),children:[(0,m.jsx)("div",{className:"shrink-0 pt-0.5",children:e.kind==="prompt"?(0,m.jsx)(Qo,{category:"prompt",size:"lg"}):(0,m.jsx)(Qo,{category:g,size:"lg"})}),(0,m.jsxs)("div",{className:"min-w-0 flex-1 space-y-2",children:[(0,m.jsxs)("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[(0,m.jsx)("h3",{className:"text-sm font-bold leading-tight text-foreground",children:f}),C?(0,m.jsxs)(Al,{className:"border-border/60 bg-muted/30 px-1.5 py-0 text-[10px] font-medium text-muted-foreground","data-testid":"trace-turn-runtime-badge",title:C.engine==="harness"?"This turn ran through the harness adapter.":C.engine==="emulated"?"This turn ran through MCPJam's emulated chat engine.":C.harness?"This turn ran through the harness adapter.":"Runtime engine was not recorded for this turn.",children:["Engine: ",$ne(C)]}):null,B==="error"?(0,m.jsx)("span",{className:"inline-block h-2 w-2 shrink-0 rounded-full bg-destructive",title:"Error","aria-label":"Error"}):null]}),(0,m.jsxs)("div",{className:"text-xs tabular-nums text-muted-foreground",children:[(0,m.jsx)("span",{className:"font-medium text-foreground",children:ul(d)}),e.kind==="prompt"&&x?(0,m.jsxs)(m.Fragment,{children:[typeof e.aggregatedInputTokens=="number"?` · ${e.aggregatedInputTokens} in`:"",typeof e.aggregatedOutputTokens=="number"?` → ${e.aggregatedOutputTokens} out`:"",typeof e.aggregatedTotalTokens=="number"?` (${e.aggregatedTotalTokens} total)`:""]}):e.kind==="span"&&A?(0,m.jsxs)(m.Fragment,{children:[typeof e.span.inputTokens=="number"?` · ${e.span.inputTokens} in`:"",typeof e.span.outputTokens=="number"?` → ${e.span.outputTokens} out`:"",typeof e.span.totalTokens=="number"?` (${e.span.totalTokens} total)`:""]}):null,(0,m.jsx)(ine,{cost:P})]}),(0,m.jsx)(one,{cost:P}),e.kind==="span"?(()=>{const _=e.span,N=_.category==="llm"?Cne(_.outputTokens,d):null,q=[];return _.provider&&q.push({label:"Provider",value:_.provider}),_.finishReason&&q.push({label:"Finish",value:_.finishReason}),typeof _.ttfcMs=="number"&&q.push({label:"TTFC",value:ul(_.ttfcMs)}),N!==null&&q.push({label:"Throughput",value:`${N.toFixed(1)} tok/s`}),_.responseId&&q.push({label:"Response ID",value:_.responseId}),q.length===0?null:(0,m.jsx)("div",{"data-testid":"trace-span-metadata",className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-muted-foreground",children:q.map(W=>(0,m.jsxs)("span",{className:"truncate",children:[(0,m.jsxs)("span",{className:"text-muted-foreground/70",children:[W.label,":"," "]}),(0,m.jsx)("span",{className:"font-medium text-foreground",children:W.value})]},W.label))})})():null]})]}),R?(0,m.jsx)("div",{className:"flex min-w-0 min-[400px]:flex-1 min-[400px]:justify-end min-[400px]:pt-0.5",children:(0,m.jsxs)(kn,{type:"button",size:"sm",variant:"outline",className:"w-full shrink-0 justify-center whitespace-nowrap min-[400px]:w-auto",onClick:()=>{c&&s&&s(c)},children:[(0,m.jsx)(pH,{className:"h-3.5 w-3.5"}),"Reveal in Chat"]})}):null]}),e.kind==="prompt"&&o?(0,m.jsx)(Zte,{turnEvent:o}):null,e.kind==="prompt"&&w?(0,m.jsx)("div",{className:"min-h-0 max-h-[min(60vh,28rem)] flex-1 overflow-auto rounded-md border border-border/50 bg-muted/10 px-3 py-2 text-xs leading-relaxed text-foreground",children:w}):null,n&&e.kind==="span"&&e.span.messageStartIndex===void 0?(0,m.jsx)("p",{className:"text-xs text-muted-foreground",children:"Message details are unavailable for this span. Read the conversation in Chat."}):e.kind==="span"?(0,m.jsxs)("div",{className:"space-y-4",children:[(0,m.jsxs)("div",{className:"space-y-2",children:[(0,m.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-muted-foreground",children:"Input"}),(0,m.jsx)(ox,{value:b??void 0})]}),(0,m.jsxs)("div",{className:he("space-y-2",e.span.category==="error"||O?"rounded-md border border-destructive/50 bg-destructive/50 p-2":""),children:[(0,m.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-muted-foreground",children:"Output"}),(0,m.jsx)(ox,{value:E??void 0}),O?(0,m.jsx)("pre",{className:"max-h-40 overflow-auto rounded-md border border-destructive/50 bg-destructive/50 p-3 text-xs whitespace-pre-wrap break-words text-foreground",children:O}):null,typeof e.span.mcpErrorCode=="number"?(0,m.jsxs)("div",{"data-testid":"trace-mcp-error-code",className:"text-[11px] tabular-nums text-muted-foreground",title:"MCP-layer error code. -32602/-32601 etc. are server JSON-RPC errors; -32000 (connection closed) / -32001 (request timeout) are transport/client failures, not server faults.",children:[(0,m.jsx)("span",{className:"text-muted-foreground/70",children:"MCP error: "}),(0,m.jsx)("span",{className:"font-medium text-foreground",children:Ste(e.span.mcpErrorCode)})]}):null]})]}):null]})}function qle({recordedSpans:e,projectedMessages:t=!1,interactionSteps:n,estimatedDurationMs:r,transcriptMessageCount:s=0,transcriptMessages:i=[],traceStartedAtMs:o=null,traceEndedAtMs:a=null,onRevealInTranscript:l,hideToolbar:c=!1,timelineFilter:u,onTimelineFilterChange:d,expandedPromptIds:h,onExpandedPromptIdsChange:f,expandedStepIds:B,onExpandedStepIdsChange:g,viewportMaxMs:C,turnRuntimeByPromptIndex:v,turnEventByPromptIndex:y,fillContent:b=!1,detailPlacement:E="below",iterationCost:w}){const{containerRef:A,direction:x}=kte(E),O=x==="horizontal",R=(0,p.useMemo)(()=>t?Tte(e??[],i):void 0,[t,e,i]),P=R?.spans??e,_=lne(P,w),N=_.spans,q=DN(),W=NM(),F=Sc(),z=(0,p.useMemo)(()=>new Set(F?(N??[]).filter(j=>j.cost).map(j=>j.id):[]),[F,N]),J=P&&P.length>0?"recorded":(r??0)>0?"estimated":"none",Z=(0,p.useMemo)(()=>P?.length?Ane(P).map(j=>R?{...j,messageStartIndex:R.userIndices[j.promptIndex]??-1,messageEndIndex:R.userIndices[j.promptIndex]??-1}:j):[],[P,R]),Q=(0,p.useMemo)(()=>{const j=new Map;for(const we of n??[]){const Ae=j.get(we.toolCallId);Ae?Ae.push(we):j.set(we.toolCallId,[we])}for(const we of j.values())we.sort((Ae,Ye)=>Ae.stepIndex-Ye.stepIndex);return j},[n]),G=P?.length?P.reduce((j,we)=>Math.max(j,we.endMs),1):Math.max(r??0,1),be=(0,p.useMemo)(()=>P?.map(j=>`${j.id}:${j.startMs}:${j.endMs}`).join("|")??J,[J,P]),[ve,X]=(0,p.useState)(1);(0,p.useEffect)(()=>{C===void 0&&X(G)},[G,be,C]);const Y=Math.max(1,C!==void 0?C:ve),ie=Math.max(1,Math.round(G/50)),ne=(0,p.useMemo)(()=>Vne({traceStartedAtMs:o,traceEndedAtMs:a,traceDurationMs:G}),[G,a,o]),[ee,Be]=(0,p.useState)("all"),de=u!==void 0?u:ee,Re=d??Be,[Ee,st]=(0,p.useState)(new Set),[at,Bt]=(0,p.useState)(new Set),tt=h!==void 0?h:Ee,pt=f??st,Lt=B!==void 0?B:at,mt=g??Bt,[lt,Vn]=(0,p.useState)(null),[it,oe]=(0,p.useState)(null),[je,Le]=(0,p.useState)(null),Un=(0,p.useRef)(null),_t=(0,p.useRef)(null),[Vt,Bn]=(0,p.useState)(-1);(0,p.useLayoutEffect)(()=>{const j=_t.current;if(!j)return;const we=()=>{const Ye=j.getBoundingClientRect().width;Bn(Number.isFinite(Ye)?Ye:0)};if(we(),typeof ResizeObserver>"u")return;const Ae=new ResizeObserver(we);return Ae.observe(j),()=>Ae.disconnect()},[x]);const An=(0,p.useMemo)(()=>Bne(Vt),[Vt]),gs=(0,p.useMemo)(()=>An.length!==2?!1:Vt<0||Vt===0?!0:Vt<fne,[Vt,An]);(0,p.useEffect)(()=>{c||(st(new Set(Z.map(j=>j.key))),Bt(rx(Z)))},[c,Z]);const Ge=(0,p.useMemo)(()=>{if(J!=="recorded")return[];const j=[],we=new Set;function Ae(te){return de==="all"?!0:de==="error"?So(te,i,t):te.category===de}function Ye(te,He,ze){const ct=te.span.category==="step",_e=ct?ze:ze+1,St=te.children.map(mn=>Ye(mn,He,_e)),ot=St.flatMap(mn=>mn.rows),pr=St.some(mn=>mn.hasVisibleContent);if(ct)return{hasVisibleContent:pr||te.children.length>0,rows:ot};if(te.span.category==="llm"&&!z.has(te.span.id)&&typeof te.span.totalTokens!="number"&&typeof te.span.inputTokens!="number"&&typeof te.span.outputTokens!="number"&&te.span.endMs-te.span.startMs<50)return{hasVisibleContent:!1,rows:[]};const Ct=te.span.toolCallId,ys=te.span.category==="tool"&&!!Ct&&!we.has(Ct);ys&&Ct&&we.add(Ct);const wc=ys&&Ct?(Q.get(Ct)??[]).filter(mn=>de==="all"||de==="tool"?!0:de==="error"?qd(mn)==="error":!1).map((mn,nf)=>({kind:"interaction",key:`interaction-${te.span.id}-${mn.stepIndex}-${nf}`,promptIndex:He,depth:ze+1,step:mn,startMs:te.span.startMs,endMs:te.span.endMs,status:qd(mn)})):[];if(!(Ae(te.span)||pr||wc.length>0))return{hasVisibleContent:pr,rows:ot};const ua={kind:"span",key:te.span.id,promptIndex:He,depth:ze,span:te.span,hasChildren:te.children.length>0,isExpanded:Lt.has(te.span.id)};return{hasVisibleContent:!0,rows:[ua,...ua.hasChildren&&ua.isExpanded?ot:[],...wc]}}for(const te of Z){const He=te.roots.map(ot=>Ye(ot,te.promptIndex,0)).flatMap(ot=>ot.rows);if(!(He.length>0||de==="all"&&te.spans.length>0))continue;const ze=te.spans.some(ot=>So(ot,i,t)),ct=Nne(i,te.messageStartIndex,te.messageEndIndex),_e=mne(te.spans),St=y?.get(te.promptIndex);j.push({kind:"prompt",key:te.key,promptIndex:te.promptIndex,label:te.label,conversationLabel:St?$te(St.event):ct?`User: "${ct}"`:void 0,startMs:te.startMs,endMs:te.endMs,messageStartIndex:te.messageStartIndex,messageEndIndex:te.messageEndIndex,counts:te.counts,hasAnyFailure:ze,isExpanded:tt.has(te.key),aggregatedInputTokens:_e.inputTokens,aggregatedOutputTokens:_e.outputTokens,aggregatedTotalTokens:_e.totalTokens}),tt.has(te.key)&&j.push(...He)}return j},[tt,Lt,de,Z,Q,J,i,t,z,y]),Cs=(0,p.useMemo)(()=>rx(Z),[Z]),Kt=(0,p.useMemo)(()=>{if(Z.length===0)return!1;for(const j of Z)if(!tt.has(j.key))return!1;for(const j of Cs)if(!Lt.has(j))return!1;return!0},[Z,tt,Lt,Cs]);(0,p.useEffect)(()=>{if(Ge.length===0){Vn(null);return}(!lt||!Ge.some(j=>j.key===lt))&&Vn(Ge[0].key)},[Ge,lt]);const vs=Ge.find(j=>j.key===lt),Qe=it?Ge.find(j=>j.key===it):void 0,xc=it?Ge.findIndex(j=>j.key===it):-1;(0,p.useEffect)(()=>{it&&!Ge.some(j=>j.key===it)&&(oe(null),Le(null),Un.current=null)},[it,Ge]);const ti=(0,p.useCallback)(j=>{const we=(j.querySelector('[data-testid="trace-row-glyph"]')??j).getBoundingClientRect();return{anchorX:we.left+we.width/2,anchorY:we.top,anchorBottom:we.bottom}},[]);(0,p.useEffect)(()=>{if(!it)return;const j=()=>{const we=Un.current;we&&Le(ti(we))};return window.addEventListener("scroll",j,!0),window.addEventListener("resize",j),()=>{window.removeEventListener("scroll",j,!0),window.removeEventListener("resize",j)}},[it,ti]);const pn=(0,p.useMemo)(()=>{if(!Qe)return null;const{startMs:j,endMs:we}=Cg(Qe),Ae=Qe.kind==="span"&&So(Qe.span,i,t),Ye=Qe.kind==="span"?gg(Qe,i,t,W(Qe.span)):null,te=Qe.kind==="prompt"?Qe.conversationLabel??Qe.label:Qe.kind==="interaction"?Jo(Qe.step):Ye.title,He=Gne(Qe,P),ze=Qe.kind==="prompt"?"prompt":Qe.kind==="interaction"?"interaction":Qe.span.category==="tool"&&Ae?"error":Qe.span.category;return{label:te,spanShowsFailure:Ae,tokenStats:He,rowStartTimestamp:ne!==null?ne+j:null,rowEndTimestamp:ne!==null?ne+we:null,glyphCategory:ze,cost:F?LM(Qe,N):void 0}},[Qe,P,N,ne,i,t,W,F]),tf=(0,p.useCallback)(j=>{if(Ge.length===0)return;const we=Ge.findIndex(Ae=>Ae.key===lt);if(j.key==="ArrowDown"){j.preventDefault();const Ae=we<0?0:Math.min(Ge.length-1,we+1);Vn(Ge[Ae].key);return}if(j.key==="ArrowUp"){j.preventDefault();const Ae=we<=0?0:we-1;Vn(Ge[Ae].key);return}if(j.key==="Enter"&&we>=0){const Ae=Ge[we];if(Ae.kind==="prompt"){j.preventDefault();const Ye=new Set(tt);Ye.has(Ae.key)?Ye.delete(Ae.key):Ye.add(Ae.key),pt(Ye);return}if(Ae.kind==="span"&&Ae.hasChildren){j.preventDefault();const Ye=new Set(Lt);Ye.has(Ae.key)?Ye.delete(Ae.key):Ye.add(Ae.key),mt(Ye)}}},[tt,Lt,Ge,lt,pt,mt]),ni=(0,m.jsxs)(m.Fragment,{children:[_.loader,(0,m.jsx)(une,{spans:N,iteration:w,unmatched:_.unmatched})]});if(J==="none")return(0,m.jsxs)(m.Fragment,{children:[ni,(0,m.jsx)("div",{className:"text-xs text-muted-foreground",children:"No timing data recorded for this iteration."})]});if(J==="estimated")return(0,m.jsxs)("div",{className:"space-y-3",children:[ni,(0,m.jsxs)("div",{className:"flex items-center gap-2",children:[(0,m.jsx)(Al,{className:"border-warning/50 bg-warning/50 text-foreground",children:"Estimated total only"}),(0,m.jsx)("span",{className:"text-xs text-muted-foreground",children:ul(r??0)})]}),(0,m.jsxs)("div",{className:"space-y-1 text-[11px] text-muted-foreground",children:[(0,m.jsx)("p",{children:"Per-step timing was not recorded for this run."}),s>0?(0,m.jsxs)("p",{children:["Conversation detail is in the Chat tab. Open"," ",(0,m.jsx)("span",{className:"font-medium text-foreground/80",children:"Raw"})," to inspect the stored trace and confirm whether a"," ",(0,m.jsx)("code",{className:"rounded border border-border/50 bg-muted/40 px-1 py-px font-mono text-[10px] text-foreground/90",children:"spans"})," ","array exists; only new runs that persist spans show a per-step timeline here."]}):null]})]});const Br=C===void 0?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(kn,{type:"button",variant:"outline",size:"icon",className:"h-7 w-7 border-border/50",title:"Zoom in timeline","aria-label":"Zoom in timeline",disabled:ve<=ie,onClick:()=>X(j=>Math.max(ie,Math.round(j*.8))),children:(0,m.jsx)(yH,{className:"size-3.5","aria-hidden":!0})}),(0,m.jsx)(kn,{type:"button",variant:"outline",size:"icon",className:"h-7 w-7 border-border/50",title:"Zoom out timeline","aria-label":"Zoom out timeline",disabled:ve>=G*4,onClick:()=>X(j=>Math.min(G*4,Math.round(j*1.25))),children:(0,m.jsx)(gH,{className:"size-3.5","aria-hidden":!0})})]}):null;return(0,m.jsxs)("div",{className:he("space-y-2",b&&"flex min-h-0 flex-1 flex-col"),children:[c?null:(0,m.jsxs)("div",{className:b?"shrink-0":void 0,children:[(0,m.jsx)(Ote,{filter:de,onFilterChange:Re,isFullyExpanded:Kt,expandDisabled:Z.length===0,zoomControls:Br,onToggleExpandAll:()=>{Kt?(pt(new Set),mt(new Set)):(pt(new Set(Z.map(j=>j.key))),mt(new Set(Cs)))}}),(0,m.jsx)("div",{className:"mt-1.5 flex flex-wrap items-center gap-x-4 gap-y-1 px-1 text-xs text-muted-foreground",children:[{label:"User",cls:"trace-waterfall-bar-prompt"},{label:"Connect",cls:"trace-waterfall-bar-step"},{label:"Discovery",cls:"trace-waterfall-bar-step"},{label:"LLM",cls:"trace-waterfall-bar-llm"},{label:"Tool",cls:"trace-waterfall-bar-tool"},{label:"Step",cls:"trace-waterfall-bar-step"},{label:"Error",cls:"trace-waterfall-bar-error"}].map(({label:j,cls:we})=>(0,m.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,m.jsx)("span",{className:he("h-2 w-2.5 rounded-sm",we)}),j]},j))})]}),ni,(0,m.jsx)("div",{ref:A,className:he("@container/trace-timeline min-w-0",b&&"flex min-h-0 flex-1 flex-col"),children:(0,m.jsxs)(Cee,{direction:x,className:he("rounded-lg border border-border/50 bg-background",b?"min-h-0 flex-1 overflow-hidden":"min-h-[min(25rem,calc(100dvh-8rem))]"),style:b?void 0:{height:"auto"},children:[(0,m.jsx)(Bg,{defaultSize:O?62:65,minSize:0,className:"min-h-0 min-w-0 overflow-hidden",children:(0,m.jsx)(Eee,{className:he(b?"h-full min-h-0 overflow-hidden":"max-h-[calc(100vh-8rem)] min-h-0"),children:(0,m.jsx)("div",{tabIndex:0,role:"region","aria-label":"Trace timeline. Use arrow keys to change selection, Enter to expand.",onKeyDown:tf,className:"relative min-h-0 outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",children:(0,m.jsxs)("div",{className:"grid pr-4",style:{gridTemplateColumns:"minmax(140px, 260px) minmax(0, 1fr) minmax(5.25rem, max-content)",gridTemplateRows:`auto repeat(${Ge.length}, minmax(48px, auto))`},children:[(0,m.jsx)("div",{className:"sticky top-0 z-20 border-b border-border/50 bg-background/95 px-4 py-1.5 backdrop-blur",style:{gridColumn:"1 / 3",gridRow:1},children:(0,m.jsxs)("div",{className:"flex min-h-6 min-w-0 items-center gap-3",children:[(0,m.jsx)("div",{className:"shrink-0 text-[10px] uppercase tracking-wide text-muted-foreground",children:"Trace"}),(0,m.jsx)("div",{className:"min-h-6 min-w-0 flex-1",children:(0,m.jsx)("div",{ref:_t,className:"relative h-6 min-w-0",children:gs?(0,m.jsx)("div",{className:"flex h-full min-w-0 items-center justify-center",children:(0,m.jsx)("span",{className:"min-w-0 max-w-full truncate text-center text-[10px] tabular-nums text-muted-foreground",title:tx(Y),children:tx(Y)})}):An.map(j=>{const we=j>=100?"100%":`${j}%`;return(0,m.jsx)("div",{className:"pointer-events-none absolute inset-y-0",style:{left:we},children:(0,m.jsx)("div",{className:he("absolute text-[10px] tabular-nums text-muted-foreground",pne(j)),children:ad(Y*j/100)})},j)})})})]})}),(0,m.jsx)("div",{className:"sticky top-0 z-20 flex min-h-0 items-center border-b border-l border-border/50 bg-background/95 px-3 py-1.5 pl-4 backdrop-blur",style:{gridColumn:3,gridRow:1},children:(0,m.jsxs)("div",{className:"flex h-6 w-full min-w-0 items-center justify-start gap-1.5",children:[(0,m.jsx)(h0,{className:"size-3 shrink-0 text-muted-foreground","aria-hidden":!0}),(0,m.jsx)("span",{className:"text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Latency"})]})}),Ge.length>0?(0,m.jsx)("div",{className:"pointer-events-none relative z-0 bg-transparent",style:{gridColumn:2,gridRow:`2 / ${Ge.length+2}`},children:An.map(j=>(0,m.jsx)("div",{className:"absolute top-0 bottom-0 w-px bg-border/40",style:{left:j>=100?"100%":`${j}%`}},j))}):null,Ge.map((j,we)=>{const Ae=j.key===lt,{startMs:Ye,endMs:te,durationMs:He}=Cg(j),ze=Ye/Y*100,ct=Math.max((te-Ye)/Y*100,.45),_e=j.kind==="span"&&So(j.span,i,t),St=j.kind==="prompt"?"prompt":j.kind==="interaction"?"interaction":j.span.category==="tool"&&_e?"error":j.span.category,ot=j.kind==="interaction"&&j.status==="error",pr=j.kind==="span"?gg(j,i,t):null,Ct=j.kind==="prompt"?j.conversationLabel??j.label:j.kind==="interaction"?Jo(j.step):pr.title,ys=ul(He),wc=j.kind==="prompt"?!0:j.kind==="interaction"?!1:j.hasChildren||j.span.category==="llm",ua=we+2,mn=Tne(j,_e),nf=wne(j,_e),_v=()=>{Ed("trace_span_clicked",{location:"trace_timeline",span_kind:j.kind}),Vn(j.key)},rf=gn=>{gn.stopPropagation(),_v()},QM=Ae?he("bg-transparent",mn):"border-l-transparent bg-background group-hover:bg-muted/20 hover:bg-muted/20",Fv=Ae?"bg-transparent":"bg-background group-hover:bg-muted/20 hover:bg-muted/20";return(0,m.jsxs)(yT.div,{"data-testid":"trace-row","data-state":Ae?"selected":void 0,onClick:_v,onMouseEnter:gn=>{oe(j.key);const Cn=gn.currentTarget;Un.current=Cn,Le(ti(Cn))},onMouseLeave:()=>{oe(gn=>gn===j.key?null:gn),Le(null),Un.current=null},onFocus:gn=>{oe(j.key);const Cn=gn.currentTarget;Un.current=Cn,Le(ti(Cn))},onBlur:gn=>{gn.currentTarget.contains(gn.relatedTarget)||(oe(Cn=>Cn===j.key?null:Cn),Le(null),Un.current=null)},initial:q||we>=20?!1:{opacity:0,y:6},animate:{opacity:1,y:0},transition:q||we>=20?{duration:0}:{duration:.15,delay:we*.03+.05,ease:[.16,1,.3,1]},style:{gridColumn:"1 / 4",gridRow:ua,display:"grid",gridTemplateColumns:"subgrid"},className:he("group min-h-0 min-w-0 cursor-pointer items-stretch",Ae&&"trace-waterfall-row-selected ring-1 ring-inset ring-ring/40"),children:[(0,m.jsxs)("div",{className:he("flex items-center gap-2 border-b border-border/40 px-4 py-2 transition-all duration-150 border-l-2",QM),children:[(0,m.jsx)("div",{className:"flex shrink-0 items-center",style:{paddingLeft:j.kind==="prompt"?0:j.depth*16},children:wc?(0,m.jsx)("button",{type:"button",className:"mr-1 inline-flex h-5 w-5 items-center justify-center rounded-sm text-muted-foreground hover:bg-muted/30 hover:text-foreground",onClick:gn=>{if(gn.stopPropagation(),j.kind==="prompt"){const Dc=new Set(tt);Dc.has(j.key)?Dc.delete(j.key):Dc.add(j.key),pt(Dc);return}const Cn=new Set(Lt);Cn.has(j.key)?Cn.delete(j.key):Cn.add(j.key),mt(Cn)},"aria-label":j.kind==="prompt"?`${j.isExpanded?"Collapse":"Expand"} ${j.label}`:`${"isExpanded"in j&&j.isExpanded?"Collapse":"Expand"} ${Ct}`,children:"isExpanded"in j&&j.isExpanded?(0,m.jsx)(uD,{className:"h-3.5 w-3.5"}):(0,m.jsx)(Mo,{className:"h-3.5 w-3.5"})}):(0,m.jsx)("span",{className:"mr-1 h-5 w-5"})}),(0,m.jsx)("button",{type:"button","data-testid":"trace-row-label-button",className:"min-w-0 flex-1 text-left",onClick:rf,children:(0,m.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,m.jsx)("span",{"data-testid":"trace-row-glyph",className:"inline-flex shrink-0 items-center",children:j.kind==="prompt"?(0,m.jsx)(Qo,{category:"prompt"}):(0,m.jsx)(Qo,{category:St})}),(0,m.jsx)("span",{className:"min-w-0 flex-1 truncate text-sm font-medium text-foreground",children:Ct}),j.kind==="prompt"?(0,m.jsx)(VM,{event:y?.get(j.promptIndex)?.event}):null,(0,m.jsx)(oJ,{name:j.kind==="span"?W(j.span):void 0}),j.kind==="prompt"&&j.hasAnyFailure?(0,m.jsx)("span",{className:"inline-block h-2 w-2 shrink-0 rounded-full bg-destructive",title:"Contains errors","aria-label":"Contains errors"}):null,j.kind==="span"&&_e||ot?(0,m.jsx)("span",{className:"inline-block h-2 w-2 shrink-0 rounded-full bg-destructive",title:"Error","aria-label":"Error"}):null]})})]}),(0,m.jsx)("button",{type:"button","data-testid":"trace-row-bar-hit","data-state":Ae?"selected":void 0,className:he("relative z-[1] flex min-h-[48px] w-full items-center overflow-hidden border-b border-border/40 border-l-2 border-l-transparent px-4 py-2 text-left transition-all duration-150",Fv),"aria-label":`Select on timeline (${ul(He)})`,onClick:rf,children:(0,m.jsx)("div",{"data-testid":j.kind==="span"&&_e?"trace-row-bar-error":"trace-row-bar",className:he("absolute top-1/2 z-[1] h-4 min-w-0 -translate-y-1/2 rounded-[3px] transition-[left,width] duration-150",nf),style:{left:`${ze}%`,width:`max(${ct}%, 3px)`}})}),(0,m.jsxs)("button",{type:"button","data-testid":"trace-row-duration-hit","data-state":Ae?"selected":void 0,className:he("flex min-h-[48px] items-center justify-start gap-1.5 whitespace-nowrap border-b border-l border-border/40 px-3 py-2 pl-4 text-[11px] tabular-nums text-muted-foreground transition-all duration-150",Fv),"aria-label":`Select row duration (${ys})`,onClick:rf,children:[(0,m.jsx)(h0,{className:"size-3 shrink-0 opacity-80","aria-hidden":!0}),ys]})]},j.key)})]})})})}),(0,m.jsx)(vee,{withHandle:!0}),(0,m.jsx)(Bg,{defaultSize:O?38:35,minSize:O?25:20,className:"min-h-0 min-w-0 overflow-hidden",children:(0,m.jsx)("div",{"data-testid":"trace-timeline-detail-sticky",className:"h-full min-h-0 min-w-0 max-h-full overflow-y-auto",children:(0,m.jsx)(Wne,{projectedMessages:t,row:vs,recordedSpans:N,transcriptMessages:i,onRevealInTranscript:l,turnRuntimeByPromptIndex:v,turnEvent:vs?.kind==="prompt"?y?.get(vs.promptIndex):void 0})})})]},x)}),Qe&&pn&&je?(0,m.jsx)(qne,{hoverPos:je,info:pn,placement:xc===0?"bottom":"top",reduceMotion:q??!1,rowKey:Qe.key}):null]})}function qne({hoverPos:e,info:t,placement:n,reduceMotion:r,rowKey:s}){if(typeof document>"u")return null;const i=304,o=12,a=8,l=i/2,c=typeof window<"u"?window.innerWidth:e.anchorX+l+o,u=164,d=Math.max(u,c-l-o),h=Math.min(Math.max(e.anchorX,u),d),f={position:"fixed",top:n==="top"?e.anchorY-a:e.anchorBottom+a,left:h,transform:n==="top"?"translate(-50%, -100%)":"translateX(-50%)",zIndex:9999};return(0,Yo.createPortal)((0,m.jsx)("div",{className:"pointer-events-none",style:f,children:(0,m.jsx)(yT.div,{"data-placement":n,"data-testid":"trace-row-hover-content",initial:r?!1:{opacity:0,y:6,filter:"blur(2px)"},animate:{opacity:1,y:0,filter:"blur(0px)"},transition:{duration:.16,ease:[.16,1,.3,1]},className:"w-[19rem] overflow-hidden rounded-md border border-border/60 bg-popover text-popover-foreground shadow-xl",children:(0,m.jsxs)("div",{"data-testid":"trace-row-hover-card",className:"space-y-3 p-3",children:[(0,m.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,m.jsx)(Qo,{category:t.glyphCategory}),(0,m.jsx)("span",{className:"min-w-0 flex-1 truncate text-xs font-semibold text-popover-foreground",children:t.label})]}),(0,m.jsxs)("div",{className:"space-y-1.5",children:[(0,m.jsx)("div",{className:"text-[10px] font-semibold uppercase tracking-wide text-popover-foreground/65",children:"Time"}),(0,m.jsxs)("div",{className:"space-y-1 text-xs",children:[(0,m.jsxs)("div",{className:"flex min-w-0 items-baseline justify-between gap-3",children:[(0,m.jsx)("span",{className:"shrink-0 text-popover-foreground/70",children:"Start"}),(0,m.jsx)("span",{"data-testid":"trace-row-hover-start",className:"min-w-0 text-right font-medium text-popover-foreground tabular-nums",children:ix(t.rowStartTimestamp)})]}),(0,m.jsxs)("div",{className:"flex min-w-0 items-baseline justify-between gap-3",children:[(0,m.jsx)("span",{className:"shrink-0 text-popover-foreground/70",children:"End"}),(0,m.jsx)("span",{"data-testid":"trace-row-hover-end",className:"min-w-0 text-right font-medium text-popover-foreground tabular-nums",children:ix(t.rowEndTimestamp)})]})]})]}),(0,m.jsxs)("div",{className:"space-y-1.5",children:[(0,m.jsx)("div",{className:"text-[10px] font-semibold uppercase tracking-wide text-popover-foreground/65",children:"Tokens"}),(0,m.jsxs)("div",{className:"space-y-1 text-xs",children:[(0,m.jsxs)("div",{className:"flex min-w-0 items-baseline justify-between gap-3",children:[(0,m.jsx)("span",{className:"shrink-0 text-popover-foreground/70",children:"Input"}),(0,m.jsx)("span",{"data-testid":"trace-row-hover-input-tokens",className:"min-w-0 text-right font-medium text-popover-foreground tabular-nums",children:OB(t.tokenStats.inputTokens)})]}),(0,m.jsxs)("div",{className:"flex min-w-0 items-baseline justify-between gap-3",children:[(0,m.jsx)("span",{className:"shrink-0 text-popover-foreground/70",children:"Output"}),(0,m.jsx)("span",{"data-testid":"trace-row-hover-output-tokens",className:"min-w-0 text-right font-medium text-popover-foreground tabular-nums",children:OB(t.tokenStats.outputTokens)})]}),(0,m.jsxs)("div",{className:"flex min-w-0 items-baseline justify-between gap-3",children:[(0,m.jsx)("span",{className:"shrink-0 text-popover-foreground/70",children:"Total"}),(0,m.jsx)("span",{"data-testid":"trace-row-hover-total-tokens",className:"min-w-0 text-right font-medium text-popover-foreground tabular-nums",children:OB(t.tokenStats.totalTokens)})]})]})]}),(0,m.jsx)(ane,{cost:t.cost})]})},s)}),document.body)}export{gle as $,MC as $a,wn as $c,Nse as $i,Koe as $n,_re as $o,Cq as $r,Ta as $s,$ae as $t,ute as A,mse as Aa,aH as Ac,qse as Ai,wae as An,Qre as Ao,Kie as Ar,Qz as As,DM as At,Dle as B,q$ as Ba,Yx as Bc,UA as Bi,Bae as Bn,AC as Bo,Rie as Br,Bre as Bs,rle as Bt,Lle as C,xse as Ca,uH as Cc,Zse as Ci,sZ as Cn,ese as Co,Zie as Cr,ure as Cs,qae as Ct,RM as D,a4 as Da,Mo as Dc,rr as Di,Aae as Dn,N5 as Do,foe as Dr,Cre as Ds,jee as Dt,Ple as E,bse as Ea,lH as Ec,Dh as Ei,oJ as En,Xre as Eo,coe as Er,Xz as Es,Vee as Et,kle as F,pse as Fa,Bw as Fc,xh as Fi,hae as Fn,D5 as Fo,Uie as Fr,gre as Fs,Qh as Ft,Qee as G,Pu as Ga,yP as Gc,fc as Gi,dae as Gn,v5 as Go,Up as Gr,lT as Gs,Iv as Gt,xle as H,OC as Ha,Jx as Hc,iW as Hi,Cae as Hn,zre as Ho,Tie as Hr,yT as Hs,Pee as Ht,Rle as I,xs as Ia,O_ as Ic,Gp as Ii,pae as In,jT as Io,zie as Ir,pre as Is,Qae as It,$ee as J,z$ as Ja,Nt as Jc,MA as Ji,cae as Jn,Ure as Jo,Sie as Jr,hh as Js,Iee as Jt,Ele as K,$$ as Ka,Ox as Kc,jse as Ki,uae as Kn,wC as Ko,cq as Kr,sV as Ks,Cle as Kt,wle as L,Ds as La,pw as Lc,GA as Li,gae as Ln,Gre as Lo,kie as Lr,hre as Ls,Nee as Lt,pg as M,oA as Ma,q_ as Mc,Use as Mi,Yb as Mn,I5 as Mo,qp as Mr,Ere as Ms,Ko as Mt,Mle as N,Cse as Na,W_ as Nc,uW as Ni,Q6 as Nn,Jre as No,$8 as Nr,vre as Ns,ule as Nt,Nle as O,lA as Oa,uD as Oc,Jse as Oi,Tae as On,P5 as Oo,qie as Or,Sre as Os,_ee as Ot,Ale as P,vse as Pa,bw as Pc,zse as Pi,Eae as Pn,Kre as Po,Vie as Pr,bre as Ps,Sle as Pt,Ree as Q,hse as Qa,Xl as Qc,W4 as Qi,Xoe as Qn,Hre as Qo,Eie as Qr,ire as Qs,zae as Qt,Tle as R,W$ as Ra,Mg as Rc,cW as Ri,vae as Rn,PT as Ro,Iie as Rr,mre as Rs,tle as Rt,Cte as S,Sse as Sa,dH as Sc,iie as Si,cZ as Sn,bh as So,Xie as Sr,cre as Ss,Fee as St,Fle as T,Ho as Ta,h0 as Tc,Yse as Ti,IJ as Tn,F5 as To,uoe as Tr,dre as Ts,nle as Tt,zee as U,cse as Ua,Dg as Uc,VA as Ui,yae as Un,$re as Uo,jb as Ur,lre as Us,Zae as Ut,ete as V,Bse as Va,uL as Vc,HA as Vi,fae as Vn,Vre as Vo,Mie as Vr,ra as Vs,bc as Vt,qee as W,NC as Wa,Gx as Wc,Vse as Wi,J6 as Wn,qre as Wo,uq as Wr,MU as Ws,Yae as Wt,ele as X,dse as Xa,Ii as Xc,X4 as Xi,rae as Xn,Wre as Xo,vie as Xr,WH as Xs,SM as Xt,fle as Y,use as Ya,Jd as Yc,LA as Yi,lae as Yn,jre as Yo,bie as Yr,g0 as Ys,Aee as Yt,kee as Z,fse as Za,Hr as Zc,dc as Zi,eae as Zn,S5 as Zo,yie as Zr,jD as Zs,Vae as Zt,Vle as _,kse as _a,mH as _c,EW as _i,WO as _n,kC as _o,roe as _r,wre as _s,kv as _t,ql as a,Fse as aa,dh as ac,JW as ai,Bg as an,N$ as ao,Foe as ar,Tre as as,mu as at,vte as b,Al as ba,fH as bc,zC as bi,BZ as bn,VT as bo,ioe as br,Uz as bs,Jae as bt,zle as c,Xa as ca,DH as cc,hie as ci,FZ as cn,s$ as co,Moe as cr,Mre as cs,dle as ct,jM as d,Ose as da,xH as dc,lie as di,LZ as dn,ose as do,Soe as dr,kre as ds,Oee as dt,Pse as ea,PH as ec,gq as ei,Se as el,Eee as en,rb as eo,Joe as er,Lre as es,Ble as et,_M as f,Rse as fa,bH as fc,XA as fi,RZ as fn,Z3 as fo,boe as fr,SC as fs,lle as ft,Gle as g,Ase as ga,gH as gc,Th as gi,Hae as gn,Sh as go,koe as gr,Dre as gs,yle as gt,Ote as h,Ise as ha,CH as hc,uie as hi,Ev as hn,tn as ho,poe as hr,r5 as hs,vle as ht,Bne as i,Y4 as ia,sre as ic,aq as ii,gt as il,vee as in,G$ as io,_oe as ir,Ore as is,Wae as it,Ole as j,gse as ja,zw as jc,qA as ji,xae as jn,Ed as jo,soe as jr,yre as js,TM as jt,OM as k,o4 as ka,Vs as kc,Kse as ki,Dae as kn,Yre as ko,Jie as kr,Yz as ks,mle as kt,$le as l,_u as la,wH as lc,cie as li,tM as ln,sse as lo,xoe as lr,Rre as ls,Hee as lt,LM as m,d4 as ma,vH as mc,oie as mi,PZ as mn,tA as mo,moe as mr,Lo as ms,Kae as mt,Ane as n,Hse as na,qg as nc,Cie as ni,fs as nl,Gae as nn,V$ as no,joe as nr,Nre as ns,Lee as nt,Wle as o,J4 as oa,AH as oc,qW as oi,Cee as on,ase as oo,Poe as or,Are as os,ble as ot,FM as p,Dse as pa,yH as pc,die as pi,jae as pn,ise as po,yoe as pr,a5 as ps,Mee as pt,Jee as q,U$ as qa,gP as qc,tW as qi,K6 as qn,LT as qo,el as qr,qe as qs,Gee as qt,rx as r,Q4 as ra,uh as rc,lq as ri,zN as rl,ba as rn,Dd as ro,Loe as rr,Ire as rs,ple as rt,Sc as s,_se as sa,TH as sc,pie as si,jZ as sn,Rp as so,Voe as sr,Pre as ss,ole as st,qle as t,Lse as ta,Fs as tc,gie as ti,bg as tl,xee as tn,lse as to,Goe as tr,Fre as ts,cle as tt,Ule as u,mA as ua,ch as uc,aie as ui,Sv as un,rse as uo,Eoe as ur,_n as us,hle as ut,Ete as v,fA as va,pH as vc,bW as vi,Fae as vn,Q5 as vo,toe as vr,xre as vs,Av as vt,Hle as w,wse as wa,_s as wc,Xse as wi,NJ as wn,Zre as wo,Qie as wr,ST as ws,ile as wt,_le as x,Ese as xa,hH as xc,sie as xi,hZ as xn,U5 as xo,eoe as xr,zz as xs,ale as xt,Dte as y,Tse as ya,BH as yc,SW as yi,_ae as yn,tse as yo,Yie as yr,t5 as ys,sle as yt,Ile as z,ws as za,nh as zc,sW as zi,mae as zn,_T as zo,Oie as zr,fre as zs,Xae as zt};
89
+
90
+ //# sourceMappingURL=trace-timeline-BZb0fhoh.js.map